$socid = GETPOST("socid"); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'prelevement','','','bons'); // Get supervariables $page = GETPOST("page"); $sortorder = ((GETPOST("sortorder")=="")) ? "DESC" : GETPOST("sortorder"); $sortfield = ((GETPOST("sortfield")=="")) ? "p.datec" : GETPOST("sortfield"); $search_line = GETPOST("search_ligne"); $search_bon = GETPOST("search_bon"); $search_code = GETPOST("search_code"); $search_societe = GETPOST("search_societe"); $statut = GETPOST("statut"); $bon=new BonPrelevement($db,""); $ligne=new LignePrelevement($db,$user); $offset = $conf->liste_limit * $page ; /* * View */ llxHeader('',$langs->trans("WithdrawalsLines")); $sql = "SELECT p.rowid, p.ref, p.statut, p.datec"; $sql.= " ,f.rowid as facid, f.facnumber, f.total_ttc"; $sql.= " , s.rowid as socid, s.nom, s.code_client"; $sql.= " , pl.amount, pl.statut as statut_ligne, pl.rowid as rowid_ligne";
print '</table>'; print '<br>'; print '<table class="border" width="100%"><tr><td width="20%">'; print $langs->trans("WithdrawalFile") . '</td><td>'; $relativepath = 'receipts/' . $bon->ref; print '<a data-ajax="false" href="' . DOL_URL_ROOT . '/document.php?type=text/plain&modulepart=prelevement&file=' . urlencode($relativepath) . '">' . $relativepath . '</a>'; print '</td></tr></table>'; dol_fiche_end(); } else { $langs->load("errors"); print $langs->trans("Error"); } /* * Stats */ $ligne = new LignePrelevement($db, $user); $sql = "SELECT sum(pl.amount), pl.statut"; $sql .= " FROM " . MAIN_DB_PREFIX . "prelevement_lignes as pl"; $sql .= " WHERE pl.fk_prelevement_bons = " . $prev_id; $sql .= " GROUP BY pl.statut"; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; print_fiche_titre($langs->trans("StatisticsByLineStatus"), '', ''); print "\n<!-- debut table -->\n"; print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">'; print '<tr class="liste_titre">'; print '<td>' . $langs->trans("Status") . '</td><td align="right">' . $langs->trans("Amount") . '</td><td align="right">%</td></tr>'; $var = false; while ($i < $num) {
header("Location: ligne.php?id=" . $id); exit; } } /* * View */ $invoicestatic = new Facture($db); llxHeader('', $langs->trans("StandingOrder")); $h = 0; $head[$h][0] = DOL_URL_ROOT . '/compta/prelevement/ligne.php?id=' . $id; $head[$h][1] = $langs->trans("Card"); $hselected = $h; $h++; if ($id) { $lipre = new LignePrelevement($db, $user); if ($lipre->fetch($id) == 0) { $bon = new BonPrelevement($db); $bon->fetch($lipre->bon_rowid); dol_fiche_head($head, $hselected, $langs->trans("StandingOrder")); print '<table class="border" width="100%">'; print '<tr><td width="20%">' . $langs->trans("WithdrawalsReceipts") . '</td><td>'; print $bon->getNomUrl(1) . '</td></tr>'; print '<tr><td width="20%">' . $langs->trans("Date") . '</td><td>' . dol_print_date($bon->datec, 'day') . '</td></tr>'; print '<tr><td width="20%">' . $langs->trans("Amount") . '</td><td>' . price($lipre->amount) . '</td></tr>'; print '<tr><td width="20%">' . $langs->trans("Status") . '</td><td>' . $lipre->LibStatut($lipre->statut, 1) . '</td></tr>'; if ($lipre->statut == 3) { $rej = new RejetPrelevement($db, $user); $resf = $rej->fetch($lipre->id); if ($resf == 0) { print '<tr><td width="20%">' . $langs->trans("RefusedReason") . '</td><td>' . $rej->motif . '</td></tr>';
} else { Header("Location: ligne.php?id=" . $id); exit; } } /* * View */ llxHeader('', $langs->trans("StandingOrder")); $h = 0; $head[$h][0] = DOL_URL_ROOT . '/compta/prelevement/ligne.php?id=' . $id; $head[$h][1] = $langs->trans("Card"); $hselected = $h; $h++; if ($id) { $lipre = new LignePrelevement($db, $user); if ($lipre->fetch($id) == 0) { $bon = new BonPrelevement($db); $bon->fetch($lipre->bon_rowid); dol_fiche_head($head, $hselected, $langs->trans("StandingOrder")); print '<table class="border" width="100%">'; print '<tr><td width="20%">' . $langs->trans("WithdrawalReceipt") . '</td><td>'; print '<a href="fiche.php?id=' . $lipre->bon_rowid . '">' . $lipre->bon_ref . '</a></td></tr>'; print '<tr><td width="20%">' . $langs->trans("Date") . '</td><td>' . dol_print_date($bon->datec, 'day') . '</td></tr>'; print '<tr><td width="20%">' . $langs->trans("Amount") . '</td><td>' . price($lipre->amount) . '</td></tr>'; print '<tr><td width="20%">' . $langs->trans("Status") . '</td><td>'; print $lipre->LibStatut($lipre->statut, 1) . '</td></tr>'; if ($lipre->statut == 3) { $rej = new RejetPrelevement($db, $user); $resf = $rej->fetch($lipre->id); if ($resf == 0) {
$sortfield = GETPOST('sortfield', 'alpha'); /* * View */ llxHeader('', $langs->trans("WithdrawsRefused")); $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if ($sortorder == "") { $sortorder = "DESC"; } if ($sortfield == "") { $sortfield = "p.datec"; } $rej = new RejetPrelevement($db, $user); $ligne = new LignePrelevement($db, $user); /* * Liste des factures * */ $sql = "SELECT pl.rowid, pr.motif, p.ref, pl.statut"; $sql .= " , s.rowid as socid, s.nom"; $sql .= " FROM " . MAIN_DB_PREFIX . "prelevement_bons as p"; $sql .= " , " . MAIN_DB_PREFIX . "prelevement_rejet as pr"; $sql .= " , " . MAIN_DB_PREFIX . "prelevement_lignes as pl"; $sql .= " , " . MAIN_DB_PREFIX . "societe as s"; $sql .= " WHERE pr.fk_prelevement_lignes = pl.rowid"; $sql .= " AND pl.fk_prelevement_bons = p.rowid"; $sql .= " AND pl.fk_soc = s.rowid"; $sql .= " AND p.entity = " . $conf->entity; if ($socid) {