35require
'../../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productstockentrepot.class.php';
43if (isModEnabled(
'productbatch')) {
44 require_once DOL_DOCUMENT_ROOT.
'/product/class/productbatch.class.php';
46if (isModEnabled(
'project')) {
47 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
51if (isModEnabled(
'variants')) {
52 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductAttribute.class.php';
53 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductAttributeValue.class.php';
54 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
55 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination2ValuePair.class.php';
59$langs->loadlangs(array(
'products',
'suppliers',
'orders',
'bills',
'stocks',
'sendings',
'margins'));
60if (isModEnabled(
'productbatch')) {
61 $langs->load(
"productbatch");
64$backtopage =
GETPOST(
'backtopage',
'alpha');
65$action =
GETPOST(
'action',
'aZ09');
66$cancel =
GETPOST(
'cancel',
'alpha');
70$stocklimit = (float)
GETPOST(
'seuil_stock_alerte');
71$desiredstock =
GETPOST(
'desiredstock');
72$cancel =
GETPOST(
'cancel',
'alpha');
73$fieldid = GETPOSTISSET(
"ref") ?
'ref' :
'rowid';
77$batchnumber =
GETPOST(
'batch_number',
'san_alpha');
78if (!empty($batchnumber)) {
79 $batchnumber = trim($batchnumber);
81$cost_price =
GETPOST(
'cost_price',
'alpha');
85 $socid = $user->socid;
92$extrafields->fetch_name_optionals_label(
$object->table_element);
94if ($id > 0 || !empty($ref)) {
95 $result =
$object->fetch($id, $ref);
98if (empty($id) && !empty(
$object->id)) {
102$modulepart =
'product';
107if (!empty($canvas)) {
108 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
109 $objcanvas =
new Canvas($db, $action);
110 $objcanvas->getCanvas(
'stockproduct',
'card', $canvas);
114$hookmanager->initHooks(array(
'stockproductcard',
'globalcard'));
120$usercancreadprice =
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') ? $user->hasRight(
'product',
'product_advance',
'read_prices') : $user->hasRight(
'product',
'lire');
121$usercanupdatestock = $user->hasRight(
'stock',
'mouvement',
'creer');
124 $label = $langs->trans(
'Service');
125 $usercancreadprice =
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') ? $user->hasRight(
'service',
'service_advance',
'read_prices') : $user->hasRight(
'service',
'lire');
129 if (
$object->type == $object::TYPE_PRODUCT) {
132 if (
$object->type == $object::TYPE_SERVICE) {
136 restrictedArea($user,
'produit|service', $id,
'product&product',
'',
'', $fieldid);
148$parameters = array(
'id' => $id,
'ref' => $ref,
'objcanvas' => $objcanvas);
149$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
154if ($action ==
'setcost_price' && $usercancreate) {
169if ($action ==
'addlimitstockwarehouse' && $usercancreate) {
170 $seuil_stock_alerte =
GETPOST(
'seuil_stock_alerte');
171 $desiredstock =
GETPOST(
'desiredstock');
174 if ($seuil_stock_alerte ==
'') {
175 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"StockLimit")),
null,
'errors');
178 if ($desiredstock ==
'') {
179 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DesiredStock")),
null,
'errors');
186 if ($pse->fetch(0, $id,
GETPOSTINT(
'fk_entrepot')) > 0) {
188 $pse->seuil_stock_alerte = $seuil_stock_alerte;
189 $pse->desiredstock = $desiredstock;
190 if ($pse->update($user) > 0) {
191 setEventMessages($langs->trans(
'ProductStockWarehouseUpdated'),
null,
'mesgs');
195 $pse->fk_entrepot =
GETPOSTINT(
'fk_entrepot');
196 $pse->fk_product = $id;
197 $pse->seuil_stock_alerte =
GETPOST(
'seuil_stock_alerte');
198 $pse->desiredstock =
GETPOST(
'desiredstock');
199 if ($pse->create($user) > 0) {
200 setEventMessages($langs->trans(
'ProductStockWarehouseCreated'),
null,
'mesgs');
205 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
209if ($action ==
'delete_productstockwarehouse' && $usercancreate) {
212 $pse->fetch(
GETPOSTINT(
'fk_productstockwarehouse'));
213 if ($pse->delete($user) > 0) {
214 setEventMessages($langs->trans(
'ProductStockWarehouseDeleted'),
null,
'mesgs');
221if ($action ==
'setseuil_stock_alerte' && $usercancreate) {
224 $object->seuil_stock_alerte = $stocklimit;
235if ($action ==
'setdesiredstock' && $usercancreate) {
238 $object->desiredstock = $desiredstock;
248if ($action ==
"correct_stock" && !$cancel && $usercanupdatestock) {
250 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
252 $action =
'correction';
255 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NumberOfUnit")),
null,
'errors');
257 $action =
'correction';
260 if (isModEnabled(
'productbatch')) {
264 if (
$object->hasbatch() && !$batchnumber) {
265 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"batch_number")),
null,
'errors');
267 $action =
'correction';
274 if (is_numeric($nbpiece) && $nbpiece != 0 && $id) {
275 $origin_element =
'';
279 $origin_element =
'project';
288 $disablestockchangeforsubproduct = 0;
289 if (
GETPOST(
'disablesubproductstockchange')) {
290 $disablestockchangeforsubproduct = 1;
294 $result =
$object->correct_stock_batch(
299 GETPOST(
"label",
'alphanohtml'),
304 GETPOST(
'inventorycode',
'alphanohtml'),
307 $disablestockchangeforsubproduct
310 $result =
$object->correct_stock(
315 GETPOST(
"label",
'alphanohtml'),
317 GETPOST(
'inventorycode',
'alphanohtml'),
320 $disablestockchangeforsubproduct
326 header(
"Location: ".$backtopage);
329 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
$object->id);
334 $action =
'correction';
341if ($action ==
"transfert_stock" && !$cancel && $usercanupdatestock) {
343 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
345 $action =
'transfert';
348 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NumberOfUnit")),
null,
'errors');
350 $action =
'transfert';
353 setEventMessages($langs->trans(
"ErrorSrcAndTargetWarehouseMustDiffers"),
null,
'errors');
355 $action =
'transfert';
357 if (isModEnabled(
'productbatch')) {
361 if (
$object->hasbatch() && !$batchnumber) {
362 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"batch_number")),
null,
'errors');
364 $action =
'transfert';
375 $object->load_stock(
'novirtual');
382 $pricedest = $pricesrc;
390 $result = $pdluo->fetch($pdluoid);
392 $srcwarehouseid = $pdluo->warehouseid;
393 $batch = $pdluo->batch;
394 $eatby = $pdluo->eatby;
395 $sellby = $pdluo->sellby;
402 $batch = $batchnumber;
411 $result1 =
$object->correct_stock_batch(
416 GETPOST(
"label",
'alphanohtml'),
421 GETPOST(
'inventorycode',
'alphanohtml')
429 $result2 =
$object->correct_stock_batch(
434 GETPOST(
"label",
'alphanohtml'),
439 GETPOST(
'inventorycode',
'alphanohtml')
448 $result1 =
$object->correct_stock(
453 GETPOST(
"label",
'alphanohtml'),
455 GETPOST(
'inventorycode',
'alphanohtml')
463 $result2 =
$object->correct_stock(
468 GETPOST(
"label",
'alphanohtml'),
470 GETPOST(
'inventorycode',
'alphanohtml')
479 if (!$error && $result1 >= 0 && $result2 >= 0) {
483 header(
"Location: ".$backtopage);
486 header(
"Location: product.php?id=".
$object->id);
492 $action =
'transfert';
499if ($action ==
'updateline' &&
GETPOST(
'save') == $langs->trans(
"Save") && $usercancreate) {
501 $result = $pdluo->fetch(
GETPOSTINT(
'pdluoid'));
505 if ((!
GETPOST(
"sellby")) && (!
GETPOST(
"eatby")) && (!$batchnumber)) {
506 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"atleast1batchfield")),
null,
'errors');
510 $pdluo->batch = $batchnumber;
511 $pdluo->eatby = $d_eatby;
512 $pdluo->sellby = $d_sellby;
513 $result = $pdluo->update($user);
519 setEventMessages($langs->trans(
'BatchInformationNotfound'),
null,
'errors');
524 header(
"Location: product.php?id=".$id);
533$form =
new Form($db);
535if (isModEnabled(
'project')) {
539if ($id > 0 || $ref) {
541 $result =
$object->fetch($id, $ref);
543 $variants =
$object->hasVariants();
547 $title = $langs->trans(
'ProductServiceCard');
551 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'Stock');
552 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
555 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'Stock');
556 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
559 llxHeader(
'', $title, $helpurl,
'', 0, 0,
'',
'',
'',
'mod-product page-card_stock_product');
561 if (!empty($conf->use_javascript_ajax)) {
563 <script
type=
"text/javascript">
564 $(document).ready(
function() {
565 $(
".collapse_batch").click(
function() {
566 console.log(
"We click on collapse_batch");
567 var id_entrepot = $(
this).attr(
'id').replace(
'ent',
'');
569 if($(
this).text().indexOf(
'+') > 0) {
570 $(
".batch_warehouse" + id_entrepot).show();
572 jQuery(
"#show_all").hide();
573 jQuery(
"#hide_all").show();
576 $(
".batch_warehouse" + id_entrepot).hide();
583 $(
"#show_all").click(
function() {
584 console.log(
"We click on show_all");
585 $(
"[class^=batch_warehouse]").show();
586 $(
"[class^=collapse_batch]").html(
'(-)');
587 jQuery(
"#show_all").hide();
588 jQuery(
"#hide_all").show();
592 $(
"#hide_all").click(
function() {
593 console.log(
"We click on hide_all");
594 $(
"[class^=batch_warehouse]").hide();
595 $(
"[class^=collapse_batch]").html(
'(+)');
596 jQuery(
"#hide_all").hide();
597 jQuery(
"#show_all").show();
608 $titre = $langs->trans(
"CardProduct".
$object->type);
615 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1&type='.
$object->type.
'">'.$langs->trans(
"BackToList").
'</a>';
616 $object->next_prev_filter =
"(te.fk_product_type:=:".((int)
$object->type).
")";
619 if ($user->socid && !in_array(
'stock', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
623 dol_banner_tab(
$object,
'ref', $linkback, $shownav,
'ref');
626 print
'<div class="fichecenter">';
628 print
'<div class="fichehalfleft">';
629 print
'<div class="underbanner clearboth"></div>';
631 print
'<table class="border tableforfield centpercent">';
634 if (isModEnabled(
"product") && isModEnabled(
"service")) {
635 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
636 print
'<tr><td class="">';
637 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type',
$object->type,
$object, 0, $typeformat) : $langs->trans(
'Type');
639 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type,
$object, 0, $typeformat);
643 if (isModEnabled(
'productbatch')) {
644 print
'<tr><td class="">'.$langs->trans(
"ManageLotSerial").
'</td><td>';
645 print
$object->getLibStatut(0, 2);
651 $textdesc = $langs->trans(
"CostPriceDescription");
652 $textdesc .=
"<br>".$langs->trans(
"CostPriceUsage");
653 $text = $form->textwithpicto($langs->trans(
"CostPrice"), $textdesc, 1,
'help',
'');
654 if (!$usercancreadprice) {
655 print $form->editfieldkey($text,
'cost_price',
'',
$object, 0,
'amount:6');
657 print $form->editfieldval($text,
'cost_price',
'',
$object, 0,
'amount:6');
659 print $form->editfieldkey($text,
'cost_price',
$object->cost_price,
$object, $usercancreate,
'amount:6');
661 print $form->editfieldval($text,
'cost_price',
$object->cost_price,
$object, $usercancreate,
'amount:6');
668 print
'<tr><td class="titlefield">';
669 print $form->textwithpicto($langs->trans(
"AverageUnitPricePMPShort"), $langs->trans(
"AverageUnitPricePMPDesc"));
672 if (
$object->pmp > 0 && $usercancreadprice) {
679 print
'<tr><td>'.$langs->trans(
"BuyingPriceMin").
'</td>';
682 if ($product_fourn->find_min_price_product_fournisseur(
$object->id) > 0) {
683 if ($product_fourn->product_fourn_price_id > 0 && $usercancreadprice) {
684 print $product_fourn->display_price_product_fournisseur();
686 print $langs->trans(
"NotDefined");
693 print
'<tr><td>'.$langs->trans(
"SellingPrice").
'</td><td>';
694 if ($usercancreadprice) {
695 if (
$object->price_base_type ==
'TTC') {
704 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td><td>';
705 if ($usercancreadprice) {
706 if (
$object->price_base_type ==
'TTC') {
715 print
'<tr><td>'.$langs->trans(
"SellingPrice").
'</td><td>';
716 print
'<span class="opacitymedium">'.$langs->trans(
"Variable").
'</span>';
720 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td><td>';
721 print
'<span class="opacitymedium">'.$langs->trans(
"Variable").
'</span>';
726 $parameters = array();
727 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
728 print $hookmanager->resPrint;
733 print
'<div class="fichehalfright"><div class="underbanner clearboth"></div>';
735 print
'<table class="border tableforfield centpercent">';
738 print
'<tr><td>'.$form->editfieldkey($form->textwithpicto($langs->trans(
"StockLimit"), $langs->trans(
"StockLimitDesc"), 1),
'seuil_stock_alerte',
$object->seuil_stock_alerte,
$object, $user->hasRight(
'produit',
'creer')).
'</td><td>';
739 print $form->editfieldval(
"StockLimit",
'seuil_stock_alerte',
$object->seuil_stock_alerte,
$object, $user->hasRight(
'produit',
'creer'),
'string');
743 print
'<tr><td>'.$form->editfieldkey($form->textwithpicto($langs->trans(
"DesiredStock"), $langs->trans(
"DesiredStockDesc"), 1),
'desiredstock',
$object->desiredstock,
$object, $user->hasRight(
'produit',
'creer'));
745 print $form->editfieldval(
"DesiredStock",
'desiredstock',
$object->desiredstock,
$object, $user->hasRight(
'produit',
'creer'),
'string');
749 $text_stock_options = $langs->trans(
"RealStockDesc").
'<br>';
750 $text_stock_options .= $langs->trans(
"RealStockWillAutomaticallyWhen").
'<br>';
751 $text_stock_options .= (
getDolGlobalString(
'STOCK_CALCULATE_ON_SHIPMENT') ||
getDolGlobalString(
'STOCK_CALCULATE_ON_SHIPMENT_CLOSE') ?
'- '.$langs->trans(
"DeStockOnShipment").
'<br>' :
'');
752 $text_stock_options .= (
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') ?
'- '.$langs->trans(
"DeStockOnValidateOrder").
'<br>' :
'');
753 $text_stock_options .= (
getDolGlobalString(
'STOCK_CALCULATE_ON_BILL') ?
'- '.$langs->trans(
"DeStockOnBill").
'<br>' :
'');
754 $text_stock_options .= (
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') ?
'- '.$langs->trans(
"ReStockOnBill").
'<br>' :
'');
755 $text_stock_options .= (
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER') ?
'- '.$langs->trans(
"ReStockOnValidateOrder").
'<br>' :
'');
756 $text_stock_options .= (
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER') ?
'- '.$langs->trans(
"ReStockOnDispatchOrder").
'<br>' :
'');
757 $text_stock_options .= (
getDolGlobalString(
'STOCK_CALCULATE_ON_RECEPTION') ||
getDolGlobalString(
'STOCK_CALCULATE_ON_RECEPTION_CLOSE') ?
'- '.$langs->trans(
"StockOnReception").
'<br>' :
'');
758 $parameters = array();
759 $reshook = $hookmanager->executeHooks(
'physicalStockTextStockOptions', $parameters,
$object, $action);
761 $text_stock_options = $hookmanager->resPrint;
762 } elseif ($reshook == 0) {
763 $text_stock_options .= $hookmanager->resPrint;
769 print $form->textwithpicto($langs->trans(
"PhysicalStock"), $text_stock_options, 1);
771 print
'<td>'.price2num(
$object->stock_reel,
'MS');
773 print
' '.img_warning($langs->trans(
"StockLowerThanLimit",
$object->seuil_stock_alerte));
776 print
' <a href="'.DOL_URL_ROOT.
'/product/stock/stockatdate.php?productid='.
$object->id.
'">'.$langs->trans(
"StockAtDate").
'</a>';
783 $helpondiff =
'<strong>'.$langs->trans(
"StockDiffPhysicTeoric").
':</strong><br>';
785 if (isModEnabled(
'order')) {
787 $helpondiff .=
'<br>';
791 $helpondiff .= $langs->trans(
"ProductQtyInCustomersOrdersRunning").
': '.
$object->stats_commande[
'qty'];
792 $result =
$object->load_stats_commande(0,
'0', 1);
796 $helpondiff .=
' <span class="opacitymedium">('.$langs->trans(
"ProductQtyInDraft").
': '.
$object->stats_commande[
'qty'].
')</span>';
800 if (isModEnabled(
"shipping")) {
801 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
802 $filterShipmentStatus =
'';
809 $helpondiff .=
'<br>';
813 $result =
$object->load_stats_sending(0,
'2', 1, $filterShipmentStatus);
814 $helpondiff .= $langs->trans(
"ProductQtyInShipmentAlreadySent").
': '.
$object->stats_expedition[
'qty'];
818 if (isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) {
820 $helpondiff .=
'<br>';
824 $result =
$object->load_stats_commande_fournisseur(0,
'3,4', 1);
825 $helpondiff .= $langs->trans(
"ProductQtyInSuppliersOrdersRunning").
': '.
$object->stats_commande_fournisseur[
'qty'];
826 $result =
$object->load_stats_commande_fournisseur(0,
'0,1,2', 1);
830 $helpondiff .=
' <span class="opacitymedium">('.$langs->trans(
"ProductQtyInDraftOrWaitingApproved").
': '.
$object->stats_commande_fournisseur[
'qty'].
')</span>';
834 if (isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) {
836 $helpondiff .=
'<br>';
840 $helpondiff .= $langs->trans(
"ProductQtyInSuppliersShipmentAlreadyRecevied").
': '.
$object->stats_reception[
'qty'];
844 if (isModEnabled(
'mrp')) {
846 $helpondiff .=
'<br>';
850 $helpondiff .= $langs->trans(
"ProductQtyToConsumeByMO").
': '.
$object->stats_mrptoconsume[
'qty'].
'<br>';
851 $helpondiff .= $langs->trans(
"ProductQtyToProduceByMO").
': '.
$object->stats_mrptoproduce[
'qty'];
853 $parameters = array(
'found' => &$found,
'id' =>
$object->id,
'includedraftpoforvirtual' =>
null);
854 $reshook = $hookmanager->executeHooks(
'virtualStockHelpOnDiff', $parameters,
$object, $action);
856 $helpondiff = $hookmanager->resPrint;
857 } elseif ($reshook == 0) {
858 $helpondiff .= $hookmanager->resPrint;
866 print $form->textwithpicto($langs->trans(
"VirtualStock"), $langs->trans(
"VirtualStockDesc"));
870 print $form->textwithpicto((empty($stocktheo) ? 0 : $stocktheo), $helpondiff);
872 print
' '.img_warning($langs->trans(
"StockLowerThanLimit",
$object->seuil_stock_alerte));
874 print
' <a href="'.DOL_URL_ROOT.
'/product/stock/stockatdate.php?mode=future&productid='.
$object->id.
'">'.$langs->trans(
"VirtualStockAtDate").
'</a>';
879 if ($user->hasRight(
'stock',
'mouvement',
'lire')) {
880 $sql =
"SELECT max(m.datem) as datem";
881 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
882 $sql .=
" WHERE m.fk_product = ".((int)
$object->id);
883 $resqlbis = $db->query($sql);
885 $obj = $db->fetch_object($resqlbis);
886 $lastmovementdate = $db->jdate($obj->datem);
890 print
'<tr><td class="tdtop">'.$langs->trans(
"LastMovement").
'</td><td>';
891 if ($lastmovementdate) {
893 print
' ';
894 print
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="pictofixedwidth"');
895 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?idproduct='.
$object->id.
'">'.$langs->trans(
"FullList").
'</a>';
897 print
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="pictofixedwidth"');
898 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?idproduct='.
$object->id.
'">'.$langs->trans(
"None").
'</a>';
908 print
'<div class="clearboth"></div>';
915 if ($action ==
"correction") {
916 include DOL_DOCUMENT_ROOT.
'/product/stock/tpl/stockcorrection.tpl.php';
921 if ($action ==
"transfert") {
922 include DOL_DOCUMENT_ROOT.
'/product/stock/tpl/stocktransfer.tpl.php';
932$parameters = array();
934$reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
935if (empty($reshook)) {
936 if (empty($action) &&
$object->id) {
937 print
"<div class=\"tabsAction\">\n";
939 if ($user->hasRight(
'stock',
'mouvement',
'creer')) {
940 if (!$variants ||
getDolGlobalString(
'VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT')) {
941 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=transfert&token='.
newToken().
'">'.$langs->trans(
"TransferStock").
'</a>';
943 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ActionAvailableOnVariantProductOnly").
'">'.$langs->trans(
"TransferStock").
'</a>';
946 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
"CorrectStock").
'</a>';
949 if ($user->hasRight(
'stock',
'mouvement',
'creer')) {
950 if (!$variants ||
getDolGlobalString(
'VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT')) {
951 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=correction&token='.
newToken().
'">'.$langs->trans(
"CorrectStock").
'</a>';
953 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ActionAvailableOnVariantProductOnly").
'">'.$langs->trans(
"CorrectStock").
'</a>';
956 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
"CorrectStock").
'</a>';
964if (!$variants ||
getDolGlobalString(
'VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT')) {
969 print
'<div class="div-table-responsive">';
970 print
'<table class="noborder centpercent">';
972 print
'<tr class="liste_titre">';
973 print
'<td colspan="4">'.$langs->trans(
"Warehouse").
'</td>';
974 print
'<td class="right">'.$langs->trans(
"NumberOfUnit").
'</td>';
975 print
'<td class="right">'.$form->textwithpicto($langs->trans(
"AverageUnitPricePMPShort"), $langs->trans(
"AverageUnitPricePMPDesc")).
'</td>';
976 print
'<td class="right">'.$langs->trans(
"EstimatedStockValueShort").
'</td>';
977 print
'<td class="right">'.$langs->trans(
"SellPriceMin").
'</td>';
978 print
'<td class="right">'.$langs->trans(
"EstimatedStockValueSellShort").
'</td>';
983 if ((isModEnabled(
'productbatch')) &&
$object->hasbatch()) {
985 print
'<tr class="liste_titre"><td class="minwidth200">';
986 if (!empty($conf->use_javascript_ajax)) {
987 print
'<a id="show_all" href="#" class="hideobject">'.img_picto(
'',
'folder-open',
'class="paddingright"').$langs->trans(
"ShowAllLots").
'</a>';
989 print
'<a id="hide_all" href="#">'.img_picto(
'',
'folder',
'class="paddingright"').$langs->trans(
"HideLots").
'</a>';
993 print
'<td class="right">'.$langs->trans(
"batch_number").
'</td>';
996 print
'<td class="center width100">'.$langs->trans(
"SellByDate").
'</td>';
1000 print
'<td class="center width100">'.$langs->trans(
"EatByDate").
'</td>';
1002 print
'<td colspan="'.$colspan.
'"></td>';
1012 $sql =
"SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut as status, ps.reel, ps.rowid as product_stock_id, p.pmp";
1013 $sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e,";
1014 $sql .=
" ".MAIN_DB_PREFIX.
"product_stock as ps";
1015 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = ps.fk_product";
1016 $sql .=
" WHERE ps.reel != 0";
1017 $sql .=
" AND ps.fk_entrepot = e.rowid";
1018 $sql .=
" AND e.entity IN (".getEntity(
'stock').
")";
1019 $sql .=
" AND ps.fk_product = ".((int)
$object->id);
1020 $sql .=
" ORDER BY e.ref";
1022 $entrepotstatic =
new Entrepot($db);
1027 $totalvalue = $totalvaluesell = 0;
1030 $resql = $db->query($sql);
1032 $num = $db->num_rows($resql);
1033 $total = $totalwithpmp;
1037 $obj = $db->fetch_object($resql);
1039 $entrepotstatic->id = $obj->rowid;
1040 $entrepotstatic->ref = $obj->ref;
1041 $entrepotstatic->label = $obj->ref;
1042 $entrepotstatic->lieu = $obj->lieu;
1043 $entrepotstatic->fk_parent = $obj->fk_parent;
1044 $entrepotstatic->statut = $obj->status;
1045 $entrepotstatic->status = $obj->status;
1047 $stock_real =
price2num($obj->reel,
'MS');
1048 print
'<tr class="oddeven">';
1051 print
'<td colspan="4">';
1052 print $entrepotstatic->getNomUrl(1);
1053 if (!empty($conf->use_javascript_ajax) && isModEnabled(
'productbatch') &&
$object->hasbatch()) {
1054 print
'<a class="collapse_batch marginleftonly" id="ent' . $entrepotstatic->id .
'" href="#">';
1060 print
'<td class="right">'.$stock_real.($stock_real < 0 ?
' '.img_warning() :
'').
'</td>';
1063 print
'<td class="right nowraponall">'.(price2num(
$object->pmp) ?
price2num(
$object->pmp,
'MU') :
'').
'</td>';
1066 if ($usercancreadprice) {
1067 print
'<td class="right amount nowraponall">'.(price2num(
$object->pmp) ?
price(
price2num(
$object->pmp * $obj->reel,
'MT')) :
'').
'</td>';
1069 print
'<td class="right amount nowraponall"></td>';
1073 $minsellprice =
null;
1074 $maxsellprice =
null;
1075 print
'<td class="right nowraponall">';
1077 foreach (
$object->multiprices as $priceforlevel) {
1078 if (is_numeric($priceforlevel)) {
1079 if (is_null($maxsellprice) || $priceforlevel > $maxsellprice) {
1080 $maxsellprice = $priceforlevel;
1082 if (is_null($minsellprice) || $priceforlevel < $minsellprice) {
1083 $minsellprice = $priceforlevel;
1087 print
'<span class="valignmiddle">';
1088 if ($usercancreadprice) {
1089 if ($minsellprice != $maxsellprice) {
1096 print $form->textwithpicto(
'', $langs->trans(
"Variable"));
1097 } elseif ($usercancreadprice) {
1103 print
'<td class="right amount nowraponall">';
1105 print
'<span class="valignmiddle">';
1106 if ($usercancreadprice) {
1107 if ($minsellprice != $maxsellprice) {
1114 print $form->textwithpicto(
'', $langs->trans(
"Variable"));
1116 if ($usercancreadprice) {
1124 $total += $obj->reel;
1126 $totalwithpmp += $obj->reel;
1128 $totalvalue = $totalvalue + (
$object->pmp * $obj->reel);
1129 $totalvaluesell = $totalvaluesell + (
$object->price * $obj->reel);
1131 if ((isModEnabled(
'productbatch')) &&
$object->hasbatch()) {
1136 foreach ($details as $pdluo) {
1137 $product_lot_static->id = $pdluo->lotid;
1138 $product_lot_static->batch = $pdluo->batch;
1139 $product_lot_static->eatby = $pdluo->eatby;
1140 $product_lot_static->sellby = $pdluo->sellby;
1142 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $pdluo->id) {
1144 print
'<td colspan="9">';
1145 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1146 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1147 print
'<input type="hidden" name="pdluoid" value="'.$pdluo->id.
'"><input type="hidden" name="action" value="updateline"><input type="hidden" name="id" value="'.$id.
'"><table class="noborder centpercent"><tr><td width="10%"></td>';
1148 print
'<td class="right" width="10%"><input type="text" name="batch_number" value="'.$pdluo->batch.
'"></td>';
1150 print
'<td class="center" width="10%">';
1151 print $form->selectDate($pdluo->sellby,
'sellby', 0, 0, 1,
'', 1, 0);
1155 print
'<td class="center" width="10%">';
1156 print $form->selectDate($pdluo->eatby,
'eatby', 0, 0, 1,
'', 1, 0);
1159 print
'<td class="right" colspan="3">'.$pdluo->qty.($pdluo->qty < 0 ?
' '.img_warning() :
'').
'</td>';
1160 print
'<td colspan="4"><input type="submit" class="button button-save" id="savelinebutton marginbottomonly" name="save" value="'.$langs->trans(
"Save").
'">';
1161 print
'<input type="submit" class="button button-cancel" id="cancellinebutton" name="Cancel" value="'.$langs->trans(
"Cancel").
'"></td></tr>';
1169 print
"\n".
'<tr style="display:'.(!
getDolGlobalString(
'STOCK_SHOW_ALL_BATCH_BY_DEFAULT') ?
'none' :
'visible').
';" class="batch_warehouse'.$entrepotstatic->id.
'"><td class="left">';
1171 print
'<td class="right nowraponall">';
1172 if ($product_lot_static->id > 0) {
1173 print $product_lot_static->getNomUrl(1);
1175 print $product_lot_static->getNomUrl(1,
'nolink');
1181 print
'<td class="center">'.dol_print_date($pdluo->sellby,
'day').
'</td>';
1185 print
'<td class="center">'.dol_print_date($pdluo->eatby,
'day').
'</td>';
1187 print
'<td class="right" colspan="'.$colspan.
'">'.$pdluo->qty.($pdluo->qty < 0 ?
' '.img_warning() : (($pdluo->qty > 1 &&
$object->status_batch == 2) ?
' '.
img_warning($langs->trans(
'IlligalQtyForSerialNumbers')) :
'')).
'</td>';
1188 print
'<td colspan="4"></td>';
1189 print
'<td class="center tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"TransferStock")).
'">';
1190 if ($entrepotstatic->status != $entrepotstatic::STATUS_CLOSED) {
1191 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&id_entrepot='.$entrepotstatic->id.
'&action=transfert&pdluoid='.$pdluo->id.
'&token='.
newToken().
'">';
1192 print
img_picto($langs->trans(
"TransferStock"),
'add',
'class="hideonsmartphone paddingright" style="color: #a69944"');
1193 print $langs->trans(
"TransferStock");
1201 print
'<td class="center tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"CorrectStock")).
'">';
1202 if ($entrepotstatic->status != $entrepotstatic::STATUS_CLOSED) {
1203 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&id_entrepot='.$entrepotstatic->id.
'&action=correction&pdluoid='.$pdluo->id.
'&token='.
newToken().
'">';
1204 print
img_picto($langs->trans(
"CorrectStock"),
'add',
'class="hideonsmartphone paddingright" style="color: #a69944"');
1205 print $langs->trans(
"CorrectStock");
1224 print
'<tr class="liste_total"><td class="right liste_total" colspan="4">'.$langs->trans(
"Total").
':</td>';
1225 print
'<td class="liste_total right">'.price2num($total,
'MS').
'</td>';
1226 print
'<td class="liste_total right">';
1227 if ($usercancreadprice) {
1228 print($totalwithpmp ?
price(
price2num($totalvalue / $totalwithpmp,
'MU')) :
' ');
1232 print
'<td class="liste_total right">';
1233 if ($usercancreadprice) {
1234 print $totalvalue ?
price(
price2num($totalvalue,
'MT'), 1) :
' ';
1237 print
'<td class="liste_total right">';
1240 print
'<span class="valignmiddle">';
1242 print $form->textwithpicto(
'', $langs->trans(
"Variable"));
1243 } elseif ($usercancreadprice) {
1244 print
price($totalvaluesell / $total, 1);
1251 print
'<td class="liste_total right amount">';
1253 print
'<span class="valignmiddle">';
1257 print $form->textwithpicto(
'', $langs->trans(
"Variable"));
1273 if ($user->hasRight(
'produit',
'creer')) {
1274 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1275 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1276 print
'<input type="hidden" name="action" value="addlimitstockwarehouse">';
1277 print
'<input type="hidden" name="id" value="'.$id.
'">';
1279 print
'<table class="noborder centpercent">';
1280 if ($user->hasRight(
'produit',
'creer')) {
1281 print
'<tr class="liste_titre"><td>'.$formproduct->selectWarehouses(
'',
'fk_entrepot').
'</td>';
1282 print
'<td class="right"><input name="seuil_stock_alerte" type="text" placeholder="'.$langs->trans(
"StockLimit").
'" /></td>';
1283 print
'<td class="right"><input name="desiredstock" type="text" placeholder="'.$langs->trans(
"DesiredStock").
'" /></td>';
1284 print
'<td class="right"><input type="submit" value="'.$langs->trans(
"Save").
'" class="button button-save" /></td>';
1287 print
'<tr class="liste_titre"><td>'.$langs->trans(
"Warehouse").
'</td>';
1288 print
'<td class="right">'.$langs->trans(
"StockLimit").
'</td>';
1289 print
'<td class="right">'.$langs->trans(
"DesiredStock").
'</td>';
1294 $lines = $pse->fetchAll($id);
1296 $visibleWarehouseEntities = explode(
',',
getEntity(
'stock'));
1298 if (!empty($lines)) {
1300 foreach ($lines as $line) {
1302 $ent->fetch($line[
'fk_entrepot']);
1304 if (!isModEnabled(
"multicompany") || in_array($ent->entity, $visibleWarehouseEntities)) {
1306 print
'<tr class="oddeven"><td>'.$ent->getNomUrl(3).
'</td>';
1307 print
'<td class="right">'.$line[
'seuil_stock_alerte'].
'</td>';
1308 print
'<td class="right">'.$line[
'desiredstock'].
'</td>';
1309 if ($user->hasRight(
'produit',
'creer')) {
1310 print
'<td class="right"><a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$id.
'&fk_productstockwarehouse='.$line[
'id'].
'&action=delete_productstockwarehouse&token='.
newToken().
'">'.
img_delete().
'</a></td>';
1319 if ($user->hasRight(
'produit',
'creer')) {
1325 include_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
1326 include_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination2ValuePair.class.php';
1327 $prodstatic =
new Product($db);
1330 $productCombinations = $prodcomb->fetchAllByFkProductParent(
$object->id);
1332 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
1333 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1334 print
'<input type="hidden" name="action" value="massaction">';
1335 print
'<input type="hidden" name="id" value="'.$id.
'">';
1336 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1339 $title = $langs->trans(
"ProductCombinations");
1341 print_barre_liste($title, 0, $_SERVER[
"PHP_SELF"],
'', $sortfield, $sortorder,
'', 0);
1343 print
'<div class="div-table-responsive">'; ?>
1344 <
table class=
"liste">
1345 <tr
class=
"liste_titre">
1346 <td
class=
"liste_titre"><?php echo $langs->trans(
'Product') ?></td>
1347 <td
class=
"liste_titre"><?php echo $langs->trans(
'Combination') ?></td>
1348 <td
class=
"liste_titre center"><?php echo $langs->trans(
'OnSell') ?></td>
1349 <td
class=
"liste_titre center"><?php echo $langs->trans(
'OnBuy') ?></td>
1350 <td
class=
"liste_titre right"><?php echo $langs->trans(
'Stock') ?></td>
1351 <td
class=
"liste_titre"></td>
1355 if (count($productCombinations)) {
1357 foreach ($productCombinations as $currcomb) {
1358 $prodstatic->fetch($currcomb->fk_product_child);
1359 $prodstatic->load_stock();
1360 $stock_total += $prodstatic->stock_reel; ?>
1361 <tr
class=
"oddeven">
1362 <td><?php echo $prodstatic->getNomUrl(1) ?></td>
1366 $productCombination2ValuePairs = $comb2val->fetchByFkCombination($currcomb->id);
1367 $iMax = count($productCombination2ValuePairs);
1369 for ($i = 0; $i < $iMax; $i++) {
1372 if ($i !== ($iMax - 1)) {
1377 <td style=
"text-align: center;"><?php echo $prodstatic->getLibStatut(2, 0) ?></td>
1378 <td style=
"text-align: center;"><?php echo $prodstatic->getLibStatut(2, 1) ?></td>
1379 <td
class=
"right"><?php echo $prodstatic->stock_reel ?></td>
1381 <a
class=
"paddingleft paddingright editfielda" href=
"<?php echo dol_buildpath('/product/stock/product.php?id='.$currcomb->fk_product_child, 2) ?>"><?php echo
img_edit() ?></a>
1389 print
'<tr class="liste_total">';
1390 print
'<td colspan="4" class="left">'.$langs->trans(
"Total").
'</td>';
1391 print
'<td class="right">'.$stock_total.
'</td>';
1395 print
'<tr><td colspan="8"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage warehouses.
const STATUS_CLOSED
Closed status -> parcel was received by customer / end of process prev status : validated or shipment...
const STATUS_VALIDATED
Validated status -> parcel is ready to be sent prev status : draft next status : closed or shipment_i...
Class ProductCombination2ValuePair Used to represent the relation between a variant and its attribute...
Class ProductCombination Used to represent the relation between a product and one of its variants.
Class to manage predefined suppliers products.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
Class ProductStockEntrepot.
Manage record for batch number management.
static findAll($dbs, $fk_product_stock, $with_qty=0, $fk_product=0)
Return all batch detail records for a given product and warehouse.
Class with list of lots and properties.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
dol_htmloutput_events($disabledoutputofmessages=0)
Print formatted messages to output (Used to show messages on html output).
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
treeview li table
No Email.
product_prepare_head($object)
Prepare array with list of tabs.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.