Unlimited stock code

Fix bug in STOCK_INV
Set MAX_ARTICLE_STOCK
Add button to add a row
This commit is contained in:
Dany De Bontridder 2013-10-19 14:53:49 +00:00
parent 5a86a7ce7d
commit ef8f51eb8f
5 changed files with 61 additions and 11 deletions

View file

@ -2353,3 +2353,40 @@ function calendar_zoom(obj)
}
/**
* @brief add a line in the form for the stock
*/
function stock_add_row()
{
try{
style='class="input_text"';
var mytable=g("stock_tb").tBodies[0];
var ofirstRow=mytable.rows[1];
var line=mytable.rows.length;
var nCell=mytable.rows[1].cells.length;
var row=mytable.insertRow(line);
var nb=g("row");
for (var e=0;e<nCell;e++)
{
var newCell=row.insertCell(e);
if (mytable.rows[1].cells[e].hasClassName('num') ) { newCell.addClassName("num");}
var tt=ofirstRow.cells[e].innerHTML;
var new_tt=tt.replace(/sg_code0/g,"sg_code"+nb.value);
new_tt=new_tt.replace(/sg_quantity0/g,"sg_quantity"+nb.value);
new_tt=new_tt.replace(/label0/g,"label"+nb.value);
newCell.innerHTML=new_tt;
new_tt.evalScripts();
}
g("sg_code"+nb.value).innerHTML='&nbsp;';
g("sg_code"+nb.value).value='';
g("label"+nb.value).innerHTML='';
g("sg_quantity"+nb.value).value='0';
nb.value++;
new_tt.evalScripts();
} catch(e) {alert(e.message);}
}

View file

@ -42,7 +42,7 @@ for ($i=0;$i<count($array);$i++)
$p_array['sg_code'.$i]=$array[$i]['sg_code'];
$p_array['sg_quantity'.$i]=$array[$i]['sg_quantity'];
$p_array['sg_type'.$i]=$array[$i]['sg_type'];
$p_array['row']=$i+1;
}
echo $st->input($p_array,true);
?>

View file

@ -75,10 +75,20 @@ class Stock_Goods extends Stock_Goods_Sql
exit();
}
$idepo->selected = $p_depot;
for ($e = 0; $e < MAX_ARTICLE; $e++)
if ($p_readonly ) {
$nb=$row;
} else {
if (isset ($row ) )
{
$nb=($row > MAX_ARTICLE_STOCK)?$row:MAX_ARTICLE_STOCK;
}else {
$nb=MAX_ARTICLE_STOCK;
}
}
for ($e = 0; $e < $nb; $e++)
{//ATTR_DEF_STOCKfiche_
$sg_code[$e] = new ICard('sg_code' . $e);
$sg_code[$e]->extra = "[sql] f_id in (select distinct f_id from fiche_Detail where ad_id=19 and coalesce(ad_value,\'\') <> \'\')";
$sg_code[$e]->extra = "[sql] fd_id = 500000";
$sg_code[$e]->set_attribute("typecard", $sg_code[$e]->extra);
$sg_code[$e]->set_attribute("label", "label" . $e);
$sg_code[$e]->value = (isset(${'sg_code' . $e})) ? ${'sg_code' . $e} : '';
@ -109,7 +119,7 @@ class Stock_Goods extends Stock_Goods_Sql
if (isDate($p_array['p_date']) == null)
throw new Exception('Date invalide');
$cn->start();
$ch = new Stock_Change_Sql();
$ch = new Stock_Change_Sql($cn);
$ch->setp("c_comment", $p_array['p_motif']);
$ch->setp("r_id", $p_array['p_depot']);
$ch->setp("c_date", $p_array['p_date']);
@ -118,10 +128,10 @@ class Stock_Goods extends Stock_Goods_Sql
$per = new Periode($cn);
$periode = $per->find_periode($p_array['p_date']);
$exercice = $per->get_exercice($periode);
for ($i = 0; $i < MAX_ARTICLE; $i++)
$nb=$p_array['row'];
for ($i = 0; $i < $nb; $i++)
{
$a = new Stock_Goods_Sql();
$a = new Stock_Goods_Sql($cn);
if ($p_array['sg_quantity' . $i] != 0 &&
trim($p_array['sg_code' . $i]) != '')
{

View file

@ -78,6 +78,7 @@ define ('NOTFOUND','--not found--');
define ("MAX_COMPTE",4);
define ('MAX_ARTICLE',5);
define ('MAX_ARTICLE_STOCK',20);
define ('MAX_CAT',15);
define ('MAX_CARD_SEARCH',550);
define ('MAX_FORECAST_ITEM',10);

View file

@ -54,7 +54,7 @@
</td>
</tr>
</table>
<table style="width: 80%">
<table id="stock_tb" style="width: 80%">
<tr>
<th style="text-align: left">
Code Stock
@ -68,7 +68,7 @@
Quantité
</th>
</tr>
<?php for($i=0;$i<MAX_ARTICLE;$i++): ?>
<?php for($i=0;$i<$nb;$i++): ?>
<tr>
<td>
<?php if ( $p_readonly == false) : ?>
@ -86,9 +86,9 @@
</td>
<?php endif;?>
<TD class="num"">
<?php if ($sg_quantity[$i]->value==0 && $p_readonly==true):?>
<?php if ($sg_quantity[$i]->value==0 && $p_readonly==true):?>
<?php else : ?>
<?php else : ?>
<?php echo $sg_quantity[$i]->input()?>
<?php endif;?>
</td>
@ -100,6 +100,8 @@
</tr>
<?php endfor; ?>
</table>
<?php if ($p_readonly == false) echo HtmlInput::button_action('Ajouter une ligne','stock_add_row();')?>
<?php if ($p_readonly == false) echo HtmlInput::submit('save','Sauver')?>
<?php if ($p_readonly == false) echo HtmlInput::hidden('row',$nb)?>
</form>
</div>