Fix work on payment by bank transfer (avoid confusion between record)

This commit is contained in:
Laurent Destailleur 2020-05-27 20:14:11 +02:00
parent ada9c9addc
commit 15f2165c12
18 changed files with 185 additions and 75 deletions

View File

@ -28,7 +28,7 @@
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
@ -75,9 +75,9 @@ print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>'; print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("NbOfInvoiceToWithdraw").'</td>'; print '<tr class="oddeven"><td>'.$langs->trans("NbOfInvoiceToPayByBankTransfer").'</td>';
print '<td class="right">'; print '<td class="right">';
print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/demandes.php?status=0">'; print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/demandes.php?status=0&type=bank-transfer">';
print $bprev->NbFactureAPrelever(); print $bprev->NbFactureAPrelever();
print '</a>'; print '</a>';
print '</td></tr>'; print '</td></tr>';
@ -100,11 +100,11 @@ $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('invoice').")"; $sql .= " AND f.entity IN (".getEntity('supplier_invoice').")";
$sql .= " AND f.total_ttc > 0"; $sql .= " AND f.total_ttc > 0";
if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS))
{ {
$sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; $sql .= " AND f.fk_statut = ".FactureFournisseur::STATUS_VALIDATED;
} }
$sql .= " AND pfd.traite = 0 AND pfd.fk_facture_fourn = f.rowid"; $sql .= " AND pfd.traite = 0 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 (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
@ -177,9 +177,11 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
/* /*
* Withdraw receipts * Withdraw receipts
*/ */
$limit = 5; $limit = 5;
$sql = "SELECT p.rowid, p.ref, p.amount, p.datec, p.statut"; $sql = "SELECT p.rowid, p.ref, p.amount, p.datec, p.statut";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= " WHERE p.type = 'bank-transfer'";
$sql .= " ORDER BY datec DESC"; $sql .= " ORDER BY datec DESC";
$sql .= $db->plimit($limit); $sql .= $db->plimit($limit);
@ -198,11 +200,11 @@ if ($result)
print '<th class="right">'.$langs->trans("Status").'</th>'; print '<th class="right">'.$langs->trans("Status").'</th>';
print '</tr>'; print '</tr>';
if ($num > 0) {
while ($i < min($num, $limit)) while ($i < min($num, $limit))
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print "<td>"; print "<td>";
@ -218,6 +220,10 @@ if ($result)
print "</tr>\n"; print "</tr>\n";
$i++; $i++;
} }
} else {
print '<tr><td class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
print "</table></div><br>"; print "</table></div><br>";
$db->free($result); $db->free($result);
} }

View File

@ -38,6 +38,8 @@ $socid = GETPOST('socid', 'int');
if ($user->socid) $socid = $user->socid; if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'prelevement', '', '', 'bons'); $result = restrictedArea($user, 'prelevement', '', '', 'bons');
$type = GETPOST('type', 'aZ09');
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha');
@ -57,6 +59,11 @@ $search_amount = GETPOST('search_amount', 'alpha');
$bon = new BonPrelevement($db); $bon = new BonPrelevement($db);
$hookmanager->initHooks(array('withdrawalsreceiptslist')); $hookmanager->initHooks(array('withdrawalsreceiptslist'));
$usercancreate = $user->rights->prelevement->bons->creer;
if ($type == 'bank-transfer') {
$usercancreate = $user->rights->paymentbybanktransfer->create;
}
/* /*
* Actions * Actions
@ -78,6 +85,11 @@ llxHeader('', $langs->trans("WithdrawalsReceipts"));
$sql = "SELECT p.rowid, p.ref, p.amount, p.statut, p.datec"; $sql = "SELECT p.rowid, p.ref, p.amount, p.statut, p.datec";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= " WHERE p.entity IN (".getEntity('invoice').")"; $sql .= " WHERE p.entity IN (".getEntity('invoice').")";
if ($type == 'bank-transfer') {
$sql .= " AND p.type = 'bank-transfer'";
} else {
$sql .= " AND p.type = 'debit-order'";
}
if ($search_ref) $sql .= natural_search("p.ref", $search_ref); if ($search_ref) $sql .= natural_search("p.ref", $search_ref);
if ($search_amount) $sql .= natural_search("p.amount", $search_amount, 1); if ($search_amount) $sql .= natural_search("p.amount", $search_amount, 1);
@ -112,7 +124,7 @@ if ($result)
$selectedfields = ''; $selectedfields = '';
$newcardbutton = ''; $newcardbutton = '';
if ($user->rights->prelevement->bons->creer) if ($usercancreate)
{ {
$newcardbutton .= dolGetButtonTitle($langs->trans('NewStandingOrder'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/prelevement/create.php'); $newcardbutton .= dolGetButtonTitle($langs->trans('NewStandingOrder'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/prelevement/create.php');
} }
@ -127,7 +139,14 @@ if ($result)
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print_barre_liste($langs->trans("WithdrawalsReceipts"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit, 0, 0, 1); $titlekey = "WithdrawalsReceipts";
$title = $langs->trans("WithdrawalsReceipts");
if ($type == 'bank-transfer') {
$titlekey = "BankTransferReceipts";
$title = $langs->trans("BankTransferReceipts");
}
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit, 0, 0, 1);
$moreforfilter = ''; $moreforfilter = '';
@ -146,7 +165,7 @@ if ($result)
print '</tr>'; print '</tr>';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("WithdrawalsReceipts", $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder); print_liste_field_titre($titlekey, $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder);
print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "p.amount", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "p.amount", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');

View File

@ -45,6 +45,8 @@ $id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
$type = GETPOST('type', 'aZ09');
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'alpha');

View File

@ -638,8 +638,7 @@ class BonPrelevement extends CommonObject
$arr = array(); $arr = array();
/* /*
* Returns all invoices presented * Returns all invoices presented within same order
* within a withdrawal receipt
*/ */
$sql = "SELECT fk_facture"; $sql = "SELECT fk_facture";
if ($amounts) $sql .= ", SUM(pl.amount)"; if ($amounts) $sql .= ", SUM(pl.amount)";
@ -1159,8 +1158,12 @@ class BonPrelevement extends CommonObject
if (!$notrigger) if (!$notrigger)
{ {
$triggername = 'DIRECT_DEBIT_ORDER_DELETE';
if ($this->type == 'bank-transfer') {
$triggername = 'PAYMENTBYBANKTRANFER_DELETE';
}
// Call trigger // Call trigger
$result = $this->call_trigger('DIRECT_DEBIT_ORDER_DELETE', $user); $result = $this->call_trigger($triggername, $user);
if ($result < 0) $error++; if ($result < 0) $error++;
// End call triggers // End call triggers
} }
@ -1224,7 +1227,12 @@ class BonPrelevement extends CommonObject
$result = ''; $result = '';
$label = '<u>'.$langs->trans("ShowWithdraw").'</u>'; $labeltoshow = 'Withdraw';
if ($this->type == 'bank-transfer') {
$labeltoshow = 'PaymentByBankTransfer';
}
$label = '<u>'.$langs->trans($labeltoshow).'</u>';
$label .= '<br>'; $label .= '<br>';
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref; $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
if (isset($this->statut)) { if (isset($this->statut)) {
@ -1232,6 +1240,9 @@ class BonPrelevement extends CommonObject
} }
$url = DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$this->id; $url = DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$this->id;
if ($this->type == 'bank-transfer') {
$url = DOL_URL_ROOT.'/compta/paymentbybanktransfer/card.php?id='.$this->id;
}
if ($option != 'nolink') if ($option != 'nolink')
{ {
@ -1272,7 +1283,7 @@ class BonPrelevement extends CommonObject
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
global $action, $hookmanager; global $action, $hookmanager;
$hookmanager->initHooks(array('myobjectdao')); $hookmanager->initHooks(array('banktransferdao'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result); $parameters = array('id'=>$this->id, 'getnomurl'=>$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $result = $hookmanager->resPrint; if ($reshook > 0) $result = $hookmanager->resPrint;

View File

@ -43,6 +43,8 @@ $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies', 'bill
if ($user->socid) $socid = $user->socid; if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'prelevement', '', '', 'bons'); $result = restrictedArea($user, 'prelevement', '', '', 'bons');
$type = GETPOST('type', 'aZ09');
// Get supervariables // Get supervariables
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$mode = GETPOST('mode', 'alpha') ?GETPOST('mode', 'alpha') : 'real'; $mode = GETPOST('mode', 'alpha') ?GETPOST('mode', 'alpha') : 'real';
@ -130,7 +132,12 @@ $h++;
dol_fiche_head($head, $hselected, $langs->trans("StandingOrders"), 0, 'payment'); dol_fiche_head($head, $hselected, $langs->trans("StandingOrders"), 0, 'payment');
*/ */
print load_fiche_titre($langs->trans("NewStandingOrder")); $title = $langs->trans("NewStandingOrder");
if ($type == 'bank-transfer') {
$title = $langs->trans("NewPaymentByBankTransfer");
}
print load_fiche_titre($title);
dol_fiche_head(); dol_fiche_head();
@ -144,12 +151,17 @@ if ($nb < 0 || $nb1 < 0 || $nb11 < 0)
} }
print '<table class="border centpercent tableforfield">'; print '<table class="border centpercent tableforfield">';
print '<tr><td class="titlefield">'.$langs->trans("NbOfInvoiceToWithdraw").'</td>'; $title = $langs->trans("NbOfInvoiceToWithdraw");
if ($type == 'bank-transfer') {
$title = $langs->trans("NbOfInvoiceToPayByBankTransfer");
}
print '<tr><td class="titlefield">'.$title.'</td>';
print '<td>'; print '<td>';
print $nb; print $nb;
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("AmountToWithdraw").'</td>'; print '<tr><td>'.$langs->trans("AmountTotal").'</td>';
print '<td>'; print '<td>';
print price($pricetowithdraw); print price($pricetowithdraw);
print '</td>'; print '</td>';
@ -160,7 +172,7 @@ print '</div>';
if ($mesg) print $mesg; if ($mesg) print $mesg;
print "<div class=\"tabsAction\">\n"; print '<div class="tabsAction">'."\n";
print '<form action="'.$_SERVER['PHP_SELF'].'?action=create" method="POST">'; print '<form action="'.$_SERVER['PHP_SELF'].'?action=create" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -184,7 +196,11 @@ if ($nb) {
} }
else else
{ {
print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("CreateAll")."</a>\n"; $title = $langs->trans("CreateAll");
if ($type == 'bank-transfer') {
$title = $langs->trans("CreateFileForPaymentByBankTransfer");
}
print '<a class="butActionRefused classfortooltip" href="#">'.$title."</a>\n";
} }
} }
} }
@ -206,7 +222,11 @@ print '<br>';
$sql = "SELECT f.ref, f.rowid, f.total_ttc, s.nom as name, s.rowid as socid,"; $sql = "SELECT f.ref, f.rowid, f.total_ttc, s.nom as name, s.rowid as socid,";
$sql .= " pfd.date_demande, pfd.amount"; $sql .= " pfd.date_demande, pfd.amount";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f,"; if ($type == 'bank-transfer') {
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,";
} else {
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f,";
}
$sql .= " ".MAIN_DB_PREFIX."societe as s,"; $sql .= " ".MAIN_DB_PREFIX."societe as s,";
$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";
@ -217,7 +237,11 @@ if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS))
} }
$sql .= " AND f.total_ttc > 0"; $sql .= " AND f.total_ttc > 0";
$sql .= " AND pfd.traite = 0"; $sql .= " AND pfd.traite = 0";
$sql .= " AND pfd.fk_facture = f.rowid"; if ($type == 'bank-transfer') {
$sql .= " AND pfd.fk_facture = f.rowid";
} else {
$sql .= " AND pfd.fk_facture_fourn = f.rowid";
}
if ($socid > 0) $sql .= " AND f.fk_soc = ".$socid; if ($socid > 0) $sql .= " AND f.fk_soc = ".$socid;
$nbtotalofrecords = ''; $nbtotalofrecords = '';
@ -252,7 +276,11 @@ if ($resql)
print '<input type="hidden" name="limit" value="'.$limit.'"/>'; print '<input type="hidden" name="limit" value="'.$limit.'"/>';
} }
print_barre_liste($langs->trans("InvoiceWaitingWithdraw"), $page, $_SERVER['PHP_SELF'], $param, '', '', '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit); $title = $langs->trans("InvoiceWaitingWithdraw");
if ($type == 'bank-transfer') {
$title = $langs->trans("InvoiceWaitingPaymentByBankTransfer");
}
print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, '', '', '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit);
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';

View File

@ -21,12 +21,13 @@
/** /**
* \file htdocs/compta/prelevement/demandes.php * \file htdocs/compta/prelevement/demandes.php
* \ingroup prelevement * \ingroup prelevement
* \brief Page to list withdraw requests * \brief Page to list bank transfer requests (debit order or payments of vendors)
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/modPrelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/modPrelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
@ -43,6 +44,8 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myo
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$type = GETPOST('type', 'aZ09');
$search_facture = GETPOST('search_facture', 'alpha'); $search_facture = GETPOST('search_facture', 'alpha');
$search_societe = trim(GETPOST('search_societe', 'alpha')); $search_societe = trim(GETPOST('search_societe', 'alpha'));
@ -85,13 +88,20 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
* View * View
*/ */
if (!$status) if ($type != 'bank-transfer') {
{ if (!$status)
{
$title = $langs->trans("RequestStandingOrderToTreat"); $title = $langs->trans("RequestStandingOrderToTreat");
} } else {
else
{
$title = $langs->trans("RequestStandingOrderTreated"); $title = $langs->trans("RequestStandingOrderTreated");
}
} else {
if (!$status)
{
$title = $langs->trans("RequestPaymentsByBankTransferToTreat");
} else {
$title = $langs->trans("RequestPaymentsByBankTransferTreated");
}
} }
llxHeader('', $title); llxHeader('', $title);
@ -105,7 +115,11 @@ $sql = "SELECT f.ref, f.rowid, f.total_ttc,";
$sql .= " s.nom as name, s.rowid as socid,"; $sql .= " s.nom as name, s.rowid as socid,";
$sql .= " pfd.date_demande as date_demande,"; $sql .= " pfd.date_demande as date_demande,";
$sql .= " pfd.fk_user_demande"; $sql .= " pfd.fk_user_demande";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f,"; if ($type != 'bank-transfer') {
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f,";
} else {
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,";
}
$sql .= " ".MAIN_DB_PREFIX."societe as s,"; $sql .= " ".MAIN_DB_PREFIX."societe as s,";
$sql .= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $sql .= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
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";
@ -120,7 +134,11 @@ if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS))
{ {
$sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; $sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED;
} }
$sql .= " AND pfd.fk_facture = f.rowid"; if ($type != 'bank-transfer') {
$sql .= " AND pfd.fk_facture = f.rowid";
} else {
$sql .= " AND pfd.fk_facture_fourn = f.rowid";
}
if ($search_facture) $sql .= natural_search("f.ref", $search_facture); if ($search_facture) $sql .= natural_search("f.ref", $search_facture);
if ($search_societe) $sql .= natural_search("s.nom", $search_societe); if ($search_societe) $sql .= natural_search("s.nom", $search_societe);
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
@ -142,9 +160,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)
{ {
$num = $nbtotalofrecords; $num = $nbtotalofrecords;
} } else {
else
{
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql); $resql = $db->query($sql);
@ -160,6 +176,9 @@ else
$newcardbutton = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/index.php">'.$langs->trans("Back").'</a>'; $newcardbutton = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/index.php">'.$langs->trans("Back").'</a>';
if ($type == 'bank-transfer') {
$newcardbutton = '<a href="'.DOL_URL_ROOT.'/compta/paymentbybanktransfer/index.php">'.$langs->trans("Back").'</a>';
}
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" id="searchFormList" name="searchFormList">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" id="searchFormList" name="searchFormList">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@ -171,6 +190,8 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$param = '';
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit);
print '<table class="liste centpercent">'; print '<table class="liste centpercent">';
@ -195,8 +216,6 @@ print $searchpicto;
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
$users = array();
$i = 0; $i = 0;
while ($i < min($num, $limit)) while ($i < min($num, $limit))
{ {

View File

@ -42,6 +42,8 @@ $prev_id = GETPOST('id', 'int');
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
$type = GETPOST('type', 'aZ09');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');

View File

@ -41,6 +41,8 @@ if ($user->socid > 0) accessforbidden();
$prev_id = GETPOST('id', 'int'); $prev_id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
$type = GETPOST('type', 'aZ09');
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'alpha');

View File

@ -39,6 +39,8 @@ if ($user->socid > 0) accessforbidden();
$prev_id = GETPOST('id', 'int'); $prev_id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
$type = GETPOST('type', 'aZ09');
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'alpha');

View File

@ -180,6 +180,7 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
$limit = 5; $limit = 5;
$sql = "SELECT p.rowid, p.ref, p.amount, p.datec, p.statut"; $sql = "SELECT p.rowid, p.ref, p.amount, p.datec, p.statut";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= " WHERE p.type = 'debit-order'";
$sql .= " ORDER BY datec DESC"; $sql .= " ORDER BY datec DESC";
$sql .= $db->plimit($limit); $sql .= $db->plimit($limit);
@ -198,6 +199,7 @@ if ($result)
print '<th class="right">'.$langs->trans("Status").'</th>'; print '<th class="right">'.$langs->trans("Status").'</th>';
print '</tr>'; print '</tr>';
if ($num > 0) {
while ($i < min($num, $limit)) while ($i < min($num, $limit))
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
@ -218,6 +220,10 @@ if ($result)
print "</tr>\n"; print "</tr>\n";
$i++; $i++;
} }
} else {
print '<tr><td class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
print "</table></div><br>"; print "</table></div><br>";
$db->free($result); $db->free($result);
} }

View File

@ -43,6 +43,8 @@ $action = GETPOST('action', 'alpha');
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
$type = GETPOST('type', 'aZ09');
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha');
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'alpha');

View File

@ -47,6 +47,8 @@ $socid = GETPOST('socid', 'int');
if ($user->socid) $socid=$user->socid; if ($user->socid) $socid=$user->socid;
$result = restrictedArea($user, 'prelevement', '', '', 'bons'); $result = restrictedArea($user, 'prelevement', '', '', 'bons');
$type = GETPOST('type', 'aZ09');
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha'); $sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha');

View File

@ -38,6 +38,8 @@ $socid = GETPOST('socid', 'int');
if ($user->socid) $socid = $user->socid; if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'prelevement', '', '', 'bons'); $result = restrictedArea($user, 'prelevement', '', '', 'bons');
$type = GETPOST('type', 'aZ09');
// Get supervariables // Get supervariables
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortorder = GETPOST('sortorder', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha');
@ -47,6 +49,8 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
/* /*
* View * View
*/ */

View File

@ -36,6 +36,8 @@ $socid = GETPOST('socid', 'int');
if ($user->socid) $socid = $user->socid; if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'prelevement', '', '', 'bons'); $result = restrictedArea($user, 'prelevement', '', '', 'bons');
$type = GETPOST('type', 'aZ09');
/* /*
* View * View

View File

@ -1496,8 +1496,6 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
$newmenu->add("/compta/prelevement/list.php?mainmenu=bank", $langs->trans("WithdrawalsLines"), 1, $user->rights->prelevement->bons->lire); $newmenu->add("/compta/prelevement/list.php?mainmenu=bank", $langs->trans("WithdrawalsLines"), 1, $user->rights->prelevement->bons->lire);
$newmenu->add("/compta/prelevement/rejets.php?mainmenu=bank", $langs->trans("Rejects"), 1, $user->rights->prelevement->bons->lire); $newmenu->add("/compta/prelevement/rejets.php?mainmenu=bank", $langs->trans("Rejects"), 1, $user->rights->prelevement->bons->lire);
$newmenu->add("/compta/prelevement/stats.php?mainmenu=bank", $langs->trans("Statistics"), 1, $user->rights->prelevement->bons->lire); $newmenu->add("/compta/prelevement/stats.php?mainmenu=bank", $langs->trans("Statistics"), 1, $user->rights->prelevement->bons->lire);
//$newmenu->add("/compta/prelevement/config.php",$langs->trans("Setup"),1,$user->rights->prelevement->bons->configurer);
} }
} }
@ -1507,12 +1505,12 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
$newmenu->add("/compta/paymentbybanktransfer/index.php?leftmenu=banktransfer&amp;mainmenu=bank", $langs->trans("PaymentByBankTransfer"), 0, $user->rights->paymentbybanktransfer->read, '', $mainmenu, 'banktransfer'); $newmenu->add("/compta/paymentbybanktransfer/index.php?leftmenu=banktransfer&amp;mainmenu=bank", $langs->trans("PaymentByBankTransfer"), 0, $user->rights->paymentbybanktransfer->read, '', $mainmenu, 'banktransfer');
if ($usemenuhider || empty($leftmenu) || $leftmenu == "banktransfer") { if ($usemenuhider || empty($leftmenu) || $leftmenu == "banktransfer") {
$newmenu->add("/compta/paymentbybanktransfer/create.php?mainmenu=bank", $langs->trans("NewPaymentByBankTransfer"), 1, $user->rights->paymentbybanktransfer->create); $newmenu->add("/compta/prelevement/create.php?type=bank-transfer&mainmenu=bank", $langs->trans("NewPaymentByBankTransfer"), 1, $user->rights->paymentbybanktransfer->create);
$newmenu->add("/compta/paymentbybanktransfer/bons.php?mainmenu=bank", $langs->trans("PaymentByBankTransferReceipts"), 1, $user->rights->paymentbybanktransfer->read); $newmenu->add("/compta/prelevement/bons.php?type=bank-transfer&mainmenu=bank", $langs->trans("PaymentByBankTransferReceipts"), 1, $user->rights->paymentbybanktransfer->read);
$newmenu->add("/compta/paymentbybanktransfer/list.php?mainmenu=bank", $langs->trans("PaymentByBankTransferLines"), 1, $user->rights->paymentbybanktransfer->read); $newmenu->add("/compta/prelevement/list.php?type=bank-transfer&mainmenu=bank", $langs->trans("PaymentByBankTransferLines"), 1, $user->rights->paymentbybanktransfer->read);
$newmenu->add("/compta/paymentbybanktransfer/rejets.php?mainmenu=bank", $langs->trans("Rejects"), 1, $user->rights->paymentbybanktransfer->read); $newmenu->add("/compta/prelevement/rejets.php?type=bank-transfer&mainmenu=bank", $langs->trans("Rejects"), 1, $user->rights->paymentbybanktransfer->read);
$newmenu->add("/compta/paymentbybanktransfer/stats.php?mainmenu=bank", $langs->trans("Statistics"), 1, $user->rights->paymentbybanktransfer->read); $newmenu->add("/compta/prelevement/stats.php?type=bank-transfer&mainmenu=bank", $langs->trans("Statistics"), 1, $user->rights->paymentbybanktransfer->read);
} }
} }

View File

@ -72,6 +72,9 @@ delete from llx_const where name = 'PROJECT_HIDE_TASKS' and entity = 0;
-- For v12 -- For v12
ALTER TABLE llx_prelevement_bons ADD COLUMN type varchar(16) DEFAULT 'debit-order';
-- Delete an old index that is duplicated -- Delete an old index that is duplicated
-- VMYSQL4.1 DROP INDEX ix_fk_product_stock on llx_product_batch; -- VMYSQL4.1 DROP INDEX ix_fk_product_stock on llx_product_batch;
-- VPGSQL8.2 DROP INDEX ix_fk_product_stock -- VPGSQL8.2 DROP INDEX ix_fk_product_stock

View File

@ -26,6 +26,7 @@
create table llx_prelevement_bons create table llx_prelevement_bons
( (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
type varchar(16) DEFAULT 'debit-order', -- 'debit-order' or 'bank-transfer'
ref varchar(12), -- reference ref varchar(12), -- reference
entity integer DEFAULT 1 NOT NULL, -- multi company id entity integer DEFAULT 1 NOT NULL, -- multi company id
datec datetime, -- date de creation datec datetime, -- date de creation

View File

@ -16,8 +16,9 @@ WithdrawalsLines=Direct debit order lines
RequestStandingOrderToTreat=Request for direct debit payment order to process RequestStandingOrderToTreat=Request for direct debit payment order to process
RequestStandingOrderTreated=Request for direct debit payment order processed RequestStandingOrderTreated=Request for direct debit payment order processed
NotPossibleForThisStatusOfWithdrawReceiptORLine=Not yet possible. Withdraw status must be set to 'credited' before declaring reject on specific lines. NotPossibleForThisStatusOfWithdrawReceiptORLine=Not yet possible. Withdraw status must be set to 'credited' before declaring reject on specific lines.
NbOfInvoiceToWithdraw=No. of qualified invoice with waiting direct debit order NbOfInvoiceToWithdraw=No. of qualified customer invoices with waiting direct debit order
NbOfInvoiceToWithdrawWithInfo=No. of customer invoice with direct debit payment orders having defined bank account information NbOfInvoiceToWithdrawWithInfo=No. of customer invoice with direct debit payment orders having defined bank account information
NbOfInvoiceToPayByBankTransfer=No. of qualified supplier invoices waiting for a payment by bank transfer
SupplierInvoiceWaitingWithdraw=Vendor invoice waiting for payment by bank transfer SupplierInvoiceWaitingWithdraw=Vendor invoice waiting for payment by bank transfer
InvoiceWaitingWithdraw=Invoice waiting for direct debit InvoiceWaitingWithdraw=Invoice waiting for direct debit
AmountToWithdraw=Amount to withdraw AmountToWithdraw=Amount to withdraw