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';
36$langs->loadLangs(array(
'mrp',
'other'));
41$action =
GETPOST(
'action',
'aZ09');
42$confirm =
GETPOST(
'confirm',
'alpha');
43$cancel =
GETPOST(
'cancel',
'aZ09');
44$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'workstationcard';
45$backtopage =
GETPOST(
'backtopage',
'alpha');
46$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
48$groups =
GETPOST(
'groups',
'array:int');
49$resources =
GETPOST(
'resources',
'array:int');
56$diroutputmassaction = $conf->workstation->dir_output.
'/temp/massgeneration/'.$user->id;
57$hookmanager->initHooks(array(
'workstationcard',
'globalcard'));
60$extrafields->fetch_name_optionals_label($object->table_element);
62$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
65$search_all =
GETPOST(
"search_all",
'alpha');
67foreach ($object->fields as $key => $val) {
68 if (
GETPOST(
'search_'.$key,
'alpha')) {
69 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
73if (empty($action) && empty($id) && empty($ref)) {
78include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
81$permissiontoread = $user->rights->workstation->workstation->read;
82$permissiontoadd = $user->rights->workstation->workstation->write;
83$permissiontodelete = $user->rights->workstation->workstation->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
84$permissionnote = $user->rights->workstation->workstation->write;
85$permissiondellink = $user->rights->workstation->workstation->write;
87$upload_dir = $conf->workstation->multidir_output[isset($object->entity) ? $object->entity : 1];
91restrictedArea($user, $object->element, $object->id, $object->table_element,
'workstation',
'fk_soc',
'rowid', $isdraft);
99$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
104if (empty($reshook)) {
107 $backurlforlist =
dol_buildpath(
'/workstation/workstation_list.php', 1);
109 if (empty($backtopage) || ($cancel && empty($id))) {
110 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
111 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
112 $backtopage = $backurlforlist;
114 $backtopage =
dol_buildpath(
'/workstation/workstation_card.php', 1).
'?id='.($id > 0 ? $id :
'__ID__');
119 $triggermodname =
'WORKSTATION_WORKSTATION_MODIFY';
122 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
125 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
128 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
134 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
136 if ($action ==
'confirm_enable' && $confirm ==
"yes" && $permissiontoadd) {
137 if (!empty($object->id)) {
138 $object->setStatus(1);
140 } elseif ($action ==
'confirm_disable' && $confirm ==
"yes" && $permissiontoadd) {
141 if (!empty($object->id)) {
142 $object->setStatus(0);
153$form =
new Form($db);
157$title = $langs->trans(
"Workstation");
158$help_url =
'EN:Module_Workstation';
164 <script
type=
"text/javascript">
166 jQuery(document).ready(
function() {
167 jQuery(
"#type").change(
function() {
168 if($(
this).val() ===
'MACHINE') {
169 $(
'#usergroups').hide();
170 $(
'#nb_operators_required').parent(
'td').parent(
'tr').hide();
171 $(
'#wsresources').show();
172 }
else if($(
this).val() ===
'HUMAN') {
173 $(
'#wsresources').hide();
174 $(
'#nb_operators_required').parent(
'td').parent(
'tr').show();
175 $(
'#usergroups').show();
178 $(
'#usergroups').show();
179 $(
'#wsresources').show();
180 $(
'#nb_operators_required').parent(
'td').parent(
'tr').show();
183 jQuery(
"#type").trigger(
'change');
190if ($action ==
'create') {
192 $object->fields[
'ref'][
'default'] = $object->getNextNumRef();
194 print
load_fiche_titre($langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"Workstation")),
'',
'object_'.$object->picto);
196 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
197 print
'<input type="hidden" name="token" value="'.newToken().
'">';
198 print
'<input type="hidden" name="action" value="add">';
200 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
202 if ($backtopageforcancel) {
203 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
208 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
211 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
213 print
'<tr id="usergroups"';
215 print $langs->trans(
'Groups');
219 print $form->select_dolgroups($groups,
'groups', 1,
'', 0,
'',
'', $object->entity,
true,
'quatrevingtpercent widthcentpercentminusx');
222 print
'<tr id="wsresources"><td>';
223 print $langs->trans(
'Machines');
227 print $formresource->select_resource_list($resources,
'resources',
'',
'', 0,
'',
'', $object->entity,
true, 0,
'quatrevingtpercent widthcentpercentminusx',
true);
233 print
'</table>'.
"\n";
237 print $form->buttonsSaveCancel(
"Create");
245if (($id || $ref) && $action ==
'edit') {
246 print
load_fiche_titre($langs->trans(
"Workstation"),
'',
'object_'.$object->picto);
248 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
249 print
'<input type="hidden" name="token" value="'.newToken().
'">';
250 print
'<input type="hidden" name="action" value="update">';
251 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
253 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
255 if ($backtopageforcancel) {
256 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
261 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
264 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
266 print
'<tr id="usergroups"';
268 print $langs->trans(
'Groups');
272 print $form->select_dolgroups(empty($groups) ? $object->usergroups : $groups,
'groups', 1,
'', 0,
'',
'', $object->entity, true,
'quatrevingtpercent widthcentpercentminusx');
275 print
'<tr id="wsresources"><td>';
276 print $langs->trans(
'Machines');
280 print $formresource->select_resource_list(empty($resources) ? $object->resources : $resources,
'resources',
'',
'', 0,
'',
'', $object->entity, true, 0,
'quatrevingtpercent widthcentpercentminusx', true);
290 print $form->buttonsSaveCancel();
296if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
297 $res = $object->fetch_optionals();
300 print
dol_get_fiche_head($head,
'card', $langs->trans(
"Workstation"), -1, $object->picto);
305 if ($action ==
'delete') {
306 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteWorkstation'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
309 if ($action ==
'clone') {
311 $formquestion = array();
312 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
316 if ($action ==
'enable') {
317 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'EnableAWorkstation'), $langs->trans(
"ConfirmEnableWorkstation", $object->ref),
'confirm_enable', $formquestion, 0, 1, 220);
318 } elseif ($action ==
'disable') {
319 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DisableAWorkstation'), $langs->trans(
"ConfirmDisableWorkstation", $object->ref),
'confirm_disable', $formquestion, 0, 1, 220);
323 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
324 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
325 if (empty($reshook)) {
326 $formconfirm .= $hookmanager->resPrint;
327 } elseif ($reshook > 0) {
328 $formconfirm = $hookmanager->resPrint;
337 $linkback =
'<a href="'.dol_buildpath(
'/workstation/workstation_list.php', 1).
'?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
339 $morehtmlref =
'<div class="refidno">';
374 $morehtmlref .=
'</div>';
377 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
380 print
'<div class="fichecenter">';
381 print
'<div class="fichehalfleft">';
382 print
'<div class="underbanner clearboth"></div>';
383 print
'<table class="border centpercent tableforfield">'.
"\n";
389 if ($object->type ===
'MACHINE') {
390 $object->fields[
'nb_operators_required'][
'visible'] = 0;
393 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
396 if ($object->type !==
'MACHINE') {
399 foreach ($object->usergroups as $id_group) {
400 $g->fetch($id_group);
401 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $g->getNomUrl(1,
'', 0,
'categtextwhite') .
'</li>';
404 print
'<tr><td>' . $langs->trans(
'Groups') .
'</td><td>';
405 print
'<div class="select2-container-multi-dolibarr"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
410 if ($object->type !==
'HUMAN') {
413 foreach ($object->resources as $id_resource) {
414 $r->fetch($id_resource);
415 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $r->getNomUrl(1,
'',
'', 0,
'categtextwhite') .
'</li>';
418 print
'<tr><td>' . $langs->trans(
'Machines') .
'</td><td>';
419 print
'<div class="select2-container-multi-dolibarr"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
424 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
430 print
'<div class="clearboth"></div>';
437 if ($action !=
'presend' && $action !=
'editline') {
438 print
'<div class="tabsAction">'.
"\n";
439 $parameters = array();
440 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
445 if (empty($reshook)) {
447 if ($permissiontoadd) {
448 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit&token='.newToken().
'">'.$langs->trans(
"Modify").
'</a>'.
"\n";
450 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
'Modify').
'</a>'.
"\n";
454 if ($permissiontoadd) {
455 print
dolGetButtonAction($langs->trans(
"ToClone"),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&socid='.$object->socid.
'&action=clone&object=workstation',
'clone', $permissiontoadd);
459 if ($permissiontoadd) {
460 if ($object->status == $object::STATUS_ENABLED) {
461 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=disable&token='.newToken().
'">'.$langs->trans(
"Disable").
'</a>'.
"\n";
463 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=enable&token='.newToken().
'">'.$langs->trans(
"Enable").
'</a>'.
"\n";
468 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.newToken(),
'delete', $permissiontodelete);
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.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
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.
workstationPrepareHead($object)
Prepare array of tabs for Workstation.