

         <script type="text/javascript">
  
		
		 $(document).on("click", "#managebtndelete", function()
        {
          var itemid = $(this).data('id');
		  $("#itemid1").val(itemid); 
		  
		  
		   
        });
		$(document).on("click", "#editbtn", function()
        {
          var mycategoryid = $(this).data('id');
		  $("#mycategoryid").val(mycategoryid); 
		   
		   		      var type = $(this).data('type');
		   $("#type").val(type);
   var maincategory = $(this).data('maincategory');
		   $("#maincategory").val(maincategory);
 
		    var name = $(this).data('name');
		   $("#name").val(name); 
		   
		     var description = $(this).data('description');
		   $("#description").val(description); 
		   var status = $(this).data('status');
		   $("#status").val(status); 
		  
		     var commission = $(this).data('commission');
		   $("#commission").val(commission); 
		 
		   var shipping = $(this).data('shipping');
		   $("#shipping").val(shipping);
		  
		   
        });
		
		
		

    </script>   
 
 <div class="row">
  
   	

   	<div class="col-md-12">
	
  
		<div class="panel panel-default" data-collapsed="0">
        	<div class="panel-heading">
																		  VIEW LOWEST CATEGORY OF PRODUCTS( No.2)

            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>
										                     <a data-toggle='modal' data-target='#addModal' class="btn btn-primary">Add Sub Category/group </a>
 <a href="<?php echo base_url();?>user/downloadcproductscategory" class="btn btn-primary">Download    category </a>	 
					 <a data-toggle='modal' data-target='#uploadModal' class="btn btn-success">Category Bulk upload  </a>

						 <a href="<?php echo base_url();?>user/viewmaincategory" class="btn btn-success">  View Main Category</a>	

						 <a href="<?php echo base_url();?>user/viewcustomedproductcategory" class="btn btn-info"> View  Customized Category  </a>	
					 <a data-toggle='modal' data-target='#uploadbulkModal' class="btn btn-danger">Bulk upload and update  </a>


            	</div>
            </div>
			<div class="panel-body">

				<div class="widget-content nopadding table_holder table-responsive" >				
	<?PHP

 $session_data = $this->session->userdata('logged_in');

   
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];

 $data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
	  echo $this->session->flashdata('deletemsg'); 

				echo $this->session->flashdata('msg'); 
								?>	
										
					<div class="row">
						<div class="col-md-12">
							
							<div class="panel-body">
	
									
									
  <table cellpadding="0" cellspacing="0" border="0" class="table  table-striped" id="example" style="border-color:#CCCCCC; width:100%;"  >

             <thead>
         <tr>
     <th>NO</th>
     <th>Name</th>
	      <th>Order No</th>

	 <th>Main Category</th>
	  
<th>Status</th>		

<th>Type</th>
<th>Comm</th>		

		
<th>Shp Cost</th>		

 
		
	<th>More</th>	

                 </tr>
             </thead><tbody>
<?php
 if(!is_array($viewproductcategory)) {

			 }else{

    
       
  
  	foreach ($viewproductcategory as $c): 

		 

             ?>



             <tr>
                
            <?php 
$id=$c->id;


?>

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

  <td><?php echo $c->name ; ?></td>
    <td><?php echo $c->description ; ?></td>

     <td><?php 
	$category=$c->maincategory;
	
	$mycategory = $this->usermodel->populateall('maincategory','id',$category);
	


if(is_array($mycategory)) {

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


}} else {
    echo 'N/a .';
}
	
	
?>
</td>
  
  
  
  
  
  
  
	  <td><?php echo $c->status ; ?></td>
	  	  	  <td><?php echo $c->type ; ?></td>
	  	  <td><?php echo $c->commission ; ?></td>

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

	  

	 <td> 

 
 
					<div class="btn-group">
                                    <button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown">
                                        More <span class="caret"></span>
                                    </button>
									
                                    <ul class="dropdown-menu dropdown-primary pull-right" role="menu">
                                        
                                        <!-- teacher EDITING LINK -->
                                      
										<?php
										if($usertype=="admin"){
											
											?>
											<!--
											  <li> 
										 <a class="btn btn-danger managebtn" id="managebtndelete"		 data-id='<?php echo  $c->id;?>'    data-toggle='modal' data-target='#myModal<?php  $c->id; ?>'>	 


                                                <i class="glyphicon glyphicon-pencil"></i>
																Delete
                                                </a>
                                                        </li>
									-->
									
                                        <li class="divider"></li>
                                        
                                     	  <li> 


	 <a class="btn btn-primary editbtn" id="editbtn"  data-type='<?php echo  $c->type;?>'  data-commission='<?php echo  $c->commission;?>'  data-status='<?php echo  $c->status;?>'  data-shipping='<?php echo  $c->shipping;?>'data-name='<?php echo  $c->name;?>' data-maincategory='<?php echo  $c->maincategory;?>'   data-description='<?php echo  $c->description;?>'  data-id='<?php echo  $c->id;?>' data-toggle='modal' data-target='#editProductModel'> 	 

                                                <i class="glyphicon glyphicon-pencil"></i>
																Update
                                                </a>
                                                        </li>
															<?php
										}
										?>
										      <li class="divider"></li>
                                           
                                     	  <li> 
	 	 <a  id="more" class="btn btn-success" href="<?php echo base_url();?>user/viewmainstockreportcategory?randomitemidentifier=<?php   {echo  $c->id ;}  ?>&type=main">


                                                <i class="glyphicon glyphicon-pencil"></i>
															View this sub category in Main Store 
                                                </a>
                                                        </li>
												<li class="divider"></li>
													  <li> 
	 	 <a  id="more" class="btn btn-info" href="<?php echo base_url();?>user/viewstockreportcategory?randomitemidentifier=<?php   {echo  $c->id ;}  ?>&type=sub">


                                                <i class="glyphicon glyphicon-pencil"></i>
																	View this sub category in	Counter/Branch  
                                                </a>
                                                        </li>
                                    </ul>
										
                                </div>
</td>
		 
		 
		 
             </tr>

	<?php endforeach;} ?>

             
<tbody>
        </table>

									
									
									
					</div>	

					
					
						<div id="uploadbulkModal" 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 Correct Products Category data(CSV)</h4>
		
      </div>
      <div class="modal-body">
      
	  	

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/updateall' , 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/viewproductcategory"id="view" class="form-control" required placeholder="Enter view">
	
	
	<div class="form-group">
    <label for="inputsurname" class="col-sm-2 control-label">	CSV 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 CSV File  here..<?php echo form_error('file'); ?>
		
		</span>
	</div>
  </div>	
  
	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="products" name="btn_uploadall" class="btn btn-primary">Upload All </button>

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

    

				</div>

		</div>
	    </div>
    </div>
					
					
					
						<div id="uploadModal" 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 Correct Products Category data(CSV)</h4>
		
      </div>
      <div class="modal-body">
      
	  	

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/uploadcategoryproducts' , 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/viewproductcategory"id="view" class="form-control" required placeholder="Enter view">
	
	
	<div class="form-group">
    <label for="inputsurname" class="col-sm-2 control-label">	CSV 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 CSV File  here..<?php echo form_error('file'); ?>
		
		</span>
	</div>
  </div>	
  
	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="products" name="btn_uploadcategoryproducts" class="btn btn-primary">Upload products Category </button>

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

    

				</div>

		</div>
	    </div>
    </div>
<div id="editProductModel" 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">Update Sub-Category/group</h4>
      </div>
      <div class="modal-body">
      
	  	

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


$imgid = $userid.time();

				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/updateproductcategory' , 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="mycategoryid" value=""id="mycategoryid" class="form-control" required placeholder="Enter mycategoryid">
			  		<input type="hidden" name="imgid" value="<?php echo $imgid ?>"id="imgid" class="form-control" required placeholder="Enter bookid">
	
	<div class="form-group">
    <label for="inputname" class="col-sm-2 control-label">	Name </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="name" value="<?php echo set_value('name'); ?>" id="name" class="form-control" required placeholder="Enter name">
		 
				
		<span class="text-danger"> <?php echo form_error('name'); ?>
		
		</span>
	</div>
  </div>
  
  
  <div class="form-group">
    <label for="inputviewmaincategory" class="col-sm-2 control-label">Main Category?</label>
    <div class="col-sm-10">
	<select class="form-control" name="maincategory"  id="maincategory" >
	
		<option value=""  >Na</option>

	
	<?php 
					 

					 


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

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



	<?php

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

	</div>
  </div>
  
  	 <div class="form-group">
    <label for="inputtype" class="col-sm-2 control-label">Commission type?</label>
    <div class="col-sm-10">
	<select class="form-control" name="type" id="type" >
			<option value="" selected="selected"  ></option>

		<option value="Percentage" >Percentage</option>
		<option value="Amount"  >Amount</option>

	

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

	</div>
  </div>
  
  <div class="form-group">
    <label for="inputcommission" class="col-sm-2 control-label">Commission (%/Amt)</label>
    <div class="col-sm-10">
		  		<input type="text" name="commission" value="<?php echo set_value('commission'); ?>" id="commission" class="form-control" required placeholder="Enter commission">

			
		<span class="text-danger"> <?php echo form_error('commission'); ?>
		
		</span>
	</div>
  </div><div class="form-group">
    <label for="inputshipping" class="col-sm-2 control-label">Shipping Cost</label>
    <div class="col-sm-10">
		  		<input type="text" name="shipping" value="<?php echo set_value('shipping'); ?>" id="shipping" class="form-control"  placeholder="Enter shipping cost">

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

	<div class="form-group">
    <label for="inputdescription" class="col-sm-2 control-label">	Order / Priority No</label>
    <div class="col-sm-10">
		  		<input type="text" name="description" value="<?php echo set_value('description'); ?>" id="description" class="form-control"  placeholder="Enter Order / Priority No">

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

	 <div class="form-group">
    <label for="inputstatus" class="col-sm-2 control-label">Status?</label>
    <div class="col-sm-10">
	<select class="form-control" name="status" id="status" required>
			<option value="" selected="selected"  ></option>

		<option value="active" >Active</option>
		<option value="inactive"  >Inactive</option>
		<option value="hide"  >Hide</option>

	

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

	</div>
  </div>


	
	
	
	
	
	
	
	 
	<div class="form-group">
    <label for="inputphoto" class="col-sm-2 control-label">	Upload Image</label>
    <div class="col-sm-10">

	

	<input type="file" name="photo" value="<?php echo set_value('photo'); ?>"id="photo" class="form-control"  placeholder="Please upload image if any">
			<span class="text-danger"> <?php echo form_error('photo'); ?>
		
		</span>
	</div>
		</div>
	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="category" name="btn_updatecategory" class="btn btn-primary"> Update Category   </button>

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

    

				</div>

		</div>
	    </div>
    </div>
					
					
					
					
					
					
					
					
					
					
					
					
						<div id="myModal" 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">Delete</h4>
      </div>
      <div class="modal-body">
        <h3>Are you sure you want to delete this item? </h3>
      </div>
      <div class="modal-footer">
	  	

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

		
                 echo form_open('user/deletebyid' , 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;?>
 <input type="hidden" id="table"name="table" class="table" placeholder="view" value="productcategory">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="user/viewproductcategory">
 <input type="hidden" id="itemid1"name="itemid" class="itemid" placeholder="itemid" value=""><br>
 <button type="button" class="btn btn-success" data-dismiss="modal">No</button>
 		  	         <button type="submit" name="btn_delete" value="deletebyid" class="btn btn-danger"> Delete  </button>

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

  </div>

  </div>	

  
<div id="addModal" 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">Add new sub product category</h4>
      </div>
      <div class="modal-body">
      
	  	

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

				echo $this->session->flashdata('deletemsg'); 


				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/addproductcategory' , 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/viewproductcategory"id="view" class="form-control" required placeholder="Enter status">




				  		
	<div class="form-group">
    <label for="inputname" class="col-sm-2 control-label">	Name </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="name" value="<?php echo set_value('name'); ?>" class="form-control" required placeholder="Enter name">
		 
				
		<span class="text-danger"> <?php echo form_error('name'); ?>
		
		</span>
	</div>
  </div>

  
  <div class="form-group">
    <label for="inputmaincategory" class="col-sm-2 control-label">Main Category?</label>
    <div class="col-sm-10">
	<select class="form-control" name="maincategory"  >
		<option value=""  >---Select Sub-category---</option>

		<option value=""  >Na</option>

	
	
	<?php 
					 

					 


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

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



	<?php

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

	</div>
  </div>
  
  
	<div class="form-group">
    <label for="inputdescription" class="col-sm-2 control-label">	Order / Priority No</label>
    <div class="col-sm-10">
		  		<input type="text" name="description" value="<?php echo set_value('description'); ?>" class="form-control"  placeholder="Enter Order / Priority No">

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

	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="category" name="btn_addproductcategory" class="btn btn-primary"> Add Category   </button>

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

    

				</div>

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





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

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

 
</div>


















