32 require
'../../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/stock.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
42 if (!empty($conf->project->enabled)) {
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');
59 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
60 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
68 $backtopage =
GETPOST(
'backtopage',
'alpha');
75 $hookmanager->initHooks(array(
'warehousecard',
'globalcard'));
81 $extrafields->fetch_name_optionals_label($object->table_element);
84 if ($id > 0 || !empty($ref)) {
85 $ret = $object->fetch($id, $ref);
92 $usercanread = (($user->rights->stock->lire));
93 $usercancreate = (($user->rights->stock->creer));
94 $usercandelete = (($user->rights->stock->supprimer));
104 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
108 if (empty($reshook)) {
109 $backurlforlist = DOL_URL_ROOT.
'/product/stock/list.php';
111 if (empty($backtopage) || ($cancel && empty($id))) {
112 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
113 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
114 $backtopage = $backurlforlist;
116 $backtopage = DOL_URL_ROOT.
'/product/stock/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
122 if (!empty($backtopageforcancel)) {
123 header(
"Location: ".$backtopageforcancel);
125 } elseif (!empty($backtopage)) {
126 header(
"Location: ".$backtopage);
133 if ($action ==
'add' && $user->rights->stock->creer) {
134 $object->ref = (string)
GETPOST(
"ref",
"alpha");
135 $object->fk_parent = (int)
GETPOST(
"fk_parent",
"int");
136 $object->fk_project =
GETPOST(
'projectid',
'int');
137 $object->label = (string)
GETPOST(
"libelle",
"alpha");
138 $object->description = (string)
GETPOST(
"desc",
"alpha");
139 $object->statut =
GETPOST(
"statut",
"int");
140 $object->lieu = (string)
GETPOST(
"lieu",
"alpha");
141 $object->address = (string)
GETPOST(
"address",
"alpha");
142 $object->zip = (string)
GETPOST(
"zipcode",
"alpha");
143 $object->town = (string)
GETPOST(
"town",
"alpha");
144 $object->country_id =
GETPOST(
"country_id");
145 $object->phone = (string)
GETPOST(
"phone",
"alpha");
146 $object->fax = (string)
GETPOST(
"fax",
"alpha");
148 if (!empty($object->label)) {
150 $ret = $extrafields->setOptionalsFromPost(
null, $object);
157 $id = $object->create($user);
161 $categories =
GETPOST(
'categories',
'array');
162 $object->setCategories($categories);
163 if (!empty($backtopage)) {
164 $backtopage = str_replace(
"__ID__", $id, $backtopage);
165 header(
"Location: ".$backtopage);
168 header(
"Location: card.php?id=".urlencode($id));
177 setEventMessages($langs->trans(
"ErrorWarehouseRefRequired"),
null,
'errors');
183 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->rights->stock->supprimer) {
184 $object->fetch(
GETPOST(
'id',
'int'));
185 $result = $object->delete($user);
188 header(
"Location: ".DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1');
197 if ($action ==
'update' && !$cancel) {
198 if ($object->fetch($id)) {
199 $object->label =
GETPOST(
"libelle");
200 $object->fk_parent =
GETPOST(
"fk_parent");
201 $object->fk_project =
GETPOST(
'projectid');
202 $object->description =
GETPOST(
"desc",
'restricthtml');
203 $object->statut =
GETPOST(
"statut");
204 $object->lieu =
GETPOST(
"lieu");
205 $object->address =
GETPOST(
"address");
206 $object->zip =
GETPOST(
"zipcode");
207 $object->town =
GETPOST(
"town");
208 $object->country_id =
GETPOST(
"country_id");
209 $object->phone =
GETPOST(
"phone");
213 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
219 $ret = $object->update($id, $user);
229 $categories =
GETPOST(
'categories',
'array');
230 $object->setCategories($categories);
237 } elseif ($action ==
'update_extras') {
241 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
246 $result = $object->insertExtraFields();
253 $action =
'edit_extras';
255 } elseif ($action ==
'classin' && $usercancreate) {
257 $object->setProject(
GETPOST(
'projectid',
'int'));
260 if ($cancel == $langs->trans(
"Cancel")) {
266 $upload_dir = $conf->stock->dir_output;
267 $permissiontoadd = $user->rights->stock->creer;
268 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
276 $productstatic =
new Product($db);
281 if (!empty($conf->project->enabled)) {
285 $title = $langs->trans(
"WarehouseCard");
286 if ($action ==
'create') {
287 $title = $langs->trans(
"NewWarehouse");
290 $help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
294 if ($action ==
'create') {
299 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">'.
"\n";
300 print
'<input type="hidden" name="token" value="'.newToken().
'">';
301 print
'<input type="hidden" name="action" value="add">';
302 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
306 print
'<table class="border centpercent">';
309 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Ref").
'</td><td><input name="libelle" size="20" value=""></td></tr>';
311 print
'<tr><td>'.$langs->trans(
"LocationSummary").
'</td><td><input name="lieu" size="40" value="'.(!empty($object->lieu) ? $object->lieu :
'').
'"></td></tr>';
314 print
'<tr><td>'.$langs->trans(
"AddIn").
'</td><td>';
315 print
img_picto(
'',
'stock').$formproduct->selectWarehouses((
GETPOSTISSET(
'fk_parent') ?
GETPOST(
'fk_parent',
'int') :
'ifone'),
'fk_parent',
'', 1);
319 if (!empty($conf->project->enabled)) {
320 $langs->load(
'projects');
321 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td colspan="2">';
322 print
img_picto(
'',
'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
323 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>';
328 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
330 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
331 $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%');
332 $doleditor->Create();
335 print
'<tr><td>'.$langs->trans(
'Address').
'</td><td><textarea name="address" class="quatrevingtpercent" rows="3" wrap="soft">';
336 print (!empty($object->address) ? $object->address :
'');
337 print
'</textarea></td></tr>';
340 print
'<tr><td>'.$langs->trans(
'Zip').
'</td><td>';
341 print $formcompany->select_ziptown((!empty($object->zip) ? $object->zip :
''),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
343 print
'<tr><td>'.$langs->trans(
'Town').
'</td><td>';
344 print $formcompany->select_ziptown((!empty($object->town) ? $object->town :
''),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
348 print
'<tr><td>'.$langs->trans(
'Country').
'</td><td>';
349 print
img_picto(
'',
'globe-americas',
'class="paddingright"');
350 print
$form->select_country((!empty($object->country_id) ? $object->country_id : $mysoc->country_code),
'country_id');
352 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
357 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Phone',
'phone',
'', $object, 0).
'</td><td>';
358 print
img_picto(
'',
'object_phoning',
'class="paddingright"');
359 print
'<input name="phone" size="20" value="'.$object->phone.
'"></td></tr>';
360 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td>';
362 print
img_picto(
'',
'object_phoning_fax',
'class="paddingright"');
363 print
'<input name="fax" size="20" value="'.$object->fax.
'"></td></tr>';
366 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
367 print
'<select id="warehousestatus" name="statut" class="flat minwidth100">';
368 foreach ($object->statuts as $key => $value) {
370 print
'<option value="'.$key.
'" selected>'.$langs->trans($value).
'</option>';
372 print
'<option value="'.$key.
'">'.$langs->trans($value).
'</option>';
380 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
384 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
385 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_WAREHOUSE,
'',
'parent', 64, 0, 1);
386 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
393 print
$form->buttonsSaveCancel(
"Create");
398 if ($id > 0 || $ref) {
400 $result = $object->fetch($id, $ref);
402 print
'No record found';
407 if ($action <>
'edit' && $action <>
're-edit') {
415 if ($action ==
'delete') {
416 $formquestion = array(
417 array(
'type' =>
'other',
'name' =>
'info',
'label' =>
img_warning(
'').$langs->trans(
"WarningThisWIllAlsoDeleteStock"),
'morecss'=>
'warning')
419 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"DeleteAWarehouse"), $langs->trans(
"ConfirmDeleteWarehouse", $object->label),
"confirm_delete", $formquestion, 0, 2);
424 $reshook = $hookmanager->executeHooks(
'formConfirm',
$parameters, $object, $action);
425 if (empty($reshook)) {
427 } elseif ($reshook > 0) {
435 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
437 $morehtmlref =
'<div class="refidno">';
438 $morehtmlref .= $langs->trans(
"LocationSummary").
' : '.$object->lieu;
441 if (!empty($conf->project->enabled)) {
442 $langs->load(
"projects");
443 $morehtmlref .=
'<br>'.img_picto(
'',
'project').
' '.$langs->trans(
'Project').
' ';
444 if ($usercancreate) {
445 if ($action !=
'classify') {
446 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
448 if ($action ==
'classify') {
449 $projectid = $object->fk_project;
450 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
451 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
452 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
453 $morehtmlref .= $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
454 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
455 $morehtmlref .=
'</form>';
457 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, ($socid > 0 ? $socid : -1), $object->fk_project,
'none', 0, 0, 0, 1,
'',
'maxwidth300');
460 if (!empty($object->fk_project)) {
462 $proj->fetch($object->fk_project);
463 $morehtmlref .=
' : '.$proj->getNomUrl(1);
465 $morehtmlref .=
' - '.$proj->title;
472 $morehtmlref .=
'</div>';
475 if ($user->socid && !in_array(
'stock', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
479 dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref',
'ref', $morehtmlref);
481 print
'<div class="fichecenter">';
482 print
'<div class="fichehalfleft">';
483 print
'<div class="underbanner clearboth"></div>';
485 print
'<table class="border centpercent tableforfield">';
488 $parentwarehouse =
new Entrepot($db);
489 if (!empty($object->fk_parent) && $parentwarehouse->fetch($object->fk_parent) > 0) {
490 print
'<tr><td>'.$langs->trans(
"ParentWarehouse").
'</td><td>';
491 print $parentwarehouse->getNomUrl(3);
498 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>'.
dol_htmlentitiesbr($object->description).
'</td></tr>';
500 $calcproductsunique = $object->nb_different_products();
501 $calcproducts = $object->nb_products();
504 print
'<tr><td>'.$langs->trans(
"NumberOfDifferentProducts").
'</td><td>';
505 print empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb'];
509 print
'<tr><td>'.$langs->trans(
"NumberOfProducts").
'</td><td>';
510 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
511 print empty($valtoshow) ?
'0' : $valtoshow;
517 print
'<div class="fichehalfright">';
518 print
'<div class="underbanner clearboth"></div>';
520 print
'<table class="border centpercent tableforfield">';
523 print
'<tr><td class="titlefield">'.$langs->trans(
"EstimatedStockValueShort").
'</td><td>';
524 print
price((empty($calcproducts[
'value']) ?
'0' :
price2num($calcproducts[
'value'],
'MT')), 0, $langs, 0, -1, -1, $conf->currency);
528 if (!empty($user->rights->stock->mouvement->lire)) {
529 $sql =
"SELECT max(m.datem) as datem";
530 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
531 $sql .=
" WHERE m.fk_entrepot = ".((int) $object->id);
532 $resqlbis = $db->query($sql);
534 $obj = $db->fetch_object($resqlbis);
535 $lastmovementdate = $db->jdate($obj->datem);
539 print
'<tr><td>'.$langs->trans(
"LastMovement").
'</td><td>';
540 if ($lastmovementdate) {
542 print
' ';
543 print
img_picto($langs->trans(
'LastMovement'),
'movement',
'class="pictofixedwidth"');
544 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?id='.$object->id.
'">'.$langs->trans(
"FullList").
'</a>';
546 print $langs->trans(
"None");
552 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
556 print
'<tr><td valign="middle">'.$langs->trans(
"Categories").
'</td><td colspan="3">';
557 print
$form->showCategories($object->id, Categorie::TYPE_WAREHOUSE, 1);
566 print
'<div class="clearboth"></div>';
574 print
"<div class=\"tabsAction\">\n";
577 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
578 if (empty($reshook)) {
579 if (empty($action) || $action ==
'classin') {
580 if ($user->rights->stock->creer) {
581 print
'<a class="butAction" href="card.php?action=edit&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Modify").
'</a>';
583 print
'<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
"Modify").
'</a>';
586 if ($user->rights->stock->supprimer) {
587 print
'<a class="butActionDelete" href="card.php?action=delete&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Delete").
'</a>';
589 print
'<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
"Delete").
'</a>';
601 $totalarray = array();
602 $totalarray[
'val'] = array ();
603 $totalarray[
'pos'] = array ();
604 $totalarray[
'type'] = array ();
605 $totalarray[
'nbfield'] = 0;
609 print
'<table class="noborder centpercent">';
610 print
"<tr class=\"liste_titre\">";
612 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle',
$parameters);
613 print $hookmanager->resPrint;
617 print_liste_field_titre(
"NumberOfUnit",
"",
"ps.reel",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
618 $totalarray[
'nbfield'] += 3;
619 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalunit';
620 $totalarray[
'type'][$totalarray[
'nbfield']] =
'stock';
622 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
624 $totalarray[
'nbfield']++;
625 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'units';
626 $totalarray[
'type'][$totalarray[
'nbfield']] =
'string';
629 print_liste_field_titre(
$form->textwithpicto($langs->trans(
"AverageUnitPricePMPShort"), $langs->trans(
"AverageUnitPricePMPDesc")),
"",
"p.pmp",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
630 $totalarray[
'nbfield']++;
632 print_liste_field_titre(
"EstimatedStockValueShort",
"",
"",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
633 $totalarray[
'nbfield']++;
634 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalvalue';
636 if (empty($conf->global->PRODUIT_MULTIPRICES)) {
637 print_liste_field_titre(
"SellPriceMin",
"",
"p.price",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
638 $totalarray[
'nbfield']++;
640 if (empty($conf->global->PRODUIT_MULTIPRICES)) {
641 print_liste_field_titre(
"EstimatedStockValueSellShort",
"",
"",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
642 $totalarray[
'nbfield']++;
643 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalvaluesell';
645 if ($user->rights->stock->mouvement->creer) {
647 $totalarray[
'nbfield']++;
649 if ($user->rights->stock->creer) {
651 $totalarray[
'nbfield']++;
654 $parameters = array(
'sortfield'=>$sortfield,
'sortorder'=>$sortorder,
'totalarray' => &$totalarray);
655 $reshook = $hookmanager->executeHooks(
'printFieldListTitle',
$parameters);
656 print $hookmanager->resPrint;
660 $totalvalue = $totalvaluesell = 0;
663 $separatedPMP =
false;
664 if (!empty($conf->global->MULTICOMPANY_PRODUCT_SHARING_ENABLED) && !empty($conf->global->MULTICOMPANY_PMP_PER_ENTITY_ENABLED)) {
665 $separatedPMP =
true;
668 $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,";
669 $sql .=
"p.tosell, p.tobuy,";
670 $sql .=
"p.accountancy_code_sell,";
671 $sql .=
"p.accountancy_code_sell_intra,";
672 $sql .=
"p.accountancy_code_sell_export,";
673 $sql .=
"p.accountancy_code_buy,";
674 $sql .=
"p.accountancy_code_buy_intra,";
675 $sql .=
"p.accountancy_code_buy_export,";
676 $sql .=
'p.barcode,';
678 $sql .=
" pa.pmp as ppmp,";
680 $sql .=
" p.pmp as ppmp,";
682 $sql .=
" ps.reel as value";
683 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
688 $reshook = $hookmanager->executeHooks(
'printFieldListSelect',
$parameters);
692 $sql .= $hookmanager->resPrint;
693 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_stock as ps, ".MAIN_DB_PREFIX.
"product as p";
696 $sql .=
", ".MAIN_DB_PREFIX.
"product_perentity as pa";
699 $sql .=
" WHERE ps.fk_product = p.rowid";
700 $sql .=
" AND ps.reel <> 0";
701 $sql .=
" AND ps.fk_entrepot = ".((int) $object->id);
704 $sql .=
" AND pa.fk_product = p.rowid AND pa.entity = ".(int) $conf->entity;
707 $sql .= $db->order($sortfield, $sortorder);
710 $resql = $db->query($sql);
712 $num = $db->num_rows(
$resql);
717 $objp = $db->fetch_object(
$resql);
721 $sql =
"SELECT label";
722 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
723 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
724 $sql .=
" AND lang = '".$db->escape($langs->getDefaultLang()).
"'";
727 $result = $db->query($sql);
729 $objtp = $db->fetch_object($result);
730 if ($objtp->label !=
'') {
731 $objp->produit = $objtp->label;
737 print
'<tr class="oddeven">';
739 $parameters = array(
'obj'=>$objp,
'totalarray' => &$totalarray);
740 $reshook = $hookmanager->executeHooks(
'printFieldListValue',
$parameters);
741 print $hookmanager->resPrint;
743 $productstatic->id = $objp->rowid;
744 $productstatic->ref = $objp->ref;
745 $productstatic->label = $objp->produit;
746 $productstatic->type = $objp->type;
747 $productstatic->entity = $objp->entity;
748 $productstatic->status_batch = $objp->tobatch;
749 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
750 $productstatic->fk_unit = $objp->fk_unit;
752 $productstatic->status = $objp->tosell;
753 $productstatic->status_buy = $objp->tobuy;
754 $productstatic->barcode = $objp->barcode;
755 $productstatic->accountancy_code_sell = $objp->accountancy_code_sell;
756 $productstatic->accountancy_code_sell_intra = $objp->accountancy_code_sell_intra;
757 $productstatic->accountancy_code_sell_export = $objp->accountancy_code_sell_export;
758 $productstatic->accountancy_code_buy = $objp->accountancy_code_buy;
759 $productstatic->accountancy_code_buy_intra = $objp->accountancy_code_buy_intra;
760 $productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export;
764 print $productstatic->getNomUrl(1,
'stock', 16);
768 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($objp->produit).
'">'.
dol_escape_htmltag($objp->produit).
'</td>';
771 print
'<td class="right">';
773 print empty($valtoshow) ?
'0' : $valtoshow;
775 $totalunit += $objp->value;
777 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
779 print
'<td align="left">';
780 if (is_null($productstatic->fk_unit)) {
781 $productstatic->fk_unit = 1;
783 print $langs->trans($productstatic->getLabelOfUnit());
788 print
'<td class="right nowraponall">'.price(
price2num($objp->ppmp,
'MU')).
'</td>';
791 print
'<td class="right amount nowraponall">'.price(
price2num($objp->ppmp * $objp->value,
'MT')).
'</td>';
792 $totalvalue +=
price2num($objp->ppmp * $objp->value,
'MT');
795 if (empty($conf->global->PRODUIT_MULTIPRICES)) {
796 $pricemin = $objp->price;
797 print
'<td class="right">';
801 print
'<td class="right">';
805 $totalvaluesell +=
price2num($pricemin * $objp->value,
'MT');
808 if ($user->rights->stock->mouvement->creer) {
809 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).
'">';
810 print
img_picto($langs->trans(
"TransferStock"),
'add',
'class="hideonsmartphone pictofixedwidth" style="color: #a69944"');
811 print $langs->trans(
"TransferStock");
816 if ($user->rights->stock->creer) {
817 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).
'">';
818 print
img_picto($langs->trans(
"CorrectStock"),
'add',
'class="hideonsmartphone pictofixedwidth" style="color: #a69944"');
819 print $langs->trans(
"CorrectStock");
828 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
830 $units = $productstatic->fk_unit;
831 } elseif ($productstatic->fk_unit != $units) {
838 $totalarray[
'val'][
'totalunit'] = $totalunit;
839 $totalarray[
'val'][
'totalvalue'] =
price2num($totalvalue,
'MT');
840 $totalarray[
'val'][
'totalvaluesell'] =
price2num($totalvaluesell,
'MT');
841 $totalarray[
'val'][
'units'] = $langs->trans($productstatic->getLabelOfUnit());
845 $reshook = $hookmanager->executeHooks(
'printFieldListTotal',
$parameters, $object);
851 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
860 if ($action ==
'edit' || $action ==
're-edit') {
861 $langs->trans(
"WarehouseEdit");
863 print
'<form action="card.php" method="POST">';
864 print
'<input type="hidden" name="token" value="'.newToken().
'">';
865 print
'<input type="hidden" name="action" value="update">';
866 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
872 print
'<table class="border centpercent">';
875 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Ref").
'</td><td><input name="libelle" size="20" value="'.$object->label.
'"></td></tr>';
877 print
'<tr><td>'.$langs->trans(
"LocationSummary").
'</td><td><input name="lieu" class="minwidth300" value="'.$object->lieu.
'"></td></tr>';
880 print
'<tr><td>'.$langs->trans(
"AddIn").
'</td><td>';
881 print $formproduct->selectWarehouses($object->fk_parent,
'fk_parent',
'', 1);
885 if (!empty($conf->project->enabled)) {
886 $projectid = $object->fk_project;
887 $langs->load(
'projects');
888 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td colspan="2">';
889 print
img_picto(
'',
'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
890 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>';
895 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
897 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
898 $doleditor =
new DolEditor(
'desc', $object->description,
'', 180,
'dolibarr_notes',
'In',
false,
true, $conf->fckeditor->enabled, ROWS_5,
'90%');
899 $doleditor->Create();
902 print
'<tr><td>'.$langs->trans(
'Address').
'</td><td><textarea name="address" class="quatrevingtpercent" rows="3" wrap="soft">';
903 print $object->address;
904 print
'</textarea></td></tr>';
907 print
'<tr><td>'.$langs->trans(
'Zip').
'</td><td>';
908 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
910 print
'<tr><td>'.$langs->trans(
'Town').
'</td><td>';
911 print $formcompany->select_ziptown($object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
915 print
'<tr><td>'.$langs->trans(
'Country').
'</td><td>';
916 print
img_picto(
'',
'globe-americas',
'class="paddingright"');
917 print
$form->select_country($object->country_id ? $object->country_id : $mysoc->country_code,
'country_id');
919 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
924 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Phone',
'phone',
'', $object, 0).
'</td><td>';
925 print
img_picto(
'',
'object_phoning',
'class="paddingright"');
926 print
'<input name="phone" size="20" value="'.$object->phone.
'"></td></tr>';
927 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td><td>';
928 print
img_picto(
'',
'object_phoning_fax',
'class="paddingright"');
929 print
'<input name="fax" size="20" value="'.$object->fax.
'"></td></tr>';
932 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
933 print
'<select id="warehousestatus" name="statut" class="flat">';
934 foreach ($object->statuts as $key => $value) {
935 if ($key == $object->statut) {
936 print
'<option value="'.$key.
'" selected>'.$langs->trans($value).
'</option>';
938 print
'<option value="'.$key.
'">'.$langs->trans($value).
'</option>';
947 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' =>
'3');
948 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
949 print $hookmanager->resPrint;
950 if (empty($reshook)) {
951 print $object->showOptionals($extrafields,
'edit',
$parameters);
956 print
'<tr><td class="tdtop">'.$langs->trans(
"Categories").
'</td><td colspan="3">';
957 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_WAREHOUSE,
'',
'parent', 64, 0, 1);
959 $cats = $c->containing($object->id, Categorie::TYPE_WAREHOUSE);
960 $arrayselected = array();
961 foreach ($cats as $cat) {
962 $arrayselected[] = $cat->id;
964 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
972 print
$form->buttonsSaveCancel();
983 $modulepart =
'stock';
985 if ($action !=
'create' && $action !=
'edit' && $action !=
'delete') {
987 print
'<div class="fichecenter"><div class="fichehalfleft">';
988 print
'<a name="builddoc"></a>';
992 $relativepath = $object->ref.
'/'.$objectref.
'.pdf';
993 $filedir = $conf->stock->dir_output.
'/'.$objectref;
994 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
995 $genallowed = $usercanread;
996 $delallowed = $usercancreate;
997 $modulepart =
'stock';
999 print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0,
'', 0,
'',
'',
'', $object);
1000 $somethingshown = $formfile->numoffiles;
1002 print
'</div><div class="fichehalfright">';
1006 $morehtmlcenter =
'';
1010 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1012 $somethingshown =
$formactions->showactions($object,
'stock', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
1014 print
'</div></div>';
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.
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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("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->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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...
isModEnabled($module)
Is Dolibarr module enabled.
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.
$formconfirm
if ($action == 'delbookkeepingyear') {
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.