<?php include('inc/header.php');
$clientObj->select($org_id); 
if(isset($_POST['setting_submit']))
{
	$clientObj->school_name=sanitize($_POST['sh_name']);
	$clientObj->address=sanitize($_POST['sh_add']);
	$clientObj->attendance_type=sanitize($_POST['sh_attendance']);
	$clientObj->contact_email=sanitize($_POST['sh_email']);
	$clientObj->contact_person=sanitize($_POST['sh_contact']);
	$clientObj->country=sanitize($_POST['sh_country']);
	$clientObj->currency_type=sanitize($_POST['sh_currency']);
	$clientObj->end_date=sanitize($_POST['enddate']);
	$clientObj->fax=sanitize($_POST['sh_fax']);
	$clientObj->grading_type=sanitize($_POST['grading_1']).','.sanitize($_POST['grading_2']).','.sanitize($_POST['grading_3']);
	$clientObj->language=sanitize($_POST['sh_language']);
	
	
$file_exts = array("jpg", "bmp", "jpeg", "gif", "png");
$upload_exts = end(explode(".", $_FILES["file"]["name"]));

if ((($_FILES["file"]["type"] == "image/gif")

|| ($_FILES["file"]["type"] == "image/jpeg")

|| ($_FILES["file"]["type"] == "image/png")

|| ($_FILES["file"]["type"] == "image/pjpeg"))

&& ($_FILES["file"]["size"] < 15000)

&& in_array($upload_exts, $file_exts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
}
else
{
// Enter your path to <span id="IL_AD5" class="IL_AD">upload file</span> here
$filename=time().$_FILES["file"]["name"];
if (file_exists("uploads/".$filename))

{

}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],"uploads/".$filename);
$clientObj->logo=sanitize("uploads/".$filename);
}

}

}
else
{
$file_err=1;

}

	
	$clientObj->mobile=sanitize($_POST['sh_mobile']);
	$clientObj->phone_number=sanitize($_POST['sh_phone']);
	$clientObj->start_date=sanitize($_POST['startdate']);
	$clientObj->timezone=sanitize($_POST['timezone']);
	$clientObj->updated_date=date('Y-m-d H:i:s');
	$clientObj->update($org_id);
	$msg=1;
}?>
<!-- mobile navigation -->
			<nav id="mobile_navigation"></nav>
			
			<section id="breadcrumbs">
				<div class="container">
					<ul>
						<li><a href="#">Web school </a></li>
						<li><span>General Settings</span></li>						
					</ul>
				</div>
			</section>
			<section class="container clearfix main_section">
				<div id="main_content_outer" class="clearfix">
					<div id="main_content">
						<div class="alert alert-info">
											
							<strong>General Settings</strong>
						</div>
                            <?php 
						if($setting_error==1)
						{
						?>
                        <div class="warning">Hello ! Please Complete your settings page. It is very important to fill up your general settings before you start.</div>
                        <?php
						}?>
                        <?php 
						if($msg==1)
						{
						?>
                        <div class="success">Settings has been saved successfully</div>
                        <?php
						}?> 
                         <?php 
						if($file_err==1)
						{
						?>
                        <div class="warning">Sorry ! Could not upload your logo. jpg,png,jpeg and gif image types are only accepted and image size must be less than 15KB.</div>
                        <?php
						}?>
						<!-- main content -->
                        <form action="#" method="POST" id="general" name="general" enctype="multipart/form-data">
						<div class="row">
							<div class="col-sm-7">
								<div class="panel panel-default">
									<!--<div class="panel-heading">
										<h4 class="panel-title">Simple Validation</h4>
									</div>-->
									<div class="panel-body">
										
											<div class="form_sep">
												<label for="reg_input_name" class="req">School/College Name</label>
												<input type="text" id="sh_name" name="sh_name" class="form-control" data-required="true" value="<?php echo $clientObj->school_name; ?>">
											</div>
                                            
                                            <div class="form_sep">
												<label for="reg_textarea_message" class="req">School/College Address</label>
												<textarea name="sh_add" id="sh_add" cols="30" rows="4" class="form-control" data-required="true" data-minlength="40"><?php echo $clientObj->address; ?></textarea>
											</div>
                                           
                                            
											<div class="form_sep">
												<label for="reg_input_email" class="req">School/College Email</label>
												<input type="text" id="sh_email" name="sh_email" class="form-control" data-required="true" data-type="email" value="<?php echo $clientObj->contact_email; ?>">
											</div>
											 <div class="form_sep">
												<label for="reg_input_name" class="req">School/College Phone</label>
												<input type="text" id="sh_phone" name="sh_phone" class="form-control" data-required="true" value="<?php echo $clientObj->phone_number; ?>">
											</div> 
                                            <div class="form_sep">
												<label for="reg_input_name" class="req">School/College Mobile </label>
												<input type="text" id="sh_mobile" name="sh_mobile" class="form-control" data-required="true" value="<?php echo $clientObj->mobile; ?>">
											</div> 
                                             <div class="form_sep">
												<label for="reg_input_name" >School/College Fax </label>
												<input type="text" id="sh_fax" name="sh_fax" class="form-control"  value="<?php echo $clientObj->fax; ?>">
											</div>
                                            <div class="form_sep">
												<label for="reg_input_name" class="req">School/College Contact Person</label>
												<input type="text" id="sh_contact" name="sh_contact" class="form-control" data-required="true" value="<?php echo $clientObj->contact_person; ?>">
											</div>  
                                             											
											<div class="form_sep">
												<label for="reg_select" class="req">Country</label>
												<select name="sh_country" id="sh_country" class="form-control" data-required="true">
												<?php if($clientObj->country==''){ ?><option value="">Select Country</option><?php } else { echo '<option value="'.$clientObj->country.'">'.$clientObj->country.'</option>'; } ?>
													<?php echo country(); ?>

                
												</select>
											</div>
											
											
										
									</div>
								</div>
							</div>
                            <div class="col-sm-5">
								<div class="panel panel-default">
									<!--<div class="panel-heading">
										<h4 class="panel-title">Simple Validation</h4>
									</div>-->
									<div class="panel-body">
									
                                    		
											<div class="form_sep">
												<label for="reg_input_currency" class="req">Currency Type</label>
												<input type="text" id="sh_currency" name="sh_currency" class="form-control" data-required="true" value="<?php echo $clientObj->currency_type; ?>">
											</div>
										
											
											
											<div class="form_sep">
												<label for="Language">Language</label>
												<input type="text" id="sh_language" name="sh_language" class="form-control" readonly value="English" >
											</div>
                                            <div class="form_sep">
												<label for="Timezone" class="req">Timezone</label>
												<select name="timezone" id="timezone" class="form-control" data-required="true">
                                                <?php if($clientObj->timezone==''){ ?><option value="">Select Timezone</option><?php } else { echo '<option value="'.$clientObj->timezone.'">'.$clientObj->timezone.'</option>'; } ?>
													<?php echo timezone(); ?>
               
												</select>
											</div>
                                            <div class="form_sep">
												<label class="req">Start Date</label>
												<div class="input-group date startdate" data-date-format="yyyy-mm-dd">
													<input  name="startdate" id="startdate" class="form-control input_validate" type="text" data-required="true" data-type="dateIso" value="<?php if($clientObj->start_date=='0000-00-00 00:00:00'){ echo ''; } else { echo date('Y-m-d',strtotime($clientObj->start_date)); } ?>">
													<span class="input-group-addon"><i class="icon-calendar"></i></span>
												</div>
											</div>
                                            <div class="form_sep">
												<label class="req">End Date</label>
												<div class="input-group date enddate" data-date-format="yyyy-mm-dd">
													<input  name="enddate" id="enddate" class="form-control input_validate" type="text" data-required="true" data-type="dateIso" value="<?php if($clientObj->end_date=='0000-00-00 00:00:00'){ echo ''; } else { echo date('Y-m-d',strtotime($clientObj->end_date)); } ?>">
													<span class="input-group-addon"><i class="icon-calendar"></i></span>
												</div>
											</div>
                                            
												<div class="form_sep">
												<label for="reg_input_attendance" >Attendance</label>
												<input type="text" id="sh_attendance" name="sh_attendance" class="form-control" data-required="true" value="Daily" readonly>
											</div>
                                            <div class="form_sep">
												<label for="reg_input_logo" >Upload Logo</label>
												<input  type="file" id="file" name="file" class="" >
											</div>
											<div class="form_sep">
												<label >Grading System</label>
												<label for="reg_chbox_a"  class="checkbox-inline">
                                                <input  name="grading_1" id="grading_1" checked="checked" type="checkbox"  value="CCA">CCA</label>
												<label for="reg_chbox_b"  class="checkbox-inline">
                                                <input name="grading_2" id="grading_2" checked="checked"  type="checkbox"  value="CWA">CWA</label>
												<label for="reg_chbox_c" class="checkbox-inline">
                                                <input name="grading_3" id="grading_3" checked="checked" type="checkbox"  value="GPA">GPA</label>
											</div>
											
										
									</div>
								</div>
                                
							</div>
                            
						</div>
                        
						<div class="row">
							<div class="col-sm-5">
							<div class="form_sep">
												<button class="btn btn-success" type="submit" name="setting_submit" id="setting_submit" >Save</button>
											</div>
                                            </div>
						</div>
				</form>
						
						
							
						</div>
					</div>
				
			</section>
			<div id="footer_space"></div>
		</div>
	<?php include('inc/footer.php'); ?>