<? 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['TXTSPLITTICKETPOST']; ?></h4>
		</div>
		<div class="modal-body">
			<div class="row">				
				<div class="col-sm-12">
					<form class="form-horizontal" role="form" name="vis_split_ticket_post_form" id="vis_split_ticket_post_form" method="post">
						<div class="form-group">
						   <label class="col-sm-2 control-label txt_left"><? echo $vis_language['TXTSPLITINTO']; ?></label>
						   <div class="col-sm-10">
							   <label class="radio-inline i-checks">
                                    <input type="radio" name="vis_split_ticket_post" id="vis_new_post" value="1" checked="checked" onclick="$('#get_ticket_hash').hide();$('#get_subject').show();"><i></i> <? echo $vis_language['TXTNEWTICKET']; ?>
                               </label>
								<label class="radio-inline i-checks">
                                    <input type="radio" name="vis_split_ticket_post" id="vis_existing_post" value="2" onclick="$('#get_ticket_hash').show();$('#get_subject').hide();"><i></i> <? echo $vis_language['TXTEXISTINGTICKET']; ?>
                                </label>									
						   </div>
						</div>
      <div id="get_subject">
                        <div class="form-group" style="" >
						   <label class="col-sm-2 control-label txt_left"></label>
						   <div class="col-sm-10">
                               <input name="vis_subject" id="vis_subject" class="form-control input-sm" placeholder="<?= $vis_language['TXTENTERTICKETSUBJECT']?>" />
						   </div>
         </div>
         <div class="form-group">
          <label class="col-sm-2 control-label txt_left"></label>
						   <div class="col-sm-10">
         <input class="form-control input-sm" type="text" name="vis_new_ticket_list_client" id="vis_new_ticket_list_client"  value="<? echo $operation['vis_email_id']; ?>" placeholder="<?= $vis_language['TXTTYPETOSEARCHEXISTINGCLIENTSEMAILADDRESS']?>" data-resize="no" style="width:100%" />
                                <script type="text/javascript">
                                    $(document).ready(function() {
                                        $("#vis_new_ticket_list_client").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: "contactDetails",
                                                tokenValue: "contactDetails",
                                                tokenLimit: 1,
                                                preventDuplicates: true,
                                                resultsFormatter: function(item) {
													//var contact= ( item.contact_number!='' && item.email!='')? item.email+' - '+item.contact_number : ((item.contact_number!='' && item.email=='')? item.contact_number:item.email );
													var contact=item.contactDetails ;
                                                    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.contactDetails ;
													//var contact= ( '<? echo $vis_channel_id;?>'==2)? item.contact_number :  item.email ;
												    return "<li><p>" + contact + "</p></li>";
                                                }
                                            }
                                        );
									    $("div.token-input-dropdown-facebook").css('width', $(".token-input-list-facebook").width() + 2 + 'px');
                                                
                                        $("#vis_new_ticket_list_client").tokenInput("add", {id: "<?= $operation['vis_client_id']; ?>", contactDetails: "<?= $operation['vis_email_id']; ?>"});
                                        $("#token-input-vis_new_ticket_list_client").parent().css('width','100%');
                                    });
                                </script>
                                </div>
         </div>
						</div>
      
                        <div class="form-group" style="display:none" id="get_ticket_hash">
						   <label class="col-sm-2 control-label txt_left"></label>
						   <div class="col-sm-10">
							  <input name="vis_ticket_hash" id="vis_ticket_hash" class="form-control input-sm"  placeholder="<?= $vis_language['TXTENTERTICKETHASH']?>"/>
						   </div>
						</div>						
					</form>
				</div>
			</div>
		</div>
		<div class="modal-footer m-n">
			<a class="btn btn-default" data-dismiss="modal"><? echo $vis_language['TXTCANCEL']; ?></a>			
			<a class="btn btn-primary" onclick="$(this).visExecution('submit_form',{'vis_module':'ticket', 'vis_operation':'split_ticket_post', 'vis_form':'vis_split_ticket_post_form', 'vis_post_id':<?= $operation['vis_post_id'];?>, 'vis_ticket_id':<?= $operation['vis_ticket_id'];?>, 'domain_id':<?= $operation['domain_id'];?>, 'vis_channel':<?= $operation['vis_channel'];?>});"><? echo $vis_language['TXTSUBMIT']; ?></a>
		</div>
	</div>
</div>
