From 34d7fb887fff25636b983f75ae21842b5421da07 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Wed, 19 Feb 2020 08:50:49 +0100 Subject: [PATCH 1/3] Show project Ref support if enable Add search and Project Ref column in the list, only if project module is enable. --- htdocs/compta/sociales/list.php | 36 ++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 5f7f7d0fc0a..6e7277c2f93 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php' require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; // Load translation files required by the page $langs->loadLangs(array('compta', 'banks', 'bills')); @@ -53,6 +54,11 @@ $search_day_lim = GETPOST('search_day_lim', 'int'); $search_month_lim = GETPOST('search_month_lim', 'int'); $search_year_lim = GETPOST('search_year_lim', 'int'); +if (! empty($conf->projet->enabled)) { + $search_project_ref=GETPOST('search_project_ref', 'alpha'); + $search_project=GETPOST('search_project', 'alpha'); +} + $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); @@ -95,6 +101,11 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_month_lim=''; $toselect=''; $search_array_options=array(); + + if (! empty($conf->projet->enabled)) { + $search_project_ref=''; + $search_project=''; + } } @@ -106,21 +117,25 @@ $form = new Form($db); $formother = new FormOther($db); $formsocialcontrib = new FormSocialContrib($db); $chargesociale_static=new ChargeSociales($db); +if (! empty($conf->projet->enabled)) $projectstatic=new Project($db); llxHeader('', $langs->trans("SocialContributions")); $sql = "SELECT cs.rowid as id, cs.fk_type as type, "; $sql.= " cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode,"; +if (! empty($conf->projet->enabled)) $sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_label,"; $sql.= " c.libelle as type_lib,"; $sql.= " SUM(pc.amount) as alreadypayed"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; $sql.= " ".MAIN_DB_PREFIX."chargesociales as cs"; +if (! empty($conf->projet->enabled)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cs.fk_projet"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid"; $sql.= " WHERE cs.fk_type = c.id"; $sql.= " AND cs.entity = ".$conf->entity; // Search criteria if ($search_ref) $sql.=" AND cs.rowid=".$db->escape($search_ref); if ($search_label) $sql.=natural_search("cs.libelle", $search_label); +if (! empty($conf->projet->enabled)) if ($search_project_ref != '') $sql.= natural_search("p.ref", $search_project_ref); if ($search_amount) $sql.=natural_search("cs.amount", price2num(trim($search_amount)), 1); if ($search_status != '' && $search_status >= 0) $sql.=" AND cs.paye = ".$db->escape($search_status); $sql.= dolSqlDateFilter("cs.periode", $search_day_lim, $search_month_lim, $search_year_lim); @@ -163,6 +178,7 @@ if ($resql) if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); if ($search_ref) $param.='&search_ref='.urlencode($search_ref); if ($search_label) $param.='&search_label='.urlencode($search_label); + if (! empty($conf->projet->enabled)) if ($search_project_ref >= 0) $param.="&search_project_ref=".urlencode($search_project_ref); if ($search_amount) $param.='&search_amount='.urlencode($search_amount); if ($search_typeid) $param.='&search_typeid='.urlencode($search_typeid); if ($search_status != '' && $search_status != '-1') $param.='&search_status='.urlencode($search_status); @@ -219,6 +235,8 @@ if ($resql) print '