31 require
'../../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/stock.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
41 if (!empty($conf->project->enabled)) {
42 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
47 $langs->loadLangs(array(
'products',
'stocks',
'companies',
'categories'));
49 $action =
GETPOST(
'action',
'aZ09');
50 $cancel =
GETPOST(
'cancel',
'alpha');
52 $projectid =
GETPOST(
'projectid',
'int');
55 $socid =
GETPOST(
'socid',
'int');
58 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
59 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
67 $backtopage =
GETPOST(
'backtopage',
'alpha');
74 $hookmanager->initHooks(array(
'warehousecard',
'globalcard'));
80 $extrafields->fetch_name_optionals_label($object->table_element);
83 if ($id > 0 || !empty($ref)) {
84 $ret = $object->fetch($id, $ref);
91 $usercanread = (($user->rights->stock->lire));
92 $usercancreate = (($user->rights->stock->creer));
93 $usercandelete = (($user->rights->stock->supprimer));
103 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
107 if (empty($reshook)) {
108 $backurlforlist = DOL_URL_ROOT.
'/product/stock/list.php';
110 if (empty($backtopage) || ($cancel && empty($id))) {
111 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
112 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
113 $backtopage = $backurlforlist;
115 $backtopage = DOL_URL_ROOT.
'/product/stock/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
121 if (!empty($backtopageforcancel)) {
122 header(
"Location: ".$backtopageforcancel);
124 } elseif (!empty($backtopage)) {
125 header(
"Location: ".$backtopage);
132 if ($action ==
'add' && $user->rights->stock->creer) {
133 $object->ref = (string)
GETPOST(
"ref",
"alpha");
134 $object->fk_parent = (int)
GETPOST(
"fk_parent",
"int");
135 $object->fk_project =
GETPOST(
'projectid',
'int');
136 $object->label = (string)
GETPOST(
"libelle",
"alpha");
137 $object->description = (string)
GETPOST(
"desc",
"alpha");
138 $object->statut =
GETPOST(
"statut",
"int");
139 $object->lieu = (string)
GETPOST(
"lieu",
"alpha");
140 $object->address = (string)
GETPOST(
"address",
"alpha");
141 $object->zip = (string)
GETPOST(
"zipcode",
"alpha");
142 $object->town = (string)
GETPOST(
"town",
"alpha");
143 $object->country_id =
GETPOST(
"country_id");
144 $object->phone = (string)
GETPOST(
"phone",
"alpha");
145 $object->fax = (string)
GETPOST(
"fax",
"alpha");
147 if (!empty($object->label)) {
149 $ret = $extrafields->setOptionalsFromPost(
null, $object);
156 $id = $object->create($user);
160 $categories =
GETPOST(
'categories',
'array');
161 $object->setCategories($categories);
162 if (!empty($backtopage)) {
163 $backtopage = str_replace(
"__ID__", $id, $backtopage);
164 header(
"Location: ".$backtopage);
167 header(
"Location: card.php?id=".urlencode($id));
176 setEventMessages($langs->trans(
"ErrorWarehouseRefRequired"),
null,
'errors');
182 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->rights->stock->supprimer) {
183 $object->fetch(
GETPOST(
'id',
'int'));
184 $result = $object->delete($user);
187 header(
"Location: ".DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1');
196 if ($action ==
'update' && !$cancel) {
197 if ($object->fetch($id)) {
198 $object->label =
GETPOST(
"libelle");
199 $object->fk_parent =
GETPOST(
"fk_parent");
200 $object->fk_project =
GETPOST(
'projectid');
201 $object->description =
GETPOST(
"desc",
'restricthtml');
202 $object->statut =
GETPOST(
"statut");
203 $object->lieu =
GETPOST(
"lieu");
204 $object->address =
GETPOST(
"address");
205 $object->zip =
GETPOST(
"zipcode");
206 $object->town =
GETPOST(
"town");
207 $object->country_id =
GETPOST(
"country_id");
208 $object->phone =
GETPOST(
"phone");
212 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
218 $ret = $object->update($id, $user);
228 $categories =
GETPOST(
'categories',
'array');
229 $object->setCategories($categories);
236 } elseif ($action ==
'update_extras') {
240 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
245 $result = $object->insertExtraFields();
252 $action =
'edit_extras';
254 } elseif ($action ==
'classin' && $usercancreate) {
256 $object->setProject(
GETPOST(
'projectid',
'int'));
259 if ($cancel == $langs->trans(
"Cancel")) {
265 $upload_dir = $conf->stock->dir_output;
266 $permissiontoadd = $user->rights->stock->creer;
267 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
275 $productstatic =
new Product($db);
280 if (!empty($conf->project->enabled)) {
284 $help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
288 if ($action ==
'create') {
293 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">'.
"\n";
294 print
'<input type="hidden" name="token" value="'.newToken().
'">';
295 print
'<input type="hidden" name="action" value="add">';
296 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
300 print
'<table class="border centpercent">';
303 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Ref").
'</td><td><input name="libelle" size="20" value=""></td></tr>';
305 print
'<tr><td>'.$langs->trans(
"LocationSummary").
'</td><td><input name="lieu" size="40" value="'.(!empty($object->lieu) ? $object->lieu :
'').
'"></td></tr>';
308 print
'<tr><td>'.$langs->trans(
"AddIn").
'</td><td>';
309 print
img_picto(
'',
'stock').$formproduct->selectWarehouses((
GETPOSTISSET(
'fk_parent') ?
GETPOST(
'fk_parent',
'int') :
'ifone'),
'fk_parent',
'', 1);
313 if (!empty($conf->project->enabled)) {
314 $langs->load(
'projects');
315 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td colspan="2">';
316 print
img_picto(
'',
'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
317 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.$socid.
'&action=create&status=1&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create&socid='.$socid).
'"><span class="fa fa-plus-circle valignmiddle" title="'.$langs->trans(
"AddProject").
'"></span></a>';
322 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
324 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
325 $doleditor =
new DolEditor(
'desc', (!empty($object->description) ? $object->description :
''),
'', 180,
'dolibarr_notes',
'In',
false,
true, empty($conf->fckeditor->enabled) ?
'' : $conf->fckeditor->enabled, ROWS_5,
'90%');
326 $doleditor->Create();
329 print
'<tr><td>'.$langs->trans(
'Address').
'</td><td><textarea name="address" class="quatrevingtpercent" rows="3" wrap="soft">';
330 print (!empty($object->address) ? $object->address :
'');
331 print
'</textarea></td></tr>';
334 print
'<tr><td>'.$langs->trans(
'Zip').
'</td><td>';
335 print $formcompany->select_ziptown((!empty($object->zip) ? $object->zip :
''),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
337 print
'<tr><td>'.$langs->trans(
'Town').
'</td><td>';
338 print $formcompany->select_ziptown((!empty($object->town) ? $object->town :
''),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
342 print
'<tr><td>'.$langs->trans(
'Country').
'</td><td>';
343 print
img_picto(
'',
'globe-americas',
'class="paddingright"');
344 print
$form->select_country((!empty($object->country_id) ? $object->country_id : $mysoc->country_code),
'country_id');
346 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
351 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Phone',
'phone',
'', $object, 0).
'</td><td>';
352 print
img_picto(
'',
'object_phoning',
'class="paddingright"');
353 print
'<input name="phone" size="20" value="'.$object->phone.
'"></td></tr>';
354 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td>';
356 print
img_picto(
'',
'object_phoning_fax',
'class="paddingright"');
357 print
'<input name="fax" size="20" value="'.$object->fax.
'"></td></tr>';
360 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
361 print
'<select id="warehousestatus" name="statut" class="flat">';
362 foreach ($object->statuts as $key => $value) {
364 print
'<option value="'.$key.
'" selected>'.$langs->trans($value).
'</option>';
366 print
'<option value="'.$key.
'">'.$langs->trans($value).
'</option>';
374 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
376 if (!empty($conf->categorie->enabled)) {
378 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
379 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_WAREHOUSE,
'',
'parent', 64, 0, 1);
380 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
387 print
$form->buttonsSaveCancel(
"Create");
392 if ($id > 0 || $ref) {
394 $result = $object->fetch($id, $ref);
396 print
'No record found';
403 if ($action <>
'edit' && $action <>
're-edit') {
411 if ($action ==
'delete') {
412 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"DeleteAWarehouse"), $langs->trans(
"ConfirmDeleteWarehouse", $object->label),
"confirm_delete",
'', 0, 2);
417 $reshook = $hookmanager->executeHooks(
'formConfirm',
$parameters, $object, $action);
418 if (empty($reshook)) {
420 } elseif ($reshook > 0) {
428 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
430 $morehtmlref =
'<div class="refidno">';
431 $morehtmlref .= $langs->trans(
"LocationSummary").
' : '.$object->lieu;
434 if (!empty($conf->project->enabled)) {
435 $langs->load(
"projects");
436 $morehtmlref .=
'<br>'.img_picto(
'',
'project').
' '.$langs->trans(
'Project').
' ';
437 if ($usercancreate) {
438 if ($action !=
'classify') {
439 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
441 if ($action ==
'classify') {
442 $projectid = $object->fk_project;
443 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
444 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
445 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
446 $morehtmlref .= $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
447 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
448 $morehtmlref .=
'</form>';
450 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, ($socid > 0 ? $socid : -1), $object->fk_project,
'none', 0, 0, 0, 1);
453 if (!empty($object->fk_project)) {
455 $proj->fetch($object->fk_project);
456 $morehtmlref .=
' : '.$proj->getNomUrl(1);
458 $morehtmlref .=
' - '.$proj->title;
465 $morehtmlref .=
'</div>';
468 if ($user->socid && !in_array(
'stock', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
472 dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref',
'ref', $morehtmlref);
474 print
'<div class="fichecenter">';
475 print
'<div class="fichehalfleft">';
476 print
'<div class="underbanner clearboth"></div>';
478 print
'<table class="border centpercent tableforfield">';
481 $parentwarehouse =
new Entrepot($db);
482 if (!empty($object->fk_parent) && $parentwarehouse->fetch($object->fk_parent) > 0) {
483 print
'<tr><td>'.$langs->trans(
"ParentWarehouse").
'</td><td>';
484 print $parentwarehouse->getNomUrl(3);
491 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>'.
dol_htmlentitiesbr($object->description).
'</td></tr>';
493 $calcproductsunique = $object->nb_different_products();
494 $calcproducts = $object->nb_products();
497 print
'<tr><td>'.$langs->trans(
"NumberOfDifferentProducts").
'</td><td>';
498 print empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb'];
502 print
'<tr><td>'.$langs->trans(
"NumberOfProducts").
'</td><td>';
503 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
504 print empty($valtoshow) ?
'0' : $valtoshow;
510 print
'<div class="fichehalfright">';
511 print
'<div class="underbanner clearboth"></div>';
513 print
'<table class="border centpercent tableforfield">';
516 print
'<tr><td class="titlefield">'.$langs->trans(
"EstimatedStockValueShort").
'</td><td>';
517 print
price((empty($calcproducts[
'value']) ?
'0' :
price2num($calcproducts[
'value'],
'MT')), 0, $langs, 0, -1, -1, $conf->currency);
521 if (!empty($user->rights->stock->mouvement->lire)) {
522 $sql =
"SELECT max(m.datem) as datem";
523 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
524 $sql .=
" WHERE m.fk_entrepot = ".((int) $object->id);
525 $resqlbis = $db->query($sql);
527 $obj = $db->fetch_object($resqlbis);
528 $lastmovementdate = $db->jdate($obj->datem);
532 print
'<tr><td>'.$langs->trans(
"LastMovement").
'</td><td>';
533 if ($lastmovementdate) {
535 print
' ';
536 print
img_picto($langs->trans(
'LastMovement'),
'movement',
'class="pictofixedwidth"');
537 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?id='.$object->id.
'">'.$langs->trans(
"FullList").
'</a>';
539 print $langs->trans(
"None");
545 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
549 print
'<tr><td valign="middle">'.$langs->trans(
"Categories").
'</td><td colspan="3">';
550 print
$form->showCategories($object->id, Categorie::TYPE_WAREHOUSE, 1);
559 print
'<div class="clearboth"></div>';
567 print
"<div class=\"tabsAction\">\n";
570 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
571 if (empty($reshook)) {
572 if (empty($action) || $action ==
'classin') {
573 if ($user->rights->stock->creer) {
574 print
'<a class="butAction" href="card.php?action=edit&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Modify").
'</a>';
576 print
'<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
"Modify").
'</a>';
579 if ($user->rights->stock->supprimer) {
580 print
'<a class="butActionDelete" href="card.php?action=delete&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Delete").
'</a>';
582 print
'<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
"Delete").
'</a>';
597 print
'<table class="noborder centpercent">';
598 print
"<tr class=\"liste_titre\">";
600 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle',
$parameters);
601 print $hookmanager->resPrint;
604 print_liste_field_titre(
"NumberOfUnit",
"",
"ps.reel",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
605 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
608 print_liste_field_titre(
$form->textwithpicto($langs->trans(
"AverageUnitPricePMPShort"), $langs->trans(
"AverageUnitPricePMPDesc")),
"",
"p.pmp",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
609 print_liste_field_titre(
"EstimatedStockValueShort",
"",
"",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
610 if (empty($conf->global->PRODUIT_MULTIPRICES)) {
611 print_liste_field_titre(
"SellPriceMin",
"",
"p.price",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
613 if (empty($conf->global->PRODUIT_MULTIPRICES)) {
614 print_liste_field_titre(
"EstimatedStockValueSellShort",
"",
"",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
616 if ($user->rights->stock->mouvement->creer) {
619 if ($user->rights->stock->creer) {
623 $parameters = array(
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
624 $reshook = $hookmanager->executeHooks(
'printFieldListTitle',
$parameters);
625 print $hookmanager->resPrint;
629 $totalvalue = $totalvaluesell = 0;
632 $separatedPMP =
false;
633 if (!empty($conf->global->MULTICOMPANY_PRODUCT_SHARING_ENABLED) && !empty($conf->global->MULTICOMPANY_PMP_PER_ENTITY_ENABLED)) {
634 $separatedPMP =
true;
637 $sql =
"SELECT p.rowid as rowid, p.ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.price, p.price_ttc, p.entity,";
638 $sql .=
"p.tosell, p.tobuy,";
639 $sql .=
"p.accountancy_code_sell,";
640 $sql .=
"p.accountancy_code_sell_intra,";
641 $sql .=
"p.accountancy_code_sell_export,";
642 $sql .=
"p.accountancy_code_buy,";
643 $sql .=
"p.accountancy_code_buy_intra,";
644 $sql .=
"p.accountancy_code_buy_export,";
645 $sql .=
'p.barcode,';
647 $sql .=
" pa.pmp as ppmp,";
649 $sql .=
" p.pmp as ppmp,";
651 $sql .=
" ps.reel as value";
652 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
657 $reshook = $hookmanager->executeHooks(
'printFieldListSelect',
$parameters);
661 $sql .= $hookmanager->resPrint;
662 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_stock as ps, ".MAIN_DB_PREFIX.
"product as p";
665 $sql .=
", ".MAIN_DB_PREFIX.
"product_perentity as pa";
668 $sql .=
" WHERE ps.fk_product = p.rowid";
669 $sql .=
" AND ps.reel <> 0";
670 $sql .=
" AND ps.fk_entrepot = ".((int) $object->id);
673 $sql .=
" AND pa.fk_product = p.rowid AND pa.entity = ".(int) $conf->entity;
676 $sql .= $db->order($sortfield, $sortorder);
679 $resql = $db->query($sql);
681 $num = $db->num_rows(
$resql);
686 $objp = $db->fetch_object(
$resql);
689 if (!empty($conf->global->MAIN_MULTILANGS)) {
690 $sql =
"SELECT label";
691 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
692 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
693 $sql .=
" AND lang = '".$db->escape($langs->getDefaultLang()).
"'";
696 $result = $db->query($sql);
698 $objtp = $db->fetch_object($result);
699 if ($objtp->label !=
'') {
700 $objp->produit = $objtp->label;
706 print
'<tr class="oddeven">';
709 $reshook = $hookmanager->executeHooks(
'printFieldListValue',
$parameters);
710 print $hookmanager->resPrint;
712 $productstatic->id = $objp->rowid;
713 $productstatic->ref = $objp->ref;
714 $productstatic->label = $objp->produit;
715 $productstatic->type = $objp->type;
716 $productstatic->entity = $objp->entity;
717 $productstatic->status_batch = $objp->tobatch;
718 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
719 $productstatic->fk_unit = $objp->fk_unit;
721 $productstatic->status = $objp->tosell;
722 $productstatic->status_buy = $objp->tobuy;
723 $productstatic->barcode = $objp->barcode;
724 $productstatic->accountancy_code_sell = $objp->accountancy_code_sell;
725 $productstatic->accountancy_code_sell_intra = $objp->accountancy_code_sell_intra;
726 $productstatic->accountancy_code_sell_export = $objp->accountancy_code_sell_export;
727 $productstatic->accountancy_code_buy = $objp->accountancy_code_buy;
728 $productstatic->accountancy_code_buy_intra = $objp->accountancy_code_buy_intra;
729 $productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export;
732 print $productstatic->getNomUrl(1,
'stock', 16);
736 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($objp->produit).
'">'.
dol_escape_htmltag($objp->produit).
'</td>';
738 print
'<td class="right">';
740 print empty($valtoshow) ?
'0' : $valtoshow;
742 $totalunit += $objp->value;
744 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
746 print
'<td align="left">';
747 if (is_null($productstatic->fk_unit)) {
748 $productstatic->fk_unit = 1;
750 print $langs->trans($productstatic->getLabelOfUnit());
754 print
'<td class="right nowraponall">'.price(
price2num($objp->ppmp,
'MU')).
'</td>';
757 print
'<td class="right amount nowraponall">'.price(
price2num($objp->ppmp * $objp->value,
'MT')).
'</td>';
758 $totalvalue +=
price2num($objp->ppmp * $objp->value,
'MT');
761 if (empty($conf->global->PRODUIT_MULTIPRICES)) {
762 $pricemin = $objp->price;
763 print
'<td class="right">';
767 print
'<td class="right">';
771 $totalvaluesell +=
price2num($pricemin * $objp->value,
'MT');
773 if ($user->rights->stock->mouvement->creer) {
774 print
'<td class="center"><a href="'.DOL_URL_ROOT.
'/product/stock/product.php?dwid='.$object->id.
'&id='.$objp->rowid.
'&action=transfert&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?id='.$id).
'">';
775 print
img_picto($langs->trans(
"TransferStock"),
'add',
'class="hideonsmartphone pictofixedwidth" style="color: #a69944"');
776 print $langs->trans(
"TransferStock");
780 if ($user->rights->stock->creer) {
781 print
'<td class="center"><a href="'.DOL_URL_ROOT.
'/product/stock/product.php?dwid='.$object->id.
'&id='.$objp->rowid.
'&action=correction&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?id='.$id).
'">';
782 print
img_picto($langs->trans(
"CorrectStock"),
'add',
'class="hideonsmartphone pictofixedwidth" style="color: #a69944"');
783 print $langs->trans(
"CorrectStock");
787 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
789 $units = $productstatic->fk_unit;
790 } elseif ($productstatic->fk_unit != $units) {
801 print
'<tr class="liste_total"><td class="liste_total" colspan="2">'.$langs->trans(
"Total").
'</td>';
802 print
'<td class="liste_total right">';
803 $valtoshow =
price2num($totalunit,
'MS');
804 if (empty($conf->global->PRODUCT_USE_UNITS) || $sameunits) {
805 print empty($valtoshow) ?
'0' : $valtoshow;
808 print
'<td class="liste_total">';
809 if (empty($conf->global->PRODUCT_USE_UNITS) && $sameunits) {
810 print $langs->trans($productstatic->getLabelOfUnit());
813 print
'<td class="liste_total right">'.price(
price2num($totalvalue,
'MT')).
'</td>';
814 if (empty($conf->global->PRODUIT_MULTIPRICES)) {
815 print
'<td class="liste_total"> </td>';
816 print
'<td class="liste_total right">'.price(
price2num($totalvaluesell,
'MT')).
'</td>';
819 if ($user->rights->stock->mouvement->creer) {
820 print
'<td class="liste_total"> </td>';
823 if ($user->rights->stock->creer) {
824 print
'<td class="liste_total"> </td>';
838 if ($action ==
'edit' || $action ==
're-edit') {
839 $langs->trans(
"WarehouseEdit");
841 print
'<form action="card.php" method="POST">';
842 print
'<input type="hidden" name="token" value="'.newToken().
'">';
843 print
'<input type="hidden" name="action" value="update">';
844 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
850 print
'<table class="border centpercent">';
853 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Ref").
'</td><td><input name="libelle" size="20" value="'.$object->label.
'"></td></tr>';
855 print
'<tr><td>'.$langs->trans(
"LocationSummary").
'</td><td><input name="lieu" class="minwidth300" value="'.$object->lieu.
'"></td></tr>';
858 print
'<tr><td>'.$langs->trans(
"AddIn").
'</td><td>';
859 print $formproduct->selectWarehouses($object->fk_parent,
'fk_parent',
'', 1);
863 if (!empty($conf->project->enabled)) {
864 $projectid = $object->fk_project;
865 $langs->load(
'projects');
866 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td colspan="2">';
867 print
img_picto(
'',
'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
868 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>';
873 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
875 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
876 $doleditor =
new DolEditor(
'desc', $object->description,
'', 180,
'dolibarr_notes',
'In',
false,
true, $conf->fckeditor->enabled, ROWS_5,
'90%');
877 $doleditor->Create();
880 print
'<tr><td>'.$langs->trans(
'Address').
'</td><td><textarea name="address" class="quatrevingtpercent" rows="3" wrap="soft">';
881 print $object->address;
882 print
'</textarea></td></tr>';
885 print
'<tr><td>'.$langs->trans(
'Zip').
'</td><td>';
886 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
888 print
'<tr><td>'.$langs->trans(
'Town').
'</td><td>';
889 print $formcompany->select_ziptown($object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
893 print
'<tr><td>'.$langs->trans(
'Country').
'</td><td>';
894 print
img_picto(
'',
'globe-americas',
'class="paddingright"');
895 print
$form->select_country($object->country_id ? $object->country_id : $mysoc->country_code,
'country_id');
897 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
902 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Phone',
'phone',
'', $object, 0).
'</td><td>';
903 print
img_picto(
'',
'object_phoning',
'class="paddingright"');
904 print
'<input name="phone" size="20" value="'.$object->phone.
'"></td></tr>';
905 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td><td>';
906 print
img_picto(
'',
'object_phoning_fax',
'class="paddingright"');
907 print
'<input name="fax" size="20" value="'.$object->fax.
'"></td></tr>';
910 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
911 print
'<select id="warehousestatus" name="statut" class="flat">';
912 foreach ($object->statuts as $key => $value) {
913 if ($key == $object->statut) {
914 print
'<option value="'.$key.
'" selected>'.$langs->trans($value).
'</option>';
916 print
'<option value="'.$key.
'">'.$langs->trans($value).
'</option>';
925 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' =>
'3');
926 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
927 print $hookmanager->resPrint;
928 if (empty($reshook)) {
929 print $object->showOptionals($extrafields,
'edit',
$parameters);
934 print
'<tr><td class="tdtop">'.$langs->trans(
"Categories").
'</td><td colspan="3">';
935 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_WAREHOUSE,
'',
'parent', 64, 0, 1);
937 $cats = $c->containing($object->id, Categorie::TYPE_WAREHOUSE);
938 $arrayselected = array();
939 foreach ($cats as $cat) {
940 $arrayselected[] = $cat->id;
942 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
950 print
$form->buttonsSaveCancel();
961 $modulepart =
'stock';
963 if ($action !=
'create' && $action !=
'edit' && $action !=
'delete') {
965 print
'<div class="fichecenter"><div class="fichehalfleft">';
966 print
'<a name="builddoc"></a>';
970 $relativepath = $object->ref.
'/'.$objectref.
'.pdf';
971 $filedir = $conf->stock->dir_output.
'/'.$objectref;
972 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
973 $genallowed = $usercanread;
974 $delallowed = $usercancreate;
975 $modulepart =
'stock';
977 print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0,
'', 0,
'',
'',
'', $object);
978 $somethingshown = $formfile->numoffiles;
980 print
'</div><div class="fichehalfright">';
984 $morehtmlcenter =
'';
988 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
990 $somethingshown =
$formactions->showactions($object,
'stock', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
992 print
'</div></div>';