[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 01/27: Ajout des clef de répartition pour la
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 01/27: Ajout des clef de répartition pour la comptabilité analytique |
Date: |
Thu, 02 Oct 2014 14:23:06 +0000 |
sparkyx pushed a commit to branch master
in repository noalyss.
commit f1c1f9b196f45025f18fdb7d3a85f12d1e47c3da
Author: Dany De Bontridder <address@hidden>
Date: Sat Sep 13 16:57:02 2014 +0200
Ajout des clef de répartition pour la comptabilité analytique
---
html/ajax_misc.php | 13 ++
html/js/anc_script.js | 81 +++++++-
html/js/infobulle.js | 1 +
include/ajax_anc_key_choice.php | 53 +++++
include/ajax_anc_key_compute.php | 61 ++++++
include/anc_key.inc.php | 64 ++++++
include/class_anc_key.php | 296 +++++++++++++++++++++++++++
include/class_anc_key_sql.php | 155 ++++++++++++++
include/template/anc_key_display_choice.php | 47 +++++
include/template/anc_key_display_list.php | 54 +++++
include/template/anc_key_input.php | 165 +++++++++++++++
11 files changed, 982 insertions(+), 8 deletions(-)
diff --git a/html/ajax_misc.php b/html/ajax_misc.php
index 2ff7135..57119fb 100644
--- a/html/ajax_misc.php
+++ b/html/ajax_misc.php
@@ -632,6 +632,19 @@ EOF;
}
exit();
break;
+
+ case 'anc_key_choice':
+ /*
+ * Show the available distribution keys for analytic
+ */
+ require_once 'ajax_anc_key_choice.php';
+ break;
+ case 'anc_key_compute':
+ /*
+ * Show the activities computed with the selected distribution key
+ */
+ require_once 'ajax_anc_key_compute.php';
+ break;
default:
var_dump($_GET);
}
diff --git a/html/js/anc_script.js b/html/js/anc_script.js
index 3186a79..87433f1 100644
--- a/html/js/anc_script.js
+++ b/html/js/anc_script.js
@@ -375,32 +375,51 @@ function filter_anc(obj, queryString)
return queryString;
}
/**
- * @brief use a distribution key
+ * @brief compute and display Analytic activity, related to the choosen
distribution key
* @param p_dossier is the dossier id
* @param p_table is table id to replace
* @param p_amount is the amount to distribute
+ * @param p_key_id is the choosen key
*
*/
-function anc_key_compute(p_dossier, p_table, p_amount)
+function anc_key_compute(p_dossier, p_table, p_amount, p_key_id)
{
waiting_box();
var op = "op=anc_key_compute";
- var queryString = op + "&gDossier=" + p_dossier + "&t=" + p_table +
"&amount=" + p_amount;
+ var queryString = op + "&gDossier=" + p_dossier + "&t=" + p_table +
"&amount=" + p_amount + '&key=' + p_key_id;
try {
var action = new Ajax.Request(
"ajax_misc.php",
{
method: 'get',
parameters: queryString,
- onFailure: error_box('Ajax failure'),
- onSuccess: function(req) {
+ onFailure: error_box,
+ onSuccess: function(req, json) {
+ try
+ {
+ var name_ctl = p_table;
+ var answer = req.responseXML;
+ remove_waiting_box();
+ var html = answer.getElementsByTagName('code');
+ if (html.length == 0) {
+ var rec = req.responseText;
+ alert('erreur :' + rec);
+ }
+ var code_html = getNodeText(html[0]); // Firefox
ne prend que les 4096 car.
+ code_html = unescape_xml(code_html);
+ console.log(code_html);
+ $(name_ctl).innerHTML = code_html;
+ } catch (e)
+ {
+ error_message(e.message);
+ }
}
}
);
} catch (e) {
- error_box(e.message);
+ error_message(e.message);
}
}
/**
@@ -408,11 +427,57 @@ function anc_key_compute(p_dossier, p_table, p_amount)
* in ajax, a window let you choose what key you want to use
*
* @param p_dossier is the dossier
- * @param p_key_id is the choosen key
* @param p_table the table id of the target
* @param p_amount amount to distribute
+ * @param p_ledger
*/
-function anc_key_choice(p_dossier, p_key_id, p_table, p_amount)
+function anc_key_choice(p_dossier, p_table, p_amount)
{
+ waiting_box();
+ var op = 'op=anc_key_choice';
+ var queryString = op + "&gDossier=" + p_dossier + "&t=" + p_table +
"&amount=" + p_amount;
+ try {
+ var ledger=$('p_jrn');
+ if (ledger == null ) {
+ error_message('error : ledger is null ');
+ return;
+ }
+
+ queryString+='&led='+ledger.value;
+ var action = new Ajax.Request(
+ "ajax_misc.php",
+ {
+ method: 'get',
+ parameters: queryString,
+ onFailure: error_box,
+ onSuccess: function(req, json) {
+ try
+ {
+ var name_ctl = 'div_anc_key_choice';
+ var answer = req.responseXML;
+ remove_waiting_box();
+ var html = answer.getElementsByTagName('code');
+ if (html.length == 0) {
+ var rec = req.responseText;
+ alert('erreur :' + rec);
+ }
+
+ console.log('Received ajax_call');
+ var code_html = getNodeText(html[0]); // Firefox
ne prend que les 4096 car.
+ code_html = unescape_xml(code_html);
+ console.log(code_html);
+ add_div({id: name_ctl, cssclass: 'inner_box',
style: 'top:30%;right:35%;position:absolute', drag: 1});
+ $(name_ctl).innerHTML = code_html;
+ } catch (e)
+ {
+ error_message(e.message);
+ }
+ }
+ }
+
+ );
+ } catch (e) {
+ error_message(e.message);
+ }
}
\ No newline at end of file
diff --git a/html/js/infobulle.js b/html/js/infobulle.js
index 77bd8bb..de8ac18 100644
--- a/html/js/infobulle.js
+++ b/html/js/infobulle.js
@@ -68,6 +68,7 @@ content[37]='Les dates sont en format DD.MM.YYYY';
content[38]='La numérotation est propre à chaque journal. Laissez à 0 pour ne
pas changer le numéro';
content[39]='Le préfixe des pièces doit être différent pour chaque journal, on
peut aussi utiliser l\'année';
content[40]='Laissez à 0 pour ne pas changer le numéro';
+content[41]='Mettez le pourcentage à zéro pour effacer la ligne';
function showBulle(p_ctl){
d=document.getElementById('bulle');
diff --git a/include/ajax_anc_key_choice.php b/include/ajax_anc_key_choice.php
new file mode 100644
index 0000000..d2d38ee
--- /dev/null
+++ b/include/ajax_anc_key_choice.php
@@ -0,0 +1,53 @@
+<?php
+/*
+ * This file is part of NOALYSS.
+ *
+ * NOALYSS 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.
+ *
+ * NOALYSS 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 NOALYSS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+/**
+ * @file
+ * @brief show the available distribution keys for analytic activities.
Expected
+ * parameter are
+ * - t for the table id
+ * - amount is the amount to distributed
+ *
+ */
+// Copyright (2014) Author Dany De Bontridder address@hidden
+if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
+$amount=HtmlInput::default_value_get("amount", 0);
+$table_id=HtmlInput::default_value_get("t", "");
+$ledger=HtmlInput::default_value_get('led',0);
+
+if ($table_id == "" || isNumber($amount) == 0 || isNumber($ledger) == 0) die
('Invalid Parameter');
+
+require_once 'class_anc_key.php';
+
+ob_start();
+echo HtmlInput::title_box(_("Choix d'une clef"), 'div_anc_key_choice');
+
+Anc_Key::display_choice($amount,$table_id,$ledger);
+
+echo HtmlInput::button_close('div_anc_key_choice');
+$response = ob_get_clean();
+$html = escape_xml($response);
+header('Content-type: text/xml; charset=UTF-8');
+echo <<<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<data>
+<ctl></ctl>
+<code>$html</code>
+</data>
+EOF;
+?>
\ No newline at end of file
diff --git a/include/ajax_anc_key_compute.php b/include/ajax_anc_key_compute.php
new file mode 100644
index 0000000..8d375fe
--- /dev/null
+++ b/include/ajax_anc_key_compute.php
@@ -0,0 +1,61 @@
+<?php
+/*
+ * This file is part of NOALYSS.
+ *
+ * NOALYSS 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.
+ *
+ * NOALYSS 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 NOALYSS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+// Copyright 2014 Author Dany De Bontridder address@hidden
+// @brief Compute the amount. This file compute the amount and distribute it
+// following the given distribution key given in parameter.
+// Parameters are :
+// - gDossier
+// - t the element HTML to use as target
+// - amount the amount to distribute
+// - key the Distribution key to use
+//
+if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
+
+require_once 'class_anc_key.php';
+ob_start();
+/////
+$key=HtmlInput::default_value_get('key',0);
+$amount=HtmlInput::default_value_get('amount',0);
+$target=HtmlInput::default_value_get('t','');
+
+if ( isNumber($key)== 0
+ || isNumber($amount) ==0
+ || $target==''
+ )
+{
+ die ('Invalid parameter');
+}
+
+$compute_key=new Anc_Key($key);
+
+$compute_key->fill_table($target,$amount);
+
+////
+$response = ob_get_clean();
+$html = escape_xml($response);
+header('Content-type: text/xml; charset=UTF-8');
+echo <<<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<data>
+<ctl></ctl>
+<code>$html</code>
+</data>
+EOF;
+?>
\ No newline at end of file
diff --git a/include/anc_key.inc.php b/include/anc_key.inc.php
new file mode 100644
index 0000000..0365fae
--- /dev/null
+++ b/include/anc_key.inc.php
@@ -0,0 +1,64 @@
+<?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
+ */
+// Copyright 2014 Author Dany De Bontridder address@hidden
+
+/**
+ * @file
+ * @brief manage distribution keys for Analytic accountancy, this file is
called by
+ * do.php
+ * @see do.php
+ *
+ */
+var_dump($_POST);
+if (!defined('ALLOWED'))
+ die('Appel direct ne sont pas permis');
+global $cn, $g_user;
+require_once 'class_anc_key.php';
+$op=HtmlInput::default_value_request("op", "list");
+
+switch ($op)
+{
+ case 'list':
+ Anc_Key::display_list();
+ break;
+ case 'consult':
+ $id=HtmlInput::default_value_request("key", "-1");
+ if (isNumber($id)==0||$id==-1)
+ {
+ die(_('Clef invalide'));
+ }
+ $key=new Anc_Key($id);
+ if (isset($_POST['save_key']))
+ {
+ try
+ {
+ $key->save($_POST);
+ Anc_Key::display_list();
+ break;
+ }
+ catch (Exception $e)
+ {
+ echo span($e->getMessage(),' class="notice"');
+ }
+ }
+ $key->input();
+ break;
+}
+?>
diff --git a/include/class_anc_key.php b/include/class_anc_key.php
new file mode 100644
index 0000000..0cdfecf
--- /dev/null
+++ b/include/class_anc_key.php
@@ -0,0 +1,296 @@
+<?php
+
+/*
+ * This file is part of NOALYSS.
+ *
+ * NOALYSS 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.
+ *
+ * NOALYSS 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 NOALYSS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+// Copyright (2014) Author Dany De Bontridder address@hidden
+
+/**
+ * @file
+ * @brief Class to manage distribution keys for Analytic accountancy
+ *
+ */
+require_once 'class_anc_key_sql.php';
+
+class Anc_Key
+{
+
+ private $key; /* ! the distribution key */
+ private $a_ledger; /* ! array of ledger where the key is available */
+ private $a_activity; /* ! array of activities of this key */
+ private $a_row; /* ! array of row */
+
+ function __construct($p_id=-1)
+ {
+ global $cn;
+ $this->key=new Anc_Key_SQL($cn, $p_id);
+ $this->a_ledger=null;
+ $this->a_activity=null;
+ $this->a_row=null;
+ }
+
+ /**
+ * @brief display list of available keys
+ * @param $p_amount amount to distribute
+ * @param $p_target target to update
+ * @param $p_ledger is the jrn_def_id
+ */
+ static function display_choice($p_amount, $p_target,$p_ledger)
+ {
+ global $cn;
+ $a_key=$cn->get_array(' select kd_id,
+ kd_name,
+ kd_description
+ from
+ key_distribution
+ join key_distribution_ledger using (kd_id)
+ where
+ jrn_def_id=$1',
+ array(
+ $p_ledger
+ ));
+ if (empty($a_key))
+ {
+ echo _('Aucune clef disponible');
+ }
+ include 'template/anc_key_display_choice.php';
+ }
+
+ /**
+ * @brief display a list of keys, choose one to modify it
+ *
+ */
+ static function display_list()
+ {
+ global $cn;
+ $keysql=new Anc_Key_SQL($cn);
+ $rkey=$keysql->seek(' order by kd_name');
+ $a_key=$cn->fetch_all($rkey);
+ if (empty($a_key))
+ {
+ echo _('Aucune clef disponible');
+ }
+ include 'template/anc_key_display_list.php';
+ }
+
+ /**
+ * @brief Show the detail for a key distribution and let you change it
+ * for adding or update
+ */
+ function input()
+ {
+ global $cn;
+
+ $plan=$cn->get_array('
+ select
+ pa_id,
+ pa_name ,
+ pa_description
+ from
+ plan_analytique
+ order by pa_name');
+ $count_max=count($plan);
+
+ $a_row=$cn->get_array('select ke_id,ke_row,ke_percent from
key_distribution_detail
+ where
+ kd_id=$1 order by ke_row', array($this->key->getp('id')));
+
+ require_once 'template/anc_key_input.php';
+ }
+
+ /**
+ * @brief verify that data are ok
+ * @param type $p_array
+ */
+ function verify($p_array)
+ {
+ $a_percent=$p_array['percent'];
+ if (count($a_percent)==0)
+ {
+ throw Exception(_('Aucune répartition'));
+ }
+ $tot_percent=0;
+ bcscale(4);
+ for ($i=0; $i<count($a_percent); $i++)
+ {
+ $tot_percent=bcadd($tot_percent, $a_percent[$i]);
+ }
+ if ($tot_percent<>100)
+ {
+ throw new Exception(_('Le total ne vaut pas 100, total calculé =
').$tot_percent);
+ }
+ }
+
+ /**
+ * @brief save the data of a repartition key.
+ * @param received an array
+ * index :
+ * - key_id : key_distribution.kd_id
+ * - row : array of key_distribution.ke_id (row
+ * - pa : array of plan_analytic.pa_id (column)
+ * - po_id : double array,
+ * first index is the row
+ * second index is the first plan, the second the second
plan...(column)
+ * - percent array, one per row
+ * - jrn : array of available ledgers
+ * @note if po_id == -1 then it is replaced by null, this why the pa_id
is needed : to identify
+ * the column
+ * @verbatim
+
+ 'key_id' => string '1' (length=1)
+ 'row' =>
+ array
+ 0 => string '1' (length=1)
+ 1 => string '2' (length=1)
+ 2 => string '3' (length=1)
+ 'pa' =>
+ array
+ 0 => string '1' (length=1)
+ 1 => string '2' (length=1)
+ 'po_id' =>
+ array
+ 0 =>
+ array
+ 0 => string '1' (length=1)
+ 1 => string '8' (length=1)
+ 1 =>
+ array
+ 0 => string '2' (length=1)
+ 1 => string '-1' (length=2)
+ 2 =>
+ array
+ 0 => string '3' (length=1)
+ 1 => string '8' (length=1)
+ 'percent' =>
+ array
+ 0 => string '50.0000' (length=7)
+ 1 => string '20.0000' (length=7)
+ 2 => string '30.0000' (length=7)
+ 'jrn' =>
+ array
+ 0 => string '3' (length=1)
+ 1 => string '2' (length=1)
+ @endverbatim
+ *
+ */
+ function save($p_array)
+ {
+ global $cn;
+ $this->verify($p_array);
+ $cn->start();
+ // for each row
+ $a_row=$p_array['row'];
+ $a_ledger=$p_array['jrn'];
+ $a_percent=$p_array['percent'];
+ $a_po_id=$p_array['po_id'];
+ $a_plan=$p_array['pa'];
+ try
+ {
+ for ($i=0; $i<count($a_row); $i++)
+ {
+ //save key_distribution_row
+ $key_row=new Anc_Key_Detail_SQL($cn);
+ $key_row->setp('id', $a_row[$i]);
+ $key_row->setp('key', $this->key->getp('id'));
+ $key_row->setp('row', $i+1);
+ $key_row->setp('percent', $a_percent[$i]);
+ $key_row->save();
+ //
+ // Save each activity + percent
+ $cn->exec_sql('delete from key_distribution_activity where
ke_id=$1', array($key_row->getp('id')));
+
+ // Don't save row with 0 %
+ if ($a_percent[$i]==0)
+ {
+ $key_row->delete();
+ continue;
+ }
+ for ($j=0; $j<count($a_po_id[$i]); $j++)
+ {
+ $activity=new Anc_Key_Activity_SQL($cn);
+ $activity->setp('detail', $key_row->getp('id'));
+ $value=($a_po_id[$i][$j]==-1)?null:$a_po_id[$i][$j];
+ $activity->setp('activity', $value);
+ $activity->setp('plan',$a_plan[$j]);
+ $activity->save();
+ }
+ }
+ // delete all from key_distribution_ledger
+ $cn->exec_sql('delete from key_distribution_ledger where
kd_id=$1', array($this->key->getp('id')));
+ for ($k=0; $k<count($a_ledger); $k++)
+ {
+ $ledger=new Anc_Key_Ledger_SQL($cn);
+ $ledger->kd_id=$this->key->getp('id');
+ $ledger->jrn_def_id=$a_ledger[$k];
+ $ledger->save();
+ }
+ }
+ catch (Exception $e)
+ {
+ echo $e->getTraceAsString();
+ }
+ $cn->commit();
+ }
+ function fill_table($p_target,$p_amount)
+ {
+ global $cn;
+ $number=str_replace('t', '', $p_target);
+
+ $op[$number]=$p_amount;
+ $array['op']=$op;
+ $a_plan=$cn->get_array('select pa_id from plan_analytique order by
pa_id');
+ for ($i=0;$i < count($a_plan);$i++)
+ {
+ $array['pa_id'][$i]=$a_plan[$i]['pa_id'];
+ }
+
+ $a_poste=$cn->get_array('select po_id,ke_percent,pa_id,ke_row
+ from key_distribution_activity
+ join key_distribution_detail using (ke_id)
+ where
+ kd_id=$1
+ order by ke_row,pa_id',
+ array($this->key->getp('id')));
+
+ for ($i=0;$i< count($a_poste);$i++)
+ {
+
$hplan[$number][$i]=($a_poste[$i]['po_id']==null)?-1:$a_poste[$i]['po_id'];
+ }
+ $array['hplan']=$hplan;
+
+ $a_amount=$cn->get_array("select distinct ke_row,ke_percent
+ from key_distribution_activity
+ join key_distribution_detail using (ke_id)
+ where
+ kd_id=$1
+ and pa_id=$2
+ order by ke_row",
+ array($this->key->getp('id'),$a_plan[0]['pa_id']));
+ bcscale(2);
+ for ($i=0;$i< count($a_amount);$i++)
+ {
+ $val[$number][$i]=bcmul($p_amount,$a_amount[$i]['ke_percent'])/100;
+ }
+ $array['val']=$val;
+
+ $anc_operation=new Anc_Operation($cn);
+ echo $anc_operation->display_form_plan($array, 1, 1, $number,
$p_amount);
+
+ }
+
+}
diff --git a/include/class_anc_key_sql.php b/include/class_anc_key_sql.php
new file mode 100644
index 0000000..ffb6577
--- /dev/null
+++ b/include/class_anc_key_sql.php
@@ -0,0 +1,155 @@
+<?php
+
+/*
+ * Copyright (C) 2014 Dany De Bontridder <address@hidden>
+ *
+ * This program 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.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * @file
+ * @brief Class to manage distribution keys for SQL.
+ *
+ */
+require_once 'class_noalyss_sql.php';
+
+
+/**
+ * @brief Manage the table key_distribution.
+ */
+class Anc_Key_SQL extends Noalyss_SQL
+{
+
+ function __construct($cn, $p_id = -1)
+ {
+ $this->table = "public.key_distribution";
+ $this->primary_key = "kd_id";
+
+ $this->name = array(
+ "id" => "kd_id",
+ "name"=>"kd_name",
+ "description"=>"kd_description"
+ );
+
+ $this->type = array(
+ "kd_id" => "numeric",
+ "kd_name" => "text",
+ "kd_description" => "text"
+ );
+
+ $this->default = array(
+ "kd_id" => "auto"
+ );
+ global $cn;
+
+ parent::__construct($cn, $p_id);
+ }
+
+}
+/**
+ * @brief manage table key_distribution_ledger
+ */
+class Anc_Key_Ledger_SQL extends Noalyss_SQL
+{
+ function __construct($cn, $p_id = -1)
+ {
+ $this->table = "public.key_distribution_ledger";
+ $this->primary_key = "kl_id";
+
+ $this->name = array(
+ "id" => "kl_id",
+ "key"=>"kd_id",
+ "ledger"=>"jrn_def_id"
+ );
+
+ $this->type = array(
+ "kl_id" => "numeric",
+ "kd_id" => "numeric",
+ "jrn_def_id" => "numeric"
+ );
+
+ $this->default = array(
+ "kl_id" => "auto"
+ );
+ global $cn;
+
+ parent::__construct($cn, $p_id);
+ }
+}
+/**
+ * @brief manage table key_distribution_detail
+ */
+class Anc_Key_Detail_SQL extends Noalyss_SQL
+{
+ function __construct($cn, $p_id = -1)
+ {
+ $this->table = "public.key_distribution_detail";
+ $this->primary_key = "ke_id";
+
+ $this->name = array(
+ "id" => "ke_id",
+ "key"=>"kd_id",
+ "row"=>"ke_row",
+ "percent"=>"ke_percent"
+ );
+
+ $this->type = array(
+ "ke_id" => "numeric",
+ "kd_id" => "numeric",
+ "ke_row" => "numeric",
+ "ke_percent" => "numeric"
+ );
+
+ $this->default = array(
+ "ke_id" => "auto"
+ );
+ global $cn;
+
+ parent::__construct($cn, $p_id);
+ }
+}
+/**
+ * @brief manage table key_distribution_activity
+ */
+class Anc_Key_Activity_SQL extends Noalyss_SQL
+{
+ function __construct($cn, $p_id = -1)
+ {
+ $this->table = "public.key_distribution_activity";
+ $this->primary_key = "ka_id";
+
+ $this->name = array(
+ "id" => "ka_id",
+ "detail"=>"ke_id",
+ "activity"=>"po_id",
+ "plan"=>"pa_id"
+ );
+
+ $this->type = array(
+ "ka_id" => "numeric",
+ "ke_id" => "numeric",
+ "po_id" => "numeric",
+ "pa_id" => "numeric"
+
+ );
+
+ $this->default = array(
+ "ka_id" => "auto"
+ );
+ global $cn;
+
+ parent::__construct($cn, $p_id);
+ }
+}
\ No newline at end of file
diff --git a/include/template/anc_key_display_choice.php
b/include/template/anc_key_display_choice.php
new file mode 100644
index 0000000..c361b66
--- /dev/null
+++ b/include/template/anc_key_display_choice.php
@@ -0,0 +1,47 @@
+<?php
+/* * *
+ Copyright (C) 2014 dany
+
+ This program 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.
+
+ This program 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 this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+/* * *
+ * @file
+ * @brief display a table with the list of available keys
+ * @see Anc_Key::display_choice
+ */
+
+
+?>
+<table class="result">
+ <?php for ($i = 0; $i < count($a_key); $i++):
+ $onclick=sprintf(' onclick="anc_key_compute(%s,\'%s\',%s,%s)"',
+ Dossier::id(),
+ $p_target,
+ $p_amount,
+ $a_key[$i]['kd_id']);
+ ?>
+ <tr>
+ <td>
+ <a class="line" <?php echo $onclick; ?> >
+ <?php echo h($a_key[$i]['kd_name']); ?>
+ </a>
+ </td>
+ <td>
+ <?php echo h($a_key[$i]['kd_description']) ?>
+ </td>
+
+ </tr>
+ <?php endfor; ?>
+</table>
\ No newline at end of file
diff --git a/include/template/anc_key_display_list.php
b/include/template/anc_key_display_list.php
new file mode 100644
index 0000000..a2dff19
--- /dev/null
+++ b/include/template/anc_key_display_list.php
@@ -0,0 +1,54 @@
+<?php
+/* * *
+ Copyright (C) 2014 dany
+
+ This program 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.
+
+ This program 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 this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+/* * *
+ * @file
+ * @brief display a table with the list of available keys for all ledgers
+ * @see Anc_Key::display_list
+ */
+
+
+?>
+<table class="result">
+ <?php for ($i = 0; $i < Database::num_row($rkey); $i++):
+ $onclick= http_build_query(array(
+ 'gDossier'=>Dossier::id(),
+ 'ac'=>$_REQUEST['ac'],
+ 'op'=>'consult',
+ 'key'=>$a_key[$i]['kd_id']
+ ));
+
+ /*sprintf(' onclick="anc_key_compute(%s,\'%s\',%s,%s)"',
+ Dossier::id(),
+ $p_target,
+ $p_amount,
+ $a_key[$i]['kd_id']);*/
+ ?>
+ <tr>
+ <td>
+ <a class="line" href="do.php?<?php echo $onclick; ?>" >
+ <?php echo $a_key[$i]['kd_name']; ?>
+ </a>
+ </td>
+ <td>
+ <?php echo $a_key[$i]['kd_description'] ?>
+ </td>
+
+ </tr>
+ <?php endfor; ?>
+</table>
\ No newline at end of file
diff --git a/include/template/anc_key_input.php
b/include/template/anc_key_input.php
new file mode 100644
index 0000000..caa6180
--- /dev/null
+++ b/include/template/anc_key_input.php
@@ -0,0 +1,165 @@
+<?php
+/*
+ Copyright (C) 2014 address@hidden
+
+ This program 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.
+
+ This program 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 this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+/*
+ * all the pa_id and analytic plan
+ */
+?>
+<form method="post">
+ <?php
+ echo HtmlInput::request_to_hidden(array('gDossier', 'ac'));
+ echo HtmlInput::hidden('key_id', $this->key->getp('id'));
+ ?>
+ <div class="content">
+ <div style="width:30%;display:inline-block;min-height: 75px">
+ <h1 class="legend">
+ <?php echo $this->key->getp('name'); ?>
+ </h1>
+ </div>
+ <div style="width: 65%;display:inline-block;min-height: 75px">
+ <p>
+ <?php echo $this->key->getp('description'); ?>
+ </p>
+
+ </div>
+ <h2>
+ <?php echo _('Répartition'); ?>
+ </h2>
+ <table class="result" style="margin-left:
8%;width:84%;margin-right:8%">
+ <tr>
+ <th><?php echo _('n°'); ?></th>
+ <?php
+ // Show all the possible analytic plan
+ for ($i=0; $i<count($plan); $i++):
+ ?>
+ <th>
+ <?php echo $plan[$i]['pa_name']; ?>
+ </th>
+ <?php
+ endfor;
+ ?>
+ <th>
+ <?php echo _('Pourcentage'); ?>
+ <?php echo HtmlInput::infobulle(41); ?>
+ </th>
+ </tr>
+ <?php
+ for ($j=0; $j<count($a_row); $j++):
+ ?>
+ <tr>
+ <td>
+ <?php echo $a_row[$j]['ke_row']; ?>
+ <?php echo HtmlInput::hidden('row[]',
$a_row[$j]['ke_id']); ?>
+ </td>
+ <?php
+ $percent=$a_row[$j]['ke_percent'];
+ // For each plan
+ for ($i=0; $i<count($plan); $i++):
+ if ( $j == 0 ) {
+ echo
HtmlInput::hidden('pa[]',$plan[$i]['pa_id']);
+ }
+ $a_poste=$cn->make_array("select po_id,po_name
from poste_analytique where pa_id=$1", 1, array($plan[$i]['pa_id']));
+ $select=new ISelect('po_id['.$j.'][]');
+ $select->value=$a_poste;
+ $value=$cn->get_array('select po_id,ke_percent
+ from key_distribution_activity as ka
+ join key_distribution_detail using (ke_id)
+ join key_distribution using (kd_id)
+ left join poste_analytique using(po_id)
+
+ where ke_id=$1 and ka.pa_id=$2 ',
array($a_row[$j]['ke_row'],$plan[$i]['pa_id']));
+ $selected=-1;
+ if (sizeof($value)==1)
+ {
+ $selected=$value[0]['po_id'];
+
+ }
+ if (isset($_POST['po_id']))
+ {
+
$a_po_id=HtmlInput::default_value_post('po_id', array());
+ $selected=$a_po_id[$j][$i];
+
$a_percent=HtmlInput::default_value_post('percent', array());
+ $percent=$a_percent[$j];
+ }
+ $select->selected=$selected;
+ ?>
+ <td>
+ <?php
+ echo $select->input();
+ ?>
+ </td>
+ <?php
+ endfor;
+ ?>
+ <td>
+ <?php
+ $inum_percent=new INum('percent[]');
+ $inum_percent->value=$percent;
+ echo $inum_percent->input();
+ ?>
+ </td>
+ </tr>
+ <?php
+ endfor;
+ ?>
+ <tr>
+
+ </tr>
+ </table>
+
+
+ <div>
+ <div>
+ <h2>
+ <?php echo _("Disponible dans les journaux "); ?>
+ </h2>
+ </div>
+ <div style="margin-left: 8%;width:84%;margin-right:8%">
+
+ <?php $jrn=$cn->get_array('select
kl_id,jrn_def_id,jrn_def_name,jrn_def_description from jrn_def
+ left join key_distribution_ledger
using (jrn_def_id)
+ where kd_id=$1 or kd_id is null
+ order by jrn_def_name ',
array($this->key->getp('id')));
+ ?>
+ <table id="jrn_def_tb" class="result">
+ <?php for ($i=0; $i<count($jrn); $i++): ?>
+ <tr>
+ <td>
+ <?php $checkbox=new ICheckBox("jrn[]"); ?>
+ <?php $checkbox->value=$jrn[$i]['jrn_def_id'];
?>
+ <?php
$checkbox->selected=($jrn[$i]['kl_id']=="")?false:true; ?>
+ <?php echo $checkbox->input(); ?>
+ </td>
+ <td>
+ <?php echo h($jrn[$i]['jrn_def_name']); ?>
+ </td>
+ <td>
+ <?php echo h($jrn[$i]['jrn_def_description']);
?>
+ </td>
+ </tr>
+ <?php endfor; ?>
+ </table>
+ </div>
+ </div>
+
+ <!-- end -->
+ </div>
+ <?php echo HtmlInput::submit('save_key', _('Sauver')); ?>
+</form>
\ No newline at end of file
- [Noalyss-commit] [noalyss] 11/27: Distribution key ; bouton ajout ligne Task #1021 - Comptabilité analytique : clef de répartition : bouton ajout, (continued)
- [Noalyss-commit] [noalyss] 11/27: Distribution key ; bouton ajout ligne Task #1021 - Comptabilité analytique : clef de répartition : bouton ajout, Dany De Bontridder, 2014/10/02
- [Noalyss-commit] [noalyss] 02/27: Ajout des clef de répartition pour la comptabilité analytique, Dany De Bontridder, 2014/10/02
- [Noalyss-commit] [noalyss] 09/27: Distribution key : add button new, Dany De Bontridder, 2014/10/02
- [Noalyss-commit] [noalyss] 17/27: remove debug info, Dany De Bontridder, 2014/10/02
- [Noalyss-commit] [noalyss] 03/27: Database::make_array ajoute un paramètre dans le cas où le SQL admet une condition, Dany De Bontridder, 2014/10/02
- [Noalyss-commit] [noalyss] 16/27: Add p_jrn is the bottom of the popup, to allow the use of distribution key, Dany De Bontridder, 2014/10/02
- [Noalyss-commit] [noalyss] 21/27: Ajout fonction pour calculer pourcentage répartition clef, Dany De Bontridder, 2014/10/02
- [Noalyss-commit] [noalyss] 20/27: Cosmetique : alignement colonne pourcent, Dany De Bontridder, 2014/10/02
- [Noalyss-commit] [noalyss] 14/27: remove debug info, Dany De Bontridder, 2014/10/02
- [Noalyss-commit] [noalyss] 13/27: Add documentation add_row_key, remove secund parameter, Dany De Bontridder, 2014/10/02
- [Noalyss-commit] [noalyss] 01/27: Ajout des clef de répartition pour la comptabilité analytique,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 24/27: Task #0001030: PRINTBAL : mettre le numéro de compte en première colonne Task #1030 - PRINTBAL : mettre le numéro de compte en première colonne, Dany De Bontridder, 2014/10/02
- [Noalyss-commit] [noalyss] 27/27: Task #1024 : add a message Task #1024 - Comptabiltié analytique : table activité lors confirmation, Dany De Bontridder, 2014/10/02
- [Noalyss-commit] [noalyss] 26/27: Task #1024 : add a message Task #1024 - Comptabiltié analytique : table activité lors confirmation, Dany De Bontridder, 2014/10/02
- [Noalyss-commit] [noalyss] 15/27: add script for table Distribution keys, Dany De Bontridder, 2014/10/02
- [Noalyss-commit] [noalyss] 19/27: fix several bugs : when adding new keys or new rows in a key Task #1021 - Comptabilité analytique : clef de répartition : bouton ajout, Dany De Bontridder, 2014/10/02
- [Noalyss-commit] [noalyss] 25/27: Task #1029: PRINTBAL : année précédente dans une autre couleur Task #1029 - PRINTBAL : année précédente dans une autre couleur, Dany De Bontridder, 2014/10/02
- [Noalyss-commit] [noalyss] 18/27: Allow to display table without button, Dany De Bontridder, 2014/10/02
- [Noalyss-commit] [noalyss] 22/27: Ajout fonction pour calculer pourcentage répartition clef, Dany De Bontridder, 2014/10/02
- [Noalyss-commit] [noalyss] 23/27: New Version of prototype.js, Dany De Bontridder, 2014/10/02