Fixed: Maxi debug of withdrawal module.

This commit is contained in:
Laurent Destailleur 2014-12-09 11:19:16 +01:00
parent cf641194a1
commit 63f2bfed24
13 changed files with 124 additions and 67 deletions

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
*
@ -153,7 +153,7 @@ print $form->select_comptes($conf->global->PRELEVEMENT_ID_BANKACCOUNT,'PRELEVEME
print '</td></tr>';
// ICS
print '<tr class="impair"><td>'.$langs->trans("ICS").'</td>';
print '<tr class="pair"><td>'.$langs->trans("ICS").'</td>';
print '<td align="left">';
print '<input type="text" name="PRELEVEMENT_ICS" value="'.$conf->global->PRELEVEMENT_ICS.'" size="9" ></td>';
print '</td></tr>';

View File

@ -2837,6 +2837,8 @@ class Facture extends CommonInvoice
*/
function demande_prelevement($user)
{
$error=0;
dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG);
if ($this->statut > 0 && $this->paye == 0)
@ -2882,21 +2884,32 @@ class Facture extends CommonInvoice
$sql .= ",'".$bac->cle_rib."')";
dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG);
if ($this->db->query($sql))
$resql=$this->db->query($sql);
if (! $resql)
{
return 1;
}
else
{
$this->error=$this->db->lasterror();
dol_syslog(get_class($this).'::demandeprelevement Erreur');
return -1;
$error++;
}
if (! $error)
{
// Force payment mode of invoice to withdraw
$payment_mode_id = dol_getIdFromCode($this->db, 'PRE', 'c_paiement');
if ($payment_mode_id > 0)
{
$result=$this->setPaymentMethods($payment_mode_id);
}
}
if ($error) return -1;
return 1;
}
else
{
$this->error="A request already exists";
dol_syslog(get_class($this).'::demandeprelevement Impossible de creer une demande, demande deja en cours');
return 0;
}
}
else

View File

@ -58,6 +58,7 @@ if ($id > 0 || ! empty($ref))
}
}
/*
* Actions
*/
@ -69,14 +70,14 @@ if ($action == "new")
$result = $object->demande_prelevement($user);
if ($result > 0)
{
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
setEventMessage($langs->trans("RecordSaved"));
}
else
{
setEventMessage($object->error, 'errors');
}
}
$action='';
}
if ($action == "delete")
@ -307,6 +308,31 @@ if ($object->id > 0)
print '</td>';
print '</tr>';
// Conditions de reglement
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentConditionsShort');
print '</td>';
if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && ! empty($object->brouillon) && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;id='.$object->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($object->type != Facture::TYPE_CREDIT_NOTE)
{
if ($action == 'editconditions')
{
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'cond_reglement_id');
}
else
{
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'none');
}
}
else
{
print '&nbsp;';
}
print '</td></tr>';
// Date payment term
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
@ -333,32 +359,7 @@ if ($object->id > 0)
}
print '</td></tr>';
// Conditions de reglement
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentConditionsShort');
print '</td>';
if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && ! empty($object->brouillon) && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;id='.$object->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($object->type != Facture::TYPE_CREDIT_NOTE)
{
if ($action == 'editconditions')
{
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'cond_reglement_id');
}
else
{
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'none');
}
}
else
{
print '&nbsp;';
}
print '</td></tr>';
// Mode de reglement
// Payment mode
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentMode');
@ -376,6 +377,26 @@ if ($object->id > 0)
}
print '</td></tr>';
// Bank Account
print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans('BankAccount');
print '<td>';
if (($action != 'editbankaccount') && $user->rights->commande->creer && ! empty($object->brouillon))
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editbankaccount')
{
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
}
else
{
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
}
print "</td>";
print '</tr>';
// Montants
print '<tr><td>'.$langs->trans('AmountHT').'</td>';
print '<td align="right" colspan="2" nowrap>'.price($object->total_ht).'</td>';

View File

@ -56,7 +56,9 @@ class BonPrelevement extends CommonObject
var $statut; // 0-Wait, 1-Trans, 2-Done
var $labelstatut=array();
var $invoice_in_error=array();
/**
* Constructor
*
@ -835,7 +837,7 @@ class BonPrelevement extends CommonObject
else
{
dol_syslog("Error on default bank number RIB/IBAN for thirdparty reported by verif() ".$fact->socid." ".$soc->name, LOG_ERR);
$facture_errors[$fac[0]]="Error on default bank number RIB/IBAN for thirdparty reported by function verif() ".$fact->socid." ".$soc->name;
$this->invoice_in_error[$fac[0]]="Error on default bank number RIB/IBAN for invoice ".$fact->getNomUrl(0)." for thirdparty (reported by function verif) ".$soc->name;
}
}
else
@ -1814,21 +1816,21 @@ class BonPrelevement extends CommonObject
if ($mode == 1)
{
if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut0').' '.$langs->trans($this->labelstatut[$statut]);
if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1').' '.$langs->trans($this->labelstatut[$statut]);
if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1').' '.$langs->trans($this->labelstatut[$statut]);
if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut3').' '.$langs->trans($this->labelstatut[$statut]);
if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut6').' '.$langs->trans($this->labelstatut[$statut]);
}
if ($mode == 2)
{
if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut0');
if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1');
if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1');
if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut3');
if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut6');
}
if ($mode == 3)
{
if ($statut==0) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut0');
if ($statut==1) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut1');
if ($statut==0) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut1');
if ($statut==1) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut3');
if ($statut==2) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut6');
}
}

View File

@ -138,20 +138,20 @@ class LignePrelevement
if ($mode == 1)
{
if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]);
if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut1').' '.$langs->trans($this->statuts[$statut]);
if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]);
if ($statut==3) return img_picto($langs->trans($this->statuts[$statut]),'statut8').' '.$langs->trans($this->statuts[$statut]);
}
if ($mode == 2)
{
if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut0');
if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut1');
if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut4');
if ($statut==3) return img_picto($langs->trans($this->statuts[$statut]),'statut8');
}
if ($mode == 3)
{
if ($statut==0) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut0');
if ($statut==0) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut1');
if ($statut==2) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut4');
if ($statut==3) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut8');
}

View File

@ -70,6 +70,10 @@ if ($action == 'create')
if ($result == 0)
{
$mesg='<div class="error">'.$langs->trans("NoInvoiceCouldBeWithdrawed").'</div>';
foreach($bprev->invoice_in_error as $key => $val)
{
$mesg.=$val."<br>\n";
}
}
}
@ -179,6 +183,7 @@ if ($resql)
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Invoice").'</td>';
print '<td>'.$langs->trans("ThirdParty").'</td>';
print '<td>'.$langs->trans("RIB").'</td>';
print '<td align="right">'.$langs->trans("AmountTTC").'</td>';
print '<td align="right">'.$langs->trans("DateRequest").'</td>';
print '</tr>';
@ -190,16 +195,22 @@ if ($resql)
{
$obj = $db->fetch_object($resql);
$var=!$var;
print '<tr '.$bc[$var].'><td>';
print '<tr '.$bc[$var].'>';
print '<td>';
$invoicestatic->id=$obj->rowid;
$invoicestatic->ref=$obj->facnumber;
print $invoicestatic->getNomUrl(1,'withdraw');
print '</td>';
// Thirdparty
print '<td>';
$thirdpartystatic->id=$obj->socid;
$thirdpartystatic->name=$obj->name;
print $thirdpartystatic->getNomUrl(1,'customer');
$thirdpartystatic->fetch($obj->socid);
print $thirdpartystatic->getNomUrl(1,'card');
print '</td>';
// RIB
print '<td>';
print $thirdpartystatic->display_rib();
print '</td>';
// Amount
print '<td align="right">';
print price($obj->total_ttc,0,$langs,0,0,-1,$conf->currency);
print '</td>';
@ -211,7 +222,7 @@ if ($resql)
$i++;
}
}
else print '<tr><td colspan="4">'.$langs->trans("None").'</td></tr>';
else print '<tr '.$bc[0].'><td colspan="5">'.$langs->trans("None").'</td></tr>';
print "</table>";
print "<br>\n";
}

View File

@ -106,7 +106,6 @@ if ($prev_id)
/*
* Stats
*
*/
$ligne=new LignePrelevement($db,$user);
@ -121,6 +120,8 @@ if ($prev_id)
$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">';

View File

@ -134,7 +134,7 @@ if ($id)
print '<table class="border" width="100%">';
print '<tr><td width="20%">'.$langs->trans("WithdrawalsReceipts").'</td><td>';
print '<a href="card.php?id='.$lipre->bon_rowid.'">'.$lipre->bon_ref.'</a></td></tr>';
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>';

View File

@ -124,8 +124,6 @@ $pagenext = $page + 1;
/*
* Liste des lignes de prelevement
*
*
*/
$sql = "SELECT pl.rowid, pl.statut, pl.amount";
$sql.= ", s.rowid as socid, s.nom as name";
@ -175,7 +173,11 @@ if ($result)
print substr('000000'.$obj->rowid, -6);
print '</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->name."</a></td>\n";
$thirdparty=new Societe($db);
$thirdparty->fetch($obj->socid);
print '<td>';
print $thirdparty->getNomUrl(1);
print "</td>\n";
print '<td align="center">'.price($obj->amount)."</td>\n";

View File

@ -21,7 +21,7 @@
/**
* \file htdocs/compta/prelevement/stats.php
* \ingroup prelevement
* \brief Page de stats des prelevements
* \brief Page with statistics on withdrawals
*/
require('../../main.inc.php');
@ -96,7 +96,7 @@ if ($resql)
print '<td width="30%">'.$langs->trans("Status").'</td><td align="center">'.$langs->trans("Number").'</td><td align="right">%</td>';
print '<td align="right">'.$langs->trans("Amount").'</td><td align="right">%</td></tr>';
$var=True;
$var=false;
while ($i < $num)
{

View File

@ -444,7 +444,7 @@ Module55Desc=Barcode management
Module56Name=Telephony
Module56Desc=Telephony integration
Module57Name=Standing orders
Module57Desc=Standing orders and withdrawal management
Module57Desc=Standing orders and withdrawal management. Also includes generation of SEPA file for european countries.
Module58Name=ClickToDial
Module58Desc=Integration of a ClickToDial system (Asterisk, ...)
Module59Name=Bookmark4u

View File

@ -79,10 +79,11 @@ CreditDate=Credit on
WithdrawalFileNotCapable=Unable to generate withdrawal receipt file for your country %s (Your country is not supported)
ShowWithdraw=Show Withdraw
IfInvoiceNeedOnWithdrawPaymentWontBeClosed=However, if invoice has at least one withdrawal payment not yet processed, it won't be set as paid to allow prior withdrawal management.
DoStandingOrdersBeforePayments=This tab allows you to request a standing order. Once it is complete, you can type the payment to close the invoice.
DoStandingOrdersBeforePayments=This tab allows you to request a standing order. Once donee, go into menu Bank->Withdrawal to manage the standing order. When standing order is closed, payment on invoice will be automatically recorded, and invoice closed if remainder to pay is null.
WithdrawalFile=Withdrawal file
SetToStatusSent=Set to status "File Sent"
ThisWillAlsoAddPaymentOnInvoice=This will also apply payments to invoices and will classify them as "Paid"
StatisticsByLineStatus=Statistics by status of lines
### Notifications
InfoCreditSubject=Payment of standing order %s by the bank

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Peter Fontaine <contact@peterfontaine.fr>
*
@ -185,6 +185,7 @@ if ($action == 'confirm_delete' && $_GET['confirm'] == 'yes')
}
}
/*
* View
*/
@ -317,8 +318,13 @@ if ($socid && $action != 'edit' && $action != "create")
print '<div class="warning">'.$langs->trans("RIBControlError").'</div>';
}
print "<br />";
print "<br>";
/*
* List of bank accounts
*/
print_titre($langs->trans("AllRIB"));
$rib_list = $soc->get_all_rib();
@ -339,7 +345,7 @@ if ($socid && $action != 'edit' && $action != "create")
foreach ($rib_list as $rib)
{
print "<tr $bc[$var]>";
print "<tr ".$bc[$var].">";
// Label
print '<td>'.$rib->label.'</td>';
// Bank name
@ -382,7 +388,7 @@ if ($socid && $action != 'edit' && $action != "create")
}
if (count($rib_list) == 0) {
print '<tr><td colspan="5" align="center">'.$langs->trans("NoBANRecord").'</td></tr>';
print '<tr '.$bc[0].'><td colspan="7" align="center">'.$langs->trans("NoBANRecord").'</td></tr>';
}
print '</table>';
@ -458,7 +464,7 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer)
if ($val == 'AccountNumber')
{
print '<td>'.$langs->trans("BankAccountNumber").'</td>';
print '<td class="fieldrequired">'.$langs->trans("BankAccountNumber").'</td>';
print '<td><input size="18" type="text" class="flat" name="number" value="'.$account->number.'"></td>';
print '</tr>';
}
@ -475,10 +481,10 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer)
}
// IBAN
print '<tr><td valign="top">'.$langs->trans("IBAN").'</td>';
print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("IBAN").'</td>';
print '<td colspan="4"><input size="30" type="text" name="iban" value="'.$account->iban.'"></td></tr>';
print '<tr><td valign="top">'.$langs->trans("BIC").'</td>';
print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("BIC").'</td>';
print '<td colspan="4"><input size="12" type="text" name="bic" value="'.$account->bic.'"></td></tr>';
print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="4">';