26require
'../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/resource/class/html.formresource.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/resource/class/dolresource.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstation.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstationusergroup.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/workstation/lib/workstation_workstation.lib.php';
35global $conf, $db, $hookmanager, $langs, $user;
38$langs->loadLangs(array(
'mrp',
'other'));
43$action =
GETPOST(
'action',
'aZ09');
44$confirm =
GETPOST(
'confirm',
'alpha');
45$cancel =
GETPOST(
'cancel',
'aZ09');
46$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
47$backtopage =
GETPOST(
'backtopage',
'alpha');
48$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
49$backtopagejsfields =
GETPOST(
'backtopagejsfields',
'alpha');
50$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
52if (!empty($backtopagejsfields)) {
53 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
54 $dol_openinpopup = $tmpbacktopagejsfields[0];
57$groups =
GETPOST(
'groups',
'array:int');
58$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') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DISABLED);
93$permissionnote = $user->hasRight(
'workstation',
'workstation',
'write');
94$permissiondellink = $user->hasRight(
'workstation',
'workstation',
'write');
96$upload_dir = $conf->workstation->multidir_output[isset($object->entity) ? $object->entity : 1];
100restrictedArea($user, $object->element, $object->id, $object->table_element,
'workstation',
'fk_soc',
'rowid', $isdraft);
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';
131 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
134 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
137 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
143 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
145 if ($action ==
'confirm_enable' && $confirm ==
"yes" && $permissiontoadd) {
146 if (!empty($object->id)) {
147 $object->setStatus(1);
149 } elseif ($action ==
'confirm_disable' && $confirm ==
"yes" && $permissiontoadd) {
150 if (!empty($object->id)) {
151 $object->setStatus(0);
162$form =
new Form($db);
166$title = $langs->trans(
"Workstation").
" - ".$langs->trans(
'Card');
167if ($action ==
'create') {
168 $title = $langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"Workstation"));
170$help_url =
'EN:Module_Workstation';
178 jQuery(document).ready(
function() {
179 jQuery(
"#type").change(
function() {
180 if($(
this).val() ===
'MACHINE') {
181 $(
'#usergroups').hide();
182 $(
'#nb_operators_required').parent(
'td').parent(
'tr').hide();
183 $(
'#wsresources').show();
184 }
else if($(
this).val() ===
'HUMAN') {
185 $(
'#wsresources').hide();
186 $(
'#nb_operators_required').parent(
'td').parent(
'tr').show();
187 $(
'#usergroups').show();
190 $(
'#usergroups').show();
191 $(
'#wsresources').show();
192 $(
'#nb_operators_required').parent(
'td').parent(
'tr').show();
195 jQuery(
"#type").trigger(
'change');
202if ($action ==
'create') {
203 if (empty($permissiontoadd)) {
208 $object->fields[
'ref'][
'default'] = $object->getNextNumRef();
212 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
213 print
'<input type="hidden" name="token" value="'.newToken().
'">';
214 print
'<input type="hidden" name="action" value="add">';
216 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
218 if ($backtopageforcancel) {
219 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
224 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
227 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
229 print
'<tr id="usergroups"';
231 print $langs->trans(
'Groups');
235 print $form->select_dolgroups($groups,
'groups', 1,
'', 0,
'',
'', $object->entity,
true,
'quatrevingtpercent widthcentpercentminusx');
238 print
'<tr id="wsresources"><td>';
239 print $langs->trans(
'Machines');
243 print $formresource->select_resource_list($resources,
'resources',
'',
'', 0,
'',
'', $object->entity,
true, 0,
'quatrevingtpercent widthcentpercentminusx',
true);
247 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
249 print
'</table>'.
"\n";
253 print $form->buttonsSaveCancel(
"Create");
261if (($id || $ref) && $action ==
'edit') {
262 print
load_fiche_titre($langs->trans(
"Workstation"),
'',
'object_'.$object->picto);
264 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
265 print
'<input type="hidden" name="token" value="'.newToken().
'">';
266 print
'<input type="hidden" name="action" value="update">';
267 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
269 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
271 if ($backtopageforcancel) {
272 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
277 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
280 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
282 print
'<tr id="usergroups"';
284 print $langs->trans(
'Groups');
288 print $form->select_dolgroups(empty($groups) ? $object->usergroups : $groups,
'groups', 1,
'', 0,
'',
'', $object->entity, true,
'quatrevingtpercent widthcentpercentminusx');
291 print
'<tr id="wsresources"><td>';
292 print $langs->trans(
'Machines');
296 print $formresource->select_resource_list(empty($resources) ? $object->resources : $resources,
'resources',
'',
'', 0,
'',
'', $object->entity, true, 0,
'quatrevingtpercent widthcentpercentminusx', true);
300 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
306 print $form->buttonsSaveCancel();
312if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
315 print
dol_get_fiche_head($head,
'card', $langs->trans(
"Workstation"), -1, $object->picto);
320 if ($action ==
'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) {
321 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteWorkstation'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0,
'action-delete');
324 if ($action ==
'clone') {
326 $formquestion = array();
327 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
331 if ($action ==
'enable') {
332 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'EnableAWorkstation'), $langs->trans(
"ConfirmEnableWorkstation", $object->ref),
'confirm_enable', $formquestion, 0, 1, 220);
333 } elseif ($action ==
'disable') {
334 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DisableAWorkstation'), $langs->trans(
"ConfirmDisableWorkstation", $object->ref),
'confirm_disable', $formquestion, 0, 1, 220);
338 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
339 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
340 if (empty($reshook)) {
341 $formconfirm .= $hookmanager->resPrint;
342 } elseif ($reshook > 0) {
343 $formconfirm = $hookmanager->resPrint;
352 $linkback =
'<a href="'.dol_buildpath(
'/workstation/workstation_list.php', 1).
'?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
354 $morehtmlref =
'<div class="refidno">';
384 $morehtmlref .=
'</div>';
387 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
390 print
'<div class="fichecenter">';
391 print
'<div class="fichehalfleft">';
392 print
'<div class="underbanner clearboth"></div>';
393 print
'<table class="border centpercent tableforfield">'.
"\n";
399 if ($object->type ===
'MACHINE') {
400 $object->fields[
'nb_operators_required'][
'visible'] = 0;
407 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
410 if ($object->type !==
'MACHINE') {
413 foreach ($object->usergroups as $id_group) {
414 $g->fetch($id_group);
415 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $g->getNomUrl(1,
'', 0,
'categtextwhite') .
'</li>';
418 print
'<tr><td>' . $langs->trans(
'Groups') .
'</td><td>';
419 print
'<div class="select2-container-multi-dolibarr"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
424 if ($object->type !==
'HUMAN') {
427 foreach ($object->resources as $id_resource) {
428 $r->fetch($id_resource);
429 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $r->getNomUrl(1,
'',
'', 0,
'categtextwhite') .
'</li>';
432 print
'<tr><td>' . $langs->trans(
'Machines') .
'</td><td>';
433 print
'<div class="select2-container-multi-dolibarr"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
438 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
444 print
'<div class="clearboth"></div>';
451 if ($action !=
'presend' && $action !=
'editline') {
452 print
'<div class="tabsAction">'.
"\n";
453 $parameters = array();
454 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
459 if (empty($reshook)) {
461 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit&token='.newToken(),
'', $permissiontoadd);
464 if ($permissiontoadd) {
465 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.(!empty($object->socid) ?
'&socid='.$object->socid :
'').
'&action=clone&token='.newToken(),
'', $permissiontoadd);
469 if ($permissiontoadd) {
470 if ($object->status == $object::STATUS_ENABLED) {
471 print
dolGetButtonAction(
'', $langs->trans(
'Disable'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=disable&token='.newToken(),
'', $permissiontoadd);
473 print
dolGetButtonAction(
'', $langs->trans(
'Enable'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=enable&token='.newToken(),
'', $permissiontoadd);
478 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.newToken();
479 $buttonId =
'action-delete-no-ajax';
480 if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) {
482 $buttonId =
'action-delete';
485 print
dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $deleteUrl, $buttonId, $permissiontodelete, $params);
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.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
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.