diff --git a/dev/skeletons/skeleton_class.class.php b/dev/skeletons/skeleton_class.class.php index 1a6a81b4dbf..aaad7b6a75e 100644 --- a/dev/skeletons/skeleton_class.class.php +++ b/dev/skeletons/skeleton_class.class.php @@ -39,9 +39,11 @@ class Skeleton_class { - var $db; - var $error=''; - var $errors=array(); + var $db; // To store db handler + var $error; // To return error code (or message) + var $errors=array(); // To return several error codes (or messages) + var $element='skeleton'; // Id that identify managed objects + var $table_element='skeleton'; // Name of table without prefix where object is stored var $id; var $prop1; diff --git a/htdocs/adherents/adherent.class.php b/htdocs/adherents/adherent.class.php index 69396911da5..6f8923da5e7 100644 --- a/htdocs/adherents/adherent.class.php +++ b/htdocs/adherents/adherent.class.php @@ -34,6 +34,7 @@ \version $Revision$ */ +require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/cotisation.class.php"); @@ -42,13 +43,15 @@ require_once(DOL_DOCUMENT_ROOT."/adherents/cotisation.class.php"); \brief Classe permettant la gestion d'un adhérent */ -class Adherent +class Adherent extends CommonObject { - var $id; var $db; var $error; var $errors=array(); + var $element='member'; + var $table_element='adherent'; + var $id; var $ref; var $prenom; var $nom; @@ -2076,40 +2079,6 @@ class Adherent } } - /** - * \brief Charge les propriétés id_previous et id_next - * \param filter filtre - * \return int <0 si ko, >0 si ok - */ - function load_previous_next_ref($filter='') - { - $sql = "SELECT MAX(rowid)"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent"; - $sql.= " WHERE rowid < '".addslashes($this->id)."'"; - if (isset($filter)) $sql.=" AND ".$filter; - $result = $this->db->query($sql) ; - if (! $result) - { - $this->error=$this->db->error(); - return -1; - } - $row = $this->db->fetch_row($result); - $this->ref_previous = $row[0]; - - $sql = "SELECT MIN(rowid)"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent"; - $sql.= " WHERE rowid > '".addslashes($this->id)."'"; - if (isset($filter)) $sql.=" AND ".$filter; - $result = $this->db->query($sql) ; - if (! $result) - { - $this->error=$this->db->error(); - return -2; - } - $row = $this->db->fetch_row($result); - $this->ref_next = $row[0]; - } - /** * \brief Initialise le membre avec valeurs fictives aléatoire diff --git a/htdocs/commonobject.class.php b/htdocs/commonobject.class.php index 35d757d8034..e0909226298 100644 --- a/htdocs/commonobject.class.php +++ b/htdocs/commonobject.class.php @@ -495,16 +495,50 @@ class CommonObject } - /** - * \brief Charge les propriétés ref_previous et ref_next - * \param filter filtre - * \return int <0 si ko, >0 si ok - */ - function load_previous_next_ref($filter='') - { - return 1; - } + /** + * \brief Load properties id_previous and id_next + * \param filter Optional filter + * \param fieldid Nom du champ a utiliser pour select next et previous + * \return int <0 if KO, >0 if OK + */ + function load_previous_next_ref($filter='',$fieldid) + { + if (! $this->table_element) + { + dolibarr_syslog("CommonObject::load_previous_next was called on objet with property table_element not defined"); + return -1; + } + $sql = "SELECT MAX(".$fieldid.")"; + $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql.= " WHERE ".$fieldid." < '".addslashes($this->ref)."'"; + if (isset($filter)) $sql.=" AND ".$filter; + $result = $this->db->query($sql) ; + if (! $result) + { + $this->error=$this->db->error(); + return -1; + } + $row = $this->db->fetch_row($result); + $this->ref_previous = $row[0]; + + $sql = "SELECT MIN(".$fieldid.")"; + $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql.= " WHERE ".$fieldid." > '".addslashes($this->ref)."'"; + if (isset($filter)) $sql.=" AND ".$filter; + $result = $this->db->query($sql) ; + if (! $result) + { + $this->error=$this->db->error(); + return -2; + } + $row = $this->db->fetch_row($result); + $this->ref_next = $row[0]; + + return 1; + } + + /** * \brief On récupère les id de liste_contact * \param source Source du contact external (llx_socpeople) ou internal (llx_user) @@ -523,6 +557,7 @@ class CommonObject } return $contactAlreadySelected; } + } ?> diff --git a/htdocs/compta/bank/account.class.php b/htdocs/compta/bank/account.class.php index f70c4f07f5d..48df2228198 100644 --- a/htdocs/compta/bank/account.class.php +++ b/htdocs/compta/bank/account.class.php @@ -29,14 +29,21 @@ \version $Revision$ */ +require_once(DOL_DOCUMENT_ROOT ."/commonobject.class.php"); + /** \class Account \brief Classe permettant la gestion des comptes bancaires */ -class Account +class Account extends CommonObject { - var $rowid; + var $db; + var $error; + var $element='bank_account'; + var $table_element='bank_account'; + + var $rowid; var $ref; var $label; var $type; @@ -425,8 +432,9 @@ class Account /* * \brief Charge un compte en memoire depuis la base * \param id Id du compte à récupérer + * \param ref Ref du compte à récupérer */ - function fetch($id) + function fetch($id,$ref='') { $sql = "SELECT rowid, ref, label, bank, number, courant, clos, rappro, url,"; $sql.= " code_banque, code_guichet, cle_rib, bic, iban_prefix,"; @@ -434,7 +442,8 @@ class Account $sql.= " account_number, currency_code,"; $sql.= " min_allowed, min_desired, comment"; $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; - $sql.= " WHERE rowid = ".$id; + if ($id) $sql.= " WHERE rowid = ".$id; + if ($ref) $sql.= " WHERE ref = '".addslashes($ref)."'"; dolibarr_syslog("Account::fetch sql=".$sql); $result = $this->db->query($sql); diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 3ce9be8ab56..7404761de40 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -119,7 +119,7 @@ $memberstatic=new Adherent($db); $html = new Form($db); -if ($account > 0) +if ($account || $_GET["ref"]) { if ($vline) { @@ -130,7 +130,15 @@ if ($account > 0) $viewline = 20; } $acct = new Account($db); - $result=$acct->fetch($account); + if ($_GET["account"]) + { + $result=$acct->fetch($_GET["account"]); + } + if ($_GET["ref"]) + { + $result=$acct->fetch(0,$_GET["ref"]); + $account=$acct->id; + } // Chargement des categories bancaires dans $options $nbcategories=0; @@ -235,7 +243,22 @@ if ($account > 0) $head=bank_prepare_head($acct); dolibarr_fiche_head($head,'journal',$langs->trans("FinancialAccount"),0); + print ''; + // Ref + print ''; + print ''; + + // Label + print ''; + print ''; + + print '
'.$langs->trans("Ref").''; + print $html->showrefnav($acct,'ref','',1,'ref'); + print '
'.$langs->trans("Label").''.$acct->label.'
'; + + print '
'; + if ($mesg) print '
'.$mesg.'
'; @@ -267,13 +290,6 @@ if ($account > 0) $navig.=''; - // Show title - if (! $_GET["action"]=='addline' && ! $_GET["action"]=='delete') - { - $titre=$langs->trans("FinancialAccount")." : ".$acct->label; - print_fiche_titre($titre,$navig); - } - // Confirmation delete if ($_GET["action"]=='delete') { @@ -285,6 +301,12 @@ if ($account > 0) print ''; + // Show title + if (! $_GET["action"]=='addline' && ! $_GET["action"]=='delete') + { + print ''; + } + // Formulaire de saisie d'une opération hors factures if ($user->rights->banque->modifier && $_GET["action"]=='addline') diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index e67c08b9cc1..23b8b4b0d2f 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2004-2007 Laurent Destailleur * * 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 @@ -17,7 +17,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ - * $Source$ */ /** @@ -54,9 +53,19 @@ if ($user->societe_id > 0) llxHeader(); +$form = new Form($db); + // Récupère info du compte $acct = new Account($db); -$acct->fetch($_GET["account"]); +if ($_GET["account"]) +{ + $result=$acct->fetch($_GET["account"]); +} +if ($_GET["ref"]) +{ + $result=$acct->fetch(0,$_GET["ref"]); + $_GET["account"]=$acct->id; +} # Ce rapport de trésorerie est basé sur llx_bank (car doit inclure les transactions sans facture) @@ -113,12 +122,27 @@ $head=bank_prepare_head($acct); dolibarr_fiche_head($head,'annual',$langs->trans("FinancialAccount"),0); $title=$langs->trans("FinancialAccount")." : ".$acct->label; -$lien=($year_start?"".img_previous()." ".img_next()."":""); -print_fiche_titre($title,$lien); +$lien=($year_start?"".img_previous()." ".$langs->trans("Year")." ".img_next()."":""); +print '
'.$navig.'
'; + +// Ref +print ''; +print ''; + +// Label +print ''; +print ''; + +print '
'.$langs->trans("Ref").''; +print $form->showrefnav($acct,'ref','',1,'ref'); +print '
'.$langs->trans("Label").''.$acct->label.'
'; + +print '
'; // Affiche tableau print ''; +print ''; print ''; for ($annee = $year_start ; $annee <= $year_end ; $annee++) diff --git a/htdocs/compta/bank/bankid_fr.php b/htdocs/compta/bank/bankid_fr.php index dd56511d553..a69f7c80782 100644 --- a/htdocs/compta/bank/bankid_fr.php +++ b/htdocs/compta/bank/bankid_fr.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2004-2007 Laurent Destailleur * * 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 @@ -18,7 +18,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ - * $Source$ */ /** @@ -95,10 +94,18 @@ $form = new Form($db); /* */ /* ************************************************************************** */ - if ($_GET["id"] && $_GET["action"] != 'edit') + if (($_GET["id"] || $_GET["ref"]) && $_GET["action"] != 'edit') { - $account = new Account($db, $_GET["id"]); - $account->fetch($_GET["id"]); + $account = new Account($db); + if ($_GET["id"]) + { + $result=$account->fetch($_GET["id"]); + } + if ($_GET["ref"]) + { + $result=$account->fetch(0,$_GET["ref"]); + $_GET["id"]=$account->id; + } /* * Affichage onglets @@ -120,7 +127,9 @@ $form = new Form($db); // Ref print ''; - print ''; + print ''; print ''; print ''; diff --git a/htdocs/compta/bank/fiche.php b/htdocs/compta/bank/fiche.php index 9cc9bd60d78..f6bd7c121ca 100644 --- a/htdocs/compta/bank/fiche.php +++ b/htdocs/compta/bank/fiche.php @@ -18,7 +18,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ - * $Source$ */ /** @@ -262,10 +261,18 @@ if ($_GET["action"] == 'create') /* ************************************************************************** */ else { - if ($_GET["id"] && $_GET["action"] != 'edit') + if (($_GET["id"] || $_GET["ref"]) && $_GET["action"] != 'edit') { - $account = new Account($db, $_GET["id"]); - $account->fetch($_GET["id"]); + $account = new Account($db); + if ($_GET["id"]) + { + $account->fetch($_GET["id"]); + } + if ($_GET["ref"]) + { + $account->fetch(0,$_GET["ref"]); + $_GET["id"]=$account->id; + } /* * Affichage onglets @@ -288,7 +295,9 @@ else // Ref print ''; - print ''; + print ''; print ''; print ''; diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 773ae90ca5f..9eee72d4660 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -1,6 +1,6 @@ - * Copyright (C) 2006 Laurent Destailleur +/* Copyright (C) 2005 Rodolphe Quiedeville + * Copyright (C) 2006-2007 Laurent Destailleur * * 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 @@ -17,7 +17,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ - * $Source$ */ /** @@ -42,15 +41,26 @@ $mesg = ''; llxHeader(); -if ($account > 0) +$form = new Form($db); + +if ($_GET["account"] || $_GET["ref"]) { + $datetime = time(); $year = strftime("%Y", $datetime); $month = strftime("%m", $datetime); $day = strftime("%d", $datetime); $acct = new Account($db); - $acct->fetch($account); + if ($_GET["account"]) + { + $result=$acct->fetch($_GET["account"]); + } + if ($_GET["ref"]) + { + $result=$acct->fetch(0,$_GET["ref"]); + $account=$acct->id; + } create_exdir($conf->banque->dir_temp); @@ -61,9 +71,9 @@ if ($account > 0) $height = 200; // Calcul de $min et $max - $sql = "SELECT min(".$db->pdate("datev")."),max(".$db->pdate("datev").")"; - $sql .= " FROM ".MAIN_DB_PREFIX."bank"; - $sql .= " WHERE fk_account = ".$account; + $sql = "SELECT min(".$db->pdate("datev")."), max(".$db->pdate("datev").")"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank"; + $sql.= " WHERE fk_account = ".$account; $resql = $db->query($sql); if ($resql) { @@ -76,8 +86,13 @@ if ($account > 0) { dolibarr_print_error($db); } -// print strftime("%Y%m%d",$max); + $log="graph.php: min=".$min." max=".$max; + dolibarr_syslog($log); + + // Tableau 1 + + // Chargement du tableau $amounts // \todo peut etre optimise en virant les date_format $amounts = array(); @@ -97,6 +112,7 @@ if ($account > 0) $amounts[$row[0]] = $row[1]; $i++; } + $db->free($resql); } else { @@ -114,6 +130,7 @@ if ($account > 0) { $row = $db->fetch_row($resql); $solde = $row[0]; + $db->free($resql); } else { @@ -126,13 +143,19 @@ if ($account > 0) $datamin = array(); $subtotal = 0; - $day = mktime(1,1,1,$month,1,$year); - $xmonth = substr("00".strftime("%m",$day), -2); + $day = dolibarr_mktime(12,0,0,$month,1,$year); + $xmonth = $month; + $i = 0; while ($xmonth == $month) { + $textdate = strftime("%Y%m%d",$day); + $xyear = substr($textdate,0,4); + $xday = substr($textdate,6,2); + $xmonth = substr($textdate,4,2); + //print strftime ("%e %d %m %y",$day)."\n"; - $subtotal = $subtotal + (isset($amounts[strftime("%Y%m%d",$day)]) ? $amounts[strftime("%Y%m%d",$day)] : 0); + $subtotal = $subtotal + (isset($amounts[$textdate]) ? $amounts[$textdate] : 0); if ($day > time()) { $datas[$i] = ''; // Valeur spéciale permettant de ne pas tracer le graph @@ -143,9 +166,8 @@ if ($account > 0) } $datamin[$i] = $acct->min_desired; //$labels[$i] = strftime("%d",$day); - $labels[$i] = strftime("%d",$day); + $labels[$i] = $xday; $day += 86400; - $xmonth = substr("00".strftime("%m",$day), -2); $i++; } @@ -173,6 +195,16 @@ if ($account > 0) $px->SetHorizTickIncrement(1); $px->SetPrecisionY(0); $px->draw($file); + + unset($graph_datas); + unset($px); + unset($datas); + unset($datamin); + unset($labels); + unset($amounts); + + + // Tableau 2 // Chargement du tableau $amounts @@ -194,6 +226,7 @@ if ($account > 0) $amounts[$row[0]] = $row[1]; $i++; } + $db->free($resql); } else { @@ -211,6 +244,7 @@ if ($account > 0) { $row = $db->fetch_row($resql); $solde = $row[0]; + $db->free($resql); } else { @@ -223,14 +257,17 @@ if ($account > 0) $datamin = array(); $subtotal = 0; - $day = mktime(1,1,1,1,1,$year); - $xyear = strftime("%Y",$day); + $now = time(); + $day = dolibarr_mktime(12,0,0,1,1,$year); $i = 0; while ($xyear == $year) { - $subtotal = $subtotal + (isset($amounts[strftime("%Y%m%d",$day)]) ? $amounts[strftime("%Y%m%d",$day)] : 0); - //print strftime ("%e %d %m %y",$day)." ".$subtotal."\n
"; - if ($day > time()) + $textdate = strftime("%Y%m%d",$day); + $xyear = substr($textdate,0,4); + $xday = substr($textdate,6,2); + + $subtotal = $subtotal + (isset($amounts[$textdate]) ? $amounts[$textdate] : 0); + if ($day > $now) { $datas[$i] = ''; // Valeur spéciale permettant de ne pas tracer le graph } @@ -239,12 +276,11 @@ if ($account > 0) $datas[$i] = $solde + $subtotal; } $datamin[$i] = $acct->min_desired; - if (strftime("%d",$day) == 15) + if ($xday == '15') { $labels[$i] = dolibarr_print_date($day,"%b"); } $day += 86400; - $xyear = strftime("%Y",$day); $i++; } @@ -273,7 +309,17 @@ if ($account > 0) $px->SetPrecisionY(0); $px->draw($file); + unset($px); + unset($graph_datas); + unset($datas); + unset($datamin); + unset($labels); + unset($amounts); + + // Tableau 3 + + // Chargement du tableau $amounts // \todo peut etre optimise en virant les date_format $amounts = array(); @@ -312,7 +358,9 @@ if ($account > 0) $i = 0; while ($day <= ($max+86400)) // On va au dela du dernier jour { - $subtotal = $subtotal + (isset($amounts[strftime("%Y%m%d",$day)]) ? $amounts[strftime("%Y%m%d",$day)] : 0); + $textdate=strftime("%Y%m%d",$day); + + $subtotal = $subtotal + (isset($amounts[$textdate]) ? $amounts[$textdate] : 0); //print strftime ("%e %d %m %y",$day)." ".$subtotal."\n
"; if ($day > ($max+86400)) { @@ -320,12 +368,12 @@ if ($account > 0) } else { - $datas[$i] = $solde + $subtotal; + $datas[$i] = '' + $solde + $subtotal; } $datamin[$i] = $acct->min_desired; - if (strftime("%d",$day) == 1) + if (substr($textdate,6,2) == '01') { - $labels[$i] = strftime("%m",$day); + $labels[$i] = substr($textdate,4,2); } $day += 86400; $i++; @@ -341,7 +389,7 @@ if ($account > 0) else $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]); } $px = new DolGraph(); - $px->SetData($graph_datas); + $px->SetData($graph_datas); if ($acct->min_desired) $px->SetLegend(array($langs->transnoentities("Balance"),$langs->transnoentities("BalanceMinimalDesired"))); else $px->SetLegend(array($langs->transnoentities("Balance"))); $px->SetLegendWidthMin(180); @@ -355,7 +403,16 @@ if ($account > 0) $px->SetPrecisionY(0); $px->draw($file); - + unset($graph_datas); + unset($datas); + unset($datamin); + unset($labels); + unset($amounts); + + + // Tableau 4 + + // Chargement du tableau $credits, $debits $credits = array(); $debits = array(); @@ -376,6 +433,7 @@ if ($account > 0) $credits[$row[0]] = $row[1]; $i++; } + $db->free($resql); } else { @@ -394,6 +452,7 @@ if ($account > 0) { $debits[$row[0]] = abs($row[1]); } + $db->free($resql); } else { @@ -408,7 +467,7 @@ if ($account > 0) { $data_credit[$i] = isset($credits[substr("0".($i+1),-2)]) ? $credits[substr("0".($i+1),-2)] : 0; $data_debit[$i] = isset($debits[substr("0".($i+1),-2)]) ? $debits[substr("0".($i+1),-2)] : 0; - $labels[$i] = strftime("%b",dolibarr_mktime(1,1,1,$i+1,1,2000)); + $labels[$i] = strftime("%b",dolibarr_mktime(12,0,0,$i+1,1,2000)); $datamin[$i] = $acct->min_desired; } @@ -436,11 +495,34 @@ if ($account > 0) $px->SetPrecisionY(0); $px->draw($file); + unset($graph_datas); + unset($px); + unset($debits); + unset($credits); + + // Onglets $head=bank_prepare_head($acct); dolibarr_fiche_head($head,'graph',$langs->trans("FinancialAccount"),0); + print '
'.$lien.'
'.$langs->trans("Month").'
'.$langs->trans("Ref").''.$account->ref.'
'; + print $form->showrefnav($account,'ref','',1,'ref'); + print '
'.$langs->trans("Label").''.$account->label.'
'.$langs->trans("Ref").''.$account->ref.'
'; + print $form->showrefnav($account,'ref','',1,'ref'); + print '
'.$langs->trans("Label").''.$account->label.'
'; + + // Ref + print ''; + print ''; + + // Label + print ''; + print ''; + + print '
'.$langs->trans("Ref").''; + print $form->showrefnav($acct,'ref','',1,'ref'); + print '
'.$langs->trans("Label").''.$acct->label.'
'; + + print '
'; + + print ''; print ''; // Name diff --git a/htdocs/dolgraph.class.php b/htdocs/dolgraph.class.php index a82eff456e9..42ef8da032f 100644 --- a/htdocs/dolgraph.class.php +++ b/htdocs/dolgraph.class.php @@ -1,6 +1,6 @@ - * Copyright (c) 2004-2006 Laurent Destailleur + * Copyright (c) 2004-2007 Laurent Destailleur * * 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 @@ -17,7 +17,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ - * $Source$ */ /** @@ -305,15 +304,15 @@ class DolGraph if (defined('TOTY')) $phplotversion=5; // Create graph - $this->graph = new PHPlot($this->width, $this->height); - $this->graph->SetIsInline(1); - $this->graph->SetPlotType($this->type); - $this->graph->SetDataValues($this->data); + $graph = new PHPlot($this->width, $this->height); + $graph->SetIsInline(1); + $graph->SetPlotType($this->type); + $graph->SetDataValues($this->data); // Precision axe y (pas de decimal si 3 chiffres ou plus) if ($this->PrecisionY > -1) { - $this->graph->SetPrecisionY($this->PrecisionY); + $graph->SetPrecisionY($this->PrecisionY); if ($this->PrecisionY == 0) // Si precision de 0 { // Determine un nombre de ticks qui permet decoupage qui tombe juste @@ -352,15 +351,15 @@ class DolGraph $maxticks=min(9,$plage); } } - $this->graph->SetNumVertTicks($maxticks); + $graph->SetNumVertTicks($maxticks); // print 'minval='.$minval.' - maxval='.$maxval.' - plage='.$plage.' - maxticks='.$maxticks.'
'; } } else { - $this->graph->SetPrecisionY(3-strlen(round($this->GetMaxValueInData()))); + $graph->SetPrecisionY(3-strlen(round($this->GetMaxValueInData()))); } - $this->graph->SetPrecisionX(0); + $graph->SetPrecisionX(0); // Set areas $top_space=40; @@ -380,52 +379,52 @@ class DolGraph } } - $this->graph->SetNewPlotAreaPixels($left_space, $top_space, $this->width - $right_space, $this->height-40); + $graph->SetNewPlotAreaPixels($left_space, $top_space, $this->width - $right_space, $this->height-40); if (isset($this->MaxValue)) { - $this->graph->SetPlotAreaWorld(0,$this->MinValue,sizeof($this->data),$this->MaxValue); + $graph->SetPlotAreaWorld(0,$this->MinValue,sizeof($this->data),$this->MaxValue); } // Define title - if (isset($this->title)) $this->graph->SetTitle($this->title); + if (isset($this->title)) $graph->SetTitle($this->title); // Défini position du graphe (et legende) au sein de l'image if (isset($this->Legend) && sizeof($this->Legend)) { - $this->graph->SetLegendPixels($this->width - $right_space+8,40,''); - $this->graph->SetLegend($this->Legend); + $graph->SetLegendPixels($this->width - $right_space+8,40,''); + $graph->SetLegend($this->Legend); } if (isset($this->SetShading)) { - $this->graph->SetShading($this->SetShading); + $graph->SetShading($this->SetShading); } - $this->graph->SetTickLength(6); + $graph->SetTickLength(6); - $this->graph->SetBackgroundColor($this->bgcolor); - $this->graph->SetDataColors($this->datacolor, $this->bordercolor); + $graph->SetBackgroundColor($this->bgcolor); + $graph->SetDataColors($this->datacolor, $this->bordercolor); if ($this->SetNumXTicks > -1) { if ($phplotversion >= 5) // If PHPlot 5, for compatibility { - $this->graph->SetXLabelType(''); - $this->graph->SetNumXTicks($this->SetNumXTicks); + $graph->SetXLabelType(''); + $graph->SetNumXTicks($this->SetNumXTicks); } else { - $this->graph->SetNumHorizTicks($this->SetNumXTicks); + $graph->SetNumHorizTicks($this->SetNumXTicks); } } if ($this->SetHorizTickIncrement > -1) { // Les ticks sont en mode forc - $this->graph->SetHorizTickIncrement($this->SetHorizTickIncrement); + $graph->SetHorizTickIncrement($this->SetHorizTickIncrement); if ($phplotversion >= 5) // If PHPlot 5, for compatibility { - $this->graph->SetXLabelType(''); - $this->graph->SetXTickLabelPos('none'); + $graph->SetXLabelType(''); + $graph->SetXTickLabelPos('none'); } } else @@ -433,23 +432,25 @@ class DolGraph // Les ticks sont en mode automatique if ($phplotversion >= 5) // If PHPlot 5, for compatibility { - $this->graph->SetXDataLabelPos('none'); + $graph->SetXDataLabelPos('none'); } } if ($phplotversion >= 5) { // Ne gere la transparence qu'en phplot >= 5 - // $this->graph->SetBgImage(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo_2.png','tile'); - $this->graph->SetDrawPlotAreaBackground(array(255,255,255)); + // $graph->SetBgImage(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo_2.png','tile'); + $graph->SetDrawPlotAreaBackground(array(255,255,255)); } - $this->graph->SetPlotBorderType("left"); // Affiche axe y a gauche uniquement - $this->graph->SetVertTickPosition('plotleft'); // Affiche tick axe y a gauche uniquement - $this->graph->SetOutputFile($file); + $graph->SetPlotBorderType("left"); // Affiche axe y a gauche uniquement + $graph->SetVertTickPosition('plotleft'); // Affiche tick axe y a gauche uniquement + $graph->SetOutputFile($file); // Generate file - $this->graph->DrawGraph(); + $graph->DrawGraph(); + + unset($graph); } diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 198d771ad9b..0e241880c20 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -23,7 +23,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ - * $Source$ */ /** @@ -44,8 +43,11 @@ require_once(DOL_DOCUMENT_ROOT ."/client.class.php"); class Facture extends CommonObject { - var $db; - var $element='facture'; + var $db; + var $error; + var $element='facture'; + var $table_element='facture'; + var $table; var $tabledetail; var $id; @@ -94,7 +96,6 @@ class Facture extends CommonObject var $nbtodo; var $nbtodolate; var $specimen; - var $error; //! Numero d'erreur de 512 à 1023 var $errno = 0; /** diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index a5b1eb80588..1938b34a368 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -3518,14 +3518,15 @@ class Form * \param object Objet a afficher * \param paramid Nom du parametre a utiliser pour nommer id dans liens URL * \param morehtml Code html supplementaire a afficher avant barre nav - * \param shownav Show Condirion + * \param shownav Show Condition + * \param fieldid Nom du champ a utiliser pour select next et previous * \return string Portion HTML avec ref + boutons nav */ - function showrefnav($object,$paramid,$morehtml='',$shownav=1) + function showrefnav($object,$paramid,$morehtml='',$shownav=1,$fieldid='rowid') { $ret=''; - $object->load_previous_next_ref($object->next_prev_filter); + $object->load_previous_next_ref($object->next_prev_filter,$fieldid); $previous_ref = $object->ref_previous?''.img_previous().'':''; $next_ref = $object->ref_next?''.img_next().'':''; diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index 4bf1baa0df7..e7aafcdd18b 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -2129,7 +2129,7 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so if ($page > 0 || $num > $conf->liste_limit) { - print '
'; } else diff --git a/htdocs/product.class.php b/htdocs/product.class.php index 1c8829caa57..bd56465d197 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -20,7 +20,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ - * $Source$ */ /** @@ -30,15 +29,21 @@ \version $Revision$ */ +require_once(DOL_DOCUMENT_ROOT ."/commonobject.class.php"); + + /** \class Product \brief Classe permettant la gestion des produits prédéfinis */ - -class Product +class Product extends CommonObject { - var $db ; - //! Identifiant unique + var $db; + var $error; + var $element='product'; + var $table_element='product'; + + //! Identifiant unique var $id ; //! Référence var $ref; @@ -91,8 +96,6 @@ class Product var $imgWidth; var $imgHeight; - //! Intitule de l'erreur - var $error; //! Numero de l'erreur //! Numero d'erreur Plage 0256-0511 var $errno = 0; @@ -975,43 +978,6 @@ class Product } - /** - * \brief Charge les propriétés ref_previous et ref_next - * \param filter filtre - * \return int <0 si ko, >0 si ok - */ - function load_previous_next_ref($filter='') - { - $sql = "SELECT MAX(ref)"; - $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE ref < '".addslashes($this->ref)."'"; - if (isset($filter)) $sql.=" AND ".$filter; - $result = $this->db->query($sql) ; - if (! $result) - { - $this->error=$this->db->error(); - return -1; - } - $row = $this->db->fetch_row($result); - $this->ref_previous = $row[0]; - - $sql = "SELECT MIN(ref)"; - $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE ref > '".addslashes($this->ref)."'"; - if (isset($filter)) $sql.=" AND ".$filter; - $result = $this->db->query($sql) ; - if (! $result) - { - $this->error=$this->db->error(); - return -2; - } - $row = $this->db->fetch_row($result); - $this->ref_next = $row[0]; - - return 1; - } - - /** * \brief Charge tableau des stats propale pour le produit/service * \param socid Id societe diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index bb892d6f51e..a4ae7adb2f9 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -761,7 +761,7 @@ if ($_GET["id"] || $_GET["ref"]) // Reference print ''; $nblignes=6; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 6364f95972c..a93b13ff720 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2007 Regis Houssin * Copyright (C) 2006 Andre Cianfarani @@ -20,7 +20,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ - * $Source$ */ /** diff --git a/htdocs/user.class.php b/htdocs/user.class.php index 682b61fcefb..291f11301b2 100644 --- a/htdocs/user.class.php +++ b/htdocs/user.class.php @@ -37,14 +37,19 @@ \version $Revision$ */ +require_once(DOL_DOCUMENT_ROOT ."/commonobject.class.php"); + /** \class User \brief Classe permettant la gestion d'un utilisateur */ -class User +class User extends CommonObject { - var $db; + var $db; + var $error; + var $element='user'; + var $table_element='user'; var $id; var $ldap_sid; @@ -81,7 +86,6 @@ class User var $statut; var $lang; - var $error; var $userpref_limite_liste; var $all_permissions_are_loaded; /**< \private all_permissions_are_loaded */ //! Liste des entrepots auquel a acces l'utilisateur @@ -1733,41 +1737,7 @@ class User dolibarr_print_error($this->db); } } - - /** - * \brief Charge les propriétés id_previous et id_next - * \param filter filtre - * \return int <0 si ko, >0 si ok - */ - function load_previous_next_ref($filter='') - { - $sql = "SELECT MAX(rowid)"; - $sql.= " FROM ".MAIN_DB_PREFIX."user"; - $sql.= " WHERE rowid < '".addslashes($this->id)."'"; - if (isset($filter)) $sql.=" AND ".$filter; - $result = $this->db->query($sql) ; - if (! $result) - { - $this->error=$this->db->error(); - return -1; - } - $row = $this->db->fetch_row($result); - $this->ref_previous = $row[0]; - - $sql = "SELECT MIN(rowid)"; - $sql.= " FROM ".MAIN_DB_PREFIX."user"; - $sql.= " WHERE rowid > '".addslashes($this->id)."'"; - if (isset($filter)) $sql.=" AND ".$filter; - $result = $this->db->query($sql) ; - if (! $result) - { - $this->error=$this->db->error(); - return -2; - } - $row = $this->db->fetch_row($result); - $this->ref_next = $row[0]; - } }
'; diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 74322cce40a..b3dda1a5ad0 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -64,10 +64,20 @@ $pagenext = $page + 1; llxHeader(); +$html = new Form($db); + // Récupère info du compte $acct = new Account($db); -$acct->fetch($_GET["account"]); +if ($_GET["account"]) +{ + $acct->fetch($_GET["account"]); +} +if ($_GET["ref"]) +{ + $acct->fetch(0,$_GET["ref"]); + $_GET["account"]=$acct->id; +} if (! isset($_GET["num"])) { @@ -91,8 +101,25 @@ if (! isset($_GET["num"])) $head=bank_prepare_head($acct); dolibarr_fiche_head($head,'statement',$langs->trans("FinancialAccount"),0); - $titre=$langs->trans("FinancialAccount")." : ".$acct->label; - print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], "&account=".$_GET["account"], $sortfield, $sortorder,'',$numrows); + print ''; + + // Ref + print ''; + print ''; + + // Label + print ''; + print ''; + + print '
'.$langs->trans("Ref").''; + print $html->showrefnav($acct,'ref','',1,'ref'); + print '
'.$langs->trans("Label").''.$acct->label.'
'; + + print '
'; + + + + print_barre_liste('', $page, $_SERVER["PHP_SELF"], "&account=".$_GET["account"], $sortfield, $sortorder,'',$numrows); print ''; print ""; @@ -173,6 +200,7 @@ else } $ve=$_GET["ve"]; + $mesprevnext ="id\">".img_previous()."  "; $mesprevnext.= $langs->trans("AccountStatement")." $num"; $mesprevnext.="   id\">".img_next().""; diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index a97e8572707..58a20167c53 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -16,7 +16,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ - * $Source$ */ /** @@ -52,13 +51,14 @@ $mesg=''; */ llxHeader(); + $societestatic = new Societe($db); $facturestatic=new Facture($db); $facturefournstatic=new FactureFournisseur($db); $html = new Form($db); -if ($account > 0) +if ($_REQUEST["account"] || $_REQUEST["ref"]) { if ($vline) { @@ -68,8 +68,19 @@ if ($account > 0) { $viewline = 20; } + $acct = new Account($db); - $result=$acct->fetch($account); + if ($_GET["account"]) + { + $result=$acct->fetch($_GET["account"]); + } + if ($_GET["ref"]) + { + $result=$acct->fetch(0,$_GET["ref"]); + $_GET["account"]=$acct->id; + } + + /* * * @@ -78,7 +89,23 @@ if ($account > 0) $head=bank_prepare_head($acct); dolibarr_fiche_head($head,'cash',$langs->trans("FinancialAccount"),0); + print '
'; + // Ref + print ''; + print ''; + + // Label + print ''; + print ''; + + print '
'.$langs->trans("Ref").''; + print $html->showrefnav($acct,'ref','',1,'ref'); + print '
'.$langs->trans("Label").''.$acct->label.'
'; + + print '
'; + + if ($mesg) print '
'.$mesg.'
'; diff --git a/htdocs/contact.class.php b/htdocs/contact.class.php index 94527da8457..7e734bddc54 100644 --- a/htdocs/contact.class.php +++ b/htdocs/contact.class.php @@ -20,7 +20,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ - * $Source$ */ /** @@ -30,17 +29,20 @@ \version $Revision$ */ +require_once(DOL_DOCUMENT_ROOT ."/commonobject.class.php"); + /** \class Contact \brief Classe permettant la gestion des contacts */ - -class Contact +class Contact extends CommonObject { var $db; var $error; - + var $element='contact'; + var $table_element='socpeople'; + var $id; var $civilite_id; var $name; @@ -385,6 +387,7 @@ class Contact $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; + $this->ref = $obj->rowid; $this->civilite_id = $obj->civilite_id; $this->name = $obj->name; $this->firstname = $obj->firstname; diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index a9d7e6597e5..20eb4578f4e 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -366,7 +366,7 @@ if ($user->rights->societe->contact->creer) // Ref print '
'.$langs->trans("Ref").''; - print $contact->id; + print $contact->ref; print '
'.$titre.' - '.$langs->trans('page').' '.($page+1); + print '
'.$titre.($titre?' - ':'').$langs->trans('page').' '.($page+1); print '
'.$langs->trans("Ref").''; - print $html->showrefnav($product,'ref'); + print $html->showrefnav($product,'ref','',1,'ref'); print '