<div class="clearfix"></div>

	

  <div class="content-wrapper">

    <div class="container-fluid">

      <!-- Breadcrumb-->

     <div class="row pt-2 pb-2">

        <div class="col-sm-9">

		    <h4 class="page-title">Lab Tests</h4>

	   </div>

     

     </div>

    <!-- End Breadcrumb-->

      <div class="row">

			<div class="col-lg-4">

			   <?php echo $this->session->flashdata("msg");?>

               <div class="card">

                    	  <div class="card-header">Add/Edit Lab Tests</div>

                    <div class="card-body">

                          <?php if($_GET['test_id']){?>

                            <form  action="<?php echo base_url();?>admin/update_test" method="post" enctype="multipart/form-data">
                            		<input type="hidden" name="test_id" value="<?php echo $edit->test_id;?>" />

                                  <div class="form-group ">

                                    <label for="email">Test Name</label>

                                    <input type="text" required class="form-control" name="test_name" value="<?php echo $edit->test_name;?>">

                                  </div>
                                 
                                  <div class="form-group">

                                    <label for="email">Test Price</label>

                                    <input type="text"  class="form-control" name="test_price" required value="<?php echo $edit->test_price;?>">

                                  </div>

                                  <div class="form-group ">

                                    <label for="email">Test Description</label>

                                    <textarea class="form-control" rows="3" name="test_desc"><?php echo $edit->test_desc;?></textarea>

                                  </div><div class="form-group ">

                                    <label for="email">Test Image</label>

                                  <input type="file" name="test_img" class="form-control"/>
                                  <input type="hidden" name="oldtest_img" value="<?php echo $edit->test_img;?>" class="form-control"/></div><br/>
                                  <img  width="100px" src="<?php echo base_url().'assets/images/'.$edit->test_img;?>" class="img img-responsive">

                                  <button type="submit" class="btn btn-success" name="submit">Update Test</button>

                                </form>

                              <?php }else{?>

                                <form  action="<?php echo base_url();?>admin/add_test" method="post" enctype="multipart/form-data">

                                  <div class="form-group ">

                                    <label for="email">Test Name</label>

                                    <input type="text" required class="form-control" name="test_name">

                                  </div>
                                 
                                  <div class="form-group">

                                    <label for="email">Test Price</label>

                                    <input type="text"  class="form-control" name="test_price" required>

                                  </div>

                                  <div class="form-group ">

                                    <label for="email">Test Description</label>

                                    <textarea class="form-control" rows="3" name="test_desc"></textarea>

                                  </div><div class="form-group ">

                                    <label for="email">Test Image</label>

                                  <input type="file" name="test_img" class="form-control"/></div><br/>

                                  <button type="submit" class="btn btn-success" name="submit">Add Test</button>

                                </form>

                                <?php }?>

                          

                    </div>

                    

               </div>                  

            </div>

            <div class="col-lg-8">

               <div class="card">

                    <div class="card-header">Listed Lab Tests</div>

                    <div class="card-body">

                          <table class="table table-sm table-bordered">

                            <thead><tr><th>S.No.</th><th>Image</th><th>Test Name</th><th>Price</th><th>Action</th></tr></thead>

                            <tbody>

                                <?php $i=1;foreach($tests as $dep){?>

                                <tr><td><?php echo $i;?></td>

                <td width="100px"><img  width="100%" src="<?php echo base_url().'assets/images/'.$dep->test_img;?>" class="img img-responsive"></td>
                                    <td><?php echo $dep->test_name;?></td>
                                    <td><?php echo $dep->test_price;?></td>

                                    <td>

                                     
                                    <a href="<?php echo base_url().'admin/lab_tests?test_id='.$dep->test_id;?>" class="btn btn-sm btn-warning"><i class="fa fa-edit"></i></a>

        <a href="#" id="<?php echo $dep->test_id;?>" class="btn btn-sm btn-danger test_delete"><i class="fa fa-trash-o"></i></a></td></tr><?php $i++;}?>

                            </tbody>

                        </table>

                    </div>

                    

               </div>                  

            </div>

            

        </div><!--End Row-->

	  

	  <!--End Row-->



    </div>

    <!-- End container-fluid-->

    

    </div><!--End content-wrapper-->

   <!--Start Back To Top Button-->

    <a href="javaScript:void();" class="back-to-top"><i class="fa fa-angle-double-up"></i> </a>

    <!--End Back To Top Button-->

	

	<!--Start footer-->

	<footer class="footer">

      <div class="container">

        <div class="text-center">

          Copyright © 2022
        </div>

      </div>

    </footer>

	<!--End footer-->

   

  </div><!--End wrapper-->





  <!-- Bootstrap core JavaScript-->

	<script>

	$(document).ready(function(){

		$(".test_delete").click(function(e){e.preventDefault();

				if(!confirm("Sure you want to delete?")){

					  return false;

				}

				var id=$(this).attr("id");$(this).closest("tr").remove();

				$.ajax({

					 type: "POST",

					 url: '<?php echo base_url();?>admin/ajax_test_delete',

					 data: {id:id},

					 success: function(response){

						 //alert(response);

					 }

				});

			});

		});

</script>

	<!-- simplebar js -->

  <script src="<?php echo base_url();?>adminassets/js/sidebar-menu.js"></script>

  <!-- Custom scripts -->

  <script src="<?php echo base_url();?>adminassets/js/app-script.js"></script>

  

  <!-- Vector map JavaScript -->

  <!-- Index js -->

  <script src="<?php echo base_url();?>adminassets/js/index.js"></script>



    

	

</body>

</html>

