26 require
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/resource/class/html.formresource.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/resource/class/dolresource.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstation.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstationusergroup.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/workstation/lib/workstation_workstation.lib.php';
36 $langs->loadLangs(array(
'workstation',
'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');
67 foreach ($object->fields as $key => $val) {
68 if (
GETPOST(
'search_'.$key,
'alpha')) {
69 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
73 if (empty($action) && empty($id) && empty($ref)) {
78 include 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];
91 restrictedArea($user, $object->element, $object->id, $object->table_element,
'workstation',
'fk_soc',
'rowid', $isdraft);
98 $parameters = array();
99 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
104 if (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);
159 $title = $langs->trans(
"Workstation");
166 <script
type=
"text/javascript">
168 jQuery(document).ready(
function() {
169 jQuery(
"#type").change(
function() {
170 if($(
this).val() ===
'MACHINE') {
171 $(
'#usergroups').hide();
172 $(
'#nb_operators_required').parent(
'td').parent(
'tr').hide();
173 $(
'#wsresources').show();
174 }
else if($(
this).val() ===
'HUMAN') {
175 $(
'#wsresources').hide();
176 $(
'#nb_operators_required').parent(
'td').parent(
'tr').show();
177 $(
'#usergroups').show();
180 $(
'#usergroups').show();
181 $(
'#wsresources').show();
182 $(
'#nb_operators_required').parent(
'td').parent(
'tr').show();
185 jQuery(
"#type").trigger(
'change');
192 if ($action ==
'create') {
193 print
load_fiche_titre($langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"Workstation")),
'',
'object_'.$object->picto);
195 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
196 print
'<input type="hidden" name="token" value="'.newToken().
'">';
197 print
'<input type="hidden" name="action" value="add">';
199 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
201 if ($backtopageforcancel) {
202 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
207 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
210 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
212 print
'<tr id="usergroups"';
214 print $langs->trans(
'Groups');
218 print
$form->select_dolgroups($groups,
'groups', 1,
'', 0,
'',
'', $object->entity,
true,
'quatrevingtpercent widthcentpercentminusx');
221 print
'<tr id="wsresources"><td>';
222 print $langs->trans(
'Machines');
226 print $formresource->select_resource_list($resources,
'resources',
'',
'', 0,
'',
'', $object->entity,
true, 0,
'quatrevingtpercent widthcentpercentminusx',
true);
232 print
'</table>'.
"\n";
236 print
$form->buttonsSaveCancel(
"Create");
244 if (($id || $ref) && $action ==
'edit') {
245 print
load_fiche_titre($langs->trans(
"Workstation"),
'',
'object_'.$object->picto);
247 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
248 print
'<input type="hidden" name="token" value="'.newToken().
'">';
249 print
'<input type="hidden" name="action" value="update">';
250 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
252 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
254 if ($backtopageforcancel) {
255 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
260 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
263 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
265 print
'<tr id="usergroups"';
267 print $langs->trans(
'Groups');
271 print
$form->select_dolgroups(empty($groups) ? $object->usergroups : $groups,
'groups', 1,
'', 0,
'',
'', $object->entity,
true,
'quatrevingtpercent widthcentpercentminusx');
274 print
'<tr id="wsresources"><td>';
275 print $langs->trans(
'Machines');
279 print $formresource->select_resource_list(empty($resources) ? $object->resources : $resources,
'resources',
'',
'', 0,
'',
'', $object->entity,
true, 0,
'quatrevingtpercent widthcentpercentminusx',
true);
289 print
$form->buttonsSaveCancel();
295 if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
296 $res = $object->fetch_optionals();
299 print
dol_get_fiche_head($head,
'card', $langs->trans(
"Workstation"), -1, $object->picto);
304 if ($action ==
'delete') {
305 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteWorkstation'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
308 if ($action ==
'clone') {
310 $formquestion = array();
311 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
315 if ($action ==
'enable') {
316 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'EnableAWorkstation'), $langs->trans(
"ConfirmEnableWorkstation", $object->ref),
'confirm_enable', $formquestion, 0, 1, 220);
317 } elseif ($action ==
'disable') {
318 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DisableAWorkstation'), $langs->trans(
"ConfirmDisableWorkstation", $object->ref),
'confirm_disable', $formquestion, 0, 1, 220);
322 $parameters = array(
'formConfirm' =>
$formconfirm,
'lineid' => $lineid);
323 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
324 if (empty($reshook)) {
326 } elseif ($reshook > 0) {
336 $linkback =
'<a href="'.dol_buildpath(
'/workstation/workstation_list.php', 1).
'?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
338 $morehtmlref =
'<div class="refidno">';
373 $morehtmlref .=
'</div>';
376 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
379 print
'<div class="fichecenter">';
380 print
'<div class="fichehalfleft">';
381 print
'<div class="underbanner clearboth"></div>';
382 print
'<table class="border centpercent tableforfield">'.
"\n";
388 if ($object->type ===
'MACHINE') {
389 $object->fields[
'nb_operators_required'][
'visible'] = 0;
392 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
395 if ($object->type !==
'MACHINE') {
398 foreach ($object->usergroups as $id_group) {
399 $g->fetch($id_group);
400 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $g->getNomUrl(1,
'', 0,
'categtextwhite') .
'</li>';
403 print
'<tr><td>' . $langs->trans(
'Groups') .
'</td><td>';
404 print
'<div class="select2-container-multi-dolibarr"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
409 if ($object->type !==
'HUMAN') {
412 foreach ($object->resources as $id_resource) {
413 $r->fetch($id_resource);
414 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $r->getNomUrl(1,
'',
'', 0,
'categtextwhite') .
'</li>';
417 print
'<tr><td>' . $langs->trans(
'Machines') .
'</td><td>';
418 print
'<div class="select2-container-multi-dolibarr"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
423 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
429 print
'<div class="clearboth"></div>';
436 if ($action !=
'presend' && $action !=
'editline') {
437 print
'<div class="tabsAction">'.
"\n";
438 $parameters = array();
439 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
444 if (empty($reshook)) {
446 if ($permissiontoadd) {
447 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>'.
"\n";
449 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
'Modify').
'</a>'.
"\n";
453 if ($permissiontoadd) {
454 print
dolGetButtonAction($langs->trans(
"ToClone"),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&socid='.$object->socid.
'&action=clone&object=workstation',
'clone', $permissiontoadd);
458 if ($permissiontoadd) {
459 if ($object->status == $object::STATUS_ENABLED) {
460 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=disable&token='.
newToken().
'">'.$langs->trans(
"Disable").
'</a>'.
"\n";
462 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=enable&token='.
newToken().
'">'.$langs->trans(
"Enable").
'</a>'.
"\n";
467 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.
newToken(),
'delete', $permissiontodelete);
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
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.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
$formconfirm
if ($action == 'delbookkeepingyear') {
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.