Debug of module withdraw.

This commit is contained in:
Laurent Destailleur 2014-11-05 17:32:42 +01:00
parent 5e0946bdc2
commit 60ca5aa026
7 changed files with 38 additions and 133 deletions

View File

@ -1,103 +0,0 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/prelevement/bon.php
* \ingroup prelevement
* \brief Fiche apercu du bon de prelevement
*/
require('../../main.inc.php');
require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$langs->load("banks");
$langs->load("categories");
$langs->load("bills");
$langs->load("categories");
// Security check
$socid=0;
$id = GETPOST('id','int');
$ref = GETPOST('ref','alpha');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'prelevement', $id);
llxHeader('','Bon de prelevement');
$form = new Form($db);
if ($id > 0 || ! empty($ref))
{
$object = new BonPrelevement($db,"");
if ($object->fetch($id) == 0)
{
$head = prelevement_prepare_head($object);
dol_fiche_head($head, 'preview', 'Prelevement : '. $object->ref);
print '<table class="border" width="100%">';
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td>'.$object->ref.'</td></tr>';
print '<tr><td width="20%">'.$langs->trans("Amount").'</td><td>'.price($object->amount).'</td></tr>';
print '<tr><td width="20%">'.$langs->trans("File").'</td><td>';
$relativepath = 'bon/'.$object->ref;
print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$object->ref.'</a>';
print '</td></tr>';
print '</table><br>';
$fileimage = $conf->prelevement->dir_output.'/receipts/'.$object->ref.'.ps.png.0';
$fileps = $conf->prelevement->dir_output.'/receipts/'.$object->ref.'.ps';
// Conversion du PDF en image png si fichier png non existant
if (!file_exists($fileimage))
{
if (class_exists("Imagick"))
{
$ret = dol_convert_file($file,'png',$fileimage);
if ($ret < 0) $error++;
}
else
{
$langs->load("errors");
print '<font class="error">'.$langs->trans("ErrorNoImagickReadimage").'</font>';
}
}
if (file_exists($fileimage))
{
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=prelevement&file='.urlencode(basename($fileimage)).'">';
}
dol_fiche_end();
}
else
{
dol_print_error($db);
}
}
llxFooter();

View File

@ -821,7 +821,9 @@ class BonPrelevement extends CommonObject
{ {
$bac = new CompanyBankAccount($this->db); $bac = new CompanyBankAccount($this->db);
$bac->fetch(0,$soc->id); $bac->fetch(0,$soc->id);
if ($bac->verif() >= 1) if ($bac->verif() >= 1)
//if (true)
{ {
$factures_prev[$i] = $fac; $factures_prev[$i] = $fac;
/* second tableau necessaire pour BonPrelevement */ /* second tableau necessaire pour BonPrelevement */
@ -1226,26 +1228,24 @@ class BonPrelevement extends CommonObject
* @return int 0 if OK, <0 if KO * @return int 0 if OK, <0 if KO
*/ */
//TODO: Optimize code to read lines in a single function //TODO: Optimize code to read lines in a single function
function Generate() function generate()
{ {
global $conf,$langs,$mysoc; global $conf,$langs,$mysoc;
$result = 0; $result = 0;
dol_syslog(get_class($this)."::Generate build file ".$this->filename); dol_syslog(get_class($this)."::generate build file ".$this->filename);
$this->file = fopen($this->filename,"w"); $this->file = fopen($this->filename,"w");
$found=0; $found=0;
// Build file for European countries // Build file for European countries
if (! $mysoc->isInEEC()) if ($mysoc->isInEEC())
{ {
$found++; $found++;
/** /**
* SECTION CREATION FICHIER SEPA
* SECTION CREATION FICHIER SEPA
* SECTION CREATION FICHIER SEPA * SECTION CREATION FICHIER SEPA
*/ */
// SEPA Initialisation // SEPA Initialisation
@ -1308,8 +1308,6 @@ class BonPrelevement extends CommonObject
} }
/** /**
* SECTION CREATION FICHIER SEPA
* SECTION CREATION FICHIER SEPA
* SECTION CREATION FICHIER SEPA * SECTION CREATION FICHIER SEPA
*/ */
// SEPA File Header // SEPA File Header
@ -1404,8 +1402,11 @@ class BonPrelevement extends CommonObject
{ {
$result = -2; $result = -2;
} }
$langs->load('withdrawals'); $langs->load('withdrawals');
fputs($this->file, $langs->trans('WithdrawalFileNotCapable'));
// TODO Add here code to generate a generic file
fputs($this->file, $langs->trans('WithdrawalFileNotCapable', $mysoc->country_code));
} }
fclose($this->file); fclose($this->file);

View File

@ -173,7 +173,8 @@ class RejetPrelevement
} }
//Tag invoice as unpaid //Tag invoice as unpaid
dol_syslog("RejetPrelevement::Create set_unpaid fac ".$fac->ref); dol_syslog("RejetPrelevement::Create set_unpaid fac ".$fac->ref);
$fac->set_unpaid($fac->id, $user);
$fac->set_unpaid($user);
//TODO: Must be managed by notifications module //TODO: Must be managed by notifications module
// Send email to sender of the standing order request // Send email to sender of the standing order request
@ -194,7 +195,7 @@ class RejetPrelevement
} }
/** /**
* Envoi mail * Send email to all users that has asked the withdraw request
* *
* @param Facture $fac Invoice object * @param Facture $fac Invoice object
* @return void * @return void

View File

@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$langs->load("banks"); $langs->load("banks");
$langs->load("categories"); $langs->load("categories");
$langs->load("widthdrawals"); $langs->load("withdrawals");
$langs->load("companies"); $langs->load("companies");
// Security check // Security check

View File

@ -105,10 +105,13 @@ if ($action == 'confirm_rejet')
} }
} }
/* /*
* View * View
*/ */
$invoicestatic=new Facture($db);
llxHeader('',$langs->trans("StandingOrder")); llxHeader('',$langs->trans("StandingOrder"));
$h = 0; $h = 0;
@ -134,9 +137,7 @@ if ($id)
print '<a href="card.php?id='.$lipre->bon_rowid.'">'.$lipre->bon_ref.'</a></td></tr>'; print '<a href="card.php?id='.$lipre->bon_rowid.'">'.$lipre->bon_ref.'</a></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("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("Amount").'</td><td>'.price($lipre->amount).'</td></tr>';
print '<tr><td width="20%">'.$langs->trans("Status").'</td><td>'; print '<tr><td width="20%">'.$langs->trans("Status").'</td><td>'.$lipre->LibStatut($lipre->statut,1).'</td></tr>';
print $lipre->LibStatut($lipre->statut,1).'</td></tr>';
if ($lipre->statut == 3) if ($lipre->statut == 3)
{ {
@ -215,7 +216,7 @@ if ($id)
print '</table><br>'; print '</table><br>';
//Confirm Button //Confirm Button
print '<center><input type="submit" class="valid" value='.$langs->trans("Confirm").'><center>'; print '<center><input type="submit" class="button" value='.$langs->trans("Confirm").'><center>';
print '</form>'; print '</form>';
} }
@ -229,13 +230,20 @@ if ($id)
if ($action == '') if ($action == '')
{ {
if ($bon->statut == 2 && $lipre->statut == 2 && $user->rights->prelevement->bons->credit) if ($bon->statut == 2 && $lipre->statut == 2)
{
if ($user->rights->prelevement->bons->credit)
{ {
print "<a class=\"butAction\" href=\"ligne.php?action=rejet&amp;id=$lipre->id\">".$langs->trans("StandingOrderReject")."</a>"; print "<a class=\"butAction\" href=\"ligne.php?action=rejet&amp;id=$lipre->id\">".$langs->trans("StandingOrderReject")."</a>";
} }
else else
{ {
print "<a class=\"butActionRefused\" href=\"#\">".$langs->trans("StandingOrderReject")."</a>"; print "<a class=\"butActionRefused\" href=\"#\" title=\"".$langs->trans("NotAllowed")."\">".$langs->trans("StandingOrderReject")."</a>";
}
}
else
{
print "<a class=\"butActionRefused\" href=\"#\" title=\"".$langs->trans("NotPossibleForThisStatusOfWithdrawReceiptORLine")."\">".$langs->trans("StandingOrderReject")."</a>";
} }
} }
@ -256,7 +264,7 @@ if ($id)
* Liste des factures * Liste des factures
*/ */
$sql = "SELECT pf.rowid"; $sql = "SELECT pf.rowid";
$sql.= " ,f.rowid as facid, f.facnumber as ref, f.total_ttc"; $sql.= " ,f.rowid as facid, f.facnumber as ref, f.total_ttc, f.paye, f.fk_statut";
$sql.= " , s.rowid as socid, s.nom as name"; $sql.= " , s.rowid as socid, s.nom as name";
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql.= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl"; $sql.= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
@ -287,7 +295,7 @@ if ($id)
print"\n<!-- debut table -->\n"; print"\n<!-- debut table -->\n";
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">'; print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Invoice").'</td><td>'.$langs->trans("ThirdParty").'</td><td align="right">'.$langs->trans("Amount").'</td>'; print '<td>'.$langs->trans("Invoice").'</td><td>'.$langs->trans("ThirdParty").'</td><td align="right">'.$langs->trans("Amount").'</td><td align="right">'.$langs->trans("Status").'</td>';
print '</tr>'; print '</tr>';
$var=True; $var=True;
@ -312,6 +320,11 @@ if ($id)
print '<td align="right">'.price($obj->total_ttc)."</td>\n"; print '<td align="right">'.price($obj->total_ttc)."</td>\n";
print '<td align="right">';
$invoicestatic->fetch($obj->facid);
print $invoicestatic->getLibStatut(5);
print "</td>\n";
print "</tr>\n"; print "</tr>\n";
$i++; $i++;

View File

@ -44,14 +44,6 @@ function prelevement_prepare_head($object)
$head[$h][2] = 'prelevement'; $head[$h][2] = 'prelevement';
$h++; $h++;
if (! empty($conf->global->MAIN_USE_PREVIEW_TABS))
{
$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/bon.php?id='.$object->id;
$head[$h][1] = $langs->trans("Preview");
$head[$h][2] = 'preview';
$h++;
}
$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/lignes.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/lignes.php?id='.$object->id;
$head[$h][1] = $langs->trans("Lines"); $head[$h][1] = $langs->trans("Lines");
$head[$h][2] = 'lines'; $head[$h][2] = 'lines';

View File

@ -16,6 +16,7 @@ WithdrawedBills=Withdrawn invoices
WithdrawalsLines=Withdrawal lines WithdrawalsLines=Withdrawal lines
RequestStandingOrderToTreat=Request for standing orders to process RequestStandingOrderToTreat=Request for standing orders to process
RequestStandingOrderTreated=Request for standing orders processed RequestStandingOrderTreated=Request for standing orders processed
NotPossibleForThisStatusOfWithdrawReceiptORLine=Not yet possible. Withdraw status must be set to 'credited' before declaring reject on specific lines.
CustomersStandingOrders=Customer standing orders CustomersStandingOrders=Customer standing orders
CustomerStandingOrder=Customer standing order CustomerStandingOrder=Customer standing order
NbOfInvoiceToWithdraw=Nb. of invoice with withdraw request NbOfInvoiceToWithdraw=Nb. of invoice with withdraw request
@ -76,7 +77,7 @@ WithBankUsingRIB=For bank accounts using RIB
WithBankUsingBANBIC=For bank accounts using IBAN/BIC/SWIFT WithBankUsingBANBIC=For bank accounts using IBAN/BIC/SWIFT
BankToReceiveWithdraw=Bank account to receive withdraws BankToReceiveWithdraw=Bank account to receive withdraws
CreditDate=Credit on CreditDate=Credit on
WithdrawalFileNotCapable=Unable to generate withdrawal receipt file for your country WithdrawalFileNotCapable=Unable to generate withdrawal receipt file for your country %s (Your country is not supported)
ShowWithdraw=Show Withdraw 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. 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 it is complete, you can type the payment to close the invoice.