<? global $vis_language;?>
<style>
.not-active {
 pointer-events: none;
 cursor: default;
}
</style>
<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['message']) && $operation['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['message']; ?>'); </script><? } ?>
			</header>
			<div class="panel-heading b-b m-t-lg">
			    <p class="pull-right m-t-n-lg">
				  <a href="?/client/change-password" class="btn btn-link btn-sm link pull-right  vis_link_button"><? echo $vis_language['TXTCHNGPASS']; ?></a>
				  <a href="?/client/update-profile" class="btn btn-link btn-sm link pull-right  vis_link_button"><?= $vis_language['TXTEDITPROFILE']; ?></a>
				</p>
			</div>
            <div class="panel-body">
              <div class="tab-content">              
                <div class="tab-pane active" id="summary">
            	  <div class="wrapper">
                    <div class="col-md-2">
					  <div class="panel-group">
						<div class="padder-v text-center clearfix">                            
						  <div class="col-xs-12">
        
							<div class="thumb-lg">
       <? if($client['image_path']=='' || $client['image_path']=='default.jpg'){?>
<div class="l-avatar">
<? 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 bg-white img-responsive" src="<?= VIS_PATH_PROFILE.'default.jpg';?>">
    <? }?>

</div>
<? }else{ ?>
<div class="l-avatar">
<img src="<? echo VIS_PATH_PROFILE; echo $client['image_path']; ?>" class="lg bg-white img-responsive">
</div>
<? }?>
							  <!--<img src="<? //echo VIS_PATH_PROFILE; echo ($client['image_path']!='')?$client['image_path']:'default.jpg'; ?>" class="bg-white img-responsive ">-->
							  <? if($client['is_banned']==1) { ?><span class="label bg-danger"><? echo $vis_language['TXTBANNED']; ?></span><? } ?>
							</div>
						  </div>
						</div>
					  </div>
					  <div class="clear"></div>
				    </div>
                    <div class="col-md-4">
                        <div class="wrapper">
                            <div class="inline">
                              <div class="h4 m-t m-b-xs font-bold text-lt"><? echo $client['first_name']; ?> <? echo $client['last_name']; ?></div>
                              <p class="text-muted m-b"><? echo $client['email']; ?></p>
                              <div class="l-h-1x">
                                  <!--<p class="m-b"><span class="font-bold"><? echo $vis_language['TXTDOMAIN']; ?>: </span><? echo $client['domain_name']; ?></p>-->
                                  <? if($client['parent_name']!=''){ ?><p class="m-b"><span class="font-bold"><? echo $vis_language['TXTPARENT']; ?>: </span><? echo $client['parent_name']; ?></p><? } ?>
                                  <p class="m-b"><span class="font-bold"><? echo $vis_language['TXTCOMPANYNAME']; ?>: </span><? echo $client['office_name']; ?></p>
                                  <p class="m-b"><span class="font-bold"><? echo $vis_language['TXTADDRESS']; ?>: </span><? echo $client['temporary_address']; ?></p>
                                  <? if($client['parent_id']==0){ 
								  if($setting_details!=-1 && $setting_details[0]['content']==1) { ?>
								  <p class="m-b"><span class="font-bold"><? echo $vis_language['TXTADDITIONALEMAILS'];?>: </span>&nbsp;&nbsp;<!--<a href="javascript:void(0)" id="btn-email" class="btn btn-rounded btn-default btn-sm dropdown-toggle" onClick="addEmail();"><i class="vh vh-plus" style="font-size:10px;"></i><? echo $vis_language['TXTADD'];?></a>-->
          <span id="btn-email" class="vis_button label vh-success-bg vis-pointer" onclick="addEmail();" style="cursor:pointer;"><i class="vh vh-plus" style="font-size:10px;"></i><? echo $vis_language['TXTADD'];?></span>
          </p>
								  <div class="form-group" id="emailaddress">
								  <? foreach($email as $i){
									 $title='';$class='';$style='';
									 if($i['is_verified']!=1){
								     $title=$vis_language['TXTRESEND'];
									 $style="color: #428bca;";
										$style1="text-decoration:line-through;";
									 }else{
									 $title="";
									 $style="color: #428bca;"; 
									 $class="not-active";
										$style1="";
									 }
									?>
								  <p><span style=" <? echo $style1;?>"><? echo $i['additional_email'];?></span>&nbsp;&nbsp;<a href="javascript:void(0)" title="<? echo $vis_language['TXTDELETE']; ?>" value="<? echo $i['email_id'];?>" onClick="removedata(<? echo $i['email_id'];?>);"> <i class="vh vh-cross-slim"></i> </a>&nbsp;<a href="javascript:void(0)" value="" onClick="emailVerify(<? echo $i['email_id'];?>);" style="<? echo $style;?>" class="<? echo $class;?>"> <? echo $title; ?> </a></p>
								  <?}?>
								  </div>
								  <div style="display:none;" id="show-email" class="form-group">
									<input type="email" id="vis_additional_email" name="vis_additional_email" class="form-control input-sm"><input type="hidden" id="vis_client_id" name="vis_client_id" value="<? echo $client['client_id'];?>" class="form-control input-sm"><input type="button" onclick="sendChat();" id="button" value="<? echo $vis_language['TXTADD']; ?>" class="btn btn-primary m-t"></div>
								  <?}}?>
							 </div>
                            </div>
                        </div>
                      </div>
                    <div class="col-md-4 col-sm-8">
                      <div class="panel b-a">
                          <header class="panel-heading font-bold b-b b-light"><?= $vis_language['TXTTICKETS']; ?></header>
                        <div class="padder-v text-center clearfix">                            
                          <div class="col-xs-6 b-r">
                            <a href="?/ticket/view-ticket"><div class="h3 font-bold text-muted"><?= $unsolved; ?></div>
                            <small class="text-muted"><?= $vis_language['TXTUNSOLVED']; ?></small></a> 
                          </div>
                          <form class="vis_solved_ticekts_form" method="post">
                          <div class="col-xs-6">
                            <a href="?/ticket/view-ticket/3" onclick="displayTicks()"><div class="h3 font-bold text-muted"><?= $solved; ?></div>
                            <small class="text-muted"><?= $vis_language['TXTSOLVED']; ?></small></a>
                          </div>
                        </div>
                        <input type="hidden" name="vis_module" value="ticket">
                        <input type="hidden" name="vis_operation" value="view_ticket">
                        <input type="hidden" name="vis_status" value="3">
                        </form>
                      </div>
                    <div class="clear"></div>
                    </div>

                    <?  if((VIS_ACCESS_BILLING==1 && $client['parent_id']==0) && VIS_MODULE_ACCESS_BILLING == 1){ ?>
                    <div class="col-md-4 col-sm-6">
                      <div class="panel b-a">
                          <header class="panel-heading font-bold b-b b-light"><?= $vis_language['TXTBILLING']; ?></header>
                        <div class="padder-v text-center clearfix">                            
                          <div class="col-xs-6 b-r">
                            <div class="h3 font-bold text-muted"><?= $client['credit']; ?></div>
                            <small class="text-muted"><?= $vis_language['TXTCASHBAL'].' ('.$domain[0]['currency'].')'; ?></small>
                          </div>
                          <div class="col-xs-6">
                             <div class="h3 font-bold text-muted"><?= ($client['balance']<0?$vis_language['TXTUNLIMITED']:$client['balance']); ?></div>
                            <small class="text-muted"><?= $vis_language['TXTTKTBAL']; ?></small>
                          </div>
                        </div>
                      </div>
                    <div class="clear"></div>
                    </div><? } ?>
            	  </div>
                </div>
              </div>
            </div>
			<? if($custom_field_var != '') { ?>
			    <div class="panel-heading">
				  <div class="wrapper b-b">
					<p class="pull-right m-t-md"><a class="btn btn-link btn-sm link pull-right  vis_link_button" href="?/client/additional-info"><?= $vis_language['TXTEDIT']; ?></a></p>
					<h4><? echo $vis_language['TXTADDITIONALFIELDS']; ?></h4>
				  </div>
				</div>
				<div class="panel-body no-padder">
					<form class="form-horizontal" ><div class="wrapper"><div class="col-md-10"><? echo $custom_field_var; ?></div></div></form>    
				</div> 
			  </div>
			<? } ?>
          </section>
         
    </div><!-- /.row -->
</div> 
</section>
<script>
function emailVerify(emailID){ 
var client = $('#vis_client_id').val();
	$.ajax({
           url: 'index.php',
           data: {'vis_module':"client", 'vis_operation':"check_verify_email", 'vis_static_area':1,'vis_verify_email':emailID, 'vis_client_id':client},
           success: function(data) {  
		         $("#vis_submit_msg_div").show();
				 $("#vis_submit_msg_div").removeClass('alert-danger').addClass('alert-success').fadeOut(10000); 
				 $("#vis_submit_msg_div").html('verification link send to your email account');
		  
		   },
		    error: function() {
            alert('ERROR!!!');
         }
       });
	
}
function removedata(val){ 
	var client = $('#vis_client_id').val();
	$.ajax({
           url: 'index.php',
           data: {'vis_module':"client", 'vis_operation':"remove_email", 'vis_remove_email':val, 'vis_client_id':client},
           success: function(data) {  
		        $( "div#emailaddress" ).html(data); 
		        $("#vis_submit_msg_div").show();
				$("#vis_submit_msg_div").removeClass('alert-danger').addClass('alert-success').fadeOut(10000); 
				$("#vis_submit_msg_div").html('email remove successfully');
				window.scrollTo(0,0);
				 $('#show-email').hide();
	             $('#btn-email').show();
		   },
		    error: function() {
            alert('ERROR!!!');
         }
       });
}
function addEmail(){
	$('#show-email').show();
	$('#btn-email').hide();	
}
function sendChat(){ 
	var email = $('#vis_additional_email').val(); 
	var client = $('#vis_client_id').val(); 
	$.ajax({
           url: 'index.php',
           data: {'vis_module':"client", 'vis_operation':"add_email", 'vis_additional_email':email, 'vis_client_id':client},
           success: function(data) {  
		    if(data=='blank'){ 
				 $("#vis_submit_msg_div").show(); 
				 $("#vis_submit_msg_div").addClass('alert-danger').fadeOut(10000); 
				 $("#vis_submit_msg_div").html('<? echo $vis_language['TXTBLANKFIELD'];?>');   
		    }else if(data=='repeat'){  
				 $("#vis_submit_msg_div").show(); 
				 $("#vis_submit_msg_div").addClass('alert-danger').fadeOut(10000); 
			     $("#vis_submit_msg_div").html('<? echo $vis_language['TXTEMAILALREADYEXIST'];?>'); 
				 $('#show-email').hide();
	             $('#btn-email').show();
		    }else if(data=='err'){
				 $("#vis_submit_msg_div").show(); 
				 $("#vis_submit_msg_div").addClass('alert-danger').fadeOut(10000); 
			     $("#vis_submit_msg_div").html('<? echo $vis_language['MSGEMAILMISS'];?>');
			}else{
			     $( "div#emailaddress" ).html(data);
				 $("#vis_submit_msg_div").show();
				 $("#vis_submit_msg_div").removeClass('alert-danger').addClass('alert-success').fadeOut(10000); 
				 //$("#vis_submit_msg_div").html('<? //echo $vis_language['MSGSUCCOPRT'];?>');  
					$("#vis_submit_msg_div").html('verification link send to your email account');
                 $('#show-email').hide();
	             $('#btn-email').show();					 
		    }
			     $('#vis_additional_email').val("");
			     window.scrollTo(0,0);
		},
		    error: function() {
            alert('ERROR!!!');
        }
    });
}
function displayTicks()
{
	$('.vis_solved_ticekts_form').submit();
}
</script>
