noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 30/323: Task #1326 & #1512 = ajout détail ex


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 30/323: Task #1326 & #1512 = ajout détail extourne, libellé
Date: Wed, 14 Mar 2018 17:38:12 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit f8129d81db8b3b7c278e4984a033fd05f8ecf272
Author: Dany De Bontridder <address@hidden>
Date:   Mon Jan 8 19:57:30 2018 +0100

    Task #1326 & #1512 = ajout détail extourne, libellé
---
 html/js/acc_ledger.js                     | 19 +++++++++++++++++-
 include/ajax/ajax_ledger.php              |  8 ++++++--
 include/class/acc_ledger.class.php        | 32 ++++++++++++++++++-------------
 include/class/acc_ledger_sold.class.php   |  2 +-
 include/template/ledger_detail_bottom.php | 18 ++++++++++++++---
 5 files changed, 59 insertions(+), 20 deletions(-)

diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js
index 5257ed2..1b75586 100644
--- a/html/js/acc_ledger.js
+++ b/html/js/acc_ledger.js
@@ -832,7 +832,24 @@ function reverseOperation(obj)
                 method: 'get',
                 parameters: qs,
                 onFailure: error_box,
-                onSuccess: infodiv
+                onSuccess: function (req) {
+                    try {
+                        var action = new Ajax.Request(
+                                "ajax_misc.php",
+                                {
+                                    method: 'get',
+                                    parameters:{"gDossier" : 
obj["gDossier"].value,"op":"ledger","act":"de","div":obj['div'].value,"jr_id":obj['jr_id'].value},
+                                    onFailure: error_box,
+                                    onSuccess: function (xml, txt) {
+                                        
+                                        success_box(xml, txt);
+                                        infodiv(req);
+                                    }
+                                });
+                    } catch (ex) {
+                        smoke.alert(ex.message);
+                    }
+                }
             }
     );
 
diff --git a/include/ajax/ajax_ledger.php b/include/ajax/ajax_ledger.php
index ca13c49..7da2448 100644
--- a/include/ajax/ajax_ledger.php
+++ b/include/ajax/ajax_ledger.php
@@ -555,17 +555,21 @@ case 'reverseop':
         try
         {
             $ext_date=$http->request("ext_date","date");
+            $ext_label=$http->request("ext_label");
             $cn->start();
             $oLedger=new Acc_Ledger($cn,$ledger);
             $oLedger->jr_id=$jr_id;
-            $oLedger->reverse($ext_date);
+            if ( trim($ext_label) == "" ) {
+                $ext_label=_("Extourne").$cn->get_value("select jr_comment 
from jrn where jr_id=$1",[$jr_id]);
+            }
+            $oLedger->reverse($ext_date,$ext_label);
             $cn->commit();
             echo _("Opération extournée");
         }
         catch (Exception $e)
         {
             record_log($e->getTraceAsString());
-            $e->getMessage();
+            echo $e->getMessage();
             $cn->rollback();
         }
     }
diff --git a/include/class/acc_ledger.class.php 
b/include/class/acc_ledger.class.php
index bb79892..4f278d3 100644
--- a/include/class/acc_ledger.class.php
+++ b/include/class/acc_ledger.class.php
@@ -175,13 +175,14 @@ class Acc_Ledger extends jrn_def_sql
      * reverse the operation by creating the opposite one,
      * the result is to avoid it
      * it must be done in
-     * - jrn
-     * - jrnx
-     * - quant_fin
-     * - quant_sold
-     * - quant_purchase
-     * - stock
-     * - ANC
+     *    - jrn
+     *    - jrnx
+     *    - quant_fin
+     *    - quant_sold
+     *    - quant_purchase
+     *    - stock
+     *    - ANC
+     * Add or update a note into jrn_note
      * @param $p_date is the date of the reversed op
      * @exception if date is invalid or other prob
      * @note automatically create a reconciliation between operation
@@ -189,7 +190,7 @@ class Acc_Ledger extends jrn_def_sql
      * This function should be in operation or call an acc_operation object
      * 
      */
-    function reverse($p_date)
+    function reverse($p_date,$p_label)
     {
         global $g_user;
         try
@@ -229,9 +230,14 @@ class Acc_Ledger extends jrn_def_sql
 
 
             // Mark the operation invalid into the ledger
-            // to avoid to nullify twice the same op.
-            $sql="update jrn set jr_comment='extourne : '||jr_comment where 
jr_id=$1";
-            $Res=$this->db->exec_sql($sql, array($this->jr_id));
+            // to avoid to nullify twice the same op., add or update a note 
into jrn_note
+            if ($this->db->get_value("select count(*) from jrn_note where 
jr_id=$1",[$this->jr_id])>0){
+                $sql="update jrn_note set n_text=$2||n_text where jr_id=$1";
+                $Res=$this->db->exec_sql($sql, array($this->jr_id,$p_label));
+            }else {
+                $sql="insert into jrn_note(n_text,jr_id) values ($1,$2)";
+                $Res=$this->db->exec_sql($sql, array($p_label,$this->jr_id));
+            }
 
             // Check return code
             if ($Res==false)
@@ -302,14 +308,14 @@ class Acc_Ledger extends jrn_def_sql
               jr_internal
               ,jr_tech_per, jr_valid
               )
-              select $1,jr_def_id,jr_montant,jr_comment,
+              select $1,jr_def_id,jr_montant,$7,
               to_date($2,'DD.MM.YYYY'),$3,$4,
               $5, true
               from
               jrn
               where   jr_id=$6";
             $Res=$this->db->exec_sql($sql,
-                    array($seq, $p_date, $grp_new, $p_internal, $per->p_id, 
$this->jr_id));
+                    array($seq, $p_date, $grp_new, $p_internal, $per->p_id, 
$this->jr_id,$p_label));
             // Check return code
             if ($Res==false)
                 throw (new Exception(__FILE__.__LINE__."SQL ERROR [ $sql ]"));
diff --git a/include/class/acc_ledger_sold.class.php 
b/include/class/acc_ledger_sold.class.php
index 658b7a4..4c5a20d 100644
--- a/include/class/acc_ledger_sold.class.php
+++ b/include/class/acc_ledger_sold.class.php
@@ -162,7 +162,7 @@ class Acc_Ledger_Sold extends Acc_Ledger {
             /* check if amount are numeric and */
             if (isNumber(${'e_march' . $i . '_price'}) == 0)
                 throw new Exception(_('La fiche ') . ${'e_march' . $i} . _('a 
un montant invalide [') . ${'e_march' . $i} . ']', 6);
-            if (isNumber(${'e_quant' . $i}) == 0)
+            if (isNumber(${'e_quant' . $i}) == 0) 
                 throw new Exception(_('La fiche ') . ${'e_march' . $i} . _('a 
une quantité invalide [') . ${'e_quant' . $i} . ']', 7);
             /* check if all card has a ATTR_DEF_ACCOUNT */
             $fiche = new Fiche($this->db);
diff --git a/include/template/ledger_detail_bottom.php 
b/include/template/ledger_detail_bottom.php
index b83000a..4900a09 100644
--- a/include/template/ledger_detail_bottom.php
+++ b/include/template/ledger_detail_bottom.php
@@ -311,7 +311,9 @@ if ( $div != 'popup' ) {
     $remove->javascript="return confirm_box(null,'Vous confirmez effacement 
?',function () 
{removeOperation('".$obj->det->jr_id."',".dossier::id().",'".$div."')})";
     echo $remove->input();
   }
-
+ //----------------------------------------------------
+ // Extourne
+ //----------------------------------------------------
   $reverse=new IButton('bext'.$div);
   $reverse->label=_('Extourner');
   $reverse->javascript="g('ext".$div."').style.display='block'";
@@ -319,8 +321,10 @@ if ( $div != 'popup' ) {
     echo '</p>';
 echo '</form>';
 
-  echo '<div id="ext'.$div.'" class="inner_box" 
style="position:relative;top:-150px;display:none">';
+  echo '<div id="ext'.$div.'" class="inner_box" 
style="position:absolute;top:40px;display:none">';
   $date=new IDate('ext_date');
+  $extourne_label=new IText("ext_label");
+  $extourne_label->size=40;
   $r="<form id=\"form_".$div."\" onsubmit=\"return false;\">";
   $r.=HtmlInput::hidden('jr_id',$_REQUEST['jr_id'])
       . 
HtmlInput::hidden('div',$div).dossier::hidden().HtmlInput::hidden('act','reverseop');
@@ -329,8 +333,16 @@ echo '</form>';
   $r.= _("Extourner une opération vous permet de l'annuler par son écriture 
inverse");
   $r.="</p>";
 
+  $r.="<p>";
   $r.=_("entrez une date")." :".$date->input();
-    $r.='<p  style="text-align:center">';
+  $r.="</p>";
+
+  $r.="<p>";
+  $r.=_("Libellé")." :".$extourne_label->input();
+  $r.="</p>";
+
+  
+  $r.='<p  style="text-align:center">';
   $r.=HtmlInput::submit('x','accepter',
           'onclick="confirm_box($(\'form_'.$div.'\'),\'Vous confirmez  ? 
\',function () 
{$(\'form_'.$div.'\').divname=\''.$div.'\';reverseOperation($(\'form_'.$div.'\'))});
 return false"');
     $r.="</p>";



reply via email to

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