예제 #1
0
 public static function map(Order $order, array $properties)
 {
     if (array_key_exists('id', $properties)) {
         $order->setId($properties['id']);
     }
     if (array_key_exists('user_id', $properties)) {
         $order->setUserId($properties['user_id']);
     }
     if (array_key_exists('business_id', $properties)) {
         $order->setBusinessId($properties['business_id']);
     }
     if (array_key_exists('order_date', $properties)) {
         $formattedDate = $properties['order_date'];
         $orderDate = self::createDateTime($formattedDate);
         if ($orderDate) {
             $order->setDate($orderDate);
         }
     }
     if (array_key_exists('status', $properties)) {
         $order->setStatus($properties['status']);
     }
     if (array_key_exists('assigned_to', $properties)) {
         $order->setAssignedTo($properties['assigned_to']);
     }
     if (array_key_exists('order_details', $properties)) {
         $order->setOrderDetails($properties['order_details']);
     }
 }
예제 #2
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);
 }
예제 #3
0
 /**
  * @param $orderID
  * @return Order
  */
 public function getOrder($orderID)
 {
     APIWrapper::verifyReadiness();
     $requestURL = "https://app.fetchapp.com/api/v2/orders/" . $orderID;
     $results = APIWrapper::makeRequest($requestURL, "GET");
     if (is_a($results, "SimpleXMLElement")) {
         $tempOrder = new Order();
         $tempOrder->setOrderID($results->id);
         $tempOrder->setVendorID($results->vendor_id);
         $tempOrder->setFirstName($results->first_name);
         $tempOrder->setLastName($results->last_name);
         $tempOrder->setEmailAddress($results->email);
         $tempOrder->setTotal($results->total);
         $tempOrder->setCurrency(Currency::getValue($results->currency));
         $tempOrder->setStatus(OrderStatus::getValue($results->status));
         $tempOrder->setProductCount($results->product_count);
         $tempOrder->setDownloadCount($results->download_count);
         $tempOrder->setExpirationDate(new \DateTime($results->expiration_date));
         $tempOrder->setDownloadLimit($results->download_limit);
         if (!isset($results->custom1['nil'])) {
             $tempOrder->setCustom1($results->custom1);
         } else {
             $tempOrder->setCustom1(null);
         }
         if (!isset($results->custom2['nil'])) {
             $tempOrder->setCustom2($results->custom2);
         } else {
             $tempOrder->setCustom2(null);
         }
         if (!isset($results->custom3['nil'])) {
             $tempOrder->setCustom3($results->custom3);
         } else {
             $tempOrder->setCustom3(null);
         }
         $tempOrder->setCreationDate(new \DateTime($results->created_at));
         $tempOrder->setLink($results->link['href']);
     }
     return $tempOrder;
 }
 /**
  * @expectedException InvalidArgumentException
  */
 public function testOrderException()
 {
     // initialize the API client
     $order = new Order();
     $order->setStatus("invalid_value");
 }
예제 #5
0
$SortName = "";
$SortType = true;
$filterOrd = new Order();
if (isset($_POST['OrderID']) & !empty($_POST['OrderID'])) {
    $filterOrd->setOrderID($_POST['OrderID']);
}
if (isset($_POST['UserID']) & !empty($_POST['UserID'])) {
    require_once "../entities/User.php";
    $filterOrd->setUser(new User($_POST['UserID']));
}
if (isset($_POST['Total']) & !empty($_POST['Total'])) {
    $filterOrd->setTotal($_POST['Total']);
}
if (isset($_POST['Status']) & !empty($_POST['Status'])) {
    require_once "../entities/Status.php";
    $filterOrd->setStatus(new Status($_POST['Status']));
}
if (isset($_POST['SortName']) & !empty($_POST['SortName'])) {
    $SortName = $_POST['SortName'];
}
if (isset($_POST['SortType']) & !empty($_POST['SortType'])) {
    $SortType = $_POST['SortType'];
}
$numberOfRows = $filterOrd->countRecords();
// Số lượng dòng của bảng
$ListOrders = array();
if ($rowsPerPage == -1) {
    // nếu là chọn hiển thị là ALL
    $rowsPerPage = $numberOfRows;
    $ListOrders = $filterOrd->loadLimit($rowsPerPage, 0, $SortName, $SortType);
} else {
예제 #6
0
파일: orders.php 프로젝트: luvyatyss/nashop
 $page->addJavascript("assets/js/sweetalert/sweetalert.min.js");
 $page->addJavascript("assets/js/jRange-master/jquery.range.js");
 $page->startBody();
 $update = null;
 $control = new Controls(Controls::Insert);
 //Chưa chọn loại sản phẩm;
 $Order = new Order();
 $maxTotal = Order::getValueMaxColName('Total');
 $maxTotal = empty($maxTotal) ? 0 : ceil($maxTotal / 1000000);
 // /1 triệu đồng
 if (isset($_POST["btnSave"])) {
     if (isset($_POST["txtOrderID"])) {
         $Order->setOrderID($_POST["txtOrderID"]);
     }
     if (isset($_POST["cboStatus"])) {
         $Order->setStatus(new Status($_POST["cboStatus"]));
     }
     $Order->update();
     $update = true;
 } else {
     if (isset($_GET["OrderID"]) && isset($_GET["control"])) {
         $Order = Order::getOrder($_GET["OrderID"]);
         if ($Order != null) {
             echo "<script> \$(function () { \$(window).load(function(){ \$('#modalOrder').modal( { backdrop: 'static', keyboard: false }, 'show');});  });</script>";
         } else {
             require_once '../helper/Utils.php';
             $url = "orders.php";
             Utils::Redirect($url);
         }
     }
 }
예제 #7
0
파일: EComm.php 프로젝트: anas/feedstore
 public function completeOrder($tid)
 {
     $transaction = Transaction::getTransactionBasedOnTID($tid);
     $user = new User($transaction->getUser());
     $order = new Order();
     $order->setTid($transaction->getTid());
     $order->setUser($transaction->getUser());
     $order->setCustomerName($user->getName());
     $order->setUserEmail($user->getEmail());
     $order->setPhone($transaction->getPhone());
     $order->setShippingStreet($transaction->getShippingStreet());
     $order->setShippingCity($transaction->getShippingCity());
     $order->setShippingPostal($transaction->getShippingPostal());
     $order->setShippingProvince($transaction->getShippingProvince());
     $order->setShippingCountry($transaction->getShippingCountry());
     $order->setBillingStreet($transaction->getBillingStreet());
     $order->setBillingCity($transaction->getBillingCity());
     $order->setBillingPostal($transaction->getBillingPostal());
     $order->setBillingProvince($transaction->getBillingProvince());
     $order->setBillingCountry($transaction->getBillingCountry());
     $order->setCostSubtotal($transaction->getCostSubtotal());
     $order->setCostTax($transaction->getCostTax());
     $order->setCostShipping($transaction->getCostShipping());
     $order->setCostTotal($transaction->getCostTotal());
     $order->setIp($transaction->getIp());
     $order->setShippingClass($transaction->getShippingClass());
     $order->setPaymentClass($transaction->getPaymentClass());
     $order->setDeliveryInstructions($transaction->getDeliveryInstructions());
     $order->setStatus('Pending');
     $order->save();
     $cartItems = CartItem::getAll($transaction->getSession());
     foreach ($cartItems as $cartItem) {
         $product = new Product($cartItem->getProduct());
         $orderDetail = new OrderDetail();
         $orderDetail->setOrderNb($order->getId());
         $orderDetail->setProduct($product->getId());
         $orderDetail->setProductName($product->getName());
         $orderDetail->setQuantity($cartItem->getQuantity());
         $orderDetail->save();
         $cartItem->delete();
     }
     $transaction->delete();
     //Send an email to the user
     $this->sendEmailOrderComplete($order->getId());
     return true;
 }
예제 #8
0
 private static function makeDealsWith(Deal $deal)
 {
     $order = new Order();
     $order->findById($deal->getOrderId());
     if ($order->getType() == OrderType::SELL) {
         $oppositeDeals = Deal::getOpenedBuyDeals($order->getPrice(), $order->getRateId());
     } else {
         $oppositeDeals = Deal::getOpenedSellDeals($order->getPrice(), $order->getRateId());
     }
     foreach ($oppositeDeals as $oppDeal) {
         $oppositeDeal = new Deal();
         $oppositeDeal->findById($oppDeal['id']);
         $oppositeOrder = new Order();
         $oppositeOrder->findById($oppositeDeal->getOrderId());
         $difference = $deal->getVolume() - $oppositeDeal->getVolume();
         if ($difference == 0) {
             $deal->setPrice($oppositeDeal->getPrice());
             $deal->setDone(1);
             $deal->save();
             $order->setPart(1.0);
             $order->setStatus(OrderStatus::DONE);
             $order->save();
             $oppositeDeal->setDone(1);
             $oppositeDeal->setDate($deal->getDate());
             $oppositeDeal->save();
             $oppositeOrder->setPart(1.0);
             $oppositeOrder->setStatus(OrderStatus::DONE);
             $oppositeOrder->setDate($deal->getDate());
             $oppositeOrder->save();
             self::transferMoney($deal, $oppositeDeal);
             break;
         }
         $intermediateDeal = new Deal();
         $intermediateDeal->setRateId($order->getRateId());
         $intermediateDeal->setDate($deal->getDate());
         $intermediateDeal->setDone(1);
         if ($difference < 0) {
             $deal->setPrice($oppositeDeal->getPrice());
             $deal->setDone(1);
             $deal->save();
             $order->setPart(1.0);
             $order->setStatus(OrderStatus::DONE);
             $order->save();
             $intermediateDeal->setOrderId($oppositeOrder->getId());
             $intermediateDeal->setUserId($oppositeOrder->getUserId());
             $intermediateDeal->setType($oppositeOrder->getType());
             $intermediateDeal->setPrice($oppositeDeal->getPrice());
             $intermediateDeal->setVolume($deal->getVolume());
             $intermediateDeal->insert();
             $oppositeOrder->updatePart();
             $oppositeOrder->setDate($deal->getDate());
             $oppositeOrder->save();
             $oppositeDeal->setVolume(-$difference);
             $oppositeDeal->setDate($deal->getDate());
             $oppositeDeal->save();
             self::transferMoney($deal, $intermediateDeal);
             break;
         } else {
             $deal->setVolume($difference);
             $deal->save();
             $intermediateDeal->setOrderId($order->getId());
             $intermediateDeal->setUserId($order->getUserId());
             $intermediateDeal->setType($order->getType());
             $intermediateDeal->setPrice($oppositeDeal->getPrice());
             $intermediateDeal->setVolume($oppositeDeal->getVolume());
             $intermediateDeal->insert();
             $order->updatePart();
             $order->save();
             $oppositeDeal->setDone(1);
             $oppositeDeal->setDate($deal->getDate());
             $oppositeDeal->save();
             $oppositeOrder->setPart(1.0);
             $oppositeOrder->setStatus(OrderStatus::DONE);
             $oppositeOrder->setDate($deal->getDate());
             $oppositeOrder->save();
             self::transferMoney($intermediateDeal, $oppositeDeal);
         }
     }
 }