Merge remote-tracking branch 'Upstream/develop' into develop-37

This commit is contained in:
aspangaro 2015-06-21 21:09:55 +02:00
commit e0ae7bd430
23 changed files with 397 additions and 394 deletions

View File

@ -3061,11 +3061,14 @@ class Facture extends CommonInvoice
/** /**
* Create a withdrawal request for a standing order * Create a withdrawal request for a standing order
* *
* @param User $user User asking standing order * @param User $fuser User asking standing order
* @param float $amount Amount we request withdraw for
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function demande_prelevement($user) function demande_prelevement($fuser, $amount=0)
{ {
global $langs;
$error=0; $error=0;
dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG);
@ -3099,27 +3102,36 @@ class Facture extends CommonInvoice
// For example print 239.2 - 229.3 - 9.9; does not return 0. // For example print 239.2 - 229.3 - 9.9; does not return 0.
//$resteapayer=bcadd($this->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT); //$resteapayer=bcadd($this->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT);
//$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); //$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT);
$resteapayer = price2num($this->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits,'MT'); if (empty($amount)) $amount = price2num($this->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits,'MT');
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'prelevement_facture_demande'; if (is_numeric($amount) && $amount != 0)
$sql .= ' (fk_facture, amount, date_demande, fk_user_demande, code_banque, code_guichet, number, cle_rib)'; {
$sql .= ' VALUES ('.$this->id; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'prelevement_facture_demande';
$sql .= ",'".price2num($resteapayer)."'"; $sql .= ' (fk_facture, amount, date_demande, fk_user_demande, code_banque, code_guichet, number, cle_rib)';
$sql .= ",'".$this->db->idate($now)."'"; $sql .= ' VALUES ('.$this->id;
$sql .= ",".$user->id; $sql .= ",'".price2num($amount)."'";
$sql .= ",'".$bac->code_banque."'"; $sql .= ",'".$this->db->idate($now)."'";
$sql .= ",'".$bac->code_guichet."'"; $sql .= ",".$fuser->id;
$sql .= ",'".$bac->number."'"; $sql .= ",'".$bac->code_banque."'";
$sql .= ",'".$bac->cle_rib."')"; $sql .= ",'".$bac->code_guichet."'";
$sql .= ",'".$bac->number."'";
$sql .= ",'".$bac->cle_rib."')";
dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if (! $resql) if (! $resql)
{ {
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
dol_syslog(get_class($this).'::demandeprelevement Erreur'); dol_syslog(get_class($this).'::demandeprelevement Erreur');
$error++; $error++;
} }
}
else
{
$this->error='WithdrawRequestErrorNilAmount';
dol_syslog(get_class($this).'::demandeprelevement WithdrawRequestErrorNilAmount');
$error++;
}
if (! $error) if (! $error)
{ {
@ -3159,11 +3171,11 @@ class Facture extends CommonInvoice
/** /**
* Supprime une demande de prelevement * Supprime une demande de prelevement
* *
* @param User $user utilisateur creant la demande * @param User $fuser User making delete
* @param int $did id de la demande a supprimer * @param int $did id de la demande a supprimer
* @return int <0 if OK, >0 if KO * @return int <0 if OK, >0 if KO
*/ */
function demande_prelevement_delete($user, $did) function demande_prelevement_delete($fuser, $did)
{ {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande';
$sql .= ' WHERE rowid = '.$did; $sql .= ' WHERE rowid = '.$did;
@ -3184,8 +3196,8 @@ class Facture extends CommonInvoice
/** /**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate) * Load indicators for dashboard (this->nbtodo and this->nbtodolate)
* *
* @param User $user Object user * @param User $user Object user
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
*/ */
function load_board($user) function load_board($user)
{ {

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
* *
@ -68,14 +68,19 @@ if ($action == "new")
{ {
if ($object->id > 0) if ($object->id > 0)
{ {
$result = $object->demande_prelevement($user); $db->begin();
$result = $object->demande_prelevement($user, GETPOST('withdraw_request_amount'));
if ($result > 0) if ($result > 0)
{ {
$db->commit();
setEventMessage($langs->trans("RecordSaved")); setEventMessage($langs->trans("RecordSaved"));
} }
else else
{ {
setEventMessage($object->error, 'errors'); $db->rollback();
setEventMessage($object->error, $object->errors, 'errors');
} }
} }
$action=''; $action='';
@ -309,7 +314,7 @@ if ($object->id > 0)
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Conditions de reglement // Payment condition
print '<tr><td>'; print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentConditionsShort'); print $langs->trans('PaymentConditionsShort');
@ -370,11 +375,11 @@ if ($object->id > 0)
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($action == 'editmode') if ($action == 'editmode')
{ {
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'mode_reglement_id'); $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id');
} }
else else
{ {
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'none'); $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none');
} }
print '</td></tr>'; print '</td></tr>';
@ -478,7 +483,13 @@ if ($object->id > 0)
{ {
if ($user->rights->prelevement->bons->creer) if ($user->rights->prelevement->bons->creer)
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=new">'.$langs->trans("MakeWithdrawRequest").'</a>'; print '<form method="POST" action="">';
print '<input type="hidden" name="id" value="' . $object->id . '" />';
print '<input type="hidden" name="action" value="new" />';
print '<label for="withdraw_request_amount">' . $langs->trans('WithdrawRequestAmount') . ' </label>';
print '<input type="text" id="withdraw_request_amount" name="withdraw_request_amount" value="' . $resteapayer . '" size="10" />';
print '<input type="submit" class="butAction" value="'.$langs->trans("MakeWithdrawRequest").'" />';
print '</form>';
} }
else else
{ {
@ -508,10 +519,12 @@ if ($object->id > 0)
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td align="left">'.$langs->trans("DateRequest").'</td>'; print '<td align="left">'.$langs->trans("DateRequest").'</td>';
print '<td align="center">'.$langs->trans("DateProcess").'</td>'; print '<td align="center">'.$langs->trans("User").'</td>';
print '<td align="center">'.$langs->trans("Amount").'</td>'; print '<td align="center">'.$langs->trans("Amount").'</td>';
print '<td align="center">'.$langs->trans("WithdrawalReceipt").'</td>'; print '<td align="center">'.$langs->trans("WithdrawalReceipt").'</td>';
print '<td align="center">'.$langs->trans("User").'</td><td>&nbsp;</td><td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '<td align="center">'.$langs->trans("DateProcess").'</td>';
print '<td>&nbsp;</td>';
print '</tr>'; print '</tr>';
$var=true; $var=true;
@ -526,15 +539,18 @@ if ($object->id > 0)
print "<tr ".$bc[$var].">"; print "<tr ".$bc[$var].">";
print '<td align="left">'.dol_print_date($db->jdate($obj->date_demande),'day')."</td>\n"; print '<td align="left">'.dol_print_date($db->jdate($obj->date_demande),'day')."</td>\n";
print '<td align="center">'.$langs->trans("OrderWaiting").'</td>'; 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">'.price($obj->amount).'</td>'; print '<td align="center">'.price($obj->amount).'</td>';
print '<td align="center">-</td>'; print '<td align="center">-</td>';
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>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '<td>';
print '<td align="center">'.$langs->trans("OrderWaiting").'</td>';
print '<td align="right">';
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=delete&amp;did='.$obj->rowid.'">'; print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=delete&amp;did='.$obj->rowid.'">';
print img_delete(); print img_delete();
print '</a></td>'; print '</a></td>';
print "</tr>\n"; print "</tr>\n";
$i++; $i++;
} }
@ -574,7 +590,7 @@ if ($object->id > 0)
print '<td align="left">'.dol_print_date($db->jdate($obj->date_demande),'day')."</td>\n"; print '<td align="left">'.dol_print_date($db->jdate($obj->date_demande),'day')."</td>\n";
print '<td align="center">'.dol_print_date($db->jdate($obj->date_traite),'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">'.price($obj->amount).'</td>'; print '<td align="center">'.price($obj->amount).'</td>';
@ -585,9 +601,10 @@ if ($object->id > 0)
print $withdrawreceipt->getNomUrl(1); print $withdrawreceipt->getNomUrl(1);
print "</td>\n"; print "</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>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '<td align="center">'.dol_print_date($db->jdate($obj->date_traite),'day')."</td>\n";
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";

View File

@ -55,7 +55,7 @@ $pagenext = $page + 1;
/* /*
* Mode Liste * Mode List
* *
*/ */
$sql = "SELECT p.rowid, p.ref, p.amount, p.statut"; $sql = "SELECT p.rowid, p.ref, p.amount, p.statut";
@ -81,7 +81,7 @@ if ($result)
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("WithdrawalsReceipts"),$_SERVER["PHP_SELF"],"p.ref",'','','class="liste_titre"'); print_liste_field_titre($langs->trans("WithdrawalsReceipts"),$_SERVER["PHP_SELF"],"p.ref",'','','class="liste_titre"');
print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"p.datec","","",'class="liste_titre" align="center"'); print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"p.datec","","",'class="liste_titre" align="center"');
print '<td class="liste_titre" align="right">'.$langs->trans("Amount").'</td>'; print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"","","",'align="center"');
print '</tr>'; print '</tr>';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -121,7 +121,7 @@ else
dol_print_error($db); dol_print_error($db);
} }
$db->close();
llxFooter(); llxFooter();
$db->close();

View File

@ -25,6 +25,7 @@
require('../../main.inc.php'); require('../../main.inc.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/prelevement/class/ligneprelevement.class.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/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
@ -45,6 +46,11 @@ if ($user->societe_id > 0) accessforbidden();
$action = GETPOST('action','alpha'); $action = GETPOST('action','alpha');
$id = GETPOST('id','int'); $id = GETPOST('id','int');
$socid = GETPOST('socid','int');
$page = GETPOST('page','int');
$sortorder = ((GETPOST('sortorder','alpha')=="")) ? "DESC" : GETPOST('sortorder','alpha');
$sortfield = ((GETPOST('sortfield','alpha')=="")) ? "pl.fk_soc" : GETPOST('sortfield','alpha');
/* /*
* Actions * Actions
@ -207,10 +213,10 @@ if ($id > 0)
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("NotifyTransmision").'</td></tr>'; print '<td colspan="3">'.$langs->trans("NotifyTransmision").'</td></tr>';
print '<tr><td width="20%">'.$langs->trans("TransData").'</td><td>'; print '<tr '.$bc[false].'><td width="20%">'.$langs->trans("TransData").'</td><td>';
print $form->select_date('','','','','',"userfile",1,1); print $form->select_date('','','','','',"userfile",1,1);
print '</td></tr>'; print '</td></tr>';
print '<tr><td width="20%">'.$langs->trans("TransMetod").'</td><td>'; print '<tr '.$bc[false].'><td width="20%">'.$langs->trans("TransMetod").'</td><td>';
print $form->selectarray("methode",$bon->methodes_trans); print $form->selectarray("methode",$bon->methodes_trans);
print '</td></tr>'; print '</td></tr>';
/* print '<tr><td width="20%">'.$langs->trans("File").'</td><td>'; /* print '<tr><td width="20%">'.$langs->trans("File").'</td><td>';
@ -230,7 +236,7 @@ if ($id > 0)
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("NotifyCredit").'</td></tr>'; print '<td colspan="3">'.$langs->trans("NotifyCredit").'</td></tr>';
print '<tr><td width="20%">'.$langs->trans('CreditDate').'</td><td>'; print '<tr '.$bc[false].'><td width="20%">'.$langs->trans('CreditDate').'</td><td>';
print $form->select_date('','','','','',"infocredit",1,1); print $form->select_date('','','','','',"infocredit",1,1);
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
@ -259,6 +265,122 @@ if ($id > 0)
print "</div>"; print "</div>";
} }
$ligne=new LignePrelevement($db,$user);
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
/*
* Lines into withdraw request
*/
$sql = "SELECT pl.rowid, pl.statut, pl.amount";
$sql.= ", s.rowid as socid, s.nom as name";
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
$sql.= ", ".MAIN_DB_PREFIX."prelevement_bons as pb";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE pl.fk_prelevement_bons = ".$id;
$sql.= " AND pl.fk_prelevement_bons = pb.rowid";
$sql.= " AND pb.entity = ".$conf->entity;
$sql.= " AND pl.fk_soc = s.rowid";
if ($socid) $sql.= " AND s.rowid = ".$socid;
$sql.= $db->order($sortfield, $sortorder);
$sql.= $db->plimit($conf->liste_limit+1, $offset);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
$urladd = "&amp;id=".$prev_id;
print_barre_liste("", $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num);
print"\n<!-- debut table -->\n";
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Lines"),$_SERVER["PHP_SELF"],"pl.rowid",'',$urladd);
print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER["PHP_SELF"],"s.nom",'',$urladd);
print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"pl.amount","",$urladd,'align="center"');
print_liste_field_titre('');
print '</tr>';
$var=false;
$total = 0;
while ($i < min($num,$conf->liste_limit))
{
$obj = $db->fetch_object($result);
print "<tr ".$bc[$var].">";
print "<td>";
print $ligne->LibStatut($obj->statut,2);
print "&nbsp;";
print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/ligne.php?id='.$obj->rowid.'">';
print substr('000000'.$obj->rowid, -6);
print '</a></td>';
$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";
print '<td>';
if ($obj->statut == 3)
{
print '<b>'.$langs->trans("StatusRefused").'</b>';
}
else
{
print "&nbsp;";
}
print '</td></tr>';
$total += $obj->total_ttc;
$var=!$var;
$i++;
}
if($socid)
{
print "<tr ".$bc[$var].">";
print '<td>'.$langs->trans("Total").'</td>';
print '<td align="center">'.price($total)."</td>\n";
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print "</tr>\n";
}
print "</table>";
$db->free($result);
}
else
{
dol_print_error($db);
}
} }

View File

@ -446,8 +446,17 @@ class BonPrelevement extends CommonObject
$fac = new Facture($this->db); $fac = new Facture($this->db);
$fac->fetch($facs[$i][0]); $fac->fetch($facs[$i][0]);
$amounts[$fac->id] = $facs[$i][1]; $amounts[$fac->id] = $facs[$i][1];
$result = $fac->set_paid($user);
$totalpaye = $fac->getSommePaiement();
$totalcreditnotes = $fac->getSumCreditNotesUsed();
$totaldeposits = $fac->getSumDepositsUsed();
$alreadypayed = $totalpaye + $totalcreditnotes + $totaldeposits;
if ($alreadypayed + $facs[$i][1] >= $fac->total_ttc) {
$result = $fac->set_paid($user);
}
} }
$paiement = new Paiement($this->db); $paiement = new Paiement($this->db);
$paiement->datepaye = $date ; $paiement->datepaye = $date ;
$paiement->amounts = $amounts; $paiement->amounts = $amounts;
@ -651,7 +660,7 @@ class BonPrelevement extends CommonObject
{ {
global $conf; global $conf;
$sql = "SELECT sum(f.total_ttc) as nb"; $sql = "SELECT sum(pfd.amount) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f,"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f,";
$sql.= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $sql.= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
//$sql.= " ,".MAIN_DB_PREFIX."c_paiement as cp"; //$sql.= " ,".MAIN_DB_PREFIX."c_paiement as cp";
@ -837,7 +846,7 @@ class BonPrelevement extends CommonObject
else else
{ {
dol_syslog(__METHOD__."::Check RIB Error on default bank number RIB/IBAN for thirdparty reported by verif() ".$fact->socid." ".$soc->name, LOG_ERR); dol_syslog(__METHOD__."::Check RIB Error on default bank number RIB/IBAN for thirdparty reported by verif() ".$fact->socid." ".$soc->name, LOG_ERR);
$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; $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->getNomUrl(0);
} }
} }
else else
@ -924,6 +933,7 @@ class BonPrelevement extends CommonObject
if ($resql) if ($resql)
{ {
$prev_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_bons"); $prev_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_bons");
$this->id = $prev_id;
$dir=$conf->prelevement->dir_output.'/receipts'; $dir=$conf->prelevement->dir_output.'/receipts';
$file=$filebonprev; $file=$filebonprev;
@ -981,6 +991,7 @@ class BonPrelevement extends CommonObject
dol_syslog(__METHOD__."::Update Orders::Sql=".$sql, LOG_DEBUG); dol_syslog(__METHOD__."::Update Orders::Sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if (! $resql) if (! $resql)
{ {
$error++; $error++;
@ -1210,7 +1221,7 @@ class BonPrelevement extends CommonObject
/** /**
* Generate a withdrawal file. * Generate a withdrawal file.
* Generation Formats: * Generation Formats:
* - Europe: SEPA (France: CFONB no more supported, Spain: AEB19 if external module EsAEB is enabled) * - Europe: SEPA (France: CFONB no more supported, Spain: AEB19 if external module EsAEB is enabled)
* - Others countries: Warning message * - Others countries: Warning message
* File is generated with name this->filename * File is generated with name this->filename
* *
@ -1226,6 +1237,11 @@ class BonPrelevement extends CommonObject
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");
if (empty($this->file))
{
$this->error=$langs->trans('ErrorFailedToOpenFile', $this->filename);
return -1;
}
$found=0; $found=0;
@ -1287,7 +1303,8 @@ class BonPrelevement extends CommonObject
//echo $sql; //echo $sql;
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ $num = $this->db->num_rows($resql); {
$num = $this->db->num_rows($resql);
while ($i < $num) while ($i < $num)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
@ -1297,7 +1314,8 @@ class BonPrelevement extends CommonObject
} }
} }
else else
{ fputs($this->file, 'ERREUR DEBITEUR '.$sql.$CrLf); {
fputs($this->file, 'ERREUR DEBITEUR '.$sql.$CrLf);
$result = -2; $result = -2;
} }
@ -1305,10 +1323,12 @@ class BonPrelevement extends CommonObject
* section Emetteur(sepa Emetteur bloc lines) * section Emetteur(sepa Emetteur bloc lines)
*/ */
if ($result != -2) if ($result != -2)
{ $fileEmetteurSection .= $this->EnregEmetteurSEPA($conf, $date_actu, $i, $this->total, $CrLf); {
$fileEmetteurSection .= $this->EnregEmetteurSEPA($conf, $date_actu, $i, $this->total, $CrLf);
} }
else else
{ fputs($this->file, 'ERREUR EMETTEUR'.$CrLf); {
fputs($this->file, 'ERREUR EMETTEUR'.$CrLf);
} }
/** /**
@ -1503,7 +1523,7 @@ class BonPrelevement extends CommonObject
*/ */
static function buildRumNumber($row_code_client, $row_datec, $row_drum) static function buildRumNumber($row_code_client, $row_datec, $row_drum)
{ {
$pre = ($row_datec > 1359673200) ? 'Rum' : '++R'; $pre = ($row_datec > 1359673200) ? 'RUM-' : '++R';
return $pre.$row_code_client.'-'.$row_drum.'-'.date('U', $row_datec); return $pre.$row_code_client.'-'.$row_drum.'-'.date('U', $row_datec);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2010-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
* *
@ -96,13 +96,19 @@ if (prelevement_check_config() < 0)
print '</div>'; print '</div>';
} }
$h=0; /*$h=0;
$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/create.php'; $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/create.php';
$head[$h][1] = $langs->trans("NewStandingOrder"); $head[$h][1] = $langs->trans("NewStandingOrder");
$head[$h][2] = 'payment';
$hselected = 'payment';
$h++; $h++;
dol_fiche_head($head, $hselected, $langs->trans("StandingOrders"), 0, 'payment'); dol_fiche_head($head, $hselected, $langs->trans("StandingOrders"), 0, 'payment');
*/
print_barre_liste($langs->trans("NewStandingOrder"), 0, $_SERVER["PHP_SELF"]);
dol_fiche_head();
$nb=$bprev->NbFactureAPrelever(); $nb=$bprev->NbFactureAPrelever();
$nb1=$bprev->NbFactureAPrelever(1); $nb1=$bprev->NbFactureAPrelever(1);
@ -161,7 +167,7 @@ print '<br>';
*/ */
$sql = "SELECT f.facnumber, f.rowid, f.total_ttc, s.nom as name, s.rowid as socid,"; $sql = "SELECT f.facnumber, f.rowid, f.total_ttc, s.nom as name, s.rowid as socid,";
$sql.= " pfd.date_demande"; $sql.= " pfd.date_demande, pfd.amount";
$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,";
$sql.= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $sql.= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
@ -184,6 +190,7 @@ if ($resql)
print '<td>'.$langs->trans("Invoice").'</td>'; print '<td>'.$langs->trans("Invoice").'</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 align="right">'.$langs->trans("AmountTTC").'</td>'; print '<td align="right">'.$langs->trans("AmountTTC").'</td>';
print '<td align="right">'.$langs->trans("DateRequest").'</td>'; print '<td align="right">'.$langs->trans("DateRequest").'</td>';
print '</tr>'; print '</tr>';
@ -210,9 +217,13 @@ if ($resql)
print '<td>'; print '<td>';
print $thirdpartystatic->display_rib(); print $thirdpartystatic->display_rib();
print '</td>'; print '</td>';
// RUM
print '<td>';
print $thirdpartystatic->display_rib('rum');
print '</td>';
// Amount // Amount
print '<td align="right">'; print '<td align="right">';
print price($obj->total_ttc,0,$langs,0,0,-1,$conf->currency); print price($obj->amount,0,$langs,0,0,-1,$conf->currency);
print '</td>'; print '</td>';
// Date // Date
print '<td align="right">'; print '<td align="right">';
@ -265,11 +276,14 @@ if ($result)
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$var=!$var; $var=!$var;
print "<tr ".$bc[$var]."><td>"; print "<tr ".$bc[$var].">";
print "<td>";
$bprev->id=$obj->rowid; $bprev->id=$obj->rowid;
$bprev->ref=$obj->ref; $bprev->ref=$obj->ref;
print $bprev->getNomUrl(1); print $bprev->getNomUrl(1);
print "</td>\n"; print "</td>\n";
print '<td align="center">'.dol_print_date($db->jdate($obj->datec),'day')."</td>\n"; print '<td align="center">'.dol_print_date($db->jdate($obj->datec),'day')."</td>\n";
print '<td align="right">'.price($obj->amount,0,$langs,0,0,-1,$conf->currency)."</td>\n"; print '<td align="right">'.price($obj->amount,0,$langs,0,0,-1,$conf->currency)."</td>\n";

View File

@ -96,7 +96,7 @@ print '</td></tr></table><br>';
* Invoices waiting for withdraw * Invoices waiting for withdraw
*/ */
$sql = "SELECT f.facnumber, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type,"; $sql = "SELECT f.facnumber, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type,";
$sql.= " pfd.date_demande,"; $sql.= " pfd.date_demande, pfd.amount,";
$sql.= " s.nom as name, s.rowid as socid"; $sql.= " s.nom as name, 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";
@ -143,7 +143,7 @@ if ($resql)
print '</td>'; print '</td>';
print '<td align="right">'; print '<td align="right">';
print price($obj->total_ttc); print price($obj->amount);
print '</td>'; print '</td>';
print '<td align="right">'; print '<td align="right">';

View File

@ -1,225 +0,0 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* 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/lignes.php
* \ingroup prelevement
* \brief Prelevement lines
*/
require('../../main.inc.php');
require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$langs->load("banks");
$langs->load("categories");
// Security check
if ($user->societe_id > 0) accessforbidden();
$langs->load('withdrawals');
$langs->load('bills');
// Get supervariables
$prev_id = GETPOST('id','int');
$socid = GETPOST('socid','int');
$page = GETPOST('page','int');
$sortorder = ((GETPOST('sortorder','alpha')=="")) ? "DESC" : GETPOST('sortorder','alpha');
$sortfield = ((GETPOST('sortfield','alpha')=="")) ? "pl.fk_soc" : GETPOST('sortfield','alpha');
/*
* View
*/
llxHeader('',$langs->trans("WithdrawalsReceipts"));
if ($prev_id)
{
$bon = new BonPrelevement($db,"");
if ($bon->fetch($prev_id) == 0)
{
$head = prelevement_prepare_head($bon);
dol_fiche_head($head, 'lines', $langs->trans("WithdrawalsReceipts"), '', 'payment');
print '<table class="border" width="100%">';
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td>'.$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($bon->amount).'</td></tr>';
// Status
print '<tr><td width="20%">'.$langs->trans('Status').'</td>';
print '<td>'.$bon->getLibStatut(1).'</td>';
print '</tr>';
if($bon->date_trans <> 0)
{
$muser = new User($db);
$muser->fetch($bon->user_trans);
print '<tr><td width="20%">'.$langs->trans("TransData").'</td><td>';
print dol_print_date($bon->date_trans,'day');
print ' '.$langs->trans("By").' '.$muser->getFullName($langs).'</td></tr>';
print '<tr><td width="20%">'.$langs->trans("TransMetod").'</td><td>';
print $bon->methodes_trans[$bon->method_trans];
print '</td></tr>';
}
if($bon->date_credit <> 0)
{
print '<tr><td width="20%">'.$langs->trans('CreditDate').'</td><td>';
print dol_print_date($bon->date_credit,'day');
print '</td></tr>';
}
print '</table>';
print '<br>';
print '<table class="border" width="100%"><tr><td width="20%">';
print $langs->trans("WithdrawalFile").'</td><td>';
$relativepath = 'receipts/'.$bon->ref;
print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
print '</td></tr></table>';
dol_fiche_end();
}
else
{
dol_print_error($db);
}
}
$ligne=new LignePrelevement($db,$user);
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$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";
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
$sql.= ", ".MAIN_DB_PREFIX."prelevement_bons as pb";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE pl.fk_prelevement_bons = ".$prev_id;
$sql.= " AND pl.fk_prelevement_bons = pb.rowid";
$sql.= " AND pb.entity = ".$conf->entity;
$sql.= " AND pl.fk_soc = s.rowid";
if ($socid) $sql.= " AND s.rowid = ".$socid;
$sql.= " ORDER BY $sortfield $sortorder ";
$sql.= $db->plimit($conf->liste_limit+1, $offset);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
$urladd = "&amp;id=".$prev_id;
print_barre_liste("", $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num);
print"\n<!-- debut table -->\n";
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Lines"),$_SERVER["PHP_SELF"],"pl.rowid",'',$urladd);
print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER["PHP_SELF"],"s.nom",'',$urladd);
print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"pl.amount","",$urladd,'align="center"');
print '<td colspan="2">&nbsp;</td></tr>';
$var=false;
$total = 0;
while ($i < min($num,$conf->liste_limit))
{
$obj = $db->fetch_object($result);
print "<tr ".$bc[$var]."><td>";
print $ligne->LibStatut($obj->statut,2);
print "&nbsp;";
print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/ligne.php?id='.$obj->rowid.'">';
print substr('000000'.$obj->rowid, -6);
print '</a></td>';
$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";
print '<td>';
if ($obj->statut == 3)
{
print '<b>'.$langs->trans("StatusRefused").'</b>';
}
else
{
print "&nbsp;";
}
print '</td></tr>';
$total += $obj->total_ttc;
$var=!$var;
$i++;
}
if($socid)
{
print "<tr ".$bc[$var]."><td>";
print '<td>Total</td>';
print '<td align="center">'.price($total)."</td>\n";
print '<td>&nbsp;</td>';
print "</tr>\n";
}
print "</table>";
$db->free($result);
}
else
{
dol_print_error($db);
}
$db->close();
llxFooter();

View File

@ -2324,7 +2324,7 @@ class Form
/** /**
* Charge dans cache la liste des conditions de paiements possibles * Load into cache list of payment terms
* *
* @return int Nb of lines loaded, <0 if KO * @return int Nb of lines loaded, <0 if KO
*/ */
@ -2358,7 +2358,7 @@ class Form
$i++; $i++;
} }
//$this->cache_conditions_paiements=dol_sort_array($this->cache_conditions_paiements, 'label'); // We use the sortorder //$this->cache_conditions_paiements=dol_sort_array($this->cache_conditions_paiements, 'label', 'asc', 0, 0, 1); // We use the field sortorder of table
return $num; return $num;
} }
@ -2403,7 +2403,7 @@ class Form
$i++; $i++;
} }
$this->cache_availability = dol_sort_array($this->cache_availability, 'label'); $this->cache_availability = dol_sort_array($this->cache_availability, 'label', 'asc', 0, 0, 1);
return $num; return $num;
} }
@ -2484,7 +2484,7 @@ class Form
$i++; $i++;
} }
$this->cache_demand_reason=dol_sort_array($tmparray, 'label', 'asc'); $this->cache_demand_reason=dol_sort_array($tmparray, 'label', 'asc', 0, 0, 1);
unset($tmparray); unset($tmparray);
return $num; return $num;
@ -2547,7 +2547,9 @@ class Form
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$sql = "SELECT id, code, libelle, type"; $this->cache_types_paiements = array();
$sql = "SELECT id, code, libelle as label, type";
$sql.= " FROM ".MAIN_DB_PREFIX."c_paiement"; $sql.= " FROM ".MAIN_DB_PREFIX."c_paiement";
$sql.= " WHERE active > 0"; $sql.= " WHERE active > 0";
@ -2561,14 +2563,15 @@ class Form
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
$label=($langs->trans("PaymentTypeShort".$obj->code)!=("PaymentTypeShort".$obj->code)?$langs->trans("PaymentTypeShort".$obj->code):($obj->libelle!='-'?$obj->libelle:'')); $label=($langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code)!=("PaymentTypeShort".$obj->code)?$langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code):($obj->label!='-'?$obj->label:''));
$this->cache_types_paiements[$obj->id]['id'] =$obj->id;
$this->cache_types_paiements[$obj->id]['code'] =$obj->code; $this->cache_types_paiements[$obj->id]['code'] =$obj->code;
$this->cache_types_paiements[$obj->id]['label']=$label; $this->cache_types_paiements[$obj->id]['label']=$label;
$this->cache_types_paiements[$obj->id]['type'] =$obj->type; $this->cache_types_paiements[$obj->id]['type'] =$obj->type;
$i++; $i++;
} }
$this->cache_types_paiements = dol_sort_array($this->cache_types_paiements, 'label'); $this->cache_types_paiements = dol_sort_array($this->cache_types_paiements, 'label', 'asc', 0, 0, 1);
return $num; return $num;
} }
@ -3579,7 +3582,7 @@ class Form
/** /**
* Affiche formulaire de selection des modes de reglement * Show form with payment mode
* *
* @param string $page Page * @param string $page Page
* @param int $selected Id mode pre-selectionne * @param int $selected Id mode pre-selectionne
@ -3607,6 +3610,7 @@ class Form
if ($selected) if ($selected)
{ {
$this->load_cache_types_paiements(); $this->load_cache_types_paiements();
print $this->cache_types_paiements[$selected]['label']; print $this->cache_types_paiements[$selected]['label'];
} else { } else {
print "&nbsp;"; print "&nbsp;";

View File

@ -4557,12 +4557,13 @@ function dol_htmloutput_errors($mesgstring='', $mesgarray='', $keepembedded=0)
* *
* @param array $array Array to sort (array of array('key','otherkey1','otherkey2'...)) * @param array $array Array to sort (array of array('key','otherkey1','otherkey2'...))
* @param string $index Key in array to use for sorting criteria * @param string $index Key in array to use for sorting criteria
* @param int $order Sort order * @param int $order Sort order ('asc' or 'desc')
* @param int $natsort 1=use "natural" sort (natsort), 0=use "standard" sort (asort) * @param int $natsort 1=use "natural" sort (natsort), 0=use "standard" sort (asort)
* @param int $case_sensitive 1=sort is case sensitive, 0=not case sensitive * @param int $case_sensitive 1=sort is case sensitive, 0=not case sensitive
* @param int $keepindex If 0 and index key of array to sort is a numeric, than index will be rewrote. If 1 or index key is not numeric, key for index is kept after sorting.
* @return array Sorted array * @return array Sorted array
*/ */
function dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0) function dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
{ {
// Clean parameters // Clean parameters
$order=strtolower($order); $order=strtolower($order);
@ -4571,13 +4572,21 @@ function dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensiti
if (is_array($array) && $sizearray>0) if (is_array($array) && $sizearray>0)
{ {
foreach(array_keys($array) as $key) $temp[$key]=$array[$key][$index]; foreach(array_keys($array) as $key) $temp[$key]=$array[$key][$index];
if (!$natsort) ($order=='asc') ? asort($temp) : arsort($temp); if (!$natsort) ($order=='asc') ? asort($temp) : arsort($temp);
else else
{ {
($case_sensitive) ? natsort($temp) : natcasesort($temp); ($case_sensitive) ? natsort($temp) : natcasesort($temp);
if($order!='asc') $temp=array_reverse($temp,TRUE); if($order!='asc') $temp=array_reverse($temp,TRUE);
} }
foreach(array_keys($temp) as $key) (is_numeric($key))? $sorted[]=$array[$key] : $sorted[$key]=$array[$key];
$sorted = array();
foreach(array_keys($temp) as $key)
{
(is_numeric($key) && empty($keepindex)) ? $sorted[]=$array[$key] : $sorted[$key]=$array[$key];
}
return $sorted; return $sorted;
} }
return $array; return $array;

View File

@ -44,11 +44,6 @@ function prelevement_prepare_head(BonPrelevement $object)
$head[$h][2] = 'prelevement'; $head[$h][2] = 'prelevement';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/lignes.php?id='.$object->id;
$head[$h][1] = $langs->trans("Lines");
$head[$h][2] = 'lines';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/factures.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/factures.php?id='.$object->id;
$head[$h][1] = $langs->trans("Bills"); $head[$h][1] = $langs->trans("Bills");
$head[$h][2] = 'invoices'; $head[$h][2] = 'invoices';

View File

@ -341,10 +341,13 @@ class pdf_standard extends ModeleExpenseReport
$pdf->MultiCell($this->posxtva-$this->posxprojet-1, 3,$object->lines[$i]->projet_ref, 0, 'C'); $pdf->MultiCell($this->posxtva-$this->posxprojet-1, 3,$object->lines[$i]->projet_ref, 0, 'C');
// VAT Rate // VAT Rate
$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
$pdf->SetFont('','', $default_font_size - 1); {
$pdf->SetXY($this->posxtva, $curY); $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
$pdf->MultiCell($this->posxup-$this->posxtva-1, 3,$vat_rate, 0, 'R'); $pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY($this->posxtva, $curY);
$pdf->MultiCell($this->posxup-$this->posxtva-1, 3,$vat_rate, 0, 'R');
}
// Unit price // Unit price
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
@ -441,12 +444,15 @@ class pdf_standard extends ModeleExpenseReport
$pdf->MultiCell($this->page_largeur - $this->marge_gauche - 160, 5, price($object->total_ht), 1, 'R'); $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 160, 5, price($object->total_ht), 1, 'R');
$pdf->SetFillColor(248,248,248); $pdf->SetFillColor(248,248,248);
$posy+=5; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
$pdf->SetXY(100, $posy); {
$pdf->SetTextColor(0,0,60); $posy+=5;
$pdf->MultiCell(60, 5, $outputlangs->transnoentities("TotalVAT"), 1,'L'); $pdf->SetXY(100, $posy);
$pdf->SetXY(160, $posy); $pdf->SetTextColor(0,0,60);
$pdf->MultiCell($this->page_largeur - $this->marge_gauche - 160, 5, price($object->total_tva),1, 'R'); $pdf->MultiCell(60, 5, $outputlangs->transnoentities("TotalVAT"), 1,'L');
$pdf->SetXY(160, $posy);
$pdf->MultiCell($this->page_largeur - $this->marge_gauche - 160, 5, price($object->total_tva),1, 'R');
}
$posy+=5; $posy+=5;
$pdf->SetXY(100, $posy); $pdf->SetXY(100, $posy);
@ -768,9 +774,12 @@ class pdf_standard extends ModeleExpenseReport
$pdf->MultiCell($this->posxtva-$this->posxprojet-1,2, $outputlangs->transnoentities("Project"),'','C'); $pdf->MultiCell($this->posxtva-$this->posxprojet-1,2, $outputlangs->transnoentities("Project"),'','C');
// VAT // VAT
$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
$pdf->SetXY($this->posxtva-1, $tab_top+1); {
$pdf->MultiCell($this->posxup-$this->posxtva-1,2, $outputlangs->transnoentities("VAT"),'','C'); $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
$pdf->SetXY($this->posxtva-1, $tab_top+1);
$pdf->MultiCell($this->posxup-$this->posxtva-1,2, $outputlangs->transnoentities("VAT"),'','C');
}
// Unit price // Unit price
$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);

View File

@ -203,8 +203,8 @@ class modExpenseReport extends DolibarrModules
$this->export_label[$r]='ListTripsAndExpenses'; $this->export_label[$r]='ListTripsAndExpenses';
$this->export_icon[$r]='trip'; $this->export_icon[$r]='trip';
$this->export_permission[$r]=array(array("expensereport","export")); $this->export_permission[$r]=array(array("expensereport","export"));
$this->export_fields_array[$r]=array('d.rowid'=>"TripId",'d.ref'=>'Ref','d.date_debut'=>'DateStart','d.date_fin'=>'DateEnd','d.date_create'=>'DateCreation','d.date_approve'=>'DateApprove','d.total_ht'=>"TotalHT",'d.total_tva'=>'TotalVAT','d.total_ttc'=>'TotalTTC','d.note_private'=>'NotePrivate','d.note_public'=>'NotePublic','u.lastname'=>'Lastname','u.firstname'=>'Firstname','u.login'=>"Login",'ed.rowid'=>'LineId','tf.code'=>'Type','ed.date'=>'Date','ed.fk_c_tva'=>'VATRate','ed.total_ht'=>'TotalHT','ed.total_tva'=>'TotalVAT','ed.total_ttc'=>'TotalTTC','ed.comments'=>'Comment','p.rowid'=>'ProjectId','p.ref'=>'Ref'); $this->export_fields_array[$r]=array('d.rowid'=>"TripId",'d.ref'=>'Ref','d.date_debut'=>'DateStart','d.date_fin'=>'DateEnd','d.date_create'=>'DateCreation','d.date_approve'=>'DateApprove','d.total_ht'=>"TotalHT",'d.total_tva'=>'TotalVAT','d.total_ttc'=>'TotalTTC','d.note_private'=>'NotePrivate','d.note_public'=>'NotePublic','u.lastname'=>'Lastname','u.firstname'=>'Firstname','u.login'=>"Login",'ed.rowid'=>'LineId','tf.code'=>'Type','ed.date'=>'Date','ed.tva_tx'=>'VATRate','ed.total_ht'=>'TotalHT','ed.total_tva'=>'TotalVAT','ed.total_ttc'=>'TotalTTC','ed.comments'=>'Comment','p.rowid'=>'ProjectId','p.ref'=>'Ref');
$this->export_entities_array[$r]=array('u.lastname'=>'user','u.firstname'=>'user','u.login'=>'user','ed.rowid'=>'expensereport_line','ed.date'=>'expensereport_line','ed.fk_c_tva'=>'expensereport_line','ed.total_ht'=>'expensereport_line','ed.total_tva'=>'expensereport_line','ed.total_ttc'=>'expensereport_line','ed.comments'=>'expensereport_line','tf.code'=>'expensereport_line','p.project_ref'=>'expensereport_line','p.rowid'=>'project','p.ref'=>'project'); $this->export_entities_array[$r]=array('u.lastname'=>'user','u.firstname'=>'user','u.login'=>'user','ed.rowid'=>'expensereport_line','ed.date'=>'expensereport_line','ed.tva_tx'=>'expensereport_line','ed.total_ht'=>'expensereport_line','ed.total_tva'=>'expensereport_line','ed.total_ttc'=>'expensereport_line','ed.comments'=>'expensereport_line','tf.code'=>'expensereport_line','p.project_ref'=>'expensereport_line','p.rowid'=>'project','p.ref'=>'project');
$this->export_alias_array[$r]=array('d.rowid'=>"idtrip",'d.type'=>"type",'d.note_private'=>'note_private','d.note_public'=>'note_public','u.lastname'=>'name','u.firstname'=>'firstname','u.login'=>'login'); $this->export_alias_array[$r]=array('d.rowid'=>"idtrip",'d.type'=>"type",'d.note_private'=>'note_private','d.note_public'=>'note_public','u.lastname'=>'name','u.firstname'=>'firstname','u.login'=>'login');
$this->export_dependencies_array[$r]=array('expensereport_line'=>'ed.rowid','type_fees'=>'tf.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them $this->export_dependencies_array[$r]=array('expensereport_line'=>'ed.rowid','type_fees'=>'tf.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them

View File

@ -822,7 +822,6 @@ if ($action == "addline")
$object_ligne->fk_c_type_fees = GETPOST('fk_c_type_fees'); $object_ligne->fk_c_type_fees = GETPOST('fk_c_type_fees');
$object_ligne->fk_c_tva = GETPOST('fk_c_tva');
$object_ligne->vatrate = price2num(GETPOST('vatrate')); $object_ligne->vatrate = price2num(GETPOST('vatrate'));
$object_ligne->fk_projet = $fk_projet; $object_ligne->fk_projet = $fk_projet;
@ -943,7 +942,6 @@ if ($action == "updateligne" )
$rowid = $_POST['rowid']; $rowid = $_POST['rowid'];
$type_fees_id = GETPOST('fk_c_type_fees'); $type_fees_id = GETPOST('fk_c_type_fees');
$object_ligne->fk_c_tva = GETPOST('fk_c_tva');
$object_ligne->vatrate = price2num(GETPOST('vatrate')); $object_ligne->vatrate = price2num(GETPOST('vatrate'));
$projet_id = $fk_projet; $projet_id = $fk_projet;
$comments = GETPOST('comments'); $comments = GETPOST('comments');
@ -1585,7 +1583,7 @@ else
// Fetch Lines of current expense report // Fetch Lines of current expense report
$sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_projet, fde.date,'; $sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_projet, fde.date,';
$sql.= ' fde.fk_c_tva as fk_c_tva, fde.tva_tx as vatrate, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,'; $sql.= ' fde.tva_tx as vatrate, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,';
$sql.= ' ctf.code as type_fees_code, ctf.label as type_fees_libelle,'; $sql.= ' ctf.code as type_fees_code, ctf.label as type_fees_libelle,';
$sql.= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref'; $sql.= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref';
$sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det as fde'; $sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det as fde';

View File

@ -748,7 +748,7 @@ class ExpenseReport extends CommonObject
$this->lines=array(); $this->lines=array();
$sql = ' SELECT de.rowid, de.comments, de.qty, de.value_unit, de.date,'; $sql = ' SELECT de.rowid, de.comments, de.qty, de.value_unit, de.date,';
$sql.= ' de.'.$this->fk_element.', de.fk_c_type_fees, de.fk_projet, de.fk_c_tva, de.tva_tx as vatrate,'; $sql.= ' de.'.$this->fk_element.', de.fk_c_type_fees, de.fk_projet, de.tva_tx as vatrate,';
$sql.= ' de.total_ht, de.total_tva, de.total_ttc,'; $sql.= ' de.total_ht, de.total_tva, de.total_ttc,';
$sql.= ' ctf.code as code_type_fees, ctf.label as libelle_type_fees,'; $sql.= ' ctf.code as code_type_fees, ctf.label as libelle_type_fees,';
$sql.= ' p.ref as ref_projet, p.title as title_projet'; $sql.= ' p.ref as ref_projet, p.title as title_projet';
@ -778,7 +778,6 @@ class ExpenseReport extends CommonObject
$deplig->fk_expensereport = $objp->fk_expensereport; $deplig->fk_expensereport = $objp->fk_expensereport;
$deplig->fk_c_type_fees = $objp->fk_c_type_fees; $deplig->fk_c_type_fees = $objp->fk_c_type_fees;
$deplig->fk_projet = $objp->fk_projet; $deplig->fk_projet = $objp->fk_projet;
$deplig->fk_c_tva = $objp->fk_c_tva;
$deplig->total_ht = $objp->total_ht; $deplig->total_ht = $objp->total_ht;
$deplig->total_tva = $objp->total_tva; $deplig->total_tva = $objp->total_tva;
@ -1475,7 +1474,6 @@ class ExpenseReportLine
var $value_unit; var $value_unit;
var $date; var $date;
var $fk_c_tva;
var $fk_c_type_fees; var $fk_c_type_fees;
var $fk_projet; var $fk_projet;
var $fk_expensereport; var $fk_expensereport;
@ -1510,7 +1508,7 @@ class ExpenseReportLine
function fetch($rowid) function fetch($rowid)
{ {
$sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_projet, fde.date,'; $sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_projet, fde.date,';
$sql.= ' fde.fk_c_tva as fk_c_tva, fde.tva_tx as vatrate, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,'; $sql.= ' fde.tva_tx as vatrate, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,';
$sql.= ' ctf.code as type_fees_code, ctf.label as type_fees_libelle,'; $sql.= ' ctf.code as type_fees_code, ctf.label as type_fees_libelle,';
$sql.= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref'; $sql.= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref';
$sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det as fde'; $sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det as fde';
@ -1530,7 +1528,6 @@ class ExpenseReportLine
$this->qty = $objp->qty; $this->qty = $objp->qty;
$this->date = $objp->date; $this->date = $objp->date;
$this->value_unit = $objp->value_unit; $this->value_unit = $objp->value_unit;
$this->fk_c_tva = $objp->fk_c_tva;
$this->fk_c_type_fees = $objp->fk_c_type_fees; $this->fk_c_type_fees = $objp->fk_c_type_fees;
$this->fk_projet = $objp->fk_projet; $this->fk_projet = $objp->fk_projet;
$this->type_fees_code = $objp->type_fees_code; $this->type_fees_code = $objp->type_fees_code;
@ -1572,11 +1569,10 @@ class ExpenseReportLine
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'expensereport_det'; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'expensereport_det';
$sql.= ' (fk_expensereport, fk_c_type_fees, fk_projet,'; $sql.= ' (fk_expensereport, fk_c_type_fees, fk_projet,';
$sql.= ' fk_c_tva, tva_tx, comments, qty, value_unit, total_ht, total_tva, total_ttc, date)'; $sql.= ' tva_tx, comments, qty, value_unit, total_ht, total_tva, total_ttc, date)';
$sql.= " VALUES (".$this->fk_expensereport.","; $sql.= " VALUES (".$this->fk_expensereport.",";
$sql.= " ".$this->fk_c_type_fees.","; $sql.= " ".$this->fk_c_type_fees.",";
$sql.= " ".($this->fk_projet>0?$this->fk_projet:'null').","; $sql.= " ".($this->fk_projet>0?$this->fk_projet:'null').",";
$sql.= " ".($this->fk_c_tva?$this->fk_c_tva:"null").",";
$sql.= " ".$this->vatrate.","; $sql.= " ".$this->vatrate.",";
$sql.= " '".$this->db->escape($this->comments)."',"; $sql.= " '".$this->db->escape($this->comments)."',";
$sql.= " ".$this->qty.","; $sql.= " ".$this->qty.",";
@ -1651,8 +1647,6 @@ class ExpenseReportLine
else $sql.= ",fk_c_type_fees=null"; else $sql.= ",fk_c_type_fees=null";
if ($this->fk_projet) $sql.= ",fk_projet=".$this->fk_projet; if ($this->fk_projet) $sql.= ",fk_projet=".$this->fk_projet;
else $sql.= ",fk_projet=null"; else $sql.= ",fk_projet=null";
if ($this->fk_c_tva) $sql.= ",fk_c_tva=".$this->fk_c_tva;
else $sql.= ",fk_c_tva=null";
$sql.= " WHERE rowid = ".$this->rowid; $sql.= " WHERE rowid = ".$this->rowid;
dol_syslog("ExpenseReportLine::update sql=".$sql); dol_syslog("ExpenseReportLine::update sql=".$sql);

View File

@ -260,17 +260,16 @@ CREATE TABLE llx_expensereport_det
fk_expensereport integer NOT NULL, fk_expensereport integer NOT NULL,
fk_c_type_fees integer NOT NULL, fk_c_type_fees integer NOT NULL,
fk_projet integer, fk_projet integer,
fk_c_tva integer,
comments text NOT NULL, comments text NOT NULL,
product_type integer DEFAULT -1, product_type integer DEFAULT -1,
qty real NOT NULL, qty real NOT NULL,
value_unit real NOT NULL, value_unit real NOT NULL,
remise_percent real, remise_percent real,
tva_tx double(6,3), -- Vat rat tva_tx double(6,3), -- Vat rat
localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate
localtax1_type varchar(10) NULL, -- localtax1 type localtax1_type varchar(10) NULL, -- localtax1 type
localtax2_tx double(6,3) DEFAULT 0, -- localtax2 rate localtax2_tx double(6,3) DEFAULT 0, -- localtax2 rate
localtax2_type varchar(10) NULL, -- localtax2 type localtax2_type varchar(10) NULL, -- localtax2 type
total_ht double(24,8) DEFAULT 0 NOT NULL, total_ht double(24,8) DEFAULT 0 NOT NULL,
total_tva double(24,8) DEFAULT 0 NOT NULL, total_tva double(24,8) DEFAULT 0 NOT NULL,
total_localtax1 double(24,8) DEFAULT 0, -- Total LocalTax1 for total quantity of line total_localtax1 double(24,8) DEFAULT 0, -- Total LocalTax1 for total quantity of line

View File

@ -22,17 +22,16 @@ CREATE TABLE llx_expensereport_det
fk_expensereport integer NOT NULL, fk_expensereport integer NOT NULL,
fk_c_type_fees integer NOT NULL, fk_c_type_fees integer NOT NULL,
fk_projet integer, fk_projet integer,
fk_c_tva integer NOT NULL,
comments text NOT NULL, comments text NOT NULL,
product_type integer DEFAULT -1, product_type integer DEFAULT -1,
qty real NOT NULL, qty real NOT NULL,
value_unit real NOT NULL, value_unit real NOT NULL,
remise_percent real, remise_percent real,
tva_tx double(6,3), -- Vat rate tva_tx double(6,3), -- Vat rate
localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate
localtax1_type varchar(10) NULL, -- localtax1 type localtax1_type varchar(10) NULL, -- localtax1 type
localtax2_tx double(6,3) DEFAULT 0, -- localtax2 rate localtax2_tx double(6,3) DEFAULT 0, -- localtax2 rate
localtax2_type varchar(10) NULL, -- localtax2 type localtax2_type varchar(10) NULL, -- localtax2 type
total_ht double(24,8) DEFAULT 0 NOT NULL, total_ht double(24,8) DEFAULT 0 NOT NULL,
total_tva double(24,8) DEFAULT 0 NOT NULL, total_tva double(24,8) DEFAULT 0 NOT NULL,
total_localtax1 double(24,8) DEFAULT 0, -- Total LocalTax1 for total quantity of line total_localtax1 double(24,8) DEFAULT 0, -- Total LocalTax1 for total quantity of line

View File

@ -87,6 +87,8 @@ StatisticsByLineStatus=Statistics by status of lines
RUM=RUM RUM=RUM
RUMWillBeGenerated=RUM number will be generated once bank account information are saved RUMWillBeGenerated=RUM number will be generated once bank account information are saved
WithdrawMode=Withdraw mode (FRST or RECUR) WithdrawMode=Withdraw mode (FRST or RECUR)
WithdrawRequestAmount=Withdraw request amount:
WithdrawRequestErrorNilAmount=Unable to create withdraw request for nil amount.
### Notifications ### Notifications
InfoCreditSubject=Payment of standing order %s by the bank InfoCreditSubject=Payment of standing order %s by the bank

View File

@ -84,6 +84,8 @@ WithdrawalFile=Fichier de prélèvement
SetToStatusSent=Mettre au statut "Fichier envoyé" SetToStatusSent=Mettre au statut "Fichier envoyé"
ThisWillAlsoAddPaymentOnInvoice=Ceci créera également les paiements sur les factures et les classera payées ThisWillAlsoAddPaymentOnInvoice=Ceci créera également les paiements sur les factures et les classera payées
StatisticsByLineStatus=Statistiques par statut des lignes StatisticsByLineStatus=Statistiques par statut des lignes
WithdrawRequestAmount=Montant de la demande de prélèvement :
WithdrawRequestErrorNilAmount=Impossible de créer une demande de prélèvement avec un montant nul.
### Notifications ### Notifications
InfoCreditSubject=Crédit prélèvement %s à la banque InfoCreditSubject=Crédit prélèvement %s à la banque

View File

@ -980,11 +980,13 @@ else
print "</td></tr>"; print "</td></tr>";
// Categories if($conf->categorie->enabled) {
print '<tr><td valign="top">'.$langs->trans("Categories").'</td><td colspan="3">'; // Categories
$cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1); print '<tr><td valign="top">'.$langs->trans("Categories").'</td><td colspan="3">';
print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, 250); $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1);
print "</td></tr>"; print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, 250);
print "</td></tr>";
}
// Units // Units
if($conf->global->PRODUCT_USE_UNITS) if($conf->global->PRODUCT_USE_UNITS)
@ -1271,16 +1273,18 @@ else
print "</td></tr>"; print "</td></tr>";
// Categories if($conf->categorie->enabled) {
print '<tr><td valign="top">'.$langs->trans("Categories").'</td><td colspan="3">'; // Categories
$cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1); print '<tr><td valign="top">'.$langs->trans("Categories").'</td><td colspan="3">';
$c = new Categorie($db); $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1);
$cats = $c->containing($object->id,Categorie::TYPE_PRODUCT); $c = new Categorie($db);
foreach($cats as $cat) { $cats = $c->containing($object->id,Categorie::TYPE_PRODUCT);
$arrayselected[] = $cat->id; foreach($cats as $cat) {
$arrayselected[] = $cat->id;
}
print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
print "</td></tr>";
} }
print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
print "</td></tr>";
// Units // Units
if($conf->global->PRODUCT_USE_UNITS) if($conf->global->PRODUCT_USE_UNITS)
@ -1593,9 +1597,11 @@ else
print '<!-- End show Note --> '."\n"; print '<!-- End show Note --> '."\n";
// Categories // Categories
print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td colspan="3">'; if($conf->categorie->enabled) {
print $form->showCategories($object->id,'product',1); print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td colspan="3">';
print "</td></tr>"; print $form->showCategories($object->id,'product',1);
print "</td></tr>";
}
print "</table>\n"; print "</table>\n";

View File

@ -163,15 +163,15 @@ class CompanyBankAccount extends Account
* Load record from database * Load record from database
* *
* @param int $id Id of record * @param int $id Id of record
* @param int $socid Id of company * @param int $socid Id of company. If this is filled, function will return the default RIB of company
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function fetch($id,$socid=0) function fetch($id, $socid=0)
{ {
if (empty($id) && empty($socid)) return -1; if (empty($id) && empty($socid)) return -1;
$sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,"; $sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
$sql.= " owner_address, default_rib, label, datec, tms as datem, frstrecur"; $sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur";
$sql.= " FROM ".MAIN_DB_PREFIX."societe_rib"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib";
if ($id) $sql.= " WHERE rowid = ".$id; if ($id) $sql.= " WHERE rowid = ".$id;
if ($socid) $sql.= " WHERE fk_soc = ".$socid." AND default_rib = 1"; if ($socid) $sql.= " WHERE fk_soc = ".$socid." AND default_rib = 1";
@ -199,6 +199,7 @@ class CompanyBankAccount extends Account
$this->default_rib = $obj->default_rib; $this->default_rib = $obj->default_rib;
$this->datec = $this->db->jdate($obj->datec); $this->datec = $this->db->jdate($obj->datec);
$this->datem = $this->db->jdate($obj->datem); $this->datem = $this->db->jdate($obj->datem);
$this->rum = $obj->rum;
$this->frstrecur = $obj->frstrecur; $this->frstrecur = $obj->frstrecur;
} }
$this->db->free($resql); $this->db->free($resql);

View File

@ -2132,16 +2132,33 @@ class Societe extends CommonObject
/** /**
* Return bank number property of thirdparty * Return bank number property of thirdparty (label or rum)
* *
* @return string Bank number * @param string $mode 'label' or 'rum'
* @return string Bank number
*/ */
function display_rib() function display_rib($mode='label')
{ {
require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php';
$bac = new CompanyBankAccount($this->db); $bac = new CompanyBankAccount($this->db);
$bac->fetch(0,$this->id); $bac->fetch(0,$this->id);
return $bac->getRibLabel(true);
if ($mode == 'label')
{
return $bac->getRibLabel(true);
}
elseif ($mode == 'rum')
{
if (empty($bac->rum))
{
$prelevement = new BonPrelevement($this->db);
$bac->fetch_thirdparty();
$bac->rum = $prelevement->buildRumNumber($bac->thirdparty->code_client, $bac->datec, $bac->id);
}
return $bac->rum;
}
return 'BadParameterToFunctionDisplayRib';
} }
/** /**

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org> * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Peter Fontaine <contact@peterfontaine.fr> * Copyright (C) 2013 Peter Fontaine <contact@peterfontaine.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
@ -396,8 +396,10 @@ if ($socid && $action != 'edit' && $action != "create")
if (! empty($conf->prelevement->enabled)) if (! empty($conf->prelevement->enabled))
{ {
// RUM
print '<td>'.$prelevement->buildRumNumber($soc->code_client, $rib->datec, $rib->id).'</td>'; print '<td>'.$prelevement->buildRumNumber($soc->code_client, $rib->datec, $rib->id).'</td>';
// FRSTRECUR
print '<td>'.$rib->frstrecur.'</td>'; print '<td>'.$rib->frstrecur.'</td>';
} }
@ -549,9 +551,13 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer)
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
if (empty($account->rum)) $account->rum = $prelevement->buildRumNumber($soc->code_client, $account->datec, $account->id);
// RUM
print '<tr><td width="35%">'.$langs->trans("RUM").'</td>'; print '<tr><td width="35%">'.$langs->trans("RUM").'</td>';
print '<td colspan="4">'.$account->rum.'</td></tr>'; print '<td colspan="4">'.$account->rum.'</td></tr>';
// FRSTRECUR
print '<tr><td width="35%">'.$langs->trans("WithdrawMode").'</td>'; print '<tr><td width="35%">'.$langs->trans("WithdrawMode").'</td>';
print '<td colspan="4"><input size="30" type="text" name="frstrecur" value="'.(GETPOST('frstrecur')?GETPOST('frstrecur'):$account->frstrecur).'"></td></tr>'; print '<td colspan="4"><input size="30" type="text" name="frstrecur" value="'.(GETPOST('frstrecur')?GETPOST('frstrecur'):$account->frstrecur).'"></td></tr>';
@ -640,9 +646,11 @@ if ($socid && $action == 'create' && $user->rights->societe->creer)
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// RUM
print '<tr><td width="35%">'.$langs->trans("RUM").'</td>'; print '<tr><td width="35%">'.$langs->trans("RUM").'</td>';
print '<td colspan="4">'.$langs->trans("RUMWillBeGenerated").'</td></tr>'; print '<td colspan="4">'.$langs->trans("RUMWillBeGenerated").'</td></tr>';
// FRSTRECUR
print '<tr><td width="35%">'.$langs->trans("WithdrawMode").'</td>'; print '<tr><td width="35%">'.$langs->trans("WithdrawMode").'</td>';
print '<td colspan="4"><input size="30" type="text" name="frstrecur" value="'.(isset($_POST['frstrecur'])?GETPOST('frstrecur'):'FRST').'"></td></tr>'; print '<td colspan="4"><input size="30" type="text" name="frstrecur" value="'.(isset($_POST['frstrecur'])?GETPOST('frstrecur'):'FRST').'"></td></tr>';