27require
'../../main.inc.php';
28include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
29include_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
30include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
31include_once DOL_DOCUMENT_ROOT.
'/product/inventory/class/inventory.class.php';
32include_once DOL_DOCUMENT_ROOT.
'/product/inventory/lib/inventory.lib.php';
33include_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
34include_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
45$langs->loadLangs(array(
"stocks",
"other",
"productbatch"));
50$action =
GETPOST(
'action',
'aZ09');
51$confirm =
GETPOST(
'confirm',
'alpha');
53$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'inventorycard';
54$backtopage =
GETPOST(
'backtopage',
'alpha');
55$listoffset =
GETPOST(
'listoffset',
'alpha');
56$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
57$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
60if (empty($page) || $page == -1) {
63$offset = $limit * $page;
70$batch =
GETPOST(
'batch',
'alphanohtml');
71$totalExpectedValuation = 0;
72$totalRealValuation = 0;
73$hookmanager->initHooks(array(
'inventorycard'));
77 $result =
restrictedArea($user,
'stock', $id,
'inventory&stock',
'inventory_advance');
83$diroutputmassaction =
$conf->stock->dir_output.
'/temp/massgeneration/'.$user->id;
94$extrafields->fetch_name_optionals_label(
$object->table_element);
96$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
99$search_all =
GETPOST(
"search_all",
'alpha');
101foreach (
$object->fields as $key => $val) {
102 if (
GETPOST(
'search_'.$key,
'alpha')) {
103 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
107if (empty($action) && empty($id) && empty($ref)) {
112include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
120$paramwithsearch =
'&sortfield=' . urlencode($sortfield);
121$paramwithsearch .=
'&sortorder=' . urlencode($sortorder);
122if ($limit > 0 && $limit !=
$conf->liste_limit) {
123 $paramwithsearch .=
'&limit='.((int) $limit);
128$sortfieldforsql = $sortfield .
',' . ($sortfield ==
'e.ref' ?
'p.ref' :
'e.ref') .
',id.batch,id.rowid';
129$sortorderforsql = $sortorder .
',' . $sortorder.
",ASC,ASC";
132 $permissiontoadd = $user->hasRight(
'stock',
'creer');
133 $permissiontodelete = $user->hasRight(
'stock',
'supprimer');
134 $permissiontoupdatestock = $user->hasRight(
'stock',
'mouvement',
'creer');
136 $permissiontoadd = $user->hasRight(
'stock',
'inventory_advance',
'write');
137 $permissiontodelete = $user->hasRight(
'stock',
'inventory_advance',
'write');
138 $permissiontoupdatestock = $user->hasRight(
'stock',
'inventory_advance',
'write');
154$parameters = array();
155$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
160if (empty($reshook)) {
163 if ($action ==
'cancel_record' && $confirm ==
'yes' && $permissiontoupdatestock &&
$object->status == $object::STATUS_VALIDATED) {
168 if ($action ==
'update' && $confirm ==
'yes' && $permissiontoupdatestock &&
$object->status == $object::STATUS_VALIDATED) {
172 $cacheOfProducts = array();
176 $sql =
'SELECT id.rowid, id.datec as date_creation, id.tms as date_modification, id.fk_inventory, id.fk_warehouse,';
177 $sql .=
' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated, id.pmp_real';
178 $sql .=
' FROM '.MAIN_DB_PREFIX.
'inventorydet as id';
179 $sql .=
' WHERE id.fk_inventory = '.((int)
$object->id);
180 $sql .=
' ORDER BY id.rowid';
182 $resql = $db->query($sql);
184 $num = $db->num_rows($resql);
190 $line = $db->fetch_object($resql);
192 $qty_stock = $line->qty_stock;
193 $qty_view = $line->qty_view;
197 if (isset($cacheOfProducts[$line->fk_product])) {
198 $product_static = $cacheOfProducts[$line->fk_product];
200 $product_static =
new Product($db);
201 $result = $product_static->fetch($line->fk_product,
'',
'',
'', 1, 1, 1);
204 $option .=
',novirtual';
205 $product_static->load_stock($option);
207 $cacheOfProducts[$product_static->id] = $product_static;
211 $realqtynow = $product_static->stock_warehouse[$line->fk_warehouse]->real;
212 if (isModEnabled(
'productbatch') && $product_static->hasbatch()) {
216 if (!empty($product_static->stock_warehouse[$line->fk_warehouse]->detail_batch)) {
217 foreach ($product_static->stock_warehouse[$line->fk_warehouse]->detail_batch as $tmpbatchnumber => $tmpdetailbatch) {
219 $realqtynow = $tmpdetailbatch->qty;
226 if (!is_null($qty_view)) {
227 $stock_movement_qty =
price2num($qty_view - $realqtynow,
'MS');
230 if ($stock_movement_qty != 0) {
231 if ($stock_movement_qty < 0) {
239 $inventorycode =
'INV-'.$object->ref;
242 $price = $line->pmp_real;
245 $idstockmove = $stockmovment->_create($user, $line->fk_product, $line->fk_warehouse, (
float) $stock_movement_qty, $movement_type, $price, $langs->trans(
'LabelOfInventoryMovemement',
$object->ref), $inventorycode, $datemovement,
'',
'', $line->batch);
246 if ($idstockmove < 0) {
253 $sqlupdate =
"UPDATE ".MAIN_DB_PREFIX.
"inventorydet";
254 $sqlupdate .=
" SET fk_movement = ".((int) $idstockmove);
255 if ($qty_stock != $realqtynow) {
256 $sqlupdate .=
", qty_stock = ".((float) $realqtynow);
258 $sqlupdate .=
" WHERE rowid = ".((int) $line->rowid);
259 $resqlupdate = $db->query($sqlupdate);
260 if (! $resqlupdate) {
268 $sqlpmp =
'UPDATE '.MAIN_DB_PREFIX.
'product SET pmp = '.((float) $line->pmp_real).
' WHERE rowid = '.((int) $line->fk_product);
269 $resqlpmp = $db->query($sqlpmp);
276 $sqlpmp =
'UPDATE '.MAIN_DB_PREFIX.
'product_perentity SET pmp = '.((float) $line->pmp_real).
' WHERE fk_product = '.((int) $line->fk_product).
' AND entity='.
$conf->entity;
277 $resqlpmp = $db->query($sqlpmp);
306 if ($action ==
'updateinventorylines' && $permissiontoupdatestock) {
307 $sql =
'SELECT id.rowid, id.datec as date_creation, id.tms as date_modification, id.fk_inventory, id.fk_warehouse,';
308 $sql .=
' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated';
309 $sql .=
' FROM '.MAIN_DB_PREFIX.
'inventorydet as id';
310 $sql .=
' LEFT JOIN ' . $db->prefix() .
'product as p ON id.fk_product = p.rowid';
311 $sql .=
' LEFT JOIN ' . $db->prefix() .
'entrepot as e ON id.fk_warehouse = e.rowid';
312 $sql .=
' WHERE id.fk_inventory = '.((int)
$object->id);
313 $sql .= $db->order($sortfieldforsql, $sortorderforsql);
314 $sql .= $db->plimit($limit, $offset);
318 $resql = $db->query($sql);
320 $num = $db->num_rows($resql);
326 $line = $db->fetch_object($resql);
327 $lineid = $line->rowid;
332 if (
GETPOST(
"id_".$lineid,
'alpha') !=
'') {
334 $result = $inventoryline->fetch($lineid);
335 if ($qtytoupdate < 0) {
337 setEventMessages($langs->trans(
"FieldCannotBeNegative", $langs->transnoentitiesnoconv(
"RealQty")),
null,
'errors');
340 $inventoryline->qty_stock = (float)
price2num(
GETPOST(
'stock_qty_'.$lineid,
'alpha'),
'MS');
341 $inventoryline->qty_view = $qtytoupdate;
342 $inventoryline->pmp_real =
price2num(
GETPOST(
'realpmp_'.$lineid,
'alpha'),
'MS');
343 $inventoryline->pmp_expected =
price2num(
GETPOST(
'expectedpmp_'.$lineid,
'alpha'),
'MS');
344 $resultupdate = $inventoryline->update($user);
346 } elseif (GETPOSTISSET(
'id_' . $lineid)) {
348 $result = $inventoryline->fetch($lineid);
350 $inventoryline->qty_view =
null;
351 $inventoryline->pmp_real =
price2num(
GETPOST(
'realpmp_'.$lineid,
'alpha'),
'MS');
352 $inventoryline->pmp_expected =
price2num(
GETPOST(
'expectedpmp_'.$lineid,
'alpha'),
'MS');
353 $resultupdate = $inventoryline->update($user);
357 if ($result < 0 || $resultupdate < 0) {
367 $sqlupdate =
"UPDATE ".MAIN_DB_PREFIX.
"inventory";
368 $sqlupdate .=
" SET fk_user_modif = ".((int) $user->id);
369 $sqlupdate .=
" WHERE rowid = ".((int)
$object->id);
370 $resqlupdate = $db->query($sqlupdate);
371 if (! $resqlupdate) {
384 $backurlforlist = DOL_URL_ROOT.
'/product/inventory/list.php';
385 $backtopage = DOL_URL_ROOT.
'/product/inventory/inventory.php?id='.
$object->id.
'&page='.$page.$paramwithsearch;
389 if ($action ==
'update') {
394 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
397 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
400 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
408 if (
GETPOST(
'addline',
'alpha')) {
410 if ($fk_warehouse <= 0) {
412 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
414 if ($fk_product <= 0) {
416 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Product")),
null,
'errors');
420 setEventMessages($langs->trans(
"FieldCannotBeNegative", $langs->transnoentitiesnoconv(
"RealQty")),
null,
'errors');
422 if (!$error && isModEnabled(
'productbatch')) {
423 $tmpproduct =
new Product($db);
424 $result = $tmpproduct->fetch($fk_product);
426 if (empty($error) && $tmpproduct->status_batch > 0 && empty($batch)) {
428 $langs->load(
"errors");
429 setEventMessages($langs->trans(
"ErrorProductNeedBatchNumber", $tmpproduct->ref),
null,
'errors');
431 if (empty($error) && $tmpproduct->status_batch == 2 && !empty($batch) && $qty > 1) {
433 $langs->load(
"errors");
434 setEventMessages($langs->trans(
"TooManyQtyForSerialNumber", $tmpproduct->ref, $batch),
null,
'errors');
436 if (empty($error) && empty($tmpproduct->status_batch) && !empty($batch)) {
438 $langs->load(
"errors");
439 setEventMessages($langs->trans(
"ErrorProductDoesNotNeedBatchNumber", $tmpproduct->ref),
null,
'errors');
444 $tmp->fk_inventory =
$object->id;
445 $tmp->fk_warehouse = $fk_warehouse;
446 $tmp->fk_product = $fk_product;
447 $tmp->batch = $batch;
449 $tmp->qty_view = $qty;
451 $result = $tmp->create($user);
453 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
454 $langs->load(
"errors");
455 setEventMessages($langs->trans(
"ErrorRecordAlreadyExists"),
null,
'errors');
461 $_POST[
'batch'] =
'';
462 $_POST[
'qtytoadd'] =
'';
474$form =
new Form($db);
479llxHeader(
'', $langs->trans(
'Inventory'), $help_url,
'', 0, 0,
'',
'',
'',
'mod-product page-inventory_inventory');
488if ($limit > 0 && $limit !=
$conf->liste_limit) {
489 $param .=
'&limit=' . ((int) $limit);
493$res =
$object->fetch_optionals();
501if ($action ==
'delete') {
502 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteInventory'), $langs->trans(
'ConfirmDeleteOrder'),
'confirm_delete',
'', 0, 1);
505if ($action ==
'deleteline') {
506 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid.
'&page='.$page.$paramwithsearch, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
510if ($action ==
'clone') {
512 $formquestion = array();
513 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneMyObject',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
517if ($action ==
'record') {
518 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&page='.$page.$paramwithsearch, $langs->trans(
'Close'), $langs->trans(
'ConfirmFinish'),
'update',
'', 0, 1);
523if ($action ==
'confirm_cancel') {
524 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'Cancel'), $langs->trans(
'ConfirmCancel'),
'cancel_record',
'', 0, 1);
528if ($action ==
'validate') {
529 $form =
new Form($db);
532 $formquestion = array(
533 array(
'type' =>
'checkbox',
'name' =>
'include_sub_warehouse',
'label' => $langs->trans(
"IncludeSubWarehouse"),
'value' => 1,
'size' =>
'10'),
535 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateInventory'), $langs->trans(
'IncludeSubWarehouseExplanation'),
'confirm_validate', $formquestion,
'', 1);
540$parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
541$reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
542if (empty($reshook)) {
543 $formconfirm .= $hookmanager->resPrint;
544} elseif ($reshook > 0) {
545 $formconfirm = $hookmanager->resPrint;
554$linkback =
'<a href="'.DOL_URL_ROOT.
'/product/inventory/list.php">'.$langs->trans(
"BackToList").
'</a>';
556$morehtmlref =
'<div class="refidno">';
596$morehtmlref .=
'</div>';
599dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
602print
'<div class="fichecenter">';
603print
'<div class="fichehalfleft">';
604print
'<div class="underbanner clearboth"></div>';
605print
'<table class="border centpercent tableforfield">'.
"\n";
608include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
611include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
619print
'<div class="clearboth"></div>';
623print
'<form id="formrecord" name="formrecord" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'?page='.$page.
'&id='.
$object->id.
'">';
624print
'<input type="hidden" name="token" value="'.newToken().
'">';
625print
'<input type="hidden" name="action" value="updateinventorylines">';
626print
'<input type="hidden" name="id" value="'.$object->id.
'">';
627print
'<input type="hidden" name="sortfield" value="' . $sortfield .
'">';
628print
'<input type="hidden" name="sortorder" value="' . $sortorder .
'">';
631print
'<input type="hidden" name="limit" value="' . ((int) $limit) .
'">';
633 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
638if ($action !=
'record') {
639 print
'<div class="tabsAction">'.
"\n";
640 $parameters = array();
641 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
646 if (empty($reshook)) {
647 if (
$object->status == Inventory::STATUS_DRAFT) {
648 if ($permissiontoupdatestock) {
650 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=validate&token='.
newToken().
'">'.$langs->trans(
"Validate").
' ('.$langs->trans(
"Start").
')</a>';
652 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken().
'">'.$langs->trans(
"Validate").
' ('.$langs->trans(
"Start").
')</a>';
655 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
'Validate').
' ('.$langs->trans(
"Start").
')</a>'.
"\n";
660 if (
$object->status == $object::STATUS_VALIDATED) {
661 if ($permissiontoupdatestock) {
662 print
'<a class="butAction classfortooltip" id="idbuttonmakemovementandclose" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=record&page='.$page.$paramwithsearch.
'&token='.
newToken().
'" title="'.
dol_escape_htmltag($langs->trans(
"MakeMovementsAndClose")).
'">'.$langs->trans(
"MakeMovementsAndClose").
'</a>'.
"\n";
664 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
'MakeMovementsAndClose').
'</a>'.
"\n";
667 if ($permissiontoupdatestock) {
668 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_cancel&page='.$page.$paramwithsearch.
'&token='.
newToken().
'">'.$langs->trans(
"Cancel").
'</a>'.
"\n";
674 if (
$object->status != Inventory::STATUS_DRAFT &&
$object->status != Inventory::STATUS_VALIDATED) {
681if (
$object->status == Inventory::STATUS_VALIDATED) {
683 if (!empty(
$conf->use_javascript_ajax)) {
684 if ($permissiontoupdatestock) {
686 if (isModEnabled(
'barcode') || isModEnabled(
'productbatch')) {
687 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=updatebyscaning&token='.
currentToken().
'" class="marginrightonly paddingright marginleftonly paddingleft">'.
img_picto(
'',
'barcode',
'class="paddingrightonly"').$langs->trans(
"UpdateByScaning").
'</a>';
691 print
'<a id="fillwithexpected" class="marginrightonly paddingright marginleftonly paddingleft" href="#">'.img_picto(
'',
'autofill',
'class="paddingrightonly"').$langs->trans(
'AutofillWithExpected').
'</a>';
693 print
'$( document ).ready(function() {';
694 print
' $("#fillwithexpected").on("click",function fillWithExpected(){
695 $(".expectedqty").each(function(){
696 var object = $(this)[0];
697 var objecttofill = $("#"+object.id+"_input")[0];
698 objecttofill.value = object.innerText;
699 jQuery(".realqty").trigger("change");
701 console.log("Values filled (after click on fillwithexpected)");
702 /* disablebuttonmakemovementandclose(); */
709 print
'<a href="#" id="clearqty" class="marginrightonly paddingright marginleftonly paddingleft">'.img_picto(
'',
'eraser',
'class="paddingrightonly"').$langs->trans(
"ClearQtys").
'</a>';
711 print
'<a class="classfortooltip marginrightonly paddingright marginleftonly paddingleft" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
"Save").
'</a>'.
"\n";
721if ($action ==
'updatebyscaning') {
722 if ($permissiontoupdatestock) {
727 var duplicatedbatchcode = [];
733 function barcodescannerjs(){
734 console.log("We catch inputs in scanner box");
735 jQuery("#scantoolmessage").text();
737 var selectaddorreplace = $("select[name=selectaddorreplace]").val();
738 var barcodemode = $("input[name=barcodemode]:checked").val();
739 var barcodeproductqty = $("input[name=barcodeproductqty]").val();
740 var textarea = $("textarea[name=barcodelist]").val();
741 var textarray = textarea.split(/[\s,;]+/);
743 duplicatedbatchcode = [];
749 textarray = textarray.filter(function(value){
752 if(textarray.some((element) => element != "")){
753 $(".expectedqty").each(function(){
755 console.log("Analyze the line "+id+" in inventory, barcodemode="+barcodemode);
756 warehouse = $("#"+id+"_warehouse").attr(\'data-ref\');
757 //console.log(warehouse);
758 productbarcode = $("#"+id+"_product").attr(\'data-barcode\');
759 //console.log(productbarcode);
760 productbatchcode = $("#"+id+"_batch").attr(\'data-batch\');
761 //console.log(productbatchcode);
763 if (barcodemode != "barcodeforproduct") {
764 tabproduct.forEach(product=>{
765 console.log("product.Batch="+product.Batch+" productbatchcode="+productbatchcode);
766 if(product.Batch != "" && product.Batch == productbatchcode){
767 console.log("duplicate batch code found for batch code "+productbatchcode);
768 duplicatedbatchcode.push(productbatchcode);
772 productinput = $("#"+id+"_input").val();
773 if(productinput == ""){
776 tabproduct.push({\'Id\':id,\'Warehouse\':warehouse,\'Barcode\':productbarcode,\'Batch\':productbatchcode,\'Qty\':productinput,\'fetched\':false});
779 console.log("Loop on each record entered in the textarea");
780 textarray.forEach(function(element,index){
781 console.log("Process record element="+element+" id="+id);
782 var verify_batch = false;
783 var verify_barcode = false;
785 case "barcodeforautodetect":
786 verify_barcode = barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,"barcode",true);
787 verify_batch = barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,"lotserial",true);
789 case "barcodeforproduct":
790 verify_barcode = barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,"barcode");
792 case "barcodeforlotserial":
793 verify_batch = barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,"lotserial");
796 alert(\''.dol_escape_js($langs->trans(
"ErrorWrongBarcodemode")).
' "\'+barcodemode+\'"\');
797 throw \''.
dol_escape_js($langs->trans(
'ErrorWrongBarcodemode')).
' "\'+barcodemode+\'"\';
800 if (verify_batch == false && verify_barcode == false) { /* If the 2 flags are false, not found error */
801 errortab2.push(element);
802 } else if (verify_batch == true && verify_barcode == true) { /* If the 2 flags are true, error: we don t know which one to take */
803 errortab3.push(element);
804 } else if (verify_batch == true) {
805 console.log("element="+element);
806 console.log(duplicatedbatchcode);
807 if (duplicatedbatchcode.includes(element)) {
808 errortab1.push(element);
813 if (Object.keys(errortab1).length < 1 && Object.keys(errortab2).length < 1 && Object.keys(errortab3).length < 1) {
814 tabproduct.forEach(product => {
816 console.log("We change #"+product.Id+"_input to match input in scanner box");
817 if(product.hasOwnProperty("reelqty")){
818 $.ajax({ url: \''.DOL_URL_ROOT.
'/product/inventory/ajax/searchfrombarcode.php\',
819 data: { "token":"'.
newToken().
'", "action":"addnewlineproduct", "fk_entrepot":product.Warehouse, "batch":product.Batch, "fk_inventory":'.
dol_escape_js((
string)
$object->id).
', "fk_product":product.fk_product, "reelqty":product.reelqty},
822 success: function(response) {
823 if (typeof response == "object") {
824 console.log("response is already type object, no need to parse it");
826 console.log("response is type "+(typeof response));
827 response = JSON.parse(response);
829 if(response.status == "success"){
830 console.log(response.message);
831 $("<input type=\'text\' value=\'"+product.Qty+"\' />")
832 .attr("id", "id_"+response.id_line+"_input")
833 .attr("name", "id_"+response.id_line)
834 .appendTo("#formrecord");
836 console.error(response.message);
839 error : function(output) {
840 console.error("Error on line creation function");
844 $("#"+product.Id+"_input").val(product.Qty);
848 jQuery("#scantoolmessage").text("'.
dol_escape_js($langs->transnoentities(
"QtyWasAddedToTheScannedBarcode")).
'\n");
849 /* document.forms["formrecord"].submit(); */
851 let stringerror = "";
852 if (Object.keys(errortab1).length > 0) {
853 stringerror += "<br>'.
dol_escape_js($langs->transnoentities(
'ErrorSameBatchNumber')).
': ";
854 errortab1.forEach(element => {
855 stringerror += (element + ", ")
857 stringerror = stringerror.slice(0, -2); /* Remove last ", " */
859 if (Object.keys(errortab2).length > 0) {
860 stringerror += "<br>'.
dol_escape_js($langs->transnoentities(
'ErrorCantFindCodeInInventory')).
': ";
861 errortab2.forEach(element => {
862 stringerror += (element + ", ")
864 stringerror = stringerror.slice(0, -2); /* Remove last ", " */
866 if (Object.keys(errortab3).length > 0) {
867 stringerror += "<br>'.
dol_escape_js($langs->transnoentities(
'ErrorCodeScannedIsBothProductAndSerial')).
': ";
868 errortab3.forEach(element => {
869 stringerror += (element + ", ")
871 stringerror = stringerror.slice(0, -2); /* Remove last ", " */
873 if (Object.keys(errortab4).length > 0) {
874 stringerror += "<br>'.
dol_escape_js($langs->transnoentities(
'ErrorBarcodeNotFoundForProductWarehouse')).
': ";
875 errortab4.forEach(element => {
876 stringerror += (element + ", ")
878 stringerror = stringerror.slice(0, -2); /* Remove last ", " */
881 jQuery("#scantoolmessage").html(\''.
dol_escape_js($langs->transnoentities(
"ErrorOnElementsInventory")).
'\' + stringerror);
889 function barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,mode,autodetect=
false){
890 BarcodeIsInProduct=0;
893 tabproduct.forEach(product => {
894 $.ajax({ url: \
''.DOL_URL_ROOT.
'/product/inventory/ajax/searchfrombarcode.php\',
895 data: { "token":"'.
newToken().
'", "action":"existbarcode", '.(!empty(
$object->fk_warehouse) ?
'"fk_entrepot":'.$object->fk_warehouse.
', ' :
'').(!empty(
$object->fk_product) ?
'"fk_product":'.$object->fk_product.
', ' :
'').
'"barcode":element, "product":product, "mode":mode},
898 success: function(response) {
899 if (typeof response == "object") {
900 console.log("response is already type object, no need to parse it");
902 console.log("response is type "+(typeof response));
903 response = JSON.parse(response);
905 if (response.status == "success"){
906 console.log(response.message);
908 newproductrow = response.object;
911 if (mode!="lotserial" && autodetect==false && !errortab4.includes(element)){
912 errortab4.push(element);
913 console.error(response.message);
917 error : function(output) {
918 console.error("Error on barcodeserialforproduct function");
921 console.log("Product "+(index+=1)+": "+element);
922 if(mode == "barcode"){
923 testonproduct = product.Barcode
924 }else if (mode == "lotserial"){
925 testonproduct = product.Batch
927 if(testonproduct == element){
928 if(selectaddorreplace == "add"){
929 productqty = parseInt(product.Qty,10);
930 product.Qty = productqty + parseInt(barcodeproductqty,10);
931 }else if(selectaddorreplace == "replace"){
932 if(product.fetched == false){
933 product.Qty = barcodeproductqty
936 productqty = parseInt(product.Qty,10);
937 product.Qty = productqty + parseInt(barcodeproductqty,10);
940 BarcodeIsInProduct+=1;
943 if(BarcodeIsInProduct==0 && newproductrow!=0){
944 tabproduct.push({\'Id\':tabproduct.length-1,\'Warehouse\':newproductrow.fk_warehouse,\'Barcode\':mode=="barcode"?element:null,\'Batch\':mode=="lotserial"?element:null,\'Qty\':barcodeproductqty,\'fetched\':true,\'reelqty\':newproductrow.reelqty,\'fk_product\':newproductrow.fk_product,\'mode\':mode});
947 if(BarcodeIsInProduct > 0){
955 include DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
957 print $formother->getHTMLScannerForm(
"barcodescannerjs",
'all');
962print
'jQuery(document).ready(function() {
963 $("#clearqty").on("click", function() {
964 console.log("Clear all values");
965 /* disablebuttonmakemovementandclose(); */
966 jQuery(".realqty").val("");
967 jQuery(".realqty").trigger("change");
968 return false; /* disable submit */
970 $(".undochangesqty").on("click", function undochangesqty() {
971 console.log("Clear value of inventory line");
973 id = id.split("_")[1];
974 tmpvalue = $("#id_"+id+"_input_tmp").val()
975 $("#id_"+id+"_input")[0].value = tmpvalue;
976 /* disablebuttonmakemovementandclose(); */
977 return false; /* disable submit */
982print
'<div class="fichecenter">';
984print
'<div class="clearboth"></div>';
988print
'<div class="div-table-responsive-no-min">';
989print
'<table id="tablelines" class="noborder noshadow centpercent">';
991print
'<tr class="liste_titre">';
992print
getTitleFieldOfList($langs->trans(
"Warehouse"), 0, $_SERVER[
'PHP_SELF'],
'e.ref',
'',
'id=' .
$object->id .
'&page=' . $page . $param,
'', $sortfield, $sortorder,
'', 0,
'') .
"\n";
993print
getTitleFieldOfList($langs->trans(
"Product"), 0, $_SERVER[
'PHP_SELF'],
'p.ref',
'',
'id=' .
$object->id .
'&page=' . $page . $param,
'', $sortfield, $sortorder,
'', 0,
'') .
"\n";
994if (isModEnabled(
'productbatch')) {
996 print $langs->trans(
"Batch");
999if (
$object->status == $object::STATUS_DRAFT ||
$object->status == $object::STATUS_VALIDATED) {
1001 print
'<td class="right">'.$form->textwithpicto($langs->trans(
"ExpectedQty"), $langs->trans(
"QtyCurrentlyKnownInStock")).
'</td>';
1004 print
'<td class="right">'.$form->textwithpicto($langs->trans(
"ExpectedQty"), $langs->trans(
"QtyInStockWhenInventoryWasValidated")).
'</td>';
1007 print
'<td class="right">'.$langs->trans(
'PMPExpected').
'</td>';
1008 print
'<td class="right">'.$langs->trans(
'ExpectedValuation').
'</td>';
1009 print
'<td class="right">'.$form->textwithpicto($langs->trans(
"RealQty"), $langs->trans(
"InventoryRealQtyHelp")).
'</td>';
1010 print
'<td class="right">'.$langs->trans(
'PMPReal').
'</td>';
1011 print
'<td class="right">'.$langs->trans(
'RealValuation').
'</td>';
1013 print
'<td class="right">';
1014 print $form->textwithpicto($langs->trans(
"RealQty"), $langs->trans(
"InventoryRealQtyHelp"));
1017if (
$object->status == $object::STATUS_DRAFT ||
$object->status == $object::STATUS_VALIDATED) {
1019 print
'<td class="center">';
1023 print
'<td class="right">';
1030if (
$object->status == $object::STATUS_DRAFT ||
$object->status == $object::STATUS_VALIDATED) {
1033 print $formproduct->selectWarehouses((GETPOSTISSET(
'fk_warehouse') ?
GETPOSTINT(
'fk_warehouse') :
$object->fk_warehouse),
'fk_warehouse',
'warehouseopen', 1, 0, 0,
'', 0, 0, array(),
'maxwidth300');
1041 print $form->select_produits((GETPOSTISSET(
'fk_product') ?
GETPOSTINT(
'fk_product') :
$object->fk_product),
'fk_product', $filtertype, 0, 0, -1, 2,
'', 0, array(), 0,
'1', 0,
'maxwidth300');
1043 if (isModEnabled(
'productbatch')) {
1045 print
'<input type="text" name="batch" class="maxwidth100" value="'.(GETPOSTISSET(
'batch') ?
GETPOST(
'batch') :
'').
'">';
1048 print
'<td class="right"></td>';
1050 print
'<td class="right">';
1052 print
'<td class="right">';
1054 print
'<td class="right">';
1055 print
'<input type="text" name="qtytoadd" class="maxwidth75" value="">';
1057 print
'<td class="right">';
1059 print
'<td class="right">';
1062 print
'<td class="right">';
1063 print
'<input type="text" name="qtytoadd" class="maxwidth75" value="">';
1067 print
'<td class="center">';
1068 if ($permissiontoupdatestock) {
1069 print
'<input type="submit" class="button paddingright" name="addline" value="'.$langs->trans(
"Add").
'">';
1071 print
'<input type="submit" class="button paddingright" disabled="disabled" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'" name="addline" value="'.$langs->trans(
"Add").
'">';
1078$sql =
'SELECT id.rowid, id.datec as date_creation, id.tms as date_modification, id.fk_inventory, id.fk_warehouse,';
1079$sql .=
' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated, id.fk_movement, id.pmp_real, id.pmp_expected';
1080$sql .=
' FROM ' . $db->prefix() .
'inventorydet as id';
1081$sql .=
' LEFT JOIN ' . $db->prefix() .
'product as p ON id.fk_product = p.rowid';
1082$sql .=
' LEFT JOIN ' . $db->prefix() .
'entrepot as e ON id.fk_warehouse = e.rowid';
1083$sql .=
' WHERE id.fk_inventory = ' . ((int)
$object->id);
1084$sql .= $db->order($sortfieldforsql, $sortorderforsql);
1085$sql .= $db->plimit($limit, $offset);
1087$cacheOfProducts = array();
1088$cacheOfWarehouses = array();
1091$resql = $db->query($sql);
1093 $num = $db->num_rows($resql);
1095 if (!empty($limit != 0) || $num > $limit || $page) {
1096 print_fleche_navigation($page, $_SERVER[
"PHP_SELF"],
'&id='.
$object->id.$paramwithsearch, ($num >= $limit ? 1 : 0),
'<li class="pagination"><span>' . $langs->trans(
"Page") .
' ' . ($page + 1) .
'</span></li>',
'', $limit);
1103 $obj = $db->fetch_object($resql);
1105 if (isset($cacheOfWarehouses[$obj->fk_warehouse])) {
1106 $warehouse_static = $cacheOfWarehouses[$obj->fk_warehouse];
1108 $warehouse_static =
new Entrepot($db);
1109 $warehouse_static->fetch($obj->fk_warehouse);
1111 $cacheOfWarehouses[$warehouse_static->id] = $warehouse_static;
1116 if (isset($cacheOfProducts[$obj->fk_product])) {
1117 $product_static = $cacheOfProducts[$obj->fk_product];
1119 $product_static =
new Product($db);
1120 $result = $product_static->fetch($obj->fk_product,
'',
'',
'', 1, 1, 1);
1123 $option .=
',novirtual';
1124 $product_static->load_stock($option);
1126 $cacheOfProducts[$product_static->id] = $product_static;
1129 print
'<tr class="oddeven">';
1130 print
'<td id="id_'.$obj->rowid.
'_warehouse" data-ref="'.
dol_escape_htmltag($warehouse_static->ref).
'">';
1131 print $warehouse_static->getNomUrl(1);
1134 print $product_static->getNomUrl(1).
' - '.$product_static->label;
1137 if (isModEnabled(
'productbatch')) {
1138 print
'<td id="id_'.$obj->rowid.
'_batch" data-batch="'.
dol_escape_htmltag($obj->batch).
'">';
1141 $res = $batch_static->fetch(0, $product_static->id, $obj->batch);
1143 print $batch_static->getNomUrl(1);
1152 print
'<td class="right expectedqty" id="id_'.$obj->rowid.
'" title="Stock viewed at last update: '.$obj->qty_stock.
'">';
1153 $valuetoshow = $obj->qty_stock;
1155 if (
$object->status == $object::STATUS_DRAFT ||
$object->status == $object::STATUS_VALIDATED) {
1156 if (isModEnabled(
'productbatch') && $product_static->hasbatch()) {
1157 $valuetoshow = $product_static->stock_warehouse[$obj->fk_warehouse]->detail_batch[$obj->batch]->qty ?? 0;
1159 $valuetoshow = !empty($product_static->stock_warehouse[$obj->fk_warehouse]->real) ? $product_static->stock_warehouse[$obj->fk_warehouse]->real : 0;
1163 print
'<input type="hidden" name="stock_qty_'.$obj->rowid.
'" value="'.$valuetoshow.
'">';
1167 if (
$object->status == $object::STATUS_DRAFT ||
$object->status == $object::STATUS_VALIDATED) {
1171 if ($qty_view !=
'') {
1177 if (!empty($obj->pmp_expected)) {
1178 $pmp_expected = $obj->pmp_expected;
1180 $pmp_expected = $product_static->pmp;
1182 $pmp_valuation = $pmp_expected * $valuetoshow;
1183 print
'<td class="right">';
1184 print is_null($pmp_expected) ?
'' :
price($pmp_expected);
1185 print
'<input type="hidden" name="expectedpmp_'.$obj->rowid.
'" value="'.$pmp_expected.
'"/>';
1187 print
'<td class="right">';
1188 print
price($pmp_valuation);
1191 print
'<td class="right">';
1192 print
'<a id="undochangesqty_'.$obj->rowid.
'" href="#" class="undochangesqty reposition marginrightonly" title="'.
dol_escape_htmltag($langs->trans(
"Clear")).
'">';
1193 print
img_picto(
'',
'eraser',
'class="opacitymedium"');
1195 print
'<input type="text" class="maxwidth50 right realqty" name="id_'.$obj->rowid.
'" id="id_'.$obj->rowid.
'_input" value="'.$qty_view.
'">';
1199 print
'<td class="right">';
1200 if (!empty($obj->pmp_real) || (
string) $obj->pmp_real ===
'0') {
1201 $pmp_real = $obj->pmp_real;
1203 $pmp_real = $product_static->pmp;
1205 $pmp_valuation_real = $pmp_real * $qty_view;
1206 print
'<input type="text" class="maxwidth75 right realpmp'.$obj->fk_product.
'" name="realpmp_'.$obj->rowid.
'" id="id_'.$obj->rowid.
'_input_pmp" value="'.(is_null($pmp_real) ?
'' :
price2num($pmp_real)).
'">';
1208 print
'<td class="right">';
1209 print
'<input type="text" class="maxwidth75 right realvaluation'.$obj->fk_product.
'" name="realvaluation_'.$obj->rowid.
'" id="id_'.$obj->rowid.
'_input_real_valuation" value="'.$pmp_valuation_real.
'">';
1212 $totalExpectedValuation += $pmp_valuation;
1213 $totalRealValuation += $pmp_valuation_real;
1215 print
'<td class="right">';
1216 print
'<a id="undochangesqty_'.$obj->rowid.
'" href="#" class="undochangesqty reposition marginrightonly" title="'.
dol_escape_htmltag($langs->trans(
"Clear")).
'">';
1217 print
img_picto(
'',
'eraser',
'class="opacitymedium"');
1219 print
'<input type="text" class="maxwidth50 right realqty" name="id_'.$obj->rowid.
'" id="id_'.$obj->rowid.
'_input" value="'.$qty_view.
'">';
1224 print
'<td class="right">';
1225 if ($permissiontoupdatestock) {
1226 print
'<a class="reposition" href="'.DOL_URL_ROOT.
'/product/inventory/inventory.php?id='.
$object->id.
'&lineid='.$obj->rowid.
'&action=deleteline&page='.$page.$paramwithsearch.
'&token='.
newToken().
'">'.
img_delete().
'</a>';
1228 $qty_tmp =
price2num(
GETPOST(
"id_".$obj->rowid.
"_input_tmp"),
'MS') >= 0 ?
GETPOST(
"id_".$obj->rowid.
"_input_tmp") : $qty_view;
1229 print
'<input type="hidden" class="maxwidth50 right realqty" name="id_'.$obj->rowid.
'_input_tmp" id="id_'.$obj->rowid.
'_input_tmp" value="'.$qty_tmp.
'">';
1234 if (!empty($obj->pmp_expected)) {
1235 $pmp_expected = $obj->pmp_expected;
1237 $pmp_expected = $product_static->pmp;
1239 $pmp_valuation = $pmp_expected * $valuetoshow;
1240 print
'<td class="right">';
1241 print is_null($pmp_expected) ?
'' :
price($pmp_expected);
1243 print
'<td class="right">';
1244 print
price($pmp_valuation);
1247 print
'<td class="right nowraponall">';
1248 print $obj->qty_view;
1252 print
'<td class="right">';
1253 if (!empty($obj->pmp_real)) {
1254 $pmp_real = $obj->pmp_real;
1256 $pmp_real = $product_static->pmp;
1258 $pmp_valuation_real = $pmp_real * $obj->qty_view;
1259 print is_null($pmp_real) ?
'' :
price($pmp_real);
1261 print
'<td class="right">';
1262 print
price($pmp_valuation_real);
1264 print
'<td class="nowraponall right">';
1266 $totalExpectedValuation += $pmp_valuation;
1267 $totalRealValuation += $pmp_valuation_real;
1269 print
'<td class="right nowraponall">';
1270 print $obj->qty_view;
1274 if ($obj->fk_movement > 0) {
1276 $stockmovment->fetch($obj->fk_movement);
1277 print $stockmovment->getNomUrl(1,
'movements');
1289 print
'<tr class="liste_total">';
1290 print
'<td colspan="4">'.$langs->trans(
"Total").
'</td>';
1291 print
'<td class="right" colspan="2">'.price($totalExpectedValuation).
'</td>';
1292 print
'<td class="right" id="totalRealValuation" colspan="3">'.price($totalRealValuation).
'</td>';
1300if (
$object->status == $object::STATUS_VALIDATED) {
1301 print
'<center><input id="submitrecord" type="submit" class="button button-save" name="save" value="'.$langs->trans(
"Save").
'"></center>';
1321print
'<script type="text/javascript">
1322 $(document).ready(function() {
1324 $(".paginationnext:last").click(function(e){
1325 var form = $("#formrecord");
1326 var actionURL = "'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&page='.($page).$paramwithsearch.
'";
1329 data: form.serialize(),
1331 success: function(result){
1332 window.location.href = "'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&page='.($page + 1).$paramwithsearch.
'";
1338 $(".paginationprevious:last").click(function(e){
1339 var form = $("#formrecord");
1340 var actionURL = "'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&page='.($page).$paramwithsearch.
'";
1343 data: form.serialize(),
1345 success: function(result){
1346 window.location.href = "'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&page='.($page - 1).$paramwithsearch.
'";
1351 $("#idbuttonmakemovementandclose").click(function(e){
1352 var form = $("#formrecord");
1353 var actionURL = "'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&page='.($page).$paramwithsearch.
'";
1357 data: form.serialize(),
1359 success: function(result){
1360 window.location.href = "'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&page='.($page).$paramwithsearch.
'&action=record";
1370<script
type=
"text/javascript">
1371$(
'.realqty').on(
'change',
function () {
1372 let realqty = $(
this).closest(
'tr').find(
'.realqty').val();
1373 let inputPmp = $(
this).closest(
'tr').find(
'input[class*=realpmp]');
1374 let realpmp = $(inputPmp).val();
1375 if (!isNaN(realqty) && !isNaN(realpmp)) {
1376 let realval = realqty * realpmp;
1377 $(
this).closest(
'tr').find(
'input[name^=realvaluation]').val(realval.toFixed(2));
1379 updateTotalValuation();
1382$(
'input[class*=realpmp]').on(
'change',
function () {
1383 let inputQtyReal = $(
this).closest(
'tr').find(
'.realqty');
1384 let realqty = $(inputQtyReal).val();
1385 let inputPmp = $(
this).closest(
'tr').find(
'input[class*=realpmp]');
1386 console.log(inputPmp);
1387 let realPmpClassname = $(inputPmp).attr(
'class').match(/[\w-]*realpmp[\w-]*/g)[0];
1388 let realpmp = $(inputPmp).val();
1389 if (!isNaN(realpmp)) {
1390 $(
'.'+realPmpClassname).val(realpmp);
1392 if (!isNaN(realqty)) {
1393 let realval = realqty * realpmp;
1394 $(
this).closest(
'tr').find(
'input[name^=realvaluation]').val(realval.toFixed(2));
1396 $(
'.realqty').trigger(
'change');
1397 updateTotalValuation();
1401$(
'input[name^=realvaluation]').on(
'change',
function () {
1402 let inputQtyReal = $(
this).closest(
'tr').find(
'.realqty');
1403 let realqty = $(inputQtyReal).val();
1404 let inputPmp = $(
this).closest(
'tr').find(
'input[class*=realpmp]');
1405 let inputRealValuation = $(
this).closest(
'tr').find(
'input[name^=realvaluation]');
1406 let realPmpClassname = $(inputPmp).attr(
'class').match(/[\w-]*realpmp[\w-]*/g)[0];
1407 let realvaluation = $(inputRealValuation).val();
1408 if (!isNaN(realvaluation) && !isNaN(realqty) && realvaluation !==
'' && realqty !==
'' && realqty !== 0) {
1409 let realpmp = realvaluation / realqty
1410 $(
'.'+realPmpClassname).val(realpmp);
1411 $(
'.realqty').trigger(
'change');
1412 updateTotalValuation();
1416function updateTotalValuation() {
1418 $(
'input[name^=realvaluation]').each(
function( index ) {
1419 let val = $(
this).val();
1420 if(!isNaN(val)) total += parseFloat($(
this).val());
1422 let currencyFractionDigits =
new Intl.NumberFormat(
'fr-FR', {
1425 }).resolvedOptions().maximumFractionDigits;
1426 $(
'#totalRealValuation').html(total.toLocaleString(
'fr-FR', {
1427 maximumFractionDigits: currencyFractionDigits
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
Class to manage stock movements.
Class to manage products or services.
Class with list of lots and properties.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
dol_strtolower($string, $encoding="UTF-8")
Convert a string to lower.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
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, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
currentToken()
Return the value of token currently saved into session with name 'token'.
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_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
print_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit=-1, $totalnboflines=0, $selectlimitsuffix='', $beforearrows='', $hidenavigation=0)
Function to show navigation arrows into lists.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
inventoryPrepareHead(&$inventory, $title='Inventory', $get='')
Define head array for tabs of inventory tools setup pages.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
if(preg_match('/(crypted|dolcrypt):/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.