<? global $vis_language;  ?>
<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title"><? echo $vis_language['TXTSENADSMS']; ?></h4>
        </div>
        <div class="modal-body">
            <div class="row">
                <div class="col-sm-12">
                    <form action="index.php" role="form" class="form-horizontal" name="vis_connect_agent_form" id="vis_connect_agent_form">
						<div class="form-group">
                            <label class="col-sm-3 control-label txt_nowrap"><? echo $vis_language['TXTDEPARTMENT']; ?></label>
                            <div class="col-sm-9">
                                <select name="vis_department" id="vis_department_new" class="form-control input-sm selectpicker"<? if(count($departments)>10) echo ' data-live-search="true"';?> onchange="get_channel_list(this.value);"><?
									if($departments!=-1) for($i=0;$i<count($departments); $i++)
									echo '<option value="'.$departments[$i]['domain_id'].':'.$departments[$i]['department_id'].'">'.$departments[$i]['domain_name'].' :: '.$departments[$i]['department_name'].'</option>' ?>
									</select>
                            </div>
                        </div>
				<?php  if($operation['vis_call_type']==4){ ?>
					  <div class="form-group">
                            <label class="col-sm-3 control-label txt_nowrap"><? echo $vis_language['TXTAPP']; ?></label>
                            <div class="col-sm-9">
                                <select name="vis_app" id="vis_app" class="form-control input-sm selectpicker"<? if(count($number_count)>10) echo ' data-live-search="true"';?> onchange="get_callerid_list(this.value);">
								<?   echo '<option value="0">'.$vis_language['TXTSELECT'].'</option>';
									if($exotel_apps!=-1) for($i=0;$i<count($exotel_apps); $i++)
									echo '<option value="'.$exotel_apps[$i]['exotel_id'].'">'.$exotel_apps[$i]['app_name'].'</option>'; ?>
									</select>
                            </div>
                        </div>
						<div class="form-group">
                            <label class="col-sm-3 control-label txt_nowrap"><? echo $vis_language['TXTCALLERID']; ?></label>
                            <div class="col-sm-9" id="caller">
                                <select name="vis_callerid" id="vis_callerid" class="form-control input-sm selectpicker"  data-live-search="true"  > <? echo '<option value="0">'.$vis_language['TXTSELECT'].'</option>'; ?>
								</select>
                            </div>
                        </div>
						<div class="form-group">
                            <label class="col-sm-3 control-label"><? echo $vis_language['TXTTO']; ?></label>
                            <div class="col-sm-9" >
							<textarea id="vis_to"   name="vis_to" class="form-control input-sm " placeholder="06308998899,06959293695,06820123475"></textarea>						  
                            </div>
                        </div> 
						<?php }else if($operation['vis_call_type']==3){ ?>
                        <div class="form-group">
                            <label class="col-sm-3 control-label"><? echo $vis_language['TXTFROM']; ?></label>
                            <div class="col-sm-9" >
                               <input id="vis_from"   name="vis_from" class="form-control input-sm " type="text" value="<?php echo $frm_no; ?>" placeholder="06908998899" onkeypress="return isNumberKey(event)" >
                            </div>
                        </div>
						<div class="form-group">
                            <label class="col-sm-3 control-label"><? echo $vis_language['TXTTO']; ?></label>
                            <div class="col-sm-9" >
                               <input id="vis_to"   name="vis_to" class="form-control input-sm " type="text" value="" placeholder="07308998899"  onkeypress="return isNumberKey(event)"   >							  
                            </div>
                        </div> 
						<?php } ?>
						<!--<script type="text/javascript">
                                    $(document).ready(function() { 
                                        $("#vis_to").tokenInput(
                                            "index.php?vis_module=client&vis_operation=list_clients&vis_domain=<? echo $operation['domain_id']; ?>",
                                            {
                                                theme: "facebook",
                                                searchDelay: 300,
                                                minChars: 3,
                                                queryParam: "vis_data",
                                                propertyToSearch: "contact_number",
                                                tokenValue: "contact_number",
                                                tokenLimit: 1,
                                                preventDuplicates: true,
                                                resultsFormatter: function(item) {
													var contact= ( item.contact_number!='')?item.contact_number : ((item.contact_number=='' && item.mobile_number!='')? item.mobile_number:item.contact_number );
													return "<li>" + "<div style='display: inline-block; padding-left: 10px;'><div class='full_name'>" + item.full_name + " < " + contact + " ></div></div></li>";
													
										        },
                                                tokenFormatter: function(item) {
													var contact= ( item.contact_number!='')? item.contact_number :  item.mobile_number ;
													
												    return "<li><p>" + contact + "</p></li>";
                                                }
                                            }
                                        );
									  /* $("div.token-input-dropdown-facebook").css('width', $(".token-input-list-facebook").width() + 2 + 'px');
                                        $("#vis_to").tokenInput("add", {id: "<?= $operation['vis_client_id']; ?>", contact_number: "<?= $operation['vis_to']; ?>"});
                                        $("#token-input-vis_to").parent().css('width','100%');*/
                                    });
                                </script> -->
								
						<div class="form-group">
                            <label class="col-sm-3 control-label"><? echo $vis_language['TXTMSGBODY']; ?></label>
                            <div class="col-sm-9" >
                               <textarea id="vis_msg_body"   name="vis_msg_body" class="form-control input-sm " ></textarea>
                            </div>
                        </div>
											
                    </form>
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <a class="btn btn-default" data-dismiss="modal"><? echo $vis_language['TXTCANCEL']; ?></a>		    
            <button type="button" class="btn btn-primary" onclick="$('#vis_workpanel_div').visExecution('submit_form',{'vis_module':'voip', 'vis_operation':'send_exo_sms','vis_call_type':'<?php echo $operation['vis_call_type']; ?>', 'vis_form':'vis_connect_agent_form' })" ><? echo $vis_language['TXTSEND']; ?></button>
		
        </div>
    </div>
</div>
<script>
    $(".selectpicker").selectpicker();
    function get_callerid_list(e){
        $('#caller').visExecution('load_area', {'vis_module':'voip', 'vis_operation':'get_caller_id','vis_exotel_id':e});
    }
	
	function get_no(){ alert('fdsafs');
			
	}
	
	function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }


</script>
