/**
  * Test "Order"
  */
 public function testOrder()
 {
     // initialize the API client
     $order = new Order();
     $order->setStatus("placed");
     $this->assertSame("placed", $order->getStatus());
 }
 /**
  * @param Order $order
  * @return string
  */
 public function handleOrder(Order $order)
 {
     if ($order->getStatus() === $this->orderStatus) {
         return $this->sendNotification($order);
     } elseif (!is_null($this->followingOrderNotification)) {
         return $this->followingOrderNotification->handleOrder($order);
     }
     return '';
 }
예제 #3
0
 public function createOrder(Order $order)
 {
     $order->setId(null);
     $order->setStatus(Order::PENDING);
     $sql = '
         INSERT INTO orders_tb(id,user_id,business_id,order_date,status,order_details)
             VALUES (:id,:user_id,:business_id,:order_date,:status,:order_details)';
     $params = array(':id' => $order->getId(), ':user_id' => $_SESSION['user_id'], ':business_id' => $_POST['business']['id'], ':order_date' => self::formatDateTime($order->getDate()), 'status' => $order->getStatus(), 'order_details' => $order->getOrderDetails());
     return $this->execute($sql, $order, $params);
 }
예제 #4
0
 public static function canEditOrder(Order $order, Role $role)
 {
     $canAcessOrderByStatus = in_array($order->getStatus()->getId(), self::canAccessOrderStatusIds($role));
     switch ($role->getId()) {
         case Role::ID_STORE_MANAGER:
         case Role::ID_SYSTEM_ADMIN:
         case Role::ID_PURCHASING:
         case Role::ID_SALES:
             return $canAcessOrderByStatus;
         case Role::ID_ACCOUNTING:
             return $canAcessOrderByStatus && !$order->getPassPaymentCheck();
         case Role::ID_WAREHOUSE:
             return $canAcessOrderByStatus && $order->getPassPaymentCheck();
     }
 }
예제 #5
0
	<tr>
		<td><?php 
        echo $order['id'];
        ?>
</td>
		<td><?php 
        echo Helper::setDate(1, $order['date']);
        ?>
</td>
		<td class="ta_r">&pound;<?php 
        echo number_format($order['total'], 2);
        ?>
</td>
		<td class="ta_r">
		<?php 
        $status = $objOrder->getStatus($order['status']);
        echo $status['name'];
        ?>
		</td>
		<td class="ta_r">
		<?php 
        echo $order['payment_status'] != null ? $order['payment_status'] : "Pending";
        ?>
		</td>
		<td class="ta_r">
		<?php 
        if ($order['status'] == 1) {
            ?>
			<a href="/admin/?page=orders&amp;action=remove&amp;id=<?php 
            echo $order['id'];
            ?>
예제 #6
0
 private function getParams(Order $order)
 {
     $params = array(':id' => $order->getId(), ':status' => $order->getStatus(), ':assigned_to' => $order->getAssignedTo());
     return $params;
 }
예제 #7
0
		<?php 
    foreach ($rows as $row) {
        ?>
			
			<tr>
				<td><?php 
        echo $row['id'];
        ?>
</td>
				<td class="ta_r"><?php 
        echo Helper::setDate(1, $row['date']);
        ?>
</td>
				<td class="ta_r">
					<?php 
        $status = $objOrder->getStatus($row['status']);
        echo $status['name'];
        ?>
				</td>
				<td class="ta_r">
					&pound;<?php 
        echo number_format($row['total'], 2);
        ?>
				</td>
				<td class="ta_r">
					<?php 
        if ($row['pp_status'] == 1) {
            echo '<a href="/?page=invoice&amp;id=';
            echo $row['id'];
            echo '" target="_blank">Invoice</a>';
        } else {
예제 #8
0
 public static function changeOrderVolume(Order $order, $newVolume)
 {
     if ($order->getStatus() != OrderStatus::ACTIVE || $newVolume == $order->getVolume()) {
         return false;
     }
     $deal = new Deal();
     $deal->findActiveDealByOrderId($order->getId());
     $volumeDifference = $order->getVolume() - $newVolume;
     if ($deal->getVolume() < $volumeDifference) {
         return false;
     }
     $rate = new Rate();
     $rate->findById($order->getRateId());
     $purse = new Purse();
     if ($order->getType() == OrderType::BUY) {
         $purseSelect = Purse::findBy(array('UID' => $order->getUserId(), 'CurId' => $rate->getSecondCurrencyId()));
         $purse->findById($purseSelect[0]['id']);
         $difference = $order->getPrice() * $volumeDifference * (1.0 + $rate->getFee());
         $purse->addValue($difference);
     } else {
         $purseSelect = Purse::findBy(array('UID' => $order->getUserId(), 'CurId' => $rate->getFirstCurrencyId()));
         $purse->findById($purseSelect[0]['id']);
         $purse->addValue($volumeDifference);
     }
     if ($purse->getValue() < 0) {
         return false;
     }
     $purse->save();
     $deal->setDate(date("Y-m-d H:i:s"));
     $deal->setVolume($newVolume);
     $deal->save();
     $order->setVolume($newVolume);
     $order->updatePart();
     $order->save();
     return true;
 }
예제 #9
0
 /**
  *
  * @param Customer    $customer
  * @param string      $orderNo
  * @param OrderStatus $status
  * @param string      $orderDate
  * @param string      $type
  * @param string      $isFromB2B
  * @param Address     $shipAddr
  * @param Address     $billAddr
  */
 public static function create(Customer $customer, $type = self::TYPE_ORDER, $orderNo = null, $comments = '', OrderStatus $status = null, $orderDate = null, $isFromB2B = false, Address $shipAddr = null, Address $billAddr = null, $passPaymentCheck = false, $poNo = '', Order $cloneFrom = null)
 {
     $order = new Order();
     $order->setOrderNo(trim($orderNo))->setCustomer($customer)->setStatus($status instanceof OrderStatus ? $status : OrderStatus::get(OrderStatus::ID_NEW))->setOrderDate(trim($orderDate) === '' ? trim(new UDate()) : trim($orderDate))->setIsFromB2B($isFromB2B)->setType(trim($type) === '' ? self::TYPE_ORDER : trim($type))->setShippingAddr($shipAddr instanceof Address ? $shipAddr : $customer->getShippingAddress())->setBillingAddr($billAddr instanceof Address ? $billAddr : $customer->getBillingAddress())->setPassPaymentCheck($passPaymentCheck)->setPONo(trim($poNo));
     if ($cloneFrom instanceof Order) {
         $counts = intval(OrderInfo::countByCriteria('value = ? and typeId = ?', array($cloneFrom->getOrderNo(), OrderInfoType::ID_CLONED_FROM_ORDER_NO)));
         $newOrderNo = $cloneFrom->getOrderNo() . '-' . ($counts + 1);
         $order->setOrderNo($newOrderNo);
         $cloneFrom->addComment($msg = 'A new order has been clone from this order:' . $newOrderNo, Comments::TYPE_SYSTEM)->addLog($msg, Log::TYPE_SYSTEM);
     }
     $order->save();
     if ($cloneFrom instanceof Order) {
         $order->addInfo(OrderInfoType::ID_CLONED_FROM_ORDER_NO, $cloneFrom->getOrderNo(), true)->addComment($msg = 'Cloned from Order:' . $cloneFrom->getOrderNo(), Comments::TYPE_SYSTEM)->addLog($msg, Comments::TYPE_SYSTEM);
     }
     $order->addComment($comments, Comments::TYPE_NORMAL)->addInfo(OrderInfoType::ID_CUS_EMAIL, $customer->getEmail())->addInfo(OrderInfoType::ID_CUS_NAME, $customer->getName())->addLog('Order (OrderNo.=' . $order->getOrderNo() . ') created with status: ' . $order->getStatus()->getName(), Log::TYPE_SYSTEM, 'Auto Log', __CLASS__ . '::' . __FUNCTION__);
     return $order;
 }
예제 #10
0
    public function update(Order $order)
    {
        $id = intval($order->getId());
        $id_delivery = intval($order->getDelivery()->getId());
        $id_billing = intval($order->getBilling()->getId());
        $status = intval($order->getStatus());
        $price = floatval($order->getPrice());
        $date_update = date('Y-m-d H:i:s', strtotime($order->getDateUpdate()));
        $date_pay = date('Y-m-d H:i:s', strtotime($order->getDatePay()));
        $date_send = date('Y-m-d H:i:s', strtotime($order->getDateSend()));
        $date_reception = date('Y-m-d H:i:s', strtotime($order->getDateReception()));
        $query = '	UPDATE order
					SET id_delivery 	= ' . $id_delivery . ',
						id_billing 		= ' . $id_billing . ',
						status 			= ' . $status . ',
						price 			= ' . $price . ',
						date_update 	= ' . $date_update . ',
						date_pay 		= ' . $date_pay . ',
						date_send 		= ' . $date_send . ',
						date_reception 	= ' . $date_reception . '
						WHERE id 		= ' . $id;
        $res = $this->db->exec($query);
        if ($res) {
            return $this->readById($id);
        } else {
            throw new Exception('Internal server error');
        }
    }