Code cleaning : renaming

This commit is contained in:
sparkyx 2007-12-20 12:15:55 +00:00
parent 9c45ef3eb0
commit c79589ecac
18 changed files with 39 additions and 356 deletions

View file

@ -34,7 +34,7 @@ require_once ('class_widget.php');
require_once ("ac_common.php");
require_once ('class_dossier.php');
require_once ('class_anc_account.php');
require_once ('class_plananalytic.php');
require_once ('class_anc_plan.php');
/*!\todo add security here : check user and access to CA
*/
@ -57,7 +57,7 @@ echo '</form>';
//------------- FORM ----------------------------------
if ( isset($_REQUEST['go'])) {
$cn=DbConnect(dossier::id());
$plan=new PlanAnalytic($cn,$_REQUEST['c2']);
$plan=new Anc_Plan($cn,$_REQUEST['c2']);
$plan->pa_id=$_REQUEST['c2'];
if ( $plan->exist()==false)
exit("Ce plan n'existe pas");

View file

@ -28,7 +28,7 @@
*
*/
require_once('class_anc_operation.php');
require_once('class_plananalytic.php');
require_once('class_anc_plan.php');
require_once('ac_common.php');
require_once('class_widget.php');

View file

@ -29,10 +29,11 @@
require_once("class_anc_account.php");
require_once ("class_widget.php");
require_once ("class_anc_operation.php");
require_once ("class_anc_plan.php");
require_once ("class_groupop.php");
$pa=new PlanAnalytic($cn);
$pa=new Anc_Plan($cn);
$m=$pa->get_list();
if ( ! $m ) { echo '<h2 class="info"> Aucun plan analytique d&eacute;fini</h2>';exit();}
echo '<div class="u_subt2menu">';

View file

@ -26,7 +26,7 @@
/* \brief Plan Analytique
*
*/
require_once("class_plananalytic.php");
require_once("class_anc_plan.php");
require_once("class_anc_account.php");
$ret="";
//---------------------------------------------------------------------------
@ -41,7 +41,7 @@ if ( isset($_REQUEST['sa']))
if ( $sa == "add_pa")
{
$wAction=new widget("hidden","","p_action","ca_pa");
$new=new PlanAnalytic($cn);
$new=new Anc_Plan($cn);
if ( $new->isAppend() == true)
{
$ret.= '<div class="u_redcontent">';
@ -68,7 +68,7 @@ if ( isset($_REQUEST['sa']))
// Add
if ( $sa == "pa_write")
{
$new=new PlanAnalytic($cn);
$new=new Anc_Plan($cn);
if ( $new->isAppend() == false)
@ -79,7 +79,7 @@ if ( isset($_REQUEST['sa']))
}
else
{
$new=new PlanAnalytic($cn);
$new=new Anc_Plan($cn);
$new->name=$_POST['pa_name'];
$new->description=$_POST['pa_description'];
$new->add();
@ -88,7 +88,7 @@ if ( isset($_REQUEST['sa']))
// show the detail
if ( $sa == "pa_detail" )
{
$new=new PlanAnalytic($cn,$_GET['pa_id']);
$new=new Anc_Plan($cn,$_GET['pa_id']);
$wAction=new widget("hidden","","p_action","ca_pa");
$wSa=new widget("HIDDEN","","sa","pa_update");
@ -114,7 +114,7 @@ if ( isset($_REQUEST['sa']))
// Update the PA
if ( $sa == "pa_update" )
{
$new=new PlanAnalytic($cn,$_GET['pa_id']);
$new=new Anc_Plan($cn,$_GET['pa_id']);
$new->name=$_POST['pa_name'];
$new->description=$_POST['pa_description'];
$new->update();
@ -149,7 +149,7 @@ if ( isset($_REQUEST['sa']))
/* delete pa */
if ( $sa == "pa_delete")
{
$delete=new PlanAnalytic($cn,$_GET['pa_id']);
$delete=new Anc_Plan($cn,$_GET['pa_id']);
$delete->delete();
}
/* po detail
@ -194,7 +194,7 @@ if ( isset($_REQUEST['sa']))
{
$count=0;
$new=new PlanAnalytic($cn,$_REQUEST['pa_id']);
$new=new Anc_Plan($cn,$_REQUEST['pa_id']);
$new->get();
$array=$new->get_poste_analytique();
$ret.='<div class="u_redcontent">';
@ -245,7 +245,7 @@ if ( isset($_REQUEST['sa']))
// Show lmenu
//
//---------------------------------------------------------------------------
$obj=new PlanAnalytic($cn);
$obj=new Anc_Plan($cn);
$list=$obj->get_list();

View file

@ -28,7 +28,7 @@
*/
require_once("class_widget.php");
require_once("postgres.php");
require_once("class_plananalytic.php");
require_once("class_anc_plan.php");
class Anc_Account
{
@ -223,7 +223,7 @@ class Anc_Account
$wGa_id->value=make_array($this->db,"select ga_id,ga_id from groupe_analytique",1);
$wGa_id->selected=$this->ga_id;
$wGa_id->table=1;
$pa=new PlanAnalytic($this->db,$this->pa_id);
$pa=new Anc_Plan($this->db,$this->pa_id);
$pa->get();
$wPaName=new widget("text","Plan A.","",$pa->name);
$wPaName->table=1;

View file

@ -30,7 +30,7 @@
*
*/
require_once ('class_anc_print.php');
require_once ('class_plananalytic.php');
require_once ('class_anc_plan.php');
class Anc_Balance_Double extends Anc_Print
{
@ -141,9 +141,9 @@ class Anc_Balance_Double extends Anc_Print
$count=ceil(count($array)/$pagesize);
$pdf= new Cezpdf("A4");
$pdf->selectFont('./addon/fonts/Helvetica.afm');
$pa=new PlanAnalytic($this->db,$this->pa_id);
$pa=new Anc_Plan($this->db,$this->pa_id);
$pa->get();
$pb=new PlanAnalytic($this->db,$this->pa_id2);
$pb=new Anc_Plan($this->db,$this->pa_id2);
$pb->get();
$titre=sprintf("Balance croise plan %s %s ",
@ -262,7 +262,7 @@ class Anc_Balance_Double extends Anc_Print
$r=parent::display_form($p_string);
// show the second plan
$r.='<span style="padding:5px;margin:5px;border:2px double blue;display:block;">';
$plan=new PlanAnalytic($this->db);
$plan=new Anc_Plan($this->db);
$plan_id=new widget("select","","pa_id2");
$plan_id->value=make_array($this->db,"select pa_id, pa_name from plan_analytique order by pa_name");
$plan_id->selected=$this->pa_id2;

View file

@ -25,7 +25,7 @@
*/
require_once ('class_anc_print.php');
require_once ('class_plananalytic.php');
require_once ('class_anc_plan.php');
require_once ('ac_common.php');
include_once("class.ezpdf.php");
require_once ('header_print.php');

View file

@ -26,7 +26,7 @@
/*! \brief
*
*/
require_once ('class_plananalytic.php');
require_once ('class_anc_plan.php');
require_once ('class_anc_print.php');
require_once ('class_anc_operation.php');
/*!

View file

@ -22,7 +22,7 @@
/* !\file
*/
require_once("class_plananalytic.php");
require_once("class_anc_plan.php");
require_once("class_widget.php");
require_once ("user_common.php");
@ -376,7 +376,7 @@ function get_balance($p_from,$p_to,$p_plan_id)
if ( $p_array != null)
extract ($p_array);
$result="";
$plan=new PlanAnalytic($this->db);
$plan=new Anc_Plan($this->db);
$a_plan=$plan->get_list();
if ( empty ($a_plan) ) return "";
$table_id="t".$p_seq;
@ -481,7 +481,7 @@ function get_balance($p_from,$p_to,$p_plan_id)
$max=${"nb_t".$p_item};
echo_debug(__FILE__.':'.__LINE__.'- ', "max of row for CA = ".$max);
// get all the PA
$plan=new PlanAnalytic($this->db);
$plan=new Anc_Plan($this->db);
$cplan=$plan->count();
echo_debug(__FILE__.':'.__LINE__," nb of PA $cplan");
// foreach row

View file

@ -32,14 +32,14 @@ require_once("class_widget.php");
require_once("class_anc_account.php");
require_once ('class_dossier.php');
class PlanAnalytic
class Anc_Plan
{
var $db; /*!<database connection */
var $name; /*!< name plan_analytique.pa_name */
var $description; /*!< description of the PA plan_analytique.pa_description*/
var $id; /*!< id = plan_analytique.pa_id */
function PlanAnalytic($p_cn,$p_id=0)
function Anc_Plan($p_cn,$p_id=0)
{
$this->db=$p_cn;
$this->id=$p_id;
@ -185,7 +185,7 @@ class PlanAnalytic
echo "clean";
ExecSql($cn,"delete from plan_analytique");
$p=new PlanAnalytic($cn);
$p=new Anc_Plan($cn);
echo "<h2>Add</h2>";
$p->name="Nouveau 1";
$p->description="C'est un test";

View file

@ -32,7 +32,7 @@ require_once('debug.php');
require_once('constant.php');
require_once ('class_widget.php');
require_once('class_dossier.php');
require_once ('class_plananalytic.php');
require_once ('class_anc_plan.php');
class Anc_Print {
var $db; /*!< $db database connection */
@ -79,7 +79,7 @@ class Anc_Print {
*/
function display_form($p_hidden="") {
/* if there is no analytic plan return */
$pa=new PlanAnalytic($this->db);
$pa=new Anc_Plan($this->db);
if ( $pa->count() == 0 ) {
echo '<h2 class="info"> Aucun plan d&eacute;fini</h2>';
exit();
@ -110,7 +110,7 @@ class Anc_Print {
$r.=$p_hidden;
$r.='<span style="padding:5px;margin:5px;border:2px double blue;display:block;">';
$plan=new PlanAnalytic($this->db);
$plan=new Anc_Plan($this->db);
$plan_id=new widget("select","","pa_id");
$plan_id->value=make_array($this->db,"select pa_id, pa_name from plan_analytique order by pa_name");
$plan_id->selected=$this->pa_id;

View file

@ -35,7 +35,7 @@ class Bud_Hypo {
var $bh_id; /*!< Primary key bud_hypo */
var $bh_saldo; /*!< saldo */
var $bh_description; /*!< Description */
var $pa_id; /*!< Foreign key to PlanAnalytic */
var $pa_id; /*!< Foreign key to Anc_Plan */
function __construct($p_cn,$p_id=0)

View file

@ -29,7 +29,7 @@
require_once ("class_anc_operation.php");
require_once ("postgres.php");
require_once ("class_widget.php");
require_once ('class_plananalytic.php');
require_once ('class_anc_plan.php');
require_once ('class_dossier.php');
class groupop
@ -90,7 +90,7 @@ class groupop
$ret.='<tr><td style="border:1px groove blue">Description</td>'.
'<td colspan="3">'.
$wDescription->IOValue()."</td></tr>";
$Plan=new PlanAnalytic($this->db);
$Plan=new Anc_Plan($this->db);
$aPlan=$Plan->get_list();
$ret.='</table><table style="border: 2px outset blue; width: 100%;">';
/* show 10 rows */
@ -162,7 +162,7 @@ class groupop
*
*/
function from_POST() {
$Plan=new PlanAnalytic($this->db);
$Plan=new Anc_Plan($this->db);
$aPlan=$Plan->get_list();

View file

@ -1,318 +0,0 @@
<?php
/*
* This file is part of PhpCompta.
*
* PhpCompta 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.
*
* PhpCompta 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 PhpCompta; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Revision$ */
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
/*!\file
*/
/*!\brief contains the object for the poste_analytique (table poste_analytique)
*
*/
require_once("class_widget.php");
require_once("postgres.php");
require_once("class_plananalytic.php");
class Poste_analytique
{
var $id; /*!< $id is po_id */
var $name; /*!< po_name */
var $pa_id; /*!< pa_id fk to the plan_analytique(pa_id) */
var $amount; /*!< po_amount just an amount */
var $description; /*!< po_description description of the post */
var $db; /*!< database connection*/
var $ga_id; /*!< FK to the table groupe analytique */
function Poste_analytique($p_db,$p_id=0)
{
$this->db=$p_db;
$this->id=$p_id;
$this->ga_id=null;
}
/*! \brief retrieve data from the database and
* fill the object
* \param $p_where the where clause
*/
private function fetch_from_db($p_where)
{
$sql="select po_id,
po_name ,
pa_id,
po_amount,
po_description,
ga_id
from poste_analytique
where ".
$p_where;
$ret=ExecSql($this->db,$sql);
if ( pg_NumRows($ret) == 0 )return null;
$line=pg_fetch_array($ret);
$this->id=$line['po_id'];
$this->name=$line['po_name'];
$this->pa_id=$line['pa_id'];
$this->amount=$line['po_amount'];
$this->description=$line['po_description'];
$this->ga_id=$line['ga_id'];
}
function get_by_id()
{
$this->fetch_from_db("po_id=".$this->id);
}
/*!
* \brief retrieve data thanks the name
* \param $p_name name of the analytic account
*
*/
function get_by_name($p_name)
{
$p_name=FormatString($p_name);
if ( $p_name == null )
$p_name=$this->name;
$this->fetch_from_db("po_name='".$p_name."'");
echo "id = ".$this->id;
}
function add()
{
$this->format_data();
if ( strlen($this->name) == 0)
return;
if ( $this->ga_id == null || strlen(trim($this->ga_id)) == 0 )
$ga_id="NULL";
else
$ga_id="'".$this->ga_id."'";
$sql="insert into poste_analytique (
po_name ,
pa_id,
po_amount,
po_description,
ga_id
) values (".
"'".$this->name."',".
$this->pa_id.",".
$this->amount.",".
"'".$this->description."',".
$ga_id.")";
try {
ExecSql($this->db,$sql);
} catch (Exception $e) {
echo_debug(__FILE__,__LINE__,$e);
if ( DEBUG ) print_r($e);
echo "<p class=\"notice\">Doublon : l'enregistrement n'est pas sauve</p>";
}
}
function update()
{
$this->format_data();
if ( strlen($this->name) == 0)
return;
$sql="update poste_analytique ".
" set po_name='".$this->name."',".
" pa_id=".$this->pa_id.",".
" po_amount=".$this->amount.",".
" po_description='".$this->description."',".
" ga_id='".$this->ga_id."'".
" where po_id=".$this->id;
try {
ExecSql($this->db,$sql);
} catch (Exception $e) {
echo_debug(__FILE__,__LINE__,$e);
echo "<p class=\"notice\">Doublon : l'enregistrement n'est pas sauve</p>";
}
}
private function format_data()
{
$this->name=FormatString($this->name);
$this->pa_id=FormatString($this->pa_id);
$this->amount=FormatString($this->amount);
if (strlen($this->amount) == 0 )
$this->amount=0.0;
$this->description=FormatString($this->description);
}
function delete()
{
$sql="delete from poste_analytique where po_id=".$this->id;
ExecSql($this->db,$sql);
}
/*! \brief return an array of object Poste_Analytique
*
*/
function get_list()
{
$sql="select po_id,
po_name ,
pa_id,
po_amount,
po_description,
ga_id
from poste_analytique ".
" order by po_name";
$ex=ExecSql($this->db,$sql);
$ret=pg_fetch_all($ex);
if ( $ret == null )
return null;
$array=array();
foreach ($ret as $line)
{
$objet=new Poste_Analytique($this->db);
$object->id=$line['po_id'];
$object->name=$line['po_name'];
$object->pa_id=$line['pa_id'];
$object->amount=$line['po_amount'];
$object->description=$line['po_description'];
$object->ga_id=$line['ga_id'];
$array[]=clone $object;
}
return $array;
}
function display_list()
{
$array=$this->get_list();
if ( empty($array) ) { echo "Vide"; return;}
foreach ($array as $line)
{
echo $line->id." / ".$line->name." / ".$line->description."/".
$line->amount." / ".$line->pa_id."/".$line->ga_id."<br>";
}
}
function debug()
{
echo "id ".$this->id."<br>";
echo "name ".$this->name."<br>";
echo "pa_id ".$this->pa_id."<br>";
echo "amount ".$this->amount."<br>";
echo "description ".$this->description."<br>";
echo "ga_id ".$this->ga_id."<br>";
}
function form()
{
$wId=new widget("hidden","po_id","po_id",$this->id);
$wName=new widget("text","Nom","po_name",$this->name);
$wPa_id=new widget("hidden","pa_id","pa_id",$this->pa_id);
$wAmount=new widget("text","Montant","po_amount",$this->amount);
$wDescription=new widget("text","Description","po_description",$this->description);
$wGa_id=new widget("select","Groupe","ga_id");
$wGa_id->value=make_array($this->db,"select ga_id,ga_id from groupe_analytique",1);
$wGa_id->selected=$this->ga_id;
$wGa_id->table=1;
$pa=new PlanAnalytic($this->db,$this->pa_id);
$pa->get();
$wPaName=new widget("text","Plan A.","",$pa->name);
$wPaName->table=1;
$wPaName->readonly=true;
$wName->table=1;
$wPa_id->table=1;
$wAmount->table=1;
$wDescription->table=1;
$r=$wId->IOValue();
$r.=$wPa_id->IOValue();
$r.="<table>";
$r.="<tr>";
$r.=$wName->IOValue();
$r.="</tr>";
$r.="<tr>";
$r.=$wAmount->IOValue();
$r.="</tr>";
$r.="<tr>";
$r.=$wDescription->IOValue();
$r.="</tr>";
$r.="<tr>";
$r.=$wPaName->IOValue();
$r.="</tr>";
$r.="<tr>";
$r.=$wGa_id->IOValue();
$r.="</tr>";
$r.="</table>";
return $r;
}
function fill_from_POST()
{
$this->name=$_POST['po_name'];
$this->description=$_POST['po_description'];
$this->pa_id=$_POST['pa_id'];
$this->amount=$_POST['po_amount'];
$this->id=$_POST['po_id'];
$this->ga_id=($_POST['ga_id'] == "-1" )?"":$_POST['ga_id'];
}
static function testme() {
$cn=DbConnect(dossier::id());
$pa_id=getDBValue($cn,"select max(pa_id) from plan_analytique");
$o=new Poste_Analytique($cn);
echo "<h1>Poste_Analytique</h1>";
echo "<h2>get_list</h2>";
$ee=$o->get_list();
print_r($ee);
//var_dump($ee);
echo "<h2>Add some </h2>";
$o->pa_id=$pa_id;
$o->name="test1";
$o->add();
$o->name="test2";
$o->add();
$o->name="test3";
$o->add();
$o->name="test4";
$o->add();
$o->name="test5";
$o->add();
echo "<h2> remove test1</h2>";
$o->get_by_name("test1");
$o->delete();
$o->display_list();
$o->get_by_name("test4");
echo "<hr>".$o->id."<hr>";
$o->name="Test Four";
$o->update();
$o->display_list();
$o->delete();
$o->display_list();
}
}
?>

View file

@ -26,7 +26,7 @@
require_once('class_fiche.php');
require_once ('class_gestion_sold.php');
require_once ('class_gestion_purchase.php');
require_once ('class_plananalytic.php');
require_once ('class_anc_plan.php');
require_once ('class_anc_operation.php');
require_once ('class_acc_ledger.php');
require_once ('class_acc_operation.php');

View file

@ -28,7 +28,7 @@ require_once("preference.php");
require_once("fiche_inc.php");
require_once("user_common.php");
require_once("class_parm_code.php");
require_once ('class_plananalytic.php');
require_once ('class_anc_plan.php');
require_once ('class_own.php');
require_once ('class_anc_operation.php');
require_once ('class_pre_op_ach.php');

View file

@ -25,7 +25,7 @@ require_once("class_widget.php");
require_once("preference.php");
require_once("fiche_inc.php");
require_once("user_common.php");
require_once ('class_plananalytic.php');
require_once ('class_anc_plan.php');
require_once ('class_own.php');
require_once ('class_anc_operation.php');
require_once ('class_pre_op_ods.php');

View file

@ -27,7 +27,7 @@ require_once("preference.php");
require_once("fiche_inc.php");
require_once("user_common.php");
require_once ("class_own.php");
require_once ("class_plananalytic.php");
require_once ("class_anc_plan.php");
require_once ('class_anc_operation.php');
require_once ('class_pre_op_ven.php');
require_once ('class_own.php');