noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 52/323: Task #1457 & 1281 : operation ouvert


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 52/323: Task #1457 & 1281 : operation ouverture séparée
Date: Wed, 14 Mar 2018 17:38:17 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 6c00cee4bec42e0c935e18dea0f0030909ef3bac
Author: Dany De Bontridder <address@hidden>
Date:   Thu Jan 11 16:52:26 2018 +0100

    Task #1457 & 1281 : operation ouverture séparée
---
 include/ajax/ajax_ledger.php               |  5 ++-
 include/balance.inc.php                    | 54 ++++++++++++++++--------
 include/class/acc_account.class.php        |  7 ++-
 include/class/acc_account_ledger.class.php |  7 ++-
 include/class/acc_balance.class.php        | 68 ++++++++++++++++++++++++------
 include/class/acc_ledger.class.php         | 15 ++-----
 include/class/acc_operation.class.php      | 37 +++++++++++++---
 include/class/acc_report.class.php         |  2 +-
 include/class/fiche.class.php              |  7 ++-
 include/export/export_gl_csv.php           |  3 +-
 include/export/export_gl_pdf.php           |  2 +-
 include/impress_gl_comptes.inc.php         | 18 ++++----
 include/opening.inc.php                    |  7 ++-
 include/operation_ods_confirm.inc.php      | 10 ++++-
 include/operation_ods_new.inc.php          |  2 +-
 include/template/ledger_detail_bottom.php  | 12 ++++++
 sql/upgrade.sql                            |  8 +++-
 17 files changed, 192 insertions(+), 72 deletions(-)

diff --git a/include/ajax/ajax_ledger.php b/include/ajax/ajax_ledger.php
index 5560099..3d21ff5 100644
--- a/include/ajax/ajax_ledger.php
+++ b/include/ajax/ajax_ledger.php
@@ -425,8 +425,8 @@ case 'save':
                }
            }
             
-            $cn->exec_sql("update jrn set 
jr_comment=$1,jr_pj_number=$2,jr_date=to_date($4,'DD.MM.YYYY') where jr_id=$3",
-                          
array($_POST['lib'],$_POST['npj'],$jr_id,$_POST['p_date']));
+            $cn->exec_sql("update jrn set 
jr_comment=$1,jr_pj_number=$2,jr_date=to_date($4,'DD.MM.YYYY'),jr_optype=$5 
where jr_id=$3",
+                          
array($_POST['lib'],$_POST['npj'],$jr_id,$_POST['p_date'],$_POST['jr_optype']));
            $cn->exec_sql("update jrnx set j_date=to_date($1,'DD.MM.YYYY') 
where j_grpt in (select jr_grpt_id from jrn where jr_id=$2)",
                          array($_POST['p_date'],$jr_id));
            $cn->exec_sql('update operation_analytique set oa_date=j_date from 
jrnx
@@ -496,6 +496,7 @@ case 'save':
             //////////////////////////////////////////////////////////////////
             $op->save_info($_POST['OTHER'],'OTHER');
             $op->save_info($_POST['BON_COMMANDE'],'BON_COMMANDE');
+            
             ///////////////////////////////////////////////////////////////////
             // Save related
             //////////////////////////////////////////////////////////////////
diff --git a/include/balance.inc.php b/include/balance.inc.php
index 87760c9..cba864e 100644
--- a/include/balance.inc.php
+++ b/include/balance.inc.php
@@ -286,10 +286,9 @@ if ( isset($_GET['view'] ) )
     $bal->to_poste=$_GET['to_poste'];
     if ( isset($_GET['unsold']))  $bal->unsold=true;
     $previous=(isset($_GET['previous_exc']))?1:0;
-    
-    $row=$bal->get_row($_GET['from_periode'],
-                       $_GET['to_periode'],
-            $previous);
+    $from_periode=$http->get("from_periode","number");
+    $to_periode=$http->get("to_periode","number");
+    $row=$bal->get_row($from_periode,$to_periode);
     $previous= (isset ($row[0]['sum_cred_previous']))?1:0;
 
     $periode=new Periode($cn);
@@ -312,18 +311,18 @@ if ( isset($_GET['view'] ) )
             echo '<th>Solde  N-1</th>';
             
     }
+    echo '<th>'._('Ouverture').'</th>';
     echo '<th>D&eacute;bit</th>';
     echo '<th>Cr&eacute;dit</th>';
-    echo '<th>Solde D&eacute;biteur </th>';
-    echo '<th>Solde Cr&eacute;diteur</th>';
-    if ( isset($_GET['lvl1']) || isset($_GET['lvl2']) || isset($_GET['lvl3'])) 
-        echo '<th>Solde</th>';
+    echo '<th>Solde</th>';
+//    if ( isset($_GET['lvl1']) || isset($_GET['lvl2']) || 
isset($_GET['lvl3'])) 
+//        echo '<th>Solde</th>';
     $i=0;
     if ( $previous == 1) {
         
$a_sum=array('sum_cred','sum_deb','solde_deb','solde_cred','sum_cred_previous','sum_deb_previous','solde_deb_previous','solde_cred_previous');
     }
     else {
-              $a_sum=array('sum_cred','sum_deb','solde_deb','solde_cred') ;
+              
$a_sum=array('sum_cred','sum_deb','solde_deb','solde_cred','sum_deb_ope','sum_cred_ope')
 ;
     }
     foreach($a_sum as $a)
       {
@@ -374,10 +373,21 @@ if ( isset($_GET['view'] ) )
                     echo td(nbm(abs($delta_previous))." 
$side_previous",'class="previous_year"  
style="text-align:right;font-weight:bold;"  ');
                     
                 }
-               echo 
td(nbm(${'lvl'.$ind}['sum_deb']),'style="text-align:right;font-weight:bold;"  
');
-               echo 
td(nbm(${'lvl'.$ind}['sum_cred']),'style="text-align:right;font-weight:bold;"');
-               echo 
td(nbm(${'lvl'.$ind}['solde_deb']),'style="text-align:right;font-weight:bold;"');
-               echo 
td(nbm(${'lvl'.$ind}['solde_cred']),'style="text-align:right;font-weight:bold;"');
+               /*echo 
td(nbm(${'lvl'.$ind}['sum_deb']),'style="text-align:right;font-weight:bold;"  
');
+               echo 
td(nbm(${'lvl'.$ind}['sum_cred']),'style="text-align:right;font-weight:bold;"');*/
+                // Ouverture
+                
$solde3=bcsub(${'lvl'.$ind}['sum_deb_ope'],${'lvl'.$ind}['sum_cred_ope']);
+                $side3=($solde3<0)?" C":" D";
+                $side3=($solde3==0)?" ":$side3;
+                echo td(nbm(abs($solde3)).$side3);
+                
+                // Saldo debit
+                
$solde_deb=bcsub(${'lvl'.$ind}['sum_deb'],${'lvl'.$ind}['sum_deb_ope']);
+               echo 
td(nbm($solde_deb),'style="text-align:right;font-weight:bold;"');
+                
+                // Saldo cred
+                
$solde_cred=bcsub(${'lvl'.$ind}['sum_cred'],${'lvl'.$ind}['sum_cred_ope']);
+               echo 
td(nbm($solde_cred),'style="text-align:right;font-weight:bold;"');
                 
$delta=bcsub(${'lvl'.$ind}['solde_cred'],${'lvl'.$ind}['solde_deb']);
                 $side=($delta > 0 ) ? "C":"D";
                 echo td(nbm(abs($delta))." 
$side",'style="text-align:right;font-weight:bold;"  ');
@@ -407,6 +417,7 @@ if ( isset($_GET['view'] ) )
         echo '<TR class="'.$tr.'">';
         echo td($view_history);
         echo td(h($r['label']));
+      
         if ($previous == 1 ) {
             echo td(nbm($r['sum_deb_previous']),' class="previous_year"');
             echo td(nbm($r['sum_cred_previous']),' class="previous_year" ');
@@ -423,10 +434,19 @@ if ( isset($_GET['view'] ) )
                                                 $r['sum_cred_previous']);
 
         }
-        echo td(nbm($r['sum_deb']),'style="text-align:right;"');
-       echo td(nbm($r['sum_cred']),'style="text-align:right;"');
-       echo td(nbm($r['solde_deb']),'style="text-align:right;"');
-       echo td(nbm($r['solde_cred']),'style="text-align:right;"');
+        $solde=bcsub($r['sum_deb_ope'],$r['sum_cred_ope']);
+        $side=($solde < 0)?" C":" D";
+        $side=($solde==0)?"":$side;
+        echo td(nbm(abs($solde)).$side,'style="text-align:right;"');
+        echo 
td(nbm(bcsub($r['sum_deb'],$r['sum_deb_ope'])),'style="text-align:right;"');
+       echo 
td(nbm(bcsub($r['sum_cred'],$r['sum_cred_ope'])),'style="text-align:right;"');
+        
+        $solde2=bcsub($r['sum_deb'],$r['sum_cred']);
+        $side=($solde2 < 0)?" C":" D";
+        $side=($solde2==0)?"":$side;
+       
+        echo td(nbm(abs($solde2)).$side,'style="text-align:right;"');
+       
         if ( isset($_GET['lvl1']) || isset($_GET['lvl2']) || 
isset($_GET['lvl3']))             echo '<td></td>';
         echo '</TR>';
         
diff --git a/include/class/acc_account.class.php 
b/include/class/acc_account.class.php
index 1d1e15e..68cb964 100644
--- a/include/class/acc_account.class.php
+++ b/include/class/acc_account.class.php
@@ -183,7 +183,12 @@ class Acc_Account
         $this->data_sql->delete();
 
     }
-    
+    function find_by_value($p_pcm_val)
+    {
+        $id=$this->db->get_value("select id from tmp_pcmn where 
pcm_val=$1",[$p_pcm_val]);
+        $this->data_sql->setp("id",$id);
+        $this->data_sql->load();
+    }
     function save() {
         try {
             $this->verify();
diff --git a/include/class/acc_account_ledger.class.php 
b/include/class/acc_account_ledger.class.php
index 8f942fe..4abcc13 100644
--- a/include/class/acc_account_ledger.class.php
+++ b/include/class/acc_account_ledger.class.php
@@ -172,6 +172,7 @@ class Acc_Account_Ledger
                                  j_debit, jr_internal,jr_pj_number
                                  ,(select distinct jl_id from sqlletter  where 
sqlletter.j_id=j1.j_id ) as letter 
                                  ,pcm_lib
+                                 ,jr_optype
                                                                 ,jr_tech_per
                                  ,p_exercice
                                  ,jrn_def_name
@@ -394,6 +395,7 @@ class Acc_Account_Ledger
         "<TH style=\"text-align:left\">"._('Code 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:right\">"._('Débit')."</TH>".
         "<TH style=\"text-align:right\">"._("Crédit")."</TH>".
         th('Prog.','style="text-align:right"').
@@ -434,7 +436,7 @@ class Acc_Account_Ledger
                    echo "<TR class=\"highlight\">".
                      "<TD>$old_exercice</TD>".
                      "<TD></TD>".td().td().td().
-                     "<TD>"._("Totaux")."</TD>".
+                     "<TD>"._("Totaux")."</TD>".td("").
                      "<TD style=\"text-align:right\">".nbm($sum_deb)."</TD>".
                      "<TD style=\"text-align:right\">".nbm($sum_cred)."</TD>".
                      td(nbm(abs($progress)).$side,'style="text-align:right"').
@@ -460,6 +462,7 @@ class Acc_Account_Ledger
              "<TD>".$vw_operation."</TD>".
                 "<TD>".$tiers."</TD>".
              "<TD>".h($op['description'])."</TD>".
+                    td($op['jr_optype']).
              "<TD style=\"text-align:right\">".nbm($op['deb_montant'])."</TD>".
              "<TD 
style=\"text-align:right\">".nbm($op['cred_montant'])."</TD>".
              td(nbm(abs($progress)).$side,'style="text-align:right"').
@@ -475,7 +478,7 @@ class Acc_Account_Ledger
         echo "<TR class=\"highlight\">".
                 td($op['p_exercice']).
                 td().td().td().td().
-        "<TD >Totaux</TD>".
+        "<TD >Totaux</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(abs($diff)).$side."</TD>".
diff --git a/include/class/acc_balance.class.php 
b/include/class/acc_balance.class.php
index 6841206..92106e1 100644
--- a/include/class/acc_balance.class.php
+++ b/include/class/acc_balance.class.php
@@ -105,13 +105,21 @@ class Acc_Balance
         {
             case 0:
                 // build query
-                $sql="select j_poste as poste,sum(deb) as sum_deb, sum(cred) 
as sum_cred from
+                $sql="select j_poste as poste,
+                        sum(deb) as sum_deb, 
+                        sum(cred) as sum_cred,
+                        sum(deb_op)  as sum_deb_ope , 
+                        sum(cred_op) as sum_cred_ope
+                    from               
                      ( select j_poste,
                      case when j_debit='t' then j_montant else 0 end as deb,
-                     case when j_debit='f' then j_montant else 0 end as cred
+                     case when j_debit='f' then j_montant else 0 end as cred,
+                     case when j_debit='t' and jr_optype='OPE'  then j_montant 
else 0 end as deb_op,
+                     case when j_debit='f' and jr_optype='OPE' then j_montant 
else 0 end as cred_op
                      from jrnx join tmp_pcmn on (j_poste=pcm_val)
                      left join parm_periode on (j_tech_per = p_id)
                      join jrn_def on (j_jrn_def=jrn_def_id)
+                     join jrn on (j_grpt=jr_grpt_id)
                      where
                      $jrn $from_poste $to_poste
                      $and $filter_sql
@@ -143,11 +151,16 @@ class Acc_Balance
                                                              $jrn $from_poste 
$to_poste
                                     $and $filter_sql and $per_sql
                                     ) as sub_m group by j_poste order by 
j_poste ) , 
-                            p as ( select j_poste,sum(deb) as sdeb,sum(cred) 
as scred 
+                            p as ( select j_poste,sum(deb) as sdeb,
+                                            sum(cred) as scred ,
+                                            sum(deb_op)  as sum_deb_ope , 
+                                            sum(cred_op) as sum_cred_ope
                                 from 
                                     (select j_poste, 
                                         case when j_debit='t' then j_montant 
else 0 end as deb, 
-                                        case when j_debit='f' then j_montant 
else 0 end as cred 
+                                        case when j_debit='f' then j_montant 
else 0 end as cred ,
+                                        case when j_debit='t' and 
jr_optype='OPE'  then j_montant else 0 end as deb_op,
+                                        case when j_debit='f' and 
jr_optype='OPE' then j_montant else 0 end as cred_op
                                         from jrnx join tmp_pcmn on 
(j_poste=pcm_val) 
                                         left join parm_periode on (j_tech_per 
= p_id) 
                                         join jrn_def on (j_jrn_def=jrn_def_id) 
@@ -158,7 +171,10 @@ class Acc_Balance
                                                                 
,coalesce(m.sdeb,0) as sum_deb
                                                                 , 
coalesce(m.scred,0) as sum_cred 
                                                                 
,coalesce(p.sdeb,0) as sum_deb_previous
-                                                                , 
coalesce(p.scred,0) as sum_cred_previous from m full join p on 
(p.j_poste=m.j_poste)
+                                                                , 
coalesce(p.scred,0) as sum_cred_previous 
+                                                                
,coalesce(sum_deb_ope)
+                                                                
,coalesce(sum_cred_ope)
+                                                        from m full join p on 
(p.j_poste=m.j_poste)
                                              order by poste";
                        
                  } catch (Exception $exc) {
@@ -166,13 +182,21 @@ class Acc_Balance
                     /*
                      * no previous exercice
                      */
-                     $sql="select upper(j_poste::text) as poste,sum(deb) as 
sum_deb, sum(cred) as sum_cred from
-                     ( select j_poste,
-                     case when j_debit='t' then j_montant else 0 end as deb,
-                     case when j_debit='f' then j_montant else 0 end as cred
-                     from jrnx join tmp_pcmn on (j_poste=pcm_val)
-                     left join parm_periode on (j_tech_per = p_id)
-                     join jrn_def on (j_jrn_def=jrn_def_id)
+                     $sql="select j_poste as poste,
+                        sum(deb) as sum_deb, 
+                        sum(cred) as sum_cred,
+                        sum(deb_op)  as sum_deb_ope , 
+                        sum(cred_op) as sum_cred_ope
+                        from               
+                         ( select j_poste,
+                         case when j_debit='t' then j_montant else 0 end as 
deb,
+                         case when j_debit='f' then j_montant else 0 end as 
cred,
+                         case when j_debit='t' and jr_optype='OPE'  then 
j_montant else 0 end as deb_op,
+                         case when j_debit='f' and jr_optype='OPE' then 
j_montant else 0 end as cred_op
+                         from jrnx join tmp_pcmn on (j_poste=pcm_val)
+                         left join parm_periode on (j_tech_per = p_id)
+                         join jrn_def on (j_jrn_def=jrn_def_id)
+                         join jrn on (j_grpt=jr_grpt_id)
                      where
                      $jrn $from_poste $to_poste
                      $and $filter_sql
@@ -188,6 +212,10 @@ class Acc_Balance
         $tot_deb=  0.0;
         $tot_deb_saldo=0.0;
         $tot_cred_saldo=0.0;
+        $tot_cred_ope=  0.0;
+        $tot_deb_ope=  0.0;
+        $tot_deb_saldo_ope=0.0;
+        $tot_cred_saldo_ope=0.0;
         $tot_cred_previous=  0.0;
         $tot_deb_previous=  0.0;
         $tot_deb_saldo_previous=0.0;
@@ -206,7 +234,11 @@ class Acc_Balance
             $a['sum_cred']=round($r['sum_cred'],2);
             $a['solde_deb']=round(( $a['sum_deb']  >=  $a['sum_cred'] )? 
$a['sum_deb']- $a['sum_cred']:0,2);
             $a['solde_cred']=round(( $a['sum_deb'] <=  $a['sum_cred'] 
)?$a['sum_cred']-$a['sum_deb']:0,2);
-            
+            // opening
+            $a['sum_deb_ope']=round($r['sum_deb_ope'],2);
+            $a['sum_cred_ope']=round($r['sum_cred_ope'],2);
+            $a['solde_deb_ope']=round(( $a['sum_deb_ope']  >=  
$a['sum_cred_ope'] )? $a['sum_deb_ope']- $a['sum_cred_ope']:0,2);
+            $a['solde_cred_ope']=round(( $a['sum_deb_ope'] <=  
$a['sum_cred_ope'] )?$a['sum_cred_ope']-$a['sum_deb_ope']:0,2);
             
             
             if ($p_previous_exc==1)
@@ -223,10 +255,16 @@ class Acc_Balance
            if ($p_previous_exc==0 && $this->unsold==true && 
$a['solde_cred']==0 && $a['solde_deb']==0) continue;
            if ($p_previous_exc==1 && $this->unsold==true && 
$a['solde_cred']==0 && $a['solde_deb']==0 && $a['solde_cred_previous']==0 && 
$a['solde_deb_previous']==0) continue;
             $array[$i]=$a;
+            // Normal op
             $tot_cred=  bcadd ($tot_cred,$a['sum_cred']);
             $tot_deb= bcadd($tot_deb, $a['sum_deb']);
             $tot_deb_saldo= bcadd($tot_deb_saldo, $a['solde_deb']);
             $tot_cred_saldo= bcadd($tot_cred_saldo,$a['solde_cred']);
+            // Opening op.
+            $tot_cred_ope=  bcadd ($tot_cred_ope,$a['sum_cred_ope']);
+            $tot_deb_ope= bcadd($tot_deb_ope, $a['sum_deb_ope']);
+            $tot_deb_saldo_ope= bcadd($tot_deb_saldo_ope, $a['solde_deb_ope']);
+            $tot_cred_saldo_ope= 
bcadd($tot_cred_saldo_ope,$a['solde_cred_ope']);
             
             
         }//for i
@@ -242,6 +280,10 @@ class Acc_Balance
         $a['sum_cred']=$tot_cred;
         $a['solde_deb']=$tot_deb_saldo;
         $a['solde_cred']=$tot_cred_saldo;
+        $a['sum_deb_ope']=$tot_deb_ope;
+        $a['sum_cred_ope']=$tot_cred_ope;
+        $a['solde_deb_ope']=$tot_deb_saldo_ope;
+        $a['solde_cred_ope']=$tot_cred_saldo_ope;
         if ($p_previous_exc==1) {
             $a['sum_deb_previous']=$tot_deb_previous;
             $a['sum_cred_previous']=$tot_cred_previous;
diff --git a/include/class/acc_ledger.class.php 
b/include/class/acc_ledger.class.php
index 7a2333e..25e95cc 100644
--- a/include/class/acc_ledger.class.php
+++ b/include/class/acc_ledger.class.php
@@ -995,7 +995,7 @@ class Acc_Ledger extends jrn_def_sql
      * @brief show the result of the array to confirm
      * before inserting
      * @param$p_array array from the form
-     * \return string
+     * @return HTML string
      */
     function confirm($p_array, $p_readonly=false)
     {
@@ -1005,7 +1005,7 @@ class Acc_Ledger extends jrn_def_sql
             $msg=$this->verify($p_array);
         $this->id=$p_array['p_jrn'];
         if (empty($p_array))
-            return 'Aucun r&eacute;sultat';
+            return _("Aucun résultat");
         $anc=null;
         extract($p_array, EXTR_SKIP);
         $lPeriode=new Periode($this->db);
@@ -1126,11 +1126,7 @@ class Acc_Ledger extends jrn_def_sql
                                 ${'amount'.$i})."</td>";
                 $total_cred=bcadd($total_cred, ${"amount".$i});
             }
-            /* $ret.="<td>";
-              $ret.=(isset(${"ck$i"})) ? HtmlInput::hidden('ck' . $i, ${'ck' . 
$i}) : "";
-              $ret.="</td>"; */
             // CA
-
             if ($g_parameter->MY_ANALYTIC!='nu') // use of AA
             {
                 if (preg_match("/^[6,7]+/", $strPoste)==1)
@@ -1306,9 +1302,6 @@ class Acc_Ledger extends jrn_def_sql
 
         $ret.=HtmlInput::hidden('nb_item', $nb_row);
         $ret.=dossier::hidden();
-
-        $ret.=dossier::hidden();
-
         $ret.=HtmlInput::hidden('jrn_type', $this->get_type());
         $info=HtmlInput::infobulle(0);
         $info_poste=HtmlInput::infobulle(9);
@@ -1370,8 +1363,7 @@ class Acc_Ledger extends jrn_def_sql
 
             if ($poste->value!='')
             {
-                $Poste=new Acc_Account($this->db);
-                $Poste->set_parameter('value', $poste->value);
+                $Poste=new Acc_Account($this->db,$poste->value);
                 $label=$Poste->get_lib();
             }
 
@@ -1731,6 +1723,7 @@ class Acc_Ledger extends jrn_def_sql
             $acc_end->grpt=$seq;
             $acc_end->jrn=$this->id;
             $acc_end->mt=$mt;
+            $acc_end->jr_optype=$jr_optype;
             $jr_id=$acc_end->insert_jrn();
             $this->jr_id=$jr_id;
             if ($jr_id==false)
diff --git a/include/class/acc_operation.class.php 
b/include/class/acc_operation.class.php
index cc51756..0144049 100644
--- a/include/class/acc_operation.class.php
+++ b/include/class/acc_operation.class.php
@@ -46,6 +46,7 @@ class Acc_Operation
     var $amount;                       /*!< amount of the operatoin */
     var $grpt;                 /*!< the group id */
     var $date_paid;
+    var $jr_optype; /*!< type of operation :NOR,CLO,EXT,OPE
     /*!
      * \brief constructor set automatically the attributes user and periode
      * \param $p_cn the databse connection
@@ -58,6 +59,7 @@ class Acc_Operation
         $this->user=$_SESSION['g_user'];
         $this->periode=$g_user->get_periode();
         $this->jr_id=0;
+        $this->jr_optype="NOR";
     }
     /**
      address@hidden retrieve the grpt_id from jrn for a jr_id
@@ -271,12 +273,12 @@ class Acc_Operation
     function insert_jrn()
     {
         $p_comment=$this->desc;
-
+        
         $diff=$this->db->get_value("select check_balance 
($1)",array($this->grpt));
         if ( $diff != 0 )
         {
 
-            echo "Erreur : balance incorrecte :diff = $diff";
+            printf (_("Erreur : balance incorrecte :diff = %d"),$diff);
             return false;
         }
 
@@ -288,11 +290,11 @@ class Acc_Operation
         // if amount == -1then the triggers will throw an error
         //
         $Res=$this->db->exec_sql("insert into jrn 
(jr_def_id,jr_montant,jr_comment,".
-                                 "jr_date,jr_ech,jr_grpt_id,jr_tech_per,jr_mt) 
  values (".
+                                 
"jr_date,jr_ech,jr_grpt_id,jr_tech_per,jr_mt,jr_optype)   values (".
                                  "$1,$2,$3,".
-                                 
"to_date($4,'DD.MM.YYYY'),to_date($5,'DD.MM.YYYY'),$6,$7,$8)",
+                                 
"to_date($4,'DD.MM.YYYY'),to_date($5,'DD.MM.YYYY'),$6,$7,$8,$9)",
                                  array ($this->jrn, $this->amount,$p_comment,
-                                        
$this->date,$echeance,$this->grpt,$this->periode,$this->mt)
+                                        
$this->date,$echeance,$this->grpt,$this->periode,$this->mt,$this->jr_optype)
                                 );
         if ( $Res == false)  return false;
         $this->jr_id=$this->db->get_current_seq('s_jrn');
@@ -708,6 +710,29 @@ class Acc_Operation
         $b=$a->get_quant();
         var_dump($b);
     }
+    /**
+     * Return a select object to choose the type of operation
+     *   - NOR normal
+     *   - EXT reverse operation
+     *   - CLO closing periode
+     *   - OPE opening periode
+     * @param string $p_status
+     * @return \ISelect
+     */
+    static function select_operation_type($p_status)
+    {
+        $type_operation=new ISelect("jr_optype");
+        $type_operation->value=array(
+            array(("label")=>_("Normal"), "value"=>"NOR"),
+            array(("label")=>_("Ouverture"), "value"=>"OPE"),
+            array(("label")=>_("Fermeture"), "value"=>"CLO"),
+            array(("label")=>_("Extourne"), "value"=>"EXT")
+        );
+
+        $type_operation->selected=$p_status;
+        return $type_operation;
+    }
+
 }
 /////////////////////////////////////////////////////////////////////////////
 class Acc_Detail extends Acc_Operation
@@ -727,7 +752,7 @@ class Acc_Detail extends Acc_Operation
         $sql="SELECT jr_id, jr_def_id, jr_montant, jr_comment, jr_date, 
jr_grpt_id,
              jr_internal, jr_tech_date, jr_tech_per, jrn_ech, jr_ech, 
jr_rapt,jr_ech,
              jr_valid, jr_opid, jr_c_opid, jr_pj, jr_pj_name, jr_pj_type,
-             jr_pj_number, jr_mt,jr_rapt,jr_date_paid
+             jr_pj_number, jr_mt,jr_rapt,jr_date_paid,jr_optype
              FROM jrn where jr_id=$1";
         $array=$this->db->get_array($sql,array($this->jr_id));
         if ( count($array) == 0 ) throw new Exception('Aucune ligne trouvée');
diff --git a/include/class/acc_report.class.php 
b/include/class/acc_report.class.php
index a4ada52..0c15e17 100644
--- a/include/class/acc_report.class.php
+++ b/include/class/acc_report.class.php
@@ -112,7 +112,7 @@ class Acc_Report
         $r.= HtmlInput::hidden('line',$p_line);
         $r.= HtmlInput::hidden('fr_id',$this->id);
         $wForm=new IText();
-        $r.="Nom du rapport : ";
+        $r.=_("Nom du rapport")." : ";
         $r.=$wForm->input('form_nom',$this->name);
 
         $r.= '<TABLE id="rap1" width="100%">';
diff --git a/include/class/fiche.class.php b/include/class/fiche.class.php
index d39ddf9..b1c3122 100644
--- a/include/class/fiche.class.php
+++ b/include/class/fiche.class.php
@@ -1254,6 +1254,7 @@ 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 using (j_id)  
group by jl_id ),
@@ -1457,6 +1458,7 @@ class Fiche
         "<TH style=\"text-align:left\">"._('Code 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:right\">"._('Débit')."  </TH>".
         "<TH style=\"text-align:right\">"._('Crédit')." </TH>".
         th('Prog.','style="text-align:right"').
@@ -1492,7 +1494,7 @@ class Fiche
                    echo "<TR class=\"highlight\">".
                       "<TD>$old_exercice</TD>".
                      td('').
-                     "<TD></TD>".
+                     "<TD></TD>".td("").td("").
                      "<TD>Totaux</TD>".
                             td().
                      "<TD style=\"text-align:right\">".nbm($sum_deb)."</TD>".
@@ -1520,6 +1522,7 @@ class Fiche
             "<TD>".$vw_operation."</TD>".
             td($tiers).
             "<TD>".h($op['description'])."</TD>".
+                    td($op['jr_optype']).
             "<TD style=\"text-align:right\">".nbm($op['deb_montant'])."</TD>".
              "<TD 
style=\"text-align:right\">".nbm($op['cred_montant'])."</TD>".
              td(nbm(abs($progress)).$side,'style="text-align:right"').
@@ -1537,7 +1540,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>".
diff --git a/include/export/export_gl_csv.php b/include/export/export_gl_csv.php
index bb3415b..6a10e1e 100644
--- a/include/export/export_gl_csv.php
+++ b/include/export/export_gl_csv.php
@@ -93,7 +93,7 @@ if ( count($a_poste) == 0 )
 }
 
 // Header
-$header = array( _("Date"), _("Référence"), _("Libellé"), 
_("Pièce"),_("Lettrage"), _("Débit"), _("Crédit"), _("Solde") );
+$header = array( _("Date"), _("Référence"), _("Libellé"), 
_("Pièce"),_("Lettrage"),_("Type"), _("Débit"), _("Crédit"), _("Solde") );
 
 $l=(isset($_GET['letter']))?2:0;
 $s=(isset($_REQUEST['solded']))?1:0;
@@ -195,6 +195,7 @@ foreach ($a_poste as $poste)
         $export->add($detail['jr_pj_number']);
         if ($detail['letter'] == -1) { $export->add(""); } 
         else { $export->add($detail['letter']);}
+        $export->add($detail['jr_optype']);
         if ($detail['deb_montant']  > 0 ) 
             $export->add($detail['deb_montant'],"number");
         else
diff --git a/include/export/export_gl_pdf.php b/include/export/export_gl_pdf.php
index 8bb9f89..72ae7b5 100644
--- a/include/export/export_gl_pdf.php
+++ b/include/export/export_gl_pdf.php
@@ -198,7 +198,7 @@ foreach ($a_poste as $poste)
         /* limit set to 40 for the substring */
         $triple_point = (mb_strlen($detail['description']) > 40 ) ? '...':'';
         // $pdf->LongLine($width[$i], 6, 
mb_substr($detail['description'],0,40).$triple_point, 0,$lor[$i]);
-        $pdf->LongLine($width[$i], 6,$detail['description'], 0,$lor[$i]);
+        $pdf->LongLine($width[$i], 
6,$detail['description'].'['.$detail['jr_optype'].']', 0,$lor[$i]);
         $i++;
         $pdf->write_cell($width[$i], 6, $detail['jr_pj_number'], 0, 0, 
$lor[$i]);
         $i++;
diff --git a/include/impress_gl_comptes.inc.php 
b/include/impress_gl_comptes.inc.php
index 8c80b2c..52c2a9e 100644
--- a/include/impress_gl_comptes.inc.php
+++ b/include/impress_gl_comptes.inc.php
@@ -146,7 +146,7 @@ if ( isset( $_REQUEST['bt_html'] ) )
     }
     if ( isDate($_REQUEST['from_periode'])==null || 
isDate($_REQUEST['to_periode'])==null)
     {
-        echo alert('Date malformée, désolée');
+        echo alert(_('Date malformée, désolée'));
         return;
     }
     echo '<div class="content">';
@@ -181,6 +181,7 @@ if ( isset( $_REQUEST['bt_html'] ) )
         <td>R&eacute;f&eacute;rence</td>
         <td>Libell&eacute;</td>
         <td>Pi&egrave;ce</td>
+        <td>Type</td>
         <td align="right">D&eacute;bit</td>
         <td align="right">Cr&eacute;dit</td>
         <td align="right">Solde</td>
@@ -205,15 +206,15 @@ if ( isset( $_REQUEST['bt_html'] ) )
                 echo '<tr class="highlight">
                <td>'.$current_exercice.'</td>
                <td>'.''.'</td>
-               <td>'.'Total du compte '.$poste_id['pcm_val'].'</td>
-               <td>'.''.'</td>
-               <td align="right">'.($solde_d  > 0 ? nbm( $solde_d)  : 
'').'</td>
+               <td>'._("Total du compte").$poste_id['pcm_val'].'</td>
+               <td>'.''.'</td>'.td("").
+               '<td align="right">'.($solde_d  > 0 ? nbm( $solde_d)  : 
'').'</td>
                <td align="right">'.($solde_c  > 0 ? nbm( $solde_c)  : 
'').'</td>
                <td align="right">'.nbm( abs($solde_c-$solde_d)).'</td>
                <td>';
                if ($solde_c > $solde_d ) echo _("Crédit");
                if ($solde_c < $solde_d )  echo _("Débit");
-               if ($solde_c == $solde_d )  echo "=";
+               if ($solde_c == $solde_d )  echo  " ";
 
              echo '</td>'.
                '</tr>';
@@ -241,7 +242,7 @@ if ( isset( $_REQUEST['bt_html'] ) )
                        $side="&nbsp;".$Poste->get_amount_side($solde);
            $letter="";
                $html_let="";
-               if ($detail['letter']!=-1) {
+               if ($detail['letter'] > 0) {
                        
$letter=strtoupper(base_convert($detail['letter'],10,36));
                        $html_let = HtmlInput::show_reconcile("", $letter);
                }
@@ -252,6 +253,7 @@ if ( isset( $_REQUEST['bt_html'] ) )
             
<td>'.HtmlInput::detail_op($detail['jr_id'],$detail['jr_internal']).'</td>
             <td>'.$detail['description'].'</td>
             <td>'.$detail['jr_pj_number'].'</td>
+            <td>'.$detail['jr_optype'].'</td>
             <td align="right">'.($detail['deb_montant']  > 0 ? 
nbm($detail['deb_montant'])  : '').'</td>
             <td align="right">'.($detail['cred_montant'] > 0 ? 
nbm($detail['cred_montant']) : '').'</td>
             <td align="right">'.nbm(abs($solde)).$side.'</td>
@@ -262,8 +264,8 @@ if ( isset( $_REQUEST['bt_html'] ) )
         <td>'.$current_exercice.'</td>
         <td>'.''.'</td>
         <td>'.'<b>'.'Total du compte '.$poste_id['pcm_val'].'</b>'.'</td>
-        <td>'.''.'</td>
-        <td align="right">'.'<b>'.($solde_d  > 0 ? nbm( $solde_d)  : 
'').'</b>'.'</td>
+        <td>'.''.'</td>'.td("").
+        '<td align="right">'.'<b>'.($solde_d  > 0 ? nbm( $solde_d)  : 
'').'</b>'.'</td>
         <td align="right">'.'<b>'.($solde_c  > 0 ? nbm( $solde_c)  : 
'').'</b>'.'</td>
         <td align="right">'.'<b>'.nbm( abs($solde_c-$solde_d)).'</b>'.'</td>
         <td>';
diff --git a/include/opening.inc.php b/include/opening.inc.php
index b37e053..0332888 100644
--- a/include/opening.inc.php
+++ b/include/opening.inc.php
@@ -163,13 +163,13 @@ if ($sa=='step2')
     $periode=$cn->make_array("select distinct p_exercice,p_exercice from 
parm_periode order by p_exercice");
     $w=new ISelect();
     $w->table=0;
-    $w->label='Periode';
+    $w->label=_('Periode N-1');
     $w->readonly=false;
     $w->value=$periode;
     $w->name="p_periode";
     $w->selected=$g_user->get_exercice()-1;
     echo "<p>";
-    echo _('Période').' : '.$w->input();
+    echo _('Période N-1').' : '.$w->input();
     echo "</p>";
     echo HtmlInput::submit('ok', _('Continuer'));
     echo dossier::hidden();
@@ -237,7 +237,7 @@ if ($sa=='step4')
     $result["ac"]=$http->request("ac");
     $result['p_periode']=$p_periode;
     $result['gDossier']=Dossier::id();
-    
+    $result['jr_optype']="OPE";
     // default date = first day of Exercice
     $periode=new Periode($cn,$g_user->get_periode());
     
list($periode_start,$periode_end)=$periode->get_limit($g_user->get_exercice());
@@ -260,7 +260,6 @@ if ($sa=='step4')
         $idx++;
     }
     $cn=Dossier::connect();
-
     $jrn=new Acc_Ledger($cn,$p_jrn);
     $_POST=$result;
     $_REQUEST=$result;
diff --git a/include/operation_ods_confirm.inc.php 
b/include/operation_ods_confirm.inc.php
index 1f9d941..8bb510c 100644
--- a/include/operation_ods_confirm.inc.php
+++ b/include/operation_ods_confirm.inc.php
@@ -45,12 +45,13 @@ echo $ledger->confirm($_POST,false);
 ?>
 <div id="tab_id" >
     <script>
-        var a_tab = ['modele_div_id','reverse_div_id','document_div_id'];
+        var a_tab = 
['modele_div_id','reverse_div_id','document_div_id','operationtype_div_id'];
     </script>
 <ul class="tabs">
     <li class="tabs_selected" style="float: none"> <a 
href="javascript:void(0)" title="<?php echo _("Modèle à sauver")?>"  
onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';show_tabs(a_tab,'modele_div_id')">
 <?php echo _('Modèle')?> </a></li>
     <li class="tabs" style="float: none"> <a href="javascript:void(0)" 
title="<?php echo _("Document")?>"  
onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';show_tabs(a_tab,'document_div_id')">
 <?php echo _('Document')?> </a></li>
     <li class="tabs" style="float: none"> <a href="javascript:void(0)" 
title="<?php echo _("Extourne")?>"  
onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';show_tabs(a_tab,'reverse_div_id')">
 <?php echo _('Extourne')?> </a></li>
+    <li class="tabs" style="float: none"> <a href="javascript:void(0)" 
title="<?php echo _("Type opération")?>"  
onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';show_tabs(a_tab,'operationtype_div_id')">
 <?php echo _('Type opération')?> </a></li>
 </ul>
     <div id="modele_div_id">
         <?php echo Pre_operation::save_propose(); ?>
@@ -73,6 +74,13 @@ echo $ledger->confirm($_POST,false);
         echo '</p>';
         ?>
     </div>
+    <div id="operationtype_div_id" 
style="display:none;height:185px;height:10rem">
+        <?php
+            $status=$http->request("jr_optype","string","NOR");
+            echo $_POST['jr_optype'];
+            echo Acc_Operation::select_operation_type($status)->input();
+        ?>
+    </div>
 </div>
 <?php
 echo HtmlInput::submit("save",_("Confirmer"));
diff --git a/include/operation_ods_new.inc.php 
b/include/operation_ods_new.inc.php
index abded40..4dbeca2 100644
--- a/include/operation_ods_new.inc.php
+++ b/include/operation_ods_new.inc.php
@@ -71,7 +71,7 @@ $p_msg=(isset($p_msg))?$p_msg:"";
 print '<p class="notice">'.$p_msg.'</p>';
 echo '<form method="post"  class="print" onsubmit="return controleBalance();" 
>';
 echo dossier::hidden();
-echo HtmlInput::request_to_hidden(array('ac'));
+echo HtmlInput::request_to_hidden(array('ac','jr_optype'));
 
 echo $ledger->input($p_post);
 
diff --git a/include/template/ledger_detail_bottom.php 
b/include/template/ledger_detail_bottom.php
index 1431661..1ff8c4c 100644
--- a/include/template/ledger_detail_bottom.php
+++ b/include/template/ledger_detail_bottom.php
@@ -145,6 +145,18 @@ endif;
         <tr>
             <td> <?php echo _("Autre information")?> : </td><td><?php echo 
HtmlInput::infobulle(30)." ".$other->input();?></td>
         </tr>
+        <tr>
+            <td>
+                <?=_("Type opération")?>
+            </td>
+            <td>
+                <?php
+                    // Opération type
+                    
+                    echo 
Acc_Operation::select_operation_type($detail->det->jr_optype)->input();
+                ?>
+            </td>
+        </tr>
     </table>
 </div>
 <div id="linked_operation_div<?php echo $div;?>" style="display:<?php echo 
$a_tab['linked_operation_div']['display']?>" class="myfieldset">
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index 9811e0e..ca1521a 100644
--- a/sql/upgrade.sql
+++ b/sql/upgrade.sql
@@ -89,4 +89,10 @@ insert into user_active_security 
(us_login,us_ledger,us_action)  select user_nam
 alter table jrn_def add jrn_enable int;
 alter table jrn_def alter  jrn_enable set default 1;
 update jrn_def set jrn_enable=1;
-comment on column jrn_def.jrn_enable is 'Set to 1 if the ledger is enable ';
\ No newline at end of file
+comment on column jrn_def.jrn_enable is 'Set to 1 if the ledger is enable ';
+
+
+alter table jrn add jr_optype varchar(3);
+alter table jrn alter jr_optype set default 'NOR';
+comment on column jrn.jr_optype is 'Type of operation , NOR = NORMAL , OPE 
opening , EXT extourne, CLO closing';
+update jrn set jr_optype='NOR';
\ No newline at end of file



reply via email to

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