initial stock when a new stock code is used
This commit is contained in:
parent
6534f4c092
commit
39c8f73c08
3 changed files with 52 additions and 4 deletions
|
|
@ -462,6 +462,25 @@ class fiche {
|
|||
ExecSql($this->cn,$sql);
|
||||
continue;
|
||||
}
|
||||
// stock
|
||||
if ( $id == ATTR_DEF_STOCK ) {
|
||||
$st=CountSql($this->cn,'select * from stock_goods where '.
|
||||
" upper(sg_code)=upper('$value')");
|
||||
if ( $st == 0 ) {
|
||||
$user=new User($this->cn);
|
||||
$exercice=$user->get_exercice();
|
||||
if ( $exercice == 0 ) throw Exception ('Annee invalide erreur');
|
||||
|
||||
$str_stock=sprintf('insert into stock_goods(f_id,sg_initial,sg_code,sg_type,sg_exercice) '.
|
||||
' values (%d,upper(\'%s\'),\'c\',\'%s\')',
|
||||
$fiche_id,
|
||||
'initial',
|
||||
FormatString($value),
|
||||
$exercice);
|
||||
|
||||
ExecSql($this->cn,$str_stock);
|
||||
}
|
||||
}
|
||||
// name
|
||||
if ( $id == ATTR_DEF_NAME )
|
||||
{
|
||||
|
|
@ -598,7 +617,25 @@ class fiche {
|
|||
|
||||
|
||||
}
|
||||
|
||||
if ( $id == ATTR_DEF_STOCK ) {
|
||||
$st=CountSql($this->cn,'select * from stock_goods where '.
|
||||
" upper(sg_code)=upper('$value')");
|
||||
if ( $st == 0 ) {
|
||||
$user=new User($this->cn);
|
||||
$exercice=$user->get_exercice();
|
||||
if ( $exercice == 0 ) throw Exception ('Annee invalide erreur');
|
||||
|
||||
$str_stock=sprintf('insert into stock_goods(f_id,sg_comment,sg_code,sg_type,sg_exercice) '.
|
||||
' values (%d,upper(\'%s\'),\'d\',\'%s\')',
|
||||
$this->id,
|
||||
'initial',
|
||||
FormatString($value),
|
||||
$exercice);
|
||||
|
||||
ExecSql($this->cn,$str_stock);
|
||||
}
|
||||
}
|
||||
|
||||
// account
|
||||
if ( $id == ATTR_DEF_ACCOUNT )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -36,13 +36,19 @@
|
|||
function ViewStock($p_cn,$p_year) {
|
||||
// build sql -- get the different merchandise sold or bought
|
||||
// during the p_year
|
||||
$sql=" select distinct sg_code
|
||||
/* $sql=" select distinct sg_code
|
||||
from stock_goods
|
||||
left outer join jrnx on (stock_goods.j_id=jrnx.j_id)
|
||||
right outer join parm_periode on (parm_periode.p_id=jrnx.j_tech_per)
|
||||
where
|
||||
p_exercice= '$p_year'
|
||||
and sg_code is not null and sg_code != '' and sg_code!='null'";
|
||||
*/
|
||||
$sql=" select distinct sg_code
|
||||
from stock_goods
|
||||
where
|
||||
sg_code is not null and sg_code != '' and sg_code!='null'";
|
||||
|
||||
|
||||
|
||||
// send the sql
|
||||
|
|
|
|||
|
|
@ -788,16 +788,21 @@ function InsertStockGoods($p_cn,$p_j_id,$p_good,$p_quant,$p_type)
|
|||
$Res=ExecSql($p_cn,$sql);
|
||||
$r=pg_fetch_array($Res,0);
|
||||
$f_id=$r['f_id'];
|
||||
$user=new User($p_cn);
|
||||
$exercice=$user->get_exercice();
|
||||
if ( $exercice == 0 ) throw Exception ('Annee invalide erreur');
|
||||
|
||||
|
||||
$Res=ExecSql($p_cn,"insert into stock_goods (
|
||||
j_id,
|
||||
f_id,
|
||||
sg_code,
|
||||
sg_quantity,
|
||||
sg_type ) values (
|
||||
sg_type,sg_exercice ) values (
|
||||
$p_j_id,
|
||||
$f_id,
|
||||
'$code_marchandise',
|
||||
$p_quant, '$p_type')
|
||||
$p_quant, '$p_type',$exercice)
|
||||
");
|
||||
return $Res;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue