Clean code

This commit is contained in:
Laurent Destailleur
2023-12-06 16:06:22 +01:00
parent be24f4d047
commit ef018a849e

View File

@@ -154,7 +154,7 @@ if (isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) {
print "</tr>\n"; print "</tr>\n";
$sql = "SELECT c.id, c.libelle as label,"; $sql = "SELECT c.id, c.libelle as label,";
$sql .= " cs.rowid, cs.libelle, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,"; $sql .= " cs.rowid, cs.libelle, cs.fk_type as type, cs.periode as period, cs.date_ech, cs.amount as total,";
$sql .= " pc.rowid as pid, pc.datep, pc.amount as totalpaid, pc.num_paiement as num_payment, pc.fk_bank,"; $sql .= " pc.rowid as pid, pc.datep, pc.amount as totalpaid, pc.num_paiement as num_payment, pc.fk_bank,";
$sql .= " pct.code as payment_code,"; $sql .= " pct.code as payment_code,";
$sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; $sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
@@ -168,8 +168,8 @@ if (isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) {
$sql .= " AND cs.entity IN (".getEntity("tax").")"; $sql .= " AND cs.entity IN (".getEntity("tax").")";
if ($year > 0) { if ($year > 0) {
$sql .= " AND ("; $sql .= " AND (";
// Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, // If period defined, we use it as dat criteria, if not we use date echeance,
// ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire // so we are compatible when period is not mandatory
$sql .= " (cs.periode IS NOT NULL AND cs.periode between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')"; $sql .= " (cs.periode IS NOT NULL AND cs.periode between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')";
$sql .= " OR (cs.periode IS NULL AND cs.date_ech between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')"; $sql .= " OR (cs.periode IS NULL AND cs.date_ech between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')";
$sql .= ")"; $sql .= ")";
@@ -190,9 +190,10 @@ if (isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) {
while ($i < min($num, $limit)) { while ($i < min($num, $limit)) {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Date // Date
$date = $obj->periode; $date = $obj->period;
if (empty($date)) { if (empty($date)) {
$date = $obj->date_ech; $date = $obj->date_ech;
} }
@@ -284,8 +285,8 @@ if (isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON ptva.fk_typepaiement = pct.id"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON ptva.fk_typepaiement = pct.id";
$sql .= " WHERE pv.entity IN (".getEntity("tax").")"; $sql .= " WHERE pv.entity IN (".getEntity("tax").")";
if ($year > 0) { if ($year > 0) {
// Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, // If period defined, we use it as dat criteria, if not we use date echeance,
// ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire // so we are compatible when period is not mandatory
$sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; $sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'";
} }
if (preg_match('/^pv\./', $sortfield) || preg_match('/^ptva\./', $sortfield)) { if (preg_match('/^pv\./', $sortfield) || preg_match('/^ptva\./', $sortfield)) {
@@ -409,8 +410,8 @@ while ($j < $numlt) {
$sql .= " FROM ".MAIN_DB_PREFIX."localtax as pv"; $sql .= " FROM ".MAIN_DB_PREFIX."localtax as pv";
$sql .= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".((int) $j); $sql .= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".((int) $j);
if ($year > 0) { if ($year > 0) {
// Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, // If period defined, we use it as dat criteria, if not we use date echeance,
// ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire // so we are compatible when period is not mandatory
$sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; $sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'";
} }
if (preg_match('/^pv/', $sortfield)) { if (preg_match('/^pv/', $sortfield)) {