27require
'../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/resource/class/html.formresource.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/resource/class/dolresource.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstation.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstationusergroup.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/workstation/lib/workstation_workstation.lib.php';
36global $conf, $db, $hookmanager, $langs, $user;
39$langs->loadLangs(array(
'mrp',
'other'));
44$action =
GETPOST(
'action',
'aZ09');
45$confirm =
GETPOST(
'confirm',
'alpha');
46$cancel =
GETPOST(
'cancel',
'aZ09');
47$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
48$backtopage =
GETPOST(
'backtopage',
'alpha');
49$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
50$backtopagejsfields =
GETPOST(
'backtopagejsfields',
'alpha');
51$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
53if (!empty($backtopagejsfields)) {
54 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
55 $dol_openinpopup = preg_replace(
'/[^a-z0-9_]/i',
'', $tmpbacktopagejsfields[0]);
58$groups =
GETPOST(
'groups',
'array:int');
59$resources =
GETPOST(
'resources',
'array:int');
66$diroutputmassaction = $conf->workstation->dir_output.
'/temp/massgeneration/'.$user->id;
67$hookmanager->initHooks(array(
$object->element.
'card',
'globalcard'));
70$extrafields->fetch_name_optionals_label(
$object->table_element);
72$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
75$search_all = trim(
GETPOST(
"search_all",
'alpha'));
77foreach (
$object->fields as $key => $val) {
78 if (
GETPOST(
'search_'.$key,
'alpha')) {
79 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
83if (empty($action) && empty($id) && empty($ref)) {
88include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
91$permissiontoread = $user->hasRight(
'workstation',
'workstation',
'read');
92$permissiontoadd = $user->hasRight(
'workstation',
'workstation',
'write');
93$permissiontodelete = $user->hasRight(
'workstation',
'workstation',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DISABLED);
94$permissionnote = $user->hasRight(
'workstation',
'workstation',
'write');
95$permissiondellink = $user->hasRight(
'workstation',
'workstation',
'write');
108$parameters = array();
109$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
114if (empty($reshook)) {
117 $backurlforlist =
dol_buildpath(
'/workstation/workstation_list.php', 1);
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(
'/workstation/workstation_card.php', 1).
'?id='.($id > 0 ? $id :
'__ID__');
129 $triggermodname =
'WORKSTATION_WORKSTATION_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';
146 if ($action ==
'confirm_enable' && $confirm ==
"yes" && $permissiontoadd) {
150 } elseif ($action ==
'confirm_disable' && $confirm ==
"yes" && $permissiontoadd) {
163$form =
new Form($db);
167$title = $langs->trans(
"Workstation").
" - ".$langs->trans(
'Card');
168if ($action ==
'create') {
169 $title = $langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"Workstation"));
171$help_url =
'EN:Module_Workstation';
173llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-workstation page-workstation_card');
179 jQuery(document).ready(
function() {
180 jQuery(
"#type").change(
function() {
181 if($(
this).val() ===
'MACHINE') {
182 $(
'#usergroups').hide();
183 $(
'#nb_operators_required').parent(
'td').parent(
'tr').hide();
184 $(
'#wsresources').show();
185 }
else if($(
this).val() ===
'HUMAN') {
186 $(
'#wsresources').hide();
187 $(
'#nb_operators_required').parent(
'td').parent(
'tr').show();
188 $(
'#usergroups').show();
191 $(
'#usergroups').show();
192 $(
'#wsresources').show();
193 $(
'#nb_operators_required').parent(
'td').parent(
'tr').show();
196 jQuery(
"#type").trigger(
'change');
203if ($action ==
'create') {
204 if (empty($permissiontoadd)) {
213 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
214 print
'<input type="hidden" name="token" value="'.newToken().
'">';
215 print
'<input type="hidden" name="action" value="add">';
217 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
219 if ($backtopageforcancel) {
220 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
225 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
228 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
230 print
'<tr id="usergroups"';
232 print $langs->trans(
'Groups');
236 print $form->select_dolgroups($groups,
'groups', 1,
'', 0,
'',
'',
$object->entity,
true,
'quatrevingtpercent widthcentpercentminusx');
239 print
'<tr id="wsresources"><td>';
240 print $langs->trans(
'Machines');
244 print $formresource->select_resource_list($resources,
'resources', [],
'', 0,
'',
'',
$object->entity,
true, 0,
'quatrevingtpercent widthcentpercentminusx',
true);
248 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
250 print
'</table>'.
"\n";
254 print $form->buttonsSaveCancel(
"Create");
262if (($id || $ref) && $action ==
'edit') {
263 print
load_fiche_titre($langs->trans(
"Workstation"),
'',
'object_'.$object->picto);
265 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
266 print
'<input type="hidden" name="token" value="'.newToken().
'">';
267 print
'<input type="hidden" name="action" value="update">';
268 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
270 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
272 if ($backtopageforcancel) {
273 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
278 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
281 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
283 print
'<tr id="usergroups"';
285 print $langs->trans(
'Groups');
289 print $form->select_dolgroups(empty($groups) ?
$object->usergroups : $groups,
'groups', 1,
'', 0,
'',
'',
$object->entity, true,
'quatrevingtpercent widthcentpercentminusx');
292 print
'<tr id="wsresources"><td>';
293 print $langs->trans(
'Machines');
297 print $formresource->select_resource_list(empty($resources) ?
$object->resources : $resources,
'resources', [],
'', 0,
'',
'',
$object->entity, true, 0,
'quatrevingtpercent widthcentpercentminusx', true);
301 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
307 print $form->buttonsSaveCancel();
313if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
321 if ($action ==
'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) {
322 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteWorkstation'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0,
'action-delete');
325 if ($action ==
'clone') {
327 $formquestion = array();
328 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
332 if ($action ==
'enable') {
333 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'EnableAWorkstation'), $langs->trans(
"ConfirmEnableWorkstation",
$object->ref),
'confirm_enable', $formquestion, 0, 1, 220);
334 } elseif ($action ==
'disable') {
335 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DisableAWorkstation'), $langs->trans(
"ConfirmDisableWorkstation",
$object->ref),
'confirm_disable', $formquestion, 0, 1, 220);
340 'formConfirm' => $formconfirm,
343 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
344 if (empty($reshook)) {
345 $formconfirm .= $hookmanager->resPrint;
346 } elseif ($reshook > 0) {
347 $formconfirm = $hookmanager->resPrint;
356 $linkback =
'<a href="'.dol_buildpath(
'/workstation/workstation_list.php', 1).
'?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
358 $morehtmlref =
'<div class="refidno">';
388 $morehtmlref .=
'</div>';
391 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
394 print
'<div class="fichecenter">';
395 print
'<div class="fichehalfleft">';
396 print
'<div class="underbanner clearboth"></div>';
397 print
'<table class="border centpercent tableforfield">'.
"\n";
403 if (
$object->type ===
'MACHINE') {
404 $object->fields[
'nb_operators_required'][
'visible'] = 0;
411 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
414 if (
$object->type !==
'MACHINE') {
417 foreach (
$object->usergroups as $id_group) {
418 $g->fetch($id_group);
419 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $g->getNomUrl(1,
'', 0,
'categtextwhite') .
'</li>';
422 print
'<tr><td>' . $langs->trans(
'Groups') .
'</td><td>';
423 print
'<div class="select2-container-multi-dolibarr"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
428 if (
$object->type !==
'HUMAN') {
431 foreach (
$object->resources as $id_resource) {
432 $r->fetch($id_resource);
433 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $r->getNomUrl(1,
'',
'', 0,
'categtextwhite') .
'</li>';
436 print
'<tr><td>' . $langs->trans(
'Machines') .
'</td><td>';
437 print
'<div class="select2-container-multi-dolibarr"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
442 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
448 print
'<div class="clearboth"></div>';
455 if ($action !=
'presend' && $action !=
'editline') {
456 print
'<div class="tabsAction">'.
"\n";
457 $parameters = array();
458 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
463 if (empty($reshook)) {
465 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
468 if ($permissiontoadd) {
469 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.(!empty(
$object->socid) ?
'&socid='.$object->socid :
'').
'&action=clone&token='.
newToken(),
'', $permissiontoadd);
473 if ($permissiontoadd) {
474 if (
$object->status == $object::STATUS_ENABLED) {
475 print
dolGetButtonAction(
'', $langs->trans(
'Disable'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=disable&token='.
newToken(),
'', $permissiontoadd);
477 print
dolGetButtonAction(
'', $langs->trans(
'Enable'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=enable&token='.
newToken(),
'', $permissiontoadd);
482 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken();
483 $buttonId =
'action-delete-no-ajax';
484 if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) {
486 $buttonId =
'action-delete';
489 print
dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $deleteUrl, $buttonId, $permissiontodelete, $params);
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.
Class to manage user groups.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
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.
if(!function_exists( 'utf8_encode')) if(!function_exists('utf8_decode')) if(!function_exists( 'str_starts_with')) if(!function_exists('str_ends_with')) if(!function_exists( 'str_contains')) getMultidirOutput($object, $module='', $forobject=0, $mode='output')
Return the full path of the directory where a module (or an object of a module) stores its files,...
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.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
workstationPrepareHead($object)
Prepare array of tabs for Workstation.