/** * Renders result of default fundsflow module * * @param array $fundsflow */ public function renderArray($fundsflow) { $allcashtypes = $this->getCashTypeNames(); $allservicenames = zb_VservicesGetAllNamesLabeled(); $result = ''; $tablecells = wf_TableCell(__('Date')); $tablecells .= wf_TableCell(__('Cash')); $tablecells .= wf_TableCell(__('From')); $tablecells .= wf_TableCell(__('To')); $tablecells .= wf_TableCell(__('Operation')); $tablecells .= wf_TableCell(__('Cash type')); $tablecells .= wf_TableCell(__('Notes')); $tablecells .= wf_TableCell(__('Admin')); $tablerows = wf_TableRow($tablecells, 'row1'); if (!empty($fundsflow)) { foreach ($fundsflow as $io => $each) { //cashtype if ($each['cashtype'] != 'z') { @($cashtype = $allcashtypes[$each['cashtype']]); } else { $cashtype = __('Fee'); } //coloring $efc = wf_tag('font', true); if ($each['operation'] == 'Fee') { $fc = wf_tag('font', false, '', 'color="#a90000"'); } if ($each['operation'] == 'Payment') { $fc = wf_tag('font', false, '', 'color="#005304"'); } if ($each['operation'] == 'Correcting') { $fc = wf_tag('font', false, '', 'color="#ff6600"'); } if (ispos($each['note'], 'MOCK:')) { $fc = wf_tag('font', false, '', 'color="#006699"'); } if (ispos($each['note'], 'BALANCESET:')) { $fc = wf_tag('font', false, '', 'color="##000000"'); } //notes translation if ($this->alterConf['TRANSLATE_PAYMENTS_NOTES']) { $displaynote = zb_TranslatePaymentNote($each['note'], $allservicenames); } else { $displaynote = $each['note']; } $tablecells = wf_TableCell($fc . $each['date'] . $efc, '150'); $tablecells .= wf_TableCell($fc . $each['summ'] . $efc); $tablecells .= wf_TableCell($fc . $each['from'] . $efc); $tablecells .= wf_TableCell($fc . $each['to'] . $efc); $tablecells .= wf_TableCell($fc . __($each['operation']) . $efc); $tablecells .= wf_TableCell($cashtype); $tablecells .= wf_TableCell($displaynote); $tablecells .= wf_TableCell($each['admin']); $tablerows .= wf_TableRow($tablecells, 'row3'); } $legendcells = wf_TableCell(__('Legend') . ':'); $legendcells .= wf_TableCell(wf_tag('font', false, '', 'color="#005304"') . __('Payment') . $efc); $legendcells .= wf_TableCell(wf_tag('font', false, '', 'color="#a90000"') . __('Fee') . $efc); $legendcells .= wf_TableCell(wf_tag('font', false, '', 'color="#ff6600"') . __('Correct saldo') . $efc); $legendcells .= wf_TableCell(wf_tag('font', false, '', 'color="#006699"') . __('Mock payment') . $efc); $legendcells .= wf_TableCell(wf_tag('font', false, '', 'color="##000000"') . __('Set cash') . $efc); $legendrows = wf_TableRow($legendcells, 'row3'); $legend = wf_TableBody($legendrows, '50%', 0, 'glamour'); $legend .= wf_tag('div', false, '', 'style="clear:both;"') . wf_tag('div', true); $legend .= wf_delimiter(); $result = wf_TableBody($tablerows, '100%', 0, 'sortable'); $result .= $legend; } return $result; }
function web_PaymentSearch($markers) { if (wf_CheckPost(array('searchtable'))) { if ($_POST['searchtable'] == 'payments') { $table = 'payments'; } if ($_POST['searchtable'] == 'corrections') { $table = 'paymentscorr'; } } else { $table = 'payments'; } $query = "SELECT * from `" . $table . "`"; $query .= $markers; $altercfg = rcms_parse_ini_file(CONFIG_PATH . "alter.ini"); $csvdata = ''; $allpayments = simple_queryall($query); if ($altercfg['FINREP_CONTRACT']) { $allcontracts = zb_UserGetAllContracts(); $allcontracts = array_flip($allcontracts); } if ($altercfg['FINREP_TARIFF']) { $alltariffs = zb_TariffsGetAllUsers(); } $allrealnames = zb_UserGetAllRealnames(); $alladdress = zb_AddressGetFulladdresslist(); $alltypes = zb_CashGetAllCashTypes(); $allservicenames = zb_VservicesGetAllNamesLabeled(); $allpaysyspercents = zb_PaySysPercentGetAll(); $totalsumm = 0; $paysyssumm = 0; $profitsumm = 0; $totalcount = 0; $cells = wf_TableCell(__('ID')); $cells .= wf_TableCell(__('Date')); $cells .= wf_TableCell(__('Cash')); $cells .= wf_TableCell(__('PS%')); $cells .= wf_TableCell(__('Profit')); $cells .= wf_TableCell(__('Login')); if ($altercfg['FINREP_CONTRACT']) { $cells .= wf_TableCell(__('Contract')); } $cells .= wf_TableCell(__('Full address')); $cells .= wf_TableCell(__('Real Name')); if ($altercfg['FINREP_TARIFF']) { $cells .= wf_TableCell(__('Tariff')); } $cells .= wf_TableCell(__('Payment type')); $cells .= wf_TableCell(__('Notes')); $cells .= wf_TableCell(__('Admin')); $rows = wf_TableRow($cells, 'row1'); if (!empty($allpayments)) { if ($altercfg['FINREP_TARIFF']) { $csvTariffColumn = ';' . __('Tariff'); } else { $csvTariffColumn = ''; } $csvdata .= __('ID') . ';' . __('Date') . ';' . __('Cash') . ';' . __('PS%') . ';' . __('Profit') . ';' . __('Login') . ';' . __('Full address') . ';' . __('Real Name') . $csvTariffColumn . ';' . __('Payment type') . ';' . __('Notes') . ';' . __('Admin') . "\n"; foreach ($allpayments as $io => $each) { $cells = wf_TableCell($each['id']); $cells .= wf_TableCell($each['date']); $cells .= wf_TableCell($each['summ']); //detecting paymentsystem and calc percent if (isset($allpaysyspercents[$each['note']])) { $currPc = $allpaysyspercents[$each['note']]['percent']; $rawSumm = $each['summ']; $paySysPc = $rawSumm / 100 * $currPc; $ourProfit = $rawSumm - $paySysPc; } else { $paySysPc = 0; $ourProfit = $each['summ']; } $cells .= wf_TableCell($paySysPc); $cells .= wf_TableCell($ourProfit); $cells .= wf_TableCell(wf_Link('?module=userprofile&username='******'login'], web_profile_icon() . ' ' . $each['login'], false, '')); if ($altercfg['FINREP_CONTRACT']) { $cells .= wf_TableCell(@$allcontracts[$each['login']]); } @($paymentRealname = $allrealnames[$each['login']]); @($paymentCashType = __($alltypes[$each['cashtypeid']])); @($paymentAddress = $alladdress[$each['login']]); $cells .= wf_TableCell($paymentAddress); $cells .= wf_TableCell($paymentRealname); if ($altercfg['FINREP_TARIFF']) { @($userTariff = $alltariffs[$each['login']]); $cells .= wf_TableCell($userTariff); $csvTariff = ';' . $userTariff; } else { $csvTariff = ''; } $cells .= wf_TableCell($paymentCashType); //payment notes translation if ($altercfg['TRANSLATE_PAYMENTS_NOTES']) { $paynote = zb_TranslatePaymentNote($each['note'], $allservicenames); } else { $paynote = $each['note']; } $cells .= wf_TableCell($paynote); $cells .= wf_TableCell($each['admin']); $rows .= wf_TableRow($cells, 'row3'); //calculating totals if ($each['summ'] > 0) { $totalsumm = $totalsumm + $each['summ']; $totalcount++; } if ($paySysPc > 0) { $paysyssumm = $paysyssumm + $paySysPc; } if ($ourProfit > 0) { $profitsumm = $profitsumm + $ourProfit; } $csvSumm = str_replace('.', ',', $each['summ']); $csvdata .= $each['id'] . ';' . $each['date'] . ';' . $csvSumm . ';' . $paySysPc . ';' . $ourProfit . ';' . $each['login'] . ';' . $paymentAddress . ';' . $paymentRealname . $csvTariff . ';' . $paymentCashType . ';' . $paynote . ';' . $each['admin'] . "\n"; } } //saving report for future download if (!empty($csvdata)) { $csvSaveName = 'exports/payfind_' . zb_rand_string(8) . '.csv'; $csvSaveNameEnc = base64_encode($csvSaveName); $csvdata = iconv('utf-8', 'windows-1251', $csvdata); file_put_contents($csvSaveName, $csvdata); $csvDownloadLink = wf_Link('?module=payfind&downloadcsv=' . $csvSaveNameEnc, wf_img('skins/excel.gif', __('Export')), false); } else { $csvDownloadLink = ''; } $result = wf_TableBody($rows, '100%', '0', 'sortable'); //additional total counters $result .= wf_tag('div', false, 'glamour') . __('Count') . ': ' . $totalcount . wf_tag('div', true); $result .= wf_tag('div', false, 'glamour') . __('Total payments') . ': ' . $totalsumm . wf_tag('div', true); $result .= wf_tag('div', false, 'glamour') . __('Payment systems %') . ': ' . $paysyssumm . wf_tag('div', true); $result .= wf_tag('div', false, 'glamour') . __('Our final profit') . ': ' . $profitsumm . wf_tag('div', true); $result .= wf_CleanDiv(); show_window(__('Payments found') . ' ' . $csvDownloadLink, $result); }
/** * Returns users finance operations history * * @param string $customerId * * @return array */ protected function getUserFinanceHistory($customerId) { $result = array(); if (isset($this->allUserData[$customerId])) { $allServices = zb_VservicesGetAllNamesLabeled(); $fundsFlow = new FundsFlow(); $allfees = $fundsFlow->getFees($customerId); $allpayments = $fundsFlow->getPayments($customerId); $allcorrectings = $fundsFlow->getPaymentsCorr($customerId); $allOps = $allfees + $allpayments + $allcorrectings; $allOps = $fundsFlow->transformArray($allOps); $i = 0; if (!empty($allOps)) { foreach ($allOps as $io => $each) { // print_r($each); $result[] = array('id' => $i, 'date' => $each['date'], 'type' => 'financial', 'name' => __($each['operation']), 'data' => json_encode(array('amount' => $each['summ'], 'from' => $each['from'], 'to' => $each['to'], 'operator_name' => $each['admin'])), 'comment' => zb_TranslatePaymentNote($each['note'], $allServices)); $i++; } } } else { $result = array('result' => 'error', 'error' => $this->errorNotices['EX_USER_NOT_EXISTS'] . ': ' . $customerId); } return $result; }
function catv_PaymentsShow($query) { $alter_conf = rcms_parse_ini_file(CONFIG_PATH . 'alter.ini'); $alladrs = catv_GetFullAddressList(); $allrealnames = catv_GetAllRealnames(); $alltypes = zb_CashGetAllCashTypes(); $allapayments = simple_queryall($query); $total = 0; $result = '<table width="100%" border="0" class="sortable">'; $result .= ' <tr class="row1"> <td>' . __('ID') . '</td> <td>' . __('IDENC') . '</td> <td>' . __('Date') . '</td> <td>' . __('Cash') . '</td> <td>' . __('User') . '</td> <td>' . __('Full address') . '</td> <td>' . __('Notes') . '</td> <td>' . __('Admin') . '</td> </tr> '; if (!empty($allapayments)) { foreach ($allapayments as $io => $eachpayment) { if ($alter_conf['TRANSLATE_PAYMENTS_NOTES']) { if ($eachpayment['notes'] == '') { $eachpayment['notes'] = __('CaTV'); } $eachpayment['notes'] = zb_TranslatePaymentNote($eachpayment['notes'], array()); } $result .= ' <tr class="row3"> <td>' . $eachpayment['id'] . '</td> <td>' . zb_NumEncode($eachpayment['id']) . '</td> <td>' . $eachpayment['date'] . '</td> <td>' . $eachpayment['summ'] . '</td> <td> <a href="?module=catv_profile&userid=' . $eachpayment['userid'] . '">' . web_profile_icon() . '</a> ' . @$allrealnames[$eachpayment['userid']] . '</td> <td>' . @$alladrs[$eachpayment['userid']] . '</td> <td>' . $eachpayment['notes'] . '</td> <td>' . $eachpayment['admin'] . '</td> </tr> '; if ($eachpayment['summ'] > 0) { $total = $total + $eachpayment['summ']; } } } $result .= '</table>'; $result .= '<strong>' . __('Total') . ': ' . $total . '</strong>'; return $result; }
/** * Returns form for payments by city within some month (by default - current month) * * @return string */ public function PaymentsShow() { $total = 0; $totalPayCount = 0; $this->LoadCashTypes(); $cells = wf_TableCell(__('IDENC')); $cells .= wf_TableCell(__('Date')); $cells .= wf_TableCell(__('Cash')); if ($this->altCfg['FINREP_CONTRACT']) { $cells .= wf_TableCell(__('Contract')); $this->LoadAllContracts(); } if ($this->altCfg['TRANSLATE_PAYMENTS_NOTES']) { $this->LoadAllServiceNames(); } $cells .= wf_TableCell(__('Login')); $cells .= wf_TableCell(__('Full address')); $cells .= wf_TableCell(__('Real Name')); if ($this->altCfg['FINREP_TARIFF']) { $cells .= wf_TableCell(__('Tariff')); $this->LoadAllTariffs(); } $cells .= wf_TableCell(__('Cash type')); $cells .= wf_TableCell(__('Was credited')); $cells .= wf_TableCell(__('Notes')); $cells .= wf_TableCell(__('Admin')); $rows = wf_TableRow($cells, 'row1'); if (!empty($this->allData)) { foreach ($this->allData as $io => $eachpayment) { if ($this->altCfg['TRANSLATE_PAYMENTS_NOTES']) { $eachpayment['note'] = zb_TranslatePaymentNote($eachpayment['note'], $this->allServiceNames); } $cells = wf_TableCell(zb_NumEncode($eachpayment['id'])); $cells .= wf_TableCell($eachpayment['date']); $cells .= wf_TableCell($eachpayment['summ']); if ($this->altCfg['FINREP_CONTRACT']) { $cells .= wf_TableCell(@$this->allContracts[$eachpayment['login']]); } $cells .= wf_TableCell(wf_Link('?module=userprofile&username='******'login'], web_profile_icon() . ' ' . $eachpayment['login'], false, '')); $cells .= wf_TableCell(@$this->allAddresses[$eachpayment['login']]); $cells .= wf_TableCell(@$this->allRealNames[$eachpayment['login']]); if ($this->altCfg['FINREP_TARIFF']) { $cells .= wf_TableCell(@$this->allTariffs[$eachpayment['login']]); } $cells .= wf_TableCell(@__($this->allCashTypes[$eachpayment['cashtypeid']])); $cells .= wf_TableCell(@$this->allCredited[$eachpayment['login']]); $cells .= wf_TableCell($eachpayment['note']); $cells .= wf_TableCell($eachpayment['admin']); $rows .= wf_TableRow($cells, 'row4'); $total = $total + $eachpayment['summ']; $totalPayCount++; } } $result = wf_TableBody($rows, '100%', '0', 'sortable id'); $result .= wf_tag('strong') . __('Cash') . ': ' . $total . wf_tag('strong', true) . wf_tag('br'); $result .= wf_tag('strong') . __('Count') . ': ' . $totalPayCount . wf_tag('strong', true); return $result; }
/** * Renders payments extracted from database with some query * * @param string $query * @return string */ function web_PaymentsShow($query) { $alter_conf = rcms_parse_ini_file(CONFIG_PATH . 'alter.ini'); $alladrs = zb_AddressGetFulladdresslist(); $allrealnames = zb_UserGetAllRealnames(); $alltypes = zb_CashGetAllCashTypes(); $allapayments = simple_queryall($query); $allservicenames = zb_VservicesGetAllNamesLabeled(); //getting full contract list if ($alter_conf['FINREP_CONTRACT']) { $allcontracts = zb_UserGetAllContracts(); $allcontracts = array_flip($allcontracts); } //getting all users tariffs if ($alter_conf['FINREP_TARIFF']) { $alltariffs = zb_TariffsGetAllUsers(); } $total = 0; $totalPaycount = 0; $cells = wf_TableCell(__('ID')); $cells .= wf_TableCell(__('IDENC')); $cells .= wf_TableCell(__('Date')); $cells .= wf_TableCell(__('Cash')); //optional contract display if ($alter_conf['FINREP_CONTRACT']) { $cells .= wf_TableCell(__('Contract')); } $cells .= wf_TableCell(__('Login')); $cells .= wf_TableCell(__('Full address')); $cells .= wf_TableCell(__('Real Name')); //optional tariff display if ($alter_conf['FINREP_TARIFF']) { $cells .= wf_TableCell(__('Tariff')); } $cells .= wf_TableCell(__('Cash type')); $cells .= wf_TableCell(__('Notes')); $cells .= wf_TableCell(__('Admin')); $rows = wf_TableRow($cells, 'row1'); if (!empty($allapayments)) { foreach ($allapayments as $io => $eachpayment) { if ($alter_conf['TRANSLATE_PAYMENTS_NOTES']) { $eachpayment['note'] = zb_TranslatePaymentNote($eachpayment['note'], $allservicenames); } $cells = wf_TableCell($eachpayment['id']); $cells .= wf_TableCell(zb_NumEncode($eachpayment['id'])); $cells .= wf_TableCell($eachpayment['date']); $cells .= wf_TableCell($eachpayment['summ']); //optional contract display if ($alter_conf['FINREP_CONTRACT']) { $cells .= wf_TableCell(@$allcontracts[$eachpayment['login']]); } $cells .= wf_TableCell(wf_Link('?module=userprofile&username='******'login'], web_profile_icon() . ' ' . $eachpayment['login'], false, '')); $cells .= wf_TableCell(@$alladrs[$eachpayment['login']]); $cells .= wf_TableCell(@$allrealnames[$eachpayment['login']]); //optional tariff display if ($alter_conf['FINREP_TARIFF']) { $cells .= wf_TableCell(@$alltariffs[$eachpayment['login']]); } $cells .= wf_TableCell(@__($alltypes[$eachpayment['cashtypeid']])); $cells .= wf_TableCell($eachpayment['note']); $cells .= wf_TableCell($eachpayment['admin']); $rows .= wf_TableRow($cells, 'row3'); if ($eachpayment['summ'] > 0) { $total = $total + $eachpayment['summ']; $totalPaycount++; } } } $result = wf_TableBody($rows, '100%', '0', 'sortable'); $result .= wf_tag('strong') . __('Cash') . ': ' . $total . wf_tag('strong', true) . wf_tag('br'); $result .= wf_tag('strong') . __('Count') . ': ' . $totalPaycount . wf_tag('strong', true); return $result; }
/** * do the payments search via some data interval * * @return string */ public function paymentSearch($datefrom, $dateto, $cashtypeid) { if (!empty($this->altcfg)) { $altercfg = $this->altcfg; } else { global $ubillingConfig; $this->altcfg = $ubillingConfig->getAlter(); $altercfg = $this->altcfg; } $datefrom = mysql_real_escape_string($datefrom); $dateto = mysql_real_escape_string($dateto); $this->loadUserRealnames(); $this->loadCashTypes(); $allservicenames = zb_VservicesGetAllNamesLabeled(); $result = ''; if ($cashtypeid != 'any') { $cashtypeid = vf($cashtypeid, 3); $cashtypeSub_q = "`cashtypeid`='" . $cashtypeid . "' AND "; } else { $cashtypeSub_q = ''; } $query = "SELECT * from `payments` WHERE " . $cashtypeSub_q . " `date` BETWEEN '" . $datefrom . "' AND '" . $dateto . "' AND `summ`> '0' ;"; $allPayments = simple_queryall($query); $totalCount = 0; $totalSumm = 0; $cells = wf_TableCell(__('ID')); $cells .= wf_TableCell(__('Date')); $cells .= wf_TableCell(__('Cash')); $cells .= wf_TableCell(__('Login')); if ($altercfg['FINREP_CONTRACT']) { $this->loadUserContracts(); $cells .= wf_TableCell(__('Contract')); } $cells .= wf_TableCell(__('Full address')); $cells .= wf_TableCell(__('Real Name')); if ($altercfg['FINREP_TARIFF']) { $this->loadUserTariffs(); $cells .= wf_TableCell(__('Tariff')); } $cells .= wf_TableCell(__('Contrahent name')); $cells .= wf_TableCell(__('Payment type')); $cells .= wf_TableCell(__('Notes')); $cells .= wf_TableCell(__('Admin')); $rows = wf_TableRow($cells, 'row1'); if (!empty($allPayments)) { foreach ($allPayments as $io => $each) { $cells = wf_TableCell($each['id']); $cells .= wf_TableCell($each['date']); $cells .= wf_TableCell($each['summ']); $cells .= wf_TableCell(wf_Link('?module=userprofile&username='******'login'], web_profile_icon() . ' ' . $each['login'], false, '')); if ($altercfg['FINREP_CONTRACT']) { $cells .= wf_TableCell($this->userContracts[$each['login']]); } $cells .= wf_TableCell(@$this->alladdress[$each['login']]); $cells .= wf_TableCell(@$this->userRealnames[$each['login']]); if ($altercfg['FINREP_TARIFF']) { $cells .= wf_TableCell(@$this->userTariffs[$each['login']]); } $cells .= wf_TableCell(@$this->agentsNamed[$this->assigns[$each['login']]]); $cells .= wf_TableCell(__(@$this->cashtypes[$each['cashtypeid']])); //payment notes translation if ($altercfg['TRANSLATE_PAYMENTS_NOTES']) { $paynote = zb_TranslatePaymentNote($each['note'], $allservicenames); } else { $paynote = $each['note']; } $cells .= wf_TableCell($paynote); $cells .= wf_TableCell($each['admin']); $rows .= wf_TableRow($cells, 'row3'); //fill stats $this->fillAgentStats($each['login'], $each['summ']); $this->fillPrintData($each); $totalCount++; $totalSumm = $totalSumm + $each['summ']; } } //show per agent stats if (!empty($this->agentsumm)) { $agCells = wf_TableCell(__('Contrahent name')); $agCells .= wf_TableCell(__('Count')); $agCells .= wf_TableCell(__('Sum')); $agCells .= wf_TableCell(__('Actions')); $agRows = wf_TableRow($agCells, 'row1'); foreach ($this->agentsumm as $eachAgentId => $eachAgentStat) { $exportControls = wf_Link("?module=report_agentfinance&exportcsvagentid=" . $eachAgentId, wf_img('skins/excel.gif', __('Export')), false, ''); $exportControls .= wf_Link("?module=report_agentfinance&exporthtmlagentid=" . $eachAgentId, wf_img('skins/icon_print.png', __('Print')), false, ''); $agCells = wf_TableCell($this->agentsNamed[$eachAgentId]); $agCells .= wf_TableCell($eachAgentStat['count']); $agCells .= wf_TableCell($eachAgentStat['summ']); $agCells .= wf_TableCell($exportControls); $agRows .= wf_TableRow($agCells, 'row3'); } $result .= wf_TableBody($agRows, '50%', 0, 'sortable'); $result .= wf_tag('span', false, 'glamour') . __('Excluded payments count') . ': ' . $this->excludeCount . wf_tag('span', true); $result .= wf_tag('span', false, 'glamour') . __('Excluded cash') . ': ' . $this->excludeSumm . wf_tag('span', true); //save per agent printing data for future usage $this->savePrintData(); } $result .= wf_TableBody($rows, '100%', 0, 'sortable'); $result .= wf_tag('span', false, 'glamour') . __('Count') . ': ' . $totalCount . wf_tag('span', true); $result .= wf_tag('span', false, 'glamour') . __('Total payments') . ': ' . $totalSumm . wf_tag('span', true); return $result; }