28require
'../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/resource/class/html.formresource.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/resource/class/dolresource.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstation.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstationusergroup.class.php';
44require_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');
65$diroutputmassaction =
$conf->workstation->dir_output.
'/temp/massgeneration/'.$user->id;
66$hookmanager->initHooks(array(
$object->element.
'card',
'globalcard'));
69$extrafields->fetch_name_optionals_label(
$object->table_element);
71$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
74$search_all = trim(
GETPOST(
"search_all",
'alpha'));
76foreach (
$object->fields as $key => $val) {
77 if (
GETPOST(
'search_'.$key,
'alpha')) {
78 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
82if (empty($action) && empty($id) && empty($ref)) {
87include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
90$permissiontoread = $user->hasRight(
'workstation',
'workstation',
'read');
91$permissiontoadd = $user->hasRight(
'workstation',
'workstation',
'write');
92$permissiontodelete = $user->hasRight(
'workstation',
'workstation',
'delete');
93$permissionnote = $user->hasRight(
'workstation',
'workstation',
'write');
94$permissiondellink = $user->hasRight(
'workstation',
'workstation',
'write');
107$parameters = array();
108$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
113if (empty($reshook)) {
116 $backurlforlist =
dol_buildpath(
'/workstation/workstation_list.php', 1);
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(
'/workstation/workstation_card.php', 1).
'?id='.(
$id > 0 ?
$id :
'__ID__');
128 $triggermodname =
'WORKSTATION_WORKSTATION_MODIFY';
130 if ($action ==
'update' && $permissiontoadd) {
132 $object->usergroups = is_array($groups) ? array_map(
'intval', $groups) : array();
133 $object->resources = is_array($resources) ? array_map(
'intval', $resources) : array();
137 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
140 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
143 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
149 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
151 if ($action ==
'confirm_enable' && $confirm ==
"yes" && $permissiontoadd) {
155 } elseif ($action ==
'confirm_disable' && $confirm ==
"yes" && $permissiontoadd) {
172$title = $langs->trans(
"Workstation").
" - ".$langs->trans(
'Card');
173if ($action ==
'create') {
174 $title = $langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"Workstation"));
176$help_url =
'EN:Module_Workstation';
178llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-workstation page-workstation_card');
184 jQuery(document).ready(
function() {
185 jQuery(
"#type").change(
function() {
186 if($(
this).val() ===
'MACHINE') {
187 $(
'#usergroups').hide();
188 $(
'#nb_operators_required').parent(
'td').parent(
'tr').hide();
189 $(
'#wsresources').show();
190 }
else if($(
this).val() ===
'HUMAN') {
191 $(
'#wsresources').hide();
192 $(
'#nb_operators_required').parent(
'td').parent(
'tr').show();
193 $(
'#usergroups').show();
196 $(
'#usergroups').show();
197 $(
'#wsresources').show();
198 $(
'#nb_operators_required').parent(
'td').parent(
'tr').show();
201 jQuery(
"#type").trigger(
'change');
208if ($action ==
'create') {
209 if (empty($permissiontoadd)) {
218 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
219 print
'<input type="hidden" name="token" value="'.newToken().
'">';
220 print
'<input type="hidden" name="action" value="add">';
222 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
224 if ($backtopageforcancel) {
225 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
230 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
233 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
235 print
'<tr id="usergroups">';
237 print $langs->trans(
'UserGroups');
240 print
img_picto(
'',
'group',
'class="pictofixedwidth"');
241 print $form->select_dolgroups($groups,
'groups', 1,
'', 0,
'', array(), (
string)
$object->entity,
true,
'quatrevingtpercent widthcentpercentminusx');
244 print
'<tr id="wsresources"><td>';
245 print $langs->trans(
'Machines');
248 print
img_picto(
'',
'resource',
'class="pictofixedwidth"');
249 print $formresource->select_resource_list($resources,
'resources',
'', 0, 0, 0, array(),
'', 2, 0,
'quatrevingtpercent widthcentpercentminusx',
true);
253 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
255 print
'</table>'.
"\n";
259 print $form->buttonsSaveCancel(
"Create");
267if (($id || $ref) && $action ==
'edit') {
268 print
load_fiche_titre($langs->trans(
"Workstation"),
'',
'object_'.$object->picto);
270 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
271 print
'<input type="hidden" name="token" value="'.newToken().
'">';
272 print
'<input type="hidden" name="action" value="update">';
273 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
275 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
277 if ($backtopageforcancel) {
278 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
283 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
286 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
288 print
'<tr id="usergroups"';
290 print $langs->trans(
'UserGroups');
293 print
img_picto(
'',
'group',
'class="pictofixedwidth"');
294 print $form->select_dolgroups(empty($groups) ?
$object->usergroups : $groups,
'groups', 1,
'', 0,
'', array(), (
string)
$object->entity, true,
'quatrevingtpercent widthcentpercentminusx');
297 print
'<tr id="wsresources"><td>';
298 print $langs->trans(
'Machines');
301 print
img_picto(
'',
'resource',
'class="pictofixedwidth"');
302 print $formresource->select_resource_list(empty($resources) ?
$object->resources : $resources,
'resources',
'', 0, 0, 0, array(),
'', 2, 0,
'quatrevingtpercent widthcentpercentminusx', true);
306 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
312 print $form->buttonsSaveCancel();
318if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
326 if ($action ==
'delete' || (
$conf->use_javascript_ajax && empty(
$conf->dol_use_jmobile))) {
327 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteWorkstation'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0,
'action-delete');
329 $formquestion = array();
331 if ($action ==
'clone') {
333 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
337 if ($action ==
'enable') {
338 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'EnableAWorkstation'), $langs->trans(
"ConfirmEnableWorkstation",
$object->ref),
'confirm_enable', $formquestion, 0, 1, 220);
339 } elseif ($action ==
'disable') {
340 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DisableAWorkstation'), $langs->trans(
"ConfirmDisableWorkstation",
$object->ref),
'confirm_disable', $formquestion, 0, 1, 220);
345 'formConfirm' => $formconfirm,
348 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
349 if (empty($reshook)) {
350 $formconfirm .= $hookmanager->resPrint;
351 } elseif ($reshook > 0) {
352 $formconfirm = $hookmanager->resPrint;
361 $linkback =
'<a href="'.dolBuildUrl(
'/workstation/workstation_list.php', [
'restore_lastsearch_values' => 1]).
'">'.$langs->trans(
"BackToList").
'</a>';
363 $morehtmlref =
'<div class="refidno">';
393 $morehtmlref .=
'</div>';
396 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
399 print
'<div class="fichecenter">';
400 print
'<div class="fichehalfleft">';
401 print
'<div class="underbanner clearboth"></div>';
402 print
'<table class="border centpercent tableforfield">'.
"\n";
408 if (
$object->type ===
'MACHINE') {
409 $object->fields[
'nb_operators_required'][
'visible'] = 0;
416 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
419 if (
$object->type !==
'MACHINE') {
422 foreach (
$object->usergroups as $id_group) {
423 $g->fetch($id_group);
424 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $g->getNomUrl(1,
'', 0,
'categtextwhite') .
'</li>';
427 print
'<tr><td>' . $langs->trans(
'Groups') .
'</td><td>';
428 print
'<div class="select2-container-multi-dolibarr"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
433 if (
$object->type !==
'HUMAN') {
436 foreach (
$object->resources as $id_resource) {
437 $r->fetch($id_resource);
438 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $r->getNomUrl(1,
'',
'', 0,
'categtextwhite') .
'</li>';
441 print
'<tr><td>' . $langs->trans(
'Machines') .
'</td><td>';
442 print
'<div class="select2-container-multi-dolibarr"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
447 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
453 print
'<div class="clearboth"></div>';
460 if ($action !=
'presend' && $action !=
'editline') {
461 print
'<div class="tabsAction">'.
"\n";
462 $parameters = array();
463 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
468 if (empty($reshook)) {
470 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
473 if ($permissiontoadd) {
474 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'clone', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=clone&token='.
newToken(),
'', $permissiontoadd);
478 if ($permissiontoadd) {
479 if (
$object->status == Workstation::STATUS_ENABLED) {
480 print
dolGetButtonAction(
'', $langs->trans(
'Disable'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=disable&token='.
newToken(),
'', $permissiontoadd);
482 print
dolGetButtonAction(
'', $langs->trans(
'Enable'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=enable&token='.
newToken(),
'', $permissiontoadd);
487 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken();
488 $buttonId =
'action-delete-no-ajax';
489 if (
$conf->use_javascript_ajax && empty(
$conf->dol_use_jmobile)) {
491 $buttonId =
'action-delete';
494 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)
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.
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
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.