/** * Save or Update invoice this is based on setting the $_POST var update to TRUE or FALSE. * @param array $_POST - Form data being submitted * @return mixed */ public function saveInv(array $post) { $dbConn = new DBConnection(); $details = new dbHandler($dbConn, 'inv_details'); if ($_POST['update'] == 'true') { // Set post date whether we are inserting or updaeting //$post['date'] = date('Y-m-d'); // If we are updating we have to delete the quote items $items = new dbHandler($dbConn, 'inv_items'); $items->deleteWhere('where invId=' . $post['invId']); //trim space function trim_value(&$value) { $value = trim($value); } array_walk($post, 'trim_value'); // Update invoice details $details->updateDatabaseWhere($post, 'where id=' . $post['invId']); // This is used for the inserting of the items we have on the invoice $invId = $post['invId']; } else { // Set post date whether we are inserting $post['date'] = date('Y-m-d'); //trim space function trim_value(&$value) { $value = trim($value); } array_walk($post, 'trim_value'); //save invoice detail $invId = $details->insertIntoDatabase($post); } // Iterate over the items on the invoice and insert them into the database foreach ($_POST['itemId'] as $row => $item) { // Build a new array so we can insert them into the database $postArray = array('invId' => $invId, 'itemId' => $_POST['itemId'][$row], 'qty' => $_POST['itemQty'][$row], 'poNumber' => $_POST['noPo'][$row], 'itemDisc' => $_POST['itemDisc'][$row], 'itemUkuran' => $_POST['itemUkuran'][$row]); $items = new dbHandler($dbConn, 'inv_items'); $items->insertIntoDatabase($postArray); } return $invId; }
/** * Save or Update invoice this is based on setting the $_POST var update to TRUE or FALSE. * @param array $_POST - Form data being submitted * @return mixed */ public function saveItem(array $post) { $dbConn = new DBConnection(); $details = new dbHandler($dbConn, 'items'); // Set post date whether we are updating or inserting // $post['date'] = date('Y-m-d'); if ($_POST['update'] == 'true') { // If we are updating we have to delete the quote items $items = new dbHandler($dbConn, 'items'); //$items->deleteWhere('where id=' . $post['itemId']); //trim space function trim_value(&$value) { $value = trim($value); } array_walk($post, 'trim_value'); // Update invoice details $details->updateDatabaseWhere($post, 'where id=' . $post['itemId']); // This is used for the inserting of the items we have on the invoice $itemId = $post['itemId']; } else { // var_export ($post); // komentar // $itemId = $details->insertIntoDatabase($post); // Iterate over the items on the invoice and insert them into the database // foreach ($_POST['itemId'] as $row => $item) { // Build a new array so we can insert them into the database //"KodeBarang", "NamaBarang", "DiskripsiBarang", "HargaBarang", "DiscBarang" $postArray = array('itemCode' => trim($_POST['itemCode']), 'itemName' => trim($_POST['itemName']), 'itemDesc' => trim($_POST['itemDesc']), 'itemPrice' => trim($_POST['itemPrice']), 'itemSize' => trim($_POST['itemSize']), 'satuan' => trim($_POST['satuan'])); $items = new dbHandler($dbConn, 'items'); // Update invoice details $items->insertIntoDatabase($postArray); // } } return $itemId; }
public function logging($ndbase, $idtable, $statuss) { $dbConn = new DBConnection(); $logging = new dbHandler($dbConn, "loging"); if (!isset($_SESSION['ID'])) { $session = "none"; } else { $session = $_SESSION['ID']; } $inputdata = array('namatabel' => $ndbase, 'iduser' => $session, 'tanggal' => date("Y-m-d H:i:s"), 'logtabel' => $idtable, 'statuss' => $statuss); //set update=false //$_POST['update'] = 'false'; //simpan data user ke db $logging->insertIntoDatabase($inputdata); }