25 require
'../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/resource/class/html.formresource.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/resource/class/dolresource.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstation.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/workstation/lib/workstation_workstation.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstationusergroup.class.php';
35 $langs->loadLangs(array(
"workstation",
"other"));
40 $action =
GETPOST(
'action',
'aZ09');
41 $confirm =
GETPOST(
'confirm',
'alpha');
42 $cancel =
GETPOST(
'cancel',
'aZ09');
43 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'workstationcard';
44 $backtopage =
GETPOST(
'backtopage',
'alpha');
45 $backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
47 $groups =
GETPOST(
'groups',
'array:int');
48 $resources =
GETPOST(
'resources',
'array:int');
54 $diroutputmassaction = $conf->workstation->dir_output.
'/temp/massgeneration/'.$user->id;
55 $hookmanager->initHooks(array(
'workstationcard',
'globalcard'));
58 $extrafields->fetch_name_optionals_label($object->table_element);
60 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
63 $search_all =
GETPOST(
"search_all",
'alpha');
65 foreach ($object->fields as $key => $val) {
66 if (
GETPOST(
'search_'.$key,
'alpha')) {
67 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
71 if (empty($action) && empty($id) && empty($ref)) {
76 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
78 $permissiontoread = $user->rights->workstation->workstation->read;
79 $permissiontoadd = $user->rights->workstation->workstation->write;
80 $permissiontodelete = $user->rights->workstation->workstation->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
81 $permissionnote = $user->rights->workstation->workstation->write;
82 $permissiondellink = $user->rights->workstation->workstation->write;
83 $upload_dir = $conf->workstation->multidir_output[isset($object->entity) ? $object->entity : 1];
87 restrictedArea($user, $object->element, $object->id, $object->table_element,
'workstation',
'fk_soc',
'rowid', $isdraft);
94 $parameters = array();
95 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
100 if (empty($reshook)) {
103 $backurlforlist =
dol_buildpath(
'/workstation/workstation_list.php', 1);
105 if (empty($backtopage) || ($cancel && empty($id))) {
106 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
107 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
108 $backtopage = $backurlforlist;
110 $backtopage =
dol_buildpath(
'/workstation/workstation_card.php', 1).
'?id='.($id > 0 ? $id :
'__ID__');
115 $triggermodname =
'WORKSTATION_WORKSTATION_MODIFY';
118 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
121 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
124 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
130 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
132 if ($action ==
'confirm_enable' && $confirm ==
"yes" && $permissiontoadd) {
133 if (!empty($object->id)) {
134 $object->setStatus(1);
136 } elseif ($action ==
'confirm_disable' && $confirm ==
"yes" && $permissiontoadd) {
137 if (!empty($object->id)) {
138 $object->setStatus(0);
156 $title = $langs->trans(
"Workstation");
163 <script
type=
"text/javascript">
165 jQuery(document).ready(
function() {
166 jQuery(
"#type").change(
function() {
167 if($(
this).val() ===
'MACHINE') {
168 $(
'#usergroups').hide();
169 $(
'#nb_operators_required').parent(
'td').parent(
'tr').hide();
170 $(
'#wsresources').show();
171 }
else if($(
this).val() ===
'HUMAN') {
172 $(
'#wsresources').hide();
173 $(
'#nb_operators_required').parent(
'td').parent(
'tr').show();
174 $(
'#usergroups').show();
177 $(
'#usergroups').show();
178 $(
'#wsresources').show();
179 $(
'#nb_operators_required').parent(
'td').parent(
'tr').show();
182 jQuery(
"#type").trigger(
'change');
189 if ($action ==
'create') {
190 print
load_fiche_titre($langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"Workstation")),
'',
'object_'.$object->picto);
192 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
193 print
'<input type="hidden" name="token" value="'.newToken().
'">';
194 print
'<input type="hidden" name="action" value="add">';
196 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
198 if ($backtopageforcancel) {
199 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
204 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
207 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
209 print
'<tr id="usergroups"';
211 print $langs->trans(
'Groups');
215 print
$form->select_dolgroups($groups,
'groups', 1,
'', 0,
'',
'', $object->entity,
true,
'quatrevingtpercent widthcentpercentminusx');
218 print
'<tr id="wsresources"><td>';
219 print $langs->trans(
'Machines');
223 print $formresource->select_resource_list($resources,
'resources',
'',
'', 0,
'',
'', $object->entity,
true, 0,
'quatrevingtpercent widthcentpercentminusx',
true);
229 print
'</table>'.
"\n";
233 print
$form->buttonsSaveCancel(
"Create");
241 if (($id || $ref) && $action ==
'edit') {
242 print
load_fiche_titre($langs->trans(
"Workstation"),
'',
'object_'.$object->picto);
244 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
245 print
'<input type="hidden" name="token" value="'.newToken().
'">';
246 print
'<input type="hidden" name="action" value="update">';
247 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
249 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
251 if ($backtopageforcancel) {
252 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
257 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
260 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
262 print
'<tr id="usergroups"';
264 print $langs->trans(
'Groups');
268 print
$form->select_dolgroups(empty($groups) ? $object->usergroups : $groups,
'groups', 1,
'', 0,
'',
'', $object->entity,
true,
'quatrevingtpercent widthcentpercentminusx');
271 print
'<tr id="wsresources"><td>';
272 print $langs->trans(
'Machines');
276 print $formresource->select_resource_list(empty($resources) ? $object->resources : $resources,
'resources',
'',
'', 0,
'',
'', $object->entity,
true, 0,
'quatrevingtpercent widthcentpercentminusx',
true);
286 print
$form->buttonsSaveCancel();
292 if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
293 $res = $object->fetch_optionals();
296 print
dol_get_fiche_head($head,
'card', $langs->trans(
"Workstation"), -1, $object->picto);
301 if ($action ==
'delete') {
302 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteWorkstation'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
305 if ($action ==
'clone') {
307 $formquestion = array();
308 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
312 if ($action ==
'enable') {
313 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'EnableAWorkstation'), $langs->trans(
"ConfirmEnableWorkstation", $object->ref),
'confirm_enable', $formquestion, 0, 1, 220);
314 } elseif ($action ==
'disable') {
315 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DisableAWorkstation'), $langs->trans(
"ConfirmDisableWorkstation", $object->ref),
'confirm_disable', $formquestion, 0, 1, 220);
319 $parameters = array(
'formConfirm' =>
$formconfirm,
'lineid' => $lineid);
320 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
321 if (empty($reshook)) {
323 } elseif ($reshook > 0) {
333 $linkback =
'<a href="'.dol_buildpath(
'/workstation/workstation_list.php', 1).
'?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
335 $morehtmlref =
'<div class="refidno">';
370 $morehtmlref .=
'</div>';
373 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
376 print
'<div class="fichecenter">';
377 print
'<div class="fichehalfleft">';
378 print
'<div class="underbanner clearboth"></div>';
379 print
'<table class="border centpercent tableforfield">'.
"\n";
385 if ($object->type ===
'MACHINE') {
386 $object->fields[
'nb_operators_required'][
'visible'] = 0;
389 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
392 if ($object->type !==
'MACHINE') {
395 foreach ($object->usergroups as $id_group) {
396 $g->fetch($id_group);
397 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $g->getNomUrl(1,
'', 0,
'categtextwhite') .
'</li>';
400 print
'<tr><td>' . $langs->trans(
'Groups') .
'</td><td>';
401 print
'<div class="select2-container-multi-dolibarr"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
406 if ($object->type !==
'HUMAN') {
409 foreach ($object->resources as $id_resource) {
410 $r->fetch($id_resource);
411 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $r->getNomUrl(1,
'',
'', 0,
'categtextwhite') .
'</li>';
414 print
'<tr><td>' . $langs->trans(
'Machines') .
'</td><td>';
415 print
'<div class="select2-container-multi-dolibarr"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
420 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
426 print
'<div class="clearboth"></div>';
433 if ($action !=
'presend' && $action !=
'editline') {
434 print
'<div class="tabsAction">'.
"\n";
435 $parameters = array();
436 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
441 if (empty($reshook)) {
443 if ($permissiontoadd) {
444 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>'.
"\n";
446 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
'Modify').
'</a>'.
"\n";
450 if ($permissiontoadd) {
451 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=clone&token='.
newToken().
'&object=workstation">'.$langs->trans(
"ToClone").
'</a>'.
"\n";
455 if ($permissiontoadd) {
456 if ($object->status == $object::STATUS_ENABLED) {
457 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=disable&token='.
newToken().
'">'.$langs->trans(
"Disable").
'</a>'.
"\n";
459 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=enable&token='.
newToken().
'">'.$langs->trans(
"Enable").
'</a>'.
"\n";
465 if ($permissiontodelete) {
466 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.
newToken().
'">'.$langs->trans(
'Delete').
'</a>'.
"\n";
468 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
'Delete').
'</a>'.
"\n";