';
+
@@ -70 +71 @@
-$invoicestatic = new FactureFournisseur($db);
+$invoicestatic = new Facture($db);
@@ -72,13 +72,0 @@
-$salary = new Salary($db);
-$user = new User($db);
-
-$newcardbutton = '';
-if ($usercancreate) {
- $newcardbutton .= dolGetButtonTitle($langs->trans('NewPaymentByBankTransfer'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/prelevement/create.php?type=bank-transfer');
-}
-
-print load_fiche_titre($langs->trans("SuppliersStandingOrdersArea"), $newcardbutton);
-
-
-print '
';
-
@@ -90,182 +78,101 @@
-$totaltoshow = 0;
-
-if (isModEnabled('supplier_invoice')) {
- print '
'.$langs->trans("NbOfInvoiceToPayByBankTransfer").' | ';
- print '';
- $amounttoshow = $bprev->SommeAPrelever('bank-transfer');
- print '';
- print $bprev->nbOfInvoiceToPay('bank-transfer');
- print '';
- print ' |
';
- $totaltoshow += $amounttoshow;
-}
-
-if (isModEnabled('salaries')) {
- print '
'.$langs->trans("NbOfInvoiceToPayByBankTransferForSalaries").' | ';
- print '';
- $amounttoshow = $bprev->SommeAPrelever('bank-transfer', 'salary');
- print '';
- print $bprev->nbOfInvoiceToPay('bank-transfer', 'salary');
- print '';
- print ' |
';
- $totaltoshow += $amounttoshow;
-}
-
-print '
'.$langs->trans("Total").' | ';
-print '';
-print price($totaltoshow, '', '', 1, -1, -1, 'auto');
-print ' |
';
-
-
-/*
- * Invoices waiting for credit transfer
- */
-if (isModEnabled('supplier_invoice')) {
- $sql = "SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type, f.datef, f.date_lim_reglement,";
- $sql .= " pfd.date_demande, pfd.amount,";
- $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";
- $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,";
- $sql .= " ".MAIN_DB_PREFIX."societe as s,";
- $sql .= " ".MAIN_DB_PREFIX."prelevement_demande as pfd";
- $sql .= " WHERE s.rowid = f.fk_soc";
- $sql .= " AND f.entity IN (".getEntity('supplier_invoice').")";
- $sql .= " AND f.total_ttc > 0";
- if (!getDolGlobalString('WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS')) {
- $sql .= " AND f.fk_statut = ".FactureFournisseur::STATUS_VALIDATED;
- }
- $sql .= " AND pfd.traite = 0";
- $sql .= " AND pfd.ext_payment_id IS NULL";
- $sql .= " AND pfd.fk_facture_fourn = f.rowid";
- if ($socid) {
- $sql .= " AND f.fk_soc = ".((int) $socid);
- }
-
- $resql = $db->query($sql);
-
- if ($resql) {
- $num = $db->num_rows($resql);
- $i = 0;
-
- print '
';
- print '
';
- print '';
- print ''.$langs->trans("SupplierInvoiceWaitingWithdraw").' ('.$num.') |
';
- if ($num) {
- while ($i < $num && $i < 20) {
- $obj = $db->fetch_object($resql);
-
- $invoicestatic->id = $obj->rowid;
- $invoicestatic->ref = $obj->ref;
- $invoicestatic->status = $obj->fk_statut;
- $invoicestatic->statut = $obj->fk_statut; // For backward comaptibility
- $invoicestatic->paye = $obj->paye;
- $invoicestatic->type = $obj->type;
- $invoicestatic->date = $db->jdate($obj->datef);
- $invoicestatic->date_echeance = $db->jdate($obj->date_lim_reglement);
- $invoicestatic->total_ttc = $obj->total_ttc;
-
- $alreadypayed = $invoicestatic->getSommePaiement();
-
- $thirdpartystatic->id = $obj->socid;
- $thirdpartystatic->name = $obj->name;
- $thirdpartystatic->email = $obj->email;
- $thirdpartystatic->tva_intra = $obj->tva_intra;
- $thirdpartystatic->idprof1 = $obj->idprof1;
- $thirdpartystatic->idprof2 = $obj->idprof2;
- $thirdpartystatic->idprof3 = $obj->idprof3;
- $thirdpartystatic->idprof4 = $obj->idprof4;
- $thirdpartystatic->idprof5 = $obj->idprof5;
- $thirdpartystatic->idprof6 = $obj->idprof6;
-
-
- print '';
- print $invoicestatic->getNomUrl(1, 'withdraw');
- print ' | ';
-
- print '';
- print $thirdpartystatic->getNomUrl(1, 'supplier');
- print ' | ';
-
- print '';
- print ''.price($obj->amount).'';
- print ' | ';
-
- print '';
- print dol_print_date($db->jdate($obj->date_demande), 'day');
- print ' | ';
-
- print '';
- print $invoicestatic->getLibStatut(3, $alreadypayed);
- print ' | ';
- print '
';
- $i++;
- }
- } else {
- $titlefortab = $langs->transnoentitiesnoconv("BankTransfer");
- print ''.$langs->trans("NoSupplierInvoiceToWithdraw", $titlefortab, $titlefortab).' |
';
- }
- print "
";
- } else {
- dol_print_error($db);
- }
-}
-
-if (isModEnabled('salaries')) {
- $sqlForSalary = "SELECT * FROM ".MAIN_DB_PREFIX."salary as s, ".MAIN_DB_PREFIX."prelevement_demande as pd";
- $sqlForSalary .= " WHERE s.rowid = pd.fk_salary AND s.paye = 0 AND pd.traite = 0";
- $sqlForSalary .= " AND s.entity IN (".getEntity('salary').")";
-
- $resql2 = $db->query($sqlForSalary);
- if ($resql2) {
- $numRow = $db->num_rows($resql2);
- $j = 0 ;
-
- print '
';
- print '
';
- print '';
- print ''.$langs->trans("SalaryInvoiceWaitingWithdraw").' ('.$numRow.') |
';
-
- if ($numRow) {
- while ($j < $numRow && $j<10) {
- $objSalary = $db->fetch_object($resql2);
-
- $user->fetch($objSalary->fk_user);
-
- $salary->fetch($objSalary->fk_salary);
-
- $alreadypayedS = $salary->getSommePaiement();
-
- print '';
- print $salary->getNomUrl(1);
- print ' | ';
-
- print '';
- print $user->getNomUrl(-1);
- print ' | ';
-
- print '';
- print ''.price($objSalary->amount).'';
- print ' | ';
-
- print '';
- print dol_print_date($db->jdate($objSalary->date_demande), 'day');
- print ' | ';
-
- print '';
- print $salary->getLibStatut(3, $alreadypayedS);
- print ' | ';
- print '
';
- $j++;
- }
- } else {
- $titlefortab = $langs->transnoentitiesnoconv("BankTransfer");
- print ''.$langs->trans("NoSalaryInvoiceToWithdraw", $titlefortab, $titlefortab).' |
';
- }
- print "
";
- } else {
- dol_print_error($db);
- }
-}
-
-
-print '
';
+print '
'.$langs->trans("NbOfInvoiceToPayByBankTransfer").' | ';
+print '';
+print '';
+print $bprev->nbOfInvoiceToPay('bank-transfer');
+print '';
+print ' |
';
+
+print '
'.$langs->trans("AmountToWithdraw").' | ';
+print '';
+print price($bprev->SommeAPrelever('bank-transfer'), '', '', 1, -1, -1, 'auto');
+print ' |
';
+
+
+
+/*
+ * Invoices waiting for withdraw
+ */
+$sql = "SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type,";
+$sql .= " pfd.date_demande, pfd.amount,";
+$sql .= " s.nom as name, s.email, s.rowid as socid";
+$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,";
+$sql .= " ".MAIN_DB_PREFIX."societe as s";
+if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+$sql .= ", ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
+$sql .= " WHERE s.rowid = f.fk_soc";
+$sql .= " AND f.entity IN (".getEntity('supplier_invoice').")";
+$sql .= " AND f.total_ttc > 0";
+if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS))
+{
+ $sql .= " AND f.fk_statut = ".FactureFournisseur::STATUS_VALIDATED;
+}
+$sql .= " AND pfd.traite = 0";
+$sql .= " AND pfd.ext_payment_id IS NULL";
+$sql .= " AND pfd.fk_facture_fourn = f.rowid";
+if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+if ($socid) $sql .= " AND f.fk_soc = ".$socid;
+
+$resql = $db->query($sql);
+if ($resql)
+{
+ $num = $db->num_rows($resql);
+ $i = 0;
+
+ print '
';
+ print '
';
+ print '';
+ print ''.$langs->trans("SupplierInvoiceWaitingWithdraw").' ('.$num.') |
';
+ if ($num)
+ {
+ while ($i < $num && $i < 20)
+ {
+ $obj = $db->fetch_object($resql);
+
+ $invoicestatic->id = $obj->rowid;
+ $invoicestatic->ref = $obj->ref;
+ $invoicestatic->statut = $obj->fk_statut;
+ $invoicestatic->paye = $obj->paye;
+ $invoicestatic->type = $obj->type;
+ $alreadypayed = $invoicestatic->getSommePaiement();
+
+ $thirdpartystatic->id = $obj->socid;
+ $thirdpartystatic->name = $obj->name;
+ $thirdpartystatic->email = $obj->email;
+
+ print '';
+ print $invoicestatic->getNomUrl(1, 'withdraw');
+ print ' | ';
+
+ print '';
+ print $thirdpartystatic->getNomUrl(1, 'customer');
+ print ' | ';
+
+ print '';
+ print price($obj->amount);
+ print ' | ';
+
+ print '';
+ print dol_print_date($db->jdate($obj->date_demande), 'day');
+ print ' | ';
+
+ print '';
+ print $invoicestatic->getLibStatut(3, $alreadypayed);
+ print ' | ';
+ print '
';
+ $i++;
+ }
+ }
+ else
+ {
+ print ''.$langs->trans("NoSupplierInvoiceToWithdraw", $langs->transnoentitiesnoconv("BankTransfer")).' |
';
+ }
+ print "
";
+}
+else
+{
+ dol_print_error($db);
+}
+
+
+print '
';
+if ($result)
+{
+ $num = $db->num_rows($result);
+ $i = 0;
+
+ print"\n\n";
+ print '
";
+ $db->free($result);
+}
+else
+{
+ dol_print_error($db);
+}
+
+
+print '