<?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>

<!-- header-->
<?php include("../template/header.php"); ?>

<!-- sidebar-->
<?php include("../template/sidebar.php"
	      ); ?>
   
<!-- Content begins -->
<div id="content">
    
    <!-- Breadcrumbs line -->
    <div class="breadLine">
        <div class="bc">
            <ul id="breadcrumbs" class="breadcrumbs">
                <li><a href="<?php echo $connect_url_data; ?>/dashboard"><?php echo $lang['Dashboard']; ?></a></li>
                <li><a href="<?php echo $connect_url_data; ?>/patient"><?php echo $lang['Patient Record']; ?></a></li>
                <li class="current"><a href="#"><?php echo $lang['Create Patient']; ?></a></li>
            </ul>
        </div>
        
<!-- breaklink -->
<?php include("../menu/breadlink.php"); ?>
	
    </div>
    
    <!-- Main content -->
    <div class="wrapper">

<?php
if($_POST)
{
$query_patient1= mysql_query("SELECT * FROM tbl_patient");
while($row= mysql_fetch_assoc($query_patient1))
{
    $db_patient1_id= $row['id'];
}
    $db_patient1_id_add = $db_patient1_id + 1;
    $db_patient1_id_add_comp = "$date_year$db_patient1_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'];
$nationality=$_POST['nationality'];
$civil_status =$_POST['civil_status'];
$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']);
$ref_name =mysql_real_escape_string(ucwords($_POST['ref_name']));
$ref_relationship=$_POST['ref_relationship'];
$ref_address =mysql_real_escape_string($_POST['ref_address']);
$ref_phone_no =mysql_real_escape_string($_POST['ref_phone_no']);
$ref_mobile_no =mysql_real_escape_string($_POST['ref_mobile_no']);

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_patient1_id_add_comp$rand_number-$image_name";

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

}

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

$query_insert = mysql_query("
  INSERT INTO tbl_patient VALUES ('','$db_patient1_id_add_comp','$file_image_generate','$firstname','$middlename','$lastname','$birth_date','$gender','$civil_status','$nationality','$address','$phone_no','$mobile_no','$email','$ref_name','$ref_relationship','$ref_address','$ref_phone_no','$ref_mobile_no','$db_user_id','$date','$time','1');
");

die ("<script> alert('Saved.');
window.location.href='$connect_url_data/patient';		
</script> ");
}
?>

<form name="form" id="form" action="<?php echo $connect_url_data; ?>/create-patient" class="main" method="POST"  enctype="multipart/form-data">
            <fieldset>
                <div class="widget fluid">
                    <div class="whead"><h6><span class="icos-add" style="margin-top:-2px;"></span>&nbsp; <?php echo $lang['Create Patient']; ?></h6></div>
                    
		    <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"/></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"/></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"/></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" /></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%;">
				<option value="Male">Male</option>
				<option value="Female">Female</option>
				</select>
                            </div>             
                    </div>
		    
		   <div class="formRow">
                            <div class="grid2"><label><?php echo $lang['Civil Status']; ?>:</label></div>
                            <div class="grid10">
                               <?php
				$query_civil_status1=mysql_query("SELECT * FROM tbl_civil_status ORDER BY civil_status ASC");
				$option_civil_status1="";
				while($row=mysql_fetch_array($query_civil_status1)) {
				$option_civil_status1 .= "<option value='$row[id]'";
				$option_civil_status1 .= ">". $row['civil_status'] ."</option>";  }
				?>    
				<select name="civil_status" id="civil_status"  data-placeholder="Choose" class="select" tabindex="2" style="width:100%;">
                                <option value=""></option> 
				<?php echo $option_civil_status1; ?>
				</select>
                            </div>             
                    </div>
		   
		    <div class="formRow">
                            <div class="grid2"><label><?php echo $lang['Nationality']; ?>:</label></div>
                            <div class="grid10">
                               <?php
				$query_nationality1=mysql_query("SELECT * FROM tbl_nationality ORDER BY nationality ASC");
				$option_nationality1="";
				while($row=mysql_fetch_array($query_nationality1)) {
				$option_nationality1 .= "<option value='$row[id]'";
				$option_nationality1 .= ">". $row['nationality'] ."</option>";  }
				?>    
				<select name="nationality" id="nationality"  data-placeholder="Choose" class="select" tabindex="2" style="width:100%;">
                                <option value=""></option> 
				<?php echo $option_nationality1; ?>
				</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"></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" /></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" /></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" /></div>
		    </div>
		       
		    <div class="formRow">
                        <div class="grid2"><label><?php echo $lang['Ref. Name']; ?>:</label></div>
                        <div class="grid10"><input type="text" name="ref_name" id="ref_name"/></div>
                    </div>
		    
		    <div class="formRow">
                            <div class="grid2"><label><?php echo $lang['Ref. Relationship']; ?>:</label></div>
                            <div class="grid10">
                               <?php
				$query_relationship1=mysql_query("SELECT * FROM tbl_relationship ORDER BY relationship ASC");
				$option_relationship1="";
				while($row=mysql_fetch_array($query_relationship1)) {
				$option_relationship1 .= "<option value='$row[id]'";
				$option_relationship1 .= ">". $row['relationship'] ."</option>";  }
				?>    
				<select name="ref_relationship" id="ref_relationship"  data-placeholder="Choose" class="select" tabindex="2" style="width:100%;">
                                <option value=""></option> 
				<?php echo $option_relationship1; ?>
				</select>
                            </div>             
                    </div>
		    
		     <div class="formRow">
                        <div class="grid2"><label><?php echo $lang['Ref. Address']; ?>:</label></div>
                        <div class="grid10">
                            <textarea rows="8" cols="" name="ref_address" id="ref_address" class="auto lim"></textarea>
                            <span class="note" id="limitingtext">Field limited to 100 characters.</span>
                        </div>
                    </div>
		      
		    <div class="formRow">
                    <div class="grid2"><label><?php echo $lang['Ref. Phone No']; ?>:</label></div>
                    <div class="grid10"><input class="span12" type="number" name="ref_phone_no" id="ref_phone_no" /></div>
                    </div>
		    
		    <div class="formRow">
                    <div class="grid2"><label><?php echo $lang['Ref. Mobile No']; ?>:</label></div>
                    <div class="grid10"><input class="span12" type="number" name="ref_mobile_no" id="ref_mobile_no" /></div>
                    </div>
		    
		    <div class="formRow">
                    <div class="grid2"><br /></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.location.href='<?php echo $connect_url_data; ?>/patient'"><span class="fa fa-times-circle"></span><span><?php echo $lang['Cancel']; ?></span></a>
		    </div>
		    
		    </div>
                  
                </div>
            </fieldset>

	    
	    
        </div>
	
    </div>
    <!-- Main content ends -->
    
</div>
<!-- Content ends -->  
             
</body>
</html>
