Skip to content

Commit

Permalink
#97 [Session] fix: filter list
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Feb 21, 2023
1 parent 6a298b6 commit 7b570c1
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 32 deletions.
5 changes: 4 additions & 1 deletion class/session.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,11 @@ public function getNomUrl(int $withpicto = 0, string $option = '', int $notoolti
if ($option == 'nolink') {
$linkstart = '<span';
} else {
$linkstart = '<a href="'. $url . '" target="_blank"';
$linkstart = '<a href="'. $url . '"';
}
if ($option == 'blank') {
$linkstart .= 'target=_blank';
}
$linkstart .= $linkclose . '>';
if ($option == 'nolink' || empty($url)) {
$linkend = '</span>';
Expand Down
14 changes: 7 additions & 7 deletions core/modules/modDoliMeet.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ public function __construct($db)
$r++;
$this->rights[$r][0] = $this->numero . sprintf('%02d', $r + 1); // Permission id (must not be already used)
$this->rights[$r][1] = $langs->transnoentities('ReadMyObject', $langs->trans('DoliMeetSessions')); // Permission label
$this->rights[$r][4] = 'meeting';
$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->dolimeet->meeting->read)
$this->rights[$r][4] = 'session';
$this->rights[$r][5] = 'assigntome'; // In php code, permission will be checked by test if ($user->rights->dolimeet->session->assigntome)
$r++;
$this->rights[$r][0] = $this->numero . sprintf('%02d', $r + 1); // Permission id (must not be already used)
$this->rights[$r][1] = $langs->transnoentities('CreateObject', $langs->trans('DoliMeetSessions')); // Permission label
Expand All @@ -320,7 +320,7 @@ public function __construct($db)
$this->rights[$r][0] = $this->numero . sprintf('%02d', $r + 1); // Permission id (must not be already used)
$this->rights[$r][1] = $langs->transnoentities('ReadMyObject', $langs->transnoentities('Meetings')); // Permission label
$this->rights[$r][4] = 'meeting';
$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->dolimeet->meeting->read)
$this->rights[$r][5] = 'assigntome'; // In php code, permission will be checked by test if ($user->rights->dolimeet->meeting->assigntome)
$r++;
$this->rights[$r][0] = $this->numero . sprintf('%02d', $r + 1); // Permission id (must not be already used)
$this->rights[$r][1] = $langs->transnoentities('CreateObject', $langs->transnoentities('Meetings')); // Permission label
Expand All @@ -341,8 +341,8 @@ public function __construct($db)
$r++;
$this->rights[$r][0] = $this->numero . sprintf('%02d', $r + 1); // Permission id (must not be already used)
$this->rights[$r][1] = $langs->transnoentities('ReadMyObject', $langs->trans('Trainingsessions')); // Permission label
$this->rights[$r][4] = 'meeting';
$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->dolimeet->meeting->read)
$this->rights[$r][4] = 'trainingsession';
$this->rights[$r][5] = 'assigntome'; // In php code, permission will be checked by test if ($user->rights->dolimeet->trainingsession->assigntome)
$r++;
$this->rights[$r][0] = $this->numero . sprintf('%02d', $r + 1); // Permission id (must not be already used)
$this->rights[$r][1] = $langs->transnoentities('CreateObject', $langs->trans('Trainingsessions')); // Permission label
Expand All @@ -363,8 +363,8 @@ public function __construct($db)
$r++;
$this->rights[$r][0] = $this->numero . sprintf('%02d', $r + 1); // Permission id (must not be already used)
$this->rights[$r][1] = $langs->transnoentities('ReadMyObject', $langs->trans('Audits')); // Permission label
$this->rights[$r][4] = 'meeting';
$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->dolimeet->meeting->read)
$this->rights[$r][4] = 'audit';
$this->rights[$r][5] = 'assigntome'; // In php code, permission will be checked by test if ($user->rights->dolimeet->audit->assigntome)
$r++;
$this->rights[$r][0] = $this->numero . sprintf('%02d', $r + 1); // Permission id (must not be already used)
$this->rights[$r][1] = $langs->transnoentities('CreateObject', $langs->trans('Audits')); // Permission label
Expand Down
12 changes: 9 additions & 3 deletions view/session/session_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@
}
}

// Action to generate pdf from odt file
require_once __DIR__ . '/../../../saturne/core/tpl/documents/saturne_manual_pdf_generation_action.tpl.php';

if ($action == 'remove_file') {
if (!empty($upload_dir)) {
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
Expand All @@ -239,8 +242,11 @@
$filetodelete = GETPOST('file', 'alpha');
$file = $upload_dir . '/' . $filetodelete;
$ret = dol_delete_file($file, 0, 0, 0, $object);
if ($ret) setEventMessages($langs->trans('FileWasRemoved', $filetodelete), null, 'mesgs');
else setEventMessages($langs->trans('ErrorFailToDeleteFile', $filetodelete), null, 'errors');
if ($ret) {
setEventMessages($langs->trans('FileWasRemoved', $filetodelete), []);
} else {
setEventMessages($langs->trans('ErrorFailToDeleteFile', $filetodelete), [], 'errors');
}

// Make a redirect to avoid to keep the remove_file into the url that create side effects
$urltoredirect = $_SERVER['REQUEST_URI'];
Expand All @@ -250,7 +256,7 @@
header('Location: ' . $urltoredirect);
exit;
} else {
setEventMessages('BugFoundVarUploaddirnotDefined', null, 'errors');
setEventMessages('BugFoundVarUploaddirnotDefined', [], 'errors');
}
}

Expand Down
48 changes: 27 additions & 21 deletions view/session/session_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@
$search_all = GETPOST('search_all') ? GETPOST('search_all') : GETPOST('sall');
$search = [];
foreach ($object->fields as $key => $val) {
if (GETPOST($key, 'alpha') !== '') {
$search[$key] = GETPOST($key, 'alpha');
if (GETPOST('search_' . $key, 'alpha') !== '') {
$search[$key] = GETPOST('search_' . $key, 'alpha');
}
if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
$search[$key . '_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_' . $key . '_dtstartmonth', 'int'), GETPOST('search_' . $key . '_dtstartday', 'int'), GETPOST('search_' . $key . '_dtstartyear', 'int'));
Expand All @@ -123,9 +123,13 @@
}

if (!empty($conf->categorie->enabled)) {
$search_category_array = GETPOST("search_category_' . $objectType . '_list", 'array');
$search_category_array = GETPOST('search_category_' . $objectType . '_list', 'array');
}

$search_internal_attendants = GETPOST('search_internal_attendants', 'int');
$search_external_attendants = GETPOST('search_external_attendants', 'int');
$search_society_attendants = GETPOST('search_society_attendants', 'int');

$error = 0;
if (!empty($fromtype)) {
switch ($fromtype) {
Expand Down Expand Up @@ -238,6 +242,9 @@
$toselect = [];
$search_array_options = [];
$search_category_array = [];
$search_internal_attendants = -1;
$search_external_attendants = -1;
$search_society_attendants = -1;
}
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')) {
Expand Down Expand Up @@ -289,14 +296,14 @@
}
}

if (GETPOST('search_internal_attendants') > 0) {
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'saturne_object_signature as search_internal_attendants on (search_internal_attendants.element_id = ' . GETPOST('search_internal_attendants') . ' AND search_internal_attendants.element_type="user" AND search_internal_attendants.status > 0)';
if ($search_internal_attendants > 0) {
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'saturne_object_signature as search_internal_attendants on (search_internal_attendants.element_id = ' . $search_internal_attendants . ' AND search_internal_attendants.element_type="user" AND search_internal_attendants.status > 0)';
}
if (GETPOST('search_external_attendants') > 0) {
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'saturne_object_signature as search_external_attendants on (search_external_attendants.element_id = ' . GETPOST('search_external_attendants') . ' AND search_external_attendants.element_type="socpeople" AND search_external_attendants.status > 0)';
if ($search_external_attendants > 0) {
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'saturne_object_signature as search_external_attendants on (search_external_attendants.element_id = ' . $search_external_attendants . ' AND search_external_attendants.element_type="socpeople" AND search_external_attendants.status > 0)';
}
if (GETPOST('search_society_attendants') > 0) {
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'socpeople as cf on (cf.fk_soc = ' . GETPOST('search_society_attendants') . ')';
if ($search_society_attendants > 0) {
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'socpeople as cf on (cf.fk_soc = ' . $search_society_attendants . ')';
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'saturne_object_signature as search_society_attendants on (search_society_attendants.element_id = cf.rowid AND search_society_attendants.element_type="socpeople" AND search_society_attendants.status > 0)';
}

Expand All @@ -311,20 +318,19 @@
$sql .= ' WHERE 1 = 1';
}

$sql .= ' AND t.status > -1';
if (is_array($signatoryObjectsArray) && dol_strlen($fromtype) > 0 && !in_array($fromtype, $linkedObjectsArray) && !in_array($fromtype, $signatoryObjectsArray)) {
$sql .= ' AND t.rowid = e.fk_target ';
} else if (is_array($signatoryObjectsArray) && in_array($fromtype, $signatoryObjectsArray)) {
} elseif (is_array($signatoryObjectsArray) && in_array($fromtype, $signatoryObjectsArray)) {
$sql .= ' AND t.rowid = e.fk_object ';
}

if (GETPOST('search_internal_attendants') > 0) {
if ($search_internal_attendants > 0) {
$sql .= ' AND t.rowid = search_internal_attendants.fk_object ';
}
if (GETPOST('search_external_attendants') > 0) {
if ($search_external_attendants > 0) {
$sql .= ' AND t.rowid = search_external_attendants.fk_object ';
}
if (GETPOST('search_society_attendants') > 0) {
if ($search_society_attendants > 0) {
$sql .= ' AND t.rowid = search_society_attendants.fk_object ';
}
if ($objectType != 'session') {
Expand All @@ -335,9 +341,6 @@
if ($key == 'status' && $val == -1) {
continue;
}
if ($val < 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 ($val == '-1' || ($val === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
Expand Down Expand Up @@ -365,7 +368,7 @@
}

if (!empty($conf->categorie->enabled)) {
$sql .= Categorie::getFilterSelectQuery($objectType, 't.rowid', $search_category_array);
$sql .= Categorie::getFilterSelectQuery('session', 't.rowid', $search_category_array);
}

// Add where from extra fields
Expand All @@ -381,6 +384,9 @@
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
/* The fast and low memory method to get and count full list converts the sql into a sql count */
$sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
if (!empty($search_category_array)) {
$sqlforcount = substr($sqlforcount, 0, -2);
}
$resql = $db->query($sqlforcount);
if ($resql) {
$objforcount = $db->fetch_object($resql);
Expand Down Expand Up @@ -621,15 +627,15 @@
if ($resource['checked']) {
if ($resource['label'] == 'InternalAttendants') {
print '<td>';
print $form->select_dolusers($fromtype == 'user' ? $fromid : GETPOST('search_internal_attendants'), 'search_internal_attendants', 1);
print $form->select_dolusers($fromtype == 'user' ? $fromid : $search_internal_attendants, 'search_internal_attendants', 1);
print '</td>';
} elseif ($resource['label'] == 'ExternalAttendants') {
print '<td>';
print $form->selectcontacts(0, $fromtype == 'socpeople' ? $fromid : GETPOST('search_external_attendants'), 'search_external_attendants', 1);
print $form->selectcontacts(0, $fromtype == 'socpeople' ? $fromid : $search_external_attendants, 'search_external_attendants', 1);
print '</td>';
} elseif ($resource['label'] == 'SocietyAttendants') {
print '<td>';
print $form->select_company($fromtype == 'thirdparty' ? $fromid : GETPOST('search_society_attendants'), 'search_society_attendants', '', 1);
print $form->select_company($fromtype == 'thirdparty' ? $fromid : $search_society_attendants, 'search_society_attendants', '', 1);
print '</td>';
}
}
Expand Down

0 comments on commit 7b570c1

Please sign in to comment.