Improve stock

This commit is contained in:
sparkyx 2007-04-17 10:51:37 +00:00
parent 11339de5cf
commit e190771e9c
5 changed files with 63 additions and 23 deletions

View file

@ -1,6 +1,8 @@
begin;
insert into format_csv_banque values ('Dexia','dexia_be.inc.php');
alter table stock_goods alter sg_quantity type numeric(8,4);
alter table stock_goods alter sg_quantity type numeric(8,4);
alter table stock_goods add sg_comment varchar(80);
alter table stock_goods add sg_exercice varchar(4);
update version set val=28;
commit;

View file

@ -56,6 +56,9 @@ if ( $action == 'fiche') {
require_once('fiche.inc.php');
}
if ( $action == 'stock') {
require_once('stock.inc.php');
}
html_page_stop();
?>

View file

@ -57,37 +57,61 @@ if ( $User->admin == 0 ) {
}
$href=basename($_SERVER['PHP_SELF']);
if ($href=='compta.php')
{
//Show the top menu
include_once ("user_menu.php");
// echo ShowMenuCompta($_SESSION['g_dossier'],"user_advanced.php");
// Show Menu Left
$left_menu=ShowMenuAdvanced("stock.php");
//echo '<div class="lmenu">';
echo $left_menu;
}
$action= ( isset ($_GET['action']))? $_GET['action']:"";
include_once("stock_inc.php");
// Adjust the stock
if ( isset ($_POST['sub_change'])) {
if ( isset ($_POST['sub_change']))
{
$change=$_POST['stock_change'];
$sg_code=$_POST['sg_code'];
$sg_date=$_POST['sg_date'];
$year=$_POST['year'];
$comment=$_POST['comment'];
if ( isDate($sg_date) == null
or isNumber($change) == 0 ) {
$msg="Stock données non conformes";
echo "<script> alert('$msg');</script>";
echo_error($msg);
} else {
// Check if User Can change the stock
if ( CheckAction($_SESSION['g_dossier'],$_SESSION['g_user'],STOCK_WRITE) == 0 ) {
NoAccess();
exit (-1);
or isNumber($change) == 0
or isNumber($year) == 0 )
{
$msg="Stock données non conformes";
echo "<script> alert('$msg');</script>";
echo_error($msg);
} else
{
// Check if User Can change the stock
if ( CheckAction($_SESSION['g_dossier'],$_SESSION['g_user'],STOCK_WRITE) == 0 ) {
NoAccess();
exit (-1);
}
// if neg the stock decrease => credit
$type=( $change < 0 )?'c':'d';
if ( $change != 0)
$Res=ExecSql($cn,"insert into stock_goods
{
$comment=FormatString($comment);
$Res=ExecSql($cn,"insert into stock_goods
( j_id,
f_id,
sg_code,
sg_quantity,
sg_type,
sg_date,
sg_exercice,
sg_comment,
sg_tech_user)
values (
null,
@ -96,8 +120,11 @@ if ( isset ($_POST['sub_change'])) {
abs($change),
'$type',
to_date('$sg_date','DD.MM.YYYY'),
'$year',
'$comment',
'".$_SESSION['g_user']."');
");
}
// to update the view
$action="detail";
}
@ -130,11 +157,11 @@ if ( $action == 'detail' ) {
$b=ChangeStock($sg_code,$year);
echo '<div class="u_redcontent">' ;
echo $a;
echo 'Entrer la valeur qui doit augmenter ou diminuer le stock, attention ne pas utiliser de d&eacute;cimales';
echo '<form action="stock.php" method="POST">';
echo 'Entrer la valeur qui doit augmenter ou diminuer le stock';
echo '<form action="?p_action=stock" method="POST">';
echo $b;
echo '<input type="submit" name="sub_change" value="Ok">';
echo '<A class="mtitle" HREF="?"><INPUT TYPE="BUTTON" value="Retour"</A>';
echo '<A class="mtitle" HREF="?p_action=stock"><INPUT TYPE="BUTTON" value="Retour"</A>';
echo '</form>';
echo '</div>';

View file

@ -147,11 +147,12 @@ $sql="select distinct f_id,av_text
function ViewDetailStock($p_cn,$p_sg_code,$p_year) {
$sql="select sg_code,
j_montant,
j_date,
coalesce(j_date,sg_date) as j_date,
sg_quantity,
sg_type,
jr_comment,
jr_internal,
jr_id,
coalesce(jr_comment,sg_comment) as comment,
coalesce(jr_internal,'Changement manuel') as jr_internal,
jr_id,
case when sg_date is not null then sg_date else j_date end as stock_date
from stock_goods
@ -159,8 +160,8 @@ $sql="select sg_code,
left outer join jrn on jr_grpt_id=j_grpt
where
sg_code='$p_sg_code' and (
to_char(sg_date,'YYYY') = '$p_year'
or to_char(j_date,'YYYY') = '$p_year'
sg_exercice = '$p_year'
or j_tech_per in (select p_id from parm_periode where p_exercice='$p_year')
)
order by stock_date
" ;
@ -188,6 +189,7 @@ $sql="select sg_code,
$r.="<th>Entrée / Sortie </th>";
$r.="<th></th>";
$r.="<th>Description</th>";
$r.="<th>Op&eacute;ration</th>";
$r.="<th>Montant</th>";
$r.="<th>Quantité</th>";
$r.="<th>Prix/Cout Unitaire</th>";
@ -211,12 +213,17 @@ $sql="select sg_code,
// jr_internal
$r.="<TD>";
if ( $l['jr_id'] != "")
$r.= "<A class=\"detail\" HREF=\"javascript:modifyOperation('".$l['jr_id']."','".$_REQUEST['PHPSESSID']."')\" > ".$l['jr_internal']."</A>";
else
$r.=$l['jr_internal'];
$r.="</TD>";
// comment
$r.="<TD>";
$r.=$l['jr_comment'];
$r.=$l['comment'];
$r.="</TD>";
//amount
@ -233,7 +240,7 @@ $sql="select sg_code,
$r.="<TD>";
$up="";
if ( $l['sg_quantity'] != 0 )
$up=$l['j_montant']/$l['sg_quantity'];
$up=round($l['j_montant']/$l['sg_quantity'],4);
$r.=$up;
$r.="</TD>";
@ -261,6 +268,7 @@ $sg_date=date("d.m.Y");
$r='
<input type="text" name="stock_change" value="0">
<input type="hidden" name="sg_code" value="'.$p_sg_code.'">
<input type="text" name="comment" value="">
<input type="text" name="sg_date" value="'.$sg_date.'">
<input type="hidden" name="year" value="'.$p_year.'">
<br>

View file

@ -495,7 +495,7 @@ $left_menu=ShowItem(array(
array('user_advanced.php?p_action=periode','Periode'),
array('central.php','Centralise'),
array('pcmn_update.php?p_start=1','Plan Comptable'),
array('stock.php','Stock'),
array('compta.php?p_action=stock','Stock'),
array('form.php','Rapport'),
array('import.php','Import Banque'),
array('ecrit_ouv.php','Ecriture ouverture')