<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE install SYSTEM "http://dev.joomla.org/xml/1.5/plugin-install.dtd"> <install version="1.5" type="plugin" group="content"> <name>payment_report</name> <author>Kayfolom</author> <authorEmail>ekorepov@ukhta-inform.ru</authorEmail> <authorUrl>authorUrl</authorUrl> <creationDate>2009</creationDate> <copyright>c</copyright> <license>license</license> <version>1.0</version> <description>description</description> <files> <filename plugin="payment_report">payment_report.php</filename> </files> <params /> </install>
<?php @ini_set("display_errors", "1"); error_reporting(E_ALL); defined( '_JEXEC' ) or die( 'Restricted access' ); require_once("./urfa/URFAClient.php"); $mainframe->registerEvent( 'onPrepareContent', 'plgPaymentReportModify' ); function plgPaymentReportModify(&$row, &$params, $page=0){ if (strpos($row->text, '_report}')!==false) { $urfa_user5 = new URFAClient_User5($_SESSION['URFA']['login'], $_SESSION['URFA']['password']); // Отчет по платежам if (strpos($row->text, '{payment_report}') > 0) { $row->text = preg_replace('/{payment_report}/', 'Отчет по платежам за год', $row->text); $report = $urfa_user5->rpcf_user5_payments_report(strtotime("-1 year"),strtotime("now")); //-0x4012 $report_table = ''; if ($report['atr_size']>0) { $report_table = '<table border="1" cellpadding="4" style="background-color:#8db3e2"><tbody>'; $report_table .= '<tr><th align=center>Дата</th><th align=center>Сумма</th><th align=center>Метод</th><th align=center>Комментарий</th></tr>'; for ($i=0;$i<$report['atr_size'];$i++) { $report_table .= '<tr style="background-color:#dbe5f1">'; $report_table .= '<td align=center>'.date("d.m.Yг. H:i",$report['payment'][$i]['actual_date']).'</td>'; $report_table .= '<td align=right>'.sprintf("%01.2fруб.",$report['payment'][$i]['payment']).'</td>'; $report_table .= '<td align=left>'.$report['payment'][$i]['payment_method'].'</td>'; $report_table .= '<td align=left>'.$report['payment'][$i]['comment'].'</td>'; $report_table .= '</tr>'; } $report_table .= '</tbody></table>'; } else { $report_table = 'Отсутствуют платежи за последний год'; } $row->text = preg_replace('/{payment_report_table}/', $report_table, $row->text); } // Отчет по услугам за $month_count месяцев if (strpos($row->text, '{service_report}') > 0) { $month_count = 2; // За сколько месяцев делаем отчет $row->text = preg_replace('/{service_report}/', "Отчет по услугам за $month_count месяца", $row->text); $report = $urfa_user5->rpcf_user5_service_report(strtotime("-$month_count month"),strtotime("now")); //-0x4012 $report_table = ''; if ($report['services'][0]['asr_size']>0) { $report_table = '<table border="1" cellpadding="4" style="background-color:#8db3e2"><tbody>'; $report_table .= '<tr><th align=center>Дата</th><th align=center>Сумма</th><th align=center>Наименование</th></tr>'; for ($i=0;$i<$report['services'][0]['asr_size'];$i++) { $report_table .= '<tr style="background-color:#dbe5f1">'; $report_table .= '<td align=center>'.date("d.m.Yг. H:i",$report['services'][0]['asr_size_array'][$i]['discount_date']).'</td>'; $report_table .= '<td align=right>'.sprintf("%01.2fруб.",$report['services'][0]['asr_size_array'][$i]['discount']).'</td>'; $report_table .= '<td align=left>'.$report['services'][0]['asr_size_array'][$i]['service_name'].'</td>'; $report_table .= '</tr>'; } $report_table .= '</tbody></table>'; } else { $report_table = "Отсутствуют услуги за последние $month_count месяца"; } $row->text = preg_replace('/{service_report_table}/', $report_table, $row->text); } function traffic_report($start_date, $end_date, $urfa_user5) { $report = $urfa_user5->rpcf_user5_traffic_report($start_date, $end_date); //-0x4012 $report_table = ''; $bytes_count = 0; $summ = 0; if ($report['count']>0) { $report_table = '<table border="1" cellpadding="4" style="background-color:#8db3e2"><tbody>'; $report_table .= '<tr><th align=center>Класс трафика</th><th align=center>Объем, МБ</th><th align=center>Цена за МБ</th><th align=center>Сумма</th></tr>'; for ($i=0;$i<$report['count'];$i++) { $report_table .= '<tr style="background-color:#dbe5f1">'; $report_table .= '<td align=left>'.$report['traffic'][$i]['tclass_name'].'</td>'; $report_table .= '<td align=right>'.sprintf("%01.3f",$report['traffic'][$i]['bytes']/1024/1024).'</td>'; $bytes_count = $bytes_count + $report['traffic'][$i]['bytes']; $report_table .= '<td align=right>'.sprintf("%01.2fруб.",$report['traffic'][$i]['base_cost']).'</td>'; $report_table .= '<td align=right>'.sprintf("%01.2fруб.",$report['traffic'][$i]['discount']).'</td>'; $summ = $summ + $report['traffic'][$i]['discount']; $report_table .= '</tr>'; } $report_table .= '<tr style="background-color:#dbe5f1"><td>Итого :</td>'; $report_table .= '<td align=right>'.sprintf("%01.3f",$bytes_count/1024/1024).'</td><td></td><td align=right>'.sprintf("%01.2fруб.",$summ).'</td>'; $report_table .= '</tbody></table>'; } else { $report_table = "Отчет отсутствует"; } return $report_table; } // Отчет по трафику за день if (strpos($row->text, '{traffic_day_report}') > 0) { $day_count = 1; $row->text = preg_replace('/{traffic_day_report}/', "Отчет по трафику за $day_count день ".date("d.m.Y",time()), $row->text); $report_table = traffic_report(strtotime(date("d.m.Y",time())),strtotime("now"),$urfa_user5); $row->text = preg_replace('/{traffic_day_report_table}/', $report_table, $row->text); } // Отчет по тарифку за Расчетный период /* if (strpos($row->text, '{traffic_discount_period_report}') > 0) { try { $urfa_admin = new URFAClient_Admin('test000', 'test000'); } catch (Exception $exception) { echo "Error in line ", $exception->getLine(); echo $exception->getMessage(); } $user_tariff = $urfa_admin->rpcf_get_user_tariffs($_SESSION['URFA']['user_id']); $discount_period = $urfa_admin->rpcf_get_discount_period($user_tariff['user_tariffs'][0]['discount_period_id']); $discount_period_start = date("d.m.Y H:i",$discount_period['start_date']); $discount_period_end = date("d.m.Y H:i",$discount_period['end_date']); $row->text = preg_replace('/{traffic_discount_period_report}/', "Отчет по трафику за расчетный период ".$discount_period_start.' - '.$discount_period_end, $row->text); $report_table = traffic_report($discount_period['start_date'],$discount_period['end_date'],$urfa_user5); $row->text = preg_replace('/{traffic_discount_period_report_table}/', $report_table, $row->text); } */ } }
{payment_report_table}
{traffic_day_report_table}
{service_report_table}