36require
'../../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productstockentrepot.class.php';
44if (isModEnabled(
'productbatch')) {
45 require_once DOL_DOCUMENT_ROOT.
'/product/class/productbatch.class.php';
47if (isModEnabled(
'project')) {
48 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
52if (isModEnabled(
'variants')) {
53 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductAttribute.class.php';
54 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductAttributeValue.class.php';
55 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
56 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination2ValuePair.class.php';
68$langs->loadlangs(array(
'products',
'suppliers',
'orders',
'bills',
'stocks',
'sendings',
'margins'));
69if (isModEnabled(
'productbatch')) {
70 $langs->load(
"productbatch");
73$backtopage =
GETPOST(
'backtopage',
'alpha');
74$action =
GETPOST(
'action',
'aZ09');
75$cancel =
GETPOST(
'cancel',
'alpha');
81$cancel =
GETPOST(
'cancel',
'alpha');
82$fieldid = GETPOSTISSET(
"ref") ?
'ref' :
'rowid';
86$batchnumber =
GETPOST(
'batch_number',
'san_alpha');
87if (!empty($batchnumber)) {
88 $batchnumber = trim($batchnumber);
90$cost_price =
GETPOST(
'cost_price',
'alpha');
94 $socid = $user->socid;
101$extrafields->fetch_name_optionals_label(
$object->table_element);
103if ($id > 0 || !empty($ref)) {
104 $result =
$object->fetch($id, $ref);
107if (empty($id) && !empty(
$object->id)) {
111$modulepart =
'product';
116if (!empty($canvas)) {
117 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
118 $objcanvas =
new Canvas($db, $action);
119 $objcanvas->getCanvas(
'stockproduct',
'card', $canvas);
123$hookmanager->initHooks(array(
'stockproductcard',
'globalcard'));
129$usercancreadprice =
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') ? $user->hasRight(
'product',
'product_advance',
'read_prices') : $user->hasRight(
'product',
'lire');
130$usercanupdatestock = $user->hasRight(
'stock',
'mouvement',
'creer');
133 $label = $langs->trans(
'Service');
134 $usercancreadprice =
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') ? $user->hasRight(
'service',
'service_advance',
'read_prices') : $user->hasRight(
'service',
'lire');
138 if (
$object->type == $object::TYPE_PRODUCT) {
141 if (
$object->type == $object::TYPE_SERVICE) {
145 restrictedArea($user,
'produit|service', $id,
'product&product',
'',
'', $fieldid);
157$parameters = array(
'id' => $id,
'ref' => $ref,
'objcanvas' => $objcanvas);
158$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
163if ($action ==
'setcost_price' && $usercancreate) {
178if ($action ==
'addlimitstockwarehouse' && $usercancreate) {
179 $seuil_stock_alerte =
GETPOST(
'seuil_stock_alerte');
180 $desiredstock =
GETPOST(
'desiredstock');
183 if ($seuil_stock_alerte ==
'') {
184 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"StockLimit")),
null,
'errors');
187 if ($desiredstock ==
'' || is_array($desiredstock)) {
188 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DesiredStock")),
null,
'errors');
192 $desiredstock = (float) $desiredstock;
197 if ($pse->fetch(0, $id,
GETPOSTINT(
'fk_entrepot')) > 0) {
199 $pse->seuil_stock_alerte = $seuil_stock_alerte;
200 $pse->desiredstock = $desiredstock;
201 if ($pse->update($user) > 0) {
202 setEventMessages($langs->trans(
'ProductStockWarehouseUpdated'),
null,
'mesgs');
206 $pse->fk_entrepot =
GETPOSTINT(
'fk_entrepot');
207 $pse->fk_product =
$id;
208 $pse->seuil_stock_alerte =
GETPOST(
'seuil_stock_alerte');
210 if ($pse->create($user) > 0) {
211 setEventMessages($langs->trans(
'ProductStockWarehouseCreated'),
null,
'mesgs');
216 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
220if ($action ==
'delete_productstockwarehouse' && $usercancreate) {
223 $pse->fetch(
GETPOSTINT(
'fk_productstockwarehouse'));
224 if ($pse->delete($user) > 0) {
225 setEventMessages($langs->trans(
'ProductStockWarehouseDeleted'),
null,
'mesgs');
232if ($action ==
'setseuil_stock_alerte' && $usercancreate) {
235 $object->seuil_stock_alerte = $stocklimit;
246if ($action ==
'setdesiredstock' && $usercancreate) {
249 $object->desiredstock = $desiredstock;
259if ($action ==
"correct_stock" && !$cancel && $usercanupdatestock) {
261 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
263 $action =
'correction';
266 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NumberOfUnit")),
null,
'errors');
268 $action =
'correction';
271 if (isModEnabled(
'productbatch')) {
275 if (
$object->hasbatch() && !$batchnumber) {
276 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"batch_number")),
null,
'errors');
278 $action =
'correction';
285 if (is_numeric($nbpiece) && $nbpiece != 0 && $id) {
286 $origin_element =
'';
290 $origin_element =
'project';
299 $disablestockchangeforsubproduct = 0;
300 if (
GETPOST(
'disablesubproductstockchange')) {
301 $disablestockchangeforsubproduct = 1;
305 $result =
$object->correct_stock_batch(
310 GETPOST(
"label",
'alphanohtml'),
315 GETPOST(
'inventorycode',
'alphanohtml'),
318 $disablestockchangeforsubproduct
321 $result =
$object->correct_stock(
326 GETPOST(
"label",
'alphanohtml'),
328 GETPOST(
'inventorycode',
'alphanohtml'),
331 $disablestockchangeforsubproduct
337 header(
"Location: ".$backtopage);
340 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
$object->id);
345 $action =
'correction';
352if ($action ==
"transfert_stock" && !$cancel && $usercanupdatestock) {
354 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
356 $action =
'transfert';
359 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NumberOfUnit")),
null,
'errors');
361 $action =
'transfert';
364 setEventMessages($langs->trans(
"ErrorSrcAndTargetWarehouseMustDiffers"),
null,
'errors');
366 $action =
'transfert';
368 if (isModEnabled(
'productbatch')) {
372 if (
$object->hasbatch() && !$batchnumber) {
373 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"batch_number")),
null,
'errors');
375 $action =
'transfert';
386 $object->load_stock(
'novirtual');
393 $pricedest = $pricesrc;
401 $result = $pdluo->fetch($pdluoid);
403 $srcwarehouseid = $pdluo->warehouseid;
404 $batch = $pdluo->batch;
405 $eatby = $pdluo->eatby;
406 $sellby = $pdluo->sellby;
413 $batch = $batchnumber;
422 $result1 =
$object->correct_stock_batch(
427 GETPOST(
"label",
'alphanohtml'),
432 GETPOST(
'inventorycode',
'alphanohtml')
440 $result2 =
$object->correct_stock_batch(
445 GETPOST(
"label",
'alphanohtml'),
450 GETPOST(
'inventorycode',
'alphanohtml')
459 $result1 =
$object->correct_stock(
464 GETPOST(
"label",
'alphanohtml'),
466 GETPOST(
'inventorycode',
'alphanohtml')
474 $result2 =
$object->correct_stock(
479 GETPOST(
"label",
'alphanohtml'),
481 GETPOST(
'inventorycode',
'alphanohtml')
490 if (!$error && $result1 >= 0 && $result2 >= 0) {
494 header(
"Location: ".$backtopage);
497 header(
"Location: product.php?id=".
$object->id);
503 $action =
'transfert';
510if ($action ==
'updateline' &&
GETPOST(
'save') == $langs->trans(
"Save") && $usercancreate) {
512 $result = $pdluo->fetch(
GETPOSTINT(
'pdluoid'));
516 if ((!
GETPOST(
"sellby")) && (!
GETPOST(
"eatby")) && (!$batchnumber)) {
517 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"atleast1batchfield")),
null,
'errors');
521 $pdluo->batch = $batchnumber;
522 $pdluo->eatby = $d_eatby;
523 $pdluo->sellby = $d_sellby;
524 $result = $pdluo->update($user);
530 setEventMessages($langs->trans(
'BatchInformationNotfound'),
null,
'errors');
535 header(
"Location: product.php?id=".$id);
544$form =
new Form($db);
546if (isModEnabled(
'project')) {
550if ($id > 0 || $ref) {
552 $result =
$object->fetch($id, $ref);
554 $variants =
$object->hasVariants();
558 $title = $langs->trans(
'ProductServiceCard');
562 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'Stock');
563 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
566 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'Stock');
567 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
570 llxHeader(
'', $title, $helpurl,
'', 0, 0,
'',
'',
'',
'mod-product page-card_stock_product');
572 if (!empty(
$conf->use_javascript_ajax)) {
574 <script
type=
"text/javascript">
575 $(document).ready(
function() {
576 $(
".collapse_batch").click(
function() {
577 console.log(
"We click on collapse_batch");
578 var id_entrepot = $(
this).attr(
'id').replace(
'ent',
'');
580 if($(
this).text().indexOf(
'+') > 0) {
581 $(
".batch_warehouse" + id_entrepot).show();
583 jQuery(
"#show_all").hide();
584 jQuery(
"#hide_all").show();
587 $(
".batch_warehouse" + id_entrepot).hide();
594 $(
"#show_all").click(
function() {
595 console.log(
"We click on show_all");
596 $(
"[class^=batch_warehouse]").show();
597 $(
"[class^=collapse_batch]").html(
'(-)');
598 jQuery(
"#show_all").hide();
599 jQuery(
"#hide_all").show();
603 $(
"#hide_all").click(
function() {
604 console.log(
"We click on hide_all");
605 $(
"[class^=batch_warehouse]").hide();
606 $(
"[class^=collapse_batch]").html(
'(+)');
607 jQuery(
"#hide_all").hide();
608 jQuery(
"#show_all").show();
619 $titre = $langs->trans(
"CardProduct".
$object->type);
626 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1&type='.
$object->type.
'">'.$langs->trans(
"BackToList").
'</a>';
629 if ($user->socid && !in_array(
'stock', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
633 dol_banner_tab(
$object,
'ref', $linkback, $shownav,
'ref');
636 print
'<div class="fichecenter">';
638 print
'<div class="fichehalfleft">';
639 print
'<div class="underbanner clearboth"></div>';
641 print
'<table class="border tableforfield centpercent">';
644 if (isModEnabled(
"product") && isModEnabled(
"service")) {
645 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
646 print
'<tr><td class="">';
647 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type',
$object->type,
$object, 0, $typeformat) : $langs->trans(
'Type');
649 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type,
$object, 0, $typeformat);
653 if (isModEnabled(
'productbatch')) {
654 print
'<tr><td class="">'.$langs->trans(
"ManageLotSerial").
'</td><td>';
655 print
$object->getLibStatut(0, 2);
661 $textdesc = $langs->trans(
"CostPriceDescription");
662 $textdesc .=
"<br>".$langs->trans(
"CostPriceUsage");
663 $text = $form->textwithpicto($langs->trans(
"CostPrice"), $textdesc, 1,
'help',
'');
664 if (!$usercancreadprice) {
665 print $form->editfieldkey($text,
'cost_price',
'',
$object, 0,
'amount:6');
667 print $form->editfieldval($text,
'cost_price',
'',
$object, 0,
'amount:6');
669 print $form->editfieldkey($text,
'cost_price',
$object->cost_price,
$object, $usercancreate,
'amount:6');
671 print $form->editfieldval($text,
'cost_price',
$object->cost_price,
$object, $usercancreate,
'amount:6');
678 print
'<tr><td class="titlefield">';
679 print $form->textwithpicto($langs->trans(
"AverageUnitPricePMPShort"), $langs->trans(
"AverageUnitPricePMPDesc"));
682 if (
$object->pmp > 0 && $usercancreadprice) {
689 print
'<tr><td>'.$langs->trans(
"BuyingPriceMin").
'</td>';
692 if ($product_fourn->find_min_price_product_fournisseur(
$object->id) > 0) {
693 if ($product_fourn->product_fourn_price_id > 0 && $usercancreadprice) {
694 print $product_fourn->display_price_product_fournisseur();
696 print $langs->trans(
"NotDefined");
703 print
'<tr><td>'.$langs->trans(
"SellingPrice").
'</td><td>';
704 if ($usercancreadprice) {
705 if (
$object->price_base_type ==
'TTC') {
714 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td><td>';
715 if ($usercancreadprice) {
716 if (
$object->price_base_type ==
'TTC') {
725 print
'<tr><td>'.$langs->trans(
"SellingPrice").
'</td><td>';
726 print
'<span class="opacitymedium">'.$langs->trans(
"Variable").
'</span>';
730 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td><td>';
731 print
'<span class="opacitymedium">'.$langs->trans(
"Variable").
'</span>';
736 $parameters = array();
737 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
738 print $hookmanager->resPrint;
743 print
'<div class="fichehalfright"><div class="underbanner clearboth"></div>';
745 print
'<table class="border tableforfield centpercent">';
748 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>';
749 print $form->editfieldval(
"StockLimit",
'seuil_stock_alerte',
$object->seuil_stock_alerte,
$object, $user->hasRight(
'produit',
'creer'),
'string');
753 print
'<tr><td>'.$form->editfieldkey($form->textwithpicto($langs->trans(
"DesiredStock"), $langs->trans(
"DesiredStockDesc"), 1),
'desiredstock',
$object->desiredstock,
$object, $user->hasRight(
'produit',
'creer'));
755 print $form->editfieldval(
"DesiredStock",
'desiredstock',
$object->desiredstock,
$object, $user->hasRight(
'produit',
'creer'),
'string');
759 $text_stock_options = $langs->trans(
"RealStockDesc").
'<br>';
760 $text_stock_options .= $langs->trans(
"RealStockWillAutomaticallyWhen").
'<br>';
761 $text_stock_options .= (
getDolGlobalString(
'STOCK_CALCULATE_ON_SHIPMENT') ||
getDolGlobalString(
'STOCK_CALCULATE_ON_SHIPMENT_CLOSE') ?
'- '.$langs->trans(
"DeStockOnShipment").
'<br>' :
'');
762 $text_stock_options .= (
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') ?
'- '.$langs->trans(
"DeStockOnValidateOrder").
'<br>' :
'');
763 $text_stock_options .= (
getDolGlobalString(
'STOCK_CALCULATE_ON_BILL') ?
'- '.$langs->trans(
"DeStockOnBill").
'<br>' :
'');
764 $text_stock_options .= (
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') ?
'- '.$langs->trans(
"ReStockOnBill").
'<br>' :
'');
765 $text_stock_options .= (
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER') ?
'- '.$langs->trans(
"ReStockOnValidateOrder").
'<br>' :
'');
766 $text_stock_options .= (
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER') ?
'- '.$langs->trans(
"ReStockOnDispatchOrder").
'<br>' :
'');
767 $text_stock_options .= (
getDolGlobalString(
'STOCK_CALCULATE_ON_RECEPTION') ||
getDolGlobalString(
'STOCK_CALCULATE_ON_RECEPTION_CLOSE') ?
'- '.$langs->trans(
"StockOnReception").
'<br>' :
'');
768 $parameters = array();
769 $reshook = $hookmanager->executeHooks(
'physicalStockTextStockOptions', $parameters,
$object, $action);
771 $text_stock_options = $hookmanager->resPrint;
772 } elseif ($reshook == 0) {
773 $text_stock_options .= $hookmanager->resPrint;
779 print $form->textwithpicto($langs->trans(
"PhysicalStock"), $text_stock_options, 1);
781 print
'<td>'.price2num(
$object->stock_reel,
'MS');
783 print
' '.img_warning($langs->trans(
"StockLowerThanLimit",
$object->seuil_stock_alerte));
786 print
' <a href="'.DOL_URL_ROOT.
'/product/stock/stockatdate.php?productid='.
$object->id.
'">'.$langs->trans(
"StockAtDate").
'</a>';
793 $helpondiff =
'<strong>'.$langs->trans(
"StockDiffPhysicTeoric").
':</strong><br>';
795 if (isModEnabled(
'order')) {
797 $helpondiff .=
'<br>';
801 $helpondiff .= $langs->trans(
"ProductQtyInCustomersOrdersRunning").
': '.
$object->stats_commande[
'qty'];
802 $result =
$object->load_stats_commande(0,
'0', 1);
806 $helpondiff .=
' <span class="opacitymedium">('.$langs->trans(
"ProductQtyInDraft").
': '.
$object->stats_commande[
'qty'].
')</span>';
810 if (isModEnabled(
"shipping")) {
811 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
812 $filterShipmentStatus =
'';
819 $helpondiff .=
'<br>';
823 $result =
$object->load_stats_sending(0,
'2', 1, $filterShipmentStatus);
824 $helpondiff .= $langs->trans(
"ProductQtyInShipmentAlreadySent").
': '.
$object->stats_expedition[
'qty'];
828 if (isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) {
830 $helpondiff .=
'<br>';
834 $result =
$object->load_stats_commande_fournisseur(0,
'3,4', 1);
835 $helpondiff .= $langs->trans(
"ProductQtyInSuppliersOrdersRunning").
': '.
$object->stats_commande_fournisseur[
'qty'];
836 $result =
$object->load_stats_commande_fournisseur(0,
'0,1,2', 1);
840 $helpondiff .=
' <span class="opacitymedium">('.$langs->trans(
"ProductQtyInDraftOrWaitingApproved").
': '.
$object->stats_commande_fournisseur[
'qty'].
')</span>';
844 if (isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) {
846 $helpondiff .=
'<br>';
850 $helpondiff .= $langs->trans(
"ProductQtyInSuppliersShipmentAlreadyRecevied").
': '.
$object->stats_reception[
'qty'];
854 if (isModEnabled(
'mrp')) {
856 $helpondiff .=
'<br>';
860 $helpondiff .= $langs->trans(
"ProductQtyToConsumeByMO").
': '.
$object->stats_mrptoconsume[
'qty'].
'<br>';
861 $helpondiff .= $langs->trans(
"ProductQtyToProduceByMO").
': '.
$object->stats_mrptoproduce[
'qty'];
863 $parameters = array(
'found' => &$found,
'id' =>
$object->id,
'includedraftpoforvirtual' =>
null);
864 $reshook = $hookmanager->executeHooks(
'virtualStockHelpOnDiff', $parameters,
$object, $action);
866 $helpondiff = $hookmanager->resPrint;
867 } elseif ($reshook == 0) {
868 $helpondiff .= $hookmanager->resPrint;
876 print $form->textwithpicto($langs->trans(
"VirtualStock"), $langs->trans(
"VirtualStockDesc"));
880 print $form->textwithpicto((empty($stocktheo) ? 0 : $stocktheo), $helpondiff);
882 print
' '.img_warning($langs->trans(
"StockLowerThanLimit",
$object->seuil_stock_alerte));
884 print
' <a href="'.DOL_URL_ROOT.
'/product/stock/stockatdate.php?mode=future&productid='.
$object->id.
'">'.$langs->trans(
"VirtualStockAtDate").
'</a>';
889 if ($user->hasRight(
'stock',
'mouvement',
'lire')) {
890 $sql =
"SELECT max(m.datem) as datem";
891 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
892 $sql .=
" WHERE m.fk_product = ".((int)
$object->id);
893 $resqlbis = $db->query($sql);
895 $obj = $db->fetch_object($resqlbis);
896 $lastmovementdate = $db->jdate($obj->datem);
900 print
'<tr><td class="tdtop">'.$langs->trans(
"LastMovement").
'</td><td>';
901 if ($lastmovementdate) {
903 print
' ';
904 print
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="pictofixedwidth"');
905 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?idproduct='.
$object->id.
'">'.$langs->trans(
"FullList").
'</a>';
907 print
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="pictofixedwidth"');
908 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?idproduct='.
$object->id.
'">'.$langs->trans(
"None").
'</a>';
918 print
'<div class="clearboth"></div>';
925 if ($action ==
"correction") {
926 include DOL_DOCUMENT_ROOT.
'/product/stock/tpl/stockcorrection.tpl.php';
931 if ($action ==
"transfert") {
932 include DOL_DOCUMENT_ROOT.
'/product/stock/tpl/stocktransfer.tpl.php';
942$parameters = array();
944$reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
945if (empty($reshook)) {
946 if (empty($action) &&
$object->id) {
947 print
"<div class=\"tabsAction\">\n";
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=transfert&token='.
newToken().
'">'.$langs->trans(
"TransferStock").
'</a>';
953 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ActionAvailableOnVariantProductOnly").
'">'.$langs->trans(
"TransferStock").
'</a>';
956 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
"TransferStock").
'</a>';
959 if ($user->hasRight(
'stock',
'mouvement',
'creer')) {
960 if (!$variants ||
getDolGlobalString(
'VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT')) {
961 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=correction&token='.
newToken().
'">'.$langs->trans(
"CorrectStock").
'</a>';
963 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ActionAvailableOnVariantProductOnly").
'">'.$langs->trans(
"CorrectStock").
'</a>';
966 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
"CorrectStock").
'</a>';
974if (!$variants ||
getDolGlobalString(
'VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT')) {
979 print
'<div class="div-table-responsive">';
980 print
'<table class="noborder centpercent">';
982 print
'<tr class="liste_titre">';
983 print
'<td colspan="4">'.$langs->trans(
"Warehouse").
'</td>';
984 print
'<td class="right">'.$langs->trans(
"NumberOfUnit").
'</td>';
985 print
'<td class="right">'.$form->textwithpicto($langs->trans(
"AverageUnitPricePMPShort"), $langs->trans(
"AverageUnitPricePMPDesc")).
'</td>';
986 print
'<td class="right">'.$langs->trans(
"EstimatedStockValueShort").
'</td>';
987 print
'<td class="right">'.$langs->trans(
"SellPriceMin").
'</td>';
988 print
'<td class="right">'.$langs->trans(
"EstimatedStockValueSellShort").
'</td>';
993 if ((isModEnabled(
'productbatch')) &&
$object->hasbatch()) {
995 print
'<tr class="liste_titre"><td class="minwidth200">';
996 if (!empty(
$conf->use_javascript_ajax)) {
997 print
'<a id="show_all" href="#" class="hideobject">'.img_picto(
'',
'folder-open',
'class="paddingright"').$langs->trans(
"ShowAllLots").
'</a>';
999 print
'<a id="hide_all" href="#">'.img_picto(
'',
'folder',
'class="paddingright"').$langs->trans(
"HideLots").
'</a>';
1003 print
'<td class="right">'.$langs->trans(
"batch_number").
'</td>';
1006 print
'<td class="center width100">'.$langs->trans(
"SellByDate").
'</td>';
1010 print
'<td class="center width100">'.$langs->trans(
"EatByDate").
'</td>';
1012 print
'<td colspan="'.$colspan.
'"></td>';
1022 $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";
1023 $sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e,";
1024 $sql .=
" ".MAIN_DB_PREFIX.
"product_stock as ps";
1025 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = ps.fk_product";
1026 $sql .=
" WHERE ps.reel != 0";
1027 $sql .=
" AND ps.fk_entrepot = e.rowid";
1028 $sql .=
" AND e.entity IN (".getEntity(
'stock').
")";
1029 $sql .=
" AND ps.fk_product = ".((int)
$object->id);
1030 $sql .=
" ORDER BY e.ref";
1032 $entrepotstatic =
new Entrepot($db);
1037 $totalvalue = $totalvaluesell = 0;
1040 $resql = $db->query($sql);
1042 $num = $db->num_rows($resql);
1043 $total = $totalwithpmp;
1047 $obj = $db->fetch_object($resql);
1049 $entrepotstatic->id = $obj->rowid;
1050 $entrepotstatic->ref = $obj->ref;
1051 $entrepotstatic->label = $obj->ref;
1052 $entrepotstatic->lieu = $obj->lieu;
1053 $entrepotstatic->fk_parent = $obj->fk_parent;
1054 $entrepotstatic->statut = $obj->status;
1055 $entrepotstatic->status = $obj->status;
1057 $stock_real =
price2num($obj->reel,
'MS');
1058 print
'<tr class="oddeven">';
1061 print
'<td colspan="4">';
1062 print $entrepotstatic->getNomUrl(1);
1063 if (!empty(
$conf->use_javascript_ajax) && isModEnabled(
'productbatch') &&
$object->hasbatch()) {
1064 print
'<a class="collapse_batch marginleftonly" id="ent' . $entrepotstatic->id .
'" href="#">';
1070 print
'<td class="right">'.$stock_real.($stock_real < 0 ?
' '.img_warning() :
'').
'</td>';
1073 print
'<td class="right nowraponall">'.(price2num(
$object->pmp) ?
price2num(
$object->pmp,
'MU') :
'').
'</td>';
1076 if ($usercancreadprice) {
1077 print
'<td class="right amount nowraponall">'.(price2num(
$object->pmp) ?
price(
price2num(
$object->pmp * $obj->reel,
'MT')) :
'').
'</td>';
1079 print
'<td class="right amount nowraponall"></td>';
1083 $minsellprice =
null;
1084 $maxsellprice =
null;
1085 print
'<td class="right nowraponall">';
1087 foreach (
$object->multiprices as $priceforlevel) {
1088 if (is_numeric($priceforlevel)) {
1089 if (is_null($maxsellprice) || $priceforlevel > $maxsellprice) {
1090 $maxsellprice = $priceforlevel;
1092 if (is_null($minsellprice) || $priceforlevel < $minsellprice) {
1093 $minsellprice = $priceforlevel;
1097 print
'<span class="valignmiddle">';
1098 if ($usercancreadprice) {
1099 if ($minsellprice != $maxsellprice) {
1106 print $form->textwithpicto(
'', $langs->trans(
"Variable"));
1107 } elseif ($usercancreadprice) {
1113 print
'<td class="right amount nowraponall">';
1115 print
'<span class="valignmiddle">';
1116 if ($usercancreadprice) {
1117 if ($minsellprice != $maxsellprice) {
1124 print $form->textwithpicto(
'', $langs->trans(
"Variable"));
1126 if ($usercancreadprice) {
1134 $total += $obj->reel;
1136 $totalwithpmp += $obj->reel;
1138 $totalvalue += (
$object->pmp * $obj->reel);
1139 $totalvaluesell += (
$object->price * $obj->reel);
1141 if ((isModEnabled(
'productbatch')) &&
$object->hasbatch()) {
1146 foreach ($details as $pdluo) {
1147 $product_lot_static->id = $pdluo->lotid;
1148 $product_lot_static->batch = $pdluo->batch;
1149 $product_lot_static->eatby = $pdluo->eatby;
1150 $product_lot_static->sellby = $pdluo->sellby;
1152 if ($action ==
'editline' &&
GETPOSTINT(
'lineid') == $pdluo->id) {
1154 print
'<td colspan="9">';
1155 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1156 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1157 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>';
1158 print
'<td class="right" width="10%"><input type="text" name="batch_number" value="'.$pdluo->batch.
'"></td>';
1160 print
'<td class="center" width="10%">';
1161 print $form->selectDate($pdluo->sellby,
'sellby', 0, 0, 1,
'', 1, 0);
1165 print
'<td class="center" width="10%">';
1166 print $form->selectDate($pdluo->eatby,
'eatby', 0, 0, 1,
'', 1, 0);
1169 print
'<td class="right" colspan="3">'.$pdluo->qty.($pdluo->qty < 0 ?
' '.img_warning() :
'').
'</td>';
1170 print
'<td colspan="4"><input type="submit" class="button button-save" id="savelinebutton marginbottomonly" name="save" value="'.$langs->trans(
"Save").
'">';
1171 print
'<input type="submit" class="button button-cancel" id="cancellinebutton" name="Cancel" value="'.$langs->trans(
"Cancel").
'"></td></tr>';
1179 print
"\n".
'<tr style="display:'.(!
getDolGlobalString(
'STOCK_SHOW_ALL_BATCH_BY_DEFAULT') ?
'none' :
'visible').
';" class="batch_warehouse'.$entrepotstatic->id.
'"><td class="left">';
1181 print
'<td class="right nowraponall">';
1182 if ($product_lot_static->id > 0) {
1183 print $product_lot_static->getNomUrl(1);
1185 print $product_lot_static->getNomUrl(1,
'nolink');
1191 print
'<td class="center">'.dol_print_date($pdluo->sellby,
'day').
'</td>';
1195 print
'<td class="center">'.dol_print_date($pdluo->eatby,
'day').
'</td>';
1197 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>';
1198 print
'<td colspan="4"></td>';
1199 print
'<td class="center tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"TransferStock")).
'">';
1200 if ($entrepotstatic->status != $entrepotstatic::STATUS_CLOSED) {
1201 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&id_entrepot='.$entrepotstatic->id.
'&action=transfert&pdluoid='.$pdluo->id.
'&token='.
newToken().
'">';
1202 print
img_picto($langs->trans(
"TransferStock"),
'add',
'class="hideonsmartphone paddingright" style="color: #a69944"');
1203 print $langs->trans(
"TransferStock");
1211 print
'<td class="center tdoverflowmax125" title="'.dol_escape_htmltag($langs->trans(
"CorrectStock")).
'">';
1212 if ($entrepotstatic->status != $entrepotstatic::STATUS_CLOSED) {
1213 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&id_entrepot='.$entrepotstatic->id.
'&action=correction&pdluoid='.$pdluo->id.
'&token='.
newToken().
'">';
1214 print
img_picto($langs->trans(
"CorrectStock"),
'add',
'class="hideonsmartphone paddingright" style="color: #a69944"');
1215 print $langs->trans(
"CorrectStock");
1234 print
'<tr class="liste_total"><td class="right liste_total" colspan="4">'.$langs->trans(
"Total").
':</td>';
1235 print
'<td class="liste_total right">'.price2num($total,
'MS').
'</td>';
1236 print
'<td class="liste_total right">';
1237 if ($usercancreadprice) {
1238 print($totalwithpmp ?
price(
price2num($totalvalue / $totalwithpmp,
'MU')) :
' ');
1242 print
'<td class="liste_total right">';
1243 if ($usercancreadprice) {
1244 print $totalvalue ?
price(
price2num($totalvalue,
'MT'), 1) :
' ';
1247 print
'<td class="liste_total right">';
1250 print
'<span class="valignmiddle">';
1252 print $form->textwithpicto(
'', $langs->trans(
"Variable"));
1253 } elseif ($usercancreadprice) {
1254 print
price($totalvaluesell / $total, 1);
1261 print
'<td class="liste_total right amount">';
1263 print
'<span class="valignmiddle">';
1267 print $form->textwithpicto(
'', $langs->trans(
"Variable"));
1283 if ($user->hasRight(
'produit',
'creer')) {
1284 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1285 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1286 print
'<input type="hidden" name="action" value="addlimitstockwarehouse">';
1287 print
'<input type="hidden" name="id" value="'.$id.
'">';
1289 print
'<table class="noborder centpercent">';
1290 if ($user->hasRight(
'produit',
'creer')) {
1291 print
'<tr class="liste_titre"><td>'.$formproduct->selectWarehouses(
'',
'fk_entrepot').
'</td>';
1292 print
'<td class="right"><input name="seuil_stock_alerte" type="text" placeholder="'.$langs->trans(
"StockLimit").
'" /></td>';
1293 print
'<td class="right"><input name="desiredstock" type="text" placeholder="'.$langs->trans(
"DesiredStock").
'" /></td>';
1294 print
'<td class="right"><input type="submit" value="'.$langs->trans(
"Save").
'" class="button button-save" /></td>';
1297 print
'<tr class="liste_titre"><td>'.$langs->trans(
"Warehouse").
'</td>';
1298 print
'<td class="right">'.$langs->trans(
"StockLimit").
'</td>';
1299 print
'<td class="right">'.$langs->trans(
"DesiredStock").
'</td>';
1304 $lines = $pse->fetchAll($id);
1306 $visibleWarehouseEntities = explode(
',',
getEntity(
'stock'));
1308 if (!empty($lines)) {
1310 foreach ($lines as $line) {
1312 $ent->fetch($line[
'fk_entrepot']);
1314 if (!isModEnabled(
"multicompany") || in_array($ent->entity, $visibleWarehouseEntities)) {
1316 print
'<tr class="oddeven"><td>'.$ent->getNomUrl(3).
'</td>';
1317 print
'<td class="right">'.$line[
'seuil_stock_alerte'].
'</td>';
1318 print
'<td class="right">'.$line[
'desiredstock'].
'</td>';
1319 if ($user->hasRight(
'produit',
'creer')) {
1320 print
'<td class="right"><a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$id.
'&fk_productstockwarehouse='.$line[
'id'].
'&action=delete_productstockwarehouse&token='.
newToken().
'">'.
img_delete().
'</a></td>';
1329 if ($user->hasRight(
'produit',
'creer')) {
1335 include_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
1336 include_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination2ValuePair.class.php';
1337 $prodstatic =
new Product($db);
1340 $productCombinations = $prodcomb->fetchAllByFkProductParent(
$object->id);
1342 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
1343 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1344 print
'<input type="hidden" name="action" value="massaction">';
1345 print
'<input type="hidden" name="id" value="'.$id.
'">';
1346 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1349 $title = $langs->trans(
"ProductCombinations");
1351 print_barre_liste($title, 0, $_SERVER[
"PHP_SELF"],
'', $sortfield, $sortorder,
'', 0);
1353 print
'<div class="div-table-responsive">'; ?>
1354 <
table class=
"liste">
1355 <tr
class=
"liste_titre">
1356 <td
class=
"liste_titre"><?php echo $langs->trans(
'Product') ?></td>
1357 <td
class=
"liste_titre"><?php echo $langs->trans(
'Combination') ?></td>
1358 <td
class=
"liste_titre center"><?php echo $langs->trans(
'OnSell') ?></td>
1359 <td
class=
"liste_titre center"><?php echo $langs->trans(
'OnBuy') ?></td>
1360 <td
class=
"liste_titre right"><?php echo $langs->trans(
'Stock') ?></td>
1361 <td
class=
"liste_titre"></td>
1365 if (count($productCombinations)) {
1367 foreach ($productCombinations as $currcomb) {
1368 $prodstatic->fetch($currcomb->fk_product_child);
1369 $prodstatic->load_stock();
1370 $stock_total += $prodstatic->stock_reel; ?>
1371 <tr
class=
"oddeven">
1372 <td><?php echo $prodstatic->getNomUrl(1) ?></td>
1376 $productCombination2ValuePairs = $comb2val->fetchByFkCombination($currcomb->id);
1377 $iMax = count($productCombination2ValuePairs);
1379 for ($i = 0; $i < $iMax; $i++) {
1382 if ($i !== ($iMax - 1)) {
1387 <td style=
"text-align: center;"><?php echo $prodstatic->getLibStatut(2, 0) ?></td>
1388 <td style=
"text-align: center;"><?php echo $prodstatic->getLibStatut(2, 1) ?></td>
1389 <td
class=
"right"><?php echo $prodstatic->stock_reel ?></td>
1391 <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>
1399 print
'<tr class="liste_total">';
1400 print
'<td colspan="4" class="left">'.$langs->trans(
"Total").
'</td>';
1401 print
'<td class="right">'.$stock_total.
'</td>';
1405 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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
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 a 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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.