<script src="<?= VIS_PATH_SCRIPT; ?>file-input/bootstrap-filestyle.min.js"></script>
<style>#customfi [class*="col"]{ padding:0 15px 0 15px;}</style>
<? global $vis_language;
   $schedule=array(0=>'Never', 1=>'Daily', 2=>'Weekly', 3=>'Monthly',4=>'Yearly');
   $status=array(1 => $vis_language['TXTINPROGRESS'],2 => $vis_language['TXTOVERDUE'],3 => $vis_language['TXTCOMPLETED'],4 => $vis_language['TXTCANCELED'],5 =>$vis_language['TXTNOTSTARTED']);
   ?>
<section id="breadcrumb" class="row m-b m-l-none m-r-none">
   <div class="col-sm-6">
      <h3 class="m-b-xs text-black"><? echo $vis_language['TXTTASKS']; ?> </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><a  class="link" href="#/home/view_tasks/<? echo $vis_language['TXTTASKS']; ?>/1"  ><? echo $vis_language['TXTTASKS'] ?></a> </li>
         <li class="active"><? echo $vis_language['TXTUPDATETASK']; ?> </li>
      </ul>
   </div>
</section>
<section class="padder">
   <section class="panel panel-default">
      <header class="panel-heading sub_header"><?echo $vis_language['TXTUPDATETASK']?></header>
      <section class="col-sm-12 bg-white">
         <form name="vis_task_update_form" id="vis_task_update_form" class="form-horizontal" method="post">
            <section class="no-borders no-gutter no-radius">
               <div class="panel-body">
                   <div class="btn-group">
                   <? if($newly_added_task_details['image']=='' || $newly_added_task_details['image']=='default.jpg'){?>
                   <div class="l-avatar m-r">
                   <? if($newly_added_task_details['name']!=''){
$namearr=explode(' ',$newly_added_task_details['name']);
$fullname='';
if($newly_added_task_details['first_name']!=''){ 
$lastname=preg_split('//u', $newly_added_task_details['last_name'], -1, PREG_SPLIT_NO_EMPTY); 
$firstname=preg_split('//u', $newly_added_task_details['first_name'], -1, PREG_SPLIT_NO_EMPTY);
$fullname=ucfirst($firstname[0]).ucfirst($lastname[0]);
}else{
	$firstname=preg_split('//u', $namearr[0], -1, PREG_SPLIT_NO_EMPTY);
	$fullname=ucfirst($firstname[0]);
}
																				?>
    <div class="md"><? echo $fullname; ?></div>
    <? }else{ ?>
    <img class="md img-circle" src="<?= VIS_PATH_PROFILE.'default.jpg';?>">
    <? }?>
                  
                    </div>
      										<? }else{?>
              <div class="l-avatar m-r">
               <img src="<? echo VIS_PATH_PROFILE; echo $newly_added_task_details['image']; ?>" class="md img-circle">
                 </div>
      									<? }?>
						<!--	<a href="#" class="thumb-md m-r">
								<img src="<? //echo VIS_PATH_PROFILE; echo ($newly_added_task_details['image']=='')?'default.jpg':$newly_added_task_details['image']; ?>"  class="img-circle"/>
							</a>	  -->
							  </div>
							   <div class="btn-group">
								<div class="m-r-md"><? echo $vis_language['TXTCREATEDBY']; ?> : <a class="text-md link" href="#/home/profile_view/<? echo $vis_language['TXTPROFILE'];?><?= ($newly_added_task_details['staff_id'] != VIS_STAFF_ID) ? '/'.$newly_added_task_details['staff_id'] : '';?>"><? echo $newly_added_task_details['name']; ?></a></div>
								  <label class="m-r-sm"><? echo $vis_language['TXTSTATUS']; ?></label>
								  <?if($newly_added_task_details['enddate_diff']<=0){ if($newly_added_task_details['task_status']!=3 && $newly_added_task_details['task_status']!=4){?>
									<label id="vis_task_status" class="btn-xs wrapper-xxs vh-danger-bg m-t-xs" ><? echo $vis_language['TXTOVERDUE']; ?></label>
									<?} else
									{ if($newly_added_task_details['task_status']==1) {?>
									<label id="vis_task_status" class="btn-xs wrapper-xxs vh-success-bg m-t-xs"><? echo $status[$newly_added_task_details['task_status']]; ?></label>
									<?}else if($newly_added_task_details['task_status']==3){?>
									<label id="vis_task_status" class="btn-xs wrapper-xxs vh-info-bg m-t-xs"><? echo $status[$newly_added_task_details['task_status']]; ?></label>
									<?}else if($newly_added_task_details['task_status']==4){ ?>
									<label id="vis_task_status" class="btn-xs wrapper-xxs vh-grey-bg m-t-xs"><? echo $status[$newly_added_task_details['task_status']]; ?></label><? }} ?>
									<?}else { if($newly_added_task_details['task_status']==1) {?>
									<label id="vis_task_status" class="btn-xs wrapper-xxs vh-success-bg m-t-xs"><? echo $status[$newly_added_task_details['task_status']]; ?></label>
									<?}else if($newly_added_task_details['task_status']==3){?>
									<label id="vis_task_status" class="btn-xs wrapper-xxs vh-info-bg m-t-xs"><? echo $status[$newly_added_task_details['task_status']]; ?></label>
									<?}else if($newly_added_task_details['task_status']==4){ ?>
									<label id="vis_task_status" class="btn-xs wrapper-xxs vh-grey-bg m-t-xs"><? echo $status[$newly_added_task_details['task_status']]; ?></label>
									<?}else if($newly_added_task_details['task_status']==5){ ?>
									<label id="vis_task_status" class="btn-xs wrapper-xxs label label-default m-t-xs"><? echo $status[$newly_added_task_details['task_status']]; ?></label><? }} ?>
								</div>
								 <?if($newly_added_task_details['parent_id']>0 && $newly_added_task_details['is_repeat']!=1) { ?>
									<div class="btn-group pull-right m-t-md">
										<label for="taskTitle" class="m-r-xs"><? echo $vis_language['TXTCHILDOF']; ?></label>
										<a class="text-md link" href="javascript:void(0);" onclick="$('#vis_workpanel_div').visExecution('load_module','<?= $parent_task_details['task_title'].'/'.$parent_task_details['task_id']?>',{'vis_module':'home', 'vis_operation':'view_update_tasks', 'vis_form':'vis_task_form'  ,'vis_filter_id':'<? echo $operation['filter_id'];?>','vis_task_id':'<? echo $parent_task_details['task_id'];?>'})"><? echo $parent_task_details['task_title']; ?></a>
									</div><? } ?>
								 <?if($newly_added_task_details['parent_id']==0 && $child_task_details[0]['total']>0) { ?>
								<div class="btn-group pull-right m-t-md">
									<button class="btn btn-default btn-xs btn-rounded" id="close"><? echo ($newly_added_task_details['task_repeat_schedule']==0 || $newly_added_task_details['task_repeat_schedule']==NULL)?$vis_language['TXTSUBTASK']:$vis_language['TXTRECURSIVETASK']; ?> (<? echo $child_task_details[0]['total'];?>)</button>
								</div><? } ?>
								<div id="vis_subtasks" class="wrapper-sm m-b-none m-t" style="display:none;">
									<? $tbl_data='';
										if($child_task_details[1]!=-1){?>
											<table class="table table-hover b-t b-light m-b-none" id="table_ticket_relation">
																<thead class="table_head">
																	<tr>
																		<th></th>
																		<th><? echo $vis_language['TXTTITLE'];?></th>
																		<th><? echo $vis_language['TXTTARGATEDATE'];?></th>	
																		<th><? echo $vis_language['TXTSTATUS'];?></th>	
																		<? if($newly_added_task_details['task_repeat_schedule']==0) {?><th></th>	<? } ?>				
																	</tr>
																</thead>
											
											<?for($i=0;$i<count($child_task_details[1]);$i++){?>
												<tr>
													<td>
             <? if($child_task_details[1][$i]['image']=='' || $child_task_details[1][$i]['image']=='default.jpg'){?>
             <div class="l-avatar m-l">
             <? if($newly_added_task_details['name']!=''){
														$namearr=explode(' ',$newly_added_task_details['name']);
$fullname='';
if($newly_added_task_details['first_name']!=''){ 
$lastname=preg_split('//u', $newly_added_task_details['last_name'], -1, PREG_SPLIT_NO_EMPTY); 
$firstname=preg_split('//u', $newly_added_task_details['first_name'], -1, PREG_SPLIT_NO_EMPTY);
$fullname=ucfirst($firstname[0]).ucfirst($lastname[0]);
}else{
	$firstname=preg_split('//u', $namearr[0], -1, PREG_SPLIT_NO_EMPTY);
	$fullname=ucfirst($firstname[0]);
}
														?>
    <div class="xs"><? echo $fullname; ?></div>
    <? }else{ ?>
    <img class="xs img-circle" src="<?= VIS_PATH_PROFILE.'default.jpg';?>">
    <? }?>
             
             </div>
             <? }else{ ?>
             <div class="l-avatar m-l">
             <img src="<? echo VIS_PATH_PROFILE; echo $child_task_details[1][$i]['image']; ?>" class="xs img-circle">
             </div>
             <? }?>

             <!--<div class="avatar thumb-xs m-l"><img src="<? //echo VIS_PATH_PROFILE; echo ($child_task_details[1][$i]['image']=='')?'default.jpg':$child_task_details[1][$i]['image']; ?>"  class="img-circle"/></div>-->
             </td>
													<td width="30%"><a class="text-md link" href="javascript:void(0);" onclick="$('#vis_workpanel_div').visExecution('load_module','<?= $child_task_details[1][$i]['task_title'].'/'.$child_task_details[1][$i]['task_id']?>',{'vis_module':'home', 'vis_operation':'view_update_tasks', 'vis_form':'vis_task_form'  ,'vis_filter_id':'<? echo $operation['filter_id'];?>','vis_task_id':'<? echo $child_task_details[1][$i]['task_id'];?>'})"><? echo $child_task_details[1][$i]['task_title'];?></a></td><td><? echo format_datetime($child_task_details[1][$i]['enddate']);?></td>
													<td><?if($child_task_details[1][$i]['enddate_diff']<=0){ if($child_task_details[1][$i]['task_status']!=3 && $child_task_details[1][$i]['task_status']!=4){?>
														<label id="vis_task_status" class="btn-xs vh-danger-bg" ><? echo $vis_language['TXTOVERDUE']; ?></label>
														<?} else
														{ if($child_task_details[1][$i]['task_status']==1) {?>
														<label id="vis_task_status" class="btn-xs vh-success-bg"><? echo $status[$child_task_details[1][$i]['task_status']]; ?></label>
														<?}else if($child_task_details[1][$i]['task_status']==3){?>
														<label id="vis_task_status" class="btn-xs vh-info-bg"><? echo $status[$child_task_details[1][$i]['task_status']]; ?></label>
														<?}else if($child_task_details[1][$i]['task_status']==4){ ?>
														<label id="vis_task_status" class="btn-xs vh-grey-bg"><? echo $status[$child_task_details[1][$i]['task_status']]; ?></label><? }} ?>
														<?}else { if($child_task_details[1][$i]['task_status']==1) {?>
														<label id="vis_task_status" class="btn-xs vh-success-bg"><? echo $status[$child_task_details[1][$i]['task_status']]; ?></label>
														<?}else if($child_task_details[1][$i]['task_status']==3){?>
														<label id="vis_task_status" class="btn-xs vh-info-bg"><? echo $status[$child_task_details[1][$i]['task_status']]; ?></label>
														<?}else if($child_task_details[1][$i]['task_status']==4){ ?>
														<label id="vis_task_status" class="btn-xs vh-grey-bg"><? echo $status[$child_task_details[1][$i]['task_status']]; ?></label>
														<?}else if($child_task_details[1][$i]['task_status']==5){ ?>
														<label id="vis_task_status" class="btn-xs label label-default"><? echo $status[$child_task_details[1][$i]['task_status']]; ?></label><? }} ?>
													</td><? if($child_task_details[1][$i]['is_repeat']==0) {?><td><a href="javascript:void(0);" class="link" data-toggle="ajaxModal" data-modal-arguments="vis_module=home&vis_operation=confirm_detach_subtask&vis_static_area=vis_subtask_area&vis_task_id=<? echo $child_task_details[1][$i]['task_id']; ?>&vis_parent_id=<? echo $newly_added_task_details['task_id']; ?>"><? echo $vis_language['TXTDETACH']; ?></a></td><? } ?></tr>
											<?}?></table>
										<?}?>
								</div>
                  <div class="wrapper">
                     <div class="form-group">
                        <label for="taskTitle"><? echo $vis_language['TXTTASKTITLE']; ?></label>
                        <input type="text" class="form-control" id="vis_tasktitle" name="vis_tasktitle" placeholder="<? echo $vis_language['TXTENTERTASKTITLE']; ?>" value="<? echo htmlentities($newly_added_task_details['task_title'], ENT_COMPAT, 'UTF-8');?>">
                     </div>
                     <div class="form-group">
                        <label for="taskDescription"><? echo $vis_language['TXTDESCRIPTION'];?></label>
                        <textarea class="form-control" rows="2" data-minwords="6" id="vis_task_description" name="vis_task_description" placeholder="<?= $vis_language['TXTADDTASKDESCRIPTION']?>" ><? echo $newly_added_task_details['description'];?></textarea>
                     </div>
                     <div class="row">
                        <div class="wrapper">
                           <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_task_priority" name="vis_task_priority">
                                    <option value="1" <? echo ($newly_added_task_details['priority']==1)?' selected="selected"':''; ?>><? echo $vis_language['TXTLOW'];?></option>
                                    <option value="2" <? echo ($newly_added_task_details['priority']==2)?' selected="selected"':''; ?>><? echo $vis_language['TXTMEDIUM'];?></option>
                                    <option value="3" <? echo ($newly_added_task_details['priority']==3)?' selected="selected"':''; ?>><? echo $vis_language['TXTHIGH'];?></option>
                                 </select>
                              </div>
                           </div>
                           <div class="col-xs-4">
                              <div class="form-group col-xs-10">
                                 <label for="taskStartdate"><? echo $vis_language['TXTSTARTDATE'];?></label>
                               <span class="input-group-addon no-padder no-borders start">  <input class="input-sm form-control" id="vis_task_start_date" name="vis_task_start_date" size="16" type="text" placeholder="<?php echo strtoupper(VIS_DATETIME_FORMAT);?>" value="<?= date(VIS_DATETIME_FORMAT, ($newly_added_task_details['startdate']+VIS_TIMEZONE)); ?>"></span>
                              </div>
                           </div>
                           <div class="col-xs-4">
                              <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_task_end_date" name="vis_task_end_date" size="16" type="text" placeholder="<?php echo strtoupper(VIS_DATETIME_FORMAT);?>" value="<?= date(VIS_DATETIME_FORMAT, ($newly_added_task_details['enddate']+VIS_TIMEZONE)); ?>"></span>
                              </div>
                           </div>
                        </div>
                     </div>
                     <? if(($newly_added_task_details['parent_id']==0 && $get_sub_task_total==0) || $get_recursive_task_total>0){ ?>
                     <div class="row">
                        <div class="col-xs-4">
                           <? /* ?><a href="#taskrepeat" id="vis_task_repeat" class="link" data-toggle="class:show animated fadeInRight"><i class="vh vh-stopwatch"></i> <? echo $vis_language['TXTREPEAT'];?> <? echo $schedule[$newly_added_task_details['task_repeat_schedule']];?></a><? */ ?>
						   <a href="#taskrepeat" id="vis_task_repeat" class="link" data-toggle="class:show"><i class="vh vh-stopwatch"></i> <? echo $vis_language['TXTREPEAT'];?> <? echo $schedule[$newly_added_task_details['task_repeat_schedule']];?></a>
                           <?if($newly_added_task_details['task_repeat_schedule']!=0 && $occurance!=''){?>
                           <p class="text-muted"><?= $occurance;?> <? echo $vis_language['TXTOCCURANCELEFT'];?></p>
                           <? } ?>
                        </div>
                     </div>
                     <div class="hide" id="taskrepeat" >
                        <div class="row">
                           <div class="wrapper">
                              <div class="col-xs-4">
                                 <div class="form-group col-xs-10">
                                    <label for="taskPriority"><? echo $vis_language['TXTSETSCHEDULE'];?></label>
                                    <select class="form-control input-sm selectpicker" id="vis_set_schedule" name="vis_set_schedule">
                                    <?
                                       for($i=0;$i<count($schedule);$i++) {
                                       if($newly_added_task_details['task_repeat_schedule'] == $i) $selected='selected="selected"'; else $selected='';
                                       echo '<option value="'.$i.'" '.$selected.' >'.$schedule[$i].'</option>'; } ?>
                                    </select>
                                 </div>
                              </div>
                              <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_task_details['task_repeat_occurence']);?>
                                    <div class="checkbox i-checks m-r-lg pull-left p-d-sm"> <label>
                                       <input type="checkbox" <? if($repeat_daily[0]==1) echo 'checked="checked"'; else echo '';?><? if($newly_added_task_details['task_repeat_occurence']!=1)  echo 'checked="checked"';?> 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" <? if($repeat_daily[1]==1) echo 'checked="checked"'; else echo '';?> <? if($newly_added_task_details['task_repeat_occurence']!=1)  echo 'checked="checked"';?>  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" <? if($repeat_daily[2]==1) echo 'checked="checked"'; else echo '';?><? if($newly_added_task_details['task_repeat_occurence']!=1)  echo 'checked="checked"';?>  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" <? if($repeat_daily[3]==1) echo 'checked="checked"'; else echo '';?> <? if($newly_added_task_details['task_repeat_occurence']!=1)  echo 'checked="checked"';?>  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" <? if($repeat_daily[4]==1) echo 'checked="checked"'; else echo '';?><? if($newly_added_task_details['task_repeat_occurence']!=1)  echo 'checked="checked"';?>  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" <? if($repeat_daily[5]==1) echo 'checked="checked"'; else echo '';?> <? if($newly_added_task_details['task_repeat_occurence']!=1)  echo 'checked="checked"';?>  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" <? if($repeat_daily[6]==1) echo 'checked="checked"'; else echo '';?> <? if($newly_added_task_details['task_repeat_occurence']!=1)  echo 'checked="checked"';?>  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" <? if($newly_added_task_details['task_repeat_occurence']==2) echo ' checked="checked"'; ?> checked="checked" value="2" 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" <? if($newly_added_task_details['task_repeat_occurence']==3) echo ' checked="checked"'; ?> value="3" 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" <? if($newly_added_task_details['task_repeat_occurence']==4) echo ' checked="checked"'; ?> value="4" 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" <? if($newly_added_task_details['task_repeat_occurence']==5) echo ' checked="checked"'; ?> value="5" 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" <? if($newly_added_task_details['task_repeat_occurence']==6) echo ' checked="checked"'; ?> value="6" 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" <? if($newly_added_task_details['task_repeat_occurence']==7) echo ' checked="checked"'; ?> value="7" 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" <? if($newly_added_task_details['task_repeat_occurence']==8) echo ' checked="checked"'; ?> value="8" id="vis_weekly7" name="vis_weekly"/><i></i><? echo $vis_language['TXTSATURDAY']; ?></label>
                                    </div>
                                 </div>
                              </div>
                           </div>
                        </div>
                     </div><? } ?>
                     <div class="row">
                        <div class="wrapper">
                           <div class="form-group">
                              <label for="taskTitle"><? echo $vis_language['TXTASSIGNTO']; ?></label>
                              <input type="text" class="form-control" id="vis_assignto" name="vis_assignto" placeholder="<? echo $vis_language['TXTSEARCHSTAFF'];?>" data-resize="no">
                              <script type="text/javascript">
                                 $(document).ready(function() {
                                 	$("#vis_assignto").tokenInput(
                                 		"index.php?vis_module=staff&vis_operation=staff_listing&vis_task_assign=1&vis_task_owner_id=<?= $newly_added_task_details['staff_id']; ?>",
                                 		{
                                 			theme: "facebook",
                                 			searchDelay: 300,
                                 			minChars: 1,
                                 			queryParam: "vis_data",
                                 			preventDuplicates: true,
                                 			propertyToSearch: "full_name",
                                 			tokenValue: "full_name",
                                 			searchingText: "<? echo $vis_language['MSGSEARCHING']."..."; ?>",
                                 			noResultsText: "<? echo $vis_language['TXTNOMATCHFOUND']; ?>",
                                 			resultsFormatter: function(item){
                                 			if(item.type=="heading"){
                                 				return "<b>" + "<div style='cursor:pointer;display: inline-block; padding-left: 10px;'><div class='full_name'>" + item.full_name + "</div></div></b>"
                                 			}
                                 			else{ return "<li>" + "<div style='display: inline-block; padding-left: 10px;margin-left:30px;'><div class='full_name'>" + item.full_name + "</div></div></li>"	} },
                                 			tokenFormatter: function(item) { if(item.id){$('#vis_task_grp_share').val($('#vis_task_grp_share').val()+item.id+',');}return "<li><p>" + item.full_name + "</p></li>" },
                                 			onDelete: function(item){
                                 if(item.id)
                                 {
                                 var staffs = $('#vis_task_grp_share').val();
                                 var old_staffs = $('#vis_old_staff').val();
                                 var Staffs1 = old_staffs.replace(item.id+',', '');
                                 $('#vis_old_staff').val(Staffs1);
                                 var newStaffs = staffs.replace(item.id+',', '');
                                 $('#vis_task_grp_share').val(newStaffs);

                                 }
                                 else
                                 {
                                 var staffs = $('#vis_task_share').val();
                                 var staffIds = $('#vis_staff').val();
                                 var newStaffs = staffs.replace(item.id+',', '');
                                 $('#vis_task_share').val(newStaffs);
                                 $('#vis_staff').val(newStaffs);
                                 }
                                 },
                                 onAdd: function(item)
                                 {
                                 if(item.type == "heading")
                                 {
                                 $("#vis_assignto").tokenInput("remove", {full_name: item.full_name});
                                 }
                                 }
                                 		}
                                 	);
                                 	<? if($assign_task_details!=-1) for($i=0 ; $i<count($assign_task_details); $i++){?>
                                 		$("#vis_assignto").tokenInput("add", {id: "<?= $assign_task_details[$i]['owner_id']; ?>", full_name: "<?= $assign_task_details[$i]['first_name']." ".$assign_task_details[$i]['last_name']; ?>"});<? } ?>
                                 });
                              </script>
                              <input type="hidden" id="vis_task_grp_share" name="vis_task_grp_share"/>
                              <input type="hidden" id="vis_task_share" name="vis_task_share"/>
                              <input type="hidden" id="vis_staff" name="vis_staff" value=""/>
                              <input type="hidden" id="vis_old_staff" name="vis_old_staff" value="<?echo $old_staff;?>"/>
                           </div>
                        </div>
                     </div>
					 <? #----------- Ticket attached blck starts here ------------- ?>
					 
					<div class="row">
						<!-- <div class="wrapper"> -->
								<div class="btn-group">
                                   <div class="btn btn-default btn-xs btn-rounded" onclick="task_tickets();" ><? echo $vis_language['TXTTICKET']. ' ('.$total_task_tickets.')'; ?>
								</div>
								</div>
						<!-- </div> -->
						<input type="hidden" value="0" id="ticket_tasks_hidden" name="ticket_tasks_hidden">
					</div> 
					<div class="row task_tickets" >
					
					    <!-- TICKET LISt -->
						
						<div  class="wrapper-sm m-b-none m-t">
						<?php if($total_task_tickets>0){
			for($i=0;$i<$total_task_tickets;$i++){?>
								<div class="row">
									<div class="col-sm-4 m-t-xs">
										<span class="m-l-sm"><a class="link m-l-xs" href="#/ticket/ticket_details/<? echo $task_ticket_data[$i]['ticket_hash'];?>/<? echo $task_ticket_data[$i]['ticket_id'];?>" title=""><? echo $task_ticket_data[$i]['ticket_hash'];?></a></span>
										<span class="m-l-sm"><? echo $task_ticket_data[$i]['subject'];?></span>
									</div>
									<div class="col-sm-3 m-t-xs">
										<span class="m-l-sm"><? echo $task_ticket_data[$i]['domain_name'].' : '.$task_ticket_data[$i]['department_name'];?></span>
									</div>
									<div class="col-sm-2 m-t-xs">
									   <label><? echo $vis_language['TXTPRIORITY']; ?></label>
									   <span class="m-l-sm"><? echo $task_ticket_data[$i]['ticket_priority'];?></span>
									</div>
									<div class="col-sm-2 m-t-xs">
									   <label><? echo $vis_language['TXTSTATUS']; ?></label>
									   <span class="m-l-sm"><? echo $task_ticket_data[$i]['ticket_status'];?></span>
									</div>
									
								</div>
			<? }
						} else { ?>
								<div class="row">
								<? echo "    No tickets attached ";
								
								//include(VIS_PATH_TEMPLATE.'no_record_yet.php');
								?>
								
								</div>
						     <? } ?>
							</div><!-- class="wrapper-sm m-b-none m-t" END HERE  -->	
						<!-- TICKET LIST  -->
					 
					</div>
					
					 <? #----------- Ticket attached blck end here ------------- ?>
					 
					 
					 
                     <!----------------- Newly added div ---------------->
                     <?
					 if($custom_field_var!=''){
						?>
						<div class="row">
							<div class="wrapper" id="customfi">
								<div class="form-group">
									<? echo $custom_field_var;?>
                                    <input type="hidden" name="vis_add_tsk" id="vis_add_tsk" value="1" />
                                    <input type="hidden" id="vis_department" name="vis_department" value="<? echo $departmentid;?>"/>
							   	</div>
							</div>
						</div>
                     	<? 
					 } 
					 ?>
                     <!-------------------------------------------------->
                     <div class="row">
                     	<div class="wrapper">
                           <div class="col-xs-12">
                           		<div class="form-group">
                                	<label for="taskTitle"><? echo $vis_language['TXTASSIGNTEAM']; ?></label>
                                    <div class="dept_access_list m-b">
										<?
										if($get_groups!=-1){
											for($i=0;$i<count($get_groups);$i++){
												?>
												<label class="checkbox-inline i-checks">
												<input type="checkbox" <? echo $chk;?> id="vis_groupnames_<? echo ($i+1);?>" name="vis_groupname[]" value="<? echo $get_groups[$i]['group_id'];?>"/>
												<i></i><? echo $get_groups[$i]['group_name']; ?></label>
												<br/><?
											}
										}
                                      ?>
                                    </div>
                                </div>
                           </div>
                        </div>
                     </div>
                     
                     <div class="row">
                        <div class="wrapper">
                           <div class="col-xs-4">
                              <div class="form-group col-xs-10">
                                 <label for="taskPriority"><? echo $vis_language['TXTSTATUS'];?></label>
                                 <select id="vis_task_status" name="vis_task_status" class="form-control selectpicker" onchange="$('#vis_workpanel_div').visExecution('load_operations', {'vis_module':'home', 'vis_operation':'update_task_status_by_assign_user', 'vis_form':'vis_task_update_form','vis_filter_id':'<? echo ($operation['filter_id']!='')?$operation['filter_id']:'1';?>','vis_tasktitle':'<?= $newly_added_task_details['task_title'];?>'});">
                                	<option value=""><?= $vis_language['TXTSELECT']; ?></option>
                                    <option value="1" <? echo ($newly_added_task_details['task_status']==4)?' selected="selected"':''; ?>><? echo $vis_language['TXTMARKASCANCEL'];?></option>
                                    <option value="2" <? echo ($newly_added_task_details['task_status']==3)?' selected="selected"':''; ?>><? echo $vis_language['TXTMARKASCOMPLETE'];?></option>
                                 </select>
                              </div>
                           </div>
                           <div class="col-xs-8">
                              <div class="form-group m-t text-right">
								 <input type="hidden" name="vis_task_id" value="<? echo $newly_added_task_details['task_id']; ?>" />
								  <input type="hidden" name="vis_parent_id" value="<? echo $newly_added_task_details['parent_id']; ?>" />
                                 <button type="button" class="btn vh-danger-bg" id="del" onclick="<?if($newly_added_task_details['staff_id']==VIS_STAFF_ID){ ?>task_delete('<? echo $newly_added_task_details['task_id'];?>','<? echo ($operation['filter_id']!='')?$operation['filter_id']:'1';?>') <?} else {?> $('#vis_global_msg_div').visInterface('load_global_message', '<? echo $vis_language['MSGACCSSDND'];?>')<? } ?>"><? echo $vis_language['TXTDELETE'];?></button>
                                 <button type="button" class="btn btn-primary" onclick="<?if($newly_added_task_details['staff_id']==VIS_STAFF_ID){ ?>$('#vis_workpanel_div').visExecution('submit_form',{'vis_module':'home', 'vis_operation':'update_task', 'vis_form':'vis_task_update_form','vis_filter_id':'<? echo ($operation['filter_id']!='')?$operation['filter_id']:'1';?>'});<?} else {?> $('#vis_global_msg_div').visInterface('load_global_message', '<? echo $vis_language['MSGACCSSDND'];?>')<? } ?>"><? echo $vis_language['TXTUPDATE'];?></button>
                              </div>
                           </div>
                        </div>
                     </div>
                  <div class="line line-dashed b-b line-lg pull-in"></div>
                  <!-- comment section start -->
                  <div id="vis_comment_list">
                     <? if($get_task_comment != -1){
                        include(VIS_PATH_TEMPLATE."task_comment_list.php");
                          }?>
                  </div>
                  <!-- comment section end -->
                  <input type="hidden" id="vis_set_task_repeat" name="vis_set_task_repeat" value="0" />
                  <input type="hidden" id="vis_filter_id" name="vis_filter_id" value="<? echo $operation['filter_id'];?>"/>
                  <input type="hidden" id="vis_task_staff_id" name="vis_task_staff_id" value="<? echo $newly_added_task_details['staff_id'];?>"/>
               </div>
               </div>
               </div>
            </section>
         </form>
      </section>
   </section>
</section>
<script>
$('.task_tickets').hide();

$('.start').datetimepicker({
        format: "<?php echo VIS_DATETIMEPICKER_FORMAT;?>"
	});
   function vis_remove_attachment(attach_id){
   $.ajax({
   	url: 'index.php',
   	data: {'vis_module':"ticket", 'vis_operation':"remove_attachment", 'vis_attachment_id':attach_id },
   	type: "POST",
   	success: function(data) {  }
   });
   var attachments=$("#vis_attachment_count").val();
   $("#vis_attachment_count").val(eval(parseInt(attachments)-1));
   var attachmentsCnt=$("#vis_attachment_count").val();
   if((attachmentsCnt==0)) $("#attachedMedia").css('display','none');
   }
   $('#vis_task_repeat').on('click',function(){
   	var cn = document.getElementById("taskrepeat").className;
   	if(cn.search("show")!=-1)
   	$("#vis_set_task_repeat").val('0');
   	else
   	$("#vis_set_task_repeat").val('1');
   });
    $(document).ready(function(){
   	$('#attachedMedia').hide();
   	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();
   });
   $('#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();
   
   $('#close').click(function (e) {
        e.preventDefault();
        $('#vis_subtasks').slideToggle();
    });
    function task_delete(task_id,filter_id)
    {
		$('#del').attr('data-toggle','ajaxModal');
		$('#del').attr('data-modal-arguments','vis_module=home&vis_operation=get_delete_task&vis_task_id='+task_id+'&vis_filter_id='+filter_id+'&vis_static_area=vis_task_delete_area');
	}
	function task_tickets()
	{
		var show_value=$('#ticket_tasks_hidden').val();
		if(show_value==0)
		{
			$('.task_tickets').show();
			$('#ticket_tasks_hidden').val(1);
		}
		else
		{
			$('.task_tickets').hide();
			$('#ticket_tasks_hidden').val(0);
		}
	}
	

</script>
