<? global $vis_language; //echo '<pre>'; print_r($aircall_call_details); echo '</pre>';
 $schedule=array(0=>'Once', 1=>'Daily', 2=>'Weekly', 3=>'Monthly');
if (isset($operation['vis_tweet_details']) && $operation['vis_tweet_details'] != '') {
    $tweet = unserialize(base64_decode($operation['vis_tweet_details']));
    $subject = $tweet->text;
    $client_name = $tweet->user->screen_name;
}

$module_title	=	$vis_language['TXTOPENNEWTICKETS'];
if(isset($operation['ticket_id']) && $operation['ticket_id'] !='' && $ticket_schedule_data[0]!=-1){
	#get data when edit schedule ticket
		$ticket_schedule_data	=	$ticket_schedule_data[1];
		if(!isset($operation['vis_internal_ticket']) && $draft[0]['client_id']==0){ $operation['vis_internal_ticket'] = 1; }
}
$ticket_details_data ='';
if($ticket_details_arr[0]>0){
	$ticket_details_data	=	$ticket_details_arr[1][0];
	if($ticket_details_data['is_deleted'] == 2){ 
		$content	=	$ticket_details_data['ticket_post_content'];  
		$module_title	=	$vis_language['TXTSCHEDULETICKET'];
	}
} 
for($oid=0;$oid<$ticket_ass_data_arr[0];$oid++){
	$owner_id_arr[]	=	$ticket_ass_data_arr[1][$oid]['owner_id'];
} 
if(isset($ticket_schedule_data['schedule_id']) && $ticket_schedule_data['schedule_id'] !=''){
		$startdate	=	date(VIS_DATETIME_FORMAT,($ticket_schedule_data['startdate']+(VIS_TIMEZONE)));
		$enddate	=	date(VIS_DATETIME_FORMAT,($ticket_schedule_data['enddate']+(VIS_TIMEZONE)));
		$scedule_type	=	$ticket_schedule_data['scedule_type']; # 0 =Never, 1=daily, 2=weekly, 3=monthly
		$days			= explode(',',$ticket_schedule_data['days']);
		
		if($scedule_type == 1){
			if($days[0] == 1)
			$daily1	=	'checked="checked"';
			if($days[1] == 1)
			$daily2	=	'checked="checked"';
			if($days[2] == 1)
			$daily3	=	'checked="checked"';
			if($days[3] == 1)
			$daily4	=	'checked="checked"';
			if($days[4] == 1)
			$daily5	=	'checked="checked"';
			if($days[5] == 1)
			$daily6	=	'checked="checked"';
			if($days[6] == 1)
			$daily7	=	'checked="checked"';
		}
		$send_email	=	$ticket_schedule_data['send_email'];
		$auto_responder		= $ticket_schedule_data['auto_responder'];
		
}else{
	$startdate	=	date(VIS_DATETIME_FORMAT,(strtotime(date('M-jS, Y G:i').'+1 days')+VIS_TIMEZONE)); 
	$enddate	=	date(VIS_DATETIME_FORMAT, (strtotime(date('M-jS, Y G:i').'+1 days')+VIS_TIMEZONE));
	$daily1 = $daily2 = $daily3 = $daily4 = $daily5 = $daily6 = $daily7 = 'checked="checked"';
}
/********** DYNAMIC TICKET PROPERTIES *****************/
$tp=0;
if($status)$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_show_subcategory']) && ($module_setting['vis_show_subcategory']==1 || $module_setting['vis_show_subcategory']==2)){
		$tp++;
		$module_setting['vis_subcategory']='';
		if(isset($module_setting['vis_show_item']) && ($module_setting['vis_show_item']==1 || $module_setting['vis_show_item']==2)){$tp++;$module_setting['vis_item']='';
		}
	}
}
//if($itil_enabled==1)$tp++;
if($tp==1 || $tp==2){$class_properties="col-sm-6";}
if($tp==3 || $tp==5 || $tp==6){$class_properties="col-sm-4";}
if($tp==4 || $tp==7 || $tp==8){$class_properties="col-sm-3";}
$enddiv=0;

?>
<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 $module_title; ?></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 $module_title; ?></li>
         </ul>
    </div>
</section>
<section class="padder">
    <section class="panel panel-default">
        <header class="panel-heading sub_header"><? echo $module_title; ?></header>
        <div class="panel-body">
            <form class="form-horizontal text-dark" method="post" enctype="multipart/form-data" name="vis_new_ticket_form" id="vis_new_ticket_form">
                <input type="hidden" value="<? echo $vis_department_id; ?>" name="vis_department" id="vis_department" />
                <input type="hidden" value="<? echo $vis_channel_id; ?>" name="vis_channel" id="vis_channel" />
<? if ((isset($operation['vis_internal_ticket']) && $operation['vis_internal_ticket'] != 1) || ((isset($operation['ticket_id']) && $operation['ticket_id']!='') && ($draft[0]['client_id']!=0))) {  ?>
                    <div class="form-group">
                        <label class="col-sm-2 control-label txt_left"><? echo $vis_language['TXTTO']; ?></label>
                        <div class="col-sm-8">
    <? if ((isset($operation['vis_client']) && $operation['vis_client'] == 1) || ((isset($operation['vis_domain_id']) && isset($operation['vis_chat_type']))&& $operation['vis_email_id']!='') || (isset($operation['ticket_id']) && $operation['ticket_id']!='')) { // from client details page for create ticket  ?>
                            <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>
    <? } else { ?>
                                <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']; ?>&vis_ticket=new_ticket&vis_channel_id=<? echo $vis_channel_id;?>",
                                            {
                                                theme: "facebook",
                                                searchDelay: 300,
                                                minChars: 3,
                                                queryParam: "vis_data",
                                                propertyToSearch: "contactDetails",
                                                tokenValue: "contactDetails",
                                                tokenLimit: 1,
                                                preventDuplicates: true,
                                                resultsFormatter: function(item) {
													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 ;
                                                    return "<li><p>" + contact + "</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-2">
                            <button type="button" class="btn btn-primary btn-sm" data-toggle="ajaxModal" data-modal-arguments="vis_module=client&vis_operation=new_client&vis_client_id=0&vis_static_area=vis_client_add_modal&vis_main_module=ticket&vis_domain_id=<? echo $operation['domain_id']; ?>"><? echo $vis_language['TXTADD']; ?></button>
                            <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: <?php echo ($ticket_details_data['people'])?'':'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="new_ticket_vis_people">
				<script type="text/javascript">
                                $(document).ready(function() {
                                    $("#vis_people").tokenInput(
                                        "index.php?vis_module=client&vis_operation=list_clients&vis_domain=<? echo $operation['domain_id']; ?>&vis_channel_id=<? echo $vis_channel_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');
									//$("#token-input-vis_people").parent().css('width','100%');
									 <? if($ticket_details_data['people']!=''){ 
									 	$peoplecc	=	explode(',',$ticket_details_data['people']);
										  for($p=0;$p<count($peoplecc);$p++){	 ?>
                                     		$("#vis_people").tokenInput("add", {email: "<?= $peoplecc[$p]; ?>"});
                                   <? } } ?>
                                });
                            </script>
                        </div>
                    </div>
                    <div class="form-group" id="vis_ticket_bcc" style="display: <?php echo ($ticket_details_data['people'])?'':'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_bcc"  >
				<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');
									<? if($ticket_details_data['receiver_bcc']!=''){ 
									 	$receiver_bcc	=	explode(',',$ticket_details_data['receiver_bcc']);
										  for($rp=0;$rp<count($receiver_bcc);$rp++){	 ?>
                                     		$("#vis_bcc").tokenInput("add", {email: "<?= $receiver_bcc[$rp]; ?>"});
                                   <? } } ?>
                                });
								 
								
                            </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>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label txt_left"><? echo $vis_language['TXTSUBJECT']; ?></label>
                    <div class="col-sm-8">
                        <input class="form-control input-sm" type="text" name="vis_subject" id="vis_subject" value="<?= $subject ?>">
                    </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 $operation['domain_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'].','.$vis_department_id.','.(isset($operation['vis_ticket_id']) ? $operation['vis_ticket_id'] : 0)?>);'"  <?php if($macro_count[$i]['macro_id']== $ticket_details_data['apply_macro']) { echo ' selected="selected" '; }  ?> ><?= $macro_count[$i]['macro_title']; ?></option>
								<? }} ?>
							</select>
						</div>
					</div>

				
					<div class="col-sm-4">
						<select name="vis_owner" <? if(count($staff_list)>10) echo ' data-live-search="true"';?> data-selector-label="<label class='m-n'><? echo $vis_language['TXTASSIGNEDTO']; ?></label>" class="selectpicker padding-xs ticketowner v-middle text-left">
                               <option value="0" selected="selected" data-content="<label class='checkbox-inline i-checks' onclick='javascript:assign_owner(0);'><input type='checkbox' <?php if($ticket_ass_data_arr[0]<1) { ?> checked='checked' <?php } ?> class='staff_0'> <i></i><span class='m-l-xs font-normal'><? echo $vis_language['TXTUNASSIGNED'];?></span></label>"><? echo $vis_language['TXTUNASSIGNED'];?></option>
                             <? foreach ($staff_list as $staff) { ?>
                               <option value="<?= $staff['staff_id'];?>" data-content="<label class='checkbox-inline i-checks' onclick='javascript:assign_owner(<?= $staff['staff_id'];?>);'><input type='checkbox' class='staff_<?= $staff['staff_id']; ?>' <?php if(in_array($staff['staff_id'],$owner_id_arr)) { ?> checked='checked' <?php } ?> > <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> 
                      
                           <label class="padding-xs control-label  m-l v-middle" id="owner_name"><? if($ticket_ass_data_arr[0]==1){ echo $ticket_ass_data_arr[1][0]['first_name'].' '. $ticket_ass_data_arr[1][0]['last_name']; }else if($ticket_ass_data_arr[0]>1){ echo  $vis_language['TXTMULTIPLEOWNERS']; }else{ echo  $vis_language['TXTUNASSIGNED']; } ?></label>
                           <input type="hidden" name="vis_owner_list" id="vis_owner_list" value="<?php echo (count($owner_id_arr))? ($owner_id_arr[0]!=0)?str_replace('0,','',implode(',',$owner_id_arr)):'' : 0; ?>" />
                           
                      
					</div>			
				</div>
				<div class="form-group" style="display:<?= (($owner_cnt > 1) || $ticket_ass_data_arr[0]>1)?'':'none' ?>" id="multipleownerlist">
						<label class="col-sm-2 control-label txt_left"><? echo $vis_language['TXTOWNER'];?></label>
						<div class="col-sm-10 p-l-none" id="owners_list">
						<?php if(isset($ticket_ass_data_arr[0]) && $owner_id_arr[0]!=0){
								for($a=0;$a<$ticket_ass_data_arr[0];$a++){	 ?>
								<div id="owners_list_<?php echo $ticket_ass_data_arr[1][$a]['owner_id']; ?>">
								<div class="btn-group pull-left m-l-sm m-b-xs">
									<span class="btn btn-xs alert-danger"><?php echo $ticket_ass_data_arr[1][$a]['first_name'].' '. $ticket_ass_data_arr[1][$a]['last_name']; ?></span>
									<button onclick="remove_owner(<?php echo $ticket_ass_data_arr[1][$a]['owner_id']; ?>);" type="button" class="btn btn-xs alert-danger" data-dismiss="alert"><span aria-hidden="true"><i class="vh vh-cross"></i></span><span class="sr-only"><? echo $vis_language['TXTCLOSE'];?></span></button>
								</div>
							 </div>
						<?php 	} //for
						}//if ?>
						</div>
                </div>
				<!--<div class="form-group">
					<div class="col-sm-2">
					<? if($macro_count!=-1) {?>
						<div id="get_macros_up" class="col-sm-8 p-l-none">
							<button type="button" class="btn btn-default btn-sm" onclick="$('#get_macros_up').visExecution('load_area', { 'vis_module': 'ticket', 'vis_operation': 'list_contents', 'vis_action':'get_macros', 'vis_department_id':<? echo $vis_department_id; ?>, 'vis_subaction':'up', 'vis_ticket_id':0 });"><span class="filter-option pull-left"><label class="m-b-n m-r-xs"><?= $vis_language['TXTAPPLYMACRO']?></label> </span><span class="caret"></span></button>
						</div>
						<div id="macro_title" class="clear pull-left padding-xs"></div>
						<? } ?>
					</div>
			</div>-->
				<div class="form-group" style="display:none;" id="vis_selfhelp_search_result">
					<div class="col-sm-12">
						<div name="vis_quick_insert_selfhelp_new" id="vis_quick_insert_selfhelp_new">
						</div>
					</div>
				</div>
                <div class="form-group">
                    <div class="col-sm-12">
                        <textarea name="vis_ticket_post" id="vis_ticket_post_0" class="form-control" rows="10"><?php if (isset($content)){ echo $content= (defined('VIS_HTML_EDITOR') && VIS_HTML_EDITOR != 1)?get_plain_text($content):$content;}elseif(isset($chat_object)){
							 $msg = $chat_object->events;
							 for($i=0;$i<count($msg);$i++){
								if(count($msg[$i]->files)>0){
									 for($a=0;$a<count($msg[$i]->files);$a++){
									  $file_name = explode('/',$msg[$i]->files[$a]);
									  $extension = explode('.',$file_name[6]);

									  if($extension[1]=='pdf' || $extension[1]=='sql' || $extension[1]=='txt')
										  $target = 'target="_blank"';
									  else
										  $target = '';

									   echo '<p>['.$vis_language['TXTATTACHMENT'].']  <a class="link" '.$target.' href="'.$msg[$i]->files[$a].'">'.$file_name[6].'</a></p>'; 									 }
								 }else{
									$author_name = '';
									if(isset($msg[$i]->author_name))$author_name=ucfirst($msg[$i]->author_name).' : ';
									echo '<p>['.format_datetime(strtotime($msg[$i]->date)).']  '.$author_name.$msg[$i]->text.'</p>';
								 }
							 }}elseif(isset($livezilla_chat_object)){
								 $chat = explode('|',$livezilla_chat_object->PlainText);
								  for($i=0;$i<count($chat);$i++){
									  if($i==0){$i++;}
									  $chat_date = format_datetime(strtotime($chat[$i]));
									  echo '<p>['.$chat_date.']  ';
									  $i++;
									  echo '   '.$chat[$i].'</p>';
								  }
							 }elseif(isset($userlike_chat)){
								 $msg = $userlike_chat->messages;

								 if($operation['vis_visitor_name']=='Not specified' && $msg[$i]->type=='co')
									$userlike_name = 'Visitor';

								 for($i=0;$i<count($msg);$i++){
								 	if($operation['vis_visitor_name']!='Not specified' && $msg[$i]->type=='co')
										$userlike_name = $operation['vis_visitor_name'];
									 elseif($msg[$i]->type!='co')
										$userlike_name = $operation['vis_staff_name'];
									 echo '<p>['.format_datetime(strtotime($msg[$i]->sent_at)).']  '.ucfirst($userlike_name).' : '.$msg[$i]->body.'</p>';
								 }

							 }elseif(isset($comm100_data)){
								 $chat_msg = explode('⊙',$comm100_data->chat_transcript);
								 for($i=0;$i<count($chat_msg);$i++){
									 $msg_data = explode(']',$chat_msg[$i]);
									 if(isset($msg_data[1])){
										echo '<p>'.$msg_data[0].']  '.$msg_data[1].'</p>';
									 }else{
										echo '<p>'.$msg_data[0].'</p>';
									 }
								 }
								 $attachment = $comm100_data->attachment;
								  if(count($attachment)>0){
									  for($a=0;$a<count($attachment);$a++){
										 echo '<p>['.$vis_language['TXTATTACHMENT'].']  <a class="link" href="'.$attachment[$a]->uri.'">'.$attachment[$a]->name.'</a></p>';
									  }
								  }
							 }else if(isset($goto_meetings)){
								 ?>
								 <p><? echo $vis_language['TXTSUBJECT'];?> : <? echo $goto_meetings[0]->subject; ?></p>
								 <p><? echo $vis_language['TXTJOINURL'];?> : <a href="https://www.gotomeeting.com/join/<? echo $goto_meetings[0]->meetingId; ?>" target="_blank"> https://www.gotomeeting.com/join/<? echo $goto_meetings[0]->meetingId; ?></a></p>
								<p><? echo $vis_language['TXTSTARTDATE'];?> : <? echo date("d M, Y H:i",strtotime($goto_meetings[0]->startTime)); ?></p>

								<p><? echo $vis_language['TXTENDDATE'];?> : <? echo date("d M Y H:i",strtotime($goto_meetings[0]->endTime)); ?></p>

								<p><? echo $vis_language['TXTCONFERENCECALLINFO'];?> : <? echo $goto_meetings[0]->conferenceCallInfo; ?></p>

								 <p><? echo $vis_language['TXTDURATION'];?> : <? echo $goto_meetings[0]->duration; echo $vis_language['TXTMINUTES'];?> </p>

								 <p><? echo $vis_language['TXTMAXPARTICIPANTS'];?> : <? echo $goto_meetings[0]->maxParticipants; ?></p>

								 <p><? echo $vis_language['TXTMEETINGID'];?> : <? echo $goto_meetings[0]->meetingId; ?></p>

								<p><? echo $vis_language['TXTMEETINGKEY'];?> : <? echo $goto_meetings[0]->meetingKey; ?></p>

								<p><? echo $vis_language['TXTMEETINGTYPE'];?> : <? echo $goto_meetings[0]->meetingType; ?></p>

								<p><? echo $vis_language['TXTMEETINGUNIQUEID'];?> : <? echo $goto_meetings[0]->uniqueMeetingId; ?></p>

							<?php }else if(isset($goto_assist)){
								 ?>
								 <p><? echo $vis_language['TXTMEETINGID'];?> : <? echo $goto_assist->screenSharing->sessionId; ?></p>
								<p><? echo $vis_language['TXTJOINURL'];?> : <a class="link" href="<? echo $goto_assist->screenSharing->customerJoinUrl; ?>" target="_blank"> <? echo $goto_assist->screenSharing->customerJoinUrl; ?></a></p>
								<p><? echo $vis_language['TXTSTARTDATE'];?> : <? echo format_datetime(strtotime($goto_assist->screenSharing->startedAt)); ?></p>
								<p><? echo $vis_language['TXTENDDATE'];?> : <? echo format_datetime(strtotime($goto_assist->screenSharing->endedAt)); ?></p>
								<p><? echo $vis_language['TXTJOINDATE'];?> : <? echo format_datetime(strtotime($goto_assist->screenSharing->customerJoinedAt)); ?></p>
								<p><? echo $vis_language['TXTEXPERTNAME'];?> : <? echo $goto_assist->screenSharing->expertName; ?></p>
								<p><? echo $vis_language['TXTEXPERTEMAIL'];?> : <? echo $goto_assist->screenSharing->expertEmail; ?></p>
								<p><? echo $vis_language['TXTSTATUS'];?> : <? echo $goto_assist->screenSharing->status; ?></p>

							<?php }else if(isset($gcal_details)){
								 if($operation['vis_event']==1){?>
								 <p><? echo $vis_language['TXTSUBJECT'];?> : <? echo $gcal_details['name']; ?></p>
								<p><? echo $vis_language['TXTDESCRIPTION'];?> : <? echo $gcal_details['description']; ?></p>
								<p><? echo $vis_language['TXTLOCATION'];?> : <? echo $gcal_details['location']; ?></p>
								<p><? echo $vis_language['TXTCREATEDBY'];?> : <? echo $gcal_details['creator']; ?></p>
								<p><? echo $vis_language['TXTCREATIONDATE'];?> : <? echo $gcal_details['created']; ?></p>
								<p><? echo $vis_language['TXTGUESTEMAIL'];?> : <? echo $gcal_details['guest_email']; ?></p>
								<p><? echo $vis_language['TXTSTARTDATE'];?> : <? echo $gcal_details['start']; ?></p>
								<p><? echo $vis_language['TXTENDDATE'];?> : <? echo $gcal_details['end']; ?></p>
								<? } else {?>
								<p><? echo $vis_language['TXTSUBJECT'];?> : <? echo $gcal_details['name']; ?></p>
								<p><? echo $vis_language['TXTDESCRIPTION'];?> : <? echo $gcal_details['description']; ?></p>
								<p><? echo $vis_language['TXTDUEDATE'];?> : <? echo $gcal_details['due']; ?></p>
								<p><? echo $vis_language['TXTMODIFICATIONDATE'];?> : <? echo $gcal_details['updated']; ?></p>
							<?php } }else if(isset($webex_meeting_details)){
								 ?>
								<p><? echo $vis_language['TXTTITLE'];?> : <? echo $webex_meeting_details['confName'];?></p>
								<p><? echo $vis_language['TXTMEETINGID'];?> : <? echo $operation['vis_chat_id'] ?></p>
								<p><? echo $vis_language['TXTJOINURL'];?> : <a class="link" href="<? echo $webex_meeting_details['join_url']; ?>" target="_blank"> <? echo $webex_meeting_details['join_url']; ?></a></p>
								<p><? echo $vis_language['TXTSTARTDATE'];?> : : <? echo format_datetime(strtotime($webex_meeting_details['startDate'])); ?></p>
								<p><? echo $vis_language['TXTTIMEZONE'];?> : : <? echo $webex_meeting_details['timeZone']; ?></p>
								<p><? echo $vis_language['TXTDURATION'];?> : <? echo $webex_meeting_details['duration']; ?></p>
								<p><? echo $vis_language['TXTEXPERTNAME'];?> : <? echo $webex_meeting_details['hostWebExID']; ?></p>
								<p><? echo $vis_language['TXTPHONE'];?> : <? echo $webex_meeting_details['telephonySupport']; ?></p>
								<p><? echo $vis_language['TXTPASSWORD'];?> : <? echo $webex_meeting_details['meetingPassword']; ?></p>

							<?php }else if(isset($twilio_call_details)){
								 ?>
								<p> <? echo $vis_language['TXTFROM'];?> : <? echo $twilio_call_details->from_formatted;?></p>
								<p><? echo $vis_language['TXTTO'];?> : <? echo $twilio_call_details->to_formatted;?></p>
								<p><? echo $vis_language['TXTSTARTDATE'];?> : <? echo format_datetime(strtotime($twilio_call_details->start_time)); ?></p>
								<p><? echo $vis_language['TXTENDDATE'];?> : <? echo format_datetime(strtotime($twilio_call_details->end_time)); ?></p>
								<p><? echo $vis_language['TXTDURATION'];?> : <? echo $twilio_call_details->duration.' '.$vis_language['TXTSECONDS'];?></p>
								<p><? echo $vis_language['TXTPRICE'];?> : <? echo $twilio_call_details->price;?></p>
								<p><? echo $vis_language['TXTPRICEUNIT'];?> : <? echo $twilio_call_details->price_unit;?></p>
								<p><? echo $vis_language['TXTDIRECTION'];?> : <? echo ($twilio_call_details->direction=='outbound-api') ? $vis_language['TXTOUTGOING'] : $vis_language['TXTINCOMING'];?></p>
								<p><? echo $vis_language['TXTSTATUS'];?> : <? echo $twilio_call_details->status;?></p>
								<?php if(count($twilio_call_recording->recordings)>0){ ?>
									<p><? echo $vis_language['TXTRECORDING'];?> : <audio src="http://api.twilio.com/2010-04-01/Accounts/<?php echo $twilio_details[0]['host_name'];?>/Recordings/<?php echo $twilio_call_recording->recordings[0]->sid;?>.mp3" controls preload="auto" autobuffer></audio>
								<?php }?>

							<?php }else if(isset($twilio_message_details)){
								 ?>
								<p><? echo $vis_language['TXTFROM'];?> : <? echo $twilio_message_details->from;?></p>
								<p><? echo $vis_language['TXTTO'];?> : <? echo $twilio_message_details->to;?></p>
								<p><? echo $vis_language['TXTCREATEDATE'];?> : <? echo format_datetime(strtotime($twilio_message_details->date_created));?></p>
								<p><? echo $vis_language['TXTUPDATEDATE'];?> : <? echo format_datetime(strtotime($twilio_message_details->date_updated));?></p>
								<p><? echo $vis_language['TXTSENDDATE'];?> : <? echo format_datetime(strtotime($twilio_message_details->date_sent)); ?></p>
								<p><? echo $vis_language['TXTMESSAGE'];?> : <? echo $twilio_message_details->body; ?></p>
								<p><? echo $vis_language['TXTPRICE'];?> : <? echo $twilio_message_details->price;?></p>
								<p><? echo $vis_language['TXTPRICEUNIT'];?> : <? echo $twilio_message_details->price_unit;?></p>
								<p><? echo $vis_language['TXTDIRECTION'];?> : <? echo ($twilio_message_details->direction=='outbound-api') ? $vis_language['TXTOUTGOING'] : $vis_language['TXTINCOMING'];?></p>
								<p><? echo $vis_language['TXTSTATUS'];?> : <? echo $twilio_message_details->status;?></p>

								<?php }else if(isset($allchat)){ 
								 ?>
								 
								 
								<?for($i=0;$i<count($allchat['data']['messages']);$i++)
								{?>
									<p>  <?
									echo '<div class="row m-b-sm">';
									$chat_date = format_datetime(substr(($allchat['data']['messages'][$i]['timestamp']),0,-3));
									echo '<div class="col-xs-2 text-right">['.$chat_date.']</div>';
									echo '<div class=" col-xs-10 text-lt text-muted">'.$allchat['data']['messages'][$i]['user']['nickname']. ' : ' .$allchat['data']['messages'][$i]['content'].'</div>
									</div>';
								}?> </p>							
							<?php }else if(isset($teamviewer_meetings)){ ?>
								<p><? echo $vis_language['TXTSUBJECT'];?> : <? echo $teamviewer_meetings['subject']; ?></p>
								<p><? echo $vis_language['TXTSTARTDATE'];?> : <? echo $teamviewer_meetings['start']; ?></p>
								<p><? echo $vis_language['TXTENDDATE'];?> : <? echo $teamviewer_meetings['end']; ?></p>
								<p><? echo $vis_language['TXTMEETINGID'];?> : <? echo $teamviewer_meetings['id']; ?></p>
								<p><? echo $vis_language['TXTWEBLINK'];?> : <? echo $teamviewer_meetings['participant_web_link']; ?></p>
								<p><? echo $vis_language['TXTCONFERENCECALLINFO'].$vis_language['TXTTYPE'];?> : <? echo $teamviewer_meetings['conference_call_information']['type']; ?></p>
								<p><? echo $vis_language['TXTCONFERENCECALLINFO'].$vis_language['TXTCUSTOMDATA'];?> : <? echo $teamviewer_meetings['conference_call_information']['custom_data']; ?></p>

							<? } else if(isset($teamviewer_sessions)){ ?>
								<p><? echo $vis_language['TXTLANGUAGECODE'];?> : <? echo $teamviewer_sessions['code']; ?></p>
								<p><? echo $vis_language['TXTSTATE'];?> : <? echo $teamviewer_sessions['state']; ?></p>
								<p><? echo $vis_language['TXTGROUPID'];?> : <? echo $teamviewer_sessions['groupid']; ?></p>
								<p><? echo $vis_language['TXTASSIGNEDUSERID'];?> : <? echo $teamviewer_sessions['assigned_userid']; ?></p>
								<p><? echo $vis_language['TXTASSIGNEDAT'];?> : <? echo $teamviewer_sessions['assigned_at']; ?></p>
								<p><? echo $vis_language['TXTENDCUSTOMERLINK'];?> : <? echo $teamviewer_sessions['end_customer_link']; ?></p>
								<p><? echo $vis_language['TXTSUPPORTERLINK'];?> : <? echo $teamviewer_sessions['supporter_link']; ?></p>
								<p><? echo $vis_language['TXTCREATEDAT'];?> : <? echo $teamviewer_sessions['created_at']; ?></p>
								<p><? echo $vis_language['TXTVALIDUNTIL'];?> : <? echo $teamviewer_sessions['valid_until']; ?></p>
								 <?  if($teamviewer_sessions['sessions'][$i]['online']!=1)
											 $teamviewer_sessions['online'] = 'false';

								 ?>
								<p><? echo $vis_language['TXTONLINE'];?> : <? echo $teamviewer_sessions['online']; ?></p>

							<? } else if(isset ($clickdesk_chat_details)) {?>
                                                                <p><? echo '['.format_datetime($clickdesk_chat_details['start_time']/1000).'] : '.$clickdesk_chat_details['user_message'];	 ?></p>                                                                      
                                                                <p><? echo '['.$vis_language['TXTMORECONVERSATION'].']'; ?>
                                                                      <a target="_blank"  href='<? echo $clickdesk_chat_details['chat_history_url'];?>'><? echo $clickdesk_chat_details['chat_history_url'];?></a></p>
                                                                      
                                                        <? } else if(isset ($zopim_chat_data)) {
                                                               if($zopim_chat_data->count->total > 0)
                                                                for($i=0;$i<count($zopim_chat_data->history);$i++) {
                                                                              if($zopim_chat_data->history[$i]->msg !='') {
                                                                               echo '<p>['.format_datetime(strtotime($zopim_chat_data->history[$i]->timestamp)).'] :';
                                                                               echo $zopim_chat_data->history[$i]->msg.'</p>';                                                     
                                                                              }
                                                                 }
                                    
                                                                else {
                                                                     echo '<p>['.format_datetime(strtotime($zopim_chat_data->session->start_date)).'] :';
                                                                     echo ''.$zopim_chat_data->message.'</p>';                                   
                                                                }

                                }else if(isset($call_details)){
									if(isset($call_details['Call'])){ ?>
									<p> <? echo $vis_language['TXTFROM'];?> : <?echo $call_details['Call']['From']; ?></p>
									<p><? echo $vis_language['TXTTO'];?> : <? echo $call_details['Call']['To']; ?></p>
									<p><? echo $vis_language['TXTEXOPHONE'];?> : <? echo $call_details['Call']['PhoneNumberSid']; ?></p>
									<p><? echo $vis_language['TXTSTARTDATE'];?> : <? echo format_datetime(strtotime($call_details['Call']['StartTime']));  ?></p>
									<p><? echo $vis_language['TXTENDDATE'];?> : <?  echo format_datetime(strtotime($call_details['Call']['EndTime'])); ?></p>
									<p><? echo $vis_language['TXTDURATION'];?> : <? echo $call_details['Call']['Duration'].' '.$vis_language['TXTSECONDS']; ?></p>
									<p><? echo $vis_language['TXTPRICE'];?> : <? echo $call_details['Call']['Price']; ?></p>
									
									<p><? echo $vis_language['TXTDIRECTION'];?> : <? echo $call_details['Call']['Direction']; ?></p>
									<p><? echo $vis_language['TXTSTATUS'];?> : <? echo $call_details['Call']['Status']; ?></p>
										<?php if($call_details['Call']['RecordingUrl'] !='' && !is_array($call_details['Call']['RecordingUrl'])){
										echo '<p>'.$vis_language['TXTRECORDING'].' : <audio src="'.trim($call_details['Call']['RecordingUrl']).'" controls preload="auto" autobuffer></audio></p>';
									}  
								}else if(isset($call_details['SMSMessage'])){ ?>
									<p> <? echo $vis_language['TXTFROM'];?> : <?echo $call_details['SMSMessage']['From']; ?></p>
									<p><? echo $vis_language['TXTTO'];?> : <? echo $call_details['SMSMessage']['To']; ?></p>
									<p><? echo $vis_language['TXTSENSTDATE'];?> : <? echo format_datetime(strtotime($call_details['SMSMessage']['DateSent']));  ?></p>
									<p><? echo $vis_language['TXTBODY'];?> : <span ><?  echo str_replace('\r\n','<br/>',$call_details['SMSMessage']['Body']); ?></span></p>									
									<p><? echo $vis_language['TXTPRICE'];?> : <? echo $call_details['SMSMessage']['Price']; ?></p>
									
									<p><? echo $vis_language['TXTDIRECTION'];?> : <? echo $call_details['SMSMessage']['Direction']; ?></p>
									<p><? echo $vis_language['TXTSTATUS'];?> : <? echo $call_details['SMSMessage']['Status']; ?></p>
								
							<?php	}
							}else if(isset($aircall_call_details[0])){
								$calls_array = $aircall_call_details[0]->call;
								if($calls_array->direction == 'outbound'){
									$to = $calls_array->raw_digits;
									$from = $calls_array->number->digits;
								}else if($calls_array->direction == 'inbound'){
									 $from = $calls_array->raw_digits;
									 $to = $calls_array->number->digits;
								}
								if(isset($calls_array->contact)){
									$contact_name = $calls_array->contact->first_name.' '.$calls_array->contact->last_name;
								}
								$staff = 'Name: '.$calls_array->user->name.'<br/>&nbsp;&nbsp;Email: '.$calls_array->user->email;
								$voiceemail = $calls_array->voicemail;
								$recording_url	= $calls_array->recording;
								?>
							   <p><? echo $vis_language['TXTFROM'];?> :<? echo $from;?></p>
							   <p><? echo $vis_language['TXTTO'];?> :<? echo $to; ?></p>
							   <?php if(isset($calls_array->contact)){ ?>
							   <p><? echo $vis_language['TXTCONTACT'];?> :<? echo $contact_name; ?></p>
							   <?php } ?>
							   <p><? echo $vis_language['TXTSTARTDATE'];?> :<? echo format_datetime($calls_array->started_at); ?></p>
							   <p><? echo $vis_language['TXTENDDATE'];?> :<? echo format_datetime($calls_array->ended_at); ?></p>
							   <p><? echo $vis_language['TXTDURATION'];?> :<? echo $calls_array->duration.' '.$vis_language['TXTSECONDS'];?></p>
							   <p><? echo $vis_language['TXTDIRECTION'];?> :<? echo $calls_array->direction;?></p>
							   <p><? echo $vis_language['TXTSTAFF'];?> :<? echo $staff;?></p>
							   <p><? echo $vis_language['TXTSTATUS'];?> :<? echo $calls_array->status; ?></p>
       
							   <?php if($recording_url !=''){ ?>
							   <p><? echo $vis_language['TXTRECORDING'];?> :<audio src="<?php echo $recording_url; ?>" controls preload="auto" autobuffer ></audio></p>
						 
								<?php }  ?>
								<?php if($voiceemail !=''){ ?>
								<p><? echo $vis_language['TXTVOICEMAIL'];?> :<audio src="<?php echo $voiceemail; ?>" controls preload="auto" autobuffer ></audio></p>
								<?php }  ?>
								
					<?php }//aircall 
					else if(isset($asterisk_call_details)&& $asterisk_count!=0){
								$calldate = $asterisk_call_details[0]['calldate'];
								$clid = $asterisk_call_details[0]['clid'];
								$src = $asterisk_call_details[0]['src'];
								$dst = $asterisk_call_details[0]['dst'];
								$dcontext = $asterisk_call_details[0]['dcontext'];
								$channel = $asterisk_call_details[0]['channel'];
								$dstchannel = $asterisk_call_details[0]['dstchannel'];
								$lastapp = $asterisk_call_details[0]['lastapp'];
								$lastdata = $asterisk_call_details[0]['lastdata'];
								$duration = $asterisk_call_details[0]['duration'];
								$billsec = $asterisk_call_details[0]['billsec'];
								$disposition = $asterisk_call_details[0]['disposition'];
								$amaflags = $asterisk_call_details[0]['amaflags'];
								$accountcode = $asterisk_call_details[0]['accountcode'];
								$uniqueid = $asterisk_call_details[0]['uniqueid'];
								$userfield = $asterisk_call_details[0]['userfield'];
								$recordingfile = $asterisk_call_details[0]['recordingfile'];
								$cnum = $asterisk_call_details[0]['cnum'];
								$cnam = $asterisk_call_details[0]['cnam'];
								$outbound_cnum = $asterisk_call_details[0]['outbound_cnum'];
								$outbound_cnam = $asterisk_call_details[0]['outbound_cnam'];
								$dst_cnam  = $asterisk_call_details[0]['dst_cnam'];
								$did = $asterisk_call_details[0]['did'];
								$LinkedId = $asterisk_call_details[0]['LinkedId'];
								
								?>
								<p><? echo ucfirst($vis_language['TXTXCALLDATE']);?> : <? echo $calldate;?></p>
								<p><? echo ucfirst($vis_language['TXTCHILD']);?> : <? echo $clid; ?></p>
								<p><? echo ucfirst($vis_language['TXTSRC']);?> : <? echo $src; ?></p>
								<p><? echo ucfirst($vis_language['TXTDST']);?> : <? echo $dst; ?></p>
								<p><? echo ucfirst($vis_language['TXTDCONTEXT']);?> : <? echo $dcontext; ?></p>
								<p><? echo ucfirst($vis_language['TXTCHANNEL']);?> : <? echo $channel; ?></p>  
								<p><? echo ucfirst($vis_language['TXTDSTCHANEL']);?> : <? echo $dstchannel; ?></p>  
								<p><? echo ucfirst($vis_language['TXTLASTAPP']);?> : <? echo $lastapp;?></p>
								<p><? echo ucfirst($vis_language['TXTLASTDATA']);?> : <? echo $lastdata;?></p>
								<p><? echo ucfirst($vis_language['TXTDURATION']);?> : <? echo $duration.' '.ucfirst($vis_language['TXTSECONDS']); ?> </p>
								<p><? echo ucfirst($vis_language['TXTBILLSEC']);?> : <? echo $billsec; ?></p>
								<p><? echo ucfirst($vis_language['TXTDISPOSITION']);?> : <? echo $disposition; ?></p>
								<p><? echo ucfirst($vis_language['TXTAMAFLAGS']);?> : <? echo $amaflags; ?></p>
								<p><? echo ucfirst($vis_language['TXTACCOUNTCODE']);?> : <? echo $accountcode; ?></p>
								<p><? echo ucfirst($vis_language['TXTUNIQUEID']);?> : <? echo $uniqueid; ?></p>
								<p><? echo ucfirst($vis_language['TXTUSERFIELD']);?> : <? echo $userfield; ?></p>
								<? if($recordingfile !=''){ ?>
								<p><? echo ucfirst($vis_language['TXTRECORDINGFILE']);?> : <audio src="<?php echo $rec_url_path.$recordingfile; ?>" controls preload="auto" autobuffer ></audio></p>
								<?php } ?>		
								<p><? echo ucfirst($vis_language['TXTCNUM']);?> : <? echo $cnum; ?></p>
								<p><? echo ucfirst($vis_language['TXTCNAM']);?> : <? echo $cnam; ?></p>
								<p><? echo ucfirst($vis_language['TXTOUTBOUNDCNUM']);?> : <? echo $outbound_cnum; ?></p>
								<p><? echo ucfirst($vis_language['TXTOUTBOUNDCNAM']);?> : <? echo $coutbound_cnam; ?></p>
								<p><? echo ucfirst($vis_language['TXTDSTCNAM']);?> : <? echo $dst_cnam; ?></p>
								<p><? echo ucfirst($vis_language['TXTDID']);?> : <? echo $did; ?></p>
								<p><? echo ucfirst($vis_language['TXTLINKEDID']);?> : <? echo $LinkedId; ?></p>
							   
					<?php }//asterisk  ?>
                            <?php if(isset($signature) && $signature!='' && (!isset($operation['ticket_id']) || $operation['ticket_id']=='' )) echo $signature; ?>
                        </textarea>
                    </div>
                </div>
				
				<div class="form-group">
                    <div class="col-sm-12">
                        <div class="col-sm-7 p-l-none" id="vis_new_ticket_attachments"> 
						<?php if($attachnemt_details_arr[0]['file_name'] !='' && count($attachnemt_details_arr)>0){
						 for($i=0;$i<count($attachnemt_details_arr);$i++){  ?>
								<a href="../attachment/<?php echo $attachnemt_details_arr[$i]['content']; ?>" download>
								<div class="btn-group wrapper-xxs"><span class="btn btn-xs alert-success"><?php echo $attachnemt_details_arr[$i]['file_name']; ?></span><button onclick="$(this).parent().remove(); $(this).visExecution(&quot;load_operations&quot;, {&quot;vis_module&quot;:&quot;ticket&quot;, &quot;vis_operation&quot;:&quot;remove_attachment&quot;, &quot;vis_attachment_id&quot;:<?php echo $attachnemt_details_arr[$i]['attachment_id']; ?>});vis_remove_attachment(<?php echo $attachnemt_details_arr[$i]['attachment_id']; ?>,&quot;vis_attachments&quot;);" data-dismiss="alert" type="button" class="btn btn-xs alert-success"><i class="vh vh-cross"></i></button></div></a>
						<?php	}//for
							}//if	 ?>					
						</div>
                        <div class="col-sm-5 p-r-none text-right">
                            <input type="file" name="files[]" multiple="multiple" class="filestyle" data-icon="false" data-classButton="btn btn-link link text-primary v-middle" data-buttonText="<? echo $vis_language['TXTATTACHFILE']; ?>" data-input="false" onchange="$(this).visExecution('upload_file', {'vis_static_area': '#vis_new_ticket_attachments', 'vis_form': 'vis_new_ticket_form', 'vis_form_attachment_area': '#vis_attachments'});">
                            <input type="hidden" name="vis_location" value="<? echo VIS_DOMAIN; ?>" />
                            <input type="hidden" name="vis_attachments" id="vis_attachments" value="" />
							
							<? if($itil_enabled==1){?>
								<span id="vis_select_cit_btn"><a href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=cmdb&vis_operation=attach_ci&vis_static_area=vis_add_cito_ticket&vis_department=<? echo $vis_department_id; ?>&attached_ci_ids=<?php if($attach_ci_details!= -1) for($i=0;$i<count($attach_ci_details);$i++) echo $attach_ci_details[$i]['child_id'].','; ?>" class="link text-primary v-middle"> <? echo $vis_language['TXTATTACHCI']; ?></a></span>
							 <? }?>
							 
							<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>                          
                            
						   <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>
                </div>
				<? if($itil_enabled==1){?>
					<div class="form-group attach_ci_div" style="display:<?php echo ($attach_ci_details!=-1)?'':'none;';?>">
						<div class="col-sm-12">
							<div class="clear m-b-xs m-t-xs">
								<label class="col-sm-1"><? echo $vis_language['TXTCI'];?></label>
								<div class="col-sm-11 p-l-none" id="vis_attach_ci">
									<input type="hidden" name="vis_ci_attach" id="vis_ci_attach" value="<?php if($attach_ci_details!= -1) for($i=0;$i<count($attach_ci_details);$i++) echo $attach_ci_details[$i]['child_id'].','; ?>" />
									<?php if($attach_ci_details!= -1){
											for($i=0;$i<count($attach_ci_details);$i++){ ?>
											<div class="btn-group wrapper-xxs"><span class="btn btn-xs alert-info"><?php echo $attach_ci_details[$i]['name']; ?></span><button class="btn btn-xs alert-info" type="button" data-dismiss="alert" onclick="vis_remove_ci_attachment(<?php echo $attach_ci_details[$i]['child_id']; ?>);"><i class="vh vh-cross"></i></button></div>
										<?php	}									
									} ?>
								</div>
							</div>
						</div>
					</div>
				 <? }?>
				
				<div class="form-group">
                    <? 
					$finalclose=0;
					
					if($status){$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($status) > 10) echo ' data-live-search="true"'; ?>>
									<? for ($i = 0; $i < count($status); $i++){
   											 echo '<option value="' . $status[$i]['status_id'] . '"';
												if($status[$i]['status_id'] == $ticket_details_data['status_id']){ echo ' selected="selected"'; }
											echo ' >' . $status[$i]['status_name'] . '</option>';
											}  ?> 
                                </select>
                            </div>
                        </div>
					<? }
					
				if($tp==$enddiv && $finalclose==0){ echo "</div>"; $finalclose=1;}
				else{if((($tp==5 || $tp==6) &&$enddiv==3) || (($tp==7 || $tp==8) && $enddiv==4) ){echo '</div><div class="form-group">';}}

					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'] . '"';
										if($priorities[$i]['priority_id'] == $ticket_details_data['priority_id']){ echo ' selected="selected"'; }
										echo ' >' . $priorities[$i]['priority_name'] . '</option>'; 
										} ?>
                                </select>
                            </div>
                        </div>
					<? }
					if($tp==$enddiv && $finalclose==0){ echo "</div>"; $finalclose=1;}
				else{if((($tp==5 || $tp==6) &&$enddiv==3) || (($tp==7 || $tp==8) && $enddiv==4) ){echo '</div><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_data['type_id']){ echo ' selected="selected"'; }
										 echo '>' . $ticket_types[$i]['type_name'] . '</option>'; 
										 } ?>
                                </select>
                            </div>
                        </div>
				   <? }
				 if($tp==$enddiv && $finalclose==0){ echo "</div>"; $finalclose=1;}
				else{if((($tp==5 || $tp==6) &&$enddiv==3) || (($tp==7 || $tp==8) && $enddiv==4) ){echo '</div><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_data['level_id']){ echo ' selected="selected"'; }
										 echo '>' . $ticket_level_details[$i]['title'] . '</option>'; 
										 } ?>
                                </select>
                            </div>
                        </div>
				<?php }?>
                <? 
				if($tp==$enddiv && $finalclose==0){ echo "</div>"; $finalclose=1;}
				else{if((($tp==5 || $tp==6) &&$enddiv==3) || (($tp==7 || $tp==8) && $enddiv==4) ){echo '</div><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,0,1);">
									<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_data['category_id']){ echo ' selected="selected"'; }
											echo ' >' . $ticket_cat_details[$i]['title'] . '</option>';
											}  ?> 
                                </select>
                            </div>
                        </div>
			
				
				<? 
			if($tp==$enddiv && $finalclose==0){ echo "</div>"; $finalclose=1;}
				else{if((($tp==5 || $tp==6) &&$enddiv==3) || (($tp==7 || $tp==8) && $enddiv==4) ){echo '</div><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,0);">
									<option value="0"><? echo $vis_language['TXTSELECT']; ?></option>
                                </select>
                            </div>
                        </div>
			
				
				<? if($tp==$enddiv && $finalclose==0){ echo "</div>"; $finalclose=1;}
				else{if((($tp==5 || $tp==6) &&$enddiv==3) || (($tp==7 || $tp==8) && $enddiv==4) ){echo '</div><div class="form-group">';}}?>   
				 <? 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>
								</select>
                            </div>
                        </div>
				<?php }}}?>
				
				<? if($tp==$enddiv && $finalclose==0){ echo "</div>"; $finalclose=1;}
				else{if((($tp==5 || $tp==6) &&$enddiv==3) || (($tp==7 || $tp==8) && $enddiv==4) ){echo '</div><div class="form-group">';}}?>
				
						<? 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,''); ?>
										<?  } ?>
									</select>
								</div>
							</div>
						<? }}?>
                   
                <? if($tp==$enddiv && $finalclose==0){ echo "</div>"; $finalclose=1;}
				else{if((($tp==5 || $tp==6) &&$enddiv==3) || (($tp==7 || $tp==8) && $enddiv==4) ){echo '</div>';}}?>
				
				
<? if ($custom_field_var != '') echo $custom_field_var; ?>
<? if ((isset($operation['vis_internal_ticket']) && $operation['vis_internal_ticket'] != 1) || ($draft[0]['client_id']!=0)) { ?>
                    <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_send_message" id="vis_send_message"<?php if (($vis_channel_id == 1 || $vis_channel_id == 5 || $vis_channel_id == 7 || ($vis_channel_id >19 && $vis_channel_id != 22 && $vis_channel_id != 23) ) && ($operation['ticket_id']=='' || $ticket_details_data['draft_id']==1)) echo ' checked="checked"';  else if($operation['ticket_id'] !='' && $send_email ==1) echo ' checked="checked"'; ?> value="1" type="checkbox"><i></i> <? echo $vis_language['TXTSENDEMAIL']; ?></label>
                            </div>
                            <div class="col-sm-3">
                                <label class="checkbox-inline i-checks">
                                    <input name="vis_sendmail" id="vis_sendmail" value="1" type="checkbox" <?php if($auto_responder){ echo 'checked="checked" '; } ?> ><i></i> <? echo $vis_language['TXTAUTORESPONDER']; ?>
                                </label>
                            </div>
                            <div class="col-sm-3">
                                <label class="checkbox-inline i-checks">
                                    <input name="vis_private" id="vis_private" <?php echo ($ticket_details_data['is_deleted']==2)?(($ticket_details_data['is_deleted']==2 && $ticket_details_data['is_visible']==1)? 'checked="checked"':''):'checked="checked"'; ?> value="1" type="checkbox"><i></i> <? echo $vis_language['TXTVISIBLETOCLIENT']; ?>
                                </label>
                            </div>
                            <div class="col-sm-3">
                                <label class="checkbox-inline i-checks">
                                    <input name="vis_as_client" id="vis_as_client"  <?php echo ($ticket_details_data['is_deleted']==2)?(($ticket_details_data['is_deleted']==2 && $ticket_details_data['as_client']==1)? 'checked="checked"':''):''; ?> value="1" type="checkbox"><i></i> <? echo $vis_language['TXTASCLIENT']; ?>
                                </label>
                            </div>	
							
                        </div>
                    </div>
                        <? } ?>
                <div class="form-group"<?php if(!$ticket_details_data['remark_id']){ ?> style="display:none;" <?php } ?> 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']; ?>" ><?php echo $ticket_details_data['remark_content']; ?></textarea>
                    </div>
                </div>
				
				
				<!-- Readminme -->
				<?php if(VIS_REDMINE_ACCESS == 1){ if($check_redmine_status != -1){ ?>
				<br/>
				<div class="form-group">				 
                    <div class="col-sm-12 text-right">					
						<div class="col-sm-3 p-l-none txt_left">
							<label class="checkbox-inline i-checks" id="lbl_redmine">
								<input name="vis_redmine" id="vis_redmine"  value="1" type="checkbox"  >
								<i></i> <? echo $vis_language['TXTCREATEISSUEWITHREADMINE']; ?>
							</label>
						</div>
					</div>
				</div>	
				
				 <div class="form-group" id="redmine_data">
				 <div class="line b-b line-lg pull-in"></div>
				 <br/>
				 		<div class="col-xs-6">
                                 <div class="form-group col-xs-10">
                                    <label for="taskPriority"><? echo $vis_language['TXTPROJECTS'];?></label> 
                                    <select class="form-control input-sm selectpicker" id="vis_project" name="vis_project" <?php if($projectAll['total_count'] > 5) $src= 'data-live-search="true"' ; ?>   >
                                    <?
                                       for($i=0;$i<$projectAll['total_count'];$i++) {                                      
                                       echo '<option value="'.$projectAll['projects'][$i]['id'].'" >'.$projectAll['projects'][$i]['name'].'</option>'; } ?>
                                    </select>
                                 </div>			 
								 
                        </div>													
				</div>
				<?php } }  ?>				
				<!-- End readmine -->	
				<!------ Vtiger ----->
				<?php if($vt_acc_list!=-1){ 			
								
						$vt_data['vtiger_url']	= $vt_acc_list[0]['vtiger_url'];
						$vt_data['vtiger_user']	= $vt_acc_list[0]['vtiger_user'];
						$vt_data['vtiger_key']	= $vt_acc_list[0]['vtiger_key'];
						$vt_data['vtiger_lic'] 	= $vt_acc_list[0]['vtiger_lic'];
						
						$vt_data['module_name'] = ($vt_data['vtiger_lic']==1)?"HelpDesk":"Cases";	
						$vt_module_desc	=	$setting_object->get_vtiger('module_desc',$vt_data);
			
						$vt_ticket_priorities = $vt_module_desc['fields'][3]['type']['picklistValues'];
						$vt_ticketstatus	=	$vt_module_desc['fields'][5]['type']['picklistValues'];
			
		
	
				?>
					<br/>
					<div class="form-group">				 
						<div class="col-sm-12 text-right">					
							<div class="col-sm-3 p-l-none txt_left">
								<label class="checkbox-inline i-checks" id="lbl_vtiger">
									<input name="vis_vtiger" id="vis_vtiger"  value="1" type="checkbox"  >
									<i></i> <? echo $vis_language['TXTCREATETICKETEWITHVTIGER']; ?>
								</label>
							</div>
						</div>
					</div>	
					
					 <div class="form-group" id="vtiger_data">
					 <div class="line b-b line-lg pull-in"></div>
					 <br/> 
							<div class="col-xs-4">
									 <div class="form-group col-xs-10">
										<label for="taskPriority"><? echo $vis_language['TXTUSER'];?></label> 
										<select class="form-control input-sm selectpicker" onchange="get_vt_status(this.value);" id="vis_vt_user" name="vis_vt_user" <?php if(count($vt_acc_list) > 5) $src= 'data-live-search="true"' ; ?>   >
										<?
										   for($i=0;$i<count($vt_acc_list);$i++) {                                      
										   echo '<option value="'.$vt_acc_list[$i]['integration_id'].'" >'.$vt_acc_list[$i]['vtiger_user'].'</option>'; } ?>
										</select>
									 </div>			 
									 
							</div> 
						<div id="ajax_vt" >
 							<div class="col-xs-4">
									 <div class="form-group col-xs-10">
										<label for="taskPriority"><? echo $vis_language['TXTSTATUS'];?></label> 
										<select class="form-control input-sm selectpicker" id="vis_vt_status" name="vis_vt_status" <?php if(count($vt_ticketstatus) > 5) $src= 'data-live-search="true"' ; ?>   >
										<?
										   for($i=0;$i<count($vt_ticketstatus);$i++) {                                      
										   echo '<option value="'.$vt_ticketstatus[$i]['value'].'" >'.$vt_ticketstatus[$i]['label'].'</option>'; } ?>
										</select>
									 </div>			 
									 
							</div>								
							<div class="col-xs-4">
									 <div class="form-group col-xs-10">
										<label for="taskPriority"><? echo $vis_language['TXTPRIORITY'];?></label> 
										<select class="form-control input-sm selectpicker" id="vis_vt_priority" name="vis_vt_priority" <?php if(count($vt_ticket_priorities) > 5) $src= 'data-live-search="true"' ; ?>   >
										<?
										   for($i=0;$i<count($vt_ticket_priorities);$i++) {                                      
										   echo '<option value="'.$vt_ticket_priorities[$i]['value'].'" >'.$vt_ticket_priorities[$i]['label'].'</option>'; } ?>
										</select>
									 </div>			 
									 
							</div>
						</div>
					</div>
				<?php
				} ?>
				<!---  End Vtiger ---->

				
				
                <div class="line b-b line-lg pull-in"></div>
                <br/>
				 <div class="form-group" id="schedule_type">
				 		<div class="col-xs-4">
                                 <div class="form-group col-xs-10">
                                    <label for="taskPriority"><? echo $vis_language['TXTREPEATSCHEDULE'];?></label>
                                    <select class="form-control input-sm selectpicker" id="vis_set_schedule" name="vis_set_schedule" onchange="show_hide_enddate();">
                                    <?
                                       for($i=0;$i<count($schedule);$i++) {
                                       if($scedule_type == $i) $selected='selected="selected"'; else $selected='';
                                       echo '<option value="'.$i.'" '.$selected.' >'.$schedule[$i].'</option>'; } ?>
                                    </select>
                                 </div>
                        </div>
						<div class="col-xs-4">
                              <div class="form-group col-xs-10">
                                 <label for="taskStartdate"><? echo $vis_language['TXTSCHEDULEDATE'];?></label>
                               <span class="input-group-addon no-padder no-borders start">  <input class="input-sm form-control" id="vis_schedule_start_date" name="vis_schedule_start_date" size="16" type="text" placeholder="DD-MM-YYYY" value="<?= $startdate; ?>"></span>
                              </div>
                        </div>
						<div class="col-xs-4" id="end_dt">
                              <div class="form-group col-xs-10">
                                 <label for="taskEnddate"><? echo $vis_language['TXTENDDATE'];?></label>
                               <span class="input-group-addon no-padder no-borders start">  <input class="input-sm form-control" id="vis_schedule_end_date" name="vis_schedule_end_date" size="16" type="text" placeholder="DD-MM-YYYY" value="<?= $enddate; ?>"></span>
                              </div>
                           </div>
						
				</div>
				<div id="vis_days">                              
				  <div class="form-group" id="vis_daily" style="display: none;">
					 <label class="col-sm-2 text-muted text-right"></label>
					 <div class="col-sm-10">
						<? $repeat_daily=explode(',', $newly_added_schedule_details['task_repeat_occurence']); ?>
						<div class="checkbox i-checks m-r-lg pull-left p-d-sm"> <label>
						   <input type="checkbox" <?  echo $daily1 ;?> value="1" id="vis_daily1" name="vis_daily1"/><i></i> <? echo $vis_language['TXTSUNDAY']; ?></label>
						</div>
						<div class="checkbox i-checks m-r-lg pull-left p-d-sm"><label>
						   <input type="checkbox" <?  echo $daily2;?>  value="1" id="vis_daily2" name="vis_daily2"/><i></i> <? echo $vis_language['TXTMONDAY']; ?></label>
						</div>
						<div class="checkbox i-checks m-r-lg pull-left p-d-sm"><label>
						   <input type="checkbox" <? echo $daily3;?>value="1" id="vis_daily3" name="vis_daily3"/><i></i> <? echo $vis_language['TXTTUESDAY']; ?></label>
						</div>
						<div class="checkbox i-checks m-r-lg pull-left p-d-sm"><label>
						   <input type="checkbox" <?  echo $daily4;?>  value="1" id="vis_daily4" name="vis_daily4"/><i></i> <? echo $vis_language['TXTWEDNESDAY']; ?></label>
						</div>
						<div class="checkbox i-checks m-r-lg pull-left p-d-sm"><label>
						   <input type="checkbox" <?  echo $daily5;?>  value="1" id="vis_daily5" name="vis_daily5"/><i></i> <? echo $vis_language['TXTTHURSDAY']; ?></label>
						</div>
						<div class="checkbox i-checks m-r-lg pull-left p-d-sm"><label>
						   <input type="checkbox" <? echo $daily6;?> value="1" id="vis_daily6" name="vis_daily6"/><i></i> <? echo $vis_language['TXTFRIDAY']; ?></label>
						</div>
						<div class="checkbox i-checks m-r-lg pull-left p-d-sm"><label>
						   <input type="checkbox" <?  echo $daily7;?>   value="1" id="vis_daily7" name="vis_daily7"/><i></i> <? echo $vis_language['TXTSATURDAY']; ?></label>
						</div>
					 </div>
				  </div>
				  <div class="form-group" id="vis_weekly" style="display: none;">
					 <label class="col-sm-2 text-muted text-right"></label>
					 <div class="col-sm-10">
						<div class="radio i-checks m-r-lg pull-left "><label>
						   <input type="radio" <?php if($days[0]==1 || count($days)<=1){ echo 'checked="checked"'; }else if($ticket_schedule_data['schedule_id']==''){ echo 'checked="checked"'; } ?> value="1" id="vis_weekly1" name="vis_weekly"/><i></i><? echo $vis_language['TXTSUNDAY']; ?></label>
						</div>
						<div class="radio i-checks m-r-lg pull-left "><label>
						   <input type="radio" <?php if($days[0]==2){ echo 'checked="checked"'; } ?>  value="2" id="vis_weekly2" name="vis_weekly"/><i></i><? echo $vis_language['TXTMONDAY']; ?></label>
						</div>
						<div class="radio i-checks m-r-lg pull-left "><label>
						   <input type="radio" <?php if($days[0]==3){ echo 'checked="checked"'; } ?> value="3" id="vis_weekly3" name="vis_weekly"/><i></i><? echo $vis_language['TXTTUESDAY']; ?></label>
						</div>
						<div class="radio i-checks m-r-lg pull-left "><label>
						   <input type="radio" <?php if($days[0]==4){ echo 'checked="checked"'; } ?> value="4" id="vis_weekly4" name="vis_weekly"/><i></i><? echo $vis_language['TXTWEDNESDAY']; ?></label>
						</div>
						<div class="radio i-checks m-r-lg pull-left "><label>
						   <input type="radio" <?php if($days[0]==5){ echo 'checked="checked"'; } ?>  value="5" id="vis_weekly5" name="vis_weekly"/><i></i><? echo $vis_language['TXTTHURSDAY']; ?></label>
						</div>
						<div class="radio i-checks m-r-lg pull-left "><label>
						   <input type="radio" <?php if($days[0]==6){ echo 'checked="checked"'; } ?>  value="6" id="vis_weekly6" name="vis_weekly"/><i></i><? echo $vis_language['TXTFRIDAY']; ?></label>
						</div>
						<div class="radio i-checks m-r-lg pull-left "><label>
						   <input type="radio" <?php if($days[0]==7){ echo 'checked="checked"'; } ?> value="7" id="vis_weekly7" name="vis_weekly"/><i></i><? echo $vis_language['TXTSATURDAY']; ?></label>
						</div>
					 </div>
				  </div>
			   </div><?php  if(VIS_SCHEDULE_TICKET_MANAGE_ACCESS == 1){ ?>
				<div class="line b-b line-lg pull-in" id="hr"></div><br id="br" /> <?php } ?>
				<br/>
                <div class="form-group">				 
                    <div class="col-sm-12 text-right">					
					<div class="col-sm-3 p-l-none txt_left">
                                <label class="checkbox-inline i-checks" id="lbl_schedule_ticket">
                                   
									<?php  if(VIS_SCHEDULE_TICKET_MANAGE_ACCESS == 1){
										if($ticket_schedule_data['schedule_id']!=''){ ?> 
									  <input name="vis_schedule_ticket" id="vis_schedule_ticket"  value="1" type="hidden"  >
									  <input  value="1" disabled="disabled" type="checkbox"  checked="checked" >
									<?php }else{ ?> 
									 <input name="vis_schedule_ticket" id="vis_schedule_ticket"  value="1" type="checkbox"  >
									<?php } ?><i></i> <? echo $vis_language['TXTSCHEDULETICKET']; 
									} ?>
								</label>
                            </div>
				 		<?php  if(VIS_SCHEDULE_TICKET_MANAGE_ACCESS == 1){ ?>
						 <button type="button" id="btn_schedule_ticket" class="btn btn-primary m-l" onclick="$(this).visExecution('submit_form', {'vis_module': 'ticket', 'vis_operation': 'open_new_ticket', 'vis_form': 'vis_new_ticket_form' , 'vis_draft': '1' , 'vis_schedule_ticket': '1'})"><? echo $vis_language['TXTSCHEDULETICKET']; ?></button>
						 <?php } ?>
                        <button type="button" id="btn_drafts_ticket" class="btn btn-default" onclick="$(this).visExecution('submit_form', {'vis_module': 'ticket', 'vis_operation': 'open_new_ticket', 'vis_form': 'vis_new_ticket_form', 'vis_draft': '1'})"><? echo $vis_language['TXTSAVEASDRAFT']; ?></button>
                        <?if(isset($operation['vis_draft']) && $operation['vis_draft']!='') $draft= ",'vis_draft':'true'"; else $draft="";?>
                        <button type="button" id="btn_add_ticket" class="btn btn-primary m-l" onclick="$(this).visExecution('submit_form', {'vis_module': 'ticket', 'vis_operation': 'open_new_ticket','vis_channel_id': '<? echo $vis_channel_id; ?>', 'vis_form': 'vis_new_ticket_form' <? echo $draft; ?>});  $(this).attr('disabled','disabled');"><? echo $vis_language['TXTADDTICKET']; ?></button>
                        <input type="hidden" name="vis_domain" value="<? echo $operation['domain_id']; ?>" />
                        <input type="hidden" name="vis_client" id="vis_client" value="<? if (isset($client)) echo $client['client_id']; ?>" />
                        <input type="hidden" name="vis_spam" id="vis_spam" value="<? if (isset($client)) echo $client['is_spam']; ?>" />
                        <input type="hidden" name="vis_internal_ticket" id="vis_internal_ticket" value="<?= $operation['vis_internal_ticket']; ?>">
                        <input type="hidden" name="vis_flag_id" id="vis_flag_id" value="1" />
                        <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" />
<? if (isset($operation['vis_tweet_details']) && $operation['vis_tweet_details'] != '') echo '<input type="hidden" name="vis_tweet_details" value="' . $operation['vis_tweet_details'] . '" />';
echo $draft_info; ?>
						<input type="hidden" name="vis_edit_id" id="vis_edit_id" value="<?php echo $operation['ticket_id']; ?>"  />
						<input type="hidden" name="vis_schedule_id" id="vis_schedule_id" value="<?php echo $ticket_schedule_data['schedule_id']; ?>"  />
                    </div>
                </div>

        </div>
       </form>
        </div>
		 
    </section>
  
</section>


<?php
function vis_show_subcategories($location_assets,$call=NULL) {
         
        for($i=0;$i<count($location_assets);$i++) { ?>
		 <? echo '<option value="'.$location_assets[$i]['location_id'].'">'.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>
	$("#redmine_data").hide();
	$("#vis_redmine").click(function(){
		if($("#vis_redmine:checked").val()){ 
			 $("#redmine_data").show();
			$("#lbl_schedule_ticket").hide();			 
		}else{ 
			$("#redmine_data").hide();
			 $("#lbl_schedule_ticket").show();
		}		
	});
	
	$("#vtiger_data").hide();
	$("#vis_vtiger").click(function(){
		if($("#vis_vtiger:checked").val()){ 
			 $("#vtiger_data").show();
			$("#lbl_schedule_ticket").hide();			 
		}else{ 
			$("#vtiger_data").hide();
			 $("#lbl_schedule_ticket").show();
		}		
	});
	
	/**/
  <?php if( $ticket_schedule_data['schedule_id']!=0){ ?> $("#lbl_redmine").hide(); <?php }/**/ ?>
  <?php if( $ticket_schedule_data['schedule_id']!=0){ ?> $("#lbl_vtiger").hide(); <?php }/**/ ?>


	$("#btn_schedule_ticket").hide();
	$("#schedule_type").hide();	
	$("#end_dt").hide();	
	$("#hr").hide();	
	$("#br").hide();
	get_subcategory('<?=$ticket_details_data['category_id'];?>','<?=$ticket_details_data['subcategory_id'];?>');	
	getitem('<?=$ticket_details_data['subcategory_id'];?>','<?=$ticket_details_data['item_id'];?>');
	
	 <?php if($ticket_schedule_data['schedule_id']!=''){ ?>
	 		$("#btn_drafts_ticket").hide();
			$("#btn_add_ticket").hide();
			$("#btn_schedule_ticket").show();
			$("#schedule_type").show();
			$("#hr").show();	
			$("#br").show();
			<?php if($scedule_type !=0){ ?>
			$("#end_dt").show();	
			<?php }
			if($scedule_type == 1){ ?>
			$("#vis_daily").show();
	 <?php } if($scedule_type == 2){ ?>
			$("#vis_weekly").show();
	 <?php } } ?>
	
	function show_hide_enddate(){ 
		if($("#vis_set_schedule").val()==0){ 
			$("#end_dt").hide();	
		}else{
			$("#end_dt").show();	
		}
	}	
	$("#vis_schedule_ticket").click(function(){
		if($("#vis_schedule_ticket:checked").val()){ 
			$("#btn_drafts_ticket").hide();
			$("#btn_add_ticket").hide();
			$("#btn_schedule_ticket").show();
			$("#schedule_type").show();
			$("#hr").show();
			$("#br").show();	
			$("#vis_days").show();
			$("#lbl_redmine").hide();
			
			/*$('#vis_as_client').attr('checked', false); 
			$("#vis_as_client").attr("disabled", true);*/
		}else{ 
			$("#btn_drafts_ticket").show();
			$("#btn_add_ticket").show();
			$("#btn_schedule_ticket").hide();
			$("#schedule_type").hide();	
			$("#hr").hide();	
			$("#br").hide();
			$("#vis_days").hide();	
			$("#lbl_redmine").show();
			/*$("#vis_as_client").removeAttr("disabled");*/		
		}
		
	});	
		
	
	$('.start').datetimepicker({
        format: "<?php echo VIS_DATETIMEPICKER_FORMAT;?>"
	});	
	 $('#vis_set_schedule').on('change',function(){
		var val=$("#vis_set_schedule").val();
		if(val=='1') $('#vis_daily').show(); else $('#vis_daily').hide();
		if(val=='2') $('#vis_weekly').show(); else $('#vis_weekly').hide();
   });
	
	
    $(".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 $operation['ticket_id'];?>&vis_tab=1');    }
        };
    };
    <?php }?>
    
				
            $('#vis_ticket_post_0').redactor({
				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",
                fileUpload:  "index.php?vis_tmpst="+new Date().getTime()+"&vis_module=ticket&vis_operation=upload_file&vis_static_area=editor_file_upload", 
                imageUploadParam: 'files',
                deniedTags: ['html', 'head', 'link', 'body', 'meta', 'script','applet'],
				linkify: false,
                plugins: ['source','drive'],
            });
			$(".redactor-toolbar").attr('z-index', '3 !important');
			
			
        });
<? } ?>
    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']?>");
      }
    }    
    function vis_remove_attachment(ticket_id, attach_location, vis_id) {
        var loc = '';
        loc = (attach_location != "" && typeof (attach_location) != "undefined") ? attach_location : "vis_attachments";
        $("#" + loc).val($("#" + loc).val().replace(ticket_id + ',', ''));
    }
	function vis_remove_ci_attachment(ticket_id){
		var attach_modi_val =$("#vis_ci_attach").val().replace(ticket_id + ',', '');
		if(attach_modi_val=='')$(".attach_ci_div").css("display", "none");
		$("#vis_ci_attach").val( attach_modi_val);
		var attach_ci_btn = '<a href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=cmdb&vis_operation=attach_ci&vis_static_area=vis_add_cito_ticket&vis_department=<? echo $vis_department_id; ?>&attached_ci_ids='+attach_modi_val+'" class="link text-primary v-middle"><?=$vis_language['TXTATTACHCI']?></a>';
		$('#vis_select_cit_btn').html(attach_ci_btn);
	}
	function get_subcategory(catid,subcatid,isCategoryChange) {
	  <? if(isset($module_setting['vis_subcategory'])){ ?>
	  if(isCategoryChange ==1)getitem();
	  $('#ajax_subcategory').visExecution('load_operations', {'vis_module':'staff', 'vis_operation':'get_ticket_drp_subcategory', 'vis_category_id':catid, 'vis_flag':'ticket','vis_subcategory_id':subcatid}); 
	  <? }?>
    }
	function getitem(subcatid,itemid) {
	   <? if(isset($module_setting['vis_item'])){ ?>
	  $('#ajax_item').visExecution('load_operations', {'vis_module':'staff', 'vis_operation':'get_ticket_drp_item', 'vis_subcategory_id':subcatid, 'vis_flag':'ticket','vis_itemid':itemid}); 
	  <? }?>
    }
	
	function get_vt_status(integration_id) {
	  $('#ajax_vt').visExecution('load_operations', {'vis_module':'ticket', 'vis_operation':'vt_status', 'vis_integration_id':integration_id}); 
	 
    }
				
		
				

 

</script>
<script src="<?= VIS_PATH_SCRIPT; ?>file-input/bootstrap-filestyle.min.js"></script>
	
