<?php
   require_once("header.php");
   require_once("menu.php");
   
   $_SESSION['error'] = '';
  
    /** Add a Supply Chain ***/
		  if(isset($_POST['submit']))
				{
					  $supply_chain['supply_chain_title'] = $_POST["supply_chain_title"];
					  $supply_chain['supply_chain_icon'] = $_POST["supply_chain_icon"];
					  
					   $ex = $obj->add_supply_chain_home($supply_chain);
					   echo '<script>window.location="supply_chain.php"</script>';
				}
    /** End Supply Chain Add Code**/

   	/** Edit Supply Chain ***/
		if(isset($_POST['update'])){
			$supply_chain['supply_chain_id'] = $_POST["supply_chain_id"];
			$supply_chain['supply_chain_title'] = $_POST["supply_chain_title"];
			$supply_chain['supply_chain_icon'] = $_POST["supply_chain_icon"];
			
			$ex = $obj->edit_supply_chain_home($supply_chain);
			echo '<script>window.location="supply_chain.php"</script>';
		}
    /** End Edit Supply Chain **/
	
	/*** View data id wise**/
			if(isset($_REQUEST['edit']))
			  {
			    $supply_chain_id = base64_decode($_REQUEST['edit']);
				$ex = $obj->view_supply_chain_by_id($supply_chain_id);
				$row = mysqli_fetch_array($ex);
			  }
     /***end data id wise***/
   ?>  
<div id="layoutSidenav_content">
<main class="mt-4">
   <div class="container-fluid">
      <div class="card mb-4">
         <div class="card-header">
            <i class="fas fa-check-square mr-1"></i>Home Page Supply chain solutions Section
            <a href="supply_chain.php" class="btn btn-primary btn-sm float-right">Back</a>
         </div>
         <div class="card-body">
            <p class="text-danger"><?php echo $_SESSION['error'];?></p>
            <form method="post">
               <input type="hidden" name="supply_chain_id" value="<?php echo $supply_chain_id;?>">
			   
               <div class="form-group">
                  <label>Title</label>
				  <input type="text" name="supply_chain_title" class="form-control" value="<?php echo $row['supply_chain_title'];?>">
               </div>
			   
               <div class="form-group">
                  <label>Icon Text</label>
                 <input type="text" name="supply_chain_icon" class="form-control" value="<?php echo $row['supply_chain_icon'];?>">
                  </div>
               
               
               <?php if(isset($_REQUEST['edit']))
                  { ?> 
               <button type="submit" class="btn btn-primary" name="update">Update</button>
               <?php } 
                  else
                  { ?>
               <button type="submit" class="btn btn-primary" name="submit">Submit</button>
               <?php } ?>
            </form>
         </div>
      </div>
   </div>
</main>
<script>
    var url = "supply_chain.php";
</script>
<?php require_once("footer.php");?>