diff --git a/htdocs/compta/loan/class/loan.class.php b/htdocs/compta/loan/class/loan.class.php index b63f9b32eff..afd15ced451 100644 --- a/htdocs/compta/loan/class/loan.class.php +++ b/htdocs/compta/loan/class/loan.class.php @@ -423,14 +423,14 @@ class Loan extends CommonObject $result=''; - if (empty($this->ref)) $this->ref=$this->lib; + if (empty($this->ref)) $this->ref=$this->label; - $lien = ''; - $lienfin=''; + $link = ''; + $linkend=''; - if ($withpicto) $result.=($lien.img_object($langs->trans("ShowSocialContribution").': '.$this->lib,'bill').$lienfin.' '); + if ($withpicto) $result.=($link.img_object($langs->trans("ShowLoan").': '.$this->label,'bill').$linkend.' '); if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$lien.($maxlen?dol_trunc($this->ref,$maxlen):$this->ref).$lienfin; + if ($withpicto != 2) $result.=$link.($maxlen?dol_trunc($this->ref,$maxlen):$this->ref).$linkend; return $result; } diff --git a/htdocs/compta/loan/index.php b/htdocs/compta/loan/index.php index d84d1897c24..41299668dd1 100644 --- a/htdocs/compta/loan/index.php +++ b/htdocs/compta/loan/index.php @@ -45,7 +45,6 @@ $limit = $conf->liste_limit; if (! $sortfield) $sortfield="l.rowid"; if (! $sortorder) $sortorder="DESC"; -$year=$_GET["year"]; $filtre=$_GET["filtre"]; /* @@ -57,33 +56,19 @@ $loan = new Loan($db); llxHeader(); -$sql = "SELECT cs.rowid as id, cs.fk_type as type, "; -$sql.= " cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode,"; -$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"; -$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; -if (GETPOST("search_label")) $sql.=" AND cs.libelle LIKE '%".$db->escape(GETPOST("search_label"))."%'"; -if ($year > 0) -{ - $sql .= " AND ("; - // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, - // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire - $sql .= " (cs.periode IS NOT NULL AND date_format(cs.periode, '%Y') = '".$year."') "; - $sql .= "OR (cs.periode IS NULL AND date_format(cs.date_ech, '%Y') = '".$year."')"; - $sql .= ")"; -} +$sql = "SELECT l.rowid as id, l.label, l.capital, l.datestart, l.dateend,"; +$sql.= " SUM(pl.amount) as alreadypayed"; +$sql.= " FROM ".MAIN_DB_PREFIX."loan as l,"; +$sql.= " ".MAIN_DB_PREFIX."payment_loan as pl"; +$sql.= " WHERE pl.fk_loan = l.rowid"; +$sql.= " AND l.entity = ".$conf->entity; +if (GETPOST("search_label")) $sql.=" AND l.label LIKE '%".$db->escape(GETPOST("search_label"))."%'"; + if ($filtre) { $filtre=str_replace(":","=",$filtre); $sql .= " AND ".$filtre; } -if ($typeid) { - $sql .= " AND cs.fk_type=".$typeid; -} -$sql.= " GROUP BY cs.rowid, cs.fk_type, cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode, c.libelle"; + $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit+1,$offset); @@ -96,18 +81,9 @@ if ($resql) $var=true; $param=''; - if ($year) $param.='&year='.$year; - if ($typeid) $param.='&typeid='.$typeid; - - if ($year) - { - print_fiche_titre($langs->trans("SocialContributions"),($year?"".img_previous()." ".$langs->trans("Year")." $year ".img_next()."":"")); - } - else - { - print_barre_liste($langs->trans("SocialContributions"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$totalnboflines); - } - + + print_fiche_titre($langs->trans("Loans")); + if (empty($mysoc->country_id) && empty($mysoc->country_code)) { print '