<? global $vis_language; ?>
<section class="container m-t-md">
   <div class="row">
      <div class="col-md-12">
         <section class="panel shadow-none">
				<? 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><? } ?>
				<? if(isset($operation['profile_message_pswd_updt']) && $operation['profile_message_pswd_updt']!='') {?><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_pswd_updt']; ?>'); </script><? } ?>
				  <div class="panel-body no-padder">
                    <form class="form-horizontal" method="post" id="vis_form_register" name="vis_form_register" 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" 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">
</div>
<? }?>
                                        <!--<div class="thumb-lg pull-left m-r-md avatar" id="vis_profile_img"><img width="48" 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" id="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>
                                </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" id="vis_firstname" name="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="<? echo $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 type="tel" class="form-control input-sm"  name="vis_contact_number" id="vis_contact_number" value="<? echo $client['contact_number']; ?>" data-type="phone" placeholder="<? echo $vis_language['TXTPHONEEG']; ?>"></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" 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" class="form-control input-sm"  name="vis_office_website" id="vis_office_website" value="<? echo $client['office_website']; ?>" /></div>
                              </div>
                              <div class="form-group">
                                <label for="JobTitle" class="col-sm-2 control-label"><? echo $vis_language['TXTLANGUAGE']; ?></label>
                                <div class="col-sm-8">
								   <select name="vis_language" id="vis_language" class="form-control input-sm <? if(!is_mobile()) echo 'selectpicker'; ?>"  <? if(count($language_list)>10) echo 'data-live-search="true"';?>><? global $language_list;
									  for($i=0;$i<count($language_list);$i++) { ?>
										<option value="<? echo $language_list[$i]['language_id']; ?>"<? if($client['language']==$language_list[$i]['language_id']) echo ' selected="selected"'?>><? echo $language_list[$i]['language_name']; ?></option><?
									  } ?></select>                              
                                </div>								   
                              </div>
							    <? if(VIS_MODULE_ACCESS_FORUM==1) {?>
							    <div class="form-group">
                                <label for="CompanyWebsite" class="col-sm-2 control-label"><? echo $vis_language['TXTFORUMSIGNATURE']; ?></label>
                                <div class="col-sm-8"> <textarea class="form-control input-sm" rows="6" name="vis_forum_signature_content" id="vis_forum_signature_content"><? echo $client['forum_signature_content']; ?></textarea></div>
                              </div>
							    <div class="form-group">
                                <label for="CompanyWebsite" class="col-sm-2 control-label"><? echo $vis_language['MSGEMAILNOTIFICATION']; ?></label>
                                <div class="col-sm-8 m-t-sm"> <input type="checkbox" name="vis_email_notification" id="vis_email_notification" <? echo ($client['forum_email_notification']==1 || $client['forum_email_notification']=='')?' checked="checked"':''; ?>><i></i> <? echo $vis_language['TXTENABLE']; ?></div>
                              </div>
								<? } ?>
							   <? if($custom_field_var!='' && $custom_field_var!=$vis_language['MSGRECORDMISS']){ ?>
								<div class="form-group m-t">
								   <div class="col-sm-12"><h5><? echo $vis_language['TXTADDITIONALFIELDS']; ?></h5></div>
								</div>
								<div class="line b-b line-lg pull-in"></div>
								<br/>
								<div class="row m-l">
									<?= $custom_field_var; ?>
								</div>
								<input type="hidden" name="vis_customfields" id="vis_customfields" value="1"/>
								<div class="line b-b line-lg pull-in"></div>
								<? } ?>
	
							    <input type="hidden" name="vis_client_id" value="<? echo $client['client_id']; ?>" />
							     <input type="hidden" name="vis_parent_client_id" value="<? echo $client['parent_id']; ?>" />
							     <input type="hidden" name="vis_domain_id" value="<? echo $client['domain_id']; ?>" /><input type="hidden" name="vis_operation" value="update_client" /> <input type="hidden" name="vis_client_type" value="<? echo $client['client_type']; ?>" /><input type="hidden" name="vis_module" value="client" />
                          </div> 
                        </div> 
                        <div class="col-lg-offset-2 col-lg-8 m-b-lg">
                            <button type="submit" class="btn btn-primary"><? echo $vis_language['TXTUPDATE']; ?></button>
                        </div>
                    </form>    
                </div> <!-- /.profile tab-pane -->
             
           </section>
       </div>
    </div>
</section>
<script>
 <? if(!defined('VIS_HEAD_MENU_HTML_EDITOR') || VIS_HEAD_MENU_HTML_EDITOR==1) { ?>    
	   $(function(){
			$('#vis_forum_signature_content').redactor({
				buttonSource: true,			
				minHeight: 180, // pixels
				maxHeight: 180,
				imageUpload: "index.php?vis_tmpst="+new Date().getTime()+"&vis_module=ticket&vis_operation=upload_file&vis_static_area=editor_image_upload",           
				imageUploadParam: 'files',
				plugins: ['source']
			});
		});  
		$("#vis_forum_signature_content").val('<? echo $client['forum_signature_content'];?>');
   <? } ?>
	function handlefilename(id) {
		var filename = id.value;
		var lastIndex = filename.lastIndexOf("\\");
		if (lastIndex >= 0) filename = filename.substring(lastIndex + 1);
        $('#vis_filename').text(filename);
    }

	function clear_prof_image()
	{
        $.ajax({
            url: 'index.php',
            data: {'vis_module':"client", 'vis_operation':"clear_client_img", 'vis_client_id':<? echo $client['client_id']; ?> },
            type: "POST",
            success: function(data) {
													<? 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" src="<? echo VIS_PATH_PROFILE; ?>default.jpg"/>';
    <? }?>
                //var img='<img width="48" src="<? echo 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>
