Debug module credit transfer

This commit is contained in:
Laurent Destailleur 2020-07-01 14:19:47 +02:00
parent 5f2486049e
commit e2a9743dd4
6 changed files with 83 additions and 43 deletions

View File

@ -48,13 +48,12 @@ $ref = GETPOST('ref', 'alpha');
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$type = GETPOST('type', 'aZ09'); $type = GETPOST('type', 'aZ09');
$mode = GETPOST('mode', 'aZ09');
$fieldid = (!empty($ref) ? 'ref' : 'rowid'); $fieldid = (!empty($ref) ? 'ref' : 'rowid');
if ($user->socid) $socid = $user->socid; if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid); $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid);
if ($mode == 'bank-transfer') { if ($type == 'bank-transfer') {
$object = new FactureFournisseur($db); $object = new FactureFournisseur($db);
} else { } else {
$object = new Facture($db); $object = new Facture($db);
@ -94,6 +93,7 @@ if (empty($reshook))
$sourcetype = 'facture'; $sourcetype = 'facture';
if ($type == 'bank-transfer') { if ($type == 'bank-transfer') {
$sourcetype = 'supplier_invoice'; $sourcetype = 'supplier_invoice';
$newtype = 'bank-transfer';
} }
$result = $object->demande_prelevement($user, price2num(GETPOST('withdraw_request_amount', 'alpha')), $newtype, $sourcetype); $result = $object->demande_prelevement($user, price2num(GETPOST('withdraw_request_amount', 'alpha')), $newtype, $sourcetype);
@ -119,7 +119,7 @@ if (empty($reshook))
$result = $object->demande_prelevement_delete($user, GETPOST('did', 'int')); $result = $object->demande_prelevement_delete($user, GETPOST('did', 'int'));
if ($result == 0) if ($result == 0)
{ {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id.'&mode='.$mode); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id.'&type='.$type);
exit; exit;
} }
} }
@ -135,7 +135,7 @@ $form = new Form($db);
$now = dol_now(); $now = dol_now();
if ($mode == 'bank-transfer') { if ($type == 'bank-transfer') {
$title = $langs->trans('InvoiceSupplier')." - ".$langs->trans('CreditTransfer'); $title = $langs->trans('InvoiceSupplier')." - ".$langs->trans('CreditTransfer');
$helpurl = ""; $helpurl = "";
} else { } else {
@ -170,7 +170,7 @@ if ($object->id > 0)
if ($object->paye) $resteapayer = 0; if ($object->paye) $resteapayer = 0;
$resteapayeraffiche = $resteapayer; $resteapayeraffiche = $resteapayer;
if ($mode == 'bank-transfer') { if ($type == 'bank-transfer') {
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Never use this if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Never use this
$filterabsolutediscount = "fk_invoice_supplier_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice $filterabsolutediscount = "fk_invoice_supplier_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
$filtercreditnote = "fk_invoice_supplier_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice $filtercreditnote = "fk_invoice_supplier_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
@ -204,7 +204,7 @@ if ($object->id > 0)
$author->fetch($object->user_author); $author->fetch($object->user_author);
} }
if ($mode == 'bank-transfer') { if ($type == 'bank-transfer') {
$head = facturefourn_prepare_head($object); $head = facturefourn_prepare_head($object);
} else { } else {
$head = facture_prepare_head($object); $head = facture_prepare_head($object);
@ -213,7 +213,7 @@ if ($object->id > 0)
dol_fiche_head($head, 'standingorders', $title, -1, 'bill'); dol_fiche_head($head, 'standingorders', $title, -1, 'bill');
// Invoice content // Invoice content
if ($mode == 'bank-transfer') { if ($type == 'bank-transfer') {
$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
} else { } else {
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
@ -221,7 +221,7 @@ if ($object->id > 0)
$morehtmlref = '<div class="refidno">'; $morehtmlref = '<div class="refidno">';
// Ref customer // Ref customer
if ($mode == 'bank-transfer') { if ($type == 'bank-transfer') {
$morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1); $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
$morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1); $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
} else { } else {
@ -230,7 +230,7 @@ if ($object->id > 0)
} }
// Thirdparty // Thirdparty
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
if ($mode == 'bank-transfer') { if ($type == 'bank-transfer') {
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)'; if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)';
} else { } else {
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)'; if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)';
@ -290,7 +290,7 @@ if ($object->id > 0)
} }
if ($object->type == $object::TYPE_REPLACEMENT) if ($object->type == $object::TYPE_REPLACEMENT)
{ {
if ($mode == 'bank-transfer') { if ($type == 'bank-transfer') {
$facreplaced = new FactureFournisseur($db); $facreplaced = new FactureFournisseur($db);
} else { } else {
$facreplaced = new Facture($db); $facreplaced = new Facture($db);
@ -300,7 +300,7 @@ if ($object->id > 0)
} }
if ($object->type == $object::TYPE_CREDIT_NOTE) if ($object->type == $object::TYPE_CREDIT_NOTE)
{ {
if ($mode == 'bank-transfer') { if ($type == 'bank-transfer') {
$facusing = new FactureFournisseur($db); $facusing = new FactureFournisseur($db);
} else { } else {
$facusing = new Facture($db); $facusing = new Facture($db);
@ -318,7 +318,7 @@ if ($object->id > 0)
{ {
if ($i == 0) print ' '; if ($i == 0) print ' ';
else print ','; else print ',';
if ($mode == 'bank-transfer') { if ($type == 'bank-transfer') {
$facavoir = new FactureFournisseur($db); $facavoir = new FactureFournisseur($db);
} else { } else {
$facavoir = new Facture($db); $facavoir = new Facture($db);
@ -341,7 +341,7 @@ if ($object->id > 0)
// Discounts // Discounts
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="3">'; print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="3">';
if ($mode == 'bank-transfer') { if ($type == 'bank-transfer') {
//$societe = new Fournisseur($db); //$societe = new Fournisseur($db);
//$result = $societe->fetch($object->socid); //$result = $societe->fetch($object->socid);
$thirdparty = $object->thirdparty; $thirdparty = $object->thirdparty;
@ -357,7 +357,7 @@ if ($object->id > 0)
print '</td></tr>'; print '</td></tr>';
// Label // Label
if ($mode == 'bank-transfer') { if ($type == 'bank-transfer') {
print '<tr>'; print '<tr>';
print '<td>'.$form->editfieldkey("Label", 'label', $object->label, $object, 0).'</td>'; print '<td>'.$form->editfieldkey("Label", 'label', $object->label, $object, 0).'</td>';
print '<td>'.$form->editfieldval("Label", 'label', $object->label, $object, 0).'</td>'; print '<td>'.$form->editfieldval("Label", 'label', $object->label, $object, 0).'</td>';
@ -427,7 +427,7 @@ if ($object->id > 0)
if ($object->type != $object::TYPE_CREDIT_NOTE) if ($object->type != $object::TYPE_CREDIT_NOTE)
{ {
$duedate = $object->date_lim_reglement; $duedate = $object->date_lim_reglement;
if ($mode == 'bank-transfer') { if ($type == 'bank-transfer') {
$duedate = $object->date_echeance; $duedate = $object->date_echeance;
} }
@ -488,7 +488,7 @@ if ($object->id > 0)
print '</tr>'; print '</tr>';
$title = 'CustomerIBAN'; $title = 'CustomerIBAN';
if ($mode == 'bank-transfer') { if ($type == 'bank-transfer') {
$title = 'SupplierIBAN'; $title = 'SupplierIBAN';
} }
print '<tr><td>'.$langs->trans($title).'</td><td colspan="3">'; print '<tr><td>'.$langs->trans($title).'</td><td colspan="3">';
@ -649,7 +649,7 @@ if ($object->id > 0)
print "\n<div class=\"tabsAction\">\n"; print "\n<div class=\"tabsAction\">\n";
$buttonlabel = $langs->trans("MakeWithdrawRequest"); $buttonlabel = $langs->trans("MakeWithdrawRequest");
if ($mode == 'bank-transfer') { if ($type == 'bank-transfer') {
$buttonlabel = $langs->trans("MakeBankTransferOrder"); $buttonlabel = $langs->trans("MakeBankTransferOrder");
} }
@ -665,6 +665,7 @@ if ($object->id > 0)
print '<form method="POST" action="">'; print '<form method="POST" action="">';
print '<input type="hidden" name="token" value="'.newToken().'" />'; print '<input type="hidden" name="token" value="'.newToken().'" />';
print '<input type="hidden" name="id" value="'.$object->id.'" />'; print '<input type="hidden" name="id" value="'.$object->id.'" />';
print '<input type="hidden" name="type" value="'.$type.'" />';
print '<input type="hidden" name="action" value="new" />'; print '<input type="hidden" name="action" value="new" />';
print '<label for="withdraw_request_amount">'.$langs->trans('BankTransferAmount').' </label>'; print '<label for="withdraw_request_amount">'.$langs->trans('BankTransferAmount').' </label>';
print '<input type="text" id="withdraw_request_amount" name="withdraw_request_amount" value="'.$remaintopaylesspendingdebit.'" size="9" />'; print '<input type="text" id="withdraw_request_amount" name="withdraw_request_amount" value="'.$remaintopaylesspendingdebit.'" size="9" />';
@ -694,7 +695,7 @@ if ($object->id > 0)
print "</div><br>\n"; print "</div><br>\n";
if ($mode == 'bank-transfer') { if ($type == 'bank-transfer') {
print '<div class="opacitymedium">'.$langs->trans("DoCreditTransferBeforePayments").'</div><br>'; print '<div class="opacitymedium">'.$langs->trans("DoCreditTransferBeforePayments").'</div><br>';
} else { } else {
print '<div class="opacitymedium">'.$langs->trans("DoStandingOrdersBeforePayments").'</div><br>'; print '<div class="opacitymedium">'.$langs->trans("DoStandingOrdersBeforePayments").'</div><br>';
@ -711,7 +712,7 @@ if ($object->id > 0)
print '<td class="left">'.$langs->trans("DateRequest").'</td>'; print '<td class="left">'.$langs->trans("DateRequest").'</td>';
print '<td class="center">'.$langs->trans("User").'</td>'; print '<td class="center">'.$langs->trans("User").'</td>';
print '<td class="center">'.$langs->trans("Amount").'</td>'; print '<td class="center">'.$langs->trans("Amount").'</td>';
if ($mode == 'bank-transfer') { if ($type == 'bank-transfer') {
print '<td class="center">'.$langs->trans("BankTransferReceipt").'</td>'; print '<td class="center">'.$langs->trans("BankTransferReceipt").'</td>';
} else { } else {
print '<td class="center">'.$langs->trans("WithdrawalReceipt").'</td>'; print '<td class="center">'.$langs->trans("WithdrawalReceipt").'</td>';
@ -723,7 +724,7 @@ if ($object->id > 0)
$sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande,"; $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande,";
$sql .= " pfd.date_traite as date_traite, pfd.amount,"; $sql .= " pfd.date_traite as date_traite, pfd.amount,";
$sql .= " u.rowid as user_id, u.lastname, u.firstname, u.login"; $sql .= " u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
@ -743,14 +744,29 @@ if ($object->id > 0)
{ {
$i = 0; $i = 0;
$tmpuser = new User($db);
$num = $db->num_rows($result); $num = $db->num_rows($result);
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($result_sql); $obj = $db->fetch_object($result_sql);
$tmpuser->id = $obj->user_id;
$tmpuser->login = $obj->login;
$tmpuser->ref = $obj->login;
$tmpuser->email = $obj->email;
$tmpuser->lastname = $obj->lastname;
$tmpuser->firstname = $obj->firstname;
$tmpuser->statut = $obj->user_status;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="left">'.dol_print_date($db->jdate($obj->date_demande), 'dayhour')."</td>\n"; print '<td class="left">'.dol_print_date($db->jdate($obj->date_demande), 'dayhour')."</td>\n";
print '<td align="center"><a href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.'</a></td>';
print '<td align="center">';
print $tmpuser->getNomUrl(1, '', 0, 0, 0, 0, 'login');
print '</td>';
print '<td class="center">'.price($obj->amount).'</td>'; print '<td class="center">'.price($obj->amount).'</td>';
print '<td align="center">-</td>'; print '<td align="center">-</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
@ -758,7 +774,7 @@ if ($object->id > 0)
print '<td class="center">'.$langs->trans("OrderWaiting").'</td>'; print '<td class="center">'.$langs->trans("OrderWaiting").'</td>';
print '<td class="right">'; print '<td class="right">';
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&did='.$obj->rowid.'&mode='.$mode.'">'; print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&did='.$obj->rowid.'&type='.$type.'">';
print img_delete(); print img_delete();
print '</a></td>'; print '</a></td>';
@ -778,7 +794,7 @@ if ($object->id > 0)
$sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande, pfd.date_traite, pfd.fk_prelevement_bons, pfd.amount,"; $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande, pfd.date_traite, pfd.fk_prelevement_bons, pfd.amount,";
$sql .= " pb.ref,"; $sql .= " pb.ref,";
$sql .= " u.rowid as user_id, u.lastname, u.firstname, u.login"; $sql .= " u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
@ -798,15 +814,27 @@ if ($object->id > 0)
$numclosed = $num; $numclosed = $num;
$i = 0; $i = 0;
$tmpuser = new User($db);
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$tmpuser->id = $obj->user_id;
$tmpuser->login = $obj->login;
$tmpuser->ref = $obj->login;
$tmpuser->email = $obj->email;
$tmpuser->lastname = $obj->lastname;
$tmpuser->firstname = $obj->firstname;
$tmpuser->statut = $obj->user_status;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="left">'.dol_print_date($db->jdate($obj->date_demande), 'day')."</td>\n"; print '<td class="left">'.dol_print_date($db->jdate($obj->date_demande), 'day')."</td>\n";
print '<td align="center"><a href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.'</a></td>'; print '<td align="center">';
print $tmpuser->getNomUrl(1, '', 0, 0, 0, 0, 'login');
print '</td>';
print '<td class="center">'.price($obj->amount).'</td>'; print '<td class="center">'.price($obj->amount).'</td>';

View File

@ -94,11 +94,11 @@ print '</td></tr></table></div><br>';
*/ */
$sql = "SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type,"; $sql = "SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type,";
$sql .= " pfd.date_demande, pfd.amount,"; $sql .= " pfd.date_demande, pfd.amount,";
$sql .= " s.nom as name, s.rowid as socid"; $sql .= " s.nom as name, s.email, s.rowid as socid";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f,"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,";
$sql .= " ".MAIN_DB_PREFIX."societe as s"; $sql .= " ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; 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 .= ", ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
$sql .= " WHERE s.rowid = f.fk_soc"; $sql .= " WHERE s.rowid = f.fk_soc";
$sql .= " AND f.entity IN (".getEntity('supplier_invoice').")"; $sql .= " AND f.entity IN (".getEntity('supplier_invoice').")";
$sql .= " AND f.total_ttc > 0"; $sql .= " AND f.total_ttc > 0";
@ -133,14 +133,15 @@ if ($resql)
$invoicestatic->type = $obj->type; $invoicestatic->type = $obj->type;
$alreadypayed = $invoicestatic->getSommePaiement(); $alreadypayed = $invoicestatic->getSommePaiement();
$thirdpartystatic->id = $obj->socid;
$thirdpartystatic->name = $obj->name;
$thirdpartystatic->email = $obj->email;
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $invoicestatic->getNomUrl(1, 'withdraw'); print $invoicestatic->getNomUrl(1, 'withdraw');
print '</td>'; print '</td>';
print '<td>'; print '<td>';
$thirdpartystatic->id = $obj->socid;
$thirdpartystatic->name = $obj->name;
print $thirdpartystatic->getNomUrl(1, 'customer'); print $thirdpartystatic->getNomUrl(1, 'customer');
print '</td>'; print '</td>';

View File

@ -703,9 +703,16 @@ class BonPrelevement extends CommonObject
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,";
} }
$sql .= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $sql .= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
$sql .= " WHERE f.fk_statut = 1"; $sql .= " WHERE f.entity IN (".getEntity('invoice').")";
$sql .= " AND f.entity IN (".getEntity('invoice').")"; if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS))
$sql .= " AND f.rowid = pfd.fk_facture"; {
$sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED;
}
if ($mode != 'bank-transfer') {
$sql .= " AND f.rowid = pfd.fk_facture";
} else {
$sql .= " AND f.rowid = pfd.fk_facture_fourn";
}
$sql .= " AND f.paye = 0"; $sql .= " AND f.paye = 0";
$sql .= " AND pfd.traite = 0"; $sql .= " AND pfd.traite = 0";
$sql .= " AND f.total_ttc > 0"; $sql .= " AND f.total_ttc > 0";
@ -744,16 +751,16 @@ class BonPrelevement extends CommonObject
/** /**
* Get number of invoices to withdrawal * Get number of invoices to withdrawal
* *
* @param string $mode 'direct-debit' or 'bank-transfer' * @param string $type 'direct-debit' or 'bank-transfer'
* @return int <O if KO, number of invoices if OK * @return int <O if KO, number of invoices if OK
*/ */
public function NbFactureAPrelever($mode = 'direct-debit') public function NbFactureAPrelever($type = 'direct-debit')
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
$sql = "SELECT count(f.rowid) as nb"; $sql = "SELECT count(f.rowid) as nb";
if ($mode == 'bank-transfer') { if ($type == 'bank-transfer') {
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
} else { } else {
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
@ -764,7 +771,7 @@ class BonPrelevement extends CommonObject
{ {
$sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; $sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED;
} }
if ($mode == 'bank-transfer') { if ($type == 'bank-transfer') {
$sql .= " AND f.rowid = pfd.fk_facture_fourn"; $sql .= " AND f.rowid = pfd.fk_facture_fourn";
} else { } else {
$sql .= " AND f.rowid = pfd.fk_facture"; $sql .= " AND f.rowid = pfd.fk_facture";

View File

@ -304,9 +304,14 @@ if ($resql)
} }
print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, '', '', '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit); print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, '', '', '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit);
$tradinvoice = "Invoice";
if ($type == 'bank-transfer') {
$tradinvoice = "SupplierInvoice";
}
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Invoice").'</td>'; print '<td>'.$langs->trans($tradinvoice).'</td>';
print '<td>'.$langs->trans("ThirdParty").'</td>'; print '<td>'.$langs->trans("ThirdParty").'</td>';
print '<td>'.$langs->trans("RIB").'</td>'; print '<td>'.$langs->trans("RIB").'</td>';
print '<td>'.$langs->trans("RUM").'</td>'; print '<td>'.$langs->trans("RUM").'</td>';

View File

@ -94,7 +94,7 @@ print '</td></tr></table></div><br>';
*/ */
$sql = "SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type,"; $sql = "SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type,";
$sql .= " pfd.date_demande, pfd.amount,"; $sql .= " pfd.date_demande, pfd.amount,";
$sql .= " s.nom as name, s.rowid as socid"; $sql .= " s.nom as name, s.email, s.rowid as socid";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f,"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f,";
$sql .= " ".MAIN_DB_PREFIX."societe as s"; $sql .= " ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@ -133,14 +133,15 @@ if ($resql)
$invoicestatic->type = $obj->type; $invoicestatic->type = $obj->type;
$alreadypayed = $invoicestatic->getSommePaiement(); $alreadypayed = $invoicestatic->getSommePaiement();
$thirdpartystatic->id = $obj->socid;
$thirdpartystatic->name = $obj->name;
$thirdpartystatic->email = $obj->email;
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $invoicestatic->getNomUrl(1, 'withdraw'); print $invoicestatic->getNomUrl(1, 'withdraw');
print '</td>'; print '</td>';
print '<td>'; print '<td>';
$thirdpartystatic->id = $obj->socid;
$thirdpartystatic->name = $obj->name;
print $thirdpartystatic->getNomUrl(1, 'customer'); print $thirdpartystatic->getNomUrl(1, 'customer');
print '</td>'; print '</td>';

View File

@ -68,7 +68,7 @@ function facturefourn_prepare_head($object)
if ($obj) $nbStandingOrders = $obj->nb; if ($obj) $nbStandingOrders = $obj->nb;
} }
else dol_print_error($db); else dol_print_error($db);
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$object->id.'&mode=bank-transfer'; $head[$h][0] = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$object->id.'&type=bank-transfer';
$head[$h][1] = $langs->trans('BankTransfer'); $head[$h][1] = $langs->trans('BankTransfer');
if ($nbStandingOrders > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbStandingOrders.'</span>'; if ($nbStandingOrders > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbStandingOrders.'</span>';
$head[$h][2] = 'standingorders'; $head[$h][2] = 'standingorders';
@ -233,8 +233,6 @@ function supplierorder_admin_prepare_head()
$head[$h][2] = 'supplierorderdet'; $head[$h][2] = 'supplierorderdet';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/admin/supplierinvoice_extrafields.php'; $head[$h][0] = DOL_URL_ROOT.'/admin/supplierinvoice_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsSupplierInvoices"); $head[$h][1] = $langs->trans("ExtraFieldsSupplierInvoices");
$head[$h][2] = 'supplierinvoice'; $head[$h][2] = 'supplierinvoice';