';
+print ' | ';
+print ' | ';
+print '';
+$formsocialcontrib->select_type_socialcontrib(GETPOSTISSET("search_sc_type") ? $search_sc_type : '', 'search_sc_type', 1, 0, 0, 'minwidth200 maxwidth300');
+print ' | ';
+print ' | ';
+print ' | ';
+print ' | ';
+print ' | ';
+if (!empty($conf->banque->enabled)) print ' | ';
+print ' | ';
+print '';
+$searchpicto = $form->showFilterButtons();
+print $searchpicto;
+print ' | ';
+print "
\n";
+
+print '';
- print '';
- print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "cs.date_ech", "", $param, 'width="140px"', $sortfield, $sortorder);
- print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "c.libelle", "", $param, '', $sortfield, $sortorder);
- print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "cs.fk_type", "", $param, '', $sortfield, $sortorder);
- print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "cs.amount", "", $param, 'class="right"', $sortfield, $sortorder);
- print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "pc.rowid", "", $param, '', $sortfield, $sortorder);
- print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pc.datep", "", $param, 'align="center"', $sortfield, $sortorder);
- print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder);
- if (!empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
- print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pc.amount", "", $param, 'class="right"', $sortfield, $sortorder);
- print "
\n";
-
- $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 .= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment, pc.fk_bank,";
- $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 .= " 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 .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pc.fk_bank = b.rowid";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
- $sql .= " WHERE cs.fk_type = c.id";
- $sql .= " AND cs.entity IN (".getEntity("tax").")";
- 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 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 .= ")";
- }
- if (preg_match('/^cs\./', $sortfield) || preg_match('/^c\./', $sortfield) || preg_match('/^pc\./', $sortfield) || preg_match('/^pct\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder);
- //$sql.= $db->plimit($limit+1,$offset);
- //print $sql;
-
- dol_syslog("compta/charges/index.php: select payment", LOG_DEBUG);
- $resql = $db->query($sql);
- if ($resql)
- {
- $num = $db->num_rows($resql);
- $i = 0;
- $total = 0;
- $totalnb = 0;
- $totalpaye = 0;
-
- while ($i < min($num, $limit))
- {
- $obj = $db->fetch_object($resql);
- print '';
- // Date
- $date = $obj->periode;
- if (empty($date)) $date = $obj->date_ech;
- print '| '.dol_print_date($date, 'day').' | ';
- // Label
- print '';
- $socialcontrib->id = $obj->rowid;
- $socialcontrib->ref = $obj->label;
- $socialcontrib->label = $obj->label;
- print $socialcontrib->getNomUrl(1, '20');
- print ' | ';
- // Type
- print ''.$obj->label.' | ';
- // Expected to pay
- print ''.price($obj->total).' | ';
- // Ref payment
- $payment_sc_static->id = $obj->pid;
- $payment_sc_static->ref = $obj->pid;
- print ''.$payment_sc_static->getNomUrl(1)." | \n";
- // Date payment
- print ''.dol_print_date($db->jdate($obj->datep), 'day').' | ';
- // Type payment
- print '';
- if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' ';
- print $obj->num_payment.' | ';
- // Account
- if (!empty($conf->banque->enabled))
- {
- print '';
- if ($obj->fk_bank > 0)
- {
- //$accountstatic->fetch($obj->fk_bank);
- $accountstatic->id = $obj->bid;
- $accountstatic->ref = $obj->bref;
- $accountstatic->number = $obj->bnumber;
- $accountstatic->accountancy_number = $obj->account_number;
- $accountstatic->accountancy_journal = $obj->accountancy_journal;
- $accountstatic->label = $obj->blabel;
- print $accountstatic->getNomUrl(1);
- } else print ' ';
- print ' | ';
- }
- // Paid
- print '';
- if ($obj->totalpaye) print price($obj->totalpaye);
- print ' | ';
- print '
';
-
- $total = $total + $obj->total;
- $totalnb = $totalnb + $obj->nb;
- $totalpaye = $totalpaye + $obj->totalpaye;
- $i++;
- }
- print '| '.$langs->trans("Total").' | ';
- print ' | '; // A total here has no sense
- print ' | ';
- print ' | ';
- print ' | ';
- if (!empty($conf->banque->enabled)) print ' | ';
- print ''.price($totalpaye)." | ";
- print "
";
- } else {
- dol_print_error($db);
- }
- print '
';
+ dol_print_error($db);
+ exit;
}
+$i = 0;
+$total = 0;
+$totalnb = 0;
+$totalpaye = 0;
+
+while ($i < min($num, $limit)) {
+ $obj = $db->fetch_object($resql);
+ print '';
+ // Date
+ $date = $obj->periode;
+ if (empty($date)) $date = $obj->date_ech;
+ print '| '.dol_print_date($date, 'day').' | ';
+ // Label
+ print '';
+ $socialcontrib->id = $obj->rowid;
+ $socialcontrib->ref = $obj->label;
+ $socialcontrib->label = $obj->label;
+ print $socialcontrib->getNomUrl(1, '20');
+ print ' | ';
+ // Type
+ print ''.$obj->label.' | ';
+ // Expected to pay
+ print ''.price($obj->total).' | ';
+ // Ref payment
+ $payment_sc_static->id = $obj->pid;
+ $payment_sc_static->ref = $obj->pid;
+ print ''.$payment_sc_static->getNomUrl(1)." | \n";
+ // Date payment
+ print ''.dol_print_date($db->jdate($obj->datep), 'day').' | ';
+ // Type payment
+ print '';
+ if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' ';
+ print $obj->num_payment.' | ';
+ // Account
+ if (!empty($conf->banque->enabled))
+ {
+ print '';
+ if ($obj->fk_bank > 0)
+ {
+ //$accountstatic->fetch($obj->fk_bank);
+ $accountstatic->id = $obj->bid;
+ $accountstatic->ref = $obj->bref;
+ $accountstatic->number = $obj->bnumber;
+ $accountstatic->accountancy_number = $obj->account_number;
+ $accountstatic->accountancy_journal = $obj->accountancy_journal;
+ $accountstatic->label = $obj->blabel;
+ print $accountstatic->getNomUrl(1);
+ } else print ' ';
+ print ' | ';
+ }
+ // Paid
+ print '';
+ if ($obj->totalpaye) print price($obj->totalpaye);
+ print ' | ';
+
+ print ' | ';
+
+ print '
';
+
+ $total = $total + $obj->total;
+ $totalnb = $totalnb + $obj->nb;
+ $totalpaye = $totalpaye + $obj->totalpaye;
+ $i++;
+}
+
+// Total
+print '