[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpcompta-dev] r591 - in trunk/rapport_avance: . include include/templa
From: |
phpcompta-dev |
Subject: |
[Phpcompta-dev] r591 - in trunk/rapport_avance: . include include/template |
Date: |
Mon, 25 Nov 2013 20:56:25 +0100 (CET) |
Author: danydb
Date: 2013-11-25 20:56:25 +0100 (Mon, 25 Nov 2013)
New Revision: 591
Added:
trunk/rapport_avance/ajax_listing_search_code.php
Modified:
trunk/rapport_avance/ajax.php
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 compute and account
Modified: trunk/rapport_avance/ajax.php
===================================================================
--- trunk/rapport_avance/ajax.php 2013-11-25 19:22:47 UTC (rev 590)
+++ trunk/rapport_avance/ajax.php 2013-11-25 19:56:25 UTC (rev 591)
@@ -5,7 +5,8 @@
'mod_form,add_row_definition,mod_param,add_param_detail,'.
'rapav_search_code,save_param_detail,rapav_declaration_display,'.
'listing_modify,listing_remove_modele,listing_display_definition,'.
- 'listing_param_add,save_param_listing,listing_remove_detail');
+ 'listing_param_add,save_param_listing,listing_detail_remove,'.
+ 'listing_search_code');
if ( in_array($act,$a_action ) == true )
{
include 'ajax_'.$act.'.php';
Added: trunk/rapport_avance/ajax_listing_search_code.php
===================================================================
--- trunk/rapport_avance/ajax_listing_search_code.php
(rev 0)
+++ trunk/rapport_avance/ajax_listing_search_code.php 2013-11-25 19:56:25 UTC
(rev 591)
@@ -0,0 +1,56 @@
+<?php
+
+/*
+ * This file is part of PhpCompta.
+ *
+ * PhpCompta is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * PhpCompta is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with PhpCompta; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+/* $Revision$ */
+
+// Copyright Author Dany De Bontridder address@hidden
+
+/**
+ * @file
+ * @brief show the list of code of the form
+ *
+ */
+global $cn;
+$array=$cn->get_array("select lp_id,lp_code,lp_comment
+ from rapport_advanced.listing_param
+ where l_id=$1 order by 2",array($f_id));
+echo HtmlInput::title_box('Code Formulaire','search_code_div');
+?>
+<table>
+ <tr>
+ <th>
+ Code
+ </th>
+ <th>
+ Libellé
+ </th>
+ </tr>
+ <?php for ($i=0;$i<count($array);$i++): ?>
+ <tr>
+ <td>
+ <?php echo
HtmlInput::anchor(h($array[$i]['lp_code']),"",
+
'onclick="$(\'form_compute\').value+=\'['.$array[$i]['lp_code'].']\';removeDiv(\'search_code_div\');"')
+ ?>
+ </td>
+ <td>
+ <?php echo h($array[$i]['lp_comment'])?>
+ </td>
+ </tr>
+ <?php endfor;?>
+</table>
Modified: trunk/rapport_avance/ajax_save_param_listing.php
===================================================================
--- trunk/rapport_avance/ajax_save_param_listing.php 2013-11-25 19:22:47 UTC
(rev 590)
+++ trunk/rapport_avance/ajax_save_param_listing.php 2013-11-25 19:56:25 UTC
(rev 591)
@@ -20,7 +20,7 @@
require_once 'class_impress.php';
require_once 'include/class_rapav_listing_param.php';
$formula = new RAPAV_Listing_Param_SQL();
-// var_dump($_GET);
+
switch ($tab)
{
case 'formula':
@@ -30,7 +30,7 @@
{
$code = 'nok';
$html = $acc_formula->errcode;
- $lp_id=0;
+ $lp_id = 0;
} else
{
$acc_formula->save($_GET);
@@ -40,74 +40,73 @@
ob_start();
echo td($acc_formula->display_code());
echo td($acc_formula->display_comment());
- $r=$acc_formula->display();
+ $r = $acc_formula->display();
echo td($r);
echo td($acc_formula->display_order());
$html.=ob_get_contents();
ob_end_clean();
- $html.='<td id="del_' . $lp_id . '">';
+ $html.='<td>';
$html.=HtmlInput::anchor("Effacer", "",
sprintf("onclick=\"listing_detail_remove('%s','%s','%s','%s')\""
- ,
$_REQUEST['gDossier'],$_REQUEST['plugin_code'], $_REQUEST['ac'], $lp_id));
+ , $_REQUEST['gDossier'],
$_REQUEST['plugin_code'], $_REQUEST['ac'], $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':
+ $compute = new RAPAV_Formula_Compute($formula);
+ $compute->data->setp('formula', $form_compute);
+ if ($compute->verify() == 1)
+ {
+ $code = 'nok';
+ $html = $compute->errcode;
+ $lp_id = 0;
+ } else
+ {
+ $compute->save($_GET);
+ $compute->load();
+ $lp_id = $compute->data->getp('lp_id');
+ $code = 'ok';
+ ob_start();
+ echo td($compute->display_code());
+ echo td($compute->display_comment());
+ $r = $compute->display();
+ echo td($r);
+ echo td($compute->display_order());
+ $html.=ob_get_contents();
+ ob_end_clean();
+ $html.='<td>';
+ $html.=HtmlInput::anchor("Effacer", "",
sprintf("onclick=\"listing_detail_remove('%s','%s','%s','%s')\""
+ , $_REQUEST['gDossier'],
$_REQUEST['plugin_code'], $_REQUEST['ac'], $lp_id));
+ $html.='</td>';
+ }
+ break;
+ case 'new_account_id':
+ $compute = new RAPAV_Formula_Account($formula);
+ $compute->data->setp('tmp_val', $p_formula);
+ if ($compute->verify() == 1)
+ {
+ $code = 'nok';
+ $html = $compute->errcode;
+ $lp_id = 0;
+ } else
+ {
+ $compute->save($_GET);
+ $compute->load();
+ $lp_id = $compute->data->getp('lp_id');
+ $code = 'ok';
+ ob_start();
+ echo td($compute->display_code());
+ echo td($compute->display_comment());
+ $r = $compute->display();
+ echo td($r);
+ echo td($compute->display_order());
+ $html.=ob_get_contents();
+ ob_end_clean();
+ $html.='<td>';
+ $html.=HtmlInput::anchor("Effacer", "",
sprintf("onclick=\"listing_detail_remove('%s','%s','%s','%s')\""
+ , $_REQUEST['gDossier'],
$_REQUEST['plugin_code'], $_REQUEST['ac'], $lp_id));
+ $html.='</td>';
+ }
+ break;
case 'new_attribute_id':
ob_start();
$attr = new RAPAV_Formula_Attribute($formula, $listing_id);
@@ -122,9 +121,8 @@
echo td($attr->display());
$html.=ob_get_contents();
ob_end_clean();
- $html.='<td id="del_' . $lp_id . '">';
- $html.=HtmlInput::anchor("Effacer", "",
sprintf("onclick=\"listing_detail_remove('%s','%s','%s','%s')\"",
- $_REQUEST['gDossier'],
$_REQUEST['plugin_code'], $_REQUEST['ac'], $lp_id));
+ $html.='<td>';
+ $html.=HtmlInput::anchor("Effacer", "",
sprintf("onclick=\"listing_detail_remove('%s','%s','%s','%s')\"",
$_REQUEST['gDossier'], $_REQUEST['plugin_code'], $_REQUEST['ac'], $lp_id));
$html.='</td>';
break;
}
Modified: trunk/rapport_avance/include/class_rapav_listing_formula.php
===================================================================
--- trunk/rapport_avance/include/class_rapav_listing_formula.php
2013-11-25 19:22:47 UTC (rev 590)
+++ trunk/rapport_avance/include/class_rapav_listing_formula.php
2013-11-25 19:56:25 UTC (rev 591)
@@ -87,6 +87,12 @@
case 'FORM':
$ret = new Rapav_Formula_Formula($obj);
break;
+ case 'ACCOUNT':
+ $ret = new Rapav_Formula_Account($obj);
+ break;
+ case 'COMP':
+ $ret = new Rapav_Formula_Compute($obj);
+ break;
default:
throw new Exception('Object ' .var_export( $obj,true) . '
invalide ');
@@ -114,6 +120,10 @@
{
$this->data->load();
}
+ function set_listing($p_id)
+ {
+ $this->data->setp('listing_id',$p_id);
+ }
}
@@ -185,7 +195,7 @@
fd_id=' . $this->cat . ' order by 2');
$select->selected = $this->data->getp('attribut_card');
- return $select->input();
+ return "Attribut à afficher pour chaque fiche ".$select->input();
}
function save($p_array)
@@ -228,7 +238,7 @@
*/
var $sig;
- function __construct(RAPAV_Listing_Param_SQL $obj)
+ function __construct(RAPAV_Listing_Param_SQL $obj,$p_cat_id = 0)
{
global $cn;
$this->data = $obj;
@@ -309,3 +319,216 @@
}
}
+///////////////////////////////////////////////////////////////////////////////
+// RAPAV_Formula_Compute
+///////////////////////////////////////////////////////////////////////////////
+/**
+ * @brief Class for the listing detail compute,
+ * Formula compute the already computed code
+ * this class
+ * use RAPAV_Listing_Param_SQL the specific columns are
+ * - fp_formula
+ *
+ */
+class RAPAV_Formula_Compute 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 = 'COMP';
+ }
+
+ function display()
+ {
+ $str = sprintf("Formule avec les codes du formulaire %s ",
$this->data->fp_formula);
+ return $str;
+ }
+
+ function compute($p_start, $p_end)
+ {
+ return 0;
+ }
+
+ function input()
+ {
+ global $cn;
+ $f_id=$this->data->getp('listing_id');
+ $account = new IText("form_compute");
+ $account->size = 50;
+ echo $account->input();
+ echo HtmlInput::button('listing_search_code_bt', 'Cherche codes',
sprintf(" onclick=\"listing_search_code('%s','%s','%s','%s')\"",
$_REQUEST['ac'], $_REQUEST['plugin_code'], $_REQUEST['gDossier'], $f_id));
+ }
+
+ 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, ad_id + common */
+ $a_toclean=explode (',','operation_pcm_val,with_tmp_val,'
+ . 'tmp_val,date_paid,jrn_def_id,type_sum_account,type_detail,'
+ . 'tt_id,jrn_def_type,fp_signed,tva_id,lp_with_card,'
+ . 'lp_card_saldo,ad_id');
+
+ parent::set_to_null($a_toclean);
+ $this->data->setp('formula', $p_array['form_compute']);
+ $this->data->setp('formula_type', 'COMP');
+ $this->data->save();
+ }
+
+ /**
+ * @brief check if the formula is valid, return 1 for an error
+ * and set errode to the error
+ */
+ function verify()
+ {
+ if (trim($this->data->fp_formula) == "")
+ {
+ $this->errcode = " Aucune formule trouvée";
+ return 1;
+ }
+
+ // copy $this->form->fp_formula to a variable
+ $formula = $this->data->fp_formula;
+
+ // remove the valid
+ preg_match_all("/\[([A-Z]*[0-9]*)*([0-9]*[A-Z]*)\]/i", $formula, $e);
+ $formula = preg_replace("/\[([A-Z]*[0-9]*)*([0-9]*[A-Z]*)\]/i", '',
$formula);
+ $formula = preg_replace('/([0-9]+.{0,1}[0.9]*)*(\+|-|\*|\/)*/', '',
$formula);
+ $formula = preg_replace('/(\(|\))/', '', $formula);
+ $formula = preg_replace('/\s/', '', $formula);
+
+ // if something remains it should be a mistake
+ if ($formula != '')
+ {
+ $this->errcode = " Erreur dans la formule " . $formula;
+ return 1;
+ }
+ return 0;
+ }
+
+}
+///////////////////////////////////////////////////////////////////////////////
+// RAPAV_Formula_Saldo
+///////////////////////////////////////////////////////////////////////////////
+/**
+ * @brief Class for the listing detail account,
+ * Compute the saldo of account used with a given accounting, the type of
+ * saldo can be
+ * - C
+ * - D
+ * - D - C
+ * You can also choose to get the account saldo of the card or of the given
+ * accounting
+ *
+ * this class use RAPAV_Listing_Param_SQL the specific columns are
+ * - fp_formula
+ * - jrn_def_id
+ * - date_paid
+ * - tt
+ *
+ */
+class RAPAV_Formula_Account 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 = 'ACCOUNT';
+ }
+
+ 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()
+ {
+ global $cn;
+ $account = new IPoste("p_formula", "", "formula_acc_input_id");
+ $account->label = _("Recherche poste");
+ $account->set_attribute('gDossier', dossier::id());
+ $account->set_attribute('account', "formula_acc_input_id");
+ echo "Poste comptable utilisée avec chaque fiche ".$account->input();
+ $sel_total_type_row=new ISelect ('tt_id');
+ $sel_total_type_row->value=$cn->make_array('select tt_id,tt_label from
'
+ . ' rapport_advanced.total_type_account order by 2');
+
+ echo '<p>';
+ echo "type de total : ".$sel_total_type_row->input();
+ echo '</p>';
+
+ $ck=new ICheckBox('card_saldo');
+ echo '<p>';
+ echo 'Prendre le total de la fiche '.$ck->input();
+ echo '</p>';
+ 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', 'ACCOUNT');
+ $this->data->save();
+ }
+
+ /**
+ * @brief check if the formula is valid, return 1 for an error
+ * and set errode to the error
+ * @todo verifier que le poste comptable existe
+ */
+ function verify()
+ {
+ return 0;
+ }
+
+}
Modified: trunk/rapport_avance/include/class_rapav_listing_param.php
===================================================================
--- trunk/rapport_avance/include/class_rapav_listing_param.php 2013-11-25
19:22:47 UTC (rev 590)
+++ trunk/rapport_avance/include/class_rapav_listing_param.php 2013-11-25
19:56:25 UTC (rev 591)
@@ -80,7 +80,10 @@
$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);
+ $formula=new RAPAV_Formula_Formula($this->Param);
+ $compute=new RAPAV_Formula_Compute($this->Param);
+ $account=new RAPAV_Formula_Account($this->Param);
+ $account->set_listing($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-25 19:22:47 UTC (rev 590)
+++ trunk/rapport_avance/include/template/listing_param_input.php
2013-11-25 19:56:25 UTC (rev 591)
@@ -66,7 +66,7 @@
<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"
+ Entrez une formule avec des postes comptables, la syntaxe
est la même que celle des "rapports"
</p>
<p>
Exemple : [70%]*0.25+[71%]
@@ -86,14 +86,14 @@
</div>
<div id="new_compute_id" style="display:none">
<p>
- Entrer une formule avec des codes utilisés dans ce
formulaires
+ Entrez une formule avec des codes utilisés dans ce
formulaire
</p>
<form id="new_padec" method="POST"
onsubmit="save_param_listing('new_padec');
return false">
<?php echo
HtmlInput::request_to_hidden(array('gDossier', 'ac', 'plugin_code', 'p_id')) ?>
<?php echo HtmlInput::hidden('tab', 'compute_id') ?>
- <?php echo "compute" ?>
+ <?php echo $compute->input() ?>
<p>
<?php echo HtmlInput::submit('save', 'Sauve') ?>
</p>
@@ -107,8 +107,7 @@
<?php echo HtmlInput::request_to_hidden(array('gDossier',
'ac', 'plugin_code', 'p_id')) ?>
<?php echo HtmlInput::hidden('tab', 'new_account_id') ?>
- <?php echo "account" ?>
-
+ <?php echo $account->input() ?>
<p>
<?php echo HtmlInput::submit('save', 'Sauve') ?>
</p>
Modified: trunk/rapport_avance/rapav_javascript.js
===================================================================
--- trunk/rapport_avance/rapav_javascript.js 2013-11-25 19:22:47 UTC (rev
590)
+++ trunk/rapport_avance/rapav_javascript.js 2013-11-25 19:56:25 UTC (rev
591)
@@ -810,4 +810,42 @@
{
alert(e.message);
}
-}
\ No newline at end of file
+}
+
+/**
+ address@hidden display a popup and let you select an existing code
+ */
+function listing_search_code(ac, plugin_code, dossier, f_id)
+{
+ try
+ {
+ var querystring = 'plugin_code=' + plugin_code + '&ac=' + ac +
'&gDossier=' + dossier + '&act=listing_search_code' + "&f_id=" + f_id;
+ waiting_box();
+ var action = new Ajax.Request(
+ "ajax.php",
+ {
+ method: 'get',
+ parameters: querystring,
+ onFailure: error_get_predef,
+ onSuccess: function(req) {
+ remove_waiting_box();
+ removeDiv('search_code_div');
+ var nTop = calcy(80);
+ var nLeft = "400px";
+ var str_style = "top:" + nTop + "px;left:" + nLeft +
";width:50em;height:auto;z-index:4";
+ add_div({
+ id: 'search_code_div',
+ style: str_style,
+ cssclass: 'inner_box',
+ drag: 1
+ });
+ $('search_code_div').innerHTML = req.responseText;
+ }
+ }
+ );
+
+ } catch (e)
+ {
+ alert("listing_search_code" + e.message);
+ }
+}
---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpcompta-dev] r591 - in trunk/rapport_avance: . include include/template,
phpcompta-dev <=