 <? 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['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-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="FirstName" class="col-sm-2 control-label"><? //echo $vis_language['TXTTITLE']; ?></label>
                                <div class="col-sm-8"><input type="hidden" class="form-control input-sm" id="vis_name" name="vis_name" value="<?= ($operation['message']!='')?$operation['vis_name']:$client[0]['group_name']; ?>"></div>
                              </div>
                              <div class="form-group">
                                <label for="LastName" class="col-sm-2 control-label"><? echo $vis_language['TXTDESCRIPTION']; ?></label>
                                <div class="col-sm-8"><textarea class="form-control input-sm" rows="4"  name="vis_details" id="vis_details"><?= ($operation['message']!='')?$operation['vis_details']:$client[0]['description']; ?></textarea></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"><?= ($operation['message']!='')?$operation['vis_caddress']:$client[0]['office_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="<?= ($operation['message']!='')?$operation['vis_city']:$client[0]['office_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="<?= ($operation['message']!='')?$operation['vis_state']:$client[0]['office_state']; ?>" /></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="<?= ($operation['message']!='')?$operation['vis_country']:$client[0]['office_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="text" class="form-control input-sm" id="vis_website" name="vis_website" value="<?= ($operation['message']!='')?$operation['vis_website']:$client[0]['office_website']; ?>" /></div>
                              </div>
							  <div class="form-group">
							   <label class="col-sm-2 control-label"><? echo $vis_language['TXTFAX']; ?></label>
							   <div class="col-sm-8">
								  <input class="form-control input-sm" type="text" name="vis_fax" id="vis_fax" value="<?= ($operation['message']!='')?$operation['vis_fax']:$client[0]['office_fax']; ?>">
							   </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['message']!='')?$operation['vis_email']:$client[0]['office_email']; ?>"></div>
                              </div>
							  <div class="form-group">
							   <label class="col-sm-2 control-label"><? echo $vis_language['TXTMOBILENUMBER']; ?></label>
							   <div class="col-sm-8">
								  <input class="form-control input-sm" type="text" name="vis_mob" id="vis_mob" value="<?= ($operation['message']!='')?$operation['vis_mob']:$client[0]['office_contact_num']; ?>">
							   </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="<?= ($operation['message']!='')?$operation['vis_contact_number']:$client[0]['office_phone']; ?>"></div>
                              </div>
                               <?php    if($custom_field_var != ''){ echo $custom_field_var;?>
							   <input type="hidden" name="vis_customfields" id="vis_customfields" value="1">
							   <?php }?>
                          </div> 
                        </div> 
                        <div class="col-lg-offset-2 col-lg-8 m-b-lg">
						    <input type="hidden" name="vis_group_id" value="<? echo $client[0]['group_id']; ?>" />
							<input type="hidden" name="vis_operation" value="update_organization_details" />
							<input type="hidden" name="vis_module" value="client" />
                            <button type="submit" class="btn btn-primary" onclick="return check_customdata();"><? echo $vis_language['TXTUPDATE']; ?></button>
                        </div>
                    </form>    
                </div> <!-- /.profile tab-pane -->
           </section>
       </div>
    </div>
</section>
<script src="<?= VIS_PATH_SCRIPT; ?>file-input/bootstrap-filestyle.min.js"></script>
<script>
function check_customdata()
   {
		var val =  $('#vis_form_register').find('input[name!=vis_operation][name!=vis_module]').serialize();
	var textareaval='';
	 var tempcustom=Array();
        var i=0;
         $('[id^="field"]' ).each(function(){
			if($(this).is(":checkbox") || $(this).is(":radio")){
				if($(this).is(":checked")){
				 if(val.indexOf('&'+this.id+'='+$(this).val())==-1)
				    textareaval=textareaval+'&'+this.id+'='+$(this).val();
				}
			}
			else {
				 if(val.indexOf('&'+this.id+'='+$(this).val())==-1)
				  textareaval=textareaval+'&'+this.id+'='+$(this).val();
			   }
            });
	
		 var returns=true;
   	 $.ajax({
             url: 'index.php',
             dataType: 'json',
             data: val+textareaval+'&vis_module=ticket&vis_operation=check_customdata&location=12&vis_department=0',
             type: "POST",
			 async:false,
             success: function(data) {
				
			if(data.res==0)
				 {
					 $("#vis_submit_err_div").show();
					 $("#vis_submit_err_div").html(data.msg); window.scrollTo(0,0);
				 setTimeout(function(){$("#vis_submit_err_div").hide();},10000);
//					  $("#vis_global_msg_div").html(data.msg);

returns=false;
				 }
				 else
				 {
					 returns=true;
				 }
				 
			             }
         });
		 return returns; 
	  
   }
</script>