<?php
    
    include 'Header.php';
    include 'Navbar.php';
	include 'Sidebar.php';
	include 'includes/admin_API_Config.php';

	
	$obj = new API_Config;
	$data = array();
	$data['refer_id']     = $_REQUEST['refer_id'];
	$data['user_id']      = $_REQUEST['id'];
	$data['customer_id']  = $_REQUEST['customer_id'];
	$response = json_decode($obj->call_API("API_getProfile.php", $data));

	//var_dump($response);
	$profile = $response->profile_data[0];

	error_reporting(0);

?>


<!-- BEGIN CONTENT -->
	<div class="page-content-wrapper">
		<div class="page-content">
		
		 
		 
		<!-- BEGIN PAGE CONTENT-->
			<div class="row profile">
				<div class="col-md-12">
					<!--BEGIN TABS-->
					<div class="tabbable tabbable-custom tabbable-noborder ">
						<ul class="nav nav-tabs">
							<li class="active">
								<a href="#personal" id="personalTab" data-toggle="tab">Personal</a>
							</li>
							<li>
								<a href="#address"  id="addressTab" data-toggle="tab">Address</a>
							</li>
							<li>
								<a href="#bank" id="bankTab" data-toggle="tab">Bank</a>
							</li>
							<li>
								<a href="#login" id="loginTab" data-toggle="tab">Login Password</a>
							</li>
							<li>
								<a href="#transaction" id="transactionTab" data-toggle="tab">Transaction Password</a>
							</li>
							<li>
								<a href="#kyc" id="kycTab" data-toggle="tab">KYC</a>
							</li>
						</ul>

						<form action="#" role="form" name="frmEditProfile" id="frmEditProfile"  class="tab-content" method="post" enctype="multipart/form-data">

						<div class="tab-content">
							<!--Personal Tab Start-->
							<div class="tab-pane active" id="personal" style="padding-top:30px:">
								<form >
									<div class="row">
										<div class="form-group form-md-line-input form-md-floating-label col-md-3">
											<input type="text" class="form-control" id="firstName" name="firstName" value="<?php echo ucwords($profile->name);?>" readonly>
											<label for="firstName">First Name</label>
											<span class="help-block"></span>
										</div>
										<div class="form-group form-md-line-input form-md-floating-label col-md-3">
											<input type="text" class="form-control" id="lastName" name="lastName" value="<?php echo ucwords($profile->last_name);?>" readonly> 
											<label for="lastName">Last Name</label>
											<span class="help-block"></span>
										</div>
										<div class="form-group form-md-line-input form-md-floating-label col-md-3">
											<input type="text" class="form-control" id="motherName" name="motherName" value="<?php echo ucwords($profile->mother_name);?>" readonly>
											<label for="text">Mother's Name</label>
											<span class="help-block"></span>
										</div>
									</div>
									<div class="row">
										<div class="form-group form-md-line-input form-md-floating-label col-md-4">
											<input class="form-control form-control-inline input-medium date-picker" size="16" type="text" id="dob" name="dob"  value="<?php echo date("d/m/Y", strtotime($profile->dob));?>" readonly>
											<label for="dob">Date of Birth</label>
											<span class="help-block"></span>
										</div>
										<div class="form-group form-md-line-input form-md-floating-label col-md-4">
											<select class="form-control" id="gender" name="gender">
												<option value="Male" <?php if($profile->gender=="Male") echo "Selected";?>>Male</option>
												<option value="Female" <?php if($profile->gender=="Female") echo "Selected";?>>Female</option>
											</select>
											<label for="gender">Select Gender</label>
											<span class="help-block"></span>
										</div>
									</div>
									<div class="row">
										<div class="form-group form-md-line-input form-md-floating-label col-md-4">
											<input type="text" class="form-control" id="emailID" name="emailID" value="<?php echo $profile->email_address;?>" readonly>
											<label for="emailID">Email Address</label>
											<span class="help-block"></span>
										</div>
										<div class="form-group form-md-line-input form-md-floating-label col-md-4" style="padding-top:0px;">
											<label for="mobileNumber">Mobile Number</label>
											<input type="tel" class="form-control" id="mobileNumber" name="mobileNumber" value="+<?php echo  $profile->country_code . $profile->mobile_number;?>" maxlength="10">
											<span class="help-block"></span>
										</div>
									</div>
								</form>
							</div>
							<!--Personal Tab End-->

							<!--Address Tab Start-->
							<div class="tab-pane" id="address">
								<div class="row">
									<div class="form-group form-md-line-input form-md-floating-label col-md-5">
										<input type="text" class="form-control" id="addressLine1" name="addressLine1" value="<?php echo ucwords($profile->address1);?>" readonly>
										<label for="addressLine1">Address Line 1</label>
										<span class="help-block"></span>
									</div>
									<div class="form-group form-md-line-input form-md-floating-label col-md-5">
										<input type="text" class="form-control" id="addressLine2" name="addressLine2" value="<?php echo ucwords($profile->address2);?>" readonly>
										<label for="addressLine2">Address Line 2</label>
										<span class="help-block"></span>
									</div>
								</div>
								<div class="row">
									<div class="form-group form-md-line-input form-md-floating-label col-md-4">
										<input type="text" class="form-control" id="country" name="country" value="<?php echo ucwords($profile->country);?>" readonly>
										<label for="country">Country</label>
										<span class="help-block"></span>
									</div>
									<div class="form-group form-md-line-input form-md-floating-label col-md-4">
										<input type="text" class="form-control" id="state" name="state" value="<?php echo ucwords($profile->state);?>" readonly>
										<label for="state">State</label>
										<span class="help-block"></span>
									</div>
								</div>
								<div class="row">
									<div class="form-group form-md-line-input form-md-floating-label col-md-4">
										<input type="text" class="form-control" id="city" name="city" value="<?php echo ucwords($profile->city);?>" readonly>
										<label for="city">City</label>
										<span class="help-block"></span>
									</div>
									<div class="form-group form-md-line-input form-md-floating-label col-md-4">
										<input type="text" class="form-control" id="zipCode" name="zipCode" value="<?php echo ucwords($profile->zip_code);?>" readonly>
										<label for="zipCode">Zip Code</label>
										<span class="help-block"></span>
									</div>
								</div>
							</div>
							<!--Address Tab End-->


							<!--Bank Tab Start-->
							<div class="tab-pane" id="bank">
								<div class="row">
									<div class="form-group form-md-line-input form-md-floating-label col-md-4">
										<input type="text" class="form-control" id="accountNo" name="accountNo"  value="<?php echo $profile->account_number;?>" readonly>
										<label for="accountNo">Account Number</label>
										<span class="help-block"></span>
									</div>
									<div class="form-group form-md-line-input form-md-floating-label col-md-4">
										<input type="text" class="form-control" id="bankName" name="bankName" value="<?php echo $profile->bank_name;?>" readonly>
										<label for="bankName">Bank Name</label>
										<span class="help-block"></span>
									</div>
								</div>
								<div class="row">
									<div class="form-group form-md-line-input form-md-floating-label col-md-4">
										<input type="text" class="form-control" id="swiftCode" name="swiftCode" value="<?php echo $profile->swift_code;?>" readonly>
										<label for="swiftCode">Swift Code</label>
										<span class="help-block"></span>
									</div>
									<div class="form-group form-md-line-input form-md-floating-label col-md-4">
										<input type="text" class="form-control" id="ifscCode" name="ifscCode" value="<?php echo $profile->ifsc_code;?>" readonly>
										<label for="ifscCode">IFSC Code</label>
										<span class="help-block"></span>
									</div>
								</div>
							</div>
							<!--Bank Tab End-->


							<!--Login Password Tab Start-->
							<div class="tab-pane" id="login">
								<div class="row">
									<div class="form-group form-md-line-input form-md-floating-label col-md-4">
										<input type="password" class="form-control" id="newLoginPassword" name="newLoginPassword">
										<label for="newLoginPassword">New Password</label>
										<span class="help-block"></span>
									</div>
									<div class="form-group form-md-line-input form-md-floating-label col-md-4">
										<input type="password" class="form-control" id="confirmLoginPassword" name="confirmLoginPassword">
										<label for="confirmLoginPassword">Confirm Password</label>
										<span class="help-block"></span>
									</div>
								</div>
							</div>
							<!--Login Password End-->

							<!--Transaction Tab Start-->
							<div class="tab-pane" id="transaction">
								<div class="row">
									<div class="form-group form-md-line-input form-md-floating-label col-md-4">
										<input type="password" class="form-control" id="newTransactionPassword" name="newTransactionPassword">
										<label for="newTransactionPassword">New Transaction Password</label>
										<span class="help-block"></span>
									</div>
									<div class="form-group form-md-line-input form-md-floating-label col-md-4">
										<input type="password" class="form-control" id="confirmTransactionPassword" name="confirmTransactionPassword">
										<label for="confirmTransactionPassword">Confirm Transaction Password</label>
										<span class="help-block"></span>
									</div>
								</div>
							</div>
							<!--Transaction Tab End-->


							<!--KYC Tab Start-->
							<div class="tab-pane" id="kyc" style="padding-left:20px;">
								<div class="row">
									<div class="form-group form-md-radios col-md-6">
										<label>Membership Account:</label>
										<div class="md-radio-inline">
											<div class="md-radio">
												<input type="radio" id="accountTypeRadios1" name="accountTypeRadios" class="md-radiobtn" value="1" 
												<?php if($profile->account_type==1) echo "checked"; else if(empty($profile->account_type)) echo "checked";?> disabled>
												<label for="accountTypeRadios1">
												<span class="inc"></span>
												<span class="check"></span>
												<span class="box"></span>
												Individual</label>
											</div>
											<div class="md-radio">
												<input type="radio" id="accountTypeRadios2" name="accountTypeRadios" class="md-radiobtn" value="2" 			<?php if($profile->account_type==2) echo "checked"; else if(empty($profile->account_type)) echo "checked";?> disabled>
												<label for="accountTypeRadios2">
												<span class="inc"></span>
												<span class="check"></span>
												<span class="box"></span>
												Company</label>
											</div>
										</div>
									</div>
									<!--div class="col-md-3">
										</u><form action="../../assets/global/plugins/dropzone/upload.php" class="dropzone" id="my-dropzone">
										</form>
									</div-->
								</div>
								<div class="row" id="companyRow" <?php if($profile->account_type==1 || empty($profile->account_type)) echo "hidden";?>>
									<div class="form-group form-md-line-input form-md-floating-label col-md-4">
										<input type="text" class="form-control" id="companyName" name="companyName" value="<?php echo $profile->company_name;?>" required disabled>
										<label for="companyName">Company Name</label>
										<span class="help-block"></span>
									</div>
									<div class="form-group form-md-line-input form-md-floating-label col-md-4">
										<input type="text" class="form-control" id="txtGSTNo" name="txtGSTNo" value="<?php echo $profile->gst_no;?>" required disabled>
										<label for="txtGSTNo">GST No</label>
										<span class="help-block"></span>
									</div>
								</div>
								<div class="row">
									<div class="form-group form-md-line-input form-md-floating-label col-md-3">
										<input type="text" class="form-control" id="txtPan" name="txtPan" value="<?php echo $profile->pan_no;?>" disabled>
										<label for="txtPan">PAN / Tax ID Number:</label>
										<span class="help-block"></span>
									</div>
									<div class="form-group col-md-3">
										 <input type="file" class="dropify" name="panDocs" id="panDocs" data-max-file-size="2M" data-allowed-file-extensions="pdf png jpeg jpg" accept="image/png, image/jpg, image/jpeg, application/pdf" data-default-file='<?php if(!empty($profile->doc_name)) echo 'https://s3.ap-south-1.amazonaws.com/mybooster/KYC/' . $profile->doc_name;?>' disabled>
										 <input type="hidden" name="txtpanDocs" id="txtpanDocs" class="form-control" value="<?php echo $profile->doc_name;?>">
								   </div>
								</div>
								<div class="row">
									<div class="form-group form-md-radios col-md-12">
										<label>KYC Documents:</label>
										<div class="md-radio-inline">
											<div class="md-radio">
												<input type="radio" id="addressProof1" name="addressProof" class="md-radiobtn" value="1"
												<?php if($profile->address_proof==1) echo "checked";?> disabled>
												<label for="addressProof1">
												<span class="inc"></span>
												<span class="check"></span>
												<span class="box"></span>
												AADHAR / Social Security Number</label>
											</div>
											<div class="md-radio">
												<input type="radio" id="addressProof2" name="addressProof" class="md-radiobtn" value="2"
												<?php if($profile->address_proof==2) echo "checked";?> disabled>
												<label for="addressProof2">
												<span class="inc"></span>
												<span class="check"></span>
												<span class="box"></span>
												Driving License</label>
											</div>
											<div class="md-radio">
												<input type="radio" id="addressProof3" name="addressProof" class="md-radiobtn" value="3"
												<?php if($profile->address_proof==3) echo "checked";?> disabled>
												<label for="addressProof3">
												<span class="inc"></span>
												<span class="check"></span>
												<span class="box"></span>
												Passport</label>
											</div>
										</div>
									</div>
								</div>
								<div class="row">
									<div class="form-group form-md-line-input form-md-floating-label col-md-3">
										<input type="text" class="form-control" id="addressProofInfo" name="addressProofInfo" value="<?php echo $profile->proof_id;?>" required disabled>
										<label for="addressProofInfo">Enter Information</label>
										<span class="help-block"></span>
									</div>
									<div class="form-group col-md-3" id="frontRow">
										 <label id="lblFront">Front Page: *</label>
										 <input type="file" class="dropify" name="frontDocs" id="frontDocs" data-max-file-size="2M" data-allowed-file-extensions="pdf png jpeg jpg" accept="image/png, image/jpg, image/jpeg, application/pdf" data-default-file='<?php if(!empty($profile->front_cover)) echo 'https://s3.ap-south-1.amazonaws.com/mybooster/KYC/' . $profile->front_cover;?>' disabled>
										 <input type="hidden" name="txtFrontDocs" id="txtFrontDocs" class="form-control" value="<?php echo $profile->front_cover;?>">
									</div>
								   <div class="form-group col-md-3" id="backRow"<?php if($profile->address_proof==2) echo "hidden";?>>
										 <label id="lblBack">Back Page: *</label>
										 <input type="file" class="dropify" name="backDocs" id="backDocs" data-max-file-size="2M" data-allowed-file-extensions="pdf png jpeg jpg" accept="image/png, image/jpg, image/jpeg, application/pdf" data-default-file='<?php if(!empty($profile->back_cover)) echo 'https://s3.ap-south-1.amazonaws.com/mybooster/KYC/' . $profile->back_cover;?>' disabled>
										 <input type="hidden" name="txtBackDocs" id="txtBackDocs" class="form-control" value="<?php echo $profile->back_cover;?>">
								   </div>
								</div>
								<input type="hidden" name="refer_id" id="refer_id" class="form-control" value="<?php echo $_REQUEST['refer_id'];?>">
								<input type="hidden" name="user_id" id="user_id" class="form-control" value="<?php echo $_REQUEST['id'];?>">
								<input type="hidden" name="customer_id" id="customer_id" class="form-control" value="<?php echo $_REQUEST['customer_id'];?>">
							</div>
							<!--KYC Tab End-->

							<div class="row"  style="padding-left:20px;">
								<p>&nbsp;</p>
								<div class="form-group col-md-3">
									<button type="submit" class="btn default btn-lg blue" id="btnEditProfile">Edit</button>
									<input type="hidden" name="section" id="section" class="form-control" hidden/>
									<input type="hidden" name="txtAuthenticate" id="txtAuthenticate" class="form-control" hidden/>
								</div>
							</div>

						</div>
					</form>
					</div>
					<!--END TABS-->
				
				</div>
			</div>
			<!--END PAGE CONTENT-->
</div>
<?php
   
   include 'footer.php';

?>


<script type="text/javascript">

	   $(".cancel").click(function(){
			 location.reload();
	   });

	   $("#personalTab, #addressTab, #bankTab, #kycTab").click(function(){
		   disableField();
		   $("#btnEditProfile").text("Edit");
	   });


	   $("#loginTab, #transactionTab").click(function(){
		   $("#btnEditProfile").text("Save");
	   });


	   $("input[name=accountTypeRadios]").click(function(){

			if($("input[name=accountTypeRadios]:checked").val() == 1)
			 {
				$("#companyRow").attr("hidden", "hidden");
				$("#companyName").removeAttr('required');
				$("#txtGSTNo").removeAttr('required');

			 }

			else
			 {
				$("#companyRow").removeAttr('hidden');
				$("#companyName").attr('required', 'required');
				$("#txtGSTNo").attr('required', 'required');

			 }

	  });


	   $("input[name=addressProof]").click(function(){

		if($("input[name=addressProof]:checked").val() == 1 || $("input[name=addressProof]:checked").val() == 3)
		 {
			$("#backRow").removeAttr('hidden');
		 }

		else
		 {
			$("#backRow").attr("hidden", "hidden");
		 }

	 });



	    function enableField()
		{
			$('#firstName').removeAttr("readonly");
		    $('#lastName').removeAttr("readonly");
		    $('#motherName').removeAttr("readonly");
			$('#mobileNumber').removeAttr("readonly");
			$('#emailID').removeAttr("readonly");
			$('#dob').removeAttr("readonly");
			$('#selectGender').removeAttr("disabled");
			$('#addressLine1').removeAttr("readonly");
			$('#addressLine2').removeAttr("readonly");
			$('#zipCode').removeAttr("readonly");
			$('#country').removeAttr("readonly");
			$('#state').removeAttr("readonly");
			$('#city').removeAttr("readonly");
			$('#accountNo').removeAttr("readonly");
			$('#bankName').removeAttr("readonly");
			$('#swiftCode').removeAttr("readonly");
			$('#ifscCode').removeAttr("readonly");
			$("#accountTypeRadios1").removeAttr('disabled');
			$("#accountTypeRadios2").removeAttr('disabled');
			$("#companyName").removeAttr('disabled');
			$("#txtGSTNo").removeAttr('disabled');
			$("#txtPan").removeAttr('disabled');
			$("#panDocs").removeAttr('disabled');
			$("#addressProof1").removeAttr('disabled');
			$("#addressProof2").removeAttr('disabled');
			$("#addressProof3").removeAttr('disabled');
			$("#addressProofInfo").removeAttr('disabled');
			$("#frontDocs").removeAttr('disabled');
			$("#backDocs").removeAttr('disabled');
	    }


		function disableField()
		{
			
			$('#firstName').attr("readonly", "readonly");
			$('#lastName').attr("readonly", "readonly");
			$('#motherName').attr("readonly", "readonly");
			$('#mobileNumber').attr("readonly", "readonly");
			$('#emailID').attr("readonly", "readonly");
			$('#selectGender').attr("readonly", "readonly");
			$('#dob').attr("readonly", "readonly");
			$('#selectGender').attr("disabled", "disabled");
			$('#addressLine1').attr("readonly", "readonly");
			$('#addressLine2').attr("readonly", "readonly");
			$('#zipCode').attr("readonly", "readonly");
			$('#country').attr("readonly", "readonly");
			$('#state').attr("readonly", "readonly");
			$('#city').attr("readonly", "readonly");
			$('#accountNo').attr("readonly", "readonly");
			$('#bankName').attr("readonly", "readonly");
			$('#swiftCode').attr("readonly", "readonly");
			$('#ifscCode').attr("readonly", "readonly");
			$('#accountTypeRadios1').attr("disabled", "disabled");
			$('#accountTypeRadios2').attr("disabled", "disabled");
			$('#companyName').attr("disabled", "disabled");
			$('#txtGSTNo').attr("disabled", "disabled");
			$('#txtPan').attr("disabled", "disabled");
			$('#panDocs').attr("disabled", "disabled");
			$('#addressProof1').attr("disabled", "disabled");
			$('#addressProof2').attr("disabled", "disabled");
			$('#addressProof3').attr("disabled", "disabled");
			$('#addressProofInfo').attr("disabled", "disabled");
			$('#frontDocs').attr("disabled", "disabled");
			$('#backDocs').attr("disabled", "disabled");

		}

</script>