phpcompta-dev
[Top][All Lists]
Advanced

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

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


From: phpcompta-dev
Subject: [Phpcompta-dev] r445 - in trunk/rapport_avance: . include include/template
Date: Thu, 29 Nov 2012 22:44:01 +0100 (CET)

Author: danydb
Date: 2012-11-29 22:44:01 +0100 (Thu, 29 Nov 2012)
New Revision: 445

Modified:
   trunk/rapport_avance/ajax_save_param_detail.php
   trunk/rapport_avance/include/class_formulaire_param.php
   trunk/rapport_avance/include/class_formulaire_param_detail.php
   trunk/rapport_avance/include/class_rapav_declaration.php
   trunk/rapport_avance/include/class_rapport_avance_sql.php
   trunk/rapport_avance/include/template/param_detail_new.php
   trunk/rapport_avance/rapav_javascript.js
Log:
rapport_avance : ajout 4i?\195?\168me formule

Modified: trunk/rapport_avance/ajax_save_param_detail.php
===================================================================
--- trunk/rapport_avance/ajax_save_param_detail.php     2012-10-02 17:33:52 UTC 
(rev 444)
+++ trunk/rapport_avance/ajax_save_param_detail.php     2012-11-29 21:44:01 UTC 
(rev 445)
@@ -31,98 +31,125 @@
  */
 require_once 'class_impress.php';
 require_once 'include/class_formulaire_param_detail.php';
-$fp_id=0;
-switch($tab)
+$fp_id = 0;
+switch ($tab)
 {
        case 'account_tva':
-               $acc_tva=new RAPAV_Account_Tva();
-               $acc_tva->tva_id=$code_tva;
-               $acc_tva->tmp_val=$formtva;
-               $acc_tva->jrn_def_type=$code_jrn;
-               $acc_tva->p_id=$p_id;
-               $acc_tva->type_detail=2;
-               $acc_tva->tt_id=$code_base;
+               $acc_tva = new RAPAV_Account_Tva();
+               $acc_tva->tva_id = $code_tva;
+               $acc_tva->tmp_val = $formtva;
+               $acc_tva->jrn_def_type = $code_jrn;
+               $acc_tva->p_id = $p_id;
+               $acc_tva->type_detail = 2;
+               $acc_tva->tt_id = $code_base;
                if ($acc_tva->verify() == 1)
                {
-                       $code='nok';
-                       $html="Erreur dans la formule ".$acc_tva->errcode;
+                       $code = 'nok';
+                       $html = "Erreur dans la formule " . $acc_tva->errcode;
                }
                else
                {
                        $acc_tva->insert();
-                       $code='ok';
-                       $fp_id=$acc_tva->fp_id;
-                       $html='<td>';
+                       $code = 'ok';
+                       $fp_id = $acc_tva->fp_id;
+                       $html = '<td>';
                        ob_start();
                        $acc_tva->display_row();
                        $html.=ob_get_contents();
                        ob_end_clean();
                        $html.= '</td>';
-                       $html.='<td id="del_'.$acc_tva->fp_id.'">';
-                       
$html.=HtmlInput::anchor("Effacer","",sprintf("onclick=\"delete_param_detail('%s','%s','%s','%s')\""
-                                       , $_REQUEST['plugin_code'], 
$_REQUEST['ac'], $_REQUEST['gDossier'], $acc_tva->fp_id));
+                       $html.='<td id="del_' . $acc_tva->fp_id . '">';
+                       $html.=HtmlInput::anchor("Effacer", "", 
sprintf("onclick=\"delete_param_detail('%s','%s','%s','%s')\""
+                                                                       , 
$_REQUEST['plugin_code'], $_REQUEST['ac'], $_REQUEST['gDossier'], 
$acc_tva->fp_id));
                        $html.= '</td>';
                }
                break;
        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 = new RAPAV_Formula();
+               $acc_formula->fp_formula = $formula_new;
+               $acc_formula->p_id = $p_id;
+               $acc_formula->type_detail = 1;
                if ($acc_formula->verify() == 1)
                {
-                       $code='nok';
-                       $html=$acc_formula->errcode;
+                       $code = 'nok';
+                       $html = $acc_formula->errcode;
                }
                else
                {
                        $acc_formula->insert();
-                       $fp_id=$acc_formula->fp_id;
-                       $code='ok';
-                       $html='<td>';
+                       $fp_id = $acc_formula->fp_id;
+                       $code = 'ok';
+                       $html = '<td>';
                        ob_start();
                        $acc_formula->display_row();
                        $html.=ob_get_contents();
                        ob_end_clean();
                        $html.= '</td>';
-                       $html.='<td id="del_'.$acc_formula->fp_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));
+                       $html.='<td id="del_' . $acc_formula->fp_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));
                        $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 = new RAPAV_Compute();
+               $acc_compute->fp_formula = $form_compute;
+               $acc_compute->p_id = $p_id;
+               $acc_compute->type_detail = 3;
                if ($acc_compute->verify() == 1)
                {
-                       $code='nok';
-                       $html=$acc_compute->errcode;
+                       $code = 'nok';
+                       $html = $acc_compute->errcode;
                }
                else
                {
                        $acc_compute->insert();
-                       $fp_id=$acc_compute->fp_id;
-                       $code='ok';
-                       $html='<td>';
+                       $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 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;
+               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;
 }
 //echo $html;exit();
-$html=escape_xml($html);
+$html = escape_xml($html);
 
 header('Content-type: text/xml; charset=UTF-8');
 echo <<<EOF

Modified: trunk/rapport_avance/include/class_formulaire_param.php
===================================================================
--- trunk/rapport_avance/include/class_formulaire_param.php     2012-10-02 
17:33:52 UTC (rev 444)
+++ trunk/rapport_avance/include/class_formulaire_param.php     2012-11-29 
21:44:01 UTC (rev 445)
@@ -185,6 +185,9 @@
                        case '3':
                                return new 
RAPAV_Compute($this->parametre[$p_index]['fp_id']);
                                break;
+                       case '4':
+                               return new 
RAPAV_Account($this->parametre[$p_index]['fp_id']);
+                               break;
                }
        }
        /**
@@ -196,7 +199,7 @@
                echo HtmlInput::hidden('p_id[]', $this->obj->p_id);
                $max = count($this->parametre);
                echo HtmlInput::hidden("count_" . $this->id, $max);
-               echo '<h5 class="title">' . 'code ' . $this->obj->p_code . 
'</h5>';
+               //echo '<h5 class="title">' . 'code ' . $this->obj->p_code . 
'</h5>';
                echo '<p>';
                echo '<table id="table_' . $this->id . '">';
                for ($i = 0; $i < $max; $i++)

Modified: trunk/rapport_avance/include/class_formulaire_param_detail.php
===================================================================
--- trunk/rapport_avance/include/class_formulaire_param_detail.php      
2012-10-02 17:33:52 UTC (rev 444)
+++ trunk/rapport_avance/include/class_formulaire_param_detail.php      
2012-11-29 21:44:01 UTC (rev 445)
@@ -35,7 +35,8 @@
        function input_new($p_id)
        {
                $parent = new Formulaire_Param($p_id);
-               echo HtmlInput::title_box($parent->p_code . " " . 
$parent->p_libelle, 'param_detail_div');
+               echo HtmlInput::title_box('Formule', 'param_detail_div');
+               echo '<h2>'.$parent->p_code . " " . $parent->p_libelle.'</h2>';
                require_once 'template/param_detail_new.php';
        }
 
@@ -190,5 +191,62 @@
        }
 
 }
+/**
+ * @TODO poste comptable utilisé avec le poste comptable, choix entre diff 
crédit - debit, diff débit-crédit, crédit, débit
+ */
+class RAPAV_Account extends Formulaire_Param_Detail
+{
 
+       function display_row()
+       {
+               global $cn;
+               $total_type_account=$cn->get_value('select tt_label from 
rapport_advanced.total_type_account where tt_id=$1',
+                               array($this->type_sum_account));
+               printf("Total %s poste comptable %s utilisé avec le poste 
comptable %s",
+                               
$total_type_account,$this->tmp_val,$this->with_tmp_val);
+       }
+
+       static function new_row($p_id)
+       {
+               global $cn;
+               $sum_type=new ISelect('account_sum_type');
+               $sum_type->value=$cn->make_array("select tt_id, tt_label from 
rapport_advanced.total_type_account ");
+
+               $account = new IPoste("account_first", "", "account_first_id");
+               $account->size = 10;
+               $account->label = _("Recherche poste");
+               $account->set_attribute('gDossier', dossier::id());
+               $account->set_attribute('account', $account->id);
+
+               $account_second = new IPoste("account_second", "", 
"account_second_id");
+               $account_second->size = 10;
+               $account_second->label = _("Recherche poste");
+               $account_second->set_attribute('gDossier', dossier::id());
+               $account_second->set_attribute('account', $account_second->id);
+               echo '<p>';
+               echo 'Calculer ';
+               echo $sum_type->input();
+               echo '</p>';
+               echo '<p>';
+               echo 'du poste comptable ';
+               echo $account->input();
+               echo '</p>';
+               echo '<p>';
+               echo ' utilisé avec le poste comptable ';
+               echo $account_second->input();
+               echo '</p>';
+       }
+       function verify()
+       {
+
+               if ( trim($this->tmp_val)=="" || trim($this->with_tmp_val)=="")
+               {
+                       $this->errcode=" Un poste comptable est manquant";
+                       return 1;
+               }
+               return 0;
+       }
+
+}
+
 ?>

Modified: trunk/rapport_avance/include/class_rapav_declaration.php
===================================================================
--- trunk/rapport_avance/include/class_rapav_declaration.php    2012-10-02 
17:33:52 UTC (rev 444)
+++ trunk/rapport_avance/include/class_rapav_declaration.php    2012-11-29 
21:44:01 UTC (rev 445)
@@ -249,7 +249,8 @@
                bcscale(2);
                $this->amount = "0";
 
-               $array = $cn->get_array("select 
fp_id,p_id,tmp_val,tva_id,fp_formula,fp_signed,jrn_def_type,tt_id,type_detail
+               $array = $cn->get_array("select 
fp_id,p_id,tmp_val,tva_id,fp_formula,fp_signed,jrn_def_type,tt_id,type_detail,
+                       with_tmp_val,type_sum_account
                        from rapport_advanced.formulaire_param_detail where 
p_id=$1", array($this->param->p_id));
                $this->compute_date($p_start, $p_end);
                for ($e = 0; $e < count($array); $e++)
@@ -290,6 +291,9 @@
                        case '3':
                                $ret = new Rapav_dd_Compute();
                                break;
+                       case '4':
+                               $ret = new Rapav_dd_Account();
+                               break;
                        default:
                                throw new Exception("Type inconnu");
                }
@@ -307,7 +311,7 @@
        function from_array($p_array)
        {
                $this->form = new Formulaire_Param_Detail();
-               $attribute = explode(',', 
'fp_id,p_id,tmp_val,tva_id,fp_formula,fp_signed,jrn_def_type,tt_id,type_detail');
+               $attribute = explode(',', 
'fp_id,p_id,tmp_val,tva_id,fp_formula,fp_signed,jrn_def_type,tt_id,type_detail,with_tmp_val,type_sum_account');
                foreach ($attribute as $e)
                {
                        $this->form->$e = $p_array[$e];
@@ -523,4 +527,113 @@
 
 }
 
+/**
+ * @brief handle the param_detail type Account
+ * The type_sum_account gives the type of total
+ *   - 0 D-C
+ *   - 1 C-D
+ *   - 2 D
+ *   - 4 C
+ * it uses tmp_val, with_tmp_val and type_sum_account
+ * @see RAPAV_Account
+ */
+class Rapav_dd_Account extends Rapav_Declaration_Detail
+{
+
+       function compute($p_start, $p_end)
+       {
+               global $cn;
+               bcscale(2);
+               switch ($this->form->type_sum_account)
+               {
+                       // Saldo
+                       case 1:
+                       case 2:
+                               // Compute D-C
+                               $sql = "
+                                               select sum(jrnx_amount)
+                                               from (
+                                                       select distinct 
jrn1.j_id,case when jrn1.j_debit = 't' then jrn1.j_montant else 
jrn1.j_montant*(-1) end as jrnx_amount
+                                                       from jrnx as jrn1
+                                                       join jrnx as jrn2 on 
(jrn1.j_grpt=jrn2.j_grpt)
+                                                       where
+                                                       jrn1.j_poste like $1
+                                                       and
+                                                       jrn2.j_poste like $2
+                                                       and (jrn1.j_date >= 
to_date($3,'DD.MM.YYYY') and jrn1.j_date <= to_date($4,'DD.MM.YYYY'))
+                                                       ) as tv_amount
+                                                        ";
+                               $amount=$cn->get_value($sql,array(
+                                       $this->form->tmp_val,
+                                       $this->form->with_tmp_val,
+                                       $p_start,
+                                       $p_end
+                                       ));
+                               // if C-D is asked then reverse the result
+                               if ($this->form->type_sum_account==2) 
$amount=bcmul($amount,-1);
+                               break;
+                       // Only DEBIT
+                       case 3:
+                                       $sql = "
+                                               select sum(jrnx_amount)
+                                               from (
+                                                       select distinct 
jrn1.j_id,jrn1.j_montant as jrnx_amount
+                                                       from jrnx as jrn1
+                                                       join jrnx as jrn2 on 
(jrn1.j_grpt=jrn2.j_grpt)
+                                                       where
+                                                       jrn1.j_poste like $1
+                                                       and
+                                                       jrn2.j_poste like $2
+                                                       and
+                                                       jrn1.j_debit='t'
+                                                       and
+                                                       (jrn1.j_date >= 
to_date($3,'DD.MM.YYYY') and jrn1.j_date <= to_date($4,'DD.MM.YYYY'))
+                                                       ) as tv_amount
+                                                        ";
+                               $amount=$cn->get_value($sql,array(
+                                       $this->form->tmp_val,
+                                       $this->form->with_tmp_val,
+                                       $p_start,
+                                       $p_end
+                                       ));
+                               break;
+                       // Only CREDIT
+                       case 4:
+                                       $sql = "
+                                               select sum(jrnx_amount)
+                                               from (
+                                                       select distinct 
jrn1.j_id,jrn1.j_montant as jrnx_amount
+                                                       from jrnx as jrn1
+                                                       join jrnx as jrn2 on 
(jrn1.j_grpt=jrn2.j_grpt)
+                                                       where
+                                                       jrn1.j_poste like $1
+                                                       and
+                                                       jrn2.j_poste like $2
+                                                       and
+                                                       jrn1.j_debit='f'
+                                                       and
+                                                       (jrn1.j_date >= 
to_date($3,'DD.MM.YYYY') and jrn1.j_date <= to_date($4,'DD.MM.YYYY'))
+                                                       ) as tv_amount
+                                                        ";
+                               $amount=$cn->get_value($sql,array(
+                                       $this->form->tmp_val,
+                                       $this->form->with_tmp_val,
+                                       $p_start,
+                                       $p_end
+                                       ));
+                               break;
+
+                       default:
+                               if ( DEBUG) var_dump($this);
+                               die (__FILE__.":".__LINE__." UNKNOW SUM TYPE");
+                               break;
+               }
+               /*
+                * 4 possibilities with type_sum_account
+                */
+               return $amount;
+       }
+
+}
+
 ?>

Modified: trunk/rapport_avance/include/class_rapport_avance_sql.php
===================================================================
--- trunk/rapport_avance/include/class_rapport_avance_sql.php   2012-10-02 
17:33:52 UTC (rev 444)
+++ trunk/rapport_avance/include/class_rapport_avance_sql.php   2012-11-29 
21:44:01 UTC (rev 445)
@@ -118,7 +118,9 @@
                        "fp_signed"=>"fp_signed",
                        "jrn_def_type"=>"jrn_def_type",
                        "tt_id"=>"tt_id",
-                       "type_detail"=>"type_detail"
+                       "type_detail"=>"type_detail",
+                       "with_tmp_val"=>"with_tmp_val",
+                       "type_sum_account"=>"type_sum_account"
                );
 
                $this->type = array(
@@ -130,7 +132,10 @@
                        "fp_signed"=>"numeric",
                        "jrn_def_type"=>"text",
                        "tt_id"=>"numeric",
-                       "type_detail"=>"numeric"
+                       "type_detail"=>"numeric",
+                       "with_tmp_val"=>"text",
+                       "type_sum_account"=>"numeric"
+
                );
 
                $this->default = array(

Modified: trunk/rapport_avance/include/template/param_detail_new.php
===================================================================
--- trunk/rapport_avance/include/template/param_detail_new.php  2012-10-02 
17:33:52 UTC (rev 444)
+++ trunk/rapport_avance/include/template/param_detail_new.php  2012-11-29 
21:44:01 UTC (rev 445)
@@ -47,6 +47,11 @@
                        Poste comptable et code TVA
                </a>
        </td>
+       <td id="new_account_id_bt"  class="tool" style="background:inherit">
+               <a class="mtitle" href="javascript:void(0)"   
onclick="show_type_formula('new_account_id')">
+                       Poste comptable
+               </a>
+       </td>
 </tr>
 </table>
 <div style="width:100%;height:290px;margin:1px">
@@ -95,4 +100,15 @@
 
 </form>
 </div>
+       <div id="new_account_id" style="display: none">
+<form id="new_paded" method="POST" 
onsubmit="save_param_detail('new_paded');return false">
+
+       
<?=HtmlInput::request_to_hidden(array('gDossier','ac','plugin_code','p_id'))?>
+
+       <?=HtmlInput::hidden('tab','new_account_id')?>
+               <?=RAPAV_Account::new_row($p_id)?>
+<?=HtmlInput::submit('save','Sauve')?>
+
+</form>
+</div>
 </div>
\ No newline at end of file

Modified: trunk/rapport_avance/rapav_javascript.js
===================================================================
--- trunk/rapport_avance/rapav_javascript.js    2012-10-02 17:33:52 UTC (rev 
444)
+++ trunk/rapport_avance/rapav_javascript.js    2012-11-29 21:44:01 UTC (rev 
445)
@@ -214,7 +214,7 @@
 {
        try
        {
-               var 
div=['new_account_tva_id','new_formula_id','new_compute_id'];
+               var 
div=['new_account_tva_id','new_formula_id','new_compute_id','new_account_id'];
                for (var r =0;r<div.length;r++ ) {
                        $(div[r]).hide();
                        $(div[r]+'_bt').style.backgroundColor="inherit";



---
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]