[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 19/27: fix several bugs : when adding new ke
From: |
Dany De Bontridder |
Subject: |
[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 |
Date: |
Thu, 02 Oct 2014 14:23:15 +0000 |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 4b1d252fddfba5731d842f2b3857384b09631764
Author: Dany De Bontridder <address@hidden>
Date: Wed Sep 17 22:07:31 2014 +0200
fix several bugs : when adding new keys or new rows in a key
Task #1021 - Comptabilité analytique : clef de répartition : bouton ajout
---
html/js/anc_script.js | 14 ++++++++----
include/anc_key.inc.php | 7 +++++-
include/class_anc_key.php | 32 +++++++++++++++++++---------
include/template/anc_key_display_list.php | 19 ++++++++++++----
include/template/anc_key_input.php | 11 ++++++++-
5 files changed, 60 insertions(+), 23 deletions(-)
diff --git a/html/js/anc_script.js b/html/js/anc_script.js
index 1d65ca6..d75d48e 100644
--- a/html/js/anc_script.js
+++ b/html/js/anc_script.js
@@ -410,6 +410,7 @@ function anc_key_compute(p_dossier, p_table, p_amount,
p_key_id)
code_html = unescape_xml(code_html);
console.log(code_html);
$(name_ctl).innerHTML = code_html;
+ removeDiv('div_anc_key_choice');
} catch (e)
{
error_message(e.message);
@@ -493,28 +494,31 @@ function add_row_key(p_table)
{
return;
}
- if (mytable.rows.length > 15)
+ var table_length=mytable.rows.length ;
+ if ( table_length > 15)
{
alert("Maximum 15 lignes ");
return;
}
var rowToCopy = mytable.rows[1];
- var row = mytable.insertRow(mytable.rows.length);
-
+ var row = mytable.insertRow(table_length);
+ var nb=mytable.rows.length -2;
for (var i = 0; i < rowToCopy.cells.length; i++)
{
var cell = row.insertCell(i);
cell.className=rowToCopy.cells[i].className;
var txt = rowToCopy.cells[i].innerHTML;
-// txt=txt.replace(/row_1/g,"row_"+new_value);
if ( i == 0 )
{
- cell.innerHTML =mytable.rows.length-1 ;
+ var change=nb+1;
+ cell.innerHTML =change+'<input id="row[]" type="hidden" value="-1"
name="row[]">';
}
else
{
if (i == rowToCopy.cells.length -1 ) {
txt=txt.replace(/value="[0-9]*.{1}[0-9]*"/,'value="0"')
+ } else {
+ txt=txt.replace(/po_id\[0\]/g,'po_id['+nb+']');
}
cell.innerHTML = txt;
}
diff --git a/include/anc_key.inc.php b/include/anc_key.inc.php
index 2527934..fbbfaec 100644
--- a/include/anc_key.inc.php
+++ b/include/anc_key.inc.php
@@ -26,7 +26,6 @@
* @see do.php
*
*/
-var_dump($_POST);
if (!defined('ALLOWED'))
die('Appel direct ne sont pas permis');
global $cn, $g_user;
@@ -63,5 +62,11 @@ switch ($op)
}
$key->input();
break;
+ case 'delete_key':
+ $id=HtmlInput::default_value_request("key", "0");
+ $key=new Anc_Key($id);
+ $key->delete();
+ Anc_Key::display_list();
+ Anc_Key::key_add();
}
?>
diff --git a/include/class_anc_key.php b/include/class_anc_key.php
index c277a52..7e70baa 100644
--- a/include/class_anc_key.php
+++ b/include/class_anc_key.php
@@ -75,9 +75,9 @@ class Anc_Key
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);
+ $a_key=$cn->get_array('select b.kd_id,b.kd_name,b.kd_description,
+ (select sum(ke_percent) from key_distribution_detail as a
where a.kd_id=b.kd_id) as distrib
+ from key_distribution as b order by b.kd_name');
if (empty($a_key))
{
echo _('Aucune clef disponible');
@@ -127,7 +127,7 @@ class Anc_Key
{
$tot_percent=bcadd($tot_percent, $a_percent[$i]);
}
- if ($tot_percent<>100)
+ if ($tot_percent >100)
{
throw new Exception(_('Le total ne vaut pas 100, total calculé =
').$tot_percent);
}
@@ -195,7 +195,7 @@ class Anc_Key
$cn->start();
// for each row
$a_row=$p_array['row'];
- $a_ledger=$p_array['jrn'];
+ $a_ledger=HtmlInput::default_value("jrn",array(),$p_array);
$a_percent=$p_array['percent'];
$a_po_id=$p_array['po_id'];
$a_plan=$p_array['pa'];
@@ -226,7 +226,7 @@ class Anc_Key
for ($j=0; $j<count($a_po_id[$i]); $j++)
{
$activity=new Anc_Key_Activity_SQL($cn);
- $activity->setp('detail', $key_row->getp('id'));
+ $activity->setp('detail', $key_row->ke_id);
$value=($a_po_id[$i][$j]==-1)?null:$a_po_id[$i][$j];
$activity->setp('activity', $value);
$activity->setp('plan',$a_plan[$j]);
@@ -243,12 +243,13 @@ class Anc_Key
$ledger->save();
}
+ $cn->commit();
}
catch (Exception $e)
{
- echo $e->getTraceAsString();
+ if ( DEBUG ) { echo $e->getTraceAsString(); var_dump($_POST);}
else { echo _('erreur');}
+ $cn->rollback();
}
- $cn->commit();
}
/**
* @brief Call the Anc_Operation::display_form_plan with the right amounts.
@@ -263,6 +264,7 @@ class Anc_Key
{
global $cn;
$number=str_replace('t', '', $p_target);
+ $number=str_replace('popup', '', $number);
$op[$number]=$p_amount;
$array['op']=$op;
@@ -302,10 +304,13 @@ class Anc_Key
$array['val']=$val;
$anc_operation=new Anc_Operation($cn);
- echo $anc_operation->display_form_plan($array, 1, 1, $number,
$p_amount);
+ echo $anc_operation->display_form_plan($array, 1, 1, $number,
$p_amount,'',false);
}
-
+ /**
+ address@hidden show a form for adding a key + button to display it
+ *
+ */
static function key_add()
{
$key=new Anc_Key();
@@ -319,4 +324,11 @@ class Anc_Key
echo '</div>';
}
+ /**
+ address@hidden delete the distribution key
+ */
+ function delete ()
+ {
+ $this->key->delete();
+ }
}
diff --git a/include/template/anc_key_display_list.php
b/include/template/anc_key_display_list.php
index 8ea60ac..9a57108 100644
--- a/include/template/anc_key_display_list.php
+++ b/include/template/anc_key_display_list.php
@@ -21,19 +21,21 @@
* @brief display a table with the list of available keys for all ledgers
* @see Anc_Key::display_list
*/
-
+global $g_succeed,$g_failed;
?>
+<div class="content">
<table class="result">
- <?php for ($i = 0; $i < Database::num_row($rkey); $i++):
+ <?php for ($i = 0; $i < count($a_key); $i++):
$onclick= http_build_query(array(
'gDossier'=>Dossier::id(),
'ac'=>$_REQUEST['ac'],
'op'=>'consult',
'key'=>$a_key[$i]['kd_id']
));
+ $class=($i%2==0)?'class="even"':'class="odd"';
?>
- <tr>
+ <tr <?php echo $class;?>>
<td>
<a class="line" href="do.php?<?php echo $onclick; ?>" >
<?php echo $a_key[$i]['kd_name']; ?>
@@ -42,7 +44,14 @@
<td>
<?php echo $a_key[$i]['kd_description'] ?>
</td>
-
+ <?php
+ $sign=($a_key[$i]['distrib']==100)?$g_succeed:$g_failed;
+ ?>
+ <td>
+ <?php echo nbm($a_key[$i]['distrib']);?>%
+ <?php echo $sign;?>
+ </td>
</tr>
<?php endfor; ?>
-</table>
\ No newline at end of file
+</table>
+</div>
\ No newline at end of file
diff --git a/include/template/anc_key_input.php
b/include/template/anc_key_input.php
index 8597306..3052341 100644
--- a/include/template/anc_key_input.php
+++ b/include/template/anc_key_input.php
@@ -22,7 +22,7 @@
* all the pa_id and analytic plan
*/
?>
-<form method="post" action="do.php">
+<form method="post" action="do.php" style="display:inline">
<?php
echo HtmlInput::request_to_hidden(array('gDossier', 'ac'));
echo HtmlInput::hidden('op','consult');
@@ -98,7 +98,7 @@
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']));
+ where ke_id=$1 and ka.pa_id=$2 ',
array($a_row[$j]['ke_id'],$plan[$i]['pa_id']));
$selected=-1;
if (sizeof($value)==1)
{
@@ -201,4 +201,11 @@
<!-- end -->
</div>
<?php echo HtmlInput::submit('save_key', _('Sauver')); ?>
+</form>
+<form style="display:inline" action="do.php" method="post">
+ <?php
+ echo HtmlInput::request_to_hidden(array('gDossier', 'ac'));
+ echo HtmlInput::hidden('op','delete_key');
+ echo HtmlInput::hidden('key', $this->key->getp('id'));
+ if ($this->key->getp('id') != -1) echo HtmlInput::submit('delete_key',
_('Effacer'),'onclick="return confirm(\''._('Confirmer effacement?').'\')"'); ?>
</form>
\ No newline at end of file
- [Noalyss-commit] [noalyss] 16/27: Add p_jrn is the bottom of the popup, to allow the use of distribution key, (continued)
- [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, 2014/10/02
- [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 <=
- [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