Guest User

Untitled

a guest
Oct 21st, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.59 KB | None | 0 0
  1. diff --git apps/intranet/modules/report/templates/_monthly5.php apps/intranet/modules/report/templates/_monthly5.php
  2. index 47693d8..9f0a7a0 100644
  3. --- apps/intranet/modules/report/templates/_monthly5.php
  4. +++ apps/intranet/modules/report/templates/_monthly5.php
  5. @@ -17,7 +17,7 @@
  6. <td><?php if (isset($stats['notices'])) { echo $stats['notices']; $total_notices += $stats['notices']; } ?></td>
  7. <td><?php if (isset($stats['no_action_leads'])) { echo $stats['no_action_leads']; $total_closed_links += $stats['no_action_leads']; } ?></td>
  8. <td><?php if (isset($stats['closed_locations'])) { echo (int) $stats['closed_locations']; $total_closed_locations += $stats['closed_locations']; } ?></td>
  9. - <td><?php if (isset($stats['closed_locations'])) echo $stats['closed_locations'] ? round((int)$stats['closed_locations'] / count($stats['domains']) * 100) : 0 ?>%</td>
  10. + <td><?php echo isset($stats['closed_locations']) ? ($stats['closed_locations']*100/$stats['notices']) : 0 ?>%</td>
  11. </tr>
  12. <?php endforeach ?>
  13. <tr>
  14. @@ -25,6 +25,6 @@
  15. <th><?php echo $total_notices ?></th>
  16. <th><?php echo $total_closed_links ?></th>
  17. <th><?php echo $total_closed_locations ?></th>
  18. - <th></th>
  19. + <th><?php echo isset($total_notices) and isset($total_closed_locations) ? ($total_closed_locations*100/$total_notices) : 0 ?>%</th>
  20. </tr>
  21. </table>
  22. diff --git lib/report/ReportPartMonthly5.php lib/report/ReportPartMonthly5.php
  23. index e5c33c4..87020f1 100644
  24. --- lib/report/ReportPartMonthly5.php
  25. +++ lib/report/ReportPartMonthly5.php
  26. @@ -67,304 +67,7 @@ class ReportPartMonthly5 extends BaseReportPart
  27. }
  28. }
  29.  
  30. -
  31. - /*
  32. - $results['ddl_closed_sites'] = '';
  33. - foreach(EmailPeer::doSelectStmt($c)->fetchAll() as $stmt)
  34. - {
  35. - if ($domain = DomainPeer::retrieveByName($stmt['DOMAIN']))
  36. - {
  37. - $c2 = new Criteria;
  38. - $c2->addJoin(CampainPeer::ID, CampainResultPeer::CAMPAIN_ID);
  39. - $c2->add(CampainPeer::CUSTOMER_ID, $this->getCustomerId());
  40. - $c2->add(CampainResultPeer::DOMAIN_ID, $domain->getId());
  41. - $c2->addJoin(LocationPeer::ID, CampainResultPeer::LOCATION_ID);
  42. - $c2->add(LocationPeer::STATUS, 1);
  43. -
  44. - if (!$count = CampainResultPeer::doSelectStmt($c2)->rowCount())
  45. - {
  46. - $results['ddl_closed_sites']++;
  47. - }
  48. - */
  49. -
  50. - /*
  51. -
  52. -/*
  53. - $c = new Criteria;
  54. - $this->addOwnersCriteria($c);
  55. - $this->addCampainsCriteria($c);
  56. - $this->addThisMonth($c, EmailPeer::CREATED_AT);
  57. - $c->addJoin(EmailPeer::SITE, Ip2LocationIspPeer::NAME, Criteria::LEFT_JOIN);
  58. - $c->add(EmailPeer::CUSTOMER, $this->customer->getName());
  59. - $c->addSelectColumn(EmailPeer::DOMAIN);
  60. - $c->add(EmailPeer::TYPE, "ISP notice");
  61. - $c->addAsColumn('c', 'COUNT(*)');
  62. - $c->addAsColumn('COUNTRY_NAME', 'COUNTRY_NAME');
  63. - $c->addAsColumn('COUNTRY_CODE', 'COUNTRY_CODE');
  64. - $c->addGroupByColumn(Ip2LocationIspPeer::COUNTRY_NAME);
  65. -
  66. - $this->countries = array();
  67. -
  68. - foreach(EmailPeer::doSelectStmt($c)->fetchAll() as $stmt)
  69. - {
  70. - $country = $stmt['COUNTRY_NAME'];
  71. - if ($stmt['COUNTRY_NAME'] == '' or $stmt['COUNTRY_NAME'] == '-') continue;
  72. -
  73. - $this->countries[$stmt['COUNTRY_NAME']] = array('notices' => $stmt['c']);
  74. -
  75. - $c2 = new Criteria;
  76. - $c2->addJoin(CampainPeer::ID, CampainResultPeer::CAMPAIN_ID);
  77. - $c2->addJoin(LocationPeer::ID, CampainResultPeer::LOCATION_ID);
  78. - $c2->addJoin(DomainPeer::ID, CampainResultPeer::DOMAIN_ID, Criteria::LEFT_JOIN);
  79. - $c2->addJoin(Ip2LocationIspPeer::ID, DomainPeer::ISP_ID, Criteria::LEFT_JOIN);
  80. - $c2->add(CampainPeer::CUSTOMER_ID, $this->getCustomerId());
  81. - $c2->add(Ip2LocationIspPeer::COUNTRY_CODE, $stmt['COUNTRY_CODE']);
  82. - $c2->add(LocationPeer::STATUS, 1);
  83. -
  84. - if (!$count = CampainResultPeer::doSelectStmt($c2)->rowCount())
  85. - {
  86. - $this->countries[$smt['COUNTRY_NAME']['closed_locations']]++;
  87. - }
  88. - }
  89. - */
  90. -
  91. -
  92. -
  93. -
  94. -
  95. -
  96. -
  97. -
  98. -
  99. -
  100. -
  101. -
  102. -
  103. -/*
  104. -
  105. -
  106. -
  107. - // Closed links
  108. - $c2 = new Criteria;
  109. - $this->addOwnersCriteria($c);
  110. - $this->addCampainsCriteria($c);
  111. - $this->addThisMonth($c2, CampainResultPeer::CREATED_AT);
  112. - $c2->addJoin(CampainPeer::ID, CampainResultPeer::CAMPAIN_ID, Criteria::LEFT_JOIN);
  113. - $c2->addJoin(CampainResultPeer::DOMAIN_ID, DomainPeer::ID, Criteria::LEFT_JOIN);
  114. - $c2->addJoin(DomainPeer::ISP_ID, Ip2LocationIspPeer::ID, Criteria::LEFT_JOIN);
  115. - $c2->add(CampainPeer::CUSTOMER_ID, $this->getCustomerId());
  116. - $c2->add(Ip2LocationIspPeer::COUNTRY_CODE, $stmt['COUNTRY_CODE']);
  117. - $c2->addSelectColumn('DISTINCT(domain_id) AS ');
  118. - #$c2->addGroupByColumn(CampainResultPeer::DOMAIN_ID);
  119. - */
  120. -
  121. - //$stmt = CampainResultPeer::doSelectStmt($c2);
  122. -
  123. - //$this->countries[$country]['closed_links'] = $stmt->fetchColumn(0);
  124. -
  125. -
  126. - /*
  127. - $query = "SELECT COUNT(email.id),created_at,type,customer,site,domain,isp.name
  128. - FROM email
  129. - LEFT JOIN ip2location_isp isp ON email.site=isp.name
  130. - where type = 'ISP Notice'
  131. - and customer='".$this->getCustomer()->getName()."'
  132. - and isp.country_name = '".$country."'
  133. - AND created_at BETWEEN '".$this->getThisMonthStart()."' AND '".$this->today."'
  134. - group by isp.country_name";
  135. -
  136. - $con = Propel::getConnection(CampainResultPeer::DATABASE_NAME);
  137. - $stmt = $con->prepare($query);
  138. - $stmt->execute();
  139. -
  140. - $this->countries[$country]['notices'] = $stmt->fetchColumn(0);
  141. -
  142. - // Sites
  143. - $query = "SELECT l.status, count(location_id) FROM campain_result cr
  144. - LEFT JOIN campain c ON c.id=cr.campain_id
  145. - left join location l ON l.id=cr.location_id
  146. - left join domain d ON d.id=cr.domain_id
  147. - left join `ip2location_isp` isp ON isp.id=d.`isp_id`
  148. - left join country ON country.iso=isp.country_code
  149. - WHERE c.customer_id=".$this->getCustomerId()."
  150. - and country.NAME = '".$country."'
  151. - AND cr.created_at BETWEEN '".$this->getThisMonthStart()."' AND '".$this->today."'
  152. - GROUP BY l.status
  153. - ";
  154. -
  155. - $con = Propel::getConnection(CampainResultPeer::DATABASE_NAME);
  156. -
  157. - $stmt = $con->prepare($query);
  158. - $stmt->execute();
  159. -
  160. - $this->countries[$country]['all_locations'] = 0;
  161. -
  162. - while ($row = $stmt->fetch())
  163. - {
  164. - $this->countries[$country]['all_locations'] += $row[1];
  165. -
  166. - if ($row[0] == -1)
  167. - {
  168. - $this->countries[$country]['closed_locations'] = $row[1];
  169. - }
  170. - }
  171. - }
  172. - */
  173. -
  174. - return $this->countries;
  175. - }
  176. -
  177. -
  178. - public function _execute()
  179. - {
  180. - $results = array();
  181. -
  182. - $c = new Criteria;
  183. - $this->addOwnersCriteria($c);
  184. - $this->addCampainsCriteria($c);
  185. - $this->addThisMonth($c, CampainResultPeer::CREATED_AT);
  186. - CampainResultPeer::addDetectedAsActiveCampainResultsCriteria($c);
  187. - $c->addJoin(DomainPeer::ID, CampainResultPeer::DOMAIN_ID);
  188. - $c->addJoin(Ip2LocationIspPeer::ID, DomainPeer::ISP_ID);
  189. - $c->addJoin(CampainPeer::ID, CampainResultPeer::CAMPAIN_ID);
  190. - $c->add(CampainPeer::CUSTOMER_ID, $this->customer->getId());
  191. - $c->addGroupByColumn(Ip2LocationIspPeer::COUNTRY_NAME);
  192. -
  193. -
  194. - $this->countries = array();
  195. - foreach(Ip2LocationIspPeer::doSelectStmt($c) as $stmt)
  196. - {
  197. - $country = $stmt['COUNTRY_NAME'];
  198. - if ($country == '-' or $country == '') continue;
  199. -
  200. - $this->countries[$country] = array('notices' => 0);
  201. -
  202. - // Closed links
  203. - $c2 = new Criteria;
  204. - $this->addOwnersCriteria($c);
  205. - $this->addCampainsCriteria($c);
  206. - $this->addThisMonth($c2, CampainResultPeer::CREATED_AT);
  207. - CampainResultPeer::addNotifiedLinksCriteria($c2);
  208. - CampainResultPeer::addDetectedAsActiveCampainResultsCriteria($c);
  209. - $c2->addJoin(CampainPeer::ID, CampainResultPeer::CAMPAIN_ID, Criteria::LEFT_JOIN);
  210. - $c2->addJoin(CampainResultPeer::DOMAIN_ID, DomainPeer::ID, Criteria::LEFT_JOIN);
  211. - $c2->addJoin(DomainPeer::ISP_ID, Ip2LocationIspPeer::ID, Criteria::LEFT_JOIN);
  212. - $c2->add(CampainPeer::CUSTOMER_ID, $this->getCustomerId());
  213. - $c2->add(Ip2LocationIspPeer::COUNTRY_CODE, $stmt['COUNTRY_CODE']);
  214. - $c2->addSelectColumn('COUNT(DISTINCT(domain_id)) AS c');
  215. - #$c2->addGroupByColumn(CampainResultPeer::DOMAIN_ID);
  216. - $stmt = CampainResultPeer::doSelectStmt($c2);
  217. -
  218. - $this->countries[$country]['closed_links'] = $stmt->fetchColumn(0);
  219. -
  220. -
  221. - $query = "SELECT COUNT(email.id),created_at,type,customer,site,domain,isp.name
  222. - FROM email
  223. - LEFT JOIN ip2location_isp isp ON email.site=isp.name
  224. - where type = 'ISP Notice'
  225. - and customer='".$this->getCustomer()->getName()."'
  226. - and isp.country_name = '".$country."'
  227. - AND created_at BETWEEN '".$this->getThisMonthStart()."' AND '".$this->today."'
  228. - group by isp.country_name";
  229. -
  230. - $con = Propel::getConnection(CampainResultPeer::DATABASE_NAME);
  231. - $stmt = $con->prepare($query);
  232. - $stmt->execute();
  233. - /*
  234. - $c3 = new Criteria;
  235. - $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);
  236. - //$c3->add(FactNoticesSentPeer::DIM_MONTH, $this->getThisMonth());
  237. - $c3->add(FactNoticesSentPeer::DIM_CUSTOMER_ID, $this->getCustomerId());
  238. - //$c3->add(FactNoticesSentPeer::DIM_ISP_ID, 0, Criteria::GREATER_THAN);
  239. - $c3->addJoin(DimCountryPeer::ID, FactNoticesSentPeer::DIM_COUNTRY_ID);
  240. - $c3->addSelectColumn('SUM(value)', null);
  241. - $c3->addSelectColumn(DimCountryPeer::NAME);
  242. - $c3->addGroupByColumn(FactNoticesSentPeer::DIM_COUNTRY_ID);
  243. - $c3->add(DimCountryPeer::NAME, $country);
  244. -
  245. - $stmt = FactNoticesSentPeer::doSelectStmt($c3);
  246. - */
  247. -
  248. - $this->countries[$country]['notices'] = $stmt->fetchColumn(0);
  249. -
  250. - // Sites
  251. - $query = "SELECT l.status, count(location_id) FROM campain_result cr
  252. - LEFT JOIN campain c ON c.id=cr.campain_id
  253. - left join location l ON l.id=cr.location_id
  254. - left join domain d ON d.id=cr.domain_id
  255. - left join `ip2location_isp` isp ON isp.id=d.`isp_id`
  256. - left join country ON country.iso=isp.country_code
  257. - WHERE c.customer_id=".$this->getCustomerId()."
  258. - and country.NAME = '".$country."'
  259. - AND cr.created_at BETWEEN '".$this->getThisMonthStart()."' AND '".$this->today."'
  260. - GROUP BY l.status
  261. - ";
  262. -
  263. - $con = Propel::getConnection(CampainResultPeer::DATABASE_NAME);
  264. -
  265. - $stmt = $con->prepare($query);
  266. - $stmt->execute();
  267. -
  268. - $this->countries[$country]['all_locations'] = 0;
  269. -
  270. - while ($row = $stmt->fetch())
  271. - {
  272. - $this->countries[$country]['all_locations'] += $row[1];
  273. -
  274. - if ($row[0] == -1)
  275. - {
  276. - $this->countries[$country]['closed_locations'] = $row[1];
  277. - }
  278. - }
  279. -
  280. - }
  281. -
  282. -
  283. - /*
  284. - // Notifications
  285. - $c3 = new Criteria;
  286. - $this->addOwnersCriteria($c);
  287. - $this->addCampainsCriteria($c);
  288. - EmailPeer::addCreatedBetweenCriteria($c3, sfDate::getInstance()->subtractMonth(), sfDate::getInstance());
  289. - $c3->add(EmailPeer::CUSTOMER, $this->customer->getName());
  290. - $c3->addSelectColumn(EmailPeer::SITE);
  291. - $c3->addSelectColumn(EmailPeer::TYPE);
  292. - $c3->addSelectColumn('COUNT(*)');
  293. - $c3->addGroupByColumn(EmailPeer::SITE);
  294. -
  295. - foreach(EmailPeer::doSelectStmt($c3) as $stmt)
  296. - {
  297. - if ($stmt['TYPE'] == 'Domain notice')
  298. - {
  299. - if ($domain = DomainPeer::retrieveByName($stmt['SITE']))
  300. - {
  301. - foreach($this->countries as $country => $stats)
  302. - {
  303. - if ($country == $domain->getIp2locationIsp()->getCountryName())
  304. - {
  305. - $this->countries[$country]['notices'] += $stmt['COUNT(*)'];
  306. - }
  307. - }
  308. - }
  309. - }
  310. - elseif ($stmt['TYPE'] == 'ISP notice')
  311. - {
  312. - if ($isp = Ip2LocationIspPeer::retrieveByName($stmt['SITE']))
  313. - {
  314. - foreach($this->countries as $country => $stats)
  315. - {
  316. - if ($country == $isp->getCountryName())
  317. - {
  318. - $this->countries[$country]['notices'] += $stmt['COUNT(*)'];
  319. - }
  320. - }
  321. - }
  322. -
  323. - }
  324. - }
  325. - */
  326. -
  327. -
  328. + ksort($this->countries);
  329.  
  330. return $this->countries;
  331. }
  332. diff --git lib/report/ReportPartMonthly6.php lib/report/ReportPartMonthly6.php
  333. index f7ac275..5c8d349 100644
  334. --- lib/report/ReportPartMonthly6.php
  335. +++ lib/report/ReportPartMonthly6.php
  336. @@ -49,7 +49,8 @@ class ReportPartMonthly6 extends BaseReportPart
  337. $this->countries[$row['COUNTRY_NAME']]['torrents'] = $row['COUNT(*)'];
  338. }
  339.  
  340. - return $this->countries;
  341. + ksort($this->countries);
  342.  
  343. + return $this->countries;
  344. }
  345. }
Add Comment
Please, Sign In to add comment