fix several bugs : when adding new keys or new rows in a key
Task #1021 - Comptabilité analytique : clef de répartition : bouton ajout
This commit is contained in:
parent
a10f9de01d
commit
4b1d252fdd
5 changed files with 60 additions and 23 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*@brief 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>';
|
||||
|
||||
}
|
||||
/**
|
||||
*@brief delete the distribution key
|
||||
*/
|
||||
function delete ()
|
||||
{
|
||||
$this->key->delete();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
</table>
|
||||
</div>
|
||||
|
|
@ -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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue