当前位置: 首页>>代码示例>>PHP>>正文


PHP Warehouse::getProductLocation方法代码示例

本文整理汇总了PHP中Warehouse::getProductLocation方法的典型用法代码示例。如果您正苦于以下问题:PHP Warehouse::getProductLocation方法的具体用法?PHP Warehouse::getProductLocation怎么用?PHP Warehouse::getProductLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Warehouse的用法示例。


在下文中一共展示了Warehouse::getProductLocation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postProcessUpdateReceipt

 /**
  * Helper function for AdminSupplyOrdersController::postProcess()
  *
  * @see AdminSupplyOrdersController::postProcess()
  */
 protected function postProcessUpdateReceipt()
 {
     // gets all box selected
     $rows = Tools::getValue('supply_order_detailBox');
     if (!$rows) {
         $this->errors[] = Tools::displayError('You did not select any products to update.');
         return;
     }
     // final array with id_supply_order_detail and value to update
     $to_update = array();
     // gets quantity for each id_order_detail
     foreach ($rows as $row) {
         if (Tools::getValue('quantity_received_today_' . $row)) {
             $to_update[$row] = (int) Tools::getValue('quantity_received_today_' . $row);
         }
     }
     // checks if there is something to update
     if (!count($to_update)) {
         $this->errors[] = Tools::displayError('You did not select any products to update.');
         return;
     }
     $supply_order = new SupplyOrder((int) Tools::getValue('id_supply_order'));
     foreach ($to_update as $id_supply_order_detail => $quantity) {
         $supply_order_detail = new SupplyOrderDetail($id_supply_order_detail);
         if (Validate::isLoadedObject($supply_order_detail) && Validate::isLoadedObject($supply_order)) {
             // checks if quantity is valid
             // It's possible to receive more quantity than expected in case of a shipping error from the supplier
             if (!Validate::isInt($quantity) || $quantity <= 0) {
                 $this->errors[] = sprintf(Tools::displayError('Quantity (%d) for product #%d is not valid'), (int) $quantity, (int) $id_supply_order_detail);
             } else {
                 // creates the history
                 $supplier_receipt_history = new SupplyOrderReceiptHistory();
                 $supplier_receipt_history->id_supply_order_detail = (int) $id_supply_order_detail;
                 $supplier_receipt_history->id_employee = (int) $this->context->employee->id;
                 $supplier_receipt_history->employee_firstname = pSQL($this->context->employee->firstname);
                 $supplier_receipt_history->employee_lastname = pSQL($this->context->employee->lastname);
                 $supplier_receipt_history->id_supply_order_state = (int) $supply_order->id_supply_order_state;
                 $supplier_receipt_history->quantity = (int) $quantity;
                 // updates quantity received
                 $supply_order_detail->quantity_received += (int) $quantity;
                 // if current state is "Pending receipt", then we sets it to "Order received in part"
                 if (3 == $supply_order->id_supply_order_state) {
                     $supply_order->id_supply_order_state = 4;
                 }
                 // Adds to stock
                 $warehouse = new Warehouse($supply_order->id_warehouse);
                 if (!Validate::isLoadedObject($warehouse)) {
                     $this->errors[] = Tools::displayError('The warehouse could not be loaded.');
                     return;
                 }
                 $price = $supply_order_detail->unit_price_te;
                 // converts the unit price to the warehouse currency if needed
                 if ($supply_order->id_currency != $warehouse->id_currency) {
                     // first, converts the price to the default currency
                     $price_converted_to_default_currency = Tools::convertPrice($supply_order_detail->unit_price_te, $supply_order->id_currency, false);
                     // then, converts the newly calculated pri-ce from the default currency to the needed currency
                     $price = Tools::ps_round(Tools::convertPrice($price_converted_to_default_currency, $warehouse->id_currency, true), 6);
                 }
                 $manager = StockManagerFactory::getManager();
                 $res = $manager->addProduct($supply_order_detail->id_product, $supply_order_detail->id_product_attribute, $warehouse, (int) $quantity, Configuration::get('PS_STOCK_MVT_SUPPLY_ORDER'), $price, true, $supply_order->id);
                 $location = Warehouse::getProductLocation($supply_order_detail->id_product, $supply_order_detail->id_product_attribute, $warehouse->id);
                 $res = Warehouse::setProductlocation($supply_order_detail->id_product, $supply_order_detail->id_product_attribute, $warehouse->id, $location ? $location : '');
                 if ($res) {
                     $supplier_receipt_history->add();
                     $supply_order_detail->save();
                     StockAvailable::synchronize($supply_order_detail->id_product);
                 } else {
                     $this->errors[] = Tools::displayError('Something went wrong when setting warehouse on product record');
                 }
             }
         }
     }
     $supply_order->id_supply_order_state = $supply_order->id_supply_order_state == 4 && $supply_order->getAllPendingQuantity() > 0 ? 4 : 5;
     $supply_order->save();
     if (!count($this->errors)) {
         // display confirm message
         $token = Tools::getValue('token') ? Tools::getValue('token') : $this->token;
         $redirect = self::$currentIndex . '&token=' . $token;
         $this->redirect_after = $redirect . '&conf=4';
     }
 }
开发者ID:zangles,项目名称:lennyba,代码行数:86,代码来源:AdminSupplyOrdersController.php

示例2: postProcessUpdateReceipt


//.........这里部分代码省略.........
                 $supply_order_detail->save();
                 $to_update[Db::getInstance()->Insert_ID()] = (int) Tools::getValue('quantity_received_today_' . $row);
                 $comment[Db::getInstance()->Insert_ID()] = Tools::getValue('input_comment_' . $row);
                 //--ERP information
                 // creates erp_supplier_order_detail for new product
                 if ((int) $supply_order_detail->id > 0) {
                     $erp_supply_order_detail = new ErpSupplyOrderDetail();
                     $erp_supply_order_detail->id_supply_order_detail = (int) $supply_order_detail->id;
                     $erp_supply_order_detail->comment = Tools::getValue('input_comment_' . $row, '');
                     $validation_esod = $erp_supply_order_detail->validateController();
                     // checks erp_supplier_order_detail validity
                     if (count($validation_esod) > 0) {
                         foreach ($validation_esod as $item) {
                             $this->errors[] = $item;
                         }
                         $this->errors[] = Tools::displayError('The ErpIllicopresta Supplier Order Detail is not correct. Please make sure all of the required fields are completed.');
                     } else {
                         $erp_supply_order_detail->save();
                     }
                 }
             }
         } else {
             if (Tools::isSubmit('quantity_received_today_' . $row)) {
                 if (Tools::isSubmit('input_comment_' . $row)) {
                     $comment[Db::getInstance()->Insert_ID()] = Tools::getValue('input_comment_' . $row);
                 }
                 $to_update[$row] = (int) Tools::getValue('quantity_received_today_' . $row);
             }
         }
     }
     // checks if there is something to update
     if (!count($to_update)) {
         $this->errors[] = Tools::displayError($this->l('You did not select any product to update.'));
         return;
     }
     foreach ($to_update as $id_supply_order_detail => $quantity) {
         $supply_order_detail = new SupplyOrderDetail($id_supply_order_detail);
         $supply_order = new SupplyOrder((int) Tools::getValue('id_supply_order'));
         if (Validate::isLoadedObject($supply_order_detail) && Validate::isLoadedObject($supply_order)) {
             // checks if quantity is valid
             // It's possible to receive more quantity than expected in case of a shipping error from the supplier
             if (!Validate::isInt($quantity) || $quantity <= 0) {
                 $this->errors[] = sprintf(Tools::displayError($this->l('Quantity (%d) for product #%d is not valid')), (int) $quantity, (int) $id_supply_order_detail);
             } else {
                 // creates the history
                 $supplier_receipt_history = new SupplyOrderReceiptHistory();
                 $supplier_receipt_history->id_supply_order_detail = (int) $id_supply_order_detail;
                 $supplier_receipt_history->id_employee = (int) $this->context->employee->id;
                 $supplier_receipt_history->employee_firstname = pSQL($this->context->employee->firstname);
                 $supplier_receipt_history->employee_lastname = pSQL($this->context->employee->lastname);
                 $supplier_receipt_history->id_supply_order_state = (int) $supply_order->id_supply_order_state;
                 $supplier_receipt_history->quantity = (int) $quantity;
                 // updates quantity received
                 $supply_order_detail->quantity_received += (int) $quantity;
                 // if current state is "Pending receipt", then we sets it to "Order received in part"
                 if (3 == $supply_order->id_supply_order_state) {
                     $supply_order->id_supply_order_state = 4;
                 }
                 // Adds to stock
                 $warehouse = new Warehouse($supply_order->id_warehouse);
                 if (!Validate::isLoadedObject($warehouse)) {
                     $this->errors[] = Tools::displayError($this->l('The warehouse could not be loaded.'));
                     return;
                 }
                 $price = $supply_order_detail->unit_price_te;
                 // converts the unit price to the warehouse currency if needed
                 if ($supply_order->id_currency != $warehouse->id_currency) {
                     // first, converts the price to the default currency
                     $price_converted_to_default_currency = Tools::convertPrice($supply_order_detail->unit_price_te, $supply_order->id_currency, false);
                     // then, converts the newly calculated pri-ce from the default currency to the needed currency
                     $price = Tools::ps_round(Tools::convertPrice($price_converted_to_default_currency, $warehouse->id_currency, true), 6);
                 }
                 $manager = StockManagerFactory::getManager();
                 $res = $manager->addProduct($supply_order_detail->id_product, $supply_order_detail->id_product_attribute, $warehouse, (int) $quantity, Configuration::get('PS_STOCK_MVT_SUPPLY_ORDER'), $price, true, $supply_order->id);
                 if ($res) {
                     StockAvailable::synchronize($supply_order_detail->id_product);
                 } else {
                     $this->errors[] = Tools::displayError($this->l('Error while adding products to the warehouse.'));
                 }
                 $location = Warehouse::getProductLocation($supply_order_detail->id_product, $supply_order_detail->id_product_attribute, $warehouse->id);
                 $res = Warehouse::setProductlocation($supply_order_detail->id_product, $supply_order_detail->id_product_attribute, $warehouse->id, $location ? $location : '');
                 //-ERP information
                 //
                 if ($res) {
                     $supplier_receipt_history->add();
                     $supply_order_detail->save();
                     $supply_order->save();
                 } else {
                     $this->errors[] = Tools::displayError($this->l('Error while setting warehouse on product record'));
                 }
             }
         }
     }
     if (!count($this->errors)) {
         // display confirm message
         $token = Tools::getValue('token') ? Tools::getValue('token') : $this->token;
         $redirect = self::$currentIndex . '&token=' . $token;
         $this->redirect_after = $redirect . '&conf=4';
     }
 }
开发者ID:prestamodule,项目名称:erpillicopresta,代码行数:101,代码来源:AdminAdvancedSupplyOrder.php


注:本文中的Warehouse::getProductLocation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。