<?php
	require_once("../admin/conn.php");
	require_once("../bll/f_common.php");
	require_once("../bll/public_common.php");

$msg="";

if(isset($_POST['form_data_insert'])){
	
	$msg_class="error";

	if(strlen($_POST['mobile_1'])!=11){
		$msg = "Primary mobile no length must be 11. ";
	}

	if(strlen($_POST['bank_id'])!=6){
		$msg = "Primary mobile no length must be 6. ";
	}

	if($_POST['name']=="" || $_POST['fathers_name']=="" || $_POST['mothers_name']=="" || $_POST['name_bangla']=="" || $_POST['present_add']=="" || $_POST['permanent_add']=="" || $_POST['dob']=="" || $_POST['join_date']=="" || $_POST['place_of_joining']=="" || $_POST['place_of_posting']=="" || $_POST['sex']=="" || $_POST['blood_group']=="")
		$msg.="One or more field is missed or left blank. Please fill all field properly and try again. ";


	if($_POST['mobile_1']!=''){
		$sql = "SELECT * FROM member_info WHERE mobile_1=\"$_POST[mobile_1]\"";
		$query = mysql_query($sql);
		if(mysql_num_rows($query)>0)
			$msg = "Member information (Mobile No) already exists for selected. ";
	}

	if($_POST['mobile_2']!=''){
		$sql = "SELECT * FROM member_info WHERE mobile_2=\"$_POST[mobile_2]\"";
		$query = mysql_query($sql);
		if(mysql_num_rows($query)>0)
			$msg = "Member information (Mobile No) already exists for selected. ";
	}	

	if($_POST['bank_id']!=''){
		$sql = "SELECT * FROM member_info WHERE bank_id=\"$_POST[bank_id]\"";
		$query = mysql_query($sql);
		if(mysql_num_rows($query)>0)
			$msg = "Member information (Bank ID) already exists for selected. ";
	}

	if($msg=='' && $_FILES["file_picture"]["name"]!=""){
		$extension = strtolower(@end(explode(".",$_FILES["file_picture"]["name"])));
		$allowedExts = array("jpg", "jpeg", "gif", "png");
		//Check file extension is allowed or not
		if(!in_array($extension, $allowedExts))
		$msg="Sorry invalid file type.";
		else{
			$target_file_name = img_name_with_timestamp($_FILES["file_picture"]["name"]);
			move_uploaded_file($_FILES["file_picture"]["tmp_name"], "../gallery/" . $target_file_name);
			$_POST['picture']=$target_file_name;
		}
	}

	if($msg==''){ 
		//Inserting data into rittik table
		unset($_POST['form_data_insert']); unset($_POST['hid_picture']); //unset($_POST['hid_logo']);

		$_POST['entry_date']=date("Y-m-d H:i:s");
		$_POST['last_update']=date("Y-m-d H:i:s");
		$_POST['entry_by']="SELF";

		if($_POST['last_promo_date']==''){
			$_POST['last_promo_date']=$_POST['join_date'];
		}

		if(save_data_into_table($_POST,"member_info")){
			$last_id=mysql_insert_id();
			$msg_class="success"; //success, error, warn
			$msg = "Member information added successfully.";
			$_POST = reset_default_values();
			header("Location: new_eo10_thanks.php");
		}

		else{
			$msg_class="error"; //success, error, warn
			$msg = "Error while inserting member information.";
		}
	}
}
elseif(!isset($_REQUEST['eid']))
{
  //default values
  $_POST = reset_default_values();
}

function reset_default_values()
{
  $default_values = array('form_serial_no'=>'', 'name'=>'', 'name_bangla'=>'', 'fathers_name'=>'', 'mothers_name'=>'', 'spouse_name'=>'', 'designation'=>'', 'bank_id'=>'', 'place_of_posting'=>'', 'join_date'=>'', 'last_promo_date'=>'', 'place_of_joining'=>'', 'dob'=>'', 'blood_group'=>'', 'grad_institute'=>'', 'grad_sub'=>'', 'pg_institute'=>'', 'pg_sub'=>'', 'pro_certificate'=>'', 'last_pomo_date'=>'', 'present_add'=>'', 'permanent_add'=>'', 'mobile_no'=>'', 'mobile_2'=>'', 'email'=>'', 'post_code'=>'', 'expertise_sector'=>'', 'pre_post_code'=>'', 'per_post_code'=>'', 'pre_district'=>'', 'per_district'=>'', 'pre_police_station'=>'', 'per_police_station'=>'', 'pre_post_office'=>'', 'per_post_office'=>'', 'sex'=>'');
  return $default_values;
}

?>
  <!--A Design by W3layouts
   Author: W3layout
   Author URL: http://w3layouts.com
   License: Creative Commons Attribution 3.0 Unported
   License URL: http://creativecommons.org/licenses/by/3.0/
   -->
<!DOCTYPE html>
<html lang="en">
   
<!-- Mirrored from demo.w3layouts.com/demos_new/template_demo/04-08-2018/summer_camp_form-demo_Free/1603175437/web/index.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 22 May 2019 12:50:09 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8" /><!-- /Added by HTTrack -->
<head>
      <title>সৎসঙ্গ : দিক্ষিত রেজিস্ট্রেশন</title>
      <!-- Meta tags -->
      <meta name="viewport" content="width=device-width, initial-scale=1" />
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <meta name="keywords" content=""
         />
      <script>
         addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); }
      </script>
      
      <!-- Meta tags -->
      <!-- Calendar -->
      <link rel="stylesheet" href="css/jquery-ui.css" />
      <!-- //Calendar -->
      <!--stylesheets-->
      <link href="css/style.css" rel='stylesheet' type='text/css' media="all">
      <!--//style sheet end here-->
      <!-- Google fonts here-->
      <link href="http://fonts.googleapis.com/css?family=Barlow:300,400,500" rel="stylesheet">
      <link href="http://fonts.googleapis.com/css?family=Josefin+Sans:300,400,600,700" rel="stylesheet">
      <!--//Google fonts here-->
      <link rel="stylesheet" href="css/jquery-ui.css">
	  <link rel="stylesheet" href="css/style.css">
	  <script src="https://code.jquery.com/jquery-3.6.0.js"></script>
	  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
	  
	  <script>
		$(document).ready(function(){
		$('#district').on('change',function(){
			var districtID = $(this).val();
			if(districtID){
				$.ajax({
					type:'POST',
					url:'ajaxData.php',
					data:'district='+districtID,
					success:function(html){
						$('#police_station').html(html);
						$('#post_office').html('<option value="">PS first</option>'); 
					}
				}); 
			}else{
				$('#police_station').html('<option value="">PS first</option>');
				$('#post_office').html('<option value="">PO first</option>'); 
			}
		});

		$('#police_station').on('change',function(){
			var police_stationID = $(this).val();
			if(police_stationID){
				$.ajax({
					type:'POST',
					url:'ajaxData.php',
					data:'police_station='+police_stationID,
					success:function(html){
						$('#post_office').html(html);
					}
				}); 
			}else{
				$('#post_office').html('<option value="">PS first</option>'); 
			}
		});

		$('#post_code').on('blur',function(){
			var post_codeID = $(this).val();
			if(post_codeID){
				$.ajax({
					type:'POST',
					url:'ajaxDataPS.php',
					data:'post_code='+post_codeID,
					success:function(html){
						$('#police_station').html(html);
					}
				}); 
				$.ajax({
					type:'POST',
					url:'ajaxDataPO.php',
					data:'post_code='+post_codeID,
					success:function(html){
						$('#post_office').html(html);
					}
				});
				$.ajax({
					type:'POST',
					url:'ajaxDataDist.php',
					data:'post_code='+post_codeID,
					success:function(html){
						//window.alert(html);
						//$('#district').val(14);    //AMINUL 1
						//$('#district').val(html);  //AMINUL 2
						//var dist_code = Number(html);
						$('#district').val(Number(html));
						//$("#district").val(html).attr('selected',true);
						//$('#district option[value="14"]').attr('selected',true);
					}
				}); 
			}
		});
	</script>
</head>
<link href="css/main.css" rel="stylesheet" media="all">
<body>
      <h1 class="header-w3ls">
         দীক্ষিত রেজিস্ট্রেশন 
      </h1>
	  <!---728x90--->

      <!-- multistep form -->
      <div class="main-bothside">
         <form name="frm_admin" id="frm_admin" method="post" action="<?php echo $current_page_name;if(isset($_REQUEST["eid"]) && strlen($_REQUEST["eid"]) > 0) echo "?eid=".$_REQUEST["eid"];?>" enctype="multipart/form-data" class="fields">
            <div class="main-title">
               <h2>Personal Information</h2>
            </div>
			<!---728x90--->
            <div class="form-group">
				<?php if($msg!=""){ ?>
				<div class="msg <?php echo $msg_class;?>"><?php echo $msg;?></div>
				<?php } ?>
			</div>
            <div class="form-group">
               <div class="form-grid-w3ls">
                  <input type="text" class="form-control" placeholder="ফ্যামিলি কোড যদি জানা থাকে তবে এখানে লিখুন (English) " required="" name="name" value="<?php echo $_POST['name'];?>">
               </div>
               <div class="form-grid-w3ls">
                  <input type="text" class="form-control" placeholder="দীক্ষিত নাম (ইউনিকোডে বাংলায়)*" required="" name="name_bangla" value="<?php echo $_POST['name_bangla'];?>">
               </div>
            </div>
            <div class="form-group">
               <div class="form-grid-w3ls">
                  <input type="text" class="form-control" placeholder="পিতার নাম (ইউনিকোডে বাংলায়)*" required="" name="fathers_name" value="<?php echo $_POST['fathers_name'];?>">
               </div>
               <div class="form-grid-w3ls">
                  <input type="text" class="form-control" placeholder="মাতার নাম (ইউনিকোডে বাংলায়)*" required="" name="mothers_name" value="<?php echo $_POST['mothers_name'];?>">
               </div>
            </div>
            <div class="form-group">
               <div class="form-grid-w3ls">
                  <input type="text" class="form-control" placeholder="স্বামী বা স্ত্রী নাম" required="" name="spouse_name" value="<?php echo $_POST['spouse_name'];?>">
               </div>
            </div>
            <div class="form-group">
               <div class="form-mid-w3ls">
                  <input id="datepicker1" type="text" placeholder="Date of Birth (YYYY-MM-DD)*" required="" name="dob" value="<?php if(strlen($_POST['dob'])==10){ echo substr($_POST['dob'],5,2)."/".substr($_POST['dob'],8,2)."/".substr($_POST['dob'],0,4); } else{ echo $_POST['dob']; } ?>">
               </div>
               <div class="form-mid-w3ls">
			   		<select class="form-control buttom" required=''>
						<option>লিঙ্গ*</option>
						<option>পুরুষ</option>
						<option>মহিলা</option>
			    		<option>বলতে ইচ্ছুক নই</option>
				    </select>
               </div>
               <div class="form-mid-w3ls">
			   		<select class="form-control buttom" required=''>
			   			<option>বৈবাহিক অবস্থা*</option>
						<option>বিবাহিত</option>
						<option>অবিবাহিত</option>
			    		<option>বলতে ইচ্ছুক নই</option>
				    </select>
               </div>
            </div>
            <div class="form-group">
               <div class="form-mid-w3ls">
                  <input type="text" class="form-control" placeholder="মোবাইল নং (English : 13 digit)*" required="" name="mobile_no" value="<?php echo $_POST['mobile_no'];?>" onkeyup="this.value = this.value.replace(/[^0-9]/, '')">
               </div>
               <div class="form-mid-w3ls">
                  <input type="text" class="form-control" placeholder="ইমেইল ঠিকানা (English)" required="" name="email" value="<?php echo $_POST['mobile_no'];?>">
               </div>
               <div class="form-mid-w3ls">
                  <input type="text" class="form-control" placeholder="ন্যাশনাল আইডি নং (English)" required="" name="national_id" value="<?php echo $_POST['mobile_no'];?>" onkeyup="this.value = this.value.replace(/[^0-9]/, '')">
               </div>
            </div>
            <div class="form-group">
               <div class="form-mid-w3ls">
              		<?php $sql ="SELECT id, caste_name FROM caste_list ORDER BY caste_name"; ?>
					<?php $query=mysql_query($sql); ?>
					<?php if(mysql_num_rows($query)>0) { ?>
					<select name="caste_name" id="caste_name" class="form-control buttom" required=''>
					  <option value="">গোত্র*</option>
					  <?php while($row=mysql_fetch_array($query)){ ?>
					  <option value="<?php echo $row["id"];?>"><?php echo $row["caste_name"];?></option>
					  <?php }  ?>
					  <script language="JavaScript" type="text/javascript">document.getElementById("caste_name").value = '<?php echo $_POST['caste_name'];?>';</script>
					</select>
					<?php }  ?>
               </div>
               <div class="form-mid-w3ls">
              		<?php $sql ="SELECT id, concat(name, ' (', r_code, ')') rittik_name FROM rittik_info ORDER BY name"; ?>
					<?php $query=mysql_query($sql); ?>
					<?php if(mysql_num_rows($query)>0) { ?>
					<select name="rittik_name" id="rittik_name" class="form-control buttom">
					  <option value="">দিক্ষাগুরুর নাম*</option>
					  <?php while($row=mysql_fetch_array($query)){ ?>
					  <option value="<?php echo $row["id"];?>"><?php echo $row["rittik_name"];?></option>
					  <?php }  ?>
					  <script language="JavaScript" type="text/javascript">document.getElementById("rittik_name").value = '<?php echo $_POST['rittik_name'];?>';</script>
					</select>
					<?php }  ?>
               </div>
               <div class="form-mid-w3ls">
                  <input id="datepicker2" type="text" placeholder="দিক্ষা গ্রহণের তারিখ (YYYY-MM-DD)*" required="" name="dob" value="<?php if(strlen($_POST['dob'])==10){ echo substr($_POST['dob'],5,2)."/".substr($_POST['dob'],8,2)."/".substr($_POST['dob'],0,4); } else{ echo $_POST['dob']; } ?>">
               </div>
            </div>
            <div class="form-group">
               <div class="form-grid-w3ls">
                  <input type="text" class="form-control" placeholder="Present Address*" required="" name="present_add" value="<?php echo $_POST['present_add'];?>">
               </div>
            </div>
            <div class="form-group">
               <div class="form-mid-w3ls">
			   		<?php $sql ="SELECT id, district_ban FROM district_list ORDER BY district_ban"; ?>
					<?php $query=mysql_query($sql); ?>
					<?php if(mysql_num_rows($query)>0) { ?>
					<select name="district" id="district" class="form-control buttom" required='' onchange="fetch_select(this.value);">
						  <option value="">জেলা</option>
						  <?php while($row=mysql_fetch_array($query)){ ?>
						  <option value="<?php echo $row["id"];?>"><?php echo $row["district_ban"];?></option>
						  <?php }  ?>
						  <script language="JavaScript" type="text/javascript">document.getElementById("district").value = '<?php echo $_POST['district'];?>';</script>
					</select>
					<?php }  ?>
               </div>
               <div class="form-mid-w3ls">
			   		<select name="police_station" id="police_station" class="form-control buttom" required=''>
					<?php
						if(isset($_REQUEST['eid']) && strlen($_REQUEST['eid']) > 0 && !isset($_POST['form_data_update'])){
						$ps_po_str = "SELECT PO.post_office_ban, PS.police_station_ban, PO.id po_id, PS.id ps_id FROM post_office_list PO LEFT JOIN police_station_list PS ON PO.police_station_id = PS.id WHERE PO.post_code = '$_POST[post_code]'";
						$query=mysql_query($ps_po_str);
						if(mysql_num_rows($query)>0){
							$row=mysql_fetch_array($query); ?>
								<option value="<?php echo $row["ps_id"];?>"><?php echo $row["police_station_ban"];?></option>
						<?php }}
					?>
					<script language="JavaScript" type="text/javascript">document.getElementById("police_station").value = '<?php echo $_POST['police_station'];?>';</script>
            		</select>
               </div>
               <div class="form-mid-w3ls">
			   		<select name="post_office" id="post_office"  class="form-control buttom" required='' onchange="post_code_load();">
					<?php
						if(isset($_REQUEST['eid']) && strlen($_REQUEST['eid']) > 0 && !isset($_POST['form_data_update'])){
						if(mysql_num_rows($query)>0){?>
								<option value="<?php echo $row["po_id"];?>"><?php echo $row["post_office_ban"];?></option>
						<?php }}
					?>
					<script language="JavaScript" type="text/javascript">document.getElementById("post_office").value = '<?php echo $_POST['post_office'];?>';</script> 
					</select>
               </div>
            </div>
            <div class="form-group">
               <div class="form-mid-w3ls">
                  <input type="text" name="post_code" id="post_code" class="form-control" placeholder="পোস্ট কোড" value="<?php echo $_POST['post_code'];?>" onchange="dt_ps_po_load();" onkeyup="this.value = this.value.replace(/[^0-9]/, '')"/>
               </div>
            </div>
            <input type="submit" value="Submit" name="form_data_insert">
         </form>
      </div>
	  <!---728x90--->

      <div class="copy">
         <p>©2022 SATSANG BANGALDESH</p>
      </div>
      <!-- js -->
      
      <!-- //Calendar -->
   </body>

<!-- Mirrored from demo.w3layouts.com/demos_new/template_demo/04-08-2018/summer_camp_form-demo_Free/1603175437/web/index.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 22 May 2019 12:50:16 GMT -->
</html>