<?php
$page = 'category';
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>Admin</title>
    <link href="<?php echo base_url(); ?>assets/Backend/css/bootstrap.min.css" rel="stylesheet">
    <link href="<?php echo base_url(); ?>assets/Backend/css/sb-admin.css" rel="stylesheet">
    <link href="<?php echo base_url(); ?>assets/Backend/css/plugins/morris.css" rel="stylesheet">
    <link href="<?php echo base_url(); ?>assets/Backend/font-awesome-4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
      <link href="<?php echo base_url();?>assets/Backend/editor/css/froala_editor.min.css" rel="stylesheet" type="text/css">
<style>
.p{
	border:1px solid #CCC;
  }
</style>
</head>

<body>

    <div id="wrapper">

        <!-- Navigation -->
        <?php
		include "include/header.php";
		?>
        <?php
		foreach($product as $row)
		$p_id = $row->p_id;
		?>

        <div id="page-wrapper">

            <div class="container-fluid">
             <?php //foreach($category as $row)
			 ?>
                <!-- Page Heading -->
                <div class="row">
                    <div class="col-lg-12">
                        <h1 class="page-header">
                            Edit Product <small><?php echo '['.$row->p_name.']';?></small>
                           <a href="<?php echo base_url();?>app/chemical_products/<?php echo $row->c_id;?>" class="pull-right btn btn-primary">Back</a>

                        </h1>
                       
                    </div>
                </div>
            <form role="form" action="<?php echo base_url();?>update/up_chemical/<?php echo $row->p_id.'/'.$row->c_id;?>" method="post" enctype="multipart/form-data">
            <div class="row">
         
            	<div class="col-lg-6">
             		<div class="form-group">
                		<label>Select Category</label>
                        <select class="form-control" name="c_id">
                        <?php foreach($category as $c_row):
						?>
                        <option <?php if($row->c_id == $c_row->c_id) {echo "selected='selected'";}?> value="<?php echo $c_row->c_id?>"><?php echo $c_row->c_name.'-',$c_row->c_type;?></option>
                        <?php endforeach;?>
                        </select>
                    </div>
                    <div class="form-group">
                		<label>Product Name</label>
             			<input type="text" class="form-control" name="p_name" value="<?php echo $row->p_name;?>">
                    </div>
                     
                    <div class="col-lg-6">
                    	<div class="form-group">
                        <label>Revision Date</label>
             			<input type="date" class="form-control" name="p_revision_date" value="<?php echo $row->p_revision_date;?>">
                    	</div>
                    </div>
                    <div class="col-lg-6">    
                		<div class="form-group">
                    	<label>Status</label>
             			<select class="form-control" name="p_status">
                        <option <?php if($row->p_status == 'New') {echo "selected='selected'";}?> value="New">New Product</option>
                        <option <?php if($row->p_status == 'Old') {echo "selected='selected'";}?>value="Old">Old Product</option>
                        </select>
                   		</div>
                    </div>
                
                   
                    <div class="form-group">
                        <label>Select Image for Uploading <b>(JPG Files Only)</b></label>
                        <input type="file" class="form-control" name="p_image" >
                    </div>
                </div> 
                <div class="col-lg-6">
             	<div class="form-group">
                	     <label>Product Image</label><br>
                         <img src="<?php echo base_url();?>assets/uploads/products/<?php echo '_'.$row->p_id.'.'?>jpg" height="250" width="350" style="border:1px solid #CCC">
                </div>	
                </div>
          </div> 
           <div class="row">      
                    <div class="col-lg-12">
							<div class="form-group">
                                <label>Product Information</label>
                                <textarea class="form-control" id="edit"  name="p_description" rows="25"><?php echo $row->p_description;?></textarea>
                            </div>
                    </div>
              </div>
           
             <br> 
             <div cass="row">
                    <div class="col-lg-12"><legend>Product Details</legend>
                        <div class="table-responsive">
                            <table class="table table-hover">
                                <tr>
                                <td width="20%"><input type="text" value="Article No" class="form-control" name="pd_property[]" readonly  required/></td>
                                 
                                <td width="30%"><input type="text" placeholder="Article No" class="form-control" name="pd_value[]" required
                                 value="<?php foreach($p_details as $pd_row) 
								              {
								           	    if($pd_row->pd_property == 'Article No')
									               echo $pd_row->pd_value; 
								               }
									 ?>">
                                </td>
                       
                                <td width="20%"><input type="text" value="Grade" class="form-control" name="pd_property[]" readonly /></td>
                                <td width="30%"><input type="text" placeholder="Grade" class="form-control" name="pd_value[]"
                                value="<?php foreach($p_details as $pd_row) 
								              {
								           	    if($pd_row->pd_property == 'Grade')
									               echo $pd_row->pd_value; 
								               }
									 ?>" /></td>
                                </tr>
                                <tr>
                                <td width="20%"><input type="text" value="Purity" class="form-control" name="pd_property[]" readonly /></td>
                                <td width="30%"><input type="text" placeholder="Purity" class="form-control" name="pd_value[]"
                                value="<?php foreach($p_details as $pd_row) 
								              {
								           	    if($pd_row->pd_property == 'Purity')
									               echo $pd_row->pd_value; 
								               }
									 ?>" /></td>
                                <td width="20%"><input type="text" value="CAS No" class="form-control" name="pd_property[]" readonly required/></td>
                                <td width="30%"><input type="text" placeholder="CAS No" class="form-control" name="pd_value[]" required
                                value="<?php foreach($p_details as $pd_row) 
								              {
								           	    if($pd_row->pd_property == 'CAS No')
									               echo $pd_row->pd_value; 
								               }
									 ?>"/></td>
                                </tr>
                                <tr>
                                <td width="20%"><input type="text" value="Molecular Formula" class="form-control" name="pd_property[]" readonly /></td>
                                <td width="30%"><input type="text" placeholder="Molecular Formula" class="form-control" name="pd_value[]" 
                                value="<?php foreach($p_details as $pd_row) 
								              {
								           	    if($pd_row->pd_property == 'Molecular Formula')
									               echo $pd_row->pd_value; 
								               }
									 ?>"/></td>
                                <td width="20%"><input type="text" value="Molecular Weight" class="form-control" name="pd_property[]" readonly /></td>
                                <td width="30%"><input type="text" placeholder="Molecular Weight" class="form-control" name="pd_value[]" 
                                value="<?php foreach($p_details as $pd_row) 
								              {
								           	    if($pd_row->pd_property == 'Molecular Weight')
									               echo $pd_row->pd_value; 
								               }
									 ?>"/></td>
                                </tr>
                                <tr>
                                <td width="20%"><input type="text" value="H.S.Code" class="form-control" name="pd_property[]" readonly /></td>
                                <td width="30%"><input type="text" placeholder="H.S.Code" class="form-control" name="pd_value[]" 
                                value="<?php foreach($p_details as $pd_row) 
								              {
								           	    if($pd_row->pd_property == 'H.S.Code')
									               echo $pd_row->pd_value; 
								               }
									 ?>"/></td>
                                <td width="20%"><input type="text" value="Shelf Life" class="form-control" name="pd_property[]" readonly /></td>
                                <td width="30%"><input type="text" placeholder="Shelf Life" class="form-control" name="pd_value[]" 
                                value="<?php foreach($p_details as $pd_row) 
								              {
								           	    if($pd_row->pd_property == 'Shelf Life')
									               echo $pd_row->pd_value; 
								               }
									 ?>
                                     " /></td>
                                </tr>
                               
                            </table>
                        </div>
                    </div>
                    </div>
               <br>
               <div class="row">
               		<div class="col-lg-6">
                    <legend>Physical Properties</legend>
                    <table class="table table-hover">
                    <thead>
                    <th width="5%"></th>
                    <th width="20%">Property</th>
                    <th width="20%">Property Details</th>
                    </thead>
                    </table>
                    <table class="table" id="dataTable1">
                       <?php foreach($p_physical as $p_row):?>
                       <tr>
                          <td width="5%"><input type="checkbox" name="ch_p[]"/></td>
                          <td width="20%"><input type="text" class="form-control" name="pp_property[]" id="pp_property[]" value="<?php echo $p_row->pp_property;?>"/></td>
                          <td width="20%"><input type="text" class="form-control" name="pp_value[]" id="pp_value[]" value="<?php echo $p_row->pp_value;?>"/></td>
                       </tr>
                       <?php endforeach;?>
                    </table>
                    <table class="mws-table mws-datatable">	
                         <tr>
                            <td><input type="button" value="+" class="btn btn-danger btn-sm" onclick="addRow('dataTable1')"/></td>
                            <td>&nbsp;<input type="button" value="-" class="btn btn-primary btn-sm" onclick="deleteRow('dataTable1')"/></td>
                         </tr>
                    </table>
                    </div>
                    <div class="col-lg-6 ">
                    <legend>Specification Details</legend>
                    <table class="table table-hover">
                    <thead>
                    <th width="5%"></th>
                    <th width="20%">Property</th>
                    <th width="20%">Property Details</th>
                    </thead>
                    </table>
                    <table class="table table-hover" id="dataTable2">
                     <?php foreach($p_specification as $s_row):?>
                           <tr>
                              <td width="5%"><input type="checkbox" name="ch[]"/></td>
                              <td width="20%"><input type="text" class="form-control" name="sd_property[]" value="<?php echo $s_row->sd_property;?>"/></td>
                              <td width="20%"><input type="text" class="form-control" name="sd_value[]" value="<?php echo $s_row->sd_value;?>"/></td>
                           </tr>
                           <?php endforeach;?>
                    </table>
                    <table class="mws-table mws-datatable">	
                             <tr>
                                <td><input type="button" value="+" class="btn btn-danger btn-sm" onclick="addRow('dataTable2')"/></td>
                                <td>&nbsp;<input type="button" value="-" class="btn btn-primary btn-sm" onclick="deleteRow('dataTable2')"/></td>
                             </tr>
                    </table>
                                       
                    </div>
               </div>
               <br><br>
               <div class="row">
               		<div class="col-lg-6">
                    
                    <legend>Packings</legend>
                    <table class="table table-hover">
                    <thead>
                    <th width="5%"></th>
                    <th width="20%">Package No</th>
                    <th width="20%">Stock</th>
                    </thead>
                    </table>
                    <table class="table table-hover" id="dataTable3">
                        <tbody>
                        <?php foreach($p_packing as $pkg_row):?>
                           <tr>
                              <td width="5%"><input type="checkbox" name="ch[]"/></td>
                              <td width="20%"><input type="text" class="form-control" name="pkg_no[]" value="<?php echo $pkg_row->pkg_no;;?>"/></td>
                              <td width="20%"><input type="text" class="form-control" name="pkg_stk[]" value="<?php echo $pkg_row->pkg_stk;?>"/></td>
                           </tr>
                           <?php endforeach;?>
                        </tbody>
                    </table>
                    <table class="mws-table mws-datatable">	
                    	<tbody>
                             <tr>
                                <td><input type="button" value="+" class="btn btn-danger btn-sm" onclick="addRow('dataTable3')"/></td>
                                <td>&nbsp;<input type="button" value="-" class="btn btn-primary btn-sm" onclick="deleteRow('dataTable3')"/></td>
                             </tr>
                        </tbody>
                    </table>
                                       
                    </div>
                    <div class="col-lg-6">
                    <legend>Safety Information</legend>
                      <div class="col-lg-4">
                      <input type="checkbox" 
					  <?php foreach($p_safety as $sa_row)
					  {
						  if($sa_row->symbol == '1')
						    echo "checked";
					  }
					  ?> value="1" name="chk[]"/>
                      <a href="#" class="">
                      <img src="<?php echo base_url();?>assets/safety img/symbols_1.png" alt="ho"/>
                      </a>
                      </div>
                      <div class="col-lg-4">
                      <input type="checkbox" 
                      <?php foreach($p_safety as $sa_row)
					  {
						  if($sa_row->symbol == '2')
						    echo "checked";
					  }
					  ?> value="2" name="chk[]"/>
                      <a href="#" class="">
                      <img src="<?php echo base_url();?>assets/safety img/symbols_2.png"/>
                      </a>
                      </div>
                      <div class="col-lg-4">
                      <input type="checkbox" 
                      <?php foreach($p_safety as $sa_row)
					  {
						  if($sa_row->symbol == '3')
						    echo "checked";
					  }
					  ?>
                      value="3" name="chk[]"/>
                      <a href="#" class="">
                      <img src="<?php echo base_url();?>assets/safety img/symbols_3.png"/>
                      </a>
                      </div>
                      <div class="col-lg-4">
                      <input type="checkbox" 
                      <?php foreach($p_safety as $sa_row)
					  {
						  if($sa_row->symbol == '4')
						    echo "checked";
					  }
					  ?>
                      value="4" name="chk[]"/>
                      <a href="#" class="">
                      <img src="<?php echo base_url();?>assets/safety img/symbols_4.png"/>
                      </a>
                      </div>
                      <div class="col-lg-4">
                      <input type="checkbox" 
                      <?php foreach($p_safety as $sa_row)
					  {
						  if($sa_row->symbol == '5')
						    echo "checked";
					  }
					  ?> value="5" name="chk[]"/>
                      <a href="#" class="">
                      <img src="<?php echo base_url();?>assets/safety img/symbols_5.png"/>
                      </a>
                      </div>
                      <div class="col-lg-4">
                      <input type="checkbox" 
                      <?php foreach($p_safety as $sa_row)
					  {
						  if($sa_row->symbol == '6')
						    echo "checked";
					  }
					  ?> value="6" name="chk[]"/>
                      <a href="#" class="">
                      <img src="<?php echo base_url();?>assets/safety img/symbols_6.png"/>
                      </a>
                      </div>
                      <div class="col-lg-4">
                      <input type="checkbox" 
                      <?php foreach($p_safety as $sa_row)
					  {
						  if($sa_row->symbol == '7')
						    echo "checked";
					  }
					  ?>  value="7" name="chk[]"/>
                      <a href="#" class="">
                      <img src="<?php echo base_url();?>assets/safety img/symbols_7.png"/>
                      </a>
                      </div>
                      <div class="col-lg-4">
                      <input type="checkbox" 
                      <?php foreach($p_safety as $sa_row)
					  {
						  if($sa_row->symbol == '8')
						    echo "checked";
					  }
					  ?>  value="8" name="chk[]"/>
                      <a href="#" class="">
                      <img src="<?php echo base_url();?>assets/safety img/symbols_8.png"/>
                      </a>
                      </div>
                      <div class="col-lg-4"> 
                      <input type="checkbox" 
                      <?php foreach($p_safety as $sa_row)
					  {
						  if($sa_row->symbol == '9')
						    echo "checked";
					  }
					  ?>  value="9" name="chk[]"/>
                      <a href="#" class="">
                      <img src="<?php echo base_url();?>assets/safety img/symbols_9.png"/>
                      </a>
                      </div>
                      <div class="col-lg-4" style="display:none"> 
                      <input type="checkbox" value="0" name="chk[]" checked />
                      <a href="#" class="">
                      <img src="<?php echo base_url();?>assets/safety img/symbols_9.png" />
                      </a>
                      </div>
                     </div>
                   </div>
                   <br><br>
                        <input type="submit" class="btn btn-primary" value="Save Information"/>
                        <a href="<?php echo base_url();?>app/chemical_products/<?php echo $row->c_id;?>" class="btn btn-primary">Cancel</a>  
               </form>
				
            </div>
            <!-- /.container-fluid -->

        </div>
        <!-- /#page-wrapper -->

    </div>
       <!-- jQuery Version 1.11.0 -->
    <script src="<?php echo base_url(); ?>assets/Backend/js/jquery-1.11.0.js"></script>
    <script src="<?php echo base_url(); ?>assets/Backend/js/addrow.js"></script>
    <!-- Bootstrap Core JavaScript -->
    <script src="<?php echo base_url(); ?>assets/Backend/js/bootstrap.min.js"></script>

    <!-- Morris Charts JavaScript -->
    <script src="<?php echo base_url(); ?>assets/Backend/js/plugins/morris/raphael.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/Backend/js/plugins/morris/morris.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/Backend/js/plugins/morris/morris-data.js"></script>
	<script src="<?php echo base_url(); ?>assets/Backend/editor/js/libs/jquery-1.11.1.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/Backend/editor/js/froala_editor.min.js"></script>
  
  <script src="<?php echo base_url(); ?>assets/Backend/editor/js/plugins/tables.min.js"></script>
  <script src="<?php echo base_url(); ?>assets/Backend/editor/js/plugins/lists.min.js"></script>
  <script src="<?php echo base_url(); ?>assets/Backend/editor/js/plugins/colors.min.js"></script>
  <script src="<?php echo base_url(); ?>assets/Backend/editor/js/plugins/font_family.min.js"></script>
  <script src="<?php echo base_url(); ?>assets/Backend/editor/js/plugins/font_size.min.js"></script>
  <script src="<?php echo base_url(); ?>assets/Backend/editor/js/plugins/block_styles.min.js"></script>
  <script src="<?php echo base_url(); ?>assets/Backend/editor/js/plugins/media_manager.min.js"></script>
  <script src="<?php echo base_url(); ?>assets/Backend/editor/js/plugins/video.min.js"></script>

  <script>
      $(function(){
        $('#edit').editable({inlineMode: false})
      });
  </script>
</body>

</html>
