public static function GetClientTransactions($cid, $category, $dates, $all) { if ($category == 1) { //Statement if ($all == 'true') { $sql = 'SELECT * FROM general_ledger_entries WHERE account_no = ' . intval($cid) . ' ORDER BY id DESC'; } else { if ($dates != '') { $split = explode(' - ', $dates); $d1 = explode('/', $split[0]); $d2 = explode('/', $split[1]); $lower = $d1[2] . $d1[0] . $d1[1] . '000000' + 0; $upper = $d2[2] . $d2[0] . $d2[1] . '999999' + 0; $sql = 'SELECT * FROM general_ledger_entries WHERE account_no = ' . intval($cid) . ' AND stamp BETWEEN ' . $lower . ' AND ' . $upper . ' ORDER BY id DESC'; } } try { $res = DatabaseHandler::GetAll($sql); $vouchers = []; foreach ($res as $tx) { if ($tx['effect'] == 'cr') { $voucher = ReceiptVoucher::GetVoucher(intval($tx['transaction_id'])); if ($voucher) { $vouchers[] = $voucher; } } else { $voucher = InvoiceVoucher::GetVoucher(intval($tx['transaction_id'])); if ($voucher) { $vouchers[] = $voucher; } } } return $vouchers; } catch (Exception $e) { } } else { //Quotations if ($all == 'true') { $sql = 'SELECT * FROM quotations WHERE client_id = ' . intval($cid) . ' ORDER BY id DESC'; } else { $split = explode(' - ', $dates); $d1 = explode('/', $split[0]); $d2 = explode('/', $split[1]); $lower = $d1[2] . $d1[0] . $d1[1] . '000000' + 0; $upper = $d2[2] . $d2[0] . $d2[1] . '999999' + 0; $sql = 'SELECT * FROM quotations WHERE client_id = ' . intval($cid) . ' AND stamp BETWEEN ' . $lower . ' AND ' . $upper . ' ORDER BY id DESC'; } try { $res = DatabaseHandler::GetAll($sql); $vouchers = []; foreach ($res as $quote) { $vouchers[] = QuotationVoucher::initialize($quote); } return $vouchers; } catch (Exception $e) { } } }
public static function MinorWorksReceipts() { $client = Client::GetClient($_GET['sid']); //, $_GET['period'], $_GET['all'] echo ' <div class="logo"> <h5 style="margin-bottom:-15px;margin-top:0px;font-size:14px;">Date: ' . date('d/m/Y') . '</h5> <h4>MINOR WORKS PAYMENTS FOR ' . $client->name . '</h4>'; /*if ($_GET['period'] != '' && $_GET['period'] ) { echo '<h5 style="margin-top:-10px">Period: '.$_GET['period'].'</h5>'; } */ echo '</div>'; $payments = ReceiptVoucher::GetWorksReceipts($_GET['sid']); echo '<h5>RECEIVED PAYMENTS</h5> <table class="table table-bordered table-striped" style="text-align:center;margin-left:0;margin-right:0;width:760px;font-size:12px;"> <thead class="title"> <tr> <td>REC. NO</td> <td>DATE</td> <td>AMOUNT</td> <td>VOUCHER</td> <td>DESCRIPTION</td> </tr> </thead> <tbody>'; $amount = 0.0; if (count($payments) > 0) { foreach ($payments as $payment) { echo '<tr> <td>' . $payment['id'] . '</td> <td>' . $payment['datetime'] . '</td> <td><script>document.writeln((' . $payment['amount'] . ').formatMoney(2, \'.\', \',\'));</script></td> <td>' . $payment['voucher_no'] . '</td> <td>' . $payment['description'] . '</td> </tr>'; $amount += $payment['amount']; } } echo '</tbody> </table> <div class="logo"> <h5 style="margin: 5px 0 0 5px;float:right">Total Received: <b>Ksh. <script>document.writeln((' . $amount . ').formatMoney(2, \'.\', \',\'));</script></b></h5> </div>'; }
public static function GetClientTransactions($cid, $category, $dates, $all) { if ($category == 1) { //Statement if ($all == 'true') { $sql = 'SELECT * FROM general_ledger_entries WHERE account_no = ' . intval($cid) . ' AND ledger_name = "Debtors" ORDER BY id DESC'; } else { if ($dates != '') { $split = explode(' - ', $dates); $d1 = explode('/', $split[0]); $d2 = explode('/', $split[1]); $lower = $d1[2] . $d1[0] . $d1[1] . '000000' + 0; $upper = $d2[2] . $d2[0] . $d2[1] . '999999' + 0; $sql = 'SELECT * FROM general_ledger_entries WHERE account_no = ' . intval($cid) . ' AND ledger_name = "Debtors" AND stamp BETWEEN ' . $lower . ' AND ' . $upper . ' ORDER BY id DESC'; } } try { $res = DatabaseHandler::GetAll($sql); $vouchers = []; foreach ($res as $tx) { if ($tx['status'] == 1) { if ($tx['effect'] == 'cr') { if (stripos($tx['description'], 'Credit Note') !== false) { $voucher = CreditVoucher::GetVoucher(intval($tx['transaction_id'])); } else { $voucher = ReceiptVoucher::GetVoucher(intval($tx['transaction_id'])); } if ($voucher) { $vouchers[] = $voucher; } } else { $voucher = SalesVoucher::GetVoucher(intval($tx['transaction_id'])); if ($voucher) { $vouchers[] = $voucher; } } } elseif ($tx['status'] == 3) { $entry = new stdClass(); $entry->transactionId = $tx['transaction_id']; $entry->date = $tx['when_charged']; $entry->amount = $tx['amount']; $entry->description = $tx['description']; $sql2 = 'SELECT * FROM transactions WHERE id = ' . intval($tx['transaction_id']); $res2 = DatabaseHandler::GetRow($sql2); $entry->user = $res2['user']; $entry->type = $res2['type']; $vouchers[] = $entry; } } return $vouchers; } catch (Exception $e) { } } else { //Quotations if ($all == 'true') { $sql = 'SELECT * FROM quotations WHERE client_id = ' . intval($cid) . ' ORDER BY id DESC'; } else { $split = explode(' - ', $dates); $d1 = explode('/', $split[0]); $d2 = explode('/', $split[1]); $lower = $d1[2] . $d1[0] . $d1[1] . '000000' + 0; $upper = $d2[2] . $d2[0] . $d2[1] . '999999' + 0; $sql = 'SELECT * FROM quotations WHERE client_id = ' . intval($cid) . ' AND stamp BETWEEN ' . $lower . ' AND ' . $upper . ' ORDER BY id DESC'; } try { $res = DatabaseHandler::GetAll($sql); $vouchers = []; foreach ($res as $quote) { $vouchers[] = QuotationVoucher::initialize($quote); } return $vouchers; } catch (Exception $e) { } } }