<? 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['TXTITILREQUESTSERVICE']; ?></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 class="active"><? echo $vis_language['TXTITILREQUESTSERVICE']; ?></li>
        </ul>
    </div>
</section>
<section class="padder">
    <section class="panel panel-default">
        <header class="panel-heading sub_header"><? echo $vis_language['TXTITILREQUESTSERVICE']; ?></header>
        <div class="panel-body">
       <!-- <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title"><? echo$vis_language['TXTITILREQUESTSERVICE']; ?></h4>
        </div>-->
        <div id="parent_list">
                <div class="col-sm-12">
                <section id="test" class="scrollable wrapper">
                <form method="post" role="form" class="form-horizontal" name="vis_service_form" id="vis_service_form">
                <div class="col-sm-12">
                <div class="form-group">
				    <label class="col-sm-2 control-label"><?= $vis_language['TXTDEPARTMENT']; ?></label>
                    <div class='col-sm-10' id="vis_department_list">
                            <select class='form-control input-sm selectpicker' onchange="set_domain_department();" name="vis_domain_department" id="vis_domain_department" <? if(count($domain_details) > 10) echo 'data-live-search="true"' ?>>
                                <!--<option value="0">-- <? //echo $vis_language['TXTSELECTDEPARTMENT']; ?> --</option>-->
                                <? for($i=0;$i<count($department_details);$i++){
                                     echo '<option value="'.$department_details[$i]['department_id'].','.$department_details[$i]['domain_id'].'">'.$department_details[$i]['domain_name'].' :: '.$department_details[$i]['department_name'].'</option>';
                                }?>
                            </select>	
                    </div>
                </div>
                <div class="form-group">
                   <label class="col-sm-2 control-label"><?= $vis_language['TXTTO']; ?></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"  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: "email",
                                                tokenValue: "email",
                                                tokenLimit: 1,
                                                preventDuplicates: true,
                                                resultsFormatter: function(item) {
												    return "<li>" + "<div style='display: inline-block; padding-left: 10px;'><div class='full_name'>" + item.full_name + " < " + item.email + " ></div></div></li>";
                                                },
                                                tokenFormatter: function(item) {
													$('#vis_service_email').val(item.email);
													$('#vis_service_client').val(item.id);
                                                    return "<li><p>" + item.email + "</p></li>";
                                                }
                                            }
                                        );
                                        $("div.token-input-dropdown-facebook").css('width', $(".token-input-list-facebook").width() + 2 + 'px');
                                        $("#token-input-vis_new_ticket_list_client").parent().css('width','100%');
                                    });
                                </script>
                  </div>
                   <div class="col-sm-3"></div>
                </div> 
				<div class="form-group">
                <label class="col-sm-2 control-label"><?= $vis_language['TXTSERVICECATEGORY']; ?></label>
                   <div class="col-sm-10">
                   <select class="form-control selectpicker" data-size="auto" data-container="body" name="vis_service_category" id="vis_service_category" <? if(count($service_cat_details) > 10) echo 'data-live-search="true"' ?>>
						<option value="0">--<?=$vis_language['TXTSELSERVICECATEGORY']?>--</option>
						<?php 
						
						for($p=0;$p<count($service_cat_details);$p++){ 
							echo '<option value="'.$service_cat_details[$p]['category_id'].'">'.$service_cat_details[$p]['name'].'</option>';
						}
						?>
                      </select>
                   </div>
                   <div class="col-sm-3"></div>
                </div>
                <div id="sevice_quantity" class="form-group" style="display:none;" >
                  <label class="col-sm-2 control-label"><?=$vis_language['TXTQUANTITY']?></label>
                  <div class="col-sm-2">
                      <input class="form-control" onkeyup="show_total_cost();" name="vis_service_quantity" id="vis_service_quantity" value="1"> 
                  </div>
                  <div class="col-sm-8 pull-right">
                   <label class="col-sm-10 control-label"><?=$vis_language['TXTTOTAL']?></label>
                   <span class="h3" id="total_cost"></span>
                  </div>
                </div>
              	<input type="hidden" name="vis_channel" id="vis_channel" value="7"/>
                <input type="hidden" name="vis_service_cost" id="vis_service_cost" value=""/>
                <input type="hidden" name="vis_subject" id="vis_subject" value=""/>
                <input type="hidden" name="vis_ticket_post" id="vis_ticket_post" value=""/>
                <input type="hidden" name="vis_domain" id="vis_service_domain" value=""/>
                <input type="hidden" name="vis_department" id="vis_service_department" value=""/>
                <input type="hidden" name="vis_client" id="vis_service_client" value=""/>
                <input type="hidden" name="vis_from" id="vis_from" value="<?= $from_email[0]['override_name'];?> &lt;<?= $from_email[0]['override_email'];?>&gt;"/>
                <input type="hidden" name="vis_client" id="vis_service_client" value=""/>
                <input type="hidden" name="vis_status" id="vis_status" value="1"/>
                <input type="hidden" name="vis_type" id="vis_type" value="1"/>
                <input type="hidden" name="vis_priority" id="vis_priority" value="1"/>
                 <input type="hidden" name="vis_from_email" id="vis_from_email" value="<?= $from_email[0]['override_email'];?>"/>
                <input type="hidden" name="vis_sendmail" id="vis_sendmail" value="1"/>
                <input type="hidden" name="vis_as_client" id="vis_as_client" value="1"/>
                <input type="hidden" name="vis_send_message" id="vis_send_message" value="1"/>
                <input type="hidden" name="vis_service_email" id="vis_service_email" value="">
                <input type="hidden" name="vis_service_request_data" id="vis_service_request_data" value="">
              </div>
              <div class="m-t col-sm-12">
                  <div class="form-group">
                    <label class="col-sm-2 control-label">&nbsp;</label>
                        <div class="col-sm-10">
                            <div id="service_item"></div>                        
                        </div>
                  </div>
              </div>
              </section>             
              </div>
        </div>
        <div class="modal-footer">
        <div class="row">
        <div class="col-sm-12">  
          	<a class="btn btn-default" data-dismiss="modal"><? echo $vis_language['TXTCANCEL']; ?></a>
            <a class="btn btn-primary" onclick="get_custom_data();"><? echo $vis_language['TXTITILPLACEREQUEST']; ?></a>
        </div>
        </div>
        </div>
        </div>
    </section>
</section>
<script type="text/javascript">
set_domain_department();
function set_domain_department(){
	var domain_department = $('#vis_domain_department').val();
	var domain_department=domain_department.split(","); 
	$('#vis_service_domain').val(domain_department[1]);
	$('#vis_service_department').val(domain_department[0]);
}
    $('.selectpicker').selectpicker();
	$("#vis_service_category").change(function () {
		if(this.value=='0'){
			$("#service_item").html('<div style="text-align:center;"><?= addcslashes($vis_language['TXTITILSELECTSERVICECATEGORY']);?></div>');
		}
		if(this.value!='0'){
			var data = {'vis_category_id':this.value};   
			$.ajax({
				url: 'index.php?vis_module=setting&vis_operation=ticket_service_item_list',
				data: data,
				type: "POST",
				success: function(data) {
					$("#service_item").html(data);
				},
				error: function(xhr, ajaxOptions, thrownError) {$("#vis_global_msg_div").visInterface("load_global_message", "Error: "+xhr.status+" - "+thrownError);}
			});
		}
	});
	function show_total_cost(){
		var quantity = $('#vis_service_quantity').val();
		var cost = $('#vis_service_cost').val();
		var total_cost = quantity*cost;
		$('#total_cost').html(total_cost).show();
	}	
</script>
