Ejemplo n.º 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']);
     }
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 3
0
 public function getOrder()
 {
     $orders = array();
     $res = mysql_query("SELECT *,orders.id AS oid FROM orders INNER JOIN food ON orders.foods=food.id WHERE orders.user_id='" . $_SESSION['user'] . "'");
     while ($userRow = mysql_fetch_array($res)) {
         $order = new Order();
         $order->setId($userRow['oid']);
         $order->setFoodname($userRow['food']);
         $order->setTotal($userRow['total']);
         $order->setDtime($userRow['dtime']);
         $orders[] = $order;
     }
 }
Ejemplo n.º 4
0
 /**
  * @param  ItemDao $item_dao
  * @return void
  **/
 public function __construct(ItemDao $item_dao)
 {
     $fp = fopen(ROOT . '/data/AbstractFactory/order.csv', 'r');
     while ($data = fgetcsv($fp, 1000, ',')) {
         $order = new Order();
         $order->setId($data[0]);
         foreach (explode(',', $data[1]) as $item_id) {
             $item = $item_dao->findById($item_id);
             if (!is_null($item)) {
                 $order->addItem($item);
             }
         }
         $this->orders[$order->getId()] = $order;
     }
 }
Ejemplo n.º 5
0
 /**
  * Updates the Order status with parameter values from the GET request
  * @return  boolean             True on success, false on failure,
  *                              or null (on NOOP)
  * @todo    Should definitely use POST instead.
  */
 static function updateStatusFromGet()
 {
     global $objDatabase, $_ARRAYLANG;
     // Update the order status if valid
     if (!isset($_GET['changeOrderStatus']) || empty($_GET['order_id'])) {
         return null;
     }
     $status = intval($_GET['changeOrderStatus']);
     $order_id = intval($_GET['order_id']);
     if ($status < Order::STATUS_PENDING || $status >= Order::STATUS_MAX || $order_id <= 0) {
         \Message::error($_ARRAYLANG['TXT_SHOP_ORDER_ERROR_UPDATING_STATUS']);
         \Cx\Core\Csrf\Controller\Csrf::redirect('index.php?cmd=Shop&act=orders');
     }
     $objUser = \FWUser::getFWUserObject()->objUser;
     $oldStatus = $objDatabase->getOne('
         SELECT
             `status`
         FROM
             `' . DBPREFIX . 'module_shop' . MODULE_INDEX . '_orders`
         WHERE
             `id`=' . contrexx_input2int($order_id));
     $query = "\n            UPDATE `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_orders`\n               SET `status`={$status},\n                   `modified_by`='" . addslashes($objUser->getUsername()) . "',\n                   `modified_on`='" . date('Y-m-d H:i:s') . "'\n             WHERE `id`={$order_id}";
     if (!$objDatabase->Execute($query)) {
         \Message::error($_ARRAYLANG['TXT_SHOP_ORDER_ERROR_UPDATING_STATUS']);
         \Cx\Core\Csrf\Controller\Csrf::redirect('index.php?cmd=Shop&act=orders');
     }
     $order = new Order();
     $order->setId($order_id);
     if (!empty($_GET['stock_update']) && $_GET['stock_update'] == 1 && ($order->isStockIncreasable($oldStatus, $status) || $order->isStockDecreasable($oldStatus, $status))) {
         $order->updateStock($order->isStockIncreasable($oldStatus, $status));
     }
     // Send an email to the customer
     if (!empty($_GET['sendMail']) && !empty($_GET['order_id'])) {
         // TODO: It might be useful to move this to its own method:
         $hasMail = false;
         $result = null;
         switch ($status) {
             case Order::STATUS_CONFIRMED:
                 $result = ShopLibrary::sendConfirmationMail($_GET['order_id']);
                 $hasMail = true;
                 break;
             case Order::STATUS_COMPLETED:
                 $result = ShopManager::sendProcessedMail($_GET['order_id']);
                 $hasMail = true;
                 break;
         }
         if ($hasMail) {
             if (!empty($result)) {
                 \Message::ok(sprintf($_ARRAYLANG['TXT_EMAIL_SEND_SUCCESSFULLY'], $result));
             } else {
                 \Message::error($_ARRAYLANG['TXT_MESSAGE_SEND_ERROR']);
             }
         }
     }
     \Cx\Core\Csrf\Controller\Csrf::redirect('index.php?cmd=Shop&act=orders');
 }
Ejemplo n.º 6
0
 function testInsertOrderViaExtendParameterMap()
 {
     $this->sqlmap->getSqlMapManager()->getTypeHandlers()->registerTypeHandler(new HundredsBool());
     $account = $this->newAccount6();
     $this->sqlmap->insert("InsertAccountViaParameterMap", $account);
     $order = new Order();
     $order->setId(99);
     $order->setCardExpiry("09/11");
     $order->setAccount($account);
     $order->setCardNumber("154564656");
     $order->setCardType("Visa");
     $order->setCity("Lyon");
     $order->setDate(null);
     //<-- null replacement
     $order->setPostalCode("69004");
     $order->setProvince("Rhone");
     $order->setStreet("rue Durand");
     $this->sqlmap->insert("InsertOrderViaExtendParameterMap", $order);
     $orderTest = $this->sqlmap->queryForObject("GetOrderLiteByColumnName", 99);
     $this->assertSame($order->getCity(), $orderTest->getCity());
 }
Ejemplo n.º 7
0
 /**
  *
  */
 function testInsertOrderViaProperties()
 {
     $this->initScript('account-init.sql');
     $this->initScript('order-init.sql');
     $account = $this->NewAccount6();
     $this->sqlmap->Insert("InsertAccountViaParameterMap", $account);
     $order = new Order();
     $order->setId(99);
     $order->setCardExpiry("09/11");
     $order->setAccount($account);
     $order->setCardNumber("154564656");
     $order->setCardType("Visa");
     $order->setCity("Lyon");
     $order->setDate('2005-05-20');
     $order->setPostalCode("69004");
     $order->setProvince("Rhone");
     $order->setStreet("rue Durand");
     $this->sqlmap->Insert("InsertOrderViaPublicFields", $order);
     $this->initScript('account-init.sql');
     $this->initScript('order-init.sql');
 }
Ejemplo n.º 8
0
<?php

include '../include/header2.php';
include '../model/processorder.php';
$processorder = new Processorder();
if (isset($_GET['delete'])) {
    $order = new Order();
    $order->setId($_GET['delete']);
    $processorder->deleteOrder($order);
}
?>
	
	<section id="cart_items">
		<div class="container">
			<div class="breadcrumbs">
				<ol class="breadcrumb">
				  <li><a href="index.php">Home</a></li>
				  <li class="active">My Orders</li>
				</ol>
			</div>
			<?php 
if ($msg_register == 1) {
    ?>
							<div class="alert alert-success">
							  <strong>Success!</strong> Order deleted successfully.
							</div>
						<?php 
} else {
    if ($msg_register == 2) {
        ?>
							<div class="alert alert-danger">