<?php
require_once("header.php");
require_once("menu.php");


if(isset($_REQUEST['edit']))
{
    $id = base64_decode($_REQUEST['edit']);
    $ex = $obj->get_inds_id($id);
    $row = mysqli_fetch_array($ex);
}
if(isset($_POST['update']))
{   
  
      $update_info['id'] = $_POST['id'];
      $update_info['icon'] = $_POST['icon'];
      $update_info['title'] = $_POST['title'];
       if(!empty($_FILES['bg_img']['name']))
        {      
            $server_url = '//'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
            $upload_dir = '../uploads/service/';      
            $tempname = $_FILES['bg_img']['tmp_name'];
            $upload_name = $upload_dir.$_FILES['bg_img']['name'];
            move_uploaded_file($tempname,$upload_name);
            $update_info['bg_img'] = $server_url."/".$upload_name;
        }
        else
        {
            $update_info['bg_img'] =$_POST['bg_img1'];
        }
     
    $ex = $obj->update_industryservice_info($update_info);
 
    echo '<script>window.location="industry_services.php"</script>';
}

if(isset($_POST['submit']))
{
          $inds_info['icon'] = $_POST['icon'];
          $inds_info['title'] = $_POST['title'];
          $server_url = '//'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
    $upload_dir = '../uploads/service/';
        
        if(!empty($_FILES['bg_img']['name']))
        {            
            $tempname = $_FILES['bg_img']['tmp_name'];
            $upload_name = $upload_dir.$_FILES['bg_img']['name'];
            move_uploaded_file($tempname,$upload_name);
            $inds_info['bg_img'] = $server_url."/".$upload_name;
        }
          $ex = $obj->add_industryservice_info($inds_info);
        
    echo '<script>window.location="industry_services.php"</script>';
}

?>

<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> Indusrty Service Section 
                <a href="industry_services.php" class="btn btn-primary btn-sm float-right">Back</a>
            </div>
            <div class="card-body">
                <form method="post" id="users" enctype="multipart/form-data">
                   <input type="hidden" name="id" value="<?php echo $row['id'];?>">
                             
             <h5 class="siteconfi">Service Section</h5>
              
         
             <div class="form-group">
                        <label>Industry Title</label><br>
						  <input type="text" class="form-control" name="icon" value="<?php echo $row['icon'];?>">
                       </div>
               <div class="form-group">
                  <label>Title</label>
				   <textarea id="w3review" name="title"  rows="6" cols="50" class="tinymce"><?php echo $row['title'];?>
                  </textarea>
               </div> 

					<div class="form-group">
                        <label>Background Image </label><br>
            
                       <input type="file" class="" name="bg_img" value="<?php echo $row['bg_img'];?>">
                       <input type="hidden" name="bg_img1" value="<?php echo $row['bg_img'];?>">
                       <img src="<?php echo $row['bg_img'];?>"  style="width: 100px;">
                     </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 = "industry_services.php";
</script>
<?php require_once("footer.php");?>

