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');
76$hookmanager->initHooks(array(
'warehousecard',
'globalcard'));
82$extrafields->fetch_name_optionals_label($object->table_element);
85if ($id > 0 || !empty($ref)) {
86 $ret = $object->fetch($id, $ref);
93$usercanread = (($user->rights->stock->lire));
94$usercancreate = (($user->rights->stock->creer));
95$usercandelete = (($user->rights->stock->supprimer));
104$parameters = array(
'id'=>$id,
'ref'=>$ref);
105$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
109if (empty($reshook)) {
110 $backurlforlist = DOL_URL_ROOT.
'/product/stock/list.php';
112 if (empty($backtopage) || ($cancel && empty($id))) {
113 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
114 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
115 $backtopage = $backurlforlist;
117 $backtopage = DOL_URL_ROOT.
'/product/stock/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
123 if (!empty($backtopageforcancel)) {
124 header(
"Location: ".$backtopageforcancel);
126 } elseif (!empty($backtopage)) {
127 header(
"Location: ".$backtopage);
134 if ($action ==
'add' && $user->rights->stock->creer) {
135 $object->ref = (string)
GETPOST(
"ref",
"alpha");
136 $object->fk_parent = (int)
GETPOST(
"fk_parent",
"int");
137 $object->fk_project =
GETPOST(
'projectid',
'int');
138 $object->label = (string)
GETPOST(
"libelle",
"alpha");
139 $object->description = (string)
GETPOST(
"desc",
"alpha");
140 $object->statut =
GETPOST(
"statut",
"int");
141 $object->lieu = (string)
GETPOST(
"lieu",
"alpha");
142 $object->address = (string)
GETPOST(
"address",
"alpha");
143 $object->zip = (string)
GETPOST(
"zipcode",
"alpha");
144 $object->town = (string)
GETPOST(
"town",
"alpha");
145 $object->country_id =
GETPOST(
"country_id");
146 $object->phone = (string)
GETPOST(
"phone",
"alpha");
147 $object->fax = (string)
GETPOST(
"fax",
"alpha");
149 if (!empty($object->label)) {
151 $ret = $extrafields->setOptionalsFromPost(
null, $object);
158 $id = $object->create($user);
162 $categories =
GETPOST(
'categories',
'array');
163 $object->setCategories($categories);
164 if (!empty($backtopage)) {
165 $backtopage = str_replace(
"__ID__", $id, $backtopage);
166 header(
"Location: ".$backtopage);
169 header(
"Location: card.php?id=".urlencode($id));
178 setEventMessages($langs->trans(
"ErrorWarehouseRefRequired"),
null,
'errors');
184 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->rights->stock->supprimer) {
185 $object->fetch(
GETPOST(
'id',
'int'));
186 $result = $object->delete($user);
189 header(
"Location: ".DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1');
198 if ($action ==
'update' && !$cancel) {
199 if ($object->fetch($id)) {
200 $object->label =
GETPOST(
"libelle");
201 $object->fk_parent =
GETPOST(
"fk_parent");
202 $object->fk_project =
GETPOST(
'projectid');
203 $object->description =
GETPOST(
"desc",
'restricthtml');
204 $object->statut =
GETPOST(
"statut");
205 $object->lieu =
GETPOST(
"lieu");
206 $object->address =
GETPOST(
"address");
207 $object->zip =
GETPOST(
"zipcode");
208 $object->town =
GETPOST(
"town");
209 $object->country_id =
GETPOST(
"country_id");
210 $object->phone =
GETPOST(
"phone");
214 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
220 $ret = $object->update($id, $user);
230 $categories =
GETPOST(
'categories',
'array');
231 $object->setCategories($categories);
238 } elseif ($action ==
'update_extras') {
242 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
247 $result = $object->insertExtraFields();
254 $action =
'edit_extras';
256 } elseif ($action ==
'classin' && $usercancreate) {
258 $object->setProject(
GETPOST(
'projectid',
'int'));
261 if ($cancel == $langs->trans(
"Cancel")) {
267 $upload_dir = $conf->stock->dir_output;
268 $permissiontoadd = $user->rights->stock->creer;
269 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
277$productstatic =
new Product($db);
278$form =
new Form($db);
282if (isModEnabled(
'project')) {
286$title = $langs->trans(
"WarehouseCard");
287if ($action ==
'create') {
288 $title = $langs->trans(
"NewWarehouse");
291$help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
295if ($action ==
'create') {
300 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">'.
"\n";
301 print
'<input type="hidden" name="token" value="'.newToken().
'">';
302 print
'<input type="hidden" name="action" value="add">';
303 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
307 print
'<table class="border centpercent">';
310 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Ref").
'</td><td><input name="libelle" size="20" value=""></td></tr>';
312 print
'<tr><td>'.$langs->trans(
"LocationSummary").
'</td><td><input name="lieu" size="40" value="'.(!empty($object->lieu) ? $object->lieu :
'').
'"></td></tr>';
315 print
'<tr><td>'.$langs->trans(
"AddIn").
'</td><td>';
316 print
img_picto(
'',
'stock').$formproduct->selectWarehouses((GETPOSTISSET(
'fk_parent') ?
GETPOST(
'fk_parent',
'int') :
'ifone'),
'fk_parent',
'', 1);
320 if (isModEnabled(
'project')) {
321 $langs->load(
'projects');
322 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td colspan="2">';
323 print
img_picto(
'',
'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
324 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>';
329 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
331 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
332 $doleditor =
new DolEditor(
'desc', (!empty($object->description) ? $object->description :
''),
'', 180,
'dolibarr_notes',
'In', false, true, isModEnabled(
'fckeditor'), ROWS_5,
'90%');
333 $doleditor->Create();
336 print
'<tr><td>'.$langs->trans(
'Address').
'</td><td><textarea name="address" class="quatrevingtpercent" rows="3" wrap="soft">';
337 print (!empty($object->address) ? $object->address :
'');
338 print
'</textarea></td></tr>';
341 print
'<tr><td>'.$langs->trans(
'Zip').
'</td><td>';
342 print $formcompany->select_ziptown((!empty($object->zip) ? $object->zip :
''),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
344 print
'<tr><td>'.$langs->trans(
'Town').
'</td><td>';
345 print $formcompany->select_ziptown((!empty($object->town) ? $object->town :
''),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
349 print
'<tr><td>'.$langs->trans(
'Country').
'</td><td>';
350 print
img_picto(
'',
'globe-americas',
'class="paddingright"');
351 print $form->select_country((!empty($object->country_id) ? $object->country_id : $mysoc->country_code),
'country_id');
353 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
358 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Phone',
'phone',
'', $object, 0).
'</td><td>';
359 print
img_picto(
'',
'object_phoning',
'class="paddingright"');
360 print
'<input name="phone" size="20" value="'.$object->phone.
'"></td></tr>';
361 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td>';
363 print
img_picto(
'',
'object_phoning_fax',
'class="paddingright"');
364 print
'<input name="fax" size="20" value="'.$object->fax.
'"></td></tr>';
367 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
368 print
'<select id="warehousestatus" name="statut" class="flat minwidth100">';
369 foreach ($object->statuts as $key => $value) {
371 print
'<option value="'.$key.
'" selected>'.$langs->trans($value).
'</option>';
373 print
'<option value="'.$key.
'">'.$langs->trans($value).
'</option>';
381 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
383 if (isModEnabled(
'categorie')) {
385 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
386 $cate_arbo = $form->select_all_categories(Categorie::TYPE_WAREHOUSE,
'',
'parent', 64, 0, 1);
387 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
394 print $form->buttonsSaveCancel(
"Create");
399 if ($id > 0 || $ref) {
401 $result = $object->fetch($id, $ref);
403 print
'No record found';
408 if ($action <>
'edit' && $action <>
're-edit') {
416 if ($action ==
'delete') {
417 $formquestion = array(
418 array(
'type' =>
'other',
'name' =>
'info',
'label' =>
img_warning(
'').$langs->trans(
"WarningThisWIllAlsoDeleteStock"),
'morecss'=>
'warning')
420 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"DeleteAWarehouse"), $langs->trans(
"ConfirmDeleteWarehouse", $object->label),
"confirm_delete", $formquestion, 0, 2);
424 $parameters = array(
'formConfirm' => $formconfirm);
425 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
426 if (empty($reshook)) {
427 $formconfirm .= $hookmanager->resPrint;
428 } elseif ($reshook > 0) {
429 $formconfirm = $hookmanager->resPrint;
436 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
438 $morehtmlref =
'<div class="refidno">';
439 $morehtmlref .= $langs->trans(
"LocationSummary").
' : '.$object->lieu;
442 if (isModEnabled(
'project')) {
443 $langs->load(
"projects");
444 $morehtmlref .=
'<br>'.img_picto(
'',
'project').
' '.$langs->trans(
'Project').
' ';
445 if ($usercancreate) {
446 if ($action !=
'classify') {
447 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
449 if ($action ==
'classify') {
450 $projectid = $object->fk_project;
451 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
452 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
453 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
454 $morehtmlref .= $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
455 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
456 $morehtmlref .=
'</form>';
458 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, ($socid > 0 ? $socid : -1), $object->fk_project,
'none', 0, 0, 0, 1,
'',
'maxwidth300');
461 if (!empty($object->fk_project)) {
463 $proj->fetch($object->fk_project);
464 $morehtmlref .=
' : '.$proj->getNomUrl(1);
466 $morehtmlref .=
' - '.$proj->title;
473 $morehtmlref .=
'</div>';
476 if ($user->socid && !in_array(
'stock', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
480 dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref',
'ref', $morehtmlref);
482 print
'<div class="fichecenter">';
483 print
'<div class="fichehalfleft">';
484 print
'<div class="underbanner clearboth"></div>';
486 print
'<table class="border centpercent tableforfield">';
489 $parentwarehouse =
new Entrepot($db);
490 if (!empty($object->fk_parent) && $parentwarehouse->fetch($object->fk_parent) > 0) {
491 print
'<tr><td>'.$langs->trans(
"ParentWarehouse").
'</td><td>';
492 print $parentwarehouse->getNomUrl(3);
499 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>'.
dol_htmlentitiesbr($object->description).
'</td></tr>';
501 $calcproductsunique = $object->nb_different_products();
502 $calcproducts = $object->nb_products();
505 print
'<tr><td>'.$langs->trans(
"NumberOfDifferentProducts").
'</td><td>';
506 print empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb'];
510 print
'<tr><td>'.$langs->trans(
"NumberOfProducts").
'</td><td>';
511 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
512 print empty($valtoshow) ?
'0' : $valtoshow;
518 print
'<div class="fichehalfright">';
519 print
'<div class="underbanner clearboth"></div>';
521 print
'<table class="border centpercent tableforfield">';
524 print
'<tr><td class="titlefield">'.$langs->trans(
"EstimatedStockValueShort").
'</td><td>';
525 print
price((empty($calcproducts[
'value']) ?
'0' :
price2num($calcproducts[
'value'],
'MT')), 0, $langs, 0, -1, -1, $conf->currency);
529 if (!empty($user->rights->stock->mouvement->lire)) {
530 $sql =
"SELECT max(m.datem) as datem";
531 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
532 $sql .=
" WHERE m.fk_entrepot = ".((int) $object->id);
533 $resqlbis = $db->query($sql);
535 $obj = $db->fetch_object($resqlbis);
536 $lastmovementdate = $db->jdate($obj->datem);
540 print
'<tr><td>'.$langs->trans(
"LastMovement").
'</td><td>';
541 if ($lastmovementdate) {
543 print
' ';
544 print
img_picto($langs->trans(
'LastMovement'),
'movement',
'class="pictofixedwidth"');
545 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?id='.$object->id.
'">'.$langs->trans(
"FullList").
'</a>';
547 print $langs->trans(
"None");
553 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
556 if (isModEnabled(
'categorie')) {
557 print
'<tr><td valign="middle">'.$langs->trans(
"Categories").
'</td><td colspan="3">';
558 print $form->showCategories($object->id, Categorie::TYPE_WAREHOUSE, 1);
567 print
'<div class="clearboth"></div>';
575 print
"<div class=\"tabsAction\">\n";
577 $parameters = array();
578 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
579 if (empty($reshook)) {
580 if (empty($action) || $action ==
'classin') {
581 if ($user->rights->stock->creer) {
582 print
'<a class="butAction" href="card.php?action=edit&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Modify").
'</a>';
584 print
'<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
"Modify").
'</a>';
587 if ($user->rights->stock->supprimer) {
588 print
'<a class="butActionDelete" href="card.php?action=delete&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Delete").
'</a>';
590 print
'<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
"Delete").
'</a>';
602 $totalarray = array();
603 $totalarray[
'val'] = array ();
604 $totalarray[
'pos'] = array ();
605 $totalarray[
'type'] = array ();
606 $totalarray[
'nbfield'] = 0;
610 print
'<table class="noborder centpercent">';
611 print
"<tr class=\"liste_titre\">";
612 $parameters = array(
'totalarray' => &$totalarray);
613 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
614 print $hookmanager->resPrint;
618 print_liste_field_titre(
"NumberOfUnit",
"",
"ps.reel",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
619 $totalarray[
'nbfield'] += 3;
620 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalunit';
621 $totalarray[
'type'][$totalarray[
'nbfield']] =
'stock';
623 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
625 $totalarray[
'nbfield']++;
626 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'units';
627 $totalarray[
'type'][$totalarray[
'nbfield']] =
'string';
630 print_liste_field_titre($form->textwithpicto($langs->trans(
"AverageUnitPricePMPShort"), $langs->trans(
"AverageUnitPricePMPDesc")),
"",
"p.pmp",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
631 $totalarray[
'nbfield']++;
633 print_liste_field_titre(
"EstimatedStockValueShort",
"",
"",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
634 $totalarray[
'nbfield']++;
635 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalvalue';
636 $totalarray[
'type'][$totalarray[
'nbfield']] =
'';
639 if (empty($conf->global->PRODUIT_MULTIPRICES)) {
640 print_liste_field_titre(
"SellPriceMin",
"",
"p.price",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
641 $totalarray[
'nbfield']++;
643 if (empty($conf->global->PRODUIT_MULTIPRICES)) {
644 print_liste_field_titre(
"EstimatedStockValueSellShort",
"",
"",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
645 $totalarray[
'nbfield']++;
646 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalvaluesell';
647 $totalarray[
'type'][$totalarray[
'nbfield']] =
'';
649 if ($user->rights->stock->mouvement->creer) {
651 $totalarray[
'nbfield']++;
653 if ($user->rights->stock->creer) {
655 $totalarray[
'nbfield']++;
658 $parameters = array(
'sortfield'=>$sortfield,
'sortorder'=>$sortorder,
'totalarray' => &$totalarray);
659 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
660 print $hookmanager->resPrint;
664 $totalvalue = $totalvaluesell = 0;
667 $separatedPMP =
false;
668 if (!empty($conf->global->MULTICOMPANY_PRODUCT_SHARING_ENABLED) && !empty($conf->global->MULTICOMPANY_PMP_PER_ENTITY_ENABLED)) {
669 $separatedPMP =
true;
672 $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,";
673 $sql .=
"p.tosell, p.tobuy,";
674 $sql .=
"p.accountancy_code_sell,";
675 $sql .=
"p.accountancy_code_sell_intra,";
676 $sql .=
"p.accountancy_code_sell_export,";
677 $sql .=
"p.accountancy_code_buy,";
678 $sql .=
"p.accountancy_code_buy_intra,";
679 $sql .=
"p.accountancy_code_buy_export,";
680 $sql .=
'p.barcode,';
682 $sql .=
" pa.pmp as ppmp,";
684 $sql .=
" p.pmp as ppmp,";
686 $sql .=
" ps.reel as value";
687 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
691 $parameters = array();
692 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
696 $sql .= $hookmanager->resPrint;
697 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_stock as ps, ".MAIN_DB_PREFIX.
"product as p";
700 $sql .=
", ".MAIN_DB_PREFIX.
"product_perentity as pa";
703 $sql .=
" WHERE ps.fk_product = p.rowid";
704 $sql .=
" AND ps.reel <> 0";
705 $sql .=
" AND ps.fk_entrepot = ".((int) $object->id);
708 $sql .=
" AND pa.fk_product = p.rowid AND pa.entity = ".(int) $conf->entity;
711 $sql .= $db->order($sortfield, $sortorder);
714 $resql = $db->query($sql);
716 $num = $db->num_rows($resql);
721 $objp = $db->fetch_object($resql);
725 $sql =
"SELECT label";
726 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
727 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
728 $sql .=
" AND lang = '".$db->escape($langs->getDefaultLang()).
"'";
731 $result = $db->query($sql);
733 $objtp = $db->fetch_object($result);
734 if ($objtp->label !=
'') {
735 $objp->produit = $objtp->label;
741 print
'<tr class="oddeven">';
743 $parameters = array(
'obj'=>$objp,
'totalarray' => &$totalarray);
744 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
745 print $hookmanager->resPrint;
747 $productstatic->id = $objp->rowid;
748 $productstatic->ref = $objp->ref;
749 $productstatic->label = $objp->produit;
750 $productstatic->type = $objp->type;
751 $productstatic->entity = $objp->entity;
752 $productstatic->status_batch = $objp->tobatch;
753 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
754 $productstatic->fk_unit = $objp->fk_unit;
756 $productstatic->status = $objp->tosell;
757 $productstatic->status_buy = $objp->tobuy;
758 $productstatic->barcode = $objp->barcode;
759 $productstatic->accountancy_code_sell = $objp->accountancy_code_sell;
760 $productstatic->accountancy_code_sell_intra = $objp->accountancy_code_sell_intra;
761 $productstatic->accountancy_code_sell_export = $objp->accountancy_code_sell_export;
762 $productstatic->accountancy_code_buy = $objp->accountancy_code_buy;
763 $productstatic->accountancy_code_buy_intra = $objp->accountancy_code_buy_intra;
764 $productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export;
768 print $productstatic->getNomUrl(1,
'stock', 16);
772 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($objp->produit).
'">'.
dol_escape_htmltag($objp->produit).
'</td>';
775 print
'<td class="right">';
777 print empty($valtoshow) ?
'0' : $valtoshow;
779 $totalunit += $objp->value;
781 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
783 print
'<td align="left">';
784 if (is_null($productstatic->fk_unit)) {
785 $productstatic->fk_unit = 1;
787 print $langs->trans($productstatic->getLabelOfUnit());
792 print
'<td class="right nowraponall">'.price(
price2num($objp->ppmp,
'MU')).
'</td>';
795 print
'<td class="right amount nowraponall">'.price(
price2num($objp->ppmp * $objp->value,
'MT')).
'</td>';
796 $totalvalue +=
price2num($objp->ppmp * $objp->value,
'MT');
799 if (empty($conf->global->PRODUIT_MULTIPRICES)) {
800 $pricemin = $objp->price;
801 print
'<td class="right">';
805 print
'<td class="right">';
809 $totalvaluesell +=
price2num($pricemin * $objp->value,
'MT');
812 if ($user->rights->stock->mouvement->creer) {
813 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).
'">';
814 print
img_picto($langs->trans(
"TransferStock"),
'add',
'class="hideonsmartphone pictofixedwidth" style="color: #a69944"');
815 print $langs->trans(
"TransferStock");
820 if ($user->rights->stock->creer) {
821 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).
'">';
822 print
img_picto($langs->trans(
"CorrectStock"),
'add',
'class="hideonsmartphone pictofixedwidth" style="color: #a69944"');
823 print $langs->trans(
"CorrectStock");
832 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
834 $units = $productstatic->fk_unit;
835 } elseif ($productstatic->fk_unit != $units) {
842 $totalarray[
'val'][
'totalunit'] = $totalunit;
843 $totalarray[
'val'][
'totalvalue'] =
price2num($totalvalue,
'MT');
844 $totalarray[
'val'][
'totalvaluesell'] =
price2num($totalvaluesell,
'MT');
845 $totalarray[
'val'][
'units'] = $langs->trans($productstatic->getLabelOfUnit());
847 $parameters = array(
'totalarray' => &$totalarray);
849 $reshook = $hookmanager->executeHooks(
'printFieldListTotal', $parameters, $object);
855 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
864 if ($action ==
'edit' || $action ==
're-edit') {
865 $langs->trans(
"WarehouseEdit");
867 print
'<form action="card.php" method="POST">';
868 print
'<input type="hidden" name="token" value="'.newToken().
'">';
869 print
'<input type="hidden" name="action" value="update">';
870 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
876 print
'<table class="border centpercent">';
879 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Ref").
'</td><td><input name="libelle" size="20" value="'.$object->label.
'"></td></tr>';
881 print
'<tr><td>'.$langs->trans(
"LocationSummary").
'</td><td><input name="lieu" class="minwidth300" value="'.$object->lieu.
'"></td></tr>';
884 print
'<tr><td>'.$langs->trans(
"AddIn").
'</td><td>';
885 print $formproduct->selectWarehouses($object->fk_parent,
'fk_parent',
'', 1);
889 if (isModEnabled(
'project')) {
890 $projectid = $object->fk_project;
891 $langs->load(
'projects');
892 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td colspan="2">';
893 print
img_picto(
'',
'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
894 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>';
899 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
901 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
902 $doleditor =
new DolEditor(
'desc', $object->description,
'', 180,
'dolibarr_notes',
'In',
false,
true, isModEnabled(
'fckeditor'), ROWS_5,
'90%');
903 $doleditor->Create();
906 print
'<tr><td>'.$langs->trans(
'Address').
'</td><td><textarea name="address" class="quatrevingtpercent" rows="3" wrap="soft">';
907 print $object->address;
908 print
'</textarea></td></tr>';
911 print
'<tr><td>'.$langs->trans(
'Zip').
'</td><td>';
912 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
914 print
'<tr><td>'.$langs->trans(
'Town').
'</td><td>';
915 print $formcompany->select_ziptown($object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
919 print
'<tr><td>'.$langs->trans(
'Country').
'</td><td>';
920 print
img_picto(
'',
'globe-americas',
'class="paddingright"');
921 print $form->select_country($object->country_id ? $object->country_id : $mysoc->country_code,
'country_id');
923 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
928 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Phone',
'phone',
'', $object, 0).
'</td><td>';
929 print
img_picto(
'',
'object_phoning',
'class="paddingright"');
930 print
'<input name="phone" size="20" value="'.$object->phone.
'"></td></tr>';
931 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td><td>';
932 print
img_picto(
'',
'object_phoning_fax',
'class="paddingright"');
933 print
'<input name="fax" size="20" value="'.$object->fax.
'"></td></tr>';
936 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
937 print
'<select id="warehousestatus" name="statut" class="flat">';
938 foreach ($object->statuts as $key => $value) {
939 if ($key == $object->statut) {
940 print
'<option value="'.$key.
'" selected>'.$langs->trans($value).
'</option>';
942 print
'<option value="'.$key.
'">'.$langs->trans($value).
'</option>';
951 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' =>
'3');
952 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
953 print $hookmanager->resPrint;
954 if (empty($reshook)) {
955 print $object->showOptionals($extrafields,
'edit', $parameters);
959 if (isModEnabled(
'categorie')) {
960 print
'<tr><td class="tdtop">'.$langs->trans(
"Categories").
'</td><td colspan="3">';
961 $cate_arbo = $form->select_all_categories(Categorie::TYPE_WAREHOUSE,
'',
'parent', 64, 0, 1);
963 $cats = $c->containing($object->id, Categorie::TYPE_WAREHOUSE);
964 $arrayselected = array();
965 foreach ($cats as $cat) {
966 $arrayselected[] = $cat->id;
968 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
976 print $form->buttonsSaveCancel();
987$modulepart =
'stock';
989if ($action !=
'create' && $action !=
'edit' && $action !=
'delete') {
991 print
'<div class="fichecenter"><div class="fichehalfleft">';
992 print
'<a name="builddoc"></a>';
996 $relativepath = $object->ref.
'/'.$objectref.
'.pdf';
997 $filedir = $conf->stock->dir_output.
'/'.$objectref;
998 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
999 $genallowed = $usercanread;
1000 $delallowed = $usercancreate;
1001 $modulepart =
'stock';
1003 print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0,
'', 0,
'',
'',
'', $object);
1004 $somethingshown = $formfile->numoffiles;
1006 print
'</div><div class="fichehalfright">';
1010 $morehtmlcenter =
'';
1014 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1016 $somethingshown =
$formactions->showactions($object,
'stock', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
1018 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.