phpcompta-dev
[Top][All Lists]
Advanced

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

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


From: phpcompta-dev
Subject: [Phpcompta-dev] r446 - in trunk/rapport_avance: . include include/template
Date: Fri, 14 Dec 2012 21:41:15 +0100 (CET)

Author: danydb
Date: 2012-12-14 21:41:14 +0100 (Fri, 14 Dec 2012)
New Revision: 446

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:
Ajout formule : op?\195?\169ration rapproch?\195?\169es

Modified: trunk/rapport_avance/ajax_save_param_detail.php
===================================================================
--- trunk/rapport_avance/ajax_save_param_detail.php     2012-11-29 21:44:01 UTC 
(rev 445)
+++ trunk/rapport_avance/ajax_save_param_detail.php     2012-12-14 20:41:14 UTC 
(rev 446)
@@ -147,6 +147,37 @@
                        $html.='</td>';
                }
                break;
+
+               case 'new_reconcile_id':
+               $acc_account = new RAPAV_Reconcile();
+               $acc_account->tmp_val = $acrec_first;
+               $acc_account->with_tmp_val = $acrec_second;
+               $acc_account->operation_pcm_val = $acrec_third;
+               $acc_account->p_id = $p_id;
+               $acc_account->type_detail = 5;
+               $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);

Modified: trunk/rapport_avance/include/class_formulaire_param.php
===================================================================
--- trunk/rapport_avance/include/class_formulaire_param.php     2012-11-29 
21:44:01 UTC (rev 445)
+++ trunk/rapport_avance/include/class_formulaire_param.php     2012-12-14 
20:41:14 UTC (rev 446)
@@ -188,6 +188,9 @@
                        case '4':
                                return new 
RAPAV_Account($this->parametre[$p_index]['fp_id']);
                                break;
+                       case '5':
+                               return new 
RAPAV_Reconcile($this->parametre[$p_index]['fp_id']);
+                               break;
                }
        }
        /**

Modified: trunk/rapport_avance/include/class_formulaire_param_detail.php
===================================================================
--- trunk/rapport_avance/include/class_formulaire_param_detail.php      
2012-11-29 21:44:01 UTC (rev 445)
+++ trunk/rapport_avance/include/class_formulaire_param_detail.php      
2012-12-14 20:41:14 UTC (rev 446)
@@ -192,7 +192,7 @@
 
 }
 /**
- * @TODO poste comptable utilisé avec le poste comptable, choix entre diff 
crédit - debit, diff débit-crédit, crédit, débit
+ address@hidden 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
 {
@@ -228,11 +228,11 @@
                echo $sum_type->input();
                echo '</p>';
                echo '<p>';
-               echo 'du poste comptable ';
+               echo 'du poste comptable '.HtmlInput::infobulle(203);
                echo $account->input();
                echo '</p>';
                echo '<p>';
-               echo ' utilisé avec le poste comptable ';
+               echo ' utilisé avec le poste comptable 
'.HtmlInput::infobulle(203);
                echo $account_second->input();
                echo '</p>';
        }
@@ -248,5 +248,74 @@
        }
 
 }
+/**
+ address@hidden poste comptable utilisé avec le poste comptable, choix entre 
diff crédit - debit, diff débit-crédit, crédit, débit
+ */
+class RAPAV_Reconcile 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 rapprochée dans la période donnée
+                       avec une opération utilisant le poste comptable %s",
+                               
$total_type_account,$this->tmp_val,$this->with_tmp_val,$this->operation_pcm_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("acrec_first", "", "acrec_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("acrec_second", "", 
"acrec_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);
+
+               $account_third = new IPoste("acrec_third", "", 
"acrec_third_id");
+               $account_third->size = 10;
+               $account_third->label = _("Recherche poste");
+               $account_third->set_attribute('gDossier', dossier::id());
+               $account_third->set_attribute('account', $account_third->id);
+               echo '<p>';
+               echo 'Calculer ';
+               echo $sum_type->input();
+               echo '</p>';
+               echo '<p>';
+               echo 'du poste comptable '.HtmlInput::infobulle(203);
+               echo $account->input();
+               echo '</p>';
+               echo '<p>';
+               echo ' utilisé avec le poste comptable 
'.HtmlInput::infobulle(203);
+               echo $account_second->input();
+               echo '</p>';
+               echo '<p>';
+               echo ' rapproché avec une opération dans la période donnée 
utilisant le poste comptable '.HtmlInput::infobulle(203);
+               echo $account_third->input();
+
+               echo '</p>';
+       }
+       function verify()
+       {
+
+               if ( trim($this->tmp_val)=="" || trim($this->with_tmp_val)=="" 
||trim($this->operation_pcm_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-11-29 
21:44:01 UTC (rev 445)
+++ trunk/rapport_avance/include/class_rapav_declaration.php    2012-12-14 
20:41:14 UTC (rev 446)
@@ -250,7 +250,7 @@
                $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,
-                       with_tmp_val,type_sum_account
+                       with_tmp_val,type_sum_account,operation_pcm_val
                        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++)
@@ -294,6 +294,9 @@
                        case '4':
                                $ret = new Rapav_dd_Account();
                                break;
+                       case '5':
+                               $ret = new Rapav_dd_Reconcile();
+                               break;
                        default:
                                throw new Exception("Type inconnu");
                }
@@ -311,7 +314,8 @@
        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,with_tmp_val,type_sum_account');
+               $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,operation_pcm_val');
                foreach ($attribute as $e)
                {
                        $this->form->$e = $p_array[$e];
@@ -635,5 +639,135 @@
        }
 
 }
+/**
+ * @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_Reconcile 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(tv_amount.jrnx_amount)
+                                                       from (
+                                                               select distinct 
jrn1.j_id,j1.jr_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)
+                                                               join jrn as j1 
on (jrn1.j_grpt=j1.jr_grpt_id)
+                                                               where
+                                                               jrn1.j_poste 
like $1
+                                                               and     
jrn2.j_poste like $2
+                                                               ) as tv_amount
+                                                       join jrn_rapt as rap1 
on (rap1.jr_id=tv_amount.jr_id or rap1.jra_concerned=tv_amount.jr_id)
+                                                       join (select distinct 
jrn3.j_id,j2.jr_id
+                                                               from jrnx as 
jrn3
+                                                               join jrn as j2 
on (j2.jr_grpt_id=jrn3.j_grpt)
+                                                               where
+                                                       (jrn3.j_date >= 
to_date($3,'DD.MM.YYYY') and jrn3.j_date <= to_date($4,'DD.MM.YYYY')) and
+                                                                jrn3.j_poste 
like $5) as reconc on (rap1.jr_id=reconc.jr_id or 
rap1.jra_concerned=reconc.jr_id)
+
+                                                        ";
+                               $amount=$cn->get_value($sql,array(
+                                       $this->form->tmp_val,
+                                       $this->form->with_tmp_val,
+                                       $p_start,
+                                       $p_end,
+                                       $this->form->operation_pcm_val
+                                       ));
+                               // 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(tv_amount.jrnx_amount)
+                                                       from (
+                                                               select distinct 
jrn1.j_id,j1.jr_id,
+                                                               jrn1.j_montant 
as jrnx_amount
+                                                               from jrnx as 
jrn1
+                                                               join jrnx as 
jrn2 on (jrn1.j_grpt=jrn2.j_grpt)
+                                                               join jrn as j1 
on (jrn1.j_grpt=j1.jr_grpt_id)
+                                                               where
+                                                               jrn1.j_poste 
like $1
+                                                               and     
jrn2.j_poste like $2
+                                                               and 
jrn1.j_debit='t'
+                                                               ) as tv_amount
+                                                       join jrn_rapt as rap1 
on (rap1.jr_id=tv_amount.jr_id or rap1.jra_concerned=tv_amount.jr_id)
+                                                       join (select distinct 
jrn3.j_id,j2.jr_id
+                                                               from jrnx as 
jrn3
+                                                               join jrn as j2 
on (j2.jr_grpt_id=jrn3.j_grpt)
+                                                               where
+                                                       (jrn3.j_date >= 
to_date($3,'DD.MM.YYYY') and jrn3.j_date <= to_date($4,'DD.MM.YYYY')) and
+                                                                jrn3.j_poste 
like $5) as reconc on (rap1.jr_id=reconc.jr_id or 
rap1.jra_concerned=reconc.jr_id)
+
+                                                        ";
+                               $amount=$cn->get_value($sql,array(
+                                       $this->form->tmp_val,
+                                       $this->form->with_tmp_val,
+                                       $p_start,
+                                       $p_end,
+                                       $this->form->operation_pcm_val
+                                       ));
+                               break;
+                       // Only CREDIT
+                       case 4:
+                                       $sql = "
+                                       select sum(tv_amount.jrnx_amount)
+                                                       from (
+                                                               select distinct 
jrn1.j_id,j1.jr_id,
+                                                               jrn1.j_montant  
as jrnx_amount
+                                                               from jrnx as 
jrn1
+                                                               join jrnx as 
jrn2 on (jrn1.j_grpt=jrn2.j_grpt)
+                                                               join jrn as j1 
on (jrn1.j_grpt=j1.jr_grpt_id)
+                                                               where
+                                                               jrn1.j_poste 
like $1
+                                                               and     
jrn2.j_poste like $2
+                                                               and 
jrn1.j_debit='f'
+                                                               ) as tv_amount
+                                                       join jrn_rapt as rap1 
on (rap1.jr_id=tv_amount.jr_id or rap1.jra_concerned=tv_amount.jr_id)
+                                                       join (select distinct 
jrn3.j_id,j2.jr_id
+                                                               from jrnx as 
jrn3
+                                                               join jrn as j2 
on (j2.jr_grpt_id=jrn3.j_grpt)
+                                                               where
+                                                       (jrn3.j_date >= 
to_date($3,'DD.MM.YYYY') and jrn3.j_date <= to_date($4,'DD.MM.YYYY')) and
+                                                                jrn3.j_poste 
like $5) as reconc on (rap1.jr_id=reconc.jr_id or 
rap1.jra_concerned=reconc.jr_id)
+
+                                                        ";
+                               $amount=$cn->get_value($sql,array(
+                                       $this->form->tmp_val,
+                                       $this->form->with_tmp_val,
+                                       $p_start,
+                                       $p_end,
+                                       $this->form->operation_pcm_val
+                                       ));
+                               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-11-29 
21:44:01 UTC (rev 445)
+++ trunk/rapport_avance/include/class_rapport_avance_sql.php   2012-12-14 
20:41:14 UTC (rev 446)
@@ -120,7 +120,8 @@
                        "tt_id"=>"tt_id",
                        "type_detail"=>"type_detail",
                        "with_tmp_val"=>"with_tmp_val",
-                       "type_sum_account"=>"type_sum_account"
+                       "type_sum_account"=>"type_sum_account",
+                       "operation_pcm_val"=>"operation_pcm_val"
                );
 
                $this->type = array(
@@ -134,7 +135,8 @@
                        "tt_id"=>"numeric",
                        "type_detail"=>"numeric",
                        "with_tmp_val"=>"text",
-                       "type_sum_account"=>"numeric"
+                       "type_sum_account"=>"numeric",
+                       "operation_pcm_val"=>"text"
 
                );
 

Modified: trunk/rapport_avance/include/template/param_detail_new.php
===================================================================
--- trunk/rapport_avance/include/template/param_detail_new.php  2012-11-29 
21:44:01 UTC (rev 445)
+++ trunk/rapport_avance/include/template/param_detail_new.php  2012-12-14 
20:41:14 UTC (rev 446)
@@ -52,10 +52,17 @@
                        Poste comptable
                </a>
        </td>
+       <td id="new_reconcile_id_bt"  class="tool" style="background:inherit">
+               <a class="mtitle" href="javascript:void(0)"   
onclick="show_type_formula('new_reconcile_id')">
+                       Opérations rapprochées
+               </a>
+       </td>
 </tr>
 </table>
 <div style="width:100%;height:290px;margin:1px">
        <span class="error" id="param_detail_info_div"></span>
+
+       <div style="padding: 10px">
 <div id="new_formula_id" style="display: block">
        <p>
        Entrer une formule avec des postes comptables, la syntaxe est la même 
que celle des "rapports"
@@ -111,4 +118,16 @@
 
 </form>
 </div>
+               <div id="new_reconcile_id" style="display: none">
+<form id="new_padee" method="POST" 
onsubmit="save_param_detail('new_padee');return false">
+
+       
<?=HtmlInput::request_to_hidden(array('gDossier','ac','plugin_code','p_id'))?>
+
+       <?=HtmlInput::hidden('tab','new_reconcile_id')?>
+               <?=RAPAV_Reconcile::new_row($p_id)?>
+<?=HtmlInput::submit('save','Sauve')?>
+
+</form>
+</div>
+       </div>
 </div>
\ No newline at end of file

Modified: trunk/rapport_avance/rapav_javascript.js
===================================================================
--- trunk/rapport_avance/rapav_javascript.js    2012-11-29 21:44:01 UTC (rev 
445)
+++ trunk/rapport_avance/rapav_javascript.js    2012-12-14 20:41:14 UTC (rev 
446)
@@ -2,6 +2,7 @@
 
 content[200]="Le code doit être unique pour ce formulaire";
 content[201]="Formula TODO";
+content[203]="Utiliser le % pour indiquer les postes comptables qui en 
dépendent ex: 70% pour reprendre tous les comptes commençant par 70";
 
 /**
  address@hidden show the definition of a form and let it modify it
@@ -87,9 +88,9 @@
                                onSuccess:function(req){
                                        remove_waiting_box();
                                        removeDiv('param_detail_div');
-                                       var nTop=calcy(100);
+                                       var nTop=calcy(90);
                                        var nLeft="200px";
-                                       var 
str_style="top:"+nTop+"px;left:"+nLeft+";width:50em;height:auto";
+                                       var 
str_style="top:"+nTop+"px;left:"+nLeft+";width:70em;height:auto";
                                        add_div({
                                                id:'param_detail_div',
                                                style:str_style,
@@ -214,7 +215,7 @@
 {
        try
        {
-               var 
div=['new_account_tva_id','new_formula_id','new_compute_id','new_account_id'];
+               var 
div=['new_account_tva_id','new_formula_id','new_compute_id','new_account_id','new_reconcile_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]