<?php

include_once("../include/main.inc.php");

check_session('MyCpanel', 'index.php');


if ($_POST['action'] == "Update") {

   


  @extract($_POST);

  $scroll_text = htmlentitiesDecode($scroll_text);
  $analitic = htmlentitiesDecode($analitic);

  if($_FILES['logo']['size'] > 0 && $_FILES['logo']['error'] == 0){

  
          $file_extension = strtolower(getExtension($_FILES['logo']['name']));
          if ($file_extension != "png" && $file_extension != "webp") {
            $_SESSION['session_message'] = '<div class="btn btn-danger"> Please upload image (.png,.webp Format Only) </div>';
         
            header("Location: " . SITE_ADMIN_URL . "/general-setting.php");
            exit;
          }
          $img_name = 'webpulse-solution-pvt-ltd';
          $img = upload_file($img_name, "logo", "uploaded-files/company");

          updateTable("admin_details", "logo='$img' where user_type='admin'");

  }


  updateTable("admin_details", " name='$name', email='$email', cc='$cc', subject='$subject',address='$address',city='$city',state='$state',country='$country',companyName='$companyName', phone='$phone',mobile='$mobile',whatsapp_no='$whatsapp_no',fax='$fax',facebook = '$facebook', instagram = '$instagram', linkedin='$linkedin', youtube='$youtube', twitter='$twitter',company_video='$company_video',map='$map',zipcode='$zipcode',gstno='$gstno',gstrate='$gstrate',donglerate='$donglerate',establish='$establish',scroll_text='$scroll_text',analitic='$analitic',company_url='$company_url',map_delhi='$map_delhi',add_ranchi='$add_ranchi',map_ranchi='$map_ranchi',add_uk='$add_uk',map_uk='$map_uk',add_aus='$add_aus',map_aus='$map_aus',mobile_meta='$mobile_meta',targetlocation='$targetlocation' where user_type='admin'");

  //$_SESSION['session_message'] = '<div class="btn btn-success">Admin details have been updated successfully </div>';
  header("Location:" . admin_url . "general-setting.php");

}
unset($_SESSION['session_message']);
$res = getResult("admin_details", " where user_type='admin'");

admin_header();

?>

<div class="content-wrapper">

    <div class="page-header">

        <h3 class="page-title p-3">Manage Admin Details</h3>

    </div>

    <div class="row">

        <div class="col-12 grid-margin stretch-card">

            <div class="card">

                <div class="card-body">

                    <form class="forms-sample" method="post" action="" enctype="multipart/form-data"
                        onsubmit="return validate(this);">

                        <?php if(isset($_SESSION['session_message']))
                        {?>
                        <div class="form-group" id="message">

                            <?php
                        echo $_SESSION['session_message'];
                      
                        
                        
      ?>

                        </div>
                        <?php }?>

                        <div class="form-group row">

                            <div class="col">

                                <label>Company Name</label>

                                <div id="the-basics">

                                    <input class="typeahead" type="text" name="companyName" placeholder="Company Name"
                                        value="<?=$res['companyName']?>">

                                </div>

                            </div>

                            <div class="col">

                                <label>Owner Name</label>

                                <div id="bloodhound">

                                    <input class="typeahead" type="text" name="name" value="<?=$res['name']?>"
                                        placeholder="Owner Name">

                                </div>

                            </div>

                            <div class="col">

                                <label>Establish Year</label>

                                <div id="bloodhound">

                                    <input class="typeahead" type="text" name="establish" value="<?=$res['establish']?>"
                                        placeholder="Establish Year">

                                </div>

                            </div>

                        </div>


                        <div class="form-group row">
                            <div class="col">
                                <label>Company Logo </label>
                                <input type="file" class="dropify" name="logo">
                            </div>
                            <div class="col">

                                <img src="<?=site_url."/uploaded-files/company/".$res['logo']?>" alt="Logo"
                                    style="width: 60%;">
                            </div>
                        </div>


                        <div class="form-group">

                            <label>Subject</label>

                            <input class="typeahead" type="text" name="subject" value="<?=$res['subject']?>"
                                placeholder="Subject">

                        </div>

                        <!-- <div class="form-group">

                            <label>Header Top Text</label>

                            <input class="typeahead" type="text" name="scroll_text" value="<?=$res['scroll_text']?>"
                                placeholder="Header Text">

                        </div> -->

                        <div class="form-group row">

                            <div class="col">

                                <label>Company Video</label>

                                <div id="the-basics">

                                    <input class="typeahead" type="text" name="company_video"
                                        value="<?=$res['company_video']?>" placeholder="Company Video">

                                </div>

                            </div>

                            <div class="col">

                                <label>Email Id</label>

                                <div id="the-basics">

                                    <input class="typeahead" type="email" name="email" value="<?=$res['email']?>"
                                        placeholder="Email Id" >

                                </div>

                            </div>

                            <div class="col">

                                <label>Alternate Email Id</label>

                                <div id="bloodhound">

                                    <input class="typeahead" type="email" name="cc" value="<?=$res['cc']?>"
                                        placeholder="Alternate Email Id">

                                </div>

                            </div>

                        </div>

                        <div class="form-group row">

                            <div class="col">

                                <label>Mobile No.</label>

                                <div id="the-basics">

                                    <input class="typeahead" type="tel" name="mobile" value="<?=$res['mobile']?>"
                                        placeholder="Mobile No.">

                                </div>

                            </div>

                            <div class="col">

                                <label>Phone No.</label>

                                <div id="the-basics">

                                    <input class="typeahead" type="tel" name="phone" value="<?=$res['phone']?>"
                                        placeholder="Phone No." >

                                </div>

                            </div>

                            <div class="col">

                                <label>Whatsapp No.</label>

                                <div id="bloodhound">

                                    <input class="typeahead" type="tel" name="whatsapp_no"
                                        value="<?=$res['whatsapp_no']?>" placeholder="Whatsapp No,">

                                </div>

                            </div>

                        </div>

                        <div class="form-group row">
                            <div class="col">

                                <label>Mobile No. (Meta)</label>

                                <div id="bloodhound">

                                    <input class="typeahead" type="text" name="mobile_meta"
                                        value="<?=$res['mobile_meta']?>" placeholder="Mobile No. for Meta tag">

                                </div>

                            </div>

                            <div class="col">

                                <label>Fax</label>

                                <div id="the-basics">

                                    <input class="typeahead" type="text" name="fax" value="<?=$res['fax']?>"
                                        placeholder="Fax">

                                </div>

                            </div>

                            <div class="col">

                                <label>Zip Code</label>

                                <div id="the-basics">

                                    <input class="typeahead" type="tel" name="zipcode" value="<?=$res['zipcode']?>"
                                        placeholder="Zip Code" >

                                </div>

                            </div>



                        </div>

                        <div class="form-group row">

                            <div class="col">

                                <label>City</label>

                                <div id="the-basics">

                                    <input class="typeahead" type="text" name="city" value="<?=$res['city']?>"
                                        placeholder="City" >

                                </div>

                            </div>

                            <div class="col">

                                <label>State</label>

                                <div id="the-basics">

                                    <input class="typeahead" type="text" name="state" value="<?=$res['state']?>"
                                        placeholder="State">

                                </div>

                            </div>

                            <div class="col">

                                <label>Country</label>

                                <div id="bloodhound">

                                    <input class="typeahead" type="text" name="country" value="<?=$res['country']?>"
                                        placeholder="Country" >

                                </div>

                            </div>

                        </div>
                        <div class="form-group row">
                            <div class="col">

                                <label>Target Location</label>

                                <div id="bloodhound">

                                    <input class="typeahead" type="text" name="targetlocation"
                                        value="<?=$res['targetlocation']?>" placeholder="Target Location">

                                </div>

                            </div>

                            <div class="col">

                                <label>GST Number</label>

                                <div id="the-basics">

                                    <input class="typeahead" type="text" name="gstno" value="<?=$res['gstno']?>"
                                        placeholder="GST Number">

                                </div>

                            </div>

                            <div class="col">

                                <label>GST Rate(%)</label>

                                <div id="the-basics">

                                    <input class="typeahead" type="text" name="gstrate" value="<?=$res['gstrate']?>"
                                        placeholder="GST Rate(%)">

                                </div>

                            </div>
                        </div>
                        <!-- <div class="form-group">

                            <label for="exampleTextarea1">Address</label>

                            <textarea class="form-control" name="address" rows="8"
                                required><?=$res['address']?></textarea>

                        </div> -->

                        <div class="form-group row">

                            <div class="col">

                                <label>Address</label>

                                <div id="the-basics">
                                    <textarea class="form-control" name="address"
                                        rows="8"><?=$res['address']?></textarea>

                                </div>

                            </div>

                            <div class="col">

                                <label>Map</label>

                                <div id="the-basics">
                                    <textarea class="form-control" name="map_delhi"
                                        rows="8"><?=$res['map_delhi']?></textarea>

                                </div>

                            </div>

                        </div>

                        <!-- <div class="form-group row">

                            <div class="col">

                                <label>Address Ranchi</label>

                                <div id="the-basics">
                                    <textarea class="form-control" name="add_ranchi"
                                        rows="8"><?=$res['add_ranchi']?></textarea>

                                </div>

                            </div>

                            <div class="col">

                                <label>Map Ranchi</label>

                                <div id="the-basics">
                                    <textarea class="form-control" name="map_ranchi"
                                        rows="8"><?=$res['map_ranchi']?></textarea>

                                </div>

                            </div>

                        </div>

                        <div class="form-group row">

                            <div class="col">

                                <label>Address UK</label>

                                <div id="the-basics">
                                    <textarea class="form-control" name="add_uk" rows="8"><?=$res['add_uk']?></textarea>

                                </div>

                            </div>

                            <div class="col">

                                <label>Map UK</label>

                                <div id="the-basics">
                                    <textarea class="form-control" name="map_uk" rows="8"><?=$res['map_uk']?></textarea>

                                </div>

                            </div>

                        </div>

                        <div class="form-group row">

                            <div class="col">

                                <label>Address Australia</label>

                                <div id="the-basics">
                                    <textarea class="form-control" name="add_aus"
                                        rows="8"><?=$res['add_aus']?></textarea>

                                </div>

                            </div>

                            <div class="col">

                                <label>Map Australia</label>

                                <div id="the-basics">
                                    <textarea class="form-control" name="map_aus"
                                        rows="8"><?=$res['map_aus']?></textarea>

                                </div>

                            </div>

                        </div> -->






                        <div class="form-group">

                            <label for="exampleTextarea1">Analytic Code, Websmater & Pixel Code etc.</label>

                            <textarea class="form-control" name="analitic" rows="10"><?=$res['analitic']?></textarea>

                        </div>







                        <div class="form-group row">

                            <div class="col">

                                <label>Facebook</label>

                                <div id="the-basics">

                                    <input class="typeahead" type="text" name="facebook" value="<?=$res['facebook']?>"
                                        placeholder="Facebook">

                                </div>

                            </div>

                            <div class="col">

                                <label>X</label>

                                <div id="bloodhound">

                                    <input class="typeahead" type="text" name="twitter" value="<?=$res['twitter']?>"
                                        placeholder="X">

                                </div>

                            </div>

                        </div>

                        <div class="form-group row">

                            <div class="col">

                                <label>Youtube</label>

                                <div id="the-basics">

                                    <input class="typeahead" type="text" name="youtube" value="<?=$res['youtube']?>"
                                        placeholder="Youtube">

                                </div>

                            </div>

                            <div class="col">

                                <label>Linkedin</label>

                                <div id="bloodhound">

                                    <input class="typeahead" type="text" name="linkedin" value="<?=$res['linkedin']?>"
                                        placeholder="Linkedin">

                                </div>

                            </div>

                        </div>

                        <div class="form-group row">

                            <div class="col">

                                <label>Instagram</label>

                                <div id="the-basics">

                                    <input class="typeahead" type="text" name="instagram" value="<?=$res['instagram']?>"
                                        placeholder="Instagram">

                                </div>

                            </div>

                            <div class="col">

                                <label>Pinterest</label>

                                <div id="bloodhound">

                                    <input class="typeahead" type="text" name="pinterest" value="<?=$res['pinterest']?>"
                                        placeholder="Pinterest">

                                </div>

                            </div>

                        </div>

                        <button type="submit" class="btn btn-primary mr-2" name="add_record">Submit</button>

                        <input type="hidden" name="action" value="Update">

                    </form>

                </div>

            </div>

        </div>

    </div>

</div>

<!-- content-wrapper ends -->

<?php

    admin_footer();

    exit;

    ?>