예제 #1
0
 public function upgradeLicense()
 {
     $upgrade_app = new Application($this->application->upgrade_app_id);
     if ($upgrade_app->ok()) {
         $o = new Order();
         $o->app_id = $upgrade_app->id;
         $o->dt = dater();
         $o->first_name = $this->order->first_name;
         $o->last_name = $this->order->last_name;
         $o->payer_email = $this->order->payer_email;
         $o->notes = "Upgrade via Shine";
         $o->type = 'Upgrade';
         $o->insert();
         $o->generateLicense();
         return $o;
     }
     return null;
 }
예제 #2
0
 public static function createOrder($userId, Rate $rate, $type, $volume, $price)
 {
     $order = new Order();
     $order->setUserId($userId);
     $order->setRateId($rate->getId());
     $order->setType($type);
     $order->setPrice($price);
     $order->setVolume($volume);
     $order->setDate(date("Y-m-d H:i:s"));
     $order->insert();
     if (!self::takePrepayment($order, $rate)) {
         self::$errorMessage = 'You do not have funds';
         return false;
     }
     $deal = self::createDealForOrder($order);
     self::makeDealsWith($deal);
     self::refreshRatePrices($rate);
     return $order->getId();
 }
예제 #3
0
 foreach ($order->meals as $orderMeal) {
     $n = $orderMeal['Count'];
     $v = $orderMeal['VegCount'];
     $itemID = $orderMeal['Meal']->ItemID;
     $menuID = $orderMeal['Meal']->MenuID;
     if ($menuID == '3') {
         $order_weekend->add_meal($itemID, (int) $n, (int) $v, '0');
     } else {
         $order_weekday->add_meal($itemID, (int) $n, (int) $v, '0');
     }
 }
 # Insert the orders
 if (empty($order_weekday->meals)) {
     # No weekday meals, give weekend the full cost
     $order_weekend->Amounts->Total = $order->Amounts->Total;
     $order_weekend->insert();
     $orderID = $order_weekend->OrderID;
 } else {
     if (empty($order_weekend->meals)) {
         # No weekend meals, give weekday the full cost
         $order_weekday->Amounts->Total = $order->Amounts->Total;
         $order_weekday->insert();
         $orderID = $order_weekday->OrderID;
     } else {
         # Neither are empty, give weekday the full cost and weekend zero
         $order_weekday->Amounts->Total = $order->Amounts->Total;
         $order_weekday->insert();
         $order_weekend->Amounts->Total = new Amount(0);
         $order_weekend->insert();
         $orderID = $order_weekday->OrderID;
     }
예제 #4
0
파일: mupromo.php 프로젝트: adib/Shine
if (empty($_POST['last_name']) || empty($_POST['first_name']) || empty($_POST['payment_gross']) || empty($_POST['transaction_id'])) {
    header("HTTP/1.1 400 Missing parameter");
    error_log("Incomplete POST variables – exiting.");
    exit;
}
//
$app = new Application();
$app->select(7);
if (!$app->ok()) {
    header("HTTP/1.1 400 Missing parameter");
    error_log("Application not found!");
    exit;
}
//
$o = new Order();
$o->app_id = $app->id;
$o->item_name = $app->name;
$o->dt = dater();
$o->type = 'MUPromo';
$o->first_name = $_POST['first_name'];
$o->last_name = $_POST['last_name'];
$o->payer_email = $_POST['email'];
$o->txn_id = $_POST['transaction_id'];
$o->payment_gross = preg_replace('/[^0-9.]/', '', $_POST['payment_gross']);
// custom
$o->insert();
$o->generateLicense();
//$o->emailLicense();
// return the URL
header('Content-type: text/plain', TRUE);
echo "http://updates.basil-salad.com/shine/order-retrieve.php?order_id=" . urlencode($o->id) . "&email=" . urlencode($o->payer_email) . "\n";
예제 #5
0
 /**
  * Processes the Order
  *
  * Verifies all data, updates and stores it in the database, and
  * initializes payment
  * @return  boolean         True on successs, false otherwise
  */
 static function process()
 {
     global $objDatabase, $_ARRAYLANG;
     // FOR TESTING ONLY (repeatedly process/store the order, also disable self::destroyCart())
     //$_SESSION['shop']['order_id'] = NULL;
     // Verify that the order hasn't yet been saved
     // (and has thus not yet been confirmed)
     if (isset($_SESSION['shop']['order_id'])) {
         return \Message::error($_ARRAYLANG['TXT_ORDER_ALREADY_PLACED']);
     }
     // No more confirmation
     self::$objTemplate->hideBlock('shopConfirm');
     // Store the customer, register the order
     $customer_ip = $_SERVER['REMOTE_ADDR'];
     $customer_host = substr(@gethostbyaddr($_SERVER['REMOTE_ADDR']), 0, 100);
     $customer_browser = substr(getenv('HTTP_USER_AGENT'), 0, 100);
     $new_customer = false;
     //\DBG::log("Shop::process(): E-Mail: ".$_SESSION['shop']['email']);
     if (self::$objCustomer) {
         //\DBG::log("Shop::process(): Existing User username ".$_SESSION['shop']['username'].", email ".$_SESSION['shop']['email']);
     } else {
         // Registered Customers are required to be logged in!
         self::$objCustomer = Customer::getRegisteredByEmail($_SESSION['shop']['email']);
         if (self::$objCustomer) {
             \Message::error($_ARRAYLANG['TXT_SHOP_CUSTOMER_REGISTERED_EMAIL']);
             \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'login') . '?redirect=' . base64_encode(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'confirm')));
         }
         // Unregistered Customers are stored as well, as their information is needed
         // nevertheless.  Their active status, however, is set to false.
         self::$objCustomer = Customer::getUnregisteredByEmail($_SESSION['shop']['email']);
         if (!self::$objCustomer) {
             self::$objCustomer = new Customer();
             // Currently, the e-mail address is set as the user name
             $_SESSION['shop']['username'] = $_SESSION['shop']['email'];
             //\DBG::log("Shop::process(): New User username ".$_SESSION['shop']['username'].", email ".$_SESSION['shop']['email']);
             self::$objCustomer->username($_SESSION['shop']['username']);
             self::$objCustomer->email($_SESSION['shop']['email']);
             // Note that the password is unset when the Customer chooses
             // to order without registration.  The generated one
             // defaults to length 8, fulfilling the requirements for
             // complex passwords.  And it's kept absolutely secret.
             $password = empty($_SESSION['shop']['password']) ? \User::make_password() : $_SESSION['shop']['password'];
             //\DBG::log("Password: $password (session: {$_SESSION['shop']['password']})");
             if (!self::$objCustomer->password($password)) {
                 \Message::error($_ARRAYLANG['TXT_INVALID_PASSWORD']);
                 \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'account'));
             }
             self::$objCustomer->active(empty($_SESSION['shop']['dont_register']));
             $new_customer = true;
         }
     }
     // Update the Customer object from the session array
     // (whether new or not -- it may have been edited)
     self::$objCustomer->gender($_SESSION['shop']['gender']);
     self::$objCustomer->firstname($_SESSION['shop']['firstname']);
     self::$objCustomer->lastname($_SESSION['shop']['lastname']);
     self::$objCustomer->company($_SESSION['shop']['company']);
     self::$objCustomer->address($_SESSION['shop']['address']);
     self::$objCustomer->city($_SESSION['shop']['city']);
     self::$objCustomer->zip($_SESSION['shop']['zip']);
     self::$objCustomer->country_id($_SESSION['shop']['countryId']);
     self::$objCustomer->phone($_SESSION['shop']['phone']);
     self::$objCustomer->fax($_SESSION['shop']['fax']);
     $arrGroups = self::$objCustomer->getAssociatedGroupIds();
     $usergroup_id = \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_reseller', 'Shop');
     if (empty($usergroup_id)) {
         //\DBG::log("Shop::process(): ERROR: Missing reseller group");
         \Message::error($_ARRAYLANG['TXT_SHOP_ERROR_USERGROUP_INVALID']);
         \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', ''));
     }
     if (!in_array($usergroup_id, $arrGroups)) {
         //\DBG::log("Shop::process(): Customer is not in Reseller group (ID $usergroup_id)");
         // Not a reseller.  See if she's a final customer
         $usergroup_id = \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_customer', 'Shop');
         if (empty($usergroup_id)) {
             //\DBG::log("Shop::process(): ERROR: Missing final customer group");
             \Message::error($_ARRAYLANG['TXT_SHOP_ERROR_USERGROUP_INVALID']);
             \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', ''));
         }
         if (!in_array($usergroup_id, $arrGroups)) {
             //\DBG::log("Shop::process(): Customer is not in final customer group (ID $usergroup_id), either");
             // Neither one, add to the final customer group (default)
             $arrGroups[] = $usergroup_id;
             self::$objCustomer->setGroups($arrGroups);
             //\DBG::log("Shop::process(): Added Customer to final customer group (ID $usergroup_id): ".var_export(self::$objCustomer->getAssociatedGroupIds(), true));
         } else {
             //\DBG::log("Shop::process(): Customer is a final customer (ID $usergroup_id) already: ".var_export(self::$objCustomer->getAssociatedGroupIds(), true));
         }
     } else {
         //\DBG::log("Shop::process(): Customer is a Reseller (ID $usergroup_id) already: ".var_export(self::$objCustomer->getAssociatedGroupIds(), true));
     }
     // Insert or update the customer
     //\DBG::log("Shop::process(): Storing Customer: ".var_export(self::$objCustomer, true));
     if (!self::$objCustomer->store()) {
         return \Message::error($_ARRAYLANG['TXT_SHOP_CUSTOMER_ERROR_STORING']);
     }
     // Authenticate new Customer
     if ($new_customer) {
         // Fails for "unregistered" Customers!
         if (self::$objCustomer->auth($_SESSION['shop']['username'], $_SESSION['shop']['password'], false, true)) {
             if (!self::_authenticate()) {
                 return \Message::error($_ARRAYLANG['TXT_SHOP_CUSTOMER_ERROR_STORING']);
             }
         }
     }
     //die();
     // Clear the ship-to country if there is no shipping
     if (!Cart::needs_shipment()) {
         $_SESSION['shop']['countryId2'] = 0;
     }
     $shipper_id = empty($_SESSION['shop']['shipperId']) ? null : $_SESSION['shop']['shipperId'];
     $payment_id = empty($_SESSION['shop']['paymentId']) ? null : $_SESSION['shop']['paymentId'];
     $objOrder = new Order();
     $objOrder->customer_id(self::$objCustomer->id());
     $objOrder->billing_gender($_SESSION['shop']['gender']);
     $objOrder->billing_firstname($_SESSION['shop']['firstname']);
     $objOrder->billing_lastname($_SESSION['shop']['lastname']);
     $objOrder->billing_company($_SESSION['shop']['company']);
     $objOrder->billing_address($_SESSION['shop']['address']);
     $objOrder->billing_city($_SESSION['shop']['city']);
     $objOrder->billing_zip($_SESSION['shop']['zip']);
     $objOrder->billing_country_id($_SESSION['shop']['countryId']);
     $objOrder->billing_phone($_SESSION['shop']['phone']);
     $objOrder->billing_fax($_SESSION['shop']['fax']);
     $objOrder->billing_email($_SESSION['shop']['email']);
     $objOrder->currency_id($_SESSION['shop']['currencyId']);
     $objOrder->sum($_SESSION['shop']['grand_total_price']);
     $objOrder->date_time(date(ASCMS_DATE_FORMAT_INTERNATIONAL_DATETIME));
     $objOrder->status(0);
     $objOrder->company($_SESSION['shop']['company2']);
     $objOrder->gender($_SESSION['shop']['gender2']);
     $objOrder->firstname($_SESSION['shop']['firstname2']);
     $objOrder->lastname($_SESSION['shop']['lastname2']);
     $objOrder->address($_SESSION['shop']['address2']);
     $objOrder->city($_SESSION['shop']['city2']);
     $objOrder->zip($_SESSION['shop']['zip2']);
     $objOrder->country_id($_SESSION['shop']['countryId2']);
     $objOrder->phone($_SESSION['shop']['phone2']);
     $objOrder->vat_amount($_SESSION['shop']['vat_price']);
     $objOrder->shipment_amount($_SESSION['shop']['shipment_price']);
     $objOrder->shipment_id($shipper_id);
     $objOrder->payment_id($payment_id);
     $objOrder->payment_amount($_SESSION['shop']['payment_price']);
     $objOrder->ip($customer_ip);
     $objOrder->host($customer_host);
     $objOrder->lang_id(FRONTEND_LANG_ID);
     $objOrder->browser($customer_browser);
     $objOrder->note($_SESSION['shop']['note']);
     if (!$objOrder->insert()) {
         // $order_id is unset!
         return \Message::error($_ARRAYLANG['TXT_SHOP_ORDER_ERROR_STORING']);
     }
     $order_id = $objOrder->id();
     $_SESSION['shop']['order_id'] = $order_id;
     // The products will be tested one by one below.
     // If any single one of them requires delivery, this
     // flag will be set to true.
     // This is used to determine the order status at the
     // end of the shopping process.
     $_SESSION['shop']['isDelivery'] = false;
     // Try to redeem the Coupon, if any
     $coupon_code = isset($_SESSION['shop']['coupon_code']) ? $_SESSION['shop']['coupon_code'] : null;
     //\DBG::log("Cart::update(): Coupon Code: $coupon_code");
     $items_total = 0;
     // Suppress Coupon messages (see Coupon::available())
     \Message::save();
     foreach (Cart::get_products_array() as $arrProduct) {
         $objProduct = Product::getById($arrProduct['id']);
         if (!$objProduct) {
             unset($_SESSION['shop']['order_id']);
             return \Message::error($_ARRAYLANG['TXT_ERROR_LOOKING_UP_ORDER']);
         }
         $product_id = $arrProduct['id'];
         $name = $objProduct->name();
         $priceOptions = !empty($arrProduct['optionPrice']) ? $arrProduct['optionPrice'] : 0;
         $quantity = $arrProduct['quantity'];
         $price = $objProduct->get_custom_price(self::$objCustomer, $priceOptions, $quantity);
         $item_total = $price * $quantity;
         $items_total += $item_total;
         $productVatId = $objProduct->vat_id();
         $vat_rate = $productVatId && Vat::getRate($productVatId) ? Vat::getRate($productVatId) : '0.00';
         // Test the distribution method for delivery
         $productDistribution = $objProduct->distribution();
         if ($productDistribution == 'delivery') {
             $_SESSION['shop']['isDelivery'] = true;
         }
         $weight = $productDistribution == 'delivery' ? $objProduct->weight() : 0;
         // grams
         if ($weight == '') {
             $weight = 0;
         }
         // Add to order items table
         $result = $objOrder->insertItem($order_id, $product_id, $name, $price, $quantity, $vat_rate, $weight, $arrProduct['options']);
         if (!$result) {
             unset($_SESSION['shop']['order_id']);
             // TODO: Verify error message set by Order::insertItem()
             return false;
         }
         // Store the Product Coupon, if applicable.
         // Note that it is not redeemed yet (uses=0)!
         if ($coupon_code) {
             $objCoupon = Coupon::available($coupon_code, $item_total, self::$objCustomer->id(), $product_id, $payment_id);
             if ($objCoupon) {
                 //\DBG::log("Shop::process(): Got Coupon for Product ID $product_id: ".var_export($objCoupon, true));
                 if (!$objCoupon->redeem($order_id, self::$objCustomer->id(), $price * $quantity, 0)) {
                     // TODO: Do something if the Coupon does not work
                     \DBG::log("Shop::process(): ERROR: Failed to store Coupon for Product ID {$product_id}");
                 }
                 $coupon_code = null;
             }
         }
     }
     // foreach product in cart
     // Store the Global Coupon, if applicable.
     // Note that it is not redeemed yet (uses=0)!
     //\DBG::log("Shop::process(): Looking for global Coupon $coupon_code");
     if ($coupon_code) {
         $objCoupon = Coupon::available($coupon_code, $items_total, self::$objCustomer->id(), null, $payment_id);
         if ($objCoupon) {
             //\DBG::log("Shop::process(): Got global Coupon: ".var_export($objCoupon, true));
             if (!$objCoupon->redeem($order_id, self::$objCustomer->id(), $items_total, 0)) {
                 \DBG::log("Shop::process(): ERROR: Failed to store global Coupon");
             }
         }
     }
     \Message::restore();
     $processor_id = Payment::getProperty($_SESSION['shop']['paymentId'], 'processor_id');
     $processor_name = PaymentProcessing::getPaymentProcessorName($processor_id);
     // other payment methods
     PaymentProcessing::initProcessor($processor_id);
     // TODO: These arguments are no longer valid.  Set them up later?
     //            Currency::getActiveCurrencyCode(),
     //            FWLanguage::getLanguageParameter(FRONTEND_LANG_ID, 'lang'));
     // if the processor is Internal_LSV, and there is account information,
     // store the information.
     if ($processor_name == 'internal_lsv') {
         if (!self::lsv_complete()) {
             // Missing mandatory data; return to payment
             unset($_SESSION['shop']['order_id']);
             \Message::error($_ARRAYLANG['TXT_ERROR_ACCOUNT_INFORMATION_NOT_AVAILABLE']);
             \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'payment'));
         }
         $query = "\n                INSERT INTO " . DBPREFIX . "module_shop" . MODULE_INDEX . "_lsv (\n                    order_id, holder, bank, blz\n                ) VALUES (\n                    {$order_id},\n                    '" . contrexx_raw2db($_SESSION['shop']['account_holder']) . "',\n                    '" . contrexx_raw2db($_SESSION['shop']['account_bank']) . "',\n                    '" . contrexx_raw2db($_SESSION['shop']['account_blz']) . "'\n                )";
         $objResult = $objDatabase->Execute($query);
         if (!$objResult) {
             // Return to payment
             unset($_SESSION['shop']['order_id']);
             \Message::error($_ARRAYLANG['TXT_ERROR_INSERTING_ACCOUNT_INFORMATION']);
             \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'payment'));
         }
     }
     $_SESSION['shop']['order_id_checkin'] = $order_id;
     $strProcessorType = PaymentProcessing::getCurrentPaymentProcessorType();
     // Test whether the selected payment method can be
     // considered an instant or deferred one.
     // This is used to set the order status at the end
     // of the shopping process.
     // TODO: Invert this flag, as it may no longer be present after paying
     // online using one of the external payment methods!  Ensure that it is set
     // instead when paying "deferred".
     $_SESSION['shop']['isInstantPayment'] = false;
     if ($strProcessorType == 'external') {
         // For the sake of simplicity, all external payment
         // methods are considered to be 'instant'.
         // All currently implemented internal methods require
         // further action from the merchant, and thus are
         // considered to be 'deferred'.
         $_SESSION['shop']['isInstantPayment'] = true;
     }
     // Send the Customer login separately, as the password possibly
     // won't be available later
     if (!empty($_SESSION['shop']['password'])) {
         self::sendLogin(self::$objCustomer->email(), $_SESSION['shop']['password']);
     }
     // Show payment processing page.
     // Note that some internal payments are redirected away
     // from this page in checkOut():
     // 'internal', 'internal_lsv'
     self::$objTemplate->setVariable('SHOP_PAYMENT_PROCESSING', PaymentProcessing::checkOut());
     // Clear the order ID.
     // The order may be resubmitted and the payment retried.
     unset($_SESSION['shop']['order_id']);
     // Custom.
     // Enable if Discount class is customized and in use.
     //self::showCustomerDiscount(Cart::get_price());
     return true;
 }
예제 #6
0
파일: test.php 프로젝트: Ukesh2010/aila
<?php

switch ($_POST['type']) {
    case 0:
        include_once '../admin/classes/order.class.php';
        $order = new Order();
        echo $order->insert($_POST['user_id']);
        break;
    case 1:
        include_once '../admin/classes/menuorder.class.php';
        $menuOrder = new MenuOrder();
        $menuOrder->insert($_POST['order_id'], $_POST['menu_id'], $_POST['qty']);
        echo true;
        break;
}
// print_r($_POST);
예제 #7
0
// it will be deleted when in line 15
$_SESSION['uid'] = 2;
if (isset($_SESSION['uid'])) {
    if (isset($_GET['id'])) {
        $user = new user($_SESSION['uid']);
        $totalPrice = $order->OrdersPrice($_SESSION['uid']);
        $product = new Product($_GET['id']);
        $order = new Order();
        $reminder = $user->credite - ($totalPrice['sum'] + $product->price);
        if ($reminder >= 0) {
            $order->user_id = $_SESSION['uid'];
            $order->num_items = $order->num_items + 1;
            $order->desc = $product->descr;
            $order->total_price = $product->price;
            $order->pid = $_GET['id'];
            $order->insert();
            // $Q=$product->quantity - $_session['quentity'];
            $Q = $product->quantity - 1;
            $product->updateQ($Q);
            $totalPrice = $order->OrdersPrice($_SESSION['uid']);
            $_SESSION['sum'] = $totalPrice['sum'];
        } else {
            //make pop up window to show that user don`t have enough credite
            echo "<script>alert('sorry,You don\\'t have enough credit.')</script>";
        }
    }
    $demand = $order->userOrder($_SESSION['uid']);
    //updateCart(count($demand));
}
?>
	 
예제 #8
0
                $old_order = Order::select(array('menu_item_id' => substr($key, 5), 'user_id' => $order->user_id, 'date' => today()));
                $menu_item = MenuItem::select(array('id' => $order->menu_item_id));
                // IF THE SAME ITEM HAS BEEN ORDERED TODAY, UPDATE THE ORDER
                if (is_object($old_order)) {
                    $old_order->quantity += $value;
                    //echo "<script>alert('update')</script>";
                    if ($old_order->update()) {
                        $alertArray['success'] = 'The order has been updated!';
                        // ADD THE COST TO TOTAL COST
                        $total_cost = $value * $menu_item->cost;
                    } else {
                        $alertArray['error'] = 'The items could not be ordered!';
                    }
                } else {
                    //echo "<script>alert('update')</script>";
                    if ($order->insert()) {
                        $alertArray['success'] = 'The items have been added to your orders';
                        $total_cost = $value * $menu_item->cost;
                    } else {
                        $alertArray['error'] = 'The items could not be ordered!';
                    }
                }
                if ($total_cost != 0) {
                    $user = Employee::select(array('user_id' => $session->user_id));
                    $user->balance += $total_cost;
                    $user->update('user_id');
                }
            }
        }
    }
}
 public function saveOrder()
 {
     $inputShipFrom = Input::get('shipFrom');
     $inputShipFrom = $this->jsonToInputArray($inputShipFrom);
     $inputshipTo = Input::get('shipTo');
     $inputshipTo = $this->jsonToInputArray($inputshipTo);
     $inputItem = Input::get('itemDetail');
     $inputItem = $this->jsonToInputArray($inputItem);
     $inputCompany = Input::get('companyInfo');
     $inputCompany = $this->jsonToInputArray($inputCompany);
     $result = array('errors' => '', 'result' => '');
     $foundErrors = false;
     //validate ship from info.
     $shipFrom = new ShipFrom();
     if ($shipFrom->validate($inputShipFrom) === false) {
         $foundErrors = true;
         $messages = $shipFrom->messages();
         if (count($messages)) {
             foreach ($messages as $message) {
                 $result['errors'] .= "<li>{$message}</li>";
             }
         }
     }
     //validate ship to information
     $shipTo = new ShipTo();
     if ($shipTo->validate($inputshipTo) === false) {
         $foundErrors = true;
         $messages = $shipTo->messages();
         if (count($messages)) {
             foreach ($messages as $message) {
                 $result['errors'] .= "<li>{$message}</li>";
             }
         }
     }
     //validate item information
     $item = new Item();
     if ($item->validate($inputItem) === false) {
         $foundErrors = true;
         $messages = $item->messages();
         if (count($messages)) {
             foreach ($messages as $message) {
                 $result['errors'] .= "<li>{$message}</li>";
             }
         }
     }
     //validate company information
     $company = new Company();
     if ($company->validate($inputCompany) === false) {
         $foundErrors = true;
         $messages = $company->messages();
         if (count($messages)) {
             foreach ($messages as $message) {
                 $result['errors'] .= "<li>{$message}</li>";
             }
         }
     }
     if ($foundErrors == true) {
         echo json_encode($result);
         return;
     }
     $data = array('shipFrom' => $inputShipFrom, 'shipTo' => $inputshipTo, 'item' => $inputItem, 'company' => $inputCompany);
     $action = Input::get('action');
     if ($action == 'update') {
         $orderId = Input::get('order_id');
         if (Order::update($orderId, $data) == true) {
             $result['result'] = 'success';
         } else {
             $result['errors'] = "<li>There was a problem with record update.Please try later.</li>";
         }
     } else {
         //create new order
         $newOrderId = Order::insert($data);
         if (is_numeric($newOrderId) && $newOrderId > 0) {
             $result['result'] = 'success';
         }
     }
     echo json_encode($result);
 }
예제 #10
0
파일: buy.php 프로젝트: osamasabry/php
// var_dump($duser);die();
$credit = $duser['credit_limit'];
// echo $credit;die();
$pric = $sprod['unit_price'];
$Upric = $pric * $qnum;
$ll = $id_product;
if ($credit >= $Upric) {
    $fq = $sprod['quantity'];
    // echo $fq;
    // echo $qnum ;die();
    if ($fq >= $qnum) {
        $rescrit = $credit - $Upric;
        $rem = $fq - $qnum;
        $query = "update product set quantity={$rem}  where id_product='{$id_product}'";
        mysqli_query($conn, $query);
        $query_user = "******";
        mysqli_query($conn, $query_user);
        $order->id_product = $id_product;
        $order->id_user = $id_user;
        $order->quantity = $qnum;
        $order->unit_price = $pric;
        $id_order = $order->insert();
        // var_dump($order);die();
        // echo "<meta http-equiv='Refresh' content='0;url=true_buy.php?img_num=$id_user' />";
        echo "<meta http-equiv='Refresh' content='0;url=true_buy.php?tuser={$id_user}' />";
    } else {
        echo "<meta http-equiv='Refresh' content='0;url=false_credit.php?img_num={$ll}' />";
    }
} else {
    echo "<meta http-equiv='Refresh' content='0;url=false_buy.php?img_num={$ll}' />";
}
예제 #11
0
파일: cart.php 프로젝트: luvyatyss/nashop
 }
 if (isset($_POST["txtUpdProId"])) {
     $updProId = explode(',', $_POST["txtUpdProId"]);
     $q = explode(',', $_POST["txtUpdQ"]);
     for ($i = 0; $i < count($updProId); $i++) {
         Cart::updateItem($updProId[$i], $q[$i]);
     }
 }
 if (isset($_POST["btnCheckout"])) {
     require_once 'helper/Context.php';
     $total = $_POST["txtTotal"];
     $ord = new Order();
     $ord->setOrderDate(new DateTime());
     $ord->setTotal($total);
     $ord->setUser(new User(Context::getCurrentUser()["userID"]));
     $ord->insert();
     foreach ($_SESSION["Cart"] as $proId => $quantity) {
         $pro = Product::loadProductByProID($proId);
         $amount = $pro->getPrice() * $quantity;
         $detail = new OrderDetail(-1, $pro, $ord, $pro->getPrice(), $quantity, $amount);
         $detail->insert();
         //Cap nhap lai so luong ton
         $inStock = $pro->getInStock() - $quantity;
         $pro->setInStock($inStock);
         $pro->updateInStock();
         //Cap nhap lai so luong ban
         $onOrder = $pro->getOnOrder() + $quantity;
         $pro->setOnOrder($onOrder);
         $pro->updateOnOrder();
     }
     $insert = true;
예제 #12
0
 $customer = new user($_SESSION['user']);
 if ($customer->cridetLimit >= trim($_GET['total'])) {
     $err = false;
     $conn = new mysqli('localhost', 'root', 'iti', 'eShop');
     mysqli_autocommit($conn, false);
     foreach ($_SESSION['cart'] as $pID => $q) {
         $product = new Product($pID);
         if ($product->pQuantity < $q) {
             echo $responce = "no enough amount of " . $product->pName . " we have only " . $product->pQuantity . " of it. We are sorry for that.";
             exit;
         }
     }
     $order = new Order();
     $order->uID = $_SESSION['user'];
     $order->oDate = date("Y-m-d");
     $oID = $order->insert();
     if ($oID == false) {
         $err = true;
     }
     $orderItem = new OrderItems();
     foreach ($_SESSION['cart'] as $pID => $q) {
         $orderItem->oID = $oID;
         $orderItem->pID = $pID;
         $orderItem->quantity = $q;
         $orderItem->insert();
         if ($orderItem == false) {
             $err = true;
         }
         $product = new product($pID);
         $product->pQuantity = $product->pQuantity - $q;
         $product->update($pID);