From 4b0938b1f36d86b648832d441c5610064d8e5d86 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 24 Sep 2017 09:59:10 +0200 Subject: [PATCH] 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 +- .../database/poste_analytique_sql.class.php | 4 + .../include/class/anc_accountTest.class.php | 176 --------- 8 files changed, 17 insertions(+), 559 deletions(-) delete mode 100644 include/class/anc_account.class.php delete mode 100644 unit-test/include/class/anc_accountTest.class.php diff --git a/html/style-r692.css b/html/style-r692.css index 3681dba50..5026e17b3 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'); } +@font-face { + 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.

Text with this font applied

*/ .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 da399162d..4eb42f166 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 5a51c3e79..02fe6afef 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 a070cfb69..000000000 --- a/include/class/anc_account.class.php +++ /dev/null @@ -1,352 +0,0 @@ -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 "

Doublon : l'enregistrement n'est pas sauve

"; - } - - } - 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 "

Doublon : l'enregistrement n'est pas sauve

"; - } - - } - 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."
"; - } - } - function debug() - { - echo "id ".$this->id."
"; - echo "name ".$this->name."
"; - echo "pa_id ".$this->pa_id."
"; - echo "amount ".$this->amount."
"; - echo "description ".$this->description."
"; - echo "ga_id ".$this->ga_id."
"; - } - 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.=""; - - $r.=""; - $r.=td(_('Nom')); - $r.=$wName->input(); - $r.=""; - - $r.=""; - $r.=td(_('Montant')); - $r.=$wAmount->input(); - $r.=""; - - - $r.=""; - $r.=td(_('Description')); - $r.=$wDescription->input(); - $r.=""; - - $r.=""; - $r.=td(_('Plan Analytique')); - $r.=$wPaName->input(); - $r.=""; - - $r.=""; - $r.=td(_('Groupe')); - $r.=$wGa_id->input(); - $r.=""; - - $r.="
"; - 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 "

Poste_Analytique

"; - echo "

get_list

"; - $ee=$o->get_list(); - print_r($ee); - //var_dump($ee); - - echo "

Add some

"; - $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 "

remove test1

"; - $o->get_by_name("test1"); - $o->delete(); - $o->display_list(); - - $o->get_by_name("test4"); - echo "
".$o->id."
"; - $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 97f9e673c..d5267cdd9 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 e3c85d645..f5ff21a53 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 name... */ diff --git a/include/database/poste_analytique_sql.class.php b/include/database/poste_analytique_sql.class.php index ba9ab3078..af1184f39 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 b818ed790..000000000 --- a/unit-test/include/class/anc_accountTest.class.php +++ /dev/null @@ -1,176 +0,0 @@ -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.' - ); - } - -}