33require
'../../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/stock.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
43if (isModEnabled(
'project')) {
44 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
49$langs->loadLangs(array(
'products',
'stocks',
'companies',
'categories'));
51$action =
GETPOST(
'action',
'aZ09');
52$cancel =
GETPOST(
'cancel',
'alpha');
54$projectid =
GETPOST(
'projectid',
'int');
57$socid =
GETPOST(
'socid',
'int');
61$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
62$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
63$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
71$backtopage =
GETPOST(
'backtopage',
'alpha');
78$hookmanager->initHooks(array(
'warehousecard',
'stocklist',
'globalcard'));
84$extrafields->fetch_name_optionals_label($object->table_element);
87if ($id > 0 || !empty($ref)) {
88 $ret = $object->fetch($id, $ref);
95$usercanread = (($user->rights->stock->lire));
96$usercancreate = (($user->rights->stock->creer));
97$usercandelete = (($user->rights->stock->supprimer));
106$parameters = array(
'id'=>$id,
'ref'=>$ref);
107$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
111if (empty($reshook)) {
112 $backurlforlist = DOL_URL_ROOT.
'/product/stock/list.php';
114 if (empty($backtopage) || ($cancel && empty($id))) {
115 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
116 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
117 $backtopage = $backurlforlist;
119 $backtopage = DOL_URL_ROOT.
'/product/stock/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
125 if (!empty($backtopageforcancel)) {
126 header(
"Location: ".$backtopageforcancel);
128 } elseif (!empty($backtopage)) {
129 header(
"Location: ".$backtopage);
136 if ($action ==
'add' && $user->hasRight(
'stock',
'creer')) {
137 $object->ref = (string)
GETPOST(
"ref",
"alpha");
138 $object->fk_parent = (int)
GETPOST(
"fk_parent",
"int");
139 $object->fk_project =
GETPOST(
'projectid',
'int');
140 $object->label = (string)
GETPOST(
"libelle",
"alpha");
141 $object->description = (string)
GETPOST(
"desc",
"alpha");
142 $object->statut =
GETPOST(
"statut",
"int");
143 $object->lieu = (string)
GETPOST(
"lieu",
"alpha");
144 $object->address = (string)
GETPOST(
"address",
"alpha");
145 $object->zip = (string)
GETPOST(
"zipcode",
"alpha");
146 $object->town = (string)
GETPOST(
"town",
"alpha");
147 $object->country_id =
GETPOST(
"country_id");
148 $object->phone = (string)
GETPOST(
"phone",
"alpha");
149 $object->fax = (string)
GETPOST(
"fax",
"alpha");
151 if (!empty($object->label)) {
153 $ret = $extrafields->setOptionalsFromPost(
null, $object);
160 $id = $object->create($user);
164 $categories =
GETPOST(
'categories',
'array');
165 $object->setCategories($categories);
166 if (!empty($backtopage)) {
167 $backtopage = str_replace(
"__ID__", $id, $backtopage);
168 header(
"Location: ".$backtopage);
171 header(
"Location: card.php?id=".urlencode($id));
180 setEventMessages($langs->trans(
"ErrorWarehouseRefRequired"),
null,
'errors');
186 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'stock',
'supprimer')) {
187 $object->fetch(
GETPOST(
'id',
'int'));
188 $result = $object->delete($user);
191 header(
"Location: ".DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1');
200 if ($action ==
'update' && !$cancel) {
201 if ($object->fetch($id)) {
202 $object->label =
GETPOST(
"libelle");
203 $object->fk_parent =
GETPOST(
"fk_parent");
204 $object->fk_project =
GETPOST(
'projectid');
205 $object->description =
GETPOST(
"desc",
'restricthtml');
206 $object->statut =
GETPOST(
"statut");
207 $object->lieu =
GETPOST(
"lieu");
208 $object->address =
GETPOST(
"address");
209 $object->zip =
GETPOST(
"zipcode");
210 $object->town =
GETPOST(
"town");
211 $object->country_id =
GETPOST(
"country_id");
212 $object->phone =
GETPOST(
"phone");
216 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
222 $ret = $object->update($id, $user);
232 $categories =
GETPOST(
'categories',
'array');
233 $object->setCategories($categories);
240 } elseif ($action ==
'update_extras') {
241 $object->oldcopy =
dol_clone($object, 2);
244 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
249 $result = $object->insertExtraFields();
256 $action =
'edit_extras';
258 } elseif ($action ==
'classin' && $usercancreate) {
260 $object->setProject(
GETPOST(
'projectid',
'int'));
263 if ($cancel == $langs->trans(
"Cancel")) {
269 $upload_dir = $conf->stock->dir_output;
270 $permissiontoadd = $user->rights->stock->creer;
271 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
279$productstatic =
new Product($db);
280$form =
new Form($db);
284if (isModEnabled(
'project')) {
288$title = $langs->trans(
"WarehouseCard");
289if ($action ==
'create') {
290 $title = $langs->trans(
"NewWarehouse");
293$help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
297if ($action ==
'create') {
302 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">'.
"\n";
303 print
'<input type="hidden" name="token" value="'.newToken().
'">';
304 print
'<input type="hidden" name="action" value="add">';
305 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
309 print
'<table class="border centpercent">';
312 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Ref").
'</td><td><input name="libelle" size="20" value=""></td></tr>';
314 print
'<tr><td>'.$langs->trans(
"LocationSummary").
'</td><td><input name="lieu" size="40" value="'.(!empty($object->lieu) ? $object->lieu :
'').
'"></td></tr>';
317 print
'<tr><td>'.$langs->trans(
"AddIn").
'</td><td>';
318 print
img_picto(
'',
'stock').$formproduct->selectWarehouses((GETPOSTISSET(
'fk_parent') ?
GETPOST(
'fk_parent',
'int') :
'ifone'),
'fk_parent',
'', 1);
322 if (isModEnabled(
'project')) {
323 $langs->load(
'projects');
324 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td colspan="2">';
325 print
img_picto(
'',
'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
326 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>';
331 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
333 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
334 $doleditor =
new DolEditor(
'desc', (!empty($object->description) ? $object->description :
''),
'', 180,
'dolibarr_notes',
'In', false, true, isModEnabled(
'fckeditor'), ROWS_5,
'90%');
335 $doleditor->Create();
338 print
'<tr><td>'.$langs->trans(
'Address').
'</td><td><textarea name="address" class="quatrevingtpercent" rows="3" wrap="soft">';
339 print(!empty($object->address) ? $object->address :
'');
340 print
'</textarea></td></tr>';
343 print
'<tr><td>'.$langs->trans(
'Zip').
'</td><td>';
344 print $formcompany->select_ziptown((!empty($object->zip) ? $object->zip :
''),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
346 print
'<tr><td>'.$langs->trans(
'Town').
'</td><td>';
347 print $formcompany->select_ziptown((!empty($object->town) ? $object->town :
''),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
351 print
'<tr><td>'.$langs->trans(
'Country').
'</td><td>';
352 print
img_picto(
'',
'globe-americas',
'class="paddingright"');
353 print $form->select_country((!empty($object->country_id) ? $object->country_id : $mysoc->country_code),
'country_id');
355 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
360 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Phone',
'phone',
'', $object, 0).
'</td><td>';
361 print
img_picto(
'',
'object_phoning',
'class="paddingright"');
362 print
'<input name="phone" size="20" value="'.$object->phone.
'"></td></tr>';
363 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td>';
365 print
img_picto(
'',
'object_phoning_fax',
'class="paddingright"');
366 print
'<input name="fax" size="20" value="'.$object->fax.
'"></td></tr>';
369 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
370 print
'<select id="warehousestatus" name="statut" class="flat minwidth100">';
371 foreach ($object->labelStatus as $key => $value) {
373 print
'<option value="'.$key.
'" selected>'.$langs->trans($value).
'</option>';
375 print
'<option value="'.$key.
'">'.$langs->trans($value).
'</option>';
383 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
385 if (isModEnabled(
'categorie')) {
387 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
388 $cate_arbo = $form->select_all_categories(Categorie::TYPE_WAREHOUSE,
'',
'parent', 64, 0, 1);
389 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
396 print $form->buttonsSaveCancel(
"Create");
401 if ($id > 0 || $ref) {
403 $result = $object->fetch($id, $ref);
405 print
'No record found';
410 if ($action !=
'edit' && $action !=
're-edit') {
418 if ($action ==
'delete') {
419 $formquestion = array(
420 array(
'type' =>
'other',
'name' =>
'info',
'label' =>
img_warning(
'').$langs->trans(
"WarningThisWIllAlsoDeleteStock"),
'morecss'=>
'warning')
422 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"DeleteAWarehouse"), $langs->trans(
"ConfirmDeleteWarehouse", $object->label),
"confirm_delete", $formquestion, 0, 2);
426 $parameters = array(
'formConfirm' => $formconfirm);
427 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
428 if (empty($reshook)) {
429 $formconfirm .= $hookmanager->resPrint;
430 } elseif ($reshook > 0) {
431 $formconfirm = $hookmanager->resPrint;
438 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
440 $morehtmlref =
'<div class="refidno">';
441 $morehtmlref .= $langs->trans(
"LocationSummary").
' : '.$object->lieu;
444 if (isModEnabled(
'project')) {
445 $langs->load(
"projects");
446 $morehtmlref .=
'<br>'.img_picto(
'',
'project').
' '.$langs->trans(
'Project').
' ';
447 if ($usercancreate) {
448 if ($action !=
'classify') {
449 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
451 if ($action ==
'classify') {
452 $projectid = $object->fk_project;
453 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
454 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
455 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
456 $morehtmlref .= $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
457 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
458 $morehtmlref .=
'</form>';
460 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, ($socid > 0 ? $socid : -1), $object->fk_project,
'none', 0, 0, 0, 1,
'',
'maxwidth300');
463 if (!empty($object->fk_project)) {
465 $proj->fetch($object->fk_project);
466 $morehtmlref .=
' : '.$proj->getNomUrl(1);
468 $morehtmlref .=
' - '.$proj->title;
475 $morehtmlref .=
'</div>';
478 if ($user->socid && !in_array(
'stock', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
482 dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref',
'ref', $morehtmlref);
484 print
'<div class="fichecenter">';
485 print
'<div class="fichehalfleft">';
486 print
'<div class="underbanner clearboth"></div>';
488 print
'<table class="border centpercent tableforfield">';
491 $parentwarehouse =
new Entrepot($db);
492 if (!empty($object->fk_parent) && $parentwarehouse->fetch($object->fk_parent) > 0) {
493 print
'<tr><td>'.$langs->trans(
"ParentWarehouse").
'</td><td>';
494 print $parentwarehouse->getNomUrl(3);
501 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>'.
dol_htmlentitiesbr($object->description).
'</td></tr>';
503 $calcproductsunique = $object->nb_different_products();
504 $calcproducts = $object->nb_products();
507 print
'<tr><td>'.$langs->trans(
"NumberOfDifferentProducts").
'</td><td>';
508 print empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb'];
512 print
'<tr><td>'.$langs->trans(
"NumberOfProducts").
'</td><td>';
513 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
514 print empty($valtoshow) ?
'0' : $valtoshow;
520 print
'<div class="fichehalfright">';
521 print
'<div class="underbanner clearboth"></div>';
523 print
'<table class="border centpercent tableforfield">';
526 print
'<tr><td class="titlefield">'.$langs->trans(
"EstimatedStockValueShort").
'</td><td>';
527 print
price((empty($calcproducts[
'value']) ?
'0' :
price2num($calcproducts[
'value'],
'MT')), 0, $langs, 0, -1, -1, $conf->currency);
531 if ($user->hasRight(
'stock',
'mouvement',
'lire')) {
532 $sql =
"SELECT max(m.datem) as datem";
533 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
534 $sql .=
" WHERE m.fk_entrepot = ".((int) $object->id);
535 $resqlbis = $db->query($sql);
537 $obj = $db->fetch_object($resqlbis);
538 $lastmovementdate = $db->jdate($obj->datem);
542 print
'<tr><td>'.$langs->trans(
"LastMovement").
'</td><td>';
543 if ($lastmovementdate) {
545 print
' ';
546 print
img_picto($langs->trans(
'LastMovement'),
'movement',
'class="pictofixedwidth"');
547 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?id='.$object->id.
'">'.$langs->trans(
"FullList").
'</a>';
549 print $langs->trans(
"None");
555 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
558 if (isModEnabled(
'categorie')) {
559 print
'<tr><td valign="middle">'.$langs->trans(
"Categories").
'</td><td colspan="3">';
560 print $form->showCategories($object->id, Categorie::TYPE_WAREHOUSE, 1);
569 print
'<div class="clearboth"></div>';
577 print
"<div class=\"tabsAction\">\n";
579 $parameters = array();
580 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
581 if (empty($reshook)) {
582 if (empty($action) || $action ==
'classin') {
583 if ($user->hasRight(
'stock',
'creer')) {
584 print
'<a class="butAction" href="card.php?action=edit&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Modify").
'</a>';
586 print
'<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
"Modify").
'</a>';
589 if ($user->hasRight(
'stock',
'supprimer')) {
590 print
'<a class="butActionDelete" href="card.php?action=delete&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Delete").
'</a>';
592 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;
613 print
'<div class="div-table-responsive">';
614 print
'<table class="noborder centpercent liste">';
615 print
'<tr class="liste_titre">';
616 $parameters = array(
'totalarray' => &$totalarray);
617 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
618 print $hookmanager->resPrint;
622 print_liste_field_titre(
"NumberOfUnit",
"",
"ps.reel",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
623 $totalarray[
'nbfield'] += 3;
624 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalunit';
625 $totalarray[
'type'][$totalarray[
'nbfield']] =
'stock';
629 $totalarray[
'nbfield']++;
630 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'units';
631 $totalarray[
'type'][$totalarray[
'nbfield']] =
'string';
634 print_liste_field_titre($form->textwithpicto($langs->trans(
"AverageUnitPricePMPShort"), $langs->trans(
"AverageUnitPricePMPDesc")),
"",
"p.pmp",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
635 $totalarray[
'nbfield']++;
637 print_liste_field_titre(
"EstimatedStockValueShort",
"",
"",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
638 $totalarray[
'nbfield']++;
639 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalvalue';
640 $totalarray[
'type'][$totalarray[
'nbfield']] =
'';
644 print_liste_field_titre(
"SellPriceMin",
"",
"p.price",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
645 $totalarray[
'nbfield']++;
648 print_liste_field_titre(
"EstimatedStockValueSellShort",
"",
"",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
649 $totalarray[
'nbfield']++;
650 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalvaluesell';
651 $totalarray[
'type'][$totalarray[
'nbfield']] =
'';
653 if ($user->hasRight(
'stock',
'mouvement',
'creer')) {
655 $totalarray[
'nbfield']++;
657 if ($user->hasRight(
'stock',
'creer')) {
659 $totalarray[
'nbfield']++;
662 $parameters = array(
'sortfield'=>$sortfield,
'sortorder'=>$sortorder,
'totalarray' => &$totalarray);
663 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
664 print $hookmanager->resPrint;
668 $totalvalue = $totalvaluesell = 0;
671 $separatedPMP =
false;
673 $separatedPMP =
true;
676 $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,";
677 $sql .=
"p.tosell, p.tobuy,";
678 $sql .=
"p.accountancy_code_sell,";
679 $sql .=
"p.accountancy_code_sell_intra,";
680 $sql .=
"p.accountancy_code_sell_export,";
681 $sql .=
"p.accountancy_code_buy,";
682 $sql .=
"p.accountancy_code_buy_intra,";
683 $sql .=
"p.accountancy_code_buy_export,";
684 $sql .=
'p.barcode,';
686 $sql .=
" pa.pmp as ppmp,";
688 $sql .=
" p.pmp as ppmp,";
690 $sql .=
" ps.reel as value";
695 $parameters = array();
696 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
700 $sql .= $hookmanager->resPrint;
701 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_stock as ps, ".MAIN_DB_PREFIX.
"product as p";
704 $sql .=
", ".MAIN_DB_PREFIX.
"product_perentity as pa";
707 $sql .=
" WHERE ps.fk_product = p.rowid";
708 $sql .=
" AND ps.reel <> 0";
709 $sql .=
" AND ps.fk_entrepot = ".((int) $object->id);
712 $sql .=
" AND pa.fk_product = p.rowid AND pa.entity = ".(int) $conf->entity;
715 $sql .= $db->order($sortfield, $sortorder);
718 $resql = $db->query($sql);
720 $num = $db->num_rows($resql);
725 $objp = $db->fetch_object($resql);
729 $sql =
"SELECT label";
730 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
731 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
732 $sql .=
" AND lang = '".$db->escape($langs->getDefaultLang()).
"'";
735 $result = $db->query($sql);
737 $objtp = $db->fetch_object($result);
738 if (isset($objtp->label) && $objtp->label !=
'') {
739 $objp->produit = $objtp->label;
745 print
'<tr class="oddeven">';
747 $parameters = array(
'obj'=>$objp,
'totalarray' => &$totalarray);
748 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
749 print $hookmanager->resPrint;
751 $productstatic->id = $objp->rowid;
752 $productstatic->ref = $objp->ref;
753 $productstatic->label = $objp->produit;
754 $productstatic->type = $objp->type;
755 $productstatic->entity = $objp->entity;
756 $productstatic->status_batch = $objp->tobatch;
758 $productstatic->fk_unit = $objp->fk_unit;
760 $productstatic->status = $objp->tosell;
761 $productstatic->status_buy = $objp->tobuy;
762 $productstatic->barcode = $objp->barcode;
763 $productstatic->accountancy_code_sell = $objp->accountancy_code_sell;
764 $productstatic->accountancy_code_sell_intra = $objp->accountancy_code_sell_intra;
765 $productstatic->accountancy_code_sell_export = $objp->accountancy_code_sell_export;
766 $productstatic->accountancy_code_buy = $objp->accountancy_code_buy;
767 $productstatic->accountancy_code_buy_intra = $objp->accountancy_code_buy_intra;
768 $productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export;
772 print $productstatic->getNomUrl(1,
'stock', 16);
776 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($objp->produit).
'">'.
dol_escape_htmltag($objp->produit).
'</td>';
779 print
'<td class="right">';
781 print empty($valtoshow) ?
'0' : $valtoshow;
783 $totalunit += $objp->value;
787 print
'<td align="left">';
788 if (is_null($productstatic->fk_unit)) {
789 $productstatic->fk_unit = 1;
791 print $langs->trans($productstatic->getLabelOfUnit());
796 print
'<td class="right nowraponall">'.price(
price2num($objp->ppmp,
'MU')).
'</td>';
799 print
'<td class="right amount nowraponall">'.price(
price2num($objp->ppmp * $objp->value,
'MT')).
'</td>';
800 $totalvalue +=
price2num($objp->ppmp * $objp->value,
'MT');
804 $pricemin = $objp->price;
805 print
'<td class="right">';
809 print
'<td class="right">';
813 $totalvaluesell +=
price2num($pricemin * $objp->value,
'MT');
816 if ($user->hasRight(
'stock',
'mouvement',
'creer')) {
817 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).
'">';
818 print
img_picto($langs->trans(
"TransferStock"),
'add',
'class="hideonsmartphone pictofixedwidth" style="color: #a69944"');
819 print $langs->trans(
"TransferStock");
824 if ($user->hasRight(
'stock',
'creer')) {
825 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).
'">';
826 print
img_picto($langs->trans(
"CorrectStock"),
'add',
'class="hideonsmartphone pictofixedwidth" style="color: #a69944"');
827 print $langs->trans(
"CorrectStock");
838 $units = $productstatic->fk_unit;
839 } elseif ($productstatic->fk_unit != $units) {
846 $totalarray[
'val'][
'totalunit'] = $totalunit;
847 $totalarray[
'val'][
'totalvalue'] =
price2num($totalvalue,
'MT');
848 $totalarray[
'val'][
'totalvaluesell'] =
price2num($totalvaluesell,
'MT');
849 $totalarray[
'val'][
'units'] = $langs->trans($productstatic->getLabelOfUnit());
851 $parameters = array(
'totalarray' => &$totalarray);
853 $reshook = $hookmanager->executeHooks(
'printFieldListTotal', $parameters, $object);
859 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
869 if ($action ==
'edit' || $action ==
're-edit') {
870 $langs->trans(
"WarehouseEdit");
872 print
'<form action="card.php" method="POST">';
873 print
'<input type="hidden" name="token" value="'.newToken().
'">';
874 print
'<input type="hidden" name="action" value="update">';
875 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
881 print
'<table class="border centpercent">';
884 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Ref").
'</td><td><input name="libelle" size="20" value="'.$object->label.
'"></td></tr>';
886 print
'<tr><td>'.$langs->trans(
"LocationSummary").
'</td><td><input name="lieu" class="minwidth300" value="'.$object->lieu.
'"></td></tr>';
889 print
'<tr><td>'.$langs->trans(
"AddIn").
'</td><td>';
890 print $formproduct->selectWarehouses($object->fk_parent,
'fk_parent',
'', 1);
894 if (isModEnabled(
'project')) {
895 $projectid = $object->fk_project;
896 $langs->load(
'projects');
897 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td colspan="2">';
898 print
img_picto(
'',
'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
899 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>';
904 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
906 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
907 $doleditor =
new DolEditor(
'desc', $object->description,
'', 180,
'dolibarr_notes',
'In',
false,
true, isModEnabled(
'fckeditor'), ROWS_5,
'90%');
908 $doleditor->Create();
911 print
'<tr><td>'.$langs->trans(
'Address').
'</td><td><textarea name="address" class="quatrevingtpercent" rows="3" wrap="soft">';
912 print $object->address;
913 print
'</textarea></td></tr>';
916 print
'<tr><td>'.$langs->trans(
'Zip').
'</td><td>';
917 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
919 print
'<tr><td>'.$langs->trans(
'Town').
'</td><td>';
920 print $formcompany->select_ziptown($object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
924 print
'<tr><td>'.$langs->trans(
'Country').
'</td><td>';
925 print
img_picto(
'',
'globe-americas',
'class="paddingright"');
926 print $form->select_country($object->country_id ? $object->country_id : $mysoc->country_code,
'country_id');
928 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
933 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Phone',
'phone',
'', $object, 0).
'</td><td>';
934 print
img_picto(
'',
'object_phoning',
'class="paddingright"');
935 print
'<input name="phone" size="20" value="'.$object->phone.
'"></td></tr>';
936 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td><td>';
937 print
img_picto(
'',
'object_phoning_fax',
'class="paddingright"');
938 print
'<input name="fax" size="20" value="'.$object->fax.
'"></td></tr>';
941 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
942 print
'<select id="warehousestatus" name="statut" class="flat">';
943 foreach ($object->labelStatus as $key => $value) {
944 if ($key == $object->statut) {
945 print
'<option value="'.$key.
'" selected>'.$langs->trans($value).
'</option>';
947 print
'<option value="'.$key.
'">'.$langs->trans($value).
'</option>';
956 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' =>
'3');
957 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
958 print $hookmanager->resPrint;
959 if (empty($reshook)) {
960 print $object->showOptionals($extrafields,
'edit', $parameters);
964 if (isModEnabled(
'categorie')) {
965 print
'<tr><td class="tdtop">'.$langs->trans(
"Categories").
'</td><td colspan="3">';
966 $cate_arbo = $form->select_all_categories(Categorie::TYPE_WAREHOUSE,
'',
'parent', 64, 0, 1);
968 $cats = $c->containing($object->id, Categorie::TYPE_WAREHOUSE);
969 $arrayselected = array();
970 foreach ($cats as $cat) {
971 $arrayselected[] = $cat->id;
973 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
981 print $form->buttonsSaveCancel();
992$modulepart =
'stock';
994if ($action !=
'create' && $action !=
'edit' && $action !=
'delete') {
996 print
'<div class="fichecenter"><div class="fichehalfleft">';
997 print
'<a name="builddoc"></a>';
1001 $relativepath = $object->ref.
'/'.$objectref.
'.pdf';
1002 $filedir = $conf->stock->dir_output.
'/'.$objectref;
1003 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
1004 $genallowed = $usercanread;
1005 $delallowed = $usercancreate;
1006 $modulepart =
'stock';
1008 print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0,
'', 0,
'',
'',
'', $object);
1009 $somethingshown = $formfile->numoffiles;
1011 print
'</div><div class="fichehalfright">';
1015 $morehtmlcenter =
'';
1019 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1021 $somethingshown =
$formactions->showactions($object,
'stock', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
1023 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 a 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...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.