noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 01/03: Restructure files , move show_pj.php t


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 01/03: Restructure files , move show_pj.php to export_receipt.php
Date: Sat, 17 Oct 2015 15:07:05 +0000

sparkyx pushed a commit to branch master
in repository noalyss.

commit c59cca605b111523a8225e2404000b3bef576900
Author: Dany De Bontridder <address@hidden>
Date:   Sat Oct 17 15:41:48 2015 +0200

    Restructure files , move show_pj.php to export_receipt.php
---
 include/ajax/ajax_ledger.php                       |   11 ++----
 include/class/class_acc_ledger_purchase.php        |    2 +-
 include/class/class_acc_ledger_sold.php            |    2 +-
 .../export/export_receipt.php                      |   34 ++++++-------------
 include/lib/class_html_input.php                   |   17 ++++++++--
 sql/upgrade.sql                                    |    5 +++
 6 files changed, 36 insertions(+), 35 deletions(-)

diff --git a/include/ajax/ajax_ledger.php b/include/ajax/ajax_ledger.php
index 0184ad6..4b639bc 100644
--- a/include/ajax/ajax_ledger.php
+++ b/include/ajax/ajax_ledger.php
@@ -231,7 +231,7 @@ case 'file':
 
             $sp=new ISpan('file'.$div);
             
$sp->style="display:none;background-color:red;color:white;font-size:12px";
-            $sp->value="Chargement";
+            $sp->value=_("Chargement");
             echo $sp->input();
             echo HtmlInput::hidden('act','loadfile');
             echo dossier::hidden();
@@ -283,9 +283,7 @@ case 'file':
         {
             $filename=mb_substr($obj->det->jr_pj_name,0,23);
         }
-        $h=sprintf('<a class="mtitle"  
href="show_pj.php?gDossier=%d&jrn=%d&jr_grpt_id=%d">%s</a>',
-                   $gDossier,$ledger,$obj->det->jr_grpt_id,h( $filename));
-        echo $h;
+        echo HtmlInput::show_receipt_document($jr_id,h($filename));
         echo $x;
         echo '</div>';
         echo '</body></html>';
@@ -324,9 +322,8 @@ case 'loadfile':
             echo $x;
         }
         $filename= $obj->det->jr_pj_name;
-        $h=sprintf('<a class="mtitle"  
href="show_pj.php?gDossier=%d&jrn=%d&jr_grpt_id=%d">%s</a>',
-                   $gDossier,$ledger,$obj->det->jr_grpt_id,h($filename));
-        echo $h;
+        echo HtmlInput::show_receipt_document($jr_id,h($filename));
+
         echo '</div>';
 
     }
diff --git a/include/class/class_acc_ledger_purchase.php 
b/include/class/class_acc_ledger_purchase.php
index f057f42..86b8afb 100644
--- a/include/class/class_acc_ledger_purchase.php
+++ b/include/class/class_acc_ledger_purchase.php
@@ -796,7 +796,7 @@ class  Acc_Ledger_Purchase extends Acc_Ledger
             if ( isset($_POST['gen_invoice']) )
             {
                 $ref_doc= $this->create_document($internal,$p_array);
-                $this->doc='<A class="line" 
HREF="show_pj.php?'.dossier::get().'&jr_grpt_id='.$seq.'&jrn='.$this->id.'">'.$ref_doc.'</A>';
+                
$this->doc=HtmlInput::show_receipt_document($this->jr_id,h($ref_doc));
             }
 
             //----------------------------------------
diff --git a/include/class/class_acc_ledger_sold.php 
b/include/class/class_acc_ledger_sold.php
index 912cf2f..d13e811 100644
--- a/include/class/class_acc_ledger_sold.php
+++ b/include/class/class_acc_ledger_sold.php
@@ -478,7 +478,7 @@ class Acc_Ledger_Sold extends Acc_Ledger {
                 /* Generate an invoice and save it into the database */
                 if (isset($_POST['gen_invoice'])) {
                     $file = $this->create_document($internal, $p_array);
-                    $this->doc='<A class="line" HREF="show_pj.php?' . 
dossier::get() . '&jr_grpt_id=' . $seq . '&jrn=' . $this->id . '">' . $file . 
'</A>';
+                    
$this->doc=HtmlInput::show_receipt_document($this->jr_id,h($file));
                 }
             }
             //----------------------------------------
diff --git a/html/show_pj.php b/include/export/export_receipt.php
similarity index 79%
rename from html/show_pj.php
rename to include/export/export_receipt.php
index 2af9bbf..93981ee 100644
--- a/html/show_pj.php
+++ b/include/export/export_receipt.php
@@ -21,37 +21,21 @@
 /*!\file
  * \brief show an attach of an operation
  */
-require_once '../include/constant.php';
+if ( ! defined ('ALLOWED')) die (_('Non autorisé'));
+
 include_once NOALYSS_INCLUDE.'/lib/ac_common.php';
 require_once  NOALYSS_INCLUDE.'/class/class_dossier.php';
-$gDossier=dossier::id();
-
-if ( !isset ($_GET['jrn'] ) ||
-        !isset($_GET['jr_grpt_id']))
-{
-    echo_error("Missing parameters");
-}
-
 require_once NOALYSS_INCLUDE.'/lib/class_database.php';
-set_language();
 
-$jr_grpt_id=$_GET['jr_grpt_id'];
+$jr_id=HtmlInput::default_value_get('jr_id',"0");
 
-$cn=Dossier::connect();
+if ( $jr_id==0 || isNumber($jr_id) != 1 ) die (_('Données invalides'));
 
+$r=$cn->exec_sql("select jr_def_id from jrn where jr_id=$1",array($jr_id));
 
-require_once NOALYSS_INCLUDE.'/class/class_user.php';
-global $g_user;
-$g_user=new User($cn);
-$g_user->Check();
-$g_user->check_dossier($gDossier);
-if ( isNumber($jr_grpt_id) != 1 ) die (_('Données invalides'));
-
-// retrieve the jrn
-$r=$cn->exec_sql("select jr_def_id from jrn where jr_grpt_id=$jr_grpt_id");
 if ( Database::num_row($r) == 0 )
 {
-    echo_error("Invalid operation id jr_grpt_id=$jr_grpt_id");
+    echo_error("Invalid operation id jr_id=$jr_id");
     exit;
 }
 $a=Database::fetch_array($r,0);
@@ -65,10 +49,14 @@ if ($g_user->check_jrn($jrn) == 'X' )
 }
 
 $cn->start();
-$ret=$cn->exec_sql("select jr_pj,jr_pj_name,jr_pj_type from jrn where 
jr_grpt_id=$jr_grpt_id");
+$ret=$cn->exec_sql("select jr_pj,jr_pj_name,jr_pj_type from jrn where 
jr_id=$1",
+        array($jr_id));
+
 if ( Database::num_row ($ret) == 0 )
     return;
+
 $row=Database::fetch_array($ret,0);
+
 if ( $row['jr_pj']==null )
 {
     ini_set('zlib.output_compression','Off');
diff --git a/include/lib/class_html_input.php b/include/lib/class_html_input.php
index 2fca3fa..ba33de0 100755
--- a/include/lib/class_html_input.php
+++ b/include/lib/class_html_input.php
@@ -884,18 +884,29 @@ class HtmlInput
          * the ledger 
          * @global $cn database connx
          * @param $p_jr_id jrn.jr_id
+         * @param $p_name name in the link , if the name is empty then we show 
the icon
          * @return nothing or HTML Code for a link to the document
          */
-        static function show_receipt_document($p_jr_id)
+        static function show_receipt_document($p_jr_id,$p_name="")
         {
             global $cn;
+            $image=$p_name;
             
+            // Check the jr_id has a receipt document
             $array=$cn->get_array('select jr_def_id,jr_pj_name,jr_grpt_id from 
jrn where jr_id=$1',array($p_jr_id));
             if (count($array)==0) return "";
             if ($array[0]['jr_pj_name'] == "") return "";
             $str_dossier=Dossier::get();
-            $image='<IMG style="width:24px;height:24px;border:0px" 
SRC="image/documents.png" title="' . $array[0]['jr_pj_name'] . '" >';
-            $r=sprintf('<A class="detail" 
HREF="show_pj.php?jrn=%s&jr_grpt_id=%s&%s">%s</A>', $array[0]['jr_def_id'], 
$array[0]['jr_grpt_id'], $str_dossier, $image);
+            
+            // Name is empty then use an image
+            if ( $p_name == "") {
+                $image='<IMG style="width:24px;height:24px;border:0px" 
SRC="image/documents.png" title="' . h($array[0]['jr_pj_name']) . '" >';
+            } 
+            
+            // Build the url
+            
$href=http_build_query(array('gDossier'=>Dossier::id(),'jr_id'=>$p_jr_id,'act'=>'RAW:receipt'));
+            
+            $r=sprintf('<A class="mtitle line" HREF="export.php?%s">%s</A>', 
$href, $image);
             return $r;
             
         }
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index 95646e0..e35879d 100644
--- a/sql/upgrade.sql
+++ b/sql/upgrade.sql
@@ -5,3 +5,8 @@ CREATE TRIGGER fiche_detail_upd_trg
   ON fiche_detail
   FOR EACH ROW
   EXECUTE PROCEDURE comptaproc.fiche_detail_qcode_upd();
+
+insert into menu_ref(me_code,me_file,me_menu,me_description,me_type) 
+values ('RAW:receipt','export_receipt.php','Export la pièce','export la pièce 
justificative d''une opération','PR');
+
+insert into profile_menu (me_code,p_id,p_type_display) select 
'RAW:receipt',p_id,'P' from profile where p_id > 0;
\ No newline at end of file



reply via email to

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