<? global $vis_language; if(VIS_ITIL==1){
 if($service_details['item_image']=='')
	$image_name = 'item_default.png';
 else
	$image_name = $service_details['item_image']; 	
 ?>
	<section  class="container m-t-md">
   <div class="row">
      <div class="col-md-12">
         <section class="panel shadow-none">
 
        <div class="panel-body" id="service_item">
	<div class="wrapper">
		<div class="row">
		  <div class="col-md-12">
            <article class="media">
               
				<div class="pull-left">
				  <a href="#"><img class="thumb-lg" src="<?= VIS_PATH_PROFILE.$image_name.'';?>" title="Item Image"></a>
				</div>
				<div class="media-body">
				  <h3><?= ucfirst($service_details['name']);?></h3>
                  <? if($service_details['cost_status']==1){?>     
				  <strong class="h4 clearfix font-bold"><?= $service_details['cost'].' '.$domain[0]['currency'];?></strong>
                  <? }?> 
				  <!--<span class="block m-t-xs"></span>-->
				 <!-- <em class="text-primary"><a href="#ViewMore">view more</a></em>-->
				</div>
			  </article>
		  </div> <!-- /col-md-12 -->
		 </div> <!-- /row -->
         <br />
         <div class="row">
		  <div class="col-md-12">
         	  <article class="media">
				  <span class="block m-t-xs"><?= $service_details['description'];?></span>
				 <!-- <em class="text-primary"><a href="#ViewMore">view more</a></em>-->
			  </article>
		  </div> <!-- /col-md-12 -->
		 </div>
        <div class="b-t b-b b-1x line-lg"></div>
		<div class="row">
		  <div class="col-md-4">
			<div class="form-group">
                <label><?= $vis_language['TXTITILREQUESTFOR']?></label>
                <input class="form-control" type="text" disabled="disabled" placeholder="Email" name="vis_email" value="<?= VIS_CLIENT_EMAIL?>">
            </div>
		  </div> <!-- /col-md-12 -->
		</div>
      
        <? if($service_details['estimate_status']==1){?> 
        <div class="row">    
        <div class="col-md-4">
          <label class="control-label"><? echo $vis_language['TXTESTIMATEDDELIVERY']; ?></label> :
            <label class="control-label"><? echo $service_details['estimated_delivery']; ?></label>	
			<label class="control-label"><? echo ($service_details['estimated_delivery']>1)?$vis_language['TXTDAYS']:$vis_language['TXTDAY'];  ?></label>, 
            <label class="control-label"><? echo $service_details['estimated_delivery_hrs']; ?></label>
			<label class="control-label"><? echo ($service_details['estimated_delivery_hrs']>1)?$vis_language['TXTHOURS']:$vis_language['TXTHOUR']; ?></label>
          </div>
        </div>
        <? }?>
		<div class="row">
		  <div class="col-md-12">
           <div role="form" class="form-inline" id="form_ticket" name="form_ticket">
         	<h3><?= $vis_language['TXTITILITEMREQUEST'];?></h3>
             	<div class="form-group h5">
					<?= ucfirst($service_details['name']);?>
				</div>
              <? if($service_details['quantity_status']==1){?>  
				<div class="form-group"><big class="m-l-sm m-r-sm">&times;</big></div>
				<div class="form-group">
					<input name="vis_service_quantity" id="vis_service_quantity" class="input-sm input-s form-control m-r" onkeyup="change_quantity(this.value);" size="4" min="0" maxlength="4" value="1" type="text" />
				</div>
              <? }else{?> 
              <input type="hidden" name="vis_service_quantity" id="vis_service_quantity" value="1" />
              <? }
			     if($service_details['cost_status']==1){?>     
				<div class="form-group m-l m-r font-bold badge">
					 <?= $service_details['cost'].' '.$domain[0]['currency'];?>
				</div>
                </div>
              	<div class="b-t b-b b-2x line-lg">
					<div class="padder-v">
						<span class="h4"><?= $vis_language['TXTTOTAL']?></span>
						<span class="pull-right m-r-lg h3 font-bold"> <span id="total_cost"><?= $service_details['cost'];?></span><?= ' '.$domain[0]['currency'];?></span>					
					</div>
				</div>
              <? }?>
             <input type="hidden" name="vis_cost" id="vis_cost" value="<?= $service_details['cost'];?>" />
             <input type="hidden" name="vis_subject" id="vis_subject" value="<?=$vis_language['TXTITILSERVICEREQUESTFOR'];?> <?= $service_details['name'];?>" />
          </div> <!-- /col-md-12 -->
		</div> <!-- /row -->
        <form role="form" method="post" id="vis_custom_field_form" name="vis_custom_field_form">
        <div class="row">
         <div class="form-horizontal">
            <div class="col-md-12">
              <div class="wrapper">
              <div id="vis_custom_field_form">
              
            	<?php echo $custom_field_var; ?>
              
              </div>
              </div>
            </div>
              
          <div class="col-lg-offset-2 col-lg-8 m-b-lg">
          	<button type="button" class="btn btn-primary" onclick="submit_form();"><?= $vis_language['TXTITILPLACEREQUEST'];?></button>
          </div>
         </div>
	</div> <!-- /wrapper -->
    </form>
  </div> <!-- /panel-body -->
</section>
</div>
</div>
 </section>
<input type="hidden" name="vis_domain" id="vis_service_domain" value=""/>
<input type="hidden" name="vis_department" id="vis_service_department" value=""/>  
<script type="application/javascript">
$("#vis_service_quantity").keyup(function(){
	return Nochange1(this.value,this.id);
});
function Nochange1(val,id)
{
	document.getElementById(id).value='';
	//var numberPattern = /\d+/g;
	var numberPattern =/^[0-9\.]+$/;
	var test=val.match(numberPattern);
	//alert(test);
	var no='';
	var lt=0;
	if(test.length!='')
	{
		lt=test.length;
		for(i=0;i<lt;i++)
		{
			no += test[i];
		}
	}
	//alert(no);
	document.getElementById(id).value=no;
}
//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]);
}*/
 var curr_stamp=0;
function change_quantity(quantity){
	var cost = $('#vis_cost').val();
	var total_cost = quantity*cost;
	//$('#vis_cost').val(total_cost);
	$('#total_cost').html(total_cost);
}
function submit_form() {
	if(check_customdata())
	{
if(curr_stamp==0 || (curr_stamp < (Date.now()-10000))){
    curr_stamp = Date.now();
    var vis_subject = $("#vis_subject").val(); 
    var vis_cost = $("#vis_cost").val(); 
    var vis_quantity = $("#vis_service_quantity").val();
    
	var datastring = $(document.forms[2]).serialize();
	      $.ajax({
            url: 'index.php',
            dataType: 'json',
            data: {'vis_module':"ticket", 'vis_operation':"open_new_ticket",'vis_from_email':"<? echo $client_detail['email']; ?>",'vis_from_name':"<? echo $client_detail['first_name'].' '.$client_detail['last_name']; ?>", 'vis_department':"<? echo $service_details['item_department_id'];?>",'vis_client':"<?= VIS_CLIENT_ID; ?>", 'vis_priority':"1" ,'vis_type':"1", 'vis_subject':''+vis_subject+'', 'vis_ticket_post':"<?= str_replace( array( "\n", "\r" ), array( "\\n", "\\r" ),$service_details['description']);?>",'vis_domain':"<? echo $service_details['domain_id']; ?>",'vis_service_item_id':"<? echo $service_details['item_id']; ?>", 'vis_status':'1', 'vis_channel':'7', 'vis_service_cost':''+vis_cost+'', 'vis_service_quantity':''+vis_quantity+'','vis_service_request_data':''+datastring+''},
            type: "POST",
            success: function(requestdata) {
                
                if(requestdata.vis_submitted=='true')
                    window.location = "index.php?/ticket/view_ticket/"+requestdata.vis_msg;	
                else if(requestdata.vis_submitted=='false') { window.location = "index.php?/ticket/submit-ticket/"+requestdata.vis_msg; }
                else if(requestdata.vis_error_msg!='') { $("#vis_submit_msg_div").show(); $("#vis_submit_msg_div").removeClass('alert-success').addClass('alert-danger'); $("#vis_submit_msg_div").html(requestdata.vis_error_msg); window.scrollTo(0,0);}		 
            }
        });
    }
	}
}
 function check_customdata()
   {
		var val =  $('#vis_custom_field_form').find('input[name!=vis_operation]').serialize();
        var vis_service_item_id="<? echo $service_details['item_id']; ?>";
		var textareaval='';
         $('[id^="field"]' ).each(function(){
		if($(this).is("textarea")){
				 textareaval=textareaval+'&'+this.id+'='+$(this).val();
			}
            });
	
		 var returns=true;
   	 $.ajax({
             url: 'index.php',
             dataType: 'json',
             data: val+textareaval+'&vis_module=ticket&vis_operation=check_customdata&location=-1&vis_service_item_id=<? echo $service_details['item_id']; ?>&vis_department=<? echo $service_details['item_department_id'];?>&vis_domain=<? echo $service_details['domain_id']; ?>',
             type: "POST",
			 async:false,
             success: function(data) {
			if(data.res==0)
				 {
					 $("#vis_submit_err_div").show();
					 $("#vis_submit_err_div").html(data.msg); window.scrollTo(0,0);
				 setTimeout(function(){$("#vis_submit_err_div").hide();},10000);
//					  $("#vis_global_msg_div").html(data.msg);

returns=false;
				 }
				 else
				 {
					 returns=true;
				 }
				 
			             }
         });
		 return returns; 
	  
   }
</script>
<? }?>
