Пример #1
0
 /**
  * Simpan atau Update berdasarkan  setting pada variabel $_POST  update to TRUE or FALSE.
  * @param array $_POST - Form data yang dimasukan
  * @return mixed
  */
 public function simpan(array $post, $ndbase)
 {
     $dbConn = new DBConnection();
     $details = new dbHandler($dbConn, $ndbase);
     //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
         $simpan = new dbHandler($dbConn, $ndbase);
         // $items->deleteWhere('where id=' . $post['Id']);
         // Update invoice details
         $details->updateDatabaseWhere($post, 'WHERE id=' . $post['editid']);
         // This is used for the inserting of the items we have on the invoice
         // $Id = $post['Id'];
         //simpan log update
         $gabungarayval = implode("', '", $post);
         $gabungaraykey = implode("', '", array_keys($post));
         $sql = "key(" . $gabungaraykey . ") val(" . $gabungarayval . ") WHERE id = " . $post['editid'];
         $this->logging($ndbase, $sql, "UPDATE");
     } else {
         $items = new dbHandler($dbConn, $ndbase);
         $items->insertIntoDatabase($post);
     }
     //return $Id;
 }
Пример #2
0
 public function updatePerusahaan(array $post)
 {
     $dbConn = new DBConnection();
     $perusahaan = new dbHandler($dbConn, 'perusahaan');
     $perusahaan->updateDatabaseWhere($post, 'where id=' . $post['id']);
 }
Пример #3
0
 /**
  * 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;
 }