public static function PurchaseOrders() { $collection = PurchaseOrder::GetAllOrders($_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>ALL PURCHASE ORDERS</h4>'; if ($_GET['period'] != '' && $_GET['period']) { echo '<h5 style="margin-top:-10px">Period: ' . $_GET['period'] . '</h5>'; } echo '</div> <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>DATE</td> <td>ORDER ID</td> <td>COMPANY</td> <td>PURPOSE</td> <td>STATUS</td> <td>TOTAL</td> </tr> </thead> <tbody>'; $total = 0.0; $invoiced = 0.0; $itms = 0; foreach ($collection as $item) { echo '<tr> <td>' . $item->date . '</td> <td>' . $item->id . '</td> <td>' . $item->party->name . '</td>'; $sql = 'SELECT * FROM purchase_orders WHERE id = ' . $item->id; $res = DatabaseHandler::GetRow($sql); $vc = PurchaseOrderVoucher::initialize($res); echo '<td>' . $vc->description . '</td>'; if ($item->status == 1) { echo '<td style="color:#232836">CREATED</td>'; } else { echo '<td style="color:#27c97b">ORDERED</td>'; $invoiced += $item->total; } echo '<td class="text-right" style="padding: 0 5px;"><script>document.writeln((' . $item->total . ').formatMoney(2, \'.\', \',\'));</script></td> </tr>'; $total += $item->total; ++$itms; } echo '</tbody> </table> <div class="logo"> <p style="margin: 5px 0 0 5px">Total Quotes: <b>' . $itms . '</b></p> <p style="margin: 5px 0 0 5px">Total Quoted: <b>Ksh. <script>document.writeln((' . $total . ').formatMoney(2, \'.\', \',\'));</script></b></p> <p style="margin: 5px 0 0 5px">Total Invoiced: <b>Ksh. <script>document.writeln((' . $invoiced . ').formatMoney(2, \'.\', \',\'));</script></b></p> </div>'; }
public static function GetSupplierTransactions($sid, $category, $dates, $all) { if ($category == 1) { //Statement if ($all == 'true') { $sql = 'SELECT * FROM general_ledger_entries WHERE account_no = ' . intval($sid) . ' AND ledger_name = "Creditors" 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($sid) . ' AND ledger_name = "Creditors" 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'] == 'dr') { $voucher = PaymentVoucher::GetVoucher(intval($tx['transaction_id'])); if ($voucher) { $vouchers[] = $voucher; } } else { $voucher = PurchaseVoucher::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 { //orders if ($all == 'true') { $sql = 'SELECT * FROM purchase_orders WHERE supplier_id = ' . intval($sid) . ' 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 purchase_orders WHERE supplier_id = ' . intval($sid) . ' AND stamp BETWEEN ' . $lower . ' AND ' . $upper . ' ORDER BY id DESC'; } try { $res = DatabaseHandler::GetAll($sql); $vouchers = []; foreach ($res as $order) { $vouchers[] = PurchaseOrderVoucher::initialize($order); } return $vouchers; } catch (Exception $e) { } } }