<? global $vis_language; ?>
<section id="breadcrumb" class="row m-b m-l-none m-r-none">
   <div class="col-sm-6">
      <h3 class="m-b-xs text-black"><? echo $operation['view_title']; ?></h3>
      <ul class="breadcrumb bg-empty no-border m-b-xxs no-padder">
         <li><a class="link" href="#/home/quick_view/<? echo $vis_language['TXTHOME']; ?>"><? echo $vis_language['TXTHOME']; ?></a></li>
         <li><a class="link" href="#/setting/setting_menu/<? echo $vis_language['TXTSETTINGS'];?>" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTSETTINGS'];?>',{'vis_module':'setting','vis_operation':'setting_menu'});"><? echo $vis_language['TXTSETTINGS']; ?></a></li>
         <li><a  class="link" href="#/setting/view_smtp/<? echo $vis_language['TXTSMTP'];?>" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTSMTP'];?>',{'vis_module':'setting','vis_operation':'view_smtp'});" class="link"><? echo $operation['view_title']; ?></a> </li>
         <li class="active"><? echo $vis_language['TXTUPDATESMTP'];?></li>
      </ul>
   </div>
</section>
<section class="padder">
   <section class="panel panel-default">
      <header class="panel-heading sub_header"><? echo $vis_language['TXTUPDATESMTP']; ?></header>
      <div class="panel-body">
         <form id="vis_smtp_form" name="vis_smtp_form" method="post" class="form-horizontal">
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTHOSTNAME']; ?></label>
               <div class="col-sm-10">
                  <input class="form-control input-sm" type="text"  name="vis_host" id="vis_host" value="<? echo $smtp_details['smtp_host']; ?>">
               </div>
            </div>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTPORT']; ?></label>
               <div class="col-sm-10">
                  <input class="form-control input-sm" type="text" name="vis_port" id="vis_port" value="<? echo $smtp_details['smtp_port']; ?>">
               </div>
            </div>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTUSERNAME']; ?></label>
               <div class="col-sm-10">
                  <input class="form-control input-sm" type="text" name="vis_username" id="vis_username" value="<? echo $smtp_details['smtp_user']; ?>">
               </div>
            </div>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTPASSWORD']; ?></label>
               <div class="col-sm-10">
                  <input class="form-control input-sm" type="password" name="vis_password" id="vis_password" value="<? echo password_decrypt($smtp_details['smtp_password'],VIS_PASSWORD_KEY); ?>" >
               </div>
            </div>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTSSL']; ?></label>
               <div class="col-sm-10">
                  <div class="radio i-checks m-r-lg pull-left p-d-sm"><label>
                  <input type="radio" name="vis_ssl" id="vis_ssl1" value="0" <? if($smtp_details['smtp_ssl']==0) echo ' checked="checked"'; ?>/><i></i>
                  <? echo $vis_language['TXTNONE']; ?></label> </div>
                  <div class="radio i-checks m-r-lg pull-left p-d-sm"><label>
                  <input type="radio" name="vis_ssl" id="vis_ssl2" value="1" <? if($smtp_details['smtp_ssl']==1) echo ' checked="checked"'; ?>/><i></i>
                  SSL
                  </label> </div>
                  <div class="radio i-checks m-r-lg pull-left p-d-sm"><label>
                  <input type="radio" name="vis_ssl" id="vis_ssl3" value="2" <? if($smtp_details['smtp_ssl']==2) echo ' checked="checked"'; ?>/><i></i>
                  TLS
                  </label> </div>
               </div>
            </div>
            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTSMTPAUTHENTICATION']; ?></label>
               <div class="col-sm-10">
                  <label class="checkbox i-checks m-r-lg pull-left p-d-sm">
                  <input type="checkbox" name="vis_smtp_auth"<? if($smtp_details['authentication']==1) echo ' checked="checked"'; ?> id="vis_smtp_auth" value="1"/><i></i></label>
               </div>
            </div>

             <div id="department_access" >
                <label class="col-sm-12"><div class="line line-lg pull-in"></div></label>
               <div class="form-group">
                  <label class="col-sm-2 control-label"><? echo $vis_language['TXTDEPARTMENTACCESS']; ?></label>
                  <div class="col-sm-10">
                     <label class="checkbox-inline i-checks">
                     <input type="checkbox" id="vis_smtp_all_dept" name="vis_smtp_all_dept" onchange="toggle_dept_list();" <? if($smtp_details['department_id']==0) echo ' checked="checked"'; ?>><i></i> <? echo $vis_language['TXTALLDEPARTMENTS']; ?>
                     </label>
                  </div>
               </div>
              <div id="vis_dept_list_section" class="form-group" style="<?= ($smtp_details['department_id']==0)?'display:none':'';?>">
                  <label class="col-sm-2 control-label"></label>
                  <div class="col-sm-10">
                      <div class="dept_access_list">
                     <? $dept_list=array(); $smpt_department=explode(',',$smtp_details['department_id']);
                        for($i=0;$i<count($department_details);$i++) { ?>
                     <label class="checkbox-inline i-checks">
                     <input type="checkbox"  value="<? echo $department_details[$i]['department_id']; ?>" <? if(in_array($department_details[$i]['department_id'], $smpt_department)) echo ' checked="checked"'; ?> id="vis_department" name="vis_department[]" /> <i></i><? echo $department_details[$i]['domain_name'].' :: '.$department_details[$i]['department_name']; ?></label><br/>
                     <?
                        $dept_list[]=$department_details[$i]['department_id'];
                        } ?>
                      </div>
                   </div>
               </div>
                <input type="hidden" name="vis_department_count" id="vis_department_count" value="<? echo count($department_details); ?>" />
                <input type="hidden" name="vis_smtp_id" id="vis_smtp_id" value="<? echo $smtp_details['smtp_id']; ?>" />
          </div>

            <div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTSTATUS']; ?></label>
               <div class="col-sm-1">
                  <label class="switch  <? if($smtp_details['is_enabled']==0) echo 'radio-no-uncheck'; ?>  ">
                  <input type="checkbox"  name="vis_status"  id="vis_status" <? if($smtp_details['is_enabled']==1) echo ' checked="checked"'; ?>   >
                  <span ></span>
                  </label>
               </div>
            </div>
            <div class="line b-b line-lg pull-in"></div>
            <br/>
            <div class="form-group">
               <div class="col-sm-4 col-sm-offset-2">
                  <button type="button" class="btn btn-primary" onclick="$('#vis_workpanel_div').visExecution('submit_form',{'vis_module':'setting', 'vis_operation':'update_smtp', 'vis_form':'vis_smtp_form'})"><? echo $vis_language['TXTUPDATE']; ?></button>
               </div>
            </div>
      </div>
      </form>
      </div>
   </section>
</section>
<script>
   $(".selectpicker").selectpicker();
  function toggle_dept_list(){
       if($('#vis_smtp_all_dept').is(":checked")) $('#vis_dept_list_section').hide();
       else $('#vis_dept_list_section').show();
   }
</script>
