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


PHP Stock::add方法代码示例

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


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

示例1: addProduct

 /**
  * @see StockManagerInterface::addProduct()
  */
 public function addProduct($id_product, $id_product_attribute = 0, Warehouse $warehouse, $quantity, $id_stock_mvt_reason, $price_te, $is_usable = true, $id_supply_order = null)
 {
     if (!Validate::isLoadedObject($warehouse) || !$price_te || !$quantity || !$id_product) {
         return false;
     }
     $price_te = (double) round($price_te, 6);
     if (!StockMvtReason::exists($id_stock_mvt_reason)) {
         $id_stock_mvt_reason = Configuration::get('PS_STOCK_MVT_INC_REASON_DEFAULT');
     }
     $context = Context::getContext();
     $mvt_params = array('id_stock' => null, 'physical_quantity' => $quantity, 'id_stock_mvt_reason' => $id_stock_mvt_reason, 'id_supply_order' => $id_supply_order, 'price_te' => $price_te, 'last_wa' => null, 'current_wa' => null, 'id_employee' => $context->employee->id, 'employee_firstname' => $context->employee->firstname, 'employee_lastname' => $context->employee->lastname, 'sign' => 1);
     $stock_exists = false;
     // switch on MANAGEMENT_TYPE
     switch ($warehouse->management_type) {
         // case CUMP mode
         case 'WA':
             $stock_collection = $this->getStockCollection($id_product, $id_product_attribute, $warehouse->id);
             // if this product is already in stock
             if (count($stock_collection) > 0) {
                 $stock_exists = true;
                 // for a warehouse using WA, there is one and only one stock for a given product
                 $stock = $stock_collection->current();
                 // calculates WA price
                 $last_wa = $stock->price_te;
                 $current_wa = $this->calculateWA($stock, $quantity, $price_te);
                 $mvt_params['id_stock'] = $stock->id;
                 $mvt_params['last_wa'] = $last_wa;
                 $mvt_params['current_wa'] = $current_wa;
                 $stock_params = array('physical_quantity' => $stock->physical_quantity + $quantity, 'price_te' => $current_wa, 'usable_quantity' => $is_usable ? $stock->usable_quantity + $quantity : $stock->usable_quantity, 'id_warehouse' => $warehouse->id);
                 // saves stock in warehouse
                 $stock->hydrate($stock_params);
                 $stock->update();
             } else {
                 $mvt_params['last_wa'] = 0;
                 $mvt_params['current_wa'] = $price_te;
             }
             break;
             // case FIFO / LIFO mode
         // case FIFO / LIFO mode
         case 'FIFO':
         case 'LIFO':
             $stock_collection = $this->getStockCollection($id_product, $id_product_attribute, $warehouse->id, $price_te);
             // if this product is already in stock
             if (count($stock_collection) > 0) {
                 $stock_exists = true;
                 // there is one and only one stock for a given product in a warehouse and at the current unit price
                 $stock = $stock_collection->current();
                 $stock_params = array('physical_quantity' => $stock->physical_quantity + $quantity, 'usable_quantity' => $is_usable ? $stock->usable_quantity + $quantity : $stock->usable_quantity);
                 // updates stock in warehouse
                 $stock->hydrate($stock_params);
                 $stock->update();
                 // sets mvt_params
                 $mvt_params['id_stock'] = $stock->id;
             }
             break;
         default:
             return false;
             break;
     }
     if (!$stock_exists) {
         $stock = new Stock();
         $stock_params = array('id_product_attribute' => $id_product_attribute, 'id_product' => $id_product, 'physical_quantity' => $quantity, 'price_te' => $price_te, 'usable_quantity' => $is_usable ? $quantity : 0, 'id_warehouse' => $warehouse->id);
         // saves stock in warehouse
         $stock->hydrate($stock_params);
         $stock->add();
         $mvt_params['id_stock'] = $stock->id;
     }
     // saves stock mvt
     $stock_mvt = new StockMvt();
     $stock_mvt->hydrate($mvt_params);
     $stock_mvt->add();
     return true;
 }
开发者ID:jicheng17,项目名称:vipinsg,代码行数:76,代码来源:StockManager.php

示例2: flush

    // プログレスバー更新
    $progressPer = $dayCount / $dayCountMax * 100;
    // 全部表示しないで間引く
    if (floor($progressPer % 10) == 0) {
        echo "<script>";
        echo "var progressBar = document.getElementById('progress');";
        echo "var progressBarValue = document.getElementById('progressValue');";
        echo "var currentProcess = document.getElementById('currentProcess');";
        echo "progressBar.value = {$progressPer};";
        echo "progressBarValue.innerHTML = {$progressPer};";
        echo "currentProcess.innerHTML = '{$date->format(Common::DATE_FORMAT)}';";
        echo "</script>";
    }
    // 株価CSVファイルをダウンロード
    $ret = $downloader->downloadCsvFile($date);
    // 株価データを追加
    $stock->add($date);
    // 株価ZIPファイルをダウンロード
    $ret = $mizDownloader->downloadZipFile($date);
    // 株価データを追加
    $stockMiz->add($date);
    // echo "{$date->format(Common::DATE_FORMAT)}</br>";
    ob_flush();
    flush();
    $date->modify("+1 day");
    $dayCount++;
}
?>


开发者ID:KittenEar,项目名称:stock,代码行数:28,代码来源:stock_downloader.php

示例3: ajouter

function ajouter($lang, $ref, $prix, $ecotaxe, $promo, $prix2, $rubrique, $nouveaute, $perso, $poids, $stock, $tva, $ligne, $titre, $chapo, $description, $postscriptum)
{
    $ref = str_replace(" ", "", $ref);
    $ref = str_replace("/", "", $ref);
    $ref = str_replace("+", "", $ref);
    $ref = str_replace(".", "-", $ref);
    $ref = str_replace(",", "-", $ref);
    $ref = str_replace(";", "-", $ref);
    $ref = str_replace("'", "", $ref);
    $ref = str_replace("\n", "", $ref);
    $ref = str_replace("\"", "", $ref);
    $produit = new Produit();
    $produit->charger($ref);
    if ($produit->id) {
        redirige("produit_modifier.php?rubrique={$rubrique}&existe=1");
    }
    $produit = new Produit();
    $prix = str_replace(",", ".", $prix);
    $produit->ref = $ref;
    $produit->datemodif = date("Y-m-d H:i:s");
    $produit->prix = $prix;
    $produit->prix2 = $prix2;
    if ($produit->prix2 == "") {
        $produit->prix2 = $prix;
    }
    $produit->ecotaxe = $ecotaxe;
    $produit->rubrique = $rubrique;
    if ($promo == "on") {
        $produit->promo = 1;
    } else {
        $produit->promo = 0;
    }
    if ($nouveaute == "on") {
        $produit->nouveaute = 1;
    } else {
        $produit->nouveaute = 0;
    }
    if ($ligne == "on") {
        $produit->ligne = 1;
    } else {
        $produit->ligne = 0;
    }
    $produit->perso = $perso;
    $produit->poids = $poids;
    $produit->stock = $stock;
    $produit->tva = str_replace(",", ".", $tva);
    $lastid = $produit->add();
    $produit->id = $lastid;
    $produitdesc = new Produitdesc();
    $produitdesc->chapo = $chapo;
    $produitdesc->description = $description;
    $produitdesc->postscriptum = $postscriptum;
    $produitdesc->produit = $lastid;
    $produitdesc->lang = $lang;
    $produitdesc->titre = $titre;
    $produitdesc->chapo = str_replace("\n", "<br />", $produitdesc->chapo);
    $produitdesc->add();
    $rubcaracteristique = new Rubcaracteristique();
    $caracteristiquedesc = new Caracteristiquedesc();
    $caracval = new Caracval();
    $query = "select * from {$rubcaracteristique->table} where rubrique='" . $produit->rubrique . "'";
    $resul = mysql_query($query);
    while ($row = mysql_fetch_object($resul)) {
        $caracval = new Caracval();
        $deb = "caract";
        $deb2 = "typecaract";
        $val = $row->caracteristique;
        $var = $deb . $val;
        $var2 = $deb2 . $val;
        global ${$var};
        global ${$var2};
        $query2 = "delete from {$caracval->table} where produit='" . $produit->id . "' and caracteristique='" . $row->caracteristique . "'";
        $resul2 = mysql_query($query2);
        if (${$var} != "") {
            if (${$var2} == "c") {
                foreach (${$var} as $selectval) {
                    $caracval->produit = $lastid;
                    $caracval->caracteristique = $row->caracteristique;
                    $caracval->caracdisp = $selectval;
                    $caracval->add();
                }
            } else {
                $caracval->produit = $lastid;
                $caracval->caracteristique = $row->caracteristique;
                $caracval->valeur = ${$var};
                $caracval->add();
            }
        }
    }
    $rubdeclinaison = new Rubdeclinaison();
    $declinaisondesc = new Declinaisondesc();
    $declidisp = new Declidisp();
    $declidispdesc = new Declidispdesc();
    $query = "select * from {$rubdeclinaison->table} where rubrique='" . $rubrique . "'";
    $resul = mysql_query($query);
    while ($row = mysql_fetch_object($resul)) {
        $declinaisondesc->charger($row->declinaison);
        $query2 = "select * from {$declidisp->table} where declinaison='{$row->declinaison}'";
        $resul2 = mysql_query($query2);
        $nbres = mysql_num_rows($resul2);
//.........这里部分代码省略.........
开发者ID:anti-conformiste,项目名称:thelia1,代码行数:101,代码来源:produit_modifier.php

示例4: postProcess

 /**
  * AdminController::postProcess() override
  * @see AdminController::postProcess()
  */
 public function postProcess()
 {
     $this->is_editing_order = false;
     // Checks access
     if (Tools::isSubmit('submitAddsupply_order') && !($this->tabAccess['add'] === '1')) {
         $this->errors[] = Tools::displayError('You do not have permission to add a supply order.');
     }
     if (Tools::isSubmit('submitBulkUpdatesupply_order_detail') && !($this->tabAccess['edit'] === '1')) {
         $this->errors[] = Tools::displayError('You do not have permission to edit an order.');
     }
     // Trick to use both Supply Order as template and actual orders
     if (Tools::isSubmit('is_template')) {
         $_GET['mod'] = 'template';
     }
     // checks if supply order reference is unique
     if (Tools::isSubmit('reference')) {
         // gets the reference
         $ref = pSQL(Tools::getValue('reference'));
         if (Tools::getValue('id_supply_order') != 0 && SupplyOrder::getReferenceById((int) Tools::getValue('id_supply_order')) != $ref) {
             if ((int) SupplyOrder::exists($ref) != 0) {
                 $this->errors[] = Tools::displayError('The reference has to be unique.');
             }
         } elseif (Tools::getValue('id_supply_order') == 0 && (int) SupplyOrder::exists($ref) != 0) {
             $this->errors[] = Tools::displayError('The reference has to be unique.');
         }
     }
     if ($this->errors) {
         return;
     }
     // Global checks when add / update a supply order
     if (Tools::isSubmit('submitAddsupply_order') || Tools::isSubmit('submitAddsupply_orderAndStay')) {
         $this->action = 'save';
         $this->is_editing_order = true;
         // get supplier ID
         $id_supplier = (int) Tools::getValue('id_supplier', 0);
         if ($id_supplier <= 0 || !Supplier::supplierExists($id_supplier)) {
             $this->errors[] = Tools::displayError('The selected supplier is not valid.');
         }
         // get warehouse id
         $id_warehouse = (int) Tools::getValue('id_warehouse', 0);
         if ($id_warehouse <= 0 || !Warehouse::exists($id_warehouse)) {
             $this->errors[] = Tools::displayError('The selected warehouse is not valid.');
         }
         // get currency id
         $id_currency = (int) Tools::getValue('id_currency', 0);
         if ($id_currency <= 0 || (!($result = Currency::getCurrency($id_currency)) || empty($result))) {
             $this->errors[] = Tools::displayError('The selected currency is not valid.');
         }
         // get delivery date
         if (Tools::getValue('mod') != 'template' && strtotime(Tools::getValue('date_delivery_expected')) <= strtotime('-1 day')) {
             $this->errors[] = Tools::displayError('The specified date cannot be in the past.');
         }
         // gets threshold
         $quantity_threshold = Tools::getValue('load_products');
         if (is_numeric($quantity_threshold)) {
             $quantity_threshold = (int) $quantity_threshold;
         } else {
             $quantity_threshold = null;
         }
         if (!count($this->errors)) {
             // forces date for templates
             if (Tools::isSubmit('is_template') && !Tools::getValue('date_delivery_expected')) {
                 $_POST['date_delivery_expected'] = date('Y-m-d h:i:s');
             }
             // specify initial state
             $_POST['id_supply_order_state'] = 1;
             //defaut creation state
             // specify global reference currency
             $_POST['id_ref_currency'] = Currency::getDefaultCurrency()->id;
             // specify supplier name
             $_POST['supplier_name'] = Supplier::getNameById($id_supplier);
             //specific discount check
             $_POST['discount_rate'] = (double) str_replace(array(' ', ','), array('', '.'), Tools::getValue('discount_rate', 0));
         }
         // manage each associated product
         $this->manageOrderProducts();
         // if the threshold is defined and we are saving the order
         if (Tools::isSubmit('submitAddsupply_order') && Validate::isInt($quantity_threshold)) {
             $this->loadProducts((int) $quantity_threshold);
         }
     }
     // Manage state change
     if (Tools::isSubmit('submitChangestate') && Tools::isSubmit('id_supply_order') && Tools::isSubmit('id_supply_order_state')) {
         if ($this->tabAccess['edit'] != '1') {
             $this->errors[] = Tools::displayError('You do not have permission to change the order status.');
         }
         // get state ID
         $id_state = (int) Tools::getValue('id_supply_order_state', 0);
         if ($id_state <= 0) {
             $this->errors[] = Tools::displayError('The selected supply order status is not valid.');
         }
         // get supply order ID
         $id_supply_order = (int) Tools::getValue('id_supply_order', 0);
         if ($id_supply_order <= 0) {
             $this->errors[] = Tools::displayError('The supply order ID is not valid.');
         }
//.........这里部分代码省略.........
开发者ID:zangles,项目名称:lennyba,代码行数:101,代码来源:AdminSupplyOrdersController.php

示例5: associateDeclinaison

 /**
  * 
  * save in stock table if needed this product with 0 to all column (valeur and surplus)
  * 
  * @return boolean if id paramter is false or empty
  */
 protected function associateDeclinaison()
 {
     if (!$this->id) {
         return false;
     }
     $query = "SELECT d.id from " . Declidisp::TABLE . " d LEFT JOIN " . Rubdeclinaison::TABLE . " r ON d.declinaison = r.declinaison WHERE r.rubrique=" . $this->rubrique;
     $resul = $this->query($query);
     while ($resul && ($row = $this->fetch_object($resul))) {
         $stock = new Stock();
         $stock->declidisp = $row->id;
         $stock->produit = $this->id;
         $stock->valeur = 0;
         $stock->surplus = 0;
         $stock->add();
     }
 }
开发者ID:anti-conformiste,项目名称:thelia1,代码行数:22,代码来源:ProductAdmin.class.php


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