<link href="<?php echo base_url(); ?>assets/autocomplete/jquery-ui.css" rel="stylesheet">
    <link href="<?php echo base_url(); ?>assets/autocomplete/ui.theme.css" rel="stylesheet">
    <link href="<?php echo base_url(); ?>assets/autocomplete/autocomplete.css" rel="stylesheet">
	
	
	<script type="text/javascript">
   $(this).ready( function() {  
            $("#searchterm").autocomplete({  
 
                minLength: 1,  
                source:   
                function(req, add){  
                    $.ajax({  
			url: "<?php echo base_url(); ?>Systemusers/branchlookupstocktaking", 
			//url: "<?php echo base_url(); ?>Systemusers/branchlookpurchase", 

                        //url: "<?php echo base_url(); ?>Systemusers/productlistlookup",  
                        dataType: 'json',  
                        type: 'POST',  
                        data: req,  
                        success:      
                        function(data){  
                            if(data.response =="true"){  
                                add(data.message);  
                                console.log(data);
                            }  
                        },  
                    });  
                },  
                     
            });  
        });  
		

		
    </script>   
<script>
	function printDiv(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

    // document.body.innerHTML = printContents.fontsize(12);
     window.print();

	 if( window.print()) {
         window.location.href = "../user/viewtocktaking";
		alert(" printing...........");
    }else {

	
		      return      window.location.href = "../user/viewtocktaking";

		    // document.body.innerHTML = originalContents;

	}
}


  
	</script>

         <script type="text/javascript">
  
		
		 $(document).on("click", "#managebtndelete", function()
        {
          var itemid = $(this).data('id');
		  $("#itemid1").val(itemid); 
		  
		  
		   
        });
		
		
		
    </script>   
  <style type="text/css">
  
  

    #printable { display: none; }
#print{  	


    background-repeat: no-repeat;
	font-size;20px;
  
    width:100%; 


}

#sale{  	


    background-repeat: no-repeat;
  
    width:100px; height:50px;


}
    @media print
    {
    	#non-printable { display: none; }
    	#printableArea { display: block; font-size:16; width:100%; }
    }
    </style>
 
 <div class="row">
  
   	

   	<div class="col-md-12">

  
		<div class="panel panel-default" data-collapsed="0">
        	<div class="panel-heading" id="non-printable">
            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>
				 <span class="pull-right"> VIEW STOCK TAKING REPORT</span>
                        <a  id="more"  class="btn btn-default" href="<?php echo base_url();?>user/viewproductlist">Back   </a>
						                        <a  id="more"  class="btn btn-default" href="<?php echo base_url();?>user/viewopeningstock">Back to Opening/closing Stock   </a>

		  <a  id="more"  class="btn btn-default" href="<?php echo base_url();?>user/viewstocktakingreport">Refresh </a>
 	 <a data-toggle='modal' data-target='#opentockModal' class="btn btn-default">Start  stock taking </a>

		 						 <a data-toggle='modal' data-target='#IncomingModal' class="btn btn-default">Stock Taking Report</a>
		 						 <a data-toggle='modal' data-target='#serialModal' class="btn btn-default">Scan Serial No  </a>
  <a data-toggle='modal' data-target='#uploadstocktakingModal' class="btn btn-default">Upload Stock Taking  </a>


				 		 	<div class="pull-right"  >

<form name="print" method="post" action="">
 <input type="submit" id="print"  accesskey="p" class="btn btn-default"  name="print"onclick="printDiv('sortable_table')" value="print receipt!" />
</form></div>
            	</div>
            </div>
			<div class="panel-body">

			
				<?PHP
function formatMoney($number, $fractional=false) {
						if ($fractional) {
							$number = sprintf('%.2f', $number);
						}
						while (true) {
							$replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);
							if ($replaced != $number) {
								$number = $replaced;
							} else {
								break;
							}
						}
						return $number;
					}
 $session_data = $this->session->userdata('logged_in');

   		
$mydate=date('Y-m-d');
$mytime=date('H:i:s');
 	 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
$data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
	
		 
	 $data['branchid'] = $session_data['branchid'];
	 $branchid = $data['branchid'];
	 				echo $this->session->flashdata('deletemsg'); 
	 				echo $this->session->flashdata('postedtime'); 

				echo $this->session->flashdata('msg'); 
				  $viewbprice=$this->usermodel->populatuserpermissionsdataarray('productlist','viewbprice',$userid);

								?>	
					<div class="row">
						<div class="col-md-12">
							
							<div class="panel-body">
	
									<div class="col-md-12">
														<div class="widget-content nopadding table_holder table-responsive" >				

        <?php 
		
        $attr = array("class" => "form-horizontal", "role" => "form", "id" => "search", "name" => "search");
        echo form_open("user/searchallstocktaking", $attr);?>
            <div class="form-group">
			
                <div class="col-md-3">
                    <input class="form-control" id="searchterm" autofocus name="searchterm" placeholder="Search for product by name, code,description.." type="text" value="<?php echo set_value('searchterm'); ?>" />
                </div>
				
				
				    <div class="col-md-2">
		  		<input type="text" name="startdate" value="<?php echo set_value('startdate',$mydate); ?>" class="form-control" required placeholder="Enter from date?">

					</div>
				
				
				
				  <div class="col-md-2">
		  		<input type="text" name="closedate" value="<?php echo set_value('closedate',$mydate); ?>" class="form-control" required placeholder="Enter to date?">

					</div>
					  <div class="col-md-2">
<select class="form-control" name="branchid"  id="branchid" required>
	
	
	<option value=""  >---Select Branch/Counter to Open--</option>

									
					<option value="all"   >All branches/Counters</option>
																			<option value="Main Store"  >Main Store</option>

								
<?php
	     $mybranch=$this->usermodel->populateall('branch','id',$branchid);


if(is_array($mybranch)) {

   foreach($mybranch as $branchrow){

   ?>
					<option  selected="selected" value="<?=  $branchrow->id;   ?>"><?=  $branchrow->name; ?></option>




	<?php

}} else {
    echo 'No Branch available.';
}
	
?>
	
	
	
	
	
	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('branch','companyid',$companyid);


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

   //echo $courserow->coursename;
    ?>
					<option  value="<?=  $maincategoryrow->id;   ?>"><?=  $maincategoryrow->name; ?></option>



	<?php

}} else {
    echo 'No main counter available.';
}
	
?>
</select>
					</div>
				
				
				
				
				
                <div class="col-md-3">
                    <input id="btn_search" name="btn_search" type="submit" class="btn btn-default" value="Search" />
                    <a href="<?php echo base_url(). "user/viewtocktaking"; ?>" class="btn btn-default">Refresh</a>
                </div>
				 
            </div>
        <?php echo form_close(); ?>

        </div>	
					
				<table class="tablesorter table table-bordered  table-hover" id="sortable_table" width="100%">			

             <thead>
         <tr>
     <th>Code</th>
     <th>Product Name</th>
	
	     <th>Category</th>

	 <th>Available</th>
	 	  <th>B.Price</th>

	  <th>S.Price</th>
		   <th>Actual qty</th> 
		   <th>Difference</th> 
	
<th>Branch</th>
<th>Start Date</th>
<th>Close Date </th>
<th>Staff</th>
<th id="non-printable">Update</th>

<th id="non-printable">Adjust</th>
<th id="non-printable">More</th>

			  </tr>
             </thead>
<?php
 
 




 if(!is_array($viewproducts)) 

 {


   echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='10'>";
    
       echo '<div class="alert alert-default text-center">There no records found..</div>';
    echo "</td>";
   echo "</tr>";
    }else {
?>
    
             <?php 
  
  $totalsales=0;
   
  	foreach ($viewproducts as $c): 

		


             ?>

							 
										<?php
					
		
                 echo form_open('user/updatestocktaking' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>	
							<input type="hidden" name="view" value="user/viewtocktaking" class="form-control" required placeholder="Enter view">
							<input type="hidden" name="myid" value="<?php echo set_value('myid',$c->id); ?>" class="form-control" required placeholder="Enter id">

							<input type="hidden" name="branchid" value="<?php echo set_value('branchid',$c->branchid); ?>" class="form-control" required placeholder="Enter branchid">
							<input type="hidden" name="open" value="<?php echo set_value('open',$c->open); ?>" class="form-control" required placeholder="Enter qty available">
							<input type="hidden" name="code" value="<?php echo set_value('code',$c->code); ?>" class="form-control" required placeholder="Enter code">
							<input type="hidden" name="startdate" value="<?php echo set_value('startdate',""); ?>" class="form-control" required placeholder="">

             <tr>
                
            <?php 
$id=$c->id;
$myaty="0";
$myaty=$c->open ;
$totalsales=$totalsales+$c->balance;

?>

              
  <td><?php echo $c->code ; ?></td>
    <td><?php 
	 $mycode=$c->code;
	  $userid=$c->userid;
   if($mycode!=""){
	  
      $productname = $this->usermodel->geteproductbyid($mycode);
  
     echo$name=$productname[0]['name']."  ". $description=$productname[0]['description'];

	
   }else{
	    echo "No Product";  
   }
  
	?>
<input type="text" name="description" value="<?php echo set_value('description',$c->description); ?>" class="form-control2"  placeholder="Enter Remarks">

	</td>

    <td><?php 
	$buyingprice="";
	  if($c->branchid==0){
	
				$myproducts  = $this->usermodel->populateallarray('products','code',$mycode);

	}else{
		 $myproducts = $this->usermodel->populatealldataarray('productlist','code', $mycode,'branch', $c->branchid);
	
	}
	$myname=$myproducts[0]['name'];
		$mysellingprice=$myproducts[0]['sellingprice'];
			$buyingprice=$myproducts[0]['buyingprice'];

	if($mycode!=""){
	  
      $productname = $this->usermodel->geteproductbyid($mycode);
  
     $category=$productname[0]['category'];

	

	
	
	$mycategory = $this->usermodel->populatecategorybyowner($category);
	


if(is_array($mycategory)) {

   foreach($mycategory as $mycategoryrow){
		echo $mycategoryrow->name;


}} else {
    echo 'No Category .';
}
	   }else{
	    echo "No Product";  
   }
  

$myuser=$this->usermodel->geteuser($c->userid);
    $myname=$myuser[0]['firstname'];

?>
</td>
	
  <td><?php echo $c->open ; ?></td>
  
  
  
  
  
  
  
  
  
  
  <td>
  	  	<?php

	
 if( $viewbprice==true){
	 ?>
	 		  						 <input type="hidden" name="buyingprice" id="non-printable" value="<?php echo set_value('buyingprice',$buyingprice); ?>" class="form-control" required placeholder="buying price" >

	 	<?php	

 }else{
	 ?>
		 <input type="text" name="buyingprice" id="non-printable" value="<?php echo set_value('buyingprice',$buyingprice); ?>" class="form-control" required placeholder="buying price" >

	 
	 <?php
 }
  ?>
  
  

</td>
    <td>
	
	
		  					<input type="text" name="sellingprice" id="non-printable" value="<?php echo set_value('sellingprice',$mysellingprice); ?>" class="form-control" required placeholder=" selling price" >

		  </td> 
 
		   <td>
		  					<input type="text" name="added" id="non-printable"  value="<?php echo set_value('added',$c->added); ?>" class="form-control" required placeholder="sold adjusted qty" >

		  </td> 
      <td><?php echo $c->balance; ?></td>  
  

												 
			  <td><?php
			  if($c->branchid==0){
				  echo "Main Store";
				  
			  }else{
				  
			 
								$mybranch = $this->usermodel->populateallarray('branch','id',$c->branchid);
					echo$branchname=$mybranch[0]['name'];
 }
		?></td> 									 
				  <td><?php echo $c->startdate; ?></td> 											 
									 
						<td><?php echo $c->closedate; ?></td> 							 
											   
			      <td><?php 
				  $myid="";
				  $updatedby=$c->updatedby;
				  if($updatedby==0){
					    $myid=$userid;
					  
				  }else{
					  $myid=$updatedby;

					  
				  }
				
		 $myuser=$this->usermodel->geteuser($c->userid);
			echo $myname=$myuser[0]['firstname'];
				  ?></td>  
	  <td id="non-printable">
									  
	<select class="form-control" name="mybranch" >
	
	
	
	
	
	<option value=""  >---Select branch--</option>
			<option value="all"  >-Store and Branches-</option>
											<option value="Main"  >Main Store</option>

<?php
if($c->branchid=="0"){
	?>
											<option selected value="0"  >Main Store</option>
	
<?php
}

	     $mybranch=$this->usermodel->populateall('branch','id',$c->branchid);


if(is_array($mybranch)) {

   foreach($mybranch as $branchrow){

   ?>
					<option selected="selected" value="<?=  $branchrow->id;   ?>"><?=  $branchrow->name; ?></option>




	<?php

}} else {
    echo 'No Branch available.';
}
	
?>

</select>

					  
 </td>
 <td id="non-printable">
 <button type="submit"  value="stocktaking" name="btn_updatestocktaking" class="btn btn-default"> <span class="glyphicon glyphicon-pencil">Adjust </button>

 </td>
 
 <td id="non-printable">
 
 
					<div class="btn-group">
                                    <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
                                        More <span class="caret"></span>
                                    </button>
									
                                    <ul class="dropdown-menu dropdown-default pull-right" role="menu">
                                        
                                        <!-- teacher EDITING LINK -->
                                      
											<li> 
	
	 	 <a  id="more" target="_blank" class="btn btn-default" href="<?php echo base_url();?>user/viewcountedserials?randomitemidentifier=<?php   {echo  $c->code ;}  ?>&branch=<?php   {echo  $c->branchid ;}  ?>&startdate=<?php   {echo  $c->startdate ;}  ?>">

                                        <i class="glyphicon glyphicon-pencil"></i>
															View counted serials Numbers
                                                </a>
												
                                                        </li> 
										
                                        <li class="divider"></li>
                                        
												<li> 
				<a  id="more" target="_blank"class="btn btn-default" href="<?php echo base_url();?>user/viewmissingserials?branch=<?php   {echo  $c->branchid;}  ?>&mycode=<?php   {echo  $c->code;}  ?>&startdate=<?php   {echo  $c->startdate ;}  ?>"> 


                                                <i class="glyphicon glyphicon-pencil"></i>
															View Missing Serial Numbers
                                                </a>
                                                        </li> 
                                        <li class="divider"></li>

										
																							
                                    </ul>
										
                                </div>
 </td>
 <?php echo form_close();?>	
		 
		 	
			</tr>

	<?php endforeach;} ?>

			  
		

			  <tr border="1" background="green">
									<td colspan="2"><b>Total</b></td>
									<td colspan="3"></td>
		<td  colspan="5" style="background:#999999 ; width:100px" ><b><?php if(isset($totalsales)) {echo $totalsales;   }?></b></td>

							
</tr>

        </table>
			  <div class="col-md-12 text-center">    <?php echo $links; ?>
					   		<span style="color:red; font-size:20px"><?php  echo $total_rows. "  Records in the system. " ;?>    </span>

        
        </div>	
	</div>

		
	
	
	
	
	<div id="opentockModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Start  stock taking</h4>
      </div>
      <div class="modal-body">
        <h3>Are you sure you want to start taking the stock? </h3>
      </div>
      <div class="modal-footer">
	  	

     
		<?PHP
				$session_data = $this->session->userdata('logged_in');
 echo $this->session->flashdata('deletemsg'); 

		
                 echo form_open('user/starttakingbranchstock' , array('class' => 'form-horizontal ', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>


	
  <div class="form-group">
    <label for="inputbranchname" class="col-sm-2 control-label">Counter/branch</label>
    <div class="col-sm-10">
	<select class="form-control" name="branchid"  id="branchid" required>
	
	
	<option value=""  >---Select one Branch/Counter to Open--</option>

									
											<option value="Main"  >Main Store</option>
		

	
	
	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('branch','companyid',$companyid);


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

   //echo $courserow->coursename;
    ?>
					<option selected="selected" value="<?=  $maincategoryrow->id;   ?>"><?=  $maincategoryrow->name; ?></option>



	<?php

}} else {
    echo 'No main counter available.';
}
	
?>
</select>

		
	</div>
  </div>

	  <div class="form-group">
    <label for="inputorderamount" class="col-sm-2 control-label">Product Type</label>
    <div class="col-sm-10">
	<select class="form-control" name="orderamount" >
	
		<option value=""  >---Select Product Type---</option>
				<option value="all"  selected="selected" >All items/products</option>

		<option value="mainitem"   >Main-item</option>
		<option value="production"  >Production-item</option>
		<option value="subitem"  >Sub-item</option>
		<option value="accompaniment"  >Accompaniment</option>


	

</select>
		
						<span class="text-danger"><?php echo form_error('orderamount'); ?>

	</div>
  </div>
	
	
	
	
	 <div class="form-group">
    <label for="inputproducttype" class="col-sm-2 control-label">Inventory Type?</label>
    <div class="col-sm-10">
	<select class="form-control" name="producttype" required>
		<option value="all"  selected="selected" >---All Inventory Type---</option>

		<option value="" >---Select Product Type---</option>
		<option value="Inventory"   >Inventory</option>
		<option value="None Inventory"  >None Inventory </option>
		<option value="Service"  >Service</option>


</select>
		
						<span class="text-danger"><?php echo form_error('status'); ?>

	</div>
  </div>
  
  
  
  

     <div class="form-group">
    <label for="inputcategory" class="col-sm-2 control-label">Category?</label>
    <div class="col-sm-10">
	<select class="form-control" name="category" required>
	
	<option value=""  >---Select Category---</option>
	<option value="all"  selected="selected" >---All Category---</option>

	
	<?php 
					 
			//$mycategory = $this->usermodel->populateproductcategorybyid($companyid);
						 		$mycategory = $this->usermodel->populatealldatawhere('productcategory','name','ASC','companyid',$companyid);



if(is_array($mycategory)) {

   foreach($mycategory as $mycategoryrow){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $mycategoryrow->id;   ?>"><?=  $mycategoryrow->name; ?></option>



	<?php

}} else {
    echo 'No category available.';
}
	
?>
</select>
		
						<span class="text-danger"><?php echo form_error('category'); ?>

	</div>
  </div>
  	

  
  
  
  
  
  
  <div class="form-group">
    <label for="inputfromdate" class="col-sm-2 control-label">Start Date </label>
    <div class="col-sm-10">
	
		  		<input type="date" name="startdate" value="<?php echo set_value('startdate',$mydate); ?>" class="form-control" required placeholder="Enter start date">
		 
						  		<input type="hidden" name="postedtime" value="<?php echo set_value('postedtime',$mytime); ?>" class="form-control" required placeholder="Enter start time">

		<span class="text-danger"> <?php echo form_error('fromdate'); ?>
	Time:	<?php echo $mytime; ?>

		</span>
	</div>
  </div>
  



	 <div class="form-group">
    <label for="inputproductstatus" class="col-sm-2 control-label">Deactivate Items during stock taking?</label>
    <div class="col-sm-10">
	<select class="form-control" name="productstatus" required>
		<option value=""  selected="selected" >---Do you want to deactivate the items during stock taking?---</option>

		<option value="" >---Select Oe--</option>
		<option value="inactive"   >Deactivate Items</option>
		<option value="no"  selected >No Change</option>


</select>
		
						<span class="text-danger"><?php echo form_error('productstatus'); ?>

	</div>
  </div>
  



 <input type="hidden" id="table"name="table" class="table" placeholder="view" value="products">

<input type="hidden" name="type" value="product"id="type" class="form-control" required placeholder="Enter type">
				<input type="hidden" name="view" value="user/viewproducts" id="view" class="form-control" required placeholder="Enter view">

 <input type="hidden" id="itemid1"name="itemid" class="itemid" placeholder="itemid" value=""><br>
 <button type="button" class="btn btn-default" data-dismiss="modal">No</button>
 		  	         <button type="submit" name="startstock" value="start" class="btn btn-default"> Start Now  </button>

	<?php echo form_close();?>
      </div>
    </div>

  </div>

  </div>				
	
	
	
	
	
	
	
	<div id="downloadModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Download stock</h4>
      </div>
      <div class="modal-body">
        <h3>Are you sure you want to download  the stockshit with this stock taking date? </h3>
      </div>
      <div class="modal-footer">
	  	

     
		<?PHP
				$session_data = $this->session->userdata('logged_in');
 echo $this->session->flashdata('deletemsg'); 

		
                 echo form_open('user/downloadstocktaking' , array('class' => 'form-horizontal ', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>


	
  <div class="form-group">
    <label for="inputbranchname" class="col-sm-2 control-label">Counter/branch</label>
    <div class="col-sm-10">
	<select class="form-control" name="branchid"  id="branchid" required>
	
	
	<option value=""  >---Select Branch/Counter to Open--</option>

									
					<option value="all"  >All branches/Counters</option>
								
<option value="Main Store"  >Main Store</option>
	
	
	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('branch','companyid',$companyid);


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

   //echo $courserow->coursename;
    ?>
					<option selected="selected" value="<?=  $maincategoryrow->id;   ?>"><?=  $maincategoryrow->name; ?></option>



	<?php

}} else {
    echo 'No main counter available.';
}
	
?>
</select>

		
	</div>
  </div>

	<div class="form-group">
    <label for="inputdepartment" class="col-sm-2 control-label">Department</label>
    <div class="col-sm-10">
	<select class="form-control" name="department"  id="department" required>
	
	
	<option value=""  >---Select department to Open--</option>

									
					<option value="all" selected="selected" >All departments</option>
								

	
	
	<?php 
					 
					 		$maindepartment = $this->usermodel->populateall('maincategory','companyid',$companyid);


							


if(is_array($maindepartment)) {

   foreach($maindepartment as $maindepartmentrow){

   //echo $courserow->coursename;
    ?>
					<option  value="<?=  $maindepartmentrow->id;   ?>"><?=  $maindepartmentrow->name; ?></option>



	<?php

}} else {
    echo 'No departmentrow counter available.';
}
	
?>
</select>

		
	</div>
  </div>
  <div class="form-group">
    <label for="inputstartdate" class="col-sm-2 control-label">Stock taking Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="startdate" value="<?php echo set_value('startdate',$mydate); ?>" class="form-control" required placeholder="Enter start date">
		 
						  		<input type="hidden" name="postedtime" value="<?php echo set_value('startdate',$mytime); ?>" class="form-control" required placeholder="Enter close date">

		<span class="text-danger"> <?php echo form_error('startdate'); ?>
	Time:	<?php echo $mytime; ?>

		</span>
	</div>
  </div>
  







 <input type="hidden" id="table"name="table" class="table" placeholder="view" value="products">

<input type="hidden" name="type" value="product"id="type" class="form-control" required placeholder="Enter type">
				<input type="hidden" name="view" value="user/viewproducts" id="view" class="form-control" required placeholder="Enter view">

 <input type="hidden" id="itemid1"name="itemid" class="itemid" placeholder="itemid" value=""><br>
 <button type="button" class="btn btn-default" data-dismiss="modal">No</button>
 		  	         <button type="submit" name="downtocktaking" value="download" class="btn btn-default"> Download Now  </button>

	<?php echo form_close();?>
      </div>
    </div>

  </div>

  </div>				
	
	
	
	
	
	
	
	
	
			<div id="IncomingModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Stock taking  Report</h4>
      </div>
      <div class="modal-body">
      
	  	

				<?PHP
//$session_data = $this->session->userdata('logged_in');
 //$mydate=date("Y-m-d");
 					 // $mydate=date("Y-m-d H:i:s");
 $fromdate=date("Y-m-d 00:00:00");


				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/viewstocktakingreport' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>

	
	
	
	
  <div class="form-group">
    <label for="inputbranchname" class="col-sm-2 control-label">Counter/branch</label>
    <div class="col-sm-10">
	<select class="form-control" name="branchid"  id="branchid" required>
	
	
	<option value=""  >---Select Branch/Counter to Open--</option>

						<!--			
					<option value="all"  >All branches/Counters</option>
								-->
											<option value="Main"  >Main Store</option>

	
	
	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('branch','companyid',$companyid);


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

   //echo $courserow->coursename;
    ?>
					<option selected="selected" value="<?=  $maincategoryrow->id;   ?>"><?=  $maincategoryrow->name; ?></option>



	<?php

}} else {
    echo 'No main counter available.';
}
	
?>
</select>

		
	</div>
  </div>
  
	
	
	<div class="form-group">
    <label for="inputdepartment" class="col-sm-2 control-label">Department</label>
    <div class="col-sm-10">
	<select class="form-control" name="department"  id="department" required>
	
	
	<option value=""  >---Select department to Open--</option>

									
					<option value="all" selected="selected" >All departments</option>
								

	
	
	<?php 
					 
					 		$maindepartment = $this->usermodel->populateall('maincategory','companyid',$companyid);


							


if(is_array($maindepartment)) {

   foreach($maindepartment as $maindepartmentrow){

   //echo $courserow->coursename;
    ?>
					<option  value="<?=  $maindepartmentrow->id;   ?>"><?=  $maindepartmentrow->name; ?></option>



	<?php

}} else {
    echo 'No departmentrow counter available.';
}
	
?>
</select>

		
	</div>
  </div>
  
	
	  <div class="form-group">
    <label for="inputorderamount" class="col-sm-2 control-label">Product Type</label>
    <div class="col-sm-10">
	<select class="form-control" name="orderamount" >
	
		<option value=""  >---Select Product Type---</option>
				<option value="all" selected="selected"  >All items/products</option>

		<option value="mainitem"  >Main-item</option>
		<option value="production"  >Production-item</option>
		<option value="subitem"  >Sub-item</option>
		<option value="accompaniment"  >Accompaniment</option>


	

</select>
		

	</div>
  </div>
  
    
	<div class="form-group">
    <label for="inputtype" class="col-sm-2 control-label">Transaction Type</label>
    <div class="col-sm-10">
	<select class="form-control" name="type" required >
	
		<option value=""  >---Select Transaction Type---</option>
		<option value="view"   >I want to view stock taken</option>

		<option value="download"   >I want to Download stock taken</option>
		<option value="close"   >I want to close stock taken(Update Stocklist)</option>
		<option value="raw"   >I want to view raw stock (Pending /new)</option>



	

</select>
		

	</div>
  </div>
  
  
  <div class="form-group">
    <label for="inputstartdate" class="col-sm-2 control-label">Open Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="startdate" value="<?php echo set_value('startdate',$mydate); ?>" class="form-control" required placeholder="Enter start date">
		 
				
		<span class="text-danger"> <?php echo form_error('startdate'); ?>
		
		</span>
	</div>
  </div>
  

  
   
	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="event" name="btn_addevent" class="btn btn-default"> View Stock stock  </button>

    </div>
  </div>
  					<?php echo form_close();?>
			</div>							   
				
									
							
								
			<div class="modal-footer">

    

				</div>

		</div>
	    </div>
    </div>	

	
	
	
						<div id="uploadstocktakingModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Please Upload stock taken(CSV)</h4>
		
      </div>
      <div class="modal-body">
        <a href="<?php echo base_url();?>downloads/stocktaking.xlsx" class="btn btn-info">Download   Stock taking  template </a>	 

	  	

				<?PHP
//$session_data = $this->session->userdata('logged_in');



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/uploadstocktaking' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>
<input type="hidden" name="type" value="product"id="type" class="form-control" required placeholder="Enter type">
				<input type="hidden" name="view" value="user/viewpurchases"id="view" class="form-control" required placeholder="Enter view">
	
	  <div class="form-group">
    <label for="inputfromdate" class="col-sm-2 control-label">Stock taking Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="fromdate" value="<?php echo set_value('fromdate',$mydate); ?>" class="form-control" required placeholder="Enter start date">
		 
				
		<span class="text-danger"> <?php echo form_error('fromdate'); ?>
		
		</span>
	</div>
  </div>
  
   <div class="form-group">
    <label for="inputbranchid" class="col-sm-2 control-label"> Branch</label>
    <div class="col-sm-10">
				
				
				<select class="form-control" name="branchid"  id="branchid" required>
	
	
	<option value=""  >---Select Branch/Counter to Open--</option>
	<option value="all"  >---All Branches--</option>

									

								
<?php
	     $mybranch=$this->usermodel->populateall('branch','id',$branchid);


if(is_array($mybranch)) {

   foreach($mybranch as $branchrow){

   ?>
					<option selected="selected" value="<?=  $branchrow->id;   ?>"><?=  $branchrow->name; ?></option>




	<?php

}} else {
    echo 'No Branch available.';
}
	
?>
	
	
	
		<option value="Main"  >Main store(Hq)</option>

	
	
	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('branch','companyid',$companyid);


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $maincategoryrow->id;   ?>"><?=  $maincategoryrow->name; ?></option>



	<?php

}} else {
    echo 'No main counter available.';
}
	
?>
</select>
				
		</div>
  </div>
					
				
				
			
  
  
  
  
  
  
  
	<div class="form-group">
    <label for="inputsurname" class="col-sm-2 control-label"> Excel	 LIST</label>
    <div class="col-sm-10">
		
			<input type="file" name="file" width="400"  value="<?php echo set_value('file') ;?>" placeholder="Select EXCELL" class="form-control" required placeholder="Enter Surname"  >

		  		
				
		<span class="text-danger"> Upload correct format of Excel File  here..<?php echo form_error('file'); ?>
		
		</span>
	</div>
  </div>	
  
	<div class="form-group">
    <label for="inputtype" class="col-sm-2 control-label"> Update type</label>
    <div class="col-sm-10">
				
				
				<select class="form-control" name="type"  id="type" required>
	
	
	<option value=""  >---Select what to update--</option>

				<option value="Stock"  selected="selected" >Update stock Only(Qty)</option>
				<option value="Both"  >Update both stock and prices</option>
								<option value="BothandNames"  >Update both stock, prices and names</option>

<option value="Prices"  >Update Only Prices</option>
			
</select>
				
		</div>
  </div>
					
				
				
			
  

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="stocktaking" name="btn_uploadstocktaking" class="btn btn-default">Upload new stock taking  </button>

    </div>
  </div>
  					<?php echo form_close();?>
			</div>							   
				
									
							
								
			<div class="modal-footer">

    

				</div>

		</div>
	    </div>
    </div>
	
	
	
	
	
	
	
	
			<div id="serialModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Serial Stock taking  Report</h4>
      </div>
      <div class="modal-body">
      
	  	

				<?PHP
//$session_data = $this->session->userdata('logged_in');
 //$mydate=date("Y-m-d");
 					 // $mydate=date("Y-m-d H:i:s");
 $fromdate=date("Y-m-d 00:00:00");


				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/viewstocktakingreportserial' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>

	
	
	
	
  <div class="form-group">
    <label for="inputbranchname" class="col-sm-2 control-label">Counter/branch</label>
    <div class="col-sm-10">
	<select class="form-control" name="branchid"  id="branchid" required>
	
	
	<option value=""  >---Select Branch/Counter to Open--</option>

									
					<option value="all"  >All branches/Counters</option>
								
											<option value="Main Store"  >Main Store</option>

	
	
	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('branch','companyid',$companyid);


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

   //echo $courserow->coursename;
    ?>
					<option selected="selected" value="<?=  $maincategoryrow->id;   ?>"><?=  $maincategoryrow->name; ?></option>



	<?php

}} else {
    echo 'No main counter available.';
}
	
?>
</select>

		
	</div>
  </div>
  
	
	
	
  <div class="form-group">
    <label for="inputstartdate" class="col-sm-2 control-label">Open Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="startdate" value="<?php echo set_value('startdate',$mydate); ?>" class="form-control" required placeholder="Enter start date">
		 
				
		<span class="text-danger"> <?php echo form_error('startdate'); ?>
		
		</span>
	</div>
  </div>
  

  
 

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="event" name="btn_addevent" class="btn btn-default"> View Stock stock  </button>

    </div>
  </div>
  					<?php echo form_close();?>
			</div>							   
				
									
							
								
			<div class="modal-footer">

    

				</div>

		</div>
	    </div>
    </div>	

	
	
	
	
	
	
	

			
			</div>
		</div>
  
  </div>
			
			
			
		
		
  

 
</div>


















