<?php 
$pgMod="site_setting";
     if($_POST)
    {

		      $ch = curl_init();
        $pcfile = new CURLFile($_FILES['principal_photo']['tmp_name'], $_FILES['principal_photo']['type'], $_FILES['principal_photo']['name']);
      
        $acfile = new CURLFile($_FILES['announcement_photo']['tmp_name'], $_FILES['announcement_photo']['type'], $_FILES['announcement_photo']['name']);
        $tcfile = new CURLFile($_FILES['toppers_photo']['tmp_name'], $_FILES['toppers_photo']['type'], $_FILES['toppers_photo']['name']);
        $lcfile = new CURLFile($_FILES['logo']['tmp_name'], $_FILES['logo']['type'], $_FILES['logo']['name']);
        $pocfile = new CURLFile($_FILES['Popup_image']['tmp_name'], $_FILES['Popup_image']['type'], $_FILES['Popup_image']['name']);
       
    //   if($_FILES['announcement_photo']['name'] !="" && $_FILES['principal_photo']['name'] !=""){
   
    //     $data = array("announcement_photo"=>$acfile,"principal_photo"=>$pcfile,"school_name"=>$_POST['school_name'],"email"=>$_POST['email'],
    //         "working_hrs"=>$_POST['working_hrs'],"address"=>$_POST['address'],
    //         "contact"=>$_POST['contact'],"admin_uname"=>$_POST['admin_uname'],
    //         "link"=>$_POST['link'],"admin_pwd"=>$_POST['admin_pwd'],
    //         "director_msg"=>$_POST['director_msg'],"principal_msg"=>$_POST['principal_msg'],
    //         "marquee"=>$_POST['marquee'],"color_code"=>$_POST['color_code']
    //         ,"facebook"=>$_POST['facebook'],"youtube"=>$_POST['youtube'],"twitter"=>$_POST['twitter']
    //         ,"linkedin"=>$_POST['linkedin'],"shows"=>$_POST['shows']);
    //   }
     
        if($_FILES['principal_photo']['name'] !=""){
      
        $data = array("principal_photo"=>$pcfile,"school_name"=>$_POST['school_name'],"email"=>$_POST['email'],
            "working_hrs"=>$_POST['working_hrs'],"address"=>$_POST['address'],
            "contact"=>$_POST['contact'],"admin_uname"=>$_POST['admin_uname'],
            "link"=>$_POST['link'],"admin_pwd"=>$_POST['admin_pwd'],
            "director_msg"=>$_POST['director_msg'],"principal_msg"=>$_POST['principal_msg'],
            "marquee"=>$_POST['marquee'],"color_code"=>$_POST['color_code']
            ,"facebook"=>$_POST['facebook'],"youtube"=>$_POST['youtube'],"twitter"=>$_POST['twitter']
            ,"linkedin"=>$_POST['linkedin'],"shows"=>$_POST['shows']);
       }
       
       else if($_FILES['announcement_photo']['name'] !=""){
      
        $data = array("announcement_photo"=>$acfile,"school_name"=>$_POST['school_name'],"email"=>$_POST['email'],
            "working_hrs"=>$_POST['working_hrs'],"address"=>$_POST['address'],
            "contact"=>$_POST['contact'],"admin_uname"=>$_POST['admin_uname'],
            "link"=>$_POST['link'],"admin_pwd"=>$_POST['admin_pwd'],
            "director_msg"=>$_POST['director_msg'],"principal_msg"=>$_POST['principal_msg'],
            "marquee"=>$_POST['marquee'],"color_code"=>$_POST['color_code']
            ,"facebook"=>$_POST['facebook'],"youtube"=>$_POST['youtube'],"twitter"=>$_POST['twitter']
            ,"linkedin"=>$_POST['linkedin'],"shows"=>$_POST['shows']);
       }
       
     
       
      else  if($_FILES['toppers_photo']['name'] !=""){
      
        $data = array("toppers_photo"=>$tcfile,"school_name"=>$_POST['school_name'],"email"=>$_POST['email'],
            "working_hrs"=>$_POST['working_hrs'],"address"=>$_POST['address'],
            "contact"=>$_POST['contact'],"admin_uname"=>$_POST['admin_uname'],
            "link"=>$_POST['link'],"admin_pwd"=>$_POST['admin_pwd'],
            "director_msg"=>$_POST['director_msg'],"principal_msg"=>$_POST['principal_msg'],
            "marquee"=>$_POST['marquee'],"color_code"=>$_POST['color_code']
            ,"facebook"=>$_POST['facebook'],"youtube"=>$_POST['youtube'],"twitter"=>$_POST['twitter']
            ,"linkedin"=>$_POST['linkedin'],"shows"=>$_POST['shows']);
       }
       
     else  if($_FILES['logo']['name'] !=""){
      
        $data = array("logo"=>$lcfile,"school_name"=>$_POST['school_name'],"email"=>$_POST['email'],
            "working_hrs"=>$_POST['working_hrs'],"address"=>$_POST['address'],
            "contact"=>$_POST['contact'],"admin_uname"=>$_POST['admin_uname'],
            "link"=>$_POST['link'],"admin_pwd"=>$_POST['admin_pwd'],
            "director_msg"=>$_POST['director_msg'],"principal_msg"=>$_POST['principal_msg'],
            "marquee"=>$_POST['marquee'],"color_code"=>$_POST['color_code']
            ,"facebook"=>$_POST['facebook'],"youtube"=>$_POST['youtube'],"twitter"=>$_POST['twitter']
            ,"linkedin"=>$_POST['linkedin'],"shows"=>$_POST['shows']);
       }
       
    else   if($_FILES['Popup_image']['name'] !=""){
      
        $data = array("Popup_image"=>$pocfile,"school_name"=>$_POST['school_name'],"email"=>$_POST['email'],
            "working_hrs"=>$_POST['working_hrs'],"address"=>$_POST['address'],
            "contact"=>$_POST['contact'],"admin_uname"=>$_POST['admin_uname'],
            "link"=>$_POST['link'],"admin_pwd"=>$_POST['admin_pwd'],
            "director_msg"=>$_POST['director_msg'],"principal_msg"=>$_POST['principal_msg'],
            "marquee"=>$_POST['marquee'],"color_code"=>$_POST['color_code']
            ,"facebook"=>$_POST['facebook'],"youtube"=>$_POST['youtube'],"twitter"=>$_POST['twitter']
            ,"linkedin"=>$_POST['linkedin'],"shows"=>$_POST['shows']);
       }
       
    //   if($_FILES['announcement_photo']['name'] !="" && $_FILES['principal_photo']['name'] !="" && $_FILES['toppers_photo']['name'] !=""&&
    //   $_FILES['logo']['name'] !="" && $_FILES['Popup_image']['name'] !=""){
    //          $data = array("announcement_photo"=>$acfile,"principal_photo"=>$pcfile,
    //          "toppers_photo"=>$tcfile,"logo"=>$lcfile,"Popup_image"=>$pocfile,
    //          "school_name"=>$_POST['school_name'],"email"=>$_POST['email'],
    //         "working_hrs"=>$_POST['working_hrs'],"address"=>$_POST['address'],
    //         "contact"=>$_POST['contact'],"admin_uname"=>$_POST['admin_uname'],
    //         "link"=>$_POST['link'],"admin_pwd"=>$_POST['admin_pwd'],
    //         "director_msg"=>$_POST['director_msg'],"principal_msg"=>$_POST['principal_msg'],
    //         "marquee"=>$_POST['marquee'],"color_code"=>$_POST['color_code']
    //         ,"facebook"=>$_POST['facebook'],"youtube"=>$_POST['youtube'],"twitter"=>$_POST['twitter']
    //         ,"linkedin"=>$_POST['linkedin'],"shows"=>$_POST['shows']);
    //   }
       
       else{
            $data = array("school_name"=>$_POST['school_name'],"email"=>$_POST['email'],
            "working_hrs"=>$_POST['working_hrs'],"address"=>$_POST['address'],
            "contact"=>$_POST['contact'],"admin_uname"=>$_POST['admin_uname'],
            "link"=>$_POST['link'],"admin_pwd"=>$_POST['admin_pwd'],
            "director_msg"=>$_POST['director_msg'],"principal_msg"=>$_POST['principal_msg'],
            "marquee"=>$_POST['marquee'],"color_code"=>$_POST['color_code']
            ,"facebook"=>$_POST['facebook'],"youtube"=>$_POST['youtube'],"twitter"=>$_POST['twitter']
            ,"linkedin"=>$_POST['linkedin'],"shows"=>$_POST['shows']);
       }

        $url = "https://bps.savarnacloudtech.com/api/site_setting.php";
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
        $responce = curl_exec($ch);

        redirect(URL_ADMIN_HOME.getQueryString(array("src"=>"website", "page_id"=>$pgMod)));

}	
?>

<?php 

$aryPgAct=array("src"=>"website", "page_id"=>$pgMod,"action"=>"add");

            $url = "https://bps.savarnacloudtech.com/api/get_site_setting.php";

            $context  = stream_context_create($options);
            $result = file_get_contents($url, false, $context);

            $data = json_decode($result,true);
            // print_r($data);
?>
	<div class="row-fluid">
        <form method="post" action="" enctype="multipart/form-data">
			<!-- Forms: Box -->
			<div class="span12">

				<!-- Forms: Top Bar -->
				<div class="top-bar">
					<h3><i class="icon-cog"></i>Site Setting</h3>
				</div>
				<!-- / Forms: Top Bar -->

				<!-- Forms: Content -->
				<div class="well no-padding">

						<input type="hidden" name="temp" value="">
                        
                        <div class="control-group">
							<label class="control-label" for="heading">School Name</label>
							<div class="controls">
								<input type="text" id="image" name="school_name" class="input-block-level" value="<?php echo $data["school_name"]; ?>" >
							</div>
						</div>
                         <div class="control-group">
							<label class="control-label" for="heading">School Address</label>
							<div class="controls">
								<input type="text" id="image" name="address" class="input-block-level" value="<?php echo $data["address"]; ?>" >
							</div>
						</div>
                         <div class="control-group">
							<label class="control-label" for="heading">School Email</label>
							<div class="controls">
								<input type="text" id="image" name="email" class="input-block-level" value="<?php echo $data["email"]; ?>" >
							</div>
						</div>
                         <div class="control-group">
							<label class="control-label" for="heading">Contact No.</label>
							<div class="controls">
								<input type="text" id="image" name="contact" class="input-block-level" value="<?php echo $data["contact"]; ?>">
							</div>
						</div>
                         <div class="control-group">
							<label class="control-label" for="heading">Working Hours</label>
							<div class="controls">
								<input type="text" id="image" name="working_hrs" class="input-block-level" value="<?php echo $data["working_hrs"]; ?>" >
							</div>
						</div>
                         <div class="control-group">
							<label class="control-label" for="heading">Admin uname</label>
							<div class="controls">
								<input type="text" id="image" name="admin_uname" class="input-block-level" value="<?php echo $data["admin_uname"]; ?>">
							</div>
						</div>
                         <div class="control-group">
							<label class="control-label" for="heading">Link</label>
							<div class="controls">
								<input type="text" id="image" name="link" class="input-block-level" value="<?php echo $data["link"]; ?>">
							</div>
						</div>
                         <div class="control-group">
							<label class="control-label" for="heading">Admin Pwd</label>
							<div class="controls">
								<input type="text" id="image" name="admin_pwd" class="input-block-level" value="<?php echo $data["admin_pwd"]; ?>">
							</div>
						</div>
                         <div class="control-group">
							<label class="control-label" for="heading">Director's Message</label>
							<div class="controls">
								<textarea rows="5" name="director_msg" class="input-block-level"><?php echo $data["director_msg"]; ?></textarea>
							</div>
						</div>
                         <div class="control-group">
							<label class="control-label" for="heading">Principal's Message</label>
							<div class="controls">
								<textarea rows="5" name="principal_msg" class="input-block-level"><?php echo $data["principal_msg"]; ?></textarea>
							</div>
						</div>
                         <div class="control-group">
							<label class="control-label" for="heading">Marquee News</label>
							<div class="controls">
								<input type="text" id="image" name="marquee" value="<?php echo $data["marquee"]; ?>" class="input-block-level" >
							</div>
						</div>
                         <div class="control-group">
							<label class="control-label" for="heading">Theme Color Code</label>
							<div class="controls">
								<input type="text" id="image" name="color_code" value="<?php echo $data["color_code"]; ?>" class="input-block-level" >
							</div>
						</div>
                        
                        <div class="control-group">
            					<label class="control-label" for="heading">Facebook Link</label>
            					<div class="controls">
            						<input type="text" id="image" name="facebook" value="<?php echo $data["facebook"]; ?>" class="input-block-level" >
            					</div>
            				</div>
                                    <div class="control-group">
            					<label class="control-label" for="heading">YouTube</label>
            					<div class="controls">
            						<input type="text" id="image" name="youtube" value="<?php echo $data["youtube"]; ?>" class="input-block-level" >
            					</div>
            				</div>
                                    <div class="control-group">
            					<label class="control-label" for="heading">Twitter</label>
            					<div class="controls">
            						<input type="text" id="image" name="twitter" value="<?php echo $data["twitter"]; ?>" class="input-block-level" >
            					</div>
            				</div>
                            <div class="control-group">
            					<label class="control-label" for="heading">LinkedIn</label>
            					<div class="controls">
            						<input type="text" id="image" name="linkedin" value="<?php echo $data["linkedin"]; ?>" class="input-block-level" >
            					</div>
            				</div>
                <!--                    <div class="control-group">-->
            				<!--	<label class="control-label" for="heading">Director Photo</label>-->
            				<!--	<div class="controls">-->
            				<!--		<input type="file" id="image" name="director_photo" class="input-block-level" >-->
            				<!--		  <?php if($data["director_photo"]!=""){ ?>-->
                <!--                    <img src="<?php echo $data["director_photo"]; ?>" style="width: 250px;">-->
                <!--                <?php } ?>-->
            				<!--	</div>-->
            					
            				<!--</div>-->
                                    <div class="control-group">
            					<label class="control-label" for="heading">Principal Photo</label>
            					<div class="controls">
            						<input type="file" id="principal_photo" name="principal_photo" class="input-block-level" >
            						  <?php if($data["principal_photo"]!=""){ ?>
                                    <img src="<?php echo $data["principal_photo"]; ?>" style="width: 250px;">
                                <?php } ?>
            					</div>
            					
            				</div>
            				
            				  <div class="control-group">
            					<label class="control-label" for="heading">Announcement Photo</label>
            					<div class="controls">
            						<input type="file" id="image" name="announcement_photo" class="input-block-level" >
            						  <?php if($data["announcement_photo"]!=""){ ?>
                                    <img src="<?php echo $data["announcement_photo"]; ?>" style="width: 250px;">
                                <?php } ?>
            					</div>
            					
            				</div>
            				<div class="control-group">
            					<label class="control-label" for="heading">Topper's Photo</label>
            					<div class="controls">
            						<input type="file" id="image" name="toppers_photo" class="input-block-level" >
            						  <?php if($data["toppers_photo"]!=""){ ?>
                                    <img src="<?php echo $data["toppers_photo"]; ?>" style="width: 250px;">
                                <?php } ?>
            					</div>
            					
            				</div>
            				<div class="control-group">
            					<label class="control-label" for="heading">School Logo</label>
            					<div class="controls">
            						<input type="file" id="image" name="logo" class="input-block-level" >
            						  <?php if($data["logo"]!=""){ ?>
                                    <img src="<?php echo $data["logo"]; ?>" style="width: 250px;">
                                <?php } ?>
            					</div>
            					
            				</div>
                                 
                               	<div class="control-group">
            					<label class="control-label" for="heading">Popup Image</label>
            					<div class="controls">
            						<input type="file" id="image" name="Popup_image" class="input-block-level" >
            						  <?php if($data["Popup_image"]!=""){ ?>
                                    <img src="<?php echo $data["Popup_image"]; ?>" style="width: 250px;">
                                <?php } ?>
            					</div>
            					
            				</div>
                                 
                             <div class="control-group">
            					<label class="control-label" for="heading">Choose</label>
            					<div class="controls">
            				  <label >Show</label>
                               <?php if($data["shows"]==1){ ?>
                                <input type="radio" name="shows" value="1" checked  />
                                <?php } 
                                else{
                                ?>
                                <input type="radio" name="shows" value="1"   />
                                <?php } ?>
                                <label >Hide</label>
                               <?php if($data["shows"]==0){ ?>
                                <input type="radio" name="shows" value="0" checked  />
                                <?php } 
                                else{
                                ?>
                                <input type="radio" name="shows" value="0"   />
                                <?php } ?>
            						
            					</div>
            					
            				</div>
                                 
                                        

						<div class="form-actions">
                        
							<button type="submit" class="btn btn-primary"> Save</button>
							<button type="button" class="btn"> Cancel</button>
						</div>
                        
				</div>
				<!-- / Forms: Content -->

			</div>
			<!-- / Forms: Box -->

        </form>
	</div>