Fix debug module expense report

This commit is contained in:
Laurent Destailleur 2015-08-28 20:11:16 +02:00
parent 4377a2d013
commit 47ea834516
13 changed files with 186 additions and 96 deletions

View File

@ -371,23 +371,32 @@ if ($id > 0 || ! empty($ref))
/*
* Boutons actions
* Buttons actions
*/
if ($action != 'delete') {
if ($action != 'delete')
{
print '<div class="tabsAction">';
if ($object->type != 2 && $object->rappro) { // If not cash account and can be reconciliate
if ($user->rights->banque->consolidate) {
if ($object->type != 2 && $object->rappro)
{
// If not cash account and can be reconciliate
if ($user->rights->banque->consolidate)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/rappro.php?account='.$object->id.($vline?'&amp;vline='.$vline:'').'">'.$langs->trans("Conciliate").'</a>';
} else {
}
else
{
print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("Conciliate").'</a>';
}
}
if ($action != 'addline') {
if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) {
if (empty($conf->accounting->enabled)) {
if ($action != 'addline')
{
if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT))
{
if (empty($conf->accounting->enabled))
{
if ($user->rights->banque->modifier) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=addline&amp;id='.$object->id.'&amp;page='.$page.($vline?'&amp;vline='.$vline:'').'">'.$langs->trans("AddBankRecord").'</a>';
} else {
@ -500,12 +509,13 @@ if ($id > 0 || ! empty($ref))
print '<br>';
}
print '<table class="noborder" width="100%">';
/*
* Affiche tableau des transactions bancaires
* Show list of bank transactions
*/
print '<table class="noborder" width="100%">';
// Ligne de titre tableau des ecritures
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Date").'</td>';
@ -654,7 +664,8 @@ if ($id > 0 || ! empty($ref))
$label=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$objp->fk_type;
if ($objp->fk_type == 'SOLD') $label='&nbsp;';
if ($objp->fk_type == 'CHQ' && $objp->fk_bordereau > 0) {
if ($objp->fk_type == 'CHQ' && $objp->fk_bordereau > 0)
{
dol_include_once('/compta/paiement/cheque/class/remisecheque.class.php');
$bordereaustatic = new RemiseCheque($db);
$bordereaustatic->id = $objp->fk_bordereau;
@ -678,6 +689,7 @@ if ($id > 0 || ! empty($ref))
{
print dol_trunc($objp->label,60);
}
// Add links after description
$links = $object->get_url($objp->rowid);
foreach($links as $key=>$val)

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
*
@ -43,6 +43,7 @@ if (! $user->rights->banque->consolidate) accessforbidden();
$action=GETPOST('action', 'alpha');
$id=GETPOST('account', 'int');
/*
* Actions
*/
@ -220,7 +221,7 @@ if ($resql)
print "<input type=\"hidden\" name=\"action\" value=\"rappro\">";
print "<input type=\"hidden\" name=\"account\" value=\"".$acct->id."\">";
print $langs->trans("InputReceiptNumber").': ';
print '<strong>'.$langs->trans("InputReceiptNumber").'</strong>: ';
print '<input class="flat" name="num_releve" type="text" value="'.(GETPOST('num_releve')?GETPOST('num_releve'):$objp->num_releve).'" size="10">';
print '<br>';
if ($options)

View File

@ -94,10 +94,10 @@ $banklinestatic=new AccountLine($db);
// Load account
$acct = new Account($db);
$object = new Account($db);
if ($id > 0 || ! empty($ref))
{
$acct->fetch($id, $ref);
$object->fetch($id, $ref);
}
if (empty($num))
@ -107,7 +107,7 @@ if (empty($num))
*/
$sql = "SELECT DISTINCT(b.num_releve) as numr";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= " WHERE b.fk_account = ".$acct->id;
$sql.= " WHERE b.fk_account = ".$object->id;
$sql.= " ORDER BY numr DESC";
$sql.= $db->plimit($conf->liste_limit+1,$offset);
@ -120,7 +120,7 @@ if (empty($num))
$i = 0;
// Onglets
$head=bank_prepare_head($acct);
$head=bank_prepare_head($object);
dol_fiche_head($head,'statement',$langs->trans("FinancialAccount"),0,'account');
print '<table class="border" width="100%">';
@ -130,19 +130,36 @@ if (empty($num))
// Ref
print '<tr><td width="25%">'.$langs->trans("Ref").'</td>';
print '<td colspan="3">';
print $form->showrefnav($acct, 'ref', $linkback, 1, 'ref');
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref');
print '</td></tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td>';
print '<td colspan="3">'.$acct->label.'</td></tr>';
print '<td colspan="3">'.$object->label.'</td></tr>';
print '</table>';
dol_fiche_end();
print '<div class="tabsAction">';
if ($object->type != 2 && $object->rappro)
{
// If not cash account and can be reconciliate
if ($user->rights->banque->consolidate)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/rappro.php?account='.$object->id.($vline?'&amp;vline='.$vline:'').'">'.$langs->trans("Conciliate").'</a>';
}
else
{
print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("Conciliate").'</a>';
}
}
print_barre_liste('', $page, $_SERVER["PHP_SELF"], "&account=".$acct->id, $sortfield, $sortorder,'',$numrows);
print '</div>';
print_barre_liste('', $page, $_SERVER["PHP_SELF"], "&account=".$object->id, $sortfield, $sortorder,'',$numrows);
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
@ -164,13 +181,13 @@ if (empty($num))
}
else
{
print '<tr '.$bc[$var].'><td><a href="releve.php?num='.$objp->numr.'&amp;account='.$acct->id.'">'.$objp->numr.'</a></td>';
print '<tr '.$bc[$var].'><td><a href="releve.php?num='.$objp->numr.'&amp;account='.$object->id.'">'.$objp->numr.'</a></td>';
// Calculate start amount
$sql = "SELECT sum(b.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= " WHERE b.num_releve < '".$db->escape($objp->numr)."'";
$sql.= " AND b.fk_account = ".$acct->id;
$sql.= " AND b.fk_account = ".$object->id;
$resql=$db->query($sql);
if ($resql)
{
@ -184,7 +201,7 @@ if (empty($num))
$sql = "SELECT sum(b.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= " WHERE b.num_releve = '".$db->escape($objp->numr)."'";
$sql.= " AND b.fk_account = ".$acct->id;
$sql.= " AND b.fk_account = ".$object->id;
$resql=$db->query($sql);
if ($resql)
{
@ -222,7 +239,7 @@ else
$sql = "SELECT DISTINCT(b.num_releve) as num";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= " WHERE b.num_releve < '".$db->escape($num)."'";
$sql.= " AND b.fk_account = ".$acct->id;
$sql.= " AND b.fk_account = ".$object->id;
$sql.= " ORDER BY b.num_releve DESC";
dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG);
@ -244,7 +261,7 @@ else
$sql = "SELECT DISTINCT(b.num_releve) as num";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= " WHERE b.num_releve > '".$db->escape($num)."'";
$sql.= " AND b.fk_account = ".$acct->id;
$sql.= " AND b.fk_account = ".$object->id;
$sql.= " ORDER BY b.num_releve ASC";
dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG);
@ -265,10 +282,10 @@ else
$found=true;
}
$mesprevnext ="<a href=\"releve.php?rel=prev&amp;num=$num&amp;ve=$ve&amp;account=$acct->id\">".img_previous()."</a> &nbsp;";
$mesprevnext ="<a href=\"releve.php?rel=prev&amp;num=$num&amp;ve=$ve&amp;account=$object->id\">".img_previous()."</a> &nbsp;";
$mesprevnext.= $langs->trans("AccountStatement")." $num";
$mesprevnext.=" &nbsp; <a href=\"releve.php?rel=next&amp;num=$num&amp;ve=$ve&amp;account=$acct->id\">".img_next()."</a>";
print_fiche_titre($langs->trans("AccountStatement").' '.$num.', '.$langs->trans("BankAccount").' : '.$acct->getNomUrl(0),$mesprevnext, 'title_bank.png');
$mesprevnext.=" &nbsp; <a href=\"releve.php?rel=next&amp;num=$num&amp;ve=$ve&amp;account=$object->id\">".img_next()."</a>";
print_fiche_titre($langs->trans("AccountStatement").' '.$num.', '.$langs->trans("BankAccount").' : '.$object->getNomUrl(0),$mesprevnext, 'title_bank.png');
print '<br>';
print "<form method=\"post\" action=\"releve.php\">";
@ -291,7 +308,7 @@ else
$sql = "SELECT sum(b.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= " WHERE b.num_releve < '".$db->escape($num)."'";
$sql.= " AND b.fk_account = ".$acct->id;
$sql.= " AND b.fk_account = ".$object->id;
$resql=$db->query($sql);
if ($resql)
@ -309,7 +326,7 @@ else
$sql.= ", ".MAIN_DB_PREFIX."bank as b";
$sql.= " WHERE b.num_releve='".$db->escape($num)."'";
if (!isset($num)) $sql.= " OR b.num_releve is null";
$sql.= " AND b.fk_account = ".$acct->id;
$sql.= " AND b.fk_account = ".$object->id;
$sql.= " AND b.fk_account = ba.rowid";
$sql.= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day
@ -321,7 +338,7 @@ else
$i = 0;
// Ligne Solde debut releve
print "<tr><td colspan=\"4\"><a href=\"releve.php?num=$num&amp;ve=1&amp;rel=$rel&amp;account=".$acct->id."\">&nbsp;</a></td>";
print "<tr><td colspan=\"4\"><a href=\"releve.php?num=$num&amp;ve=1&amp;rel=$rel&amp;account=".$object->id."\">&nbsp;</a></td>";
print "<td align=\"right\" colspan=\"2\"><b>".$langs->trans("InitialBankBalance")." :</b></td><td align=\"right\"><b>".price($total)."</b></td><td>&nbsp;</td></tr>\n";
while ($i < $numrows)
@ -337,10 +354,10 @@ else
// Date de valeur
print '<td align="center" valign="center" class="nowrap">';
print '<a href="releve.php?action=dvprev&amp;num='.$num.'&amp;account='.$acct->id.'&amp;dvid='.$objp->rowid.'">';
print '<a href="releve.php?action=dvprev&amp;num='.$num.'&amp;account='.$object->id.'&amp;dvid='.$objp->rowid.'">';
print img_previous().'</a> ';
print dol_print_date($db->jdate($objp->dv),"day") .' ';
print '<a href="releve.php?action=dvnext&amp;num='.$num.'&amp;account='.$acct->id.'&amp;dvid='.$objp->rowid.'">';
print '<a href="releve.php?action=dvnext&amp;num='.$num.'&amp;account='.$object->id.'&amp;dvid='.$objp->rowid.'">';
print img_next().'</a>';
print "</td>\n";
@ -353,7 +370,7 @@ else
print '<td class="nowrap">'.$type_label.' '.($objp->num_chq?$objp->num_chq:'').'</td>';
// Description
print '<td valign="center"><a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&amp;account='.$acct->id.'">';
print '<td valign="center"><a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&amp;account='.$object->id.'">';
$reg=array();
preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parenthese on tente recherche de traduction
if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) print $langs->trans($reg[1]);
@ -364,7 +381,7 @@ else
* Ajout les liens (societe, company...)
*/
$newline=1;
$links = $acct->get_url($objp->rowid);
$links = $object->get_url($objp->rowid);
foreach($links as $key=>$val)
{
if (! $newline) print ' - ';
@ -500,7 +517,7 @@ else
if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
{
print "<td align=\"center\"><a href=\"ligne.php?rowid=$objp->rowid&amp;account=".$acct->id."\">";
print "<td align=\"center\"><a href=\"ligne.php?rowid=$objp->rowid&amp;account=".$object->id."\">";
print img_edit();
print "</a></td>";
}
@ -522,6 +539,7 @@ else
print "</table></form>\n";
}
$db->close();
llxFooter();
$db->close();

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
*
@ -166,7 +166,8 @@ if ($action == 'update' && $user->rights->expensereport->creer)
$object->fk_c_paiement = GETPOST('fk_c_paiement','int');
$object->note_public = GETPOST('note_public');
$object->note_private = GETPOST('note_private');
$object->fk_user_modif = $user->id;
$result = $object->update($user);
if ($result > 0)
{
@ -1318,30 +1319,35 @@ else
{
dol_fiche_head($head, 'card', $langs->trans("TripCard"), 0, 'trip');
if ($action == 'save'):
$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$id,$langs->trans("SaveTrip"),$langs->trans("ConfirmSaveTrip"),"confirm_validate","","",1);
if ($ret == 'html') print '<br>';
endif;
if ($action == 'save')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$id,$langs->trans("SaveTrip"),$langs->trans("ConfirmSaveTrip"),"confirm_validate","","",1);
if ($ret == 'html') print '<br>';
}
if ($action == 'save_from_refuse'):
$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$id,$langs->trans("SaveTrip"),$langs->trans("ConfirmSaveTrip"),"confirm_save_from_refuse","","",1);
if ($ret == 'html') print '<br>';
endif;
if ($action == 'save_from_refuse')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$id,$langs->trans("SaveTrip"),$langs->trans("ConfirmSaveTrip"),"confirm_save_from_refuse","","",1);
if ($ret == 'html') print '<br>';
}
if ($action == 'delete'):
$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$id,$langs->trans("DeleteTrip"),$langs->trans("ConfirmDeleteTrip"),"confirm_delete","","",1);
if ($ret == 'html') print '<br>';
endif;
if ($action == 'delete')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$id,$langs->trans("DeleteTrip"),$langs->trans("ConfirmDeleteTrip"),"confirm_delete","","",1);
if ($ret == 'html') print '<br>';
}
if ($action == 'validate'):
$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$id,$langs->trans("ValideTrip"),$langs->trans("ConfirmValideTrip"),"confirm_approve","","",1);
if ($ret == 'html') print '<br>';
endif;
if ($action == 'validate')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$id,$langs->trans("ValideTrip"),$langs->trans("ConfirmValideTrip"),"confirm_approve","","",1);
if ($ret == 'html') print '<br>';
}
if ($action == 'paid'):
$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$id,$langs->trans("PaidTrip"),$langs->trans("ConfirmPaidTrip"),"confirm_paid","","",1);
if ($ret == 'html') print '<br>';
endif;
if ($action == 'paid')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$id,$langs->trans("PaidTrip"),$langs->trans("ConfirmPaidTrip"),"confirm_paid","","",1);
if ($ret == 'html') print '<br>';
}
if ($action == 'cancel')
{
@ -1968,7 +1974,7 @@ if ($action != 'create' && $action != 'edit')
* ET user à droit de "to_paid"
* Afficher : "Annuler" / "Payer" / "Supprimer"
*/
if ($user->rights->expensereport->to_paid && $object->fk_statut == 5)
if ($user->rights->expensereport->to_paid && ! empty($conf->banque->enabled) && $object->fk_statut == 5)
{
// Pay
if ($remaintopay == 0)
@ -1979,8 +1985,11 @@ if ($action != 'create' && $action != 'edit')
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/expensereport/payment/payment.php?id=' . $object->id . '&amp;action=create">' . $langs->trans('DoPayment') . '</a></div>';
}
if (round($remaintopay) == 0 && $object->paid == 0)
}
if (($user->rights->expensereport->to_paid || empty($conf->banque->enabled)) && $object->fk_statut == 5)
{
if ((round($remaintopay) == 0 || empty($conf->banque->enabled)) && $object->paid == 0)
{
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id='.$object->id.'&action=set_paid">'.$langs->trans("ClassifyPaid")."</a></div>";
}

View File

@ -61,14 +61,16 @@ class ExpenseReport extends CommonObject
var $code_paiement;
var $code_statut;
/*
ACTIONS
*/
// ACTIONS
// Enregistrement
// Create
var $date_create;
var $fk_user_author;
// Update
var $date_modif;
var $fk_user_modif;
// Refus
var $date_refuse;
var $detail_refuse;
@ -141,6 +143,7 @@ class ExpenseReport extends CommonObject
$sql.= ",date_create";
$sql.= ",fk_user_author";
$sql.= ",fk_user_validator";
$sql.= ",fk_user_modif";
$sql.= ",fk_statut";
$sql.= ",fk_c_paiement";
$sql.= ",paid";
@ -156,6 +159,7 @@ class ExpenseReport extends CommonObject
$sql.= ", '".$this->db->idate($now)."'";
$sql.= ", ".($user->id > 0 ? $user->id:"null");
$sql.= ", ".($this->fk_user_validator > 0 ? $this->fk_user_validator:"null");
$sql.= ", ".($this->fk_user_modif > 0 ? $this->fk_user_modif:"null");
$sql.= ", ".($this->fk_statut > 1 ? $this->fk_statut:0);
$sql.= ", ".($this->modepaymentid?$this->modepaymentid:"null");
$sql.= ", 0";
@ -240,6 +244,7 @@ class ExpenseReport extends CommonObject
$sql.= " , fk_user_author = ".($user->id > 0 ? "'".$user->id."'":"null");
$sql.= " , fk_user_validator = ".($this->fk_user_validator > 0 ? $this->fk_user_validator:"null");
$sql.= " , fk_user_valid = ".($this->fk_user_valid > 0 ? $this->fk_user_valid:"null");
$sql.= " , fk_user_modif = ".($this->fk_user_modif > 0 ? $this->fk_user_modif:"null");
$sql.= " , fk_statut = ".($this->fk_statut >= 0 ? $this->fk_statut:'0');
$sql.= " , fk_c_paiement = ".($this->fk_c_paiement > 0 ? $this->fk_c_paiement:"null");
$sql.= " , note_public = ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"''");
@ -275,9 +280,10 @@ class ExpenseReport extends CommonObject
$sql.= " d.detail_refuse, d.detail_cancel, d.fk_user_refuse, d.fk_user_cancel,"; // ACTIONS
$sql.= " d.date_refuse, d.date_cancel,"; // ACTIONS
$sql.= " d.total_ht, d.total_ttc, d.total_tva,"; // TOTAUX (int)
$sql.= " d.date_debut, d.date_fin, d.date_create, d.date_valid, d.date_approve,"; // DATES (datetime)
$sql.= " d.fk_user_author, d.fk_user_validator, d.fk_statut as status, d.fk_c_paiement,";
$sql.= " d.date_debut, d.date_fin, d.date_create, d.tms as date_modif, d.date_valid, d.date_approve,"; // DATES (datetime)
$sql.= " d.fk_user_author, d.fk_user_modif, d.fk_user_validator,";
$sql.= " d.fk_user_valid, d.fk_user_approve,";
$sql.= " d.fk_statut as status, d.fk_c_paiement,";
$sql.= " dp.libelle as libelle_paiement, dp.code as code_paiement"; // INNER JOIN paiement
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as d LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as dp ON d.fk_c_paiement = dp.id";
if ($ref) $sql.= " WHERE d.ref = '".$this->db->escape($ref)."'";
@ -306,16 +312,18 @@ class ExpenseReport extends CommonObject
$this->date_valid = $this->db->jdate($obj->date_valid);
$this->date_approve = $this->db->jdate($obj->date_approve);
$this->date_create = $this->db->jdate($obj->date_create);
$this->date_modif = $this->db->jdate($obj->date_modif);
$this->date_refuse = $this->db->jdate($obj->date_refuse);
$this->date_cancel = $this->db->jdate($obj->date_cancel);
$this->fk_user_author = $obj->fk_user_author;
$this->fk_user_modif = $obj->fk_user_modif;
$this->fk_user_validator = $obj->fk_user_validator;
$this->fk_user_valid = $obj->fk_user_valid;
$this->fk_user_refuse = $obj->fk_user_refuse;
$this->fk_user_cancel = $obj->fk_user_cancel;
$this->fk_user_approve = $obj->fk_user_approve;
$user_author = new User($this->db);
if ($this->fk_user_author > 0) $user_author->fetch($this->fk_user_author);
@ -496,7 +504,13 @@ class ExpenseReport extends CommonObject
$muser->fetch($obj->fk_user_modification);
$this->user_modification = $muser;
}
if ($obj->fk_user_approve)
{
$auser = new User($this->db);
$auser->fetch($obj->fk_user_approve);
$this->user_approve = $auser;
}
}
$this->db->free($resql);
}
@ -869,20 +883,21 @@ class ExpenseReport extends CommonObject
if ($this->fk_statut != 2)
{
$now = dol_now();
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET ref = '".$this->ref."', fk_statut = 2, fk_user_valid = ".$fuser->id.",";
$sql.= " SET ref = '".$this->ref."', fk_statut = 2, fk_user_valid = ".$fuser->id.", date_valid='".$this->db->idate($now)."',";
$sql.= " ref_number_int = ".$ref_number_int;
$sql.= ' WHERE rowid = '.$this->id;
dol_syslog(get_class($this)."::set_save sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql))
$resql=$this->db->query($sql);
if ($resql)
{
return 1;
}
else
{
$this->error=$this->db->error();
$this->error=$this->db->lasterror();
return -1;
}
}

View File

@ -469,7 +469,7 @@ class PaymentExpenseReport extends CommonObject
*/
function addPaymentToBank($user,$mode,$label,$accountid,$emetteur_nom,$emetteur_banque)
{
global $conf;
global $langs,$conf;
$error=0;
@ -482,7 +482,7 @@ class PaymentExpenseReport extends CommonObject
$total=$this->total;
if ($mode == 'payment_expensereport') $amount=$total;
// Insert payment into llx_bank
$bank_line_id = $acc->addline(
$this->datepaid,
@ -519,6 +519,32 @@ class PaymentExpenseReport extends CommonObject
dol_print_error($this->db);
}
}
// Add link 'user' in bank_url between user and bank transaction
if (! $error)
{
foreach ($this->amounts as $key => $value) // We should have always same third party but we loop in case of.
{
if ($mode == 'payment_expensereport')
{
$euser = new User($this->db);
$euser->fetch($key);
$result=$acc->add_url_line(
$bank_line_id,
$euser->id,
DOL_URL_ROOT.'/user/card.php?id=',
$euser->getFullName($langs),
'user'
);
if ($result <= 0)
{
$this->error=$this->db->lasterror();
dol_syslog(get_class($this).'::addPaymentToBank '.$this->error);
$error++;
}
}
}
}
}
else
{

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -59,6 +59,6 @@ if ($id)
print '</div>';
}
$db->close();
llxFooter();
$db->close();

View File

@ -157,19 +157,19 @@ print $form->showrefnav($payment,'id','',1,'rowid','id');
print '</td></tr>';
// Date
print '<tr><td valign="top">'.$langs->trans('Date').'</td><td colspan="3">'.dol_print_date($payment->datep,'day').'</td></tr>';
print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">'.dol_print_date($payment->datep,'day').'</td></tr>';
// Mode
print '<tr><td valign="top">'.$langs->trans('Mode').'</td><td colspan="3">'.$langs->trans("PaymentType".$payment->type_code).'</td></tr>';
print '<tr><td>'.$langs->trans('Mode').'</td><td colspan="3">'.$langs->trans("PaymentType".$payment->type_code).'</td></tr>';
// Number
print '<tr><td valign="top">'.$langs->trans('Number').'</td><td colspan="3">'.$payment->num_payment.'</td></tr>';
print '<tr><td>'.$langs->trans('Numero').'</td><td colspan="3">'.$payment->num_payment.'</td></tr>';
// Amount
print '<tr><td valign="top">'.$langs->trans('Amount').'</td><td colspan="3">'.price($payment->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
print '<tr><td>'.$langs->trans('Amount').'</td><td colspan="3">'.price($payment->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
// Note
print '<tr><td valign="top">'.$langs->trans('Note').'</td><td colspan="3">'.nl2br($payment->note).'</td></tr>';
print '<tr><td class="tdtop">'.$langs->trans('Note').'</td><td colspan="3">'.nl2br($payment->note).'</td></tr>';
// Bank account
if (! empty($conf->banque->enabled))

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
/* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -31,6 +32,7 @@ $langs->load("bills");
$chid=GETPOST("id");
$action=GETPOST('action');
$amounts = array();
$accountid=GETPOST('accountid','int');
// Security check
$socid=0;
@ -67,7 +69,7 @@ if ($action == 'add_payment')
$mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("Date"));
$error++;
}
if (! empty($conf->banque->enabled) && ! $_POST["accountid"] > 0)
if (! empty($conf->banque->enabled) && ! $accountid > 0)
{
$mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("AccountToCredit"));
$error++;
@ -76,6 +78,7 @@ if ($action == 'add_payment')
if (! $error)
{
$paymentid = 0;
$total = 0;
// Read possible payments
foreach ($_POST as $key => $value)
@ -84,6 +87,7 @@ if ($action == 'add_payment')
{
$other_chid = substr($key,7);
$amounts[$other_chid] = price2num($_POST[$key]);
$total += price2num($_POST[$key]);
}
}
@ -102,6 +106,7 @@ if ($action == 'add_payment')
$payment->chid = $chid;
$payment->datepaid = $datepaid;
$payment->amounts = $amounts; // Tableau de montant
$payment->total = $total;
$payment->fk_typepayment = $_POST["fk_typepayment"];
$payment->num_payment = $_POST["num_payment"];
$payment->note = $_POST["note"];
@ -118,7 +123,7 @@ if ($action == 'add_payment')
if (! $error)
{
$result=$payment->addPaymentToBank($user,'payment_expensereport','(ExpenseReportPayment)',$_POST['accountid'],'','');
$result=$payment->addPaymentToBank($user,'payment_expensereport','(ExpenseReportPayment)',$accountid,'','');
if (! $result > 0)
{
$errmsg=$payment->error;

View File

@ -22,6 +22,7 @@
UPDATE llx_facture_fourn set ref=rowid where ref IS NULL;
ALTER TABLE llx_facture_fourn MODIFY COLUMN ref varchar(255) NOT NULL;
ALTER TABLE llx_bank_url MODIFY COLUMN type varchar(24) NOT NULL;
-- IVORY COST (id country=21)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values (211, 21, '0','0',0,0,0,0,'IVA Rate 0',1);

View File

@ -1,6 +1,6 @@
-- ===================================================================
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2007 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2007-2015 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- 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
@ -24,5 +24,5 @@ create table llx_bank_url
url_id integer,
url varchar(255),
label varchar(255),
type varchar(20) NOT NULL
type varchar(24) NOT NULL
)ENGINE=innodb;

View File

@ -51,6 +51,9 @@ CREATE TABLE llx_expensereport (
detail_cancel varchar(255) DEFAULT NULL,
integration_compta integer DEFAULT NULL, -- not used
fk_bank_account integer DEFAULT NULL,
model_pdf varchar(50) DEFAULT NULL
model_pdf varchar(50) DEFAULT NULL,
import_key varchar(14),
extraparams varchar(255) -- for other parameters with json format
) ENGINE=innodb;

View File

@ -78,11 +78,11 @@ create table llx_facture
fk_incoterms integer, -- for incoterms
location_incoterms varchar(255), -- for incoterms
import_key varchar(14),
extraparams varchar(255), -- for stock other parameters with json format
situation_cycle_ref smallint, -- situation cycle reference
situation_counter smallint, -- situation counter
situation_final smallint -- is the situation final ?
situation_final smallint, -- is the situation final ?
import_key varchar(14),
extraparams varchar(255) -- for other parameters with json format
)ENGINE=innodb;