Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git apps/intranet/modules/report/templates/_monthly5.php apps/intranet/modules/report/templates/_monthly5.php
- index 47693d8..9f0a7a0 100644
- --- apps/intranet/modules/report/templates/_monthly5.php
- +++ apps/intranet/modules/report/templates/_monthly5.php
- @@ -17,7 +17,7 @@
- <td><?php if (isset($stats['notices'])) { echo $stats['notices']; $total_notices += $stats['notices']; } ?></td>
- <td><?php if (isset($stats['no_action_leads'])) { echo $stats['no_action_leads']; $total_closed_links += $stats['no_action_leads']; } ?></td>
- <td><?php if (isset($stats['closed_locations'])) { echo (int) $stats['closed_locations']; $total_closed_locations += $stats['closed_locations']; } ?></td>
- - <td><?php if (isset($stats['closed_locations'])) echo $stats['closed_locations'] ? round((int)$stats['closed_locations'] / count($stats['domains']) * 100) : 0 ?>%</td>
- + <td><?php echo isset($stats['closed_locations']) ? ($stats['closed_locations']*100/$stats['notices']) : 0 ?>%</td>
- </tr>
- <?php endforeach ?>
- <tr>
- @@ -25,6 +25,6 @@
- <th><?php echo $total_notices ?></th>
- <th><?php echo $total_closed_links ?></th>
- <th><?php echo $total_closed_locations ?></th>
- - <th></th>
- + <th><?php echo isset($total_notices) and isset($total_closed_locations) ? ($total_closed_locations*100/$total_notices) : 0 ?>%</th>
- </tr>
- </table>
- diff --git lib/report/ReportPartMonthly5.php lib/report/ReportPartMonthly5.php
- index e5c33c4..87020f1 100644
- --- lib/report/ReportPartMonthly5.php
- +++ lib/report/ReportPartMonthly5.php
- @@ -67,304 +67,7 @@ class ReportPartMonthly5 extends BaseReportPart
- }
- }
- -
- - /*
- - $results['ddl_closed_sites'] = '';
- - foreach(EmailPeer::doSelectStmt($c)->fetchAll() as $stmt)
- - {
- - if ($domain = DomainPeer::retrieveByName($stmt['DOMAIN']))
- - {
- - $c2 = new Criteria;
- - $c2->addJoin(CampainPeer::ID, CampainResultPeer::CAMPAIN_ID);
- - $c2->add(CampainPeer::CUSTOMER_ID, $this->getCustomerId());
- - $c2->add(CampainResultPeer::DOMAIN_ID, $domain->getId());
- - $c2->addJoin(LocationPeer::ID, CampainResultPeer::LOCATION_ID);
- - $c2->add(LocationPeer::STATUS, 1);
- -
- - if (!$count = CampainResultPeer::doSelectStmt($c2)->rowCount())
- - {
- - $results['ddl_closed_sites']++;
- - }
- - */
- -
- - /*
- -
- -/*
- - $c = new Criteria;
- - $this->addOwnersCriteria($c);
- - $this->addCampainsCriteria($c);
- - $this->addThisMonth($c, EmailPeer::CREATED_AT);
- - $c->addJoin(EmailPeer::SITE, Ip2LocationIspPeer::NAME, Criteria::LEFT_JOIN);
- - $c->add(EmailPeer::CUSTOMER, $this->customer->getName());
- - $c->addSelectColumn(EmailPeer::DOMAIN);
- - $c->add(EmailPeer::TYPE, "ISP notice");
- - $c->addAsColumn('c', 'COUNT(*)');
- - $c->addAsColumn('COUNTRY_NAME', 'COUNTRY_NAME');
- - $c->addAsColumn('COUNTRY_CODE', 'COUNTRY_CODE');
- - $c->addGroupByColumn(Ip2LocationIspPeer::COUNTRY_NAME);
- -
- - $this->countries = array();
- -
- - foreach(EmailPeer::doSelectStmt($c)->fetchAll() as $stmt)
- - {
- - $country = $stmt['COUNTRY_NAME'];
- - if ($stmt['COUNTRY_NAME'] == '' or $stmt['COUNTRY_NAME'] == '-') continue;
- -
- - $this->countries[$stmt['COUNTRY_NAME']] = array('notices' => $stmt['c']);
- -
- - $c2 = new Criteria;
- - $c2->addJoin(CampainPeer::ID, CampainResultPeer::CAMPAIN_ID);
- - $c2->addJoin(LocationPeer::ID, CampainResultPeer::LOCATION_ID);
- - $c2->addJoin(DomainPeer::ID, CampainResultPeer::DOMAIN_ID, Criteria::LEFT_JOIN);
- - $c2->addJoin(Ip2LocationIspPeer::ID, DomainPeer::ISP_ID, Criteria::LEFT_JOIN);
- - $c2->add(CampainPeer::CUSTOMER_ID, $this->getCustomerId());
- - $c2->add(Ip2LocationIspPeer::COUNTRY_CODE, $stmt['COUNTRY_CODE']);
- - $c2->add(LocationPeer::STATUS, 1);
- -
- - if (!$count = CampainResultPeer::doSelectStmt($c2)->rowCount())
- - {
- - $this->countries[$smt['COUNTRY_NAME']['closed_locations']]++;
- - }
- - }
- - */
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -/*
- -
- -
- -
- - // Closed links
- - $c2 = new Criteria;
- - $this->addOwnersCriteria($c);
- - $this->addCampainsCriteria($c);
- - $this->addThisMonth($c2, CampainResultPeer::CREATED_AT);
- - $c2->addJoin(CampainPeer::ID, CampainResultPeer::CAMPAIN_ID, Criteria::LEFT_JOIN);
- - $c2->addJoin(CampainResultPeer::DOMAIN_ID, DomainPeer::ID, Criteria::LEFT_JOIN);
- - $c2->addJoin(DomainPeer::ISP_ID, Ip2LocationIspPeer::ID, Criteria::LEFT_JOIN);
- - $c2->add(CampainPeer::CUSTOMER_ID, $this->getCustomerId());
- - $c2->add(Ip2LocationIspPeer::COUNTRY_CODE, $stmt['COUNTRY_CODE']);
- - $c2->addSelectColumn('DISTINCT(domain_id) AS ');
- - #$c2->addGroupByColumn(CampainResultPeer::DOMAIN_ID);
- - */
- -
- - //$stmt = CampainResultPeer::doSelectStmt($c2);
- -
- - //$this->countries[$country]['closed_links'] = $stmt->fetchColumn(0);
- -
- -
- - /*
- - $query = "SELECT COUNT(email.id),created_at,type,customer,site,domain,isp.name
- - FROM email
- - LEFT JOIN ip2location_isp isp ON email.site=isp.name
- - where type = 'ISP Notice'
- - and customer='".$this->getCustomer()->getName()."'
- - and isp.country_name = '".$country."'
- - AND created_at BETWEEN '".$this->getThisMonthStart()."' AND '".$this->today."'
- - group by isp.country_name";
- -
- - $con = Propel::getConnection(CampainResultPeer::DATABASE_NAME);
- - $stmt = $con->prepare($query);
- - $stmt->execute();
- -
- - $this->countries[$country]['notices'] = $stmt->fetchColumn(0);
- -
- - // Sites
- - $query = "SELECT l.status, count(location_id) FROM campain_result cr
- - LEFT JOIN campain c ON c.id=cr.campain_id
- - left join location l ON l.id=cr.location_id
- - left join domain d ON d.id=cr.domain_id
- - left join `ip2location_isp` isp ON isp.id=d.`isp_id`
- - left join country ON country.iso=isp.country_code
- - WHERE c.customer_id=".$this->getCustomerId()."
- - and country.NAME = '".$country."'
- - AND cr.created_at BETWEEN '".$this->getThisMonthStart()."' AND '".$this->today."'
- - GROUP BY l.status
- - ";
- -
- - $con = Propel::getConnection(CampainResultPeer::DATABASE_NAME);
- -
- - $stmt = $con->prepare($query);
- - $stmt->execute();
- -
- - $this->countries[$country]['all_locations'] = 0;
- -
- - while ($row = $stmt->fetch())
- - {
- - $this->countries[$country]['all_locations'] += $row[1];
- -
- - if ($row[0] == -1)
- - {
- - $this->countries[$country]['closed_locations'] = $row[1];
- - }
- - }
- - }
- - */
- -
- - return $this->countries;
- - }
- -
- -
- - public function _execute()
- - {
- - $results = array();
- -
- - $c = new Criteria;
- - $this->addOwnersCriteria($c);
- - $this->addCampainsCriteria($c);
- - $this->addThisMonth($c, CampainResultPeer::CREATED_AT);
- - CampainResultPeer::addDetectedAsActiveCampainResultsCriteria($c);
- - $c->addJoin(DomainPeer::ID, CampainResultPeer::DOMAIN_ID);
- - $c->addJoin(Ip2LocationIspPeer::ID, DomainPeer::ISP_ID);
- - $c->addJoin(CampainPeer::ID, CampainResultPeer::CAMPAIN_ID);
- - $c->add(CampainPeer::CUSTOMER_ID, $this->customer->getId());
- - $c->addGroupByColumn(Ip2LocationIspPeer::COUNTRY_NAME);
- -
- -
- - $this->countries = array();
- - foreach(Ip2LocationIspPeer::doSelectStmt($c) as $stmt)
- - {
- - $country = $stmt['COUNTRY_NAME'];
- - if ($country == '-' or $country == '') continue;
- -
- - $this->countries[$country] = array('notices' => 0);
- -
- - // Closed links
- - $c2 = new Criteria;
- - $this->addOwnersCriteria($c);
- - $this->addCampainsCriteria($c);
- - $this->addThisMonth($c2, CampainResultPeer::CREATED_AT);
- - CampainResultPeer::addNotifiedLinksCriteria($c2);
- - CampainResultPeer::addDetectedAsActiveCampainResultsCriteria($c);
- - $c2->addJoin(CampainPeer::ID, CampainResultPeer::CAMPAIN_ID, Criteria::LEFT_JOIN);
- - $c2->addJoin(CampainResultPeer::DOMAIN_ID, DomainPeer::ID, Criteria::LEFT_JOIN);
- - $c2->addJoin(DomainPeer::ISP_ID, Ip2LocationIspPeer::ID, Criteria::LEFT_JOIN);
- - $c2->add(CampainPeer::CUSTOMER_ID, $this->getCustomerId());
- - $c2->add(Ip2LocationIspPeer::COUNTRY_CODE, $stmt['COUNTRY_CODE']);
- - $c2->addSelectColumn('COUNT(DISTINCT(domain_id)) AS c');
- - #$c2->addGroupByColumn(CampainResultPeer::DOMAIN_ID);
- - $stmt = CampainResultPeer::doSelectStmt($c2);
- -
- - $this->countries[$country]['closed_links'] = $stmt->fetchColumn(0);
- -
- -
- - $query = "SELECT COUNT(email.id),created_at,type,customer,site,domain,isp.name
- - FROM email
- - LEFT JOIN ip2location_isp isp ON email.site=isp.name
- - where type = 'ISP Notice'
- - and customer='".$this->getCustomer()->getName()."'
- - and isp.country_name = '".$country."'
- - AND created_at BETWEEN '".$this->getThisMonthStart()."' AND '".$this->today."'
- - group by isp.country_name";
- -
- - $con = Propel::getConnection(CampainResultPeer::DATABASE_NAME);
- - $stmt = $con->prepare($query);
- - $stmt->execute();
- - /*
- - $c3 = new Criteria;
- - $c3->add(FactNoticesSentPeer::DIM_DATE, 'MONTH('.FactNoticesSentPeer::DIM_DATE.') ='.date('m', strtotime($this->today)).' AND YEAR('.FactNoticesSentPeer::DIM_DATE.') ='.date('Y', strtotime($this->today)), Criteria::CUSTOM);
- - //$c3->add(FactNoticesSentPeer::DIM_MONTH, $this->getThisMonth());
- - $c3->add(FactNoticesSentPeer::DIM_CUSTOMER_ID, $this->getCustomerId());
- - //$c3->add(FactNoticesSentPeer::DIM_ISP_ID, 0, Criteria::GREATER_THAN);
- - $c3->addJoin(DimCountryPeer::ID, FactNoticesSentPeer::DIM_COUNTRY_ID);
- - $c3->addSelectColumn('SUM(value)', null);
- - $c3->addSelectColumn(DimCountryPeer::NAME);
- - $c3->addGroupByColumn(FactNoticesSentPeer::DIM_COUNTRY_ID);
- - $c3->add(DimCountryPeer::NAME, $country);
- -
- - $stmt = FactNoticesSentPeer::doSelectStmt($c3);
- - */
- -
- - $this->countries[$country]['notices'] = $stmt->fetchColumn(0);
- -
- - // Sites
- - $query = "SELECT l.status, count(location_id) FROM campain_result cr
- - LEFT JOIN campain c ON c.id=cr.campain_id
- - left join location l ON l.id=cr.location_id
- - left join domain d ON d.id=cr.domain_id
- - left join `ip2location_isp` isp ON isp.id=d.`isp_id`
- - left join country ON country.iso=isp.country_code
- - WHERE c.customer_id=".$this->getCustomerId()."
- - and country.NAME = '".$country."'
- - AND cr.created_at BETWEEN '".$this->getThisMonthStart()."' AND '".$this->today."'
- - GROUP BY l.status
- - ";
- -
- - $con = Propel::getConnection(CampainResultPeer::DATABASE_NAME);
- -
- - $stmt = $con->prepare($query);
- - $stmt->execute();
- -
- - $this->countries[$country]['all_locations'] = 0;
- -
- - while ($row = $stmt->fetch())
- - {
- - $this->countries[$country]['all_locations'] += $row[1];
- -
- - if ($row[0] == -1)
- - {
- - $this->countries[$country]['closed_locations'] = $row[1];
- - }
- - }
- -
- - }
- -
- -
- - /*
- - // Notifications
- - $c3 = new Criteria;
- - $this->addOwnersCriteria($c);
- - $this->addCampainsCriteria($c);
- - EmailPeer::addCreatedBetweenCriteria($c3, sfDate::getInstance()->subtractMonth(), sfDate::getInstance());
- - $c3->add(EmailPeer::CUSTOMER, $this->customer->getName());
- - $c3->addSelectColumn(EmailPeer::SITE);
- - $c3->addSelectColumn(EmailPeer::TYPE);
- - $c3->addSelectColumn('COUNT(*)');
- - $c3->addGroupByColumn(EmailPeer::SITE);
- -
- - foreach(EmailPeer::doSelectStmt($c3) as $stmt)
- - {
- - if ($stmt['TYPE'] == 'Domain notice')
- - {
- - if ($domain = DomainPeer::retrieveByName($stmt['SITE']))
- - {
- - foreach($this->countries as $country => $stats)
- - {
- - if ($country == $domain->getIp2locationIsp()->getCountryName())
- - {
- - $this->countries[$country]['notices'] += $stmt['COUNT(*)'];
- - }
- - }
- - }
- - }
- - elseif ($stmt['TYPE'] == 'ISP notice')
- - {
- - if ($isp = Ip2LocationIspPeer::retrieveByName($stmt['SITE']))
- - {
- - foreach($this->countries as $country => $stats)
- - {
- - if ($country == $isp->getCountryName())
- - {
- - $this->countries[$country]['notices'] += $stmt['COUNT(*)'];
- - }
- - }
- - }
- -
- - }
- - }
- - */
- -
- -
- + ksort($this->countries);
- return $this->countries;
- }
- diff --git lib/report/ReportPartMonthly6.php lib/report/ReportPartMonthly6.php
- index f7ac275..5c8d349 100644
- --- lib/report/ReportPartMonthly6.php
- +++ lib/report/ReportPartMonthly6.php
- @@ -49,7 +49,8 @@ class ReportPartMonthly6 extends BaseReportPart
- $this->countries[$row['COUNTRY_NAME']]['torrents'] = $row['COUNT(*)'];
- }
- - return $this->countries;
- + ksort($this->countries);
- + return $this->countries;
- }
- }
Add Comment
Please, Sign In to add comment