diff --git a/htdocs/compta/bank/account.class.php b/htdocs/compta/bank/account.class.php index 60323fd8b58..e799e7b96c4 100644 --- a/htdocs/compta/bank/account.class.php +++ b/htdocs/compta/bank/account.class.php @@ -55,7 +55,9 @@ class Account var $adresse_proprio; var $type_lib=array(); - + /** + * Constructeur + */ function Account($DB, $rowid=0) { global $langs; @@ -327,7 +329,8 @@ class Account } /* - * \brief Charge en memoire depuis la base le compte + * \brief Charge en memoire depuis la base le compte + * \param id Id du compte à récupérer */ function fetch($id) { @@ -531,4 +534,113 @@ class Account } + +class AccountLine +{ + var $db; + + /** + * Constructeur + */ + function AccountLine($DB, $rowid=0) + { + global $langs; + + $this->db = $DB; + $this->rowid = $rowid; + + return 1; + } + + /** + * \brief Charge en memoire depuis la base, une ecriture sur le compte + * \param id Id de la ligne écriture à récupérer + */ + function fetch($rowid) + { + $sql = "SELECT datec, datev, dateo, amount, label, fk_user_author, fk_user_rappro,"; + $sql.= " fk_type, num_releve, num_chq, rappro, note"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank"; + $sql.= " WHERE rowid = ".$rowid; + + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + + $this->rowid = $rowid; + $this->ref = $rowid; + + $this->datec = $obj->datec; + $this->datev = $obj->datev; + $this->dateo = $obj->dateo; + $this->amount = $obj->amount; + $this->label = $obj->label; + $this->note = $obj->note; + + $this->fk_user_author = $obj->fk_user_author; + $this->fk_user_rappro = $obj->fk_user_rappro; + + $this->fk_type = $obj->fk_type; + $this->num_releve = $obj->num_releve; + $this->num_chq = $obj->num_chq; + + $this->rappro = $obj->rappro; + } + $this->db->free($result); + } + else + { + dolibarr_print_error($this->db); + } + } + + + /** + * \brief Charge les informations d'ordre info dans l'objet facture + * \param id Id de la facture a charger + */ + function info($rowid) + { + $sql = 'SELECT b.rowid, '.$this->db->pdate('datec').' as datec,'; + $sql.= ' fk_user_author, fk_user_rappro'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'bank as b'; + $sql.= ' WHERE b.rowid = '.$rowid; + + $result=$this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + + if ($obj->fk_user_author) + { + $cuser = new User($this->db, $obj->fk_user_author); + $cuser->fetch(); + $this->user_creation = $cuser; + } + if ($obj->fk_user_rappro) + { + $ruser = new User($this->db, $obj->fk_user_rappro); + $ruser->fetch(); + $this->user_rappro = $ruser; + } + + $this->date_creation = $obj->datec; + //$this->date_rappro = $obj->daterappro; // \todo pas encore gérée + } + $this->db->free($result); + } + else + { + dolibarr_print_error($this->db); + } + } + +} + ?> diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 4be51a02ba8..93a6661d4a4 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -32,7 +32,7 @@ require("./pre.inc.php"); if (!$user->rights->banque->lire) - accessforbidden(); + accessforbidden(); $account=isset($_GET["account"])?$_GET["account"]:$_POST["account"]; @@ -41,52 +41,46 @@ $action=isset($_GET["action"])?$_GET["action"]:$_POST["action"]; $page=isset($_GET["page"])?$_GET["page"]:0; if ($_POST["action"] == 'add' && $account && ! isset($_POST["cancel"])) -{ - - if ($_POST["credit"] > 0) +{ + if ($_POST["credit"] > 0) { - $amount = $_POST["credit"]; + $amount = $_POST["credit"]; } - else + else { - $amount = - $_POST["debit"]; + $amount = - $_POST["debit"]; } - - $dateop = $_POST["dateoy"].$_POST["dateo"]; - $operation=$_POST["operation"]; - $label=$_POST["label"]; - $operation=$_POST["operation"]; - $num_chq=$_POST["num_chq"]; - $cat1=$_POST["cat1"]; - $acct=new Account($db,$account); + $dateop = $_POST["dateoy"].$_POST["dateo"]; + $operation=$_POST["operation"]; + $label=$_POST["label"]; + $operation=$_POST["operation"]; + $num_chq=$_POST["num_chq"]; + $cat1=$_POST["cat1"]; - $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, $cat1); + $acct=new Account($db,$account); - if ($insertid) + $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, $cat1); + + if ($insertid) { Header("Location: account.php?account=" . $account); } - else + else { dolibarr_print_error($db); } } if ($_GET["action"] == 'del' && $account && $user->rights->banque->modifier) { - $acct=new Account($db,$account); - $acct->deleteline($_GET["rowid"]); + $acct=new Account($db,$account); + $acct->deleteline($_GET["rowid"]); } -/*********************************************************************************** - * - * - */ llxHeader(); - if ($account > 0) { if ($vline) @@ -177,21 +171,21 @@ if ($account > 0) $limitsql = $nbline; } - /* - * Formulaire de recherche - * - */ - $mesg=''; - - $nbpage=floor($total_lines/$viewline)+($total_lines % $viewline > 0?1:0); // Nombre de page total - if ($limitsql > $viewline) + /** + * Formulaire de recherche + * + */ + $mesg=''; + + $nbpage=floor($total_lines/$viewline)+($total_lines % $viewline > 0?1:0); // Nombre de page total + if ($limitsql > $viewline) { - $mesg.=''.img_previous().''; + $mesg.=''.img_previous().''; } - $mesg.= ' Page '.($nbpage-$page).'/'.$nbpage.' '; - if ($total_lines > $limitsql ) + $mesg.= ' Page '.($nbpage-$page).'/'.$nbpage.' '; + if ($total_lines > $limitsql ) { - $mesg.= ''.img_next().''; + $mesg.= ''.img_next().''; } @@ -249,7 +243,7 @@ if ($account > 0) print " \n"; } - // Ligne de titre + // Ligne de titre tableau des acritures print ''; print ''.$langs->trans("Date").''.$langs->trans("Value").''.$langs->trans("Type").''.$langs->trans("Description").''; print ''.$langs->trans("Debit").''.$langs->trans("Credit").''; @@ -279,16 +273,11 @@ if ($account > 0) */ $sql = "SELECT b.rowid,".$db->pdate("b.dateo")." as do,".$db->pdate("b.datev")." as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type"; - $sql .= " FROM ".MAIN_DB_PREFIX."bank as b "; - $sql .= " WHERE fk_account=".$acct->id; - - if ($req_debit) - { - $sql .= " AND b.amount = -".$req_debit; - } - - $sql .= $sql_rech; - + $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql.= " WHERE fk_account=".$acct->id; + if ($req_debit) $sql .= " AND b.amount = -".$req_debit; + if ($req_credit) $sql .= " AND b.amount = ".$req_credit; + $sql.= $sql_rech; if ($vue) { if ($vue == 'credit') @@ -300,9 +289,8 @@ if ($account > 0) $sql .= " AND b.amount < 0 "; } } - - $sql .= " ORDER BY b.datev ASC"; - $sql .= $db->plimit($limitsql, 0); + $sql.= " ORDER BY b.datev ASC"; + $sql.= $db->plimit($limitsql, 0); $result = $db->query($sql); if ($result) @@ -405,9 +393,16 @@ function _print_lines($db,$result,$sql,$acct) { print ' - '; print ''; - // if ($links[$key]['type']=='payment') { print img_object($langs->trans('ShowPayment'),'payment').' '; } - // if ($links[$key]['type']=='company') { print img_object($langs->trans('ShowCustomer'),'company').' '; } - print $links[$key]['label'].''; + if ($links[$key]['type']=='payment') { + //print img_object($langs->trans('ShowPayment'),'payment').' '; + print $langs->trans("Payment"); + } + else if ($links[$key]['type']=='company') { + //print img_object($langs->trans('ShowCustomer'),'company').' '; + print $links[$key]['label']; + } + else print $links[$key]['label']; + print ''; } print ''; diff --git a/htdocs/compta/bank/config.php b/htdocs/compta/bank/config.php index 5af7b5decbc..1c317f63532 100644 --- a/htdocs/compta/bank/config.php +++ b/htdocs/compta/bank/config.php @@ -38,8 +38,8 @@ llxHeader(); print_titre($langs->trans("AccountSetup")); print '
'; print ''; -print ""; -print ''; +print ''; +print ''; print ''; print ''; print ''; @@ -65,7 +65,7 @@ if ($result) $objp = $db->fetch_object($result); $var=!$var; - print ""; + print ''; print ''; print ''; print ''; diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index 6b8326aedea..b1c2bb20059 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -105,7 +105,7 @@ foreach ($accounts as $key=>$type) $solde = $acc->solde(); print '"; print ''; print ''; @@ -147,7 +147,7 @@ foreach ($accounts as $key=>$type) $solde = $acc->solde(); print ""; print ''; print ''; @@ -189,7 +189,7 @@ foreach ($accounts as $key=>$type) $solde = $acc->solde(); print "'; print ''; print ''; diff --git a/htdocs/compta/bank/info.php b/htdocs/compta/bank/info.php new file mode 100644 index 00000000000..3ccc80c307e --- /dev/null +++ b/htdocs/compta/bank/info.php @@ -0,0 +1,75 @@ + + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + */ + +/** + \file htdocs/compta/bank/info.php + \ingroup banque + \brief Onglet info d'une ecriture bancaire + \version $Revision$ +*/ + +require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/paiement.class.php"); + +$langs->load("banks"); +$langs->load("companies"); + + +/* + * Visualisation de la fiche + * + */ + +llxHeader(); + +$line = new AccountLine($db); +$line->fetch($_GET["rowid"], $user); +$line->info($_GET["rowid"]); + + +$h=0; + +$head[$h][0] = DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$_GET["rowid"]; +$head[$h][1] = $langs->trans("Card"); +$h++; + +$head[$h][0] = DOL_URL_ROOT.'/compta/bank/info.php?rowid='.$_GET["rowid"]; +$head[$h][1] = $langs->trans("Info"); +$hselected = $h; +$h++; + + +dolibarr_fiche_head($head, $hselected, $langs->trans("LineRecord").": ".$line->ref); + +print '
'.$langs->trans("Ref")."".$langs->trans("Label")."".$langs->trans("Type")."".$langs->trans("Bank").'
'.$langs->trans("Ref")."".$langs->trans("Type")."".$langs->trans("Bank").''.$langs->trans("AccountIdShort").''.$langs->trans("Conciliable").''.$langs->trans("Status").'
$objp->rowidrowid\">$objp->label
'.img_object($langs->trans("ShowAccount"),'account').' '.$objp->label.''.$account->type_lib[$objp->type].''.$objp->bank.' '.$objp->number.' '.yn($objp->rappro).'
'; - print ''.$acc->label.''; + print ''.img_object($langs->trans("ShowAccount"),'account').' '.$acc->label.''; print ''.$acc->bank."$acc->number'.yn($acc->rappro).''.$acc->status[$acc->clos].'
"; - print ''.$acc->label.''; + print ''.img_object($langs->trans("ShowAccount"),'account').' '.$acc->label.''; print "$acc->bank$acc->number'.yn($acc->rappro).''.$acc->status[$acc->clos].'
"; - print ''.$acc->label.''; + print ''.img_object($langs->trans("ShowAccount"),'account').' '.$acc->label.''; print ''.$acc->bank.'  
'; +dolibarr_print_object_info($line); +print '
'; + +print ''; + +// Juste pour éviter bug IE qui réorganise mal div précédents si celui-ci absent +print '
'; +print '
'; + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index 535cb1f369e..2951fc2c320 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -180,6 +180,10 @@ $head[$h][1] = $langs->trans('Card'); $hselected=$h; $h++; +$head[$h][0] = DOL_URL_ROOT.'/compta/bank/info.php?rowid='.$_GET["rowid"]; +$head[$h][1] = $langs->trans("Info"); +$h++; + dolibarr_fiche_head($head, $hselected, $langs->trans('LineRecord').': '.$_GET["rowid"]); @@ -329,9 +333,16 @@ if ($result) { if ($key) print '
'; print ''; - if ($links[$key]['type']=='payment') { print img_object($langs->trans('ShowPayment'),'payment').' '; } - if ($links[$key]['type']=='company') { print img_object($langs->trans('ShowCustomer'),'company').' '; } - print $links[$key]['label'].''; + if ($links[$key]['type']=='payment') { + print img_object($langs->trans('ShowPayment'),'payment').' '; + print $langs->trans("Payment"); + } + else if ($links[$key]['type']=='company') { + print img_object($langs->trans('ShowCustomer'),'company').' '; + print $links[$key]['label']; + } + else print $links[$key]['label']; + print ''; } print ' '; } @@ -419,8 +430,9 @@ print ""; print ""; $sql = "SELECT c.label, c.rowid"; -$sql .= " FROM ".MAIN_DB_PREFIX."bank_class as a, ".MAIN_DB_PREFIX."bank_categ as c WHERE a.lineid=$rowid AND a.fk_categ = c.rowid "; -$sql .= " ORDER BY c.label"; +$sql.= " FROM ".MAIN_DB_PREFIX."bank_class as a, ".MAIN_DB_PREFIX."bank_categ as c"; +$sql.= " WHERE a.lineid=".$rowid." AND a.fk_categ = c.rowid"; +$sql.= " ORDER BY c.label"; $result = $db->query($sql); if ($result) { diff --git a/htdocs/compta/paiement/fiche.php b/htdocs/compta/paiement/fiche.php index 4a6e426f14f..1d8170cc7b2 100644 --- a/htdocs/compta/paiement/fiche.php +++ b/htdocs/compta/paiement/fiche.php @@ -79,30 +79,32 @@ if ($_POST['action'] == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user- } -/* - * - * - */ - -llxHeader(); - - -print '
'; -print ''.$langs->trans('Payment').''; -print ''.$langs->trans('Info').''; -print '
'; - -print '
'; - /* * Visualisation de la fiche */ +llxHeader(); + $paiement = new Paiement($db); $paiement->fetch($_GET['id']); + $html = new Form($db); +$h=0; + +$head[$h][0] = DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$_GET["id"]; +$head[$h][1] = $langs->trans("Card"); +$hselected = $h; +$h++; + +$head[$h][0] = DOL_URL_ROOT.'/compta/paiement/info.php?id='.$_GET["id"]; +$head[$h][1] = $langs->trans("Info"); +$h++; + + +dolibarr_fiche_head($head, $hselected, $langs->trans("Payment").": ".$paiement->ref); + /* * Confirmation de la suppression du paiement */ @@ -127,10 +129,12 @@ print ''.$langs->trans('Ref').''.$paie if ($paiement->bank_account) { // Si compte renseigné, on affiche libelle - print ''; $bank=new Account($db); $bank->fetch($paiement->bank_account); - print $langs->trans('BankAccount').''.$bank->label.''; + + print ''; + print ''.$langs->trans('BankAccount').''; + print ''.img_object($langs->trans("ShowAccount"),'account').' '.$bank->label.''; } print ''.$langs->trans('Date').''.dolibarr_print_date($paiement->date).''; print ''.$langs->trans('Type').''.$paiement->type_libelle.''; @@ -152,10 +156,10 @@ $sql = 'SELECT f.facnumber, f.total_ttc, pf.amount, f.rowid as facid, f.paye, f. $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf,'.MAIN_DB_PREFIX.'facture as f,'.MAIN_DB_PREFIX.'societe as s'; $sql .= ' WHERE pf.fk_facture = f.rowid AND f.fk_soc = s.idp'; $sql .= ' AND pf.fk_paiement = '.$paiement->id; - -if ($db->query($sql)) +$resql=$db->query($sql); +if ($resql) { - $num = $db->num_rows(); + $num = $db->num_rows($resql); $i = 0; $total = 0; @@ -171,7 +175,7 @@ if ($db->query($sql)) while ($i < $num) { - $objp = $db->fetch_object(); + $objp = $db->fetch_object($resql); $var=!$var; print ''; print ''.img_object($langs->trans('ShowBill'),'bill').' '; @@ -193,7 +197,7 @@ if ($db->query($sql)) $var=!$var; print "\n"; - $db->free(); + $db->free($resql); } else { diff --git a/htdocs/compta/paiement/info.php b/htdocs/compta/paiement/info.php index dcfcf799702..17be2fd649d 100644 --- a/htdocs/compta/paiement/info.php +++ b/htdocs/compta/paiement/info.php @@ -18,7 +18,6 @@ * * $Id$ * $Source$ - * */ /** @@ -34,31 +33,42 @@ require_once(DOL_DOCUMENT_ROOT."/paiement.class.php"); $langs->load("bills"); $langs->load("companies"); -llxHeader(); - -print '
'; -print ''.$langs->trans("Payment").''; -print ''.$langs->trans("Info").''; -print '
'; /* * Visualisation de la fiche * */ +llxHeader(); + $paiement = new Paiement($db); $paiement->fetch($_GET["id"], $user); $paiement->info($_GET["id"]); -print '
'; + +$h=0; + +$head[$h][0] = DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$_GET["id"]; +$head[$h][1] = $langs->trans("Card"); +$h++; + +$head[$h][0] = DOL_URL_ROOT.'/compta/paiement/info.php?id='.$_GET["id"]; +$head[$h][1] = $langs->trans("Info"); +$hselected = $h; +$h++; + + +dolibarr_fiche_head($head, $hselected, $langs->trans("Payment").": ".$paiement->ref); print '
'; -print '
'; dolibarr_print_object_info($paiement); print '
'; print '
'; +// Juste pour éviter bug IE qui réorganise mal div précédents si celui-ci absent +print '
'; +print '
'; $db->close(); diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 395fe5fd2a5..1919cedd3dc 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -74,4 +74,6 @@ AccountIdShort=Number EditBankRecord=Edit record LineRecord=Transaction AddBankRecord=Add transaction -AddBankRecordLong=Add transaction manually \ No newline at end of file +AddBankRecordLong=Add transaction manually +ConciliatedBy=Conciliated by +DateConciliating=Conciliate date \ No newline at end of file diff --git a/htdocs/langs/fr_FR/banks.lang b/htdocs/langs/fr_FR/banks.lang index 0d0b101d9b7..4e82ececf82 100644 --- a/htdocs/langs/fr_FR/banks.lang +++ b/htdocs/langs/fr_FR/banks.lang @@ -74,4 +74,6 @@ AccountIdShort=Num EditBankRecord=Editer écriture LineRecord=Ecriture AddBankRecord=Ajouter écriture -AddBankRecordLong=Saisie d'une écriture manuelle hors facture \ No newline at end of file +AddBankRecordLong=Saisie d'une écriture manuelle hors facture +ConciliatedBy=Rapproché par +DateConciliating=Date rapprochement \ No newline at end of file diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index 9a494c4c81f..bd2a5bb1c19 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -436,6 +436,12 @@ function dolibarr_print_object_info($object) if (isset($object->date_cloture)) print $langs->trans("DateClosing")." : " . dolibarr_print_date($object->date_cloture,"%A %d %B %Y %H:%M:%S") . '
'; + + if (isset($object->user_rappro) && $object->user_rappro->fullname ) + print $langs->trans("ConciliatedBy")." : " . $object->user_rappro->fullname . '
'; + + if (isset($object->date_rappro)) + print $langs->trans("DateConciliating")." : " . dolibarr_print_date($object->date_rappro,"%A %d %B %Y %H:%M:%S") . '
'; } /** diff --git a/htdocs/paiement.class.php b/htdocs/paiement.class.php index 36f7c7ded2c..03f9ffa36cd 100644 --- a/htdocs/paiement.class.php +++ b/htdocs/paiement.class.php @@ -19,7 +19,6 @@ * * $Id$ * $Source$ - * */ /** @@ -37,7 +36,7 @@ class Paiement { var $id; - var $db; + var $ref; var $facid; var $datepaye; var $amount; @@ -52,6 +51,7 @@ class Paiement // fk_paiement dans llx_paiement est l'id du type de paiement (7 pour CHQ, ...) // fk_paiement dans llx_paiement_facture est le rowid du paiement + var $db; /** * \brief Constructeur de la classe @@ -64,12 +64,12 @@ class Paiement $this->db = $DB ; } - /** - * \brief Récupère l'objet paiement - * \param id id du paiement a récupérer - */ - - function fetch($id) + /** + * \brief Récupère l'objet paiement + * \param id id du paiement a récupérer + * \return int <0 si ko, >0 si ok + */ + function fetch($id) { $sql = 'SELECT p.rowid,'.$this->db->pdate('p.datep').' as dp, p.amount, p.statut, p.fk_bank'; $sql .=', c.libelle as paiement_type'; @@ -85,6 +85,7 @@ class Paiement { $obj = $this->db->fetch_object(); $this->id = $obj->rowid; + $this->ref = $obj->rowid; $this->date = $obj->dp; $this->numero = $obj->num_paiement; $this->bank_account = $obj->fk_account; @@ -97,14 +98,14 @@ class Paiement } else { - return 0; + return -2; } $this->db->free(); } else { dolibarr_print_error($this->db); - return 0; + return -1; } }