25require
'../../main.inc.php';
26require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/product/inventory/class/inventory.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/product/inventory/lib/inventory.lib.php';
33$langs->loadLangs(array(
"stocks",
"other"));
38$action =
GETPOST(
'action',
'aZ09');
39$confirm =
GETPOST(
'confirm',
'alpha');
40$cancel =
GETPOST(
'cancel',
'aZ09');
41$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'inventorycard';
42$backtopage =
GETPOST(
'backtopage',
'alpha');
43$include_sub_warehouse = !empty(
GETPOST(
'include_sub_warehouse')) ?
GETPOST(
'include_sub_warehouse') : 0;
48 $result =
restrictedArea($user,
'stock', $id,
'',
'inventory_advance');
55$includedocgeneration =
false;
56$diroutputmassaction =
null;
58$hookmanager->initHooks(array(
'inventorycard',
'globalcard'));
61$extrafields->fetch_name_optionals_label(
$object->table_element);
63$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
66$search_all =
GETPOST(
"search_all",
'alpha');
68foreach (
$object->fields as $key => $val) {
69 if (
GETPOST(
'search_'.$key,
'alpha')) {
70 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
74if (empty($action) && empty($id) && empty($ref)) {
79include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
87 $permissiontoread = $user->hasRight(
'stock',
'lire');
88 $permissiontoadd = $user->hasRight(
'stock',
'creer');
89 $permissiontodelete = $user->hasRight(
'stock',
'supprimer');
90 $permissionnote = $user->hasRight(
'stock',
'creer');
91 $permissiondellink = $user->hasRight(
'stock',
'creer');
92 $upload_dir = $conf->stock->multidir_output[isset(
$object->entity) ?
$object->entity : 1];
94 $permissiontoread = $user->hasRight(
'stock',
'inventory_advance',
'read');
95 $permissiontoadd = $user->hasRight(
'stock',
'inventory_advance',
'write');
96 $permissiontodelete = $user->hasRight(
'stock',
'inventory_advance',
'delete');
97 $permissionnote = $user->hasRight(
'stock',
'inventory_advance',
'write');
98 $permissiondellink = $user->hasRight(
'stock',
'inventory_advance',
'write');
99 $upload_dir = $conf->stock->multidir_output[isset(
$object->entity) ?
$object->entity : 1];
107$parameters = array();
108$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
113if (empty($reshook)) {
114 $savaction = $action;
117 $backurlforlist = DOL_URL_ROOT.
'/product/inventory/list.php';
119 if (empty($backtopage) || ($cancel && empty($id))) {
120 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
121 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
122 $backtopage = $backurlforlist;
124 $backtopage =
dol_buildpath(
'/product/inventory/card.php', 1).
'?id='.($id > 0 ? $id :
'__ID__');
128 $triggermodname =
'STOCK_INVENTORY_MODIFY';
131 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
134 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
137 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
143 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
149 if ($action ==
'classin' && $permissiontoadd) {
154 $triggersendname =
'INVENTORY_SENTBYMAIL';
155 $autocopy =
'MAIN_MAIL_AUTOCOPY_INVENTORY_TO';
156 $trackid =
'stockinv'.$object->id;
157 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
159 if (!$error && $savaction ==
'confirm_validate' && $action ==
'' &&
$object->id > 0) {
161 header(
"Location: ".DOL_URL_ROOT.
'/product/inventory/inventory.php?id='.
$object->id);
173$form =
new Form($db);
177$title = $langs->trans(
"Inventory");
179$help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks|DE:Modul_Bestände';
181llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-product page-inventory_card');
186if ($action ==
'create') {
189 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
190 print
'<input type="hidden" name="token" value="'.newToken().
'">';
191 print
'<input type="hidden" name="action" value="add">';
193 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
195 if (!empty($backtopageforcancel)) {
196 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
201 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
204 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
207 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
211 print
'</table>'.
"\n";
215 print $form->buttonsSaveCancel(
"Create");
223if (($id || $ref) && $action ==
'edit') {
226 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
227 print
'<input type="hidden" name="token" value="'.newToken().
'">';
228 print
'<input type="hidden" name="action" value="update">';
229 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
231 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
233 if ($backtopageforcancel) {
234 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
239 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
242 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
245 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
251 print $form->buttonsSaveCancel();
257if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
258 $res =
$object->fetch_optionals();
267 if ($action ==
'setdraft') {
268 $text = $langs->trans(
'ConfirmSetToDraftInventory',
$object->ref);
269 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'SetToDraft'), $text,
'confirm_setdraft',
'', 0, 1, 220);
272 if ($action ==
'delete') {
273 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteInventory'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
277 if ($action ==
'clone') {
279 $formquestion = array();
280 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
284 if ($action ==
'xxx') {
285 $formquestion = array();
296 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
300 if ($action ==
'validate') {
301 $form =
new Form($db);
304 $formquestion = array(
305 array(
'type' =>
'checkbox',
'name' =>
'include_sub_warehouse',
'label' => $langs->trans(
"IncludeSubWarehouse"),
'value' => 1,
'size' =>
'10'),
307 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateInventory'), $langs->trans(
'IncludeSubWarehouseExplanation'),
'confirm_validate', $formquestion,
'', 1);
312 $parameters = array(
'formConfirm' => $formconfirm);
313 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
314 if (empty($reshook)) {
315 $formconfirm .= $hookmanager->resPrint;
316 } elseif ($reshook > 0) {
317 $formconfirm = $hookmanager->resPrint;
326 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/inventory/list.php'.(!empty($socid) ?
'?socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
328 $morehtmlref =
'<div class="refidno">';
368 $morehtmlref .=
'</div>';
371 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
374 print
'<div class="fichecenter">';
375 print
'<div class="fichehalfleft">';
376 print
'<div class="underbanner clearboth"></div>';
377 print
'<table class="border centpercent tableforfield">'.
"\n";
380 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
383 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
389 print
'<div class="clearboth"></div>';
395 if ($action !=
'presend' && $action !=
'editline') {
396 print
'<div class="tabsAction">'.
"\n";
397 $parameters = array();
398 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
403 if (empty($reshook)) {
405 if (empty($user->socid)) {
406 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&mode=init&token='.
newToken().
'#formmailbeforetitle">'.$langs->trans(
'SendMail').
'</a>'.
"\n";
410 if (
$object->status == $object::STATUS_VALIDATED) {
411 if ($permissiontoadd) {
412 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=setdraft&confirm=yes&token='.
newToken().
'">'.$langs->trans(
"SetToDraft").
'</a>';
416 if (
$object->status == $object::STATUS_RECORDED) {
417 if ($permissiontoadd) {
418 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken().
'">'.$langs->trans(
"ReOpen").
'</a>';
423 if (
$object->status == $object::STATUS_DRAFT) {
424 if ($permissiontoadd) {
425 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>'.
"\n";
427 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
'Modify').
'</a>'.
"\n";
432 if (
$object->status == $object::STATUS_DRAFT ||
$object->status == $object::STATUS_CANCELED) {
433 if ($permissiontoadd) {
435 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=validate&token='.
newToken().
'">'.$langs->trans(
"Validate").
' ('.$langs->trans(
"ToStart").
')</a>';
437 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken().
'">'.$langs->trans(
"Validate").
' ('.$langs->trans(
"ToStart").
')</a>';
443 if ($permissiontoadd) {
448 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'delete', $permissiontodelete);
455 if (
GETPOST(
'modelselected')) {
459 if ($action !=
'presend') {
460 print
'<div class="fichecenter"><div class="fichehalfleft">';
461 print
'<a name="builddoc"></a>';
464 if ($includedocgeneration) {
466 $relativepath = $objref.
'/'.$objref.
'.pdf';
467 $filedir = $conf->mymodule->dir_output.
'/'.
$object->element.
'/'.$objref;
468 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
469 $genallowed = $user->hasRight(
'mymodule',
'myobject',
'read');
470 $delallowed = $user->hasRight(
'mymodule',
'myobject',
'write');
471 print $formfile->showdocuments(
'mymodule:MyObject',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
475 $linktoelem = $form->showLinkToObjectBlock(
$object,
null, array(
'inventory'));
476 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem);
479 print
'</div><div class="fichehalfright">';
484 $morehtmlcenter =
'';
487 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
489 $somethingshown = $formactions->showactions(
$object,
$object->element, 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
491 print
'</div></div>';
496 if (
GETPOST(
'modelselected')) {
501 $modelmail =
'inventory';
502 $defaulttopic =
'InformationMessage';
503 $diroutput = $conf->product->dir_output.
'/inventory';
504 $trackid =
'stockinv'.$object->id;
506 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
inventoryPrepareHead(&$inventory, $title='Inventory', $get='')
Define head array for tabs of inventory tools setup pages.
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.