<?php
include_once("../include/main.inc.php");
check_session('MyCpanel', 'index.php');

if ($_POST['action'] == "Update") {
  @extract($_POST);
  if($_FILES[companyLogo][name]!=""){
    

		$file_extension=strtolower(getExtension($_FILES[companyLogo][name]));
		if($file_extension!="jpg" && $file_extension!="jpeg" && $file_extension!="png" ){
			$_SESSION[session_message]='Please upload image (.jpg,.png Format Only)';
			
		}
		if($_FILES[companyLogo][name]!=""){
			
			$filename1=$res['companyLogo'];
			if($filename1!="") {
				$file=SITE_DIR_PATH."/uploaded-files/logo/".$filename1;
				if(file_exists($file)) {
					unlink($file);
				}
				
				$file_thumb=SITE_DIR_PATH."/uploaded-files/logo/thumbs/".$filename1;
				if(file_exists($file_thumb)) {
					unlink($file_thumb);
				}
			}
			$img_name1='logo';
			$img1=upload_file($img_name1,"companyLogo","uploaded-files/logo");
updateTable("admin_details","companyLogo='$img1' where user_type='admin'");
			
			
		}
	}
  $analytics = str_ireplace("'", "&apos;", $analytics);
  $analytics = str_ireplace('"', "&quot;", $analytics);
  updateTable("admin_details", " name='$name', email='$email', cc='$cc', subject='$subject', website='$website', address='$address', companyName='$companyName', phone='$phone',facebook_link = '$facebook_link', instagram_link = '$instagram_link', linked_link='$linked_link', youtube_link='$youtube_link', twitter_link='$twitter_link', pinterest_link='$pinterest_link', company_video='$company_video',mobile='$mobile', city='$city', state='$state', country='$country',whatsapp_no='$whatsapp',targetlocation='$targetlocation', companyAddress ='$companyAddress',mobile_meta='$mobile_meta',analytics='$analytics' where user_type='admin'");
  $_SESSION['session_message'] = "Admin details have been updated successfully";
  header("Location:" . SITE_ADMIN_URL . "/myaccount.php");
  exit;
}

$res = getResult("admin_details", " where user_type='admin'");
admin_header();
?>
<form name="form1" method="post" action="" onsubmit="return validate(this);" enctype="multipart/form-data">

  <h4 align="center" style="font-weight: 600;
      margin: 10px 10px 15px 15px;
      padding: 10px 15px;
      border: 15px;
      ">Manage Admin Details</h4>

  <?php
  if ($_SESSION['session_message'] != "") {
    ?>
    <center><?php print_message(); ?></center>
    <?php
  }
  ?>
  <div class="form-group">
    <label for="email">Owner Name *:</label>
    <input type="text" class="form-control txtfieldadmin" value="<?= $res['name']; ?>" placeholder="Owner Name" name="name">   </div>
  <div class="form-group">
    <label for="email">Company Name *:</label>
    <input type="text" class="form-control txtfieldadmin" value="<?= $res['companyName']; ?>" placeholder="Company Name" name="companyName"> 
  </div>
 
  <div class="form-group">
  <label for="companyLogo">Company Logo:</label>
  <?php
                        if ($res['companyLogo'] != "") {
                          ?>
                         
                          <input name="companyLogo" type="file" size="40"  class="form-control">
                          <strong>Image Size: Please upload Logo (size 400X60).</strong> <br>
                          <?php
                          $banner = SITE_DIR_PATH . "/uploaded-files/logo/" . $res['companyLogo'];
                          if (file_exists($banner)) {
                            $dimens = GetImageSize($banner);
                            if ($dimens[0] > 130) {
                              $dimens[0] = $dimens[0] + 50;
                              $dimens[1] = $dimens[1] + 80;
                            } else {
                              $dimens[0] = 200;
                              $dimens[1] = 200;
                            }
                            echo "<br>&nbsp;<a href=\"javascript:void(0);\" onClick=\"openwin('" . SITE_ADMIN_URL . "/popup_new.php?img=logo/" . $res[companyLogo] . "', '$dimens[0]', '$dimens[1]')\" class=\"linkgray fontbold\"><b>View Image</b></a>";
                          }
                        }
                          else{
                              ?>
                              
                               <input type="file" class="form-control" name="companyLogo">
                                <strong>Image Size: Please upload Logo (size 400X60).</strong>
                          <?php
                          }
                        ?>
                      
                      </div> 

  <div class="form-group">
    <label for="email">Address *:</label>
    <textarea name="address"  class="form-control txtfieldadmin" rows="5" cols="10"><?= $res['address']; ?></textarea>
  </div>
  <div class="form-group">
      <label for="companyAddress">Factory Address </label>
      <textarea name="companyAddress" class="form-control" rows="5" cols="10"><?= $res['companyAddress']; ?></textarea>
  </div>
  <div class="form-group">
      <label for="analytics">Seo Schema (Google Analytics, Webmaster, Schema) </label>
      <textarea name="analytics" class="form-control" rows="5" cols="15"><?= $res['analytics']; ?></textarea>
     
  </div>
  <div class="form-group">
    <label for="email">Email Id *:</label>
    <input type="text" class="form-control txtfieldadmin" value="<?= $res['email']; ?>" placeholder="Email ID" name="email"> 
  </div>
  <div class="form-group">
    <label for="email">Email Id (CC) *:</label>
    <input type="text" class="form-control txtfieldadmin" value="<?= $res['cc']; ?>" placeholder="Email ID (cc)" name="cc"> 
  </div>
  <div class="form-group">
    <label for="email">Subject *:</label>
    <textarea name="subject"  class="form-control txtfieldadmin" rows="5" cols="10"><?= $res['subject']; ?></textarea>
  </div>
  <div class="form-group">
    <label for="email">Website Name *:</label>
    <input type="text" class="form-control txtfieldadmin" value="<?= $res['website']; ?>" placeholder="Website Name" name="website"> 
  </div>
  <div class="form-group">
    <label for="email">Company Phone *:</label>
    <input type="text" class="form-control txtfieldadmin" value="<?= $res['phone']; ?>" placeholder="Company Phone" name="phone"> 
  </div>
  <div class="form-group">
    <label for="email">Mobile Number *:</label>
    <input type="text" class="form-control txtfieldadmin" value="<?= $res['mobile']; ?>" placeholder="Mobile Number" name="mobile"> 
  </div>
  <div class="form-group">
    <label for="email">Whatsapp Number *:</label>
    <input type="text" class="form-control txtfieldadmin" value="<?= $res['whatsapp_no']; ?>" placeholder="Whatsapp Number" name="whatsapp"> 
  </div>
  <div class="form-group">
    <label for="email">Mobile Number (For Meta tag) *:</label>
    <input type="text" class="form-control txtfieldadmin" value="<?= $res['mobile_meta']; ?>" placeholder="Mobile Number (Don't Use hyphens)" name="mobile_meta"> 
  </div>
  <div class="form-group">
    <label for="email">City *:</label>
    <input type="text" class="form-control txtfieldadmin" value="<?= $res['city']; ?>" placeholder="City Name" name="city"> 
  </div>
  <div class="form-group">
    <label for="email">State *:</label>
    <input type="text" class="form-control txtfieldadmin" value="<?= $res['state']; ?>" placeholder="State Name" name="state"> 
  </div>
  <div class="form-group">
    <label for="email">Country *:</label>
    <input type="text" class="form-control txtfieldadmin" value="<?= $res['country']; ?>" placeholder="Country Name" name="country"> 
  </div>
  <div class="form-group">
    <label for="email">Target Location :</label>
    <input type="text" class="form-control txtfieldadmin" value="<?= $res['targetlocation']; ?>" placeholder="Target Location" name="targetlocation"> 
  </div>
      <div class="form-group">
    <label for="email">Facebook Link *:</label>
    <input type="text" class="form-control txtfieldadmin" value="<?= $res['facebook_link']; ?>" placeholder="Facebook Link" name="facebook_link"> 
  </div>
     <div class="form-group">
    <label for="email">Instagram Link *:</label>
    <input type="text" class="form-control txtfieldadmin" value="<?= $res['instagram_link']; ?>" placeholder="Instagram Link" name="instagram_link"> 
  </div>

     <div class="form-group">
    <label for="email">Youtube Link *:</label>
    <input type="text" class="form-control txtfieldadmin" value="<?= $res['youtube_link']; ?>" placeholder="Youtube Link" name="youtube_link"> 
  </div>
     <div class="form-group">
    <label for="email">Linked-in Link *:</label>
    <input type="text" class="form-control txtfieldadmin" value="<?= $res['linked_link']; ?>" placeholder="Linked-in Link" name="linked_link"> 
  </div>
     <div class="form-group">
    <label for="email">Twiiter Link *:</label>
    <input type="text" class="form-control txtfieldadmin" value="<?= $res['twitter_link']; ?>" placeholder="Twitter Link" name="twitter_link"> 
  </div>
  <div class="form-group">
    <label for="email">Pinterest Link *:</label>
    <input type="text" class="form-control txtfieldadmin" value="<?= $res['pinterest_link']; ?>" placeholder="Pinterest Link" name="pinterest_link"> 
  </div>
  <div class="form-group">
    <label for="email">Company Video link *:</label>
    <input type="text" class="form-control txtfieldadmin" value="<?= $res['company_video']; ?>" placeholder="company_video" name="company_video"> 
  </div>

    <input type="hidden" name="action" value="Update">
    <input name="f2" type="submit" class="button btn btn-success" value="Submit">  </td>

    </form>
    <?php
    admin_footer();
    exit;
    ?>