forked from Wavyzz/dolibarr
FIX late contract services search option (#30741)
* Fixed search late contract services. Added search late contract services checkbox. Cleaned code. * Cleaned code * Fixed escaped string
This commit is contained in:
@@ -2312,20 +2312,21 @@ class Contrat extends CommonObject
|
||||
$now = dol_now();
|
||||
|
||||
if ($mode == 'inactive') {
|
||||
$warning_delay = $conf->contrat->services->inactifs->warning_delay;
|
||||
$warning_delay = $conf->contract->services->inactifs->warning_delay;
|
||||
$label = $langs->trans("BoardNotActivatedServices");
|
||||
$labelShort = $langs->trans("BoardNotActivatedServicesShort");
|
||||
$url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&search_status=0&sortfield=cd.date_fin_validite&sortorder=asc';
|
||||
} elseif ($mode == 'expired') {
|
||||
$warning_delay = $conf->contrat->services->expires->warning_delay;
|
||||
$url_late = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&search_status=0&search_option=late';
|
||||
} elseif ($mode == 'active') {
|
||||
$warning_delay = $conf->contract->services->expires->warning_delay;
|
||||
$url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&search_status=4&filter=expired&sortfield=cd.date_fin_validite&sortorder=asc';
|
||||
$url_late = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&search_status=4&search_option=late';
|
||||
$label = $langs->trans("BoardExpiredServices");
|
||||
$labelShort = $langs->trans("BoardExpiredServicesShort");
|
||||
} else {
|
||||
$warning_delay = $conf->contrat->services->expires->warning_delay;
|
||||
$url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&search_status=4&sortfield=cd.date_fin_validite&sortorder=asc';
|
||||
//$url.= '&op2day='.$arraydatetouse['mday'].'&op2month='.$arraydatetouse['mon'].'&op2year='.$arraydatetouse['year'];
|
||||
//if ($warning_delay >= 0) $url.='&filter=expired';
|
||||
$warning_delay = $conf->contract->services->expires->warning_delay;
|
||||
$url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&sortfield=cd.date_fin_validite&sortorder=asc';
|
||||
$url_late = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&search_option=late';
|
||||
$label = $langs->trans("BoardRunningServices");
|
||||
$labelShort = $langs->trans("BoardRunningServicesShort");
|
||||
}
|
||||
@@ -2335,6 +2336,7 @@ class Contrat extends CommonObject
|
||||
$response->label = $label;
|
||||
$response->labelShort = $labelShort;
|
||||
$response->url = $url;
|
||||
$response->url_late = $url_late;
|
||||
$response->img = img_object('', "contract");
|
||||
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
|
||||
@@ -73,6 +73,7 @@ $search_total_ttc = GETPOST("search_total_ttc", 'alpha');
|
||||
$search_contract = GETPOST("search_contract", 'alpha');
|
||||
$search_service = GETPOST("search_service", 'alpha');
|
||||
$search_status = GETPOST("search_status", 'alpha');
|
||||
$search_option = GETPOST('search_option', 'alpha');
|
||||
$search_product_category = GETPOSTINT('search_product_category');
|
||||
|
||||
// To support selection into combo list of status with detailed status '4&filter'
|
||||
@@ -194,6 +195,7 @@ if (empty($reshook)) {
|
||||
$search_contract = "";
|
||||
$search_service = "";
|
||||
$search_status = "";
|
||||
$search_option = '';
|
||||
$opouvertureprevuemonth = "";
|
||||
$opouvertureprevueday = "";
|
||||
$opouvertureprevueyear = "";
|
||||
@@ -307,6 +309,14 @@ if ($search_status == "4&filter=notexpired" || ($search_status == '4' && $filter
|
||||
if ($search_status == "5") {
|
||||
$sql .= " AND cd.statut = 5";
|
||||
}
|
||||
if ($search_option == 'late' && $search_status != '0') {
|
||||
$warning_date = $db->idate(dol_now() - $conf->contract->services->expires->warning_delay);
|
||||
$sql .= " AND cd.date_fin_validite < '".addslashes($warning_date)."'";
|
||||
}
|
||||
if ($search_option == 'late' && $search_status == '0') {
|
||||
$warning_date = $db->idate(dol_now() - $conf->contract->services->expires->warning_delay);
|
||||
$sql .= " AND (cd.date_ouverture_prevue < '".addslashes($warning_date)."' OR cd.date_fin_validite < '".addslashes($warning_date)."')";
|
||||
}
|
||||
if ($search_subprice) {
|
||||
$sql .= natural_search("cd.subprice", $search_subprice, 1);
|
||||
}
|
||||
@@ -477,6 +487,9 @@ if ($search_service) {
|
||||
if ($search_status) {
|
||||
$param .= '&search_status='.urlencode($search_status);
|
||||
}
|
||||
if ($search_option) {
|
||||
$param .= "&search_option=".urlencode($search_option);
|
||||
}
|
||||
if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1) {
|
||||
$param .= '&filter_opouvertureprevue='.urlencode($filter_opouvertureprevue);
|
||||
}
|
||||
@@ -552,6 +565,10 @@ if (isModEnabled('category') && ($user->hasRight('produit', 'lire') || $user->ha
|
||||
$moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'widthcentpercentminusx maxwidth300', 1);
|
||||
$moreforfilter .= '</div>';
|
||||
}
|
||||
// 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>';
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
|
||||
Reference in New Issue
Block a user