
<?php 
$PageSecurity = 2;
$title = _('Process Material Issue Slip');
$_SESSION['modid']=$_REQUEST['modid'];
$_SESSION['frmid']=$_REQUEST['frmid'];
$frmpermission= $px->GetFileAccess($_SESSION['modid'],$_SESSION['frmid'],$_SESSION['ACGRoleId']);
$_SESSION['frmAdd']=$frmpermission[0];
$_SESSION['frmEdit']=$frmpermission[1];
$_SESSION['frmDelete']=$frmpermission[2];
$_SESSION['frmView']=$frmpermission[3];
 unset($_SESSION['ACGRequisition-ItemList']); 


 //For User Store
$sql_user_store="select hmis_storeid,StoreCode from www_users left join storetype on storetype.id=www_users.hmis_storeid where www_users.id='".$_SESSION['UserID']."'";
$result_user_store=DB_query($sql_user_store,$db);
$rs_user_store=DB_fetch_array($result_user_store);
$main_store=$rs_user_store[0];


$sql_other_store="select store_id,StoreCode from www_users_dtls left join storetype on storetype.id=www_users_dtls.store_id where user_id='".$_SESSION['UserID']."'";
$result_other_store=DB_query($sql_other_store,$db);
while($rs_other_store=DB_fetch_array($result_other_store))
{
  $store[]=$rs_other_store['store_id'];
}
if(!empty($store))
{
  $get_store_id=implode(",",$store);
}

?>	

<style>
#slidingDiv 
{
    display: none;
	height:auto;
	background-color:transparent;
	padding:0px;
}
</style>

<script type="text/javascript">
function showSlidingDiv(){
$("#slidingDiv").animate({"height": "toggle"}, { duration: 700 });
}
</script>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
 
<h1><?php echo $s->getField('modules_form','id',$_REQUEST['frmid'],'frm_name'); ?></h1>

<table width="100%" border="0" cellspacing="0" cellpadding="3" class="thborder">
  <tr>
    <th>MRS No.</th>
    <th width="10%">Date</th>
    <!-- <th width="10%">Job Card No.</th> -->
    <!--<td><strong>Job Card No</strong></td>
    <td><strong>Date</strong></td>
  	<td><strong>Product</strong></td>
  	<td><strong>Unit</strong></td>
  	<td><strong>Batch Size</strong></td> -->
  	<th width="18%">From Store</th>
    <th width="18%">To Store</th>
  	<th width="7%" class="text-center">Action</th>
  </tr>  
  	<?php 
  			$i=1;
        if($_SESSION['UserType']!='SuperAdmin')
        {
          if($get_store_id!='' && $main_store!='')
          {
            $result = DB_query("Select * from material_slip_against_job_card where to_store in('".$main_store."','".$get_store_id."') and issue_status='0' ",$db);
          }
          else if($main_store!='')
          { 
             $result = DB_query("Select * from material_slip_against_job_card where to_store in('".$main_store."') and issue_status='0'  ",$db);
          }
        }
        else
        {
            $result = DB_query("Select * from material_slip_against_job_card where issue_status='0' ",$db);
        }  
  			
  			if(DB_Num_rows($result)>0)
  			{

  				while ($data=DB_Fetch_array($result)) 
  				{

            ?>  					 
  					<tr>
  						<td><?php echo $data['mat_slip_no']; ?></td>
  						<td><?php echo ConvertSqlDate($data['date']); ?></td>
              <!-- <td><?php echo $s->getField('tpl_breakdown_mgmt','id',$data['job_card_id'],'tt_no'); ?></td> -->  				 
  						<td><select name="store" id="store_<?php echo $i; ?>" id="store"  >
    						<!-- <option value="0">Select</option> -->
    						<?php
		      					 $sql_store12 ="SELECT  id, StoreCode, StoreName FROM storetype where store_type='M' and id='".$data['from_store']."'  ";
		 	 					$resultStkLocs12 = DB_query($sql_store12,$db);
		 	 					while ($storedata=DB_Fetch_array($resultStkLocs12)) {
                  ?>
		 	 						<option value="<?php echo $storedata['id'];  ?>"><?php echo $storedata['StoreName']; ?></option>
		 	 				<?php }?>
    						</select></td>
              <td><?php  $sql_store12 ="SELECT  id, StoreCode, StoreName FROM storetype where store_type='M' and id='".$data['to_store']."'  ";
                $resultStkLocs12 = DB_query($sql_store12,$db);
                while ($storedata=DB_Fetch_array($resultStkLocs12)) {                  
                  }?><select name="store" id="store_<?php echo $i; ?>" id="store">
                <!-- <option value="0">Select</option> -->
                <?php
                     $sql_store12 ="SELECT  id, StoreCode, StoreName FROM storetype where store_type='M' and id='".$data['to_store']."'  ";
                $resultStkLocs12 = DB_query($sql_store12,$db);
                while ($storedata=DB_Fetch_array($resultStkLocs12)) {
              ?>
                  <option value="<?php echo $storedata['id'];  ?>"><?php echo $storedata['StoreName']; ?></option>
              <?php }?>
                </select></td>
  						<td class="text-center"><input type="button" id="button_<?php echo $i; ?>" value="Create" class="search" onclick="loadData('<?php echo $_REQUEST['frmid'] ?>','<?php echo $_REQUEST['modid'];?>','<?php echo $data['id']?>',this.id);" /></td> 
  					</tr>  					 
  				<?php 
  				$i++;}
  			}
  			else
  			{?>
  				<tr><td colspan="4"><strong>No Record Found</strong></td></tr>
  			<?php 
  			}
  	?>  
</table>
</form>
 
</div></div> 
<script type="text/javascript">
	function loadData(frmid,modid,id,ids)
	{
	    var idk=ids.split('_');
	    var store=document.getElementById('store_'+idk[1]).value;
	    if(store=='0')
	    {
	    	alert("Please select store");
	    	return false;
	    }
		window.location.href="index.php?route=Inventory/transation/process_Issue_slip_add&modid="+modid+"&frmid="+frmid+"&action=add&mrsid="+id+"&store="+store;
	}

</script>
