$total_debit = 0; $total_credit = 0; foreach ($page_list as $row) { #Show one row at a time if ($row['type'] == 'DEBIT') { $debit = $row['amount']; $credit = 0; $balance -= $debit; $total_debit += $debit; } else { $debit = 0; $credit = $row['amount']; $balance += $credit; $total_credit += $credit; } $fee = get_fee_lines($this, $row['fee']); echo "<tr class='listrow' style='" . get_row_color($counter, 2, 'row_borders') . "'>\r\r\n\t\t<td valign='top' nowrap>"; if (check_user_access($this, 'delete_deal')) { echo "<a href='javascript:void(0)' onclick=\"confirmDeleteEntity('" . base_url() . "finances/delete_fee/i/" . encryptValue($row['id']) . "', 'Are you sure you want to remove this fee? \\nThis operation can not be undone. \\nClick OK to confirm, \\nCancel to cancel this operation and stay on this page.');\" title=\"Click to remove this fee.\"><img src='" . base_url() . "images/delete.png' border='0'/></a>"; } #if(check_user_access($this,'update_deals')){ echo " <a href='#' title=\"Click to print this transaction details.\"><img src='" . base_url() . "images/small_pdf.png' border='0'/></a>"; #} echo "</td>\r\r\n\t\t \t\t<td valign='top'>" . date("j M, Y", GetTimeStamp($row['dateadded'])) . "</td>\r\r\n\t\t\t\t<td valign='top'>" . $fee['fee'] . "</td>\r\r\n\t\t\t\t<td valign='top' nowrap align='right'>" . number_format($debit, 0, '.', ',') . "</td>\r\r\n\t\t\t\t<td valign='top' nowrap align='right'>" . number_format($credit, 0, '.', ',') . "</td>\r\r\n\t\t\t\t<td valign='top' nowrap align='right'>" . number_format($balance, 0, '.', ',') . "</td>\r\r\n\t\t\t</tr>"; $counter++; } echo "<tr>\r\r\n\t\t <td colspan='3'></td>\r\r\n\t\t <td><div class='sum'>" . number_format($total_debit, 0, '.', ',') . "</div></td>\r\r\n\t\t <td><div class='sum'>" . number_format($total_credit, 0, '.', ',') . "</div></td>\r\r\n\t\t <td style='padding-right:0'><div class='sum'>" . number_format(-($total_debit - $total_credit), 0, '.', ',') . "</div></td>\r\r\n\t\t </tr>"; echo "<tr>\r\r\n\t<td colspan='6' align='right' class='layer_table_pagination'>" . pagination($this->session->userdata('search_total_results'), $rows_per_page, $current_list_page, base_url() . "classes/manage_classes/p/%d") . "</td>\r\r\n\t</tr>\r\r\n\t</table>"; } else { echo "<div>No transactions have been added.</div"; }
function print_student_statement() { access_control($this); # Get the passed details into the url data array if any $urldata = $this->uri->uri_to_assoc(3, array('m', 'i')); # Pick all assigned data $data = assign_to_data($urldata); #Get the student's details $studentid = decryptValue($data['i']); $data['studentdetails'] = $this->Query_reader->get_row_as_array('get_students_list', array('isactive' => 'Y', 'limittext' => '', 'searchstring' => ' AND id = ' . $studentid)); #Check if the student belongs to the current user's school if ($data['studentdetails']['school'] != $this->myschool['id']) { $data['studentdetails'] = array(); $studentid = ''; $data['msg'] = 'ERROR : The student data could not be found.'; } #Get student's finances $query = $this->Query_reader->get_query_by_code('search_student_accounts', array('isactive' => 'Y', 'limittext' => '', 'searchstring' => ' AND student = ' . $studentid)); $query_results = $this->db->query($query); $financial_details = $query_results->result_array(); #Format the statement $report_html = ''; #$financial_details = array(); if (!empty($financial_details)) { $report_html = "<table width='100%' border='0' cellspacing='0' cellpadding='5'>\n \t\t `\t\t\t<tr>\n\t\t\t\t \t\t\t\t<td class='listheader'>Date</td>\n \t\t \t\t\t\t<td class='listheader' nowrap>Particulars</td>\n\t\t\t\t \t\t\t\t<td class='listheader' nowrap align='right'>Debit</td>\n\t\t\t\t \t\t\t\t<td class='listheader' nowrap align='right'>Credit</td>\n \t\t \t\t\t\t<td class='listheader' nowrap align='right'>Balance</td>\n\t\t\t\t \t\t </tr>"; $counter = 0; $balance = 0; $total_debit = 0; $total_credit = 0; foreach ($financial_details as $row) { #Show one row at a time if ($row['type'] == 'DEBIT') { $debit = $row['amount']; $credit = 0; $balance -= $debit; $total_debit += $debit; } else { $debit = 0; $credit = $row['amount']; $balance += $credit; $total_credit += $credit; } $fee = get_fee_lines($this, $row['fee']); $report_html .= "<tr style='" . get_row_color($counter, 2) . "'>\t\t\n\t\t \t\t\t\t\t\t<td valign='top'>" . date("j M, Y", GetTimeStamp($row['dateadded'])) . "</td>\n\t\t\t\t\t\t\t\t<td valign='top'>" . $fee['fee'] . "</td>\t\t\n\t\t\t\t\t\t\t\t<td valign='top' nowrap align='right'>" . number_format($debit, 0, '.', ',') . "</td>\n\t\t\t\t\t\t\t\t<td valign='top' nowrap align='right'>" . number_format($credit, 0, '.', ',') . "</td>\t\t\t\t\n\t\t\t\t\t\t\t\t<td valign='top' nowrap align='right'>" . number_format($balance, 0, '.', ',') . "</td>\t\n\t\t\t\t\t\t\t\t</tr>"; $counter++; } $report_html .= "<tr>\n\t\t \t\t\t\t\t<td colspan='2'></td>\n\t\t \t\t\t\t\t<td nowrap align='right'><div>" . number_format($total_debit, 0, '.', ',') . "</div></td>\n\t\t \t\t\t\t\t<td nowrap align='right'><div>" . number_format($total_credit, 0, '.', ',') . "</div></td>\n\t\t \t\t\t\t\t<td style='padding-right:0' nowrap align='right'><div class='sum'>" . number_format(-($total_debit - $total_credit), 0, '.', ',') . "</div></td>\n\t\t \t\t\t\t\t</tr></table>"; } else { $report_html .= "<div>No transactions have been added.</div"; } $this->load->library('parser'); $data['report_html'] = $report_html; $output = $this->parser->parse('incl/print_data', $data, true); gen_pdf($this, $output); #$this->load->view('incl/print_data', $data); }