<?php  
/********** DYNAMIC TICKET PROPERTIES *****************/
$tp=0;
if(count($departments)>0) $tp++;
if($statuses)$tp++;
if(isset($module_setting['vis_priority']))$tp++;
if(isset($module_setting['vis_assets_location']))$tp++;
if(isset($module_setting['vis_tickettype']))$tp++;
if(isset($module_setting['vis_level']))$tp++;
if(isset($module_setting['vis_category']))$tp++;
if(isset($module_setting['vis_subcategory']))$tp++;
if(isset($module_setting['vis_item']))$tp++;
//if($itil_enabled==1)$tp++;
if($tp==2){$class_properties="col-sm-6";}
if($tp==3 || $tp==5 || $tp==6 || $tp==9){$class_properties="col-sm-4";}
if($tp==4 || $tp==7 || $tp==8){$class_properties="col-sm-3";}
$enddiv=0;
?>
<section class="panel panel-default">
	<header class="panel-heading sub_header"><? echo $vis_language['TXTFORWARD']; ?></header>
	<div class="panel-body">
		<form class="form-horizontal text-dark" method="post" enctype="multipart/form-data" target="vis_hidden_frame" name="vis_ticket_forward_form" id="vis_ticket_forward_form_<? echo $ticket_details['ticket_id']; ?>">
			<div class="form-group">
				<label class="col-sm-2 control-label txt_left"><? echo $vis_language['TXTTO']; ?></label>
				<div class="col-sm-8">					
					<input class="form-control input-sm" type="text" name="vis_to_email" autocomplete="off" id="vis_to_email_<?= $ticket_details['ticket_id']; ?>" data-module="forward_vis_to_email"/>
					<script type="text/javascript">
					$(document).ready(function() {
						$("#vis_to_email_<?= $ticket_details['ticket_id']; ?>").tokenInput(
							"index.php?vis_module=client&vis_operation=list_clients&vis_domain=<?= $ticket_details['domain_id']; ?>",
							{
								theme: "facebook",
								searchDelay: 300,
								minChars: 3,
								queryParam: "vis_data",
								propertyToSearch: "email",
								tokenValue: "email",
								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) { return "<li><p>" + item.email + "</p></li>" }
							}
						);
						$("div.token-input-dropdown-facebook").css('width',$(".token-input-list-facebook").width()+2+'px');
					});
					</script>
				</div>
				 <div class="col-sm-2">				
					<button type="button" class="btn btn-primary btn-sm" onclick="$('#vis_ticket_cc').toggle();$('#vis_ticket_bcc').toggle();"><?= $vis_language['TXTCC']; ?></button>
				</div>				
			</div>
			<div class="form-group" id="vis_ticket_cc" style="display:none">
				<label class="col-sm-2 control-label txt_left"><? echo $vis_language['TXTCC']; ?></label>
				<div class="col-sm-8">
					<input class="form-control input-sm" type="text" name="vis_people" id="vis_people" data-module="forward_vis_people">
					<script type="text/javascript">
					$(document).ready(function() {
						$("#vis_people").tokenInput(
							"index.php?vis_module=client&vis_operation=list_clients&vis_domain=<?= $ticket_details['domain_id']; ?>",{
								theme: "facebook",
								searchDelay: 300,
								minChars: 3,
								queryParam: "vis_data",
								propertyToSearch: "email",
								tokenValue: "email",
								resultsFormatter: function(item){ return "<li>" + "<div style='display: inline-block;' class='m-xs'><div class='full_name'>" + item.full_name + " < " + item.email + " ></div></div></li>" },
								tokenFormatter: function(item) { return "<li><p>" + item.email + "</p></li>" }
							}
						);
						$("div.token-input-dropdown-facebook").css('width',$(".token-input-list-facebook").width()+2+'px');
					});
					</script>			
				</div>
			</div>

                         <div class="form-group" id="vis_ticket_bcc" style="display:none">
				<label class="col-sm-2 control-label txt_left"><? echo $vis_language['TXTBCC']; ?></label>
				<div class="col-sm-8">
					<input class="form-control input-sm" type="text" name="vis_bcc" id="vis_bcc" data-module="new_ticket_vis_people">
                              <script type="text/javascript">
                                $(document).ready(function() {
                                    $("#vis_bcc").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",
                                            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) {
                                                return "<li><p>" + item.email + "</p></li>";
                                            }
                                        }
                                    );
                                    $("div.token-input-dropdown-facebook").css('width', $(".token-input-list-facebook").width() + 2 + 'px');
                                });
                            </script>			
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-2 control-label txt_left"><? echo $vis_language['TXTFROM']; ?></label>
				<div class="col-sm-8">
					<select name="vis_from" class="form-control input-sm selectpicker">
					<? for($i=0;$i<count($from_email);$i++){
						if($i==0){
							if($from_email[0]['override_name']==''){
								$from_email[0]['override_name'] = $from_email[count($from_email)-1]['override_name'];
							}
						}
						echo '<option value="'.$from_email[$i]['override_name'].' &lt;'.$from_email[$i]['override_email'].'&gt;">'.$from_email[$i]['override_name'].' &lt;'.$from_email[$i]['override_email'].'&gt;</option>'; }?>
					</select>
				</div>
				<? if (VIS_MODULE_ACCESS_SELFHELP == 1 && $selfhelp==1) { ?>
					<div class="col-sm-2 control-label txt_left">						
						<a class="link" href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=ticket&amp;vis_operation=article_search&vis_domain_id=<? echo $ticket_details['domain_id']; ?>&vis_forward=1&vis_ticket_id=<? echo $ticket_details['ticket_id']; ?>&vis_signature=<?=isset($signature) && $signature!=''?1:0;?>" title="Article search"><? echo $vis_language['TXTSELFHELPSEARCH']; ?></a>
					</div>	<? } ?>
			</div>
			<div class="form-group">	
				<label class="col-sm-2 control-label txt_left"><? echo $vis_language['TXTAPPLYMACRO'];?></label>
				<div class="col-sm-4">
					<div id="get_macros_up" class="col-sm-12 p-l-none">
						<select class="form-control input-sm selectpicker" id="apply_macro" name="apply_macro"<? if (count($macro_count) > 10) echo ' data-live-search="true"'; ?>>
							<option value='0'><?= $vis_language['TXTSELECT']?></option>
							<? if($macro_count!=-1) {for($i=0; $i<count($macro_count); $i++){ ?>
								<option value="<?= $macro_count[$i]['macro_id']; ?>" data-onclick="onclick='javascript:ticket_apply_macro(<?= $macro_count[$i]['macro_id'].','.$operation['vis_department_id'].','.(isset($operation['vis_ticket_id']) ? $operation['vis_ticket_id'] : 0)?>);'"><?= $macro_count[$i]['macro_title']; ?></option>
							<? }} ?>
						</select>
					</div>
				</div>
				<div class="col-sm-4">
					<div class="col-sm-6 p-l-none txt_left ticketowner">
						<select name="vis_owner" <? if(count($staff_list)>9) echo ' data-live-search="true"';?> data-selector-label="<label class='m-n font-bold'><? echo $vis_language['TXTASSIGNEDTO']; ?></label>" class="selectpicker ticketowner">
                            <option <? if($owner_details[0]['staff_id'] == 0) echo 'selected="selected"';?> value="0" data-content="<label class='checkbox-inline i-checks'<? if($owner_details[0]['staff_id'] != 0) echo " ";?> onclick='javascript:assign_owner(0);'><input type='checkbox' class='staff_0' <? if($owner_details[0]['staff_id'] == 0) echo "checked='checked'";?>> <i></i><span class='m-l-xs font-normal'><? echo $vis_language['TXTUNASSIGNED'];?></span></label>"><? echo $vis_language['TXTUNASSIGNED'];?></option>
                            <?  $owner1 = $vis_language['TXTUNASSIGNED'];
                                $owner_cnt = (!empty($owner_details) && $owner_details != -1) ? count($owner_details) : 0;
                                foreach ($staff_list as $staff) {
                                    $selected = $checked = ""; $this_value = 1;
                                    if ($owner_details != -1 ) {
                                        foreach ($owner_details as $owner) {
                                        if ($owner1 == $vis_language['TXTUNASSIGNED']) {
                                            $owner1 = $owner['first_name'] . ' ' . $owner['last_name'];
                                        }
                                        if ($staff['staff_id'] == $owner['staff_id']) {
                                            $vis_owner_list.=$owner['staff_id'].',';
                                            $selected = ' selected="selected"';
                                            $checked = " checked='checked'";
                                            $this_value = 0;
                                            break;
                                        } else {
                                            $this_value = 1;
                                        }
                                    }
                                    }else $vis_owner_list='0';
                                ?>
                            <option value="<?= $staff['staff_id'];?>"<? echo $selected ;?> data-content="<label class='checkbox-inline i-checks' onclick='javascript:assign_owner(<?= $staff['staff_id'];?>);'><input type='checkbox'<? echo $checked;?> class='staff_<?= $staff['staff_id']; ?>'> <i></i><span class='m-l-xs font-normal'><?= $staff['first_name'].' '.$staff['last_name'];?></span></label>"><?= $staff['first_name'].' '.$staff['last_name'];?></option>
                            <? } ?>
                        </select>
					</div>
                    <label class="col-sm-6 control-label p-l-none txt_left m-l-n" id="owner_name"><? if ($owner_cnt > 1) echo $vis_language['TXTMULTIPLEOWNERS']; else  echo $owner1; ?></label>
                    <input type="hidden" name="vis_owner_list" id="vis_owner_list" value="<?= $vis_owner_list; ?>" />
					<input type="hidden" value="" name="vis_tag_list" id="vis_tag_list">
					<input type="hidden" value="" name="vis_label_list" id="vis_label_list">
					
				</div>
				<div class="form-group11" style="display:<?= ($owner_cnt > 1)?'':'none' ?>" id="multipleownerlist">
					<div class="col-sm-12"><br />                    	
						<div class="form-group clear m-b-xs m-t-xs">
							<label class="col-sm-2">Owners</label>
							<div class="col-sm-10 p-l-none" id="owners_list"></div>
						</div>
					</div>
           		</div>
			</div>
			<div class="form-group">
				<div class="col-sm-12">
					<textarea name="vis_ticket_post" id="vis_ticket_post_<? echo $ticket_details['ticket_id']; ?>" class="form-control" rows="10"><? echo $ticket_posts; ?></textarea>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-12">
					<div class="col-sm-8 p-l-none" id="vis_forward_attachments">
					<?php
					$atts='';
					if($attachments!=-1) {
						for($i=0;$i<count($attachments);$i++) {
							$atts.=$attachments[$i]['attachment_id'].','; 
							echo '<div class="btn-group wrapper-xxs"><label class="btn btn-xs alert-success">'.$attachments[$i]['file_name'].'</label><button class="btn btn-xs alert-success" type="button" data-dismiss="alert" onclick=\'$(this).parent().remove();vis_remove_attachment('.$attachments[$i]['attachment_id'] .',"vis_fattachments",'.$ticket_details['ticket_id'].');\'><i class="vh vh-cross"></i></button></div>';
						}
					 }
					?></div>					
					<div class="col-sm-4 p-r-none text-right">
						<input type="file" name="files[]" multiple="multiple" class="filestyle" data-icon="false" data-classButton="btn btn-link link" data-buttonText="<? echo $vis_language['TXTATTACHFILE']; ?>" data-input="false" onchange="$(this).visExecution('upload_file', {'vis_static_area':'#vis_forward_attachments', 'vis_form':'vis_ticket_forward_form_<? echo $ticket_details['ticket_id']; ?>', 'vis_form_attachment_area':'#vis_fattachments'});" style="display:none;">
						<input type="hidden" name="vis_location" value="<? echo VIS_DOMAIN; ?>" />
						<input type="hidden" name="vis_fattachments" id="vis_fattachments" value="<?php echo $atts; ?>" />
						<a href="javascript:void(0);" onclick="javscript:vis_add_comment(<? echo VIS_ADDCOMMENT_ACCESS;?>);" class="link text-primary m-l v-middle"><? echo $vis_language['TXTADDCOMMENT']; ?></a>							
					</div>
				</div>
			</div>
			<div class="form-group">
				<? if($departments){$enddiv++;?>					 
				<div class="<?=$class_properties;?>">
					
						<label class="col-sm-3 control-label p-l-none txt_left"><? echo $vis_language['TXTDEPARTMENT']; ?></label>
						<div class="col-sm-9">                                                  
							<select class="form-control input-sm selectpicker" name="vis_department" id="vis_department"<? if(count($departments)>10) echo ' data-live-search="true"';?>><?
								for($i=0;$i<count($departments);$i++){									
									if($i==0) echo '</optgroup>';
									echo '<option value="'.$departments[$i]['department_id'].'"'.(($departments[$i]['department_id']==$ticket_details['department_id'])?' selected="selected"':'').'>'.$departments[$i]['domain_name'].' : '.$departments[$i]['department_name'].'</option>';
								}
								echo '</optgroup>';?>
							</select>                                            
						</div>
					</div>		
										
					<? } if($statuses){$enddiv++;?>
					<div class="<?=$class_properties;?>">
						<label class="col-sm-3 control-label p-l-none txt_left"><? echo $vis_language['TXTSTATUS']; ?></label>
						<div class="col-sm-9">                                                     
							<select class="form-control input-sm selectpicker" name="vis_status" id="vis_status"<? if(count($statuses)>10) echo ' data-live-search="true"';?>><?
								for($i=0;$i<count($statuses);$i++) echo '<option value="'.$statuses[$i]['status_id'].'"'.(($statuses[$i]['status_id']==$ticket_details['status_id'])?' selected="selected"':'').'>'.$statuses[$i]['status_name'].'</option>';?>
							</select>                                                  
						</div>
					</div>
					<? } ?>
						<? if($tp==2 && $enddiv==2){$enddiv=0;echo "</div>";}
						
					if(isset($module_setting['vis_priority'])){$enddiv++;?>
					<div class="<?=$class_properties;?>">
						<label class="col-sm-3 control-label p-l-none txt_left"><? echo $vis_language['TXTPRIORITY']; ?></label>
						<div class="col-sm-9">                                                   
							<select class="form-control input-sm selectpicker" name="vis_priority" id="vis_priority"<? if(count($priorities)>10) echo ' data-live-search="true"';?>><?
								for($i=0;$i<count($priorities);$i++) echo '<option value="'.$priorities[$i]['priority_id'].'"'.(($priorities[$i]['priority_id']==$ticket_details['priority_id'])?' selected="selected"':'').'>'.$priorities[$i]['priority_name'].'</option>';?>
							</select>                                                
						</div>
					</div>
					<?php } ?>
					<? if( ($tp==3 && $enddiv==3) || ($tp==5 && $enddiv==3) || ($tp==6 && $enddiv==3) || ($tp==9 && $enddiv==3)){ if($tp!=5 && $tp!=6 && $tp!=9)$enddiv=0;echo "</div>";}?>
				   <? if(($tp==5 && $enddiv==3) || ($tp==6 && $enddiv==3)  || ($tp==9 && $enddiv==3)){echo '<div class="form-group">';}?>
				   
				  <? if(isset($module_setting['vis_tickettype'])){$enddiv++;?>
                        <div class="<?=$class_properties;?>">
                            <label class="col-sm-3 control-label p-l-none txt_left"><? echo $vis_language['TXTTYPE']; ?></label>
                            <div class="col-sm-9">
                                <select class="form-control input-sm selectpicker" name="vis_type" id="vis_type"<? if (count($ticket_types) > 10) echo ' data-live-search="true"'; ?>>
								<? for ($i = 0; $i < count($ticket_types); $i++){
   										 echo '<option value="' . $ticket_types[$i]['type_id'] . '"';
												if($ticket_types[$i]['type_id'] == $ticket_details['type_id']){ echo ' selected="selected"'; }
										 echo '>' . $ticket_types[$i]['type_name'] . '</option>'; 
										 } ?>
                                </select>
                            </div>
                        </div>
				   <? }?>
				   
				  <? if(($tp==2 && $enddiv==2) || ($tp==3 && $enddiv==3) || ($tp==4 && $enddiv==4) || ($tp==5 && $enddiv==3) || ($tp==6 && $enddiv==3) || ($tp==8 && $enddiv==4)){
					if($tp!=5 && $tp!=6 && $tp!=8)$enddiv=0;echo "</div>";}?>
					
				<? if(($tp==5 && $enddiv==3) || ($tp==6 && $enddiv==3) || ($tp==8 && $enddiv==4)){echo '<div class="form-group">';}?>
				
				<? if(isset($module_setting['vis_level'])){$enddiv++;?>
				         <div class="<?=$class_properties;?>">
                           <label class="col-sm-3 control-label p-l-none txt_left"><? echo $vis_language['TXTTICKETLEVEL']; ?></label>
                            <div class="col-sm-9">
                                <select class="form-control input-sm selectpicker" name="vis_ticket_level" id="vis_ticket_level"<? if (count($ticket_level_details) > 10) echo ' data-live-search="true"'; ?>>
									<option value="0"><? echo $vis_language['TXTSELECT']; ?></option>
								<? if($ticket_level_details!=-1)for ($i = 0; $i < count($ticket_level_details); $i++){
   										 echo '<option value="' . $ticket_level_details[$i]['level_id'] . '"';
												if($ticket_level_details[$i]['level_id'] == $ticket_details['level_id']){ echo ' selected="selected"'; }
										 echo '>' . $ticket_level_details[$i]['title'] . '</option>'; 
										 } ?>
                                </select>
                            </div>
                        </div>
				<?php }?>
                <? if(($tp==2 && $enddiv==2) || ($tp==3 && $enddiv==3) || ($tp==4 && $enddiv==4) || ($tp==5 && $enddiv==3) || ($tp==6 && $enddiv==3) || ($tp==7 && $enddiv==4) || ($tp==8 && $enddiv==4)){
					if($tp!=5 && $tp!=6 && $tp!=7 && $tp!=8)$enddiv=0;echo "</div>";}?>
				<? if(($tp==5 && $enddiv==3) || ($tp==6 && $enddiv==3) || ($tp==7 && $enddiv==4) || ($tp==8 && $enddiv==4)){echo '<div class="form-group">';}?>    
                
				<? if(isset($module_setting['vis_category'])){$enddiv++;?>
                        <div class="<?=$class_properties;?>">
                            <label class="col-sm-3 control-label p-l-none txt_left"><? echo $vis_language['TXTTICKETCATEGORY']; ?></label>
                            <div class="col-sm-9" >
                                <select class="form-control input-sm selectpicker" name="vis_category" id="vis_category" <? if (count($ticket_cat_details) > 10) echo ' data-live-search="true"'; ?> onchange="get_subcategory(this.value);">
									<option value="0"><? echo $vis_language['TXTSELECT']; ?></option>
									<? if($ticket_cat_details!=-1)for ($i = 0; $i < count($ticket_cat_details); $i++){
   											 echo '<option value="' . $ticket_cat_details[$i]['category_id'] . '"';
												if($ticket_cat_details[$i]['category_id'] == $ticket_details['category_id']){ echo ' selected="selected"'; }
											echo ' >' . $ticket_cat_details[$i]['title'] . '</option>';
											}  ?> 
                                </select>
                            </div>
                        </div>
			
				
				<? if(($tp==2 && $enddiv==2) || ($tp==3 && $enddiv==3) || ($tp==4 && $enddiv==4) || ($tp==5 && $enddiv==3) || ($tp==6 && $enddiv==3) || ($tp==7 && $enddiv==4) || ($tp==8 && $enddiv==4) || ($tp==5 && $enddiv==5)){
					if($tp!=6 && $tp!=7 && $tp!=8)$enddiv=0;echo "</div>";}?>
				<? if(($tp==5 && $enddiv==3) || ($tp==6 && $enddiv==3) || ($tp==7 && $enddiv==4) || ($tp==8 && $enddiv==4)){echo '<div class="form-group">';}?>  
                 
				<? if(isset($module_setting['vis_subcategory'])){$enddiv++;?>
					<div class="<?=$class_properties;?>">
                            <label class="col-sm-3 control-label p-l-none txt_left"><? echo $vis_language['TXTTICKETSUBCATEGORY']; ?></label>
                            <div class="col-sm-9" id="ajax_subcategory">
                                <select class="form-control input-sm selectpicker" name="vis_subcategory" id="vis_subcategory" <? if (count($priorities) > 10) echo ' data-live-search="true"'; ?>  onchange="getitem(this.value);">
									<option value="0"><? echo $vis_language['TXTSELECT']; ?></option>
									<?php if($subcategory_list){
										for($sc=0;$sc<count($subcategory_list);$sc++){ ?>
										<option value="<?php echo $subcategory_list[$sc]['subcategory_id']; ?>" <?php if($subcategory_list[$sc]['subcategory_id']==$ticket_details['subcategory_id']){ echo 'selected="selected"'; } ?> ><? echo $subcategory_list[$sc]['title'] ?></option>
									<?php } } ?>
                                </select>
                            </div>
                        </div>
			
				
				<? if(($tp==2 && $enddiv==2) || ($tp==3 && $enddiv==3) || ($tp==4 && $enddiv==4) || ($tp==5 && $enddiv==3) || ($tp==6 && $enddiv==3) || ($tp==7 && $enddiv==4) || ($tp==8 && $enddiv==4) || ($tp==5 && $enddiv==5) || ($tp==6 && $enddiv==6)){
					if($tp!=7 && $tp!=8)$enddiv=0;echo "</div>";}?>
				 
				 <? if(isset($module_setting['vis_item'])){$enddiv++;?>
                        <div class="<?=$class_properties;?>">
                            <label class="col-sm-3 control-label p-l-none txt_left"><? echo $vis_language['TXTTICKETITEM']; ?></label>
                            <div class="col-sm-9" id="ajax_item">
                                <select class="form-control input-sm selectpicker" name="vis_item" id="vis_item" <? if (count($ticket_types) > 10) echo ' data-live-search="true"'; ?>>
									<option value="0"><? echo $vis_language['TXTSELECT']; ?></option>
									<?php if($item_list){
										for($il=0;$il<count($item_list);$il++){ ?>
										<option value="<?php echo $item_list[$il]['item_id']; ?>" <?php if($item_list[$il]['item_id']==$ticket_details['item_id']){ echo 'selected="selected"'; } ?> ><? echo $item_list[$il]['title'] ?></option>
									<?php } } ?>
								</select>
                            </div>
                        </div>
				<?php }}}?>
				
				<? if(($tp==2 && $enddiv==2) || ($tp==3 && $enddiv==3) || ($tp==4 && $enddiv==4) || ($tp==5 && $enddiv==3) || ($tp==6 && $enddiv==3) || ($tp==7 && $enddiv==4) || ($tp==8 && $enddiv==4) || ($tp==7 && $enddiv==7) || ($tp==5 && $enddiv==5) || ($tp==6 && $enddiv==6)){
					if($tp!=8)$enddiv=0; echo "</div>";} ?>		
					<? if($itil_enabled==1){if(isset($module_setting['vis_assets_location'])){$enddiv++;?>
						<div class="<?=$class_properties;?>">
							<label class="col-sm-3 control-label p-l-none txt_left"><? echo $vis_language['TXTLOCATION']; ?></label>
							<div class="col-sm-9">
								<select class="form-control input-sm selectpicker" name="vis_assets_location" id="vis_assets_location">
									<option value="0"><? echo $vis_language['TXTSELECT']; ?></option>
									<?	if(isset($location_assets) && $location_assets!=NULL && $location_assets!=-1) {
									vis_show_subcategories($location_assets,$ticket_details['location_id']); ?>
									<?  } ?>
								</select>
							</div>
						</div>
					<? }}?>
                   
                <? if(($tp==2 && $enddiv==2) || ($tp==3 && $enddiv==3) || ($tp==4 && $enddiv==4) || ($tp==5 && $enddiv==3) || ($tp==6 && $enddiv==3) || ($tp==7 && $enddiv==4) || ($tp==8 && $enddiv==4) || ($tp==8 && $enddiv==8) || ($tp==7 && $enddiv==7) || ($tp==5 && $enddiv==5) || ($tp==6 && $enddiv==6) || ($tp==9 && $enddiv==9)){echo "</div>"; }?>
            
			<? if($custom_field_var != '') echo $custom_field_var; ?>
			<div class="form-group">
				<div class="col-sm-12 text-left">
					<div class="col-sm-3 p-l-none txt_left">
						<label class="checkbox-inline i-checks">
						<input name="vis_sendmail" checked="checked" id="vis_sendmail" value="1" type="checkbox"><i></i> <? echo $vis_language['TXTSENDEMAIL']; ?></label>
					</div>
					<? if($ticket_details['client_id']!=0){ ?>
					<div class="col-sm-3">
						<label class="checkbox-inline i-checks">
						<input name="vis_private" id="vis_private" value="1" type="checkbox"><i></i> <? echo $vis_language['TXTVISIBLETOCLIENT']; ?>
						</label>
					</div>
					<? } ?>				
				</div>
			</div>
			<div class="form-group" style="display:none;" id="vis_add_comment">
				<div class="col-sm-12">
					<textarea name="vis_comment" id="vis_comment" class="form-control input-sm" placeholder="<? echo $vis_language['TXTSTAFFCOMMENT'];?>" ></textarea>
				</div>
			</div>
			<div class="line b-b line-lg pull-in"></div>
			<br/>
			<div class="form-group">
				<div class="col-sm-12 text-right">	
					<button type="button" class="btn btn-default m-l" onclick="$('#vis_ticket_reply_<? echo $ticket_details['ticket_id']; ?>').html('')"><? echo $vis_language['TXTDISCARD']; ?></button>
					<button type="button" id="vis_ticket_forward_button" class="btn btn-primary m-l" onclick="$(this).visExecution('submit_form',{'vis_module':'ticket', 'vis_operation':'forward_ticket', 'vis_form':'vis_ticket_forward_form_<? echo $ticket_details['ticket_id']; ?>','vis_ticket_id':<? echo $ticket_details['ticket_id']; ?>}); $(this).attr('disabled','disabled');"><? echo $vis_language['TXTSEND']; ?></button>  
					<input type="hidden" name="vis_ticket_id" value="<? echo $ticket_details['ticket_id']; ?>" />
				    <input type="hidden" name="vis_flag_id" id="vis_flag_id" value="<? echo $ticket_details['flag_id']; ?>" />
				    <input type="hidden" name="vis_apply_macros" id="vis_apply_macros" value="0" />
				    <input type="hidden" name="vis_macro_sla_id" id="vis_macro_sla_id" value="0" />
				</div>
			</div>
		</form>
	</div>
</section>
<?php
function vis_show_subcategories($location_assets,$call=NULL) {
         
        for($i=0;$i<count($location_assets);$i++) {
									if($location_assets[$i]['location_id']==$call){ $selected='selected="selected"'; }else{$selected='';}
									 ?>
		 <? echo '<option value="'.$location_assets[$i]['location_id'].'" '.$selected.'>'.ucfirst($location_assets[$i]['name']). '</option>';?>
				 <?php 
				if(isset($location_assets[$i]['subcat']) && $location_assets[$i]['subcat']!=NULL) { 
					 
					  vis_show_subcategories($location_assets[$i]['subcat'],'sub_cat'); 
					}
		}
		
    }
	?> 
<script language="javascript">
$(".selectpicker").selectpicker();
<? if(!defined('VIS_HTML_EDITOR') || VIS_HTML_EDITOR==1) { ?>    
$(function(){
	<?php if($drive_setting==1){?>
	 $.Redactor.prototype.drive = function(){
        return { init: function (){
                var button = this.button.add('drive', 'Drive');
																this.button.addCallback(button, this.drive.showDrive);
																var icons = {'drive': '<i class="vh vh-my-drive"></i>'};
                $.each(this.button.all(), $.proxy(function(i,s){
                    var key = $(s).attr('rel');
                    if (typeof icons[key] !== 'undefined'){
                        var icon = icons[key];
                        var button = this.button.get(key);
                        this.button.setIcon(button, icon);
                    }
 
                }, this));
            },
            showDrive: function(buttonName){
    $('.re-drive').attr('data-toggle','ajaxModal');
			 $('.re-drive').attr('data-modal-arguments','vis_module=ticket&vis_operation=drive_search&vis_domain_id=<? echo $operation['domain_id']; ?>&vis_action=<? echo $ticket_details['ticket_id']; ?>&vis_tab=1');    }
        };
    };
    <?php }?>
				
	$('#vis_ticket_post_<?= $ticket_details['ticket_id']; ?>').redactor({
		toolbarFixed: false,
		buttonSource: true,
		minHeight: 180, // pixels
		maxHeight: 180,
		imageUpload: "index.php?vis_tmpst="+new Date().getTime()+"&vis_module=ticket&vis_operation=upload_file&vis_static_area=editor_image_upload",
        imageUploadParam: 'files',
        fileUpload:  "index.php?vis_tmpst="+new Date().getTime()+"&vis_module=ticket&vis_operation=upload_file&vis_static_area=editor_file_upload",  
		removeComments: true,
		cleanOnPaste: false,
		paragraphize: false,
		replaceDivs: false,
		linebreaks: false,
		linkify: false,
		plugins: ['source','drive'],
	    //linkify: false, // attribute for convert link into tag (ex.img,iframe)  
		deniedTags: ['html', 'head', 'link', 'body', 'meta', 'script','applet']
	});
});
<? } ?>
function vis_add_comment(access){
     if(access!=0){
	$('#vis_add_comment').toggle();
	if(!$('#vis_add_comment').is(':visible')) $("#vis_comment").val('');
    }
    else {
        $("#vis_global_msg_div").visInterface("load_global_message", "<?php echo $vis_language['MSGACCSSDND']?>");
    }	
}
<? if ($owner_details != -1 ) foreach ($owner_details as $owner) echo 'add_owner('.$owner['staff_id'].');'; ?>
</script>
<script src="<?= VIS_PATH_SCRIPT; ?>file-input/bootstrap-filestyle.min.js"></script>
