noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 55/219: Task #1469 Code Cleaning: remove Anc_


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 55/219: Task #1469 Code Cleaning: remove Anc_Account Use a CSS with 2 fonts , one for the title and clickable item, and a normal one. Correct Anc_Account_Table::check duplicate for update and insert
Date: Mon, 18 Dec 2017 13:22:37 -0500 (EST)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 4b0938b1f36d86b648832d441c5610064d8e5d86
Author: Dany De Bontridder <address@hidden>
Date:   Sun Sep 24 09:59:10 2017 +0200

    Task #1469 Code Cleaning: remove Anc_Account
    Use a CSS with 2 fonts , one for the title and clickable item, and a
    normal one.
    Correct Anc_Account_Table::check duplicate for update and insert
---
 html/style-r692.css                               |  15 +-
 include/ajax/ajax_anc_search.php                  |   1 -
 include/anc_od.inc.php                            |   1 -
 include/class/anc_account.class.php               | 352 ----------------------
 include/class/anc_account_table.class.php         |   4 +-
 include/class/anc_plan.class.php                  |  23 +-
 include/database/poste_analytique_sql.class.php   |   4 +
 unit-test/include/class/anc_accountTest.class.php | 176 -----------
 8 files changed, 17 insertions(+), 559 deletions(-)

diff --git a/html/style-r692.css b/html/style-r692.css
index 3681dba..5026e17 100644
--- a/html/style-r692.css
+++ b/html/style-r692.css
@@ -7,6 +7,11 @@
        src: url('image/SansationLight/SansationLight.eot');
        src: local('SansationLight'), 
url('image/SansationLight/SansationLight.woff') format('woff'), 
url('image/SansationLight/SansationLight.ttf') format('truetype');
 }
address@hidden {
+       font-family: 'OpenSansRegular';
+       src: url('image/OpenSansRegular.eot');
+       src: local('OpenSansRegular'), url('image/OpenSansRegular.woff') 
format('woff'), url('image/OpenSansRegular.ttf') format('truetype');
+}
 /* use this class to attach this font to any element i.e. <p 
class="fontsforweb_fontid_38327">Text with this font applied</p> */
 .fontsforweb_fontid_38327 {
        font-family: 'OpenSansRegular' !important;
@@ -14,7 +19,7 @@
 
 BODY {
     font-family: Arial, Helvetica, "Liberation Sans"  , FreeSans, sans-serif;
-    font-family: 'SansationLight';
+    font-family: 'OpenSansRegular';
     padding : 0px;
     margin:0px;
     color:#0000FF; 
@@ -22,7 +27,7 @@ BODY {
     font-size:0.95rem;*/
 }
 input{
-    font-family: 'SansationLight';
+    font-family: 'OpenSansRegular';
     padding : 3px;
     margin:3px;
     color:#0000FF; 
@@ -55,7 +60,7 @@ table.resultfooter tfoot {
 table.sortable th,  table.table_large th,table.result th {
     font-weight:bold;
     font-family: Arial, Helvetica, "Liberation Sans", FreeSans, sans-serif;
-    font-family: 'SansationLight';
+    font-family: 'OpenSansRegular';
     border-bottom:2px #5d90cd groove;
     border-top:0;
 
@@ -223,7 +228,7 @@ div.redcontent{
     padding-top:7px;
     padding-left:8px;
     font-family: Arial, Helvetica, "Liberation Sans", FreeSans, sans-serif;
-    font-family: 'SansationLight';
+    font-family: 'OpenSansRegular';
     width:75%;
 
 }
@@ -232,7 +237,7 @@ div.content{
     margin-top:0.0030%;
     width:100%;
     font-family: Arial, Helvetica, "Liberation Sans", FreeSans, sans-serif;
-    font-family: 'SansationLight';
+    font-family: 'OpenSansRegular';
     font-size:12px;
     font-size:0.90rem;
 
diff --git a/include/ajax/ajax_anc_search.php b/include/ajax/ajax_anc_search.php
index da39916..4eb42f1 100644
--- a/include/ajax/ajax_anc_search.php
+++ b/include/ajax/ajax_anc_search.php
@@ -34,7 +34,6 @@ require_once NOALYSS_INCLUDE.'/lib/ibutton.class.php';
 require_once NOALYSS_INCLUDE.'/lib/database.class.php';
 require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
 require_once NOALYSS_INCLUDE.'/class/dossier.class.php';
-require_once NOALYSS_INCLUDE.'/class/anc_account.class.php';
 require_once NOALYSS_INCLUDE.'/class/anc_plan.class.php';
 require_once NOALYSS_INCLUDE.'/lib/function_javascript.php';
 require_once NOALYSS_INCLUDE.'/lib/http_input.class.php';
diff --git a/include/anc_od.inc.php b/include/anc_od.inc.php
index 5a51c3e..02fe6af 100644
--- a/include/anc_od.inc.php
+++ b/include/anc_od.inc.php
@@ -28,7 +28,6 @@
 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
 require_once NOALYSS_INCLUDE.'/lib/ihidden.class.php';
 require_once NOALYSS_INCLUDE.'/lib/iselect.class.php';
-require_once NOALYSS_INCLUDE.'/class/anc_account.class.php';
 require_once  NOALYSS_INCLUDE.'/class/anc_operation.class.php';
 require_once  NOALYSS_INCLUDE.'/class/anc_plan.class.php';
 require_once  NOALYSS_INCLUDE.'/class/anc_group_operation.class.php';
diff --git a/include/class/anc_account.class.php 
b/include/class/anc_account.class.php
deleted file mode 100644
index a070cfb..0000000
--- a/include/class/anc_account.class.php
+++ /dev/null
@@ -1,352 +0,0 @@
-<?php
-/*
- *   This file is part of NOALYSS.
- *
- *   NOALYSS 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.
- *
- *   NOALYSS 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 NOALYSS; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-
-// Copyright Author Dany De Bontridder address@hidden
-
-/*!\file
-*\brief contains the object for the poste_analytique (table poste_analytique)
- */
-
-/*!\brief contains the object for the poste_analytique (table poste_analytique)
- *
- */
-require_once NOALYSS_INCLUDE.'/lib/ihidden.class.php';
-require_once NOALYSS_INCLUDE.'/lib/itext.class.php';
-require_once NOALYSS_INCLUDE.'/lib/iselect.class.php';
-require_once NOALYSS_INCLUDE.'/lib/ispan.class.php';
-require_once NOALYSS_INCLUDE.'/lib/database.class.php';
-require_once NOALYSS_INCLUDE.'/class/anc_plan.class.php';
-
-class Anc_Account
-{
-    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 __construct($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=$this->db->exec_sql($sql);
-        if ( Database::num_row($ret) == 0 )return null;
-        $line=Database::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=sql_string($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 ($1,$2,$3,$4,$5)";
-
-        try
-        {
-            
$this->db->exec_sql($sql,array($this->name,$this->pa_id,$this->amount,$this->description,$ga_id));
-
-        }
-        catch (Exception $e)
-        {
-            record_log($e->getTraceAsString());
-            if ( DEBUG ) print_r($e);
-            echo "<p class=\"notice\">Doublon : l'enregistrement n'est pas 
sauve</p>";
-        }
-
-    }
-    static function make_array_name($cn,$pa_id)
-    {
-        $a=$cn->make_array("select  po_name,po_name from poste_analytique ".
-                           " where ".
-                           " pa_id = $1 order by po_name ",0,array($pa_id));
-        return $a;
-    }
-    function update()
-    {
-        $this->format_data();
-        if ( strlen($this->name) == 0)
-            return;
-        $sql="update poste_analytique ".
-             " set po_name=$1".
-             " ,pa_id=$2".
-             " ,po_amount=$3".
-             " ,po_description=$4".
-             " ,ga_id=$5".
-             " where po_id=$6";
-        try
-        {
-            
$this->db->exec_sql($sql,array($this->name,$this->pa_id,$this->amount,
-                                           
$this->description,$this->ga_id,$this->id));
-        }
-        catch (Exception $e)
-        {
-            record_log($e->getTraceAsString());
-            echo "<p class=\"notice\">Doublon : l'enregistrement n'est pas 
sauve</p>";
-        }
-
-    }
-    private function format_data()
-    {
-
-        $this->name=$this->name;
-        $this->pa_id=$this->pa_id;
-        $this->amount=$this->amount;
-        if (strlen($this->amount) == 0 )
-            $this->amount=0.0;
-        if ( isNumber($this->amount) ==0 )
-            $this->amount=0;
-
-        $this->description=$this->description;
-    }
-    function delete()
-    {
-        $sql="delete from poste_analytique where po_id=".$this->id;
-        $this->db->exec_sql($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=$this->db->exec_sql($sql);
-        $ret=Database::fetch_all($ex);
-        if ( $ret  == null )
-            return null;
-
-        $array=array();
-        foreach ($ret as $line)
-        {
-            $object=new Anc_Account($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()
-    {
-        $r='';
-        $wName=new IText("po_name",$this->name);
-        $wAmount=new INum("po_amount",$this->amount);
-        $wDescription=new IText("po_description",$this->description);
-        //@bug
-        $aGroup_analytic=$this->db->make_array("select ga_id,ga_id from 
groupe_analytique where pa_id=$1",1,array($this->pa_id));
-        if ( count($aGroup_analytic) > 1 )
-        {
-            $wGa_id=new ISelect("ga_id");
-            $wGa_id->value=$aGroup_analytic;
-            $wGa_id->selected=$this->ga_id;
-            $wGa_id->table=1;
-        }
-        else
-        {
-            $wGa_id=new ISpan();
-        }
-        $pa=new Anc_Plan($this->db,$this->pa_id);
-        $pa->get();
-        $wPaName=new IText("",$pa->name);
-        $wPaName->table=1;
-        $wPaName->readOnly=true;
-
-        $wName->table=1;
-        $wAmount->table=1;
-        $wDescription->table=1;
-        $r.=HtmlInput::hidden("pa_id",$this->pa_id);
-        $r.=HtmlInput::hidden("po_id",$this->id);
-
-        $r.="<table>";
-
-        $r.="<tr>";
-        $r.=td(_('Nom'));
-        $r.=$wName->input();
-        $r.="</tr>";
-
-        $r.="<tr>";
-        $r.=td(_('Montant'));
-        $r.=$wAmount->input();
-        $r.="</tr>";
-
-
-        $r.="<tr>";
-        $r.=td(_('Description'));
-        $r.=$wDescription->input();
-        $r.="</tr>";
-
-        $r.="<tr>";
-        $r.=td(_('Plan Analytique'));
-        $r.=$wPaName->input();
-        $r.="</tr>";
-
-        $r.="<tr>";
-        $r.=td(_('Groupe'));
-        $r.=$wGa_id->input();
-        $r.="</tr>";
-
-        $r.="</table>";
-        return $r;
-
-    }
-    function get_from_array($p_array)
-    {
-        $this->name=(isset ($p_array['po_name']))?$p_array['po_name']:"";
-        $this->description=(isset 
($p_array['po_description']))?$p_array['po_description']:"";
-        $this->pa_id=(isset ($p_array['pa_id']))?$p_array['pa_id']:"";
-        $this->amount=(isset ($p_array['po_amount']))?$p_array['po_amount']:0;
-        $this->id=(isset ($p_array['po_id']))?$p_array['po_id']:-1;
-        //    $this->ga_id=(isset($p_array['ga_id']) && $p_array['ga_id'] == 
"-1" )?null:2;
-        $this->ga_id=(isset($p_array['ga_id']) && $p_array['ga_id'] != "-1" 
)?$p_array['ga_id']:null;
-    }
-    static function test_me()
-    {
-        $cn=Dossier::connect();
-        $pa_id=$cn->get_value("select max(pa_id) from plan_analytique");
-        $o=new Anc_Account($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();
-    }
-}
-?>
diff --git a/include/class/anc_account_table.class.php 
b/include/class/anc_account_table.class.php
index 97f9e67..d5267cd 100644
--- a/include/class/anc_account_table.class.php
+++ b/include/class/anc_account_table.class.php
@@ -74,8 +74,8 @@ class Anc_Account_Table extends Manage_Table_SQL
         $table->po_name=str_replace(">", '', $table->po_name);
         
         // po_name must be uniq in the Analytic Plan
-        if ( $cn->get_value("select count(*) from poste_analytique where 
pa_id=$1 and po_name=$2",
-                array($table->pa_id,$table->po_name)) > 0 && $table->po_id==-1)
+        if ( $cn->get_value("select count(*) from poste_analytique where 
pa_id=$1 and po_name=$2 and po_id != $3",
+                array($table->pa_id,$table->po_name,$table->po_id)) > 0)
         {
             $is_error++;
             $this->set_error("po_name", _("Le nom doit être unique dans un 
plan analytique"));
diff --git a/include/class/anc_plan.class.php b/include/class/anc_plan.class.php
index e3c85d6..f5ff21a 100644
--- a/include/class/anc_plan.class.php
+++ b/include/class/anc_plan.class.php
@@ -30,7 +30,7 @@ require_once NOALYSS_INCLUDE.'/lib/itext.class.php';
 require_once NOALYSS_INCLUDE.'/lib/ihidden.class.php';
 require_once NOALYSS_INCLUDE.'/constant.php';
 require_once NOALYSS_INCLUDE.'/lib/database.class.php';
-require_once NOALYSS_INCLUDE.'/class/anc_account.class.php';
+require_once NOALYSS_INCLUDE.'/database/poste_analytique_sql.class.php';
 require_once  NOALYSS_INCLUDE.'/class/dossier.class.php';
 
 class Anc_Plan
@@ -134,27 +134,6 @@ class Anc_Plan
         else
             return true;
     }
-    /*!\brief get all the poste related to the current
-     *        Analytic plan
-     * \return an array of Poste_analytic object
-     */
-    function get_poste_analytique($p_order="")
-    {
-        $sql="select po_id,po_name from poste_analytique where pa_id=$1 
$p_order";
-        $r=$this->db->exec_sql($sql,array($this->id));
-        $ret=array();
-        if ( Database::num_row($r) == 0 )
-            return $ret;
-
-        $all=Database::fetch_all($r);
-        foreach ($all as $line)
-        {
-            $obj=new Anc_Account($this->db,$line['po_id']);
-            $obj->get_by_id();
-            $ret[]=clone $obj;
-        }
-        return $ret;
-    }
     /*!\brief show the header for a table for PA
      * \return string like <th>name</th>...
      */
diff --git a/include/database/poste_analytique_sql.class.php 
b/include/database/poste_analytique_sql.class.php
index ba9ab30..af1184f 100644
--- a/include/database/poste_analytique_sql.class.php
+++ b/include/database/poste_analytique_sql.class.php
@@ -28,6 +28,10 @@
  * 
  * @class
  * @brief abstract of the table public.poste_analytique */
+require_once NOALYSS_INCLUDE.'/lib/database.class.php';
+require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
+require_once NOALYSS_INCLUDE.'/lib/noalyss_sql.class.php';
+
 class Poste_analytique_SQL extends Noalyss_SQL
 {
 
diff --git a/unit-test/include/class/anc_accountTest.class.php 
b/unit-test/include/class/anc_accountTest.class.php
deleted file mode 100644
index b818ed7..0000000
--- a/unit-test/include/class/anc_accountTest.class.php
+++ /dev/null
@@ -1,176 +0,0 @@
-<?php
-
-/**
- * Generated by PHPUnit_SkeletonGenerator on 2014-11-08 at 14:21:16.
- */
-class Anc_AccountTest extends PHPUnit_Framework_TestCase
-{
-
-    /**
-     * @var Anc_Account
-     */
-    protected $object;
-
-    /**
-     * Sets up the fixture, for example, opens a network connection.
-     * This method is called before a test is executed.
-     */
-    protected function setUp()
-    {
-        $this->object=new Anc_Account;
-    }
-
-    /**
-     * Tears down the fixture, for example, closes a network connection.
-     * This method is called after a test is executed.
-     */
-    protected function tearDown()
-    {
-        
-    }
-
-    /**
-     * @covers Anc_Account::get_by_id
-     * @todo   Implement testGet_by_id().
-     */
-    public function testGet_by_id()
-    {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
-    }
-
-    /**
-     * @covers Anc_Account::get_by_name
-     * @todo   Implement testGet_by_name().
-     */
-    public function testGet_by_name()
-    {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
-    }
-
-    /**
-     * @covers Anc_Account::add
-     * @todo   Implement testAdd().
-     */
-    public function testAdd()
-    {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
-    }
-
-    /**
-     * @covers Anc_Account::make_array_name
-     * @todo   Implement testMake_array_name().
-     */
-    public function testMake_array_name()
-    {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
-    }
-
-    /**
-     * @covers Anc_Account::update
-     * @todo   Implement testUpdate().
-     */
-    public function testUpdate()
-    {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
-    }
-
-    /**
-     * @covers Anc_Account::delete
-     * @todo   Implement testDelete().
-     */
-    public function testDelete()
-    {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
-    }
-
-    /**
-     * @covers Anc_Account::get_list
-     * @todo   Implement testGet_list().
-     */
-    public function testGet_list()
-    {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
-    }
-
-    /**
-     * @covers Anc_Account::display_list
-     * @todo   Implement testDisplay_list().
-     */
-    public function testDisplay_list()
-    {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
-    }
-
-    /**
-     * @covers Anc_Account::debug
-     * @todo   Implement testDebug().
-     */
-    public function testDebug()
-    {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
-    }
-
-    /**
-     * @covers Anc_Account::form
-     * @todo   Implement testForm().
-     */
-    public function testForm()
-    {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
-    }
-
-    /**
-     * @covers Anc_Account::get_from_array
-     * @todo   Implement testGet_from_array().
-     */
-    public function testGet_from_array()
-    {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
-    }
-
-    /**
-     * @covers Anc_Account::test_me
-     * @todo   Implement testTest_me().
-     */
-    public function testTest_me()
-    {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
-    }
-
-}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]