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


PHP Product::load_stock方法代码示例

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


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

示例1: get

 /**
  * Get properties of a product object
  *
  * Return an array with product informations
  *
  * @param 	int 	$id     ID of product
  * @param   string  $ref    Product ref
  * @param   string  $ref_ext    Product ref ext
  * @return 	array|mixed data without useless information
  * 
  * @url	GET product/{id}
  * @throws 	RestException
  */
 function get($id = '', $ref = '', $ref_ext = '')
 {
     if (!DolibarrApiAccess::$user->rights->produit->lire) {
         throw new RestException(401);
     }
     $result = $this->product->fetch($id, $ref, $ref_ext);
     if (!$result) {
         throw new RestException(404, 'Product not found');
     }
     if (!DolibarrApi::_checkAccessToResource('product', $this->product->id)) {
         throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
     }
     $this->product->load_stock();
     return $this->_cleanObjectDatas($this->product);
 }
开发者ID:Samara94,项目名称:dolibarr,代码行数:28,代码来源:api_product.class.php

示例2: isLineShippable

 function isLineShippable(&$line, &$TSomme)
 {
     global $conf, $user;
     $db =& $this->db;
     $TSomme[$line->fk_product] += $line->qty_toship;
     if (!isset($line->stock) && $line->fk_product > 0) {
         if (empty($this->TProduct[$line->fk_product])) {
             $produit = new Product($db);
             $produit->fetch($line->fk_product);
             $produit->load_stock(false);
             $this->TProduct[$line->fk_product] = $produit;
         } else {
             $produit =& $this->TProduct[$line->fk_product];
         }
         $line->stock = $produit->stock_reel;
         // Filtre par entrepot de l'utilisateur
         if (!empty($conf->global->SHIPPABLEORDER_ENTREPOT_BY_USER) && !empty($user->array_options['options_entrepot_preferentiel'])) {
             $line->stock = $produit->stock_warehouse[$user->array_options['options_entrepot_preferentiel']]->real;
         } elseif (!empty($conf->global->SHIPPABLEORDER_SPECIFIC_WAREHOUSE)) {
             $line->stock = 0;
             //Récupération des entrepôts valide
             $TIdWarehouse = explode(',', $conf->global->SHIPPABLEORDER_SPECIFIC_WAREHOUSE);
             foreach ($produit->stock_warehouse as $identrepot => $objecttemp) {
                 if (in_array($identrepot, $TIdWarehouse)) {
                     $line->stock += $objecttemp->real;
                 }
             }
         }
     }
     if ($conf->global->SHIPPABLE_ORDER_ALLOW_SHIPPING_IF_NOT_ENOUGH_STOCK) {
         $isShippable = 1;
         $qtyShippable = $line->qty;
         $line->stock = $line->qty;
     } else {
         if ($line->stock <= 0 || $line->qty_toship <= 0) {
             $isShippable = 0;
             $qtyShippable = 0;
         } else {
             if ($TSomme[$line->fk_product] <= $line->stock) {
                 $isShippable = 1;
                 $qtyShippable = $line->qty_toship;
             } else {
                 $isShippable = 2;
                 $qtyShippable = $line->qty_toship - $TSomme[$line->fk_product] + $line->stock;
             }
         }
     }
     $this->TlinesShippable[$line->id] = array('stock' => $line->stock, 'shippable' => $isShippable, 'to_ship' => $line->qty_toship, 'qty_shippable' => $qtyShippable);
     return $isShippable;
 }
开发者ID:ATM-Consulting,项目名称:dolibarr_module_shippableorder,代码行数:50,代码来源:shippableorder.class.php

示例3: setEventMessages

        }
    } else {
        setEventMessages($pdluo->error, null, 'errors');
    }
    header("Location: product.php?id=" . $id);
    exit;
}
/*
 * View
 */
$form = new Form($db);
$formproduct = new FormProduct($db);
if ($id > 0 || $ref) {
    $object = new Product($db);
    $result = $object->fetch($id, $ref);
    $object->load_stock();
    $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
    llxHeader("", $langs->trans("CardProduct" . $object->type), $help_url);
    if ($result > 0) {
        $head = product_prepare_head($object);
        $titre = $langs->trans("CardProduct" . $object->type);
        $picto = $object->type == Product::TYPE_SERVICE ? 'service' : 'product';
        dol_fiche_head($head, 'stock', $titre, 0, $picto);
        dol_htmloutput_events();
        dol_banner_tab($object, 'ref', '', $user->societe_id ? 0 : 1, 'ref');
        print '<div class="fichecenter">';
        print '<div class="underbanner clearboth"></div>';
        print '<table class="border tableforfield" width="100%">';
        if ($conf->productbatch->enabled) {
            print '<tr><td class="titlefield">' . $langs->trans("ManageLotSerial") . '</td><td>';
            print $object->getLibStatut(0, 2);
开发者ID:Albertopf,项目名称:prueba,代码行数:31,代码来源:product.php

示例4:

 print '<table class="nobordernopadding"><tr class="nocellnopadd">';
 print '<td class="nobordernopadding nowrap">';
 print $generic_commande->getNomUrl(1, $viewstatut != 2 ? 0 : $objp->fk_statut);
 print '</td>';
 // Shippable Icon
 if ($objp->fk_statut > 0 && $objp->fk_statut < 3 && !empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) {
     $notshippable = 0;
     $text_info = '';
     $nbprod = 0;
     for ($lig = 0; $lig < count($generic_commande->lines); $lig++) {
         if ($generic_commande->lines[$lig]->product_type == 0) {
             $nbprod++;
             // order contains real products
             $generic_product->id = $generic_commande->lines[$lig]->fk_product;
             if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) {
                 $generic_product->load_stock(true);
                 $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_reel;
             } else {
                 $generic_product->stock_reel = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'];
             }
             // stock order and stock order_supplier
             $stock_order = 0;
             $stock_order_supplier = 0;
             if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) {
                 if (!empty($conf->commande->enabled)) {
                     if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'])) {
                         $generic_product->load_stats_commande(0, '1,2');
                         $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'] = $generic_product->stats_commande['qty'];
                     } else {
                         $generic_product->stats_commande['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'];
                     }
开发者ID:sergioeugenio,项目名称:Dolibarr37_berrypro_Modulo,代码行数:31,代码来源:list_commande.php

示例5:

			dol_fiche_end();


			// List of subproducts
			$prods_arbo = $product->get_arbo_each_prod();
			if (count($prods_arbo) > 0)
			{
				print '<tr><td colspan="2">';
				print '<b>'.$langs->trans("ProductAssociationList").'</b><br>';
				print '<table class="nobordernopadding">';
				foreach($prods_arbo as $value)
				{
					$productstatic->id=$value['id'];
					$productstatic->type=$value['type'];
					$productstatic->ref=$value['fullpath'];
					if ($conf->stock->enabled) $productstatic->load_stock();
					//var_dump($value);
					//print '<pre>'.$productstatic->ref.'</pre>';
					//print $productstatic->getNomUrl(1).'<br>';
					//print $value[0];	// This contains a tr line.
					print '<tr>';
					print '<td>'.$productstatic->getNomUrl(1,'composition').' ('.$value['nb'].') &nbsp &nbsp</td>';
					if ($conf->stock->enabled) print '<td>'.$langs->trans("Stock").' : <b>'.$productstatic->stock_reel.'</b></td>';
					print '</tr>';
				}
				print '</table>';
				print '</td></tr>';
			}

			// Number of parent products
			print '<tr><td>'.$langs->trans("ParentProductsNumber").'</td><td>'.count($prodsfather).'</td>';
开发者ID:nrjacker4,项目名称:crm-php,代码行数:31,代码来源:fiche.php

示例6: Product

print_liste_field_titre($langs->trans('Supplier'), $_SERVER["PHP_SELF"], '', $param, '', 'align="right"', $sortfield, $sortorder);
print "</tr>\n";
// Lignes des champs de filtre
print '<tr class="liste_titre">' . '<td class="liste_titre">&nbsp;</td>' . '<td class="liste_titre"><input class="flat" type="text" name="sref" size="8" value="' . dol_escape_htmltag($sref) . '"></td>' . '<td class="liste_titre"><input class="flat" type="text" name="snom" size="8" value="' . dol_escape_htmltag($snom) . '"></td>';
if (!empty($conf->service->enabled) && $type == 1) {
    print '<td class="liste_titre">&nbsp;</td>';
}
print '<td class="liste_titre">&nbsp;</td>' . '<td class="liste_titre" align="right">&nbsp;</td>' . '<td class="liste_titre" align="right">' . $langs->trans('AlertOnly') . '&nbsp;<input type="checkbox" id="salert" name="salert" ' . (!empty($alertchecked) ? $alertchecked : '') . '></td>' . '<td class="liste_titre" align="right">&nbsp;</td>' . '<td class="liste_titre">&nbsp;</td>' . '<td class="liste_titre" align="right">' . '<input class="liste_titre" name="button_search" type="image" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">' . '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" name="button_removefilter" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">' . '</td>';
print '</tr>';
$prod = new Product($db);
$var = True;
while ($i < ($limit ? min($num, $limit) : $num)) {
    $objp = $db->fetch_object($resql);
    if (!empty($conf->global->STOCK_SUPPORTS_SERVICES) || $objp->fk_product_type == 0) {
        $prod->fetch($objp->rowid);
        $prod->load_stock();
        // Multilangs
        if (!empty($conf->global->MAIN_MULTILANGS)) {
            $sql = 'SELECT label';
            $sql .= ' FROM ' . MAIN_DB_PREFIX . 'product_lang';
            $sql .= ' WHERE fk_product = ' . $objp->rowid;
            $sql .= ' AND lang = "' . $langs->getDefaultLang() . '"';
            $sql .= ' LIMIT 1';
            $resqlm = $db->query($sql);
            if ($resqlm) {
                $objtp = $db->fetch_object($resqlm);
                if (!empty($objtp->label)) {
                    $objp->label = $objtp->label;
                }
            }
        }
开发者ID:Albertopf,项目名称:prueba,代码行数:31,代码来源:replenish.php

示例7: run_trigger

 /**
  * Function called when a Dolibarrr business event is done.
  * All functions "run_trigger" are triggered if file
  * is inside directory core/triggers
  *
  * 	@param		string		$action		Event action code
  * 	@param		Object		$object		Object
  * 	@param		User		$user		Object user
  * 	@param		Translate	$langs		Object langs
  * 	@param		conf		$conf		Object conf
  * 	@return		int						<0 if KO, 0 if no triggered ran, >0 if OK
  */
 public function run_trigger($action, $object, $user, $langs, $conf)
 {
     if ($action === 'ORDER_VALIDATE') {
         global $conf, $db;
         if ($conf->global->CREATE_OF_ON_ORDER_VALIDATE) {
             define('INC_FROM_DOLIBARR', true);
             dol_include_once('/product/class/product.class.php');
             dol_include_once('/of/config.php');
             dol_include_once('/of/class/ordre_fabrication_asset.class.php');
             $PDOdb = new TPDOdb();
             foreach ($object->lines as $line) {
                 // Uniquement si c'est un produit
                 if (!empty($line->fk_product) && $line->fk_product_type == 0) {
                     // On charge le produit pour vérifier son stock
                     $prod = new Product($db);
                     $prod->fetch($line->fk_product);
                     $prod->load_stock();
                     if ($prod->stock_reel < $line->qty) {
                         $assetOF = new TAssetOF();
                         $assetOF->fk_commande = $_REQUEST['id'];
                         $assetOF->fk_soc = $object->socid;
                         $assetOF->addLine($PDOdb, $line->fk_product, 'TO_MAKE', $line->qty);
                         $assetOF->save($PDOdb);
                     }
                 }
             }
         }
     } elseif ($action === 'ORDER_CANCEL') {
         if ($conf->global->DELETE_OF_ON_ORDER_CANCEL) {
             define('INC_FROM_DOLIBARR', true);
             dol_include_once('/of/config.php');
             dol_include_once('/of/class/ordre_fabrication_asset.class.php');
             $PDOdb = new TPDOdb();
             // On récupère les identifiants des of créés à partir de cette commande
             $TID_OF_command = TAssetOF::getTID_OF_command($_REQUEST['id']);
             foreach ($TID_OF_command as $id_of) {
                 $asset = new TAssetOF();
                 $asset->load($PDOdb, $id_of);
                 if ($asset->status == "DRAFT" || $asset->status == "VALID") {
                     $asset->delete($PDOdb);
                 }
             }
         }
     } elseif ($action === 'TASK_TIMESPENT_CREATE') {
         if ($conf->workstation->enabled) {
             define('INC_FROM_DOLIBARR', true);
             dol_include_once('/of/config.php');
             dol_include_once('/of/class/ordre_fabrication_asset.class.php');
             $PDOdb = new TPDOdb();
             $PDOdb->Execute("SELECT rowid \n\t\t\t\t\t\tFROM " . MAIN_DB_PREFIX . "asset_workstation_of \n\t\t\t\t\t\tWHERE fk_project_task=" . $object->id);
             if ($obj = $PDOdb->Get_line()) {
                 $wsof = new TAssetWorkstationOF();
                 $wsof->load($PDOdb, $obj->rowid);
                 $wsof->nb_hour_real = ($object->duration_effective + $object->timespent_duration) / 3600;
                 // Parce que Dolibarr mets le THM à jour après la création de la tâche :/
                 $sql = "UPDATE " . MAIN_DB_PREFIX . "projet_task_time";
                 $sql .= " SET thm = (SELECT thm FROM " . MAIN_DB_PREFIX . "user WHERE rowid = " . $object->timespent_fk_user . ")";
                 // set average hour rate of user
                 $sql .= " WHERE rowid = " . $object->timespent_id;
                 $object->db->query($sql);
                 $wsof->db =& $object->db;
                 $wsof->save($PDOdb);
             }
         }
     } elseif ($action === 'ORDERSUPPLIER_ADD_LIVRAISON') {
         global $db;
         if ($conf->of->enabled) {
             define('INC_FROM_DOLIBARR', true);
             dol_include_once('/of/config.php');
             dol_include_once('/of/class/ordre_fabrication_asset.class.php');
             $resql = $db->query('SELECT fk_statut FROM llx_commande_fournisseur WHERE rowid = ' . $_REQUEST['id']);
             $res = $db->fetch_object($resql);
             if ($res->fk_statut == 5) {
                 // La livraison est totale
                 //On cherche l'OF lié
                 $resql = $db->query("SELECT fk_source \n\t\t\t\t\t\t\t\t\t\t\tFROM " . MAIN_DB_PREFIX . "element_element \n\t\t\t\t\t\t\t\t\t\t\tWHERE fk_target = " . $_REQUEST['id'] . " \n\t\t\t\t\t\t\t\t\t\t\t\tAND sourcetype = 'ordre_fabrication' \n\t\t\t\t\t\t\t\t\t\t\t\tAND targettype = 'order_supplier'");
                 $res = $db->fetch_object($resql);
                 $id_of = $res->fk_source;
                 if ($id_of > 0) {
                     $of = new TAssetOF();
                     $of->load($PDOdb, $id_of);
                     if ($of->status != 'CLOSE') {
                         $of->closeOF($PDOdb);
                         setEventMessage($langs->trans('OFAttachedClosedAutomatically', '<a href="' . dol_buildpath('/of/fiche_of.php?id=' . $id_of, 2) . '">' . $of->numero . '</a>'));
                     }
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:ATM-Consulting,项目名称:dolibarr_module_of,代码行数:101,代码来源:interface_99_modof_oftrigger.class.php

示例8: price

             if ($product_fourn->product_fourn_price_id > 0) {
                 if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) {
                     $htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1);
                     print $form->textwithpicto(price($product_fourn->fourn_unitprice) . ' ' . $langs->trans("HT"), $htmltext);
                 } else {
                     print price($product_fourn->fourn_unitprice) . ' ' . $langs->trans("HT");
                 }
             }
         }
     }
     print '</td>';
 }
 if (!empty($conf->stock->enabled) && $user->rights->stock->lire && $type != 1) {
     if ($objp->fk_product_type != 1) {
         $product_static->id = $objp->rowid;
         $product_static->load_stock();
     }
 }
 // Desired stock
 if (!empty($arrayfields['p.desiredstock']['checked'])) {
     print '<td align="right">';
     if ($objp->fk_product_type != 1) {
         print $objp->desiredstock;
     }
     print '</td>';
 }
 // Desired stock
 if (!empty($arrayfields['p.tobatch']['checked'])) {
     print '<td align="center">';
     print yn($objp->tobatch);
     print '</td>';
开发者ID:Albertopf,项目名称:prueba,代码行数:31,代码来源:list.php

示例9: addline

 /**
  * Add a expedition line.
  * If STOCK_WAREHOUSE_NOT_REQUIRED_FOR_SHIPMENTS is set, you can add a shipment line, with no stock source defined
  * If STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT is not set, you can add a shipment line, even if not enough into stock
  *
  * @param 	int		$entrepot_id		Id of warehouse
  * @param 	int		$id					Id of source line (order line)
  * @param 	int		$qty				Quantity
  * @param	array		$array_options		extrafields array
  * @return	int							<0 if KO, >0 if OK
  */
 function addline($entrepot_id, $id, $qty, $array_options = 0)
 {
     global $conf, $langs;
     $num = count($this->lines);
     $line = new ExpeditionLigne($this->db);
     $line->entrepot_id = $entrepot_id;
     $line->origin_line_id = $id;
     $line->qty = $qty;
     $orderline = new OrderLine($this->db);
     $orderline->fetch($id);
     if (!empty($conf->stock->enabled) && !empty($orderline->fk_product)) {
         $fk_product = $orderline->fk_product;
         if (!($entrepot_id > 0) && empty($conf->global->STOCK_WAREHOUSE_NOT_REQUIRED_FOR_SHIPMENTS)) {
             $langs->load("errors");
             $this->error = $langs->trans("ErrorWarehouseRequiredIntoShipmentLine");
             return -1;
         }
         if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT) {
             // Check must be done for stock of product into warehouse if $entrepot_id defined
             $product = new Product($this->db);
             $result = $product->fetch($fk_product);
             $product_type = $product->type;
             if ($entrepot_id > 0) {
                 $product->load_stock();
                 $product_stock = $product->stock_warehouse[$entrepot_id]->real;
             } else {
                 $product_stock = $product->stock_reel;
             }
             if ($product_type == 0 && $product_stock < $qty) {
                 $this->error = $langs->trans('ErrorStockIsNotEnough');
                 $this->db->rollback();
                 return -3;
             }
         }
     }
     // extrafields
     if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) {
         // For avoid conflicts if trigger used
         $line->array_options = $array_options;
     }
     $this->lines[$num] = $line;
 }
开发者ID:Albertopf,项目名称:prueba,代码行数:53,代码来源:expedition.class.php

示例10: Product

 /**
  *	Add a movement of stock (in one direction only)
  *
  *	@param		User	$user			User object
  *	@param		int		$fk_product		Id of product
  *	@param		int		$entrepot_id	Id of warehouse
  *	@param		int		$qty			Qty of movement (can be <0 or >0)
  *	@param		int		$type			Direction of movement:
  *										0=input (stock increase after stock transfert), 1=output (stock decrease after stock transfer),
  *										2=output (stock decrease), 3=input (stock increase)
  *	@param		int		$price			Unit price HT of product, used to calculate average weighted price (PMP in french). If 0, average weighted price is not changed.
  *	@param		string	$label			Label of stock movement
  *	@param		string	$datem			Force date of movement
  *	@param		date	$eatby			eat-by date
  *	@param		date	$sellby			sell-by date
  *	@param		string	$batch			batch number
  *	@param		boolean	$skip_sellby	If set to true, stock mouvement is done without impacting batch record
  *	@return		int						<0 if KO, 0 if fk_product is null, >0 if OK
  */
 function _create($user, $fk_product, $entrepot_id, $qty, $type, $price = 0, $label = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $skip_sellby = false)
 {
     global $conf, $langs;
     require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
     $error = 0;
     dol_syslog(get_class($this) . "::_create start userid={$user->id}, fk_product={$fk_product}, warehouse={$entrepot_id}, qty={$qty}, type={$type}, price={$price} label={$label}");
     // Clean parameters
     if (empty($price)) {
         $price = 0;
     }
     if (empty($fk_product)) {
         return 0;
     }
     $now = !empty($datem) ? $datem : dol_now();
     $this->db->begin();
     $product = new Product($this->db);
     $result = $product->fetch_opt($fk_product);
     if ($result < 0) {
         dol_print_error('', "Failed to fetch product");
         return -1;
     }
     $product->load_stock();
     // Define if we must make the stock change (If product type is a service or if stock is used also for services)
     $movestock = 0;
     if ($product->type != 1 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
         $movestock = 1;
     }
     if ($movestock && $entrepot_id > 0) {
         if (!empty($this->origin)) {
             $origintype = $this->origin->element;
             $fk_origin = $this->origin->id;
         } else {
             $origintype = '';
             $fk_origin = 0;
         }
         $sql = "INSERT INTO " . MAIN_DB_PREFIX . "stock_mouvement";
         $sql .= " (datem, fk_product, fk_entrepot, value, type_mouvement, fk_user_author, label, price, fk_origin, origintype)";
         $sql .= " VALUES ('" . $this->db->idate($now) . "', " . $fk_product . ", " . $entrepot_id . ", " . $qty . ", " . $type . ",";
         $sql .= " " . $user->id . ",";
         $sql .= " '" . $this->db->escape($label) . "',";
         $sql .= " '" . price2num($price) . "',";
         $sql .= " '" . $fk_origin . "',";
         $sql .= " '" . $origintype . "'";
         $sql .= ")";
         dol_syslog(get_class($this) . "::_create sql=" . $sql, LOG_DEBUG);
         $resql = $this->db->query($sql);
         if ($resql) {
             $mvid = $this->db->last_insert_id(MAIN_DB_PREFIX . "stock_mouvement");
         } else {
             $this->error = $this->db->lasterror();
             dol_syslog(get_class($this) . "::_create " . $this->error, LOG_ERR);
             $error = -1;
         }
         // Define current values for qty and pmp
         $oldqty = $product->stock_reel;
         $oldqtywarehouse = 0;
         $oldpmp = $product->pmp;
         $oldpmpwarehouse = 0;
         // Test if there is already a record for couple (warehouse / product)
         $num = 0;
         if (!$error) {
             $sql = "SELECT rowid, reel, pmp FROM " . MAIN_DB_PREFIX . "product_stock";
             $sql .= " WHERE fk_entrepot = " . $entrepot_id . " AND fk_product = " . $fk_product;
             dol_syslog(get_class($this) . "::_create sql=" . $sql);
             $resql = $this->db->query($sql);
             if ($resql) {
                 $obj = $this->db->fetch_object($resql);
                 if ($obj) {
                     $num = 1;
                     $oldqtywarehouse = $obj->reel;
                     $oldpmpwarehouse = $obj->pmp;
                     $fk_product_stock = $obj->rowid;
                 }
                 $this->db->free($resql);
             } else {
                 $this->error = $this->db->lasterror();
                 dol_syslog(get_class($this) . "::_create echec update " . $this->error, LOG_ERR);
                 $error = -2;
             }
         }
         // Calculate new PMP.
//.........这里部分代码省略.........
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:101,代码来源:mouvementstock.class.php

示例11: multicreate

 /**
  *      Create object into database
  *      @param      User	$user        	User that create
  *      @param      Array	$toPrint	    Array with products to print
  *      @return     int         			<0 if KO, Id of created object if OK
  */
 function multicreate($user, $toPrint)
 {
     global $conf, $langs;
     $error = 0;
     require_once DOL_DOCUMENT_ROOT . "/product/class/product.class.php";
     $product = new Product($this->db);
     foreach ($toPrint as $prodid) {
         $result = $product->fetch($prodid);
         if ($result) {
             if ($conf->stock->enabled) {
                 $product->load_stock();
                 $qty = $product->stock_reel;
             }
         }
         $res = $this->fetch($this->id, $product->id);
         if ($res == 1) {
             $qty = $this->qty + $qty;
             $this->qty = $qty;
             $res = $this->update($user, $notrigger);
             if ($res != 1) {
                 $error++;
                 $this->errors[] = "Error " . $this->db->lasterror();
             }
         } else {
             // Insert request
             $sql = "INSERT INTO " . MAIN_DB_PREFIX . "labelprint(";
             $sql .= "entity,";
             $sql .= "fk_product,";
             $sql .= "qty,";
             $sql .= "fk_user,";
             $sql .= "datec,";
             $sql .= "price_level";
             $sql .= ") VALUES (";
             $sql .= " " . $conf->entity . ",";
             $sql .= " " . $product->id . ",";
             $sql .= " " . $qty . ",";
             $sql .= " " . $user->id . ",";
             $sql .= " " . (!isset($this->datec) || dol_strlen($this->datec) == 0 ? 'NULL' : $this->db->idate($this->datec)) . ",";
             $sql .= " " . (!isset($this->price_level) ? 1 : $this->price_level) . "";
             $sql .= ")";
             //$this->db->begin();
             dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG);
             $resql = $this->db->query($sql);
             if (!$resql) {
                 $error++;
                 $this->errors[] = "Error " . $this->db->lasterror();
             }
         }
     }
     if (!$error) {
         $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "labelprint");
     }
     // Commit or rollback
     if ($error) {
         foreach ($this->errors as $errmsg) {
             dol_syslog(get_class($this) . "::multicreate " . $errmsg, LOG_ERR);
             $this->error .= $this->error ? ', ' . $errmsg : $errmsg;
         }
         //$this->db->rollback();
         return -1 * $error;
     } else {
         //$this->db->commit();
         return $this->id;
     }
 }
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:71,代码来源:labelprint.class.php

示例12: switch

 function import2Dolibarr($object, $typeimport)
 {
     global $conf;
     global $langs;
     $this->process_msg = '';
     $error = 0;
     $fp = @fopen($this->filename, "r");
     if ($fp) {
         switch ($object) {
             case 'ImportStock':
                 $doliprod = new Product($this->db);
                 $i = 0;
                 while ($ligne = fgetcsv($fp, 1000, ";")) {
                     $doliprod->id = '';
                     $i++;
                     if ($this->firstline && $i == 1) {
                         continue;
                     }
                     if ($conf->global->IMPORT_BARCODE) {
                         $ligne[0] = $this->get_product_by_barcode($ligne[0]);
                     }
                     if ($doliprod->fetch('', $ligne[0]) <= 0) {
                         $this->process_msg .= $langs->trans("ErrProdNoExist", $ligne[0], $doliprod->error) . "\n";
                     } else {
                         $pid = $doliprod->id;
                         $doliprod->ref = $ligne[0];
                         $entrepot = $ligne[1];
                         $newstock = $ligne[2];
                         $price = $ligne[3];
                         if ($conf->global->IMPORT_TOTAL_STOCK) {
                             $doliprod->load_stock();
                             dol_syslog("stock produit " . $doliprod->stock_warehouse[$entrepot]->real . " entrepot " . $entrepot . " " . $doliprod->stock_reel, LOG_DEBUG);
                             // correction de stock
                             $delta = 0;
                             if ($newstock > $doliprod->stock_warehouse[$entrepot]->real) {
                                 $delta = $newstock - $doliprod->stock_warehouse[$entrepot]->real;
                                 $sens = 0;
                             } elseif ($newstock < $doliprod->stock_warehouse[$entrepot]->real) {
                                 $delta = $doliprod->stock_warehouse[$entrepot]->real - $newstock;
                                 $sens = 1;
                             }
                             if ($delta) {
                                 $res = $doliprod->correct_stock($this->user, $entrepot, $delta, $sens, $langs->trans("StockCorrection"), $price);
                                 if ($res < 0) {
                                     $this->process_msg .= $langs->trans("ErrMovStock", $ligne[0], $doliprod->error) . "\n";
                                     $error++;
                                 }
                             }
                             dol_syslog("maj stock delta = " . $delta . " sens " . $sens, LOG_DEBUG);
                         } else {
                             $res = $doliprod->correct_stock($this->user, $entrepot, abs($newstock), $newstock > 0 ? 0 : 1, $langs->trans("StockCorrection"), $price);
                             if ($res < 0) {
                                 $this->process_msg .= $langs->trans("ErrMovStock", $ligne[0], $doliprod->error) . "\n";
                                 $error++;
                             }
                         }
                     }
                 }
                 break;
             case 'ImportProduct':
                 //$doliprod = new Product($this->db);
                 $i = 0;
                 while ($ligne = fgetcsv($fp, 1000, ";")) {
                     $i++;
                     $doliprod = new Product($this->db);
                     $doliprod->id = '';
                     if ($this->firstline && $i == 1) {
                         continue;
                     }
                     if ($doliprod->fetch('', $ligne[0]) < 0) {
                         $this->process_msg .= $langs->trans("ErrProdNoExist", $ligne[0], $doliprod->error) . "\n";
                     } else {
                         $pid = $doliprod->id;
                         $doliprod->ref = $ligne[0];
                         if (!empty($ligne[1])) {
                             $doliprod->libelle = $ligne[1];
                         }
                         if (!empty($ligne[2])) {
                             $doliprod->status = $ligne[2];
                         }
                         $doliprod->status_buy = 1;
                         if (!empty($ligne[3])) {
                             $doliprod->description = $ligne[3];
                         }
                         if (!empty($ligne[4])) {
                             $doliprod->price = $ligne[4];
                         }
                         if (!empty($ligne[5])) {
                             $doliprod->tva_tx = $ligne[5];
                         }
                         if (!empty($ligne[6])) {
                             $doliprod->weight = $ligne[6];
                         }
                         if (!empty($ligne[7])) {
                             $doliprod->volume = $ligne[7];
                         }
                         if (!empty($ligne[9])) {
                             $doliprod->barcode = $ligne[9];
                         }
                         if (!empty($ligne[9])) {
//.........这里部分代码省略.........
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:101,代码来源:importator.class.php

示例13: _fiche_ligne

function _fiche_ligne(&$form, &$of, $type)
{
    global $db, $conf, $langs, $hookmanager;
    //TODO rules guys ! To Facto ! AA
    $formProduct = new FormProduct($db);
    $PDOdb = new TPDOdb();
    $TRes = array();
    foreach ($of->TAssetOFLine as $k => &$TAssetOFLine) {
        $product =& $TAssetOFLine->product;
        if (is_null($product)) {
            $product = new Product($db);
            $product->fetch($TAssetOFLine->fk_product);
            $product->fetch_optionals();
        }
        $conditionnement = $TAssetOFLine->conditionnement;
        if (!empty($conf->asset->enabled)) {
            $TAssetType = new TAsset_type();
            $TAssetType->load($PDOdb, $product->array_options['options_type_asset']);
            $conditionnement_unit = $TAssetType->measuring_units == 'unit' || $TAssetType->gestion_stock == 'UNIT' ? 'unité(s)' : $TAssetOFLine->libUnite();
        } else {
            $conditionnement_unit = 'unité(s)';
            // TODO translate
        }
        //$conditionnement_unit = $TAssetOFLine->libUnite();
        if ($TAssetOFLine->measuring_units != 'unit' && !empty($TAssetOFLine->measuring_units)) {
            $conditionnement_label = ' / ' . $conditionnement . " " . $conditionnement_unit;
            $conditionnement_label_edit = ' par ' . $form->texte('', 'TAssetOFLine[' . $k . '][conditionnement]', $conditionnement, 5, 5, '', '') . $conditionnement_unit;
        } else {
            $conditionnement_label = $conditionnement_label_edit = '';
        }
        if ($TAssetOFLine->type == "NEEDED" && $type == "NEEDED") {
            $stock_needed = TAssetOF::getProductStock($product->id);
            $TLine = array('id' => $TAssetOFLine->getId(), 'idprod' => $form->hidden('TAssetOFLine[' . $k . '][fk_product]', $product->id), 'lot_number' => $of->status == 'DRAFT' ? $form->texte('', 'TAssetOFLine[' . $k . '][lot_number]', $TAssetOFLine->lot_number, 15, 50, 'type_product="NEEDED" fk_product="' . $product->id . '" rel="lot-' . $TAssetOFLine->getId() . '" ', 'TAssetOFLineLot') : $TAssetOFLine->lot_number, 'libelle' => $product->getNomUrl(1) . ' ' . $product->label . ' - ' . ($stock_needed > 0 ? $langs->trans("Stock") . " : " . $stock_needed : '<span style="color:red;font-weight:bold;">' . $langs->trans("Stock") . " : " . $stock_needed . '</span>') . _fiche_ligne_asset($PDOdb, $form, $of, $TAssetOFLine, 'NEEDED'), 'qty_needed' => $TAssetOFLine->qty_needed . $conditionnement_label, 'qty' => $of->status == 'DRAFT' ? $form->texte('', 'TAssetOFLine[' . $k . '][qty]', $TAssetOFLine->qty, 5, 50) : $TAssetOFLine->qty, 'qty_used' => $of->status == 'OPEN' || $of->status == 'CLOSE' ? $form->texte('', 'TAssetOFLine[' . $k . '][qty_used]', $TAssetOFLine->qty_used, 5, 50) : $TAssetOFLine->qty_used, 'qty_toadd' => $TAssetOFLine->qty - $TAssetOFLine->qty_used, 'workstations' => $conf->workstation->enabled ? $TAssetOFLine->visu_checkbox_workstation($db, $of, $form, 'TAssetOFLine[' . $k . '][fk_workstation][]') : '', 'delete' => $form->type_aff == 'edit' && ($of->status == 'DRAFT' || !empty($conf->global->OF_USE_DESTOCKAGE_PARTIEL) && $of->status != 'CLOSE' && empty($TAssetOFLine->qty_used)) ? '<a href="javascript:deleteLine(' . $TAssetOFLine->getId() . ',\'NEEDED\');">' . img_picto('Supprimer', 'delete.png') . '</a>' : '', 'fk_entrepot' => !empty($conf->global->ASSET_MANUAL_WAREHOUSE) && ($of->status == 'DRAFT' || $of->status == 'VALID') && $form->type_aff == 'edit' ? $formProduct->selectWarehouses($TAssetOFLine->fk_entrepot, 'TAssetOFLine[' . $k . '][fk_entrepot]', '', 0, 0, $TAssetOFLine->fk_product) : $TAssetOFLine->getLibelleEntrepot($PDOdb), 'note_private' => $of->status == 'DRAFT' ? $form->zonetexte('', 'TAssetOFLine[' . $k . '][note_private]', $TAssetOFLine->note_private, 50, 1) : $TAssetOFLine->note_private);
            $action = $form->type_aff;
            $parameter = array('of' => &$of, 'line' => &$TLine, 'type' => 'NEEDED');
            $res = $hookmanager->executeHooks('lineObjectOptions', $parameter, $TAssetOFLine, $action);
            if ($res > 0 && !empty($hookmanager->resArray)) {
                $TLine = $hookmanager->resArray;
            }
            $TRes[] = $TLine;
        } elseif ($TAssetOFLine->type == "TO_MAKE" && $type == "TO_MAKE") {
            if (empty($TAssetOFLine->TFournisseurPrice)) {
                $TAssetOFLine->loadFournisseurPrice($PDOdb);
            }
            // Permet de sélectionner par défaut "(Fournisseur "Interne" => Fabrication interne)" si le produit TO_MAKE n'a pas de stock lorsqu'on est en mode edit et que la ligne TO_MAKE n'a pas encore de prix fournisseur enregistré
            dol_include_once('/product/class/product.class.php');
            $p = new Product($db);
            $selected = 0;
            if ($p->fetch($TAssetOFLine->fk_product)) {
                $p->load_stock();
                $p->stock_reel;
                if ($TAssetOFLine->type === 'TO_MAKE' && $p->stock_reel <= 0 && $_REQUEST['action'] === 'edit') {
                    $selected = -2;
                }
            }
            // *************************************************************
            $Tab = array();
            foreach ($TAssetOFLine->TFournisseurPrice as &$objPrice) {
                $label = "";
                //Si on a un prix fournisseur pour le produit
                if ($objPrice->price > 0) {
                    $unit = $objPrice->quantity == 1 ? 'Unité' : 'Unités';
                    $label .= floatval($objPrice->price) . ' ' . $conf->currency . ' - ' . $objPrice->quantity . ' ' . $unit . ' -';
                }
                //Affiche le nom du fournisseur
                $label .= ' (Fournisseur "' . utf8_encode($objPrice->name) . '"';
                //Prix unitaire minimum si renseigné dans le PF
                if ($objPrice->quantity > 0) {
                    ' ' . $objPrice->quantity . ' pièce(s) min,';
                }
                //Affiche le type du PF :
                if ($objPrice->compose_fourni) {
                    //			soit on fabrique les composants
                    $label .= ' => Fabrication interne';
                } elseif ($objPrice->quantity <= 0) {
                    //			soit on a le produit finis déjà en stock
                    $label .= ' => Sortie de stock';
                }
                if ($objPrice->quantity > 0) {
                    //				soit on commande a un fournisseur
                    $label .= ' => Commande fournisseur';
                }
                $label .= ")";
                $Tab[$objPrice->rowid] = array('label' => $label, 'compose_fourni' => $objPrice->compose_fourni ? $objPrice->compose_fourni : 0);
            }
            if ($conf->nomenclature->enabled) {
                dol_include_once('/nomenclature/class/nomenclature.class.php');
                if ($of->status == 'DRAFT' && !$TAssetOFLine->nomenclature_valide) {
                    $TNomenclature = TNomenclature::get($PDOdb, $TAssetOFLine->fk_product, true);
                    if (count($TNomenclature) > 0) {
                        $nomenclature = '<div>' . $form->combo('', 'TAssetOFLine[' . $k . '][fk_nomenclature]', $TNomenclature, $TAssetOFLine->fk_nomenclature);
                        if ($form->type_aff == 'edit') {
                            $nomenclature .= '<a href="#" class="valider_nomenclature" data-id_of="' . $of->getId() . '" data-product="' . $TAssetOFLine->fk_product . '" data-of_line="' . $TAssetOFLine->rowid . '">Valider</a>';
                        } else {
                            $nomenclature .= " - Nomenclature à sélectionner";
                        }
                        $nomenclature .= '</div>';
                    } else {
                        $nomenclature = '';
                    }
//.........这里部分代码省略.........
开发者ID:ATM-Consulting,项目名称:dolibarr_module_of,代码行数:101,代码来源:fiche_of.php

示例14: addMoreLine

 function addMoreLine($parameters, &$object, &$action, $hookmanager)
 {
     global $db, $conf, $langs;
     if (!empty($conf->global->OF_SHOW_QTY_THEORIQUE_MOINS_OF)) {
         $langs->load('asset@asset');
         dol_include_once('/product/class/procudt.class.php');
         $product = new Product($db);
         $fk_product = GETPOST('id', 'int');
         $ref_product = GETPOST('ref', 'alpha');
         $f = $product->fetch($fk_product, $ref_product);
         if ($f > 0) {
             $product->load_stock();
             list($qty_to_make, $qty_needed) = $this->_calcQtyOfProductInOf($db, $conf, $product);
             $qty = $product->stock_theorique + $qty_to_make - $qty_needed;
             print '<tr>';
             print '<td>' . $langs->trans('ofLabelQtyTheoriqueMoinsOf') . '</td>';
             print '<td>' . $langs->trans('ofResultQty', $qty, $qty_to_make, $qty_needed) . '</td>';
             print '</tr>';
         }
     }
 }
开发者ID:ATM-Consulting,项目名称:dolibarr_module_of,代码行数:21,代码来源:actions_of.class.php

示例15: Product

	}
}

// Transfer stock from a warehouse to another warehouse
if ($action == "transfert_stock" && ! $_POST["cancel"])
{
	if ($_POST["id_entrepot_source"] <> $_POST["id_entrepot_destination"])
	{
		if (is_numeric($_POST["nbpiece"]) && $id)
		{
			$product = new Product($db);
			$result=$product->fetch($id);

			$db->begin();

			$product->load_stock();	// Load array product->stock_warehouse

			// Define value of products moved
			$pricesrc=0;
			if (isset($product->stock_warehouse[$_POST["id_entrepot_source"]]->pmp)) $pricesrc=$product->stock_warehouse[$_POST["id_entrepot_source"]]->pmp;
			$pricedest=$pricesrc;

			//print 'price src='.$pricesrc.', price dest='.$pricedest;exit;

			// Remove stock
			$result1=$product->correct_stock(
    			$user,
    			$_POST["id_entrepot_source"],
    			$_POST["nbpiece"],
    			1,
    			$_POST["label"],
开发者ID:nrjacker4,项目名称:crm-php,代码行数:31,代码来源:product.php


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