0byt3m1n1
Path:
C:
/
wamp64
/
www
/
cpms_new
/
ADMIN
/
[
Home
]
File: lastphysicalquantity_ctrl.php
<?php require_once "../lib/config.php"; //require_once BASE_DIR."/lib/db/DBconnection.php"; require_once BASE_DIR."/lib/db/connection.php"; $division_name=@$_SESSION['division_d']; $sql1="select user_id from user where user_name='$division_name'"; $sql=mysql_query($sql1); while($row=mysql_fetch_array($sql)) { $u_id=$row['user_id']; } $sql="select * from stockitem where user_id='$u_id'"; $sql=mysql_query($sql); $i=0; $item_name_array= []; while($row=mysql_fetch_array($sql)) { $item_name_db=$row['item_name']; $item_desc_db[$i]=$row['description']; $i=$i+1; $item_name_array[$i]=$item_name_db; } if(isset($_POST['show'])) { $error_flag=0; $item_name_restore=@$_POST['cmbitem']; $item_name=$item_name_array[$item_name_restore]; $date_dd= @$_POST['cmbstockbalancedd']; $date_mm=@$_POST['cmbstockbalancemm']; $date_yy=@$_POST['txtstockbalanceyy']; $date=$date_yy."-".$date_mm."-".$date_dd; if (!is_numeric(@$_POST['txtstockbalanceyy'])) { $error['date_numeric']="Please enter valid year"; $error_flag=1; } if ($date_yy="") { $error['date_null']="Please enter year"; $error_flag=1; } if($error_flag==1) { echo "<script>window.location='http://localhost/CPFMS/ADMIN/lastphysicalquantity.php</script>"; /*$url="http://".$server_ip."/CPFMS/USER/ledger.php?pcode=".$p_code_value; echo "<script>window.location='$url'</script>"; */ } if($error_flag==0) { //$division_name=@$_SESSION['division_d']; // $sql1="select user_id from user where user_name='$division_name'"; // $sql=mysql_query($sql1); // while($row=mysql_fetch_array($sql)) // { // $u_id=$row['user_id']; // } if ($item_name=="") { $sql1="select distinct(item_name) from stockentry where user_id='$u_id' and stockentrydate<='$date'"; $item_name="All"; } else { $sql1="select distinct(item_name) from stockentry where user_id='$u_id' and item_name ='$item_name' and stockentrydate<='$date'"; } lastphysicalquantityreport::printstockbalanceDetails($sql1,$date,$item_name); } } class lastphysicalquantityreport { //7 public function printstockbalanceDetails($sql1,$date,$item_name) {//10 $sql=mysql_query($sql1); if(mysql_affected_rows()>0) {//14 $division_name=@$_SESSION['division_d']; $sql2="select user_id from user where user_name='$division_name'"; $sql2=mysql_query($sql2); while($row2=mysql_fetch_array($sql2)) { $u_id=$row2['user_id']; } ?> <div align="center"><strong><?php echo"Stock deal of $item_name as on:$date"?></strong></div> <table width="444" height="53" border="1" align="center" id="ledgertable"> <tr> <th width="54" height="23"> S No </th> <th width="108">Item Name</th> <th width="108">Description</th> <th width="106">Category</th> <th width="148">Stock balance</th> </tr> <?php $balance_totel=0; while($row=mysql_fetch_array($sql)) {//32 ?> <tr> <th height="22"><div align="center"> <?php @$_SESSION['sl_no']=@$_SESSION['sl_no']+1; echo @$_SESSION['sl_no']; ?> </div></th> <th><div align="center"> <?php $itemname_db=$row['item_name']; echo $itemname_db; ?> </div></th> <th><div align="center"> <?php $sqlcat="select * from stockentry where item_name='$itemname_db'"; $sql1=mysql_query($sqlcat); while($row1=mysql_fetch_array($sql1)) { echo $row1['description']; } ?> </div></th> <th><div align="center"> <?php $sqlcat="select * from stockitem where item_name='$itemname_db'"; $sql1=mysql_query($sqlcat); while($row1=mysql_fetch_array($sql1)) { echo $row1['category_name']; } ?> </div></th> <th><div align="center"> <?php if ($item_name=="All") {//86 $sqlinstock="select sum(itemsinstock) from stockentry where user_id='$u_id' and item_name='$itemname_db' and stockentrydate<='$date' GROUP BY item_name "; $sql4=mysql_query($sqlinstock); $count_item_instock= 0; while($row4=mysql_fetch_array($sql4)) { $count_item_instock=$row4[0]; } }//86 else {//86 $sqlinstock="select sum(itemsinstock) from stockentry where user_id='$u_id' and item_name='$item_name' and stockentrydate<='$date' GROUP BY item_name "; $sql2=mysql_query($sqlinstock); $count_item_instock= 0; while($row2=mysql_fetch_array($sql2)) { $count_item_instock=$row2[0]; } }//86 if ($item_name=="All") {//108 $sqlused="select sum(itemused) from stockusage_entry where user_id='$u_id'and item_name='$itemname_db' and date<='$date' GROUP BY item_name"; $sql5=mysql_query($sqlused); $count_itemused= 0; while($row5=mysql_fetch_array($sql5)) { $count_itemused=$row5[0]; } }//108 else { //108 $sqlused="select sum(itemused) from stockusage_entry where user_id='$u_id' and item_name='$item_name' and date<='$date' GROUP BY item_name"; $sql3=mysql_query($sqlused); $count_itemused= 0; while($row3=mysql_fetch_array($sql3)) { $count_itemused=$row3[0]; } }//108 echo $balance=$count_item_instock- $count_itemused; $balance_totel=$balance_totel+$balance; ?> </div></th> </tr> <?php }//32 ?> </table> <table width="440" align="center"> <tr> <td width="134"><div align=""><strong>Total balance</strong></div></td> <td width="181"><div align="center"></div></td> <td width="109"><div align="center"><?php echo $balance_totel;?></div></td> </tr> </table> <?php }//14 else {//14 ?><font color="#CC0000"><b><?php echo "No Details to display"; ?></b></font><?php }//14 }//10 }//7 if(isset($_POST['show'])) { ?> </p> <p><a href="#" class="projectboldtxt style2" onclick="window.print()">Print</a> <a href="division_report.php">Back</a></p> </blockquote> <?php } ?>