<? global $vis_language; ?>
 <section class="container m-t-md">
   <div class="row">
      <div class="col-md-12">
          <section class="panel shadow-none">
		<header class="vis_login_head">
			<? if(isset($operation['profile_message']) && $operation['profile_message']!='') { ?>
			<script> $("#<?= ($operation['success']==1)?'vis_submit_msg_div':'vis_submit_err_div'; ?>").show(); $("#<?= ($operation['success']==1)?'vis_submit_msg_div':'vis_submit_err_div'; ?>").html('<? echo $operation['profile_message']; ?>'); </script><? } ?>
		</header>
		
		  <div class="panel-body">
            <div class="form-horizontal">
                <div class="col-sm-1"></div>
                <div class="col-sm-11">
                    <div class="radio i-checks pull-left m-r-lg">
                    <label>
                        <input type="radio" name="vis_password_btn" id="vis_updatepassword" value="1" checked="checked"><i></i>
                        <? echo $vis_language['TXTUPDATECONTACT']; ?>
                    </label></div>
                    <div class="radio i-checks pull-left">
                    <label>
                        <input type="radio" id="vis_resetpassword" name="vis_password_btn" value="0" ><i></i>
                        <? echo $vis_language['TXTSENDRESETPASSWORDEMAIL']; ?>
                    </label></div>	
                </div>	
            </div>
            <div class="line b-b line-lg pull-in"></div>  <br/><br/><br/>              
			<form class="form-horizontal" id="vis_form_register" name="vis_form_register" method="post" enctype="multipart/form-data">
				<div class="col-md-12">
				  <div class="wrapper">
					  <div class="form-group">
						<label for="ProfileImage" class="col-sm-2 control-label"><? echo $vis_language['TXTPROFILEIMG']; ?></label>
						<div class="col-sm-8">
						  <div class="row">
							<div class="col-md-12">
       <? if($client['image_path']=='' || $client['image_path']=='default.jpg'){?>
<div class="l-avatar pull-left m-r-md" id="vis_profile_img">
<? if($client['first_name']!=''){
	$firstname=preg_split('//u', $client['first_name'], -1, PREG_SPLIT_NO_EMPTY);
$lastname=preg_split('//u', $client['last_name'], -1, PREG_SPLIT_NO_EMPTY);
	?>
    <div class="lg"><? echo ucfirst($firstname[0]).ucfirst($lastname[0]);?></div>
    <? }else{ ?>
    <img class="lg m-t-sm m-b-sm bg-light" src="<?= VIS_PATH_PROFILE.'default.jpg';?>">
    <? }?>

</div>
<? }else{ ?>
<div class="l-avatar pull-left m-r-md" id="vis_profile_img">
<img src="<? echo VIS_PATH_PROFILE; echo $client['image_path']; ?>" class="lg m-t-sm m-b-sm bg-light">
</div>
<? }?>
                                <!--<div class="thumb-lg pull-left m-r-md avatar" id="vis_profile_img">
								<img width="48" class="m-t-sm m-b-sm bg-light" src="<? //echo VIS_PATH_PROFILE; echo ($client['image_path']!='')?$client['image_path']:'default.jpg'; ?>" /> 
								</div>-->
								<div class="col-lg-6 m-t-lg">
									 <input type="file" name=vis_pro_img class="filestyle" data-icon="false" data-classButton="btn btn-link link text-xm" data-buttonText="<? echo $vis_language['TXTUPLOADIMG']; ?>" data-input="false" onchange="handlefilename(this);">
									<label id="vis_filename"></label>
                                    <span id="clearImg">
                                        <? if($client['image_path']!='') {?>	
                                            <button type="button" id="clearBtn" class="btn btn-primary btn-xs" onclick="javascript:clear_prof_image();"><? echo $vis_language['TXTCLEAR']; ?></button> 
                                        <? }?>
                                    </span>	
								</div>
							</div>
						  </div> <!-- /.row -->
						</div>
					  </div>
					  <div class="form-group">
						<label for="FirstName" class="col-sm-2 control-label"><? echo $vis_language['TXTFIRSTNAME']; ?></label>
						<div class="col-sm-8"><input type="text" class="form-control input-sm" name="vis_firstname" id="vis_firstname" value="<?= ($operation['profile_message']!='')?$operation['vis_firstname']:$client['first_name']; ?>"></div>
					  </div>
					  <div class="form-group">
						<label for="LastName" class="col-sm-2 control-label"><? echo $vis_language['TXTLASTNAME']; ?></label>
						<div class="col-sm-8"><input type="text" class="form-control input-sm" name="vis_lastname" id="vis_lastname" value="<?= $client['last_name']; ?>"></div>
					  </div>
					  <div class="form-group">
						<label for="PersonalEmail" class="col-sm-2 control-label"><? echo $vis_language['TXTEMAIL']; ?></label>
						<div class="col-sm-8"><input type="email" class="form-control input-sm" name="vis_email" id="vis_email" value="<?= ($operation['profile_message']!='')?$operation['vis_email']:$client['email']; ?>"></div>
					  </div>
					  <div class="form-group">
						<label for="UserName" class="col-sm-2 control-label"><? echo $vis_language['TXTUSERNAME']; ?></label>
						<div class="col-sm-8"><input type="text" class="form-control input-sm" name="vis_username" id="vis_username" value="<?= ($operation['profile_message']!='')?$operation['vis_username']:$client['user_name']; ?>"></div>
					  </div>
					  <div class="form-group">
						<label for="PhoneNumber" class="col-sm-2 control-label"><? echo $vis_language['TXTPHONE']; ?></label>
						<div class="col-sm-8"><input name="vis_contact_number" id="vis_contact_number" value="<? echo $client['contact_number']; ?>" class="form-control input-sm" data-type="phone"></div>
					  </div>
					  <div class="form-group">
						<label for="HomeAddress" class="col-sm-2 control-label"><? echo $vis_language['TXTADDRESS']; ?></label>
						<div class="col-sm-8"><textarea class="form-control input-sm" rows="4" name="vis_caddress" id="vis_caddress"><? echo $client['temporary_address']; ?></textarea></div>
					  </div>
					  <div class="form-group">
						<label for="PersonalCity" class="col-sm-2 control-label"><? echo $vis_language['TXTCITY']; ?></label>
						<div class="col-sm-8"><input type="text" class="form-control input-sm" name="vis_city" id="vis_city" value="<? echo $client['city']; ?>" /></div>
					  </div>
					  <div class="form-group">
						<label for="PersonalState" class="col-sm-2 control-label"><? echo $vis_language['TXTSTATE']; ?></label>
						<div class="col-sm-8"><input type="text" class="form-control input-sm" name="vis_state" id="vis_state" value="<? echo $client['state']; ?>"></div>
					  </div>
					  <div class="form-group">
						<label for="PersonalPostalCode" class="col-sm-2 control-label"><? echo $vis_language['TXTZIPCODE']; ?></label>
						<div class="col-sm-8"><input type="text" class="form-control input-sm" name="vis_zipcode" id="vis_zipcode" value="<? echo $client['zip_code']; ?>"></div>
					  </div>
					  <div class="form-group">
						<label for="PersonalCountry" class="col-sm-2 control-label"><? echo $vis_language['TXTCOUNTRY']; ?></label>
						<div class="col-sm-8"><input type="text" class="form-control input-sm" name="vis_country" id="vis_country" value="<? echo $client['country']; ?>"></div>
					  </div>
					  <div class="form-group">
						<label for="PersonalWebsite" class="col-sm-2 control-label"><? echo $vis_language['TXTWEBSITE']; ?></label>
						<div class="col-sm-8"><input type="url" data-type="url" class="form-control input-sm" id="vis_website" name="vis_website" value="<? echo $client['website']; ?>"></div>
					  </div>
					  <div class="form-group">
						<label for="CompanyName" class="col-sm-2 control-label"><? echo $vis_language['TXTCOMPANYNAME']; ?></label>
						<div class="col-sm-8"><input type="text" class="form-control input-sm" name="vis_office_name" id="vis_office_name" value="<? echo $client['office_name']; ?>"></div>
					  </div>
					  <div class="form-group">
						<label for="Department" class="col-sm-2 control-label"><? echo $vis_language['TXTDEPARTMENT']; ?></label>
						<div class="col-sm-8"><input type="text" class="form-control input-sm" id="vis_department" name="vis_department" value="<? echo $client['department']; ?>"></div>
					  </div>
					  <div class="form-group">
						<label for="JobTitle" class="col-sm-2 control-label"><? echo $vis_language['TXTJOBTITLE']; ?></label>
						<div class="col-sm-8"><input type="text" class="form-control input-sm" name="vis_job_title" id="vis_job_title" value="<? echo $client['job_title']; ?>"></div>
					  </div>
					  <div class="form-group">
						<label for="CompanyWebsite" class="col-sm-2 control-label"><? echo $vis_language['TXTCOMPANYWEBSITE']; ?></label>
						<div class="col-sm-8"><input type="url" data-type="url" class="form-control input-sm"  name="vis_office_website" id="vis_office_website" value="<? echo $client['office_website']; ?>"></div>
					  </div>
					  <div class="line line-dashed b-b line-lg pull-in"></div>
					<div class="form-group">
					  <label class="col-sm-2 control-label"><? echo $vis_language['TXTACCESS']; ?></label>
					  <div class="col-sm-10">
						<div class="checkbox i-checks">
						  <label><input type="checkbox" name="vis_openticket" id="vis_openticket" <? echo ($client_setting[3]==1)?' checked="checked"':''; ?> value="1">
							<i></i><? echo $vis_language['TXTVIEWREPLYSELFTICKET']; ?>
						  </label>
						</div>
						<div class="checkbox i-checks">
						  <label>
							<input type="checkbox" name="vis_view_tickets" id="vis_view_tickets" <? echo ($client_setting[2]==1)?' checked="checked"':''; ?> value="1">
							<i></i><? echo $vis_language['TXTTKTPSTGRM']; ?>
						  </label>
						</div>
						<div class="checkbox i-checks">
						  <label>
							<input type="checkbox" name="vis_replyticket" id="vis_replyticket" <? echo ($client_setting[4]==1)?' checked="checked"':''; ?> value="1">
							<i></i><? echo $vis_language['TXTRTKTPSTGRM']; ?>
						  </label>
						</div>
						
						<div class="checkbox i-checks">
						  <label>
							<input type="checkbox" name="vis_rcv_cont_mail" id="vis_rcv_cont_mail" <? echo ($client_setting[6]==1)?' checked="checked"':''; ?> value="1">
							<i></i><? echo $vis_language['TXTRECEIVECONTACTMAIL']; ?>
						  </label>
						</div>
						<div class="checkbox i-checks">
						  <label>
							<input type="checkbox" name="vis_rcv_pc_cont_mail" id="vis_rcv_pc_cont_mail" <? echo ($client_setting[7]==1)?' checked="checked"':''; ?> value="1">
							<i></i><? echo $vis_language['TXTRECIEVEPCLIENTANDCONTACTSMAIL']; ?>
						  </label>
						</div>		
						
                        <? if(VIS_HEAD_MENU_BILLING==1 && VIS_MODULE_ACCESS_BILLING==1) { ?>
                        <div class="checkbox i-checks">
						  <label>
							<input type="checkbox" name="vis_billingacess" id="vis_billingacess" <? echo ($client_setting[5]==1)?' checked="checked"':''; ?> value="1">
							<i></i><? echo $vis_language['TXTBILLINGACCESS']; ?>
						  </label>
						</div>
                        <? } ?>
					  </div>
					  
					</div>
					<div class="form-group">
							<label for="UserName" class="col-sm-2 control-label"><? echo $vis_language['TXTSTATUS']; ?></label>
							<div class="col-sm-8">
							<label class="switch" value="0"<? if($client['is_approved']!=1) echo 'radio-no-uncheck'; ?>>							
							<input type="checkbox"  name="is_approved"  id="is_approved" value="1" <?php if($client['is_approved']==1){echo  'checked="checked"'; } ?> >
							<span></span>		
							</label>
							</div>
					</div>
				  <div class="line line-dashed b-b line-lg pull-in"></div>
				  </div>
				</div>
				<div class="col-lg-offset-2 col-lg-8 m-b-lg">
					<button type="submit" class="btn btn-primary m-r"><? echo $vis_language['TXTUPDATE']; ?></button>
					<a class="btn btn-default" onclick = "result = confirm('<?php echo str_replace('<br />', '\n', $vis_language['MSGCLTDELETE']); ?>');if(result== false) return false;"  href="?/client/delete_client/<? echo $client['first_name']." ".$client['last_name']."/".$client['client_id']; ?>"><span class="vis_button"><?php echo $vis_language['TXTDELETE'];?></span></a>
					<input type="hidden" name="vis_operation" value="update_client" /><input type="hidden" name="vis_module" value="client" /><input type="hidden" name="vis_parent_client_id" id="vis_client_id" value="<? echo $client['parent_id']; ?>" /><input type="hidden" name="vis_client_id" id="vis_client_id" value="<? echo $client['client_id']; ?>" /><input type="hidden" name="vis_domain_id" id="vis_domain_id" value="<? echo $client['domain_id']; ?>" />
				</div>
			</form>  
            
            <form class="form-horizontal" data-validate="parsley" id="vis_reset_email_form" name="vis_reset_email_form" style="display:none;">
                <div class="form-group">
                    <div class="col-sm-2 col-sm-offset-2">
                         <button onclick="send_resetpasswordlink();" class="btn btn-primary" type="button"><? echo $vis_language['TXTSEND']; ?></button>
                </div></div>
            </form>

           </div>
          </section>
      </div>
   </div>
</section>
<style>
.switch input:checked + span {
    background-color: #1aae88 !important;
}
</style>
<script>
    $("#vis_updatepassword").change( function(){ $("#vis_reset_email_form").hide();$("#vis_form_register").show(); });
	$("#vis_resetpassword").change( function(){ $("#vis_reset_email_form").show();$("#vis_form_register").hide(); });
    function send_resetpasswordlink() {
        $.ajax({
            url: 'index.php',
            data: {'vis_module':"client", 'vis_operation':"reset_send_password", 'vis_client_id':'<?= $client['client_id']; ?>' },
            type: "POST",
            success: function(data) {
                $("#vis_submit_msg_div").show(); $("#vis_submit_msg_div").addClass('alert-success'); $("#vis_submit_msg_div").html('<?= $vis_language['MSGEMAILSENTTORESETPASSWORD']; ?>');
            }
        });
    }
	function handlefilename(id) {
		var filename = id.value;
		var lastIndex = filename.lastIndexOf("\\");
		if (lastIndex >= 0) filename = filename.substring(lastIndex + 1);
        $('#vis_filename').text(filename);
    }
    enter_pass();
    function enter_pass()
    {
      if ($('#vis_reset_pass').is(":checked"))
       {
         $('#vis_pass').show();
       }
       else
       {
         $('#vis_pass').hide();
       }
    }

	$(document).ready(function(){
		function change_password_strength(strengthPercentage, is_valid){
			$("#password_strength_per").val(strengthPercentage);
			var show_password_result;
				if(strengthPercentage>=0 && strengthPercentage<50){show_password_result='<span class="label vh-yellow-bg"> <?=$vis_language['TXTWEAK'];?> </span>';}
				else if(strengthPercentage>=50 && strengthPercentage<70){show_password_result='<span class="label vh-green-bg"> <?=$vis_language['TXTMEDIUM'];?> </span>';}
				else if(strengthPercentage>=70 && strengthPercentage<90){show_password_result='<span class="label vh-orange-bg"> <?=$vis_language['TXTSTRONG'];?> </span>';}
				else if(strengthPercentage>=90 && strengthPercentage<=100){show_password_result='<span class="label vh-red-bg"> <?=$vis_language['TXTVERYSTRONG'];?> </span>';}
				if(is_valid=='not_allowed') $('#password_strenght_id').html('<? echo $vis_language['TXTPASSWORDSRENGTH']."&nbsp;&nbsp;"; ?> '+show_password_result+ '&nbsp;&nbsp; <?=$vis_language['TXTNOTALLOWED']?>');
				else if(is_valid=='allowed') $('#password_strenght_id').html('<? echo $vis_language['TXTPASSWORDSRENGTH']."&nbsp;&nbsp;"; ?> '+show_password_result+ '&nbsp;&nbsp; <?=$vis_language['TXTALLOWED']?>');
				return true;	
		}
		
		$('#vis_password').pStrength({
			'changeBackground'          : false,
			'onPasswordStrengthChanged' : function(passwordStrength, strengthPercentage) {
				if(passwordStrength!=0){change_password_strength(strengthPercentage,'not_allowed');}
			},
			'passwordValidFrom': '<?=$security_password_details[0]['content']?>',
			'onValidatePassword': function(strengthPercentage) {
				change_password_strength(strengthPercentage,'allowed');
			}
		});
	});
    
    function clear_prof_image()
	{
        $.ajax({
            url: 'index.php',
            data: {'vis_module':"client", 'vis_operation':"clear_client_img", 'vis_client_id':<? echo $client['client_id']; ?>, 'vis_parent_id':<? echo VIS_CLIENT_ID; ?> },
            type: "POST",
            success: function(data) {
                //var img='<img width="48" src="<? //echo VIS_PATH_PROFILE; ?>default.jpg"/>';
																<? if($client['first_name']!=''){
																	$firstname=preg_split('//u', $client['first_name'], -1, PREG_SPLIT_NO_EMPTY);
$lastname=preg_split('//u', $client['last_name'], -1, PREG_SPLIT_NO_EMPTY);
																	?>
    var img='<div class="lg"><? echo ucfirst($firstname[0]).ucfirst($lastname[0]);?></div>';
    <? }else{ ?>
    var img='<img class="lg m-t-sm m-b-sm bg-light" src="<?= VIS_PATH_PROFILE.'default.jpg';?>">';
    <? }?>
																
                $("#vis_profile_img").html(img);
                $("#clearImg").hide();
            }
        });
	}
</script>
<script src="<?= VIS_PATH_SCRIPT; ?>file-input/bootstrap-filestyle.min.js"></script>
