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';
45$langs->loadLangs(array(
'mrp',
'other'));
50$action =
GETPOST(
'action',
'aZ09');
51$confirm =
GETPOST(
'confirm',
'alpha');
52$cancel =
GETPOST(
'cancel',
'aZ09');
53$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
54$backtopage =
GETPOST(
'backtopage',
'alpha');
55$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
56$backtopagejsfields =
GETPOST(
'backtopagejsfields',
'alpha');
57$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
59if (!empty($backtopagejsfields)) {
60 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
61 $dol_openinpopup = preg_replace(
'/[^a-z0-9_]/i',
'', $tmpbacktopagejsfields[0]);
64$groups =
GETPOST(
'groups',
'array:int');
65$resources =
GETPOST(
'resources',
'array:int');
72$diroutputmassaction =
$conf->workstation->dir_output.
'/temp/massgeneration/'.$user->id;
73$hookmanager->initHooks(array(
$object->element.
'card',
'globalcard'));
76$extrafields->fetch_name_optionals_label(
$object->table_element);
78$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
81$search_all = trim(
GETPOST(
"search_all",
'alpha'));
83foreach (
$object->fields as $key => $val) {
84 if (
GETPOST(
'search_'.$key,
'alpha')) {
85 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
89if (empty($action) && empty($id) && empty($ref)) {
94include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
97$permissiontoread = $user->hasRight(
'workstation',
'workstation',
'read');
98$permissiontoadd = $user->hasRight(
'workstation',
'workstation',
'write');
99$permissiontodelete = $user->hasRight(
'workstation',
'workstation',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DISABLED);
100$permissionnote = $user->hasRight(
'workstation',
'workstation',
'write');
101$permissiondellink = $user->hasRight(
'workstation',
'workstation',
'write');
114$parameters = array();
115$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
120if (empty($reshook)) {
123 $backurlforlist =
dol_buildpath(
'/workstation/workstation_list.php', 1);
125 if (empty($backtopage) || ($cancel && empty($id))) {
126 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
127 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
128 $backtopage = $backurlforlist;
130 $backtopage =
dol_buildpath(
'/workstation/workstation_card.php', 1).
'?id='.(
$id > 0 ?
$id :
'__ID__');
135 $triggermodname =
'WORKSTATION_WORKSTATION_MODIFY';
138 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
141 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
144 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
150 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
152 if ($action ==
'confirm_enable' && $confirm ==
"yes" && $permissiontoadd) {
156 } elseif ($action ==
'confirm_disable' && $confirm ==
"yes" && $permissiontoadd) {
169$form =
new Form($db);
173$title = $langs->trans(
"Workstation").
" - ".$langs->trans(
'Card');
174if ($action ==
'create') {
175 $title = $langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"Workstation"));
177$help_url =
'EN:Module_Workstation';
179llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-workstation page-workstation_card');
185 jQuery(document).ready(
function() {
186 jQuery(
"#type").change(
function() {
187 if($(
this).val() ===
'MACHINE') {
188 $(
'#usergroups').hide();
189 $(
'#nb_operators_required').parent(
'td').parent(
'tr').hide();
190 $(
'#wsresources').show();
191 }
else if($(
this).val() ===
'HUMAN') {
192 $(
'#wsresources').hide();
193 $(
'#nb_operators_required').parent(
'td').parent(
'tr').show();
194 $(
'#usergroups').show();
197 $(
'#usergroups').show();
198 $(
'#wsresources').show();
199 $(
'#nb_operators_required').parent(
'td').parent(
'tr').show();
202 jQuery(
"#type").trigger(
'change');
209if ($action ==
'create') {
210 if (empty($permissiontoadd)) {
219 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
220 print
'<input type="hidden" name="token" value="'.newToken().
'">';
221 print
'<input type="hidden" name="action" value="add">';
223 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
225 if ($backtopageforcancel) {
226 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
231 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
234 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
236 print
'<tr id="usergroups"';
238 print $langs->trans(
'Groups');
242 print $form->select_dolgroups($groups,
'groups', 1,
'', 0,
'',
'',
$object->entity,
true,
'quatrevingtpercent widthcentpercentminusx');
245 print
'<tr id="wsresources"><td>';
246 print $langs->trans(
'Machines');
250 print $formresource->select_resource_list($resources,
'resources', [],
'', 0,
'',
'',
$object->entity,
true, 0,
'quatrevingtpercent widthcentpercentminusx',
true);
254 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
256 print
'</table>'.
"\n";
260 print $form->buttonsSaveCancel(
"Create");
268if (($id || $ref) && $action ==
'edit') {
269 print
load_fiche_titre($langs->trans(
"Workstation"),
'',
'object_'.$object->picto);
271 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
272 print
'<input type="hidden" name="token" value="'.newToken().
'">';
273 print
'<input type="hidden" name="action" value="update">';
274 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
276 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
278 if ($backtopageforcancel) {
279 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
284 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
287 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
289 print
'<tr id="usergroups"';
291 print $langs->trans(
'Groups');
295 print $form->select_dolgroups(empty($groups) ?
$object->usergroups : $groups,
'groups', 1,
'', 0,
'',
'',
$object->entity, true,
'quatrevingtpercent widthcentpercentminusx');
298 print
'<tr id="wsresources"><td>';
299 print $langs->trans(
'Machines');
303 print $formresource->select_resource_list(empty($resources) ?
$object->resources : $resources,
'resources', [],
'', 0,
'',
'',
$object->entity, true, 0,
'quatrevingtpercent widthcentpercentminusx', true);
307 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
313 print $form->buttonsSaveCancel();
319if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
327 if ($action ==
'delete' || (
$conf->use_javascript_ajax && empty(
$conf->dol_use_jmobile))) {
328 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteWorkstation'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0,
'action-delete');
331 if ($action ==
'clone') {
333 $formquestion = array();
334 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
338 if ($action ==
'enable') {
339 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'EnableAWorkstation'), $langs->trans(
"ConfirmEnableWorkstation",
$object->ref),
'confirm_enable', $formquestion, 0, 1, 220);
340 } elseif ($action ==
'disable') {
341 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DisableAWorkstation'), $langs->trans(
"ConfirmDisableWorkstation",
$object->ref),
'confirm_disable', $formquestion, 0, 1, 220);
346 'formConfirm' => $formconfirm,
349 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
350 if (empty($reshook)) {
351 $formconfirm .= $hookmanager->resPrint;
352 } elseif ($reshook > 0) {
353 $formconfirm = $hookmanager->resPrint;
362 $linkback =
'<a href="'.dol_buildpath(
'/workstation/workstation_list.php', 1).
'?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
364 $morehtmlref =
'<div class="refidno">';
394 $morehtmlref .=
'</div>';
397 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
400 print
'<div class="fichecenter">';
401 print
'<div class="fichehalfleft">';
402 print
'<div class="underbanner clearboth"></div>';
403 print
'<table class="border centpercent tableforfield">'.
"\n";
409 if (
$object->type ===
'MACHINE') {
410 $object->fields[
'nb_operators_required'][
'visible'] = 0;
417 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
420 if (
$object->type !==
'MACHINE') {
423 foreach (
$object->usergroups as $id_group) {
424 $g->fetch($id_group);
425 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $g->getNomUrl(1,
'', 0,
'categtextwhite') .
'</li>';
428 print
'<tr><td>' . $langs->trans(
'Groups') .
'</td><td>';
429 print
'<div class="select2-container-multi-dolibarr"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
434 if (
$object->type !==
'HUMAN') {
437 foreach (
$object->resources as $id_resource) {
438 $r->fetch($id_resource);
439 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $r->getNomUrl(1,
'',
'', 0,
'categtextwhite') .
'</li>';
442 print
'<tr><td>' . $langs->trans(
'Machines') .
'</td><td>';
443 print
'<div class="select2-container-multi-dolibarr"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
448 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
454 print
'<div class="clearboth"></div>';
461 if ($action !=
'presend' && $action !=
'editline') {
462 print
'<div class="tabsAction">'.
"\n";
463 $parameters = array();
464 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
469 if (empty($reshook)) {
471 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
474 if ($permissiontoadd) {
475 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.(!empty(
$object->socid) ?
'&socid='.$object->socid :
'').
'&action=clone&token='.
newToken(),
'', $permissiontoadd);
479 if ($permissiontoadd) {
480 if (
$object->status == $object::STATUS_ENABLED) {
481 print
dolGetButtonAction(
'', $langs->trans(
'Disable'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=disable&token='.
newToken(),
'', $permissiontoadd);
483 print
dolGetButtonAction(
'', $langs->trans(
'Enable'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=enable&token='.
newToken(),
'', $permissiontoadd);
488 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken();
489 $buttonId =
'action-delete-no-ajax';
490 if (
$conf->use_javascript_ajax && empty(
$conf->dol_use_jmobile)) {
492 $buttonId =
'action-delete';
495 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($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.
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.
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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.
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.