noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 33/46: Task #1277 : RTF conversion char accen


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 33/46: Task #1277 : RTF conversion char accentuated
Date: Mon, 4 May 2020 13:38:52 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 8f95aeed5d690d4907c6a4ba903d6eafcdfe936c
Author: Dany De Bontridder <address@hidden>
AuthorDate: Sat Apr 4 01:21:56 2020 +0200

    Task #1277 : RTF conversion char accentuated
---
 include/class/acc_bilan.class.php | 15 ++++---
 include/impress_bilan.inc.php     | 82 ++++++++++++++++++++-------------------
 include/lib/ac_common.php         | 20 +++++++++-
 3 files changed, 72 insertions(+), 45 deletions(-)

diff --git a/include/class/acc_bilan.class.php 
b/include/class/acc_bilan.class.php
index 76ec7b8..398a3eb 100644
--- a/include/class/acc_bilan.class.php
+++ b/include/class/acc_bilan.class.php
@@ -258,9 +258,10 @@ class Acc_Bilan
      */
     function get_request_get()
     {
-        $this->b_id=(isset($_GET['b_id']))?$_GET['b_id']:"";
-        $this->from=( isset ($_GET['from_periode']))?$_GET['from_periode']:-1;
-        $this->to=( isset ($_GET['to_periode']))?$_GET['to_periode']:-1;
+        $http=new \HttpInput();
+        $this->b_id=$http->get("b_id","number","");
+        $this->from=$http->get("from_periode","number",-1);
+        $this->to=$http->get("to_periode","number",-1);
     }
     /*!\brief load from the database the document data  */
     function load()
@@ -501,7 +502,10 @@ class Acc_Bilan
         }
 
        $header_txt=header_txt($this->db);
-
+        
+        if  ($this->b_type == "rtf") {
+            $header_txt=convert_to_rtf($header_txt);
+        }
         while ( !feof($p_file) )
         {
             $line_rtf=fgets($p_file);
@@ -537,7 +541,8 @@ class Acc_Bilan
                             if($ret[0]['acct_name'])
                             {
                                 /* for rtf we have the string to put it in 
latin1 */
-                                $a = utf8_decode($ret[0]['acct_name']);
+                                if ( $this->b_type != "rtf") { $a = 
utf8_decode($ret[0]['acct_name']);}
+                                if ( $this->b_type == "rtf") { $a 
=convert_to_rtf($ret[0]['acct_name']);}
                             }
                         }
                     }
diff --git a/include/impress_bilan.inc.php b/include/impress_bilan.inc.php
index bde62b6..89cca00 100644
--- a/include/impress_bilan.inc.php
+++ b/include/impress_bilan.inc.php
@@ -36,51 +36,55 @@ global $g_user;
 //-----------------------------------------------------
 // Form
 //-----------------------------------------------------
-
+$http=new \HttpInput();
 $bilan=new Acc_Bilan($cn);
 $bilan->get_request_get();
 echo '<div class="content">';
-$exercice=(isset($_GET['exercice']))?$_GET['exercice']:$g_user->get_exercice();
+$exercice=$http->get("exercice","number",$g_user->get_exercice());
+//----------------------------------------------------------------
+// Verification
+//----------------------------------------------------------------
 if ( ! isset ($_GET['verif']))
 {
-/*
- * Let you change the exercice
- */
-echo '<fieldset><legend>'._('Exercice').'</legend>';;
-echo '<form method="GET">';
-echo _('Choisissez un autre exercice');
-$ex=new Exercice($cn);
-$wex=$ex->select('exercice',$exercice,' onchange="submit(this)"');
-echo $wex->input();
-echo dossier::hidden();
-echo HtmlInput::get_to_hidden(array('ac','type'));
-echo '</form>';
-echo '</fieldset>';
+    /*
+     * Let you change the exercice
+     */
+    echo '<fieldset><legend>'._('Exercice').'</legend>';;
+    echo '<form method="GET">';
+    echo _('Choisissez un autre exercice');
+    $ex=new Exercice($cn);
+    $wex=$ex->select('exercice',$exercice,' onchange="submit(this)"');
+    echo $wex->input();
+    echo dossier::hidden();
+    echo HtmlInput::get_to_hidden(array('ac','type'));
+    echo '</form>';
+    echo '</fieldset>';
 
-$filter_year=" where p_exercice='".sql_string($exercice)."'";
-echo '<FORM  METHOD="GET">';
-echo HtmlInput::hidden('type','bilan');
-echo dossier::hidden();
+    $filter_year=" where p_exercice='".sql_string($exercice)."'";
+    echo '<FORM  METHOD="GET">';
+    echo HtmlInput::hidden('type','bilan');
+    echo dossier::hidden();
 
-// By default , show last day of exercice
-if ($bilan->to == -1 ){
-    $t_periode=new Periode($cn);
-    list($per_max,$per_min)=$t_periode->get_limit($exercice);
-    $bilan->to=$per_min->p_id;
-}
-echo $bilan->display_form ($filter_year);
-echo '<span class="notice"> '._('Attention : si le bilan n\'est pas 
équilibré.<br> Vérifiez <ul>
-       <li>L\'affectation du résultat est fait</li>
-       <li>Vos comptes actifs ont  un solde débiteur (sauf les comptes dit 
inversés)</li>
-       <li> les comptes passifs ont un solde créditeur (sauf les comptes dit 
inversés) </li>
-       </ul>
-       Utilisez la balance des comptes pour vérifier.').' </span>';
-echo HtmlInput::submit('verif',_('Verification comptabilite'));
-echo HtmlInput::get_to_hidden(array('ac','exercice'));
-echo '</FORM>';
+    // By default , show last day of exercice
+    if ($bilan->to == -1 ){
+        $t_periode=new Periode($cn);
+        list($per_max,$per_min)=$t_periode->get_limit($exercice);
+        $bilan->to=$per_min->p_id;
+    }
+    echo $bilan->display_form ($filter_year);
+    echo '<span class="notice"> '._('Attention : si le bilan n\'est pas 
équilibré.<br> Vérifiez <ul>
+           <li>L\'affectation du résultat est fait</li>
+           <li>Vos comptes actifs ont  un solde débiteur (sauf les comptes dit 
inversés)</li>
+           <li> les comptes passifs ont un solde créditeur (sauf les comptes 
dit inversés) </li>
+           </ul>
+           Utilisez la balance des comptes pour vérifier.').' </span>';
+    echo HtmlInput::submit('verif',_('Verification comptabilite'));
+    echo HtmlInput::get_to_hidden(array('ac','exercice'));
+    echo '</FORM>';
 }
-
-
+//----------------------------------------------------------------
+// Print 
+//----------------------------------------------------------------
 if ( isset($_GET['verif']))
 {
     $periode=new Periode($cn);
@@ -95,7 +99,7 @@ if ( isset($_GET['verif']))
     echo '<FORM METHOD="GET" ACTION="export.php">';
     echo dossier::hidden();
     echo HtmlInput::get_to_hidden(array('exercice'));
-    echo HtmlInput::hidden('b_id',$_GET['b_id']);
+    echo HtmlInput::hidden('b_id',$bilan->b_id);
     echo HtmlInput::hidden('act','OTH:Bilan');
 
     echo HtmlInput::hidden('from_periode',$bilan->from);
@@ -107,4 +111,4 @@ if ( isset($_GET['verif']))
 
 echo '<hr>';
 echo '</div>';
-?>
+
diff --git a/include/lib/ac_common.php b/include/lib/ac_common.php
index d93463f..df4ae72 100644
--- a/include/lib/ac_common.php
+++ b/include/lib/ac_common.php
@@ -1347,4 +1347,22 @@ if(!function_exists('tracedebug')) {
     file_put_contents($tmp_file, $output, FILE_APPEND);
   }
 }
-?>
+/**
+ * encode the string for RTF, return a stringu
+ * @param $p_string string to convert
+ * @return string
+ */
+function convert_to_rtf($p_string)
+{
+    $result="";
+    $p_string2=utf8_decode($p_string);
+    $nb_result=strlen($p_string2);
+    for ($i = 0 ; $i < $nb_result ; $i++ ){
+        if (ord($p_string[$i]) < 127 ) {
+            $result.=$p_string[$i];
+        } else {
+            $result.='\u'.ord($p_string[$i]).chr(92).chr(39).'3f';
+        }
+    }
+    return $result;
+}
\ No newline at end of file



reply via email to

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