32require
'../../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/stock.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
42if (isModEnabled(
'project')) {
43 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
48$langs->loadLangs(array(
'products',
'stocks',
'companies',
'categories'));
50$action =
GETPOST(
'action',
'aZ09');
51$cancel =
GETPOST(
'cancel',
'alpha');
53$projectid =
GETPOST(
'projectid',
'int');
56$socid =
GETPOST(
'socid',
'int');
60$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
61$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
62$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
70$backtopage =
GETPOST(
'backtopage',
'alpha');
77$hookmanager->initHooks(array(
'warehousecard',
'globalcard'));
83$extrafields->fetch_name_optionals_label($object->table_element);
86if ($id > 0 || !empty($ref)) {
87 $ret = $object->fetch($id, $ref);
94$usercanread = (($user->rights->stock->lire));
95$usercancreate = (($user->rights->stock->creer));
96$usercandelete = (($user->rights->stock->supprimer));
105$parameters = array(
'id'=>$id,
'ref'=>$ref);
106$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
110if (empty($reshook)) {
111 $backurlforlist = DOL_URL_ROOT.
'/product/stock/list.php';
113 if (empty($backtopage) || ($cancel && empty($id))) {
114 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
115 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
116 $backtopage = $backurlforlist;
118 $backtopage = DOL_URL_ROOT.
'/product/stock/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
124 if (!empty($backtopageforcancel)) {
125 header(
"Location: ".$backtopageforcancel);
127 } elseif (!empty($backtopage)) {
128 header(
"Location: ".$backtopage);
135 if ($action ==
'add' && $user->rights->stock->creer) {
136 $object->ref = (string)
GETPOST(
"ref",
"alpha");
137 $object->fk_parent = (int)
GETPOST(
"fk_parent",
"int");
138 $object->fk_project =
GETPOST(
'projectid',
'int');
139 $object->label = (string)
GETPOST(
"libelle",
"alpha");
140 $object->description = (string)
GETPOST(
"desc",
"alpha");
141 $object->statut =
GETPOST(
"statut",
"int");
142 $object->lieu = (string)
GETPOST(
"lieu",
"alpha");
143 $object->address = (string)
GETPOST(
"address",
"alpha");
144 $object->zip = (string)
GETPOST(
"zipcode",
"alpha");
145 $object->town = (string)
GETPOST(
"town",
"alpha");
146 $object->country_id =
GETPOST(
"country_id");
147 $object->phone = (string)
GETPOST(
"phone",
"alpha");
148 $object->fax = (string)
GETPOST(
"fax",
"alpha");
150 if (!empty($object->label)) {
152 $ret = $extrafields->setOptionalsFromPost(
null, $object);
159 $id = $object->create($user);
163 $categories =
GETPOST(
'categories',
'array');
164 $object->setCategories($categories);
165 if (!empty($backtopage)) {
166 $backtopage = str_replace(
"__ID__", $id, $backtopage);
167 header(
"Location: ".$backtopage);
170 header(
"Location: card.php?id=".urlencode($id));
179 setEventMessages($langs->trans(
"ErrorWarehouseRefRequired"),
null,
'errors');
185 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->rights->stock->supprimer) {
186 $object->fetch(
GETPOST(
'id',
'int'));
187 $result = $object->delete($user);
190 header(
"Location: ".DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1');
199 if ($action ==
'update' && !$cancel) {
200 if ($object->fetch($id)) {
201 $object->label =
GETPOST(
"libelle");
202 $object->fk_parent =
GETPOST(
"fk_parent");
203 $object->fk_project =
GETPOST(
'projectid');
204 $object->description =
GETPOST(
"desc",
'restricthtml');
205 $object->statut =
GETPOST(
"statut");
206 $object->lieu =
GETPOST(
"lieu");
207 $object->address =
GETPOST(
"address");
208 $object->zip =
GETPOST(
"zipcode");
209 $object->town =
GETPOST(
"town");
210 $object->country_id =
GETPOST(
"country_id");
211 $object->phone =
GETPOST(
"phone");
215 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
221 $ret = $object->update($id, $user);
231 $categories =
GETPOST(
'categories',
'array');
232 $object->setCategories($categories);
239 } elseif ($action ==
'update_extras') {
243 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
248 $result = $object->insertExtraFields();
255 $action =
'edit_extras';
257 } elseif ($action ==
'classin' && $usercancreate) {
259 $object->setProject(
GETPOST(
'projectid',
'int'));
262 if ($cancel == $langs->trans(
"Cancel")) {
268 $upload_dir = $conf->stock->dir_output;
269 $permissiontoadd = $user->rights->stock->creer;
270 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
278$productstatic =
new Product($db);
279$form =
new Form($db);
283if (isModEnabled(
'project')) {
287$title = $langs->trans(
"WarehouseCard");
288if ($action ==
'create') {
289 $title = $langs->trans(
"NewWarehouse");
292$help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
296if ($action ==
'create') {
301 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">'.
"\n";
302 print
'<input type="hidden" name="token" value="'.newToken().
'">';
303 print
'<input type="hidden" name="action" value="add">';
304 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
308 print
'<table class="border centpercent">';
311 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Ref").
'</td><td><input name="libelle" size="20" value=""></td></tr>';
313 print
'<tr><td>'.$langs->trans(
"LocationSummary").
'</td><td><input name="lieu" size="40" value="'.(!empty($object->lieu) ? $object->lieu :
'').
'"></td></tr>';
316 print
'<tr><td>'.$langs->trans(
"AddIn").
'</td><td>';
317 print
img_picto(
'',
'stock').$formproduct->selectWarehouses((GETPOSTISSET(
'fk_parent') ?
GETPOST(
'fk_parent',
'int') :
'ifone'),
'fk_parent',
'', 1);
321 if (isModEnabled(
'project')) {
322 $langs->load(
'projects');
323 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td colspan="2">';
324 print
img_picto(
'',
'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
325 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>';
330 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
332 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
333 $doleditor =
new DolEditor(
'desc', (!empty($object->description) ? $object->description :
''),
'', 180,
'dolibarr_notes',
'In', false, true, isModEnabled(
'fckeditor'), ROWS_5,
'90%');
334 $doleditor->Create();
337 print
'<tr><td>'.$langs->trans(
'Address').
'</td><td><textarea name="address" class="quatrevingtpercent" rows="3" wrap="soft">';
338 print (!empty($object->address) ? $object->address :
'');
339 print
'</textarea></td></tr>';
342 print
'<tr><td>'.$langs->trans(
'Zip').
'</td><td>';
343 print $formcompany->select_ziptown((!empty($object->zip) ? $object->zip :
''),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
345 print
'<tr><td>'.$langs->trans(
'Town').
'</td><td>';
346 print $formcompany->select_ziptown((!empty($object->town) ? $object->town :
''),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
350 print
'<tr><td>'.$langs->trans(
'Country').
'</td><td>';
351 print
img_picto(
'',
'globe-americas',
'class="paddingright"');
352 print $form->select_country((!empty($object->country_id) ? $object->country_id : $mysoc->country_code),
'country_id');
354 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
359 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Phone',
'phone',
'', $object, 0).
'</td><td>';
360 print
img_picto(
'',
'object_phoning',
'class="paddingright"');
361 print
'<input name="phone" size="20" value="'.$object->phone.
'"></td></tr>';
362 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td>';
364 print
img_picto(
'',
'object_phoning_fax',
'class="paddingright"');
365 print
'<input name="fax" size="20" value="'.$object->fax.
'"></td></tr>';
368 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
369 print
'<select id="warehousestatus" name="statut" class="flat minwidth100">';
370 foreach ($object->statuts as $key => $value) {
372 print
'<option value="'.$key.
'" selected>'.$langs->trans($value).
'</option>';
374 print
'<option value="'.$key.
'">'.$langs->trans($value).
'</option>';
382 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
384 if (isModEnabled(
'categorie')) {
386 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
387 $cate_arbo = $form->select_all_categories(Categorie::TYPE_WAREHOUSE,
'',
'parent', 64, 0, 1);
388 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
395 print $form->buttonsSaveCancel(
"Create");
400 if ($id > 0 || $ref) {
402 $result = $object->fetch($id, $ref);
404 print
'No record found';
409 if ($action <>
'edit' && $action <>
're-edit') {
417 if ($action ==
'delete') {
418 $formquestion = array(
419 array(
'type' =>
'other',
'name' =>
'info',
'label' =>
img_warning(
'').$langs->trans(
"WarningThisWIllAlsoDeleteStock"),
'morecss'=>
'warning')
421 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"DeleteAWarehouse"), $langs->trans(
"ConfirmDeleteWarehouse", $object->label),
"confirm_delete", $formquestion, 0, 2);
425 $parameters = array(
'formConfirm' => $formconfirm);
426 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
427 if (empty($reshook)) {
428 $formconfirm .= $hookmanager->resPrint;
429 } elseif ($reshook > 0) {
430 $formconfirm = $hookmanager->resPrint;
437 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
439 $morehtmlref =
'<div class="refidno">';
440 $morehtmlref .= $langs->trans(
"LocationSummary").
' : '.$object->lieu;
443 if (isModEnabled(
'project')) {
444 $langs->load(
"projects");
445 $morehtmlref .=
'<br>'.img_picto(
'',
'project').
' '.$langs->trans(
'Project').
' ';
446 if ($usercancreate) {
447 if ($action !=
'classify') {
448 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
450 if ($action ==
'classify') {
451 $projectid = $object->fk_project;
452 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
453 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
454 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
455 $morehtmlref .= $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
456 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
457 $morehtmlref .=
'</form>';
459 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, ($socid > 0 ? $socid : -1), $object->fk_project,
'none', 0, 0, 0, 1,
'',
'maxwidth300');
462 if (!empty($object->fk_project)) {
464 $proj->fetch($object->fk_project);
465 $morehtmlref .=
' : '.$proj->getNomUrl(1);
467 $morehtmlref .=
' - '.$proj->title;
474 $morehtmlref .=
'</div>';
477 if ($user->socid && !in_array(
'stock', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
481 dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref',
'ref', $morehtmlref);
483 print
'<div class="fichecenter">';
484 print
'<div class="fichehalfleft">';
485 print
'<div class="underbanner clearboth"></div>';
487 print
'<table class="border centpercent tableforfield">';
490 $parentwarehouse =
new Entrepot($db);
491 if (!empty($object->fk_parent) && $parentwarehouse->fetch($object->fk_parent) > 0) {
492 print
'<tr><td>'.$langs->trans(
"ParentWarehouse").
'</td><td>';
493 print $parentwarehouse->getNomUrl(3);
500 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>'.
dol_htmlentitiesbr($object->description).
'</td></tr>';
502 $calcproductsunique = $object->nb_different_products();
503 $calcproducts = $object->nb_products();
506 print
'<tr><td>'.$langs->trans(
"NumberOfDifferentProducts").
'</td><td>';
507 print empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb'];
511 print
'<tr><td>'.$langs->trans(
"NumberOfProducts").
'</td><td>';
512 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
513 print empty($valtoshow) ?
'0' : $valtoshow;
519 print
'<div class="fichehalfright">';
520 print
'<div class="underbanner clearboth"></div>';
522 print
'<table class="border centpercent tableforfield">';
525 print
'<tr><td class="titlefield">'.$langs->trans(
"EstimatedStockValueShort").
'</td><td>';
526 print
price((empty($calcproducts[
'value']) ?
'0' :
price2num($calcproducts[
'value'],
'MT')), 0, $langs, 0, -1, -1, $conf->currency);
530 if (!empty($user->rights->stock->mouvement->lire)) {
531 $sql =
"SELECT max(m.datem) as datem";
532 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
533 $sql .=
" WHERE m.fk_entrepot = ".((int) $object->id);
534 $resqlbis = $db->query($sql);
536 $obj = $db->fetch_object($resqlbis);
537 $lastmovementdate = $db->jdate($obj->datem);
541 print
'<tr><td>'.$langs->trans(
"LastMovement").
'</td><td>';
542 if ($lastmovementdate) {
544 print
' ';
545 print
img_picto($langs->trans(
'LastMovement'),
'movement',
'class="pictofixedwidth"');
546 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?id='.$object->id.
'">'.$langs->trans(
"FullList").
'</a>';
548 print $langs->trans(
"None");
554 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
557 if (isModEnabled(
'categorie')) {
558 print
'<tr><td valign="middle">'.$langs->trans(
"Categories").
'</td><td colspan="3">';
559 print $form->showCategories($object->id, Categorie::TYPE_WAREHOUSE, 1);
568 print
'<div class="clearboth"></div>';
576 print
"<div class=\"tabsAction\">\n";
578 $parameters = array();
579 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
580 if (empty($reshook)) {
581 if (empty($action) || $action ==
'classin') {
582 if ($user->rights->stock->creer) {
583 print
'<a class="butAction" href="card.php?action=edit&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Modify").
'</a>';
585 print
'<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
"Modify").
'</a>';
588 if ($user->rights->stock->supprimer) {
589 print
'<a class="butActionDelete" href="card.php?action=delete&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Delete").
'</a>';
591 print
'<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
"Delete").
'</a>';
603 $totalarray = array();
604 $totalarray[
'val'] = array ();
605 $totalarray[
'pos'] = array ();
606 $totalarray[
'type'] = array ();
607 $totalarray[
'nbfield'] = 0;
611 print
'<table class="noborder centpercent">';
612 print
"<tr class=\"liste_titre\">";
613 $parameters = array(
'totalarray' => &$totalarray);
614 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
615 print $hookmanager->resPrint;
619 print_liste_field_titre(
"NumberOfUnit",
"",
"ps.reel",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
620 $totalarray[
'nbfield'] += 3;
621 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalunit';
622 $totalarray[
'type'][$totalarray[
'nbfield']] =
'stock';
624 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
626 $totalarray[
'nbfield']++;
627 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'units';
628 $totalarray[
'type'][$totalarray[
'nbfield']] =
'string';
631 print_liste_field_titre($form->textwithpicto($langs->trans(
"AverageUnitPricePMPShort"), $langs->trans(
"AverageUnitPricePMPDesc")),
"",
"p.pmp",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
632 $totalarray[
'nbfield']++;
634 print_liste_field_titre(
"EstimatedStockValueShort",
"",
"",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
635 $totalarray[
'nbfield']++;
636 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalvalue';
637 $totalarray[
'type'][$totalarray[
'nbfield']] =
'';
640 if (empty($conf->global->PRODUIT_MULTIPRICES)) {
641 print_liste_field_titre(
"SellPriceMin",
"",
"p.price",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
642 $totalarray[
'nbfield']++;
644 if (empty($conf->global->PRODUIT_MULTIPRICES)) {
645 print_liste_field_titre(
"EstimatedStockValueSellShort",
"",
"",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
646 $totalarray[
'nbfield']++;
647 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalvaluesell';
648 $totalarray[
'type'][$totalarray[
'nbfield']] =
'';
650 if ($user->rights->stock->mouvement->creer) {
652 $totalarray[
'nbfield']++;
654 if ($user->rights->stock->creer) {
656 $totalarray[
'nbfield']++;
659 $parameters = array(
'sortfield'=>$sortfield,
'sortorder'=>$sortorder,
'totalarray' => &$totalarray);
660 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
661 print $hookmanager->resPrint;
665 $totalvalue = $totalvaluesell = 0;
668 $separatedPMP =
false;
669 if (!empty($conf->global->MULTICOMPANY_PRODUCT_SHARING_ENABLED) && !empty($conf->global->MULTICOMPANY_PMP_PER_ENTITY_ENABLED)) {
670 $separatedPMP =
true;
673 $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,";
674 $sql .=
"p.tosell, p.tobuy,";
675 $sql .=
"p.accountancy_code_sell,";
676 $sql .=
"p.accountancy_code_sell_intra,";
677 $sql .=
"p.accountancy_code_sell_export,";
678 $sql .=
"p.accountancy_code_buy,";
679 $sql .=
"p.accountancy_code_buy_intra,";
680 $sql .=
"p.accountancy_code_buy_export,";
681 $sql .=
'p.barcode,';
683 $sql .=
" pa.pmp as ppmp,";
685 $sql .=
" p.pmp as ppmp,";
687 $sql .=
" ps.reel as value";
688 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
692 $parameters = array();
693 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
697 $sql .= $hookmanager->resPrint;
698 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_stock as ps, ".MAIN_DB_PREFIX.
"product as p";
701 $sql .=
", ".MAIN_DB_PREFIX.
"product_perentity as pa";
704 $sql .=
" WHERE ps.fk_product = p.rowid";
705 $sql .=
" AND ps.reel <> 0";
706 $sql .=
" AND ps.fk_entrepot = ".((int) $object->id);
709 $sql .=
" AND pa.fk_product = p.rowid AND pa.entity = ".(int) $conf->entity;
712 $sql .= $db->order($sortfield, $sortorder);
715 $resql = $db->query($sql);
717 $num = $db->num_rows($resql);
722 $objp = $db->fetch_object($resql);
726 $sql =
"SELECT label";
727 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
728 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
729 $sql .=
" AND lang = '".$db->escape($langs->getDefaultLang()).
"'";
732 $result = $db->query($sql);
734 $objtp = $db->fetch_object($result);
735 if ($objtp->label !=
'') {
736 $objp->produit = $objtp->label;
742 print
'<tr class="oddeven">';
744 $parameters = array(
'obj'=>$objp,
'totalarray' => &$totalarray);
745 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
746 print $hookmanager->resPrint;
748 $productstatic->id = $objp->rowid;
749 $productstatic->ref = $objp->ref;
750 $productstatic->label = $objp->produit;
751 $productstatic->type = $objp->type;
752 $productstatic->entity = $objp->entity;
753 $productstatic->status_batch = $objp->tobatch;
754 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
755 $productstatic->fk_unit = $objp->fk_unit;
757 $productstatic->status = $objp->tosell;
758 $productstatic->status_buy = $objp->tobuy;
759 $productstatic->barcode = $objp->barcode;
760 $productstatic->accountancy_code_sell = $objp->accountancy_code_sell;
761 $productstatic->accountancy_code_sell_intra = $objp->accountancy_code_sell_intra;
762 $productstatic->accountancy_code_sell_export = $objp->accountancy_code_sell_export;
763 $productstatic->accountancy_code_buy = $objp->accountancy_code_buy;
764 $productstatic->accountancy_code_buy_intra = $objp->accountancy_code_buy_intra;
765 $productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export;
769 print $productstatic->getNomUrl(1,
'stock', 16);
773 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($objp->produit).
'">'.
dol_escape_htmltag($objp->produit).
'</td>';
776 print
'<td class="right">';
778 print empty($valtoshow) ?
'0' : $valtoshow;
780 $totalunit += $objp->value;
782 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
784 print
'<td align="left">';
785 if (is_null($productstatic->fk_unit)) {
786 $productstatic->fk_unit = 1;
788 print $langs->trans($productstatic->getLabelOfUnit());
793 print
'<td class="right nowraponall">'.price(
price2num($objp->ppmp,
'MU')).
'</td>';
796 print
'<td class="right amount nowraponall">'.price(
price2num($objp->ppmp * $objp->value,
'MT')).
'</td>';
797 $totalvalue +=
price2num($objp->ppmp * $objp->value,
'MT');
800 if (empty($conf->global->PRODUIT_MULTIPRICES)) {
801 $pricemin = $objp->price;
802 print
'<td class="right">';
806 print
'<td class="right">';
810 $totalvaluesell +=
price2num($pricemin * $objp->value,
'MT');
813 if ($user->rights->stock->mouvement->creer) {
814 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).
'">';
815 print
img_picto($langs->trans(
"TransferStock"),
'add',
'class="hideonsmartphone pictofixedwidth" style="color: #a69944"');
816 print $langs->trans(
"TransferStock");
821 if ($user->rights->stock->creer) {
822 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).
'">';
823 print
img_picto($langs->trans(
"CorrectStock"),
'add',
'class="hideonsmartphone pictofixedwidth" style="color: #a69944"');
824 print $langs->trans(
"CorrectStock");
833 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
835 $units = $productstatic->fk_unit;
836 } elseif ($productstatic->fk_unit != $units) {
843 $totalarray[
'val'][
'totalunit'] = $totalunit;
844 $totalarray[
'val'][
'totalvalue'] =
price2num($totalvalue,
'MT');
845 $totalarray[
'val'][
'totalvaluesell'] =
price2num($totalvaluesell,
'MT');
846 $totalarray[
'val'][
'units'] = $langs->trans($productstatic->getLabelOfUnit());
848 $parameters = array(
'totalarray' => &$totalarray);
850 $reshook = $hookmanager->executeHooks(
'printFieldListTotal', $parameters, $object);
856 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
865 if ($action ==
'edit' || $action ==
're-edit') {
866 $langs->trans(
"WarehouseEdit");
868 print
'<form action="card.php" method="POST">';
869 print
'<input type="hidden" name="token" value="'.newToken().
'">';
870 print
'<input type="hidden" name="action" value="update">';
871 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
877 print
'<table class="border centpercent">';
880 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Ref").
'</td><td><input name="libelle" size="20" value="'.$object->label.
'"></td></tr>';
882 print
'<tr><td>'.$langs->trans(
"LocationSummary").
'</td><td><input name="lieu" class="minwidth300" value="'.$object->lieu.
'"></td></tr>';
885 print
'<tr><td>'.$langs->trans(
"AddIn").
'</td><td>';
886 print $formproduct->selectWarehouses($object->fk_parent,
'fk_parent',
'', 1);
890 if (isModEnabled(
'project')) {
891 $projectid = $object->fk_project;
892 $langs->load(
'projects');
893 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td colspan="2">';
894 print
img_picto(
'',
'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
895 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>';
900 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
902 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
903 $doleditor =
new DolEditor(
'desc', $object->description,
'', 180,
'dolibarr_notes',
'In',
false,
true, isModEnabled(
'fckeditor'), ROWS_5,
'90%');
904 $doleditor->Create();
907 print
'<tr><td>'.$langs->trans(
'Address').
'</td><td><textarea name="address" class="quatrevingtpercent" rows="3" wrap="soft">';
908 print $object->address;
909 print
'</textarea></td></tr>';
912 print
'<tr><td>'.$langs->trans(
'Zip').
'</td><td>';
913 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
915 print
'<tr><td>'.$langs->trans(
'Town').
'</td><td>';
916 print $formcompany->select_ziptown($object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
920 print
'<tr><td>'.$langs->trans(
'Country').
'</td><td>';
921 print
img_picto(
'',
'globe-americas',
'class="paddingright"');
922 print $form->select_country($object->country_id ? $object->country_id : $mysoc->country_code,
'country_id');
924 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
929 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Phone',
'phone',
'', $object, 0).
'</td><td>';
930 print
img_picto(
'',
'object_phoning',
'class="paddingright"');
931 print
'<input name="phone" size="20" value="'.$object->phone.
'"></td></tr>';
932 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td><td>';
933 print
img_picto(
'',
'object_phoning_fax',
'class="paddingright"');
934 print
'<input name="fax" size="20" value="'.$object->fax.
'"></td></tr>';
937 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
938 print
'<select id="warehousestatus" name="statut" class="flat">';
939 foreach ($object->statuts as $key => $value) {
940 if ($key == $object->statut) {
941 print
'<option value="'.$key.
'" selected>'.$langs->trans($value).
'</option>';
943 print
'<option value="'.$key.
'">'.$langs->trans($value).
'</option>';
952 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' =>
'3');
953 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
954 print $hookmanager->resPrint;
955 if (empty($reshook)) {
956 print $object->showOptionals($extrafields,
'edit', $parameters);
960 if (isModEnabled(
'categorie')) {
961 print
'<tr><td class="tdtop">'.$langs->trans(
"Categories").
'</td><td colspan="3">';
962 $cate_arbo = $form->select_all_categories(Categorie::TYPE_WAREHOUSE,
'',
'parent', 64, 0, 1);
964 $cats = $c->containing($object->id, Categorie::TYPE_WAREHOUSE);
965 $arrayselected = array();
966 foreach ($cats as $cat) {
967 $arrayselected[] = $cat->id;
969 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
977 print $form->buttonsSaveCancel();
988$modulepart =
'stock';
990if ($action !=
'create' && $action !=
'edit' && $action !=
'delete') {
992 print
'<div class="fichecenter"><div class="fichehalfleft">';
993 print
'<a name="builddoc"></a>';
997 $relativepath = $object->ref.
'/'.$objectref.
'.pdf';
998 $filedir = $conf->stock->dir_output.
'/'.$objectref;
999 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
1000 $genallowed = $usercanread;
1001 $delallowed = $usercancreate;
1002 $modulepart =
'stock';
1004 print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0,
'', 0,
'',
'',
'', $object);
1005 $somethingshown = $formfile->numoffiles;
1007 print
'</div><div class="fichehalfright">';
1011 $morehtmlcenter =
'';
1015 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1017 $somethingshown =
$formactions->showactions($object,
'stock', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
1019 print
'</div></div>';
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.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage categories.
Class to manage a WYSIWYG editor.
Class to manage warehouses.
Class to manage products or services.
Class to manage projects.
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.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
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_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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...
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
stock_prepare_head($object)
Prepare array with list of tabs.