<?php include 'header.php';?>
<div class="col-md-10 content">
<div class="row">
<div class="col-md-12 ">
<!-- edit Plant -->
<?php
if(isset($_POST['edit_plant']))
{
$cat_id= $_POST['cat_id'];
$select_plant_edit = $con->prepare("SELECT * FROM tbl_category_features WHERE cat_id=:cat_id");
$select_plant_edit->bindParam(':cat_id', $cat_id);
$select_plant_edit->execute();
$fetch_edit_plant = $select_plant_edit->fetch(PDO::FETCH_ASSOC);
?>
<div class="panel panel-primary" id="edit_plant_panel">
<div class="panel-heading">
<h3>Category Name : <?php echo $_POST['cat_name']; ?> </h3>
</div>
<div class="panel-body">
<div class="col-md-8">
<form id="create_product" method="POST" enctype="multipart/form-data" >
<input type="hidden" class="form-control" name="cat_id" value="<?php echo $cat_id?>">
<div class="row">
<div class="col-md-12">
<h4 class="header_separator"><i class="fa fa-area-chart" aria-hidden="true"></i> Category Features</h4>
<hr>
</div>
<div class="col-md-12">
<label>Plant Maintenance :</label>
<div class="form-group">
<div class="col-md-4">
<label><input type="checkbox" <?php if($fetch_edit_plant['maint_low']==1){ echo 'checked'; } ?> value="1" name="maint_low"> Low</label>
</div>
<div class="col-md-4">
<label><input type="checkbox" <?php if($fetch_edit_plant['maint_medium']==1){ echo 'checked'; } ?> value="1" name="maint_medium"> Medium</label>
</div>
<div class="col-md-4">
<label><input type="checkbox" <?php if($fetch_edit_plant['maint_high']==1){ echo 'checked'; } ?> value="1" name="maint_high"> High</label>
</div>
</div>
</div>
</div>
<br/>
<div class="row">
<div class="col-md-12">
<label>Plant Lighting :</label>
<div class="form-group">
<div class="col-md-4">
<label><input type="checkbox" <?php if($fetch_edit_plant['light_low_light']==1){ echo 'checked'; } ?> value="1" name="light_low_light"> indoors: low light</label>
</div>
<div class="col-md-4">
<label><input type="checkbox" <?php if($fetch_edit_plant['light_medium_light']==1){ echo 'checked'; } ?> value="1" name="light_medium_light"> indoors: medium light</label>
</div>
<div class="col-md-4">
<label><input type="checkbox" <?php if($fetch_edit_plant['light_high_light']==1){ echo 'checked'; } ?> value="1" name="light_high_light"> indoors: high light</label>
</div>
<div class="col-md-4">
<label><input type="checkbox" <?php if($fetch_edit_plant['light_out_sun']==1){ echo 'checked'; } ?> value="1" name="light_out_sun"> outside: sun</label>
</div>
<div class="col-md-4">
<label><input type="checkbox" <?php if($fetch_edit_plant['light_out_part_sun']==1){ echo 'checked'; } ?> value="1" name="light_out_part_sun"> outside: part sun</label>
</div>
<div class="col-md-4">
<label><input type="checkbox" <?php if($fetch_edit_plant['light_out_shade']==1){ echo 'checked'; } ?> value="1" name="light_out_shade"> outside: shade</label>
</div>
</div>
</div>
</div>
<br/>
<div class="row">
<div class="col-md-12">
<label>Plant Shade :</label>
<div class="form-group">
<div class="col-md-4">
<label><input type="checkbox" <?php if($fetch_edit_plant['shade_low']==1){ echo 'checked'; } ?> value="1" name="shade_low"> Low</label>
</div>
<div class="col-md-4">
<label><input type="checkbox" <?php if($fetch_edit_plant['shade_medium']==1){ echo 'checked'; } ?> value="1" name="shade_medium"> Medium</label>
</div>
<div class="col-md-4">
<label><input type="checkbox" <?php if($fetch_edit_plant['shade_high']==1){ echo 'checked'; } ?> value="1" name="shade_high"> High</label>
</div>
</div>
</div>
</div>
<br/>
<div class="row">
<div class="col-md-12">
<button class="btn btn-primary" type="submit" name="udpate_edited_plant">Update It</button>
<button type="button" class="btn btn-danger" id="cancel" >Cancel</button>
</div>
</div>
</form>
</div>
</div>
</div>
<!-- end edit Plant -->
<?php
}
if(isset($_POST['udpate_edited_plant']))
{
$cat_id= $_POST['cat_id'];
$maint_low=$maint_medium=$maint_high= $light_low_light=$light_medium_light=$light_high_light=$light_out_sun=$shade_high=$light_out_part_sun=$light_out_shade=$shade_medium=$shade_low=0;
//Start Maintenance
if(isset($_POST['maint_low']))
{
$maint_low=1;
}
if(isset($_POST['maint_medium']))
{
$maint_medium=1;
}
if(isset($_POST['maint_high']))
{
$maint_high=1;
}
//End Maintenance
//Start Lighting
if(isset($_POST['light_low_light']))
{
$light_low_light=1;
}
if(isset($_POST['light_medium_light']))
{
$light_medium_light=1;
}
if(isset($_POST['light_high_light']))
{
$light_high_light=1;
}
if(isset($_POST['light_out_sun']))
{
$light_out_sun=1;
}
if(isset($_POST['light_out_part_sun']))
{
$light_out_part_sun=1;
}
if(isset($_POST['light_out_shade']))
{
$light_out_shade=1;
}
//End Lighting
//Start Shade
if(isset($_POST['shade_low']))
{
$shade_low=1;
}
if(isset($_POST['shade_medium']))
{
$shade_medium=1;
}
if(isset($_POST['shade_high']))
{
$shade_high=1;
}
//End Shade
$add_new_plant = $con->prepare("UPDATE tbl_category_features SET maint_low=:maint_low, maint_medium=:maint_medium,
maint_high=:maint_high, light_low_light=:light_low_light, light_medium_light=:light_medium_light,
light_high_light=:light_high_light, light_out_sun=:light_out_sun, light_out_part_sun=:light_out_part_sun, light_out_shade=:light_out_shade,
shade_low=:shade_low, shade_medium=:shade_medium, shade_high=:shade_high WHERE cat_id=:cat_id");
$add_new_plant->bindParam(":maint_low", $maint_low);
$add_new_plant->bindParam(":maint_medium", $maint_medium);
$add_new_plant->bindParam(":maint_high", $maint_high);
$add_new_plant->bindParam(":light_low_light", $light_low_light);
$add_new_plant->bindParam(":light_medium_light", $light_medium_light);
$add_new_plant->bindParam(":light_high_light", $light_high_light);
$add_new_plant->bindParam(":light_out_sun", $light_out_sun);
$add_new_plant->bindParam(":light_out_part_sun", $light_out_part_sun);
$add_new_plant->bindParam(":light_out_shade", $light_out_shade);
$add_new_plant->bindParam(":shade_low", $shade_low);
$add_new_plant->bindParam(":shade_medium", $shade_medium);
$add_new_plant->bindParam(":shade_high", $shade_high);
$add_new_plant->bindParam(":cat_id", $cat_id);
if($add_new_plant->execute())
{
echo "<script> alert('Plant has been updated successfully');</script>";
}
else
{
echo "<script> alert('Please try agin.');</script>";
}
}
?>
<div class="panel panel-primary">
<div class="panel-heading">
<h3>Category List</h3>
</div>
<div class="panel-body">
<div class="col-md-12 ">
<div class="table-responsive">
<table id="example" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
<thead>
<tr>
<th>SL No</th>
<th>Category Name</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$sl=1;
$select_all_plants = $con->prepare("SELECT * FROM tbl_plant_categories");
$select_all_plants->execute();
while($fetch_all_plants = $select_all_plants->fetch(PDO::FETCH_ASSOC))
{
?>
<tr>
<td><?php echo $sl; ?></td>
<td><?php echo $fetch_all_plants['cat_name']; ?></td>
<td>
<form action="" method="post">
<input type="hidden" name="cat_name" value="<?php echo $fetch_all_plants['cat_name']; ?>">
<input type="hidden" name="cat_id" value="<?php echo $fetch_all_plants['id']; ?>">
<button type="submit" name="edit_plant" class="btn btn-info">Edit Features</button>
</form>
</td>
</tr>
<?php
$sl++;
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include 'footer.php';?>
<script type="text/javascript" src="js/tinymce_js/tinymce/tinymce.min.js"></script>
<script type="text/javascript">
tinymce.init({
selector: "textarea",
plugins: [
"advlist autolink lists link image charmap print preview anchor",
"searchreplace visualblocks code fullscreen",
"insertdatetime media table contextmenu paste"
],
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
});
$("#cancel").click(function(){
$("#edit_plant_panel").hide();
});
</script>
|