Esempio n. 1
0
 /**
  * @dataProvider receiveDataProvider
  *
  * @param array $parameters
  * @param array $response
  *
  * @throws ServiceException
  * @throws UndefinedCallbackException
  */
 public function testProcessDataInterface($parameters, $response)
 {
     $orderStatus = \Mockery::mock('\\Hcapi\\Interfaces\\IShopImplementation');
     $orderStatus->shouldReceive('getResponse')->with($parameters)->once()->andReturn($response);
     $service = new OrderStatus();
     $this->assertNotNull($service->processData($orderStatus, $parameters));
 }
Esempio n. 2
0
 public function save()
 {
     try {
         $this->_db->transactionStart();
         //save customer
         $customer_id = $this->saveCustomer();
         if (!$customer_id) {
             $this->writeLog('Save customer failed');
             return false;
         }
         //save order
         AImporter::helper('orderstatus');
         OrderStatus::init();
         $order_status = OrderStatus::$PENDING->getValue();
         $this->data = array('type' => 'CUSTOMIZE', 'user_id' => $customer_id, 'pay_method' => '', 'promo_code' => $this->customer['promo_code'], 'order_status' => $order_status, 'pay_status' => 'PENDING', 'notes' => $this->customer['notes']);
         if (!$this->store()) {
             $this->writeLog('Save order failed');
             return false;
         }
         if (!$this->saveOrderInfo()) {
             $this->writeLog('Save orderinfo failed');
             return false;
         }
         $this->table->order_number = 'CS' . $this->table->order_number;
         $this->table->store();
         $this->_db->transactionCommit();
     } catch (Exception $e) {
         $this->writeLog($e->getMessage());
         $this->_db->transactionRollback();
         return false;
     }
     return true;
 }
Esempio n. 3
0
 /**
  * Update order
  * @param bool $new
  * @throws CHttpException
  */
 public function actionUpdate($new = false)
 {
     if (SLicenseChecker::check() === false && SLicenseChecker::isOnLocalhost() === false) {
         throw new CHttpException(404, 'В ознакомительной версии редактирование заказов недоступно.');
     }
     if ($new === true) {
         $model = new Order();
         $model->unsetAttributes();
     } else {
         $model = $this->_loadModel($_GET['id']);
     }
     if (Yii::app()->request->isPostRequest) {
         $model->attributes = $_POST['Order'];
         if ($model->validate()) {
             $model->save();
             // Update quantities
             if (sizeof(Yii::app()->request->getPost('quantity', array()))) {
                 $model->setProductQuantities(Yii::app()->request->getPost('quantity'));
             }
             $model->updateDeliveryPrice();
             $model->updateTotalPrice();
             $this->setFlashMessage(Yii::t('OrdersModule.admin', 'Изменения успешно сохранены'));
             if (isset($_POST['REDIRECT'])) {
                 $this->smartRedirect($model);
             } else {
                 $this->redirect(array('index'));
             }
         }
     }
     $this->render('update', array('deliveryMethods' => StoreDeliveryMethod::model()->applyTranslateCriteria()->orderByName()->findAll(), 'statuses' => OrderStatus::model()->orderByPosition()->findAll(), 'model' => $model));
 }
Esempio n. 4
0
 function getOrderStatusSelect()
 {
     OrderStatus::init();
     $options = OrderStatus::$map;
     $options[] = array('value' => '0', 'text' => 'All');
     return JHTML::_('select.genericlist', $options, 'filter_order_status', ' class="inputbox input-medium" title="' . JText::_('COM_BOOKPRO_ORDER_STATUS') . '"', 'value', 'text', $this->state->get('filter.order_status'), 'filter_order_status');
 }
 public function actionIndex($method)
 {
     if (isset($_POST[$method])) {
         $criteria = new CDbCriteria();
         $criteria->condition = 'setting_group=:group';
         $criteria->params = array(':group' => $method);
         Setting::model()->deleteAll($criteria);
         foreach ($_POST[$method] as $key => $value) {
             $payment = new Setting();
             $payment->setting_group = $method;
             $payment->key = $key;
             $payment->value = $value;
             $payment->serialized = 0;
             $payment->save();
         }
         Yii::app()->user->setFlash('success', $this->accept_param[$method] . ' payment method has been saved.');
         $this->redirect(Yii::app()->createUrl('payment/index', array('method' => $method)));
     }
     $models = $this->loadModel($method);
     $form_data = array();
     foreach ($models as $model) {
         $form_data[$model->attributes['key']] = $model->attributes['value'];
     }
     $order_statuses = array();
     $order_status_models = OrderStatus::model()->findAll();
     foreach ($order_status_models as $model) {
         $order_statuses[$model->order_status_id] = $model->name;
     }
     $this->render('index', array('title' => $this->accept_param[$method], 'method' => $method, 'form' => '_form_' . $method, 'form_data' => $form_data, 'order_statuses' => $order_statuses));
 }
Esempio n. 6
0
 public function edit($id)
 {
     if (Request::isMethod('post')) {
         $rules = array('status_id' => 'required');
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             return Redirect::to("admin/{$this->name}/{$id}/{$this->action}")->withErrors($validator)->withInput(Input::except(''));
         } else {
             $table = Order::find($id);
             $table->status_id = Input::get('status_id');
             if ($table->save()) {
                 $name = trans("name.{$this->name}");
                 return Redirect::to("admin/{$this->name}")->with('success', trans("message.{$this->action}", ['name' => $name]));
             }
             return Redirect::to("admin/{$this->name}")->with('error', trans('message.error'));
         }
     }
     $order = DB::table('orders as o')->join('users as u', 'o.user_id', '=', 'u.id')->join('order_status as os', 'o.status_id', '=', 'os.id')->join('orders_details as od', 'o.id', '=', 'od.order_id')->select('o.id', DB::raw('CONCAT(u.firstname, " ", u.lastname) AS fullname'), 'os.title', 'o.created_at', DB::raw('SUM(od.price) AS total'), 'o.comment', 'o.status_id')->where('o.id', $id)->first();
     $products = DB::table('products as p')->join('orders_details as od', 'p.id', '=', 'od.product_id')->join('orders as o', 'od.order_id', '=', 'o.id')->select('p.id', 'p.link', 'p.name', 'od.price', 'od.quantity', DB::raw('od.price * od.quantity AS total'))->where('o.id', $id)->orderBy('o.id', 'asc')->get();
     $ordersStatus = OrderStatus::all();
     foreach ($ordersStatus as $status) {
         $orderStatus[$status['id']] = $status['title'];
     }
     return View::make("admin.shop.order.edit", ['item' => $order, 'name' => $this->name, 'action' => $this->action, 'status' => $orderStatus, 'products' => $products]);
 }
Esempio n. 7
0
 public static function canAccessOrderStatusIds(Role $role)
 {
     if (isset(self::$_cache['accessOrderStatusIds'])) {
         self::$_cache['accessOrderStatusIds'] = array();
     }
     if (!isset(self::$_cache['accessOrderStatusIds'][$role->getId()])) {
         switch ($role->getId()) {
             case Role::ID_STORE_MANAGER:
             case Role::ID_SYSTEM_ADMIN:
             case Role::ID_SALES:
                 self::$_cache['accessOrderStatusIds'][$role->getId()] = array_map(create_function('$a', 'return intval($a->getId());'), OrderStatus::getAllByCriteria('id not in(?,?) ', array(OrderStatus::ID_CANCELLED, OrderStatus::ID_SHIPPED)));
                 break;
             case Role::ID_ACCOUNTING:
                 self::$_cache['accessOrderStatusIds'][$role->getId()] = array_map(create_function('$a', 'return intval($a->getId());'), OrderStatus::getAllByCriteria('id not in(?,?) ', array(OrderStatus::ID_CANCELLED, OrderStatus::ID_SHIPPED)));
                 break;
             case Role::ID_PURCHASING:
                 self::$_cache['accessOrderStatusIds'][$role->getId()] = array(OrderStatus::ID_NEW, OrderStatus::ID_INSUFFICIENT_STOCK);
                 break;
             case Role::ID_WAREHOUSE:
                 self::$_cache['accessOrderStatusIds'][$role->getId()] = array(OrderStatus::ID_ETA, OrderStatus::ID_STOCK_CHECKED_BY_PURCHASING, OrderStatus::ID_PICKED, OrderStatus::ID_INSUFFICIENT_STOCK);
                 break;
             case Role::ID_WORKSHOP:
                 self::$_cache['accessOrderStatusIds'][$role->getId()] = array(OrderStatus::ID_STOCK_CHECKED_BY_PURCHASING, OrderStatus::ID_NEW);
                 break;
         }
     }
     return self::$_cache['accessOrderStatusIds'][$role->getId()];
 }
Esempio n. 8
0
 public function actionUpdate($id)
 {
     $model = new SettingsForm();
     if (isset($_POST['SettingsForm'])) {
         $model->attributes = $_POST['SettingsForm'];
         if ($model->validate() && $model->save()) {
             $this->redirect(array('index'));
         }
     } else {
         $model->loadDataFromStore($id);
     }
     $directories = glob(Yii::getPathOfAlias('webroot.themes') . "/*", GLOB_ONLYDIR);
     $themes = array();
     foreach ($directories as $directory) {
         $themes[] = basename($directory);
     }
     $layouts = CHtml::listData(Layout::model()->findAll(), 'layout_id', 'name');
     $countries = CHtml::listData(Country::model()->findAll(), 'country_id', 'name');
     $zones = CHtml::listData(Zone::model()->findAllByAttributes(array('country_id' => $model->country)), 'zone_id', 'name');
     $languages = CHtml::listData(Language::model()->findAll(), 'language_id', 'name');
     $currencies = CHtml::listData(Currency::model()->findAll(), 'currency_id', 'title');
     $yesNoOptions = array(0 => Yii::t('settings', 'No'), 1 => Yii::t('settings', 'Yes'));
     $lengthClasses = CHtml::listData(LengthClassDescription::model()->findAll(), 'length_class_id', 'title');
     $weightClasses = CHtml::listData(WeightClassDescription::model()->findAll(), 'weight_class_id', 'title');
     $taxesOptions = array("" => Yii::t("settings", "--- None ---"), "shipping" => Yii::t("settings", "Shipping Address"), "payment" => Yii::t("settings", "Payment Address"));
     $customerGroups = CHtml::listData(CustomerGroupDescription::model()->findAll(), 'customer_group_id', 'name');
     $informations = array_merge(array(0 => Yii::t("settings", "--- None ---")), CHtml::listData(InformationDescription::model()->findAll(), 'information_id', 'title'));
     // TODO: localisation
     $orderStatuses = CHtml::listData(OrderStatus::model()->findAllByAttributes(array('language_id' => 1)), 'order_status_id', 'name');
     // TODO: localisation
     $returnStatuses = CHtml::listData(ReturnStatus::model()->findAllByAttributes(array('language_id' => 1)), 'return_status_id', 'name');
     $mailProtocols = array("mail" => Yii::t("settings", "Mail"), "smtp" => Yii::t("settings", "SMTP"));
     $this->render('update', array('model' => $model, 'themes' => $themes, 'layouts' => $layouts, 'countries' => $countries, 'zones' => $zones, 'languages' => $languages, 'currencies' => $currencies, 'yesNoOptions' => $yesNoOptions, 'lengthClasses' => $lengthClasses, 'weightClasses' => $weightClasses, 'taxesOptions' => $taxesOptions, 'customerGroups' => $customerGroups, 'informations' => $informations, 'orderStatuses' => $orderStatuses, 'returnStatuses' => $returnStatuses, 'mailProtocols' => $mailProtocols));
 }
 /**
  * @param $id
  * @return OrderStatus
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = OrderStatus::model()->findByPk($id, 'is_system != 1');
     if ($model === null) {
         throw new CHttpException(404, Yii::t('OrderModule.order', 'Page not found!'));
     }
     return $model;
 }
Esempio n. 10
0
 public function getOrderStatus($order_status_id)
 {
     $status = OrderStatus::model()->findByPk($order_status_id);
     if (!empty($status)) {
         return $status->getName();
     }
     return null;
 }
Esempio n. 11
0
 /**
  * @param string $status
  */
 public function setStatus($status)
 {
     if (!OrderStatus::validatStatus($status)) {
         throw new \InvalidArgumentException('State not allowed');
     }
     $this->status = $status;
     return $this;
 }
Esempio n. 12
0
 public function postAdd()
 {
     $rules = ['firstname' => 'required|min:2', 'lastname' => 'required|min:2', 'address' => 'required|min:5', 'phone' => 'required|min:7'];
     if (!Auth::check()) {
         array_push($rules, ['email' => 'required|email|unique:users']);
     }
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to("checkout")->withErrors($validator)->withInput(Input::except(''));
     } else {
         if (Auth::check()) {
             $user = User::find(Auth::user()->id);
         } else {
             $user = new User();
             $user->email = Input::get('email');
             $password = str_random(10);
             $user->password = Hash::make($password);
         }
         $user->firstname = Input::get('firstname');
         $user->lastname = Input::get('lastname');
         $user->address = Input::get('address');
         $user->phone = Input::get('phone');
         if ($user->save()) {
             $role = Role::where('name', '=', 'Customer')->first();
             if (!$user->hasRole("Customer")) {
                 $user->roles()->attach($role->id);
             }
             $order = new Order();
             $order->user_id = $user->id;
             $order->status_id = OrderStatus::where('title', '=', 'Новый')->first()->id;
             $order->comment = 'Телефон: <b>' . $user->phone . '</b><br>Адрес: <b>' . $user->address . '</b><br>Комментарий покупателя: ' . '<i>' . Input::get('comment') . '</i>';
             if ($order->save()) {
                 $cart = Cart::content();
                 foreach ($cart as $product) {
                     $orderDetails = new OrderDetails();
                     $orderDetails->order_id = $order->id;
                     $orderDetails->product_id = $product->id;
                     $orderDetails->quantity = $product->qty;
                     $orderDetails->price = $product->price;
                     $orderDetails->save();
                 }
             }
             if (!Auth::check()) {
                 Mail::send('mail.registration', ['firstname' => $user->firstname, 'login' => $user->email, 'password' => $password, 'setting' => Config::get('setting')], function ($message) {
                     $message->to(Input::get('email'))->subject("Регистрация прошла успешно");
                 });
             }
             $orderId = $order->id;
             Mail::send('mail.order', ['cart' => $cart, 'order' => $order, 'phone' => $user->phone, 'user' => $user->firstname . ' ' . $user->lastname], function ($message) use($orderId) {
                 $message->to(Input::get('email'))->subject("Ваша заявка №{$orderId} принята");
             });
             Cart::destroy();
             return Redirect::to("checkout/thanks/spasibo-vash-zakaz-prinyat")->with('successcart', 'ok', ['cart' => $cart]);
         }
     }
 }
Esempio n. 13
0
 public function run()
 {
     DB::table('order_status')->truncate();
     DB::table('order_status')->delete();
     OrderStatus::create(array('id' => 1, 'title' => 'Новый'));
     OrderStatus::create(array('id' => 2, 'title' => 'Обрабатывается'));
     OrderStatus::create(array('id' => 3, 'title' => 'Отправлен'));
     OrderStatus::create(array('id' => 4, 'title' => 'Выполнен'));
     OrderStatus::create(array('id' => 5, 'title' => 'Отменен'));
 }
Esempio n. 14
0
 /**
  * @return array
  */
 public static function labelList()
 {
     $labels = [];
     $statuses = OrderStatus::model()->findAll();
     foreach ($statuses as $status) {
         if ($status->color) {
             $labels[$status->id] = ['class' => 'label-' . $status->color];
         }
     }
     return $labels;
 }
Esempio n. 15
0
 public function afterUninstall()
 {
     Yii::app()->settings->clear($this->id);
     //Yii::app()->unintallComponent('cart');
     $db = Yii::app()->db;
     $tablesArray = array(Order::model()->tableName(), OrderHistory::model()->tableName(), OrderProduct::model()->tableName(), OrderStatus::model()->tableName(), OrderProductHistroy::model()->tableName(), ShopPaymentMethod::model()->tableName(), ShopPaymentMethodTranslate::model()->tableName(), ShopDeliveryMethod::model()->tableName(), ShopDeliveryMethodTranslate::model()->tableName(), ShopDeliveryPayment::model()->tableName(), ProductNotifications::model()->tableName());
     foreach ($tablesArray as $table) {
         $db->createCommand()->dropTable($table);
     }
     return parent::afterInstall();
 }
Esempio n. 16
0
 public function actionView($id)
 {
     $order = Order::model()->findByPk($id);
     if (is_null($order)) {
         // TODO: send an error here!
         die;
     }
     // TODO: add locale
     $orderStatuses = OrderStatus::model()->findAllByAttributes(array('language_id' => 1));
     $orderStatuses = CHtml::listData($orderStatuses, 'order_status_id', 'name');
     $this->render('view', array('order' => $order, 'orderHistoryModel' => new OrderHistory(), 'orderStatuses' => $orderStatuses));
 }
Esempio n. 17
0
 public function beforeSave()
 {
     if ($this->position == '') {
         $max = OrderStatus::model()->orderByPositionDesc()->find();
         if ($max) {
             $this->position = (int) $max->position + 1;
         } else {
             $this->position = 0;
         }
     }
     return parent::beforeSave();
 }
Esempio n. 18
0
 /**
  * (non-PHPdoc)
  * @see StaticsPageAbstract::getData()
  */
 public function getData($sender, $param)
 {
     $results = $errors = array();
     try {
         $timeRange = $this->_getXnames();
         $names = array_keys($timeRange);
         $series = array();
         $series[] = array('name' => 'All', 'data' => $this->_getSeries($timeRange, $timeRange[$names[0]]['from'], $timeRange[$names[count($names) - 1]]['to']));
         foreach (OrderStatus::getAll() as $status) {
             $series[] = array('name' => $status->getName(), 'data' => $this->_getSeries($timeRange, $timeRange[$names[0]]['from'], $timeRange[$names[count($names) - 1]]['to'], array($status->getId())));
         }
         $results = array('chart' => array('type' => 'line'), 'title' => array('text' => 'BPC: Monthly Order Trend', 'x' => -20), 'subtitle' => array('text' => 'This is just order trend from last 12 month', 'x' => -20), 'xAxis' => array('categories' => $names), 'yAxis' => array('title' => array('text' => 'No of Orders')), 'series' => $series);
     } catch (Exception $ex) {
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
Esempio n. 19
0
 /**
  * Delete status
  * @param array $id
  */
 public function actionDelete($id = array())
 {
     if (Yii::app()->request->isPostRequest) {
         $model = OrderStatus::model()->findAllByPk($_REQUEST['id']);
         if (!empty($model)) {
             foreach ($model as $m) {
                 if ($m->countOrders() == 0 && $m->id != 1) {
                     $m->delete();
                 } else {
                     throw new CHttpException(409, Yii::t('OrdersModule.admin', 'Ошибка удаления статуса. Он используется заказами.'));
                 }
             }
         }
         if (!Yii::app()->request->isAjaxRequest) {
             $this->redirect('index');
         }
     }
 }
Esempio n. 20
0
 /**
  * Delete status
  * @param array $id
  */
 public function actionDelete($id = array())
 {
     if (Yii::app()->request->isPostRequest) {
         $model = OrderStatus::model()->findAllByPk($_REQUEST['id']);
         if (!empty($model)) {
             foreach ($model as $m) {
                 if ($m->countOrders() == 0 && $m->id != 1) {
                     $m->delete();
                 } else {
                     throw new CHttpException(409, Yii::t('CartModule.admin', 'ERR_DELETE_STATUS'));
                 }
             }
         }
         if (!Yii::app()->request->isAjaxRequest) {
             $this->redirect('index');
         }
     }
 }
Esempio n. 21
0
 /**
  * Update order
  * @param bool $new
  * @throws CHttpException
  */
 public function actionUpdate($new = false)
 {
     Yii::app()->clientScript->registerScriptFile($this->module->assetsUrl . '/admin/orders.update.js', CClientScript::POS_END);
     if ($new === true) {
         $model = new Order();
         $model->unsetAttributes();
     } else {
         $model = $this->_loadModel($_GET['id']);
     }
     if (!$model->isNewRecord) {
         $update = Yii::t('CartModule.admin', 'UPDATE_ORDER', array('{order_id}' => CHtml::encode($model->id)));
     }
     $this->pageName = $model->isNewRecord ? Yii::t('CartModule.admin', 'Создание заказа') : Yii::t('CartModule.admin', 'ORDER', 0);
     $this->breadcrumbs = array(Yii::t('CartModule.admin', 'ORDER', 0) => $this->createUrl('index'), $model->isNewRecord ? Yii::t('CartModule.admin', 'Создание заказа') : $update);
     if (Yii::app()->request->isPostRequest) {
         $model->attributes = $_POST['Order'];
         if ($model->validate()) {
             $model->save();
             // Update quantities
             if (sizeof(Yii::app()->request->getPost('quantity', array()))) {
                 $model->setProductQuantities(Yii::app()->request->getPost('quantity'));
             }
             $model->updateDeliveryPrice();
             $model->updateTotalPrice();
             if ($model->isNewRecord === false) {
                 $template[] = 'delete';
             }
             // register all delivery methods to recalculate prices
             Yii::app()->clientScript->registerScript('deliveryMetohds', strtr('var deliveryMethods = {data};', array('{data}' => CJavaScript::jsonEncode($deliveryMethods))), CClientScript::POS_END);
             ///  if ($new) {
             //      $this->setFlashMessage(Yii::t('core', 'Теперь Вы можете добавить товары.'));
             //}
             $this->redirect(array('update', 'id' => $model->id));
         }
     }
     $this->render('update', array('deliveryMethods' => ShopDeliveryMethod::model()->applyTranslateCriteria()->orderByName()->findAll(), 'paymentMethods' => ShopPaymentMethod::model()->findAll(), 'statuses' => OrderStatus::model()->orderByPosition()->findAll(), 'model' => $model));
 }
Esempio n. 22
0
 /**
  * Import Orders
  *
  * @param string $lastUpdatedTime The datatime string
  *
  * @return B2BConnector
  */
 public function importOrders($lastUpdatedTime = '')
 {
     $totalItems = 0;
     $this->_log(0, get_class($this), 'starting ...', self::LOG_TYPE, 'start', __FUNCTION__);
     if (($lastUpdatedTime = trim($lastUpdatedTime)) === '') {
         $this->_log(0, get_class($this), 'Getting the last updated time', self::LOG_TYPE, '$lastUpdatedTime is blank', __FUNCTION__);
         // 			$lastImportTime = new UDate(SystemSettings::getSettings(SystemSettings::TYPE_B2B_SOAP_LAST_IMPORT_TIME), SystemSettings::getSettings(SystemSettings::TYPE_B2B_SOAP_TIMEZONE));
         $lastUpdatedTime = trim(SystemSettings::getSettings(SystemSettings::TYPE_B2B_SOAP_LAST_IMPORT_TIME));
     }
     //getting the lastest order since last updated time
     $orders = $this->getlastestOrders($lastUpdatedTime);
     $this->_log(0, get_class($this), 'Found ' . count($orders) . ' order(s) since "' . $lastUpdatedTime . '".', self::LOG_TYPE, '', __FUNCTION__);
     if (is_array($orders) && count($orders) > 0) {
         $transStarted = false;
         try {
             try {
                 Dao::beginTransaction();
             } catch (Exception $e) {
                 $transStarted = true;
             }
             foreach ($orders as $index => $order) {
                 $this->_log(0, get_class($this), 'Found order from Magento with orderNo = ' . trim($order->increment_id) . '.', self::LOG_TYPE, '', __FUNCTION__);
                 $order = $this->getOrderInfo(trim($order->increment_id));
                 if (!is_object($order)) {
                     $this->_log(0, get_class($this), 'Found no object from $order, next element!', self::LOG_TYPE, '$index = ' . $index, __FUNCTION__);
                     continue;
                 }
                 if (($status = trim($order->state)) === '') {
                     $this->_log(0, get_class($this), 'Found no state Elment from $order, next element!', self::LOG_TYPE, '$index = ' . $index, __FUNCTION__);
                     continue;
                 }
                 //saving the order
                 $orderDate = new UDate(trim($order->created_at), SystemSettings::getSettings(SystemSettings::TYPE_B2B_SOAP_TIMEZONE));
                 $orderDate->setTimeZone('UTC');
                 // 				$totalPaid = (!isset($order->total_paid) ? 0 : trim($order->total_paid));
                 $shippingAddr = $billingAddr = null;
                 if (($o = Order::getByOrderNo(trim($order->increment_id))) instanceof Order) {
                     //skip, if order exsits
                     $this->_log(0, get_class($this), 'Found order from DB, ID = ' . $o->getId(), self::LOG_TYPE, '$index = ' . $index, __FUNCTION__);
                     continue;
                     // 					$shippingAddr = $o->getShippingAddr();
                     // 					$billingAddr = $o->getBillingAddr();
                 }
                 $o = new Order();
                 $this->_log(0, get_class($this), 'Found no order from DB, create new', self::LOG_TYPE, '$index = ' . $index, __FUNCTION__);
                 $customer = Customer::create(isset($order->billing_address) && isset($order->billing_address->company) && trim($order->billing_address->company) !== '' ? trim($order->billing_address->company) : (isset($order->customer_firstname) ? trim($order->customer_firstname) . ' ' . trim($order->customer_lastname) : ''), '', trim($order->customer_email), $this->_createAddr($order->billing_address, $billingAddr), true, '', $this->_createAddr($order->shipping_address, $shippingAddr), isset($order->customer_id) ? trim($order->customer_id) : 0);
                 $o->setOrderNo(trim($order->increment_id))->setOrderDate(trim($orderDate))->setTotalAmount(trim($order->grand_total))->setStatus(strtolower($status) === 'canceled' ? OrderStatus::get(OrderStatus::ID_CANCELLED) : OrderStatus::get(OrderStatus::ID_NEW))->setIsFromB2B(true)->setShippingAddr($customer->getShippingAddress())->setBillingAddr($customer->getBillingAddress())->setCustomer($customer)->save();
                 $this->_log(0, get_class($this), 'Saved the order, ID = ' . $o->getId(), self::LOG_TYPE, '$index = ' . $index, __FUNCTION__);
                 $totalShippingCost = StringUtilsAbstract::getValueFromCurrency(trim($order->shipping_amount)) * 1.1;
                 //create order info
                 $this->_createOrderInfo($o, OrderInfoType::get(OrderInfoType::ID_CUS_NAME), trim($customer->getName()))->_createOrderInfo($o, OrderInfoType::get(OrderInfoType::ID_CUS_EMAIL), trim($customer->getEmail()))->_createOrderInfo($o, OrderInfoType::get(OrderInfoType::ID_QTY_ORDERED), intval(trim($order->total_qty_ordered)))->_createOrderInfo($o, OrderInfoType::get(OrderInfoType::ID_MAGE_ORDER_STATUS), trim($order->status))->_createOrderInfo($o, OrderInfoType::get(OrderInfoType::ID_MAGE_ORDER_STATE), trim($order->state))->_createOrderInfo($o, OrderInfoType::get(OrderInfoType::ID_MAGE_ORDER_TOTAL_AMOUNT), trim($order->grand_total))->_createOrderInfo($o, OrderInfoType::get(OrderInfoType::ID_MAGE_ORDER_SHIPPING_METHOD), trim($order->shipping_description))->_createOrderInfo($o, OrderInfoType::get(OrderInfoType::ID_MAGE_ORDER_SHIPPING_COST), $totalShippingCost)->_createOrderInfo($o, OrderInfoType::get(OrderInfoType::ID_MAGE_ORDER_PAYMENT_METHOD), !isset($order->payment) ? '' : (!isset($order->payment->method) ? '' : trim($order->payment->method)));
                 $this->_log(0, get_class($this), 'Updated order info', self::LOG_TYPE, '$index = ' . $index, __FUNCTION__);
                 //saving the order item
                 $totalItemCost = 0;
                 foreach ($order->items as $item) {
                     $this->_createItem($o, $item);
                     $totalItemCost = $totalItemCost * 1 + StringUtilsAbstract::getValueFromCurrency($item->row_total) * 1.1;
                 }
                 if (($possibleSurchargeAmount = $o->getTotalAmount() - $totalShippingCost - $totalItemCost) > 0 && ($product = Product::getBySku('surcharge')) instanceof Product) {
                     OrderItem::create($o, $product, $possibleSurchargeAmount, 1, $possibleSurchargeAmount);
                 }
                 //record the last imported time for this import process
                 SystemSettings::addSettings(SystemSettings::TYPE_B2B_SOAP_LAST_IMPORT_TIME, trim($order->created_at));
                 $this->_log(0, get_class($this), 'Updating the last updated time :' . trim($order->created_at), self::LOG_TYPE, '', __FUNCTION__);
                 $totalItems++;
             }
             if ($transStarted === false) {
                 Dao::commitTransaction();
             }
         } catch (Exception $e) {
             if ($transStarted === false) {
                 Dao::rollbackTransaction();
             }
             throw $e;
         }
     }
     $this->_log(0, get_class($this), $lastUpdatedTime . " => " . SystemSettings::getSettings(SystemSettings::TYPE_B2B_SOAP_LAST_IMPORT_TIME) . ' => ' . $totalItems, self::LOG_TYPE, '', __FUNCTION__);
     return $this;
 }
Esempio n. 23
0
<div class="row">
    <div class="col-md-3">
        <?php 
$this->renderPartial('_nav');
?>
    </div>
    <div class="col-md-9">
        <h1><?php 
echo $this->pageName;
?>
</h1>
        <?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'ordersListGrid', 'itemsCssClass' => 'table table-striped table-condensed', 'dataProvider' => $orders->search(), 'template' => '{items}', 'columns' => array(array('name' => 'user_name', 'type' => 'raw', 'value' => 'Html::link(Html::encode($data->user_name), array("/cart/default/view", "secret_key"=>$data->secret_key))'), 'user_email', 'user_phone', array('name' => 'status_id', 'filter' => Html::listData(OrderStatus::model()->orderByPosition()->findAll(), 'id', 'name'), 'value' => '$data->status_name'), array('name' => 'delivery_id', 'filter' => Html::listData(ShopDeliveryMethod::model()->orderByPosition()->findAll(), 'id', 'name'), 'value' => '$data->delivery_name'), array('type' => 'raw', 'name' => 'full_price', 'value' => 'ShopProduct::formatPrice($data->full_price)'))));
?>
    </div>
</div>
Esempio n. 24
0
        </div>
        <?php 
$res = get_all_orders();
?>

        <?php 
while ($row = mysql_fetch_array($res, MYSQL_BOTH)) {
    ?>

            <div class="description">
                <form method="post">
                <ul>
                    <li>
                        <select name="status">
                            <?php 
    foreach (OrderStatus::get() as $k => $v) {
        ?>
                                <option <?php 
        echo $k == $row['status'] ? 'selected' : '';
        ?>
 value="<?php 
        echo $k;
        ?>
"><?php 
        echo $v;
        ?>
</option>
                            <?php 
    }
    ?>
                        </select>
Esempio n. 25
0
?>
		<?php 
echo $form->dropDownList($model, 'shipping_method', CHtml::listData(ShippingMethod::model()->findAll(), 'id', function ($data) {
    return $data->getName();
}));
?>
		<?php 
echo $form->error($model, 'shipping_method');
?>
	</div>
	<div class="row">
		<?php 
echo $form->labelEx($model, 'order_status_id');
?>
		<?php 
echo $form->dropDownList($model, 'order_status_id', CHtml::listData(OrderStatus::model()->findAll(), 'id', function ($data) {
    return $data->getName();
}));
?>
		<?php 
echo $form->error($model, 'order_status_id');
?>
	</div>
	<div class="row">
		<?php 
echo $form->labelEx($description, 'comment');
?>
		<?php 
echo $form->textArea($description, 'comment', array('rows' => 6, 'cols' => 50));
?>
		<?php 
Esempio n. 26
0
        echo JHtml::link(JURI::root() . 'index.php?option=com_bookpro&view=orderdetail&order_number=' . $order->order_number . '&email=' . $customer->email, $order->order_number, 'class="cancelbt"');
        ?>
					</td>
					
					<td style="border: 1px #ccc solid;">
						<?php 
        echo PayStatus::format($order->pay_status);
        ?>
						<br>
						 <label class="label"><?php 
        echo $order->pay_method;
        ?>
</label>
					</td>
					<td style="border: 1px #ccc solid;"><?php 
        echo OrderStatus::format($order->order_status);
        ?>
					</td>
					<td style="border: 1px #ccc solid;"><?php 
        echo CurrencyHelper::formatprice($order->subtotal);
        ?>
					</td>
					
					<td style="border: 1px #ccc solid;"><?php 
        echo CurrencyHelper::formatprice($order->deposit);
        ?>
					</td>
					
					<td style="border: 1px #ccc solid;"><?php 
        echo CurrencyHelper::formatprice($order->tax);
        ?>
 public function clearETA($sender, $param)
 {
     $results = $errors = array();
     try {
         if (!isset($param->CallbackParameter->item_id) || !($item = OrderItem::get($param->CallbackParameter->item_id)) instanceof OrderItem) {
             throw new Exception('System Error: invalid order item provided!');
         }
         if (!isset($param->CallbackParameter->comments) || ($comments = trim($param->CallbackParameter->comments)) === '') {
             $comments = '';
         }
         Dao::beginTransaction();
         //saving the order item
         $item->setETA(UDate::zeroDate())->addComment('Clearing the ETA: ' . $comments);
         $order = $item->getOrder();
         $sku = $item->getProduct()->getSku();
         $order->addComment('Clearing the ETA for product (' . $sku . '): ' . $comments, Comments::TYPE_PURCHASING);
         $item->save();
         //check to see whether we need to update the order as well
         $allChecked = true;
         foreach ($order->getOrderItems() as $orderItems) {
             if (trim($orderItems->getETA()) !== trim(UDate::zeroDate())) {
                 $allChecked = false;
             }
         }
         if ($allChecked === true) {
             $order->addComment('Auto Push this order status from [' . $order->getStatus() . '] to [' . OrderStatus::ID_ETA . '], as the last ETA cleared', Comments::TYPE_SYSTEM);
             $order->setStatus(OrderStatus::get(OrderStatus::ID_STOCK_CHECKED_BY_PURCHASING));
         }
         $order->save();
         $results = $item->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
Esempio n. 28
0
 public function getEditableParams()
 {
     return ['notifyEmailFrom', 'notifyEmailsTo', 'showOrder' => $this->getChoice(), 'enableCheck' => $this->getChoice(), 'defaultStatus' => CHtml::listData(OrderStatus::model()->findAll(), 'id', 'name')];
 }
Esempio n. 29
0
$this->widget('bootstrap.widgets.TbButton', ['buttonType' => 'submit', 'context' => 'primary', 'label' => $model->getIsNewRecord() ? Yii::t('CouponModule.coupon', 'Add coupon and continue') : Yii::t('CouponModule.coupon', 'Save coupon and continue')]);
?>

        <?php 
$this->widget('bootstrap.widgets.TbButton', ['buttonType' => 'submit', 'htmlOptions' => ['name' => 'submit-type', 'value' => 'index'], 'label' => $model->getIsNewRecord() ? Yii::t('CouponModule.coupon', 'Add coupon and close') : Yii::t('CouponModule.coupon', 'Save coupon and close')]);
?>

        <?php 
$this->endWidget();
?>
    </div>

    <?php 
if (!$model->getIsNewRecord()) {
    ?>
    <div class="tab-pane panel-body" id="history">

        <?php 
    Yii::app()->getModule('order');
    $order = new Order('search');
    $order->unsetAttributes();
    $this->widget('yupe\\widgets\\CustomGridView', ['id' => 'order-grid', 'type' => 'condensed', 'dataProvider' => $order->search($model->id), 'filter' => $order, 'rowCssClassExpression' => '$data->paid == Order::PAID_STATUS_PAID ? "alert-success" : ""', 'ajaxUrl' => Yii::app()->createUrl('/order/orderBackend/index'), 'actionsButtons' => false, 'bulkActions' => [false], 'columns' => [['name' => 'id', 'htmlOptions' => ['width' => '90px'], 'type' => 'raw', 'value' => 'CHtml::link(Yii::t("CouponModule.coupon", "Order #").$data->id, array("/order/orderBackend/update", "id" => $data->id))'], ['name' => 'name', 'type' => 'raw', 'value' => '$data->name . ($data->note ? "<br><div class=\\"note\\">$data->note</div>" : "")', 'htmlOptions' => ['width' => '400px']], 'total_price', ['name' => 'paid', 'value' => '$data->getPaidStatus()', 'filter' => $order->getPaidStatusList()], ['name' => 'date'], ['name' => 'status', 'type' => 'raw', 'value' => function ($data) {
        return $data->status->getTitle();
    }, 'filter' => OrderStatus::model()->getList()]]]);
    ?>
    </div>
    <?php 
}
?>
</div>
Esempio n. 30
0
 public function save()
 {
     try {
         $this->_db->transactionStart();
         //save customer
         $customer_id = $this->saveCustomer();
         if (!$customer_id) {
             $this->writeLog('Save customer failed');
             return false;
         }
         //save order
         AImporter::helper('orderstatus');
         OrderStatus::init();
         $order_status = OrderStatus::$PENDING->getValue();
         $this->data = array('type' => 'TRANSPORT', 'user_id' => $customer_id, 'pay_method' => '', 'promo_code' => $this->customer['promo_code'], 'order_status' => $order_status, 'pay_status' => 'PENDING', 'notes' => $this->customer['notes'], 'tax' => $this->cart->tax, 'service_fee' => $this->cart->service_fee);
         $this->setPrice();
         $this->addCoupon();
         if (!$this->store()) {
             $this->writeLog('Save order failed');
         }
         if (!$this->savePassenger()) {
             $this->writeLog('Save passenger failed');
         }
         if (!$this->saveOrderInfo()) {
             $this->writeLog('Save orderinfo failed');
         }
         if (!$this->saveAddon()) {
             $this->writeLog('Save addon failed');
         }
         if (!$this->saveOrderInfoStop()) {
             $this->writeLog('Save orderinfo stop failed');
         }
         //save order number
         $this->table->order_number = $this->cart->filter['type'] == 1 ? 'PR' . $this->table->order_number : 'SR' . $this->table->order_number;
         $this->table->store();
         $this->_db->transactionCommit();
     } catch (Exception $e) {
         $this->writeLog($e->getMessage());
         $this->_db->transactionRollback();
         return false;
     }
     return true;
 }