26require
'../../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/product/inventory/class/inventory.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/product/inventory/lib/inventory.lib.php';
42$langs->loadLangs(array(
"stocks",
"other"));
47$action =
GETPOST(
'action',
'aZ09');
48$confirm =
GETPOST(
'confirm',
'alpha');
49$cancel =
GETPOST(
'cancel',
'aZ09');
50$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'inventorycard';
51$backtopage =
GETPOST(
'backtopage',
'alpha');
52$include_sub_warehouse = !empty(
GETPOST(
'include_sub_warehouse')) ?
GETPOST(
'include_sub_warehouse') : 0;
54$hookmanager->initHooks(array(
'inventorycard',
'globalcard'));
59 $result =
restrictedArea($user,
'stock', $id,
'',
'inventory_advance');
66$includedocgeneration =
false;
67$diroutputmassaction =
null;
71$extrafields->fetch_name_optionals_label(
$object->table_element);
73$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
76$search_all =
GETPOST(
"search_all",
'alpha');
78foreach (
$object->fields as $key => $val) {
79 if (
GETPOST(
'search_'.$key,
'alpha')) {
80 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
84if (empty($action) && empty($id) && empty($ref)) {
89include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
97 $permissiontoread = $user->hasRight(
'stock',
'lire');
98 $permissiontoadd = $user->hasRight(
'stock',
'creer');
99 $permissiontodelete = $user->hasRight(
'stock',
'supprimer');
100 $permissionnote = $user->hasRight(
'stock',
'creer');
101 $permissiondellink = $user->hasRight(
'stock',
'creer');
104 $permissiontoread = $user->hasRight(
'stock',
'inventory_advance',
'read');
105 $permissiontoadd = $user->hasRight(
'stock',
'inventory_advance',
'write');
106 $permissiontodelete = $user->hasRight(
'stock',
'inventory_advance',
'delete');
107 $permissionnote = $user->hasRight(
'stock',
'inventory_advance',
'write');
108 $permissiondellink = $user->hasRight(
'stock',
'inventory_advance',
'write');
117$parameters = array();
118$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
123if (empty($reshook)) {
124 $savaction = $action;
127 $backurlforlist = DOL_URL_ROOT.
'/product/inventory/list.php';
129 if (empty($backtopage) || ($cancel && empty($id))) {
130 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
131 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
132 $backtopage = $backurlforlist;
134 $backtopage =
dol_buildpath(
'/product/inventory/card.php', 1).
'?id='.(
$id > 0 ?
$id :
'__ID__');
138 $triggermodname =
'STOCK_INVENTORY_MODIFY';
141 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
144 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
147 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
153 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
159 if ($action ==
'classin' && $permissiontoadd) {
164 $triggersendname =
'INVENTORY_SENTBYMAIL';
165 $autocopy =
'MAIN_MAIL_AUTOCOPY_INVENTORY_TO';
166 $trackid =
'stockinv'.$object->id;
167 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
169 if (!$error && $savaction ==
'confirm_validate' && $action ==
'' &&
$object->id > 0) {
171 header(
"Location: ".DOL_URL_ROOT.
'/product/inventory/inventory.php?id='.
$object->id);
183$form =
new Form($db);
187$title = $langs->trans(
"Inventory");
189$help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks|DE:Modul_Bestände';
191llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-product page-inventory_card');
196if ($action ==
'create') {
199 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
200 print
'<input type="hidden" name="token" value="'.newToken().
'">';
201 print
'<input type="hidden" name="action" value="add">';
203 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
205 if (!empty($backtopageforcancel)) {
206 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
211 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
214 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
217 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
221 print
'</table>'.
"\n";
225 print $form->buttonsSaveCancel(
"Create");
233if (($id || $ref) && $action ==
'edit') {
236 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
237 print
'<input type="hidden" name="token" value="'.newToken().
'">';
238 print
'<input type="hidden" name="action" value="update">';
239 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
241 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
243 if ($backtopageforcancel) {
244 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
249 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
252 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
255 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
261 print $form->buttonsSaveCancel();
267if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
268 $res =
$object->fetch_optionals();
277 if ($action ==
'setdraft') {
278 $text = $langs->trans(
'ConfirmSetToDraftInventory',
$object->ref);
279 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'SetToDraft'), $text,
'confirm_setdraft',
'', 0, 1, 220);
282 if ($action ==
'delete') {
283 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteInventory'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
287 if ($action ==
'clone') {
289 $formquestion = array();
290 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
294 if ($action ==
'xxx') {
295 $formquestion = array();
306 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
310 if ($action ==
'validate') {
311 $form =
new Form($db);
314 $formquestion = array(
315 array(
'type' =>
'checkbox',
'name' =>
'include_sub_warehouse',
'label' => $langs->trans(
"IncludeSubWarehouse"),
'value' => 1,
'size' =>
'10'),
317 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateInventory'), $langs->trans(
'IncludeSubWarehouseExplanation'),
'confirm_validate', $formquestion,
'', 1);
322 $parameters = array(
'formConfirm' => $formconfirm);
323 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
324 if (empty($reshook)) {
325 $formconfirm .= $hookmanager->resPrint;
326 } elseif ($reshook > 0) {
327 $formconfirm = $hookmanager->resPrint;
336 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/inventory/list.php'.(!empty($socid) ?
'?socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
338 $morehtmlref =
'<div class="refidno">';
378 $morehtmlref .=
'</div>';
381 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
384 print
'<div class="fichecenter">';
385 print
'<div class="fichehalfleft">';
386 print
'<div class="underbanner clearboth"></div>';
387 print
'<table class="border centpercent tableforfield">'.
"\n";
390 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
393 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
399 print
'<div class="clearboth"></div>';
405 if ($action !=
'presend' && $action !=
'editline') {
406 print
'<div class="tabsAction">'.
"\n";
407 $parameters = array();
408 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
413 if (empty($reshook)) {
415 if (empty($user->socid)) {
416 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&mode=init&token='.
newToken().
'#formmailbeforetitle">'.$langs->trans(
'SendMail').
'</a>'.
"\n";
420 if (
$object->status == $object::STATUS_VALIDATED) {
421 if ($permissiontoadd) {
422 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=setdraft&confirm=yes&token='.
newToken().
'">'.$langs->trans(
"SetToDraft").
'</a>';
426 if (
$object->status == $object::STATUS_RECORDED) {
427 if ($permissiontoadd) {
428 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken().
'">'.$langs->trans(
"ReOpen").
'</a>';
433 if (
$object->status == $object::STATUS_DRAFT) {
434 if ($permissiontoadd) {
435 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>'.
"\n";
437 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
'Modify').
'</a>'.
"\n";
442 if (
$object->status == $object::STATUS_DRAFT ||
$object->status == $object::STATUS_CANCELED) {
443 if ($permissiontoadd) {
445 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=validate&token='.
newToken().
'">'.$langs->trans(
"Validate").
' ('.$langs->trans(
"ToStart").
')</a>';
447 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>';
453 if ($permissiontoadd) {
458 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'delete', $permissiontodelete);
465 if (
GETPOST(
'modelselected')) {
469 if ($action !=
'presend') {
470 print
'<div class="fichecenter"><div class="fichehalfleft">';
471 print
'<a name="builddoc"></a>';
474 if ($includedocgeneration) {
476 $relativepath = $objref.
'/'.$objref.
'.pdf';
477 $filedir =
$conf->mymodule->dir_output.
'/'.
$object->element.
'/'.$objref;
478 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
479 $genallowed = $user->hasRight(
'mymodule',
'myobject',
'read');
480 $delallowed = $user->hasRight(
'mymodule',
'myobject',
'write');
481 print $formfile->showdocuments(
'mymodule:MyObject',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
485 $tmparray = $form->showLinkToObjectBlock(
$object, array(), array(
'inventory'), 1);
486 $linktoelem = $tmparray[
'linktoelem'];
487 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
488 print $htmltoenteralink;
490 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem);
493 print
'</div><div class="fichehalfright">';
498 $morehtmlcenter =
'';
501 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
503 $somethingshown = $formactions->showactions(
$object,
$object->element, 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
505 print
'</div></div>';
510 if (
GETPOST(
'modelselected')) {
515 $modelmail =
'inventory';
516 $defaulttopic =
'InformationMessage';
517 $diroutput =
$conf->product->dir_output.
'/inventory';
518 $trackid =
'stockinv'.$object->id;
520 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.
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.