Changeset 187
- Timestamp:
- 02/08/07 23:32:28 (15 years ago)
- Location:
- dev
- Files:
-
- 1 added
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
dev/common/class.contract.php
r158 r187 541 541 } 542 542 543 function getTableStats() 544 { 545 $qry = new DBQuery(); 546 while ($contract = $this->contractlist_->getContract()) 547 { 548 // generate all neccessary objects within the contract 549 $contract->execQuery(); 550 551 // this is the sql for kills 552 $sql = 'select count(*) AS kills,'; 553 if (config::get('ship_values')) 554 { 555 $sql .= ' sum(ifnull(ksv.shp_value,scl.scl_value)) AS killisk FROM kb3_kills kll 556 INNER JOIN kb3_ships shp ON ( shp.shp_id = kll.kll_ship_id ) 557 left join kb3_ships_values ksv on (shp.shp_id = ksv.shp_id)'; 558 } 559 else 560 { 561 $sql .= ' sum(scl.scl_value) AS kisk FROM kb3_kills kll 562 INNER JOIN kb3_ships shp ON ( shp.shp_id = kll.kll_ship_id )'; 563 } 564 $sql .= ' INNER JOIN kb3_ship_classes scl ON ( scl.scl_id = shp.shp_class ) 565 inner join kb3_systems sys on ( sys.sys_id = kll.kll_system_id )'; 566 if ($contract->klist_->inv_crp_) 567 { 568 $sql .= ' inner join kb3_inv_crp inc on ( inc.inc_crp_id in ( '.join(',', $contract->klist_->inv_crp_).' ) and kll.kll_id = inc.inc_kll_id ) '; 569 } 570 if ($contract->klist_->inv_all_) 571 { 572 $sql .= ' inner join kb3_inv_all ina on ( ina.ina_all_id in ( '.join(',', $contract->klist_->inv_all_).' ) and kll.kll_id = ina.ina_kll_id ) '; 573 } 574 if ($contract->klist_->inv_plt_) 575 { 576 $sql .= ' inner join kb3_inv_plt inp on ( inp.inp_plt_id in ( '.join(',', $contract->klist_->inv_plt_).' ) and kll.kll_id = inp.inp_kll_id ) '; 577 } 578 if ($contract->klist_->regions_) 579 { 580 $sql .= ' inner join kb3_constellations con 581 on ( con.con_id = sys.sys_con_id ) 582 inner join kb3_regions reg on ( reg.reg_id = con.con_reg_id 583 and reg.reg_id in ( '.join(',', $contract->klist_->regions_).' ) )'; 584 } 585 if ($contract->klist_->systems_) 586 { 587 $sql .= ' and kll.kll_system_id in ( '.join(',', $contract->klist_->systems_).')'; 588 } 589 590 $sql .= ' where 1=1 '; 591 if ($contract->klist_->vic_plt_) 592 $sql .= " and kll.kll_victim_id in ( ".join(',', $contract->klist_->vic_plt_)." )"; 593 if ($contract->klist_->vic_crp_) 594 $sql .= " and kll.kll_crp_id in ( ".join(',', $contract->klist_->vic_crp_)." )"; 595 if ($contract->klist_->vic_all_) 596 $sql .= " and kll.kll_all_id in ( ".join(',', $contract->klist_->vic_all_)." )"; 597 598 $result = $qry->execute($sql); 599 $kdata = $qry->getRow($result); 600 601 // and here goes the losses 602 $sql = 'select count(*) AS losses,'; 603 if (config::get('ship_values')) 604 { 605 $sql .= ' sum(ifnull(ksv.shp_value,scl.scl_value)) AS lossisk FROM kb3_kills kll 606 INNER JOIN kb3_ships shp ON ( shp.shp_id = kll.kll_ship_id ) 607 left join kb3_ships_values ksv on (shp.shp_id = ksv.shp_id)'; 608 } 609 else 610 { 611 $sql .= ' sum(scl.scl_value) AS kisk FROM kb3_kills kll 612 INNER JOIN kb3_ships shp ON ( shp.shp_id = kll.kll_ship_id )'; 613 } 614 $sql .= ' INNER JOIN kb3_ship_classes scl ON ( scl.scl_id = shp.shp_class ) 615 inner join kb3_systems sys on ( sys.sys_id = kll.kll_system_id )'; 616 if ($contract->llist_->inv_crp_) 617 { 618 $sql .= ' inner join kb3_inv_crp inc on ( inc.inc_crp_id in ( '.join(',', $contract->llist_->inv_crp_).' ) and kll.kll_id = inc.inc_kll_id ) '; 619 } 620 if ($contract->llist_->inv_all_) 621 { 622 $sql .= ' inner join kb3_inv_all ina on ( ina.ina_all_id in ( '.join(',', $contract->llist_->inv_all_).' ) and kll.kll_id = ina.ina_kll_id ) '; 623 } 624 if ($contract->llist_->inv_plt_) 625 { 626 $sql .= ' inner join kb3_inv_plt inp on ( inp.inp_plt_id in ( '.join(',', $contract->llist_->inv_plt_).' ) and kll.kll_id = inp.inp_kll_id ) '; 627 } 628 if ($contract->llist_->regions_) 629 { 630 $sql .= ' inner join kb3_constellations con 631 on ( con.con_id = sys.sys_con_id ) 632 inner join kb3_regions reg on ( reg.reg_id = con.con_reg_id 633 and reg.reg_id in ( '.join(',', $contract->llist_->regions_).' ) )'; 634 } 635 if ($contract->llist_->systems_) 636 { 637 $sql .= ' and kll.kll_system_id in ( '.join(',', $contract->llist_->systems_).')'; 638 } 639 640 $sql .= ' where 1=1 '; 641 if ($contract->llist_->vic_plt_) 642 $sql .= " and kll.kll_victim_id in ( ".join(',', $contract->llist_->vic_plt_)." )"; 643 if ($contract->llist_->vic_crp_) 644 $sql .= " and kll.kll_crp_id in ( ".join(',', $contract->llist_->vic_crp_)." )"; 645 if ($contract->llist_->vic_all_) 646 $sql .= " and kll.kll_all_id in ( ".join(',', $contract->llist_->vic_all_)." )"; 647 648 $result = $qry->execute($sql); 649 $ldata = $qry->getRow($result); 650 651 if ($kdata['killisk']) 652 { 653 $efficiency = round($kdata['killisk'] / ($kdata['killisk']+$ldata['lossisk']) *100, 2); 654 } 655 else 656 { 657 $efficiency = 0; 658 } 659 $bar = new BarGraph($efficiency, 100, 75); 660 661 $tbldata[] = array_merge(array('name' => $contract->getName(), 'startdate' => $contract->getStartDate(), 'bar' => $bar->generate(), 662 'enddate' => $contract->getEndDate(), 'efficiency' => $efficiency, 'id' => $contract->getID()), $kdata, $ldata); 663 } 664 $this->contractlist_->contractcounter_ = 1; 665 $this->contractlist_->qry_->rewind(); 666 return $tbldata; 667 } 668 543 669 function generate() 544 670 { 671 if ($table = $this->getTableStats()) 672 { 673 global $smarty; 674 675 $smarty->assign('contract_getactive', $this->contractlist_->getActive()); 676 $smarty->assign_by_ref('contracts', $table); 677 $pagesplitter = new PageSplitter($this->contractlist_->getCount(), 10); 678 679 return $smarty->fetch(get_tpl('contractlisttable')).$pagesplitter->generate(); 680 } 681 682 // old stuff, not used anymore (kept for reference) 545 683 if ($this->contractlist_->getCount()) 546 684 { -
dev/common/class.killlist.php
r162 r187 80 80 if ($this->inv_plt_) 81 81 $this->sql_ .= " inner join kb3_inv_plt inp 82 on ( inp.inp_plt_id in ( ". substr($this->inv_plt_, 0, strlen($this->inv_plt_) - 2)." ) and kll.kll_id = inp.inp_kll_id ) ";82 on ( inp.inp_plt_id in ( ".join(',', $this->inv_plt_)." ) and kll.kll_id = inp.inp_kll_id ) "; 83 83 if ($this->inv_crp_) 84 84 $this->sql_ .= " inner join kb3_inv_crp inc 85 on ( inc.inc_crp_id in ( ". substr($this->inv_crp_, 0, strlen($this->inv_crp_) - 2)." ) and kll.kll_id = inc.inc_kll_id85 on ( inc.inc_crp_id in ( ".join(',', $this->inv_crp_)." ) and kll.kll_id = inc.inc_kll_id 86 86 and inc.inc_crp_id != kll.kll_crp_id ) "; 87 87 if ($this->inv_all_) 88 88 $this->sql_ .= " inner join kb3_inv_all ina 89 on ( ina.ina_all_id in ( ". substr($this->inv_all_, 0, strlen($this->inv_all_) - 2)." ) and kll.kll_id = ina.ina_kll_id89 on ( ina.ina_all_id in ( ".join(',', $this->inv_all_)." ) and kll.kll_id = ina.ina_kll_id 90 90 and ina.ina_all_id != kll.kll_all_id ) "; 91 91 } … … 118 118 119 119 if ($this->vic_plt_) 120 $this->sql_ .= " ".$op." kll.kll_victim_id in ( ". substr($this->vic_plt_, 0, strlen($this->vic_plt_) - 2)." )";120 $this->sql_ .= " ".$op." kll.kll_victim_id in ( ".join(',', $this->vic_plt_)." )"; 121 121 if ($this->vic_crp_) 122 $this->sql_ .= " ".$op." kll.kll_crp_id in ( ". substr($this->vic_crp_, 0, strlen($this->vic_crp_) - 2)." )";122 $this->sql_ .= " ".$op." kll.kll_crp_id in ( ".join(',', $this->vic_crp_)." )"; 123 123 if ($this->vic_all_) 124 $this->sql_ .= " ".$op." kll.kll_all_id in ( ". substr($this->vic_all_, 0, strlen($this->vic_all_) - 2)." )";124 $this->sql_ .= " ".$op." kll.kll_all_id in ( ".join(',', $this->vic_all_)." )"; 125 125 126 126 if ($this->mixedvictims_) … … 163 163 { 164 164 $replace = " inner join kb3_inv_plt inp 165 on ( inp.inp_plt_id in ( ". substr($this->inv_plt_, 0, strlen($this->inv_plt_) - 2)." ) and kll.kll_id = inp.inp_kll_id ) ";165 on ( inp.inp_plt_id in ( ".join(',', $this->inv_plt_)." ) and kll.kll_id = inp.inp_kll_id ) "; 166 166 $psql = str_replace("<ph>", $replace, $this->sql_); 167 167 } … … 169 169 { 170 170 $replace = " inner join kb3_inv_crp inc 171 on ( inc.inc_crp_id in ( ". substr($this->inv_crp_, 0, strlen($this->inv_crp_) - 2)." ) and kll.kll_id = inc.inc_kll_id ) ";171 on ( inc.inc_crp_id in ( ".join(',', $this->inv_crp_)." ) and kll.kll_id = inc.inc_kll_id ) "; 172 172 $csql = str_replace("<ph>", $replace, $this->sql_); 173 173 } … … 175 175 { 176 176 $replace = " inner join kb3_inv_all ina 177 on ( ina.ina_all_id in ( ". substr($this->inv_all_, 0, strlen($this->inv_all_) - 2)." ) and kll.kll_id = ina.ina_kll_id ) ";177 on ( ina.ina_all_id in ( ".join(',', $this->inv_all_)." ) and kll.kll_id = ina.ina_kll_id ) "; 178 178 $asql = str_replace("<ph>", $replace, $this->sql_); 179 179 } … … 306 306 function addInvolvedPilot($pilot) 307 307 { 308 $this->inv_plt_ .= $pilot->getID().", ";308 $this->inv_plt_[] = $pilot->getID(); 309 309 if ($this->inv_crp_ || $this->inv_all_) 310 310 $this->mixedinvolved_ = true; … … 313 313 function addInvolvedCorp($corp) 314 314 { 315 $this->inv_crp_ .= $corp->getID().", ";315 $this->inv_crp_[] = $corp->getID(); 316 316 if ($this->inv_plt_ || $this->inv_all_) 317 317 $this->mixedinvolved_ = true; … … 320 320 function addInvolvedAlliance($alliance) 321 321 { 322 $this->inv_all_ .= $alliance->getID().", ";322 $this->inv_all_[] = $alliance->getID(); 323 323 if ($this->inv_plt_ || $this->inv_crp_) 324 324 $this->mixedinvolved_ = true; … … 327 327 function addVictimPilot($pilot) 328 328 { 329 $this->vic_plt_ .= $pilot->getID().", ";329 $this->vic_plt_[] = $pilot->getID(); 330 330 if ($this->vic_crp_ || $this->vic_all_) 331 331 $this->mixedvictims_ = true; … … 334 334 function addVictimCorp($corp) 335 335 { 336 $this->vic_crp_ .= $corp->getID().", ";336 $this->vic_crp_[] = $corp->getID(); 337 337 if ($this->vic_plt_ || $this->vic_all_) 338 338 $this->mixedvictims_ = true; … … 341 341 function addVictimAlliance($alliance) 342 342 { 343 $this->vic_all_ .= $alliance->getID().", ";343 $this->vic_all_[] = $alliance->getID(); 344 344 if ($this->vic_plt_ || $this->vic_crp_) 345 345 $this->mixedvictims_ = true;