--- /tmp/dsg/dolibarr/htdocs/product/stock/github_19.0.3_card.php +++ /tmp/dsg/dolibarr/htdocs/product/stock/client_card.php @@ -7,4 +6,0 @@ - * Copyright (C) 2021 Noé Cendrier - * Copyright (C) 2021 Frédéric France - * Copyright (C) 2022-2023 Charlene Benke - * Copyright (C) 2023 Christian Foellmann @@ -32 +27,0 @@ -// Load Dolibarr environment @@ -43,5 +37,0 @@ -if (isModEnabled('project')) { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; -} - @@ -54 +43,0 @@ -$projectid = GETPOST('projectid', 'int'); @@ -57 +45,0 @@ -$socid = GETPOST('socid', 'int'); @@ -60,10 +48,4 @@ -// Load variable for pagination -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); -if (!$sortfield) { - $sortfield = "p.ref"; -} -if (!$sortorder) { - $sortorder = "DESC"; -} +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +if (!$sortfield) $sortfield = "p.ref"; +if (!$sortorder) $sortorder = "DESC"; @@ -78 +60 @@ -$hookmanager->initHooks(array('warehousecard', 'stocklist', 'globalcard')); +$hookmanager->initHooks(array('warehousecard', 'globalcard')); @@ -88,5 +70,7 @@ - $ret = $object->fetch($id, $ref); - if ($ret <= 0) { - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; - } + $ret = $object->fetch($id, $ref); + // if ($ret > 0) + // $ret = $object->fetch_thirdparty(); + if ($ret <= 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } @@ -93,0 +78,7 @@ + + +/* + * Actions + */ + +$error = 0; @@ -99,7 +89,0 @@ - -/* - * Actions - */ - -$error = 0; - @@ -108,27 +92,3 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} -if (empty($reshook)) { - $backurlforlist = DOL_URL_ROOT.'/product/stock/list.php'; - - if (empty($backtopage) || ($cancel && empty($id))) { - if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { - if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { - $backtopage = $backurlforlist; - } else { - $backtopage = DOL_URL_ROOT.'/product/stock/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__'); - } - } - } - - if ($cancel) { - if (!empty($backtopageforcancel)) { - header("Location: ".$backtopageforcancel); - exit; - } elseif (!empty($backtopage)) { - header("Location: ".$backtopage); - exit; - } - $action = ''; - } - +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if (empty($reshook)) +{ @@ -136,27 +96,28 @@ - if ($action == 'add' && $user->hasRight('stock', 'creer')) { - $object->ref = (string) GETPOST("ref", "alpha"); - $object->fk_parent = (int) GETPOST("fk_parent", "int"); - $object->fk_project = GETPOST('projectid', 'int'); - $object->label = (string) GETPOST("libelle", "alpha"); - $object->description = (string) GETPOST("desc", "alpha"); - $object->statut = GETPOST("statut", "int"); - $object->lieu = (string) GETPOST("lieu", "alpha"); - $object->address = (string) GETPOST("address", "alpha"); - $object->zip = (string) GETPOST("zipcode", "alpha"); - $object->town = (string) GETPOST("town", "alpha"); - $object->country_id = GETPOST("country_id"); - $object->phone = (string) GETPOST("phone", "alpha"); - $object->fax = (string) GETPOST("fax", "alpha"); - - if (!empty($object->label)) { - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) { - $error++; - $action = 'create'; - } - - if (!$error) { - $id = $object->create($user); - if ($id > 0) { - setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); + if ($action == 'add' && $user->rights->stock->creer) + { + $object->ref = GETPOST("ref"); + $object->fk_parent = GETPOST("fk_parent"); + $object->libelle = GETPOST("libelle"); + $object->description = GETPOST("desc"); + $object->statut = GETPOST("statut"); + $object->lieu = GETPOST("lieu"); + $object->address = GETPOST("address"); + $object->zip = GETPOST("zipcode"); + $object->town = GETPOST("town"); + $object->country_id = GETPOST("country_id"); + $object->phone = GETPOST("phone"); + $object->fax = GETPOST("fax"); + + if (!empty($object->libelle)) + { + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) { + $error++; + $action = 'create'; + } + + if (!$error) { + $id = $object->create($user); + if ($id > 0) { + setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); @@ -166,14 +127,15 @@ - if (!empty($backtopage)) { - $backtopage = str_replace("__ID__", $id, $backtopage); - header("Location: ".$backtopage); - exit; - } else { - header("Location: card.php?id=".urlencode($id)); - exit; - } - } else { - $action = 'create'; - setEventMessages($object->error, $object->errors, 'errors'); - } - } - } else { + if (!empty($backtopage)) { + header("Location: ".$backtopage); + exit; + } else { + header("Location: card.php?id=".$id); + exit; + } + } else { + $action = 'create'; + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + else + { @@ -186 +148,2 @@ - if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('stock', 'supprimer')) { + if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->stock->supprimer) + { @@ -189,2 +152,3 @@ - if ($result > 0) { - setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); + if ($result > 0) + { + setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); @@ -193 +157,3 @@ - } else { + } + else + { @@ -200,3 +166,5 @@ - if ($action == 'update' && !$cancel) { - if ($object->fetch($id)) { - $object->label = GETPOST("libelle"); + if ($action == 'update' && $cancel <> $langs->trans("Cancel")) + { + if ($object->fetch($id)) + { + $object->libelle = GETPOST("libelle"); @@ -204,2 +172 @@ - $object->fk_project = GETPOST('projectid'); - $object->description = GETPOST("desc", 'restricthtml'); + $object->description = GETPOST("desc"); @@ -215,12 +182,8 @@ - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); - if ($ret < 0) { - $error++; - } - - if (!$error) { - $ret = $object->update($id, $user); - if ($ret < 0) { - $error++; - } - } + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) $error++; + + if (!$error) { + $ret = $object->update($id, $user); + if ($ret < 0) $error++; + } @@ -234,3 +197,5 @@ - $action = ''; - } - } else { + $action = ''; + } + } + else + { @@ -240,21 +204,0 @@ - } elseif ($action == 'update_extras') { - $object->oldcopy = dol_clone($object, 2); - - // Fill array 'array_options' with data from update form - $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); - if ($ret < 0) { - $error++; - } - if (!$error) { - $result = $object->insertExtraFields(); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } - if ($error) { - $action = 'edit_extras'; - } - } elseif ($action == 'classin' && $usercancreate) { - // Link to a project - $object->setProject(GETPOST('projectid', 'int')); @@ -262,2 +206,18 @@ - - if ($cancel == $langs->trans("Cancel")) { + elseif ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); + + // Fill array 'array_options' with data from update form + $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); + if ($ret < 0) $error++; + if (!$error) { + $result = $object->insertExtraFields(); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + } + if ($error) $action = 'edit_extras'; + } + + if ($cancel == $langs->trans("Cancel")) + { @@ -284,8 +243,0 @@ -if (isModEnabled('project')) { - $formproject = new FormProjets($db); -} - -$title = $langs->trans("WarehouseCard"); -if ($action == 'create') { - $title = $langs->trans("NewWarehouse"); -} @@ -294,4 +246,5 @@ -llxHeader("", $title, $help_url); - - -if ($action == 'create') { +llxHeader("", $langs->trans("WarehouseCard"), $help_url); + + +if ($action == 'create') +{ @@ -307 +260 @@ - print dol_get_fiche_head(); + dol_fiche_head(); @@ -318 +271 @@ - print img_picto('', 'stock').$formproduct->selectWarehouses((GETPOSTISSET('fk_parent') ? GETPOST('fk_parent', 'int') : 'ifone'), 'fk_parent', '', 1); + print $formproduct->selectWarehouses('', 'fk_parent', '', 1); @@ -320,9 +272,0 @@ - - // Project - if (isModEnabled('project')) { - $langs->load('projects'); - print ''.$langs->trans('Project').''; - print img_picto('', 'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); - print ' '; - print ''; - } @@ -334 +278 @@ - $doleditor = new DolEditor('desc', (!empty($object->description) ? $object->description : ''), '', 180, 'dolibarr_notes', 'In', false, true, isModEnabled('fckeditor'), ROWS_5, '90%'); + $doleditor = new DolEditor('desc', (!empty($object->description) ? $object->description : ''), '', 180, 'dolibarr_notes', 'In', false, true, $conf->fckeditor->enabled, ROWS_5, '90%'); @@ -339 +283 @@ - print(!empty($object->address) ? $object->address : ''); + print (!empty($object->address) ? $object->address : ''); @@ -354,3 +298 @@ - if ($user->admin) { - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - } + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); @@ -360 +302 @@ - print ''.$form->editfieldkey('Phone', 'phone', '', $object, 0).''; + print ''.$form->editfieldkey('Phone', 'phone', '', $object, 0).''; @@ -363 +305 @@ - print ''.$form->editfieldkey('Fax', 'fax', '', $object, 0).''; + print ''.$form->editfieldkey('Fax', 'fax', '', $object, 0).''; @@ -370,3 +312,5 @@ - print ''; + foreach ($object->statuts as $key => $value) + { + if ($key == 1) + { @@ -374 +318,3 @@ - } else { + } + else + { @@ -379 +324,0 @@ - print ajax_combobox('warehousestatus'); @@ -382,4 +327,4 @@ - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; - - if (isModEnabled('categorie')) { + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + + if ($conf->categorie->enabled) { @@ -389 +334 @@ - print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print $form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, '', 0, '100%'); @@ -394,3 +339,7 @@ - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel("Create"); + dol_fiche_end(); + + print '
'; + print ''; + print '     '; + print ''; + print '
'; @@ -399,3 +348,6 @@ -} else { - $id = GETPOST("id", 'int'); - if ($id > 0 || $ref) { +} +else +{ + $id = GETPOST("id", 'int'); + if ($id > 0 || $ref) + { @@ -404 +356,2 @@ - if ($result <= 0) { + if ($result <= 0) + { @@ -409,2 +362,5 @@ - // View mode - if ($action != 'edit' && $action != 're-edit') { + /* + * Affichage fiche + */ + if ($action <> 'edit' && $action <> 're-edit') + { @@ -413 +369 @@ - print dol_get_fiche_head($head, 'card', $langs->trans("Warehouse"), -1, 'stock'); + dol_fiche_head($head, 'card', $langs->trans("Warehouse"), -1, 'stock'); @@ -418,5 +374,3 @@ - if ($action == 'delete') { - $formquestion = array( - array('type' => 'other', 'name' => 'info', 'label' => img_warning('').$langs->trans("WarningThisWIllAlsoDeleteStock"), 'morecss'=>'warning') - ); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteAWarehouse"), $langs->trans("ConfirmDeleteWarehouse", $object->label), "confirm_delete", $formquestion, 0, 2); + if ($action == 'delete') + { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteAWarehouse"), $langs->trans("ConfirmDeleteWarehouse", $object->label), "confirm_delete", '', 0, 2); @@ -428,5 +382,2 @@ - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; @@ -442,47 +393,12 @@ - - // Project - if (isModEnabled('project')) { - $langs->load("projects"); - $morehtmlref .= '
'.img_picto('', 'project').' '.$langs->trans('Project').' '; - if ($usercancreate) { - if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; - } - if ($action == 'classify') { - $projectid = $object->fk_project; - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, ($socid > 0 ? $socid : -1), $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ' : '.$proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.$proj->title; - } - } else { - $morehtmlref .= ''; - } - } - } - $morehtmlref .= ''; - - $shownav = 1; - if ($user->socid && !in_array('stock', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) { - $shownav = 0; - } - - dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref); - - print '
'; - print '
'; - print '
'; - - print ''; + $morehtmlref .= ''; + + $shownav = 1; + if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref); + + print '
'; + print '
'; + print '
'; + + print '
'; @@ -498,2 +413,0 @@ - print ''; - @@ -501 +415 @@ - print ''; + print ''; @@ -513,2 +427,2 @@ - $valtoshow = price2num($calcproducts['nb'], 'MS'); - print empty($valtoshow) ? '0' : $valtoshow; + $valtoshow = price2num($calcproducts['nb'], 'MS'); + print empty($valtoshow) ? '0' : $valtoshow; @@ -520,0 +435 @@ + print '
'; @@ -531 +446 @@ - if ($user->hasRight('stock', 'mouvement', 'lire')) { + if (!empty($user->rights->stock->mouvement->lire)) { @@ -534 +449 @@ - $sql .= " WHERE m.fk_entrepot = ".((int) $object->id); + $sql .= " WHERE m.fk_entrepot = '".$object->id."'"; @@ -544,4 +459,2 @@ - print dol_print_date($lastmovementdate, 'dayhour'); - print '     '; - print img_picto($langs->trans('LastMovement'), 'movement', 'class="pictofixedwidth"'); - print ''.$langs->trans("FullList").''; + print dol_print_date($lastmovementdate, 'dayhour').' '; + print '('.$langs->trans("FullList").')'; @@ -554,3 +467,2 @@ - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; @@ -558 +470 @@ - if (isModEnabled('categorie')) { + if ($conf->categorie->enabled) { @@ -563 +474,0 @@ - @@ -567,0 +479 @@ + print '
'; @@ -571,6 +483,9 @@ - print dol_get_fiche_end(); - - - /* - * Action bar - */ + dol_fiche_end(); + + + /* ************************************************************************** */ + /* */ + /* Barre d'action */ + /* */ + /* ************************************************************************** */ + @@ -581,13 +496,13 @@ - if (empty($reshook)) { - if (empty($action) || $action == 'classin') { - if ($user->hasRight('stock', 'creer')) { - print ''.$langs->trans("Modify").''; - } else { - print ''.$langs->trans("Modify").''; - } - - if ($user->hasRight('stock', 'supprimer')) { - print ''.$langs->trans("Delete").''; - } else { - print ''.$langs->trans("Delete").''; - } + if (empty($reshook)) + { + if (empty($action)) + { + if ($user->rights->stock->creer) + print "id."\">".$langs->trans("Modify").""; + else + print "".$langs->trans("Modify").""; + + if ($user->rights->stock->supprimer) + print "id."\">".$langs->trans("Delete").""; + else + print "".$langs->trans("Delete").""; @@ -600,21 +515,10 @@ - // Show list of products into warehouse - - - $totalarray = array(); - $totalarray['val'] = array(); - $totalarray['pos'] = array(); - $totalarray['type'] = array(); - $totalarray['nbfield'] = 0; - - // TODO Create $arrayfields with all fields to show - - print load_fiche_titre($langs->trans("Stock"), '', 'stock'); - - print '
'; - print '
'.$langs->trans("Description").''.dol_htmlentitiesbr($object->description).'
'.$langs->trans("Description").''.nl2br($object->description).'
'; - print ''; - $parameters = array('totalarray' => &$totalarray); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - print_liste_field_titre("Products", "", "p.ref", "&id=".$id, "", "", $sortfield, $sortorder); + /* ************************************************************************** */ + /* */ + /* Affichage de la liste des produits de l'entrepot */ + /* */ + /* ************************************************************************** */ + print '
'; + + print '
'; + print ""; + print_liste_field_titre("Product", "", "p.ref", "&id=".$id, "", "", $sortfield, $sortorder); @@ -622,15 +526,3 @@ - print_liste_field_titre("NumberOfUnit", "", "ps.reel", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield'] += 3; - $totalarray['pos'][$totalarray['nbfield']] = 'totalunit'; - $totalarray['type'][$totalarray['nbfield']] = 'stock'; - - if (getDolGlobalString('PRODUCT_USE_UNITS')) { - print_liste_field_titre("Unit", "", "p.fk_unit", "&id=".$id, "", 'align="left"', $sortfield, $sortorder); - $totalarray['nbfield']++; - $totalarray['pos'][$totalarray['nbfield']] = 'units'; - $totalarray['type'][$totalarray['nbfield']] = 'string'; - } - - print_liste_field_titre($form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc")), "", "p.pmp", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - + print_liste_field_titre("Units", "", "ps.reel", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); + if (!empty($conf->global->PRODUCT_USE_UNITS)) print_liste_field_titre("Unit", "", "p.fk_unit", "&id=".$id, "", 'align="left"', $sortfield, $sortorder); + print_liste_field_titre("AverageUnitPricePMPShort", "", "p.pmp", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); @@ -638,27 +530,12 @@ - $totalarray['nbfield']++; - $totalarray['pos'][$totalarray['nbfield']] = 'totalvalue'; - $totalarray['type'][$totalarray['nbfield']] = ''; - - - if (!getDolGlobalString('PRODUIT_MULTIPRICES')) { - print_liste_field_titre("SellPriceMin", "", "p.price", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - } - if (!getDolGlobalString('PRODUIT_MULTIPRICES')) { - print_liste_field_titre("EstimatedStockValueSellShort", "", "", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - $totalarray['pos'][$totalarray['nbfield']] = 'totalvaluesell'; - $totalarray['type'][$totalarray['nbfield']] = ''; - } - if ($user->hasRight('stock', 'mouvement', 'creer')) { - print_liste_field_titre(''); - $totalarray['nbfield']++; - } - if ($user->hasRight('stock', 'creer')) { - print_liste_field_titre(''); - $totalarray['nbfield']++; - } - // Hook fields - $parameters = array('sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray' => &$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + if (empty($conf->global->PRODUIT_MULTIPRICES)) { + print_liste_field_titre("SellPriceMin", "", "p.price", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); + } + if (empty($conf->global->PRODUIT_MULTIPRICES)) { + print_liste_field_titre("EstimatedStockValueSellShort", "", "", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); + } + if ($user->rights->stock->mouvement->creer) { + print_liste_field_titre(''); + } + if ($user->rights->stock->creer) { + print_liste_field_titre(''); + } @@ -670,20 +547 @@ - //For MultiCompany PMP per entity - $separatedPMP = false; - if (getDolGlobalString('MULTICOMPANY_PRODUCT_SHARING_ENABLED') && getDolGlobalString('MULTICOMPANY_PMP_PER_ENTITY_ENABLED')) { - $separatedPMP = true; - } - - $sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.price, p.price_ttc, p.entity,"; - $sql .= "p.tosell, p.tobuy,"; - $sql .= "p.accountancy_code_sell,"; - $sql .= "p.accountancy_code_sell_intra,"; - $sql .= "p.accountancy_code_sell_export,"; - $sql .= "p.accountancy_code_buy,"; - $sql .= "p.accountancy_code_buy_intra,"; - $sql .= "p.accountancy_code_buy_export,"; - $sql .= 'p.barcode,'; - if ($separatedPMP) { - $sql .= " pa.pmp as ppmp,"; - } else { - $sql .= " p.pmp as ppmp,"; - } + $sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.pmp as ppmp, p.price, p.price_ttc, p.entity,"; @@ -691,10 +549 @@ - if (getDolGlobalString('PRODUCT_USE_UNITS')) { - $sql .= ",fk_unit"; - } - // Add fields from hooks - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook - if ($reshook > 0) { //Note that $sql is replaced if reshook > 0 - $sql = ""; - } - $sql .= $hookmanager->resPrint; + if (!empty($conf->global->PRODUCT_USE_UNITS)) $sql .= ",fk_unit"; @@ -702,5 +550,0 @@ - - if ($separatedPMP) { - $sql .= ", ".MAIN_DB_PREFIX."product_perentity as pa"; - } - @@ -709,6 +553 @@ - $sql .= " AND ps.fk_entrepot = ".((int) $object->id); - - if ($separatedPMP) { - $sql .= " AND pa.fk_product = p.rowid AND pa.entity = ".(int) $conf->entity; - } - + $sql .= " AND ps.fk_entrepot = ".$object->id; @@ -719 +558,2 @@ - if ($resql) { + if ($resql) + { @@ -722,3 +562,2 @@ - $sameunits = true; - - while ($i < $num) { + while ($i < $num) + { @@ -728 +567,2 @@ - if (getDolGlobalInt('MAIN_MULTILANGS')) { // si l'option est active + if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active + { @@ -731,2 +571,2 @@ - $sql .= " WHERE fk_product = ".((int) $objp->rowid); - $sql .= " AND lang = '".$db->escape($langs->getDefaultLang())."'"; + $sql .= " WHERE fk_product=".$objp->rowid; + $sql .= " AND lang='".$langs->getDefaultLang()."'"; @@ -736 +576,2 @@ - if ($result) { + if ($result) + { @@ -738,3 +579 @@ - if (isset($objtp->label) && $objtp->label != '') { - $objp->produit = $objtp->label; - } + if ($objtp->label != '') $objp->produit = $objtp->label; @@ -743,0 +583 @@ + @@ -746,5 +586 @@ - - $parameters = array('obj'=>$objp, 'totalarray' => &$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - + print "'; - - // Value + print ''; + @@ -785,15 +606,12 @@ - if (getDolGlobalString('PRODUCT_USE_UNITS')) { - // Units - print ''; - } - - // Price buy PMP - print ''; - - // Total PMP - print ''; + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + // Units + print ''; + } + // Price buy PMP + print ''; + + // Total PMP + print ''; @@ -802,15 +620,16 @@ - // Price sell min - if (!getDolGlobalString('PRODUIT_MULTIPRICES')) { - $pricemin = $objp->price; - print ''; - // Total sell min - print ''; - } - $totalvaluesell += price2num($pricemin * $objp->value, 'MT'); - - // Link to transfer - if ($user->hasRight('stock', 'mouvement', 'creer')) { + // Price sell min + if (empty($conf->global->PRODUIT_MULTIPRICES)) + { + $pricemin = $objp->price; + print ''; + // Total sell min + print ''; + } + $totalvaluesell += price2num($pricemin * $objp->value, 'MT'); + + if ($user->rights->stock->mouvement->creer) + { @@ -818,2 +637 @@ - print img_picto($langs->trans("TransferStock"), 'add', 'class="hideonsmartphone pictofixedwidth" style="color: #a69944"'); - print $langs->trans("TransferStock"); + print img_picto($langs->trans("StockMovement"), 'uparrow.png', 'class="hideonsmartphone"').' '.$langs->trans("StockMovement"); @@ -823,2 +641,2 @@ - // Link to stock - if ($user->hasRight('stock', 'creer')) { + if ($user->rights->stock->creer) + { @@ -826,2 +644 @@ - print img_picto($langs->trans("CorrectStock"), 'add', 'class="hideonsmartphone pictofixedwidth" style="color: #a69944"'); - print $langs->trans("CorrectStock"); + print $langs->trans("StockCorrection"); @@ -829,32 +646,30 @@ - } - - print ""; - - $i++; - - // Define $unit and $sameunits - if (getDolGlobalString('PRODUCT_USE_UNITS')) { - if ($i == 0) { - $units = $productstatic->fk_unit; - } elseif ($productstatic->fk_unit != $units) { - $sameunits = false; - } - } - } - $db->free($resql); - - $totalarray['val']['totalunit'] = $totalunit; - $totalarray['val']['totalvalue'] = price2num($totalvalue, 'MT'); - $totalarray['val']['totalvaluesell'] = price2num($totalvaluesell, 'MT'); - $totalarray['val']['units'] = $langs->trans($productstatic->getLabelOfUnit()); - - $parameters = array('totalarray' => &$totalarray); - // Note that $action and $object may have been modified by hook - $reshook = $hookmanager->executeHooks('printFieldListTotal', $parameters, $object); - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors); - } - - // Show total line - include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; - } else { + } + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if ($i == 0) $units = $productstatic->fk_unit; + elseif ($productstatic->fk_unit != $units) $sameunits = false; + } + print ""; + $i++; + } + $db->free($resql); + + print ''; + print ''; + print ''; + print ''; + if (empty($conf->global->PRODUIT_MULTIPRICES)) + { + print ''; + print ''; + } + print ''; + print ''; + print ''; + } + else + { @@ -863,7 +678,9 @@ - print "
"; @@ -757,15 +593 @@ - if (getDolGlobalString('PRODUCT_USE_UNITS')) { - $productstatic->fk_unit = $objp->fk_unit; - } - $productstatic->status = $objp->tosell; - $productstatic->status_buy = $objp->tobuy; - $productstatic->barcode = $objp->barcode; - $productstatic->accountancy_code_sell = $objp->accountancy_code_sell; - $productstatic->accountancy_code_sell_intra = $objp->accountancy_code_sell_intra; - $productstatic->accountancy_code_sell_export = $objp->accountancy_code_sell_export; - $productstatic->accountancy_code_buy = $objp->accountancy_code_buy; - $productstatic->accountancy_code_buy_intra = $objp->accountancy_code_buy_intra; - $productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export; - - // Ref - print ""; + $productstatic->fk_unit = $objp->fk_unit; @@ -776,3 +598,2 @@ - print ''.dol_escape_htmltag($objp->produit).''.$objp->produit.''; - if (is_null($productstatic->fk_unit)) { - $productstatic->fk_unit = 1; - } - print $langs->trans($productstatic->getLabelOfUnit()); - print ''.price(price2num($objp->ppmp, 'MU')).''.price(price2num($objp->ppmp * $objp->value, 'MT')).''; + if (is_null($productstatic->fk_unit))$productstatic->fk_unit = 1; + print $langs->trans($productstatic->getLabelOfUnit()); + print ''.price(price2num($objp->ppmp, 'MU')).''.price(price2num($objp->ppmp * $objp->value, 'MT')).''; - print price(price2num($pricemin, 'MU'), 1); - print ''; - print price(price2num($pricemin * $objp->value, 'MT'), 1); - print ''; + print price(price2num($pricemin, 'MU'), 1); + print ''; + print price(price2num($pricemin * $objp->value, 'MT'), 1); + print '
'.$langs->trans("Total").''; + $valtoshow = price2num($totalunit, 'MS'); + if (empty($conf->global->PRODUCT_USE_UNITS) || $sameunits) print empty($valtoshow) ? '0' : $valtoshow; + print ''; + if (empty($conf->global->PRODUCT_USE_UNITS) && $sameunits) print $langs->trans($productstatic->getLabelOfUnit()); + print ''.price(price2num($totalvalue, 'MT')).' '.price(price2num($totalvaluesell, 'MT')).'  
"; - print '
'; - } - - - // Edit mode - if ($action == 'edit' || $action == 're-edit') { + print "\n"; + } + + + /* + * Edition fiche + */ + if ($action == 'edit' || $action == 're-edit') + { @@ -879 +696 @@ - print dol_get_fiche_head($head, 'card', $langs->trans("Warehouse"), 0, 'stock'); + dol_fiche_head($head, 'card', $langs->trans("Warehouse"), 0, 'stock'); @@ -886 +703 @@ - print ''.$langs->trans("LocationSummary").''; + print ''.$langs->trans("LocationSummary").''; @@ -893,10 +709,0 @@ - // Project - if (isModEnabled('project')) { - $projectid = $object->fk_project; - $langs->load('projects'); - print ''.$langs->trans('Project').''; - print img_picto('', 'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); - print ' 0 ? '&socid='.$socid : "")).'">'; - print ''; - } - @@ -907 +714 @@ - $doleditor = new DolEditor('desc', $object->description, '', 180, 'dolibarr_notes', 'In', false, true, isModEnabled('fckeditor'), ROWS_5, '90%'); + $doleditor = new DolEditor('desc', $object->description, '', 180, 'dolibarr_notes', 'In', false, true, $conf->fckeditor->enabled, ROWS_5, '90%'); @@ -927,3 +734 @@ - if ($user->admin) { - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - } + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); @@ -933 +738 @@ - print ''.$form->editfieldkey('Phone', 'phone', '', $object, 0).''; + print ''.$form->editfieldkey('Phone', 'phone', '', $object, 0).''; @@ -936 +741 @@ - print ''.$form->editfieldkey('Fax', 'fax', '', $object, 0).''; + print ''.$form->editfieldkey('Fax', 'fax', '', $object, 0).''; @@ -942,3 +747,5 @@ - print ''; + foreach ($object->statuts as $key => $value) + { + if ($key == $object->statut) + { @@ -946 +753,3 @@ - } else { + } + else + { @@ -951,2 +759,0 @@ - print ajax_combobox('warehousestatus'); - @@ -955,8 +762,8 @@ - // Other attributes - $parameters = array('colspan' => ' colspan="3"', 'cols' => '3'); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit', $parameters); - } - + // Other attributes + $parameters = array('colspan' => ' colspan="3"', 'cols' => '3'); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (empty($reshook)) + { + print $object->showOptionals($extrafields, 'edit', $parameters); + } @@ -964 +771,2 @@ - if (isModEnabled('categorie')) { + if ($conf->categorie->enabled) + { @@ -973 +781 @@ - print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); @@ -976 +783,0 @@ - @@ -979,3 +786,7 @@ - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel(); + dol_fiche_end(); + + print '
'; + print ''; + print '     '; + print ''; + print '
'; @@ -989 +800 @@ - * Documents generated + * Documents generes @@ -992,14 +803,2 @@ -$modulepart = 'stock'; - -if ($action != 'create' && $action != 'edit' && $action != 'delete') { - print '
'; - print '
'; - print ''; // ancre - - // Documents - $objectref = dol_sanitizeFileName($object->ref); - $relativepath = $object->ref.'/'.$objectref.'.pdf'; - $filedir = $conf->stock->dir_output.'/'.$objectref; - $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $usercanread; - $delallowed = $usercancreate; +if ($conf->global->MAIN_FEATURES_LEVEL >= 2) +{ @@ -1008,16 +807,33 @@ - print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, '', 0, '', '', '', $object); - $somethingshown = $formfile->numoffiles; - - print '
'; - - $MAXEVENT = 10; - - $morehtmlcenter = ''; - //$morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/product/stock/agenda.php?id='.$object->id); - - // List of actions on element - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'stock', 0, 1, '', $MAXEVENT, '', $morehtmlcenter); // Show all action for product - - print '
'; + if ($action != 'create' && $action != 'edit' && $action != 'delete') + { + print '
'; + print '
'; + print ''; // ancre + + // Documents + $objectref = dol_sanitizeFileName($object->ref); + $relativepath = $comref.'/'.$objectref.'.pdf'; + $filedir = $conf->stock->dir_output.'/'.$objectref; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed = $usercanread; + $delallowed = $usercancreate; + $modulepart = 'stock'; + + print $formfile->showdocuments($modulepart, $object->ref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object); + $somethingshown = $formfile->numoffiles; + + print '
'; + + $MAXEVENT = 10; + + $morehtmlright = ''; + $morehtmlright .= $langs->trans("SeeAll"); + $morehtmlright .= ''; + + // List of actions on element + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'stock', 0, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for product + + print '
'; + } --- /tmp/dsg/dolibarr/htdocs/product/stock/github_19.0.3_fiche-valo.php +++ /tmp/dsg/dolibarr/htdocs/product/stock/client_fiche-valo.php @@ -25 +24,0 @@ -// Load Dolibarr environment @@ -32,2 +31 @@ - -$id = GETPOST('id', 'int'); +$mesg = ''; @@ -48 +46,4 @@ -if ($id > 0) { +if ($_GET["id"]) +{ + if ($mesg) print $mesg; + @@ -50,2 +51,3 @@ - $result = $entrepot->fetch($id); - if ($result < 0) { + $result = $entrepot->fetch($_GET["id"]); + if ($result < 0) + { @@ -54,0 +57 @@ + @@ -57 +60 @@ - print dol_get_fiche_head($head, 'value', $langs->trans("Warehouse"), 0, 'stock'); + dol_fiche_head($head, 'value', $langs->trans("Warehouse"), 0, 'stock'); @@ -109 +112 @@ - $year = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); + $year = strftime("%Y", time()); @@ -120 +123,2 @@ - if (file_exists($file)) { + if (file_exists($file)) + { @@ -124 +128,2 @@ - if (file_exists(DOL_DATA_ROOT.'/entrepot/temp/entrepot-'.$entrepot->id.'-'.($year - 1).'.png')) { + if (file_exists(DOL_DATA_ROOT.'/entrepot/temp/entrepot-'.$entrepot->id.'-'.($year - 1).'.png')) + { @@ -128 +133,3 @@ - } else { + } + else + { --- /tmp/dsg/dolibarr/htdocs/product/stock/github_19.0.3_index.php +++ /tmp/dsg/dolibarr/htdocs/product/stock/client_index.php @@ -2,5 +2,4 @@ -/* Copyright (C) 2003-2006 Rodolphe Quiedeville - * Copyright (C) 2004-2016 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2019 Nicolas ZABOURI - * Copyright (C) 2020 Tobias Sekan +/* Copyright (C) 2003-2006 Rodolphe Quiedeville + * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2019 Nicolas ZABOURI @@ -23,3 +22,3 @@ - * \file htdocs/product/stock/index.php - * \ingroup stock - * \brief Home page of stock area + * \file htdocs/product/stock/index.php + * \ingroup stock + * \brief Home page of stock area @@ -28 +26,0 @@ -// Load Dolibarr environment @@ -32 +29,0 @@ -require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; @@ -64,10 +61,11 @@ -if (getDolGlobalString('MAIN_SEARCH_FORM_ON_HOME_AREAS')) { // This may be useless due to the global search combo - print '
'; - print ''; - print '
'; - print ''; - print ""; - print ''; - print ''; - print "
'.$langs->trans("Search").'
'; - print $langs->trans("Warehouse").':

"; +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo +{ + print '
'; + print ''; + print '
'; + print ''; + print ""; + print ''; + print ''; + print "
'.$langs->trans("Search").'
'; + print $langs->trans("Warehouse").':

"; @@ -80 +78 @@ -$sql .= " WHERE e.statut in (".Entrepot::STATUS_CLOSED.",".Entrepot::STATUS_OPEN_ALL.")"; +$sql .= " WHERE e.statut in (0,1)"; @@ -87,52 +85,48 @@ -if ($result) { - $num = $db->num_rows($result); - - print '
'; - print ''; - print ''; - print ''; - print ''; - - $i = 0; - if ($num) { - while ($i < min($max, $num)) { - $objp = $db->fetch_object($result); - - $warehouse->id = $objp->rowid; - $warehouse->statut = $objp->status; - $warehouse->label = $objp->label; - $warehouse->lieu = $objp->lieu; - - print ''; - print ''."\n"; - print ''; - print "\n"; - $i++; - } - $db->free($result); - } else { - print ''; - } - if ($num > $max) { - print ''; - } - - print "
'; - print $langs->trans("Warehouses").' '; - print ''; - // TODO: "search_status" on "/product/stock/list.php" currently only accept a single integer value - //print ''; - print ''.$num.''; - print ''; - print '
'; - print $warehouse->getNomUrl(1); - print ''; - print $warehouse->getLibStatut(5); - print '
'.$langs->trans("None").'
'.$langs->trans("More").'...
"; - print '
'; -} else { - dol_print_error($db); -} - - -print '
'; +if ($result) +{ + $num = $db->num_rows($result); + + $i = 0; + + print '
'; + print ''; + print ''; + + if ($num) + { + while ($i < min($max, $num)) + { + $objp = $db->fetch_object($result); + + $warehouse->id = $objp->rowid; + $warehouse->statut = $objp->status; + $warehouse->label = $objp->label; + $warehouse->lieu = $objp->lieu; + + print ''; + print ''."\n"; + print ''; + print "\n"; + $i++; + } + $db->free($result); + } + if ($num > $max) { + print ''; + } + + print "
'.$langs->trans("Warehouses").'
'; + print $warehouse->getNomUrl(1); + print ''; + print $warehouse->getLibStatut(5); + print '
'.$langs->trans("More").'...
"; + print '
'; +} +else +{ + dol_print_error($db); +} + + +//print ''; +print '
'; @@ -145 +139 @@ -$sql .= " m.rowid as mid, m.value as qty, m.datem, m.batch, m.eatby, m.sellby"; +$sql .= " m.value as qty, m.datem, m.batch, m.eatby, m.sellby"; @@ -152,3 +146 @@ -if (!getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { - $sql .= " AND p.fk_product_type = ".Product::TYPE_PRODUCT; -} +if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = 0"; @@ -160 +152,2 @@ -if ($resql) { +if ($resql) +{ @@ -163 +156 @@ - print '
'; + print '
'; @@ -165 +158 @@ - print ''; + print ""; @@ -168 +161,2 @@ - if (isModEnabled('productbatch')) { + if (!empty($conf->productbatch->enabled)) + { @@ -170,6 +164,2 @@ - /*if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { - print ''.$langs->trans("SellByDate").''; - } - if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { - print ''.$langs->trans("EatByDate").''; - }*/ + print ''.$langs->trans("SellByDate").''; + print ''.$langs->trans("EatByDate").''; @@ -181,2 +170,0 @@ - $tmplotstatic = new Productlot($db); - @@ -184 +172,2 @@ - while ($i < min($num, $max)) { + while ($i < min($num, $max)) + { @@ -199,4 +187,0 @@ - $tmplotstatic->batch = $objp->batch; - $tmplotstatic->sellby = $objp->sellby; - $tmplotstatic->eatby = $objp->eatby; - @@ -204,2 +189,2 @@ - print ''.img_picto($langs->trans("Ref").' '.$objp->mid, 'movement', 'class="pictofixedwidth"').dol_print_date($db->jdate($objp->datem), 'dayhour').''; - print ''; + print ''.dol_print_date($db->jdate($objp->datem), 'dayhour').''; + print ''; @@ -208,10 +193,5 @@ - if (isModEnabled('productbatch')) { - print ''; - print $tmplotstatic->getNomUrl(0, 'nolink'); - print ''; - /*if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { - print ''.dol_print_date($db->jdate($objp->sellby), 'day').''; - } - if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { - print ''.dol_print_date($db->jdate($objp->eatby), 'day').''; - }*/ + if (!empty($conf->productbatch->enabled)) + { + print ''.$objp->batch.''; + print ''.dol_print_date($db->jdate($objp->sellby), 'day').''; + print ''.dol_print_date($db->jdate($objp->eatby), 'day').''; @@ -219 +199 @@ - print ''; + print ''; @@ -223,3 +203 @@ - if ($objp->qty > 0) { - print '+'; - } + if ($objp->qty > 0) print '+'; @@ -233 +211 @@ - print '
'; + print '
'; @@ -238 +216,2 @@ -print '
'; +//print ''; +print ''; --- /tmp/dsg/dolibarr/htdocs/product/stock/github_19.0.3_info.php +++ /tmp/dsg/dolibarr/htdocs/product/stock/client_info.php @@ -24 +23,0 @@ -// Load Dolibarr environment @@ -39 +38 @@ -$usercancreate = $user->rights->stock->creer; + @@ -54 +53 @@ -print dol_get_fiche_head($head, 'info', $langs->trans("Warehouse"), -1, 'stock'); +dol_fiche_head($head, 'info', $langs->trans("Warehouse"), -1, 'stock'); @@ -61,33 +59,0 @@ - -// Project -if (isModEnabled('project')) { - $langs->load("projects"); - $morehtmlref .= '
'.img_picto('', 'project').' '.$langs->trans('Project').' '; - if ($usercancreate) { - if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; - } - if ($action == 'classify') { - $projectid = $object->fk_project; - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (!empty($object->socid) ? $object->socid : 0), $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ' : '.$proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.$proj->title; - } - } else { - $morehtmlref .= ''; - } - } -} @@ -97,3 +63 @@ -if ($user->socid && !in_array('stock', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) { - $shownav = 0; -} +if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; --- /tmp/dsg/dolibarr/htdocs/product/stock/github_19.0.3_list.php +++ /tmp/dsg/dolibarr/htdocs/product/stock/client_list.php @@ -28 +27,0 @@ -// Load Dolibarr environment @@ -31,3 +30,4 @@ - -if (isModEnabled('categorie')) { - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php'; + +if (!empty($conf->categorie->enabled)) +{ @@ -40 +40 @@ -$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ... +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... @@ -46 +46 @@ -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'stocklist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'stocklist'; // To manage different context of search @@ -49,6 +49,4 @@ -$toselect = GETPOST('toselect', 'array'); -$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...) - -$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); -$search_ref = GETPOST("sref", "alpha") ? GETPOST("sref", "alpha") : GETPOST("search_ref", "alpha"); -$search_label = GETPOST("snom", "alpha") ? GETPOST("snom", "alpha") : GETPOST("search_label", "alpha"); + +$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$search_ref = GETPOST("sref", "alpha") ?GETPOST("sref", "alpha") : GETPOST("search_ref", "alpha"); +$search_label = GETPOST("snom", "alpha") ?GETPOST("snom", "alpha") : GETPOST("search_label", "alpha"); @@ -57 +55,2 @@ -if (isModEnabled('categorie')) { +if (!empty($conf->categorie->enabled)) +{ @@ -62,3 +61,3 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); @@ -66,5 +65 @@ -if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { - // If $page is not defined, or '' or -1 or if we click on clear filters - $page = 0; -} -// Initialize technical objects +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action @@ -74,6 +69,5 @@ -if (!$sortfield) { - $sortfield = "t.ref"; -} -if (!$sortorder) { - $sortorder = "ASC"; -} +if (!$sortfield) $sortfield = "t.ref"; +if (!$sortorder) $sortorder = "ASC"; + +// Security check +$result = restrictedArea($user, 'stock'); @@ -84,2 +78,2 @@ -$diroutputmassaction = $conf->stock->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array($contextpage)); +$diroutputmassaction = $conf->inventory->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('stocklist')); @@ -91,0 +86,13 @@ + +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array( + 't.ref'=>"Ref", + 't.lieu'=>"LocationSummary", + 't.description'=>"Description", + 't.address'=>"Address", + 't.zip'=>'Zip', + 't.town'=>'Town', + 't.phone'=>'Phone', + 't.fax'=>'Fax', +); + @@ -93 +100 @@ -$search_all = GETPOST("search_all", 'alphanohtml'); +$search_all = trim(GETPOST("search_all", 'alpha')); @@ -95,19 +102,6 @@ -foreach ($object->fields as $key => $val) { - $search_key = $key; - if ($search_key == 'statut') { - $search_key = 'status'; // remove this after refactor entrepot.class property statut to status - } - if (GETPOST('search_'.$search_key, 'alpha') !== '') { - $search[$search_key] = GETPOST('search_'.$search_key, 'alpha'); - } -} - -// List of fields to search into when doing a "search in all" -$fieldstosearchall = array(); -foreach ($object->fields as $key => $val) { - if (!empty($val['searchall'])) { - $fieldstosearchall['t.'.$key] = $val['label']; - } -} - -// Definition of array of fields for columns +foreach ($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha'); +} + +// Definition of fields for list @@ -115,3 +109,3 @@ - 'stockqty'=>array('type'=>'float', 'label'=>'PhysicalStock', 'enabled'=>1, 'visible'=>-2, 'checked'=>0, 'position'=>170), - 'estimatedvalue'=>array('type'=>'float', 'label'=>'EstimatedStockValue', 'enabled'=>1, 'visible'=>1, 'checked'=>1, 'position'=>171), - 'estimatedstockvaluesell'=>array('type'=>'float', 'label'=>'EstimatedStockValueSell', 'enabled'=>1, 'checked'=>1, 'visible'=>2, 'position'=>172), + 'stockqty'=>array('type'=>'float', 'label'=>'PhysicalStock', 'enabled'=>1, 'visible'=>-2, 'position'=>70), + 'estimatedvalue'=>array('type'=>'float', 'label'=>'EstimatedStockValue', 'enabled'=>1, 'visible'=>-2, 'position'=>71), + 'estimatedstockvaluesell'=>array('type'=>'float', 'label'=>'EstimatedStockValueSell', 'enabled'=>1, 'visible'=>-2, 'position'=>72), @@ -119 +113,2 @@ -foreach ($object->fields as $key => $val) { +foreach ($object->fields as $key => $val) +{ @@ -121,10 +116 @@ - if (!empty($val['visible'])) { - $visible = (int) dol_eval($val['visible'], 1); - $arrayfields['t.'.$key] = array( - 'label'=>$val['label'], - 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)), - 'position'=>$val['position'], - 'help'=> isset($val['help']) ? $val['help'] : '' - ); - } + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); @@ -133,2 +119,14 @@ -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; - +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) +{ + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { + $arrayfields["ef.".$key] = array( + 'label'=>$extrafields->attributes[$object->table_element]['label'][$key], + 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), + 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], + 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]) + ); + } + } +} @@ -138,6 +135,0 @@ -$permissiontoread = $user->rights->stock->lire; -$permissiontodelete = $user->rights->stock->supprimer; -$permissiontoadd = $user->rights->stock->creer; - -// Security check -$result = restrictedArea($user, 'stock'); @@ -150,7 +142,2 @@ -if (GETPOST('cancel', 'alpha')) { - $action = 'list'; - $massaction = ''; -} -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { - $massaction = ''; -} +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } @@ -160,5 +147,4 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ @@ -169,2 +155,4 @@ - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers - foreach ($object->fields as $key => $val) { + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + foreach ($object->fields as $key => $val) + { @@ -172,6 +160,2 @@ - if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - $search[$key.'_dtstart'] = ''; - $search[$key.'_dtend'] = ''; - } - } - $toselect = array(); + } + $toselect = ''; @@ -179 +162,0 @@ - $search_category_list = array(); @@ -182 +165,2 @@ - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) + { @@ -188,0 +173,2 @@ + $permissiontoread = $user->rights->stock->lire; + $permissiontodelete = $user->rights->stock->supprimer; @@ -195 +181 @@ - * View + * View @@ -198,0 +185 @@ +$formcategory = new FormCategory($db); @@ -200,0 +188 @@ +$totalarray = array(); @@ -203 +190,0 @@ -$title = $langs->trans("Warehouses"); @@ -204,0 +192 @@ +$title = $langs->trans("ListOfWarehouses"); @@ -210 +198,4 @@ -$sql .= $object->getFieldList('t'); +foreach ($object->fields as $key => $val) +{ + $sql .= 't.'.$key.', '; +} @@ -213,15 +204,3 @@ - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); - } -} - -//For Multicompany PMP per entity -$separatedPMP = false; -if (getDolGlobalString('MULTICOMPANY_PRODUCT_SHARING_ENABLED') && getDolGlobalString('MULTICOMPANY_PMP_PER_ENTITY_ENABLED')) { - $separatedPMP = true; - $sql .= ", SUM(pa.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty"; -} else { - $sql .= ", SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty"; -} - - + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); +} +$sql .= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty"; @@ -233,3 +211,0 @@ - -$sqlfields = $sql; // $sql fields to remove for count total - @@ -237,3 +213,5 @@ -if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; -} +if (!empty($conf->categorie->enabled)) +{ + $sql .= Categorie::getFilterJoinQuery(Categorie::TYPE_WAREHOUSE, "t.rowid"); +} +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; @@ -244,3 +221,0 @@ -if ($separatedPMP) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_perentity as pa ON pa.fk_product = p.rowid AND pa.fk_product = ps.fk_product AND pa.entity = ". (int) $conf->entity; -} @@ -248,67 +223,15 @@ -foreach ($search as $key => $val) { - if (array_key_exists($key, $object->fields)) { - $class_key = $key; - if ($class_key == 'status') { - $class_key = 'statut'; // remove this after refactoring entrepot.class property statut to status - } - if (($key == 'status' && $search[$key] == -1) || $key == 'entity') { - continue; - } - $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); - if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) { - if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) { - $search[$key] = ''; - } - $mode_search = 2; - } - if ($search[$key] != '') { - $sql .= natural_search((($key == "ref") ? "t.ref" : "t.".$class_key), $search[$key], (($key == 'status') ? 2 : $mode_search)); - } - } else { - if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') { - $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key); - if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) { - if (preg_match('/_dtstart$/', $key)) { - $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'"; - } - if (preg_match('/_dtend$/', $key)) { - $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'"; - } - } - } - } -} -if ($search_all) { - $sql .= natural_search(array_keys($fieldstosearchall), $search_all); -} -// Search for tag/category ($searchCategoryWarehouseList is an array of ID) -$searchCategoryWarehouseList = $search_category_list; -$searchCategoryWarehouseOperator = 0; -if (!empty($searchCategoryWarehouseList)) { - $searchCategoryWarehouseSqlList = array(); - $listofcategoryid = ''; - foreach ($searchCategoryWarehouseList as $searchCategoryWarehouse) { - if (intval($searchCategoryWarehouse) == -2) { - $searchCategoryWarehouseSqlList[] = " NOT EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE t.rowid = ck.fk_warehouse)"; - } elseif (intval($searchCategoryWarehouse) > 0) { - if ($searchCategoryWarehouseOperator == 0) { - $searchCategoryWarehouseSqlList[] = " EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE t.rowid = ck.fk_warehouse AND ck.fk_categorie = ".((int) $searchCategoryWarehouse).")"; - } else { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryWarehouse); - } - } - } - if ($listofcategoryid) { - $searchCategoryWarehouseSqlList[] = " EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE t.rowid = ck.fk_warehouse AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))"; - } - if ($searchCategoryWarehouseOperator == 1) { - if (!empty($searchCategoryWarehouseSqlList)) { - $sql .= " AND (".implode(' OR ', $searchCategoryWarehouseSqlList).")"; - } - } else { - if (!empty($searchCategoryWarehouseSqlList)) { - $sql .= " AND (".implode(' AND ', $searchCategoryWarehouseSqlList).")"; - } - } -} - +if (!empty($conf->categorie->enabled)) +{ + $sql .= Categorie::getFilterSelectQuery(Categorie::TYPE_WAREHOUSE, "t.rowid", $search_category_list); +} +foreach ($search as $key => $val) +{ + if ($key == 'status' && $search[$key] == -1) continue; + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if (strpos($object->fields[$key]['type'], 'integer:') === 0) { + if ($search[$key] == '-1') $search[$key] = ''; + $mode_search = 2; + } + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); +} +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); @@ -319 +242 @@ -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook @@ -321 +243,0 @@ - @@ -323,2 +245,3 @@ -foreach ($object->fields as $key => $val) { - $sql .= "t.".$db->escape($key).", "; +foreach ($object->fields as $key => $val) +{ + $sql .= 't.'.$key.', '; @@ -328,5 +251,3 @@ - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); - } -} -// Add groupby from hooks + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); +} +// Add where from hooks @@ -337 +258 @@ - +$totalnboflines = 0; @@ -339 +260,2 @@ -if ($result) { +if ($result) +{ @@ -343 +265,2 @@ - while ($line < $totalnboflines) { + while ($line < $totalnboflines) + { @@ -345,2 +268,2 @@ - $total += $objp->estimatedvalue; - $totalsell += $objp->sellvalue; + $total += price2num($objp->estimatedvalue, 'MU'); + $totalsell += price2num($objp->sellvalue, 'MU'); @@ -350,4 +273,5 @@ - $totalarray['val']['stockqty'] = price2num($totalStock, 'MS'); - $totalarray['val']['estimatedvalue'] = price2num($total, 'MT'); - $totalarray['val']['estimatedstockvaluesell'] = price2num($totalsell, 'MT'); -} + $totalarray['val']['stockqty'] = $totalStock; + $totalarray['val']['estimatedvalue'] = $total; + $totalarray['val']['estimatedstockvaluesell'] = $totalsell; +} +$sql .= $db->order($sortfield, $sortorder); @@ -357,13 +281,6 @@ -if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); - $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); - $resql = $db->query($sqlforcount); - if ($resql) { - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; - } else { - dol_print_error($db); - } - - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0 +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 + { @@ -373,6 +290,8 @@ - $db->free($resql); -} - -// Complete request and execute it with limit -$sql .= $db->order($sortfield, $sortorder); -if ($limit) { +} +// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. +if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) +{ + $num = $nbtotalofrecords; +} +else +{ @@ -380,9 +299,10 @@ -} - -$resql = $db->query($sql); -if (!$resql) { - dol_print_error($db); - exit; -} - -$num = $db->num_rows($resql); + + $resql = $db->query($sql); + if (!$resql) + { + dol_print_error($db); + exit; + } + + $num = $db->num_rows($resql); +} @@ -391 +311,2 @@ -if ($num == 1 && !getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) { +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +{ @@ -407,27 +328,8 @@ -if (!empty($mode)) { - $param .= '&mode='.urlencode($mode); -} -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); -} -if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); -} -if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); -} -foreach ($search as $key => $val) { - if (is_array($search[$key])) { - foreach ($search[$key] as $skey) { - if ($skey != '') { - $param .= '&search_'.$key.'[]='.urlencode($skey); - } - } - } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) { - $param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int')); - $param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int')); - $param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int')); - } elseif ($search[$key] != '') { - $param .= '&search_'.$key.'='.urlencode($search[$key]); - } -} +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) +{ + if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); + else $param .= '&search_'.$key.'='.urlencode($search[$key]); +} +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); @@ -436,4 +337,0 @@ -// Add $param from hooks -$parameters = array('param' => &$param); -$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -$param .= $hookmanager->resPrint; @@ -443,2 +341,2 @@ - //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), - //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), @@ -446,7 +344,2 @@ -//if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']=img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) { - $arrayofmassactions = array(); -} -if (isModEnabled('category') && $user->hasRight('stock', 'creer')) { - $arrayofmassactions['preaffecttag'] = img_picto('', 'label', 'class="pictofixedwidth"').$langs->trans("AffectTag"); -} +//if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); @@ -456,3 +349 @@ -if ($optioncss != '') { - print ''; -} +if ($optioncss != '') print ''; @@ -464 +354,0 @@ -print ''; @@ -466,9 +356,2 @@ -print ''; -print ''; - - -$newcardbutton = ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitleSeparator(); -$newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewWarehouse'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->hasRight('stock', 'creer')); + +$newcardbutton = dolGetButtonTitle($langs->trans('MenuNewWarehouse'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->stock->creer); @@ -486,7 +369,3 @@ -if ($search_all) { - $setupstring = ''; - foreach ($fieldstosearchall as $key => $val) { - $fieldstosearchall[$key] = $langs->trans($val); - $setupstring .= $key."=".$val.";"; - } - print ''."\n"; +if ($search_all) +{ + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); @@ -498,2 +377,2 @@ -if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { - $formcategory = new FormCategory($db); +if (!empty($conf->categorie->enabled)) +{ @@ -508,8 +387,6 @@ -$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -if (empty($reshook)) { - $moreforfilter .= $hookmanager->resPrint; -} else { - $moreforfilter = $hookmanager->resPrint; -} - -if (!empty($moreforfilter)) { +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; +else $moreforfilter = $hookmanager->resPrint; + +if (!empty($moreforfilter)) +{ @@ -518,3 +394,0 @@ - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; @@ -525 +399 @@ -$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields @@ -528 +402 @@ -print '
'; +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table @@ -534,42 +408,17 @@ -// Action column -if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - $searchpicto = $form->showFilterButtons('left'); - print $searchpicto; - print ''; -} -foreach ($object->fields as $key => $val) { - if ($key == 'statut') { - continue; - } - $searchkey = empty($search[$key]) ? '' : $search[$key]; - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { - print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), (isset($val['notnull']) ? $val['notnull'] : 0), 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1); - } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) { - print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1); - } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - print '
'; - print $form->selectDate(isset($search[$key.'_dtstart']) ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate(isset($search[$key.'_dtend']) ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; - } elseif ($key == 'lang') { - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; - $formadmin = new FormAdmin($db); - print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2); - } else { - print ''; - } + +foreach ($object->fields as $key => $val) +{ + if ($key == 'statut') { continue; } + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); + elseif (strpos($val['type'], 'integer:') === 0 || strpos($val['type'], 'sellist:') === 0) { + print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); + } + elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; @@ -597 +446 @@ -$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook @@ -602,2 +451,2 @@ - print ''; - print $form->selectarray('search_status', $warehouse->labelStatus, $search_status, 1, 0, 0, '', 1, 0, 0, '', 'search_status width100 onrightofpage'); + print ''; + print $form->selectarray('search_status', $warehouse->statuts, $search_status, 1, 0, 0, '', 1); @@ -608,6 +457,4 @@ -if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print ''; -} +print ''; +$searchpicto = $form->showFilterButtons(); +print $searchpicto; +print ''; @@ -615,2 +461,0 @@ - -$totalarray['nbfield'] = 0; @@ -621,23 +466,12 @@ -// Action column -if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; - $totalarray['nbfield']++; -} -foreach ($object->fields as $key => $val) { - if ($key == 'statut') { - continue; - } - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label - if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''), 0, (empty($val['helplist']) ? '' : $val['helplist']))."\n"; - $totalarray['nbfield']++; + +foreach ($object->fields as $key => $val) +{ + if ($key == 'statut') { continue; } + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) + { + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; @@ -649,2 +482,0 @@ - $totalarray['nbfield']++; - $totalarray['type'][$totalarray['nbfield']] = 'stock'; @@ -655,2 +486,0 @@ - $totalarray['nbfield']++; - $totalarray['type'][$totalarray['nbfield']] = 'price'; @@ -661,2 +490,0 @@ - $totalarray['nbfield']++; - $totalarray['type'][$totalarray['nbfield']] = 'price'; @@ -674,2 +502 @@ - print_liste_field_titre($arrayfields['t.statut']['label'], $_SERVER["PHP_SELF"], "t.statut", '', $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; + print_liste_field_titre($arrayfields['t.statut']['label'], $_SERVER["PHP_SELF"], "t.statut", '', $param, '', $sortfield, $sortorder, 'right '); @@ -679,4 +506 @@ -if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; - $totalarray['nbfield']++; -} +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; @@ -684,2 +507,0 @@ - -$warehouse = new Entrepot($db); @@ -690,47 +512,42 @@ -$savnbfield = $totalarray['nbfield']; -$totalarray['nbfield'] = 0; -$imaxinloop = ($limit ? min($num, $limit) : $num); -while ($i < $imaxinloop) { - $obj = $db->fetch_object($resql); - if (empty($obj)) { - break; // Should not happen - } - - // Store properties in $object - $warehouse->setVarsFromFetchObj($obj); - - $warehouse->label = $warehouse->ref; - $warehouse->sellvalue = $obj->sellvalue; - - $object = $warehouse; - - if ($mode == 'kanban') { - if ($i == 0) { - print ''; - print '
'; - } - // Output Kanban - $selected = -1; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($object->id, $arrayofselected)) { - $selected = 1; - } - } - print $object->getKanbanView('', array('selected' => $selected)); - if ($i == ($imaxinloop - 1)) { - print '
'; - print ''; - } - } else { - // Show line of result - $j = 0; - print ''; - - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($object->id, $arrayofselected)) { - $selected = 1; +if ($num) +{ + $warehouse = new Entrepot($db); + + while ($i < min($num, $limit)) + { + $obj = $db->fetch_object($resql); + if (empty($obj)) break; // Should not happen + + $warehouse->id = $obj->rowid; + $warehouse->ref = $obj->ref; + $warehouse->label = $obj->ref; + $warehouse->lieu = $obj->lieu; + $warehouse->fk_parent = $obj->fk_parent; + $warehouse->statut = $obj->statut; + + foreach ($object->fields as $key => $val) { + $warehouse->{$key} = $obj->{$key}; + } + + + // Show here line of result + print ''; + + foreach ($warehouse->fields as $key => $val) + { + if ($key == 'statut') { continue; } + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + + if (!empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + if ($key == 'statut') print $warehouse->getLibStatut(5); + if ($key == 'phone') { + print dol_print_phone($obj->phone, '', 0, $obj->rowid, 'AC_TEL'); @@ -738,35 +555,2 @@ - print ''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - foreach ($object->fields as $key => $val) { - if ($key == 'statut') { - continue; - } - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } - - if (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall'; - } elseif ($key == 'ref') { - $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall'; - } - - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && empty($val['arrayofkeyval'])) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) { - $cssforfield = 'tdoverflowmax100'; - } - - if (!empty($arrayfields['t.'.$key]['checked'])) { - print '$key)) { - print ' title="'.dol_escape_htmltag($object->$key).'"'; + elseif ($key == 'fax') { + print dol_print_phone($obj->fax, '', 0, $obj->rowid, 'AC_FAX'); @@ -774,10 +558,2 @@ - print '>'; - if ($key == 'statut') { - print $object->getLibStatut(5); - } - if ($key == 'phone') { - print dol_print_phone($object->phone, '', 0, $object->id, 'AC_TEL'); - } elseif ($key == 'fax') { - print dol_print_phone($object->fax, '', 0, $object->id, 'AC_FAX'); - } else { - print $warehouse->showOutputField($val, $key, $object->$key, ''); + else { + print $warehouse->showOutputField($val, $key, $warehouse->$key, ''); @@ -786,14 +562,5 @@ - if (!$i) { - $totalarray['nbfield']++; - } - if (!empty($val['isameasure']) && $val['isameasure'] == 1) { - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; - } - if (!isset($totalarray['val'])) { - $totalarray['val'] = array(); - } - if (!isset($totalarray['val']['t.'.$key])) { - $totalarray['val']['t.'.$key] = 0; - } - $totalarray['val']['t.'.$key] += $object->$key; + if (!$i) $totalarray['nbfield']++; + if (!empty($val['isameasure'])) + { + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + $totalarray['val']['t.'.$key] += $warehouse->$key; @@ -806,7 +573,3 @@ - print ''.price(price2num($obj->stockqty, 'MS')).''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'stockqty'; - } + print ''.price2num($obj->stockqty, 5).''; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'stockqty'; @@ -818,5 +581,2 @@ - if (price2num($obj->estimatedvalue, 'MT')) { - print ''.price(price2num($obj->estimatedvalue, 'MT'), 1).''; - } else { - print ''; - } + if (price2num($obj->estimatedvalue, 'MT')) print price(price2num($obj->estimatedvalue, 'MT'), 1); + else print ''; @@ -824,6 +584,2 @@ - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'estimatedvalue'; - } + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'estimatedvalue'; @@ -835,5 +591,2 @@ - if (!getDolGlobalString('PRODUIT_MULTIPRICES')) { - if ($obj->sellvalue) { - print ''.price(price2num($obj->sellvalue, 'MT'), 1).''; - } - } else { + if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($obj->sellvalue, 'MT'), 1); + else { @@ -841 +594 @@ - print $form->textwithtooltip(''.$langs->trans("Variable").'', $htmltext); + print $form->textwithtooltip($langs->trans("Variable"), $htmltext); @@ -844,6 +597,2 @@ - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'estimatedstockvaluesell'; - } + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'estimatedstockvaluesell'; @@ -855,2 +604,2 @@ - $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook @@ -861,4 +610,2 @@ - print ''.$warehouse->LibStatut($obj->statut, 5).''; - if (!$i) { - $totalarray['nbfield']++; - } + print ''.$warehouse->LibStatut($obj->statut, 5).''; + if (!$i) $totalarray['nbfield']++; @@ -868,14 +615,9 @@ - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($object->id, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } + print ''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; + } + print ''; + if (!$i) $totalarray['nbfield']++; @@ -884,19 +626,10 @@ - } - - $i++; -} - -if ($totalnboflines - $offset <= $limit) { - // Show total line - include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; -} - -// If no record found -if ($num == 0) { - $colspan = 1; - foreach ($arrayfields as $key => $val) { - if (!empty($val['checked'])) { - $colspan++; - } - } - print ''.$langs->trans("NoRecordFound").''; + + + $i++; + } + + if ($totalnboflines - $offset <= $limit) + { + // Show total line + include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + } @@ -916 +649,2 @@ -if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) +{ @@ -918,3 +652 @@ - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { - $hidegeneratedfilelistifempty = 0; - } + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; @@ -930,4 +662,4 @@ - $genallowed = $user->rights->stock->lire; - $delallowed = $user->rights->stock->creer; - - print $formfile->showdocuments('massfilesarea_stock', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); + $genallowed = $user->rights->mymodule->read; + $delallowed = $user->rights->mymodule->create; + + print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); --- /tmp/dsg/dolibarr/htdocs/product/stock/github_19.0.3_massstockmove.php +++ /tmp/dsg/dolibarr/htdocs/product/stock/client_massstockmove.php @@ -2 +2 @@ -/* Copyright (C) 2013-2022 Laurent Destaileur +/* Copyright (C) 2013-2018 Laurent Destaileur @@ -26 +25,0 @@ -// Load Dolibarr environment @@ -34,6 +32,0 @@ -require_once DOL_DOCUMENT_ROOT.'/core/modules/import/import_csv.modules.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/import.lib.php'; - -$confirm = GETPOST('confirm', 'alpha'); -$filetoimport = GETPOST('filetoimport'); @@ -49 +42 @@ - $socid = $user->socid; + $socid = $user->socid; @@ -55 +48 @@ -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); @@ -63,4 +56,2 @@ -// Load variable for pagination -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); @@ -68,4 +59,10 @@ -if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { - // If $page is not defined, or '' or -1 or if we click on clear filters - $page = 0; -} +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 + +if (!$sortfield) { + $sortfield = 'p.ref'; +} + +if (!$sortorder) { + $sortorder = 'ASC'; +} +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -73,13 +70 @@ -$pageprev = $page - 1; -$pagenext = $page + 1; - -if (!$sortfield) { - $sortfield = 'p.ref'; -} -if (!$sortorder) { - $sortorder = 'ASC'; -} - -if (GETPOST('init')) { - unset($_SESSION['massstockmove']); -} + @@ -87,5 +72 @@ -if (!empty($_SESSION['massstockmove'])) { - $listofdata = json_decode($_SESSION['massstockmove'], true); -} - -$error = 0; +if (!empty($_SESSION['massstockmove'])) $listofdata = json_decode($_SESSION['massstockmove'], true); @@ -98,9 +79,14 @@ -if ($action == 'addline' && $user->hasRight('stock', 'mouvement', 'creer')) { - if (!($id_sw > 0)) { - //$error++; - //setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseSource")), null, 'errors'); - if ($id_sw < 0) { - $id_sw = 0; - } - } - if (!($id_tw > 0)) { +if ($action == 'addline') +{ + if (!($id_product > 0)) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); + } + if (!($id_sw > 0)) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseSource")), null, 'errors'); + } + if (!($id_tw > 0)) + { @@ -110 +96,2 @@ - if ($id_sw > 0 && $id_tw == $id_sw) { + if ($id_sw > 0 && $id_tw == $id_sw) + { @@ -115,7 +102,4 @@ - if (!($id_product > 0)) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); - } - if (!$qty) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors'); + if (!$qty) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors'); @@ -125 +109,2 @@ - if (!$error) { + if (!$error) + { @@ -128,2 +113,4 @@ - if ($producttmp->hasbatch()) { - if (empty($batch)) { + if ($producttmp->hasbatch()) + { + if (empty($batch)) + { @@ -138,2 +125,3 @@ - // What is more important is to have qty when doing action 'createmovements' - if (!$error) { + // What is important is to have qty when doing action 'createmovements' + if (!$error) + { @@ -141,2 +129,2 @@ - if ($producttmp->hasbatch()) { - } else { + if ($producttmp->hasbatch()) + { @@ -144,8 +132,2 @@ - } - - //var_dump($_SESSION['massstockmove']);exit; - if (!$error) { - if (count(array_keys($listofdata)) > 0) { - $id = max(array_keys($listofdata)) + 1; - } else { - $id = 1; + else + { @@ -152,0 +135,6 @@ + } + + if (!$error) + { + if (count(array_keys($listofdata)) > 0) $id = max(array_keys($listofdata)) + 1; + else $id = 1; @@ -155,0 +144 @@ + unset($id_product); @@ -158,2 +146,0 @@ - unset($id_product); - unset($batch); @@ -164,12 +151,9 @@ -if ($action == 'delline' && $idline != '' && $user->hasRight('stock', 'mouvement', 'creer')) { - if (!empty($listofdata[$idline])) { - unset($listofdata[$idline]); - } - if (count($listofdata) > 0) { - $_SESSION['massstockmove'] = json_encode($listofdata); - } else { - unset($_SESSION['massstockmove']); - } -} - -if ($action == 'createmovements' && $user->hasRight('stock', 'mouvement', 'creer')) { +if ($action == 'delline' && $idline != '') +{ + if (!empty($listofdata[$idline])) unset($listofdata[$idline]); + if (count($listofdata) > 0) $_SESSION['massstockmove'] = json_encode($listofdata); + else unset($_SESSION['massstockmove']); +} + +if ($action == 'createmovements') +{ @@ -178 +162,2 @@ - if (!GETPOST("label")) { + if (!GETPOST("label")) + { @@ -185 +170,2 @@ - if (!$error) { + if (!$error) + { @@ -188 +174,2 @@ - foreach ($listofdata as $key => $val) { // Loop on each movement to do + foreach ($listofdata as $key => $val) // Loop on each movement to do + { @@ -198 +185,2 @@ - if (!$error && $id_sw != $id_tw && is_numeric($qty) && $id_product) { + if (!$error && $id_sw <> $id_tw && is_numeric($qty) && $id_product) + { @@ -205,3 +193 @@ - if (!empty($product->pmp)) { - $pricesrc = $product->pmp; - } + if (!empty($product->pmp)) $pricesrc = $product->pmp; @@ -212,16 +198,16 @@ - if (empty($conf->productbatch->enabled) || !$product->hasbatch()) { // If product does not need lot/serial - // Remove stock if source warehouse defined - if ($id_sw > 0) { - $result1 = $product->correct_stock( - $user, - $id_sw, - $qty, - 1, - GETPOST("label"), - $pricesrc, - GETPOST("codemove") - ); - if ($result1 < 0) { - $error++; - setEventMessages($product->error, $product->errors, 'errors'); - } + if (empty($conf->productbatch->enabled) || !$product->hasbatch()) // If product does not need lot/serial + { + // Remove stock + $result1 = $product->correct_stock( + $user, + $id_sw, + $qty, + 1, + GETPOST("label"), + $pricesrc, + GETPOST("codemove") + ); + if ($result1 < 0) + { + $error++; + setEventMessages($product->errors, $product->errorss, 'errors'); @@ -232,6 +218,6 @@ - $user, - $id_tw, - $qty, - 0, - GETPOST("label"), - $pricedest, + $user, + $id_tw, + $qty, + 0, + GETPOST("label"), + $pricedest, @@ -240 +226,2 @@ - if ($result2 < 0) { + if ($result2 < 0) + { @@ -242,3 +229,5 @@ - setEventMessages($product->error, $product->errors, 'errors'); - } - } else { + setEventMessages($product->errors, $product->errorss, 'errors'); + } + } + else + { @@ -246 +235,2 @@ - if (count($arraybatchinfo) > 0) { + if (count($arraybatchinfo) > 0) + { @@ -250,6 +240,4 @@ - //var_dump($batch); - //var_dump($arraybatchinfo); - //var_dump($firstrecord); - //var_dump($dlc); - //var_dump($dluo); exit; - } else { + //var_dump($batch); var_dump($arraybatchinfo); var_dump($firstrecord); var_dump($dlc); var_dump($dluo); exit; + } + else + { @@ -261,27 +249,7 @@ - if ($id_sw > 0) { - $result1 = $product->correct_stock_batch( - $user, - $id_sw, - $qty, - 1, - GETPOST("label"), - $pricesrc, - $dlc, - $dluo, - $batch, - GETPOST("codemove") - ); - if ($result1 < 0) { - $error++; - setEventMessages($product->error, $product->errors, 'errors'); - } - } - - // Add stock - $result2 = $product->correct_stock_batch( - $user, - $id_tw, - $qty, - 0, - GETPOST("label"), - $pricedest, + $result1 = $product->correct_stock_batch( + $user, + $id_sw, + $qty, + 1, + GETPOST("label"), + $pricesrc, @@ -293 +261,2 @@ - if ($result2 < 0) { + if ($result1 < 0) + { @@ -295 +264,20 @@ - setEventMessages($product->error, $product->errors, 'errors'); + setEventMessages($product->errors, $product->errorss, 'errors'); + } + + // Add stock + $result2 = $product->correct_stock_batch( + $user, + $id_tw, + $qty, + 0, + GETPOST("label"), + $pricedest, + $dlc, + $dluo, + $batch, + GETPOST("codemove") + ); + if ($result2 < 0) + { + $error++; + setEventMessages($product->errors, $product->errorss, 'errors'); @@ -298 +286,3 @@ - } else { + } + else + { @@ -304,3 +294,3 @@ - //var_dump($_SESSION['massstockmove']);exit; - - if (!$error) { + + if (!$error) + { @@ -313 +303,3 @@ - } else { + } + else + { @@ -319,213 +310,0 @@ -if ($action == 'importCSV' && $user->hasRight('stock', 'mouvement', 'creer')) { - dol_mkdir($conf->stock->dir_temp); - $nowyearmonth = dol_print_date(dol_now(), '%Y%m%d%H%M%S'); - - $fullpath = $conf->stock->dir_temp."/".$user->id.'-csvfiletotimport.csv'; - $resultupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $fullpath, 1); - if (is_numeric($resultupload) && $resultupload > 0) { - dol_syslog("File ".$fullpath." was added for import"); - } else { - $error++; - $langs->load("errors"); - if ($resultupload === 'ErrorDirNotWritable') { - setEventMessages($langs->trans("ErrorFailedToSaveFile").' - '.$langs->trans($resultupload, $fullpath), null, 'errors'); - } else { - setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); - } - } - - if (!$error) { - $importcsv = new ImportCsv($db, 'massstocklist'); - //print $importcsv->separator; - - $nblinesrecord = $importcsv->import_get_nb_of_lines($fullpath)-1; - $importcsv->import_open_file($fullpath); - $labelsrecord = $importcsv->import_read_record(); - - if ($nblinesrecord < 1) { - setEventMessages($langs->trans("BadNumberOfLinesMustHaveAtLeastOneLinePlusTitle"), null, 'errors'); - } else { - $i=0; - $data = array(); - $productstatic = new Product($db); - $warehousestatics = new Entrepot($db); - $warehousestatict = new Entrepot($db); - - // Loop on each line in CSV file - while (($i < $nblinesrecord) && !$error) { - $newrecord = $importcsv->import_read_record(); - - $data[$i] = $newrecord; - if (count($data[$i]) == 1) { - // Only 1 empty line - unset($data[$i]); - $i++; - continue; - } - - $tmp_id_sw = $data[$i][0]['val']; - $tmp_id_tw = $data[$i][1]['val']; - $tmp_id_product = $data[$i][2]['val']; - $tmp_qty = $data[$i][3]['val']; - $tmp_batch = $data[$i][4]['val']; - - $errorforproduct = 0; - $isidorref = 'ref'; - if (!is_numeric($tmp_id_product) && $tmp_id_product != '' && preg_match('/^id:/i', $tmp_id_product)) { - $isidorref = 'id'; - } - $tmp_id_product = preg_replace('/^(id|ref):/i', '', $tmp_id_product); - - if ($isidorref === 'ref') { - $tmp_id_product = preg_replace('/^ref:/', '', $tmp_id_product); - $result = fetchref($productstatic, $tmp_id_product); - if ($result === -2) { - $error++; - $errorforproduct = 1; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorMultipleRecordFoundFromRef", $tmp_id_product), null, 'errors'); - } elseif ($result <= 0) { - $error++; - $errorforproduct = 1; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorRefNotFound", $tmp_id_product), null, 'errors'); - } - $tmp_id_product = $result; - } - $data[$i][2]['val'] = $tmp_id_product; - if (!$errorforproduct && !($tmp_id_product > 0)) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); - } - - if ($tmp_id_sw !== '') { - // For source, we allow empty value - $errorforwarehouses = 0; - $isidorref = 'ref'; - if (!is_numeric($tmp_id_sw) && $tmp_id_sw != '' && preg_match('/^id:/i', $tmp_id_sw)) { - $isidorref = 'id'; - } - $tmp_id_sw = preg_replace('/^(id|ref):/i', '', $tmp_id_sw); - if ($isidorref === 'ref') { - $tmp_id_sw = preg_replace('/^ref:/', '', $tmp_id_sw); - $result = fetchref($warehousestatics, $tmp_id_sw); - if ($result === -2) { - $error++; - $errorforwarehouses = 1; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorMultipleRecordFoundFromRef", $tmp_id_sw), null, 'errors'); - } elseif ($result <= 0) { - $error++; - $errorforwarehouses = 1; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorRefNotFound", $tmp_id_sw), null, 'errors'); - } - $tmp_id_sw = $result; - } - $data[$i][0]['val'] = $tmp_id_sw; - if (!$errorforwarehouses && !($tmp_id_sw > 0)) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseSource")), null, 'errors'); - } - } - - $errorforwarehouset = 0; - $isidorref = 'ref'; - if (!is_numeric($tmp_id_tw) && $tmp_id_tw != '' && preg_match('/^id:/i', $tmp_id_tw)) { - $isidorref = 'id'; - } - $tmp_id_tw = preg_replace('/^(id|ref):/i', '', $tmp_id_tw); - if ($isidorref === 'ref') { - $tmp_id_tw = preg_replace('/^ref:/', '', $tmp_id_tw); - $result = fetchref($warehousestatict, $tmp_id_tw); - if ($result === -2) { - $error++; - $errorforwarehouset = 1; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorMultipleRecordFoundFromRef", $tmp_id_tw), null, 'errors'); - } elseif ($result <= 0) { - $error++; - $errorforwarehouset = 1; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorRefNotFound", $tmp_id_tw), null, 'errors'); - } - $tmp_id_tw = $result; - } - $data[$i][1]['val'] = $tmp_id_tw; - if (!$errorforwarehouset && !($tmp_id_tw > 0)) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseTarget")), null, 'errors'); - } - - // If a source is provided and same than target - if ($tmp_id_sw > 0 && $tmp_id_tw == $tmp_id_sw) { - $error++; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorWarehouseMustDiffers"), null, 'errors'); - } - if (!$tmp_qty) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors'); - } - - // Check a batch number is provided if product need it - if (!$error) { - $producttmp = new Product($db); - $producttmp->fetch($tmp_id_product); - if ($producttmp->hasbatch()) { - if (empty($tmp_batch)) { - $error++; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorTryToMakeMoveOnProductRequiringBatchData", $producttmp->ref), null, 'errors'); - } - } - } - - $i++; - } - - if (!$error) { - foreach ($data as $key => $value) { - if (count(array_keys($listofdata)) > 0) { - $id = max(array_keys($listofdata)) + 1; - } else { - $id = 1; - } - $tmp_id_sw = $data[$key][0]['val']; - $tmp_id_tw = $data[$key][1]['val']; - $tmp_id_product = $data[$key][2]['val']; - $tmp_qty = $data[$key][3]['val']; - $tmp_batch = $data[$key][4]['val']; - $listofdata[$key] = array('id'=>$key, 'id_sw'=>$tmp_id_sw, 'id_tw'=>$tmp_id_tw, 'id_product'=>$tmp_id_product, 'qty'=>$tmp_qty, 'batch'=>$tmp_batch); - } - } - } - } - if ($error) { - $listofdata = array(); - } - - $_SESSION['massstockmove'] = json_encode($listofdata); -} - -if ($action == 'confirm_deletefile' && $confirm == 'yes') { - $langs->load("other"); - - $param = '&datatoimport='.urlencode($datatoimport).'&format='.urlencode($format); - if ($excludefirstline) { - $param .= '&excludefirstline='.urlencode($excludefirstline); - } - if ($endatlinenb) { - $param .= '&endatlinenb='.urlencode($endatlinenb); - } - - $file = $conf->stock->dir_temp.'/'.GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). - $ret = dol_delete_file($file); - if ($ret) { - setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - } else { - setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - } - Header('Location: '.$_SERVER["PHP_SELF"]); - exit; -} @@ -539 +317,0 @@ -$error = 0; @@ -547,2 +324,0 @@ -$help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks|DE:Modul_Bestände'; - @@ -551 +327 @@ -llxHeader('', $title, $help_url); +llxHeader('', $title); @@ -556 +332 @@ -$buttonrecord = $langs->trans("RecordMovements"); +$buttonrecord = $langs->trans("RecordMovement"); @@ -558,92 +334,3 @@ -$buttonrecordnoent = $langs->transnoentitiesnoconv("RecordMovements"); -print ''.$langs->trans("SelectProductInAndOutWareHouse", $titletoaddnoent, $buttonrecordnoent).''; - -print '
'; -//print '
'; - -// Form to upload a file -print '
'; -print ''; -print ''; -if (!empty($conf->dol_optimize_smallscreen)) { - print '
'; -} -print ''; -print $langs->trans("or"); -print ' '; -$importcsv = new ImportCsv($db, 'massstocklist'); -print $form->textwithpicto($langs->trans('SelectAStockMovementFileToImport'), $langs->transnoentitiesnoconv("InfoTemplateImport", $importcsv->separator)); -print ''; - -$maxfilesizearray = getMaxFileSizeArray(); -$maxmin = $maxfilesizearray['maxmin']; -if ($maxmin > 0) { - print ''; // MAX_FILE_SIZE must precede the field type=file -} -print '     '; -$out = (!getDolGlobalString('MAIN_UPLOAD_DOC') ? ' disabled' : ''); -print ''; -$out = ''; -if (getDolGlobalString('MAIN_UPLOAD_DOC')) { - $max = $conf->global->MAIN_UPLOAD_DOC; // In Kb - $maxphp = @ini_get('upload_max_filesize'); // In unknown - if (preg_match('/k$/i', $maxphp)) { - $maxphp = preg_replace('/k$/i', '', $maxphp); - $maxphp = $maxphp * 1; - } - if (preg_match('/m$/i', $maxphp)) { - $maxphp = preg_replace('/m$/i', '', $maxphp); - $maxphp = $maxphp * 1024; - } - if (preg_match('/g$/i', $maxphp)) { - $maxphp = preg_replace('/g$/i', '', $maxphp); - $maxphp = $maxphp * 1024 * 1024; - } - if (preg_match('/t$/i', $maxphp)) { - $maxphp = preg_replace('/t$/i', '', $maxphp); - $maxphp = $maxphp * 1024 * 1024 * 1024; - } - $maxphp2 = @ini_get('post_max_size'); // In unknown - if (preg_match('/k$/i', $maxphp2)) { - $maxphp2 = preg_replace('/k$/i', '', $maxphp2); - $maxphp2 = $maxphp2 * 1; - } - if (preg_match('/m$/i', $maxphp2)) { - $maxphp2 = preg_replace('/m$/i', '', $maxphp2); - $maxphp2 = $maxphp2 * 1024; - } - if (preg_match('/g$/i', $maxphp2)) { - $maxphp2 = preg_replace('/g$/i', '', $maxphp2); - $maxphp2 = $maxphp2 * 1024 * 1024; - } - if (preg_match('/t$/i', $maxphp2)) { - $maxphp2 = preg_replace('/t$/i', '', $maxphp2); - $maxphp2 = $maxphp2 * 1024 * 1024 * 1024; - } - // Now $max and $maxphp and $maxphp2 are in Kb - $maxmin = $max; - $maxphptoshow = $maxphptoshowparam = ''; - if ($maxphp > 0) { - $maxmin = min($max, $maxphp); - $maxphptoshow = $maxphp; - $maxphptoshowparam = 'upload_max_filesize'; - } - if ($maxphp2 > 0) { - $maxmin = min($max, $maxphp2); - if ($maxphp2 < $maxphp) { - $maxphptoshow = $maxphp2; - $maxphptoshowparam = 'post_max_size'; - } - } - - $langs->load('other'); - $out .= ' '; - $out .= info_admin($langs->trans("ThisLimitIsDefinedInSetup", $max, $maxphptoshow), 1); -} else { - $out .= ' ('.$langs->trans("UploadDisabled").')'; -} -print $out; - -print '
'; - -print '

'; +$buttonrecordnoent = $langs->transnoentitiesnoconv("RecordMovement"); +print ''.$langs->trans("SelectProductInAndOutWareHouse", $titletoaddnoent, $buttonrecordnoent).'
'; +print '
'."\n"; @@ -658,0 +346 @@ +//print '
'; @@ -662,0 +351,4 @@ +print getTitleFieldOfList($langs->trans('ProductRef'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone '); +if ($conf->productbatch->enabled) { + print getTitleFieldOfList($langs->trans('Batch'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone '); +} @@ -665,5 +357 @@ -print getTitleFieldOfList($langs->trans('Product'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone '); -if (isModEnabled('productbatch')) { - print getTitleFieldOfList($langs->trans('Batch'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone '); -} -print getTitleFieldOfList($langs->trans('Qty'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'right tagtd maxwidthonsmartphone '); +print getTitleFieldOfList($langs->trans('Qty'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'center tagtd maxwidthonsmartphone '); @@ -672,0 +361 @@ + @@ -674,8 +362,0 @@ -// From warehouse -print ''; -print img_picto($langs->trans("WarehouseSource"), 'stock', 'class="paddingright"').$formproduct->selectWarehouses($id_sw, 'id_sw', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200'); -print ''; -// To warehouse -print ''; -print img_picto($langs->trans("WarehouseTarget"), 'stock', 'class="paddingright"').$formproduct->selectWarehouses($id_tw, 'id_tw', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200'); -print ''; @@ -683 +364 @@ -print ''; +print ''; @@ -685,4 +366,2 @@ -if (getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { - $filtertype = ''; -} -if (getDolGlobalInt('PRODUIT_LIMIT_SIZE') <= 0) { +if (!empty($conf->global->STOCK_SUPPORTS_SERVICES)) $filtertype = ''; +if ($conf->global->PRODUIT_LIMIT_SIZE <= 0) { @@ -690 +369,3 @@ -} else { +} +else +{ @@ -694,2 +375 @@ -print img_picto($langs->trans("Product"), 'product', 'class="paddingright"'); -print $form->select_produits($id_product, 'productid', $filtertype, $limit, 0, -1, 2, '', 1, array(), 0, '1', 0, 'minwidth200imp maxwidth300', 1, '', null, 1); +$form->select_produits($id_product, 'productid', $filtertype, $limit, 0, -1, 2, '', 0, array(), 0, '1', 0, 'minwidth200imp maxwidth300', 1); @@ -698,6 +378,14 @@ -if (isModEnabled('productbatch')) { - print ''; - print img_picto($langs->trans("LotSerial"), 'lot', 'class="paddingright"'); - print ''; - print ''; -} +if ($conf->productbatch->enabled) +{ + print ''; + print ''; + print ''; +} +// In warehouse +print ''; +print $formproduct->selectWarehouses($id_sw, 'id_sw', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200'); +print ''; +// Out warehouse +print ''; +print $formproduct->selectWarehouses($id_tw, 'id_tw', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200'); +print ''; @@ -705 +393 @@ -print ''; +print ''; @@ -711,2 +399,3 @@ -foreach ($listofdata as $key => $val) { - $productstatic->id = 0; + +foreach ($listofdata as $key => $val) +{ @@ -714,25 +403,9 @@ - - $warehousestatics->id = 0; - if ($val['id_sw'] > 0) { - $warehousestatics->fetch($val['id_sw']); - } - $warehousestatict->id = 0; - if ($val['id_tw'] > 0) { - $warehousestatict->fetch($val['id_tw']); - } - - if ($productstatic->id <= 0) { - $error++; - setEventMessages($langs->trans("ObjectNotFound", $langs->transnoentitiesnoconv("Product").' (id='.$val['id_product'].')'), null, 'errors'); - } - if ($warehousestatics->id < 0) { // We accept 0 for source warehouse id - $error++; - setEventMessages($langs->trans("ObjectNotFound", $langs->transnoentitiesnoconv("WarehouseSource").' (id='.$val['id_sw'].')'), null, 'errors'); - } - if ($warehousestatict->id <= 0) { - $error++; - setEventMessages($langs->trans("ObjectNotFound", $langs->transnoentitiesnoconv("WarehouseTarget").' (id='.$val['id_tw'].')'), null, 'errors'); - } - - if (!$error) { - print ''; + $warehousestatics->fetch($val['id_sw']); + $warehousestatict->fetch($val['id_tw']); + + print ''; + print ''; + print $productstatic->getNomUrl(1).' - '.$productstatic->label; + print ''; + if ($conf->productbatch->enabled) + { @@ -740,7 +413 @@ - if ($warehousestatics->id > 0) { - print $warehousestatics->getNomUrl(1); - } else { - print ''; - print $langs->trans("None"); - print ''; - } + print $val['batch']; @@ -748,15 +415,11 @@ - print ''; - print $warehousestatict->getNomUrl(1); - print ''; - print ''; - print $productstatic->getNomUrl(1).' - '.dol_escape_htmltag($productstatic->label); - print ''; - if (isModEnabled('productbatch')) { - print ''; - print dol_escape_htmltag($val['batch']); - print ''; - } - print ''.price2num((float) $val['qty'], 'MS').''; - print ''.img_delete($langs->trans("Remove")).''; - print ''; - } + } + print ''; + print $warehousestatics->getNomUrl(1); + print ''; + print ''; + print $warehousestatict->getNomUrl(1); + print ''; + print ''.$val['qty'].''; + print ''.img_delete($langs->trans("Remove")).''; + + print ''; @@ -769,0 +433 @@ + @@ -772,29 +436,27 @@ -// Form to validate all movements -if (count($listofdata)) { - print '
'; - print ''; - print ''; - - // Button to record mass movement - $codemove = (GETPOSTISSET("codemove") ? GETPOST("codemove", 'alpha') : dol_print_date(dol_now(), '%Y%m%d%H%M%S')); - $labelmovement = GETPOST("label") ? GETPOST('label') : $langs->trans("MassStockTransferShort").' '.dol_print_date($now, '%Y-%m-%d %H:%M'); - - print '
'; - print ''.$langs->trans("InventoryCode").': '; - print '   '; - print ''; - print $langs->trans("MovementLabel").': '; - print '
'; - print '
'; - - print '
'; - - print '
'; - print '
'; - - print '
'; -} - -if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?urlfile='.urlencode(GETPOST('urlfile')).'&step=3'.$param, $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); -} + +print '
'; +print ''; +print ''; + +// Button to record mass movement +$codemove = (isset($_POST["codemove"]) ?GETPOST("codemove", 'alpha') : dol_print_date(dol_now(), '%Y%m%d%H%M%S')); +$labelmovement = GETPOST("label") ?GETPOST('label') : $langs->trans("StockTransfer").' '.dol_print_date($now, '%Y-%m-%d %H:%M'); + +print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; +print '
'.$langs->trans("InventoryCode").''; + print ''; + print '
'.$langs->trans("MovementLabel").''; + print ''; + print '

'; + +print '
'; + +print '
'; @@ -805,31 +466,0 @@ - - -/** - * Verify if $haystack startswith $needle - * - * @param string $haystack string to test - * @param string $needle string to find - * @return bool false if Ko true else - */ -function startsWith($haystack, $needle) -{ - $length = strlen($needle); - return substr($haystack, 0, $length) === $needle; -} - -/** - * Fetch object with ref - * - * @param Object $static_object static object to fetch - * @param string $tmp_ref ref of the object to fetch - * @return int Return integer <0 if Ko or Id of object - */ -function fetchref($static_object, $tmp_ref) -{ - if (startsWith($tmp_ref, 'ref:')) { - $tmp_ref = str_replace('ref:', '', $tmp_ref); - } - $static_object->id = 0; - $static_object->fetch('', $tmp_ref); - return $static_object->id; -} --- /tmp/dsg/dolibarr/htdocs/product/stock/github_19.0.3_movement_card.php +++ /tmp/dsg/dolibarr/htdocs/product/stock/client_movement_card.php @@ -29 +28,0 @@ -// Load Dolibarr environment @@ -41 +40 @@ -if (isModEnabled('project')) { +if (!empty($conf->projet->enabled)) { @@ -48,3 +47 @@ -if (isModEnabled('productbatch')) { - $langs->load("productbatch"); -} +if (!empty($conf->productbatch->enabled)) $langs->load("productbatch"); @@ -61 +58 @@ -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'movementlist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'movementlist'; @@ -77 +74 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -79,5 +76,3 @@ -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -85,6 +80,2 @@ -if (!$sortfield) { - $sortfield = "m.datem"; -} -if (!$sortorder) { - $sortorder = "DESC"; -} +if (!$sortfield) $sortfield = "m.datem"; +if (!$sortorder) $sortorder = "DESC"; @@ -106,13 +97,13 @@ - 'm.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), - 'm.datem'=>array('label'=>$langs->trans("Date"), 'checked'=>1), - 'p.ref'=>array('label'=>$langs->trans("ProductRef"), 'checked'=>1, 'css'=>'maxwidth100'), - 'p.label'=>array('label'=>$langs->trans("ProductLabel"), 'checked'=>1), - 'm.batch'=>array('label'=>$langs->trans("BatchNumberShort"), 'checked'=>1, 'enabled'=>(isModEnabled('productbatch'))), - 'pl.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(isModEnabled('productbatch'))), - 'pl.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(isModEnabled('productbatch'))), - 'e.ref'=>array('label'=>$langs->trans("Warehouse"), 'checked'=>1, 'enabled'=>(!($id > 0))), // If we are on specific warehouse, we hide it - 'm.fk_user_author'=>array('label'=>$langs->trans("Author"), 'checked'=>0), - 'm.inventorycode'=>array('label'=>$langs->trans("InventoryCodeShort"), 'checked'=>1), - 'm.label'=>array('label'=>$langs->trans("MovementLabel"), 'checked'=>1), - 'm.type_mouvement'=>array('label'=>$langs->trans("TypeMovement"), 'checked'=>1), - 'origin'=>array('label'=>$langs->trans("Origin"), 'checked'=>1), + 'm.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 'm.datem'=>array('label'=>$langs->trans("Date"), 'checked'=>1), + 'p.ref'=>array('label'=>$langs->trans("ProductRef"), 'checked'=>1, 'css'=>'maxwidth100'), + 'p.label'=>array('label'=>$langs->trans("ProductLabel"), 'checked'=>1), + 'm.batch'=>array('label'=>$langs->trans("BatchNumberShort"), 'checked'=>1, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'pl.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'pl.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'e.ref'=>array('label'=>$langs->trans("Warehouse"), 'checked'=>1, 'enabled'=>(!$id > 0)), // If we are on specific warehouse, we hide it + 'm.fk_user_author'=>array('label'=>$langs->trans("Author"), 'checked'=>0), + 'm.inventorycode'=>array('label'=>$langs->trans("InventoryCodeShort"), 'checked'=>1), + 'm.label'=>array('label'=>$langs->trans("MovementLabel"), 'checked'=>1), + 'm.type_mouvement'=>array('label'=>$langs->trans("TypeMovement"), 'checked'=>1), + 'origin'=>array('label'=>$langs->trans("Origin"), 'checked'=>1), @@ -122 +113 @@ - //'m.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500) + //'m.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500) @@ -135,7 +126,2 @@ -if (GETPOST('cancel', 'alpha')) { - $action = 'list'; - $massaction = ''; -} -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { - $massaction = ''; -} +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } @@ -145,2 +131,22 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + +// Do we click on purge search criteria ? +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers +{ + $year = ''; + $month = ''; + $search_ref = ''; + $search_movement = ""; + $search_type_mouvement = ""; + $search_inventorycode = ""; + $search_product_ref = ""; + $search_product = ""; + $search_warehouse = ""; + $search_user = ""; + $search_batch = ""; + $search_qty = ''; + $sall = ""; + $toselect = ''; + $search_array_options = array(); @@ -149,21 +154,0 @@ -include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - -// Do we click on purge search criteria ? -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers - $year = ''; - $month = ''; - $search_ref = ''; - $search_movement = ""; - $search_type_mouvement = ""; - $search_inventorycode = ""; - $search_product_ref = ""; - $search_product = ""; - $search_warehouse = ""; - $search_user = ""; - $search_batch = ""; - $search_qty = ''; - $sall = ""; - $toselect = array(); - $search_array_options = array(); -} - @@ -171 +156,2 @@ -if ($action == "correct_stock") { +if ($action == "correct_stock") +{ @@ -173,3 +159 @@ - if (!empty($product_id)) { - $result = $product->fetch($product_id); - } + if (!empty($product_id)) $result = $product->fetch($product_id); @@ -179 +163,2 @@ - if (empty($product_id)) { + if (empty($product_id)) + { @@ -184 +169,2 @@ - if (!is_numeric(GETPOST("nbpiece"))) { + if (!is_numeric($_POST["nbpiece"])) + { @@ -190 +176,2 @@ - if (!$error) { + if (!$error) + { @@ -194 +181,2 @@ - if (GETPOST('projectid', 'int')) { + if (GETPOST('projectid', 'int')) + { @@ -199,49 +187,53 @@ - if ($product->hasbatch()) { - $batch = GETPOST('batch_number', 'alpha'); - - //$eatby=GETPOST('eatby'); - //$sellby=GETPOST('sellby'); - $eatby = dol_mktime(0, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int')); - $sellby = dol_mktime(0, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int')); - - $result = $product->correct_stock_batch( - $user, - $id, - GETPOST("nbpiece", 'int'), - GETPOST("mouvement", 'int'), - GETPOST("label", 'san_alpha'), - GETPOST('unitprice', 'alpha'), - $eatby, - $sellby, - $batch, - GETPOST('inventorycode', 'alpha'), - $origin_element, - $origin_id - ); // We do not change value of stock for a correction - } else { - $result = $product->correct_stock( - $user, - $id, - GETPOST("nbpiece", 'int'), - GETPOST("mouvement", 'alpha'), - GETPOST("label", 'san_alpha'), - GETPOST('unitprice', 'alpha'), - GETPOST('inventorycode', 'alpha'), - $origin_element, - $origin_id - ); // We do not change value of stock for a correction - } - - if ($result > 0) { - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; - } else { - $error++; - setEventMessages($product->error, $product->errors, 'errors'); - $action = 'correction'; - } - } - - if (!$error) { - $action = ''; - } + if ($product->hasbatch()) + { + $batch = GETPOST('batch_number', 'alpha'); + + //$eatby=GETPOST('eatby'); + //$sellby=GETPOST('sellby'); + $eatby = dol_mktime(0, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int')); + $sellby = dol_mktime(0, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int')); + + $result = $product->correct_stock_batch( + $user, + $id, + GETPOST("nbpiece", 'int'), + GETPOST("mouvement", 'int'), + GETPOST("label", 'san_alpha'), + GETPOST('unitprice', 'alpha'), + $eatby, + $sellby, + $batch, + GETPOST('inventorycode', 'alpha'), + $origin_element, + $origin_id + ); // We do not change value of stock for a correction + } + else + { + $result = $product->correct_stock( + $user, + $id, + GETPOST("nbpiece", 'int'), + GETPOST("mouvement", 'alpha'), + GETPOST("label", 'san_alpha'), + GETPOST('unitprice', 'alpha'), + GETPOST('inventorycode', 'alpha'), + $origin_element, + $origin_id + ); // We do not change value of stock for a correction + } + + if ($result > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + else + { + $error++; + setEventMessages($product->error, $product->errors, 'errors'); + $action = 'correction'; + } + } + + if (!$error) $action = ''; @@ -251 +243,2 @@ -if ($action == "transfert_stock" && !$cancel) { +if ($action == "transfert_stock" && !$cancel) +{ @@ -253,10 +246,10 @@ - if (!empty($product_id)) { - $result = $product->fetch($product_id); - } - - if (!(GETPOST("id_entrepot_destination", 'int') > 0)) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); - $error++; - $action = 'transfert'; - } - if (empty($product_id)) { + if (!empty($product_id)) $result = $product->fetch($product_id); + + if (!(GETPOST("id_entrepot_destination", 'int') > 0)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); + $error++; + $action = 'transfert'; + } + if (empty($product_id)) + { @@ -267,127 +260,147 @@ - if (!GETPOST("nbpiece", 'int')) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); - $error++; - $action = 'transfert'; - } - if ($id == GETPOST("id_entrepot_destination", 'int')) { - setEventMessages($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), null, 'errors'); - $error++; - $action = 'transfert'; - } - - if (isModEnabled('productbatch')) { - $product = new Product($db); - $result = $product->fetch($product_id); - - if ($product->hasbatch() && !GETPOST("batch_number", 'alpha')) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); - $error++; - $action = 'transfert'; - } - } - - if (!$error) { - if ($id) { - $object = new Entrepot($db); - $result = $object->fetch($id); - - $db->begin(); - - $product->load_stock('novirtual'); // Load array product->stock_warehouse - - // Define value of products moved - $pricesrc = 0; - if (isset($product->pmp)) { - $pricesrc = $product->pmp; - } - $pricedest = $pricesrc; - - if ($product->hasbatch()) { - $pdluo = new Productbatch($db); - - if ($pdluoid > 0) { - $result = $pdluo->fetch($pdluoid); - if ($result) { - $srcwarehouseid = $pdluo->warehouseid; - $batch = $pdluo->batch; - $eatby = $pdluo->eatby; - $sellby = $pdluo->sellby; - } else { - setEventMessages($pdluo->error, $pdluo->errors, 'errors'); - $error++; - } - } else { - $srcwarehouseid = $id; - $batch = GETPOST('batch_number', 'alpha'); - $eatby = $d_eatby; - $sellby = $d_sellby; - } - - if (!$error) { - // Remove stock - $result1 = $product->correct_stock_batch( - $user, - $srcwarehouseid, - GETPOST("nbpiece", 'int'), - 1, - GETPOST("label", 'san_alpha'), - $pricesrc, - $eatby, - $sellby, - $batch, - GETPOST('inventorycode', 'alpha') - ); - // Add stock - $result2 = $product->correct_stock_batch( - $user, - GETPOST("id_entrepot_destination", 'int'), - GETPOST("nbpiece", 'int'), - 0, - GETPOST("label", 'san_alpha'), - $pricedest, - $eatby, - $sellby, - $batch, - GETPOST('inventorycode', 'alpha') - ); - } - } else { - // Remove stock - $result1 = $product->correct_stock( - $user, - $id, - GETPOST("nbpiece", 'int'), - 1, - GETPOST("label", 'alpha'), - $pricesrc, - GETPOST('inventorycode', 'alpha') - ); - - // Add stock - $result2 = $product->correct_stock( - $user, - GETPOST("id_entrepot_destination"), - GETPOST("nbpiece", 'int'), - 0, - GETPOST("label", 'alpha'), - $pricedest, - GETPOST('inventorycode', 'alpha') - ); - } - if (!$error && $result1 >= 0 && $result2 >= 0) { - $db->commit(); - - if ($backtopage) { - header("Location: ".$backtopage); - exit; - } else { - header("Location: movement_list.php?id=".$object->id); - exit; - } - } else { - setEventMessages($product->error, $product->errors, 'errors'); - $db->rollback(); - $action = 'transfert'; - } - } - } + if (!GETPOST("nbpiece", 'int')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); + $error++; + $action = 'transfert'; + } + if ($id == GETPOST("id_entrepot_destination", 'int')) + { + setEventMessages($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), null, 'errors'); + $error++; + $action = 'transfert'; + } + + if (!empty($conf->productbatch->enabled)) + { + $product = new Product($db); + $result = $product->fetch($product_id); + + if ($product->hasbatch() && !GETPOST("batch_number", 'alpha')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); + $error++; + $action = 'transfert'; + } + } + + if (!$error) + { + if ($id) + { + $object = new Entrepot($db); + $result = $object->fetch($id); + + $db->begin(); + + $product->load_stock('novirtual'); // Load array product->stock_warehouse + + // Define value of products moved + $pricesrc = 0; + if (isset($product->pmp)) $pricesrc = $product->pmp; + $pricedest = $pricesrc; + + if ($product->hasbatch()) + { + $pdluo = new Productbatch($db); + + if ($pdluoid > 0) + { + $result = $pdluo->fetch($pdluoid); + if ($result) + { + $srcwarehouseid = $pdluo->warehouseid; + $batch = $pdluo->batch; + $eatby = $pdluo->eatby; + $sellby = $pdluo->sellby; + } + else + { + setEventMessages($pdluo->error, $pdluo->errors, 'errors'); + $error++; + } + } + else + { + $srcwarehouseid = $id; + $batch = GETPOST('batch_number', 'alpha'); + $eatby = $d_eatby; + $sellby = $d_sellby; + } + + if (!$error) + { + // Remove stock + $result1 = $product->correct_stock_batch( + $user, + $srcwarehouseid, + GETPOST("nbpiece", 'int'), + 1, + GETPOST("label", 'san_alpha'), + $pricesrc, + $eatby, + $sellby, + $batch, + GETPOST('inventorycode', 'alpha') + ); + // Add stock + $result2 = $product->correct_stock_batch( + $user, + GETPOST("id_entrepot_destination", 'int'), + GETPOST("nbpiece", 'int'), + 0, + GETPOST("label", 'san_alpha'), + $pricedest, + $eatby, + $sellby, + $batch, + GETPOST('inventorycode', 'alpha') + ); + } + } + else + { + // Remove stock + $result1 = $product->correct_stock( + $user, + $id, + GETPOST("nbpiece", 'int'), + 1, + GETPOST("label", 'alpha'), + $pricesrc, + GETPOST('inventorycode', 'alpha') + ); + + // Add stock + $result2 = $product->correct_stock( + $user, + GETPOST("id_entrepot_destination"), + GETPOST("nbpiece", 'int'), + 0, + GETPOST("label", 'alpha'), + $pricedest, + GETPOST('inventorycode', 'alpha') + ); + } + if (!$error && $result1 >= 0 && $result2 >= 0) + { + $db->commit(); + + if ($backtopage) + { + header("Location: ".$backtopage); + exit; + } + else + { + header("Location: movement_list.php?id=".$object->id); + exit; + } + } + else + { + setEventMessages($product->error, $product->errors, 'errors'); + $db->rollback(); + $action = 'transfert'; + } + } + } @@ -407,6 +420,7 @@ -if (empty($reshook) && $action != 'remove_file') { - $objectclass = 'MouvementStock'; - $objectlabel = 'Movements'; - $permissiontoread = $user->rights->stock->lire; - $permissiontodelete = $user->rights->stock->supprimer; - $uploaddir = $conf->stock->dir_output."/movement/"; +if (empty($reshook) && $action != 'remove_file') +{ + $objectclass = 'MouvementStock'; + $objectlabel = 'Movements'; + $permissiontoread = $user->rights->stock->lire; + $permissiontodelete = $user->rights->stock->supprimer; + $uploaddir = $conf->stock->dir_output."/movement/"; @@ -422 +436 @@ -$productlot = new Productlot($db); +$productlot = new ProductLot($db); @@ -430,3 +444 @@ -if (isModEnabled('project')) { - $formproject = new FormProjets($db); -} +if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); @@ -443,3 +455 @@ - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); - } + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); @@ -454,3 +464 @@ -if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (m.rowid = ef.fk_object)"; -} +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (m.rowid = ef.fk_object)"; @@ -460,3 +468 @@ -if ($msid > 0) { - $sql .= " AND m.rowid = ".((int) $msid); -} +if ($msid > 0) $sql .= " AND m.rowid = ".$msid; @@ -465,6 +471,2 @@ -if (!getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { - $sql .= " AND p.fk_product_type = 0"; -} -if ($id > 0) { - $sql .= " AND e.rowid = ".((int) $id); -} +if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = 0"; +if ($id > 0) $sql .= " AND e.rowid ='".$id."'"; @@ -472,33 +474,11 @@ -if ($idproduct > 0) { - $sql .= " AND p.rowid = ".((int) $idproduct); -} -if (!empty($search_ref)) { - $sql .= natural_search('m.rowid', $search_ref, 1); -} -if (!empty($search_movement)) { - $sql .= natural_search('m.label', $search_movement); -} -if (!empty($search_inventorycode)) { - $sql .= natural_search('m.inventorycode', $search_inventorycode); -} -if (!empty($search_product_ref)) { - $sql .= natural_search('p.ref', $search_product_ref); -} -if (!empty($search_product)) { - $sql .= natural_search('p.label', $search_product); -} -if ($search_warehouse != '' && $search_warehouse != '-1') { - $sql .= natural_search('e.rowid', $search_warehouse, 2); -} -if (!empty($search_user)) { - $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_user); -} -if (!empty($search_batch)) { - $sql .= natural_search('m.batch', $search_batch); -} -if ($search_qty != '') { - $sql .= natural_search('m.value', $search_qty, 1); -} -if ($search_type_mouvement != '' && $search_type_mouvement != '-1') { - $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2); -} +if ($idproduct > 0) $sql .= " AND p.rowid = '".$idproduct."'"; +if (!empty($search_ref)) $sql .= natural_search('m.rowid', $search_ref, 1); +if (!empty($search_movement)) $sql .= natural_search('m.label', $search_movement); +if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $search_inventorycode); +if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref); +if (!empty($search_product)) $sql .= natural_search('p.label', $search_product); +if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('e.rowid', $search_warehouse, 2); +if (!empty($search_user)) $sql .= natural_search('u.login', $search_user); +if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch); +if ($search_qty != '') $sql .= natural_search('m.value', $search_qty, 1); +if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2); @@ -514,7 +494,9 @@ -if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 - $page = 0; - $offset = 0; - } +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } @@ -527 +509,2 @@ -if ($resql) { +if ($resql) +{ @@ -531,2 +514,25 @@ - if ($idproduct > 0) { - $product->fetch($idproduct); + if ($idproduct > 0) + { + $product->fetch($idproduct); + } + if ($id > 0 || $ref) + { + $result = $object->fetch($id, $ref); + if ($result < 0) + { + dol_print_error($db); + } + } + + $num = $db->num_rows($resql); + + $arrayofselected = is_array($toselect) ? $toselect : array(); + + + $i = 0; + $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; + if ($msid) $texte = $langs->trans('StockMovementForId', $msid); + else + { + $texte = $langs->trans("ListOfStockMovements"); + if ($id) $texte .= ' ('.$langs->trans("ForThisWarehouse").')'; @@ -534,114 +540,99 @@ - if ($id > 0 || $ref) { - $result = $object->fetch($id, $ref); - if ($result < 0) { - dol_print_error($db); - } - } - - $num = $db->num_rows($resql); - - $arrayofselected = is_array($toselect) ? $toselect : array(); - - - $i = 0; - $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; - if ($msid) { - $texte = $langs->trans('StockMovementForId', $msid); - } else { - $texte = $langs->trans("ListOfStockMovements"); - if ($id) { - $texte .= ' ('.$langs->trans("ForThisWarehouse").')'; - } - } - llxHeader("", $texte, $help_url); - - /* - * Show tab only if we ask a particular warehouse - */ - if ($object->id > 0) { - $head = stock_prepare_head($object); - - print dol_get_fiche_head($head, 'movements', $langs->trans("Warehouse"), -1, 'stock'); - - - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
'; - $morehtmlref .= $langs->trans("LocationSummary").' : '.$object->lieu; - $morehtmlref .= '
'; - - $shownav = 1; - if ($user->socid && !in_array('stock', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) { - $shownav = 0; - } - - dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref); - - - print '
'; - print '
'; - print '
'; - - print ''; - - print ''; - - // Description - print ''; - - $calcproductsunique = $object->nb_different_products(); - $calcproducts = $object->nb_products(); - - // Total nb of different products - print '"; - - // Nb of products - print '"; - - print '
'.$langs->trans("Description").''.dol_htmlentitiesbr($object->description).'
'.$langs->trans("NumberOfDifferentProducts").''; - print empty($calcproductsunique['nb']) ? '0' : $calcproductsunique['nb']; - print "
'.$langs->trans("NumberOfProducts").''; - $valtoshow = price2num($calcproducts['nb'], 'MS'); - print empty($valtoshow) ? '0' : $valtoshow; - print "
'; - - print '
'; - print '
'; - print '
'; - - print ''; - - // Value - print '"; - - // Last movement - $sql = "SELECT MAX(m.datem) as datem"; - $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; - $sql .= " WHERE m.fk_entrepot = ".(int) $object->id; - $resqlbis = $db->query($sql); - if ($resqlbis) { - $obj = $db->fetch_object($resqlbis); - $lastmovementdate = $db->jdate($obj->datem); - } else { - dol_print_error($db); - } - - print '"; - - print "
'.$langs->trans("EstimatedStockValueShort").''; - print price((empty($calcproducts['value']) ? '0' : price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency); - print "
'.$langs->trans("LastMovement").''; - if ($lastmovementdate) { - print dol_print_date($lastmovementdate, 'dayhour'); - } else { - print $langs->trans("None"); - } - print "
"; - - print '
'; - print '
'; - - print '
'; - - print dol_get_fiche_end(); - } + llxHeader("", $texte, $help_url); + + /* + * Show tab only if we ask a particular warehouse + */ + if ($object->id > 0) + { + $head = stock_prepare_head($object); + + dol_fiche_head($head, 'movements', $langs->trans("Warehouse"), -1, 'stock'); + + + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
'; + $morehtmlref .= $langs->trans("LocationSummary").' : '.$object->lieu; + $morehtmlref .= '
'; + + $shownav = 1; + if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + print '
'; + + print ''; + + print ''; + + // Description + print ''; + + $calcproductsunique = $object->nb_different_products(); + $calcproducts = $object->nb_products(); + + // Total nb of different products + print '"; + + // Nb of products + print '"; + + print '
'.$langs->trans("Description").''.dol_htmlentitiesbr($object->description).'
'.$langs->trans("NumberOfDifferentProducts").''; + print empty($calcproductsunique['nb']) ? '0' : $calcproductsunique['nb']; + print "
'.$langs->trans("NumberOfProducts").''; + $valtoshow = price2num($calcproducts['nb'], 'MS'); + print empty($valtoshow) ? '0' : $valtoshow; + print "
'; + + print '
'; + print '
'; + print '
'; + print '
'; + + print ''; + + // Value + print '"; + + // Last movement + $sql = "SELECT MAX(m.datem) as datem"; + $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; + $sql .= " WHERE m.fk_entrepot = ".(int) $object->id; + $resqlbis = $db->query($sql); + if ($resqlbis) + { + $obj = $db->fetch_object($resqlbis); + $lastmovementdate = $db->jdate($obj->datem); + } + else + { + dol_print_error($db); + } + + print '"; + + print "
'.$langs->trans("EstimatedStockValueShort").''; + print price((empty($calcproducts['value']) ? '0' : price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency); + print "
'.$langs->trans("LastMovement").''; + if ($lastmovementdate) + { + print dol_print_date($lastmovementdate, 'dayhour'); + } + else + { + print $langs->trans("None"); + } + print "
"; + + print '
'; + print '
'; + print '
'; + + print '
'; + + dol_fiche_end(); + } @@ -653 +644,2 @@ - if ($action == "correction") { + if ($action == "correction") + { @@ -661 +653,2 @@ - if ($action == "transfert") { + if ($action == "transfert") + { @@ -667,56 +660,38 @@ - /* - * Action bar - */ - if ((empty($action) || $action == 'list') && $id > 0) { - print "
\n"; - - if ($user->hasRight('stock', 'mouvement', 'creer')) { - print ''.$langs->trans("CorrectStock").''; - } - - if ($user->hasRight('stock', 'mouvement', 'creer')) { - print ''.$langs->trans("TransferStock").''; - } - - print '

'; - } - - $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); - } - if ($id > 0) { - $param .= '&id='.urlencode($id); - } - if ($search_movement) { - $param .= '&search_movement='.urlencode($search_movement); - } - if ($search_inventorycode) { - $param .= '&search_inventorycode='.urlencode($search_inventorycode); - } - if ($search_type_mouvement) { - $param .= '&search_type_mouvement='.urlencode($search_type_mouvement); - } - if ($search_product_ref) { - $param .= '&search_product_ref='.urlencode($search_product_ref); - } - if ($search_product) { - $param .= '&search_product='.urlencode($search_product); - } - if ($search_batch) { - $param .= '&search_batch='.urlencode($search_batch); - } - if ($search_warehouse > 0) { - $param .= '&search_warehouse='.urlencode($search_warehouse); - } - if ($search_user) { - $param .= '&search_user='.urlencode($search_user); - } - if ($idproduct > 0) { - $param .= '&idproduct='.urlencode($idproduct); - } - // Add $param from extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + /* ************************************************************************** */ + /* */ + /* Barre d'action */ + /* */ + /* ************************************************************************** */ + + if ((empty($action) || $action == 'list') && $id > 0) + { + print "
\n"; + + if ($user->rights->stock->mouvement->creer) + { + print ''.$langs->trans("CorrectStock").''; + } + + if ($user->rights->stock->mouvement->creer) + { + print ''.$langs->trans("TransferStock").''; + } + + print '

'; + } + + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($id > 0) $param .= '&id='.urlencode($id); + if ($search_movement) $param .= '&search_movement='.urlencode($search_movement); + if ($search_inventorycode) $param .= '&search_inventorycode='.urlencode($search_inventorycode); + if ($search_type_mouvement) $param .= '&search_type_mouvement='.urlencode($search_type_mouvement); + if ($search_product_ref) $param .= '&search_product_ref='.urlencode($search_product_ref); + if ($search_product) $param .= '&search_product='.urlencode($search_product); + if ($search_batch) $param .= '&search_batch='.urlencode($search_batch); + if ($search_warehouse > 0) $param .= '&search_warehouse='.urlencode($search_warehouse); + if ($search_user) $param .= '&search_user='.urlencode($search_user); + if ($idproduct > 0) $param .= '&idproduct='.urlencode($idproduct); + // Add $param from extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -730,3 +705 @@ - if (in_array($massaction, array('presend', 'predelete'))) { - $arrayofmassactions = array(); - } + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); @@ -735,29 +708,21 @@ - print '
'; - if ($optioncss != '') { - print ''; - } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($id > 0) { - print ''; - } - - if ($id > 0) { - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit); - } else { - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, '', '', $limit); - } - - if ($sall) { - foreach ($fieldstosearchall as $key => $val) { - $fieldstosearchall[$key] = $langs->trans($val); - } - print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; - } - - $moreforfilter = ''; + print ''; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($id > 0) print ''; + + if ($id > 0) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit); + else print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, '', '', $limit); + + if ($sall) + { + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; + } + + $moreforfilter = ''; @@ -767,4 +732,8 @@ - if (empty($reshook)) { - $moreforfilter .= $hookmanager->resPrint; - } else { - $moreforfilter = $hookmanager->resPrint; + if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; + else $moreforfilter = $hookmanager->resPrint; + + if (!empty($moreforfilter)) + { + print '
'; + print $moreforfilter; + print '
'; @@ -773,4 +742,44 @@ - if (!empty($moreforfilter)) { - print '
'; - print $moreforfilter; - print '
'; + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + + print '
'; + print ''."\n"; + + // Fields title search + print ''; + if (!empty($arrayfields['m.rowid']['checked'])) + { + // Ref + print ''; + } + if (!empty($arrayfields['m.datem']['checked'])) + { + print ''; + } + if (!empty($arrayfields['p.ref']['checked'])) + { + // Product Ref + print ''; + } + if (!empty($arrayfields['p.label']['checked'])) + { + // Product label + print ''; + } + // Batch + if (!empty($arrayfields['m.batch']['checked'])) + { + print ''; @@ -778,80 +787,44 @@ - - $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - - print '
'; - print '
'; + print ''; + print ''; + print ''; + if (empty($conf->productbatch->enabled)) print ' '; + //else print '
'; + $syear = $year ? $year : -1; + print ''; + //print $formother->selectyear($syear,'year',1, 20, 5); + print '
'; + print ''; + print ''; + print ''; + print '
'."\n"; - - // Fields title search - print ''; - if (!empty($arrayfields['m.rowid']['checked'])) { - // Ref - print ''; - } - if (!empty($arrayfields['m.datem']['checked'])) { - print ''; - } - if (!empty($arrayfields['p.ref']['checked'])) { - // Product Ref - print ''; - } - if (!empty($arrayfields['p.label']['checked'])) { - // Product label - print ''; - } - // Batch - if (!empty($arrayfields['m.batch']['checked'])) { - print ''; - } - if (!empty($arrayfields['pl.eatby']['checked'])) { - print ''; - } - if (!empty($arrayfields['pl.sellby']['checked'])) { - print ''; - } - // Warehouse - if (!empty($arrayfields['e.ref']['checked'])) { - print ''; - } - if (!empty($arrayfields['m.fk_user_author']['checked'])) { - // Author - print ''; - } - if (!empty($arrayfields['m.inventorycode']['checked'])) { - // Inventory code - print ''; - } - if (!empty($arrayfields['m.label']['checked'])) { - // Label of movement - print ''; - } - if (!empty($arrayfields['m.type_mouvement']['checked'])) { - // Type of movement - print ''; + } + if (!empty($arrayfields['pl.sellby']['checked'])) + { + print ''; + } + // Warehouse + if (!empty($arrayfields['e.ref']['checked'])) + { + print ''; + } + if (!empty($arrayfields['m.fk_user_author']['checked'])) + { + // Author + print ''; + } + if (!empty($arrayfields['m.inventorycode']['checked'])) + { + // Inventory code + print ''; + } + if (!empty($arrayfields['m.label']['checked'])) + { + // Label of movement + print ''; + } + if (!empty($arrayfields['m.type_mouvement']['checked'])) + { + // Type of movement + print ''; - } - if (!empty($arrayfields['origin']['checked'])) { - // Origin of movement - print ''; - } - if (!empty($arrayfields['m.value']['checked'])) { - // Qty - print ''; - } - if (!empty($arrayfields['m.price']['checked'])) { - // Price - print ''; - } - - - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + print ''; + } + if (!empty($arrayfields['origin']['checked'])) + { + // Origin of movement + print ''; + } + if (!empty($arrayfields['m.value']['checked'])) + { + // Qty + print ''; + } + if (!empty($arrayfields['m.price']['checked'])) + { + // Price + print ''; + } + + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -898,3 +874,4 @@ - if (!empty($arrayfields['m.datec']['checked'])) { - print ''; + if (!empty($arrayfields['m.datec']['checked'])) + { + print ''; @@ -903,3 +880,4 @@ - if (!empty($arrayfields['m.tms']['checked'])) { - print ''; + if (!empty($arrayfields['m.tms']['checked'])) + { + print ''; @@ -907,9 +885,9 @@ - // Actions - print ''; - print "\n"; - - print ''; - if (!empty($arrayfields['m.rowid']['checked'])) { + // Actions + print ''; + print "\n"; + + print ''; + if (!empty($arrayfields['m.rowid']['checked'])) @@ -917,2 +895 @@ - } - if (!empty($arrayfields['m.datem']['checked'])) { + if (!empty($arrayfields['m.datem']['checked'])) @@ -920,2 +897 @@ - } - if (!empty($arrayfields['p.ref']['checked'])) { + if (!empty($arrayfields['p.ref']['checked'])) @@ -923,2 +899 @@ - } - if (!empty($arrayfields['p.label']['checked'])) { + if (!empty($arrayfields['p.label']['checked'])) @@ -926,2 +901 @@ - } - if (!empty($arrayfields['m.batch']['checked'])) { + if (!empty($arrayfields['m.batch']['checked'])) @@ -929,2 +903 @@ - } - if (!empty($arrayfields['pl.eatby']['checked'])) { + if (!empty($arrayfields['pl.eatby']['checked'])) @@ -932,2 +905 @@ - } - if (!empty($arrayfields['pl.sellby']['checked'])) { + if (!empty($arrayfields['pl.sellby']['checked'])) @@ -935 +906,0 @@ - } @@ -937,4 +908,4 @@ - // We are on a specific warehouse card, no filter on other should be possible - print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder); - } - if (!empty($arrayfields['m.fk_user_author']['checked'])) { + // We are on a specific warehouse card, no filter on other should be possible + print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder); + } + if (!empty($arrayfields['m.fk_user_author']['checked'])) @@ -942,2 +913 @@ - } - if (!empty($arrayfields['m.inventorycode']['checked'])) { + if (!empty($arrayfields['m.inventorycode']['checked'])) @@ -945,2 +915 @@ - } - if (!empty($arrayfields['m.label']['checked'])) { + if (!empty($arrayfields['m.label']['checked'])) @@ -948,2 +917 @@ - } - if (!empty($arrayfields['m.type_mouvement']['checked'])) { + if (!empty($arrayfields['m.type_mouvement']['checked'])) @@ -951,2 +919 @@ - } - if (!empty($arrayfields['origin']['checked'])) { + if (!empty($arrayfields['origin']['checked'])) @@ -954,2 +921 @@ - } - if (!empty($arrayfields['m.value']['checked'])) { + if (!empty($arrayfields['m.value']['checked'])) @@ -957,2 +923 @@ - } - if (!empty($arrayfields['m.price']['checked'])) { + if (!empty($arrayfields['m.price']['checked'])) @@ -960,4 +925,3 @@ - } - - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -967,2 +931,2 @@ - $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; @@ -970,2 +934,2 @@ - print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - } + print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } @@ -973,2 +937,2 @@ - print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - } + print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } @@ -976,30 +940,31 @@ - print "\n"; - - - $arrayofuniqueproduct = array(); - while ($i < ($limit ? min($num, $limit) : $num)) { - $objp = $db->fetch_object($resql); - - $userstatic->id = $objp->fk_user_author; - $userstatic->login = $objp->login; - $userstatic->lastname = $objp->lastname; - $userstatic->firstname = $objp->firstname; - $userstatic->photo = $objp->photo; - - $productstatic->id = $objp->rowid; - $productstatic->ref = $objp->product_ref; - $productstatic->label = $objp->produit; - $productstatic->type = $objp->type; - $productstatic->entity = $objp->entity; - $productstatic->status_batch = $objp->tobatch; - - $productlot->id = $objp->lotid; - $productlot->batch = $objp->batch; - $productlot->eatby = $objp->eatby; - $productlot->sellby = $objp->sellby; - - $warehousestatic->id = $objp->entrepot_id; - $warehousestatic->label = $objp->warehouse_ref; - $warehousestatic->lieu = $objp->lieu; - - $arrayofuniqueproduct[$objp->rowid] = $objp->produit; + print "\n"; + + + $arrayofuniqueproduct = array(); + while ($i < ($limit ? min($num, $limit) : $num)) { + $objp = $db->fetch_object($resql); + + $userstatic->id = $objp->fk_user_author; + $userstatic->login = $objp->login; + $userstatic->lastname = $objp->lastname; + $userstatic->firstname = $objp->firstname; + $userstatic->photo = $objp->photo; + + $productstatic->id = $objp->rowid; + $productstatic->ref = $objp->product_ref; + $productstatic->label = $objp->produit; + $productstatic->type = $objp->type; + $productstatic->entity = $objp->entity; + $productstatic->status_batch = $objp->tobatch; + + $productlot->id = $objp->lotid; + $productlot->batch = $objp->batch; + $productlot->eatby = $objp->eatby; + $productlot->sellby = $objp->sellby; + + $warehousestatic->id = $objp->entrepot_id; + $warehousestatic->libelle = $objp->warehouse_ref; // deprecated + $warehousestatic->label = $objp->warehouse_ref; + $warehousestatic->lieu = $objp->lieu; + + $arrayofuniqueproduct[$objp->rowid] = $objp->produit; @@ -1012,5 +977,44 @@ - print ''; - // Id movement - if (!empty($arrayfields['m.rowid']['checked'])) { - // This is primary not movement id - print ''; + print ''; + // Id movement + if (!empty($arrayfields['m.rowid']['checked'])) + { + // This is primary not movement id + print ''; + } + if (!empty($arrayfields['m.datem']['checked'])) + { + // Date + print ''; + } + if (!empty($arrayfields['p.ref']['checked'])) + { + // Product ref + print '\n"; + } + if (!empty($arrayfields['p.label']['checked'])) + { + // Product label + print '\n"; + } + if (!empty($arrayfields['m.batch']['checked'])) + { + print ''; + } + if (!empty($arrayfields['pl.eatby']['checked'])) + { + print ''; + } + if (!empty($arrayfields['pl.sellby']['checked'])) + { + print ''; @@ -1018,3 +1022,6 @@ - if (!empty($arrayfields['m.datem']['checked'])) { - // Date - print ''; + // Warehouse + if (!empty($arrayfields['e.ref']['checked'])) + { + print '\n"; @@ -1022,46 +1029,11 @@ - if (!empty($arrayfields['p.ref']['checked'])) { - // Product ref - print '\n"; - } - if (!empty($arrayfields['p.label']['checked'])) { - // Product label - print '\n"; - } - if (!empty($arrayfields['m.batch']['checked'])) { - print ''; - } - if (!empty($arrayfields['pl.eatby']['checked'])) { - print ''; - } - if (!empty($arrayfields['pl.sellby']['checked'])) { - print ''; - } - // Warehouse - if (!empty($arrayfields['e.ref']['checked'])) { - print '\n"; - } - // Author - if (!empty($arrayfields['m.fk_user_author']['checked'])) { - print '\n"; - } - if (!empty($arrayfields['m.inventorycode']['checked'])) { - // Inventory code - print '\n"; + } + if (!empty($arrayfields['m.inventorycode']['checked'])) + { + // Inventory code + print ''; - } - if (!empty($arrayfields['m.type_mouvement']['checked'])) { - // Type of movement - switch ($objp->type_mouvement) { - case "0": - print ''; - break; - case "1": - print ''; - break; - case "2": - print ''; - break; - case "3": - print ''; - break; - } - } - if (!empty($arrayfields['origin']['checked'])) { - // Origin of movement - print ''; - } - if (!empty($arrayfields['m.value']['checked'])) { - // Qty - print ''; - } - if (!empty($arrayfields['m.price']['checked'])) { - // Price - print ''; - } - // Action column - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - - print "\n"; - $i++; - } - $db->free($resql); - - print "
'; - print ''; - print ''; - print ''; - if (empty($conf->productbatch->enabled)) { - print ' '; - } - //else print '
'; - $syear = $year ? $year : -1; - print ''; - //print $formother->selectyear($syear,'year',1, 20, 5); - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - //print ''; - print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200'); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - //print ''; + if (!empty($arrayfields['pl.eatby']['checked'])) + { + print ''; + print ''; + print ''; + //print ''; + print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200'); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; @@ -868,24 +841,27 @@ - print ''; - print '  '; - print ''; - print ''; - print ''; - print '  '; - print ''; + print '  '; + print ''; + print ''; + print ''; + print '  '; + print ''; - print ''; + print ''; - print ''; + print ''; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print '
'; + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print '
'.$objp->mid.'
'.$objp->mid.''.dol_print_date($db->jdate($objp->datem), 'dayhour').''; + print $productstatic->getNomUrl(1, 'stock', 16); + print "'; + /*$productstatic->id=$objp->rowid; + $productstatic->ref=$objp->produit; + $productstatic->type=$objp->type; + print $productstatic->getNomUrl(1,'',16);*/ + print $productstatic->label; + print "'; + if ($productlot->id > 0) print $productlot->getNomUrl(1); + else print $productlot->batch; // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement. + print ''.dol_print_date($objp->eatby, 'day').''.dol_print_date($objp->sellby, 'day').''.dol_print_date($db->jdate($objp->datem), 'dayhour').''; + print $warehousestatic->getNomUrl(1); + print "'; - print $productstatic->getNomUrl(1, 'stock', 16); - print "'; - /*$productstatic->id=$objp->rowid; - $productstatic->ref=$objp->produit; - $productstatic->type=$objp->type; - print $productstatic->getNomUrl(1,'',16);*/ - print $productstatic->label; - print "'; - if ($productlot->id > 0) { - print $productlot->getNomUrl(1); - } else { - print $productlot->batch; // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement. - } - print ''.dol_print_date($objp->eatby, 'day').''.dol_print_date($objp->sellby, 'day').''; - print $warehousestatic->getNomUrl(1); - print "'; - print $userstatic->getNomUrl(-1); - print "'; + print $userstatic->getNomUrl(-1); + print "'.$objp->label.''.$langs->trans('StockIncreaseAfterCorrectTransfer').''.$langs->trans('StockDecreaseAfterCorrectTransfer').''.$langs->trans('StockDecrease').''.$langs->trans('StockIncrease').''.$origin.''; - if ($objp->qt > 0) { - print '+'; - } - print $objp->qty; - print ''; - if ($objp->price != 0) { - print price($objp->price); - } - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print '
"; - print '
'; - print "
"; - - // Add number of product when there is a filter on period - if (count($arrayofuniqueproduct) == 1 && is_numeric($year)) { - print "
"; - - $productidselected = 0; - foreach ($arrayofuniqueproduct as $key => $val) { - $productidselected = $key; - $productlabelselected = $val; - } + } + if (!empty($arrayfields['m.label']['checked'])) + { + // Label of movement + print ''.$objp->label.''; + } + if (!empty($arrayfields['m.type_mouvement']['checked'])) + { + // Type of movement + switch ($objp->type_mouvement) { + case "0": + print ''.$langs->trans('StockIncreaseAfterCorrectTransfer').''; + break; + case "1": + print ''.$langs->trans('StockDecreaseAfterCorrectTransfer').''; + break; + case "2": + print ''.$langs->trans('StockDecrease').''; + break; + case "3": + print ''.$langs->trans('StockIncrease').''; + break; + } + } + if (!empty($arrayfields['origin']['checked'])) + { + // Origin of movement + print ''.$origin.''; + } + if (!empty($arrayfields['m.value']['checked'])) + { + // Qty + print ''; + if ($objp->qt > 0) print '+'; + print $objp->qty; + print ''; + } + if (!empty($arrayfields['m.price']['checked'])) + { + // Price + print ''; + if ($objp->price != 0) print price($objp->price); + print ''; + } + // Action column + print ''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; + } + print ''; + if (!$i) $totalarray['nbfield']++; + + print "\n"; + $i++; + } + $db->free($resql); + + print ""; + print '
'; + print ""; + + // Add number of product when there is a filter on period + if (count($arrayofuniqueproduct) == 1 && is_numeric($year)) + { + print "
"; + + $productidselected = 0; + foreach ($arrayofuniqueproduct as $key => $val) { + $productidselected = $key; + $productlabelselected = $val; + } @@ -1151,20 +1122,18 @@ - $balancebefore = $movement->calculateBalanceForProductBefore($productidselected, $datebefore); - $balanceafter = $movement->calculateBalanceForProductBefore($productidselected, $dateafter); - - //print ''; - print $langs->trans("NbOfProductBeforePeriod", $productlabelselected, dol_print_date($datebefore, 'day', 'gmt')); - //print ''; - //print ''; - print ': '.$balancebefore; - print "
\n"; - //print ''; - //print ''; - print $langs->trans("NbOfProductAfterPeriod", $productlabelselected, dol_print_date($dateafter, 'day', 'gmt')); - //print ''; - //print ''; - print ': '.$balanceafter; - print "
\n"; - //print ''; - } -} else { - dol_print_error($db); + $balancebefore = $movement->calculateBalanceForProductBefore($productidselected, $datebefore); + $balanceafter = $movement->calculateBalanceForProductBefore($productidselected, $dateafter); + + //print ''; + print $langs->trans("NbOfProductBeforePeriod", $productlabelselected, dol_print_date($datebefore, 'day', 'gmt')); + //print ''; + //print ''; + print ': '.$balancebefore; + print "
\n"; + //print ''; + //print ''; + print $langs->trans("NbOfProductAfterPeriod", $productlabelselected, dol_print_date($dateafter, 'day', 'gmt')); + //print ''; + //print ''; + print ': '.$balanceafter; + print "
\n"; + //print ''; + } @@ -1171,0 +1141,4 @@ +else +{ + dol_print_error($db); +} @@ -1176 +1149 @@ - * Generated documents + * Documents generes @@ -1181,7 +1154,8 @@ -if ($action != 'create' && $action != 'edit' && $action != 'delete' && $id > 0) { - print '
'; - print '
'; - print ''; // ancre - - // Documents - $objectref = dol_sanitizeFileName($object->ref); +if ($action != 'create' && $action != 'edit' && $action != 'delete' && $id > 0) +{ + print '
'; + print '
'; + print ''; // ancre + + // Documents + $objectref = dol_sanitizeFileName($object->ref); @@ -1189,12 +1163,8 @@ - if (!empty($search_inventorycode)) { - $objectref .= "_".$id."_".$search_inventorycode; - } - if ($search_type_mouvement) { - $objectref .= "_".$search_type_mouvement; - } - $relativepath = $comref.'/'.$objectref.'.pdf'; - $filedir = $conf->stock->dir_output.'/movement/'.$objectref; - - $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id."&search_inventorycode=".$search_inventorycode."&search_type_mouvement=$search_type_mouvement"; - $genallowed = $usercanread; - $delallowed = $usercancreate; + if (!empty($search_inventorycode)) $objectref .= "_".$id."_".$search_inventorycode; + if ($search_type_mouvement) $objectref .= "_".$search_type_mouvement; + $relativepath = $comref.'/'.$objectref.'.pdf'; + $filedir = $conf->stock->dir_output.'/movement/'.$objectref; + + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id."&search_inventorycode=".$search_inventorycode."&search_type_mouvement=$search_type_mouvement"; + $genallowed = $usercanread; + $delallowed = $usercancreate; @@ -1203,17 +1173,19 @@ - $delallowed = $user->rights->stock->creer; - - print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object); - $somethingshown = $formfile->numoffiles; - - print '
'; - - $MAXEVENT = 10; - - $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/product/agenda.php?id='.$object->id); - - // List of actions on element - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'mouvement', 0, 1, '', $MAXEVENT, '', $morehtmlcenter); // Show all action for product - - print '
'; + $delallowed = $user->rights->stock->creer; + + print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object); + $somethingshown = $formfile->numoffiles; + + print '
'; + + $MAXEVENT = 10; + + $morehtmlright = ''; + $morehtmlright .= $langs->trans("SeeAll"); + $morehtmlright .= ''; + + // List of actions on element + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'mouvement', 0, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for product + + print '
'; --- /tmp/dsg/dolibarr/htdocs/product/stock/github_19.0.3_movement_list.php +++ /tmp/dsg/dolibarr/htdocs/product/stock/client_movement_list.php @@ -6 +6 @@ - * Copyright (C) 2018-2022 Ferran Marcet + * Copyright (C) 2018 Ferran Marcet @@ -29 +28,0 @@ -// Load Dolibarr environment @@ -41,4 +40,3 @@ -require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -if (isModEnabled('project')) { - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; @@ -49,4 +47,9 @@ -if (isModEnabled('productbatch')) { - $langs->load("productbatch"); -} - +if (!empty($conf->productbatch->enabled)) $langs->load("productbatch"); + +// Security check +$result = restrictedArea($user, 'stock'); + +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$msid = GETPOST('msid', 'int'); +$product_id = GETPOST("product_id", 'int'); @@ -57 +60 @@ -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'movementlist'; @@ -59,8 +62,5 @@ -$backtopage = GETPOST("backtopage", "alpha"); -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$show_files = GETPOST('show_files', 'aZ'); -$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...) - -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); -$msid = GETPOST('msid', 'int'); + +// Security check +//$result=restrictedArea($user, 'stock', $id, 'entrepot&stock'); +$result = restrictedArea($user, 'stock'); + @@ -68,11 +68,2 @@ -$product_id = GETPOST("product_id", 'int'); - -$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); -$search_date_startday = GETPOST('search_date_startday', 'int'); -$search_date_startmonth = GETPOST('search_date_startmonth', 'int'); -$search_date_startyear = GETPOST('search_date_startyear', 'int'); -$search_date_endday = GETPOST('search_date_endday', 'int'); -$search_date_endmonth = GETPOST('search_date_endmonth', 'int'); -$search_date_endyear = GETPOST('search_date_endyear', 'int'); -$search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int'), 'tzuserrel'); -$search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int'), 'tzuserrel'); +$year = GETPOST("year"); +$month = GETPOST("month"); @@ -89,8 +80,2 @@ -$search_fk_project=GETPOST("search_fk_project", 'int'); - -$type = GETPOST("type", "int"); - -// Load variable for pagination -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); + +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -98,4 +83,3 @@ -if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { - // If $page is not defined, or '' or -1 or if we click on clear filters - $page = 0; -} +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -103,9 +87,2 @@ -$pageprev = $page - 1; -$pagenext = $page + 1; - -if (!$sortfield) { - $sortfield = "m.datem"; -} -if (!$sortorder) { - $sortorder = "DESC"; -} +if (!$sortfield) $sortfield = "m.datem"; +if (!$sortorder) $sortorder = "DESC"; @@ -115 +92 @@ -// Initialize technical objects +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -116,0 +94 @@ +$hookmanager->initHooks(array('movementlist')); @@ -118,3 +95,0 @@ -$diroutputmassaction = $conf->stock->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array of activated contexes - @@ -123 +98 @@ -// Fetch optionals attributes and labels +// fetch optionals attributes and labels @@ -129,18 +104,18 @@ - 'm.rowid'=>array('label'=>"Ref", 'checked'=>1, 'position'=>1), - 'm.datem'=>array('label'=>"Date", 'checked'=>1, 'position'=>2), - 'p.ref'=>array('label'=>"ProductRef", 'checked'=>1, 'css'=>'maxwidth100', 'position'=>3), - 'p.label'=>array('label'=>"ProductLabel", 'checked'=>0, 'position'=>5), - 'm.batch'=>array('label'=>"BatchNumberShort", 'checked'=>1, 'position'=>8, 'enabled'=>(isModEnabled('productbatch'))), - 'pl.eatby'=>array('label'=>"EatByDate", 'checked'=>0, 'position'=>9, 'enabled'=>(isModEnabled('productbatch'))), - 'pl.sellby'=>array('label'=>"SellByDate", 'checked'=>0, 'position'=>10, 'enabled'=>(isModEnabled('productbatch'))), - 'e.ref'=>array('label'=>"Warehouse", 'checked'=>1, 'position'=>100, 'enabled'=>(!($id > 0))), // If we are on specific warehouse, we hide it - 'm.fk_user_author'=>array('label'=>"Author", 'checked'=>0, 'position'=>120), - 'm.inventorycode'=>array('label'=>"InventoryCodeShort", 'checked'=>1, 'position'=>130), - 'm.label'=>array('label'=>"MovementLabel", 'checked'=>1, 'position'=>140), - 'm.type_mouvement'=>array('label'=>"TypeMovement", 'checked'=>0, 'position'=>150), - 'origin'=>array('label'=>"Origin", 'checked'=>1, 'position'=>155), - 'm.fk_projet'=>array('label'=>'Project', 'checked'=>0, 'position'=>180), - 'm.value'=>array('label'=>"Qty", 'checked'=>1, 'position'=>200), - 'm.price'=>array('label'=>"UnitPurchaseValue", 'checked'=>0, 'position'=>210, 'enabled'=>(!getDolGlobalInt('STOCK_MOVEMENT_LIST_HIDE_UNIT_PRICE'))) - //'m.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), - //'m.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500) + 'm.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 'm.datem'=>array('label'=>$langs->trans("Date"), 'checked'=>1), + 'p.ref'=>array('label'=>$langs->trans("ProductRef"), 'checked'=>1, 'css'=>'maxwidth100'), + 'p.label'=>array('label'=>$langs->trans("ProductLabel"), 'checked'=>1), + 'm.batch'=>array('label'=>$langs->trans("BatchNumberShort"), 'checked'=>1, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'pl.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>0, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'pl.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'e.ref'=>array('label'=>$langs->trans("Warehouse"), 'checked'=>1, 'enabled'=>(!$id > 0)), // If we are on specific warehouse, we hide it + 'm.fk_user_author'=>array('label'=>$langs->trans("Author"), 'checked'=>0), + 'm.inventorycode'=>array('label'=>$langs->trans("InventoryCodeShort"), 'checked'=>1), + 'm.label'=>array('label'=>$langs->trans("MovementLabel"), 'checked'=>1), + 'm.type_mouvement'=>array('label'=>$langs->trans("TypeMovement"), 'checked'=>1), + 'origin'=>array('label'=>$langs->trans("Origin"), 'checked'=>1), + 'm.value'=>array('label'=>$langs->trans("Qty"), 'checked'=>1), + 'm.price'=>array('label'=>$langs->trans("UnitPurchaseValue"), 'checked'=>0), + 'm.fk_projet'=>array('label'=>$langs->trans('Project'), 'checked'=>0) + //'m.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + //'m.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500) @@ -149,17 +123,0 @@ -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; - -if (getDolGlobalString('PRODUCT_DISABLE_SELLBY')) { - unset($arrayfields['pl.sellby']); -} -if (getDolGlobalString('PRODUCT_DISABLE_EATBY')) { - unset($arrayfields['pl.eatby']); -} - - -$tmpwarehouse = new Entrepot($db); -if ($id > 0 || !empty($ref)) { - $tmpwarehouse->fetch($id, $ref); - $id = $tmpwarehouse->id; -} - - @@ -167,5 +125 @@ -//$result=restrictedArea($user, 'stock', $id, 'entrepot&stock'); -$result = restrictedArea($user, 'stock'); - -// Security check -if (!$user->hasRight('stock', 'mouvement', 'lire')) { +if (!$user->rights->stock->mouvement->lire) { @@ -174,2 +127,0 @@ - -$uploaddir = $conf->stock->dir_output.'/movements'; @@ -185,2 +136,0 @@ -$error = 0; - @@ -192,7 +142,2 @@ -if (GETPOST('cancel', 'alpha')) { - $action = 'list'; - $massaction = ''; -} -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { - $massaction = ''; -} +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } @@ -202,6 +147,4 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - // Selection of new fields +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ @@ -210,28 +153,18 @@ - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers - $search_date_startday = ''; - $search_date_startmonth = ''; - $search_date_startyear = ''; - $search_date_endday = ''; - $search_date_endmonth = ''; - $search_date_endyear = ''; - $search_date_start = ''; - $search_date_end = ''; - $search_ref = ''; - $search_movement = ""; - $search_type_mouvement = ""; - $search_inventorycode = ""; - $search_product_ref = ""; - $search_product = ""; - $search_warehouse = ""; - $search_user = ""; - $search_batch = ""; - $search_qty = ''; - $search_fk_project = ""; - $search_all = ""; - $toselect = array(); - $search_array_options = array(); - } - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { - $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation + // Do we click on purge search criteria ? + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers + { + $year = ''; + $month = ''; + $search_ref = ''; + $search_movement = ""; + $search_type_mouvement = ""; + $search_inventorycode = ""; + $search_product_ref = ""; + $search_product = ""; + $search_warehouse = ""; + $search_user = ""; + $search_batch = ""; + $search_qty = ''; + $sall = ""; + $toselect = ''; + $search_array_options = array(); @@ -243,78 +176 @@ - - if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('button_search')) { - if (empty($diroutputmassaction)) { - dol_print_error(null, 'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined'); - exit; - } - - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - - $objecttmp = new $objectclass($db); - $listofobjectid = array(); - foreach ($toselect as $toselectid) { - $objecttmp = new $objectclass($db); // must create new instance because instance is saved into $listofobjectref array for future use - $result = $objecttmp->fetch($toselectid); - if ($result > 0) { - $listofobjectid[$toselectid] = $toselectid; - } - } - - $arrayofinclusion = array(); - foreach ($listofobjectref as $tmppdf) { - $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'\.pdf$'; - } - foreach ($listofobjectref as $tmppdf) { - $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'_[a-zA-Z0-9-_]+\.pdf$'; // To include PDF generated from ODX files - } - $listoffiles = dol_dir_list($uploaddir, 'all', 1, implode('|', $arrayofinclusion), '\.meta$|\.png', 'date', SORT_DESC, 0, true); - - // Define output language (Here it is not used because we do only merging existing PDF) - $outputlangs = $langs; - $newlang = ''; - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { - $newlang = GETPOST('lang_id', 'aZ09'); - } - //elseif (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && is_object($objecttmp->thirdparty)) { // On massaction, we can have several values for $objecttmp->thirdparty - // $newlang = $objecttmp->thirdparty->default_lang; - //} - if (!empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - - // Create output dir if not exists - dol_mkdir($diroutputmassaction); - - // Defined name of merged file - $filename = strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel))); - $filename = preg_replace('/\s/', '_', $filename); - - // Save merged file - /* - if ($year) { - $filename .= '_'.$year; - } - if ($month) { - $filename .= '_'.$month; - } - */ - $now = dol_now(); - $file = $diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf'; - - - // Create PDF - // TODO Create the pdf including list of movement ids found into $listofobjectid - // ... - - - if (!$error) { - $langs->load("exports"); - setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs'); - } - - $massaction = ''; - $action = ''; - } - + $uploaddir = $conf->stock->dir_output; @@ -324,20 +179,0 @@ -if ($action == 'update_extras') { - $tmpwarehouse->oldcopy = dol_clone($tmpwarehouse); - - // Fill array 'array_options' with data from update form - $ret = $extrafields->setOptionalsFromPost(null, $tmpwarehouse, GETPOST('attribute', 'restricthtml')); - if ($ret < 0) { - $error++; - } - if (!$error) { - $result = $tmpwarehouse->insertExtraFields(); - if ($result < 0) { - setEventMessages($tmpwarehouse->error, $tmpwarehouse->errors, 'errors'); - $error++; - } - } - if ($error) { - $action = 'edit_extras'; - } -} - @@ -345 +181,2 @@ -if ($action == "correct_stock") { +if ($action == "correct_stock") +{ @@ -347,3 +184 @@ - if (!empty($product_id)) { - $result = $product->fetch($product_id); - } + if (!empty($product_id)) $result = $product->fetch($product_id); @@ -353 +188,2 @@ - if (empty($product_id)) { + if (empty($product_id)) + { @@ -358 +194,2 @@ - if (!is_numeric(GETPOST("nbpiece"))) { + if (!is_numeric($_POST["nbpiece"])) + { @@ -364 +201,2 @@ - if (!$error) { + if (!$error) + { @@ -368 +206,2 @@ - if (GETPOST('projectid', 'int')) { + if (GETPOST('projectid', 'int')) + { @@ -373,7 +212,8 @@ - if ($product->hasbatch()) { - $batch = GETPOST('batch_number', 'alphanohtml'); - - //$eatby=GETPOST('eatby'); - //$sellby=GETPOST('sellby'); - $eatby = dol_mktime(0, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int')); - $sellby = dol_mktime(0, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int')); + if ($product->hasbatch()) + { + $batch = GETPOST('batch_number', 'alphanohtml'); + + //$eatby=GETPOST('eatby'); + //$sellby=GETPOST('sellby'); + $eatby = dol_mktime(0, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int')); + $sellby = dol_mktime(0, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int')); @@ -382,9 +222,7 @@ - $user, - $id, - GETPOST("nbpiece", 'int'), - GETPOST("mouvement", 'int'), - GETPOST("label", 'alphanohtml'), - price2num(GETPOST('unitprice'), 'MT'), - $eatby, - $sellby, - $batch, + $user, + $id, + GETPOST("nbpiece", 'int'), + GETPOST("mouvement"), + GETPOST("label", 'san_alpha'), + GETPOST('unitprice'), + $eatby, $sellby, $batch, @@ -392,6 +230,6 @@ - $origin_element, - $origin_id, - 0, - $extrafields - ); // We do not change value of stock for a correction - } else { + $origin_element, + $origin_id + ); // We do not change value of stock for a correction + } + else + { @@ -399,6 +237,6 @@ - $user, - $id, - GETPOST("nbpiece", 'int'), - GETPOST("mouvement", "int"), - GETPOST("label", 'alphanohtml'), - price2num(GETPOST('unitprice'), 'MT'), + $user, + $id, + GETPOST("nbpiece", 'int'), + GETPOST("mouvement"), + GETPOST("label", 'san_alpha'), + GETPOST('unitprice'), @@ -406,20 +244,19 @@ - $origin_element, - $origin_id, - 0, - $extrafields - ); // We do not change value of stock for a correction - } - - if ($result > 0) { - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; - } else { - $error++; - setEventMessages($product->error, $product->errors, 'errors'); - $action = 'correction'; - } - } - - if (!$error) { - $action = ''; - } + $origin_element, + $origin_id + ); // We do not change value of stock for a correction + } + + if ($result > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + else + { + $error++; + setEventMessages($product->error, $product->errors, 'errors'); + $action = 'correction'; + } + } + + if (!$error) $action = ''; @@ -429 +266,2 @@ -if ($action == "transfert_stock" && !$cancel) { +if ($action == "transfert_stock" && !$cancel) +{ @@ -431,10 +269,10 @@ - if (!empty($product_id)) { - $result = $product->fetch($product_id); - } - - if (!(GETPOST("id_entrepot_destination", 'int') > 0)) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); - $error++; - $action = 'transfert'; - } - if (empty($product_id)) { + if (!empty($product_id)) $result = $product->fetch($product_id); + + if (!(GETPOST("id_entrepot_destination", 'int') > 0)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); + $error++; + $action = 'transfert'; + } + if (empty($product_id)) + { @@ -445,143 +283,143 @@ - if (!GETPOST("nbpiece", 'int')) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); - $error++; - $action = 'transfert'; - } - if ($id == GETPOST("id_entrepot_destination", 'int')) { - setEventMessages($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), null, 'errors'); - $error++; - $action = 'transfert'; - } - - if (isModEnabled('productbatch')) { - $product = new Product($db); - $result = $product->fetch($product_id); - - if ($product->hasbatch() && !GETPOST("batch_number")) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); - $error++; - $action = 'transfert'; - } - } - - if (!$error) { - if ($id) { - $object = new Entrepot($db); - $result = $object->fetch($id); - - $db->begin(); - - $product->load_stock('novirtual'); // Load array product->stock_warehouse - - // Define value of products moved - $pricesrc = 0; - if (isset($product->pmp)) { - $pricesrc = $product->pmp; - } - $pricedest = $pricesrc; - - if ($product->hasbatch()) { - $pdluo = new Productbatch($db); - - if ($pdluoid > 0) { - $result = $pdluo->fetch($pdluoid); - if ($result) { - $srcwarehouseid = $pdluo->warehouseid; - $batch = $pdluo->batch; - $eatby = $pdluo->eatby; - $sellby = $pdluo->sellby; - } else { - setEventMessages($pdluo->error, $pdluo->errors, 'errors'); - $error++; - } - } else { - $srcwarehouseid = $id; - $batch = GETPOST('batch_number', 'alphanohtml'); - $eatby = $d_eatby; - $sellby = $d_sellby; - } - - if (!$error) { - // Remove stock - $result1 = $product->correct_stock_batch( - $user, - $srcwarehouseid, - GETPOST("nbpiece", 'int'), - 1, - GETPOST("label", 'san_alpha'), - $pricesrc, - $eatby, - $sellby, - $batch, - GETPOST('inventorycode'), - '', - null, - 0, - $extrafields - ); - // Add stock - $result2 = $product->correct_stock_batch( - $user, - GETPOST("id_entrepot_destination", 'int'), - GETPOST("nbpiece", 'int'), - 0, - GETPOST("label", 'san_alpha'), - $pricedest, - $eatby, - $sellby, - $batch, - GETPOST('inventorycode', 'alphanohtml'), - '', - null, - 0, - $extrafields - ); - } - } else { - // Remove stock - $result1 = $product->correct_stock( - $user, - $id, - GETPOST("nbpiece"), - 1, - GETPOST("label", 'san_alpha'), - $pricesrc, - GETPOST('inventorycode', 'alphanohtml'), - '', - null, - 0, - $extrafields - ); - - // Add stock - $result2 = $product->correct_stock( - $user, - GETPOST("id_entrepot_destination"), - GETPOST("nbpiece"), - 0, - GETPOST("label", 'san_alpha'), - $pricedest, - GETPOST('inventorycode', 'alphanohtml'), - '', - null, - 0, - $extrafields - ); - } - if (!$error && $result1 >= 0 && $result2 >= 0) { - $db->commit(); - - if ($backtopage) { - header("Location: ".$backtopage); - exit; - } else { - header("Location: movement_list.php?id=".$object->id); - exit; - } - } else { - setEventMessages($product->error, $product->errors, 'errors'); - $db->rollback(); - $action = 'transfert'; - } - } - } + if (!GETPOST("nbpiece", 'int')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); + $error++; + $action = 'transfert'; + } + if ($id == GETPOST("id_entrepot_destination", 'int')) + { + setEventMessages($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), null, 'errors'); + $error++; + $action = 'transfert'; + } + + if (!empty($conf->productbatch->enabled)) + { + $product = new Product($db); + $result = $product->fetch($product_id); + + if ($product->hasbatch() && !GETPOST("batch_number")) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); + $error++; + $action = 'transfert'; + } + } + + if (!$error) + { + if ($id) + { + $object = new Entrepot($db); + $result = $object->fetch($id); + + $db->begin(); + + $product->load_stock('novirtual'); // Load array product->stock_warehouse + + // Define value of products moved + $pricesrc = 0; + if (isset($product->pmp)) $pricesrc = $product->pmp; + $pricedest = $pricesrc; + + if ($product->hasbatch()) + { + $pdluo = new Productbatch($db); + + if ($pdluoid > 0) + { + $result = $pdluo->fetch($pdluoid); + if ($result) + { + $srcwarehouseid = $pdluo->warehouseid; + $batch = $pdluo->batch; + $eatby = $pdluo->eatby; + $sellby = $pdluo->sellby; + } + else + { + setEventMessages($pdluo->error, $pdluo->errors, 'errors'); + $error++; + } + } + else + { + $srcwarehouseid = $id; + $batch = GETPOST('batch_number', 'alphanohtml'); + $eatby = $d_eatby; + $sellby = $d_sellby; + } + + if (!$error) + { + // Remove stock + $result1 = $product->correct_stock_batch( + $user, + $srcwarehouseid, + GETPOST("nbpiece", 'int'), + 1, + GETPOST("label", 'san_alpha'), + $pricesrc, + $eatby, $sellby, $batch, + GETPOST('inventorycode') + ); + // Add stock + $result2 = $product->correct_stock_batch( + $user, + GETPOST("id_entrepot_destination", 'int'), + GETPOST("nbpiece", 'int'), + 0, + GETPOST("label", 'san_alpha'), + $pricedest, + $eatby, $sellby, $batch, + GETPOST('inventorycode', 'alphanohtml') + ); + } + } + else + { + // Remove stock + $result1 = $product->correct_stock( + $user, + $id, + GETPOST("nbpiece"), + 1, + GETPOST("label", 'san_alpha'), + $pricesrc, + GETPOST('inventorycode', 'alphanohtml') + ); + + // Add stock + $result2 = $product->correct_stock( + $user, + GETPOST("id_entrepot_destination"), + GETPOST("nbpiece"), + 0, + GETPOST("label", 'san_alpha'), + $pricedest, + GETPOST('inventorycode', 'alphanohtml') + ); + } + if (!$error && $result1 >= 0 && $result2 >= 0) + { + $db->commit(); + + if ($backtopage) + { + header("Location: ".$backtopage); + exit; + } + else + { + header("Location: movement_list.php?id=".$object->id); + exit; + } + } + else + { + setEventMessages($product->error, $product->errors, 'errors'); + $db->rollback(); + $action = 'transfert'; + } + } + } @@ -590,39 +427,0 @@ -// reverse mouvement of stock -if ($action == 'confirm_reverse' && $confirm == "yes") { - $listMouvement = array(); - $toselect = array_map('intval', $toselect); - - $sql = "SELECT rowid, label, inventorycode, datem"; - $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement"; - $sql .= " WHERE rowid IN ("; - foreach ($toselect as $id) { - $sql .= ((int) $id).","; - } - $sql = rtrim($sql, ','); - $sql .= ")"; - - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) { - $obj = $db->fetch_object($resql); - $object->fetch($obj->rowid); - $reverse = $object->reverseMouvement(); - if ($reverse < 0) { - $hasError = true; - } else { - $hasSuccess = true; - } - $i++; - } - if ($hasError) { - setEventMessages($langs->trans("WarningAlreadyReverse", $langs->transnoentities($idAlreadyReverse)), null, 'warnings'); - } - if ($hasSuccess) { - setEventMessages($langs->trans("ReverseConfirmed"), null); - } - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } -} @@ -634,6 +433 @@ -$form = new Form($db); -$formproduct = new FormProduct($db); -if (isModEnabled('project')) { - $formproject = new FormProjets($db); -} -$productlot = new Productlot($db); +$productlot = new ProductLot($db); @@ -644,5 +438,5 @@ - -$now = dol_now(); - -// Build and execute select -// -------------------------------------------------------------------- +$form = new Form($db); +$formother = new FormOther($db); +$formproduct = new FormProduct($db); +if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); + @@ -656 +450 @@ -$sql .= " u.login, u.photo, u.lastname, u.firstname, u.email as user_email, u.statut as user_status"; +$sql .= " u.login, u.photo, u.lastname, u.firstname"; @@ -659,3 +453 @@ - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); - } + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); @@ -665 +457 @@ -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook @@ -667,4 +458,0 @@ -$sql = preg_replace('/,\s*$/', '', $sql); - -$sqlfields = $sql; // $sql fields to remove for count total - @@ -674,3 +462 @@ -if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (m.rowid = ef.fk_object)"; -} +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (m.rowid = ef.fk_object)"; @@ -679,6 +464,0 @@ - -// Add table from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; - @@ -686,3 +466 @@ -if ($msid > 0) { - $sql .= " AND m.rowid = ".((int) $msid); -} +if ($msid > 0) $sql .= " AND m.rowid = ".$msid; @@ -691,51 +469,14 @@ -if (!getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { - $sql .= " AND p.fk_product_type = 0"; -} -if ($id > 0) { - $sql .= " AND e.rowid = ".((int) $id); -} -if (!empty($search_date_start)) { - $sql .= " AND m.datem >= '" . $db->idate($search_date_start) . "'"; -} -if (!empty($search_date_end)) { - $sql .= " AND m.datem <= '" . $db->idate($search_date_end) . "'"; -} -if ($idproduct > 0) { - $sql .= " AND p.rowid = ".((int) $idproduct); -} -if (!empty($search_ref)) { - $sql .= natural_search('m.rowid', $search_ref, 1); -} -if (!empty($search_movement)) { - $sql .= natural_search('m.label', $search_movement); -} -if (!empty($search_inventorycode)) { - $sql .= natural_search('m.inventorycode', $search_inventorycode); -} -if (!empty($search_product_ref)) { - $sql .= natural_search('p.ref', $search_product_ref); -} -if (!empty($search_product)) { - $sql .= natural_search('p.label', $search_product); -} -if ($search_warehouse != '' && $search_warehouse != '-1') { - $sql .= natural_search('e.rowid', $search_warehouse, 2); -} -if (!empty($search_user)) { - $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_user); -} -if (!empty($search_batch)) { - $sql .= natural_search('m.batch', $search_batch); -} -if (!empty($product_id) && $product_id != '-1') { - $sql .= natural_search('p.rowid', $product_id); -} -if (!empty($search_fk_project) && $search_fk_project != '-1') { - $sql .= natural_search('m.fk_projet', $search_fk_project); -} -if ($search_qty != '') { - $sql .= natural_search('m.value', $search_qty, 1); -} -if ($search_type_mouvement != '' && $search_type_mouvement != '-1') { - $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2); -} +if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = 0"; +if ($id > 0) $sql .= " AND e.rowid ='".$id."'"; +$sql .= dolSqlDateFilter('m.datem', 0, $month, $year); +if ($idproduct > 0) $sql .= " AND p.rowid = '".$idproduct."'"; +if (!empty($search_ref)) $sql .= natural_search('m.rowid', $search_ref, 1); +if (!empty($search_movement)) $sql .= natural_search('m.label', $search_movement); +if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $search_inventorycode); +if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref); +if (!empty($search_product)) $sql .= natural_search('p.label', $search_product); +if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('e.rowid', $search_warehouse, 2); +if (!empty($search_user)) $sql .= natural_search('u.login', $search_user); +if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch); +if ($search_qty != '') $sql .= natural_search('m.value', $search_qty, 1); +if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2); @@ -746 +487 @@ -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook @@ -748,2 +489,2 @@ - -// Count total nb of records +$sql .= $db->order($sortfield, $sortorder); + @@ -751,17 +492,9 @@ -if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); - $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); - $resql = $db->query($sqlforcount); - if ($resql) { - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; - } else { - dol_print_error($db); - } - - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0 - $page = 0; - $offset = 0; - } - $db->free($resql); +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } @@ -770,3 +503,2 @@ -// Complete request and execute it with limit -$sql .= $db->order($sortfield, $sortorder); -if ($limit) { +if (empty($search_inventorycode)) +{ @@ -774,0 +507,6 @@ +else +{ + $limit = 0; +} + +//print $sql; @@ -777,3 +515,681 @@ -if (!$resql) { - dol_print_error($db); - exit; + +if (!empty($search_inventorycode)) $limit = $db->num_rows($resql); + +if ($resql) +{ + $product = new Product($db); + $object = new Entrepot($db); + + if ($idproduct > 0) + { + $product->fetch($idproduct); + } + if ($id > 0 || $ref) + { + $result = $object->fetch($id, $ref); + if ($result < 0) + { + dol_print_error($db); + } + } + + $num = $db->num_rows($resql); + + $arrayofselected = is_array($toselect) ? $toselect : array(); + + + $i = 0; + $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; + if ($msid) $texte = $langs->trans('StockMovementForId', $msid); + else + { + $texte = $langs->trans("ListOfStockMovements"); + if ($id) $texte .= ' ('.$langs->trans("ForThisWarehouse").')'; + } + llxHeader("", $texte, $help_url); + + /* + * Show tab only if we ask a particular warehouse + */ + if ($object->id > 0) + { + $head = stock_prepare_head($object); + + dol_fiche_head($head, 'movements', $langs->trans("Warehouse"), -1, 'stock'); + + + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
'; + $morehtmlref .= $langs->trans("LocationSummary").' : '.$object->lieu; + $morehtmlref .= '
'; + + $shownav = 1; + if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + print '
'; + + print ''; + + print ''; + + // Description + print ''; + + $calcproductsunique = $object->nb_different_products(); + $calcproducts = $object->nb_products(); + + // Total nb of different products + print '"; + + // Nb of products + print '"; + + print '
'.$langs->trans("Description").''.dol_htmlentitiesbr($object->description).'
'.$langs->trans("NumberOfDifferentProducts").''; + print empty($calcproductsunique['nb']) ? '0' : $calcproductsunique['nb']; + print "
'.$langs->trans("NumberOfProducts").''; + $valtoshow = price2num($calcproducts['nb'], 'MS'); + print empty($valtoshow) ? '0' : $valtoshow; + print "
'; + + print '
'; + print '
'; + print '
'; + print '
'; + + print ''; + + // Value + print '"; + + // Last movement + $sql = "SELECT MAX(m.datem) as datem"; + $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; + $sql .= " WHERE m.fk_entrepot = '".$object->id."'"; + $resqlbis = $db->query($sql); + if ($resqlbis) + { + $objbis = $db->fetch_object($resqlbis); + $lastmovementdate = $db->jdate($objbis->datem); + } + else + { + dol_print_error($db); + } + + print '"; + + print "
'.$langs->trans("EstimatedStockValueShort").''; + print price((empty($calcproducts['value']) ? '0' : price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency); + print "
'.$langs->trans("LastMovement").''; + if ($lastmovementdate) + { + print dol_print_date($lastmovementdate, 'dayhour'); + } + else + { + print $langs->trans("None"); + } + print "
"; + + print '
'; + print '
'; + print '
'; + + print '
'; + + dol_fiche_end(); + } + + + /* + * Correct stock + */ + if ($action == "correction") + { + include DOL_DOCUMENT_ROOT.'/product/stock/tpl/stockcorrection.tpl.php'; + print '
'; + } + + /* + * Transfer of units + */ + if ($action == "transfert") + { + include DOL_DOCUMENT_ROOT.'/product/stock/tpl/stocktransfer.tpl.php'; + print '
'; + } + + + /* ************************************************************************** */ + /* */ + /* Barre d'action */ + /* */ + /* ************************************************************************** */ + + if ((empty($action) || $action == 'list') && $id > 0) + { + print "
\n"; + + if ($user->rights->stock->mouvement->creer) + { + print ''.$langs->trans("CorrectStock").''; + } + + if ($user->rights->stock->mouvement->creer) + { + print ''.$langs->trans("TransferStock").''; + } + + print '

'; + } + + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($id > 0) $param .= '&id='.urlencode($id); + if ($search_movement) $param .= '&search_movement='.urlencode($search_movement); + if ($search_inventorycode) $param .= '&search_inventorycode='.urlencode($search_inventorycode); + if ($search_type_mouvement) $param .= '&search_type_mouvement='.urlencode($search_type_mouvement); + if ($search_product_ref) $param .= '&search_product_ref='.urlencode($search_product_ref); + if ($search_product) $param .= '&search_product='.urlencode($search_product); + if ($search_batch) $param .= '&search_batch='.urlencode($search_batch); + if ($search_warehouse > 0) $param .= '&search_warehouse='.urlencode($search_warehouse); + if ($search_user) $param .= '&search_user='.urlencode($search_user); + if ($idproduct > 0) $param .= '&idproduct='.urlencode($idproduct); + // Add $param from extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + + // List of mass actions available + $arrayofmassactions = array( + // 'presend'=>$langs->trans("SendByMail"), + // 'builddoc'=>$langs->trans("PDFMerge"), + ); + // By default, we should never accept deletion of stock movement. + if (!empty($conf->global->STOCK_ALLOW_DELETE_OF_MOVEMENT) && $permissiontodelete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); + if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); + + print '
'; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($id > 0) print ''; + + if ($id > 0) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'stock', 0, '', '', $limit, 0, 0, 1); + else print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'stock', 0, '', '', $limit, 0, 0, 1); + + // Add code for pre mass action (confirmation or email presend form) + $topicmail = "SendStockMovement"; + $modelmail = "movementstock"; + $objecttmp = new MouvementStock($db); + $trackid = 'mov'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + + if ($sall) + { + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; + } + + $moreforfilter = ''; + + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; + else $moreforfilter = $hookmanager->resPrint; + + if (!empty($moreforfilter)) + { + print '
'; + print $moreforfilter; + print '
'; + } + + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + + print '
'; + print ''."\n"; + + // Fields title search + print ''; + if (!empty($arrayfields['m.rowid']['checked'])) + { + // Ref + print ''; + } + if (!empty($arrayfields['m.datem']['checked'])) + { + // Date + print ''; + } + if (!empty($arrayfields['p.ref']['checked'])) + { + // Product Ref + print ''; + } + if (!empty($arrayfields['p.label']['checked'])) + { + // Product label + print ''; + } + // Batch + if (!empty($arrayfields['m.batch']['checked'])) + { + print ''; + } + if (!empty($arrayfields['pl.eatby']['checked'])) + { + print ''; + } + if (!empty($arrayfields['pl.sellby']['checked'])) + { + print ''; + } + // Warehouse + if (!empty($arrayfields['e.ref']['checked'])) + { + print ''; + } + if (!empty($arrayfields['m.fk_user_author']['checked'])) + { + // Author + print ''; + } + if (!empty($arrayfields['m.inventorycode']['checked'])) + { + // Inventory code + print ''; + } + if (!empty($arrayfields['m.label']['checked'])) + { + // Label of movement + print ''; + } + if (!empty($arrayfields['m.type_mouvement']['checked'])) + { + // Type of movement + print ''; + } + if (!empty($arrayfields['origin']['checked'])) + { + // Origin of movement + print ''; + } + if (!empty($arrayfields['m.value']['checked'])) + { + // Qty + print ''; + } + if (!empty($arrayfields['m.price']['checked'])) + { + // Price + print ''; + } + if (!empty($arrayfields['m.fk_projet']['checked'])) + { + // fk_project + print ''; + } + + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['m.datec']['checked'])) + { + print ''; + } + // Date modification + if (!empty($arrayfields['m.tms']['checked'])) + { + print ''; + } + // Actions + print ''; + print "\n"; + + print ''; + if (!empty($arrayfields['m.rowid']['checked'])) { + print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['m.datem']['checked'])) { + print_liste_field_titre($arrayfields['m.datem']['label'], $_SERVER["PHP_SELF"], 'm.datem', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['p.ref']['checked'])) { + print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['p.label']['checked'])) { + print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['m.batch']['checked'])) { + print_liste_field_titre($arrayfields['m.batch']['label'], $_SERVER["PHP_SELF"], 'm.batch', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['pl.eatby']['checked'])) { + print_liste_field_titre($arrayfields['pl.eatby']['label'], $_SERVER["PHP_SELF"], 'pl.eatby', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['pl.sellby']['checked'])) { + print_liste_field_titre($arrayfields['pl.sellby']['label'], $_SERVER["PHP_SELF"], 'pl.sellby', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['e.ref']['checked'])) { + // We are on a specific warehouse card, no filter on other should be possible + print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder); + } + if (!empty($arrayfields['m.fk_user_author']['checked'])) { + print_liste_field_titre($arrayfields['m.fk_user_author']['label'], $_SERVER["PHP_SELF"], "m.fk_user_author", "", $param, "", $sortfield, $sortorder); + } + if (!empty($arrayfields['m.inventorycode']['checked'])) { + print_liste_field_titre($arrayfields['m.inventorycode']['label'], $_SERVER["PHP_SELF"], "m.inventorycode", "", $param, "", $sortfield, $sortorder); + } + if (!empty($arrayfields['m.label']['checked'])) { + print_liste_field_titre($arrayfields['m.label']['label'], $_SERVER["PHP_SELF"], "m.label", "", $param, "", $sortfield, $sortorder); + } + if (!empty($arrayfields['m.type_mouvement']['checked'])) { + print_liste_field_titre($arrayfields['m.type_mouvement']['label'], $_SERVER["PHP_SELF"], "m.type_mouvement", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['origin']['checked'])) { + print_liste_field_titre($arrayfields['origin']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); + } + if (!empty($arrayfields['m.value']['checked'])) { + print_liste_field_titre($arrayfields['m.value']['label'], $_SERVER["PHP_SELF"], "m.value", "", $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['m.price']['checked'])) { + print_liste_field_titre($arrayfields['m.price']['label'], $_SERVER["PHP_SELF"], "m.price", "", $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['m.fk_projet']['checked'])) { + print_liste_field_titre($arrayfields['m.fk_projet']['label'], $_SERVER["PHP_SELF"], "m.fk_projet", "", $param, 'align="right"', $sortfield, $sortorder); + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + + // Hook fields + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (!empty($arrayfields['m.datec']['checked'])) { + print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + if (!empty($arrayfields['m.tms']['checked'])) { + print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + print "\n"; + + + $arrayofuniqueproduct = array(); + + $i = 0; + $totalarray = array(); + while ($i < min($num, $limit)) + { + $objp = $db->fetch_object($resql); + + $userstatic->id = $objp->fk_user_author; + $userstatic->login = $objp->login; + $userstatic->lastname = $objp->lastname; + $userstatic->firstname = $objp->firstname; + $userstatic->photo = $objp->photo; + + $productstatic->id = $objp->rowid; + $productstatic->ref = $objp->product_ref; + $productstatic->label = $objp->produit; + $productstatic->type = $objp->type; + $productstatic->entity = $objp->entity; + $productstatic->status = $objp->tosell; + $productstatic->status_buy = $objp->tobuy; + $productstatic->status_batch = $objp->tobatch; + + $productlot->id = $objp->lotid; + $productlot->batch = $objp->batch; + $productlot->eatby = $objp->eatby; + $productlot->sellby = $objp->sellby; + + $warehousestatic->id = $objp->entrepot_id; + $warehousestatic->ref = $objp->warehouse_ref; + $warehousestatic->libelle = $objp->warehouse_ref; // deprecated + $warehousestatic->label = $objp->warehouse_ref; + $warehousestatic->lieu = $objp->lieu; + $warehousestatic->fk_parent = $objp->fk_parent; + $warehousestatic->statut = $objp->statut; + + $arrayofuniqueproduct[$objp->rowid] = $objp->produit; + if (!empty($objp->fk_origin)) { + $origin = $movement->get_origin($objp->fk_origin, $objp->origintype); + } else { + $origin = ''; + } + + print ''; + // Id movement + if (!empty($arrayfields['m.rowid']['checked'])) + { + print ''; // This is primary not movement id + } + if (!empty($arrayfields['m.datem']['checked'])) + { + // Date + print ''; + } + if (!empty($arrayfields['p.ref']['checked'])) + { + // Product ref + print '\n"; + } + if (!empty($arrayfields['p.label']['checked'])) + { + // Product label + print '\n"; + } + if (!empty($arrayfields['m.batch']['checked'])) + { + print ''; + } + if (!empty($arrayfields['pl.eatby']['checked'])) + { + print ''; + } + if (!empty($arrayfields['pl.sellby']['checked'])) + { + print ''; + } + // Warehouse + if (!empty($arrayfields['e.ref']['checked'])) + { + print '\n"; + } + // Author + if (!empty($arrayfields['m.fk_user_author']['checked'])) + { + print '\n"; + } + if (!empty($arrayfields['m.inventorycode']['checked'])) + { + // Inventory code + print ''; + } + if (!empty($arrayfields['m.label']['checked'])) + { + // Label of movement + print ''; + } + if (!empty($arrayfields['m.type_mouvement']['checked'])) + { + // Type of movement + switch ($objp->type_mouvement) { + case "0": + print ''; + break; + case "1": + print ''; + break; + case "2": + print ''; + break; + case "3": + print ''; + break; + } + } + if (!empty($arrayfields['origin']['checked'])) + { + // Origin of movement + print ''; + } + if (!empty($arrayfields['m.value']['checked'])) + { + // Qty + print ''; + } + if (!empty($arrayfields['m.price']['checked'])) + { + // Price + print ''; + } + if (!empty($arrayfields['m.fk_projet']['checked'])) + { + // fk_project + print ''; + } + // Action column + print ''; + if (!$i) $totalarray['nbfield']++; + + print "\n"; + $i++; + } + $db->free($resql); + + print "
'; + print ''; + print ''; + print ''; + if (empty($conf->productbatch->enabled)) print ' '; + //else print '
'; + $syear = $year ? $year : -1; + print ''; + //print $formother->selectyear($syear,'year',1, 20, 5); + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200'); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print ''; + print ajax_combobox('search_type_mouvement'); + // TODO: add new function $formentrepot->selectTypeOfMovement(...) like + // print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200'); + print ''; + print '  '; + print ''; + print ''; + print ''; + print '  '; + print ''; + print '  '; + print ''; + print ''; + print ''; + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print '
'.$objp->mid.''.dol_print_date($db->jdate($objp->datem), 'dayhour', 'tzuserrel').''; + print $productstatic->getNomUrl(1, 'stock', 16); + print "'; + /*$productstatic->id=$objp->rowid; + $productstatic->ref=$objp->produit; + $productstatic->type=$objp->type; + print $productstatic->getNomUrl(1,'',16);*/ + print $productstatic->label; + print "'; + if ($productlot->id > 0) print $productlot->getNomUrl(1); + else print $productlot->batch; // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement. + print ''.dol_print_date($objp->eatby, 'day').''.dol_print_date($objp->sellby, 'day').''; + print $warehousestatic->getNomUrl(1); + print "'; + print $userstatic->getNomUrl(-1); + print "'.$objp->inventorycode.''.$objp->label.''.$langs->trans('StockIncreaseAfterCorrectTransfer').''.$langs->trans('StockDecreaseAfterCorrectTransfer').''.$langs->trans('StockDecrease').''.$langs->trans('StockIncrease').''.$origin.''; + if ($objp->qt > 0) print '+'; + print $objp->qty; + print ''; + if ($objp->price != 0) print price($objp->price); + print ''; + if ($objp->fk_project != 0) print $movement->get_origin($objp->fk_project, 'project'); + print ''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected = 0; + if (in_array($objp->mid, $arrayofselected)) $selected = 1; + print ''; + } + print '
"; + print '
'; + print "
"; + + // Add number of product when there is a filter on period + if (count($arrayofuniqueproduct) == 1 && is_numeric($year)) + { + print "
"; + + $productidselected = 0; + foreach ($arrayofuniqueproduct as $key => $val) + { + $productidselected = $key; + $productlabelselected = $val; + } + $datebefore = dol_get_first_day($year ? $year : strftime("%Y", time()), $month ? $month : 1, true); + $dateafter = dol_get_last_day($year ? $year : strftime("%Y", time()), $month ? $month : 12, true); + $balancebefore = $movement->calculateBalanceForProductBefore($productidselected, $datebefore); + $balanceafter = $movement->calculateBalanceForProductBefore($productidselected, $dateafter); + + //print ''; + print $langs->trans("NbOfProductBeforePeriod", $productlabelselected, dol_print_date($datebefore, 'day', 'gmt')); + //print ''; + //print ''; + print ': '.$balancebefore; + print "
\n"; + //print ''; + //print ''; + print $langs->trans("NbOfProductAfterPeriod", $productlabelselected, dol_print_date($dateafter, 'day', 'gmt')); + //print ''; + //print ''; + print ': '.$balanceafter; + print "
\n"; + //print ''; + } @@ -781,9 +1197,3 @@ - -$num = $db->num_rows($resql); - - -$product = new Product($db); -$object = new Entrepot($db); - -if ($idproduct > 0) { - $product->fetch($idproduct); +else +{ + dol_print_error($db); @@ -791,894 +1201 @@ -if ($id > 0 || $ref) { - $result = $object->fetch($id, $ref); - if ($result < 0) { - dol_print_error($db); - } -} - - -// Output page -// -------------------------------------------------------------------- - -$i = 0; -$help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; -if ($msid) { - $title = $langs->trans('StockMovementForId', $msid); -} else { - $title = $langs->trans("ListOfStockMovements"); - if ($id) { - if (!empty($object->ref)) { - $title .= ' ('.$object->ref.')'; - } else { - $title .= ' ('.$langs->trans("ForThisWarehouse").')'; - } - } -} - - -// Output page -// -------------------------------------------------------------------- - -llxHeader('', $title, $help_url); - -/* - * Show tab only if we ask a particular warehouse - */ -if ($object->id > 0) { - $head = stock_prepare_head($object); - - print dol_get_fiche_head($head, 'movements', $langs->trans("Warehouse"), -1, 'stock'); - - - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
'; - $morehtmlref .= $langs->trans("LocationSummary").' : '.$object->lieu; - - // Project - if (isModEnabled('project')) { - $langs->load("projects"); - $morehtmlref .= '
'.img_picto('', 'project').' '.$langs->trans('Project').' '; - if ($usercancreate && 1 == 2) { - if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; - } - if ($action == 'classify') { - $projectid = $object->fk_project; - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ' : '.$proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.$proj->title; - } - } else { - $morehtmlref .= ''; - } - } - } - $morehtmlref .= '
'; - - $shownav = 1; - if ($user->socid && !in_array('stock', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) { - $shownav = 0; - } - - dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref); - - - print '
'; - print '
'; - print '
'; - - print ''; - - print ''; - - // Description - print ''; - - $calcproductsunique = $object->nb_different_products(); - $calcproducts = $object->nb_products(); - - // Total nb of different products - print '"; - - // Nb of products - print '"; - - print '
'.$langs->trans("Description").''.dol_htmlentitiesbr($object->description).'
'.$langs->trans("NumberOfDifferentProducts").''; - print empty($calcproductsunique['nb']) ? '0' : $calcproductsunique['nb']; - print "
'.$langs->trans("NumberOfProducts").''; - $valtoshow = price2num($calcproducts['nb'], 'MS'); - print empty($valtoshow) ? '0' : $valtoshow; - print "
'; - - print '
'; - print '
'; - print '
'; - - print ''; - - // Value - print '"; - - // Last movement - $sql = "SELECT MAX(m.datem) as datem"; - $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; - $sql .= " WHERE m.fk_entrepot = ".((int) $object->id); - $resqlbis = $db->query($sql); - if ($resqlbis) { - $objbis = $db->fetch_object($resqlbis); - $lastmovementdate = $db->jdate($objbis->datem); - } else { - dol_print_error($db); - } - - print '"; - - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - - // Categories - if (isModEnabled('categorie')) { - print '"; - } - - print "
'.$langs->trans("EstimatedStockValueShort").''; - print price((empty($calcproducts['value']) ? '0' : price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency); - print "
'.$langs->trans("LastMovement").''; - if ($lastmovementdate) { - print dol_print_date($lastmovementdate, 'dayhour'); - } else { - print $langs->trans("None"); - } - print "
'.$langs->trans("Categories").''; - print $form->showCategories($object->id, Categorie::TYPE_WAREHOUSE, 1); - print "
"; - - print '
'; - print '
'; - - print '
'; - - print dol_get_fiche_end(); -} - - -// Correct stock -if ($action == "correction") { - include DOL_DOCUMENT_ROOT.'/product/stock/tpl/stockcorrection.tpl.php'; - print '
'; -} - -// Transfer of units -if ($action == "transfert") { - include DOL_DOCUMENT_ROOT.'/product/stock/tpl/stocktransfer.tpl.php'; - print '
'; -} - - -// Action bar -if ((empty($action) || $action == 'list') && $id > 0) { - print "
\n"; - - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been - // modified by hook - if (empty($reshook)) { - if ($user->hasRight('stock', 'mouvement', 'creer')) { - print ''.$langs->trans("CorrectStock").''; - } - - if ($user->hasRight('stock', 'mouvement', 'creer')) { - print ''.$langs->trans("TransferStock").''; - } - } - - print '

'; -} - -$arrayofselected = is_array($toselect) ? $toselect : array(); - -$param = ''; -if (!empty($mode)) { - $param .= '&mode='.urlencode($mode); -} -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); -} -if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); -} -if ($id > 0) { - $param .= '&id='.urlencode($id); -} -if ($search_date_startday) { - $param .= '&search_date_startday='.urlencode($search_date_startday); -} -if ($search_date_startmonth) { - $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); -} -if ($search_date_startyear) { - $param .= '&search_date_startyear='.urlencode($search_date_startyear); -} -if ($search_date_endday) { - $param .= '&search_date_endday='.urlencode($search_date_endday); -} -if ($search_date_endmonth) { - $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); -} -if ($search_date_endyear) { - $param .= '&search_date_endyear='.urlencode($search_date_endyear); -} -if ($search_movement) { - $param .= '&search_movement='.urlencode($search_movement); -} -if ($search_inventorycode) { - $param .= '&search_inventorycode='.urlencode($search_inventorycode); -} -if ($search_type_mouvement) { - $param .= '&search_type_mouvement='.urlencode($search_type_mouvement); -} -if ($search_product_ref) { - $param .= '&search_product_ref='.urlencode($search_product_ref); -} -if ($search_product) { - $param .= '&search_product='.urlencode($search_product); -} -if ($search_batch) { - $param .= '&search_batch='.urlencode($search_batch); -} -if ($search_warehouse > 0) { - $param .= '&search_warehouse='.urlencode($search_warehouse); -} -if ($search_user) { - $param .= '&search_user='.urlencode($search_user); -} -if ($idproduct > 0) { - $param .= '&idproduct='.urlencode($idproduct); -} -if ($search_fk_project != '' && $search_fk_project != '-1') { - $param .= '&search_fk_project='.urlencode($search_fk_project); -} -// Add $param from extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; -// Add $param from hooks -$parameters = array('param' => &$param); -$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -$param .= $hookmanager->resPrint; - -// List of mass actions available -$arrayofmassactions = array(); -if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { - $arrayofmassactions['builddoc'] = img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("GeneratePDF"); -} -// By default, we should never accept deletion of stock movement -if (getDolGlobalString('STOCK_ALLOW_DELETE_OF_MOVEMENT') && $permissiontodelete) { - $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); -} -if (!empty($permissiontoadd)) { - $arrayofmassactions['prereverse'] = img_picto('', 'add', 'class="pictofixedwidth"').$langs->trans("Reverse"); -} -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'prereverse'))) { - $arrayofmassactions = array(); -} - -$massactionbutton = $form->selectMassAction('', $arrayofmassactions); - -print '
'."\n"; -if ($optioncss != '') { - print ''; -} -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -if ($id > 0) { - print ''; -} - - -$newcardbutton = ''; - -if ($id > 0) { - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'movement', 0, '', '', $limit, 0, 0, 1); -} else { - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'movement', 0, '', '', $limit, 0, 0, 1); -} - -// Add code for pre mass action (confirmation or email presend form) -$topicmail = "SendStockMovement"; -$modelmail = "movementstock"; -$objecttmp = new MouvementStock($db); -$trackid = 'mov'.$object->id; -include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($massaction == 'prereverse') { - print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassReverse"), $langs->trans("ConfirmMassReverseQuestion", count($toselect)), "confirm_reverse", null, '', 0, 200, 500, 1, 'Yes'); -} - - -if ($search_all) { - $setupstring = ''; - foreach ($fieldstosearchall as $key => $val) { - $fieldstosearchall[$key] = $langs->trans($val); - $setupstring .= $key."=".$val.";"; - } - print ''."\n"; - print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n"; -} - -$moreforfilter = ''; - -$parameters = array('arrayfields'=>&$arrayfields); -$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -if (empty($reshook)) { - $moreforfilter .= $hookmanager->resPrint; -} else { - $moreforfilter = $hookmanager->resPrint; -} - -if (!empty($moreforfilter)) { - print '
'; - print $moreforfilter; - print '
'; -} - -$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields -$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); - -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print ''."\n"; - -// Fields title search -// -------------------------------------------------------------------- -print ''; -// Action column -if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; -} -if (!empty($arrayfields['m.rowid']['checked'])) { - // Ref - print ''; -} -if (!empty($arrayfields['m.datem']['checked'])) { - // Date - print ''; -} -if (!empty($arrayfields['p.ref']['checked'])) { - // Product Ref - print ''; -} -if (!empty($arrayfields['p.label']['checked'])) { - // Product label - print ''; -} -// Batch -if (!empty($arrayfields['m.batch']['checked'])) { - print ''; -} -if (!empty($arrayfields['pl.eatby']['checked'])) { - print ''; -} -if (!empty($arrayfields['pl.sellby']['checked'])) { - print ''; -} -// Warehouse -if (!empty($arrayfields['e.ref']['checked'])) { - print ''; -} -if (!empty($arrayfields['m.fk_user_author']['checked'])) { - // Author - print ''; -} -if (!empty($arrayfields['m.inventorycode']['checked'])) { - // Inventory code - print ''; -} -if (!empty($arrayfields['m.label']['checked'])) { - // Label of movement - print ''; -} -if (!empty($arrayfields['origin']['checked'])) { - // Origin of movement - print ''; -} -if (!empty($arrayfields['m.fk_projet']['checked'])) { - // fk_project - print ''; -} -if (!empty($arrayfields['m.type_mouvement']['checked'])) { - // Type of movement - print ''; -} -if (!empty($arrayfields['m.value']['checked'])) { - // Qty - print ''; -} -if (!empty($arrayfields['m.price']['checked'])) { - // Price - print ''; -} - -// Extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; - -// Fields from hook -$parameters = array('arrayfields'=>$arrayfields); -$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; -// Date creation -if (!empty($arrayfields['m.datec']['checked'])) { - print ''; -} -// Date modification -if (!empty($arrayfields['m.tms']['checked'])) { - print ''; -} -// Action column -if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; -} -print ''."\n"; - -$totalarray = array(); -$totalarray['nbfield'] = 0; - -// Fields title label -// -------------------------------------------------------------------- -print ''; -// Action column -if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; - $totalarray['nbfield']++; -} -if (!empty($arrayfields['m.rowid']['checked'])) { - print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder); -} -if (!empty($arrayfields['m.datem']['checked'])) { - print_liste_field_titre($arrayfields['m.datem']['label'], $_SERVER["PHP_SELF"], 'm.datem', '', $param, '', $sortfield, $sortorder, 'center '); -} -if (!empty($arrayfields['p.ref']['checked'])) { - print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); -} -if (!empty($arrayfields['p.label']['checked'])) { - print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder); -} -if (!empty($arrayfields['m.batch']['checked'])) { - print_liste_field_titre($arrayfields['m.batch']['label'], $_SERVER["PHP_SELF"], 'm.batch', '', $param, '', $sortfield, $sortorder, 'center '); -} -if (!empty($arrayfields['pl.eatby']['checked'])) { - print_liste_field_titre($arrayfields['pl.eatby']['label'], $_SERVER["PHP_SELF"], 'pl.eatby', '', $param, '', $sortfield, $sortorder, 'center '); -} -if (!empty($arrayfields['pl.sellby']['checked'])) { - print_liste_field_titre($arrayfields['pl.sellby']['label'], $_SERVER["PHP_SELF"], 'pl.sellby', '', $param, '', $sortfield, $sortorder, 'center '); -} -if (!empty($arrayfields['e.ref']['checked'])) { - // We are on a specific warehouse card, no filter on other should be possible - print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder); -} -if (!empty($arrayfields['m.fk_user_author']['checked'])) { - print_liste_field_titre($arrayfields['m.fk_user_author']['label'], $_SERVER["PHP_SELF"], "m.fk_user_author", "", $param, "", $sortfield, $sortorder); -} -if (!empty($arrayfields['m.inventorycode']['checked'])) { - print_liste_field_titre($arrayfields['m.inventorycode']['label'], $_SERVER["PHP_SELF"], "m.inventorycode", "", $param, "", $sortfield, $sortorder); -} -if (!empty($arrayfields['m.label']['checked'])) { - print_liste_field_titre($arrayfields['m.label']['label'], $_SERVER["PHP_SELF"], "m.label", "", $param, "", $sortfield, $sortorder); -} -if (!empty($arrayfields['origin']['checked'])) { - print_liste_field_titre($arrayfields['origin']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); -} -if (!empty($arrayfields['m.fk_projet']['checked'])) { - print_liste_field_titre($arrayfields['m.fk_projet']['label'], $_SERVER["PHP_SELF"], "m.fk_projet", "", $param, '', $sortfield, $sortorder); -} -if (!empty($arrayfields['m.type_mouvement']['checked'])) { - print_liste_field_titre($arrayfields['m.type_mouvement']['label'], $_SERVER["PHP_SELF"], "m.type_mouvement", "", $param, '', $sortfield, $sortorder, 'center '); -} -if (!empty($arrayfields['m.value']['checked'])) { - print_liste_field_titre($arrayfields['m.value']['label'], $_SERVER["PHP_SELF"], "m.value", "", $param, '', $sortfield, $sortorder, 'right '); -} -if (!empty($arrayfields['m.price']['checked'])) { - print_liste_field_titre($arrayfields['m.price']['label'], $_SERVER["PHP_SELF"], "m.price", "", $param, '', $sortfield, $sortorder, 'right '); -} - -// Extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; - -// Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); -$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; -if (!empty($arrayfields['m.datec']['checked'])) { - print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -} -if (!empty($arrayfields['m.tms']['checked'])) { - print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -} -// Action column -if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; - $totalarray['nbfield']++; -} -print ''."\n"; - - -$arrayofuniqueproduct = array(); - - -// Loop on record -// -------------------------------------------------------------------- -$i = 0; -$savnbfield = $totalarray['nbfield']; -$totalarray = array(); -$totalarray['nbfield'] = 0; -$imaxinloop = ($limit ? min($num, $limit) : $num); -while ($i < $imaxinloop) { - $obj = $db->fetch_object($resql); - if (empty($obj)) { - break; // Should not happen - } - - $userstatic->id = $obj->fk_user_author; - $userstatic->login = $obj->login; - $userstatic->lastname = $obj->lastname; - $userstatic->firstname = $obj->firstname; - $userstatic->photo = $obj->photo; - $userstatic->email = $obj->user_email; - $userstatic->statut = $obj->user_status; - - // Multilangs - if (getDolGlobalInt('MAIN_MULTILANGS')) { // If multilang is enabled - // TODO Use a cache - $sql = "SELECT label"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql .= " WHERE fk_product = ".((int) $obj->rowid); - $sql .= " AND lang = '".$db->escape($langs->getDefaultLang())."'"; - $sql .= " LIMIT 1"; - - $result = $db->query($sql); - if ($result) { - $objtp = $db->fetch_object($result); - if (!empty($objtp->label)) { - $obj->produit = $objtp->label; - } - } - } - - $productstatic->id = $obj->rowid; - $productstatic->ref = $obj->product_ref; - $productstatic->label = $obj->produit; - $productstatic->type = $obj->type; - $productstatic->entity = $obj->entity; - $productstatic->status = $obj->tosell; - $productstatic->status_buy = $obj->tobuy; - $productstatic->status_batch = $obj->tobatch; - - $productlot->id = $obj->lotid; - $productlot->batch = $obj->batch; - $productlot->eatby = $obj->eatby; - $productlot->sellby = $obj->sellby; - - $warehousestatic->id = $obj->entrepot_id; - $warehousestatic->ref = $obj->warehouse_ref; - $warehousestatic->label = $obj->warehouse_ref; - $warehousestatic->lieu = $obj->lieu; - $warehousestatic->fk_parent = $obj->fk_parent; - $warehousestatic->statut = $obj->statut; - - $movement->type = $obj->type_mouvement; - - $arrayofuniqueproduct[$obj->rowid] = $obj->produit; - if (!empty($obj->fk_origin)) { - $origin = $movement->get_origin($obj->fk_origin, $obj->origintype); - } else { - $origin = ''; - } - - if ($mode == 'kanban') { - if ($i == 0) { - print ''; - } - } else { - // Show here line of result - $j = 0; - print ''; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Id movement - if (!empty($arrayfields['m.rowid']['checked'])) { - print ''; // This is primary not movement id - } - if (!empty($arrayfields['m.datem']['checked'])) { - // Date - print ''; - } - if (!empty($arrayfields['p.ref']['checked'])) { - // Product ref - print '\n"; - } - if (!empty($arrayfields['p.label']['checked'])) { - // Product label - print '\n"; - } - if (!empty($arrayfields['m.batch']['checked'])) { - print ''; - } - if (!empty($arrayfields['pl.eatby']['checked'])) { - print ''; - } - if (!empty($arrayfields['pl.sellby']['checked'])) { - print ''; - } - // Warehouse - if (!empty($arrayfields['e.ref']['checked'])) { - print '\n"; - } - // Author - if (!empty($arrayfields['m.fk_user_author']['checked'])) { - print '\n"; - } - if (!empty($arrayfields['m.inventorycode']['checked'])) { - // Inventory code - print ''; - } - if (!empty($arrayfields['m.label']['checked'])) { - // Label of movement - print ''; - } - if (!empty($arrayfields['origin']['checked'])) { - // Origin of movement - print ''; - } - if (!empty($arrayfields['m.fk_projet']['checked'])) { - // fk_project - print ''; - } - if (!empty($arrayfields['m.type_mouvement']['checked'])) { - // Type of movement - print ''; - } - if (!empty($arrayfields['m.value']['checked'])) { - // Qty - print ''; - } - if (!empty($arrayfields['m.price']['checked'])) { - // Price - print ''; - } - - // Extra fields - $object = $movement; - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - print ''."\n"; - } - - $i++; -} - -// If no record found -if ($num == 0) { - $colspan = 1; - foreach ($arrayfields as $key => $val) { - if (!empty($val['checked'])) { - $colspan++; - } - } - print ''; -} - -$db->free($resql); - -$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; - -print '
'; - $searchpicto = $form->showFilterButtons('left'); - print $searchpicto; - print ''; - print ''; - print ''; - print '
'; - print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'), 'tzuserrel'); - print '
'; - print '
'; - print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'), 'tzuserrel'); - print '
'; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - //print ''; - print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200'); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '  '; - print ''; - print $object->showInputField($object->fields['fk_project'], 'fk_project', $search_fk_project, '', '', 'search_', 'maxwidth125', 1); - print ''; - //print ''; - print ''; - print ajax_combobox('search_type_mouvement'); - // TODO: add new function $formentrepot->selectTypeOfMovement(...) like - // print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200'); - print ''; - print ''; - print ''; - print '  '; - print ''; - print ''; - print ''; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print '
'; - print '
'; - } - // Output Kanban - $selected = -1; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($object->id, $arrayofselected)) { - $selected = 1; - } - } - print $object->getKanbanView('', array('selected' => $selected)); - if ($i == ($imaxinloop - 1)) { - print '
'; - print '
'; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->mid, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print ''; - print img_picto($langs->trans("StockMovement"), 'movement', 'class="pictofixedwidth"'); - print $obj->mid; - print ''.dol_print_date($db->jdate($obj->datem), 'dayhour', 'tzuserrel').''; - print $productstatic->getNomUrl(1, 'stock', 16); - print "'; - print $productstatic->label; - print "'; - if ($productlot->id > 0) { - print $productlot->getNomUrl(1); - } else { - print $productlot->batch; // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement. - } - print ''.dol_print_date($obj->eatby, 'day').''.dol_print_date($obj->sellby, 'day').''; - print $warehousestatic->getNomUrl(1); - print "'; - print $userstatic->getNomUrl(-1); - print "inventorycode.'$').'">'.dol_escape_htmltag($obj->inventorycode).''.dol_escape_htmltag($obj->label).''.$origin.''; - if ($obj->fk_project != 0) { - print $movement->get_origin($obj->fk_project, 'project'); - } - print ''; - print $movement->getTypeMovement(); - print ''; - if ($obj->qty > 0) { - print ''; - print '+'; - print $obj->qty; - print ''; - } else { - print ''; - print $obj->qty; - print ''; - } - print ''; - if ($obj->price != 0) { - print price($obj->price); - } - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->mid, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print '
'.$langs->trans("NoRecordFound").'
'."\n"; -print '
'."\n"; - -print '
'."\n"; - -// Add number of product when there is a filter on period -if (count($arrayofuniqueproduct) == 1 && !empty($year) && is_numeric($year)) { - print "
"; - - $productidselected = 0; - foreach ($arrayofuniqueproduct as $key => $val) { - $productidselected = $key; - $productlabelselected = $val; - } - $datebefore = dol_get_first_day($year ? $year : strftime("%Y", time()), $month ? $month : 1, true); - $dateafter = dol_get_last_day($year ? $year : strftime("%Y", time()), $month ? $month : 12, true); - $balancebefore = $movement->calculateBalanceForProductBefore($productidselected, $datebefore); - $balanceafter = $movement->calculateBalanceForProductBefore($productidselected, $dateafter); - - //print ''; - print $langs->trans("NbOfProductBeforePeriod", $productlabelselected, dol_print_date($datebefore, 'day', 'gmt')); - //print ''; - //print ''; - print ': '.$balancebefore; - print "
\n"; - //print ''; - //print ''; - print $langs->trans("NbOfProductAfterPeriod", $productlabelselected, dol_print_date($dateafter, 'day', 'gmt')); - //print ''; - //print ''; - print ': '.$balanceafter; - print "
\n"; - //print ''; -} - -if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { - $hidegeneratedfilelistifempty = 0; - } - - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; - $formfile = new FormFile($db); - - // Show list of available documents - $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource .= str_replace('&', '&', $param); - - $filedir = $diroutputmassaction; - $genallowed = $permissiontoread; - $delallowed = $permissiontoadd; - - print $formfile->showdocuments('massfilesarea_'.$object->module, '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); -} + --- /tmp/dsg/dolibarr/htdocs/product/stock/github_19.0.3_product.php +++ /tmp/dsg/dolibarr/htdocs/product/stock/client_product.php @@ -2,11 +2,10 @@ -/* Copyright (C) 2001-2007 Rodolphe Quiedeville - * Copyright (C) 2004-2020 Laurent Destailleur - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005 Simon TOSSER - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2013 Cédric Salvador - * Copyright (C) 2013-2018 Juanjo Menent - * Copyright (C) 2014-2015 Cédric Gross - * Copyright (C) 2015 Marcos García - * Copyright (C) 2018-2019 Frédéric France - * Copyright (C) 2021 Gauthier VERDOL +/* Copyright (C) 2001-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005 Simon TOSSER + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2013-2018 Juanjo Menent + * Copyright (C) 2014-2015 Cédric Gross + * Copyright (C) 2015 Marcos García + * Copyright (C) 2018-2019 Frédéric France @@ -34 +32,0 @@ -// Load Dolibarr environment @@ -43,4 +41,4 @@ -if (isModEnabled('productbatch')) { - require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; -} -if (isModEnabled('project')) { +if (!empty($conf->productbatch->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; +} +if (!empty($conf->projet->enabled)) { @@ -51 +49 @@ -if (isModEnabled('variants')) { +if (!empty($conf->variants->enabled)) { @@ -59,4 +57,2 @@ -$langs->loadlangs(array('products', 'suppliers', 'orders', 'bills', 'stocks', 'sendings', 'margins')); -if (isModEnabled('productbatch')) { - $langs->load("productbatch"); -} +$langs->loadlangs(array('products', 'orders', 'bills', 'stocks', 'sendings')); +if (!empty($conf->productbatch->enabled)) $langs->load("productbatch"); @@ -74,2 +70,2 @@ -$d_eatby = dol_mktime(0, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int')); -$d_sellby = dol_mktime(0, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int')); +$d_eatby = dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); +$d_sellby = dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); @@ -81 +76,0 @@ -$cost_price = GETPOST('cost_price', 'alpha'); @@ -84,3 +79,3 @@ -if ($user->socid) { - $socid = $user->socid; -} +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'produit&stock', $id, 'product&product', '', '', $fieldid); + @@ -94,7 +89,6 @@ -if ($id > 0 || !empty($ref)) { - $result = $object->fetch($id, $ref); -} - -if (empty($id) && !empty($object->id)) { - $id = $object->id; -} +if ($id > 0 || !empty($ref)) +{ + $result = $object->fetch($id, $ref); +} + +if (empty($id) && !empty($object->id)) $id = $object->id; @@ -107,4 +101,5 @@ -if (!empty($canvas)) { - require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; - $objcanvas = new Canvas($db, $action); - $objcanvas->getCanvas('stockproduct', 'card', $canvas); +if (!empty($canvas)) +{ + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; + $objcanvas = new Canvas($db, $action); + $objcanvas->getCanvas('stockproduct', 'card', $canvas); @@ -115,22 +109,0 @@ - -$error = 0; - -$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'lire'))); -$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'creer'))); -$usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('product', 'product_advance', 'read_prices') : $user->hasRight('product', 'lire'); - -if ($object->isService()) { - $label = $langs->trans('Service'); - $usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('service', 'service_advance', 'read_prices') : $user->hasRight('service', 'lire'); -} - -if ($object->id > 0) { - if ($object->type == $object::TYPE_PRODUCT) { - restrictedArea($user, 'produit', $object->id, 'product&product', '', ''); - } - if ($object->type == $object::TYPE_SERVICE) { - restrictedArea($user, 'service', $object->id, 'product&product', '', ''); - } -} else { - restrictedArea($user, 'produit|service', $id, 'product&product', '', '', $fieldid); -} @@ -143,3 +116 @@ -if ($cancel) { - $action = ''; -} +if ($cancel) $action = ''; @@ -149,20 +120,4 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if ($action == 'setcost_price') { - if ($id) { - $result = $object->fetch($id); - $object->cost_price = price2num($cost_price); - $result = $object->update($object->id, $user); - if ($result > 0) { - setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - $action = ''; - } else { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - } - } -} - -if ($action == 'addlimitstockwarehouse' && $user->hasRight('produit', 'creer')) { +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if ($action == 'addlimitstockwarehouse' && !empty($user->rights->produit->creer)) +{ @@ -188,3 +143 @@ - if ($pse->update($user) > 0) { - setEventMessages($langs->trans('ProductStockWarehouseUpdated'), null, 'mesgs'); - } + if ($pse->update($user) > 0) setEventMessages($langs->trans('ProductStockWarehouseUpdated'), null, 'mesgs'); @@ -193 +146 @@ - $pse->fk_entrepot = GETPOST('fk_entrepot', 'int'); + $pse->fk_entrepot = GETPOST('fk_entrepot'); @@ -197,3 +150 @@ - if ($pse->create($user) > 0) { - setEventMessages($langs->trans('ProductStockWarehouseCreated'), null, 'mesgs'); - } + if ($pse->create($user) > 0) setEventMessages($langs->trans('ProductStockWarehouseCreated'), null, 'mesgs'); @@ -207 +158,2 @@ -if ($action == 'delete_productstockwarehouse' && $user->hasRight('produit', 'creer')) { +if ($action == 'delete_productstockwarehouse' && !empty($user->rights->produit->creer)) +{ @@ -211,3 +163 @@ - if ($pse->delete($user) > 0) { - setEventMessages($langs->trans('ProductStockWarehouseDeleted'), null, 'mesgs'); - } + if ($pse->delete($user) > 0) setEventMessages($langs->trans('ProductStockWarehouseDeleted'), null, 'mesgs'); @@ -219,11 +169,11 @@ -if ($action == 'setseuil_stock_alerte' && $user->hasRight('produit', 'creer')) { - $object = new Product($db); - $result = $object->fetch($id); - $object->seuil_stock_alerte = $stocklimit; - $result = $object->update($object->id, $user, 0, 'update'); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - //else - // setEventMessages($lans->trans("SavedRecordSuccessfully"), null, 'mesgs'); - $action = ''; +if ($action == 'setseuil_stock_alerte' && !empty($user->rights->produit->creer)) +{ + $object = new Product($db); + $result = $object->fetch($id); + $object->seuil_stock_alerte = $stocklimit; + $result = $object->update($object->id, $user, 0, 'update'); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); + //else + // setEventMessages($lans->trans("SavedRecordSuccessfully"), null, 'mesgs'); + $action = ''; @@ -233,9 +183,9 @@ -if ($action == 'setdesiredstock' && $user->hasRight('produit', 'creer')) { - $object = new Product($db); - $result = $object->fetch($id); - $object->desiredstock = $desiredstock; - $result = $object->update($object->id, $user, 0, 'update'); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - $action = ''; +if ($action == 'setdesiredstock' && !empty($user->rights->produit->creer)) +{ + $object = new Product($db); + $result = $object->fetch($id); + $object->desiredstock = $desiredstock; + $result = $object->update($object->id, $user, 0, 'update'); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; @@ -246,2 +196,4 @@ -if ($action == "correct_stock" && !$cancel) { - if (!(GETPOST("id_entrepot", 'int') > 0)) { +if ($action == "correct_stock" && !$cancel) +{ + if (!(GETPOST("id_entrepot") > 0)) + { @@ -252 +204,2 @@ - if (!GETPOST("nbpiece")) { + if (!GETPOST("nbpiece")) + { @@ -258 +211,2 @@ - if (isModEnabled('productbatch')) { + if (!empty($conf->productbatch->enabled)) + { @@ -262 +216,2 @@ - if ($object->hasbatch() && !$batchnumber) { + if ($object->hasbatch() && !$batchnumber) + { @@ -269 +224,2 @@ - if (!$error) { + if (!$error) + { @@ -271,2 +227,2 @@ - $nbpiece = price2num(GETPOST("nbpiece", 'alphanohtml')); - if (is_numeric($nbpiece) && $nbpiece != 0 && $id) { + if (is_numeric(GETPOST("nbpiece")) && $id) + { @@ -276 +232,2 @@ - if (GETPOST('projectid', 'int')) { + if (GETPOST('projectid', 'int')) + { @@ -285,7 +242,2 @@ - - $disablestockchangeforsubproduct = 0; - if (GETPOST('disablesubproductstockchange')) { - $disablestockchangeforsubproduct = 1; - } - - if ($object->hasbatch()) { + if ($object->hasbatch()) + { @@ -294,4 +246,4 @@ - GETPOST("id_entrepot", 'int'), - $nbpiece, - GETPOST("mouvement", 'int'), - GETPOST("label", 'alphanohtml'), // label movement + GETPOST("id_entrepot"), + GETPOST("nbpiece"), + GETPOST("mouvement"), + GETPOST("label"), // label movement @@ -302 +254 @@ - GETPOST('inventorycode', 'alphanohtml'), + GETPOST('inventorycode'), @@ -304,2 +256 @@ - $origin_id, - $disablestockchangeforsubproduct + $origin_id @@ -307 +258,3 @@ - } else { + } + else + { @@ -309,7 +262,7 @@ - $user, - GETPOST("id_entrepot", 'int'), - $nbpiece, - GETPOST("mouvement", 'int'), - GETPOST("label", 'alphanohtml'), - $priceunit, - GETPOST('inventorycode', 'alphanohtml'), + $user, + GETPOST("id_entrepot"), + GETPOST("nbpiece"), + GETPOST("mouvement"), + GETPOST("label"), + $priceunit, + GETPOST('inventorycode'), @@ -317,2 +270 @@ - $origin_id, - $disablestockchangeforsubproduct + $origin_id @@ -322,2 +274,4 @@ - if ($result > 0) { - if ($backtopage) { + if ($result > 0) + { + if ($backtopage) + { @@ -326,2 +280,4 @@ - } else { - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); + } + else + { + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); @@ -330,3 +286,5 @@ - } else { - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'correction'; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'correction'; @@ -339,2 +297,4 @@ -if ($action == "transfert_stock" && !$cancel) { - if (!(GETPOST("id_entrepot", 'int') > 0) || !(GETPOST("id_entrepot_destination", 'int') > 0)) { +if ($action == "transfert_stock" && !$cancel) +{ + if (!(GETPOST("id_entrepot", 'int') > 0) || !(GETPOST("id_entrepot_destination", 'int') > 0)) + { @@ -345 +305,2 @@ - if (!GETPOST("nbpiece", 'int')) { + if (!GETPOST("nbpiece", 'int')) + { @@ -350 +311,2 @@ - if (GETPOST("id_entrepot", 'int') == GETPOST("id_entrepot_destination", 'int')) { + if (GETPOST("id_entrepot", 'int') == GETPOST("id_entrepot_destination", 'int')) + { @@ -355,13 +317,17 @@ - if (isModEnabled('productbatch')) { - $object = new Product($db); - $result = $object->fetch($id); - - if ($object->hasbatch() && !$batchnumber) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); - $error++; - $action = 'transfert'; - } - } - - if (!$error) { - if ($id) { + if (!empty($conf->productbatch->enabled)) + { + $object = new Product($db); + $result = $object->fetch($id); + + if ($object->hasbatch() && !$batchnumber) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); + $error++; + $action = 'transfert'; + } + } + + if (!$error) + { + if ($id) + { @@ -377,3 +343 @@ - if (isset($object->pmp)) { - $pricesrc = $object->pmp; - } + if (isset($object->pmp)) $pricesrc = $object->pmp; @@ -382,3 +346,2 @@ - $nbpiece = price2num(GETPOST("nbpiece", 'alphanohtml')); - - if ($object->hasbatch()) { + if ($object->hasbatch()) + { @@ -387 +350,2 @@ - if ($pdluoid > 0) { + if ($pdluoid > 0) + { @@ -389 +353,2 @@ - if ($result) { + if ($result) + { @@ -394 +359,3 @@ - } else { + } + else + { @@ -398 +365,3 @@ - } else { + } + else + { @@ -405,3 +374,2 @@ - $nbpiece = price2num(GETPOST("nbpiece", 'alphanohtml')); - - if (!$error) { + if (!$error) + { @@ -412 +380 @@ - $nbpiece, + GETPOST("nbpiece", 'int'), @@ -414 +382 @@ - GETPOST("label", 'alphanohtml'), + GETPOST("label", 'san_alpha'), @@ -416,4 +384,2 @@ - $eatby, - $sellby, - $batch, - GETPOST('inventorycode', 'alphanohtml') + $eatby, $sellby, $batch, + GETPOST('inventorycode') @@ -421,5 +387,4 @@ - if ($result1 < 0) { - $error++; - } - } - if (!$error) { + if ($result1 < 0) $error++; + } + if (!$error) + { @@ -430 +395 @@ - $nbpiece, + GETPOST("nbpiece", 'int'), @@ -432 +397 @@ - GETPOST("label", 'alphanohtml'), + GETPOST("label", 'san_alpha'), @@ -434,4 +399,2 @@ - $eatby, - $sellby, - $batch, - GETPOST('inventorycode', 'alphanohtml') + $eatby, $sellby, $batch, + GETPOST('inventorycode') @@ -439,39 +402,38 @@ - if ($result2 < 0) { - $error++; - } - } - } else { - if (!$error) { - // Remove stock - $result1 = $object->correct_stock( - $user, - GETPOST("id_entrepot", 'int'), - $nbpiece, - 1, - GETPOST("label", 'alphanohtml'), - $pricesrc, - GETPOST('inventorycode', 'alphanohtml') - ); - if ($result1 < 0) { - $error++; - } - } - if (!$error) { - // Add stock - $result2 = $object->correct_stock( - $user, - GETPOST("id_entrepot_destination", 'int'), - $nbpiece, - 0, - GETPOST("label", 'alphanohtml'), - $pricedest, - GETPOST('inventorycode', 'alphanohtml') - ); - if ($result2 < 0) { - $error++; - } - } - } - - - if (!$error && $result1 >= 0 && $result2 >= 0) { + if ($result2 < 0) $error++; + } + } + else + { + if (!$error) + { + // Remove stock + $result1 = $object->correct_stock( + $user, + GETPOST("id_entrepot"), + GETPOST("nbpiece"), + 1, + GETPOST("label"), + $pricesrc, + GETPOST('inventorycode') + ); + if ($result1 < 0) $error++; + } + if (!$error) + { + // Add stock + $result2 = $object->correct_stock( + $user, + GETPOST("id_entrepot_destination"), + GETPOST("nbpiece"), + 0, + GETPOST("label"), + $pricedest, + GETPOST('inventorycode') + ); + if ($result2 < 0) $error++; + } + } + + + if (!$error && $result1 >= 0 && $result2 >= 0) + { @@ -480 +442,2 @@ - if ($backtopage) { + if ($backtopage) + { @@ -483 +446,3 @@ - } else { + } + else + { @@ -487 +452,3 @@ - } else { + } + else + { @@ -497,27 +464,37 @@ -if ($action == 'updateline' && GETPOST('save') == $langs->trans("Save")) { - $pdluo = new Productbatch($db); - $result = $pdluo->fetch(GETPOST('pdluoid', 'int')); - - if ($result > 0) { - if ($pdluo->id) { - if ((!GETPOST("sellby")) && (!GETPOST("eatby")) && (!$batchnumber)) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("atleast1batchfield")), null, 'errors'); - } else { - $d_eatby = dol_mktime(0, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int')); - $d_sellby = dol_mktime(0, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int')); - $pdluo->batch = $batchnumber; - $pdluo->eatby = $d_eatby; - $pdluo->sellby = $d_sellby; - $result = $pdluo->update($user); - if ($result < 0) { - setEventMessages($pdluo->error, $pdluo->errors, 'errors'); - } - } - } else { - setEventMessages($langs->trans('BatchInformationNotfound'), null, 'errors'); - } - } else { - setEventMessages($pdluo->error, null, 'errors'); - } - header("Location: product.php?id=".$id); - exit; +if ($action == 'updateline' && GETPOST('save') == $langs->trans('Save')) +{ + $pdluo = new Productbatch($db); + $result = $pdluo->fetch(GETPOST('pdluoid', 'int')); + + if ($result > 0) + { + if ($pdluo->id) + { + if ((!GETPOST("sellby")) && (!GETPOST("eatby")) && (!$batchnumber)) { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("atleast1batchfield")), null, 'errors'); + } + else + { + $d_eatby = dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); + $d_sellby = dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); + $pdluo->batch = $batchnumber; + $pdluo->eatby = $d_eatby; + $pdluo->sellby = $d_sellby; + $result = $pdluo->update($user); + if ($result < 0) + { + setEventMessages($pdluo->error, $pdluo->errors, 'errors'); + } + } + } + else + { + setEventMessages($langs->trans('BatchInformationNotfound'), null, 'errors'); + } + } + else + { + setEventMessages($pdluo->error, null, 'errors'); + } + header("Location: product.php?id=".$id); + exit; @@ -534,5 +511,4 @@ -if (isModEnabled('project')) { - $formproject = new FormProjets($db); -} - -if ($id > 0 || $ref) { +if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); + +if ($id > 0 || $ref) +{ @@ -549 +525,2 @@ - if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { + if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) + { @@ -553 +530,2 @@ - if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { + if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) + { @@ -560,46 +538,2 @@ - if (!empty($conf->use_javascript_ajax)) { - ?> - - 0) { + if ($result > 0) + { @@ -610 +544 @@ - print dol_get_fiche_head($head, 'stock', $titre, -1, $picto); + dol_fiche_head($head, 'stock', $titre, -1, $picto); @@ -614,8 +548,11 @@ - $linkback = ''.$langs->trans("BackToList").''; - - $shownav = 1; - if ($user->socid && !in_array('stock', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) { - $shownav = 0; - } - - dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); + $linkback = ''.$langs->trans("BackToList").''; + + $shownav = 1; + if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); + + print '
'; + + print '
'; + print ''; @@ -624,19 +561,2 @@ - print '
'; - - print '
'; - print '
'; - - print '
'; - - // Type - if (isModEnabled("product") && isModEnabled("service")) { - $typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); - print ''; - } - - if (isModEnabled('productbatch')) { - print ''; - - - - // AWP - print ''; + // PMP + print ''; @@ -670,3 +570 @@ - if ($object->pmp > 0 && $usercancreadprice) { - print price($object->pmp).' '.$langs->trans("HT"); - } + if ($object->pmp > 0) print price($object->pmp).' '.$langs->trans("HT"); @@ -681,5 +579,2 @@ - if ($product_fourn->product_fourn_price_id > 0 && $usercancreadprice) { - print $product_fourn->display_price_product_fournisseur(); - } else { - print $langs->trans("NotDefined"); - } + if ($product_fourn->product_fourn_price_id > 0) print $product_fourn->display_price_product_fournisseur(); + else print $langs->trans("NotDefined"); @@ -689 +584 @@ - if (!getDolGlobalString('PRODUIT_MULTIPRICES')) { + if (empty($conf->global->PRODUIT_MULTIPRICES)) { @@ -692,6 +587,4 @@ - if ($usercancreadprice) { - if ($object->price_base_type == 'TTC') { - print price($object->price_ttc).' '.$langs->trans($object->price_base_type); - } else { - print price($object->price).' '.$langs->trans($object->price_base_type); - } + if ($object->price_base_type == 'TTC') { + print price($object->price_ttc).' '.$langs->trans($object->price_base_type); + } else { + print price($object->price).' '.$langs->trans($object->price_base_type); @@ -703,6 +596,4 @@ - if ($usercancreadprice) { - if ($object->price_base_type == 'TTC') { - print price($object->price_min_ttc).' '.$langs->trans($object->price_base_type); - } else { - print price($object->price_min).' '.$langs->trans($object->price_base_type); - } + if ($object->price_base_type == 'TTC') { + print price($object->price_min_ttc).' '.$langs->trans($object->price_base_type); + } else { + print price($object->price_min).' '.$langs->trans($object->price_base_type); @@ -714 +605 @@ - print ''.$langs->trans("Variable").''; + print $langs->trans("Variable"); @@ -719 +610 @@ - print ''.$langs->trans("Variable").''; + print $langs->trans("Variable"); @@ -721,0 +613,5 @@ + + // Stock alert threshold + print ''; @@ -728,12 +623,0 @@ - print '
'; - print (!getDolGlobalString('PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans('Type'); - print ''; - print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat); - print '
'.$langs->trans("ManageLotSerial").''; + if ($conf->productbatch->enabled) { + print '
'.$langs->trans("ManageLotSerial").''; @@ -647,22 +567,2 @@ - // Cost price. Can be used for margin module for option "calculate margin on explicit cost price - print '
'; - $textdesc = $langs->trans("CostPriceDescription"); - $textdesc .= "
".$langs->trans("CostPriceUsage"); - $text = $form->textwithpicto($langs->trans("CostPrice"), $textdesc, 1, 'help', ''); - if (!$usercancreadprice) { - print $form->editfieldkey($text, 'cost_price', '', $object, 0, 'amount:6'); - print '
'; - print $form->editfieldval($text, 'cost_price', '', $object, 0, 'amount:6'); - } else { - print $form->editfieldkey($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6'); - print ''; - print $form->editfieldval($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6'); - } - print '
'; - print $form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc")); - print '
'.$langs->trans("AverageUnitPricePMP").'
'.$form->editfieldkey($form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1), 'seuil_stock_alerte', $object->seuil_stock_alerte, $object, $user->rights->produit->creer).''; + print $form->editfieldval("StockLimit", 'seuil_stock_alerte', $object->seuil_stock_alerte, $object, $user->rights->produit->creer, 'string'); + print '
'; - - print '
'; - print '
'; - - print ''; - - // Stock alert threshold - print ''; - @@ -741 +625 @@ - print '
'.$form->editfieldkey($form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1), 'seuil_stock_alerte', $object->seuil_stock_alerte, $object, $user->hasRight('produit', 'creer')).''; - print $form->editfieldval("StockLimit", 'seuil_stock_alerte', $object->seuil_stock_alerte, $object, $user->hasRight('produit', 'creer'), 'string'); - print '
'.$form->editfieldkey($form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1), 'desiredstock', $object->desiredstock, $object, $user->hasRight('produit', 'creer')); + print '
'.$form->editfieldkey($form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1), 'desiredstock', $object->desiredstock, $object, $user->rights->produit->creer); @@ -743 +627 @@ - print $form->editfieldval("DesiredStock", 'desiredstock', $object->desiredstock, $object, $user->hasRight('produit', 'creer'), 'string'); + print $form->editfieldval("DesiredStock", 'desiredstock', $object->desiredstock, $object, $user->rights->produit->creer, 'string'); @@ -749,16 +633,7 @@ - $text_stock_options .= (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT') || getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE') ? '- '.$langs->trans("DeStockOnShipment").'
' : ''); - $text_stock_options .= (getDolGlobalString('STOCK_CALCULATE_ON_VALIDATE_ORDER') ? '- '.$langs->trans("DeStockOnValidateOrder").'
' : ''); - $text_stock_options .= (getDolGlobalString('STOCK_CALCULATE_ON_BILL') ? '- '.$langs->trans("DeStockOnBill").'
' : ''); - $text_stock_options .= (getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_BILL') ? '- '.$langs->trans("ReStockOnBill").'
' : ''); - $text_stock_options .= (getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER') ? '- '.$langs->trans("ReStockOnValidateOrder").'
' : ''); - $text_stock_options .= (getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER') ? '- '.$langs->trans("ReStockOnDispatchOrder").'
' : ''); - $text_stock_options .= (getDolGlobalString('STOCK_CALCULATE_ON_RECEPTION') || getDolGlobalString('STOCK_CALCULATE_ON_RECEPTION_CLOSE') ? '- '.$langs->trans("StockOnReception").'
' : ''); - $parameters = array(); - $reshook = $hookmanager->executeHooks('physicalStockTextStockOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook > 0) { - $text_stock_options = $hookmanager->resPrint; - } elseif ($reshook == 0) { - $text_stock_options .= $hookmanager->resPrint; - } else { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE) ? $langs->trans("DeStockOnShipment").'
' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) ? $langs->trans("DeStockOnValidateOrder").'
' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_BILL) ? $langs->trans("DeStockOnBill").'
' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) ? $langs->trans("ReStockOnBill").'
' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) ? $langs->trans("ReStockOnValidateOrder").'
' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) ? $langs->trans("ReStockOnDispatchOrder").'
' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) ? $langs->trans("StockOnReception").'
' : ''); @@ -770,5 +645 @@ - if ($object->seuil_stock_alerte != '' && ($object->stock_reel < $object->seuil_stock_alerte)) { - print ' '.img_warning($langs->trans("StockLowerThanLimit", $object->seuil_stock_alerte)); - } - - print '    '.$langs->trans("StockAtDate").''; + if ($object->seuil_stock_alerte != '' && ($object->stock_reel < $object->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockLowerThanLimit", $object->seuil_stock_alerte)); @@ -782,7 +653,3 @@ - // Number of sales orders running - if (isModEnabled('commande')) { - if ($found) { - $helpondiff .= '
'; - } else { - $found = 1; - } + // Number of customer orders running + if (!empty($conf->commande->enabled)) { + if ($found) $helpondiff .= '
'; else $found = 1; @@ -791,20 +658,14 @@ - if ($result < 0) { - dol_print_error($db, $object->error); - } - $helpondiff .= ' ('.$langs->trans("ProductQtyInDraft").': '.$object->stats_commande['qty'].')'; - } - - // Number of product from sales order already sent (partial shipping) - if (isModEnabled("expedition")) { - require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; - $filterShipmentStatus = ''; - if (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT')) { - $filterShipmentStatus = Expedition::STATUS_VALIDATED.','.Expedition::STATUS_CLOSED; - } elseif (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE')) { - $filterShipmentStatus = Expedition::STATUS_CLOSED; - } - if ($found) { - $helpondiff .= '
'; - } else { - $found = 1; - } + if ($result < 0) dol_print_error($db, $object->error); + $helpondiff .= ' ('.$langs->trans("ProductQtyInDraft").': '.$object->stats_commande['qty'].')'; + } + + // Number of product from customer order already sent (partial shipping) + if (!empty($conf->expedition->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; + $filterShipmentStatus = ''; + if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) { + $filterShipmentStatus = Expedition::STATUS_VALIDATED.','.Expedition::STATUS_CLOSED; + } elseif (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { + $filterShipmentStatus = Expedition::STATUS_CLOSED; + } + if ($found) $helpondiff .= '
'; else $found = 1; @@ -816,6 +677,3 @@ - if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { - if ($found) { - $helpondiff .= '
'; - } else { - $found = 1; - } + if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) + { + if ($found) $helpondiff .= '
'; else $found = 1; @@ -825,4 +683,2 @@ - if ($result < 0) { - dol_print_error($db, $object->error); - } - $helpondiff .= ' ('.$langs->trans("ProductQtyInDraftOrWaitingApproved").': '.$object->stats_commande_fournisseur['qty'].')'; + if ($result < 0) dol_print_error($db, $object->error); + $helpondiff .= ' ('.$langs->trans("ProductQtyInDraftOrWaitingApproved").': '.$object->stats_commande_fournisseur['qty'].')'; @@ -832,6 +688,2 @@ - if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { - if ($found) { - $helpondiff .= '
'; - } else { - $found = 1; - } + if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) { + if ($found) $helpondiff .= '
'; else $found = 1; @@ -842,6 +694,2 @@ - if (isModEnabled('mrp')) { - if ($found) { - $helpondiff .= '
'; - } else { - $found = 1; - } + if (!empty($conf->mrp->enabled)) { + if ($found) $helpondiff .= '
'; else $found = 1; @@ -850,9 +697,0 @@ - } - $parameters = array('found' => &$found, 'id' => $object->id, 'includedraftpoforvirtual' => null); - $reshook = $hookmanager->executeHooks('virtualStockHelpOnDiff', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook > 0) { - $helpondiff = $hookmanager->resPrint; - } elseif ($reshook == 0) { - $helpondiff .= $hookmanager->resPrint; - } else { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -869,4 +708 @@ - if ($object->seuil_stock_alerte != '' && ($object->stock_theorique < $object->seuil_stock_alerte)) { - print ' '.img_warning($langs->trans("StockLowerThanLimit", $object->seuil_stock_alerte)); - } - print '    '.$langs->trans("VirtualStockAtDate").''; + if ($object->seuil_stock_alerte != '' && ($object->stock_theorique < $object->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockLowerThanLimit", $object->seuil_stock_alerte)); @@ -877 +713,2 @@ - if ($user->hasRight('stock', 'mouvement', 'lire')) { + if (!empty($user->rights->stock->mouvement->lire)) + { @@ -880 +717 @@ - $sql .= " WHERE m.fk_product = ".((int) $object->id); + $sql .= " WHERE m.fk_product = '".$object->id."'"; @@ -891,3 +728 @@ - print '     '; - print img_picto($langs->trans("StockMovement"), 'movement', 'class="pictofixedwidth"'); - print ''.$langs->trans("FullList").''; + print '('.$langs->trans("FullList").')'; @@ -895 +729,0 @@ - print img_picto($langs->trans("StockMovement"), 'movement', 'class="pictofixedwidth"'); @@ -900,10 +734,7 @@ - - print "
"; - - print '
'; - print '
'; - - print '
'; - } - - print dol_get_fiche_end(); + } + print ""; + + print '
'; + print '
'; + + dol_fiche_end(); @@ -913 +744,2 @@ - if ($action == "correction") { + if ($action == "correction") + { @@ -919 +751,2 @@ - if ($action == "transfert") { + if ($action == "transfert") + { @@ -923 +756,3 @@ -} else { +} +else +{ @@ -928 +763,5 @@ -// Actions buttons +/* ************************************************************************** */ +/* */ +/* Barre d'action */ +/* */ +/* ************************************************************************** */ @@ -933,8 +772,29 @@ -if (empty($reshook)) { - if (empty($action) && $object->id) { - print "
\n"; - - if ($user->hasRight('stock', 'mouvement', 'creer')) { - if (!$variants || getDolGlobalString('VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT')) { - print ''.$langs->trans("TransferStock").''; - } else { +if (empty($reshook)) +{ + if (empty($action) && $object->id) + { + print "
\n"; + + if ($user->rights->stock->mouvement->creer) + { + if (!$variants || !empty($conf->global->VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT)) { + print ''.$langs->trans("CorrectStock").''; + } + else + { + print ''.$langs->trans("CorrectStock").''; + } + } + else + { + print ''.$langs->trans("CorrectStock").''; + } + + //if (($user->rights->stock->mouvement->creer) && ! $object->hasbatch()) + if ($user->rights->stock->mouvement->creer) + { + if (!$variants || !empty($conf->global->VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT)) { + print ''.$langs->trans("TransferStock").''; + } + else + { @@ -943 +803,3 @@ - } else { + } + else + { @@ -947,10 +808,0 @@ - if ($user->hasRight('stock', 'mouvement', 'creer')) { - if (!$variants || getDolGlobalString('VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT')) { - print ''.$langs->trans("CorrectStock").''; - } else { - print ''.$langs->trans("CorrectStock").''; - } - } else { - print ''.$langs->trans("CorrectStock").''; - } - @@ -962 +814 @@ -if (!$variants || getDolGlobalString('VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT')) { +if (!$variants) { @@ -973 +825 @@ - print ''.$form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc")).''; + print ''.$langs->trans("AverageUnitPricePMPShort").''; @@ -977,2 +828,0 @@ - print ''; - print ''; @@ -980,22 +830,5 @@ - - if ((isModEnabled('productbatch')) && $object->hasbatch()) { - $colspan = 3; - print ''; - if (!empty($conf->use_javascript_ajax)) { - print ''.img_picto('', 'folder-open', 'class="paddingright"').$langs->trans("ShowAllLots").''; - //print '   '; - print ''.img_picto('', 'folder', 'class="paddingright"').$langs->trans("HideLots").''; - //print ' '.$form->textwithpicto('', $langs->trans('CollapseBatchDetailHelp'), 1, 'help', ''); - } - print ''; - print ''.$langs->trans("batch_number").''; - if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) { - $colspan--; - print ''.$langs->trans("SellByDate").''; - } - if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) { - $colspan--; - print ''.$langs->trans("EatByDate").''; - } - print ''; - print ''; + if ((!empty($conf->productbatch->enabled)) && $object->hasbatch()) { + print ''; + print ''.$langs->trans("batch_number").''; + print ''.$langs->trans("EatByDate").''; + print ''.$langs->trans("SellByDate").''; @@ -1010 +843 @@ - $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"; + $sql = "SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp"; @@ -1017 +850 @@ - $sql .= " AND ps.fk_product = ".((int) $object->id); + $sql .= " AND ps.fk_product = ".$object->id; @@ -1023 +855,0 @@ - $num = 0; @@ -1026 +857,0 @@ - $totalwithpmp = 0; @@ -1038,0 +870 @@ + $entrepotstatic->libelle = $obj->ref; @@ -1042,2 +874 @@ - $entrepotstatic->statut = $obj->status; - $entrepotstatic->status = $obj->status; + $entrepotstatic->statut = $obj->statut; @@ -1047,9 +878,10 @@ - - // Warehouse - print ''; - print $entrepotstatic->getNomUrl(1); - if (!empty($conf->use_javascript_ajax) && isModEnabled('productbatch') && $object->hasbatch()) { - print ''; - print(!getDolGlobalString('STOCK_SHOW_ALL_BATCH_BY_DEFAULT') ? '(+)' : '(-)'); - print ''; - } + print ''.$entrepotstatic->getNomUrl(1).''; + print ''.$stock_real.($stock_real < 0 ? ' '.img_warning() : '').''; + // PMP + print ''.(price2num($object->pmp) ? price2num($object->pmp, 'MU') : '').''; + // Value purchase + print ''.(price2num($object->pmp) ? price(price2num($object->pmp * $obj->reel, 'MT')) : '').''; + // Sell price + print ''; + if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price, 'MU'), 1); + else print $langs->trans("Variable"); @@ -1057,43 +888,0 @@ - - print ''.$stock_real.($stock_real < 0 ? ' '.img_warning() : '').''; - - // PMP - print ''.(price2num($object->pmp) ? price2num($object->pmp, 'MU') : '').''; - - // Value purchase - if ($usercancreadprice) { - print ''.(price2num($object->pmp) ? price(price2num($object->pmp * $obj->reel, 'MT')) : '').''; - } else { - print ''; - } - - // Sell price - $minsellprice = null; - $maxsellprice = null; - print ''; - if (getDolGlobalString('PRODUIT_MULTIPRICES')) { - foreach ($object->multiprices as $priceforlevel) { - if (is_numeric($priceforlevel)) { - if (is_null($maxsellprice) || $priceforlevel > $maxsellprice) { - $maxsellprice = $priceforlevel; - } - if (is_null($minsellprice) || $priceforlevel < $minsellprice) { - $minsellprice = $priceforlevel; - } - } - } - print ''; - if ($usercancreadprice) { - if ($minsellprice != $maxsellprice) { - print price(price2num($minsellprice, 'MU'), 1).' - '.price(price2num($maxsellprice, 'MU'), 1); - } else { - print price(price2num($minsellprice, 'MU'), 1); - } - } - print ''; - print $form->textwithpicto('', $langs->trans("Variable")); - } elseif ($usercancreadprice) { - print price(price2num($object->price, 'MU'), 1); - } - print ''; - @@ -1101,20 +890,3 @@ - print ''; - if (getDolGlobalString('PRODUIT_MULTIPRICES')) { - print ''; - if ($usercancreadprice) { - if ($minsellprice != $maxsellprice) { - print price(price2num($minsellprice * $obj->reel, 'MT'), 1).' - '.price(price2num($maxsellprice * $obj->reel, 'MT'), 1); - } else { - print price(price2num($minsellprice * $obj->reel, 'MT'), 1); - } - } - print ''; - print $form->textwithpicto('', $langs->trans("Variable")); - } else { - if ($usercancreadprice) { - print price(price2num($object->price * $obj->reel, 'MT'), 1); - } - } - print ''; - print ''; - print ''; + print ''; + if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price * $obj->reel, 'MT'), 1).''; + else print $langs->trans("Variable"); @@ -1123,3 +895 @@ - if (price2num($object->pmp)) { - $totalwithpmp += $obj->reel; - } + if (price2num($object->pmp)) $totalwithpmp += $obj->reel; @@ -1129 +899 @@ - if ((isModEnabled('productbatch')) && $object->hasbatch()) { + if ((!empty($conf->productbatch->enabled)) && $object->hasbatch()) { @@ -1131,3 +901 @@ - if ($details < 0) { - dol_print_error($db); - } + if ($details < 0) dol_print_error($db); @@ -1147,13 +915,9 @@ - if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) { - print ''; - print $form->selectDate($pdluo->sellby, 'sellby', '', '', 1, '', 1, 0); - print ''; - } - if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) { - print ''; - print $form->selectDate($pdluo->eatby, 'eatby', '', '', 1, '', 1, 0); - print ''; - } - print ''.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').''; - print ''; - print ''; + print ''; + print $form->selectDate($pdluo->eatby, 'eatby', '', '', 1, '', 1, 0); + print ''; + print ''; + print $form->selectDate($pdluo->sellby, 'sellby', '', '', 1, '', 1, 0); + print ''; + print ''.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').''; + print ''; + print ''; @@ -1161,0 +926,11 @@ + print ''; + } else { + print "\n".''; + print img_picto($langs->trans("Tranfer"), 'uparrow', 'class="hideonsmartphone"').' '; + print 'id.'">'.$langs->trans("TransferStock").''; + // Disabled, because edition of stock content must use the "Correct stock menu". + // Do not use this, or data will be wrong (bad tracking of movement label, inventory code, ... + //print 'id.'#'.$pdluo->id.'">'; + //print img_edit().''; + print ''; + print $product_lot_static->getNomUrl(1); @@ -1163,23 +938,3 @@ - print ''; - print ''; - print ''; - } else { - print "\n".''; - print ''; - print ''; - if ($product_lot_static->id > 0) { - print $product_lot_static->getNomUrl(1); - } else { - print $product_lot_static->getNomUrl(1, 'nolink'); - } - print ''; - $colspan = 3; - if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) { - $colspan--; - print ''.dol_print_date($pdluo->sellby, 'day').''; - } - if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) { - $colspan--; - print ''.dol_print_date($pdluo->eatby, 'day').''; - } - print ''.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : (($pdluo->qty > 1 && $object->status_batch == 2) ? ' '.img_warning($langs->trans('IlligalQtyForSerialNumbers')) : '')).''; + print ''.dol_print_date($pdluo->eatby, 'day').''; + print ''.dol_print_date($pdluo->sellby, 'day').''; + print ''.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').''; @@ -1187,24 +941,0 @@ - print ''; - if ($entrepotstatic->status != $entrepotstatic::STATUS_CLOSED) { - print 'id.'">'; - print img_picto($langs->trans("TransferStock"), 'add', 'class="hideonsmartphone paddingright" style="color: #a69944"'); - print $langs->trans("TransferStock"); - print ''; - // Disabled, because edition of stock content must use the "Correct stock menu". - // Do not use this, or data will be wrong (bad tracking of movement label, inventory code, ... - //print 'id.'#'.$pdluo->id.'">'; - //print img_edit().''; - } - print ''; - print ''; - if ($entrepotstatic->status != $entrepotstatic::STATUS_CLOSED) { - print 'id.'">'; - print img_picto($langs->trans("CorrectStock"), 'add', 'class="hideonsmartphone paddingright" style="color: #a69944"'); - print $langs->trans("CorrectStock"); - print ''; - // Disabled, because edition of stock content must use the "Correct stock menu". - // Do not use this, or data will be wrong (bad tracking of movement label, inventory code, ... - //print 'id.'#'.$pdluo->id.'">'; - //print img_edit().''; - } - print ''; @@ -1217,3 +948 @@ - } else { - dol_print_error($db); - } + } else dol_print_error($db); @@ -1225,3 +954 @@ - if ($usercancreadprice) { - print($totalwithpmp ? price(price2num($totalvalue / $totalwithpmp, 'MU')) : ' '); // This value may have rounding errors - } + print ($totalwithpmp ? price(price2num($totalvalue / $totalwithpmp, 'MU')) : ' '); // This value may have rounding errors @@ -1231,3 +958 @@ - if ($usercancreadprice) { - print $totalvalue ? price(price2num($totalvalue, 'MT'), 1) : ' '; - } + print $totalvalue ? price(price2num($totalvalue, 'MT'), 1) : ' '; @@ -1236,11 +961,2 @@ - if ($num) { - if ($total) { - print ''; - if (getDolGlobalString('PRODUIT_MULTIPRICES')) { - print $form->textwithpicto('', $langs->trans("Variable")); - } elseif ($usercancreadprice) { - print price($totalvaluesell / $total, 1); - } - print ''; - } - } + if (empty($conf->global->PRODUIT_MULTIPRICES)) print ($total ? price($totalvaluesell / $total, 1) : ' '); + else print $langs->trans("Variable"); @@ -1249,10 +965,3 @@ - print ''; - if ($num) { - print ''; - if (!getDolGlobalString('PRODUIT_MULTIPRICES') && $usercancreadprice) { - print price(price2num($totalvaluesell, 'MT'), 1); - } else { - print $form->textwithpicto('', $langs->trans("Variable")); - } - print ''; - } + print ''; + if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($totalvaluesell, 'MT'), 1); + else print $langs->trans("Variable"); @@ -1260,2 +968,0 @@ - print ''; - print ''; @@ -1267 +974 @@ - if (getDolGlobalString('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE')) { + if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) { @@ -1271 +978 @@ - if ($user->hasRight('produit', 'creer')) { + if (!empty($user->rights->produit->creer)) { @@ -1278,2 +985,2 @@ - if ($user->hasRight('produit', 'creer')) { - print ''.$formproduct->selectWarehouses('', 'fk_entrepot').''; + if (!empty($user->rights->produit->creer)) { + print ''.$formproduct->selectWarehouses('', 'fk_entrepot').''; @@ -1282 +989 @@ - print ''; + print ''; @@ -1285 +992 @@ - print ''.$langs->trans("Warehouse").''; + print ''.$langs->trans("Warehouse").''; @@ -1299 +1006 @@ - print ''.$ent->getNomUrl(3).''; + print ''.$ent->getNomUrl(3).''; @@ -1302,2 +1009,2 @@ - if ($user->hasRight('produit', 'creer')) { - print ''.img_delete().''; + if (!empty($user->rights->produit->creer)) { + print ''.img_delete().''; @@ -1311 +1018 @@ - if ($user->hasRight('produit', 'creer')) { + if (!empty($user->rights->produit->creer)) { @@ -1335 +1042,2 @@ - print '
'; ?> + print '
'; + ?> @@ -1347 +1055,2 @@ - if (count($productCombinations)) { + if (count($productCombinations)) + { @@ -1349 +1058,2 @@ - foreach ($productCombinations as $currcomb) { + foreach ($productCombinations as $currcomb) + { @@ -1352 +1062,2 @@ - $stock_total += $prodstatic->stock_reel; ?> + $stock_total += $prodstatic->stock_reel; + ?> @@ -1373 +1084 @@ - + @@ -1386 +1097,3 @@ - } else { + } + else + { @@ -1388 +1101,2 @@ - } ?> + } + ?> --- /tmp/dsg/dolibarr/htdocs/product/stock/github_19.0.3_productlot_card.php +++ /tmp/dsg/dolibarr/htdocs/product/stock/client_productlot_card.php @@ -4 +3,0 @@ - * Copyright (C) 2021 Noé Cendrier @@ -27 +25,0 @@ -// Load Dolibarr environment @@ -32 +29,0 @@ -require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -37,2 +33,0 @@ -global $conf, $db, $langs, $user; - @@ -44,5 +39 @@ -$lineid = GETPOST('lineid', 'int'); -$action = GETPOST('action', 'aZ09'); -$confirm = GETPOST('confirm', 'alpha'); -$cancel = GETPOST('cancel', 'aZ09'); -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectcard'; // To manage different context of search +$action = GETPOST('action', 'alpha'); @@ -50,27 +41,3 @@ - -// Initialize technical objects -$object = new Productlot($db); -$extrafields = new ExtraFields($db); -$hookmanager->initHooks(array('productlotcard', 'globalcard')); // Note that conf->hooks_modules contains array - -// Fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label($object->table_element); - -$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); - -// Initialize array of search criterias -$search_all = GETPOST("search_all", 'alpha'); -$search = array(); -foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) { - $search[$key] = GETPOST('search_'.$key, 'alpha'); - } -} - -if (empty($action) && empty($id) && empty($ref)) { - $action = 'view'; -} - -$batch = GETPOST('batch', 'alpha'); -$productid = GETPOST('productid', 'int'); -$ref = GETPOST('ref', 'alpha'); // ref is productid_batch +$batch = GETPOST('batch', 'alpha'); +$productid = GETPOST('productid', 'int'); +$ref = GETPOST('ref', 'alpha'); // ref is productid_batch @@ -85,3 +52,17 @@ -if (empty($action) && empty($id) && empty($ref)) { - $action = 'list'; -} +if (empty($action) && empty($id) && empty($ref)) $action = 'list'; + + +// Protection if external user +if ($user->socid > 0) +{ + //accessforbidden(); +} +//$result = restrictedArea($user, 'mymodule', $id); + + +$object = new ProductLot($db); +$extrafields = new ExtraFields($db); +$formfile = new FormFile($db); + +// fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); @@ -91,6 +72,8 @@ -if ($id || $ref) { - if ($ref) { - $tmp = explode('_', $ref); - $productid = $tmp[0]; - $batch = $tmp[1]; - } +if ($id || $ref) +{ + if ($ref) + { + $tmp = explode('_', $ref); + $productid = $tmp[0]; + $batch = $tmp[1]; + } @@ -98,7 +81 @@ - $object->ref = $object->batch; // Old system for document management ( it uses $object->ref) - $upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, $modulepart); - $filearray = dol_dir_list($upload_dir, "files"); - if (empty($filearray)) { - // If no files linked yet, use new system on lot id. (Batch is not unique and can be same on different product) - $object->fetch($id, $productid, $batch); - } + $object->ref = $object->batch; // For document management ( it use $object->ref) @@ -111,28 +88,7 @@ -$permissionnote = $user->hasRight('stock', 'creer'); // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->hasRight('stock', 'creer'); // Used by the include of actions_dellink.inc.php -$permissiontoadd = $user->hasRight('stock', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php - -$usercanread = $user->hasRight('produit', 'lire'); -$usercancreate = $user->hasRight('produit', 'creer'); -$usercandelete = $user->hasRight('produit', 'supprimer'); - -$upload_dir = $conf->productbatch->multidir_output[$conf->entity]; - -$permissiontoread = $usercanread; -$permissiontoadd = $usercancreate; -$permissiontodelete = $usercandelete; - -// Security check -if (!isModEnabled('productbatch')) { - accessforbidden('Module not enabled'); -} -$socid = 0; -if ($user->socid > 0) { // Protection if external user - //$socid = $user->socid; - accessforbidden(); -} -//$result = restrictedArea($user, 'productbatch'); -if (!$permissiontoread) { - accessforbidden(); -} - +$permissionnote = $user->rights->stock->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->stock->creer; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->rights->stock->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php + +$usercanread = $user->rights->produit->lire; +$usercancreate = $user->rights->produit->creer; +$usercandelete = $user->rights->produit->supprimer; @@ -146,11 +102,7 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - $error = 0; - - $backurlforlist = dol_buildpath('/product/stock/productlot_list.php', 1); - - if ($action == 'seteatby' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) { - $newvalue = dol_mktime(12, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int')); +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + if ($action == 'seteatby' && $user->rights->stock->creer) + { + $newvalue = dol_mktime(12, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); @@ -158,10 +110,6 @@ - if ($result < 0) { - setEventMessages($object->error, null, 'errors'); - $action = 'editeatby'; - } else { - $action = 'view'; - } - } - - if ($action == 'setsellby' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) { - $newvalue = dol_mktime(12, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int')); + if ($result < 0) dol_print_error($db, $object->error); + } + + if ($action == 'setsellby' && $user->rights->stock->creer) + { + $newvalue = dol_mktime(12, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); @@ -169,78 +117,17 @@ - if ($result < 0) { - setEventMessages($object->error, null, 'errors'); - $action = 'editsellby'; - } else { - $action = 'view'; - } - } - - if ($action == 'seteol_date' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) { - $newvalue = dol_mktime(12, 0, 0, GETPOST('eol_datemonth', 'int'), GETPOST('eol_dateday', 'int'), GETPOST('eol_dateyear', 'int')); - $result = $object->setValueFrom('eol_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); - if ($result < 0) { - setEventMessages($object->error, null, 'errors'); - $action = 'editeol_date'; - } else { - $action = 'view'; - } - } - - if ($action == 'setmanufacturing_date' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) { - $newvalue = dol_mktime(12, 0, 0, GETPOST('manufacturing_datemonth', 'int'), GETPOST('manufacturing_dateday', 'int'), GETPOST('manufacturing_dateyear', 'int')); - $result = $object->setValueFrom('manufacturing_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); - if ($result < 0) { - setEventMessages($object->error, null, 'errors'); - $action = 'editmanufacturing_date'; - } else { - $action = 'view'; - } - } - - if ($action == 'setscrapping_date' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) { - $newvalue = dol_mktime(12, 0, 0, GETPOST('scrapping_datemonth', 'int'), GETPOST('scrapping_dateday', 'int'), GETPOST('scrapping_dateyear', 'int')); - $result = $object->setValueFrom('scrapping_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); - if ($result < 0) { - setEventMessages($object->error, null, 'errors'); - $action = 'editscrapping_date'; - } else { - $action = 'view'; - } - } - - /* if ($action == 'setcommissionning_date' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) { - $newvalue = dol_mktime(12, 0, 0, GETPOST('commissionning_datemonth', 'int'), GETPOST('commissionning_dateday', 'int'), GETPOST('commissionning_dateyear', 'int')); - $result = $object->setValueFrom('commissionning_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); - if ($result < 0) { - setEventMessages($object->error, null, 'errors'); - $action == 'editcommissionning_date'; - } else { - $action = 'view'; - } - } */ - - if ($action == 'setqc_frequency' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) { - $result = $object->setValueFrom('qc_frequency', GETPOST('qc_frequency'), '', null, 'int', '', $user, 'PRODUCT_MODIFY'); - if ($result < 0) { // Prévoir un test de format de durée - setEventMessages($object->error, null, 'errors'); - $action = 'editqc_frequency'; - } else { - $action = 'view'; - } - } - - $triggermodname = 'PRODUCT_LOT_MODIFY'; // Name of trigger action code to execute when we modify record - - // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen - include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; - /* - if ($action == 'update_extras') { - $object->oldcopy = dol_clone($object, 2); - - // Fill array 'array_options' with data from update form - $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); - if ($ret < 0) $error++; - - if (!$error) { - // Actions on extra fields - $result = $object->insertExtraFields('PRODUCT_LOT_MODIFY'); - if ($result < 0) { + if ($result < 0) dol_print_error($db, $object->error); + } + + if ($action == 'update_extras') + { + $object->oldcopy = dol_clone($object); + + // Fill array 'array_options' with data from update form + $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); + if ($ret < 0) $error++; + + if (!$error) + { + // Actions on extra fields + $result = $object->insertExtraFields('PRODUCT_LOT_MODIFY'); + if ($result < 0) + { @@ -250,6 +137,5 @@ - } - - if ($error) { - $action = 'edit_extras'; - } - } + } + + if ($error) + $action = 'edit_extras'; + } @@ -258,2 +144,4 @@ - if ($action == 'add') { - if (GETPOST('cancel', 'alpha')) { + if ($action == 'add') + { + if (GETPOST('cancel', 'alpha')) + { @@ -267,8 +155,11 @@ - $object->entity = GETPOST('entity', 'int'); - $object->fk_product = GETPOST('fk_product', 'int'); - $object->batch = GETPOST('batch', 'alpha'); - $object->fk_user_creat = GETPOST('fk_user_creat', 'int'); - $object->fk_user_modif = GETPOST('fk_user_modif', 'int'); - $object->import_key = GETPOST('import_key', 'int'); - - if (empty($object->ref)) { + /* object_prop_getpost_prop */ + + $object->entity = GETPOST('entity', 'int'); + $object->fk_product = GETPOST('fk_product', 'int'); + $object->batch = GETPOST('batch', 'alpha'); + $object->fk_user_creat = GETPOST('fk_user_creat', 'int'); + $object->fk_user_modif = GETPOST('fk_user_modif', 'int'); + $object->import_key = GETPOST('import_key', 'int'); + + if (empty($object->ref)) + { @@ -279 +170,2 @@ - if (!$error) { + if (!$error) + { @@ -281 +173,2 @@ - if ($result > 0) { + if ($result > 0) + { @@ -290 +183 @@ - else setEventMessages($object->error, null, 'errors'); + else setEventMessages($object->error, null, 'errors'); @@ -293 +186,3 @@ - } else { + } + else + { @@ -302 +197,2 @@ - if ($action == 'update' && !GETPOST('cancel', 'alpha')) { + if ($action == 'update' && !GETPOST('cancel', 'alpha')) + { @@ -305,8 +201,9 @@ - $object->entity = GETPOST('entity', 'int'); - $object->fk_product = GETPOST('fk_product', 'int'); - $object->batch = GETPOST('batch', 'alpha'); - $object->fk_user_creat = GETPOST('fk_user_creat', 'int'); - $object->fk_user_modif = GETPOST('fk_user_modif', 'int'); - $object->import_key = GETPOST('import_key', 'int'); - - if (empty($object->ref)) { + $object->entity = GETPOST('entity', 'int'); + $object->fk_product = GETPOST('fk_product', 'int'); + $object->batch = GETPOST('batch', 'alpha'); + $object->fk_user_creat = GETPOST('fk_user_creat', 'int'); + $object->fk_user_modif = GETPOST('fk_user_modif', 'int'); + $object->import_key = GETPOST('import_key', 'int'); + + if (empty($object->ref)) + { @@ -317 +214,2 @@ - if (!$error) { + if (!$error) + { @@ -319 +217,2 @@ - if ($result > 0) { + if ($result > 0) + { @@ -321 +220,3 @@ - } else { + } + else + { @@ -327 +228,3 @@ - } else { + } + else + { @@ -333 +236,2 @@ - if ($action == 'confirm_delete') { + if ($action == 'confirm_delete') + { @@ -335 +239,2 @@ - if ($result > 0) { + if ($result > 0) + { @@ -340 +245,3 @@ - } else { + } + else + { @@ -345,9 +252,5 @@ - */ - // Action to build doc - include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; - - // Actions to send emails - $triggersendname = 'PRODUCT_LOT_SENTBYMAIL'; - $autocopy = 'MAIN_MAIL_AUTOCOPY_PRODUCT_LOT_TO'; - $trackid = 'productlot'.$object->id; - include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; + + // Actions to build doc + $upload_dir = $conf->productbatch->multidir_output[$conf->entity]; + $permissiontoadd = $usercancreate; + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; @@ -362,0 +266,2 @@ +llxHeader('', 'ProductLot', ''); + @@ -364,6 +268,0 @@ -$formfile = new FormFile($db); - -$title = $langs->trans("ProductLot"); -$help_url = ''; - -llxHeader('', $title, $help_url); @@ -373,2 +272,3 @@ -if ($action == 'create') { - print load_fiche_titre($langs->trans("Batch"), '', 'object_'.$object->picto); +if ($action == 'create') +{ + print load_fiche_titre($langs->trans("Batch")); @@ -377 +276,0 @@ - print ''; @@ -379,16 +278,12 @@ - if ($backtopage) { - print ''; - } - if ($backtopageforcancel) { - print ''; - } - - print dol_get_fiche_head(array(), ''); - - print ''."\n"; - - // Common attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; - - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + print ''; + + dol_fiche_head(); + + print '
'."\n"; + // print ''; + // + print ''; + print ''; + print ''; + print ''; + print ''; @@ -398,3 +293,3 @@ - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel("Create"); + dol_fiche_end(); + + print '
 
'; @@ -403,2 +297,0 @@ - - //dol_set_focus('input[name="ref"]'); @@ -409 +302,2 @@ -if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) +{ @@ -412,6 +306,6 @@ - $head = productlot_prepare_head($object); - print dol_get_fiche_head($head, 'card', $langs->trans("Batch"), -1, $object->picto); - - $formconfirm = ''; - - // Confirmation to delete + //print load_fiche_titre($langs->trans("Batch")); + + $head = productlot_prepare_head($object); + dol_fiche_head($head, 'card', $langs->trans("Batch"), -1, 'barcode'); + + @@ -420,16 +314,4 @@ - } - - // Call Hook formConfirm - $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } - - // Print form confirm - print $formconfirm; - - // Object card - // ------------------------------------------------------------ + print $formconfirm; + } + + @@ -438,12 +320,9 @@ - $shownav = 1; - if ($user->socid && !in_array('batch', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) { - $shownav = 0; - } - - $morehtmlref = ''; - - dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch', $morehtmlref); - - print '
'; - print '
'; - print '
'.$langs->trans("Label").'
'.$langs->trans("Fieldfk_product").'
'.$langs->trans("Fieldbatch").'
'.$langs->trans("Fieldfk_user_creat").'
'.$langs->trans("Fieldfk_user_modif").'
'.$langs->trans("Fieldimport_key").'
'."\n"; + $shownav = 1; + if ($user->socid && !in_array('batch', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + + dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch'); + + print '
'; + print '
'; + + print '
'."\n"; @@ -452,53 +331,25 @@ - print ''; - - // Sell by - if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) { - print ''; - print ''; - } - - // Eat by - if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) { - print ''; - print ''; - } - - if (getDolGlobalString('PRODUCT_LOT_ENABLE_TRACEABILITY')) { - print ''; - print ''; - print ''; - // print ''; - // print ''; - // print ''; - print ''; - print ''; - print ''; - } - - // Quality control - if (getDolGlobalString('PRODUCT_LOT_ENABLE_QUALITY_CONTROL')) { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + print ''; + + // Eat by + print ''; + print ''; + + // Sell by + print ''; + print ''; + + // Other attributes + $cols = 2; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; @@ -510,6 +361,26 @@ - print '
'; - - print dol_get_fiche_end(); - - // Link to other lists - print ''.img_object('', 'stock', 'class="pictofixedwidth"').$langs->trans("ShowCurrentStockOfLot").'
'; + dol_fiche_end(); + + + // Buttons + print '
'."\n"; + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + if (empty($reshook)) + { + /*TODO if ($user->rights->stock->lire) + { + print ''."\n"; + } + + if ($user->rights->stock->supprimer) + { + print ''."\n"; + } + */ + } + print '
'."\n"; + + + print ''.$langs->trans("ShowCurrentStockOfLot").'
'; @@ -517 +388 @@ - print ''.img_object('', 'movement', 'class="pictofixedwidth"').$langs->trans("ShowLogOfMovementIfLot").'
'; + print ''.$langs->trans("ShowLogOfMovementIfLot").'
'; @@ -520,22 +390,0 @@ - - - // Buttons for actions - if ($action != 'presend' && $action != 'editline') { - print '
'."\n"; - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } - - if (empty($reshook)) { - /*TODO - if ($user->hasRight('stock', 'lire')) { - print ''."\n"; - } - */ - print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete); - } - - print '
'."\n"; - } @@ -547 +396 @@ - * Generated documents + * Documents generes @@ -550,26 +399,15 @@ -if ($action != 'presend') { - print '
'; - print ''; // ancre - - $includedocgeneration = 1; - - // Documents - if ($includedocgeneration) { - $objref = dol_sanitizeFileName($object->ref); - $relativepath = $objref.'/'.$objref.'.pdf'; - $filedir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'product_batch'); - $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $usercanread; // If you can read, you can build the PDF to read content - $delallowed = $usercancreate; // If you can create/edit, you can remove a file on card - print $formfile->showdocuments('product_batch', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, '', 0, '', (empty($object->default_lang) ? '' : $object->default_lang), '', $object); - } - - print '
'; - - $MAXEVENT = 10; - - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'productlot', 0, 1, '', $MAXEVENT); - - print '
'; +if (empty($action)) +{ + print '
'; + print ''; // ancre + + // Documents + $filedir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product_batch').dol_sanitizeFileName($object->ref); + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed = $usercanread; + $delallowed = $usercancreate; + + print $formfile->showdocuments('product_batch', dol_sanitizeFileName($object->ref), $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object); + $somethingshown = $formfile->numoffiles; + + print '
'; --- /tmp/dsg/dolibarr/htdocs/product/stock/github_19.0.3_productlot_document.php +++ /tmp/dsg/dolibarr/htdocs/product/stock/client_productlot_document.php @@ -29 +29 @@ - * \brief Page of attached documents for product lots + * \brief Page des documents joints sur les lots produits @@ -32 +31,0 @@ -// Load Dolibarr environment @@ -41,2 +39,0 @@ -global $conf, $db, $langs, $user; - @@ -46,3 +43,3 @@ -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); @@ -54,3 +51 @@ -if ($user->socid) { - $socid = $user->socid; -} +if ($user->socid) $socid = $user->socid; @@ -64,2 +59,2 @@ -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -67,3 +62 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -73,6 +66,2 @@ -if (!$sortorder) { - $sortorder = "ASC"; -} -if (!$sortfield) { - $sortfield = "position_name"; -} +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "position_name"; @@ -82,8 +71,10 @@ -if ($id || $ref) { - if ($ref) { - $tmp = explode('_', $ref); - $productid = $tmp[0]; - $batch = $tmp[1]; - } - $object->fetch($id, $productid, $batch); - $object->ref = $object->batch; // Old system for document management ( it uses $object->ref) +if ($id || $ref) +{ + if ($ref) + { + $tmp = explode('_', $ref); + $productid = $tmp[0]; + $batch = $tmp[1]; + } + $object->fetch($id, $productid, $batch); + $object->ref = $object->batch; // For document management ( it use $object->ref) @@ -91,36 +82 @@ - if (isModEnabled('productbatch')) { - $upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, $modulepart); - $filearray = dol_dir_list($upload_dir, "files"); - if (empty($filearray)) { - // If no files linked yet, use new system on lot id. (Batch is not unique and can be same on different product) - $object->fetch($id, $productid, $batch); - $upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, $modulepart); - } - } -} - -$usercanread = $user->hasRight('produit', 'lire'); -$usercancreate = $user->hasRight('produit', 'creer'); -$usercandelete = $user->hasRight('produit', 'supprimer'); - -if (empty($upload_dir)) { - $upload_dir = $conf->productbatch->multidir_output[$conf->entity]; -} - -$permissiontoread = $usercanread; -$permissiontoadd = $usercancreate; -$permtoedit = $user->rights->produit->creer; -//$permissiontodelete = $usercandelete; - -// Security check -if (!isModEnabled('productbatch')) { - accessforbidden('Module not enabled'); -} -$socid = 0; -if ($user->socid > 0) { // Protection if external user - //$socid = $user->socid; - accessforbidden(); -} -//$result = restrictedArea($user, 'productbatch'); -if (!$permissiontoread) { - accessforbidden(); + if (!empty($conf->productbatch->enabled)) $upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, $modulepart).dol_sanitizeFileName($object->ref); @@ -136,2 +92,6 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + // Action submit/delete file/link + include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; @@ -140,4 +100 @@ -if (empty($reshook)) { - // Action submit/delete file/link - include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; -} +$permtoedit = $user->rights->produit->creer; @@ -155 +112,2 @@ -if ($object->id) { +if ($object->id) +{ @@ -157 +115 @@ - print dol_get_fiche_head($head, 'documents', $langs->trans("Batch"), -1, 'barcode'); + dol_fiche_head($head, 'documents', $langs->trans("Batch"), -1, 'barcode'); @@ -162,4 +120,2 @@ - print $hookmanager->resPrint; - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } + print $hookmanager->resPrint; + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -168 +124 @@ - $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); @@ -171 +127,2 @@ - foreach ($filearray as $key => $file) { + foreach ($filearray as $key => $file) + { @@ -176 +133 @@ - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; @@ -178,4 +135,2 @@ - $shownav = 1; - if ($user->socid && !in_array('batch', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) { - $shownav = 0; - } + $shownav = 1; + if ($user->socid && !in_array('batch', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; @@ -185 +140 @@ - print '
'; + print '
'; @@ -187,2 +142,2 @@ - print '
'; - print '
'.$langs->trans("Product").''; - $producttmp = new Product($db); - $producttmp->fetch($object->fk_product); - print $producttmp->getNomUrl(1, 'stock')." - ".$producttmp->label; - print '
'; - print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->hasRight('stock', 'creer'), 'datepicker'); - print ''; - print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->hasRight('stock', 'creer'), 'datepicker', '', null, null, '', 1, '', 'id', 'auto', array(), $action); - print '
'; - print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->hasRight('stock', 'creer'), 'datepicker'); - print ''; - print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->hasRight('stock', 'creer'), 'datepicker', '', null, null, '', 1, '', 'id', 'auto', array(), $action); - print '
'.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->hasRight('stock', 'creer')).''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').'
'.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->hasRight('stock', 'creer')).''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').'
'.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->hasRight('stock', 'creer')).''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').'
'.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->hasRight('stock', 'creer')).''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').'
'.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->hasRight('stock', 'creer')).''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->hasRight('stock', 'creer'), 'string').'
'.$form->editfieldkey($langs->trans('Lifetime'), 'lifetime', $object->lifetime, $object, $user->hasRight('stock', 'creer')).''.$form->editfieldval($langs->trans('Lifetime'), 'lifetime', $object->lifetime, $object, $user->hasRight('stock', 'creer'), 'string').'
'.$langs->trans("Product").''; + $producttmp = new Product($db); + $producttmp->fetch($object->fk_product); + print $producttmp->getNomUrl(1, 'stock'); + print '
'; + print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + print ''; + print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + print '
'; + print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + print ''; + print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + print '
'; + print '
'; + print '
'; @@ -190,6 +145,3 @@ - // Product - print ''; + print ''; + print ''; + print '
'.$langs->trans("Product").''; - $producttmp = new Product($db); - $producttmp->fetch($object->fk_product); - print $producttmp->getNomUrl(1, 'stock')." - ".$producttmp->label; - print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
'; @@ -197,3 +149,2 @@ - print ''.$langs->trans("NbOfAttachedFiles").''.count($filearray).''; - print ''.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).''; - print ''; + print '
'; + print '
'; @@ -201,2 +152 @@ - print '
'; - print '
'; + dol_fiche_end(); @@ -204,5 +154,6 @@ - print dol_get_fiche_end(); - - $param = '&id='.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; -} else { + $permission = ($user->rights->produit->creer); + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; +} +else +{ --- /tmp/dsg/dolibarr/htdocs/product/stock/github_19.0.3_productlot_list.php +++ /tmp/dsg/dolibarr/htdocs/product/stock/client_productlot_list.php @@ -3 +3 @@ - * Copyright (C) 2018-2021 Ferran Marcet + * Copyright (C) 2018 Ferran Marcet @@ -27 +26,0 @@ -// Load Dolibarr environment @@ -40,2 +39 @@ -$action = GETPOST('action', 'aZ09'); -$massaction = GETPOST('massaction', 'alpha'); +$action = GETPOST('action', 'alpha'); @@ -43,2 +41 @@ -$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'productlotlist'; // To manage different context of search +$toselect = GETPOST('toselect', 'array'); @@ -46 +42,0 @@ -$mode = GETPOST('mode', 'alpha'); @@ -56,3 +52,3 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); @@ -60,4 +56 @@ -if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { - // If $page is not defined, or '' or -1 or if we click on clear filters - $page = 0; -} +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -66,0 +60,10 @@ +if (!$sortfield) $sortfield = "t.batch"; // Set here default search field +if (!$sortorder) $sortorder = "ASC"; + +// Protection if external user +$socid = 0; +if ($user->socid > 0) +{ + $socid = $user->socid; + //accessforbidden(); +} @@ -69,0 +73 @@ +$hookmanager->initHooks(array('product_lotlist')); @@ -71,4 +75,2 @@ -$diroutputmassaction = $conf->productbatch->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('product_lotlist')); - -// Fetch optionals attributes and labels + +// fetch optionals attributes and labels @@ -76 +77,0 @@ -//$extrafields->fetch_name_optionals_label($object->table_element_line); @@ -80,21 +80,0 @@ -// Default sort order (if not yet defined by previous GETPOST) -if (!$sortfield) { - $sortfield = "t.fk_product,t.batch"; // Set here default search field. By default 1st field in definition. -} -if (!$sortorder) { - $sortorder = "ASC"; -} - -// Initialize array of search criterias -$search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'); -$search = array(); -foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha') !== '') { - $search[$key] = GETPOST('search_'.$key, 'alpha'); - } - if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int')); - $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int')); - } -} - @@ -102,22 +82,20 @@ -$fieldstosearchall = array(); -foreach ($object->fields as $key => $val) { - if (!empty($val['searchall'])) { - $fieldstosearchall['t.'.$key] = $val['label']; - } -} - -// Definition of array of fields for columns -$arrayfields = array(); -foreach ($object->fields as $key => $val) { - // If $val['visible']==0, then we never show the field - if (!empty($val['visible'])) { - $visible = (int) dol_eval($val['visible'], 1); - $arrayfields['t.'.$key] = array( - 'label'=>$val['label'], - 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)), - 'position'=>$val['position'], - 'help'=> isset($val['help']) ? $val['help'] : '' - ); - } -} +$fieldstosearchall = array( + 't.ref'=>'Ref', + 't.note_public'=>'NotePublic', +); + +// Definition of fields for list +$arrayfields = array( + //'t.entity'=>array('label'=>$langs->trans("Fieldentity"), 'checked'=>1), + 't.batch'=>array('label'=>$langs->trans("Batch"), 'checked'=>1), + 't.fk_product'=>array('label'=>$langs->trans("Product"), 'checked'=>1), + 't.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>1), + 't.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>1), + //'t.import_key'=>array('label'=>$langs->trans("ImportId"), 'checked'=>1), + //'t.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))), + //'t.fk_user_creat'=>array('label'=>$langs->trans("UserCreationShort"), 'checked'=>0, 'position'=>500), + //'t.fk_user_modif'=>array('label'=>$langs->trans("UserModificationShort"), 'checked'=>0, 'position'=>500), + 't.datec'=>array('label'=>$langs->trans("DateCreationShort"), 'checked'=>0, 'position'=>500), + 't.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + //'t.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), +); @@ -125,2 +103,8 @@ -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; - +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) +{ + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } +} @@ -130,23 +114,7 @@ -$usercanread = $user->rights->produit->lire; -$usercancreate = $user->rights->produit->creer; -$usercandelete = $user->rights->produit->supprimer; - -$upload_dir = $conf->productbatch->multidir_output[$conf->entity]; - -$permissiontoread = $usercanread; -$permissiontoadd = $usercancreate; -//$permissiontodelete = $usercandelete; - -// Security check -if (empty($conf->productbatch->enabled)) { - accessforbidden('Module not enabled'); -} -$socid = 0; -if ($user->socid > 0) { // Protection if external user - //$socid = $user->socid; - accessforbidden(); -} -//$result = restrictedArea($user, 'productbatch'); -if (!$permissiontoread) { - accessforbidden(); -} +// Load object if id or ref is provided as parameter +if (($id > 0 || !empty($ref)) && $action != 'add') +{ + $result = $object->fetch($id, $ref); + if ($result < 0) dol_print_error($db); +} + @@ -159,7 +127,2 @@ -if (GETPOST('cancel', 'alpha')) { - $action = 'list'; - $massaction = ''; -} -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { - $massaction = ''; -} +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'confirm_presend') { $massaction = ''; } @@ -169,26 +132,22 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - // Selection of new fields - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers - foreach ($object->fields as $key => $val) { - $search[$key] = ''; - if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - $search[$key.'_dtstart'] = ''; - $search[$key.'_dtend'] = ''; - } - } - $toselect = array(); - $search_array_options = array(); - } - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { - $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation - } - - // Mass actions +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + +// Purge search criteria +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers +{ + $search_entity = ''; + $search_product = ''; + $search_batch = ''; + $search_fk_user_creat = ''; + $search_fk_user_modif = ''; + $search_import_key = ''; + $search_date_creation = ''; + $search_date_update = ''; + $toselect = array(); + $search_array_options = array(); +} + + +if (empty($reshook)) +{ @@ -197 +156,3 @@ - $uploaddir = $conf->productbatch->dir_output; + $permissiontoread = $user->rights->stock->read; + $permissiontodelete = $user->rights->stock->delete; + $uploaddir = $conf->stock->dir_output; @@ -201,0 +163,2 @@ + + @@ -203 +166 @@ - * View + * VIEW @@ -205,0 +169 @@ +$now = dol_now(); @@ -208,4 +172,4 @@ - -$now = dol_now(); - -$help_url = 'EN:Module_Lot_/_Serial|FR:Module_Lot_/_Série'; +$productstatic = new Product($db); + +//$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; +$help_url = ''; @@ -213,9 +177,39 @@ -$morejs = array(); -$morecss = array(); - - -// Build and execute select -// -------------------------------------------------------------------- -$sql = 'SELECT '; -$sql .= $object->getFieldList('t'); -// Add fields from extrafields +llxHeader('', $title, $help_url); + +// Put here content of your page + +// Example : Adding jquery code +print ''; + + +$sql = "SELECT"; +$sql .= " t.rowid,"; +$sql .= " t.entity,"; +$sql .= " t.fk_product,"; +$sql .= " t.batch,"; +$sql .= " t.sellby,"; +$sql .= " t.eatby,"; +$sql .= " t.datec as date_creation,"; +$sql .= " t.tms as date_update,"; +$sql .= " t.fk_user_creat,"; +$sql .= " t.fk_user_modif,"; +$sql .= " t.import_key,"; +$sql .= " p.fk_product_type as product_type,"; +$sql .= " p.ref as product_ref,"; +$sql .= " p.label as product_label,"; +$sql .= " p.tosell,"; +$sql .= " p.tobuy,"; +$sql .= " p.tobatch"; +// Add fields for extrafields @@ -223,3 +217 @@ - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); - } + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); @@ -229 +221 @@ -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook @@ -231,50 +223,14 @@ -$sql = preg_replace('/,\s*$/', '', $sql); - -$sqlfields = $sql; - -$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; -} -// Add table from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; -if ($object->ismultientitymanaged == 1) { - $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; -} else { - $sql .= " WHERE 1 = 1"; -} -foreach ($search as $key => $val) { - if (array_key_exists($key, $object->fields)) { - if ($key == 'status' && $search[$key] == -1) { - continue; - } - $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); - if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) { - if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) { - $search[$key] = ''; - } - $mode_search = 2; - } - if ($search[$key] != '') { - $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search)); - } - } else { - if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') { - $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key); - if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) { - if (preg_match('/_dtstart$/', $key)) { - $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'"; - } - if (preg_match('/_dtend$/', $key)) { - $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'"; - } - } - } - } -} -if ($search_all) { - $sql .= natural_search(array_keys($fieldstosearchall), $search_all); -} -//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear); +$sql .= " FROM ".MAIN_DB_PREFIX."product_lot as t"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +$sql .= ", ".MAIN_DB_PREFIX."product as p"; +$sql .= " WHERE p.rowid = t.fk_product"; +$sql .= " AND p.entity IN (".getEntity('product').")"; + +if ($search_entity) $sql .= natural_search("entity", $search_entity); +if ($search_product) $sql .= natural_search("p.ref", $search_product); +if ($search_batch) $sql .= natural_search("batch", $search_batch); +if ($search_fk_user_creat) $sql .= natural_search("fk_user_creat", $search_fk_user_creat); +if ($search_fk_user_modif) $sql .= natural_search("fk_user_modif", $search_fk_user_modif); +if ($search_import_key) $sql .= natural_search("import_key", $search_import_key); + +if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); @@ -285 +241 @@ -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook @@ -287,18 +243,2 @@ - -/* If a group by is required -$sql.= " GROUP BY "; -foreach($object->fields as $key => $val) { - $sql .= "t.".$db->escape($key).", "; -} -// Add fields from extrafields -if (!empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); - } -} -// Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/,\s*$/','', $sql); -*/ +$sql .= $db->order($sortfield, $sortorder); +//$sql.= $db->plimit($conf->liste_limit+1, $offset); @@ -308,27 +248,6 @@ -if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - /* This old and fast method to get and count full list returns all record so use a high amount of memory. - $resql = $db->query($sql); - $nbtotalofrecords = $db->num_rows($resql); - */ - /* The slow method does not consume memory on mysql (not tested on pgsql) */ - /*$resql = $db->query($sql, 0, 'auto', 1); - while ($db->fetch_object($resql)) { - if (empty($nbtotalofrecords)) { - $nbtotalofrecords = 1; // We can't make +1 because init value is '' - } else { - $nbtotalofrecords++; - } - }*/ - /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); - $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); - - $resql = $db->query($sqlforcount); - if ($resql) { - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; - } else { - dol_print_error($db); - } - - if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { @@ -338,9 +257,6 @@ - $db->free($resql); -} - -// Complete request and execute it with limit -$sql .= $db->order($sortfield, $sortorder); -if ($limit) { - $sql .= $db->plimit($limit + 1, $offset); -} - +} + +$sql .= $db->plimit($limit + 1, $offset); + + +dol_syslog($script_file, LOG_DEBUG); @@ -348,123 +264,54 @@ -if (!$resql) { - dol_print_error($db); - exit; -} - -$num = $db->num_rows($resql); - -$i = 0; - -// Direct jump if only one record found -if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) { - $obj = $db->fetch_object($resql); - $id = $obj->rowid; - header("Location: ".DOL_URL_ROOT.'/product/stock/productlot_card.php?id='.$id); - exit; -} - - -// Output page -// -------------------------------------------------------------------- - -llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); - -$arrayofselected = is_array($toselect) ? $toselect : array(); - -$param = ''; -if (!empty($mode)) { - $param .= '&mode='.urlencode($mode); -} -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); -} -if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); -} -foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) { - foreach ($search[$key] as $skey) { - if ($skey != '') { - $param .= '&search_'.$key.'[]='.urlencode($skey); - } - } - } elseif ($search[$key] != '') { - $param .= '&search_'.$key.'='.urlencode($search[$key]); - } -} -if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); -} -// Add $param from extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; -// Add $param from hooks -$parameters = array('param' => &$param); -$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook -$param .= $hookmanager->resPrint; - -// List of mass actions available -$arrayofmassactions = array( - //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"), - //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), - //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), - //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), -); -if (!empty($permissiontodelete)) { - $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); -} -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { - $arrayofmassactions = array(); -} -$massactionbutton = $form->selectMassAction('', $arrayofmassactions); - -print '
'."\n"; -if ($optioncss != '') { - print ''; -} -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; - -$newcardbutton = ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/product/stock/productlot_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); - -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); - -// Add code for pre mass action (confirmation or email presend form) -$topicmail = "Information"; -$modelmail = "productlot"; -$objecttmp = new Productlot($db); -$trackid = 'lot'.$object->id; -include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - -if ($search_all) { - $setupstring = ''; - foreach ($fieldstosearchall as $key => $val) { - $fieldstosearchall[$key] = $langs->trans($val); - $setupstring .= $key."=".$val.";"; - } - print ''."\n"; - print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n"; -} - -// Filter on categories -$moreforfilter = ''; -/*$moreforfilter.='
'; - $moreforfilter.= $langs->trans('MyFilter') . ': '; - $moreforfilter.= '
';*/ - -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook -if (empty($reshook)) { - $moreforfilter .= $hookmanager->resPrint; -} else { - $moreforfilter = $hookmanager->resPrint; -} - -if (!empty($moreforfilter)) { - print '
'; - print $moreforfilter; +if ($resql) +{ + $num = $db->num_rows($resql); + + $arrayofselected = is_array($toselect) ? $toselect : array(); + + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if ($search_entity != '') $param .= '&search_entity='.urlencode($search_entity); + if ($search_product != '') $param .= '&search_product='.urlencode($search_product); + if ($search_batch != '') $param .= '&search_batch='.urlencode($search_batch); + if ($search_fk_user_creat != '') $param .= '&search_fk_user_creat='.urlencode($search_fk_user_creat); + if ($search_fk_user_modif != '') $param .= '&search_fk_user_modif='.urlencode($search_fk_user_modif); + if ($search_import_key != '') $param .= '&search_import_key='.urlencode($search_import_key); + if ($optioncss != '') $param .= '&optioncss='.$optioncss; + // Add $param from extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + + $arrayofmassactions = array( + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), + ); + //if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); + + print ''; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'lot', 0, '', '', $limit, 0, 0, 1); + + $topicmail = "Information"; + $modelmail = "productlot"; + $objecttmp = new Productlot($db); + $trackid = 'lot'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + + if ($sall) + { + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; + } + + /*$moreforfilter = ''; + $moreforfilter.='
'; + $moreforfilter.= $langs->trans('MyFilter') . ': '; + $moreforfilter.= '
';*/ + @@ -472,0 +320,32 @@ + if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; + else $moreforfilter = $hookmanager->resPrint; + + if (!empty($moreforfilter)) + { + print '
'; + print $moreforfilter; + print '
'; + } + + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + + print '
'; + print ''."\n"; + + // Fields title search + print ''; + if (!empty($arrayfields['t.entity']['checked'])) print ''; + if (!empty($arrayfields['t.batch']['checked'])) print ''; + if (!empty($arrayfields['t.fk_product']['checked'])) print ''; + if (!empty($arrayfields['t.sellby']['checked'])) print ''; + if (!empty($arrayfields['t.eatby']['checked'])) print ''; + if (!empty($arrayfields['t.fk_user_creat']['checked'])) print ''; + if (!empty($arrayfields['t.fk_user_modif']['checked'])) print ''; + if (!empty($arrayfields['t.import_key']['checked'])) print ''; + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook @@ -474,16 +353,20 @@ - print ''; -} - -$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields -$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); - -print '
'; -print '
'."\n"; - - -// Fields title search -// -------------------------------------------------------------------- -print ''; -// Action column -if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + if (!empty($arrayfields['t.datec']['checked'])) + { + // Date creation + print ''; + } + if (!empty($arrayfields['t.tms']['checked'])) + { + // Date modification + print ''; + } + /*if (! empty($arrayfields['u.statut']['checked'])) + { + // Status + print ''; + }*/ + // Action column @@ -491 +374 @@ - $searchpicto = $form->showFilterButtons('left'); + $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); @@ -494,32 +377,135 @@ -} -foreach ($object->fields as $key => $val) { - $searchkey = empty($search[$key]) ? '' : $search[$key]; - $cssforfield = (empty($val['css']) ? '' : $val['css']); - if ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''."\n"; + + // Fields title + print ''; + if (!empty($arrayfields['t.entity']['checked'])) print_liste_field_titre($arrayfields['t.entity']['label'], $_SERVER['PHP_SELF'], 't.entity', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.batch']['checked'])) print_liste_field_titre($arrayfields['t.batch']['label'], $_SERVER['PHP_SELF'], 't.batch', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.fk_product']['checked'])) print_liste_field_titre($arrayfields['t.fk_product']['label'], $_SERVER['PHP_SELF'], 't.fk_product', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.sellby']['checked'])) print_liste_field_titre($arrayfields['t.sellby']['label'], $_SERVER['PHP_SELF'], 't.sellby', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.eatby']['checked'])) print_liste_field_titre($arrayfields['t.eatby']['label'], $_SERVER['PHP_SELF'], 't.eatby', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.fk_user_creat']['checked'])) print_liste_field_titre($arrayfields['t.fk_user_creat']['label'], $_SERVER['PHP_SELF'], 't.fk_user_creat', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.fk_user_modif']['checked'])) print_liste_field_titre($arrayfields['t.fk_user_modif']['label'], $_SERVER['PHP_SELF'], 't.fk_user_modif', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.import_key']['checked'])) print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER['PHP_SELF'], 't.import_key', '', $param, '', $sortfield, $sortorder); + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + // Hook fields + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (!empty($arrayfields['t.datec']['checked'])) { + print_liste_field_titre($arrayfields['t.datec']['label'], $_SERVER["PHP_SELF"], "t.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + if (!empty($arrayfields['t.tms']['checked'])) { + print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER["PHP_SELF"], "t.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + //if (! empty($arrayfields['t.status']['checked'])) { + // print_liste_field_titre($arrayfields['t.status']['label'], $_SERVER["PHP_SELF"], "t.status", "", $param, '', $sortfield, $sortorder, 'center '); + //} + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + print ''."\n"; + + $productlot = new Productlot($db); + + $i = 0; + $totalarray = array(); + while ($i < min($num, $limit)) + { + $obj = $db->fetch_object($resql); + if ($obj) + { + $productlot->id = $obj->rowid; + $productlot->status = $obj->tosell; + $productlot->batch = $obj->batch; + + // You can use here results + print ''; + if (!empty($arrayfields['t.entity']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['t.batch']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['t.fk_product']['checked'])) + { + $productstatic->id = $obj->fk_product; + $productstatic->type = $obj->product_type; + $productstatic->ref = $obj->product_ref; + $productstatic->label = $obj->product_label; + $productstatic->status = $obj->tosell; + $productstatic->status_buy = $obj->tobuy; + $productstatic->status_batch = $obj->tobatch; + + print ''; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['t.sellby']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['t.eatby']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['t.fk_user_creat']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['t.fk_user_modif']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['t.import_key']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['t.datec']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Date modification + if (!empty($arrayfields['t.tms']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Status + /* + if (! empty($arrayfields['u.statut']['checked'])) + { + $userstatic->statut=$obj->statut; + print ''; + }*/ + + // Action column + print ''; + if (!$i) $totalarray['nbfield']++; + + print ''; @@ -527,162 +513,10 @@ - print ''; - } -} -// Extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; - -// Fields from hook -$parameters = array('arrayfields'=>$arrayfields); -$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; -/*if (!empty($arrayfields['anotherfield']['checked'])) { - print ''; - }*/ -// Action column -if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; -} -print ''."\n"; - -$totalarray = array(); -$totalarray['nbfield'] = 0; - -// Fields title label -// -------------------------------------------------------------------- -print ''; -if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; -} -foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label - if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; - $totalarray['nbfield']++; - } -} -// Extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; -// Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); -$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; -// Action column -if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; -} -$totalarray['nbfield']++; -print ''."\n"; - - -// Detect if we need a fetch on each output line -$needToFetchEachLine = 0; -if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { - foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (!is_null($val) && preg_match('/\$object/', $val)) { - $needToFetchEachLine++; // There is at least one compute field that use $object - } - } -} - - -// Loop on record -// -------------------------------------------------------------------- -$i = 0; -$savnbfield = $totalarray['nbfield']; -$totalarray['nbfield'] = 0; -$imaxinloop = ($limit ? min($num, $limit) : $num); -while ($i < $imaxinloop) { - $obj = $db->fetch_object($resql); - if (empty($obj)) { - break; // Should not happen - } - - // Store properties in $object - $object->setVarsFromFetchObj($obj); - - // Show here line of result - $j = 0; - print ''; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } - - if (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif ($key == 'ref' || $key == 'batch') { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } - - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; - - if (!empty($arrayfields['t.'.$key]['checked'])) { - print '$key)) { - print ' title="'.dol_escape_htmltag($object->$key).'"'; - } - print '>'; - if ($key == 'status') { - print $object->getLibStatut(5); - } elseif ($key == 'rowid') { - print $object->showOutputField($val, $key, $object->id, ''); - } else { - if ($key == 'batch') { - print $object->getNomUrl(1); - } else { - print $object->showOutputField($val, $key, $object->$key, ''); - } - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!empty($val['isameasure']) && $val['isameasure'] == 1) { - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; - } - if (!isset($totalarray['val'])) { - $totalarray['val'] = array(); - } - if (!isset($totalarray['val']['t.'.$key])) { - $totalarray['val']['t.'.$key] = 0; - } - $totalarray['val']['t.'.$key] += $object->$key; - } - } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $i++; + } + + // Show total line + include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + + $db->free($resql); + + $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook @@ -690,65 +524,25 @@ - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - - print ''."\n"; - - $i++; -} - -// Show total line -include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; - -// If no record found -if ($num == 0) { - $colspan = 1; - foreach ($arrayfields as $key => $val) { - if (!empty($val['checked'])) { - $colspan++; - } - } - print ''; -} - - -$db->free($resql); - -$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; - -print '
'; + print ''; + print ''; + print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut); + print ''; - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { - print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); - } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) { - print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1); - } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - print '
'; - print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; - } elseif ($key == 'lang') { - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; - $formadmin = new FormAdmin($db); - print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2); - } else { - print ''; + print '
'.$obj->entity.''.$productlot->getNomUrl(1).''.$productstatic->getNomUrl(1).''.dol_print_date($db->jdate($obj->sellby), 'day').''.dol_print_date($db->jdate($obj->eatby), 'day').''.$obj->fk_user_creat.''.$obj->fk_user_modif.''.$obj->import_key.''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''.$userstatic->getLibStatut(3).''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; + } + print '
'; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print '
'; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($object->id, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($object->id, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print '
'.$langs->trans("NoRecordFound").'
'."\n"; -print '
'."\n"; - -print ''."\n"; - -if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { - $hidegeneratedfilelistifempty = 0; - } - - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; - $formfile = new FormFile($db); - - // Show list of available documents - $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource .= str_replace('&', '&', $param); - - $filedir = $diroutputmassaction; - $genallowed = $permissiontoread; - $delallowed = $permissiontoadd; - - print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); + + print ''."\n"; + print '
'; + + print ''."\n"; + + /* + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); + + $filedir=$diroutputmassaction; + $genallowed=$user->rights->facture->lire; + $delallowed=$user->rights->facture->creer; + + print $formfile->showdocuments('massfilesarea_orders','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); + */ +} +else +{ + $error++; + dol_print_error($db); --- /tmp/dsg/dolibarr/htdocs/product/stock/github_19.0.3_replenish.php +++ /tmp/dsg/dolibarr/htdocs/product/stock/client_replenish.php @@ -8,2 +7,0 @@ - * Copyright (C) 2021 Ferran Marcet - * Copyright (C) 2021 Antonin MARCHAL @@ -31 +28,0 @@ -// Load Dolibarr environment @@ -33,5 +30,5 @@ -require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php'; -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php'; -require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; @@ -45 +42 @@ - $socid = $user->socid; + $socid = $user->socid; @@ -54,4 +51,4 @@ -$action = GETPOST('action', 'aZ09'); -$search_ref = GETPOST('search_ref', 'alpha'); -$search_label = GETPOST('search_label', 'alpha'); -$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$action = GETPOST('action', 'alpha'); +$sref = GETPOST('sref', 'alpha'); +$snom = GETPOST('snom', 'alpha'); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); @@ -61 +57,0 @@ -$includeproductswithoutdesiredqty = GETPOST('includeproductswithoutdesiredqty', 'alpha'); @@ -69,19 +64,0 @@ - -// List all visible warehouses -$resWar = $db->query("SELECT rowid FROM " . MAIN_DB_PREFIX . "entrepot WHERE entity IN (" . $db->sanitize(getEntity('stock')) . ")"); -$listofqualifiedwarehousesid = ""; -$count = 0; -while ($tmpobj = $db->fetch_object($resWar)) { - if (!empty($listofqualifiedwarehousesid)) { - $listofqualifiedwarehousesid .= ","; - } - $listofqualifiedwarehousesid .= $tmpobj->rowid; - $lastWarehouseID = $tmpobj->rowid; - $count++; -} - -//MultiCompany : If only 1 Warehouse is visible, filter will automatically be set to it. -if ($count == 1 && (empty($fk_entrepot) || $fk_entrepot <= 0) && getDolGlobalString('MULTICOMPANY_PRODUCT_SHARING_ENABLED')) { - $fk_entrepot = $lastWarehouseID; -} - @@ -90,2 +67,2 @@ -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); @@ -93,4 +70,2 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -100 +75 @@ - $sortfield = 'p.ref'; + $sortfield = 'p.ref'; @@ -104 +79 @@ - $sortorder = 'ASC'; + $sortorder = 'ASC'; @@ -109,20 +84,13 @@ -if (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT') - || getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER') - || getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE') - || getDolGlobalString('STOCK_CALCULATE_ON_RECEPTION') - || getDolGlobalString('STOCK_CALCULATE_ON_RECEPTION_CLOSE') - || isModEnabled('mrp')) { - $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs. -} - -if ($virtualdiffersfromphysical) { - $usevirtualstock = !getDolGlobalString('STOCK_USE_REAL_STOCK_BY_DEFAULT_FOR_REPLENISHMENT') ? 1 : 0; -} else { - $usevirtualstock = 0; -} -if ($mode == 'physical') { - $usevirtualstock = 0; -} -if ($mode == 'virtual') { - $usevirtualstock = 1; -} +if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) + || !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) + || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE) + || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) + || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) + || !empty($conf->mrp->enabled)) +{ + $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs. +} + +$usevirtualstock = !empty($conf->global->STOCK_USE_VIRTUAL_STOCK); +if ($mode == 'physical') $usevirtualstock = 0; +if ($mode == 'virtual') $usevirtualstock = 1; @@ -132,3 +100 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -141,6 +107,6 @@ -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers - $search_ref = ''; - $search_label = ''; - $sall = ''; - $salert = ''; - $includeproductswithoutdesiredqty = ''; +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || isset($_POST['valid'])) // Both test are required to be compatible with all browsers +{ + $sref = ''; + $snom = ''; + $sall = ''; + $salert = ''; @@ -149,4 +115 @@ -$draftchecked = ""; -if ($draftorder == 'on') { - $draftchecked = "checked"; -} +if ($draftorder == 'on') $draftchecked = "checked"; @@ -155,3 +118,4 @@ -if ($action == 'order' && GETPOST('valid')) { - $linecount = GETPOST('linecount', 'int'); - $box = 0; +if ($action == 'order' && isset($_POST['valid'])) +{ + $linecount = GETPOST('linecount', 'int'); + $box = 0; @@ -159,6 +123,7 @@ - unset($_POST['linecount']); - if ($linecount > 0) { - $db->begin(); - - $suppliers = array(); - require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php'; + unset($_POST['linecount']); + if ($linecount > 0) + { + $db->begin(); + + $suppliers = array(); + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; @@ -166,7 +131,9 @@ - for ($i = 0; $i < $linecount; $i++) { - if (GETPOST('choose' . $i, 'alpha') === 'on' && GETPOST('fourn' . $i, 'int') > 0) { - //one line - $box = $i; - $supplierpriceid = GETPOST('fourn' . $i, 'int'); - //get all the parameters needed to create a line - $qty = GETPOST('tobuy' . $i, 'int'); + for ($i = 0; $i < $linecount; $i++) + { + if (GETPOST('choose'.$i, 'alpha') === 'on' && GETPOST('fourn'.$i, 'int') > 0) + { + //one line + $box = $i; + $supplierpriceid = GETPOST('fourn'.$i, 'int'); + //get all the parameters needed to create a line + $qty = GETPOST('tobuy'.$i, 'int'); @@ -175,12 +142,15 @@ - if ($res && $idprod > 0) { - if ($qty) { - //might need some value checks - $line = new CommandeFournisseurLigne($db); - $line->qty = $qty; - $line->fk_product = $idprod; - - //$product = new Product($db); - //$product->fetch($obj->fk_product); - if (getDolGlobalInt('MAIN_MULTILANGS')) { - $productsupplier->getMultiLangs(); - } + if ($res && $idprod > 0) + { + if ($qty) + { + //might need some value checks + $line = new CommandeFournisseurLigne($db); + $line->qty = $qty; + $line->fk_product = $idprod; + + //$product = new Product($db); + //$product->fetch($obj->fk_product); + if (!empty($conf->global->MAIN_MULTILANGS)) + { + $productsupplier->getMultiLangs(); + } @@ -189 +159 @@ - if (!empty($productsupplier->desc_supplier) && getDolGlobalString('PRODUIT_FOURN_TEXTS')) { + if (!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) { @@ -194,11 +164,12 @@ - $line->desc = $desc; - if (getDolGlobalInt('MAIN_MULTILANGS')) { - // TODO Get desc in language of thirdparty - } - - $line->tva_tx = $productsupplier->vatrate_supplier; - $line->subprice = $productsupplier->fourn_pu; - $line->total_ht = $productsupplier->fourn_pu * $qty; - $tva = $line->tva_tx / 100; - $line->total_tva = $line->total_ht * $tva; - $line->total_ttc = $line->total_ht + $line->total_tva; + $line->desc = $desc; + if (!empty($conf->global->MAIN_MULTILANGS)) + { + // TODO Get desc in language of thirdparty + } + + $line->tva_tx = $productsupplier->vatrate_supplier; + $line->subprice = $productsupplier->fourn_pu; + $line->total_ht = $productsupplier->fourn_pu * $qty; + $tva = $line->tva_tx / 100; + $line->total_tva = $line->total_ht * $tva; + $line->total_ttc = $line->total_ht + $line->total_tva; @@ -206 +177 @@ - $line->ref_fourn = $productsupplier->ref_supplier; + $line->ref_fourn = $productsupplier->ref_supplier; @@ -209,3 +180,5 @@ - $suppliers[$productsupplier->fourn_socid]['lines'][] = $line; - } - } elseif ($idprod == -1) { + $suppliers[$productsupplier->fourn_socid]['lines'][] = $line; + } + } + elseif ($idprod == -1) + { @@ -213,3 +185,0 @@ - } else { - $error = $db->lasterror(); - dol_print_error($db); @@ -217,46 +187,45 @@ - - unset($_POST['fourn' . $i]); - } - unset($_POST[$i]); - } - - //we now know how many orders we need and what lines they have - $i = 0; - $fail = 0; - $orders = array(); - $suppliersid = array_keys($suppliers); - foreach ($suppliers as $supplier) { - $order = new CommandeFournisseur($db); - - // Check if an order for the supplier exists - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "commande_fournisseur"; - $sql .= " WHERE fk_soc = " . ((int) $suppliersid[$i]); - $sql .= " AND source = " . ((int) $order::SOURCE_ID_REPLENISHMENT) . " AND fk_statut = " . ((int) $order::STATUS_DRAFT); - $sql .= " AND entity IN (" . getEntity('commande_fournisseur') . ")"; - $sql .= " ORDER BY date_creation DESC"; - $resql = $db->query($sql); - if ($resql && $db->num_rows($resql) > 0) { - $obj = $db->fetch_object($resql); - - $order->fetch($obj->rowid); - $order->fetch_thirdparty(); - - foreach ($supplier['lines'] as $line) { - if (empty($line->remise_percent)) { - $line->remise_percent = $order->thirdparty->remise_supplier_percent; - } - $result = $order->addline( - $line->desc, - $line->subprice, - $line->qty, - $line->tva_tx, - $line->localtax1_tx, - $line->localtax2_tx, - $line->fk_product, - 0, - $line->ref_fourn, - $line->remise_percent, - 'HT', - 0, - $line->type, - 0, + else + { + $error = $db->lasterror(); + dol_print_error($db); + } + + unset($_POST['fourn'.$i]); + } + unset($_POST[$i]); + } + + //we now know how many orders we need and what lines they have + $i = 0; + $fail = 0; + $orders = array(); + $suppliersid = array_keys($suppliers); + foreach ($suppliers as $supplier) + { + $order = new CommandeFournisseur($db); + // Check if an order for the supplier exists + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande_fournisseur"; + $sql .= " WHERE fk_soc = ".$suppliersid[$i]; + $sql .= " AND source = 42 AND fk_statut = 0"; + $sql .= " AND entity IN (".getEntity('commande_fournisseur').")"; + $sql .= " ORDER BY date_creation DESC"; + $resql = $db->query($sql); + if ($resql && $db->num_rows($resql) > 0) { + $obj = $db->fetch_object($resql); + $order->fetch($obj->rowid); + foreach ($supplier['lines'] as $line) { + $result = $order->addline( + $line->desc, + $line->subprice, + $line->qty, + $line->tva_tx, + $line->localtax1_tx, + $line->localtax2_tx, + $line->fk_product, + 0, + $line->ref_fourn, + $line->remise_percent, + 'HT', + 0, + $line->type, + 0, @@ -268,55 +237,50 @@ - ); - } - if ($result < 0) { - $fail++; - $msg = $langs->trans('OrderFail') . " : "; - $msg .= $order->error; - setEventMessages($msg, null, 'errors'); - } else { - $id = $result; - } - $i++; - } else { - $order->socid = $suppliersid[$i]; - $order->fetch_thirdparty(); - - // Trick to know which orders have been generated using the replenishment feature - $order->source = $order::SOURCE_ID_REPLENISHMENT; - - foreach ($supplier['lines'] as $line) { - if (empty($line->remise_percent)) { - $line->remise_percent = $order->thirdparty->remise_supplier_percent; - } - $order->lines[] = $line; - } - $order->cond_reglement_id = $order->thirdparty->cond_reglement_supplier_id; - $order->mode_reglement_id = $order->thirdparty->mode_reglement_supplier_id; - - $id = $order->create($user); - if ($id < 0) { - $fail++; - $msg = $langs->trans('OrderFail') . " : "; - $msg .= $order->error; - setEventMessages($msg, null, 'errors'); - } - $i++; - } - } - - if ($errorQty) { - setEventMessages($langs->trans('ErrorOrdersNotCreatedQtyTooLow'), null, 'warnings'); - } - - if (!$fail && $id) { - $db->commit(); - - setEventMessages($langs->trans('OrderCreated'), null, 'mesgs'); - header('Location: replenishorders.php'); - exit; - } else { - $db->rollback(); - } - } - if ($box == 0) { - setEventMessages($langs->trans('SelectProductWithNotNullQty'), null, 'warnings'); - } + ); + } + if ($result < 0) { + $fail++; + $msg = $langs->trans('OrderFail')." : "; + $msg .= $order->error; + setEventMessages($msg, null, 'errors'); + } else { + $id = $result; + } + } else { + $order->socid = $suppliersid[$i]; + $order->fetch_thirdparty(); + //trick to know which orders have been generated this way + $order->source = 42; + foreach ($supplier['lines'] as $line) { + $order->lines[] = $line; + } + $order->cond_reglement_id = $order->thirdparty->cond_reglement_supplier_id; + $order->mode_reglement_id = $order->thirdparty->mode_reglement_supplier_id; + $id = $order->create($user); + if ($id < 0) { + $fail++; + $msg = $langs->trans('OrderFail')." : "; + $msg .= $order->error; + setEventMessages($msg, null, 'errors'); + } + $i++; + } + } + + if ($errorQty) setEventMessages($langs->trans('ErrorOrdersNotCreatedQtyTooLow'), null, 'warnings'); + + if (!$fail && $id) + { + $db->commit(); + + setEventMessages($langs->trans('OrderCreated'), null, 'mesgs'); + header('Location: replenishorders.php'); + exit; + } + else + { + $db->rollback(); + } + } + if ($box == 0) + { + setEventMessages($langs->trans('SelectProductWithNotNullQty'), null, 'warnings'); + } @@ -334,3 +298,3 @@ -$title = $langs->trans('MissingStocks'); - -if (getDolGlobalString('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE') && $fk_entrepot > 0) { +$title = $langs->trans('Status'); + +if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { @@ -345 +309 @@ -$sql .= ' p.price_ttc, p.price_base_type, p.fk_product_type,'; +$sql .= ' p.price_ttc, p.price_base_type,p.fk_product_type,'; @@ -348 +312 @@ -if (getDolGlobalString('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE') && $fk_entrepot > 0) { +if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { @@ -351 +315 @@ -$sql .= " " . $sqldesiredtock . " as desiredstockcombined, " . $sqlalertstock . " as seuil_stock_alertecombined,"; +$sql .= ' '.$sqldesiredtock.' as desiredstockcombined, '.$sqlalertstock.' as seuil_stock_alertecombined,'; @@ -353,4 +317 @@ -$sql .= " SUM(".$db->ifsql("s.reel IS NULL", "0", "s.reel").') as stock_physique'; -if (getDolGlobalString('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE') && $fk_entrepot > 0) { - $sql .= ", SUM(".$db->ifsql("s.reel IS NULL OR s.fk_entrepot <> ".((int) $fk_entrepot), "0", "s.reel").') as stock_real_warehouse'; -} +$sql .= ' SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").') as stock_physique'; @@ -363,14 +324,10 @@ -$list_warehouse = (empty($listofqualifiedwarehousesid) ? '0' : $listofqualifiedwarehousesid); - -$sql .= ' FROM ' . MAIN_DB_PREFIX . 'product as p'; -$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_stock as s ON p.rowid = s.fk_product'; -$sql .= ' AND s.fk_entrepot IN (' . $db->sanitize($list_warehouse) . ')'; - -$list_warehouse_selected = ($fk_entrepot < 0 || empty($fk_entrepot)) ? $list_warehouse : $fk_entrepot; -$sql .= ' AND s.fk_entrepot IN (' . $db->sanitize($list_warehouse_selected) . ')'; - - -//$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot AS ent ON s.fk_entrepot = ent.rowid AND ent.entity IN('.getEntity('stock').')'; -if (getDolGlobalString('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE') && $fk_entrepot > 0) { - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_warehouse_properties AS pse ON (p.rowid = pse.fk_product AND pse.fk_entrepot = '.((int) $fk_entrepot).')'; -} +$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s ON p.rowid = s.fk_product'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot AS ent ON s.fk_entrepot = ent.rowid AND ent.entity IN('.getEntity('stock').')'; +if ($fk_supplier > 0) { + $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price pfp ON (pfp.fk_product = p.rowid AND pfp.fk_soc = '.$fk_supplier.')'; +} +if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_warehouse_properties AS pse ON (p.rowid = pse.fk_product AND pse.fk_entrepot = '.$fk_entrepot.')'; +} + @@ -382,4 +339,2 @@ -$sql .= ' WHERE p.entity IN (' . getEntity('product') . ')'; -if ($sall) { - $sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall); -} +$sql .= ' WHERE p.entity IN ('.getEntity('product').')'; +if ($sall) $sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall); @@ -388,12 +343,8 @@ - if ($type == 1) { - $sql .= ' AND p.fk_product_type = 1'; - } else { - $sql .= ' AND p.fk_product_type <> 1'; - } -} -if ($search_ref) { - $sql .= natural_search('p.ref', $search_ref); -} -if ($search_label) { - $sql .= natural_search('p.label', $search_label); -} + if ($type == 1) { + $sql .= ' AND p.fk_product_type = 1'; + } else { + $sql .= ' AND p.fk_product_type <> 1'; + } +} +if ($sref) $sql .= natural_search('p.ref', $sref); +if ($snom) $sql .= natural_search('p.label', $snom); @@ -401,11 +352 @@ -if (isModEnabled('variants') && !getDolGlobalString('VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT')) { // Add test to exclude products that has variants - $sql .= ' AND p.rowid NOT IN (SELECT pac.fk_product_parent FROM '.MAIN_DB_PREFIX.'product_attribute_combination as pac WHERE pac.entity IN ('.getEntity('product').'))'; -} -if ($fk_supplier > 0) { - $sql .= ' AND EXISTS (SELECT pfp.rowid FROM ' . MAIN_DB_PREFIX . 'product_fournisseur_price as pfp WHERE pfp.fk_product = p.rowid AND pfp.fk_soc = ' . ((int) $fk_supplier) . ' AND pfp.entity IN (' . getEntity('product_fournisseur_price') . '))'; -} -// Add where from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; - +if (!empty($canvas)) $sql .= ' AND p.canvas = "'.$db->escape($canvas).'"'; @@ -417 +358 @@ -if (getDolGlobalString('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE') && $fk_entrepot > 0) { +if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { @@ -423,2 +364,3 @@ -if ($usevirtualstock) { - if (isModEnabled('commande')) { +if ($usevirtualstock) +{ + if (!empty($conf->commande->enabled)) { @@ -427 +369 @@ - $sqlCommandesCli .= " WHERE c1.rowid = cd1.fk_commande AND c1.entity IN (".getEntity(getDolGlobalString('STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE') ? 'stock' : 'commande').")"; + $sqlCommandesCli .= " WHERE c1.rowid = cd1.fk_commande AND c1.entity IN (".getEntity('commande').")"; @@ -434 +376 @@ - if (isModEnabled("expedition")) { + if (!empty($conf->expedition->enabled)) { @@ -438 +380 @@ - $sqlExpeditionsCli .= " ".MAIN_DB_PREFIX."commande as c2,"; + $sqlExpeditionsCli .= " ".MAIN_DB_PREFIX."commande as c2,"; @@ -440,3 +382,3 @@ - $sqlExpeditionsCli .= " WHERE ed2.fk_expedition = e2.rowid AND cd2.rowid = ed2.fk_origin_line AND e2.entity IN (".getEntity(getDolGlobalString('STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE') ? 'stock' : 'expedition').")"; - $sqlExpeditionsCli .= " AND cd2.fk_commande = c2.rowid"; - $sqlExpeditionsCli .= " AND c2.fk_statut IN (1,2)"; + $sqlExpeditionsCli .= " WHERE ed2.fk_expedition = e2.rowid AND cd2.rowid = ed2.fk_origin_line AND e2.entity IN (".getEntity('expedition').")"; + $sqlExpeditionsCli .= " AND cd2.fk_commande = c2.rowid"; + $sqlExpeditionsCli .= " AND c2.fk_statut IN (1,2)"; @@ -449,4 +391,4 @@ - if (isModEnabled("supplier_order")) { - $sqlCommandesFourn = "(SELECT " . $db->ifsql("SUM(cd3.qty) IS NULL", "0", "SUM(cd3.qty)") . " as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL - $sqlCommandesFourn .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseurdet as cd3,"; - $sqlCommandesFourn .= " " . MAIN_DB_PREFIX . "commande_fournisseur as c3"; + if (!empty($conf->fournisseur->enabled)) { + $sqlCommandesFourn = "(SELECT ".$db->ifsql("SUM(cd3.qty) IS NULL", "0", "SUM(cd3.qty)")." as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL + $sqlCommandesFourn .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd3,"; + $sqlCommandesFourn .= " ".MAIN_DB_PREFIX."commande_fournisseur as c3"; @@ -454 +396 @@ - $sqlCommandesFourn .= " AND c3.entity IN (".getEntity(getDolGlobalString('STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE') ? 'stock' : 'supplier_order').")"; + $sqlCommandesFourn .= " AND c3.entity IN (".getEntity('supplier_order').")"; @@ -461 +403 @@ - $sqlReceptionFourn .= " WHERE fd4.fk_commande = cf4.rowid AND cf4.entity IN (".getEntity(getDolGlobalString('STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE') ? 'stock' : 'supplier_order').")"; + $sqlReceptionFourn .= " WHERE fd4.fk_commande = cf4.rowid AND cf4.entity IN (".getEntity('supplier_order').")"; @@ -469 +411 @@ - if (isModEnabled('mrp')) { + if (!empty($conf->mrp->enabled)) { @@ -473 +415 @@ - $sqlProductionToConsume .= " WHERE mm5.rowid = mp5.fk_mo AND mm5.entity IN (".getEntity(getDolGlobalString('STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE') ? 'stock' : 'mo').")"; + $sqlProductionToConsume .= " WHERE mm5.rowid = mp5.fk_mo AND mm5.entity IN (".getEntity('mo').")"; @@ -475 +417 @@ - $sqlProductionToConsume .= " AND mp5.role IN ('toconsume', 'consumed')"; + $sqlProductionToConsume .= " AND mp5.role IN ('toconsume', 'consummed')"; @@ -478 +420 @@ - $sqlProductionToProduce = "(SELECT GREATEST(0, ".$db->ifsql("SUM(".$db->ifsql("mp5.role = 'toproduce'", 'mp5.qty', '- mp5.qty').") IS NULL", "0", "SUM(".$db->ifsql("mp5.role = 'toproduce'", 'mp5.qty', '- mp5.qty').")").") as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL + $sqlProductionToProduce = "(SELECT GREATEST(0, ".$db->ifsql("SUM(".$db->ifsql("mp5.role = 'toproduce'", 'mp5.qty', '- mp5.qty').") IS NULL", "0", "SUM(".$db->ifsql("mp5.role = 'toconsume'", 'mp5.qty', '- mp5.qty').")").") as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL @@ -481 +423 @@ - $sqlProductionToProduce .= " WHERE mm5.rowid = mp5.fk_mo AND mm5.entity IN (".getEntity(getDolGlobalString('STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE') ? 'stock' : 'mo').")"; + $sqlProductionToProduce .= " WHERE mm5.rowid = mp5.fk_mo AND mm5.entity IN (".getEntity('mo').")"; @@ -485 +427,2 @@ - } else { + } else + { @@ -491,16 +434,9 @@ - $sql .= " (" . $sqldesiredtock . " >= 0 AND (" . $sqldesiredtock . " > SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ')'; - $sql .= " - (" . $sqlCommandesCli . " - " . $sqlExpeditionsCli . ") + (" . $sqlCommandesFourn . " - " . $sqlReceptionFourn . ") + (" . $sqlProductionToProduce . " - " . $sqlProductionToConsume . ")))"; - $sql .= ' OR'; - if ($includeproductswithoutdesiredqty == 'on') { - $sql .= " ((" . $sqlalertstock . " >= 0 OR " . $sqlalertstock . " IS NULL) AND (" . $db->ifsql($sqlalertstock . " IS NULL", "0", $sqlalertstock) . " > SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ")"; - } else { - $sql .= " (" . $sqlalertstock . " >= 0 AND (" . $sqlalertstock . " > SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ')'; - } - $sql .= " - (" . $sqlCommandesCli . " - " . $sqlExpeditionsCli . ") + (" . $sqlCommandesFourn . " - " . $sqlReceptionFourn . ") + (" . $sqlProductionToProduce . " - " . $sqlProductionToConsume . ")))"; - $sql .= ")"; - if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { - $sql .= " AND ("; - $sql .= " pse.desiredstock > 0)"; - } - - if ($salert == 'on') { // Option to see when stock is lower than alert + $sql .= ' ('.$sqldesiredtock.' >= 0 AND ('.$sqldesiredtock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + $sql .= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.') + ('.$sqlProductionToProduce.' - '.$sqlProductionToConsume.')))'; + $sql .= ' OR '; + $sql .= ' ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + $sql .= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.') + ('.$sqlProductionToProduce.' - '.$sqlProductionToConsume.')))'; + $sql .= ')'; + + if ($salert == 'on') // Option to see when stock is lower than alert + { @@ -508,7 +444,3 @@ - if ($includeproductswithoutdesiredqty == 'on') { - $sql .= "(" . $sqlalertstock . " >= 0 OR " . $sqlalertstock . " IS NULL) AND (" . $db->ifsql($sqlalertstock . " IS NULL", "0", $sqlalertstock) . " > SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ")"; - } else { - $sql .= $sqlalertstock . " >= 0 AND (" . $sqlalertstock . " > SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ")"; - } - $sql .= " - (" . $sqlCommandesCli . " - " . $sqlExpeditionsCli . ") + (" . $sqlCommandesFourn . " - " . $sqlReceptionFourn . ") + (" . $sqlProductionToProduce . " - " . $sqlProductionToConsume . "))"; - $sql .= ")"; + $sql .= $sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + $sql .= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.') + ('.$sqlProductionToProduce.' - '.$sqlProductionToConsume.'))'; + $sql .= ')'; @@ -518,22 +450,6 @@ - $sql .= ' HAVING ('; - $sql .= "(" . $sqldesiredtock . " >= 0 AND (" . $sqldesiredtock . " > SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ")))"; - $sql .= ' OR'; - if ($includeproductswithoutdesiredqty == 'on') { - $sql .= " ((" . $sqlalertstock . " >= 0 OR " . $sqlalertstock . " IS NULL) AND (" . $db->ifsql($sqlalertstock . " IS NULL", "0", $sqlalertstock) . " > SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ')))'; - } else { - $sql .= " (" . $sqlalertstock . " >= 0 AND (" . $sqlalertstock . " > SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ')))'; - } - $sql .= ')'; - if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { - $sql .= " AND ("; - $sql .= " pse.desiredstock > 0)"; - } - - if ($salert == 'on') { // Option to see when stock is lower than alert - $sql .= " AND ("; - if ($includeproductswithoutdesiredqty == 'on') { - $sql .= " (" . $sqlalertstock . " >= 0 OR " . $sqlalertstock . " IS NULL) AND (" . $db->ifsql($sqlalertstock . " IS NULL", "0", $sqlalertstock) . " > SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . "))"; - } else { - $sql .= " " . $sqlalertstock . " >= 0 AND (" . $sqlalertstock . " > SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . '))'; - } - $sql .= ')'; + $sql .= ' HAVING (('.$sqldesiredtock.' >= 0 AND ('.$sqldesiredtock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; + $sql .= ' OR ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").'))))'; + + if ($salert == 'on') // Option to see when stock is lower than alert + { + $sql .= ' AND ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; @@ -544,14 +460,4 @@ -$includeproductswithoutdesiredqtychecked = ''; -if ($includeproductswithoutdesiredqty == 'on') { - $includeproductswithoutdesiredqtychecked = 'checked'; -} - -$nbtotalofrecords = ''; -if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) { - $page = 0; - $offset = 0; - } -} +// Add where from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; @@ -564,3 +470,4 @@ -if (empty($resql)) { - dol_print_error($db); - exit; +if (empty($resql)) +{ + dol_print_error($db); + exit; @@ -578,2 +485 @@ - -$head[0][0] = DOL_URL_ROOT . '/product/stock/replenish.php'; +$head[0][0] = DOL_URL_ROOT.'/product/stock/replenish.php'; @@ -582,2 +488 @@ - -$head[1][0] = DOL_URL_ROOT . '/product/stock/replenishorders.php'; +$head[1][0] = DOL_URL_ROOT.'/product/stock/replenishorders.php'; @@ -590,26 +495,21 @@ -print dol_get_fiche_head($head, 'replenish', '', -1, ''); - -print '' . $langs->trans("ReplenishmentStatusDesc") . '' . "\n"; - -//$link = ''.$langs->trans("MenuNewWarehouse").''; - -if (empty($fk_entrepot) && getDolGlobalString('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE')) { - print ''.$langs->trans("ReplenishmentStatusDescPerWarehouse").''."\n"; -} -print '

'; -if ($usevirtualstock == 1) { - print $langs->trans("CurentSelectionMode") . ': '; - print '' . $langs->trans("UseVirtualStock") . ''; - print ' 0 ? '&fk_supplier=' . $fk_supplier : '') . ($fk_entrepot > 0 ? '&fk_entrepot=' . $fk_entrepot : '') . '">' . $langs->trans("UsePhysicalStock") . ''; - print '
'; -} -if ($usevirtualstock == 0) { - print $langs->trans("CurentSelectionMode") . ': '; - print ' 0 ? '&fk_supplier=' . $fk_supplier : '') . ($fk_entrepot > 0 ? '&fk_entrepot=' . $fk_entrepot : '') . '">' . $langs->trans("UseVirtualStock") . ''; - print ' ' . $langs->trans("UsePhysicalStock") . ''; - print '
'; -} -print '
' . "\n"; - -print '
'; -print ''; +dol_fiche_head($head, 'replenish', '', -1, ''); + +print ''.$langs->trans("ReplenishmentStatusDesc").'
'."\n"; +if (empty($fk_warhouse) && !empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) { + print ''.$langs->trans("ReplenishmentStatusDescPerWarehouse").''."
\n"; +} +if ($usevirtualstock == 1) +{ + print $langs->trans("CurentSelectionMode").': '; + print $langs->trans("CurentlyUsingVirtualStock").' - '; + print ''.$langs->trans("UsePhysicalStock").'
'; +} +if ($usevirtualstock == 0) +{ + print $langs->trans("CurentSelectionMode").': '; + print $langs->trans("CurentlyUsingPhysicalStock").' - '; + print ''.$langs->trans("UseVirtualStock").'
'; +} +print '
'."\n"; + +print ''; @@ -617,10 +517,7 @@ -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -if ($limit > 0 && $limit != $conf->liste_limit) { - print ''; -} -if (getDolGlobalString('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE')) { +print ''; +print ''; +print ''; +print ''; +print ''; +if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) +{ @@ -628 +525 @@ - print $langs->trans('Warehouse') . ' ' . $formproduct->selectWarehouses($fk_entrepot, 'fk_entrepot', '', 1); + print $langs->trans('Warehouse').' '.$formproduct->selectWarehouses($fk_entrepot, 'fk_entrepot', '', 1); @@ -632,2 +529 @@ -$filter = '(fournisseur:=:1)'; -print $langs->trans('Supplier') . ' ' . $form->select_company($fk_supplier, 'fk_supplier', $filter, 1); +print $langs->trans('Supplier').' '.$form->select_company($fk_supplier, 'fk_supplier', 'fournisseur=1', 1); @@ -638,3 +534 @@ -if (empty($reshook)) { - print $hookmanager->resPrint; -} +if (empty($reshook)) print $hookmanager->resPrint; @@ -643 +537 @@ -print ''; +print ''; @@ -648,81 +542,8 @@ -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; - - -if ($search_ref || $search_label || $sall || $salert || $draftorder || GETPOST('search', 'alpha')) { - $filters = '&search_ref=' . urlencode($search_ref) . '&search_label=' . urlencode($search_label); - $filters .= '&sall=' . urlencode($sall); - $filters .= '&salert=' . urlencode($salert); - $filters .= '&draftorder=' . urlencode($draftorder); - $filters .= '&mode=' . urlencode($mode); - if ($fk_supplier > 0) { - $filters .= '&fk_supplier=' . urlencode($fk_supplier); - } - if ($fk_entrepot > 0) { - $filters .= '&fk_entrepot=' . urlencode($fk_entrepot); - } -} else { - $filters = '&search_ref=' . urlencode($search_ref) . '&search_label=' . urlencode($search_label); - $filters .= '&fourn_id=' . urlencode($fourn_id); - $filters .= (isset($type) ? '&type=' . urlencode($type) : ''); - $filters .= '&=' . urlencode($salert); - $filters .= '&draftorder=' . urlencode($draftorder); - $filters .= '&mode=' . urlencode($mode); - if ($fk_supplier > 0) { - $filters .= '&fk_supplier=' . urlencode($fk_supplier); - } - if ($fk_entrepot > 0) { - $filters .= '&fk_entrepot=' . urlencode($fk_entrepot); - } -} -if ($limit > 0 && $limit != $conf->liste_limit) { - $filters .= '&limit=' . ((int) $limit); -} -if (!empty($includeproductswithoutdesiredqty)) { - $filters .= '&includeproductswithoutdesiredqty='.urlencode($includeproductswithoutdesiredqty); -} -if (!empty($salert)) { - $filters .= '&salert='.urlencode($salert); -} - -$param = (isset($type) ? '&type='.urlencode($type) : ''); -$param .= '&fourn_id='.urlencode($fourn_id).'&search_label='.urlencode($search_label).'&includeproductswithoutdesiredqty='.urlencode($includeproductswithoutdesiredqty).'&salert='.urlencode($salert).'&draftorder='.urlencode($draftorder); -$param .= '&search_ref='.urlencode($search_ref); -$param .= '&mode='.urlencode($mode); -$param .= '&fk_supplier='.urlencode($fk_supplier); -$param .= '&fk_entrepot='.urlencode($fk_entrepot); -if (!empty($includeproductswithoutdesiredqty)) { - $param .= '&includeproductswithoutdesiredqty='.urlencode($includeproductswithoutdesiredqty); -} -if (!empty($salert)) { - $param .= '&salert='.urlencode($salert); -} - -$stocklabel = $langs->trans('Stock'); -$stocklabelbis = $langs->trans('Stock'); -$stocktooltip = ''; -if ($usevirtualstock == 1) { - $stocklabel = $langs->trans('VirtualStock'); - $stocktooltip = $langs->trans("VirtualStockDesc"); -} -if ($usevirtualstock == 0) { - $stocklabel = $langs->trans('PhysicalStock'); -} -if (getDolGlobalString('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE') && $fk_entrepot > 0) { - $stocklabelbis = $stocklabel.' (Selected warehouse)'; - $stocklabel .= ' ('.$langs->trans("AllWarehouses").')'; -} -$texte = $langs->trans('Replenishment'); - -print '
'; - - -if (getDolGlobalString('REPLENISH_ALLOW_VARIABLESIZELIST')) { +if ($sref || $snom || $sall || $salert || $draftorder || GETPOST('search', 'alpha')) { + $filters = '&sref='.$sref.'&snom='.$snom; + $filters .= '&sall='.$sall; + $filters .= '&salert='.$salert; + $filters .= '&draftorder='.$draftorder; + $filters .= '&mode='.$mode; + $filters .= '&fk_supplier='.$fk_supplier; + $filters .= '&fk_entrepot='.$fk_entrepot; @@ -737,7 +558 @@ - $num, - $nbtotalofrecords, - '', - 0, - '', - '', - $limit + $num @@ -745,0 +561,8 @@ + $filters = '&sref='.$sref.'&snom='.$snom; + $filters .= '&fourn_id='.$fourn_id; + $filters .= (isset($type) ? '&type='.$type : ''); + $filters .= '&='.$salert; + $filters .= '&draftorder='.$draftorder; + $filters .= '&mode='.$mode; + $filters .= '&fk_supplier='.$fk_supplier; + $filters .= '&fk_entrepot='.$fk_entrepot; @@ -754,3 +577 @@ - $num, - $nbtotalofrecords, - '' + $num @@ -760,2 +581 @@ - -print '
'; +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table @@ -762,0 +583,25 @@ + +$param = (isset($type) ? '&type='.$type : ''); +$param .= '&fourn_id='.$fourn_id.'&snom='.$snom.'&salert='.$salert.'&draftorder='.$draftorder; +$param .= '&sref='.$sref; +$param .= '&mode='.$mode; +$param .= '&fk_supplier='.$fk_supplier; +$param .= '&fk_entrepot='.$fk_entrepot; + +$stocklabel = $langs->trans('Stock'); +if ($usevirtualstock == 1) $stocklabel = $langs->trans('VirtualStock'); +if ($usevirtualstock == 0) $stocklabel = $langs->trans('PhysicalStock'); +if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) +{ + $stocklabel .= ' ('.$langs->trans("AllWarehouses").')'; +} +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; @@ -767,7 +612,5 @@ -print ''; -print ''; -if (isModEnabled("service") && $type == 1) { - print ' '; -} -print '' . $form->textwithpicto($langs->trans('IncludeEmptyDesiredStock'), $langs->trans('IncludeProductWithUndefinedAlerts')) . ' '; -print ''; +print ''; +print ''; +if (!empty($conf->service->enabled) && $type == 1) print ' '; +print ' '; +print ' '; @@ -775,8 +618 @@ -if (getDolGlobalString('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE') && $fk_entrepot > 0) { - print ' '; -} -print ''; -if (getDolGlobalString('STOCK_REPLENISH_ADD_CHECKBOX_INCLUDE_DRAFT_ORDER')) { - print $langs->trans('IncludeAlsoDraftOrders').' '; -} -print ''; +print ''.$langs->trans('IncludeAlsoDraftOrders').' '; @@ -785 +621 @@ -$parameters = array('param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder); +$parameters = array('param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); @@ -789 +625 @@ -print ''; +print ''; @@ -798 +634 @@ -print_liste_field_titre('ProductRef', $_SERVER["PHP_SELF"], 'p.ref', $param, '', '', $sortfield, $sortorder); +print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'p.ref', $param, '', '', $sortfield, $sortorder); @@ -800,3 +636 @@ -if (isModEnabled("service") && $type == 1) { - print_liste_field_titre('Duration', $_SERVER["PHP_SELF"], 'p.duration', $param, '', '', $sortfield, $sortorder, 'center '); -} +if (!empty($conf->service->enabled) && $type == 1) print_liste_field_titre('Duration', $_SERVER["PHP_SELF"], 'p.duration', $param, '', '', $sortfield, $sortorder, 'center '); @@ -805,4 +639 @@ -print_liste_field_titre($stocklabel, $_SERVER["PHP_SELF"], 'stock_physique', $param, '', '', $sortfield, $sortorder, 'right ', $stocktooltip); -if (getDolGlobalString('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE') && $fk_entrepot > 0) { - print_liste_field_titre($stocklabelbis, $_SERVER["PHP_SELF"], 'stock_real_warehouse', $param, '', '', $sortfield, $sortorder, 'right '); -} +print_liste_field_titre($stocklabel, $_SERVER["PHP_SELF"], 'stock_physique', $param, '', '', $sortfield, $sortorder, 'right '); @@ -814 +645 @@ -$parameters = array('param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder); +$parameters = array('param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); @@ -820 +651,2 @@ -while ($i < ($limit ? min($num, $limit) : $num)) { +while ($i < ($limit ? min($num, $limit) : $num)) +{ @@ -823,8 +655,4 @@ - if (getDolGlobalString('STOCK_SUPPORTS_SERVICES') || $objp->fk_product_type == 0) { - $result = $prod->fetch($objp->rowid); - if ($result < 0) { - dol_print_error($db); - exit; - } - - $prod->load_stock('warehouseopen, warehouseinternal'.(!$usevirtualstock ? ', novirtual' : ''), $draftchecked); + if (!empty($conf->global->STOCK_SUPPORTS_SERVICES) || $objp->fk_product_type == 0) + { + $prod->fetch($objp->rowid); + $prod->load_stock('warehouseopen, warehouseinternal', $draftchecked); @@ -833 +661,2 @@ - if (getDolGlobalInt('MAIN_MULTILANGS')) { + if (!empty($conf->global->MAIN_MULTILANGS)) + { @@ -835,3 +664,3 @@ - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'product_lang'; - $sql .= ' WHERE fk_product = ' . ((int) $objp->rowid); - $sql .= " AND lang = '" . $db->escape($langs->getDefaultLang()) . "'"; + $sql .= ' FROM '.MAIN_DB_PREFIX.'product_lang'; + $sql .= ' WHERE fk_product = '.$objp->rowid; + $sql .= ' AND lang = "'.$langs->getDefaultLang().'"'; @@ -841 +670,2 @@ - if ($resqlm) { + if ($resqlm) + { @@ -843,6 +673,2 @@ - if (!empty($objtp->description)) { - $objp->description = $objtp->description; - } - if (!empty($objtp->label)) { - $objp->label = $objtp->label; - } + if (!empty($objtp->description)) $objp->description = $objtp->description; + if (!empty($objtp->label)) $objp->label = $objtp->label; @@ -852,2 +678,2 @@ - $stockwarehouse = 0; - if ($usevirtualstock) { + if ($usevirtualstock) + { @@ -856,2 +682,3 @@ - //TODO $stockwarehouse = $prod->stock_warehouse[$fk_entrepot]->; - } else { + } + else + { @@ -859,3 +685,0 @@ - if (!empty($prod->stock_warehouse[$fk_entrepot])) { - $stockwarehouse = $prod->stock_warehouse[$fk_entrepot]->real; - } @@ -867 +691 @@ - } elseif (!$usevirtualstock) { + } else { @@ -871,3 +695 @@ - if (!$usevirtualstock) { - $result = $prod->load_stats_reception(0, '4'); - } + $result = $prod->load_stats_reception(0, '4'); @@ -879,4 +701,2 @@ - $desiredstock = $objp->desiredstock; - $alertstock = $objp->seuil_stock_alerte; - $desiredstockwarehouse = (!empty($objp->desiredstockpse) ? $objp->desiredstockpse : 0); - $alertstockwarehouse = (!empty($objp->seuil_stock_alertepse) ? $objp->seuil_stock_alertepse : 0); + $desiredstock = ($objp->desiredstockpse ? $objp->desiredstockpse : $objp->desiredstock); + $alertstock = ($objp->seuil_stock_alertepse ? $objp->seuil_stock_alertepse : $objp->seuil_stock_alerte); @@ -885,6 +705,3 @@ - if ($alertstock && ($stock < $alertstock)) { - $warning = img_warning($langs->trans('StockTooLow')) . ' '; - } - $warningwarehouse = ''; - if ($alertstockwarehouse && ($stockwarehouse < $alertstockwarehouse)) { - $warningwarehouse = img_warning($langs->trans('StockTooLow')) . ' '; + if ($alertstock && ($stock < $alertstock)) + { + $warning = img_warning($langs->trans('StockTooLow')).' '; @@ -896,2 +713,15 @@ - if (empty($usevirtualstock)) { - $stocktobuy = max(max($desiredstock, $alertstock) - $stock - $ordered, 0); + if (empty($usevirtualstock)) $stocktobuy = max(max($desiredstock, $alertstock) - $stock - $ordered, 0); + else $stocktobuy = max(max($desiredstock, $alertstock) - $stock, 0); //ordered is already in $stock in virtual mode + + $disabled = ''; + if ($ordered > 0) + { + $stockforcompare = $usevirtualstock ? $stock : $stock + $ordered; + if ($stockforcompare >= $desiredstock) + { + $picto = img_picto('', './img/yes', '', 1); + $disabled = 'disabled'; + } + else { + $picto = img_picto('', './img/no', '', 1); + } @@ -899 +729,2 @@ - $stocktobuy = max(max($desiredstock, $alertstock) - $stock, 0); //ordered is already in $stock in virtual mode + //$picto = img_help('',$langs->trans("NoPendingReceptionOnSupplierOrder")); + $picto = img_picto($langs->trans("NoPendingReceptionOnSupplierOrder"), './img/no', '', 1); @@ -901,18 +731,0 @@ - if (empty($usevirtualstock)) { - $stocktobuywarehouse = max(max($desiredstockwarehouse, $alertstockwarehouse) - $stockwarehouse - $ordered, 0); - } else { - $stocktobuywarehouse = max(max($desiredstockwarehouse, $alertstockwarehouse) - $stockwarehouse, 0); //ordered is already in $stock in virtual mode - } - - $picto = ''; - if ($ordered > 0) { - $stockforcompare = ($usevirtualstock ? $stock : $stock + $ordered); - /*if ($stockforcompare >= $desiredstock) - { - $picto = img_picto('', 'help'); - } else { - $picto = img_picto('', 'help'); - }*/ - } else { - $picto = img_picto($langs->trans("NoPendingReceptionOnSupplierOrder"), 'help'); - } @@ -923,7 +736,7 @@ - print ''; - - print '' . $prod->getNomUrl(1, 'stock') . ''; - - print ''; - print dol_escape_htmltag($objp->label); - print ''; // TODO Remove this and make a fetch to get description when creating order instead of a GETPOST + //print ''; + print ''; + + print ''.$prod->getNomUrl(1, '').''; + + print ''.$objp->label; + print ''; // TODO Remove this and make a fetch to get description when creating order instead of a GETPOST @@ -932,2 +745,2 @@ - if (isModEnabled("service") && $type == 1) { - $regs = array(); + if (!empty($conf->service->enabled) && $type == 1) + { @@ -935 +748 @@ - $duration = $regs[1] . ' ' . $langs->trans('DurationYear'); + $duration = $regs[1].' '.$langs->trans('DurationYear'); @@ -937 +750 @@ - $duration = $regs[1] . ' ' . $langs->trans('DurationMonth'); + $duration = $regs[1].' '.$langs->trans('DurationMonth'); @@ -939 +752 @@ - $duration = $regs[1] . ' ' . $langs->trans('DurationDay'); + $duration = $regs[1].' '.$langs->trans('DurationDay'); @@ -943 +756 @@ - print '' . $duration . ''; + print ''.$duration.''; @@ -947 +760 @@ - print ''.((getDolGlobalString('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE') && $fk_entrepot > 0) > 0 ? $desiredstockwarehouse : $desiredstock).''; + print ''.$desiredstock.''; @@ -950 +763 @@ - print ''.((getDolGlobalString('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE') && $fk_entrepot > 0) > 0 ? $alertstockwarehouse : $alertstock).''; + print ''.$alertstock.''; @@ -953,8 +766 @@ - print '' . $warning . $stock; - print ''; - print ''; - - // Current stock (warehouse selected only) - if (getDolGlobalString('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE') && $fk_entrepot > 0) { - print ''.$warningwarehouse.$stockwarehouse.''; - } + print ''.$warning.$stock.''; @@ -963 +769 @@ - print '' . $ordered . ' ' . $picto . ''; + print ''.$ordered.' '.$picto.''; @@ -966,2 +772,2 @@ - $tobuy = ((getDolGlobalString('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE') && $fk_entrepot > 0) > 0 ? $stocktobuywarehouse : $stocktobuy); - print ''; + //print ''; + print ''; @@ -971,2 +777,2 @@ - print $form->select_product_fourn_price($prod->id, 'fourn' . $i, $fk_supplier); - print ''; + print $form->select_product_fourn_price($prod->id, 'fourn'.$i, $fk_supplier); + print ''; @@ -975 +781 @@ - $parameters = array('objp' => $objp, 'i' => $i, 'tobuy' => $tobuy); + $parameters = array('objp'=>$objp); @@ -984,16 +790 @@ -if ($num == 0) { - $colspan = 9; - if (isModEnabled("service") && $type == 1) { - $colspan++; - } - if (getDolGlobalString('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE') && $fk_entrepot > 0) { - $colspan++; - } - print ''; - print ''; - print $langs->trans("None"); - print ''; - print ''; -} - -$parameters = array('sql' => $sql); +$parameters = array('sql'=>$sql); @@ -1008 +799 @@ -print dol_get_fiche_end(); +dol_fiche_end(); @@ -1012 +803 @@ -print '
'; +print '
'; --- /tmp/dsg/dolibarr/htdocs/product/stock/github_19.0.3_replenishorders.php +++ /tmp/dsg/dolibarr/htdocs/product/stock/client_replenishorders.php @@ -28 +27,0 @@ -// Load Dolibarr environment @@ -41 +40,3 @@ -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'replenishorders'; // To manage different context of search +// Security check +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'produit|service'); @@ -49 +50 @@ -$search_product = GETPOST('search_product', 'int'); +$sproduct = GETPOST('sproduct', 'int'); @@ -54,11 +55,6 @@ -$optioncss = GETPOST('optioncss', 'alpha'); - -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); -if (!$sortorder) { - $sortorder = 'DESC'; -} -if (!$sortfield) { - $sortfield = 'cf.date_creation'; -} + +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +if (!$sortorder) $sortorder = 'DESC'; +if (!$sortfield) $sortfield = 'cf.date_creation'; @@ -66,3 +62 @@ -if ($page < 0) { - $page = 0; -} +if ($page < 0) $page = 0; @@ -70,6 +63,0 @@ - -// Security check -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'produit|service'); @@ -82,11 +70,12 @@ -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers - $sall = ""; - $sref = ""; - $snom = ""; - $suser = ""; - $sttc = ""; - $search_date = ''; - $search_datemonth = ''; - $search_dateday = ''; - $search_dateyear = ''; - $search_product = 0; +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers +{ + $sall = ""; + $sref = ""; + $snom = ""; + $suser = ""; + $sttc = ""; + $search_date = ''; + $search_datemonth = ''; + $search_dateday = ''; + $search_dateyear = ''; + $sproduct = 0; @@ -111 +99,0 @@ - @@ -113 +101 @@ -$head[0][1] = $langs->trans('MissingStocks'); +$head[0][1] = $langs->trans('Status'); @@ -115 +102,0 @@ - @@ -120 +107 @@ -print dol_get_fiche_head($head, 'replenishorders', '', -1, ''); +dol_fiche_head($head, 'replenishorders', '', -1, ''); @@ -129,2 +116,2 @@ -if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= ', '.MAIN_DB_PREFIX.'societe_commerciaux as sc'; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ', '.MAIN_DB_PREFIX.'societe_commerciaux as sc'; @@ -134,4 +121,4 @@ -if (getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER')) { - $sql .= ' AND cf.fk_statut < 3'; -} elseif (getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER') || getDolGlobalString('STOCK_CALCULATE_ON_RECEPTION') || getDolGlobalString('STOCK_CALCULATE_ON_RECEPTION_CLOSE')) { - $sql .= ' AND cf.fk_statut < 6'; // We want also status 5, we will keep them visible if dispatching is not yet finished (tested with function dolDispatchToDo). +if ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) { + $sql .= ' AND cf.fk_statut < 3'; +} elseif ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) { + $sql .= ' AND cf.fk_statut < 6'; // We want also status 5, we will keep them visible if dispatching is not yet finished (tested with function dolDispatchToDo). @@ -139,17 +126,9 @@ - $sql .= ' AND cf.fk_statut < 5'; -} -if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= ' AND s.rowid = sc.fk_soc AND sc.fk_user = '.((int) $user->id); -} -if ($sref) { - $sql .= natural_search('cf.ref', $sref); -} -if ($snom) { - $sql .= natural_search('s.nom', $snom); -} -if ($suser) { - natural_search(array('u.lastname', 'u.firstname', 'u.login'), $suser); -} -if ($sttc) { - $sql .= natural_search('cf.total_ttc', $sttc, 1); -} + $sql .= ' AND cf.fk_statut < 5'; +} +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ' AND s.rowid = sc.fk_soc AND sc.fk_user = '.$user->id; +} +if ($sref) $sql .= natural_search('cf.ref', $sref); +if ($snom) $sql .= natural_search('s.nom', $snom); +if ($suser) $sql .= natural_search('u.login', $suser); +if ($sttc) $sql .= natural_search('cf.total_ttc', $sttc, 1); @@ -157,6 +136,2 @@ -if ($sall) { - $sql .= natural_search(array('cf.ref', 'cf.note'), $sall); -} -if (!empty($socid)) { - $sql .= ' AND s.rowid = '.((int) $socid); -} +if ($sall) $sql .= natural_search(array('cf.ref', 'cf.note'), $sall); +if (!empty($socid)) $sql .= ' AND s.rowid = '.$socid; @@ -164 +139 @@ - $sql .= ' AND fk_statut = '.GETPOST('statut', 'int'); + $sql .= ' AND fk_statut = '.GETPOST('statut', 'int'); @@ -169 +144 @@ -if (!$search_product) { +if (!$sproduct) { @@ -174,8 +149,8 @@ -if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - - print ''; - print ''; - - print ''.$langs->trans("ReplenishmentOrdersDesc").'
'; +if ($resql) +{ + $num = $db->num_rows($resql); + $i = 0; + + print ''.$langs->trans("ReplenishmentOrdersDesc").'

'; + + print ''; @@ -185,182 +160,161 @@ - $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); - } - if ($sref) { - $param .= '&search_ref='.urlencode($sref); - } - if ($snom) { - $param .= '&search_nom='.urlencode($snom); - } - if ($suser) { - $param .= '&search_user='.urlencode($suser); - } - if ($sttc) { - $param .= '&search_ttc='.urlencode($sttc); - } - if ($search_dateyear) { - $param .= '&search_dateyear='.urlencode($search_dateyear); - } - if ($search_datemonth) { - $param .= '&search_datemonth='.urlencode($search_datemonth); - } - if ($search_dateday) { - $param .= '&search_dateday='.urlencode($search_dateday); - } - if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); - } - - print '
'; - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; - print_liste_field_titre( - 'Ref', - $_SERVER['PHP_SELF'], - 'cf.ref', - '', - $param, - '', - $sortfield, - $sortorder - ); - print_liste_field_titre( - 'Company', - $_SERVER['PHP_SELF'], - 's.nom', - '', - $param, - '', - $sortfield, - $sortorder - ); - print_liste_field_titre( - 'Author', - $_SERVER['PHP_SELF'], - 'u.login', - '', - '', - '', - $sortfield, - $sortorder - ); - print_liste_field_titre( - 'AmountTTC', - $_SERVER['PHP_SELF'], - 'cf.total_ttc', - '', - $param, - '', - $sortfield, - $sortorder, - 'right ' - ); - print_liste_field_titre( - 'OrderCreation', - $_SERVER['PHP_SELF'], - 'cf.date_creation', - '', - $param, - '', - $sortfield, - $sortorder, - 'center ' - ); - print_liste_field_titre( - 'Status', - $_SERVER['PHP_SELF'], - 'cf.fk_statut', - '', - $param, - '', - $sortfield, - $sortorder, - 'right ' - ); - print ''; - - $userstatic = new User($db); - - while ($i < min($num, $search_product ? $num : $conf->liste_limit)) { - $obj = $db->fetch_object($resql); - - $showline = dolDispatchToDo($obj->rowid) && (!$search_product || in_array($search_product, getProducts($obj->rowid))); - - if ($showline) { - $href = DOL_URL_ROOT.'/fourn/commande/card.php?id='.$obj->rowid; - - print ''; - - // Ref - print ''; - - // Company - $href = DOL_URL_ROOT.'/fourn/card.php?socid='.$obj->socid; - print ''; - - // Author - $userstatic->id = $obj->fk_user_author; - $userstatic->login = $obj->login; - if ($userstatic->id) { - $txt = $userstatic->getLoginUrl(1); - } else { - $txt = ' '; - } - print ''; - - // Amount - print ''; - - // Date - if ($obj->dc) { - $date = dol_print_date($db->jdate($obj->dc), 'dayhour', 'tzuserrel'); - } else { - $date = '-'; - } - print ''; - - // Statut - print ''; - - print ''; - } - $i++; - } - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print $form->selectDate($search_date, 'search_date', 0, 0, 1, '', 1, 0, 0, ''); - print ''; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print '
'; - print ''.img_object($langs->trans('ShowOrder'), 'order').' '.$obj->ref.''; - print ''.img_object($langs->trans('ShowCompany'), 'company').' '.$obj->name.''.$txt.''.price($obj->total_ttc).''.$date.''.$commandestatic->LibStatut($obj->fk_statut, 5).'
'; - print '
'; - - print ''; - - $db->free($resql); - - print dol_get_fiche_end(); -} else { - dol_print_error($db); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sref) $param .= '&search_ref='.urlencode($sref); + if ($snom) $param .= '&search_nom='.urlencode($snom); + if ($suser) $param .= '&search_user='.urlencode($suser); + if ($sttc) $param .= '&search_ttc='.urlencode($sttc); + if ($search_dateyear) $param .= '&search_dateyear='.urlencode($search_dateyear); + if ($search_datemonth) $param .= '&search_datemonth='.urlencode($search_datemonth); + if ($search_dateday) $param .= '&search_dateday='.urlencode($search_dateday); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print_liste_field_titre( + 'Ref', + $_SERVER['PHP_SELF'], + 'cf.ref', + '', + $param, + '', + $sortfield, + $sortorder + ); + print_liste_field_titre( + 'Company', + $_SERVER['PHP_SELF'], + 's.nom', + '', + $param, + '', + $sortfield, + $sortorder + ); + print_liste_field_titre( + 'Author', + $_SERVER['PHP_SELF'], + 'u.login', + '', + '', + '', + $sortfield, + $sortorder + ); + print_liste_field_titre( + 'AmountTTC', + $_SERVER['PHP_SELF'], + 'cf.total_ttc', + '', + $param, + '', + $sortfield, + $sortorder + ); + print_liste_field_titre( + 'OrderCreation', + $_SERVER['PHP_SELF'], + 'cf.date_creation', + '', + $param, + '', + $sortfield, + $sortorder + ); + print_liste_field_titre( + 'Status', + $_SERVER['PHP_SELF'], + 'cf.fk_statut', + '', + $param, + '', + $sortfield, + $sortorder, + 'right ' + ); + print ''; + + $userstatic = new User($db); + + while ($i < min($num, $sproduct ? $num : $conf->liste_limit)) + { + $obj = $db->fetch_object($resql); + + $showline = dolDispatchToDo($obj->rowid) && (!$sproduct || in_array($sproduct, getProducts($obj->rowid))); + + if ($showline) + { + $href = DOL_URL_ROOT.'/fourn/commande/card.php?id='.$obj->rowid; + + print ''; + + // Ref + print ''; + + // Company + $href = DOL_URL_ROOT.'/fourn/card.php?socid='.$obj->socid; + print ''; + + // Author + $userstatic->id = $obj->fk_user_author; + $userstatic->login = $obj->login; + if ($userstatic->id) { + $txt = $userstatic->getLoginUrl(1); + } else { + $txt = ' '; + } + print ''; + + // Amount + print ''; + + // Date + if ($obj->dc) { + $date = dol_print_date($db->jdate($obj->dc), 'dayhour'); + } else { + $date = '-'; + } + print ''; + + // Statut + print ''; + + print ''; + } + $i++; + } + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $form->selectDate($search_date, 'search_date', 0, 0, 1, '', 1, 0, 0, ''); + print ''; + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print '
'; + print ''.img_object($langs->trans('ShowOrder'), 'order').' '.$obj->ref.''; + print ''.img_object($langs->trans('ShowCompany'), 'company').' '.$obj->name.''.$txt.''.price($obj->total_ttc).''.$date.''.$commandestatic->LibStatut($obj->fk_statut, 5).'
'; + print ''; + + $db->free($resql); + + dol_fiche_end(); +} +else +{ + dol_print_error($db); --- /tmp/dsg/dolibarr/htdocs/product/stock/github_19.0.3_valo.php +++ /tmp/dsg/dolibarr/htdocs/product/stock/client_valo.php @@ -26 +25,0 @@ -// Load Dolibarr environment @@ -38 +37 @@ -$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); @@ -40,8 +39,4 @@ -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); -if (!$sortfield) { - $sortfield = "e.ref"; -} -if (!$sortorder) { - $sortorder = "ASC"; -} +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +if (!$sortfield) $sortfield = "e.ref"; +if (!$sortorder) $sortorder = "ASC"; @@ -49,4 +44,2 @@ -if ($page < 0) { - $page = 0; -} -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +if ($page < 0) $page = 0; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -55 +48 @@ -$year = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); +$year = strftime("%Y", time()); @@ -68,9 +61,8 @@ -if ($sref) { - $sql .= natural_search("e.ref", $sref); -} -if ($sall) { - $sql .= " AND (e.ref LIKE '%".$db->escape($sall)."%'"; - $sql .= " OR e.description LIKE '%".$db->escape($sall)."%'"; - $sql .= " OR e.lieu LIKE '%".$db->escape($sall)."%'"; - $sql .= " OR e.address LIKE '%".$db->escape($sall)."%'"; - $sql .= " OR e.town LIKE '%".$db->escape($sall)."%')"; +if ($sref) $sql .= natural_search("e.ref", $sref); +if ($sall) +{ + $sql .= " AND (e.ref LIKE '%".$db->escape($sall)."%'"; + $sql .= " OR e.description LIKE '%".$db->escape($sall)."%'"; + $sql .= " OR e.lieu LIKE '%".$db->escape($sall)."%'"; + $sql .= " OR e.address LIKE '%".$db->escape($sall)."%'"; + $sql .= " OR e.town LIKE '%".$db->escape($sall)."%')"; @@ -83,2 +75,3 @@ -if ($result) { - $num = $db->num_rows($result); +if ($result) +{ + $num = $db->num_rows($result); @@ -86 +79 @@ - $i = 0; + $i = 0; @@ -88,2 +81,2 @@ - $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; - llxHeader("", $langs->trans("EnhancedValueOfWarehouses"), $help_url); + $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; + llxHeader("", $langs->trans("EnhancedValueOfWarehouses"), $help_url); @@ -91 +84 @@ - print_barre_liste($langs->trans("EnhancedValueOfWarehouses"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num); + print_barre_liste($langs->trans("EnhancedValueOfWarehouses"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num); @@ -93,8 +86,8 @@ - print ''; - print ""; - print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "e.ref", "", "", "", $sortfield, $sortorder); - print_liste_field_titre("LocationSummary", $_SERVER["PHP_SELF"], "e.lieu", "", "", "", $sortfield, $sortorder); - print_liste_field_titre("EstimatedStockValue", $_SERVER["PHP_SELF"], "e.valo_pmp", '', '', '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("EstimatedStockValueSell", $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "e.statut", '', '', '', $sortfield, $sortorder, 'right '); - print "\n"; + print '
'; + print ""; + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "e.ref", "", "", "", $sortfield, $sortorder); + print_liste_field_titre("LocationSummary", $_SERVER["PHP_SELF"], "e.lieu", "", "", "", $sortfield, $sortorder); + print_liste_field_titre("EstimatedStockValue", $_SERVER["PHP_SELF"], "e.valo_pmp", '', '', '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("EstimatedStockValueSell", $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "e.statut", '', '', '', $sortfield, $sortorder, 'right '); + print "\n"; @@ -102,30 +95,26 @@ - if ($num) { - $entrepot = new Entrepot($db); - $total = $totalsell = 0; - $var = false; - while ($i < min($num, $limit)) { - $objp = $db->fetch_object($result); - print ''; - print ''; - print ''; - // PMP value - print ''; - // Selling value - print ''; - // Status - print ''; - print "\n"; - $total += price2num($objp->estimatedvalue, 'MU'); - $totalsell += price2num($objp->sellvalue, 'MU'); + if ($num) + { + $entrepot = new Entrepot($db); + $total = $totalsell = 0; + $var = false; + while ($i < min($num, $limit)) + { + $objp = $db->fetch_object($result); + print ''; + print ''; + print ''; + // PMP value + print ''; + // Selling value + print ''; + // Status + print ''; + print "\n"; + $total += price2num($objp->estimatedvalue, 'MU'); + $totalsell += price2num($objp->sellvalue, 'MU'); @@ -133,2 +122,2 @@ - $i++; - } + $i++; + } @@ -136,7 +125,7 @@ - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - } + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + } @@ -144 +133 @@ - $db->free($result); + $db->free($result); @@ -146 +135 @@ - print "
'.img_object($langs->trans("ShowWarehouse"), 'stock').' '.$objp->ref.''.$objp->lieu.''; - if (price2num($objp->estimatedvalue, 'MT')) { - print price(price2num($objp->estimatedvalue, 'MT'), 1); - } else { - print ''; - } - print ''; - if (!getDolGlobalString('PRODUIT_MULTIPRICES')) { - print price(price2num($objp->sellvalue, 'MT'), 1); - } else { - print $langs->trans("Variable"); - } - print ''.$entrepot->LibStatut($objp->statut, 5).'
'.img_object($langs->trans("ShowWarehouse"), 'stock').' '.$objp->ref.''.$objp->lieu.''; + if (price2num($objp->estimatedvalue, 'MT')) print price(price2num($objp->estimatedvalue, 'MT'), 1); + else print ''; + print ''; + if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($objp->sellvalue, 'MT'), 1); + else print $langs->trans("Variable"); + print ''.$entrepot->LibStatut($objp->statut, 5).'
'.$langs->trans("Total").''.price(price2num($total, 'MT'), 1, $langs, 0, 0, -1, $conf->currency).''.price(price2num($totalsell, 'MT'), 1, $langs, 0, 0, -1, $conf->currency).' 
'.$langs->trans("Total").''.price(price2num($total, 'MT'), 1, $langs, 0, 0, -1, $conf->currency).''.price(price2num($totalsell, 'MT'), 1, $langs, 0, 0, -1, $conf->currency).' 
"; + print ""; @@ -148 +137 @@ - print '
'; + print '
'; @@ -150,5 +139,6 @@ - $file = 'entrepot-'.$year.'.png'; - if (file_exists($conf->stock->dir_temp.'/'.$file)) { - $url = DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&file='.$file; - print ''; - } + $file = 'entrepot-'.$year.'.png'; + if (file_exists($conf->stock->dir_temp.'/'.$file)) + { + $url = DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&file='.$file; + print ''; + } @@ -156,7 +146,10 @@ - $file = 'entrepot-'.($year - 1).'.png'; - if (file_exists($conf->stock->dir_temp.'/'.$file)) { - $url = DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&file='.$file; - print '
'; - } -} else { - dol_print_error($db); + $file = 'entrepot-'.($year - 1).'.png'; + if (file_exists($conf->stock->dir_temp.'/'.$file)) + { + $url = DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&file='.$file; + print '
'; + } +} +else +{ + dol_print_error($db);