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 ''; $formsocialcontrib->select_type_socialcontrib($search_typeid, 'search_typeid', 1, 0, 0, 'maxwidth100onsmartphone'); print ''; + // Ref Project + if (! empty($conf->projet->enabled)) print ''; // Period end date print ''; if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; @@ -246,6 +264,7 @@ if ($resql) print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "id", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "cs.libelle", "", $param, 'class="left"', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "type", "", $param, 'class="left"', $sortfield, $sortorder); + if (! empty($conf->projet->enabled)) print_liste_field_titre('ProjectRef', $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "periode", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "cs.amount", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("DateDue", $_SERVER["PHP_SELF"], "cs.date_ech", "", $param, 'align="center"', $sortfield, $sortorder); @@ -263,7 +282,11 @@ if ($resql) $chargesociale_static->ref=$obj->id; $chargesociale_static->lib=$obj->libelle; $chargesociale_static->type_libelle=$obj->type_lib; - + if (! empty($conf->projet->enabled)) { + $projectstatic->id=$obj->project_id; + $projectstatic->ref=$obj->project_ref; + $projectstatic->title=$obj->project_label; + } print ''; // Ref @@ -277,6 +300,16 @@ if ($resql) // Type print ''.$obj->type_lib.''; + // Project Ref + if (! empty($conf->projet->enabled)) { + print ''; + if ($obj->project_id > 0) + { + print $projectstatic->getNomUrl(1); + } + print ''; + } + // Date end period print ''; if ($obj->periode) @@ -314,6 +347,7 @@ if ($resql) else print ''.$langs->trans("Totalforthispage").''; print ''; print ''; + if (! empty($conf->projet->enabled)) print ''; print ''; print ''.price($totalarray['totalttc']).''; print ''; From bebc37abe39fd6371250b1e2954bc4f392be9a66 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Wed, 19 Feb 2020 08:54:10 +0100 Subject: [PATCH 2/3] Update list.php --- htdocs/compta/sociales/list.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 6e7277c2f93..11f5fe43d19 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2016 Frédéric France + * Copyright (C) 2020 Pierre Ardoin * * 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 From 7796724d6372b865ad386989cdc46eaadac022ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Feb 2020 01:07:41 +0100 Subject: [PATCH 3/3] Update list.php --- htdocs/compta/sociales/list.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 94a7eadf0fb..4b8500f5206 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -54,11 +54,8 @@ $search_status = GETPOST('search_status', 'int'); $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'); -} +$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');