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';
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'));
90$usercancreadsupplierprice =
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') ? $user->hasRight(
'product',
'product_advance',
'read_supplier_prices') : $user->hasRight(
'product',
'read');
96$extrafields->fetch_name_optionals_label(
$object->table_element);
99if ($id > 0 || !empty($ref)) {
100 $ret =
$object->fetch($id, $ref);
107$usercanread = $user->hasRight(
'stock',
'lire');
108$usercancreate = $user->hasRight(
'stock',
'creer');
109$usercandelete = $user->hasRight(
'stock',
'supprimer');
110$permissiontoeditextra = $usercancreate;
111if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
113 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
123$parameters = array(
'context' =>
'warehousecard',
'id' => $id,
'ref' => $ref);
124$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
126 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
128if (empty($reshook)) {
129 $backurlforlist = DOL_URL_ROOT.
'/product/stock/list.php';
131 if (empty($backtopage) || ($cancel && empty($id))) {
132 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
133 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
134 $backtopage = $backurlforlist;
136 $backtopage = DOL_URL_ROOT.
'/product/stock/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
142 if (!empty($backtopageforcancel)) {
143 header(
"Location: ".$backtopageforcancel);
145 } elseif (!empty($backtopage)) {
146 header(
"Location: ".$backtopage);
153 if ($action ==
'add' && $user->hasRight(
'stock',
'creer')) {
170 $ret = $extrafields->setOptionalsFromPost(
null, $object);
179 setEventMessages($langs->trans(
"RecordSaved"),
null,
'mesgs');
181 $categories =
GETPOST(
'categories',
'array:int');
182 $object->setCategories($categories);
183 if (!empty($backtopage)) {
184 $backtopage = str_replace(
"__ID__", (
string) $id, $backtopage);
185 header(
"Location: ".$backtopage);
188 header(
"Location: card.php?id=".urlencode((
string) ($id)));
197 setEventMessages($langs->trans(
"ErrorWarehouseRefRequired"),
null,
'errors');
203 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'stock',
'supprimer')) {
206 $result =
$object->delete($user);
208 setEventMessages($langs->trans(
"RecordDeleted"),
null,
'mesgs');
209 header(
"Location: ".DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1');
218 if ($action ==
'update' && !$cancel && $user->hasRight(
'stock',
'creer')) {
234 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
240 $ret =
$object->update($id, $user);
250 $categories =
GETPOST(
'categories',
'array:int');
251 $object->setCategories($categories);
258 } elseif ($action ==
'update_extras' && $permissiontoeditextra) {
261 $attribute_name =
GETPOST(
'attribute',
'aZ09');
264 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
270 $result =
$object->updateExtraField($attribute_name,
'PRODUCT_MODIFY');
278 $action =
'edit_extras';
280 } elseif ($action ==
'classin' && $usercancreate) {
285 if ($cancel == $langs->trans(
"Cancel")) {
290 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
293 $upload_dir =
$conf->stock->dir_output;
294 $permissiontoadd = $user->hasRight(
'stock',
'creer');
295 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
303$productstatic =
new Product($db);
304$form =
new Form($db);
313$title = $langs->trans(
"WarehouseCard");
314if ($action ==
'create') {
315 $title = $langs->trans(
"NewWarehouse");
318$help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
319llxHeader(
"", $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-product page-stock_card');
322if ($action ==
'create') {
327 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">'.
"\n";
328 print
'<input type="hidden" name="token" value="'.newToken().
'">';
329 print
'<input type="hidden" name="action" value="add">';
330 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
334 print
'<table class="border centpercent">';
337 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Ref").
'</td><td><input class="width200" name="libelle" value=""></td></tr>';
339 print
'<tr><td>'.$langs->trans(
"LocationSummary").
'</td><td><input name="lieu" size="40" value="'.(!empty(
$object->lieu) ?
$object->lieu :
'').
'"></td></tr>';
342 print
'<tr><td>'.$langs->trans(
"AddIn").
'</td><td>';
343 print img_picto(
'',
'stock',
'class="pictofixedwidth"').$formproduct->selectWarehouses((
GETPOSTISSET(
'fk_parent') ?
GETPOSTINT(
'fk_parent') :
'ifone'),
'fk_parent',
'', 1);
348 $langs->load(
'projects');
349 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td colspan="2">';
350 print img_picto(
'',
'project',
'class="pictofixedwidth"').$formproject->select_projects(($socid > 0 ? $socid : -1), (string) $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
351 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>';
356 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
358 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
359 $doleditor =
new DolEditor(
'desc', (!empty(
$object->description) ?
$object->description :
''),
'', 180,
'dolibarr_notes',
'In', false, true,
isModEnabled(
'fckeditor'), ROWS_5,
'90%');
360 $doleditor->Create();
363 print
'<tr><td>'.$langs->trans(
'Address').
'</td><td><textarea name="address" class="quatrevingtpercent" rows="3" wrap="soft">';
365 print
'</textarea></td></tr>';
368 print
'<tr><td>'.$langs->trans(
'Zip').
'</td><td>';
369 print $formcompany->select_ziptown((!empty(
$object->zip) ?
$object->zip :
''),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
371 print
'<tr><td>'.$langs->trans(
'Town').
'</td><td>';
372 print $formcompany->select_ziptown((!empty(
$object->town) ?
$object->town :
''),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
376 print
'<tr><td>'.$langs->trans(
'Country').
'</td><td>';
377 print img_picto(
'',
'globe-americas',
'class="pictofixedwidth"');
378 print $form->select_country((!empty(
$object->country_id) ?
$object->country_id :
$mysoc->country_code),
'country_id');
380 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
385 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Phone',
'phone',
'', $object, 0).
'</td><td>';
386 print $form->showPhoneInput(
$object->phone,
'phone',
$object->country_id,
'object_phoning',
'maxwidth150 widthcentpercentminusx');
388 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td>';
390 print $form->showPhoneInput(
$object->fax,
'fax',
$object->country_id,
'object_phoning_fax',
'maxwidth150 widthcentpercentminusx');
399 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
400 print
'<select id="warehousestatus" name="statut" class="flat minwidth100">';
401 foreach (
$object->labelStatus as $key => $value) {
403 print
'<option value="'.$key.
'" selected>'.$langs->trans($value).
'</option>';
405 print
'<option value="'.$key.
'">'.$langs->trans($value).
'</option>';
413 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
417 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
418 print $form->selectCategories(Categorie::TYPE_WAREHOUSE,
'categories', $object);
425 print $form->buttonsSaveCancel(
"Create");
430 if ($id > 0 || $ref) {
432 $result =
$object->fetch($id, $ref);
434 print
'No record found';
439 if ($action !=
'edit' && $action !=
're-edit') {
447 if ($action ==
'delete') {
448 $formquestion = array(
449 array(
'type' =>
'other',
'name' =>
'info',
'label' => img_warning(
'').$langs->trans(
"WarningThisWIllAlsoDeleteStock"),
'morecss' =>
'warning')
451 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"DeleteAWarehouse"), $langs->trans(
"ConfirmDeleteWarehouse",
$object->label),
"confirm_delete", $formquestion, 0, 2);
455 $parameters = array(
'context' =>
'warehousecard',
'formConfirm' => $formconfirm);
456 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
457 if (empty($reshook)) {
458 $formconfirm .= $hookmanager->resPrint;
459 } elseif ($reshook > 0) {
460 $formconfirm = $hookmanager->resPrint;
467 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
469 $morehtmlref =
'<div class="refidno">';
470 $morehtmlref .= $langs->trans(
"LocationSummary").
' : '.
$object->lieu;
474 $langs->load(
"projects");
475 $morehtmlref .=
'<br>'.img_picto(
'',
'project',
'class="pictofixedwidth"').
' '.$langs->trans(
'Project').
' ';
476 if ($usercancreate) {
477 if ($action !=
'classify') {
478 $morehtmlref .=
'<a class="editfielda" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'classify',
'id' =>
$object->id],
true).
'">'.img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
480 if ($action ==
'classify') {
481 $projectid =
$object->fk_project;
482 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
483 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
484 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
485 $morehtmlref .= $formproject->select_projects(($socid > 0 ? $socid : -1), (string) $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
486 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
487 $morehtmlref .=
'</form>';
489 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, ($socid > 0 ? $socid : -1), (string)
$object->fk_project,
'none', 0, 0, 0, 1,
'',
'maxwidth300');
492 if (!empty(
$object->fk_project)) {
494 $proj->fetch(
$object->fk_project);
495 $morehtmlref .=
' : '.$proj->getNomUrl(1);
497 $morehtmlref .=
' - '.$proj->title;
504 $morehtmlref .=
'</div>';
507 if ($user->socid && !in_array(
'stock', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
511 dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref',
'ref', $morehtmlref);
513 print
'<div class="fichecenter">';
514 print
'<div class="fichehalfleft">';
515 print
'<div class="underbanner clearboth"></div>';
517 print
'<table class="border centpercent tableforfield">';
520 $parentwarehouse =
new Entrepot($db);
521 if (!empty(
$object->fk_parent) && $parentwarehouse->fetch(
$object->fk_parent) > 0) {
522 print
'<tr><td>'.$langs->trans(
"ParentWarehouse").
'</td><td>';
523 print $parentwarehouse->getNomUrl(3);
530 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>'.
dol_htmlentitiesbr(
$object->description).
'</td></tr>';
534 $labelusagestring =
$object->fields[
'warehouse_usage'][
'arrayofkeyval'][empty(
$object->warehouse_usage) ? 1 :
$object->warehouse_usage];
535 $labelusage = $labelusagestring ? $langs->trans($labelusagestring) :
'Unknown';
536 print
'<td class="titlefield tdtop">'.$langs->trans(
"WarehouseUsage").
'</td><td>'.
dol_htmlentitiesbr($labelusage).
'</td></tr>';
539 $calcproductsunique =
$object->nb_different_products();
540 $calcproducts =
$object->nb_products();
543 print
'<tr><td>'.$langs->trans(
"NumberOfDifferentProducts").
'</td><td>';
544 print empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb'];
548 print
'<tr><td>'.$langs->trans(
"NumberOfProducts").
'</td><td>';
549 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
550 print empty($valtoshow) ?
'0' : $valtoshow;
556 print
'<div class="fichehalfright">';
557 print
'<div class="underbanner clearboth"></div>';
559 print
'<table class="border centpercent tableforfield">';
562 if ($usercancreadsupplierprice) {
563 print
'<tr><td class="titlefield">'.$langs->trans(
"EstimatedStockValueShort").
'</td><td>';
564 print
price((empty($calcproducts[
'value']) ?
'0' :
price2num($calcproducts[
'value'],
'MT')), 0, $langs, 0, -1, -1,
$conf->currency);
569 if ($user->hasRight(
'stock',
'mouvement',
'lire')) {
570 $sql =
"SELECT max(m.datem) as datem";
571 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
572 $sql .=
" WHERE m.fk_entrepot = ".((int)
$object->id);
573 $lastmovementdate = 0;
574 $resqlbis = $db->query($sql);
576 $obj = $db->fetch_object($resqlbis);
577 $lastmovementdate = $db->jdate($obj->datem);
579 dol_print_error($db);
581 print
'<tr><td>'.$langs->trans(
"LastMovement").
'</td><td>';
582 if ($lastmovementdate) {
584 print
' ';
585 print img_picto($langs->trans(
'LastMovement'),
'movement',
'class="pictofixedwidth"');
586 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?id='.
$object->id.
'">'.$langs->trans(
"FullList").
'</a>';
588 print $langs->trans(
"None");
594 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
598 print
'<tr><td valign="middle">'.$langs->trans(
"Categories").
'</td><td colspan="3">';
599 print $form->showCategories(
$object->id, Categorie::TYPE_WAREHOUSE, 1);
608 print
'<div class="clearboth"></div>';
616 print
"<div class=\"tabsAction\">\n";
618 $parameters = array(
'context' =>
'warehousecard');
619 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
620 if (empty($reshook)) {
621 if (empty($action) || $action ==
'classin') {
622 if ($user->hasRight(
'stock',
'creer')) {
623 print
'<a class="butAction" href="card.php?action=edit&token='.newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"Modify").
'</a>';
625 print
'<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
"Modify").
'</a>';
628 if ($user->hasRight(
'stock',
'supprimer')) {
629 print dolGetButtonAction($langs->trans(
"Delete"), $langs->trans(
"Delete"),
'delete',
'card.php?action=delete&token='.newToken().
'&id='.
$object->id,
'',
true, array(
'attr' => array(
'class' =>
'reposition'))).
"\n";
631 print
'<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
"Delete").
'</a>';
640 $totalarray = array();
641 $totalarray[
'val'] = array();
642 $totalarray[
'pos'] = array();
643 $totalarray[
'type'] = array();
644 $totalarray[
'nbfield'] = 0;
650 print
'<div class="div-table-responsive">';
651 print
'<table class="noborder centpercent liste">';
652 print
'<tr class="liste_titre">';
653 $parameters = array(
'context' =>
'warehousecard',
'totalarray' => &$totalarray);
654 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
655 print $hookmanager->resPrint;
660 $totalarray[
'nbfield'] += 3;
661 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalunit';
662 $totalarray[
'type'][$totalarray[
'nbfield']] =
'stock';
666 $totalarray[
'nbfield']++;
667 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'units';
668 $totalarray[
'type'][$totalarray[
'nbfield']] =
'string';
670 if ($usercancreadsupplierprice) {
671 print_liste_field_titre($form->textwithpicto($langs->trans(
"AverageUnitPricePMPShort"), $langs->trans(
"AverageUnitPricePMPDesc")),
"",
"p.pmp",
"",
"&id=".$object->id,
'', $sortfield, $sortorder,
'right ');
672 $totalarray[
'nbfield']++;
675 $totalarray[
'nbfield']++;
676 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalvalue';
677 $totalarray[
'type'][$totalarray[
'nbfield']] =
'';
682 $totalarray[
'nbfield']++;
686 $totalarray[
'nbfield']++;
687 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalvaluesell';
688 $totalarray[
'type'][$totalarray[
'nbfield']] =
'';
690 if ($user->hasRight(
'stock',
'mouvement',
'creer')) {
692 $totalarray[
'nbfield']++;
694 if ($user->hasRight(
'stock',
'creer')) {
696 $totalarray[
'nbfield']++;
699 $parameters = array(
'context' =>
'warehousecard',
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'totalarray' => &$totalarray);
700 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
701 print $hookmanager->resPrint;
705 $totalvalue = $totalvaluesell = 0;
708 $separatedPMP =
false;
710 $separatedPMP =
true;
713 $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,";
714 $sql .=
"p.tosell, p.tobuy,";
715 $sql .=
"p.accountancy_code_sell,";
716 $sql .=
"p.accountancy_code_sell_intra,";
717 $sql .=
"p.accountancy_code_sell_export,";
718 $sql .=
"p.accountancy_code_buy,";
719 $sql .=
"p.accountancy_code_buy_intra,";
720 $sql .=
"p.accountancy_code_buy_export,";
721 $sql .=
'p.barcode,';
726 $sql .=
" COALESCE(pa.pmp, p.pmp) as ppmp,";
728 $sql .=
" p.pmp as ppmp,";
730 $sql .=
" ps.reel as value";
737 $sql .=
", (ps.reel * COALESCE(pa.pmp, p.pmp)) as svalue";
739 $sql .=
", (ps.reel * p.pmp) as svalue";
742 $parameters = array(
'context' =>
'warehousecard');
743 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
747 $sql .= $hookmanager->resPrint;
748 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_stock as ps, ".MAIN_DB_PREFIX.
"product as p";
753 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = ".((int)
$conf->entity);
755 $parameters = array(
'context' =>
'warehousecard');
756 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters);
760 $sql .= $hookmanager->resPrint;
762 $sql .=
" WHERE ps.fk_product = p.rowid";
763 $sql .=
" AND ps.reel <> 0";
764 $sql .=
" AND ps.fk_entrepot = ".((int)
$object->id);
766 $parameters = array(
'context' =>
'warehousecard');
767 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
771 $sql .= $hookmanager->resPrint;
773 $sql .= $db->order($sortfield, $sortorder);
776 $resql = $db->query($sql);
778 $num = $db->num_rows($resql);
784 $objp = $db->fetch_object($resql);
788 $sql =
"SELECT label";
789 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
790 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
791 $sql .=
" AND lang = '".$db->escape($langs->getDefaultLang()).
"'";
794 $result = $db->query($sql);
796 $objtp = $db->fetch_object($result);
797 if (isset($objtp->label) && $objtp->label !=
'') {
798 $objp->produit = $objtp->label;
804 print
'<tr class="oddeven">';
806 $productstatic->id = $objp->rowid;
807 $productstatic->ref = $objp->ref;
808 $productstatic->label = $objp->produit;
809 $productstatic->type = $objp->type;
810 $productstatic->entity = $objp->entity;
811 $productstatic->status_batch = $objp->tobatch;
813 $productstatic->fk_unit = $objp->fk_unit;
815 $productstatic->status = $objp->tosell;
816 $productstatic->status_buy = $objp->tobuy;
817 $productstatic->barcode = $objp->barcode;
818 $productstatic->accountancy_code_sell = $objp->accountancy_code_sell;
819 $productstatic->accountancy_code_sell_intra = $objp->accountancy_code_sell_intra;
820 $productstatic->accountancy_code_sell_export = $objp->accountancy_code_sell_export;
821 $productstatic->accountancy_code_buy = $objp->accountancy_code_buy;
822 $productstatic->accountancy_code_buy_intra = $objp->accountancy_code_buy_intra;
823 $productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export;
827 print $productstatic->getNomUrl(1,
'stock', 16);
831 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($objp->produit).
'">'.
dol_escape_htmltag($objp->produit).
'</td>';
834 print
'<td class="right">';
836 print empty($valtoshow) ?
'0' : $valtoshow;
838 $totalunit += $objp->value;
842 print
'<td align="left">';
843 if (is_null($productstatic->fk_unit)) {
844 $productstatic->fk_unit = 1;
846 print $productstatic->getLabelOfUnit(
'long', $langs);
849 if ($usercancreadsupplierprice) {
851 print
'<td class="right nowraponall">'.price(
price2num($objp->ppmp,
'MU')).
'</td>';
854 print
'<td class="right amount nowraponall">'.price(
price2num($objp->ppmp * $objp->value,
'MT')).
'</td>';
855 $totalvalue +=
price2num($objp->ppmp * $objp->value,
'MT');
860 $pricemin = $objp->price;
861 print
'<td class="right">';
865 print
'<td class="right">';
869 $totalvaluesell +=
price2num($pricemin * $objp->value,
'MT');
872 if ($user->hasRight(
'stock',
'mouvement',
'creer')) {
873 print
'<td class="center"><a href="'.DOL_URL_ROOT.
'/product/stock/product.php?dwid='.
$object->id.
'&id='.$objp->rowid.
'&action=transfer&token='.
newToken().
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?id='.$id).
'">';
874 print img_picto($langs->trans(
"TransferStock"),
'add',
'class="hideonsmartphone pictofixedwidth" style="color: #a69944"');
875 print $langs->trans(
"TransferStock");
880 if ($user->hasRight(
'stock',
'creer')) {
881 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).
'">';
882 print img_picto($langs->trans(
"CorrectStock"),
'add',
'class="hideonsmartphone pictofixedwidth" style="color: #a69944"');
883 print $langs->trans(
"CorrectStock");
887 $parameters = array(
'context' =>
'warehousecard',
'obj' => $objp,
'totalarray' => &$totalarray);
888 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
889 print $hookmanager->resPrint;
896 $units = $productstatic->fk_unit;
897 } elseif ($productstatic->fk_unit != $units) {
906 $totalarray[
'val'][
'totalunit'] = $totalunit;
907 $totalarray[
'val'][
'totalvalue'] =
price2num($totalvalue,
'MT');
908 $totalarray[
'val'][
'totalvaluesell'] =
price2num($totalvaluesell,
'MT');
909 $totalarray[
'val'][
'units'] = $productstatic->getLabelOfUnit(
'long', $langs);
911 $parameters = array(
'context' =>
'warehousecard',
'totalarray' => &$totalarray);
913 $reshook = $hookmanager->executeHooks(
'printFieldListTotal', $parameters, $object);
915 setEventMessages($hookmanager->error, $hookmanager->errors);
919 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
921 dol_print_error($db);
929 if ($action ==
'edit' || $action ==
're-edit') {
930 $langs->trans(
"WarehouseEdit");
932 print
'<form action="card.php" method="POST">';
933 print
'<input type="hidden" name="token" value="'.newToken().
'">';
934 print
'<input type="hidden" name="action" value="update">';
935 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
941 print
'<table class="border centpercent">';
944 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Ref").
'</td><td><input name="libelle" size="20" value="'.
$object->label.
'"></td></tr>';
946 print
'<tr><td>'.$langs->trans(
"LocationSummary").
'</td><td><input name="lieu" class="minwidth300" value="'.
$object->lieu.
'"></td></tr>';
949 print
'<tr><td>'.$langs->trans(
"AddIn").
'</td><td>';
950 print $formproduct->selectWarehouses(
$object->fk_parent,
'fk_parent',
'', 1);
955 $projectid =
$object->fk_project;
956 $langs->load(
'projects');
957 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td colspan="2">';
958 print img_picto(
'',
'project',
'class="pictofixedwidth"').$formproject->select_projects(($socid > 0 ? $socid : -1), (string) $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
959 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>';
964 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
966 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
967 $doleditor =
new DolEditor(
'desc',
$object->description,
'', 180,
'dolibarr_notes',
'In',
false,
true,
isModEnabled(
'fckeditor'), ROWS_5,
'90%');
968 $doleditor->Create();
971 print
'<tr><td>'.$langs->trans(
'Address').
'</td><td><textarea name="address" class="quatrevingtpercent" rows="3" wrap="soft">';
973 print
'</textarea></td></tr>';
976 print
'<tr><td>'.$langs->trans(
'Zip').
'</td><td>';
977 print $formcompany->select_ziptown(
$object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
979 print
'<tr><td>'.$langs->trans(
'Town').
'</td><td>';
980 print $formcompany->select_ziptown(
$object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
984 print
'<tr><td>'.$langs->trans(
'Country').
'</td><td>';
985 print img_picto(
'',
'globe-americas',
'class="pictofixedwidth"');
986 print $form->select_country(
$object->country_id ?
$object->country_id :
$mysoc->country_code,
'country_id');
988 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
993 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Phone',
'phone',
'', $object, 0).
'</td><td>';
994 print $form->showPhoneInput(
$object->phone,
'phone',
$object->country_id,
'object_phoning',
'maxwidth150 widthcentpercentminusx');
996 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td><td>';
997 print $form->showPhoneInput(
$object->fax,
'fax',
$object->country_id,
'object_phoning_fax',
'maxwidth150 widthcentpercentminusx');
1001 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
1002 print
'<select id="warehousestatus" name="statut" class="flat">';
1003 foreach (
$object->labelStatus as $key => $value) {
1004 if ($key ==
$object->statut) {
1005 print
'<option value="'.$key.
'" selected>'.$langs->trans($value).
'</option>';
1007 print
'<option value="'.$key.
'">'.$langs->trans($value).
'</option>';
1016 $parameters = array(
'context' =>
'warehousecard',
'colspan' =>
' colspan="3"',
'cols' =>
'3');
1017 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1018 print $hookmanager->resPrint;
1019 if (empty($reshook)) {
1020 print
$object->showOptionals($extrafields,
'edit', $parameters);
1025 print
'<tr><td class="tdtop">'.$langs->trans(
"Categories").
'</td><td colspan="3">';
1026 print $form->selectCategories(Categorie::TYPE_WAREHOUSE,
'categories', $object);
1034 print $form->buttonsSaveCancel();
1045$modulepart =
'stock';
1047if ($action !=
'create' && $action !=
'edit' && $action !=
'delete') {
1049 print
'<div class="fichecenter"><div class="fichehalfleft">';
1050 print
'<a name="builddoc"></a>';
1054 $relativepath =
$object->ref.
'/'.$objectref.
'.pdf';
1055 $filedir =
$conf->stock->dir_output.
'/'.$objectref;
1056 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
1057 $genallowed = $usercanread;
1058 $delallowed = $usercancreate;
1059 $modulepart =
'stock';
1061 print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 0, 0, 0, 28, 0,
'',
'',
'',
'',
'', $object);
1062 $somethingshown = $formfile->numoffiles;
1064 print
'</div><div class="fichehalfright">';
1068 $morehtmlcenter =
'';
1072 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1074 $somethingshown = $formactions->showactions($object,
'stock', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
1076 print
'</div></div>';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='', $placeholder='')
Convert a html select field into an ajax combobox.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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 a WYSIWYG editor.
Class to manage warehouses.
Class to manage products or services.
Class to manage projects.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.
stock_prepare_head($object)
Prepare array with list of tabs.