28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/resource/class/html.formresource.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/resource/class/dolresource.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstation.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstationusergroup.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/workstation/lib/workstation_workstation.lib.php';
47$langs->loadLangs(array(
'mrp',
'other'));
52$action =
GETPOST(
'action',
'aZ09');
53$confirm =
GETPOST(
'confirm',
'alpha');
55$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
56$backtopage =
GETPOST(
'backtopage',
'alpha');
57$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
58$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
60$groups =
GETPOST(
'groups',
'array:int');
61$resources =
GETPOST(
'resources',
'array:int');
68$diroutputmassaction = $conf->workstation->dir_output.
'/temp/massgeneration/'.$user->id;
69$hookmanager->initHooks(array(
$object->element.
'card',
'globalcard'));
72$extrafields->fetch_name_optionals_label(
$object->table_element);
74$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
77$search_all = trim(
GETPOST(
"search_all",
'alpha'));
79foreach (
$object->fields as $key => $val) {
80 if (
GETPOST(
'search_'.$key,
'alpha')) {
81 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
85if (empty($action) && empty($id) && empty($ref)) {
90include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
93$permissiontoread = $user->hasRight(
'workstation',
'workstation',
'read');
94$permissiontoadd = $user->hasRight(
'workstation',
'workstation',
'write');
95$permissiontodelete = $user->hasRight(
'workstation',
'workstation',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == Workstation::STATUS_DISABLED);
96$permissionnote = $user->hasRight(
'workstation',
'workstation',
'write');
97$permissiondellink = $user->hasRight(
'workstation',
'workstation',
'write');
110$parameters = array();
111$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
116if (empty($reshook)) {
119 $backurlforlist =
dol_buildpath(
'/workstation/workstation_list.php', 1);
121 if (empty($backtopage) || ($cancel && empty($id))) {
122 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
123 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
124 $backtopage = $backurlforlist;
126 $backtopage =
dol_buildpath(
'/workstation/workstation_card.php', 1).
'?id='.(
$id > 0 ?
$id :
'__ID__');
131 $triggermodname =
'WORKSTATION_WORKSTATION_MODIFY';
134 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
137 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
140 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
146 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
148 if ($action ==
'confirm_enable' && $confirm ==
"yes" && $permissiontoadd) {
152 } elseif ($action ==
'confirm_disable' && $confirm ==
"yes" && $permissiontoadd) {
165$form =
new Form($db);
169$title = $langs->trans(
"Workstation").
" - ".$langs->trans(
'Card');
170if ($action ==
'create') {
171 $title = $langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"Workstation"));
173$help_url =
'EN:Module_Workstation';
175llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-workstation page-workstation_card');
181 jQuery(document).ready(
function() {
182 jQuery(
"#type").change(
function() {
183 if($(
this).val() ===
'MACHINE') {
184 $(
'#usergroups').hide();
185 $(
'#nb_operators_required').parent(
'td').parent(
'tr').hide();
186 $(
'#wsresources').show();
187 }
else if($(
this).val() ===
'HUMAN') {
188 $(
'#wsresources').hide();
189 $(
'#nb_operators_required').parent(
'td').parent(
'tr').show();
190 $(
'#usergroups').show();
193 $(
'#usergroups').show();
194 $(
'#wsresources').show();
195 $(
'#nb_operators_required').parent(
'td').parent(
'tr').show();
198 jQuery(
"#type").trigger(
'change');
205if ($action ==
'create') {
206 if (empty($permissiontoadd)) {
215 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
216 print
'<input type="hidden" name="token" value="'.newToken().
'">';
217 print
'<input type="hidden" name="action" value="add">';
219 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
221 if ($backtopageforcancel) {
222 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
227 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
230 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
232 print
'<tr id="usergroups">';
234 print $langs->trans(
'UserGroups');
237 print
img_picto(
'',
'group',
'class="pictofixedwidth"');
238 print $form->select_dolgroups($groups,
'groups', 1,
'', 0,
'', array(), (
string)
$object->entity,
true,
'quatrevingtpercent widthcentpercentminusx');
241 print
'<tr id="wsresources"><td>';
242 print $langs->trans(
'Machines');
245 print
img_picto(
'',
'resource',
'class="pictofixedwidth"');
246 print $formresource->select_resource_list($resources,
'resources',
'', 0, 0, 0, array(),
'', 2, 0,
'quatrevingtpercent widthcentpercentminusx',
true);
250 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
252 print
'</table>'.
"\n";
256 print $form->buttonsSaveCancel(
"Create");
264if (($id || $ref) && $action ==
'edit') {
265 print
load_fiche_titre($langs->trans(
"Workstation"),
'',
'object_'.$object->picto);
267 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
268 print
'<input type="hidden" name="token" value="'.newToken().
'">';
269 print
'<input type="hidden" name="action" value="update">';
270 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
272 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
274 if ($backtopageforcancel) {
275 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
280 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
283 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
285 print
'<tr id="usergroups"';
287 print $langs->trans(
'UserGroups');
290 print
img_picto(
'',
'group',
'class="pictofixedwidth"');
291 print $form->select_dolgroups(empty($groups) ?
$object->usergroups : $groups,
'groups', 1,
'', 0,
'', array(), (string)
$object->entity, true,
'quatrevingtpercent widthcentpercentminusx');
294 print
'<tr id="wsresources"><td>';
295 print $langs->trans(
'Machines');
298 print
img_picto(
'',
'resource',
'class="pictofixedwidth"');
299 print $formresource->select_resource_list(empty($resources) ?
$object->resources : $resources,
'resources',
'', 0, 0, 0, array(),
'', 2, 0,
'quatrevingtpercent widthcentpercentminusx', true);
303 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
309 print $form->buttonsSaveCancel();
315if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
323 if ($action ==
'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) {
324 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteWorkstation'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0,
'action-delete');
326 $formquestion = array();
328 if ($action ==
'clone') {
330 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
334 if ($action ==
'enable') {
335 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'EnableAWorkstation'), $langs->trans(
"ConfirmEnableWorkstation",
$object->ref),
'confirm_enable', $formquestion, 0, 1, 220);
336 } elseif ($action ==
'disable') {
337 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DisableAWorkstation'), $langs->trans(
"ConfirmDisableWorkstation",
$object->ref),
'confirm_disable', $formquestion, 0, 1, 220);
342 'formConfirm' => $formconfirm,
345 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
346 if (empty($reshook)) {
347 $formconfirm .= $hookmanager->resPrint;
348 } elseif ($reshook > 0) {
349 $formconfirm = $hookmanager->resPrint;
358 $linkback =
'<a href="'.dol_buildpath(
'/workstation/workstation_list.php', 1).
'?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
360 $morehtmlref =
'<div class="refidno">';
390 $morehtmlref .=
'</div>';
393 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
396 print
'<div class="fichecenter">';
397 print
'<div class="fichehalfleft">';
398 print
'<div class="underbanner clearboth"></div>';
399 print
'<table class="border centpercent tableforfield">'.
"\n";
405 if (
$object->type ===
'MACHINE') {
406 $object->fields[
'nb_operators_required'][
'visible'] = 0;
413 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
416 if (
$object->type !==
'MACHINE') {
419 foreach (
$object->usergroups as $id_group) {
420 $g->fetch($id_group);
421 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $g->getNomUrl(1,
'', 0,
'categtextwhite') .
'</li>';
424 print
'<tr><td>' . $langs->trans(
'Groups') .
'</td><td>';
425 print
'<div class="select2-container-multi-dolibarr"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
430 if (
$object->type !==
'HUMAN') {
433 foreach (
$object->resources as $id_resource) {
434 $r->fetch($id_resource);
435 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $r->getNomUrl(1,
'',
'', 0,
'categtextwhite') .
'</li>';
438 print
'<tr><td>' . $langs->trans(
'Machines') .
'</td><td>';
439 print
'<div class="select2-container-multi-dolibarr"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
444 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
450 print
'<div class="clearboth"></div>';
457 if ($action !=
'presend' && $action !=
'editline') {
458 print
'<div class="tabsAction">'.
"\n";
459 $parameters = array();
460 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
465 if (empty($reshook)) {
467 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
470 if ($permissiontoadd) {
471 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=clone&token='.
newToken(),
'', $permissiontoadd);
475 if ($permissiontoadd) {
476 if (
$object->status == Workstation::STATUS_ENABLED) {
477 print
dolGetButtonAction(
'', $langs->trans(
'Disable'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=disable&token='.
newToken(),
'', $permissiontoadd);
479 print
dolGetButtonAction(
'', $langs->trans(
'Enable'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=enable&token='.
newToken(),
'', $permissiontoadd);
484 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken();
485 $buttonId =
'action-delete-no-ajax';
486 if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) {
488 $buttonId =
'action-delete';
491 print
dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $deleteUrl, $buttonId, $permissiontodelete, $params);
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
Class to manage user groups.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
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, $morecssdiv='')
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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.