?
Current Path : /home1/savoy/public_html/savoyglobal.net/eldertree/application/views/accounting/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/public_html/savoyglobal.net/eldertree/application/views/accounting/xls_profit_loss.php |
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?> <?php if(!$company){ $images=base_url() .'assets/logo/default_header.jpg'; $company_name = '';} else { foreach($company as $company) { $loggo=$company['logo']; $images=base_url() .'assets/logo/'.$loggo; $company_name = $company['nursery_name']; // echo $images; } } $html=""; $image = '<img src="' . $images . '" widtd="285px" height="100px">'; $html.=' <html> <head> </head> <body style="margin: 20px 20px 30px 20px;"> <table widtd="100%" border="0" cellpadding="2" cellspacing="2"> <tbody> <tr><td colspan="2" align="left">'. $image .'</td></tr> </tbody> </table><br/> <table> <tr><th colspan="3"><b><u><b>'. $company_name .'</b></u></b></th></tr> <tr><th colspan="3"><b><u>'. $heading .'</u></b></th></tr> </table> <table> <tr>'; $dt1=($date1 != 0) ? $date1 : "-" ; $dt2=($date2 != 0) ? $date2 : "-" ; $html.='<td colspan="3"> Period : '.$dt1.' to '.$dt2.'</td> </tr> </table> <br/><hr>'; $revenue = array(); $cost_of_sale = array(); $expense = array(); $chart_types=$this->mastermodel->get_data_joined('finance_chart_type', 'chart_account_group', 'chart_group', 'chart_group_id', '', '', ""); foreach ($chart_types as $list){ if($list['account_group']=="revenue") $revenue[]=$list['chart_type_id']; if($list['account_group']=="cost_of_sales") $cost_of_sale[]=$list['chart_type_id']; if($list['account_group']=="expenses") $expense[]=$list['chart_type_id']; } // var_dump($expense);die(); $revenue_list = ""; $cost_of_sale_list = ""; $expense_list = ""; $revenue_sum = 0; $cost_of_sale_sum = 0; $expense_sum = 0; $ex = 0; foreach ($result as $list) { $list['account_amount']=$list['account_amount_debit']-$list['account_amount_credit']; // foreach ($account as $list) { if (in_array($list['chart_id'], $revenue)) { $revenue_list.='<tr> <td style="text-align:left">' . $list['account_name'] . '</td> <td></td> <td style="text-align:right">' . number_format($list['account_amount'], 2) . '</td> </tr>'; $revenue_sum+=$list['account_amount']; } if (in_array($list['chart_id'], $cost_of_sale)) { $cost_of_sale_list.='<tr> <td style="text-align:left">' . $list['account_name'] . '</td> <td></td> <td style="text-align:right">' . number_format($list['account_amount'], 2) . '</td> </tr>'; $cost_of_sale_sum+=$list['account_amount']; } if (in_array($list['chart_id'], $expense)) { $expense_list.='<tr> <td style="text-align:left">' . $list['account_name'] . '</td> <td></td> <td style="text-align:right">' . number_format($list['account_amount'], 2) . '</td> </tr>'; $expense_sum+=$list['account_amount']; } // } } $html.=' <table cellspacing="-1" style="widtd:100%;text-align:left;"> <tr> <td></td> <td></td> <td style="text-align:right"><b style="text-align:right">Amount</b></td> </tr> <tr> <td style="text-align:left">REVENUE</td> <td></td> <td></td> </tr> '. $revenue_list .' <tr> <td style="text-align:left" >Total Revenue</td> <td></td> <td style="text-align:right">'. $revenue_sum .'</td> </tr> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td style="text-align:left">COST OF SALES</td> <td></td> <td></td> </tr> '. $cost_of_sale_list .' <tr> <td style="text-align:left">Total Cost of Sales</td> <td></td> <td style="text-align:right">'. number_format($cost_of_sale_sum, 2) .'</td> </tr> <tr> <td></td> <td></td> <td></td> </tr>'; $gross_profit = $revenue_sum - $cost_of_sale_sum; $html.=' <tr> <td>GROSS PROFIT</td> <td></td> <td style="text-align:right">'. number_format($gross_profit, 2) .'</td> </tr> <tr> <td>(Revenue - Cost of Sales)</td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td style="text-align: left;">EXPENSES</td> <td></td> <td></td> </tr> '. $expense_list .' <tr> <td style="text-align: left;">Total Expenses</td> <td></td> <td style="text-align:right">'. number_format($expense_sum, 2) .'</td> </tr> <tr> <td></td> <td></td> <td></td> </tr>'; $net_income = $gross_profit - $expense_sum; $html.=' <tr> <td style="text-align: left;">NET INCOME</td> <td></td> <td style="text-align:right">'. number_format($net_income, 2) .'</td> </tr> <tr> <td>(Gross Profit - Expenses)</td> <td></td> <td></td> </tr> </table> </body> </html>'; //echo $html;die(); $fname=$file_name; if ($reportin == 'pdf') pdf_create($html, $fname, 'true'); else { header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=" . $fname . ".xls"); header("Pragma: no-cache"); header("Expires: 0"); print $html; exit; } ?>