noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 181/238: Mantis #1611: Problème Plan comptab


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 181/238: Mantis #1611: Problème Plan comptable - mise en évidence poste utilisés
Date: Sat, 26 Oct 2019 04:41:00 -0400 (EDT)

sparkyx pushed a commit to annotated tag rel7110
in repository noalyss.

commit 634e89a2b0f89b9fc349e3ec4aec35050fd2605c
Author: Dany De Bontridder <address@hidden>
Date:   Sun Feb 3 15:34:13 2019 +0100

    Mantis #1611: Problème Plan comptable - mise en évidence poste utilisés
---
 include/class/acc_plan_mtable.class.php |  15 +++-
 include/class/fiche.class.php           | 149 +++++++++-----------------------
 2 files changed, 51 insertions(+), 113 deletions(-)

diff --git a/include/class/acc_plan_mtable.class.php 
b/include/class/acc_plan_mtable.class.php
index c9ba7d7..30dc019 100644
--- a/include/class/acc_plan_mtable.class.php
+++ b/include/class/acc_plan_mtable.class.php
@@ -84,15 +84,17 @@ class Acc_Plan_MTable extends Manage_Table_SQL
             $v=$this->a_order[$i];
             $nb=0;
             $cn=Dossier::connect();
-            $nb=$cn->get_value("select count(*) from jrnx where 
j_poste=$1",[$p_row['pcm_val']]);
-            $nb+=$cn->get_value("select count(*) from tmp_pcmn where 
pcm_val_parent=$1",[$p_row['pcm_val']]);
+            $nb_used=$cn->get_value("select count(*) from jrnx where 
j_poste=$1",[$p_row['pcm_val']]);
+            $nb_plan=$cn->get_value("select count(*) from tmp_pcmn where 
pcm_val_parent=$1",[$p_row['pcm_val']]);
+            $nb=$nb_used+$nb_plan;
             if ($v=="pcm_val")
             {
                 $js=sprintf("onclick=\"%s.input('%s','%s');\"", 
$this->object_name,
                         $p_row[$this->table->primary_key], $this->object_name);
                 echo sprintf('<td sort_type="text" sort_value="X%s">%s',
                         htmlspecialchars($p_row[$v]),
-                        HtmlInput::anchor($p_row[$v], "", $js)).'</td>';
+                        HtmlInput::anchor($p_row[$v], "", $js)).
+                        '</td>';
             }
             elseif ($v == "fiche_qcode") {
                 $count=$this->table->cn->get_value("select count(*) from 
fiche_detail where ad_id=5 and ad_value=$1",array($p_row['pcm_val']));
@@ -122,7 +124,12 @@ class Acc_Plan_MTable extends Manage_Table_SQL
                 
                 if ( $nb >0){
                     echo "<td>";
-                    echo 
HtmlInput::history_account($p_row['pcm_val'],h($p_row["pcm_lib"]));
+                    if ($nb_used > 0) {
+                        $used=sprintf (' (%s)',$nb_used);
+                        echo 
HtmlInput::history_account($p_row['pcm_val'],h($p_row["pcm_lib"].$used));
+                    } else {
+                        echo h($p_row["pcm_lib"]);
+                    }
                     echo "</td>";
                 } else {
                     echo td($p_row[$v]);
diff --git a/include/class/fiche.class.php b/include/class/fiche.class.php
index 91aaae8..8354e46 100644
--- a/include/class/fiche.class.php
+++ b/include/class/fiche.class.php
@@ -58,8 +58,6 @@ class Fiche
         $this->cn=$p_cn;
         $this->id=$p_id;
         $this->quick_code='';
-        $this->attribut=[];
-        
     }
     /**
      *@brief used with a usort function, to sort an array of Fiche on the name
@@ -347,8 +345,8 @@ class Fiche
      */
     function strAttribut($p_ad_id,$p_return=1)
     {
-       $return=($p_return==1)?NOTFOUND:"";
-        if (is_array($this->attribut) && sizeof ($this->attribut) == 0 )
+               $return=($p_return==1)?NOTFOUND:"";
+        if ( sizeof ($this->attribut) == 0 )
         {
 
             if ($this->id==0) {
@@ -502,7 +500,7 @@ class Fiche
                             $w->set_attribute('ipopup', 'ipop_account');
                             $w->set_attribute('account', "av_text" . 
$attr->ad_id);
                             $w->table = 1;
-                            $bulle = Icon_Action::infobulle(14);
+                            $bulle = HtmlInput::infobulle(14);
                             break;
                     case 'select':
                             $w = new ISelect("av_text" . $attr->ad_id);
@@ -531,7 +529,7 @@ class Fiche
             $w->name = "av_text" . $attr->ad_id;
             if ($attr->ad_id == 21 || 
$attr->ad_id==22||$attr->ad_id==20||$attr->ad_id==31)
             {
-                    $bulle=Icon_Action::infobulle(21);
+                    $bulle=HtmlInput::infobulle(21);
             }
             if ($attr->ad_id == ATTR_DEF_NAME || $attr->ad_id== 
ATTR_DEF_QUICKCODE) 
                 $class=" input_text highlight info";
@@ -600,10 +598,10 @@ class Fiche
                     $sql="select account_auto($this->fiche_def)";
                     $ret_sql=$this->cn->exec_sql($sql);
                     $a=Database::fetch_array($ret_sql, 0);
-                    $bulle=Icon_Action::infobulle(10);
+                    $bulle=HtmlInput::infobulle(10);
 
                     if ($a['account_auto']=='t')
-                        $bulle.=" ".Icon_Action::warnbulle(11);
+                        $bulle.=HtmlInput::warnbulle(11);
                 }
                 elseif ($r->ad_id==ATTR_DEF_TVA)
                 {
@@ -642,7 +640,7 @@ class Fiche
                             $w->dbl_click_history();
                             $w->width=$r->ad_size;
                             $w->table=0;
-                            $bulle=Icon_Action::infobulle(14);
+                            $bulle=HtmlInput::infobulle(14);
                             $w->value=$r->av_text;
                             break;
                         case 'card':
@@ -714,7 +712,7 @@ class Fiche
 
             if ($r->ad_id==21||$r->ad_id==22||$r->ad_id==20||$r->ad_id==31)
             {
-                $bulle=Icon_Action::infobulle(21);
+                $bulle=HtmlInput::infobulle(21);
             }
             if ($r->ad_id == ATTR_DEF_NAME || $r->ad_id== 
ATTR_DEF_QUICKCODE||$r->ad_id==ATTR_DEF_ACCOUNT) 
                 $class=" input_text highlight info";
@@ -767,11 +765,11 @@ class Fiche
         if ($transaction)
             $this->cn->start();
         /*
-         * Sort the array for having the name BEFORE the quickcode and the 
+         * Sort the array for having the name AFTER the quickcode and the 
          * Accounting
          */
         ksort($p_array);
-        $name="";
+
         try
         {
             $this->cn->start();
@@ -803,13 +801,11 @@ class Fiche
                 {
                     if (strlen(trim($value))==0)
                         $value="pas de nom";
-                    $account_name=$value;
                 }
                 // account
                 if ($id==ATTR_DEF_ACCOUNT)
                 {
-                    $v=mb_strtoupper(sql_string($value));
-                    
+                    $v=mb_substr(sql_string($value), 0, 40);
                     try
                     {
                         // Check that the accounting can be used directly
@@ -817,20 +813,12 @@ class Fiche
                         {
                             if (strpos($value, ',')==0)
                             {
-                                if ( mb_strlen($value)>40) throw new Exception 
(_("Poste comptable trop long"), 1);
-                                $acc_account=new Acc_Account($this->cn,$v);
+                                $v=$this->cn->get_value("select 
format_account($1)",
+                                        array($value));
                                 
-                                if ($acc_account->get_parameter("id")== -1 ) {
-                                    $acc_account->set_parameter("pcm_lib", 
$account_name);
-                                   // By Default can be used directly
-                                    
$acc_account->set_parameter('pcm_direct_use',"Y") ;
-                                    $parent=$acc_account->find_parent();
-                                    
$acc_account->set_parameter("pcm_val_parent",$parent);
-                                    $acc_account->save();
-                                } else 
                                 // Check that the accounting can be used 
directly
-                                if ( 
$acc_account->get_parameter('pcm_direct_use') == 'N') {
-                                    
+                                $acc_account=new Acc_Account($this->cn,$v);
+                                if 
($acc_account->get_parameter('pcm_direct_use') == 'N') {
                                     throw new Exception(_("Utilisation directe 
interdite du poste comptable $v"));
                                 }
                             }
@@ -842,31 +830,21 @@ class Fiche
                                 
                                 $part1=$ac_array[0];
                                 $part2=$ac_array[1];
-                                if ( mb_strlen($part1)>40) throw new Exception 
(_("Poste comptable trop long"), 1);
-                                if ( mb_strlen($part2)>40) throw new Exception 
(_("Poste comptable trop long"), 1);
+                                $part1=$this->cn->get_value('select 
format_account($1)',
+                                        array($part1));
+                                $part2=$this->cn->get_value('select 
format_account($1)',
+                                        array($part2));
+                                $v=$part1.','.$part2;
                                 // Check that the accounting can be used 
directly
                                 $acc_account1=new 
Acc_Account($this->cn,$part1);
-                                if ($acc_account1->get_parameter("id")== -1 ) {
-                                    $acc_account1->set_parameter("pcm_lib", 
$account_name);
-                                    
$acc_account1->set_parameter('pcm_direct_use',"Y") ;
-                                    $parent=$acc_account1->find_parent();
-                                    
$acc_account1->set_parameter("pcm_val_parent",$parent);
-                                    $acc_account1->save();
-                                } else if 
($acc_account1->get_parameter('pcm_direct_use') == 'N') {
+                                if 
($acc_account1->get_parameter('pcm_direct_use') == 'N') {
                                     throw new Exception(_("Utilisation directe 
interdite du poste comptable $part1"));
                                 }
                                 // Check that the accounting can be used 
directly
                                 $acc_account2=new 
Acc_Account($this->cn,$part2);
-                                if ($acc_account2->get_parameter("id")== -1 ) {
-                                    $acc_account2->set_parameter("pcm_lib", 
$account_name);
-                                    
$acc_account2->set_parameter('pcm_direct_use',"Y") ;
-                                    $parent=$acc_account2->find_parent();
-                                    
$acc_account2->set_parameter("pcm_val_parent",$parent);
-                                    $acc_account2->save();
-                                } else if 
($acc_account2->get_parameter('pcm_direct_use') == 'N') {
+                                if 
($acc_account2->get_parameter('pcm_direct_use') == 'N') {
                                     throw new Exception(_("Utilisation directe 
interdite du poste comptable $part2"));
                                 }
-
                             }
                             $parameter=array($this->id, $v);
                         }
@@ -874,8 +852,8 @@ class Fiche
                         {
                             $parameter=array($this->id, null);
                         }
-                       $v=$this->cn->get_value("select account_insert($1,$2)",
-                                $parameter); 
+                        $v=$this->cn->get_value("select account_insert($1,$2)",
+                                $parameter);
                     }
                     catch (Exception $e)
                     {
@@ -941,8 +919,8 @@ class Fiche
                     continue;
 
                 // retrieve jft_id to update table attr_value
-                $sql=" select jft_id from fiche_detail where ad_id=$1 and 
f_id=$2";
-                $Ret=$this->cn->exec_sql($sql,[$id,$this->id]);
+                $sql=" select jft_id from fiche_detail where ad_id=$id and 
f_id=$this->id";
+                $Ret=$this->cn->exec_sql($sql);
                 if (Database::num_row($Ret)==0)
                 {
                     // we need to insert this new attribut
@@ -976,7 +954,7 @@ class Fiche
                 // account
                 if ($id==ATTR_DEF_ACCOUNT)
                 {
-                    $v=mb_strtoupper(sql_string($value));
+                    $v=sql_string($value);
                     if (trim($v)!='')
                     {
                         if (strpos($v, ',')!=0)
@@ -986,17 +964,8 @@ class Fiche
                                 throw new Exception('Désolé, il y a trop de 
virgule dans le poste comptable '.h($v));
                             $part1=$ac_array[0];
                             $part2=$ac_array[1];
-                            if ( mb_strlen($part1)>40) throw new Exception 
(_("Poste comptable trop long"), 1);
-                            if ( mb_strlen($part2)>40) throw new Exception 
(_("Poste comptable trop long"), 1);
-                            $acc_account1=new Acc_Account($this->cn,$part1);
-                            if ($acc_account1->get_parameter("id")== -1 ) {
-                                
$account_name=$this->strAttribut(ATTR_DEF_NAME);
-                                $acc_account1->set_parameter("pcm_lib", 
$account_name);
-                                
$acc_account1->set_parameter('pcm_direct_use',"Y") ;
-                                $parent=$acc_account1->find_parent();
-                                
$acc_account1->set_parameter("pcm_val_parent",$parent);
-                                $acc_account1->save();
-                            }
+                            $part1=$this->cn->get_value('select 
format_account($1)',
+                                    array($part1));
                             $part2=$this->cn->get_value('select 
format_account($1)',
                                     array($part2));
                             $v=$part1.','.$part2;
@@ -1007,34 +976,16 @@ class Fiche
                             }
                             // Check that the accounting can be used directly
                             $acc_account2=new Acc_Account($this->cn,$part2);
-                            if ($acc_account2->get_parameter("id")== -1 ) {
-                                    
$account_name=$this->strAttribut(ATTR_DEF_NAME);
-                                    $acc_account2->set_parameter("pcm_lib", 
$account_name);
-                                    
$acc_account2->set_parameter('pcm_direct_use',"Y") ;
-                                    $parent=$acc_account2->find_parent();
-                                    
$acc_account2->set_parameter("pcm_val_parent",$parent);
-                                    $acc_account2->save();
-                                }
                             if ($acc_account2->get_parameter('pcm_direct_use') 
== 'N') {
                                 throw new Exception(_("Utilisation directe 
interdite du poste comptable $part2"));
                             }
                         }
                         else
                         {
-                            if ( mb_strlen($v)>40) throw new Exception 
(_("Poste comptable trop long"), 1);
-                            $acc_account=new Acc_Account($this->cn,$v);
-                            // Set default for new accounting
-                             if ($acc_account->get_parameter("id")== -1 ) {
-                                    
$account_name=$this->strAttribut(ATTR_DEF_NAME);
-                                    $acc_account->set_parameter("pcm_lib", 
$account_name);
-                                   // By Default can be used directly
-                                    
$acc_account->set_parameter('pcm_direct_use',"Y") ;
-                                    $parent=$acc_account->find_parent();
-                                    
$acc_account->set_parameter("pcm_val_parent",$parent);
-                                    $acc_account->save();
-                                }
-                            
+                            $v=$this->cn->get_value('select 
format_account($1)',
+                                    array($value));
                             // Check that the accounting can be used directly
+                            $acc_account=new Acc_Account($this->cn,$v);
                             if ($acc_account->get_parameter('pcm_direct_use') 
== 'N') {
                                 throw new Exception(_("Utilisation directe 
interdite du poste comptable $v"));
                             }
@@ -1258,7 +1209,6 @@ class Fiche
                                  "case when j_debit='f' then j_montant else 0 
end as cred_montant,".
                                  " jr_comment as description,jrn_def_name as 
jrn_name,j_poste,".
                                 " jr_pj_number,".
-                                " jr_optype,".
                                  "j_debit, jr_internal,jr_id,(select distinct 
jl_id from sqlletter  where sqlletter.j_id=j1.j_id ) as letter , ".
                                 " jr_tech_per,p_exercice,jrn_def_name,
                                      (with cred as (select jl_id, 
sum(j_montant) as amount_cred from letter_cred left join jrnx as j3 on 
(j3.j_id=j1.j_id)  group by jl_id ),
@@ -1474,7 +1424,6 @@ class Fiche
         "<TH style=\"text-align:left\">"._('Interne')." </TH>".
         "<TH style=\"text-align:left\">"._('Tiers')." </TH>".
         "<TH style=\"text-align:left\">"._('Description')." </TH>".
-        "<TH style=\"text-align:left\">"._('Type')." </TH>".
         "<TH style=\"text-align:left\">"._('ISO')."</TH>".
         "<TH style=\"text-align:right\">"._('Dev.')."</TH>".
         "<TH style=\"text-align:right\">"._('Débit')."  </TH>".
@@ -1570,7 +1519,7 @@ class Fiche
                td().
                td().
         td(_('Totaux')).
-        "<TD></TD>".td("").td("").
+        "<TD></TD>".
         "<TD  style=\"text-align:right\">".nbm($sum_deb)."</TD>".
         "<TD  style=\"text-align:right\">".nbm($sum_cred)."</TD>".
          "<TD style=\"text-align:right\">".nbm($diff)."</TD>".
@@ -1809,9 +1758,9 @@ class Fiche
         
         $r.='<table  id="tiers_tb" class="sortable"  
style="width:90%;margin-left:5%">
             <TR >
-            <TH>'._('Quick Code').Icon_Action::infobulle(17).'</TH>'.
+            <TH>'._('Quick Code').HtmlInput::infobulle(17).'</TH>'.
             '<th>'._('Poste comptable').'</th>'.
-            '<th  class="sorttable_sorted">'._('Nom').'</th>
+            '<th  class="sorttable_sorted">'._('Nom').'<span 
id="sorttable_sortfwdind"><img src="image/up.gif"></span>'.'</th>
             <th>'._('Adresse').'</th>
             <th style="text-align:right">'._('Total débit').'</th>
             <th style="text-align:right">'._('Total crédit').'</th>
@@ -2030,37 +1979,19 @@ class Fiche
         $qcode=$this->strAttribut(ATTR_DEF_QUICKCODE);
         $sql='select count(*) as c from jrnx where j_qcode=$1';
         $count=$this->cn->get_value($sql,array($qcode));
-        if ( $count > 0 ) return TRUE;
-        $count=$this->cn->get_value("select count(*) from action_gestion where 
f_id_dest=$1 or ag_contact=$1 ",
-                [$this->id]);
-        if ( $count > 0 ) return TRUE;
-        $count=$this->cn->get_value("select count(*) from action_person where 
f_id=$1 ",
-                [$this->id]);
-        if ( $count > 0 ) return TRUE;
-        
-        $count=$this->cn->get_value("select count(*) 
-                from attr_def
-                join fiche_detail using (ad_id)
-                where ad_type='card'
-                and ad_value=$1"
-                ,[$qcode]);
-        
-        if ( $count > 0 ) return TRUE;
-        
-        return FALSE;
+        if ( $count == 0 ) return false;
+        return true;
     }
     /*\brief remove a card without verification */
     function delete()
     {
-        $this->cn->start();
         // Remove from attr_value
         $Res=$this->cn->exec_sql("delete from fiche_detail
                                  where
-                                   f_id=$1",[$this->id]);
+                                   f_id=".$this->id);
 
         // Remove from fiche
-        $Res=$this->cn->exec_sql("delete from fiche where 
f_id=$1",[$this->id]);
-        $this->cn->commit();
+        $Res=$this->cn->exec_sql("delete from fiche where f_id=".$this->id);
 
     }
     /*!\brief create the sql statement for retrieving all
@@ -2272,7 +2203,7 @@ class Fiche
      */
 
     function filter_history($p_table_id) {
-        return _('Cherche').' '.HtmlInput::filter_table($p_table_id, 
'0,1,2,3,4,5,6,7,8,9,10', 1);
+        return _('Cherche').' '.HtmlInput::filter_table($p_table_id, 
'0,1,2,3,4,5,6,7', 1);
     }
     /**
      * Returns the Acc_Ledger_Fin ledger for which the card is the default 
bank account or null if no ledger is found.



reply via email to

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