public static function createJV($data) { $jv = $data['JV']; $entries = json_decode($data['entries']); $userID = $data['userID']; $JVNo = JVoucher::JVnum(); $JVNumSeries = JVoucher::getJVNum(); $ID = $JVNumSeries[0]->idNum; $Voucher = $JVNumSeries[0]->numSeries + 1; DB::table('tbl_series')->where('idNum', $ID)->update(['numSeries' => $Voucher]); $id = DB::table('tbl_gj')->insertGetId(['JVNum' => $JVNo[0]->JV, 'transDate' => Carbon::NOW(), 'prepBy' => $userID, 'particulars' => $jv['particulars']]); for ($i = 0; $i < count($entries); $i++) { $var = $entries[$i]; $amount = isset($var->DB) && $var->DB > 0 ? $var->DB : $var->CR; if (isset($var->DB) && !empty($var->DB)) { $ID = $var->title; } else { $ID = null; } if (isset($var->CR) && !empty($var->CR)) { $ID2 = $var->title; } else { $ID2 = null; } DB::table('tbl_journalEntries')->insert(['JID' => $id, 'idAcctTitleDB' => $ID, 'idAcctTitleCR' => $ID2, 'amount' => $amount]); } if ($id) { $ids['success'] = 'true'; $ids['msg'] = 'New Journal Voucher Entry has been saved.'; } else { $ids['success'] = 'false'; $ids['msg'] = 'WARNING: Unknown error occur while saving the record'; } return $ids; }
public static function createPO($data) { $po = $data['PO']; $userID = $data['userID']; $entries = json_decode($data['entries']); $POSeries = PurchaseOrders::PONumseries(); $PONo = PurchaseOrders::getPONum(); $ID = $PONo[0]->idNum; $Voucher = $PONo[0]->numSeries + 1; DB::table('tbl_series')->where('idNum', $ID)->update(['numSeries' => $Voucher]); $result = DB::table('tbl_po')->insertGetId(['po_num' => $POSeries[0]->PO, 'supplier' => $po['supplier'], 'branch' => $po['branch'], 'PO_date' => Carbon::NOW(), 'bank' => $po['bank'], 'purchasing_agent' => $po['POAgent'], 'requestedby' => $po['brName'], 'mop' => $po['mop'], 'userID' => $userID]); for ($i = 0; $i < count($entries); $i++) { $var = $entries[$i]; $quantity = $var->qty; $unit = $var->unit; $Items = $var->Items; $unitPrice = $var->unitPrice; $total = $var->total; DB::table('tbl_po_items')->insert(['poID' => $result, 'items' => $Items, 'qty' => $quantity, 'unit' => $unit, 'unit_price' => $unitPrice, 'total' => $total]); } if ($result) { $results['success'] = 'true'; $results['msg'] = 'New Purchase Order has been saved.'; } else { $results['success'] = 'false'; $results['msg'] = 'WARNING: Unknown error occur while saving the record'; } return $results; }
public static function updateAPV($id, $data) { $apv = $data['APV']; $userID = $data['userID']; $result = DB::table('tbl_apv')->where('apvID', $id)->update(['transDate' => Carbon::NOW(), 'particulars' => $apv['particulars'], 'prepBy' => $userID]); if ($result) { $results['success'] = 'true'; $results['msg'] = 'Account Payable Voucher has been updated.'; } else { $results['success'] = 'false'; $results['msg'] = 'WARNING: Unknown error occur while updating APV.'; } return $results; }
public static function saveOR($data) { $OR = $data['OR']; $userID = $data['userID']; $result = DB::insert('INSERT INTO tbl_OR(ORNum,transDate,branch,amount,particulars,userID) VALUES (?,?,?,?,?,?)', [$OR['ORNum'], Carbon::NOW(), $OR['payer'], $OR['amount'], $OR['particulars'], $userID]); if ($result) { $results['success'] = 'true'; $results['msg'] = 'Offcial Receipt has been saved'; } else { $results['success'] = 'false'; $results['msg'] = 'WARNING: Unknown error occur while saving the record'; } return $results; }
public static function createAsset($data) { $Asset = $data['asset']; $userID = $data['userID']; $result = DB::insert('INSERT INTO tbl_assetinfo(itemName,cost,datePurchased,estLife,qty,categoryID,postedDate,postedBy) VALUES(?,?,?,?,?,?,?,?)', [$Asset['itemName'], $Asset['cost'], $Asset['datePurchased'], $Asset['estLife'], $Asset['qty'], $Asset['category'], Carbon::NOW(), $userID]); if ($result) { $results['success'] = 'true'; $results['msg'] = 'New Asset Item has been added successfully.'; } else { $results['success'] = 'false'; $results['msg'] = 'WARNING: Unknown error occur while saving the record'; } return $results; }
public static function updateCDV($id, $data) { $CDV = $data['CDV']; $userID = $data['userID']; $result = DB::table('tbl_cdv')->where('cdvID', $id)->update(['payee' => $CDV['payee'], 'address' => $CDV['address'], 'chkDate' => $CDV['dt'], 'bankID' => $CDV['bank'], 'amount' => $CDV['amount'], 'chkNO' => $CDV['chkNO'], 'particular' => $CDV['particular'], 'transDate' => Carbon::NOW(), 'prepBy' => $userID]); if ($result) { $results['success'] = 'true'; $results['msg'] = 'Check Disbursement Voucher has been updated.'; } else { $results['success'] = 'false'; $results['msg'] = 'WARNING: Unknown error occur while updating CDV.'; } return $results; }