assign('_title', $_L['Reports'].'- '. $config['CompanyName']); $ui->assign('_sysfrm_menu', 'reports'); $action = $routes['1']; $admin = Admin::_info(); $ui->assign('_admin', $admin); $mdate = date('Y-m-d'); $tdate = date('Y-m-d', strtotime('today - 30 days')); //first day of month $first_day_month = date('Y-m-01'); // $this_week_start = date('Y-m-d',strtotime( 'previous sunday')); // 30 days before $before_30_days = date('Y-m-d', strtotime('today - 30 days')); //this month $month_n = date('n'); switch ($action) { case 'print-by-date': $mdate = date('Y-m-d'); $d = ORM::for_table('tbl_transactions'); $d->where('recharged_on', $mdate); $d->order_by_desc('id'); $x = $d->find_many(); $dr = ORM::for_table('tbl_transactions'); $dr->where('recharged_on', $mdate); $dr->order_by_desc('id'); $xy = $dr->sum('price'); $ui->assign('d',$x); $ui->assign('dr',$xy); $ui->assign('mdate',$mdate); $ui->assign('recharged_on',$mdate); $ui->display('print-by-date.tpl'); break; case 'pdf-by-date': $mdate = date('Y-m-d'); $d = ORM::for_table('tbl_transactions'); $d->where('recharged_on', $mdate); $d->order_by_desc('id'); $x = $d->find_many(); $dr = ORM::for_table('tbl_transactions'); $dr->where('recharged_on', $mdate); $dr->order_by_desc('id'); $xy = $dr->sum('price'); $title = ' Reports ['.$mdate.']'; $title = str_replace('-',' ',$title); if ($x) { $html = '

'.$config['CompanyName'].'

'.$config['address'].'
'.$_L['Phone_Number'].': '.$config['phone'].'
'; $c = true; foreach ($x as $value) { $username = $value['username']; $plan_name = $value['plan_name']; $type = $value['type']; $price = $_c['currency_code'].' '. number_format($value['price'],0,$_c['dec_point'],$_c['thousands_sep']); $recharged_on = date( $config['date_format'], strtotime($value['recharged_on'])); $expiration = date( $config['date_format'], strtotime($value['expiration'])); $time = $value['time']; $method = $value['method']; $routers = $value['routers']; $html .= ""." "; } $html .= '
'.$_L['Username'].' '.$_L['Plan_Name'].' '.$_L['Type'].' '.$_L['Plan_Price'].' '.$_L['Created_On'].' '.$_L['Expires_On'].' '.$_L['Method'].' '.$_L['Routers'].'
$username $plan_name $type $price $recharged_on $time $expiration $time $method $routers

'.$_L['Total_Income'].':

'.$_c['currency_code'].' '.number_format($xy,2,$_c['dec_point'],$_c['thousands_sep']).'

'; define('_MPDF_PATH','system/vendors/mpdf/'); require('system/vendors/mpdf/mpdf.php'); $mpdf=new mPDF('c','A4','','',20,15,25,25,10,10); $mpdf->SetProtection(array('print')); $mpdf->SetTitle($config['CompanyName'].' Reports'); $mpdf->SetAuthor($config['CompanyName']); $mpdf->SetWatermarkText($d['price']); $mpdf->showWatermarkText = true; $mpdf->watermark_font = 'Helvetica'; $mpdf->watermarkTextAlpha = 0.1; $mpdf->SetDisplayMode('fullpage'); $style = ''; $nhtml = <<WriteHTML($nhtml); $mpdf->Output(date('Y-m-d')._raid(4).'.pdf', 'D'); }else{ echo 'No Data'; } break; case 'print-by-period': $fdate = _post('fdate'); $tdate = _post('tdate'); $stype = _post('stype'); $d = ORM::for_table('tbl_transactions'); if ($stype != ''){ $d->where('type', $stype); } $d->where_gte('recharged_on', $fdate); $d->where_lte('recharged_on', $tdate); $d->order_by_desc('id'); $x = $d->find_many(); $dr = ORM::for_table('tbl_transactions'); if ($stype != ''){ $dr->where('type', $stype); } $dr->where_gte('recharged_on', $fdate); $dr->where_lte('recharged_on', $tdate); $xy = $dr->sum('price'); $ui->assign('d',$x); $ui->assign('dr',$xy); $ui->assign('fdate',$fdate); $ui->assign('tdate',$tdate); $ui->assign('stype',$stype); $ui->display('print-by-period.tpl'); break; case 'pdf-by-period': $fdate = _post('fdate'); $tdate = _post('tdate'); $stype = _post('stype'); $d = ORM::for_table('tbl_transactions'); if ($stype != ''){ $d->where('type', $stype); } $d->where_gte('recharged_on', $fdate); $d->where_lte('recharged_on', $tdate); $d->order_by_desc('id'); $x = $d->find_many(); $dr = ORM::for_table('tbl_transactions'); if ($stype != ''){ $dr->where('type', $stype); } $dr->where_gte('recharged_on', $fdate); $dr->where_lte('recharged_on', $tdate); $xy = $dr->sum('price'); $title = ' Reports ['.$mdate.']'; $title = str_replace('-',' ',$title); if ($x) { $html = '

'.$config['CompanyName'].'

'.$config['address'].'
'.$_L['Phone_Number'].': '.$config['phone'].'
'; $c = true; foreach ($x as $value) { $username = $value['username']; $plan_name = $value['plan_name']; $type = $value['type']; $price = $_c['currency_code'].' '. number_format($value['price'],0,$_c['dec_point'],$_c['thousands_sep']); $recharged_on = date( $config['date_format'], strtotime($value['recharged_on'])); $expiration = date( $config['date_format'], strtotime($value['expiration'])); $time = $value['time']; $method = $value['method']; $routers = $value['routers']; $html .= ""." "; } $html .= '
'.$_L['Username'].' '.$_L['Plan_Name'].' '.$_L['Type'].' '.$_L['Plan_Price'].' '.$_L['Created_On'].' '.$_L['Expires_On'].' '.$_L['Method'].' '.$_L['Routers'].'
$username $plan_name $type $price $recharged_on $time $expiration $time $method $routers

'.$_L['Total_Income'].':

'.$_c['currency_code'].' '.number_format($xy,2,$_c['dec_point'],$_c['thousands_sep']).'

'; define('_MPDF_PATH','system/vendors/mpdf/'); require('system/vendors/mpdf/mpdf.php'); $mpdf=new mPDF('c','A4','','',20,15,25,25,10,10); $mpdf->SetProtection(array('print')); $mpdf->SetTitle($config['CompanyName'].' Reports'); $mpdf->SetAuthor($config['CompanyName']); $mpdf->SetWatermarkText($d['price']); $mpdf->showWatermarkText = true; $mpdf->watermark_font = 'Helvetica'; $mpdf->watermarkTextAlpha = 0.1; $mpdf->SetDisplayMode('fullpage'); $style = ''; $nhtml = <<WriteHTML($nhtml); $mpdf->Output(date('Y-m-d')._raid(4).'.pdf', 'D'); }else{ echo 'No Data'; } break; default: echo 'action not defined'; }