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;
45$hookmanager->initHooks(array(
'inventorycard',
'globalcard'));
50 $result =
restrictedArea($user,
'stock', $id,
'',
'inventory_advance');
57$includedocgeneration =
false;
58$diroutputmassaction =
null;
62$extrafields->fetch_name_optionals_label(
$object->table_element);
64$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
67$search_all =
GETPOST(
"search_all",
'alpha');
69foreach (
$object->fields as $key => $val) {
70 if (
GETPOST(
'search_'.$key,
'alpha')) {
71 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
75if (empty($action) && empty($id) && empty($ref)) {
80include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
88 $permissiontoread = $user->hasRight(
'stock',
'lire');
89 $permissiontoadd = $user->hasRight(
'stock',
'creer');
90 $permissiontodelete = $user->hasRight(
'stock',
'supprimer');
91 $permissionnote = $user->hasRight(
'stock',
'creer');
92 $permissiondellink = $user->hasRight(
'stock',
'creer');
93 $upload_dir = $conf->stock->multidir_output[isset(
$object->entity) ?
$object->entity : 1];
95 $permissiontoread = $user->hasRight(
'stock',
'inventory_advance',
'read');
96 $permissiontoadd = $user->hasRight(
'stock',
'inventory_advance',
'write');
97 $permissiontodelete = $user->hasRight(
'stock',
'inventory_advance',
'delete');
98 $permissionnote = $user->hasRight(
'stock',
'inventory_advance',
'write');
99 $permissiondellink = $user->hasRight(
'stock',
'inventory_advance',
'write');
100 $upload_dir = $conf->stock->multidir_output[isset(
$object->entity) ?
$object->entity : 1];
108$parameters = array();
109$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
114if (empty($reshook)) {
115 $savaction = $action;
118 $backurlforlist = DOL_URL_ROOT.
'/product/inventory/list.php';
120 if (empty($backtopage) || ($cancel && empty($id))) {
121 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
122 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
123 $backtopage = $backurlforlist;
125 $backtopage =
dol_buildpath(
'/product/inventory/card.php', 1).
'?id='.(
$id > 0 ?
$id :
'__ID__');
129 $triggermodname =
'STOCK_INVENTORY_MODIFY';
132 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
135 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
138 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
144 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
150 if ($action ==
'classin' && $permissiontoadd) {
155 $triggersendname =
'INVENTORY_SENTBYMAIL';
156 $autocopy =
'MAIN_MAIL_AUTOCOPY_INVENTORY_TO';
157 $trackid =
'stockinv'.$object->id;
158 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
160 if (!$error && $savaction ==
'confirm_validate' && $action ==
'' &&
$object->id > 0) {
162 header(
"Location: ".DOL_URL_ROOT.
'/product/inventory/inventory.php?id='.
$object->id);
174$form =
new Form($db);
178$title = $langs->trans(
"Inventory");
180$help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks|DE:Modul_Bestände';
182llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-product page-inventory_card');
187if ($action ==
'create') {
190 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
191 print
'<input type="hidden" name="token" value="'.newToken().
'">';
192 print
'<input type="hidden" name="action" value="add">';
194 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
196 if (!empty($backtopageforcancel)) {
197 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
202 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
205 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
208 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
212 print
'</table>'.
"\n";
216 print $form->buttonsSaveCancel(
"Create");
224if (($id || $ref) && $action ==
'edit') {
227 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
228 print
'<input type="hidden" name="token" value="'.newToken().
'">';
229 print
'<input type="hidden" name="action" value="update">';
230 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
232 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
234 if ($backtopageforcancel) {
235 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
240 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
243 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
246 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
252 print $form->buttonsSaveCancel();
258if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
259 $res =
$object->fetch_optionals();
268 if ($action ==
'setdraft') {
269 $text = $langs->trans(
'ConfirmSetToDraftInventory',
$object->ref);
270 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'SetToDraft'), $text,
'confirm_setdraft',
'', 0, 1, 220);
273 if ($action ==
'delete') {
274 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteInventory'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
278 if ($action ==
'clone') {
280 $formquestion = array();
281 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
285 if ($action ==
'xxx') {
286 $formquestion = array();
297 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
301 if ($action ==
'validate') {
302 $form =
new Form($db);
305 $formquestion = array(
306 array(
'type' =>
'checkbox',
'name' =>
'include_sub_warehouse',
'label' => $langs->trans(
"IncludeSubWarehouse"),
'value' => 1,
'size' =>
'10'),
308 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateInventory'), $langs->trans(
'IncludeSubWarehouseExplanation'),
'confirm_validate', $formquestion,
'', 1);
313 $parameters = array(
'formConfirm' => $formconfirm);
314 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
315 if (empty($reshook)) {
316 $formconfirm .= $hookmanager->resPrint;
317 } elseif ($reshook > 0) {
318 $formconfirm = $hookmanager->resPrint;
327 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/inventory/list.php'.(!empty($socid) ?
'?socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
329 $morehtmlref =
'<div class="refidno">';
369 $morehtmlref .=
'</div>';
372 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
375 print
'<div class="fichecenter">';
376 print
'<div class="fichehalfleft">';
377 print
'<div class="underbanner clearboth"></div>';
378 print
'<table class="border centpercent tableforfield">'.
"\n";
381 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
384 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
390 print
'<div class="clearboth"></div>';
396 if ($action !=
'presend' && $action !=
'editline') {
397 print
'<div class="tabsAction">'.
"\n";
398 $parameters = array();
399 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
404 if (empty($reshook)) {
406 if (empty($user->socid)) {
407 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&mode=init&token='.
newToken().
'#formmailbeforetitle">'.$langs->trans(
'SendMail').
'</a>'.
"\n";
411 if (
$object->status == $object::STATUS_VALIDATED) {
412 if ($permissiontoadd) {
413 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=setdraft&confirm=yes&token='.
newToken().
'">'.$langs->trans(
"SetToDraft").
'</a>';
417 if (
$object->status == $object::STATUS_RECORDED) {
418 if ($permissiontoadd) {
419 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken().
'">'.$langs->trans(
"ReOpen").
'</a>';
424 if (
$object->status == $object::STATUS_DRAFT) {
425 if ($permissiontoadd) {
426 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>'.
"\n";
428 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
'Modify').
'</a>'.
"\n";
433 if (
$object->status == $object::STATUS_DRAFT ||
$object->status == $object::STATUS_CANCELED) {
434 if ($permissiontoadd) {
436 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=validate&token='.
newToken().
'">'.$langs->trans(
"Validate").
' ('.$langs->trans(
"ToStart").
')</a>';
438 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>';
444 if ($permissiontoadd) {
449 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'delete', $permissiontodelete);
456 if (
GETPOST(
'modelselected')) {
460 if ($action !=
'presend') {
461 print
'<div class="fichecenter"><div class="fichehalfleft">';
462 print
'<a name="builddoc"></a>';
465 if ($includedocgeneration) {
467 $relativepath = $objref.
'/'.$objref.
'.pdf';
468 $filedir = $conf->mymodule->dir_output.
'/'.
$object->element.
'/'.$objref;
469 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
470 $genallowed = $user->hasRight(
'mymodule',
'myobject',
'read');
471 $delallowed = $user->hasRight(
'mymodule',
'myobject',
'write');
472 print $formfile->showdocuments(
'mymodule:MyObject',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
476 $tmparray = $form->showLinkToObjectBlock(
$object, array(), array(
'inventory'), 1);
477 $linktoelem = $tmparray[
'linktoelem'];
478 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
479 print $htmltoenteralink;
481 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem);
484 print
'</div><div class="fichehalfright">';
489 $morehtmlcenter =
'';
492 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
494 $somethingshown = $formactions->showactions(
$object,
$object->element, 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
496 print
'</div></div>';
501 if (
GETPOST(
'modelselected')) {
506 $modelmail =
'inventory';
507 $defaulttopic =
'InformationMessage';
508 $diroutput = $conf->product->dir_output.
'/inventory';
509 $trackid =
'stockinv'.$object->id;
511 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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
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.
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.
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 a 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.