Skip to content

Commit

Permalink
FIX late project search option (#30739)
Browse files Browse the repository at this point in the history
* Fixed search late project. Added search late project checkbox.

* Added contributor details
  • Loading branch information
W1W1-M authored Aug 23, 2024
1 parent 4843029 commit 40c090d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions htdocs/projet/class/project.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Copyright (C) 2023 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -2266,6 +2267,7 @@ public function load_board($user)
$response->label = $langs->trans("OpenedProjects");
$response->labelShort = $langs->trans("Opened");
$response->url = DOL_URL_ROOT.'/projet/list.php?search_project_user=-1&search_status=1&mainmenu=project';
$response->url_late = DOL_URL_ROOT.'/projet/list.php?search_option=late&mainmenu=project';
$response->img = img_object('', "projectpub");
$response->nbtodo = 0;
$response->nbtodolate = 0;
Expand Down
17 changes: 17 additions & 0 deletions htdocs/projet/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 Benjamin Falière <benjamin.faliere@altairis.fr>
* Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -192,6 +193,10 @@
$search_status = (GETPOST('search_status', 'intcomma') != '' ? GETPOST('search_status', 'intcomma') : '0,1');
}

$search_option = GETPOST('search_option', 'alpha');
if ($search_option == 'late') {
$search_status = '1';
}
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
$object = new Project($db);
$hookmanager->initHooks(array('projectlist'));
Expand Down Expand Up @@ -352,6 +357,7 @@
$search_societe_alias = '';
$search_societe_country = '';
$search_status = -1;
$search_option = '';
$search_opp_status = -1;
$search_opp_amount = '';
$search_opp_percent = '';
Expand Down Expand Up @@ -638,6 +644,9 @@
$sql .= " AND p.fk_statut IN (".$db->sanitize($db->escape($search_status)).")";
}
}
if ($search_option == 'late') {
$sql .= " AND p.datee < '".$db->idate(dol_now() - $conf->project->warning_delay)."'";
}
if ($search_opp_status) {
if (is_numeric($search_opp_status) && $search_opp_status > 0) {
$sql .= " AND p.fk_opp_status = ".((int) $search_opp_status);
Expand Down Expand Up @@ -1009,6 +1018,9 @@
if ($search_status != '' && $search_status != '-1') {
$param .= "&search_status=".urlencode($search_status);
}
if ($search_option) {
$param .= "&search_option=".urlencode($search_option);
}
if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all', 'openedopp', 'notopenedopp', 'none'))) {
$param .= '&search_opp_status='.urlencode($search_opp_status);
}
Expand Down Expand Up @@ -1193,6 +1205,11 @@
$moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_CUSTOMER, $searchCategoryCustomerList, 'minwidth300', $searchCategoryCustomerList ? $searchCategoryCustomerList : 0);
}

// alert on late date
$moreforfilter .= '<div class="divsearchfield">';
$moreforfilter .= $langs->trans('Alert').' <input type="checkbox" name="search_option" value="late"'.($search_option == 'late' ? ' checked' : '').'>';
$moreforfilter .= '</div>';

if (getDolGlobalInt('PROJECT_ENABLE_SUB_PROJECT')) {
//Checkbox for omitting child projects filter
$moreforfilter .= '<p style="display: inline-block; margin-left: 5px;">'.$langs->trans("Omit sub-projects").' </p><input type="checkbox" style="margin-left: 10px" class="valignmiddle" id="search_omitChildren" name="search_omitChildren"'.($search_omitChildren ? ' checked="checked"' : '').'"> ';
Expand Down

0 comments on commit 40c090d

Please sign in to comment.