<? 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 $vis_language['TXTUPDATEDIALPLAN']; ?></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/asterisk/<? echo $vis_language['TXTASTERISK'];?>" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTASTERISK'];?>',{'vis_module':'setting','vis_operation':'asterisk'});"><? echo $vis_language['TXTASTERISK']; ?></a></li>
		<li><a class="link" href="#/setting/asterisk_dialplan/<? echo $vis_language['TXTASTDIALPLANS'].'/'.$asterisk_details['integration_id'];?>" ><? echo $vis_language['TXTASTDIALPLANS']; ?></a></li>
		<li class="active"><? echo $vis_language['TXTUPDATEDIALPLAN']; ?></li>
	 </ul>
   </div> 
</section>
<section class="padder">
   <section class="panel panel-default">
      <header class="panel-heading sub_header"><? echo $vis_language['TXTUPDATEDIALPLAN']; ?></header>
      <form class="form-horizontal" data-validate="parsley" id="vis_new_asterisk_dialplan" name="vis_new_asterisk_dialplan" method="post" >
	  <input type="hidden" name="vis_asterisk_id" value="<? echo $asterisk_details['asterisk_id']; ?>" />
         <div class="panel-body">
            <div class="col-md-12">
               <div class="wrapper">
			   <div class="form-group">
					<label class="col-sm-2 control-label"><?= $vis_language['TXTDOMAIN']; ?></label>
					<div class='col-sm-10'>
						<select class='form-control input-sm selectpicker' name="vis_domain_id" id="vis_domain_id"  <? if(count($department) > 10) echo 'data-live-search="true"' ?>>
							<option value="0">-- <? echo $vis_language['TXTSELECTDOMAIN']; ?> --</option>
							<? for($i=0;$i<count($department);$i++){
								$sel = ($asterisk_details['domain_id']==$department[$i]['domain_id'])?"selected='selected'":"";
								echo '<option value="'.$department[$i]['domain_id'].'" '.$sel.' >'.$department[$i]['domain_name'].'</option>';
							}  ?>
						</select>
					</div>
				  </div>
				    <div class="form-group">
					<label class="col-sm-2 control-label p-d-sm"><? echo $vis_language['TXTTITLE']; ?></label>
                    <div class="col-sm-10">
                        <input class="form-control input-sm" type="text" name="vis_title" id="vis_title" value="<?=$asterisk_details['dialplan_name']?>">
                     </div>
				  </div>
				   <div class="form-group">
					<label class="col-sm-2 control-label p-d-sm"><? echo $vis_language['TXTCHANNEL']; ?></label>
                    <div class="col-sm-10">
                        <input class="form-control input-sm" type="text" name="vis_channel" id="vis_channel" value="<?=$asterisk_details['channel']?>">
                     </div>
				  </div>
				  <div class="form-group">
					<label class="col-sm-2 control-label p-d-sm"><? echo $vis_language['TXTCONTEXT']; ?></label>
                    <div class="col-sm-10">
                        <input class="form-control input-sm" type="text" name="vis_context" id="vis_context" value="<?=$asterisk_details['context']?>">
                     </div>
				  </div>
				  <div class="form-group">
					<label class="col-sm-2 control-label p-d-sm"><? echo $vis_language['TXTCALLERID']; ?></label>
                    <div class="col-sm-10">
                        <input class="form-control input-sm" type="text" name="vis_callerid" id="vis_callerid" value="<?=$asterisk_details['callerId']?>">
                     </div>
				  </div>
				  <div class="form-group">
					<label class="col-sm-2 control-label p-d-sm"><? echo $vis_language['TXTEXTEN']; ?></label>
                    <div class="col-sm-10">
                        <input class="form-control input-sm" type="text" name="vis_exten" id="vis_exten" value="<?=$asterisk_details['exten']?>">
                     </div>
				  </div>
				  <div class="form-group">
					<label class="col-sm-2 control-label p-d-sm"><? echo $vis_language['TXTASYNC']; ?></label>
                    <div class="col-sm-10">
                        <input class="form-control input-sm" type="text" name="vis_async" id="vis_async" value="<?=$asterisk_details['async']?>">
                     </div>
				  </div>
				  <div class="form-group">
					<label class="col-sm-2 control-label p-d-sm"><? echo $vis_language['TXTPRIORITY']; ?></label>
                    <div class="col-sm-10">
                        <input class="form-control input-sm" type="text" name="vis_priority" id="vis_priority" value="<?=$asterisk_details['priority'];?>">
                     </div>
				  </div>
				   <div class="form-group">
					<label class="col-sm-2 control-label p-d-sm"><? echo $vis_language['TXTSTATUS']; ?></label>
                    <div class="col-sm-10">
                        <label class="switch ">
						<input id="vis_status" name="vis_status" <?php echo ($asterisk_details['status']==1)? 'checked="checked"':''; ?> type="checkbox">
						<span></span>
						</label>

                     </div>
				  </div>
				  <?php /* ?><div class="form-group">
                    <label class="col-sm-2 control-label p-d-sm"><? echo $vis_language['TXTAPPID']; ?></label>
                    <div class="col-sm-10">
                       <input class="form-control input-sm" type="text"  name="asterisk_id" id="asterisk_id" value="<?=$asterisk_details['app_id']; ?>"  >
                    </div>
				  </div>
				  <div class="form-group">
                    <label class="col-sm-2 control-label p-d-sm"><? echo $vis_language['TXTDEPARTMENT']; ?></label>
                    <div class="col-sm-10">
                       <select name="vis_department" id="vis_department_new" class="form-control input-sm selectpicker"<? if(count($departments)>10) echo ' data-live-search="true"';?> ><?
									if($departments!=-1) {
										for($i=0;$i<count($departments); $i++){
											if(trim($departments[$i]['domain_id'].':'.$departments[$i]['department_id'])===$asterisk_details['department']){ $selected = ' selected="selected" '; }else{ $selected =''; }
											echo '<option value="'.$departments[$i]['domain_id'].':'.$departments[$i]['department_id'].'" '.$selected.' >'.$departments[$i]['domain_name'].' :: '.$departments[$i]['department_name'].'</option>';
										}
								} ?>
									</select>
                  </div>
				  </div>	
				  <div class="form-group">
                    <label class="col-sm-2 control-label p-d-sm"><? echo $vis_language['TXTEXOPHONE']; ?></label>
                    <div class="col-sm-8">
					    <input id="vis_exo_phone1"   name="vis_exo_phone[]" class="form-control input-sm " type="text" value="<?php echo trim($exophones[0]); ?>" placeholder="04439592073" onkeypress="return isNumberKey(event)" >
						<span id="exo1">
						  <?php 
						    $html = '';
						    for($i=1;$i<count($exophones);$i++){
							 $html .= '<br><input id="vis_exo_phone'.($i+1).'"   name="vis_exo_phone[]" class="form-control input-sm " type="text" value="'.$exophones[$i].'" placeholder="04439592073" onkeypress="return isNumberKey(event)" ><span id="exo'.($i+1).'">';
						  }
						  for($i=1;$i<count($exophones);$i++){
							$html .= '</span>';
						  }
						  echo $html;
						  ?>
						</span>
                    </div>
					<div class="col-sm-2">
						  <label>
						  <button type="button" class="btn btn-primary btn-xs"  onclick="javascript:vis_add_new()"><? echo $vis_language['TXTADDNEW']; ?></button>
						  </label>
								  
					   </div>
				  </div>
				  <div class="form-group">
					<label class="col-sm-2 control-label" ><? echo $vis_language['TXTAUTOTICKETECREATION']; ?></label>
					<div class="col-sm-10">
						<label class="switch"  value="1"<? if($asterisk_details['auto_ticket']!=1) echo 'radio-no-uncheck'; ?>  >
						<input type="checkbox"  name="vis_auto_tickete"  id="vis_auto_tickete" value="1" <? if($asterisk_details['auto_ticket']==1 || !isset($asterisk_details['auto_ticket'])) echo ' checked="checked"'; ?> > 
						<span></span>
						</label>
					</div>
				  </div>
				  <?php
				  <input type="hidden" id="exo_cnt" value="<?php echo intval(count($exophones)); ?>" > */ ?>
				    <input type="hidden" id="vis_integration_id" name="vis_integration_id" value="<?php echo $asterisk_details['integration_id']; ?>" >
				  
               </div>
            </div>
            </div>
      </form>
        <div class="padder">
		    <div class="line b-b line-lg pull-in"></div><br/>
         <div class="col-sm col-sm-offset-2">
            <button type="button" class="btn btn-primary" onclick="$('#vis_workpanel_div').visExecution('submit_form',{'vis_module':'setting', 'vis_operation':'update_asterisk_dialplan', 'vis_form':'vis_new_asterisk_dialplan' })"><? echo $vis_language['TXTUPDATE']; ?></button>
         </div><br/>
      </div>
   </section>
</section>
<script type="text/javascript">
    $(".selectpicker").selectpicker();	
    function vis_add_new(){ 
		var exo_main = $("#exo_cnt").val();
		exo_cnt= Math.round(exo_main)+1;
		$("#exo"+exo_main).html('<br><input id="vis_exo_phone'+exo_cnt+'"   name="vis_exo_phone[]" class="form-control input-sm " type="text" value="" placeholder="04439592073" onkeypress="return isNumberKey(event)"  ><span id="exo'+exo_cnt+'"></span>');		
								
		$("#exo_cnt").val(exo_cnt);
	}
	function vis_remove_exophone(){ 
		var exo_main = $("#exo_cnt").val();
		exo_cnt= Math.round(exo_main)+1;
	}	
	 function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }


</script>
