<?php session_start(); ?> <!-- session start -->
<?php include("../include/config.php"); ?> <!-- database connection -->
<?php include("../include/connect_url.php"); ?> <!-- connection url/link folder -->
<?php include("../include/date_time.php"); ?> <!-- date & time format -->
<?php include("../database/account.php"); ?> <!-- query database account -->
<?php include("../include/lang.php"); ?> <!-- language -->
<?php include("../include/session_login.php"); ?> <!-- session login -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<title><?php include("../template/title.php"); ?></title>

<link rel="shortcut icon" href="<?php echo $connect_url_data; ?>/favicon.ico" />

<link href="<?php echo $connect_url_data; ?>/css/styles.css" rel="stylesheet" type="text/css" />
<!--[if IE]> <link href="<?php echo $connect_url_data; ?>/css/ie.css" rel="stylesheet" type="text/css"> <![endif]-->
<link rel="stylesheet" href="<?php echo $connect_url_data; ?>/font/font-awesome-4.3.0/css/font-awesome.min.css">

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/download/jquery183.js"></script> 
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/download/jquery192.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/charts/excanvas.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/charts/jquery.flot.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/charts/jquery.flot.orderBars.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/charts/jquery.flot.pie.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/charts/jquery.flot.resize.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/charts/jquery.sparkline.min.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/tables/jquery.dataTables.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/tables/jquery.sortable.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/tables/jquery.resizable.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.autosize.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.uniform.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.inputlimiter.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.tagsinput.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.maskedinput.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.autotab.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.select2.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.dualListBox.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.cleditor.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.ibutton.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.validationEngine-en.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.validationEngine.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/globalize/globalize.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/globalize/globalize.culture.de-DE.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/globalize/globalize.culture.ja-JP.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/uploader/plupload.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/uploader/plupload.html4.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/uploader/plupload.html5.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/uploader/jquery.plupload.queue.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/wizards/jquery.form.wizard.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/wizards/jquery.validate.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/wizards/jquery.form.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.collapsible.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.breadcrumbs.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.tipsy.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.progress.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.timeentry.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.colorpicker.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.jgrowl.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.fancybox.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.fileTree.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.sourcerer.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/others/jquery.fullcalendar.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/others/jquery.elfinder.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.mousewheel.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.easytabs.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/files/bootstrap.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/files/functions.js"></script>

</head>

<body>

<?php    
$query_consultant2 = mysql_query("SELECT * FROM tbl_consultant WHERE id='$_GET[consultant_id]'"); 
while($row= mysql_fetch_assoc($query_consultant2))
{
    $db_consultant2_id = $row['id'];
    $db_consultant2_consultant_no = $row['consultant_no'];
    $db_consultant2_image = $row['image'];
    $db_consultant2_firstname = $row['firstname'];
    $db_consultant2_middlename = $row['middlename'];
    $db_consultant2_lastname = $row['lastname'];
    $db_consultant2_birth_date = $row['birth_date'];
    $db_consultant2_gender = $row['gender'];
    $db_consultant2_address = $row['address'];
    $db_consultant2_phone_no = $row['phone_no'];
    $db_consultant2_mobile_no = $row['mobile_no'];
    $db_consultant2_email = $row['email'];
    $db_consultant2_date = $row['date'];
    $db_consultant2_time = $row['time'];
    $db_consultant2_a_status = $row['a_status'];
}
?>



<?php
if($_POST)
{
$query_consultant1= mysql_query("SELECT * FROM tbl_consultant");
while($row= mysql_fetch_assoc($query_consultant1))
{
    $db_consultant1_id= $row['id'];
}
    $db_consultant1_id_add = $db_consultant1_id + 1;
    $db_consultant1_id_add_comp = "$date_year$db_consultant1_id_add";


$image_extension_allowed = array('jpg','gif','png','');
$image_name = strtolower($_FILES['image']['name']);
$image_extension = strtolower(end(explode('.', $image_name)));
$image_tmp_name  = $_FILES['image']['tmp_name'];
$image_size = $_FILES['image']['size'];
$image_type = $_FILES['image']['type'];


$firstname =mysql_real_escape_string(ucwords($_POST['firstname']));
$middlename =mysql_real_escape_string(ucwords($_POST['middlename']));
$lastname =mysql_real_escape_string(ucwords($_POST['lastname']));
$birth_date =$_POST['birth_date'];
$gender =$_POST['gender'];
$address =mysql_real_escape_string($_POST['address']);
$phone_no =mysql_real_escape_string($_POST['phone_no']);
$mobile_no =mysql_real_escape_string($_POST['mobile_no']);
$email =mysql_real_escape_string($_POST['email']);

$a_status = $_POST['a_status'];

if($image_name)
{

if(in_array($image_extension, $image_extension_allowed)=== false){ 	 
die ("<script>  
alert('File extension for image is not allowed.');
window.location.href='javascript:history.back();';
</script>");
}     

if(!get_magic_quotes_gpc())
	{
		$image_name =addslashes($image_name);
	}
        
if($image_name=="")
{
die("<script>	
alert('ERROR: Please select file.'); 
window.location.href='javascript:history.back();';		
</script> ");
}

$rand_number = rand(1, 1000000);
$file_image_generate = "$db_consultant1_id_add_comp$rand_number-$image_name";

if (move_uploaded_file($image_tmp_name, "../images/consultant/".$file_image_generate)){
}

$sql = "UPDATE tbl_consultant SET image= '$file_image_generate'  WHERE id = '$db_consultant2_id'";
$result = mysql_query($sql) or die("Error: Failed to Update!");

}
//end if image



if($firstname==""){
die ("<script> alert('Please fill firstname.');
window.location.href='javascript:history.back();';		
</script> ");
}


$sql = "UPDATE tbl_consultant SET  firstname='$firstname', middlename='$middlename', lastname='$lastname', birth_date='$birth_date', gender='$gender', address='$address', phone_no='$phone_no', mobile_no='$mobile_no', email='$email', a_status='$a_status' WHERE  id ='$db_consultant2_id '";
$result = mysql_query($sql) or die("Error: Failed to Update!");

die ("<script> alert('Saved.');
window.close();		
</script> ");
}
?>


	

  <form name="form" id="form" action="<?php echo $connect_url_data; ?>/consultant/e/<?php echo $db_consultant2_id; ?>" class="main" method="POST"  enctype="multipart/form-data">
            <fieldset style="margin-top:-35px;">
                <div class="widget fluid">
                    <div class="whead"><h6><span class="fa fa-edit" style="margin-top:-2px;"></span>&nbsp; <?php echo $lang['Profile']; ?>Edit Consultant</h6></div>
                    
		    <!-- Tabs -->
		<div class="fluid" >
                <div class="widget grid12" style="margin-top:-0px;">       
                    <div class="tabs">
                        <ul>
                            <li><a href="#tabs-1"><?php echo $lang['Profile']; ?>Consultant Information</a></li>
                        </ul>
			
			
			
                <div id="tabs-1">
		    
		    <?php if($db_consultant2_image){?>
		    <div class="formRow">
                            <div class="grid2"><label><?php echo $lang['Preview']; ?>:</label> </div>
                            <div class="grid10">
                                <img src="<?php echo $connect_url_data; ?>/images/consultant/<?php echo $db_consultant2_image; ?>" width="100" height="100">
                            </div>
                     </div>
		    <?php } ?>
		    
		    <div class="formRow">
                            <div class="grid2"><label><?php echo $lang['Profile Picture']; ?>:</label> </div>
                            <div class="grid10">
                                <input type="file" class="styled" name="image" id="image" /> (file format: jpg, png, gif)
                            </div>
                     </div>
		    
		    <div class="formRow">
                        <div class="grid2"><label><?php echo $lang['Firstname']; ?>:</label></div>
                        <div class="grid10"><input type="text" name="firstname" id="firstname" value="<?php echo $db_consultant2_firstname; ?>"/></div>
                    </div>
		    
		    <div class="formRow">
                        <div class="grid2"><label><?php echo $lang['Middlename']; ?>:</label></div>
                        <div class="grid10"><input type="text" name="middlename" id="middlename" value="<?php echo $db_consultant2_middlename; ?>"/></div>
                    </div>
		    
		     <div class="formRow">
                        <div class="grid2"><label><?php echo $lang['Lastname']; ?>:</label></div>
                        <div class="grid10"><input type="text" name="lastname" id="lastname" value="<?php echo $db_consultant2_lastname; ?>"/></div>
                    </div>
		    
		    <div class="formRow">
                    <div class="grid2"><label><?php echo $lang['Birth Date']; ?>:</label></div>
                    <div class="grid10"><input class="span12" type="date" name="birth_date" id="birth_date" value="<?php echo $db_consultant2_birth_date; ?>"/></div>
                    </div>
		    
		    <div class="formRow">
                            <div class="grid2"><label><?php echo $lang['Gender']; ?>:</label></div>
                            <div class="grid10">
				<select name="gender" id="gender"  data-placeholder="Choose" class="select" tabindex="2" style="width:100%;">
				<?php if($db_consultant2_gender=="Male"){
			        echo "<option value='Male'>Male</option>
				<option value='Female'>Female</option>";
				}?>
			        <?php if($db_consultant2_gender=="Female"){
			        echo "<option value='Female'>Female</option>
				<option value='Male'>Male</option>
				";
				}?>
				</select>
                            </div>             
                    </div>
		    
		    <div class="formRow">
                        <div class="grid2"><label><?php echo $lang['Address']; ?>:</label></div>
                        <div class="grid10">
                            <textarea rows="8" cols="" name="address" id="address" class="auto lim"><?php echo $db_consultant2_address; ?></textarea>
                            <span class="note" id="limitingtext">Field limited to 100 characters.</span>
                        </div>
                    </div>
		      
		    <div class="formRow">
                    <div class="grid2"><label><?php echo $lang['Phone No']; ?>:</label></div>
                    <div class="grid10"><input class="span12" type="number" name="phone_no" id="phone_no" value="<?php echo $db_consultant2_phone_no; ?>"/></div>
                    </div>
		    
		    <div class="formRow">
                    <div class="grid2"><label><?php echo $lang['Mobile No']; ?>:</label></div>
                    <div class="grid10"><input class="span12" type="number" name="mobile_no" id="mobile_no" value="<?php echo $db_consultant2_mobile_no; ?>"/></div>
                    </div>
		         
		    <div class="formRow">
                    <div class="grid2"><label><?php echo $lang['Email']; ?>:</label></div>
                    <div class="grid10"><input class="span12" type="email" name="email" id="email" value="<?php echo $db_consultant2_email; ?>"/></div>
		    </div>
		       
		       
		     <div class="formRow">
                            <div class="grid2"><label><?php echo $lang['Status']; ?>:</label></div>
                            <div class="grid10">
                               <select name="a_status" id="a_status" class="select" tabindex="2" style="width:100%;">
				<?php
				if($db_consultant2_a_status==1){
				echo "
				<option value='1' SELECTED>Active</option>
				<option value='2'>Inactive</option>
				";
				}
				if($db_consultant2_a_status==2){
				echo "
				<option value='2' SELECTED>Inactive</option>
				<option value='1'>Active</option>
				";
				}							
				
				?>
				</select>
                            </div>             
                    </div>
		    
		
		    
	     </div>
	    <!-- end tabs 1 -->

	    
</div>
</div>	    
<!-- end tabs body -->
                  
                </div>
            </fieldset>
	    
    <div class="formRow">
                    <div class="grid2"></div>
                    <div class="grid10">
		<a href="#" class="buttonM bBlue" onclick="document.getElementById('form').submit();"><span class="fa fa-save"></span><span><?php echo $lang['Save']; ?></span></a>
		        <a href="#" class="buttonM bBlue" onclick="window.close();"><span class="fa fa-times-circle"></span><span><?php echo $lang['Cancel']; ?></span></a>
		    </div>
		    
		    </div>
             
</body>
</html>
