phpcompta-dev
[Top][All Lists]
Advanced

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

[Phpcompta-dev] r587 - in trunk/rapport_avance: . include include/templa


From: phpcompta-dev
Subject: [Phpcompta-dev] r587 - in trunk/rapport_avance: . include include/template
Date: Sat, 23 Nov 2013 21:31:28 +0100 (CET)

Author: danydb
Date: 2013-11-23 21:31:27 +0100 (Sat, 23 Nov 2013)
New Revision: 587

Modified:
   trunk/rapport_avance/ajax_save_param_listing.php
   trunk/rapport_avance/include/class_rapav_listing_formula.php
   trunk/rapport_avance/include/class_rapav_listing_param.php
   trunk/rapport_avance/include/template/listing_param_input.php
   trunk/rapport_avance/rapav_javascript.js
Log:
Add RAPAV_Formula_Formula : display and save

Modified: trunk/rapport_avance/ajax_save_param_listing.php
===================================================================
--- trunk/rapport_avance/ajax_save_param_listing.php    2013-11-23 13:08:07 UTC 
(rev 586)
+++ trunk/rapport_avance/ajax_save_param_listing.php    2013-11-23 20:31:27 UTC 
(rev 587)
@@ -1,4 +1,5 @@
 <?php
+
 /**
  * @file
  * @brief sauve la nouvelle ligne de détail (listing) et renvoie un xml
@@ -22,106 +23,106 @@
 // var_dump($_GET);
 switch ($tab)
 {
-   /* case 'formula':
-        $acc_formula = new RAPAV_Formula();
-        $acc_formula->fp_formula = $formula_new;
-        $acc_formula->p_id = $p_id;
-        $acc_formula->type_detail = 1;
-        $acc_formula->jrn_def_id = $p_ledger;
-        $acc_formula->date_paid = (isset($p_paid)) ? 1 : 0;
+    case 'formula':
+        $acc_formula = new RAPAV_Formula_Formula($formula);
+        $acc_formula->data->setp('formula', $p_formula);
         if ($acc_formula->verify() == 1)
         {
             $code = 'nok';
             $html = $acc_formula->errcode;
+            $lp_id=0;
         } else
         {
-            $acc_formula->insert();
-            $fp_id = $acc_formula->fp_id;
+            $acc_formula->save($_GET);
+            $acc_formula->load();
+            $lp_id = $acc_formula->data->getp('lp_id');
             $code = 'ok';
-            $html = '<td>';
             ob_start();
-            $acc_formula->display_row();
+            echo td($acc_formula->display_code());
+            echo td($acc_formula->display_comment());
+            $r=$acc_formula->display();
+            echo td($r);
+            echo td($acc_formula->display_order());
             $html.=ob_get_contents();
             ob_end_clean();
-            $html.= '</td>';
-            $html.='<td id="del_' . $acc_formula->fp_id . '">';
+            $html.='<td id="del_' . $lp_id . '">';
             $html.=HtmlInput::anchor("Effacer", "", 
sprintf("onclick=\"delete_param_detail('%s','%s','%s','%s')\""
-                                    , $_REQUEST['plugin_code'], 
$_REQUEST['ac'], $_REQUEST['gDossier'], $acc_formula->fp_id));
+                                    , $_REQUEST['plugin_code'], 
$_REQUEST['ac'], $_REQUEST['gDossier'], $lp_id));
             $html.='</td>';
         }
         break;
-    case 'compute_id':
-        $acc_compute = new RAPAV_Compute();
-        $acc_compute->fp_formula = $form_compute;
-        $acc_compute->p_id = $p_id;
-        $acc_compute->type_detail = 3;
-        $acc_compute->jrn_def_id = null;
-        if ($acc_compute->verify() == 1)
-        {
-            $code = 'nok';
-            $html = $acc_compute->errcode;
-        } else
-        {
-            $acc_compute->insert();
-            $fp_id = $acc_compute->fp_id;
-            $code = 'ok';
-            $html = '<td>';
-            ob_start();
-            $acc_compute->display_row();
-            $html.=ob_get_contents();
-            ob_end_clean();
-            $html.= '</td>';
-            $html.='<td id="del_' . $acc_compute->fp_id . '">';
-            $html.=HtmlInput::anchor("Effacer", "", 
sprintf("onclick=\"delete_param_detail('%s','%s','%s','%s')\""
-                                    , $_REQUEST['plugin_code'], 
$_REQUEST['ac'], $_REQUEST['gDossier'], $acc_compute->fp_id));
-            $html.='</td>';
-        }
-        break;
-    case 'new_account_id':
-        $acc_account = new RAPAV_Account();
-        $acc_account->tmp_val = $account_first;
-        $acc_account->with_tmp_val = $account_second;
-        $acc_account->p_id = $p_id;
-        $acc_account->type_detail = 4;
-        $acc_account->type_sum_account = $account_sum_type;
-        $acc_account->jrn_def_id = $p_ledger;
-        $acc_account->date_paid = (isset($p_paid)) ? 1 : 0;
-        if ($acc_account->verify() == 1)
-        {
-            $code = 'nok';
-            $html = $acc_account->errcode;
-        } else
-        {
-            $acc_account->insert();
-            $fp_id = $acc_account->fp_id;
-            $code = 'ok';
-            $html = '<td>';
-            ob_start();
-            $acc_account->display_row();
-            $html.=ob_get_contents();
-            ob_end_clean();
-            $html.= '</td>';
-            $html.='<td id="del_' . $acc_account->fp_id . '">';
-            $html.=HtmlInput::anchor("Effacer", "", 
sprintf("onclick=\"delete_param_detail('%s','%s','%s','%s')\""
-                                    , $_REQUEST['plugin_code'], 
$_REQUEST['ac'], $_REQUEST['gDossier'], $acc_account->fp_id));
-            $html.='</td>';
-        }
-        break;*/
+    /*  case 'compute_id':
+      $acc_compute = new RAPAV_Compute();
+      $acc_compute->fp_formula = $form_compute;
+      $acc_compute->p_id = $p_id;
+      $acc_compute->type_detail = 3;
+      $acc_compute->jrn_def_id = null;
+      if ($acc_compute->verify() == 1)
+      {
+      $code = 'nok';
+      $html = $acc_compute->errcode;
+      } else
+      {
+      $acc_compute->insert();
+      $fp_id = $acc_compute->fp_id;
+      $code = 'ok';
+      $html = '<td>';
+      ob_start();
+      $acc_compute->display_row();
+      $html.=ob_get_contents();
+      ob_end_clean();
+      $html.= '</td>';
+      $html.='<td id="del_' . $acc_compute->fp_id . '">';
+      $html.=HtmlInput::anchor("Effacer", "", 
sprintf("onclick=\"delete_param_detail('%s','%s','%s','%s')\""
+      , $_REQUEST['plugin_code'], $_REQUEST['ac'], $_REQUEST['gDossier'], 
$acc_compute->fp_id));
+      $html.='</td>';
+      }
+      break;
+      case 'new_account_id':
+      $acc_account = new RAPAV_Account();
+      $acc_account->tmp_val = $account_first;
+      $acc_account->with_tmp_val = $account_second;
+      $acc_account->p_id = $p_id;
+      $acc_account->type_detail = 4;
+      $acc_account->type_sum_account = $account_sum_type;
+      $acc_account->jrn_def_id = $p_ledger;
+      $acc_account->date_paid = (isset($p_paid)) ? 1 : 0;
+      if ($acc_account->verify() == 1)
+      {
+      $code = 'nok';
+      $html = $acc_account->errcode;
+      } else
+      {
+      $acc_account->insert();
+      $fp_id = $acc_account->fp_id;
+      $code = 'ok';
+      $html = '<td>';
+      ob_start();
+      $acc_account->display_row();
+      $html.=ob_get_contents();
+      ob_end_clean();
+      $html.= '</td>';
+      $html.='<td id="del_' . $acc_account->fp_id . '">';
+      $html.=HtmlInput::anchor("Effacer", "", 
sprintf("onclick=\"delete_param_detail('%s','%s','%s','%s')\""
+      , $_REQUEST['plugin_code'], $_REQUEST['ac'], $_REQUEST['gDossier'], 
$acc_account->fp_id));
+      $html.='</td>';
+      }
+      break; */
     case 'new_attribute_id':
         ob_start();
         $attr = new RAPAV_Formula_Attribute($formula, $listing_id);
         $attr->save($_GET);
         $attr->load();
-        $lp_id=$attr->data->getp("lp_id");
+        $lp_id = $attr->data->getp("lp_id");
         $code = 'ok';
-        $html="";
+        $html = "";
         echo td($attr->display_code());
         echo td($attr->display_comment());
         echo td($attr->display_order());
         echo td($attr->display());
         $html.=ob_get_contents();
         ob_end_clean();
-        $html.='<td id="del_' .$lp_id . '">';
+        $html.='<td id="del_' . $lp_id . '">';
         $html.=HtmlInput::anchor("Effacer", "", 
sprintf("onclick=\"delete_listing_detail('%s','%s','%s','%s')\""
                                 , $_REQUEST['plugin_code'], $_REQUEST['ac'], 
$_REQUEST['gDossier'], $lp_id));
         $html.='</td>';

Modified: trunk/rapport_avance/include/class_rapav_listing_formula.php
===================================================================
--- trunk/rapport_avance/include/class_rapav_listing_formula.php        
2013-11-23 13:08:07 UTC (rev 586)
+++ trunk/rapport_avance/include/class_rapav_listing_formula.php        
2013-11-23 20:31:27 UTC (rev 587)
@@ -11,6 +11,8 @@
  *
  * @author dany
  */
+require_once 'class_impress.php';
+
 abstract class RAPAV_Listing_Formula
 {
 
@@ -80,28 +82,34 @@
         switch ($obj->getp('formula_type'))
         {
             case 'ATTR':
-                $ret=new Rapav_Formula_Attribute($obj);
+                $ret = new Rapav_Formula_Attribute($obj);
                 break;
+            case 'FORM':
+                $ret = new Rapav_Formula_Formula($obj);
+                break;
 
             default:
-                throw new Exception ('Object '.$obj.' invalide ');
+                throw new Exception('Object ' .var_export( $obj,true) . ' 
invalide ');
                 break;
-           
         }
         return $ret;
     }
+
     function display_code()
     {
         return $this->data->getp('code');
     }
+
     function display_comment()
     {
         return $this->data->getp('comment');
     }
+
     function display_order()
     {
         return $this->data->getp('order');
     }
+
     function load()
     {
         $this->data->load();
@@ -114,15 +122,24 @@
 
///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
  * @brief Class for the listing detail attribute, this class use 
RAPAV_Listing_Param_SQL
- * the specific columns are attribut_card
+ * the specific columns are 
+ *   - attribut_card
  */
 class RAPAV_Formula_Attribute extends RAPAV_Listing_Formula
 {
 
-    var $data;           /**< RAPAV_Listing_Param_SQL objet */
-    var $cat;            /**< categorie id */
-    var $sig;            /**< Object signature */
+    /**
+     * RAPAV_Listing_Param_SQL objet */
+    var $data;
 
+    /**
+     * categorie id */
+    var $cat;
+
+    /**
+     * Object signature */
+    var $sig;
+
     function __construct(RAPAV_Listing_Param_SQL $obj, $p_cat_id = 0)
     {
         global $cn;
@@ -187,3 +204,108 @@
     }
 
 }
+
+///////////////////////////////////////////////////////////////////////////////
+// RAPAV_Formula_Formula
+///////////////////////////////////////////////////////////////////////////////
+/**
+ * @brief Class for the listing detail attribute, this class 
+ * use RAPAV_Listing_Param_SQL the specific columns are 
+ *   - fp_formula
+ *   - jrn_def_id
+ *   - date_paid
+ *  
+ */
+class RAPAV_Formula_Formula extends RAPAV_Listing_Formula
+{
+
+    /**
+     * < RAPAV_Listing_Param_SQL objet */
+    var $data;
+
+    /**
+     * < Object signature 
+     */
+    var $sig;
+
+    function __construct(RAPAV_Listing_Param_SQL $obj)
+    {
+        global $cn;
+        $this->data = $obj;
+        $this->sig = 'FORM';
+    }
+
+    function display()
+    {
+        $ledger = $this->get_ledger_name();
+        $paid = ( $this->data->date_paid != 0 ) ? "la date concerne la date de 
paiement, la recherche sera limitée au journaux de type ACH & VEN" : "";
+        $str = sprintf("Résultat de la formule %s utilisant $ledger %s", 
$this->data->fp_formula, $paid);
+        return $str;
+    }
+
+    function compute($p_start, $p_end)
+    {
+        return 0;
+    }
+
+    function input()
+    {
+        $account = new IPoste("p_formula", "", "formula_input_id");
+        $account->size = 50;
+        $account->label = _("Recherche poste");
+        $account->set_attribute('gDossier', dossier::id());
+        $account->set_attribute('bracket', 1);
+        $account->set_attribute('no_overwrite', 1);
+        $account->set_attribute('noquery', 1);
+        $account->set_attribute('account', "formula_input_id");
+        echo $account->input();
+        parent::input_date_paiement();
+        parent::input_ledger();
+    }
+
+    function save($p_array)
+    {
+        parent::set($p_array);
+        $this->data->setp('listing_id', $p_array['listing_id']);
+        /* Clean everything but keep the lp_id, l_id, with_Card and ad_id  + 
common */
+        $a_toclean = explode(',', 'operation_pcm_val,with_tmp_val,tmp_val, '
+                . 'type_sum_account, tt_id, '
+                . 'fp_signed,  tva_id'
+                . ',lp_card_saldo,attribut_card');
+
+        parent::set_to_null($a_toclean);
+        $this->data->setp('with_card', 'N');
+        $this->data->setp('formula', $p_array['p_formula']);
+        if (isset($p_array['p_paid']))
+        {
+            $this->data->setp('date_paid', 1);
+        } else
+        {
+            $this->data->setp('date_paid', null);
+            
+        }
+        $this->data->setp('jrn_def_id', $p_array['p_ledger']);
+        $this->data->setp('formula_type', 'FORM');
+        $this->data->save();
+    }
+
+    /**
+     * @brief check if the formula is valid, return 1 for an error
+     * and set errode to the error
+     */
+    function verify()
+    {
+        if (Impress::check_formula($this->data->fp_formula) == false)
+        {
+            $this->errcode = "Erreur dans votre formule";
+            return 1;
+        }
+        if (trim($this->data->fp_formula) == "")
+        {
+            $this->errcode = " Aucune formule trouvée";
+            return 1;
+        }
+        return 0;
+    }
+
+}

Modified: trunk/rapport_avance/include/class_rapav_listing_param.php
===================================================================
--- trunk/rapport_avance/include/class_rapav_listing_param.php  2013-11-23 
13:08:07 UTC (rev 586)
+++ trunk/rapport_avance/include/class_rapav_listing_param.php  2013-11-23 
20:31:27 UTC (rev 587)
@@ -80,6 +80,7 @@
         $order=new INum('order');
         $order->value=10;
         $attribute=new RAPAV_Formula_Attribute($this->Param,$p_id);
+        $formula=new RAPAV_Formula_Formula($this->Param,$p_id);
         require 'template/listing_param_input.php';
     }
 }

Modified: trunk/rapport_avance/include/template/listing_param_input.php
===================================================================
--- trunk/rapport_avance/include/template/listing_param_input.php       
2013-11-23 13:08:07 UTC (rev 586)
+++ trunk/rapport_avance/include/template/listing_param_input.php       
2013-11-23 20:31:27 UTC (rev 587)
@@ -77,7 +77,7 @@
                           <?php echo 
HtmlInput::request_to_hidden(array('gDossier', 'ac', 'plugin_code', 'p_id')) ?>
                     <p>
                         <?php echo HtmlInput::hidden('tab', 'formula') ?>
-                        <?php echo "formula"; ?>
+                        <?php echo $formula->input() ?>
                     </p>
 
                     <?php echo HtmlInput::submit('save', 'Sauve') ?>

Modified: trunk/rapport_avance/rapav_javascript.js
===================================================================
--- trunk/rapport_avance/rapav_javascript.js    2013-11-23 13:08:07 UTC (rev 
586)
+++ trunk/rapport_avance/rapav_javascript.js    2013-11-23 20:31:27 UTC (rev 
587)
@@ -658,10 +658,13 @@
                             var position = fixed_position(451, 217) + 
';width:50%';
                             add_div({'id': json.cin, 'cssclass': 'inner_box', 
'drag': 1, 'style': position});
                             $(json.cin).innerHTML = code_html;
+                          
                         } catch (e) {
                             console.log(e);
                             console.log(code_html);
                         }
+                        console.log('trying to execute javascript');
+                        code_html.evalScripts();
                     }
                 }
         );



---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu



reply via email to

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