コード例 #1
0
ファイル: Payment.php プロジェクト: alsimfer/HomePage
 public function save($params, $payment_id = 0)
 {
     $returnArray = array();
     // Adjust the params for the further DB usage.
     foreach ($params as $key => $value) {
         $params[$key] = $this->db->res($value);
     }
     util_UtilFunctions::p($params);
     $validationArray = $this->validate($params);
     if (empty($validationArray) === FALSE) {
         $returnArray['result'] = FALSE;
         $returnArray['error'] = implode(' ', $validationArray);
     } else {
         // Check if we are adding a new Payment or updating an old one.
         if ((int) $payment_id > 0) {
             $query = '
                     UPDATE payment
                     SET 
                         date = ' . $this->db->quote(util_UtilFunctions::dateFormat($params['date'], 'sql')) . ',
                         paid_amount = ' . (double) $params['paid_amount'] . ',
                         bank_name = ' . $this->db->quote($params['bank_name']) . ',
                         extras = ' . $this->db->quote($params['extras']) . '
                     WHERE id = ' . (int) $payment_id . '
                             ';
         } else {
             $query = '
                 INSERT INTO payment (id, date, paid_amount, bank_name, extras)
                     VALUES (
                         DEFAULT,
                         ' . $this->db->quote(util_UtilFunctions::dateFormat($params['date'], 'sql')) . ',
                         ' . (double) $params['paid_amount'] . ',
                         ' . $this->db->quote($params['bank_name']) . ',
                         ' . $this->db->quote($params['extras']) . '
                     )';
         }
         $result = $this->db->query($query);
         $returnArray = array();
         $returnArray['result'] = $result;
         $returnArray['error'] = $this->db->error();
     }
     return $returnArray;
 }
コード例 #2
0
ファイル: Shipment.php プロジェクト: alsimfer/HomePage
 public function save($params, $shipment_id = 0)
 {
     $returnArray = array();
     // Adjust the params for the further DB usage.
     foreach ($params as $key => $value) {
         $params[$key] = $this->db->res($value);
     }
     $validationArray = $this->validate($params);
     if (empty($validationArray) === FALSE) {
         $returnArray['result'] = FALSE;
         $returnArray['error'] = implode(' ', $validationArray);
     } else {
         // Check if we are adding a new Customer or updating an old one.
         if ((int) $shipment_id > 0) {
             $query = '
             UPDATE shipment SET 
                     number = ' . $this->db->quote($params['number']) . ',
                     date = ' . $this->db->quote(util_UtilFunctions::dateFormat($params['date'], 'sql')) . ',  
                     transport_charge = ' . (double) $params['transport_charge'] . ',
                     extras = ' . $this->db->quote($params['extras']) . ' 
                 WHERE id = ' . (int) $shipment_id . '';
         } else {
             $query = '
             INSERT INTO shipment (id, number, date, transport_charge, extras)
                 VALUES (
                     DEFAULT,                        
                     ' . $this->db->quote($params['number']) . ',
                     ' . $this->db->quote(util_UtilFunctions::dateFormat($params['date'], 'sql')) . ',
                     ' . (double) $params['transport_charge'] . ',
                     ' . $this->db->quote($params['extras']) . '
                             
                 )';
         }
         $result = $this->db->query($query);
         $returnArray = array();
         $returnArray['result'] = $result;
         $returnArray['error'] = $this->db->error();
     }
     return $returnArray;
 }