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');
44if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
47 $result =
restrictedArea($user,
'stock', $id,
'',
'inventory_advance');
54$includedocgeneration =
false;
55$diroutputmassaction =
null;
57$hookmanager->initHooks(array(
'inventorycard',
'globalcard'));
60$extrafields->fetch_name_optionals_label($object->table_element);
62$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
65$search_all =
GETPOST(
"search_all",
'alpha');
67foreach ($object->fields as $key => $val) {
68 if (
GETPOST(
'search_'.$key,
'alpha')) {
69 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
73if (empty($action) && empty($id) && empty($ref)) {
78include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
85if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
86 $permissiontoread = $user->rights->stock->lire;
87 $permissiontoadd = $user->rights->stock->creer;
88 $permissiontodelete = $user->rights->stock->supprimer;
89 $permissionnote = $user->rights->stock->creer;
90 $permissiondellink = $user->rights->stock->creer;
91 $upload_dir = $conf->stock->multidir_output[isset($object->entity) ? $object->entity : 1];
93 $permissiontoread = $user->rights->stock->inventory_advance->read;
94 $permissiontoadd = $user->rights->stock->inventory_advance->write;
95 $permissiontodelete = $user->rights->stock->inventory_advance->delete;
96 $permissionnote = $user->rights->stock->inventory_advance->write;
97 $permissiondellink = $user->rights->stock->inventory_advance->write;
98 $upload_dir = $conf->stock->multidir_output[isset($object->entity) ? $object->entity : 1];
106$parameters = array();
107$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
112if (empty($reshook)) {
113 $savaction = $action;
116 $backurlforlist = DOL_URL_ROOT.
'/product/inventory/list.php';
118 if (empty($backtopage) || ($cancel && empty($id))) {
119 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
120 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
121 $backtopage = $backurlforlist;
123 $backtopage =
dol_buildpath(
'/product/inventory/card.php', 1).
'?id='.($id > 0 ? $id :
'__ID__');
127 $triggermodname =
'STOCK_INVENTORY_MODIFY';
130 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
133 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
136 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
142 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
148 if ($action ==
'classin' && $permissiontoadd) {
149 $object->setProject(
GETPOST(
'projectid',
'int'));
153 $triggersendname =
'INVENTORY_SENTBYMAIL';
154 $autocopy =
'MAIN_MAIL_AUTOCOPY_INVENTORY_TO';
155 $trackid =
'stockinv'.$object->id;
156 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
158 if (!$error && $savaction ==
'confirm_validate' && $action ==
'' && $object->id > 0) {
160 header(
"Location: ".DOL_URL_ROOT.
'/product/inventory/inventory.php?id='.$object->id);
172$form =
new Form($db);
176$title = $langs->trans(
"Inventory");
178$help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks|DE:Modul_Bestände';
185if ($action ==
'create') {
188 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
189 print
'<input type="hidden" name="token" value="'.newToken().
'">';
190 print
'<input type="hidden" name="action" value="add">';
192 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
194 if (!empty($backtopageforcancel)) {
195 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
200 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
203 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
206 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
210 print
'</table>'.
"\n";
214 print $form->buttonsSaveCancel(
"Create");
222if (($id || $ref) && $action ==
'edit') {
225 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
226 print
'<input type="hidden" name="token" value="'.newToken().
'">';
227 print
'<input type="hidden" name="action" value="update">';
228 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
230 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
232 if ($backtopageforcancel) {
233 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
238 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
241 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
244 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
250 print $form->buttonsSaveCancel();
256if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
257 $res = $object->fetch_optionals();
265 if ($action ==
'delete') {
266 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteInventory'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
270 if ($action ==
'clone') {
272 $formquestion = array();
273 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
277 if ($action ==
'xxx') {
278 $formquestion = array();
289 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
293 $parameters = array(
'formConfirm' => $formconfirm);
294 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
295 if (empty($reshook)) {
296 $formconfirm .= $hookmanager->resPrint;
297 } elseif ($reshook > 0) {
298 $formconfirm = $hookmanager->resPrint;
307 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/inventory/list.php'.(!empty($socid) ?
'?socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
309 $morehtmlref =
'<div class="refidno">';
349 $morehtmlref .=
'</div>';
352 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
355 print
'<div class="fichecenter">';
356 print
'<div class="fichehalfleft">';
357 print
'<div class="underbanner clearboth"></div>';
358 print
'<table class="border centpercent tableforfield">'.
"\n";
361 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
364 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
370 print
'<div class="clearboth"></div>';
376 if ($action !=
'presend' && $action !=
'editline') {
377 print
'<div class="tabsAction">'.
"\n";
378 $parameters = array();
379 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
384 if (empty($reshook)) {
386 if (empty($user->socid)) {
387 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=presend&mode=init&token='.newToken().
'#formmailbeforetitle">'.$langs->trans(
'SendMail').
'</a>'.
"\n";
391 if ($object->status == $object::STATUS_VALIDATED) {
392 if ($permissiontoadd) {
393 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=confirm_setdraft&confirm=yes&token='.newToken().
'">'.$langs->trans(
"SetToDraft").
'</a>';
397 if ($object->status == $object::STATUS_RECORDED) {
398 if ($permissiontoadd) {
399 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=confirm_validate&confirm=yes&token='.newToken().
'">'.$langs->trans(
"ReOpen").
'</a>';
404 if ($object->status == $object::STATUS_DRAFT) {
405 if ($permissiontoadd) {
406 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit&token='.newToken().
'">'.$langs->trans(
"Modify").
'</a>'.
"\n";
408 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
'Modify').
'</a>'.
"\n";
413 if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_CANCELED) {
414 if ($permissiontoadd) {
415 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>';
420 if ($permissiontoadd) {
425 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.newToken(),
'delete', $permissiontodelete);
432 if (
GETPOST(
'modelselected')) {
436 if ($action !=
'presend') {
437 print
'<div class="fichecenter"><div class="fichehalfleft">';
438 print
'<a name="builddoc"></a>';
441 if ($includedocgeneration) {
443 $relativepath = $objref.
'/'.$objref.
'.pdf';
444 $filedir = $conf->mymodule->dir_output.
'/'.$object->element.
'/'.$objref;
445 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
446 $genallowed = $user->rights->mymodule->myobject->read;
447 $delallowed = $user->rights->mymodule->myobject->write;
448 print $formfile->showdocuments(
'mymodule:MyObject', $object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
452 $linktoelem = $form->showLinkToObjectBlock($object,
null, array(
'inventory'));
453 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
456 print
'</div><div class="fichehalfright">';
461 $morehtmlcenter =
'';
464 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
466 $somethingshown =
$formactions->showactions($object, $object->element, 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
468 print
'</div></div>';
473 if (
GETPOST(
'modelselected')) {
478 $modelmail =
'inventory';
479 $defaulttopic =
'InformationMessage';
480 $diroutput = $conf->product->dir_output.
'/inventory';
481 $trackid =
'stockinv'.$object->id;
483 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif( $action=='specimen') elseif($action=='setmodel') elseif( $action=='del') elseif($action=='setdoc') $formactions
View.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
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.
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.