currentstock

This commit is contained in:
gandhimathi 2018-06-25 19:07:42 +05:30
parent bf72ad8fca
commit c42f6120cf
4 changed files with 60 additions and 21 deletions

View File

@ -252,6 +252,7 @@ else
$RawMaterialID = $_GET['RID'];
$MaterialType = $_GET['MType'];
$UOM = $_GET['UOM'];
$currentdate=$_GET['date1'];
}
else
{
@ -259,7 +260,7 @@ else
}
$data['materialDetails'] = $this->rawmaterialdetails_model->getMaterialDetails($RawMaterialID);
$data['currentstock'] = $this->rawmaterialdetails_model->getMaterialstock($RawMaterialID);
$data['currentstock'] = $this->rawmaterialdetails_model->getMaterialstock($RawMaterialID, $currentdate);
$data['materialType'] = $this->rawmaterialdetails_model->getmaterialType($MaterialType );
$data['materialCategory'] = $this->rawmaterialdetails_model->getmaterialCategory($MaterialCategory);
$data['UOMList'] = $this->rawmaterialdetails_model->getUOM($UOM);

View File

@ -109,26 +109,61 @@ class rawmaterialdetails_model extends CI_Model
* @param number $userId : This is user id
* @return array $result : This is user information
*/
function getMaterialDetails($MaterialCode)
function getMaterialDetails($MaterialCode)
{
$this->db->select('*');
$this->db->from('T_MaterialMaster');
$this->db->where('MaterialCode', $MaterialCode);
$query = $this->db->get();
//sprint_r($this->db->last_query());
return $query->result();
$sql=" SELECT * FROM T_MaterialMaster WHERE MaterialCode =$MaterialCode";
$query = $this->db->query( $sql);
return $query->result();
}
function getMaterialstock($MaterialCode)
function getMaterialstock($MaterialCode, $currentdate)
{
$dt = date('d',strtotime($currentdate));
$year = date('Y', strtotime($currentdate));
$month = date('m', strtotime($currentdate));
if($month<04)
{
//echo "b4finance";
$newyr = $year - 1;
$startdate = $newyr.'-'.'04'.'-'.'01';
// print_r( $startdate);die();
//echo $startdate;
}
else
{
//echo "after Finance";
$startdate = $year.'-'.'04'.'-'.'01';
// print_r( $startdate);die();
// echo $startdate;
}
$nedt= $dt+1;
$newdate=$year.'-'.$month.'-'.$nedt;
$subquery="SELECT SUM(IF(Transaction_type='Add',Quantity,0)) - SUM(IF(Transaction_type='Reduce',Quantity,0))as remainingqty
FROM T_Material_stock_history
where MaterialCode='$MaterialCode'";
$query = $this->db->query($subquery);
return $query->result();
WHERE MaterialCode=? AND CreatedOn >=? AND CreatedOn <=? ";
$query = $this->db->query($subquery,array($MaterialCode,$startdate,$newdate));
return $query->result_array();
}
function getAssetcode()
{
$this->db->select('AssetCode,AssetName');

View File

@ -53,19 +53,21 @@ if(!empty($materialDetails))
if(!empty($currentstock))
{
foreach ($currentstock as $MC)
{
// print_r($currentstock);
// die();
$currentstock =$MC->remainingqty;
}
$currentstock =$currentstock[0]['remainingqty'];
$x = $openstock;
$y = $currentstock;
$total= $x + $y;
}
?>
<?php
if($currentstock <= $reorder){
if( $total <= $reorder){
echo '<script type="text/javascript">alert("Current Stock Low ");</script>';
@ -287,7 +289,7 @@ $("#Date").datepicker({
<div class="col-md-3">
<div class="form-group">
<label for="conversionfactor">Current Stock</label>
<input type="text" class="form-control" id="currentstock" readonly value="<?php echo $currentstock; ?>" name="currentstock" maxlength="255">
<input type="text" class="form-control" id="currentstock" readonly value="<?php echo $total; ?>" name="currentstock" maxlength="255">
</div>
</div>

View File

@ -40,11 +40,12 @@
{
foreach($userRecords as $record)
{
$date=date("Y-m-d");
?>
<tr>
<td style="width:9%;"><u><a href="<?php echo base_url().'rawmaterialdetails/viewRawmaterial?RID='.$record->MaterialCode.'&MType='.$record->MaterialType.'&UOM='.$record->UOM ?>" data-toggle="tooltip" title="<?php echo $record->MaterialCode; ?> - Click here to view Material details"><?php echo $record->MaterialCode ?> </a></u></td>
<td style="width:9%;"><u><a href="<?php echo base_url().'rawmaterialdetails/viewRawmaterial?RID='.$record->MaterialCode.'&MType='.$record->MaterialType.'&UOM='.$record->UOM.'&date1='.$date ?>" data-toggle="tooltip" title="<?php echo $record->MaterialCode; ?> - Click here to view Material details"><?php echo $record->MaterialCode ?> </a></u></td>
<!--<td><u><a href="<?php echo base_url().'rawmaterialdetails/viewRawmaterial?RID='.$record->RMCode.'&MType='.$record->MaterialType.'&UOM='.$record->UOM ?>" data-toogle="tooltip" title="<?php echo $record->RMCode; ?> - Click here to view Material details"><?php echo $record->RMCode ?> </a></u></td>-->
<td style="width:12%;"><?php echo $record->MaterialName ?></td>
<td style="width:10%;"><?php echo $record->MaterialType ?></td>