<?php


	 	if ($this->input->post('btn_delete') == "deletebyid")
					   {
						   
						   	 $itemid = $this->input->post("itemid");
		 		



	
			  $usr_result = $this->usermodel->deletebyname("actionid",$itemid,"modulesactions");
			  
			  
		


														
							//check if username and password is correct
							if ($usr_result ==TRUE) //active user record is present
							{
								
								 
						 $this->session->set_flashdata('msg', '<div class="alert alert-info fade in"><a href="#" class="close" data-dismiss="alert">&times;</a>
						 
								<strong>Success!</strong> You have successfully deleted  the module.</div>');	
							redirect('admin/viewmodulesactions');																
							}
							else if ($usr_result ==FALSE) 
							{     

			 $this->session->set_flashdata('msg', '<div class="alert alert-danger fade in"><a href="#" class="close" data-dismiss="alert">&times;</a>
						  <strong>Error!</strong> Module was not deleted.. Try again</div>');
								
								 redirect('admin/viewmodulesactions');
							}
			  
			  
			  
			  
			  
			  
			  
			  
			  



					   }






?>




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


</script>






  <div class="container-fluid">
 
 <div class="row">
		<div class="col-md-12">
  
		<div class="panel panel-primary" data-collapsed="0">
        	<div class="panel-heading">
            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>
				Please Enter Correct Details of the New action Module
            	</div>
            </div>
			<div class="panel-body">

													                     <a data-toggle='modal' data-target='#addModal' class="btn btn-primary">Add Sub Category/group </a>

										
					<div class="row">
						<div class="col-md-12">
							
							<div class="panel-body">
							
					
	
				<?PHP
 echo $this->session->flashdata('msg'); 
		?>
		
		
			<?PHP
				$session_data = $this->session->userdata('adminlogged_in');


		
                 echo form_open('admin/addmoduleaction' , 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="inputmoduleid" class="col-sm-2 control-label">	Module name</label>
    <div class="col-sm-10">
	<select name="moduleid"class="form-control" required>
	<option value=""> Select</Option>
  <?php
  
  
          		$allmodules= $this->usermodel->populatealldata('modules','sort','ASC');


	


if(is_array($allmodules)) {

   foreach($allmodules as $mycategoryrow){
	   
	   
	     ?>

		 <option value="<?php echo$mycategoryrow->id?>" > <?php echo$mycategoryrow->name?></Option>

  <?php
  	
	   
	   
	   }} else {
  
}
	   
	   ?>

	
		</select>		
		<span class="text-danger"> 	<?php echo form_error('moduleid'); ?>
		
		</span>
	</div>
  </div>		
	<div class="form-group">
    <label for="inputactionid" class="col-sm-2 control-label">	Action code</label>
    <div class="col-sm-10">

		  		<input type="text" name="actionid" required value="<?php echo set_value('actionid'); ?>"id="actionid" class="form-control"  placeholder="Enter action actionid">
		 
				
		<span class="text-danger"> 	<?php echo form_error('actionid'); ?>
		
		</span>
	</div>
  </div>	



	<div class="form-group">
    <label for="inputname" class="col-sm-2 control-label">	Action Name</label>
    <div class="col-sm-10">

		  		<input type="text" name="name" required value="<?php echo set_value('name'); ?>"id="name" class="form-control"  placeholder="Enter action Name">
		 
				
		<span class="text-danger"> 	<?php echo form_error('name'); ?>
		
		</span>
	</div>
  </div>	

	
			

	<div class="form-group">
    <label for="inputsort" class="col-sm-2 control-label">	Action Sorting</label>
    <div class="col-sm-10">

		  		<input type="text" required name="sort" value="<?php echo set_value('name'); ?>"id="name" class="form-control"  placeholder="Enter sorting number">
		 
				
		<span class="text-danger"> 	<?php echo form_error('sort'); ?>
		
		</span>
	</div>
  </div>	



  


  
  
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
<button type="submit" name="btn_moduleaction" class="btn btn-primary" value="action">
                                <span class="glyphicon glyphicon-log-in"></span> Add action                           
								 </button>
    </div>
  </div>
			</div>							   
									<?php echo form_close();?>

							
						</div>
					</div>



 <div class="table-responsive">
 
<table id="example"  cellspacing="1" class="table  table" width="100%">
   <thead>
  <tr>

    <th>Action actionid</th>

    <th>Action Name</th>    

    <th>Moduleid actionid</th>    

 
	
    <th> Sorting</th> 
		
  
    <th>Action</th>    

  </tr>
   </thead>
<?php 
	

if(is_array($viewmodulesactions)) {

   foreach($viewmodulesactions as $row){



?>
  <tr>

      <td><?php echo $row->actionid ; ?></td>
	  	  	  <td><?php echo $row->name ; ?></td>
	  	  <td><?php echo $row->moduleid ; ?></td>

		  	  <td><?php echo $row->sort ; ?></td>
  <td>
  
										 <a class="btn btn-danger managebtn" id="managebtndelete"		 data-id='<?php echo  $row->actionid;?>'    data-toggle='modal' data-target='#myModal<?php  $row->actionid; ?>'>	 


                                                <i class="glyphicon glyphicon-pencil"></i>
																Delete
                                                </a>
                                                        
  </td>
</tr>
 <?php

}



} 






?>

</table>
		
			</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('' , 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="modulesactions">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="admin/viewmodulesactions">
 <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"  required>
		<option value=""  >---Select Sub-category---</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>




















































