29 require
'../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/prelevement.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
37 $langs->loadLangs(array(
'banks',
'categories',
'withdrawals'));
40 $socid =
GETPOST(
'socid',
'int');
42 $socid = $user->socid;
46 $usercancreate = $user->rights->paymentbybanktransfer->create;
60 llxHeader(
'', $langs->trans(
"SuppliersStandingOrdersArea"));
63 $langs->load(
"errors");
64 setEventMessages($langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"PaymentByBankTransfer")),
null,
'errors');
69 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewPaymentByBankTransfer'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/compta/prelevement/create.php?type=bank-transfer');
72 print
load_fiche_titre($langs->trans(
"SuppliersStandingOrdersArea"), $newcardbutton);
75 print
'<div class="fichecenter"><div class="fichethirdleft">';
78 $thirdpartystatic =
new Societe($db);
82 print
'<div class="div-table-responsive-no-min">';
83 print
'<table class="noborder centpercent">';
84 print
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Statistics").
'</th></tr>';
86 print
'<tr class="oddeven"><td>'.$langs->trans(
"NbOfInvoiceToPayByBankTransfer").
'</td>';
87 print
'<td class="right">';
88 print
'<a href="'.DOL_URL_ROOT.
'/compta/prelevement/demandes.php?status=0&type=bank-transfer">';
89 print $bprev->nbOfInvoiceToPay(
'bank-transfer');
93 print
'<tr class="oddeven"><td>'.$langs->trans(
"AmountToTransfer").
'</td>';
94 print
'<td class="right"><span class="amount">';
95 print
price($bprev->SommeAPrelever(
'bank-transfer'),
'',
'', 1, -1, -1,
'auto');
96 print
'</span></td></tr></table></div><br>';
103 $sql =
"SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type,";
104 $sql .=
" pfd.date_demande, pfd.amount,";
105 $sql .=
" s.nom as name, s.email, s.rowid as socid, s.tva_intra, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6";
106 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f,";
107 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
108 if (empty($user->rights->societe->client->voir) && !$socid) {
109 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
111 $sql .=
", ".MAIN_DB_PREFIX.
"prelevement_facture_demande as pfd";
112 $sql .=
" WHERE s.rowid = f.fk_soc";
113 $sql .=
" AND f.entity IN (".getEntity(
'supplier_invoice').
")";
114 $sql .=
" AND f.total_ttc > 0";
115 if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) {
116 $sql .=
" AND f.fk_statut = ".FactureFournisseur::STATUS_VALIDATED;
118 $sql .=
" AND pfd.traite = 0";
119 $sql .=
" AND pfd.ext_payment_id IS NULL";
120 $sql .=
" AND pfd.fk_facture_fourn = f.rowid";
121 if (empty($user->rights->societe->client->voir) && !$socid) {
122 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
125 $sql .=
" AND f.fk_soc = ".((int) $socid);
128 $resql = $db->query($sql);
130 $num = $db->num_rows(
$resql);
133 print
'<div class="div-table-responsive-no-min">';
134 print
'<table class="noborder centpercent">';
135 print
'<tr class="liste_titre">';
136 print
'<th colspan="5">'.$langs->trans(
"SupplierInvoiceWaitingWithdraw").
' ('.$num.
')</th></tr>';
138 while ($i < $num && $i < 20) {
139 $obj = $db->fetch_object(
$resql);
141 $invoicestatic->id = $obj->rowid;
142 $invoicestatic->ref = $obj->ref;
143 $invoicestatic->statut = $obj->fk_statut;
144 $invoicestatic->paye = $obj->paye;
145 $invoicestatic->type = $obj->type;
146 $alreadypayed = $invoicestatic->getSommePaiement();
148 $thirdpartystatic->id = $obj->socid;
149 $thirdpartystatic->name = $obj->name;
150 $thirdpartystatic->email = $obj->email;
151 $thirdpartystatic->tva_intra = $obj->tva_intra;
152 $thirdpartystatic->siren = $obj->idprof1;
153 $thirdpartystatic->siret = $obj->idprof2;
154 $thirdpartystatic->ape = $obj->idprof3;
155 $thirdpartystatic->idprof1 = $obj->idprof1;
156 $thirdpartystatic->idprof2 = $obj->idprof2;
157 $thirdpartystatic->idprof3 = $obj->idprof3;
158 $thirdpartystatic->idprof4 = $obj->idprof4;
159 $thirdpartystatic->idprof5 = $obj->idprof5;
160 $thirdpartystatic->idprof6 = $obj->idprof6;
162 print
'<tr class="oddeven"><td class="nowraponall">';
163 print $invoicestatic->getNomUrl(1,
'withdraw');
166 print
'<td class="tdoverflowmax150">';
167 print $thirdpartystatic->getNomUrl(1,
'supplier');
170 print
'<td class="right">';
171 print
'<span class="amount">'.price($obj->amount).
'</span>';
174 print
'<td class="right">';
178 print
'<td class="right">';
179 print $invoicestatic->getLibStatut(3, $alreadypayed);
185 print
'<tr class="oddeven"><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"NoSupplierInvoiceToWithdraw", $langs->transnoentitiesnoconv(
"BankTransfer")).
'</span></td></tr>';
187 print
"</table></div><br>";
193 print
'</div><div class="fichetwothirdright">';
201 $sql =
"SELECT p.rowid, p.ref, p.amount, p.datec, p.statut";
202 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
203 $sql .=
" WHERE p.type = 'bank-transfer'";
204 $sql .=
" AND p.entity IN (".getEntity(
'invoice').
")";
205 $sql .=
" ORDER BY datec DESC";
206 $sql .= $db->plimit($limit);
208 $result = $db->query($sql);
210 $num = $db->num_rows($result);
213 print
"\n<!-- debut table -->\n";
214 print
'<div class="div-table-responsive-no-min">';
215 print
'<table class="noborder centpercent">';
216 print
'<tr class="liste_titre">';
217 print
'<th>'.$langs->trans(
"LatestBankTransferReceipts", $limit).
'</th>';
218 print
'<th>'.$langs->trans(
"Date").
'</th>';
219 print
'<th class="right">'.$langs->trans(
"Amount").
'</th>';
220 print
'<th class="right">'.$langs->trans(
"Status").
'</th>';
224 while ($i < min($num, $limit)) {
225 $obj = $db->fetch_object($result);
227 print
'<tr class="oddeven">';
229 print
'<td class="nowraponall">';
230 $bprev->id = $obj->rowid;
231 $bprev->ref = $obj->ref;
232 $bprev->statut = $obj->statut;
233 print $bprev->getNomUrl(1);
235 print
'<td>'.dol_print_date($db->jdate($obj->datec),
"dayhour").
"</td>\n";
236 print
'<td class="right nowraponall"><span class="amount">'.price($obj->amount).
"</span></td>\n";
237 print
'<td class="right"><span class="amount">'.$bprev->getLibStatut(3).
"</span></td>\n";
243 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
246 print
"</table></div><br>";
253 print
'</div></div>';