30 require
'../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formcompany.class.php';
33 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formfile.class.php';
34 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
35 require_once DOL_DOCUMENT_ROOT .
'/hrm/class/job.class.php';
36 require_once DOL_DOCUMENT_ROOT .
'/hrm/lib/hrm_job.lib.php';
39 $langs->loadLangs(array(
"hrm",
"other",
'products'));
44 $action =
GETPOST(
'action',
'aZ09');
45 $confirm =
GETPOST(
'confirm',
'alpha');
46 $cancel =
GETPOST(
'cancel',
'aZ09');
47 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'jobcard';
48 $backtopage =
GETPOST(
'backtopage',
'alpha');
49 $backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
53 $object =
new Job($db);
55 $diroutputmassaction = $conf->hrm->dir_output .
'/temp/massgeneration/' . $user->id;
56 $hookmanager->initHooks(array(
'jobcard',
'globalcard'));
59 $extrafields->fetch_name_optionals_label($object->table_element);
61 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
64 $search_all =
GETPOST(
"search_all",
'alpha');
66 foreach ($object->fields as $key => $val) {
67 if (
GETPOST(
'search_' . $key,
'alpha')) {
68 $search[$key] =
GETPOST(
'search_' . $key,
'alpha');
72 if (empty($action) && empty($id) && empty($ref)) {
77 include DOL_DOCUMENT_ROOT .
'/core/actions_fetchobject.inc.php';
80 $permissiontoread = $user->rights->hrm->all->read;
81 $permissiontoadd = $user->rights->hrm->all->write;
82 $permissiontodelete = $user->rights->hrm->all->delete;
83 $upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1] .
'/job';
91 if (!$permissiontoread || ($action ===
'create' && !$permissiontoadd))
accessforbidden();
98 $parameters = array();
99 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
104 if (empty($reshook)) {
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(
'/hrm/job_card.php', 1) .
'?id=' . ($id > 0 ? $id :
'__ID__');
119 $triggermodname =
'hrm_JOB_MODIFY';
123 include DOL_DOCUMENT_ROOT .
'/core/actions_addupdatedelete.inc.php';
126 include DOL_DOCUMENT_ROOT .
'/core/actions_dellink.inc.php';
129 include DOL_DOCUMENT_ROOT .
'/core/actions_printing.inc.php';
135 include DOL_DOCUMENT_ROOT .
'/core/actions_builddoc.inc.php';
137 if ($action ==
'set_thirdparty' && $permissiontoadd) {
138 $object->setValueFrom(
'fk_soc',
GETPOST(
'fk_soc',
'int'),
'',
'',
'date',
'', $user, $triggermodname);
140 if ($action ==
'classin' && $permissiontoadd) {
141 $object->setProject(
GETPOST(
'projectid',
'int'));
145 $triggersendname =
'hrm_JOB_SENTBYMAIL';
146 $autocopy =
'MAIN_MAIL_AUTOCOPY_JOB_TO';
147 $trackid =
'job' . $object->id;
148 include DOL_DOCUMENT_ROOT .
'/core/actions_sendmails.inc.php';
162 $title = $langs->trans(
"Job");
183 if ($action ==
'create') {
184 print
load_fiche_titre($langs->trans(
"NewObject", $langs->transnoentities(
'Job')),
'',
'object_' . $object->picto);
186 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
187 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
188 print
'<input type="hidden" name="action" value="add">';
190 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
192 if ($backtopageforcancel) {
193 print
'<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel .
'">';
198 print
'<table class="border centpercent tableforfieldcreate">' .
"\n";
201 include DOL_DOCUMENT_ROOT .
'/core/tpl/commonfields_add.tpl.php';
204 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_add.tpl.php';
206 print
'</table>' .
"\n";
210 print
'<div class="center">';
211 print
'<input type="submit" class="button" name="add" value="' .
dol_escape_htmltag($langs->trans(
"Create")) .
'">';
213 print
'<input type="' . ($backtopage ?
"submit" :
"button") .
'" class="button button-cancel" name="cancel" value="' .
dol_escape_htmltag($langs->trans(
"Cancel")) .
'"' . ($backtopage ?
'' :
' onclick="javascript:history.go(-1)"') .
'>';
222 if (($id || $ref) && $action ==
'edit') {
223 print
load_fiche_titre($langs->trans(
"Job"),
'',
'object_' . $object->picto);
225 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
226 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
227 print
'<input type="hidden" name="action" value="update">';
228 print
'<input type="hidden" name="id" value="' . $object->id .
'">';
230 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
232 if ($backtopageforcancel) {
233 print
'<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel .
'">';
238 print
'<table class="border centpercent tableforfieldedit">' .
"\n";
241 include DOL_DOCUMENT_ROOT .
'/core/tpl/commonfields_edit.tpl.php';
244 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_edit.tpl.php';
250 print
'<div class="center"><input type="submit" class="button button-save" name="save" value="' . $langs->trans(
"Save") .
'">';
251 print
' <input type="submit" class="button button-cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
258 if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
259 $res = $object->fetch_optionals();
262 $picto =
'company.png';
263 print
dol_get_fiche_head($head,
'job_card', $langs->trans(
"Workstation"), -1, $object->picto);
268 if ($action ==
'delete') {
269 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' . $object->id, $langs->trans(
'DeleteJob'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
272 if ($action ==
'deleteline') {
273 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' . $object->id .
'&lineid=' . $lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
276 if ($action ==
'clone') {
278 $formquestion = array();
279 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' . $object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
283 if ($action ==
'xxx') {
284 $formquestion = array();
295 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' . $object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
299 $parameters = array(
'formConfirm' =>
$formconfirm,
'lineid' => $lineid);
300 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
301 if (empty($reshook)) {
303 } elseif ($reshook > 0) {
313 $linkback =
'<a href="' .
dol_buildpath(
'/hrm/job_list.php', 1) .
'?restore_lastsearch_values=1' . (!empty($socid) ?
'&socid=' . $socid :
'') .
'">' . $langs->trans(
"BackToList") .
'</a>';
315 $morehtmlref =
'<div class="refid">';
316 $morehtmlref.= $object->label;
317 $morehtmlref .=
'</div>';
320 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'rowid', $morehtmlref);
323 print
'<div class="fichecenter">';
324 print
'<div class="fichehalfleft">';
325 print
'<div class="underbanner clearboth"></div>';
326 print
'<table class="border centpercent tableforfield">' .
"\n";
332 $object->fields[
'label'][
'visible']=0;
333 include DOL_DOCUMENT_ROOT .
'/core/tpl/commonfields_view.tpl.php';
336 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
342 print
'<div class="clearboth"></div>';
351 if (!empty($object->table_element_line)) {
353 $result = $object->getLinesArray();
355 print
' <form name="addproduct" id="addproduct" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' . $object->id . (($action !=
'editline') ?
'' :
'#line_' .
GETPOST(
'lineid',
'int')) .
'" method="POST">
356 <input type="hidden" name="token" value="' .
newToken() .
'">
357 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline') .
'">
358 <input type="hidden" name="mode" value="">
359 <input type="hidden" name="page_y" value="">
360 <input type="hidden" name="id" value="' . $object->id .
'">
363 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
364 include DOL_DOCUMENT_ROOT .
'/core/tpl/ajaxrow.tpl.php';
367 print
'<div class="div-table-responsive-no-min">';
368 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
369 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
372 if (!empty($object->lines)) {
373 $object->printObjectLines($action, $mysoc,
null,
GETPOST(
'lineid',
'int'), 1);
377 if ($object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
378 if ($action !=
'editline') {
381 $parameters = array();
382 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
383 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
385 $object->formAddObjectLine(1, $mysoc, $soc);
389 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
400 if ($action !=
'presend' && $action !=
'editline') {
401 print
'<div class="tabsAction">' .
"\n";
402 $parameters = array();
403 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
408 if (empty($reshook)) {
410 if ($object->status == $object::STATUS_VALIDATED) {
411 print
dolGetButtonAction($langs->trans(
'SetToDraft'),
'',
'default', $_SERVER[
"PHP_SELF"] .
'?id=' . $object->id .
'&action=confirm_setdraft&confirm=yes&token=' .
newToken(),
'', $permissiontoadd);
414 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
"PHP_SELF"] .
'?id=' . $object->id .
'&action=edit&token=' .
newToken(),
'', $permissiontoadd);
417 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id .
'&action=delete&token=' .
newToken(),
'', $permissiontodelete);
419 print
'</div>' .
"\n";
424 if (
GETPOST(
'modelselected')) {
428 if ($action !=
'presend') {
429 print
'<div class="fichecenter"><div class="fichehalfleft">';
430 print
'<a name="builddoc"></a>';
432 $includedocgeneration = 0;
435 if ($includedocgeneration) {
437 $relativepath = $objref .
'/' . $objref .
'.pdf';
438 $filedir = $conf->hrm->dir_output .
'/' . $object->element .
'/' . $objref;
439 $urlsource = $_SERVER[
"PHP_SELF"] .
"?id=" . $object->id;
440 $genallowed = $user->rights->hrm->job->read;
441 $delallowed = $user->rights->hrm->job->write;
442 print $formfile->showdocuments(
'hrm:Job', $object->element .
'/' . $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
446 $linktoelem =
$form->showLinkToObjectBlock($object,
null, array(
'job'));
447 $somethingshown =
$form->showLinkedObjectBlock($object, $linktoelem);
450 print
'</div><div class="fichehalfright">';
454 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/hrm/job_agenda.php?id='.$object->id);
457 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formactions.class.php';
459 $somethingshown =
$formactions->showactions($object, $object->element .
'@' . $object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
461 print
'</div></div>';
466 $defaulttopic =
'InformationMessage';
467 $diroutput = $conf->hrm->dir_output;
468 $trackid =
'job' . $object->id;
470 include DOL_DOCUMENT_ROOT .
'/core/tpl/card_presend.tpl.php';