예제 #1
0
 /**
  * addpayment
  * Add a payment information to a order
  * @param integer $orderid
  * @param string $transactionid
  * @param integer $bankid
  * @param boolean $status
  * @param float $amount
  */
 public static function addpayment($orderid, $transactionid, $bankid, $status, $amount, $paymentdate = null, $customer_id = null, $payment_description = null)
 {
     $payment = new Payments();
     // We make a double check to properly manage "null" output coming from Shineisp_Commons_Utilities::formatDateIn
     if (!empty($paymentdate)) {
         $paymentdate = Shineisp_Commons_Utilities::formatDateIn($paymentdate);
     }
     $paymentdate = !empty($paymentdate) ? $paymentdate : date('Y-m-d H:i:s');
     // Set the payment data
     $payment->order_id = $orderid;
     $payment->bank_id = $bankid;
     $payment->reference = $transactionid;
     $payment->confirmed = 0;
     $payment->income = $amount;
     // Additional fields for Orders::saveAll()
     $payment->paymentdate = $paymentdate;
     $payment->customer_id = isset($customer_id) ? intval($customer_id) : intval(Orders::getCustomer($orderid));
     $payment->description = isset($payment_description) ? $payment_description : null;
     $save = $payment->trySave();
     if ($save) {
         Shineisp_Commons_Utilities::logs("Payments::addPayment(): save ok");
         // Confirm payment, if needed. Invoices::confirm() will activate order.
         if ($status) {
             self::confirm($orderid, $status);
         }
     }
     return $save;
 }