<?php require_once './utility/texteditor_utility.php';?>
<?php
$req = $_POST['List'];
if(empty($req)){
		$req ="Add";
}
$ctrl_name = BASE_URL."/members";
$page_name = BASE_URL."/members/".$req;
$num = $cnt;
?>
<style>
		.black_overlay{
			display: none;
			position:fixed;
			top: 0%;
			left: 0%;
			width: 100%;
			height: 100%;
			background-color: black;
			z-index:1001;
			-moz-opacity: 0.7;
			opacity:.70;
			filter: alpha(opacity=70);
		}
		.white_content {
			display: none;
			position:fixed;
			top: 30%;
			left: 32%;
			width: 470px;
			height: 600px;
			z-index:1002;
			overflow: auto;
		}
</style>
<h1 class="page-header"><?php echo ($_REQUEST["List"]=="AddFamily")?"Add Family":"Edit Family";?> Member</h1>          
<div class="bs-example table-responsive">
	<table align="center" width="100%" border="0">    	
    	 <?php if(!empty($error_msg)) {?>     
            <tr>
                <td align="center">  
                  <div class="col-lg-8 alert alert-danger" style="clear:right">
                    <?php echo $error_msg;?>
                 </div>             
                </td>
             </tr>   
			 
         <?php } ?> 
		 	<tr>
                <td align="center">  
                  <div style="clear:right" align="right">
                   <button value="AddRecord" type="button" name="AddButton" class="btn btn-primary" onclick="gotoback('frm')">Back to Femily Members</button>
                 </div>             
                </td>
             </tr>   
        <tr>
        	<td align="center">       
             <div class="col-lg-12">
             <div class="well">
                  <form name="frm" id="frm" method="post" class="bs-example form-horizontal" enctype="multipart/form-data">
                  <input type="hidden" name="act" id="act" value="" />
				  <input type="hidden" name="List" value="<?php echo $_REQUEST['List']?>">
				  <input type="hidden" name="ctrl_name" value="<?php echo $ctrl_name?>"> 
					<input type="hidden" name="member_id" id="member_id" value="<?php echo $_REQUEST["member_id"]?>" />
					<input type="hidden" name="member_name" id="member_name" value="<?php echo $_REQUEST["member_name"]?>" />
					<input type="hidden" name="family_id" id="family_id" value="<?php echo $userDetails->id?>" />
					<input type="hidden" name="familyno" id="familyno" value="<?php echo $_REQUEST["familyno"]?>" />
                    <fieldset>    
					<div class="form-group">
                          <label class="col-lg-3 control-label" for="name">Full Name</label>
                        <div class="col-lg-8">
                          <input name="fam_fullname" type="text" class="validate[required] form-control" id="fam_fullname" value="<?php echo $userDetails->fam_fullname?>" />
                        </div>
                      </div>      
					  <div class="form-group">
                          <label class="col-lg-3 control-label" for="name">Gender</label>
                        <div class="col-lg-5">
                          <select id="fam_gender" name="fam_gender" class="form-control">
                          	<option value="">[Gender]</option>
									<option value="Male" <?php if("Male"==$userDetails->fam_gender){echo "selected";}?>>Male</option>
									<option value="Female" <?php if("Female"==$userDetails->fam_gender){echo "selected";}?>>Female</option>
                          </select>
                        </div>
                      </div>           
					 <div class="form-group">
                          <label class="col-lg-3 control-label" for="client_id">Blood Group</label>
                        <div class="col-lg-5">
                           <select id="fam_bloodgroup" name="fam_bloodgroup" class="form-control">
                          	<option value="">[Blood Group]</option>
                            <option value="A+" <?php if($userDetails->fam_bloodgroup == 'A+') { echo "Selected"; } ?>>A+</option>
							<option value="B+" <?php if($userDetails->fam_bloodgroup == 'B+') { echo "Selected"; } ?>>B+</option>
							<option value="A-" <?php if($userDetails->fam_bloodgroup == 'A-') { echo "Selected"; } ?>>A-</option>
							<option value="B-" <?php if($userDetails->fam_bloodgroup == 'B-') { echo "Selected"; } ?>>B-</option>
							<option value="AB+" <?php if($userDetails->fam_bloodgroup == 'AB+') { echo "Selected"; } ?>>AB+</option>
							<option value="AB-" <?php if($userDetails->fam_bloodgroup == 'AB-') { echo "Selected"; } ?>>AB-</option>
							<option value="O+" <?php if($userDetails->fam_bloodgroup == 'O+') { echo "Selected"; } ?>>O+</option>
							<option value="O-" <?php if($userDetails->fam_bloodgroup == 'O-') { echo "Selected"; } ?>>O-</option>
                          </select>           
                        </div>
                      </div>
					  <div class="form-group">
                          <label class="col-lg-3 control-label" for="startdate">Birth Date</label>
                        <div class="col-lg-5">
                        	<div class='input-group date' id='dob_dt'>
							<?php if($userDetails->fam_dob=='0000-00-00'){$userDetails->fam_dob='';}?>
                                <input type="text" placeholder="Birth Date" id="fam_dob" name="fam_dob" class="form-control"  value="<?php echo $userDetails->fam_dob?>" data-format="YYYY-MM-DD"> 
                                <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
                                </span>
                            </div>
                            <script type="text/javascript">
								 $(function () {
									$('#dob_dt').datetimepicker({
										pickTime: false
									});
								});
							</script>
                         </div>
                      </div>
					  <div class="form-group">
                          <label class="col-lg-3 control-label" for="startdate">Anniversary Date</label>
                        <div class="col-lg-5">
                        	<div class='input-group date' id='fam_expirydate_dt'>
							<?php if($userDetails->fam_expirydate=='0000-00-00'){$userDetails->fam_expirydate='';}?>
                                <input type="text" placeholder="Anniversary Date" id="fam_expirydate" name="fam_expirydate" class="form-control"  value="<?php echo $userDetails->fam_expirydate?>" data-format="YYYY-MM-DD"> 
                                <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
                                </span>
                            </div>
                            <script type="text/javascript">
								 $(function () {
									$('#fam_expirydate_dt').datetimepicker({
										pickTime: false
									});
								});
							</script>
                         </div>
                      </div>
					  
					  <div class="form-group">
                          <label class="col-lg-3 control-label" for="name">Relation with Member</label>
                        <div class="col-lg-8">
                          <input name="fam_relationwithmember" type="text" class="validate[required] form-control" id="fam_relationwithmember" value="<?php echo $userDetails->fam_relationwithmember?>" />
                        </div>
                      </div>
					  
					  <div class="form-group">
                          <label class="col-lg-3 control-label" for="name">Marital Status</label>
                        <div class="col-lg-5">
                          <select id="fam_maritalstatus" name="fam_maritalstatus" class="form-control">
                          	<option value="">[Marital Status]</option>
                            <option value="Married" <?php if($userDetails->fam_maritalstatus == 'Married') { echo "Selected"; } ?>>Married</option>
							<option value="Unmarried" <?php if($userDetails->fam_maritalstatus == 'Unmarried') { echo "Selected"; } ?>>Unmarried</option>
                            <option value="Divorce" <?php if($userDetails->fam_maritalstatus == 'Divorce') { echo "Selected"; } ?>>Divorce</option>
                          </select>  
                        </div>
                      </div>
					 
					  <div class="form-group">
                          <label class="col-lg-3 control-label" for="name">Education</label>
                        <div class="col-lg-8">
                          <input name="fam_education" type="text" class="validate[required] form-control" id="fam_education" value="<?php echo $userDetails->fam_education?>" />
                        </div>
                      </div>
					  <div class="form-group">
                          <label class="col-lg-3 control-label" for="name">Occupation</label>
                        <div class="col-lg-5">
                          <select id="fam_occupation" name="fam_occupation" class="form-control">
                          	<option value="">[Occupation]</option>
                            <option value="Business" <?php if($userDetails->fam_occupation == 'Business') { echo "Selected"; } ?>>Business</option>
							<option value="Job" <?php if($userDetails->fam_occupation == 'Job') { echo "Selected"; } ?>>Job</option>
                          </select>  
                        </div>
                      </div>
					  <div class="form-group">
                          <label class="col-lg-3 control-label" for="name">Name of Company</label>
                        <div class="col-lg-8">
<input name="fam_nameofcompany" type="text" class="validate[required] form-control" id="fam_nameofcompany" value="<?php echo $userDetails->fam_nameofcompany?>" />
                        </div>
                      </div>
					  <div class="form-group">
                          <label class="col-lg-3 control-label" for="name">Nature of Business</label>
                        <div class="col-lg-8">
                          <input name="bus_nature" type="text" class="validate[required] form-control" id="bus_nature" value="<?php echo $userDetails->bus_nature?>" />
                        </div>
                      </div>
					  <div class="form-group">
                          <label class="col-lg-3 control-label" for="name">Designation</label>
                        <div class="col-lg-8">
                          <input name="fam_designation" type="text" class="validate[required] form-control" id="fam_designation" value="<?php echo $userDetails->fam_designation?>" />
                        </div>
                      </div>
					  <div class="form-group">
                          <label class="col-lg-3 control-label" for="name">Business Address1</label>
                        <div class="col-lg-8">
                          <input name="fam_address1" type="text" class="validate[required] form-control" id="fam_address1" value="<?php echo $userDetails->fam_address1?>" />
                        </div>
                      </div>
					  <div class="form-group">
                          <label class="col-lg-3 control-label" for="name">Business Address2</label>
                        <div class="col-lg-8">
                          <input name="fam_address2" type="text" class="validate[required] form-control" id="fam_address2" value="<?php echo $userDetails->fam_address2?>" />
                        </div>
                      </div>
					  <div class="form-group">
                          <label class="col-lg-3 control-label" for="name">Business City</label>
                        <div class="col-lg-8">
                          <input name="fam_city" type="text" class="validate[required] form-control" id="fam_city" value="<?php echo $userDetails->fam_city?>" />
                        </div>
                      </div>
					  <div class="form-group">
                          <label class="col-lg-3 control-label" for="name">Business State</label>
                        <div class="col-lg-8">
                          <input name="fam_state" type="text" class="validate[required] form-control" id="fam_state" value="<?php echo $userDetails->fam_state?>" />
                        </div>
                      </div>
					  <div class="form-group">
                          <label class="col-lg-3 control-label" for="name">Business Country</label>
                        <div class="col-lg-5">
                          <select id="fam_country" name="fam_country" class="form-control">
                          	<option value="">[Country]</option>
							<?php
							
							foreach($countries as $country){
								?>
									<option value="<?php echo $country->name?>" <?php if($country->name==$userDetails->fam_country){echo "selected";}?>><?php echo $country->name?></option>
								<?php
							}
							?>
                          </select>  
                        </div>
                      </div>
					  <div class="form-group">
                          <label class="col-lg-3 control-label" for="name">Business Zip</label>
                        <div class="col-lg-8">
                          <input name="fam_zip" type="text" class="validate[required] form-control" id="fam_zip" value="<?php echo $userDetails->fam_zip?>" />
                        </div>
                      </div>
					  <div class="form-group">
                          <label class="col-lg-3 control-label" for="name">Business Phone</label>
                        <div class="col-lg-8">
                          <input name="fam_phone" type="text" class="validate[required] form-control" id="fam_phone" value="<?php echo $userDetails->fam_phone?>" />
                        </div>
                      </div>
					  <div class="form-group">
                          <label class="col-lg-3 control-label" for="name">Business Website</label>
                        <div class="col-lg-8">
                          <input name="fam_website" type="text" class="validate[required] form-control" id="fam_website" value="<?php echo $userDetails->fam_website?>" />
                        </div>
                      </div>
					  <div class="form-group">
                          <label class="col-lg-3 control-label" for="name">Business Email</label>
                        <div class="col-lg-8">
                          <input name="fam_email" type="text" class="validate[required] form-control" id="fam_email" value="<?php echo $userDetails->fam_email?>" />
                        </div>
                      </div>
					  
					 
					  
					  
					 <?php /*?> <?php if($userDetails->approved!=1){?>
					  <div class="form-group">
                          <label class="col-lg-3 control-label" for="designer_email">Approved</label>
                        <div class="col-lg-8" align="left">
                          <input type="checkbox" name="approved" id="approved" value="1" <?php if($userDetails->approved==1){echo "checked";}?> />
                        </div>
                      </div>
					  <?php }?><?php */?>
                      <div class="form-group">
                          <label class="col-lg-3 control-label" for="name">Image</label>
                        <div class="col-lg-8" align="left">
                          <input type="file" name="fam_simage" id="fam_simage" /> (Only <?php echo VALID_EXT_MEMBERS?>) 
                        </div>
                      </div>
                      <div class="form-group">
                          <label class="col-lg-3 control-label" for="page_content"></label>
                        <div class="col-lg-6">
                          <?php 
					  if(!empty($userDetails->fam_simage)){
								 ?>
							 	<table align="center" border="0" cellpadding="3" cellspacing="3" width="100%">
                               	   <tr>	
                                   		<td width="133"><?php if(!empty($userDetails->fam_simage)){?> <img src="<?php echo "../". UPLOADDIR_MEMBERS."/".$userDetails->fam_simage?>?<?php echo date("YmdHis")?>" width="100" height="100" alt="<?php echo SEO_IMAGE_ALT; ?>" title="<?php echo SEO_IMAGE_TITLE; ?>"> <?php }?><input type="hidden" name="homebanner_image_old" value="<?php echo $userDetails->fam_simage?>">
										</td>
                                   	   
                                   </tr>
                               </table>
                             <?php } ?>
                        </div>
                      </div>
					  
					  <div class="form-group">
                          <label class="col-lg-3 control-label" for="designer_email">Status</label>
                        <div class="col-lg-8" align="left">
                          <select name="fam_status" id="fam_status" class="form-control" style="width:100px; text-align:left">
												  	<option value="1" <?php if($userDetails->fam_status==1){echo "selected";}?>>Active</option>
													<option value="0" <?php if($userDetails->fam_status==0){echo "selected";}?>>Inactive</option>
												  </select>
                        </div>
                      </div>
                  
                      <div class="form-group">
                        <div class="col-lg-8 col-lg-offset-1">                    
                          <button class="btn btn-primary" name="Submit" type="submit" value="Submit">Submit</button>&nbsp; <button class="btn btn-primary" name="Cancel" type="button" value="Cancel" onclick="location.href='<?php echo BASE_URL?>/members/index'">Cancel</button>
                        </div>
                      </div>
                    </fieldset>
                  </form>
            </div>
          </div>
            </td>
        </tr>
    </table>
</div>
<script type="text/javascript">
function gotoback(frm_name){
		var Frm = document.getElementById(frm_name);
		Frm.action=Frm.ctrl_name.value+"/viewfamily";						
		Frm.submit();
}
$(document).ready(function() {
    $('#frm').bootstrapValidator({
        message: 'This value is not valid',
        fields: {
			
			fam_fullname: {
                message: 'The Name is not valid',
                validators: {
                    notEmpty: {
                        message: 'The Name is required and can\'t be empty'
                    }
                }
            }
        }
    });
});
</script>