31 require
'../../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/stock.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
41 if (!empty($conf->project->enabled)) {
42 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
47 $langs->loadLangs(array(
'products',
'stocks',
'companies',
'categories'));
49 $action =
GETPOST(
'action',
'aZ09');
50 $cancel =
GETPOST(
'cancel',
'alpha');
52 $projectid =
GETPOST(
'projectid',
'int');
55 $socid =
GETPOST(
'socid',
'int');
58 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
59 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
67 $backtopage =
GETPOST(
'backtopage',
'alpha');
74 $hookmanager->initHooks(array(
'warehousecard',
'globalcard'));
80 $extrafields->fetch_name_optionals_label($object->table_element);
83 if ($id > 0 || !empty($ref)) {
84 $ret = $object->fetch($id, $ref);
91 $usercanread = (($user->rights->stock->lire));
92 $usercancreate = (($user->rights->stock->creer));
93 $usercandelete = (($user->rights->stock->supprimer));
102 $parameters = array(
'id'=>$id,
'ref'=>$ref);
103 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
107 if (empty($reshook)) {
108 $backurlforlist = DOL_URL_ROOT.
'/product/stock/list.php';
110 if (empty($backtopage) || ($cancel && empty($id))) {
111 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
112 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
113 $backtopage = $backurlforlist;
115 $backtopage = DOL_URL_ROOT.
'/product/stock/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
121 if (!empty($backtopageforcancel)) {
122 header(
"Location: ".$backtopageforcancel);
124 } elseif (!empty($backtopage)) {
125 header(
"Location: ".$backtopage);
132 if ($action ==
'add' && $user->rights->stock->creer) {
133 $object->ref = (string)
GETPOST(
"ref",
"alpha");
134 $object->fk_parent = (int)
GETPOST(
"fk_parent",
"int");
135 $object->fk_project =
GETPOST(
'projectid',
'int');
136 $object->label = (string)
GETPOST(
"libelle",
"alpha");
137 $object->description = (string)
GETPOST(
"desc",
"alpha");
138 $object->statut =
GETPOST(
"statut",
"int");
139 $object->lieu = (string)
GETPOST(
"lieu",
"alpha");
140 $object->address = (string)
GETPOST(
"address",
"alpha");
141 $object->zip = (string)
GETPOST(
"zipcode",
"alpha");
142 $object->town = (string)
GETPOST(
"town",
"alpha");
143 $object->country_id =
GETPOST(
"country_id");
144 $object->phone = (string)
GETPOST(
"phone",
"alpha");
145 $object->fax = (string)
GETPOST(
"fax",
"alpha");
147 if (!empty($object->label)) {
149 $ret = $extrafields->setOptionalsFromPost(null, $object);
156 $id = $object->create($user);
160 $categories =
GETPOST(
'categories',
'array');
161 $object->setCategories($categories);
162 if (!empty($backtopage)) {
163 $backtopage = str_replace(
"__ID__", $id, $backtopage);
164 header(
"Location: ".$backtopage);
167 header(
"Location: card.php?id=".urlencode($id));
176 setEventMessages($langs->trans(
"ErrorWarehouseRefRequired"), null,
'errors');
182 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->rights->stock->supprimer) {
183 $object->fetch(
GETPOST(
'id',
'int'));
184 $result = $object->delete($user);
187 header(
"Location: ".DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1');
196 if ($action ==
'update' && !$cancel) {
197 if ($object->fetch($id)) {
198 $object->label =
GETPOST(
"libelle");
199 $object->fk_parent =
GETPOST(
"fk_parent");
200 $object->fk_project =
GETPOST(
'projectid');
201 $object->description =
GETPOST(
"desc");
202 $object->statut =
GETPOST(
"statut");
203 $object->lieu =
GETPOST(
"lieu");
204 $object->address =
GETPOST(
"address");
205 $object->zip =
GETPOST(
"zipcode");
206 $object->town =
GETPOST(
"town");
207 $object->country_id =
GETPOST(
"country_id");
208 $object->phone =
GETPOST(
"phone");
212 $ret = $extrafields->setOptionalsFromPost(null, $object,
'@GETPOSTISSET');
218 $ret = $object->update($id, $user);
228 $categories =
GETPOST(
'categories',
'array');
229 $object->setCategories($categories);
236 } elseif ($action ==
'update_extras') {
240 $ret = $extrafields->setOptionalsFromPost(null, $object,
GETPOST(
'attribute',
'restricthtml'));
245 $result = $object->insertExtraFields();
252 $action =
'edit_extras';
254 } elseif ($action ==
'classin' && $usercancreate) {
256 $object->setProject(
GETPOST(
'projectid',
'int'));
259 if ($cancel == $langs->trans(
"Cancel")) {
265 $upload_dir = $conf->stock->dir_output;
266 $permissiontoadd = $user->rights->stock->creer;
267 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
275 $productstatic =
new Product($db);
280 if (!empty($conf->project->enabled)) {
284 $help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
288 if ($action ==
'create') {
293 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">'.
"\n";
294 print
'<input type="hidden" name="token" value="'.newToken().
'">';
295 print
'<input type="hidden" name="action" value="add">';
296 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
300 print
'<table class="border centpercent">';
303 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Ref").
'</td><td><input name="libelle" size="20" value=""></td></tr>';
305 print
'<tr><td>'.$langs->trans(
"LocationSummary").
'</td><td><input name="lieu" size="40" value="'.(!empty($object->lieu) ? $object->lieu :
'').
'"></td></tr>';
308 print
'<tr><td>'.$langs->trans(
"AddIn").
'</td><td>';
309 print
img_picto(
'',
'stock').$formproduct->selectWarehouses((
GETPOSTISSET(
'fk_parent') ?
GETPOST(
'fk_parent',
'int') :
'ifone'),
'fk_parent',
'', 1);
313 if (!empty($conf->project->enabled)) {
314 $langs->load(
'projects');
315 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td colspan="2">';
316 print
img_picto(
'',
'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
317 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.$socid.
'&action=create&status=1&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create&socid='.$socid).
'"><span class="fa fa-plus-circle valignmiddle" title="'.$langs->trans(
"AddProject").
'"></span></a>';
322 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
324 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
325 $doleditor =
new DolEditor(
'desc', (!empty($object->description) ? $object->description :
''),
'', 180,
'dolibarr_notes',
'In',
false,
true, empty($conf->fckeditor->enabled) ?
'' : $conf->fckeditor->enabled, ROWS_5,
'90%');
326 $doleditor->Create();
329 print
'<tr><td>'.$langs->trans(
'Address').
'</td><td><textarea name="address" class="quatrevingtpercent" rows="3" wrap="soft">';
330 print (!empty($object->address) ? $object->address :
'');
331 print
'</textarea></td></tr>';
334 print
'<tr><td>'.$langs->trans(
'Zip').
'</td><td>';
335 print $formcompany->select_ziptown((!empty($object->zip) ? $object->zip :
''),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
337 print
'<tr><td>'.$langs->trans(
'Town').
'</td><td>';
338 print $formcompany->select_ziptown((!empty($object->town) ? $object->town :
''),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
342 print
'<tr><td>'.$langs->trans(
'Country').
'</td><td>';
343 print
img_picto(
'',
'globe-americas',
'class="paddingright"');
344 print
$form->select_country((!empty($object->country_id) ? $object->country_id : $mysoc->country_code),
'country_id');
346 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
351 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Phone',
'phone',
'', $object, 0).
'</td><td>';
352 print
img_picto(
'',
'object_phoning',
'class="paddingright"');
353 print
'<input name="phone" size="20" value="'.$object->phone.
'"></td></tr>';
354 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td>';
356 print
img_picto(
'',
'object_phoning_fax',
'class="paddingright"');
357 print
'<input name="fax" size="20" value="'.$object->fax.
'"></td></tr>';
360 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
361 print
'<select id="warehousestatus" name="statut" class="flat">';
362 foreach ($object->statuts as $key => $value) {
364 print
'<option value="'.$key.
'" selected>'.$langs->trans($value).
'</option>';
366 print
'<option value="'.$key.
'">'.$langs->trans($value).
'</option>';
374 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
376 if (!empty($conf->categorie->enabled)) {
378 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
379 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_WAREHOUSE,
'',
'parent', 64, 0, 1);
380 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
387 print
$form->buttonsSaveCancel(
"Create");
392 if ($id > 0 || $ref) {
394 $result = $object->fetch($id, $ref);
396 print
'No record found';
403 if ($action <>
'edit' && $action <>
're-edit') {
411 if ($action ==
'delete') {
412 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"DeleteAWarehouse"), $langs->trans(
"ConfirmDeleteWarehouse", $object->label),
"confirm_delete",
'', 0, 2);
416 $parameters = array(
'formConfirm' => $formconfirm);
417 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
418 if (empty($reshook)) {
419 $formconfirm .= $hookmanager->resPrint;
420 } elseif ($reshook > 0) {
421 $formconfirm = $hookmanager->resPrint;
428 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
430 $morehtmlref =
'<div class="refidno">';
431 $morehtmlref .= $langs->trans(
"LocationSummary").
' : '.$object->lieu;
434 if (!empty($conf->project->enabled)) {
435 $langs->load(
"projects");
436 $morehtmlref .=
'<br>'.img_picto(
'',
'project').
' '.$langs->trans(
'Project').
' ';
437 if ($usercancreate) {
438 if ($action !=
'classify') {
439 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
441 if ($action ==
'classify') {
442 $projectid = $object->fk_project;
443 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
444 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
445 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
446 $morehtmlref .= $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
447 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
448 $morehtmlref .=
'</form>';
450 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, ($socid > 0 ? $socid : -1), $object->fk_project,
'none', 0, 0, 0, 1);
453 if (!empty($object->fk_project)) {
455 $proj->fetch($object->fk_project);
456 $morehtmlref .=
' : '.$proj->getNomUrl(1);
458 $morehtmlref .=
' - '.$proj->title;
465 $morehtmlref .=
'</div>';
468 if ($user->socid && !in_array(
'stock', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
472 dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref',
'ref', $morehtmlref);
474 print
'<div class="fichecenter">';
475 print
'<div class="fichehalfleft">';
476 print
'<div class="underbanner clearboth"></div>';
478 print
'<table class="border centpercent tableforfield">';
481 $parentwarehouse =
new Entrepot($db);
482 if (!empty($object->fk_parent) && $parentwarehouse->fetch($object->fk_parent) > 0) {
483 print
'<tr><td>'.$langs->trans(
"ParentWarehouse").
'</td><td>';
484 print $parentwarehouse->getNomUrl(3);
491 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>'.
dol_htmlentitiesbr($object->description).
'</td></tr>';
493 $calcproductsunique = $object->nb_different_products();
494 $calcproducts = $object->nb_products();
497 print
'<tr><td>'.$langs->trans(
"NumberOfDifferentProducts").
'</td><td>';
498 print empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb'];
502 print
'<tr><td>'.$langs->trans(
"NumberOfProducts").
'</td><td>';
503 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
504 print empty($valtoshow) ?
'0' : $valtoshow;
510 print
'<div class="fichehalfright">';
511 print
'<div class="underbanner clearboth"></div>';
513 print
'<table class="border centpercent tableforfield">';
516 print
'<tr><td class="titlefield">'.$langs->trans(
"EstimatedStockValueShort").
'</td><td>';
517 print
price((empty($calcproducts[
'value']) ?
'0' :
price2num($calcproducts[
'value'],
'MT')), 0, $langs, 0, -1, -1, $conf->currency);
521 if (!empty($user->rights->stock->mouvement->lire)) {
522 $sql =
"SELECT max(m.datem) as datem";
523 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
524 $sql .=
" WHERE m.fk_entrepot = ".((int) $object->id);
525 $resqlbis = $db->query($sql);
527 $obj = $db->fetch_object($resqlbis);
528 $lastmovementdate = $db->jdate($obj->datem);
532 print
'<tr><td>'.$langs->trans(
"LastMovement").
'</td><td>';
533 if ($lastmovementdate) {
535 print
' ';
536 print
img_picto($langs->trans(
'LastMovement'),
'movement',
'class="pictofixedwidth"');
537 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?id='.$object->id.
'">'.$langs->trans(
"FullList").
'</a>';
539 print $langs->trans(
"None");
545 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
549 print
'<tr><td valign="middle">'.$langs->trans(
"Categories").
'</td><td colspan="3">';
550 print
$form->showCategories($object->id, Categorie::TYPE_WAREHOUSE, 1);
559 print
'<div class="clearboth"></div>';
567 print
"<div class=\"tabsAction\">\n";
569 $parameters = array();
570 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
571 if (empty($reshook)) {
572 if (empty($action) || $action ==
'classin') {
573 if ($user->rights->stock->creer) {
574 print
'<a class="butAction" href="card.php?action=edit&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Modify").
'</a>';
576 print
'<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
"Modify").
'</a>';
579 if ($user->rights->stock->supprimer) {
580 print
'<a class="butActionDelete" href="card.php?action=delete&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Delete").
'</a>';
582 print
'<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
"Delete").
'</a>';
597 print
'<table class="noborder centpercent">';
598 print
"<tr class=\"liste_titre\">";
599 $parameters = array();
600 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
601 print $hookmanager->resPrint;
604 print_liste_field_titre(
"NumberOfUnit",
"",
"ps.reel",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
605 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
608 print_liste_field_titre(
$form->textwithpicto($langs->trans(
"AverageUnitPricePMPShort"), $langs->trans(
"AverageUnitPricePMPDesc")),
"",
"p.pmp",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
609 print_liste_field_titre(
"EstimatedStockValueShort",
"",
"",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
610 if (empty($conf->global->PRODUIT_MULTIPRICES)) {
611 print_liste_field_titre(
"SellPriceMin",
"",
"p.price",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
613 if (empty($conf->global->PRODUIT_MULTIPRICES)) {
614 print_liste_field_titre(
"EstimatedStockValueSellShort",
"",
"",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
616 if ($user->rights->stock->mouvement->creer) {
619 if ($user->rights->stock->creer) {
623 $parameters = array(
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
624 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
625 print $hookmanager->resPrint;
629 $totalvalue = $totalvaluesell = 0;
632 $separatedPMP =
false;
633 if (!empty($conf->global->MULTICOMPANY_PRODUCT_SHARING_ENABLED) && !empty($conf->global->MULTICOMPANY_PMP_PER_ENTITY_ENABLED)) {
634 $separatedPMP =
true;
637 $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,";
638 $sql .=
"p.tosell, p.tobuy,";
639 $sql .=
"p.accountancy_code_sell,";
640 $sql .=
"p.accountancy_code_sell_intra,";
641 $sql .=
"p.accountancy_code_sell_export,";
642 $sql .=
"p.accountancy_code_buy,";
643 $sql .=
"p.accountancy_code_buy_intra,";
644 $sql .=
"p.accountancy_code_buy_export,";
645 $sql .=
'p.barcode,';
647 $sql .=
" pa.pmp as ppmp,";
649 $sql .=
" p.pmp as ppmp,";
651 $sql .=
" ps.reel as value";
652 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
656 $parameters = array();
657 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
661 $sql .= $hookmanager->resPrint;
662 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_stock as ps, ".MAIN_DB_PREFIX.
"product as p";
665 $sql .=
", ".MAIN_DB_PREFIX.
"product_perentity as pa";
668 $sql .=
" WHERE ps.fk_product = p.rowid";
669 $sql .=
" AND ps.reel <> 0";
670 $sql .=
" AND ps.fk_entrepot = ".((int) $object->id);
673 $sql .=
" AND pa.fk_product = p.rowid AND pa.entity = ".(int) $conf->entity;
676 $sql .= $db->order($sortfield, $sortorder);
679 $resql = $db->query($sql);
681 $num = $db->num_rows(
$resql);
686 $objp = $db->fetch_object(
$resql);
689 if (!empty($conf->global->MAIN_MULTILANGS)) {
690 $sql =
"SELECT label";
691 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
692 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
693 $sql .=
" AND lang = '".$db->escape($langs->getDefaultLang()).
"'";
696 $result = $db->query($sql);
698 $objtp = $db->fetch_object($result);
699 if ($objtp->label !=
'') {
700 $objp->produit = $objtp->label;
706 print
'<tr class="oddeven">';
708 $parameters = array(
'obj'=>$objp);
709 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
710 print $hookmanager->resPrint;
712 $productstatic->id = $objp->rowid;
713 $productstatic->ref = $objp->ref;
714 $productstatic->label = $objp->produit;
715 $productstatic->type = $objp->type;
716 $productstatic->entity = $objp->entity;
717 $productstatic->status_batch = $objp->tobatch;
718 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
719 $productstatic->fk_unit = $objp->fk_unit;
721 $productstatic->status = $objp->tosell;
722 $productstatic->status_buy = $objp->tobuy;
723 $productstatic->barcode = $objp->barcode;
724 $productstatic->accountancy_code_sell = $objp->accountancy_code_sell;
725 $productstatic->accountancy_code_sell_intra = $objp->accountancy_code_sell_intra;
726 $productstatic->accountancy_code_sell_export = $objp->accountancy_code_sell_export;
727 $productstatic->accountancy_code_buy = $objp->accountancy_code_buy;
728 $productstatic->accountancy_code_buy_intra = $objp->accountancy_code_buy_intra;
729 $productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export;
732 print $productstatic->getNomUrl(1,
'stock', 16);
736 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($objp->produit).
'">'.
dol_escape_htmltag($objp->produit).
'</td>';
738 print
'<td class="right">';
740 print empty($valtoshow) ?
'0' : $valtoshow;
742 $totalunit += $objp->value;
744 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
746 print
'<td align="left">';
747 if (is_null($productstatic->fk_unit)) {
748 $productstatic->fk_unit = 1;
750 print $langs->trans($productstatic->getLabelOfUnit());
754 print
'<td class="right nowraponall">'.price(
price2num($objp->ppmp,
'MU')).
'</td>';
757 print
'<td class="right amount nowraponall">'.price(
price2num($objp->ppmp * $objp->value,
'MT')).
'</td>';
758 $totalvalue +=
price2num($objp->ppmp * $objp->value,
'MT');
761 if (empty($conf->global->PRODUIT_MULTIPRICES)) {
762 $pricemin = $objp->price;
763 print
'<td class="right">';
767 print
'<td class="right">';
771 $totalvaluesell +=
price2num($pricemin * $objp->value,
'MT');
773 if ($user->rights->stock->mouvement->creer) {
774 print
'<td class="center"><a href="'.DOL_URL_ROOT.
'/product/stock/product.php?dwid='.$object->id.
'&id='.$objp->rowid.
'&action=transfert&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?id='.$id).
'">';
775 print
img_picto($langs->trans(
"TransferStock"),
'add',
'class="hideonsmartphone pictofixedwidth" style="color: #a69944"');
776 print $langs->trans(
"TransferStock");
780 if ($user->rights->stock->creer) {
781 print
'<td class="center"><a href="'.DOL_URL_ROOT.
'/product/stock/product.php?dwid='.$object->id.
'&id='.$objp->rowid.
'&action=correction&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?id='.$id).
'">';
782 print
img_picto($langs->trans(
"CorrectStock"),
'add',
'class="hideonsmartphone pictofixedwidth" style="color: #a69944"');
783 print $langs->trans(
"CorrectStock");
786 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
788 $units = $productstatic->fk_unit;
789 } elseif ($productstatic->fk_unit != $units) {
798 print
'<tr class="liste_total"><td class="liste_total" colspan="2">'.$langs->trans(
"Total").
'</td>';
799 print
'<td class="liste_total right">';
800 $valtoshow =
price2num($totalunit,
'MS');
801 if (empty($conf->global->PRODUCT_USE_UNITS) || $sameunits) {
802 print empty($valtoshow) ?
'0' : $valtoshow;
805 print
'<td class="liste_total">';
806 if (empty($conf->global->PRODUCT_USE_UNITS) && $sameunits) {
807 print $langs->trans($productstatic->getLabelOfUnit());
810 print
'<td class="liste_total right">'.price(
price2num($totalvalue,
'MT')).
'</td>';
811 if (empty($conf->global->PRODUIT_MULTIPRICES)) {
812 print
'<td class="liste_total"> </td>';
813 print
'<td class="liste_total right">'.price(
price2num($totalvaluesell,
'MT')).
'</td>';
815 print
'<td class="liste_total"> </td>';
816 print
'<td class="liste_total"> </td>';
817 print
'<td class="liste_total"> </td>';
829 if ($action ==
'edit' || $action ==
're-edit') {
830 $langs->trans(
"WarehouseEdit");
832 print
'<form action="card.php" method="POST">';
833 print
'<input type="hidden" name="token" value="'.newToken().
'">';
834 print
'<input type="hidden" name="action" value="update">';
835 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
841 print
'<table class="border centpercent">';
844 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Ref").
'</td><td><input name="libelle" size="20" value="'.$object->label.
'"></td></tr>';
846 print
'<tr><td>'.$langs->trans(
"LocationSummary").
'</td><td><input name="lieu" class="minwidth300" value="'.$object->lieu.
'"></td></tr>';
849 print
'<tr><td>'.$langs->trans(
"AddIn").
'</td><td>';
850 print $formproduct->selectWarehouses($object->fk_parent,
'fk_parent',
'', 1);
854 if (!empty($conf->project->enabled)) {
855 $projectid = $object->fk_project;
856 $langs->load(
'projects');
857 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td colspan="2">';
858 print
img_picto(
'',
'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
859 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.($socid > 0 ? $socid :
"").
'&action=create&status=1&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create'.($socid > 0 ?
'&socid='.$socid :
"")).
'"><span class="fa fa-plus-circle valignmiddle" title="'.$langs->trans(
"AddProject").
'"></span></a>';
864 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
866 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
867 $doleditor =
new DolEditor(
'desc', $object->description,
'', 180,
'dolibarr_notes',
'In',
false,
true, $conf->fckeditor->enabled, ROWS_5,
'90%');
868 $doleditor->Create();
871 print
'<tr><td>'.$langs->trans(
'Address').
'</td><td><textarea name="address" class="quatrevingtpercent" rows="3" wrap="soft">';
872 print $object->address;
873 print
'</textarea></td></tr>';
876 print
'<tr><td>'.$langs->trans(
'Zip').
'</td><td>';
877 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
879 print
'<tr><td>'.$langs->trans(
'Town').
'</td><td>';
880 print $formcompany->select_ziptown($object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
884 print
'<tr><td>'.$langs->trans(
'Country').
'</td><td>';
885 print
img_picto(
'',
'globe-americas',
'class="paddingright"');
886 print
$form->select_country($object->country_id ? $object->country_id : $mysoc->country_code,
'country_id');
888 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
893 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Phone',
'phone',
'', $object, 0).
'</td><td>';
894 print
img_picto(
'',
'object_phoning',
'class="paddingright"');
895 print
'<input name="phone" size="20" value="'.$object->phone.
'"></td></tr>';
896 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td><td>';
897 print
img_picto(
'',
'object_phoning_fax',
'class="paddingright"');
898 print
'<input name="fax" size="20" value="'.$object->fax.
'"></td></tr>';
901 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
902 print
'<select id="warehousestatus" name="statut" class="flat">';
903 foreach ($object->statuts as $key => $value) {
904 if ($key == $object->statut) {
905 print
'<option value="'.$key.
'" selected>'.$langs->trans($value).
'</option>';
907 print
'<option value="'.$key.
'">'.$langs->trans($value).
'</option>';
916 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' =>
'3');
917 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
918 print $hookmanager->resPrint;
919 if (empty($reshook)) {
920 print $object->showOptionals($extrafields,
'edit', $parameters);
925 print
'<tr><td class="tdtop">'.$langs->trans(
"Categories").
'</td><td colspan="3">';
926 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_WAREHOUSE,
'',
'parent', 64, 0, 1);
928 $cats = $c->containing($object->id, Categorie::TYPE_WAREHOUSE);
929 $arrayselected = array();
930 foreach ($cats as $cat) {
931 $arrayselected[] = $cat->id;
933 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
941 print
$form->buttonsSaveCancel();
952 $modulepart =
'stock';
954 if ($action !=
'create' && $action !=
'edit' && $action !=
'delete') {
956 print
'<div class="fichecenter"><div class="fichehalfleft">';
957 print
'<a name="builddoc"></a>';
961 $relativepath = $object->ref.
'/'.$objectref.
'.pdf';
962 $filedir = $conf->stock->dir_output.
'/'.$objectref;
963 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
964 $genallowed = $usercanread;
965 $delallowed = $usercancreate;
966 $modulepart =
'stock';
968 print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0,
'', 0,
'',
'',
'', $object);
969 $somethingshown = $formfile->numoffiles;
971 print
'</div><div class="fichehalfright">';
975 $morehtmlcenter =
'';
979 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
981 $somethingshown =
$formactions->showactions($object,
'stock', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
983 print
'</div></div>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action== 'set') elseif($action== 'specimen') elseif($action== 'setmodel') elseif($action== 'del') elseif($action== 'setdoc') $formactions
View.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
Class to manage products or services.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for properties) With native = 0: P...
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom= 'UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save"&&empty($cancel)) $help_url
View.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Class to manage categories.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= 'hideonsmartphone', $textfordropdown= '')
Show information for admin users or standard users.
Class to manage projects.
stock_prepare_head($object)
Prepare array with list of tabs.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete= 'resolve', $idforemptyvalue= '-1')
Convert a html select field into an ajax combobox.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
isModEnabled($module)
Is Dolibarr module enabled.
Class to manage a WYSIWYG editor.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
$formconfirm
if ($action == 'delbookkeepingyear') {
Class to manage warehouses.