api.assignreport.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. <?php
  2. /**
  3. * Agent assigns report class
  4. */
  5. class agentAssignReport {
  6. protected $allassigns = array();
  7. protected $allassignsstrict = array();
  8. protected $assigns = array();
  9. protected $agents = array();
  10. protected $agentsNamed = array();
  11. protected $users = array();
  12. protected $alladdress = array();
  13. protected $excludeTariffs = array();
  14. protected $altcfg = array();
  15. protected $agentsumm = array();
  16. protected $agentPrint = array();
  17. protected $userTariffs = array();
  18. protected $userContracts = array();
  19. protected $userRealnames = array();
  20. protected $cashtypes = array();
  21. protected $excludeCount = 0;
  22. protected $excludeSumm = 0;
  23. const EXPORT_PATH = './exports/';
  24. const PRINT_TEMPLATE = './config/printableheaders.tpl';
  25. public function __construct() {
  26. $this->loadAllAssigns();
  27. $this->loadAllAssignsStrict();
  28. $this->loadUsers();
  29. $this->loadTariffExcludes();
  30. $this->excludeUsersTariffMask();
  31. $this->loadAgents();
  32. $this->agentsPreprocessNamed();
  33. $this->loadAddress();
  34. $this->assignsPreprocess();
  35. }
  36. /**
  37. * loads available assigns from database into private prop
  38. *
  39. * @return void
  40. */
  41. protected function loadAllAssigns() {
  42. $this->allassigns = zb_AgentAssignGetAllData();
  43. }
  44. /**
  45. * loads available assigns from database into private prop
  46. *
  47. * @return void
  48. */
  49. protected function loadAllAssignsStrict() {
  50. $this->allassignsstrict = zb_AgentAssignStrictGetAllData();
  51. }
  52. /**
  53. * loads all available users logins into private prop
  54. *
  55. * @return void
  56. */
  57. protected function loadUsers() {
  58. $this->users = zb_UserGetAllStargazerData();
  59. }
  60. /**
  61. * Load tariff excludes from config
  62. *
  63. * @return void
  64. */
  65. protected function loadTariffExcludes() {
  66. global $ubillingConfig;
  67. $this->altcfg = $ubillingConfig->getAlter();
  68. if (isset($this->altcfg['AGENT_ASSIGN_EXCLUDE_TARIFFS'])) {
  69. if (!empty($this->altcfg['AGENT_ASSIGN_EXCLUDE_TARIFFS'])) {
  70. $this->excludeTariffs = explode(',', $this->altcfg['AGENT_ASSIGN_EXCLUDE_TARIFFS']);
  71. }
  72. }
  73. }
  74. /**
  75. * Excludes users in private users property by tariff mask
  76. *
  77. * @return void
  78. */
  79. protected function excludeUsersTariffMask() {
  80. if (!empty($this->users)) {
  81. if (!empty($this->excludeTariffs)) {
  82. foreach ($this->users as $io => $eachUser) {
  83. foreach ($this->excludeTariffs as $ia => $eachTariffMask) {
  84. if (ispos($eachUser['Tariff'], $eachTariffMask)) {
  85. unset($this->users[$io]);
  86. }
  87. }
  88. }
  89. }
  90. }
  91. }
  92. /**
  93. * loads contragent data into protected prop
  94. *
  95. * @return void
  96. */
  97. protected function loadAgents() {
  98. $tmpArr = array();
  99. $tmpArr = zb_ContrAhentGetAllData();
  100. if (!empty($tmpArr)) {
  101. foreach ($tmpArr as $io => $each) {
  102. $this->agents[$each['id']] = $each;
  103. }
  104. }
  105. }
  106. /**
  107. * load all user address into private prop
  108. *
  109. * @return void
  110. */
  111. protected function loadAddress() {
  112. $this->alladdress = zb_AddressGetFullCityaddresslist();
  113. }
  114. /**
  115. * preprocess all users into assigns private prop
  116. *
  117. * @return void
  118. */
  119. protected function assignsPreprocess() {
  120. if (!empty($this->users)) {
  121. foreach ($this->users as $userid => $eachuser) {
  122. $assignedAgentId = zb_AgentAssignCheckLoginFast($eachuser['login'], $this->allassigns, @$this->alladdress[$eachuser['login']], $this->allassignsstrict);
  123. if (!empty($assignedAgentId)) {
  124. $this->assigns[$eachuser['login']] = $assignedAgentId;
  125. } else {
  126. $this->assigns[$eachuser['login']] = '';
  127. }
  128. }
  129. }
  130. }
  131. /**
  132. * public getter for private assigns property
  133. *
  134. * @return array
  135. */
  136. public function getAssigns() {
  137. return ($this->assigns);
  138. }
  139. /**
  140. * preprocess available agents into labeled private prop
  141. *
  142. * @return void
  143. */
  144. protected function agentsPreprocessNamed() {
  145. if (!empty($this->agents)) {
  146. foreach ($this->agents as $io => $each) {
  147. $this->agentsNamed[$each['id']] = $each['contrname'];
  148. }
  149. }
  150. }
  151. /**
  152. * public getter for named agents
  153. *
  154. * @return array
  155. */
  156. public function getAgentsNamed() {
  157. return ($this->agentsNamed);
  158. }
  159. /**
  160. * returns payments search form
  161. *
  162. * @return string
  163. */
  164. public function paymentSearchForm() {
  165. //try to save calendar states
  166. if (wf_CheckPost(array('datefrom', 'dateto'))) {
  167. $curdate = $_POST['dateto'];
  168. $yesterday = $_POST['datefrom'];
  169. } else {
  170. $curdate = date("Y-m-d", time() + 60 * 60 * 24);
  171. $yesterday = curdate();
  172. }
  173. //try to save cashtype selector state
  174. if (wf_CheckPost(array('cashtypeid'))) {
  175. $currentCashtypeId = $_POST['cashtypeid'];
  176. } else {
  177. //cash money by default
  178. $currentCashtypeId = 1;
  179. }
  180. $allcashtypes = zb_CashGetAlltypes();
  181. $cashTypesArr = array();
  182. if (!empty($allcashtypes)) {
  183. foreach ($allcashtypes as $io => $each) {
  184. $cashTypesArr[$each['id']] = __($each['cashtype']);
  185. }
  186. }
  187. $cashTypesArr['any'] = __('Any');
  188. $inputs = __('Date');
  189. $inputs .= wf_DatePickerPreset('datefrom', $yesterday) . ' ' . __('From');
  190. $inputs .= wf_DatePickerPreset('dateto', $curdate) . ' ' . __('To') . ' ';
  191. $inputs .= wf_Selector('cashtypeid', $cashTypesArr, __('Cash type'), $currentCashtypeId, false);
  192. $inputs .= wf_HiddenInput('dosearch', 'true');
  193. $inputs .= wf_Submit(__('Search'));
  194. $result = wf_Form("", 'POST', $inputs, 'glamour');
  195. return ($result);
  196. }
  197. /**
  198. * loads all users tariffs from database
  199. *
  200. * @return void
  201. */
  202. protected function loadUserTariffs() {
  203. $this->userTariffs = zb_TariffsGetAllUsers();
  204. }
  205. /**
  206. * loads all user contracts
  207. *
  208. * @return void
  209. */
  210. protected function loadUserContracts() {
  211. $this->userContracts = zb_UserGetAllContracts();
  212. $this->userContracts = array_flip($this->userContracts);
  213. }
  214. /**
  215. * loads all users realnames
  216. *
  217. * @return void
  218. */
  219. protected function loadUserRealnames() {
  220. $this->userRealnames = zb_UserGetAllRealnames();
  221. }
  222. /**
  223. * loads available cash types
  224. *
  225. * @return void
  226. */
  227. protected function loadCashTypes() {
  228. $tmpArr = zb_CashGetAlltypes();
  229. if (!empty($tmpArr)) {
  230. foreach ($tmpArr as $io => $each) {
  231. $this->cashtypes[$each['id']] = $each['cashtype'];
  232. }
  233. }
  234. }
  235. /**
  236. * fill agentstats by some payments
  237. *
  238. * @param string $login Existing ubilling user login
  239. * @param float $summ Payment summ
  240. *
  241. * @return void
  242. */
  243. protected function fillAgentStats($login, $summ) {
  244. if (isset($this->assigns[$login])) {
  245. $agentId = $this->assigns[$login];
  246. if (isset($this->agentsumm[$agentId])) {
  247. $this->agentsumm[$agentId]['summ'] = $this->agentsumm[$agentId]['summ'] + $summ;
  248. $this->agentsumm[$agentId]['count'] = $this->agentsumm[$agentId]['count'] + 1;
  249. } else {
  250. $this->agentsumm[$agentId]['summ'] = $summ;
  251. $this->agentsumm[$agentId]['count'] = 1;
  252. }
  253. } else {
  254. //excluded cash counters
  255. $this->excludeCount++;
  256. $this->excludeSumm = $this->excludeSumm + $summ;
  257. }
  258. }
  259. /**
  260. * Prepares per-agent CSV data for future printing
  261. *
  262. * @return void
  263. */
  264. protected function fillPrintData($payment) {
  265. if (isset($this->assigns[$payment['login']])) {
  266. $this->agentPrint[$this->assigns[$payment['login']]][] = $payment;
  267. }
  268. }
  269. /**
  270. * stores private agentPrint property for future printing and download
  271. * filename: self::EXPORT_PATH.'report_agentfinance.printdataraw'
  272. *
  273. * @return void
  274. */
  275. protected function savePrintData() {
  276. if (!empty($this->agentPrint)) {
  277. $arrayToStore = serialize($this->agentPrint);
  278. file_put_contents(self::EXPORT_PATH . 'report_agentfinance.prindataraw', $arrayToStore);
  279. }
  280. }
  281. /**
  282. * form printable result by default tablestyle, template stores in self::PRINT_TEMPLATE
  283. *
  284. * @param string $data Raw html data to preprocess
  285. * @param string $title Replaces macro {PAGE_TITLE}
  286. *
  287. * @return string
  288. */
  289. protected function parsePrintable($data, $title = '') {
  290. if (file_exists(self::PRINT_TEMPLATE)) {
  291. $template = file_get_contents(self::PRINT_TEMPLATE);
  292. $template = str_replace('{PAGE_TITLE}', $title, $template);
  293. $result = $template . $data;
  294. } else {
  295. $result = $data;
  296. }
  297. return ($result);
  298. }
  299. /**
  300. * extracts data from agentPring cache for future printing in HTML
  301. *
  302. * @param int $agentid Existing agent ID in database
  303. *
  304. * @return void
  305. */
  306. public function exportHtml($agentid) {
  307. $tmpArr = array();
  308. $result = '';
  309. if (!empty($this->altcfg)) {
  310. $altercfg = $this->altcfg;
  311. } else {
  312. global $ubillingConfig;
  313. $this->altcfg = $ubillingConfig->getAlter();
  314. $altercfg = $this->altcfg;
  315. }
  316. if (file_exists(self::EXPORT_PATH . 'report_agentfinance.prindataraw')) {
  317. $rawData = file_get_contents(self::EXPORT_PATH . 'report_agentfinance.prindataraw');
  318. $tmpArr = unserialize($rawData);
  319. $allservicenames = zb_VservicesGetAllNamesLabeled();
  320. $this->loadUserRealnames();
  321. $this->loadCashTypes();
  322. if (!empty($tmpArr)) {
  323. if (isset($tmpArr[$agentid])) {
  324. if (!empty($tmpArr[$agentid])) {
  325. //table header
  326. $result .= wf_tag('h2') . @$this->agentsNamed[$agentid] . wf_tag('h2', true);
  327. $cells = wf_TableCell(__('ID'));
  328. $cells .= wf_TableCell(__('Date'));
  329. $cells .= wf_TableCell(__('Cash'));
  330. $cells .= wf_TableCell(__('Login'));
  331. if ($altercfg['FINREP_CONTRACT']) {
  332. $this->loadUserContracts();
  333. $cells .= wf_TableCell(__('Contract'));
  334. }
  335. $cells .= wf_TableCell(__('Full address'));
  336. $cells .= wf_TableCell(__('Real Name'));
  337. if ($altercfg['FINREP_TARIFF']) {
  338. $this->loadUserTariffs();
  339. $cells .= wf_TableCell(__('Tariff'));
  340. }
  341. $cells .= wf_TableCell(__('Contrahent name'));
  342. $cells .= wf_TableCell(__('Payment type'));
  343. $cells .= wf_TableCell(__('Notes'));
  344. $cells .= wf_TableCell(__('Admin'));
  345. $rows = wf_TableRow($cells, 'row1');
  346. foreach ($tmpArr[$agentid] as $io => $each) {
  347. $cells = wf_TableCell($each['id']);
  348. $cells .= wf_TableCell($each['date']);
  349. $cells .= wf_TableCell($each['summ']);
  350. $cells .= wf_TableCell($each['login']);
  351. if ($altercfg['FINREP_CONTRACT']) {
  352. $cells .= wf_TableCell($this->userContracts[$each['login']]);
  353. }
  354. $cells .= wf_TableCell(@$this->alladdress[$each['login']]);
  355. $cells .= wf_TableCell(@$this->userRealnames[$each['login']]);
  356. if ($altercfg['FINREP_TARIFF']) {
  357. $cells .= wf_TableCell(@$this->userTariffs[$each['login']]);
  358. }
  359. $cells .= wf_TableCell(@$this->agentsNamed[$this->assigns[$each['login']]]);
  360. $cells .= wf_TableCell(__(@$this->cashtypes[$each['cashtypeid']]));
  361. //payment notes translation
  362. if ($altercfg['TRANSLATE_PAYMENTS_NOTES']) {
  363. $paynote = zb_TranslatePaymentNote($each['note'], $allservicenames);
  364. } else {
  365. $paynote = $each['note'];
  366. }
  367. $cells .= wf_TableCell($paynote);
  368. $cells .= wf_TableCell($each['admin']);
  369. $rows .= wf_TableRow($cells, 'row3');
  370. }
  371. $result .= wf_TableBody($rows, '100%', 1, 'printable');
  372. //adds ending for templating
  373. $result .= wf_tag('body', true);
  374. $result .= wf_tag('html', true);
  375. }
  376. }
  377. }
  378. }
  379. $result = $this->parsePrintable($result, @$this->agentsNamed[$agentid]);
  380. die($result);
  381. }
  382. /**
  383. * extracts data from agentPring cache for future export in CSV
  384. *
  385. * @param int $agentid Existing agent ID in database
  386. *
  387. * @return void
  388. */
  389. public function exportCSV($agentid) {
  390. $tmpArr = array();
  391. $result = '';
  392. if (!empty($this->altcfg)) {
  393. $altercfg = $this->altcfg;
  394. } else {
  395. global $ubillingConfig;
  396. $this->altcfg = $ubillingConfig->getAlter();
  397. $altercfg = $this->altcfg;
  398. }
  399. if (file_exists(self::EXPORT_PATH . 'report_agentfinance.prindataraw')) {
  400. $rawData = file_get_contents(self::EXPORT_PATH . 'report_agentfinance.prindataraw');
  401. $tmpArr = unserialize($rawData);
  402. $allservicenames = zb_VservicesGetAllNamesLabeled();
  403. $this->loadUserRealnames();
  404. $this->loadCashTypes();
  405. if (!empty($tmpArr)) {
  406. if (isset($tmpArr[$agentid])) {
  407. if (!empty($tmpArr[$agentid])) {
  408. //CSV header
  409. $result .= __('ID') . ';' . __('Date') . ';' . __('Cash') . ';' . __('Login') . ';' . __('Full address') . ';' . __('Real Name') . ';' . __('Contrahent name') . ';' . __('Payment type') . ';' . __('Notes') . ';' . __('Admin') . "\n";
  410. //CSV data
  411. foreach ($tmpArr[$agentid] as $io => $each) {
  412. $summ = str_replace('.', ',', $each['summ']); //need for normal summ in excel
  413. $result .= $each['id'] . ';' . $each['date'] . ';' . $summ . ';' . $each['login'] . ';' . @$this->alladdress[$each['login']] . ';' . @$this->userRealnames[$each['login']] . ';' . @$this->agentsNamed[$this->assigns[$each['login']]] . ';' . __(@$this->cashtypes[$each['cashtypeid']]) . ';' . zb_TranslatePaymentNote($each['note'], $allservicenames) . ';' . $each['admin'] . "\n";
  414. }
  415. }
  416. }
  417. }
  418. }
  419. $saveCsvName = self::EXPORT_PATH . 'report_agentfinance_' . $agentid . '_' . zb_rand_string(8) . '.csv';
  420. $result = iconv('utf-8', 'windows-1251', $result);
  421. file_put_contents($saveCsvName, $result);
  422. zb_DownloadFile($saveCsvName, 'csv');
  423. die();
  424. }
  425. /**
  426. * extracts data from agentPring cache for future export in CSV
  427. *
  428. * @param int $agentid Existing agent ID in database
  429. *
  430. * @return void
  431. */
  432. public function exportCSV2($agentid) {
  433. $tmpArr = array();
  434. $result = '';
  435. $shortAddres = zb_AddressGetFulladdresslistCached();
  436. if (!empty($this->altcfg)) {
  437. $altercfg = $this->altcfg;
  438. } else {
  439. global $ubillingConfig;
  440. $this->altcfg = $ubillingConfig->getAlter();
  441. $altercfg = $this->altcfg;
  442. }
  443. if (file_exists(self::EXPORT_PATH . 'report_agentfinance.prindataraw')) {
  444. $rawData = file_get_contents(self::EXPORT_PATH . 'report_agentfinance.prindataraw');
  445. $tmpArr = unserialize($rawData);
  446. $allservicenames = zb_VservicesGetAllNamesLabeled();
  447. $this->loadUserRealnames();
  448. $this->loadCashTypes();
  449. if (!empty($tmpArr)) {
  450. if (isset($tmpArr[$agentid])) {
  451. if (!empty($tmpArr[$agentid])) {
  452. //CSV header
  453. $result .= __('Date') . ';' . __('Cash') . ';' . __('Full address') . ';' . __('Real Name') . ';' . __('Notes') . "\n";
  454. //CSV data
  455. foreach ($tmpArr[$agentid] as $io => $each) {
  456. $summ = str_replace('.', ',', $each['summ']); //need for normal summ in excel
  457. $timeStamp = strtotime($each['date']);
  458. $newDate = date("Y-m-d", $timeStamp);
  459. $result .= $newDate . ';' . $summ . ';' . @$shortAddres[$each['login']] . ';' . @$this->userRealnames[$each['login']] . ';' . zb_TranslatePaymentNote($each['note'], $allservicenames) . "\n";
  460. }
  461. }
  462. }
  463. }
  464. }
  465. $saveCsvName = self::EXPORT_PATH . 'report_agentfinance_' . $agentid . '_' . zb_rand_string(8) . '.csv';
  466. $result = iconv('utf-8', 'windows-1251', $result);
  467. file_put_contents($saveCsvName, $result);
  468. zb_DownloadFile($saveCsvName, 'csv');
  469. die();
  470. }
  471. /**
  472. * do the payments search via some data interval
  473. *
  474. * @return string
  475. */
  476. public function paymentSearch($datefrom, $dateto, $cashtypeid) {
  477. if (!empty($this->altcfg)) {
  478. $altercfg = $this->altcfg;
  479. } else {
  480. global $ubillingConfig;
  481. $this->altcfg = $ubillingConfig->getAlter();
  482. $altercfg = $this->altcfg;
  483. }
  484. $datefrom = mysql_real_escape_string($datefrom);
  485. $dateto = mysql_real_escape_string($dateto);
  486. $this->loadUserRealnames();
  487. $this->loadCashTypes();
  488. $allservicenames = zb_VservicesGetAllNamesLabeled();
  489. $result = '';
  490. if ($cashtypeid != 'any') {
  491. $cashtypeid = vf($cashtypeid, 3);
  492. $cashtypeSub_q = "`cashtypeid`='" . $cashtypeid . "' AND ";
  493. } else {
  494. $cashtypeSub_q = '';
  495. }
  496. $query = "SELECT * from `payments` WHERE " . $cashtypeSub_q . " `date` BETWEEN '" . $datefrom . "' AND '" . $dateto . "' AND `summ`> '0' ;";
  497. $allPayments = simple_queryall($query);
  498. $totalCount = 0;
  499. $totalSumm = 0;
  500. $cells = wf_TableCell(__('ID'));
  501. $cells .= wf_TableCell(__('Date'));
  502. $cells .= wf_TableCell(__('Cash'));
  503. $cells .= wf_TableCell(__('Login'));
  504. if ($altercfg['FINREP_CONTRACT']) {
  505. $this->loadUserContracts();
  506. $cells .= wf_TableCell(__('Contract'));
  507. }
  508. $cells .= wf_TableCell(__('Full address'));
  509. $cells .= wf_TableCell(__('Real Name'));
  510. if ($altercfg['FINREP_TARIFF']) {
  511. $this->loadUserTariffs();
  512. $cells .= wf_TableCell(__('Tariff'));
  513. }
  514. $cells .= wf_TableCell(__('Contrahent name'));
  515. $cells .= wf_TableCell(__('Payment type'));
  516. $cells .= wf_TableCell(__('Notes'));
  517. $cells .= wf_TableCell(__('Admin'));
  518. $rows = wf_TableRow($cells, 'row1');
  519. if (!empty($allPayments)) {
  520. foreach ($allPayments as $io => $each) {
  521. $cells = wf_TableCell($each['id']);
  522. $cells .= wf_TableCell($each['date']);
  523. $cells .= wf_TableCell($each['summ']);
  524. $cells .= wf_TableCell(wf_Link('?module=userprofile&username=' . $each['login'], web_profile_icon() . ' ' . $each['login'], false, ''));
  525. if ($altercfg['FINREP_CONTRACT']) {
  526. $cells .= wf_TableCell($this->userContracts[$each['login']]);
  527. }
  528. $cells .= wf_TableCell(@$this->alladdress[$each['login']]);
  529. $cells .= wf_TableCell(@$this->userRealnames[$each['login']]);
  530. if ($altercfg['FINREP_TARIFF']) {
  531. $cells .= wf_TableCell(@$this->userTariffs[$each['login']]);
  532. }
  533. $cells .= wf_TableCell(@$this->agentsNamed[$this->assigns[$each['login']]]);
  534. $cells .= wf_TableCell(__(@$this->cashtypes[$each['cashtypeid']]));
  535. //payment notes translation
  536. if ($altercfg['TRANSLATE_PAYMENTS_NOTES']) {
  537. $paynote = zb_TranslatePaymentNote($each['note'], $allservicenames);
  538. } else {
  539. $paynote = $each['note'];
  540. }
  541. $cells .= wf_TableCell($paynote);
  542. $cells .= wf_TableCell($each['admin']);
  543. $rows .= wf_TableRow($cells, 'row3');
  544. //fill stats
  545. $this->fillAgentStats($each['login'], $each['summ']);
  546. $this->fillPrintData($each);
  547. $totalCount++;
  548. $totalSumm = $totalSumm + $each['summ'];
  549. }
  550. }
  551. //show per agent stats
  552. if (!empty($this->agentsumm)) {
  553. $agCells = wf_TableCell(__('Contrahent name'));
  554. $agCells .= wf_TableCell(__('Count'));
  555. $agCells .= wf_TableCell(__('Sum'));
  556. $agCells .= wf_TableCell(__('Actions'));
  557. $agRows = wf_TableRow($agCells, 'row1');
  558. foreach ($this->agentsumm as $eachAgentId => $eachAgentStat) {
  559. $exportControls = wf_Link("?module=report_agentfinance&exportcsvagentid=" . $eachAgentId, wf_img('skins/excel.gif', __('Export') . ' ' . __('full')), false, '') . ' ';
  560. $exportControls .= wf_Link("?module=report_agentfinance&exportcsvagentidshort=" . $eachAgentId, wf_img('skins/excel.gif', __('Export') . ' ' . __('short')), false, '') . ' ';
  561. $exportControls .= wf_Link("?module=report_agentfinance&exporthtmlagentid=" . $eachAgentId, wf_img('skins/icon_print.png', __('Print')), false, '');
  562. $agCells = wf_TableCell($this->agentsNamed[$eachAgentId]);
  563. $agCells .= wf_TableCell($eachAgentStat['count']);
  564. $agCells .= wf_TableCell(zb_CashBigValueFormat($eachAgentStat['summ']), '', '', 'align="right"');
  565. $agCells .= wf_TableCell($exportControls);
  566. $agRows .= wf_TableRow($agCells, 'row3');
  567. }
  568. $result .= wf_TableBody($agRows, '50%', 0, 'sortable');
  569. $result .= wf_tag('span', false, 'glamour') . __('Excluded payments count') . ': ' . $this->excludeCount . wf_tag('span', true);
  570. $result .= wf_tag('span', false, 'glamour') . __('Excluded cash') . ': ' . $this->excludeSumm . wf_tag('span', true);
  571. $result .= wf_CleanDiv();
  572. //save per agent printing data for future usage
  573. $this->savePrintData();
  574. }
  575. $result .= wf_TableBody($rows, '100%', 0, 'sortable');
  576. $result .= wf_tag('span', false, 'glamour') . __('Count') . ': ' . $totalCount . wf_tag('span', true);
  577. $result .= wf_tag('span', false, 'glamour') . __('Total payments') . ': ' . $totalSumm . wf_tag('span', true);
  578. $result .= wf_CleanDiv();
  579. return ($result);
  580. }
  581. }
  582. ?>