' . "\n";
- // Common attributes
- //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
- //unset($object->fields['fk_project']); // Hide field already shown in banner
- //unset($object->fields['fk_soc']); // Hide field already shown in banner
- $object->fields['label']['visible']=0; // Already in banner
- include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
+ // Common attributes
+ //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
+ //unset($object->fields['fk_project']); // Hide field already shown in banner
+ //unset($object->fields['fk_soc']); // Hide field already shown in banner
+ $object->fields['label']['visible']=0; // Already in banner
+ include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
- // Other attributes. Fields from hook formObjectOptions and Extrafields.
- include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
+ // Other attributes. Fields from hook formObjectOptions and Extrafields.
+ include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
- print '
';
- print '
';
+ print '
';
+ print '
';
+ print '
';
+
+ print '';
+
+ print dol_get_fiche_end();
+
+
+ // List of positions
+
+ $object = $objectposition;
+
+
+ //$help_url="EN:Module_Position|FR:Module_Position_FR|ES:Módulo_Position";
+ $help_url = '';
+ $title = $langs->trans("Positions");
+ $morejs = array();
+ $morecss = array();
+
+
+ // Build and execute select
+ // --------------------------------------------------------------------
+ $sql = 'SELECT ';
+ $sql .= $object->getFieldList('t');
+ // Add fields from extrafields
+ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
+ foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
+ $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef." . $key . " as options_" . $key . ', ' : '');
+ }
+ }
+ // Add fields from hooks
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
+ $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
+ $sql = preg_replace('/,\s*$/', '', $sql);
+ $sql .= " FROM " . MAIN_DB_PREFIX . $object->table_element . " as t";
+ if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
+ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $object->table_element . "_extrafields as ef on (t.rowid = ef.fk_object)";
+ }
+ // Add table from hooks
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
+ $sql .= $hookmanager->resPrint;
+ if ($object->ismultientitymanaged == 1) {
+ $sql .= " WHERE t.entity IN (" . getEntity($object->element) . ")";
+ } else {
+ $sql .= " WHERE 1 = 1";
+ }
+ $sql .= " AND t.fk_job = " . ((int) $fk_job) . " ";
+
+ foreach ($search as $key => $val) {
+ if (array_key_exists($key, $object->fields)) {
+ if ($key == 'status' && $search[$key] == -1) {
+ continue;
+ }
+ $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
+ if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
+ if ($search[$key] == '-1' || $search[$key] === '0') {
+ $search[$key] = '';
+ }
+ $mode_search = 2;
+ }
+ if ($search[$key] != '') {
+ $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
+ }
+ } else {
+ if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
+ $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
+ if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
+ if (preg_match('/_dtstart$/', $key)) {
+ $sql .= " AND t." . $columnName . " >= '" . $db->idate($search[$key]) . "'";
+ }
+ if (preg_match('/_dtend$/', $key)) {
+ $sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'";
+ }
+ }
+ }
+ }
+ }
+ if ($search_all) {
+ $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
+ }
+ //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
+ // Add where from extra fields
+ include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_sql.tpl.php';
+ // Add where from hooks
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
+ $sql .= $hookmanager->resPrint;
+
+ $sql .= $db->order($sortfield, $sortorder);
+
+ // Count total nb of records
+ $nbtotalofrecords = '';
+ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
+ $resql = $db->query($sql);
+ $nbtotalofrecords = $db->num_rows($resql);
+ if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
+ $page = 0;
+ $offset = 0;
+ }
+ }
+ // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
+ if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
+ $num = $nbtotalofrecords;
+ } else {
+ if ($limit) {
+ $sql .= $db->plimit($limit + 1, $offset);
+ }
+
+ $resql = $db->query($sql);
+ if (!$resql) {
+ dol_print_error($db);
+ exit;
+ }
+
+ $num = $db->num_rows($resql);
+ }
+
+ // Direct jump if only one record found
+ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
+ $obj = $db->fetch_object($resql);
+ $id = $obj->rowid;
+ header("Location: " . dol_buildpath('/hrm/position.php', 1) . '?id=' . $id);
+ exit;
+ }
+
+ $arrayofselected = is_array($toselect) ? $toselect : array();
+
+ $param = 'fk_job=' . $fk_job;
+ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
+ $param .= '&contextpage=' . urlencode($contextpage);
+ }
+ if ($limit > 0 && $limit != $conf->liste_limit) {
+ $param .= '&limit=' . urlencode($limit);
+ }
+ foreach ($search as $key => $val) {
+ if (is_array($search[$key]) && count($search[$key])) {
+ foreach ($search[$key] as $skey) {
+ $param .= '&search_' . $key . '[]=' . urlencode($skey);
+ }
+ } else {
+ $param .= '&search_' . $key . '=' . urlencode($search[$key]);
+ }
+ }
+ if ($optioncss != '') {
+ $param .= '&optioncss=' . urlencode($optioncss);
+ }
+ // Add $param from extra fields
+ include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php';
+ // Add $param from hooks
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
+ $param .= $hookmanager->resPrint;
+
+ // List of mass actions available
+ $arrayofmassactions = array(
+ //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
+ //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
+ //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
+ //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
+ );
+ if ($permissiontodelete) {
+ $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"') . $langs->trans("Delete");
+ }
+ if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
+ $arrayofmassactions = array();
+ }
+ $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
+
+ print '' . "\n";
+
+ if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
+ $hidegeneratedfilelistifempty = 1;
+ if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
+ $hidegeneratedfilelistifempty = 0;
+ }
+
+ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
+ $formfile = new FormFile($db);
+
+ // Show list of available documents
+ $urlsource = $_SERVER['PHP_SELF'] . '?sortfield=' . $sortfield . '&sortorder=' . $sortorder;
+ $urlsource .= str_replace('&', '&', $param);
+
+ $filedir = $diroutputmassaction;
+ $genallowed = $permissiontoread;
+ $delallowed = $permissiontoadd;
+
+ print $formfile->showdocuments('massfilesarea_hrm', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
+ }
}
+
+
/**
* Show a list of positions for the current job
*
@@ -276,16 +790,6 @@ function DisplayPositionList()
{
global $user, $langs, $db, $conf, $extrafields, $hookmanager, $permissiontoadd, $permissiontodelete;
- require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
- require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
- require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
-
- // load hrm libraries
- require_once __DIR__ . '/class/position.class.php';
-
- // for other modules
- //dol_include_once('/othermodule/class/otherobject.class.php');
-
$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
@@ -389,68 +893,6 @@ function DisplayPositionList()
//if (!$permissiontoread) accessforbidden();
- /*
- * Actions
- */
-
- if (GETPOST('cancel', 'alpha')) {
- $action = 'list';
- $massaction = '';
- }
- if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
- $massaction = '';
- }
-
- $parameters = array();
- $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- }
-
- if (empty($reshook)) {
- // Selection of new fields
- include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php';
-
- // Purge search criteria
- if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
- foreach ($object->fields as $key => $val) {
- $search[$key] = '';
- if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
- $search[$key . '_dtstart'] = '';
- $search[$key . '_dtend'] = '';
- }
- }
- $toselect = array();
- $search_array_options = array();
- }
- if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
- || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
- $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
- }
-
- // Mass actions
- $objectclass = 'Position';
- $objectlabel = 'Position';
- $uploaddir = $conf->hrm->dir_output;
- include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php';
- }
-
-
- /*
- * View
- */
-
- $form = new Form($db);
-
- $now = dol_now();
-
- //$help_url="EN:Module_Position|FR:Module_Position_FR|ES:Módulo_Position";
- $help_url = '';
- $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Positions"));
- $morejs = array();
- $morecss = array();
-
-
// Build and execute select
// --------------------------------------------------------------------
$sql = 'SELECT ';
@@ -898,50 +1340,6 @@ function DisplayPositionList()
}
}
-// Part to create
-if ($action == 'create') {
- $object = new Position($db);
- // Fetch optionals attributes and labels
- $extrafields->fetch_name_optionals_label($object->table_element);
- print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Position")), '', 'object_' . $object->picto);
-
- print '';
-
- //dol_set_focus('input[name="ref"]');
-}
-
// End of page
llxFooter();
$db->close();
diff --git a/htdocs/hrm/position_agenda.php b/htdocs/hrm/position_agenda.php
index 846202e26a0..af60ddea1b8 100644
--- a/htdocs/hrm/position_agenda.php
+++ b/htdocs/hrm/position_agenda.php
@@ -155,10 +155,10 @@ if ($object->id > 0) {
$morehtmlref = '
';
+ if ($objecttype == 'job') {
+ // Common attributes
+ //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
+ //unset($object->fields['fk_project']); // Hide field already shown in banner
+ //unset($object->fields['fk_soc']); // Hide field already shown in banner
+ $object->fields['label']['visible']=0; // Already in banner
+ include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
+
+ // Other attributes. Fields from hook formObjectOptions and Extrafields.
+ include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
} else {
- print '