noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 09/15: Cosmetic & code cleaning


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 09/15: Cosmetic & code cleaning
Date: Mon, 25 Jan 2021 18:56:22 -0500 (EST)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 957a19247b535467c60e670dd26dcac2f542d2ac
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Sun Jan 24 10:19:29 2021 +0100

    Cosmetic & code cleaning
---
 html/style-classic7.css                | 35 ++++++++------
 include/ajax/ajax_card.php             | 41 ++++++++--------
 include/balance.inc.php                | 34 ++++++++------
 include/class/acc_ledger.class.php     |  4 +-
 include/class/fiche.class.php          | 85 ++++++++++++++++++++--------------
 include/class/pre_operation.class.php  |  2 +-
 include/fiche.inc.php                  |  2 +-
 include/history_operation.inc.php      |  4 +-
 include/template/letter_all.php        |  2 +-
 include/template/letter_prop.php       |  2 +-
 scenario/select-box-test.php           | 31 +++++++++++++
 unit-test/include/class/fiche.Test.php | 32 ++++++++++++-
 12 files changed, 184 insertions(+), 90 deletions(-)

diff --git a/html/style-classic7.css b/html/style-classic7.css
index 6bb8ce0..c3612dc 100644
--- a/html/style-classic7.css
+++ b/html/style-classic7.css
@@ -264,6 +264,7 @@ td.mtitle {
     border-bottom-left-radius: 0px;
 
     border-collapse: collapse;
+    background-color: #366497;
 }
 @media only screen and (max-width:1250px) {
     td.mtitle {
@@ -278,7 +279,7 @@ td.mtitle {
     }
 }
 td.mtitle a.mtitle {
-    color : white;
+    color : lightgray;
     display:block;
     font-size:1rem;
     font-family:OpenSansRegular;
@@ -517,7 +518,7 @@ a.document:hover {
     margin:1px;
 }
 .input_text {
-    border:solid text #4b4b91;
+    border:1px solid #4b4b91;
     margin:1px;
     border-radius: 2px;
 }
@@ -922,7 +923,7 @@ div.inner_box  {
 /*! -webkit-box-shadow: 10px 10px 5px #888; */
 box-shadow: 15px 15px 15px #888;
 font-size:14.4px;
-font-size:0.90rem;
+font-size:0.9rem;
 }
 div.inner_box  {
     width: 85%;
@@ -930,7 +931,7 @@ div.inner_box  {
 @media only screen and (min-width: 1281px) {
 div.inner_box  {
     width: 85%;
-    /*! border-radius: 9px; */
+     border-radius: 9px; 
     /*! padding: 5px; */
     }
 }
@@ -1230,17 +1231,25 @@ h1.title {
 }
 h2.title {
  
-    color:#FFFFFF;
+    color:white;
     text-align:center;
   
     
     padding-top: 9px;
     margin-top: 0px;
     padding-bottom: 2px;
-    background-color: #366497;
-    font-size: 1.05rem;
+    background-color: #5681B7;
+    font-size: 1.1rem;
     height: 25px;
     vertical-align: middle;
+    border-bottom: white;
+    border-bottom-style: groove;
+    border-bottom-width: 2px;
+    font-style: normal;
+    font-stretch: normal;
+    font-variant-caps: all-small-caps;
+    font-family: OpenSansRegular;
+    margin-bottom: 1px;
 }
 h3.title {
     color: #0000FF;
@@ -1304,7 +1313,7 @@ div.menu2 a.mtitle:hover {
     /*! padding: 5px; */
 }
 div.menu2 table {
-    border-collapse: collapse;
+    border-collapse: separate;
     /*! border-spacing:1px; */
 }
 div.menu3 {
@@ -1977,8 +1986,8 @@ td.box {
   right: 0px;
   visibility: hidden;
   opacity: 0;
-  background: rgba(0,0,0,.3);
-  filter: 
progid:DXImageTransform.Microsoft.gradient(startColorstr=#90000000,endColorstr=#900000000);
+  background-color: rgba(0,0,0,.3);
+  filter: 
progid:DXImageTransform.Microsoft.gradient(startColorstr=#90000000,endColorstr=#90000000);
 }
 
 .smoke-base.smoke-visible {
@@ -2257,7 +2266,7 @@ div.menu2 td.mtitle, div.menu2 td.mtitle a{
     border-width: 0.1px;
     border-color:white;
     height:25px;
-    /*! border-radius: 0px 0px 0px 10px; */
+    border-radius: 4px 4px 4px 4px;
 }
 div.menu2 td.mtitle a{
     border-width:0px;
@@ -2282,7 +2291,7 @@ div.menu2 td.mtitle a{
  */
 div.bxbutton .icon
 {
-    color:white;
+    /*! color:white; */
     text-decoration:none;
     margin-left: 6px;
     margin-right:6px;
@@ -2292,6 +2301,7 @@ div.bxbutton .icon
     cursor: pointer;
     border:0px;
     height: 18px;
+    color: #f0d19a;
 }
 div.bxbutton .icon:hover
 {
@@ -2488,7 +2498,6 @@ p.info {
 /* Cell with tag */
 span.tagcell {
     border-radius:3px;
-    border:1px solid darkblue;
     padding:3px;margin:1px;
     display: inline-block;
 }    
diff --git a/include/ajax/ajax_card.php b/include/ajax/ajax_card.php
index 3c0e86d..ce42ebc 100644
--- a/include/ajax/ajax_card.php
+++ b/include/ajax/ajax_card.php
@@ -110,14 +110,18 @@ switch($op2)
 case 'dc':
     $f=new Fiche($cn);
     /* add title + close */
-    $html=HtmlInput::title_box(_("Détail fiche"), $ctl,"close","","y");
-    
+    $qcode=$http->request("qcode","string",false);
     // if there is no qcode then try to find it thanks the card id
-    if ( ! isset ($qcode) ){
+    if ( $qcode == false ){
         $f->id=$http->get("f_id","number");
         $qcode=$f->get_quick_code();
+    } else {
+        $f->get_by_qcode($qcode);
+
     }
-    
+    $title=$f->getLabelCategory();
+    $html=HtmlInput::title_box($title, $ctl,"close","","y");
+
     // after save , we can either show a card in readonly or update a row
     $safter_save=$http->request("after_save","string","1");
     switch ($safter_save)
@@ -134,22 +138,21 @@ case 'dc':
             break;
     }
 
-    if ( $qcode != '')
+    if ( $qcode != null)
     {
-        $f->get_by_qcode($qcode);
-       $can_modify=$g_user->check_action(FIC);
-       if ( isset($ro) )
-         {
-           $can_modify=0;
-         }
-       if ( $can_modify==1)
-         $card=$f->Display(false,$ctl);
-       else
-         $card=$f->Display(true);
-       if ( $card == 'FNT' )
-         {
-           $html.='<h2 class="error">'._('Fiche non trouvée').'</h2>';
-         }
+        $can_modify=$g_user->check_action(FIC);
+        if ( isset($ro) )
+          {
+            $can_modify=0;
+          }
+        if ( $can_modify==1)
+          $card=$f->Display(false,$ctl);
+        else
+          $card=$f->Display(true);
+        if ( $card == 'FNT' )
+          {
+            $html.='<h2 class="error">'._('Fiche non trouvée').'</h2>';
+          }
        else
          {
 
diff --git a/include/balance.inc.php b/include/balance.inc.php
index f5eec77..2b38736 100644
--- a/include/balance.inc.php
+++ b/include/balance.inc.php
@@ -207,7 +207,11 @@ if ( isset ($_GET['view']  ) )
 {
 
     $hid=new IHidden();
-
+    $from_periode=$http->get("from_periode","number");
+    $to_periode=$http->get("to_periode","number");
+    $from_poste=$http->get("from_poste","string");
+    $to_poste=$http->get("to_poste","string");
+    $p_filter=$http->get("p_filter");
 
     echo "<table>";
     echo '<TR>';
@@ -217,9 +221,9 @@ if ( isset ($_GET['view']  ) )
     HtmlInput::hidden("ac",$_REQUEST['ac']).
     HtmlInput::hidden("act","PDF:balance").
             HtmlInput::hidden("summary", $is_summary).
-    HtmlInput::hidden("from_periode",$_GET['from_periode']).
-    HtmlInput::hidden("to_periode",$_GET['to_periode']);
-    echo HtmlInput::hidden('p_filter',$_GET['p_filter']);
+    HtmlInput::hidden("from_periode",$from_periode).
+    HtmlInput::hidden("to_periode",$to_periode);
+    echo HtmlInput::hidden('p_filter',$p_filter);
     for ($e=0;$e<count($selected);$e++)
         if (isset($selected[$e]) && in_array ($selected[$e],$array))
             echo    HtmlInput::hidden("r_jrn[$e]",$selected[$e]);
@@ -227,8 +231,8 @@ if ( isset ($_GET['view']  ) )
         if (isset($select_cat[$e]))
             echo    HtmlInput::hidden("r_cat[$e]",$e);
 
-    echo HtmlInput::hidden("from_poste",$_GET['from_poste']).
-    HtmlInput::hidden("to_poste",$_GET['to_poste']);
+    echo HtmlInput::hidden("from_poste",$from_poste).
+    HtmlInput::hidden("to_poste",$to_poste);
     echo 
HtmlInput::get_to_hidden(array('lvl1','lvl2','lvl3','unsold','previous_exc'));
 
     echo "</form></TD>";
@@ -237,10 +241,10 @@ if ( isset ($_GET['view']  ) )
     HtmlInput::submit('bt_csv',"Export CSV").
     dossier::hidden().
     HtmlInput::hidden("act","CSV:balance").
-    HtmlInput::hidden("from_periode",$_GET['from_periode']).
-    HtmlInput::hidden("to_periode",$_GET['to_periode']);
+    HtmlInput::hidden("from_periode",$from_periode).
+    HtmlInput::hidden("to_periode",$to_periode);
     echo HtmlInput::get_to_hidden(array('ac'));
-    echo HtmlInput::hidden('p_filter',$_GET['p_filter']);
+    echo HtmlInput::hidden('p_filter',$p_filter);
     for ($e=0;$e<count($selected);$e++){
         if (isset($selected[$e]) && in_array ($selected[$e],$array)){
                 echo    HtmlInput::hidden("r_jrn[$e]",$selected[$e]);
@@ -250,8 +254,8 @@ if ( isset ($_GET['view']  ) )
         if (isset($select_cat[$e]))
             echo    HtmlInput::hidden("r_cat[$e]",$e);
 
-    echo   HtmlInput::hidden("from_poste",$_GET['from_poste']).
-    HtmlInput::hidden("to_poste",$_GET['to_poste']);
+    echo   HtmlInput::hidden("from_poste",$from_poste).
+    HtmlInput::hidden("to_poste",$to_poste);
     echo HtmlInput::get_to_hidden(array('unsold','previous_exc'));
 
     echo "</form></TD>";
@@ -295,9 +299,11 @@ if ( isset($_GET['view'] ) )
     $previous= (isset ($row[0]['sum_cred_previous']))?1:0;
 
     $periode=new Periode($cn);
-    $a=$periode->get_date_limit($_GET['from_periode']);
-    $b=$periode->get_date_limit($_GET['to_periode']);
-    echo "<h2 class=\"info\"> période du ".$a['p_start']." au 
".$b['p_end']."</h2>";
+    $a=$periode->get_date_limit($from_periode);
+    $b=$periode->get_date_limit($to_periode);
+    echo '<h2>';
+    printf ( _("période du %s au %s"),$a['p_start'],$b['p_end']);
+    echo '</h2>';
        echo '<span style="display:block">';
        echo _('Cherche').Icon_Action::infobulle(24);
        echo HtmlInput::filter_table("t_balance", "0,1","1");
diff --git a/include/class/acc_ledger.class.php 
b/include/class/acc_ledger.class.php
index ae10b90..ce5ef05 100644
--- a/include/class/acc_ledger.class.php
+++ b/include/class/acc_ledger.class.php
@@ -883,7 +883,7 @@ class Acc_Ledger  extends jrn_def_sql
         $ret.=HtmlInput::hidden('jrn_type', $this->get_type());
         $info=Icon_Action::infobulle(0);
         $info_poste=Icon_Action::infobulle(9);
-        $ret.='<table id="quick_item" style="position:float;width:100%">';
+        $ret.='<table id="quick_item" style="width:100%">';
         $ret.='<tr>'.
                 '<th style="text-align:left">Quickcode'.$info.'</th>'.
                 '<th style="text-align:left">'._('Poste').$info_poste.'</th>'.
@@ -2040,7 +2040,7 @@ class Acc_Ledger  extends jrn_def_sql
                 echo '<input type="hidden" value="'.$id.'" name="p_jrn">';
                 $op=new Pre_operation($cn);
                 $op->p_jrn=$id;
-                $op->od_direct='t';
+
                 if ($op->count()!=0)
                 {
                     echo HtmlInput::submit('use_opd',
diff --git a/include/class/fiche.class.php b/include/class/fiche.class.php
index e4942bb..d6a7549 100644
--- a/include/class/fiche.class.php
+++ b/include/class/fiche.class.php
@@ -20,7 +20,7 @@
 
 
 // Copyright Author Dany De Bontridder danydb@aevalys.eu
-include_once("class/fiche_attr.class.php");
+require_once NOALYSS_INCLUDE."/class/fiche_attr.class.php";
 require_once NOALYSS_INCLUDE.'/lib/ispan.class.php';
 require_once NOALYSS_INCLUDE.'/lib/itva_popup.class.php';
 require_once NOALYSS_INCLUDE.'/lib/itext.class.php';
@@ -60,7 +60,7 @@ class Fiche
         $this->id=$p_id;
         $this->quick_code='';
         $this->attribut=array();
-        $f_enable='1';
+        $this->f_enable='1';
     }
     public function get_id()
     {
@@ -162,8 +162,8 @@ class Fiche
     /**
      *@brief set an attribute by a value, if the attribut array is empty
      * a call to getAttribut is performed
-     *@param the AD_ID
-     *@param the value
+     *@param int  AD_ID
+     *@param int value
      *@see constant.php table: attr_def
      */
     function setAttribut($p_ad_id,$p_value)
@@ -253,9 +253,9 @@ class Fiche
     }
     /**
      * @brief find the card with the p_attribut equal to p_value, it is not 
case sensitive
-     * @param $p_attribut attribute to find see table attr_def
-     * @param $p_value value in attr_value.av_text
-     * @return return ARRAY OF jft_id,f_id,fd_id,ad_id,av_text
+     * @param int $p_attribut attribute to find see table attr_def
+     * @param string $p_value value in attr_value.av_text
+     * @return array returns ARRAY OF jft_id,f_id,fd_id,ad_id,av_text
      */
     function seek($p_attribut,$p_value)
     {
@@ -281,30 +281,36 @@ class Fiche
 
     /*!
      **************************************************
-     * \brief  Return array of card from the frd family
+     * \brief  Count the nb of card with the reference card id frd_id
      *
      * \param $p_frd_id the fiche_def_ref.frd_id
      * \param $p_search p_search is a filter on the name
      * \param $p_sql extra sql condition
      *
-     * \return array of fiche object
+     * \return nb of item found
      */
     function count_by_modele($p_frd_id,$p_search="",$p_sql="")
     {
-        $sql="select *
-             from
-             fiche join fiche_Def using (fd_id)
-             where frd_id=".$p_frd_id;
+
         if ( $p_search != "" )
         {
-            $a=sql_string($p_search);
-            $sql="select * from vw_fiche_attr where frd_id=".$p_frd_id.
-                 " and vw_name ilike '%$p_search%'";
+            $result = $this->cn->get_value("select count(*) from 
+                        vw_fiche_attr 
+                        where 
+                        frd_id=$1 
+                        and vw_name ilike '%'||$2||'%'",
+                    [$p_frd_id,$p_search]);
+            return $result;
+        } else {
+            $result = $this->cn->get_value("select count(*)
+                                 from
+                                 fiche join fiche_Def using (fd_id)
+                                 where frd_id=$1 ".sql_string($p_sql)
+                ,[$p_frd_id]);
+            return $result;
         }
 
-        $Ret=$this->cn->exec_sql($sql.$p_sql);
 
-        return Database::num_row($Ret) ;
     }
     /*!
      **************************************************
@@ -375,8 +381,8 @@ class Fiche
     /***
      * @brief  return the string of the given attribute
      *        (attr_def.ad_id)
-     * @param $p_ad_id the AD_ID from attr_def.ad_id
-     * @param $p_return 1 return NOTFOUND otherwise an empty string
+     * @param int  $p_ad_id  AD_ID from attr_def.ad_id
+     * @param int $p_return 1 return NOTFOUND otherwise an empty string
      * @see constant.php
      * @return string
      */
@@ -591,6 +597,17 @@ class Fiche
         return $r;
     }
 
+    /**
+     *
+     * @return string with the category
+     */
+    function getLabelCategory()
+    {
+        $type_card=$this->cn->get_value('select fd_label '
+            . ' from fiche_def join fiche using (fd_id) where f_id=$1',
+            array($this->id));
+        return $type_card;
+    }
 
     /*!
      * \brief  Display object instance, getAttribute
@@ -605,14 +622,9 @@ class Fiche
     {
         $this->GetAttribut();
         $attr=$this->attribut;
-        /* show card type here */
-        $type_card=$this->cn->get_value('select fd_label '
-                . ' from fiche_def join fiche using (fd_id) where f_id=$1',
-                array($this->id));
         $ret="";
-        $ret.=h2(_("Catégorie")." ".$type_card, 'style="display:inline"');
-        $ret.='<span style="margin-right:5px;float:right">'.
-                _('id fiche').':'.$this->id."</span>";
+        $ret.='<span style="margin-right:5px;float:right;font-size:80%">'.
+                _('id').':'.$this->id."</span>";
         $ret.="<table style=\"width:98%;margin:1%\">";
         if (empty($attr))
         {
@@ -849,8 +861,12 @@ class Fiche
         try
         {
             $this->cn->start();
-            
-            $Ret=$this->cn->exec_sql("insert into fiche(f_id,f_enable,fd_id) 
value ($1,$2,$3)",
+
+            // by default the card is available
+            if ( !isset ($p_array['f_enable'])) {
+                $p_array['f_enable']=1;
+            }
+            $Ret=$this->cn->exec_sql("insert into fiche(f_id,f_enable,fd_id) 
values ($1,$2,$3)",
                     array($fiche_id, $p_array['f_enable'],$p_fiche_def));
             
             // parse the $p_array array
@@ -1806,6 +1822,7 @@ class Fiche
     function Summary($p_search="",$p_action="",$p_sql="",$p_amount=false)
     {
         global $g_user;
+        $http=new HttpInput();
         $bank=new Acc_Parm_Code($this->cn,'BANQUE');
         $cash=new Acc_Parm_Code($this->cn,'CAISSE');
         $cc=new Acc_Parm_Code($this->cn,'COMPTE_COURANT');
@@ -1826,8 +1843,8 @@ class Fiche
 
         
$all_tiers=$this->count_by_modele($this->fiche_def_ref,"",$p_sql.$filter_amount);
         // Get offset and page variable
-        $offset=( isset ($_REQUEST['offset'] )) ?$_REQUEST['offset']:0;
-        $page=(isset($_REQUEST['page']))?$_REQUEST['page']:1;
+        $offset=$http->request("offset","number",0);
+        $page=$http->request("page","number",1);
         
$bar=navigation_bar($offset,$all_tiers,$_SESSION[SESSION_KEY.'g_pagesize'],$page);
 
         // set a filter ?
@@ -2140,7 +2157,7 @@ class Fiche
                 {
                     case 'cred':
                         if (!isset($jrn))
-                            throw ('Erreur pas de valeur pour jrn');
+                            throw Exception('Erreur pas de valeur pour jrn');
                         $filter_jrn=$this->cn->make_list("select 
jrn_def_fiche_cred from jrn_Def where jrn_def_id=$1",
                                 array($jrn));
                         $filter_fd_id=" fd_id in (".$filter_jrn.")";
@@ -2148,7 +2165,7 @@ class Fiche
                         break;
                     case 'deb':
                         if (!isset($jrn))
-                            throw ('Erreur pas de valeur pour jrn');
+                            throw Exception('Erreur pas de valeur pour jrn');
                         $filter_jrn=$this->cn->make_list("select 
jrn_def_fiche_deb from jrn_Def where jrn_def_id=$1",
                                 array($jrn));
                         $filter_fd_id=" fd_id in (".$filter_jrn.")";
@@ -2156,7 +2173,7 @@ class Fiche
                         break;
                     case 'filter':
                         if (!isset($jrn))
-                            throw ('Erreur pas de valeur pour jrn');
+                            throw Exception('Erreur pas de valeur pour jrn');
                         $filter_jrn=$this->cn->make_list("select 
jrn_def_fiche_deb from jrn_Def where jrn_def_id=$1",
                                 array($jrn));
 
diff --git a/include/class/pre_operation.class.php 
b/include/class/pre_operation.class.php
index 4a6ad18..43c1aef 100644
--- a/include/class/pre_operation.class.php
+++ b/include/class/pre_operation.class.php
@@ -40,7 +40,7 @@ class Pre_operation
     private  $jrn_type;                                        /*!< $jrn_type 
*/
     private  $name;                                            /*!< $name name 
of the predef. operation */
     private  $detail;                /*!< Pre_operation_detail object */
-    private  $od_direct ;    /*!< Compatibility for ACH in direct mode, only 
for ODS */
+    var     $od_direct ;    /*!< Compatibility for ACH in direct mode, only 
for ODS */
     private  $od_id;         /*!< id of the Predefined Operation */
     private $isloaded;
     private $description; /*!< description of the predefined operation */
diff --git a/include/fiche.inc.php b/include/fiche.inc.php
index 39f1189..b5c5479 100644
--- a/include/fiche.inc.php
+++ b/include/fiche.inc.php
@@ -132,7 +132,7 @@ if ( $allcard == 0 ){
 if ($array == null && $allcard == 0 && $histo->selected != 3 )
 {
         echo '<div class="content">';
-       echo '<h2 class="info2"> '._('Aucune fiche trouvée').'</h2>';
+       echo '<h2 class="error"> '._('Aucune fiche trouvée').'</h2>';
        echo $str_add_card;
         echo '</div>';
        return;
diff --git a/include/history_operation.inc.php 
b/include/history_operation.inc.php
index ed6f516..69a0359 100644
--- a/include/history_operation.inc.php
+++ b/include/history_operation.inc.php
@@ -94,13 +94,13 @@ if (!isset($p_array['date_start']))
        list($date_start, $date_end) = $per->get_date_limit();
        $p_array['date_start'] = $date_start;
        $p_array['date_end'] = $date_end;
-       $msg='<h2 class="info2">'.sprintf(_("Période %s au %s 
"),$date_start,$date_end).'</h2>';
+       $msg='<h2 class="">'.sprintf(_("Période %s au %s 
"),$date_start,$date_end).'</h2>';
 }
 else
 {
     $date_start=$http->get("date_start","string","");
     $date_end=$http->get("date_end","string","");
-    $msg='<h2 class="info2">'.sprintf(_("Période %s au %s 
"),$date_start,$date_end) .'</h2>';
+    $msg='<h2 class="">'.sprintf(_("Période %s au %s "),$date_start,$date_end) 
.'</h2>';
 
 }
 /*  compute the sql stmt */
diff --git a/include/template/letter_all.php b/include/template/letter_all.php
index 32f4e86..6f51bf2 100644
--- a/include/template/letter_all.php
+++ b/include/template/letter_all.php
@@ -10,7 +10,7 @@ global $g_failed;
 
 if ( count($this->content) == 0 ) :
 ?>
-  <h2 class="info2"><?php echo _('Désolé aucun résultat trouvé')?></h2>
+  <h2 class="error"><?php echo _('Désolé aucun résultat trouvé')?></h2>
 
 <?php exit();
   endif;?>
diff --git a/include/template/letter_prop.php b/include/template/letter_prop.php
index 558cff0..6489cee 100644
--- a/include/template/letter_prop.php
+++ b/include/template/letter_prop.php
@@ -8,7 +8,7 @@ require_once  
NOALYSS_INCLUDE.'/class/acc_reconciliation.class.php';
 $gDossier=dossier::id();
 if ( count($this->content) == 0 ) :
 ?>
-  <h2 class="info2"><?php echo _('Désolé aucun résultat trouvé')?></h2>
+  <h2 class="error"><?php echo _('Désolé aucun résultat trouvé')?></h2>
 
     <?php
   else :
diff --git a/scenario/select-box-test.php b/scenario/select-box-test.php
index d9dc0a9..d439de5 100644
--- a/scenario/select-box-test.php
+++ b/scenario/select-box-test.php
@@ -3,6 +3,37 @@
     <script src="prototype.js"></script>
 
     <style>
+        /* The container <div> - needed to position the dropdown content */
+        .select_box{
+            position: relative;
+            display: inline-block;
+        }
+
+        /* Dropdown Content (Hidden by Default) */
+        .dropdown-content {
+            display: none;
+            position: absolute;
+            background-color: #f9f9f9;
+            min-width: 160px;
+            box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
+            z-index: 1;
+        }
+
+        /* Links inside the dropdown */
+        .dropdown-content a {
+            color: black;
+            padding: 12px 16px;
+            text-decoration: none;
+            display: block;
+        }
+
+        /* Change color of dropdown links on hover */
+        .dropdown-content a:hover {background-color: #f1f1f1}
+
+        /* Show the dropdown menu on hover */
+        .dropdown:hover .dropdown-content {
+            display: block;
+        }
       .select_box {
       border:solid 0.5px darkblue;
       background:white;
diff --git a/unit-test/include/class/fiche.Test.php 
b/unit-test/include/class/fiche.Test.php
index 08e2cf4..ae08322 100644
--- a/unit-test/include/class/fiche.Test.php
+++ b/unit-test/include/class/fiche.Test.php
@@ -20,6 +20,8 @@ class FicheTest extends TestCase
      */
     protected function setUp()
     {
+        include 'global.php';
+        $this->object=new Fiche($g_connection);
     }
 
     /**
@@ -37,7 +39,7 @@ class FicheTest extends TestCase
      */
     public function testCmp_name()
     {
-       include 'global.php';
+        global $g_connection;
        $fiche=new \Fiche($g_connection,21);
        $fiche_2=new \Fiche($g_connection,25);
        $this->assertGreaterThan(\Fiche::cmp_name($fiche, $fiche_2),0);
@@ -49,7 +51,7 @@ class FicheTest extends TestCase
      */
     public function testGet_bk_account()
     {
-     include 'global.php';
+        include 'global.php';
      $this->object=new Fiche($g_connection);
      $result=$this->object->get_bk_account();
      $this->assertEquals(gettype($result),'array');
@@ -84,4 +86,30 @@ class FicheTest extends TestCase
         $this->assertEquals($a_result[0][24]["deb_montant"],204.71);
     }
 
+    /**
+     * @covers Fiche::count_by_modele()
+     */
+    public function testCount_by_modele()
+    {
+
+        $nb=$this->object->count_by_modele(1,"","");
+        $this->assertEquals(4,$nb,"number of Sales Card ");
+        $nb=$this->object->count_by_modele(3,"eau","");
+        $this->assertEquals(1,$nb,"Purchase card water ");
+        $nb=$this->object->count_by_modele(3,"EAU","");
+        $this->assertEquals(1,$nb,"Purchase card water ");
+        $nb=$this->object->count_by_modele(3,"ZZ","");
+        $this->assertEquals(0,$nb,"no  card  found");
+        $nb=$this->object->count_by_modele(3000,"","");
+        $this->assertEquals(0,$nb,"no  card found");
+        $nb=$this->object->count_by_modele(3,"","");
+        $this->assertEquals(7,$nb,"Purchase cards ");
+        // attempt to inject SQL command, you must get an error
+        try {
+            $nb=@$this->object->count_by_modele(3,""," and 1';delete from 
jrn;");
+            $this->assertFalse(true,"Inject SQL command");
+        }  catch(Exception $e) {
+            $this->assertTrue(true,"Inject SQL command");
+        }
+    }
 }



reply via email to

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