34require
'../../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/stock.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
44if (isModEnabled(
'project')) {
45 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
59$langs->loadLangs(array(
'products',
'stocks',
'companies',
'categories'));
61$action =
GETPOST(
'action',
'aZ09');
62$cancel =
GETPOST(
'cancel',
'alpha');
64$backtopage =
GETPOST(
'backtopage',
'alpha');
65$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
75$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
76$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
85$hookmanager->initHooks(array(
'warehousecard',
'stocklist',
'globalcard'));
95$extrafields->fetch_name_optionals_label(
$object->table_element);
98if ($id > 0 || !empty($ref)) {
99 $ret =
$object->fetch($id, $ref);
106$usercanread = $user->hasRight(
'stock',
'lire');
107$usercancreate = $user->hasRight(
'stock',
'creer');
108$usercandelete = $user->hasRight(
'stock',
'supprimer');
117$parameters = array(
'context' =>
'warehousecard',
'id' => $id,
'ref' => $ref);
118$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
122if (empty($reshook)) {
123 $backurlforlist = DOL_URL_ROOT.
'/product/stock/list.php';
125 if (empty($backtopage) || ($cancel && empty($id))) {
126 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
127 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
128 $backtopage = $backurlforlist;
130 $backtopage = DOL_URL_ROOT.
'/product/stock/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
136 if (!empty($backtopageforcancel)) {
137 header(
"Location: ".$backtopageforcancel);
139 } elseif (!empty($backtopage)) {
140 header(
"Location: ".$backtopage);
147 if ($action ==
'add' && $user->hasRight(
'stock',
'creer')) {
164 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
175 $categories =
GETPOST(
'categories',
'array');
176 $object->setCategories($categories);
177 if (!empty($backtopage)) {
178 $backtopage = str_replace(
"__ID__", (
string) $id, $backtopage);
179 header(
"Location: ".$backtopage);
182 header(
"Location: card.php?id=".urlencode((
string) ($id)));
191 setEventMessages($langs->trans(
"ErrorWarehouseRefRequired"),
null,
'errors');
197 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'stock',
'supprimer')) {
199 $result =
$object->delete($user);
202 header(
"Location: ".DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1');
211 if ($action ==
'update' && !$cancel && $user->hasRight(
'stock',
'creer')) {
227 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
233 $ret =
$object->update($id, $user);
243 $categories =
GETPOST(
'categories',
'array');
244 $object->setCategories($categories);
251 } elseif ($action ==
'update_extras' && $user->hasRight(
'stock',
'creer')) {
255 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
260 $result =
$object->insertExtraFields();
267 $action =
'edit_extras';
269 } elseif ($action ==
'classin' && $usercancreate) {
274 if ($cancel == $langs->trans(
"Cancel")) {
280 $upload_dir =
$conf->stock->dir_output;
281 $permissiontoadd = $user->hasRight(
'stock',
'creer');
282 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
290$productstatic =
new Product($db);
291$form =
new Form($db);
295if (isModEnabled(
'project')) {
299$title = $langs->trans(
"WarehouseCard");
300if ($action ==
'create') {
301 $title = $langs->trans(
"NewWarehouse");
304$help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
305llxHeader(
"", $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-product page-stock_card');
308if ($action ==
'create') {
313 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">'.
"\n";
314 print
'<input type="hidden" name="token" value="'.newToken().
'">';
315 print
'<input type="hidden" name="action" value="add">';
316 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
320 print
'<table class="border centpercent">';
323 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Ref").
'</td><td><input class="width200" name="libelle" value=""></td></tr>';
325 print
'<tr><td>'.$langs->trans(
"LocationSummary").
'</td><td><input name="lieu" size="40" value="'.(!empty(
$object->lieu) ?
$object->lieu :
'').
'"></td></tr>';
328 print
'<tr><td>'.$langs->trans(
"AddIn").
'</td><td>';
329 print
img_picto(
'',
'stock').$formproduct->selectWarehouses((GETPOSTISSET(
'fk_parent') ?
GETPOSTINT(
'fk_parent') :
'ifone'),
'fk_parent',
'', 1);
333 if (isModEnabled(
'project')) {
334 $langs->load(
'projects');
335 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td colspan="2">';
336 print
img_picto(
'',
'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
337 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>';
342 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
344 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
345 $doleditor =
new DolEditor(
'desc', (!empty(
$object->description) ?
$object->description :
''),
'', 180,
'dolibarr_notes',
'In', false, true, isModEnabled(
'fckeditor'), ROWS_5,
'90%');
346 $doleditor->Create();
349 print
'<tr><td>'.$langs->trans(
'Address').
'</td><td><textarea name="address" class="quatrevingtpercent" rows="3" wrap="soft">';
351 print
'</textarea></td></tr>';
354 print
'<tr><td>'.$langs->trans(
'Zip').
'</td><td>';
355 print $formcompany->select_ziptown((!empty(
$object->zip) ?
$object->zip :
''),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
357 print
'<tr><td>'.$langs->trans(
'Town').
'</td><td>';
358 print $formcompany->select_ziptown((!empty(
$object->town) ?
$object->town :
''),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
362 print
'<tr><td>'.$langs->trans(
'Country').
'</td><td>';
363 print
img_picto(
'',
'globe-americas',
'class="paddingright"');
364 print $form->select_country((!empty(
$object->country_id) ?
$object->country_id : $mysoc->country_code),
'country_id');
366 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
371 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Phone',
'phone',
'',
$object, 0).
'</td><td>';
372 print
img_picto(
'',
'object_phoning',
'class="paddingright"');
373 print
'<input name="phone" size="20" value="'.$object->phone.
'"></td></tr>';
374 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Fax',
'fax',
'',
$object, 0).
'</td>';
376 print
img_picto(
'',
'object_phoning_fax',
'class="paddingright"');
377 print
'<input name="fax" size="20" value="'.$object->fax.
'"></td></tr>';
385 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
386 print
'<select id="warehousestatus" name="statut" class="flat minwidth100">';
387 foreach (
$object->labelStatus as $key => $value) {
389 print
'<option value="'.$key.
'" selected>'.$langs->trans($value).
'</option>';
391 print
'<option value="'.$key.
'">'.$langs->trans($value).
'</option>';
399 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
401 if (isModEnabled(
'category')) {
403 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
404 $cate_arbo = $form->select_all_categories(Categorie::TYPE_WAREHOUSE,
'',
'parent', 64, 0, 3);
405 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
412 print $form->buttonsSaveCancel(
"Create");
417 if ($id > 0 || $ref) {
419 $result =
$object->fetch($id, $ref);
421 print
'No record found';
426 if ($action !=
'edit' && $action !=
're-edit') {
434 if ($action ==
'delete') {
435 $formquestion = array(
436 array(
'type' =>
'other',
'name' =>
'info',
'label' =>
img_warning(
'').$langs->trans(
"WarningThisWIllAlsoDeleteStock"),
'morecss' =>
'warning')
438 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"DeleteAWarehouse"), $langs->trans(
"ConfirmDeleteWarehouse",
$object->label),
"confirm_delete", $formquestion, 0, 2);
442 $parameters = array(
'context' =>
'warehousecard',
'formConfirm' => $formconfirm);
443 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
444 if (empty($reshook)) {
445 $formconfirm .= $hookmanager->resPrint;
446 } elseif ($reshook > 0) {
447 $formconfirm = $hookmanager->resPrint;
454 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
456 $morehtmlref =
'<div class="refidno">';
457 $morehtmlref .= $langs->trans(
"LocationSummary").
' : '.
$object->lieu;
460 if (isModEnabled(
'project')) {
461 $langs->load(
"projects");
462 $morehtmlref .=
'<br>'.img_picto(
'',
'project').
' '.$langs->trans(
'Project').
' ';
463 if ($usercancreate) {
464 if ($action !=
'classify') {
465 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
467 if ($action ==
'classify') {
468 $projectid =
$object->fk_project;
469 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
470 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
471 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
472 $morehtmlref .= $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
473 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
474 $morehtmlref .=
'</form>';
476 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, ($socid > 0 ? $socid : -1),
$object->fk_project,
'none', 0, 0, 0, 1,
'',
'maxwidth300');
479 if (!empty(
$object->fk_project)) {
481 $proj->fetch(
$object->fk_project);
482 $morehtmlref .=
' : '.$proj->getNomUrl(1);
484 $morehtmlref .=
' - '.$proj->title;
491 $morehtmlref .=
'</div>';
494 if ($user->socid && !in_array(
'stock', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
498 dol_banner_tab(
$object,
'ref', $linkback, $shownav,
'ref',
'ref', $morehtmlref);
500 print
'<div class="fichecenter">';
501 print
'<div class="fichehalfleft">';
502 print
'<div class="underbanner clearboth"></div>';
504 print
'<table class="border centpercent tableforfield">';
507 $parentwarehouse =
new Entrepot($db);
508 if (!empty(
$object->fk_parent) && $parentwarehouse->fetch(
$object->fk_parent) > 0) {
509 print
'<tr><td>'.$langs->trans(
"ParentWarehouse").
'</td><td>';
510 print $parentwarehouse->getNomUrl(3);
517 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>'.
dol_htmlentitiesbr(
$object->description).
'</td></tr>';
521 $labelusagestring =
$object->fields[
'warehouse_usage'][
'arrayofkeyval'][empty(
$object->warehouse_usage) ? 1 :
$object->warehouse_usage];
522 $labelusage = $labelusagestring ? $langs->trans($labelusagestring) :
'Unknown';
523 print
'<td class="titlefield tdtop">'.$langs->trans(
"WarehouseUsage").
'</td><td>'.
dol_htmlentitiesbr($labelusage).
'</td></tr>';
526 $calcproductsunique =
$object->nb_different_products();
527 $calcproducts =
$object->nb_products();
530 print
'<tr><td>'.$langs->trans(
"NumberOfDifferentProducts").
'</td><td>';
531 print empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb'];
535 print
'<tr><td>'.$langs->trans(
"NumberOfProducts").
'</td><td>';
536 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
537 print empty($valtoshow) ?
'0' : $valtoshow;
543 print
'<div class="fichehalfright">';
544 print
'<div class="underbanner clearboth"></div>';
546 print
'<table class="border centpercent tableforfield">';
549 print
'<tr><td class="titlefield">'.$langs->trans(
"EstimatedStockValueShort").
'</td><td>';
550 print
price((empty($calcproducts[
'value']) ?
'0' :
price2num($calcproducts[
'value'],
'MT')), 0, $langs, 0, -1, -1,
$conf->currency);
554 if ($user->hasRight(
'stock',
'mouvement',
'lire')) {
555 $sql =
"SELECT max(m.datem) as datem";
556 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
557 $sql .=
" WHERE m.fk_entrepot = ".((int)
$object->id);
558 $resqlbis = $db->query($sql);
560 $obj = $db->fetch_object($resqlbis);
561 $lastmovementdate = $db->jdate($obj->datem);
565 print
'<tr><td>'.$langs->trans(
"LastMovement").
'</td><td>';
566 if ($lastmovementdate) {
568 print
' ';
569 print
img_picto($langs->trans(
'LastMovement'),
'movement',
'class="pictofixedwidth"');
570 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?id='.
$object->id.
'">'.$langs->trans(
"FullList").
'</a>';
572 print $langs->trans(
"None");
578 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
581 if (isModEnabled(
'category')) {
582 print
'<tr><td valign="middle">'.$langs->trans(
"Categories").
'</td><td colspan="3">';
583 print $form->showCategories(
$object->id, Categorie::TYPE_WAREHOUSE, 1);
592 print
'<div class="clearboth"></div>';
600 print
"<div class=\"tabsAction\">\n";
602 $parameters = array(
'context' =>
'warehousecard');
603 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
604 if (empty($reshook)) {
605 if (empty($action) || $action ==
'classin') {
606 if ($user->hasRight(
'stock',
'creer')) {
607 print
'<a class="butAction" href="card.php?action=edit&token='.newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"Modify").
'</a>';
609 print
'<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
"Modify").
'</a>';
612 if ($user->hasRight(
'stock',
'supprimer')) {
613 print
'<a class="butActionDelete" href="card.php?action=delete&token='.newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"Delete").
'</a>';
615 print
'<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
"Delete").
'</a>';
624 $totalarray = array();
625 $totalarray[
'val'] = array();
626 $totalarray[
'pos'] = array();
627 $totalarray[
'type'] = array();
628 $totalarray[
'nbfield'] = 0;
634 print
'<div class="div-table-responsive">';
635 print
'<table class="noborder centpercent liste">';
636 print
'<tr class="liste_titre">';
637 $parameters = array(
'context' =>
'warehousecard',
'totalarray' => &$totalarray);
638 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
639 print $hookmanager->resPrint;
643 print_liste_field_titre(
"NumberOfUnit",
"",
"ps.reel",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
644 $totalarray[
'nbfield'] += 3;
645 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalunit';
646 $totalarray[
'type'][$totalarray[
'nbfield']] =
'stock';
650 $totalarray[
'nbfield']++;
651 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'units';
652 $totalarray[
'type'][$totalarray[
'nbfield']] =
'string';
655 print_liste_field_titre($form->textwithpicto($langs->trans(
"AverageUnitPricePMPShort"), $langs->trans(
"AverageUnitPricePMPDesc")),
"",
"p.pmp",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
656 $totalarray[
'nbfield']++;
658 print_liste_field_titre(
"EstimatedStockValueShort",
"",
"svalue",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
659 $totalarray[
'nbfield']++;
660 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalvalue';
661 $totalarray[
'type'][$totalarray[
'nbfield']] =
'';
665 print_liste_field_titre(
"SellPriceMin",
"",
"p.price",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
666 $totalarray[
'nbfield']++;
669 print_liste_field_titre(
"EstimatedStockValueSellShort",
"",
"",
"&id=".$id,
"",
'', $sortfield, $sortorder,
'right ');
670 $totalarray[
'nbfield']++;
671 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalvaluesell';
672 $totalarray[
'type'][$totalarray[
'nbfield']] =
'';
674 if ($user->hasRight(
'stock',
'mouvement',
'creer')) {
676 $totalarray[
'nbfield']++;
678 if ($user->hasRight(
'stock',
'creer')) {
680 $totalarray[
'nbfield']++;
683 $parameters = array(
'context' =>
'warehousecard',
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'totalarray' => &$totalarray);
684 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
685 print $hookmanager->resPrint;
689 $totalvalue = $totalvaluesell = 0;
692 $separatedPMP =
false;
694 $separatedPMP =
true;
697 $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,";
698 $sql .=
"p.tosell, p.tobuy,";
699 $sql .=
"p.accountancy_code_sell,";
700 $sql .=
"p.accountancy_code_sell_intra,";
701 $sql .=
"p.accountancy_code_sell_export,";
702 $sql .=
"p.accountancy_code_buy,";
703 $sql .=
"p.accountancy_code_buy_intra,";
704 $sql .=
"p.accountancy_code_buy_export,";
705 $sql .=
'p.barcode,';
707 $sql .=
" pa.pmp as ppmp,";
709 $sql .=
" p.pmp as ppmp,";
711 $sql .=
" ps.reel as value";
715 $sql .=
", (ps.reel * p.pmp) as svalue";
717 $parameters = array(
'context' =>
'warehousecard');
718 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
722 $sql .= $hookmanager->resPrint;
723 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_stock as ps, ".MAIN_DB_PREFIX.
"product as p";
726 $sql .=
", ".MAIN_DB_PREFIX.
"product_perentity as pa";
729 $sql .=
" WHERE ps.fk_product = p.rowid";
730 $sql .=
" AND ps.reel <> 0";
731 $sql .=
" AND ps.fk_entrepot = ".((int)
$object->id);
734 $sql .=
" AND pa.fk_product = p.rowid AND pa.entity = ".(int)
$conf->entity;
737 $sql .= $db->order($sortfield, $sortorder);
740 $resql = $db->query($sql);
742 $num = $db->num_rows($resql);
748 $objp = $db->fetch_object($resql);
752 $sql =
"SELECT label";
753 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
754 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
755 $sql .=
" AND lang = '".$db->escape($langs->getDefaultLang()).
"'";
758 $result = $db->query($sql);
760 $objtp = $db->fetch_object($result);
761 if (isset($objtp->label) && $objtp->label !=
'') {
762 $objp->produit = $objtp->label;
768 print
'<tr class="oddeven">';
770 $productstatic->id = $objp->rowid;
771 $productstatic->ref = $objp->ref;
772 $productstatic->label = $objp->produit;
773 $productstatic->type = $objp->type;
774 $productstatic->entity = $objp->entity;
775 $productstatic->status_batch = $objp->tobatch;
777 $productstatic->fk_unit = $objp->fk_unit;
779 $productstatic->status = $objp->tosell;
780 $productstatic->status_buy = $objp->tobuy;
781 $productstatic->barcode = $objp->barcode;
782 $productstatic->accountancy_code_sell = $objp->accountancy_code_sell;
783 $productstatic->accountancy_code_sell_intra = $objp->accountancy_code_sell_intra;
784 $productstatic->accountancy_code_sell_export = $objp->accountancy_code_sell_export;
785 $productstatic->accountancy_code_buy = $objp->accountancy_code_buy;
786 $productstatic->accountancy_code_buy_intra = $objp->accountancy_code_buy_intra;
787 $productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export;
791 print $productstatic->getNomUrl(1,
'stock', 16);
795 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($objp->produit).
'">'.
dol_escape_htmltag($objp->produit).
'</td>';
798 print
'<td class="right">';
800 print empty($valtoshow) ?
'0' : $valtoshow;
802 $totalunit += $objp->value;
806 print
'<td align="left">';
807 if (is_null($productstatic->fk_unit)) {
808 $productstatic->fk_unit = 1;
810 print $langs->trans($productstatic->getLabelOfUnit());
815 print
'<td class="right nowraponall">'.price(
price2num($objp->ppmp,
'MU')).
'</td>';
818 print
'<td class="right amount nowraponall">'.price(
price2num($objp->ppmp * $objp->value,
'MT')).
'</td>';
819 $totalvalue +=
price2num($objp->ppmp * $objp->value,
'MT');
823 $pricemin = $objp->price;
824 print
'<td class="right">';
828 print
'<td class="right">';
832 $totalvaluesell +=
price2num($pricemin * $objp->value,
'MT');
835 if ($user->hasRight(
'stock',
'mouvement',
'creer')) {
836 print
'<td class="center"><a href="'.DOL_URL_ROOT.
'/product/stock/product.php?dwid='.
$object->id.
'&id='.$objp->rowid.
'&action=transfert&token='.
newToken().
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?id='.$id).
'">';
837 print
img_picto($langs->trans(
"TransferStock"),
'add',
'class="hideonsmartphone pictofixedwidth" style="color: #a69944"');
838 print $langs->trans(
"TransferStock");
843 if ($user->hasRight(
'stock',
'creer')) {
844 print
'<td class="center"><a href="'.DOL_URL_ROOT.
'/product/stock/product.php?dwid='.
$object->id.
'&id='.$objp->rowid.
'&action=correction&token='.
newToken().
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?id='.$id).
'">';
845 print
img_picto($langs->trans(
"CorrectStock"),
'add',
'class="hideonsmartphone pictofixedwidth" style="color: #a69944"');
846 print $langs->trans(
"CorrectStock");
850 $parameters = array(
'context' =>
'warehousecard',
'obj' => $objp,
'totalarray' => &$totalarray);
851 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
852 print $hookmanager->resPrint;
859 $units = $productstatic->fk_unit;
860 } elseif ($productstatic->fk_unit != $units) {
869 $totalarray[
'val'][
'totalunit'] = $totalunit;
870 $totalarray[
'val'][
'totalvalue'] =
price2num($totalvalue,
'MT');
871 $totalarray[
'val'][
'totalvaluesell'] =
price2num($totalvaluesell,
'MT');
872 $totalarray[
'val'][
'units'] = $langs->trans($productstatic->getLabelOfUnit());
874 $parameters = array(
'context' =>
'warehousecard',
'totalarray' => &$totalarray);
876 $reshook = $hookmanager->executeHooks(
'printFieldListTotal', $parameters,
$object);
882 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
892 if ($action ==
'edit' || $action ==
're-edit') {
893 $langs->trans(
"WarehouseEdit");
895 print
'<form action="card.php" method="POST">';
896 print
'<input type="hidden" name="token" value="'.newToken().
'">';
897 print
'<input type="hidden" name="action" value="update">';
898 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
904 print
'<table class="border centpercent">';
907 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Ref").
'</td><td><input name="libelle" size="20" value="'.
$object->label.
'"></td></tr>';
909 print
'<tr><td>'.$langs->trans(
"LocationSummary").
'</td><td><input name="lieu" class="minwidth300" value="'.
$object->lieu.
'"></td></tr>';
912 print
'<tr><td>'.$langs->trans(
"AddIn").
'</td><td>';
913 print $formproduct->selectWarehouses(
$object->fk_parent,
'fk_parent',
'', 1);
917 if (isModEnabled(
'project')) {
918 $projectid =
$object->fk_project;
919 $langs->load(
'projects');
920 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td colspan="2">';
921 print
img_picto(
'',
'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
922 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>';
927 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
929 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
930 $doleditor =
new DolEditor(
'desc',
$object->description,
'', 180,
'dolibarr_notes',
'In',
false,
true, isModEnabled(
'fckeditor'), ROWS_5,
'90%');
931 $doleditor->Create();
934 print
'<tr><td>'.$langs->trans(
'Address').
'</td><td><textarea name="address" class="quatrevingtpercent" rows="3" wrap="soft">';
936 print
'</textarea></td></tr>';
939 print
'<tr><td>'.$langs->trans(
'Zip').
'</td><td>';
940 print $formcompany->select_ziptown(
$object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
942 print
'<tr><td>'.$langs->trans(
'Town').
'</td><td>';
943 print $formcompany->select_ziptown(
$object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
947 print
'<tr><td>'.$langs->trans(
'Country').
'</td><td>';
948 print
img_picto(
'',
'globe-americas',
'class="paddingright"');
949 print $form->select_country(
$object->country_id ?
$object->country_id : $mysoc->country_code,
'country_id');
951 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
956 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Phone',
'phone',
'',
$object, 0).
'</td><td>';
957 print
img_picto(
'',
'object_phoning',
'class="paddingright"');
958 print
'<input name="phone" size="20" value="'.$object->phone.
'"></td></tr>';
959 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Fax',
'fax',
'',
$object, 0).
'</td><td>';
960 print
img_picto(
'',
'object_phoning_fax',
'class="paddingright"');
961 print
'<input name="fax" size="20" value="'.$object->fax.
'"></td></tr>';
964 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
965 print
'<select id="warehousestatus" name="statut" class="flat">';
966 foreach (
$object->labelStatus as $key => $value) {
968 print
'<option value="'.$key.
'" selected>'.$langs->trans($value).
'</option>';
970 print
'<option value="'.$key.
'">'.$langs->trans($value).
'</option>';
979 $parameters = array(
'context' =>
'warehousecard',
'colspan' =>
' colspan="3"',
'cols' =>
'3');
980 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
981 print $hookmanager->resPrint;
982 if (empty($reshook)) {
983 print
$object->showOptionals($extrafields,
'edit', $parameters);
987 if (isModEnabled(
'category')) {
988 print
'<tr><td class="tdtop">'.$langs->trans(
"Categories").
'</td><td colspan="3">';
989 $cate_arbo = $form->select_all_categories(Categorie::TYPE_WAREHOUSE,
'',
'parent', 64, 0, 3);
991 $cats = $c->containing(
$object->id, Categorie::TYPE_WAREHOUSE);
992 $arrayselected = array();
993 foreach ($cats as $cat) {
994 $arrayselected[] = $cat->id;
996 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1004 print $form->buttonsSaveCancel();
1015$modulepart =
'stock';
1017if ($action !=
'create' && $action !=
'edit' && $action !=
'delete') {
1019 print
'<div class="fichecenter"><div class="fichehalfleft">';
1020 print
'<a name="builddoc"></a>';
1024 $relativepath =
$object->ref.
'/'.$objectref.
'.pdf';
1025 $filedir =
$conf->stock->dir_output.
'/'.$objectref;
1026 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
1027 $genallowed = $usercanread;
1028 $delallowed = $usercancreate;
1029 $modulepart =
'stock';
1031 print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 0, 0, 0, 28, 0,
'', 0,
'',
'',
'',
$object);
1032 $somethingshown = $formfile->numoffiles;
1034 print
'</div><div class="fichehalfright">';
1038 $morehtmlcenter =
'';
1042 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1044 $somethingshown = $formactions->showactions(
$object,
'stock', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
1046 print
'</div></div>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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_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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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'.
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.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify 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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.