<? if(isset($firstimeload)){
	 if($firstimeload==1 || $firstimeload==2){
	?>
    <a id="firsttimel" href="javascript:void(0);" data-backdrop="static" data-keyboard="false" data-toggle="ajaxModal" data-modal-arguments="vis_module=staff&amp;vis_operation=first_time_login&amp;vis_static_area=vis_open_new_dialog"></a>
    <script type="application/javascript">$(document).ready(function(){ $("#firsttimel").trigger("click");  }); </script>
    
<? }else if($firstimeload==3){ ?> 
<script type="text/javascript">
function vis_update_first_login_intro(){
	var data = {'vis_firstlogin':'0' };
    $.ajax({
		url: 'index.php?vis_module=home&vis_operation=update_firsttime_status',
		data: data,
		type: "POST",
		dataType: "json",
		success: function(data) {
			//alert(data.vis_result);
			loadtips();
		},
		error: function(xhr, ajaxOptions, thrownError) {$("#vis_global_msg_div").visInterface("load_global_message", "Error: "+xhr.status+" - "+thrownError);}
	});
}

function loadintos(){
+function ($) {
  $(function(){
    var intro = introJs();
    intro.setOptions({
      steps: [
      {
			element: '#ticketmenu',
			intro: '<div class="h5 text-uc introhead">Filters</div><p>This section shows a list of default and custom ticket filters, you can create custom filters from Inbox >> Advance search section.</p>',
			position: 'bottom'
        },
		{
          element: '#homenav',
          intro: '<div class="h5 text-uc introhead">Dashboard</div><p>This section shows quick summary of tickets, customer, tasks and few other modules. It also shows list of staff members that are currently signed in. Additionally it shows ticket activity tree.</p>',
          position: 'bottom'
        },
		{
          element: '#inboxnav',
          intro: '<div class="h5 text-uc introhead">Inbox</div><p>From inbox section you can manage all ticket related activity, Optionally you can filter the ticket list using left panel department and ticket status tree.</p>',
          position: 'bottom'
        },
		{
          element: '#clientnav',
          intro: '<div class="h5 text-uc introhead">Clients</div><p>Under clients section you can manage end users and their profile. You can track each customer’s tickets, their organization details and their sub contacts.</p>',
          position: 'bottom'
        },
		{
          element: '#toolbardiv',
          intro: '<div class="h5 text-uc introhead">Modules</div><p>Vision Helpdesk offers several modules, like blabby, solutions, tasks, billing, reports and more. From this section you can jump to respective module pages.</p>',
          position: 'bottom'
        },
		{
          element: '#vis_global_searchbar',
          intro: '<div class="h5 text-uc introhead">Quick Search</div><p>Here you can search tickets with its hash, subject, customers with their name and email address.</p>',
          position: 'bottom'
        },
        {
          element: '#newdiv',
          intro: '<div class="h5 text-uc introhead">+New</div><p>This section allows you to create new ticket, add client and more.</p>',
          position: 'bottom'
        },
		{
          element: '#vis_notify_container',
          intro: '<div class="h5 text-uc introhead">Notification</div><p>You should see new ticket, new client and various module alerts in this section.</p>',
          position: 'left'
        },
        {
          element: '#vis_top_user_detail_menu',
          intro: '<div class="h5 text-uc introhead">Staff Profile</div><p>Staff can manage their profile, create email alert rules, set ticket listing views and manage macros from this section.</p>',
          position: 'left'
        },
		{
          element: '#setingdiv',
          intro: '<div class="h5 text-uc introhead">Admin Settings</div><p>This section is visible to admin users only and it allows admin users to manage admin settings.</p>',
          position: 'left'
        }
		
      ],
      showBullets: false,
	  keyboardNavigation:false,
	  exitOnOverlayClick:false,
	  showStepNumbers:false,
    });

    intro.start();
  });
  
  /*start*/ 
 setInterval(function () {
    $(".introjs-helperLayer").css("border-color", function () {
        this.switch = !this.switch
        return this.switch ? "#ffff00" : ""
    });
	$(".top").attr("class", function () {
        this.switch = !this.switch
        return this.switch ? "topfade introjs-arrow top" : "introjs-arrow top"
    });
}, 300);
 /*end*/ 
 
}(jQuery);
vis_update_first_login_intro();
}

loadintos();
</script>
<? }}?>
<?  global $vis_language;
    $operationsTicket = array ( 0  => $vis_language['MSGNEWTKTCRT'], 
								1  => $vis_language['MSGTKTRPLD'], 
								2  => $vis_language['MSGSTSUPD'], 
								3  => $vis_language['MSGPRIOUPD'], 
								4  => $vis_language['MSGDEPTCHNG'], 
								5  => $vis_language['MSGTKTTYPCHG'], 
								6  => $vis_language['MSGFLGCHG'], 
								7  => $vis_language['MSGTKTASSIG'], 
								8  => $vis_language['MSGTKTTRSH'], 
								9  => $vis_language['MSGTKTTRSH'], 
								10 => $vis_language['MSGTKTMRGD'], 
								11 => $vis_language['MSGTKTFRWD'], 
								12 => $vis_language['MSGTKTDELETED'], 
								13 => $vis_language['MSGSLACHG'], 
								14 => $vis_language['MSGSPAMMRK'], 
								15 => $vis_language['MSGUNSPAM'],
								16 => $vis_language['MSGTASKLINKED'],
								17 => $vis_language['TXTDETACHEDATTACHEDTASK'],
								18 => $vis_language['MSGCILINKED'],
								19 => $vis_language['TXTDETACHCI'],
								20 => $vis_language['MSGPROBLEMLINKED'],
								22 => $vis_language['MSGCHANGESLINKED'],
								23 => $vis_language['TXTDETACHEDATTACHEDCHANGE'],
								24 => $vis_language['MSGTICKETLINKED'],
								25 => $vis_language['MSGTICKETPOSTDELETE'], 
								26 => $vis_language['MSGTICKETSPLIT'],
								29 => $vis_language['TXTADDLABEL'],
								30 => $vis_language['TXTPINNED'],
								31 => $vis_language['TXTREMOVEDLABEL'],
								33 => $vis_language['MSGTICKETNOTEADDED'],
								34 => $vis_language['MSGTICKETNOTEDELETED'],
								35 => $vis_language['MSGTICKETCOMMENTADDED'],
								36 => $vis_language['MSGTICKETCOMMENTDELETED'],
								42 => $vis_language['MSGADDEDNEWTAG'],
								43 => $vis_language['MSGTICKHASHLINK'],
								44 => $vis_language['MSGNEWSCHEDULETKTCRT'],
								45 => $vis_language['MSGTICKETLEVELCHANGED'],
								46 => $vis_language['MSGTICKETCATEGORYCHANGED'],
								47 => $vis_language['MSGTICKETSUBCATEGORYCHANGED'],
								48 => $vis_language['MSGTICKETITEMCHANGED'],
								49 => $vis_language['MSGITILLOCATIONCHANGED'],
								50 => $vis_language['TXTSLAPAUSED'],
								51 => $vis_language['TXTSLARESUMED'],
								52 => $vis_language['TXTREADTICKETFORSTAFF'],
								53 => $vis_language['TXTSENDTICKETAPPROVAL'],
								54 => $vis_language['TXTCHANGETICKETAPPROVALSTATUS']);
    $channel_colors=array(1=>'vh-brown-bg', 2=>'vh-green-bg', 3=>'vh-facebook-bgcolor', 4=>'vh-twitter-bgcolor');
    $operations = array ( 0 => $vis_language['TXTADDEDARTICLE'], 1 => $vis_language['TXTCOMMENTSUB'] );	?>
                      <div class="timeline">
                        <article class="timeline-item active">
                            <div class="timeline-caption">
                              <div class="panel bg-dark wrapper-sm lt no-borders rounded">
								  <span class="vh vh-rss vh-yellow"></span>
                                  <span class="h5 text-white"><? echo $vis_language['TXTTICKETACTIVITY']; ?></span>
                              </div>
                        </div></article>      
                        <? if($recentActivities != -1):?>	
                            <?  $cnt = $n = 0;  foreach ($recentActivities as $activity): $n++;
                            if($activity['channel_id'] == 3) { if (strpos($activity['image'], 'color')) $activity['image'] = str_replace("color","bgcolor",$activity['image']);}
                            ?>
                            <? if($cnt%5==0) $cnt=0;
                            if(($n%2)!=0) { 
                                if($activity['operation_id']==2 || $activity['operation_id']==3 || $activity['operation_id']==4 || $activity['operation_id']==5 || $activity['operation_id']==6) $activity_msg=$operationsTicket[$activity['operation_id']].' from '.$activity['old_info'].' to '.$activity['new_info'];
                                else if($activity['operation_id']==7){                          
                                    if($activity['new_info']>0)
                                        $activity_msg = $operationsTicket[$activity['operation_id']].' to '. $activity['user_info'];
                                    elseif($activity['new_info']==0 && $activity['old_info']>0)
                                        $activity_msg = $vis_language['TXTTICKETUNASSIGNEDFROM'].' '. $activity['user_info'];
                                    elseif($activity['new_info']==0) 
                                        $activity_msg = $vis_language['TXTTICKETASSIGNEDTONOBODY'];
                                    else
                                        $activity_msg = $operationsTicket[$activity['operation_id']];
                                }else if($activity['operation_id']==13){
                                    if($activity['new_info']!='' && $activity['old_info']!='')
                                        $activity_msg = $vis_language['TXTSLACHANGEDFROM'].' '. $activity['old_info']. ' to '. $activity['new_info'];
        else if($activity['old_info']=='' && $activity['new_info']!='')
            $activity_msg = $vis_language['TXTSLASETTO'].' '. $activity['new_info'];
                                        else if($activity['new_info']==0)
            $activity_msg = $vis_language['TXTAPPLIEDCUSTOMSLAPLAN'];
                                }else if($activity['operation_id']==24) {
                                    $activity_msg=$activity['old_info'].' '.$operationsTicket[$activity['operation_id']].' '.$activity['new_info'];
                                }else if($activity['operation_id']==45 || $activity['operation_id']==46 || $activity['operation_id']==47 || $activity['operation_id']==48 || $activity['operation_id']==49){
											$activity_msg = ($activity['old_info'] == '')?$operationsTicket[$activity['operation_id']].' '.$activity['old_info'].' to '.$activity['new_info']:$operationsTicket[$activity['operation_id']].' from '.$activity['old_info'].' to '.$activity['new_info'];
							   }else if($activity['operation_id']==29){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==30){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==31){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==33){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==34){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==35){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==36){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==42){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==43){ // Added by Sachin E.
							   		$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==8 && $activity['old_info']==0 && $activity['new_info']==''){ // Added by Sachin E.
									$activity_msg = $vis_language['TXTTKTMOVEINBOCFROMTRASH'];
							   }else if($activity['operation_id']==14 && $activity['old_info']==1 && $activity['new_info']==0){ // Added by Sachin E.
									$activity_msg = $vis_language['MSGUNSPAM'];				
							   }else if($activity['operation_id']==50){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']].' to '.$activity['new_info'];$activity['operator_id']=0;
							   }else if($activity['operation_id']==51){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']].' to '.$activity['new_info'];$activity['operator_id']=0;
							   }else if($activity['operation_id']==52){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==53){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']].' to '.$activity['old_info'];$activity['operator_id']=0;
							   }else if($activity['operation_id']==54){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']].' to '.$activity['old_info'];$activity['operator_id']=0;
							   }else $activity_msg=$operationsTicket[$activity['operation_id']];
								    ?>
                            <? if($activity['ticket_hash']): ?>	
                             <article class="timeline-item">
                                <div class="timeline-caption">
                                  <div class="panel panel-default">
                                    <div class="panel-body">
                                      <span class="arrow left"></span>
                                      <span class="timeline-icon"><i class="<? echo $activity['image'].' time-icon '.(($channel_colors[$activity['channel_id']]=='')?'vh-grey-bg vh-warning-bg':$channel_colors[$activity['channel_id']]); ?>"></i></span>
                                      <span class="timeline-date"><?= format_datetime($activity['entry_date']); ?></span>
                                      <div class="text-sm"><a class="link" href="#/ticket/ticket_details/<? echo $activity['ticket_hash']; ?>/<? echo $activity['ticket_id']; ?>" ><? echo $activity['ticket_hash']." : ".$activity['subject']; ?></a></div>
                                      <span>  <?  $user_name=($activity['name']!="")?$activity['name'].' - ':''; if($activity['operator_id']!=0) { $user=($activity['operator'] ==1)? ' by '.$user_name.$activity['email']:  ' by '.$activity['name']; } else { $user=""; }?>                          
                                       <? echo $activity_msg.$user; ?>
                                      </span>
                                    </div>       
                                  </div>
                                </div>
                            </article>                 
                            <? endif; ?><?  } else { 
                                if($activity['operation_id']==2 || $activity['operation_id']==3 || $activity['operation_id']==4 || $activity['operation_id']==5 || $activity['operation_id']==6) $activity_msg=$operationsTicket[$activity['operation_id']].' from '.$activity['old_info'].' to '.$activity['new_info'];
                                else if($activity['operation_id']==7){                          
                                    if($activity['new_info']>0)
                                        $activity_msg = $operationsTicket[$activity['operation_id']].' to '. $activity['user_info'];
                                    elseif($activity['new_info']==0 && $activity['old_info']>0)
                                        $activity_msg = $vis_language['TXTTICKETUNASSIGNEDFROM'].' '. $activity['user_info'];
                                    elseif($activity['new_info']==0) 
                                        $activity_msg = $vis_language['TXTTICKETUNASSIGNED'];
                                    else
                                        $activity_msg = $operationsTicket[$activity['operation_id']];
                                }else if($activity['operation_id']==45 || $activity['operation_id']==46 || $activity['operation_id']==47 || $activity['operation_id']==48 || $activity['operation_id']==49){
											$activity_msg = ($activity['old_info'] == '')?$operationsTicket[$activity['operation_id']].' '.$activity['old_info'].' to '.$activity['new_info']:$operationsTicket[$activity['operation_id']].' from '.$activity['old_info'].' to '.$activity['new_info'];
							   }else if($activity['operation_id']==29){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==30){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==31){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==33){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==34){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==35){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==36){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==42){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==43){ // Added by Sachin E.
							   		$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==8 && $activity['old_info']==0 && $activity['new_info']==''){ // Added by Sachin E.
									$activity_msg = $vis_language['TXTTKTMOVEINBOCFROMTRASH'];
							   }else if($activity['operation_id']==14 && $activity['old_info']==1 && $activity['new_info']==0){ // Added by Sachin E.
									$activity_msg = $vis_language['MSGUNSPAM'];				
							   }else if($activity['operation_id']==53){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']].' to '.$activity['old_info'];$activity['operator_id']=0;
							   }else if($activity['operation_id']==54){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']].' to '.$activity['old_info'];$activity['operator_id']=0;
							   }else $activity_msg=$operationsTicket[$activity['operation_id']];
								    ?>
                            <? if($activity['ticket_hash']): ?>	
                            <article class="timeline-item alt">
                                <div class="timeline-caption">                
                                  <div class="panel panel-default">
                                    <div class="panel-body">
                                      <span class="arrow right"></span>
                                      <span class="timeline-icon"><i class="<? echo $activity['image'].' time-icon '.(($channel_colors[$activity['channel_id']]=='')?'vh-grey-bg vh-warning-bg':$channel_colors[$activity['channel_id']]); ?>"></i></span>
                                      <span class="timeline-date"><?= format_datetime($activity['entry_date']); ?></span>
                                      <div class="text-sm"><a class="link" href="#/ticket/ticket_details/<? echo $activity['ticket_hash']; ?>/<? echo $activity['ticket_id']; ?>" ><? echo $activity['ticket_hash']." : ".$activity['subject']; ?></a></div>
                                      <span>   <? $user_name=($activity['name']!="")?$activity['name'].' - ':''; if($activity['operator_id']!=0) { $user=($activity['operator'] ==1)? ' by '.$user_name.$activity['email']:  ' by '.$activity['name']; } else { $user=""; }?>                          
                                        <? echo $activity_msg.$user; ?>
                                      </span>
                                    </div>
                                  </div>
                                </div>
                            </article>          
                            <? endif; ?> <? } $cnt++;?>       							
                            <? endforeach;?>
                        <? else: ?>
                        <section class="wrapper fullFrame">
                            <div class="fullMiddle"><? echo $vis_language['TXTNOTHINGTODISPLAY']; ?></div>
                        </section>
                        <? endif; ?>
                        </div>
                        <? if($recentActivities != -1 &&  $total_pages>1){?>	
                        <div id="load_more_activities" onclick="javascript:load_more_recent_activities(<?= $page+1;?>);">
                        <div style="text-align: center;">
                            <span class="link vis-pointer"><?= $vis_language['TXTLOADMORE'];?></span>
                        </div>
                        </div><? } ?>
<script>
  $("#agent_cnt").html('<?= $agent_count; ?>');
  $("#problems_cnt").html('<?= $counts['problems']; ?>');
  $("#changes_cnt").html('<?= $counts['changes']; ?>');
  $("#releases_cnt").html('<?= $counts['releases']; ?>');
  $("#service_request_cnt").html('<?= $counts['service_request']; ?>');
  $("#new_cnt").html('<?= $counts['new']; ?>');
  $("#overdue_cnt").html('<?= $counts['overdue']; ?>');
  $("#assigned_cnt").html('<?= $counts['assigned']; ?>');
  $("#draft_cnt").html('<?= $counts['draft']; ?>');
  $("#spam_cnt").html('<?= $clientCounts['spammer']; ?>');
  $("#unregistered_cnt").html('<?= $clientCounts['unregistered']; ?>');
  $("#banned_cnt").html('<?= $clientCounts['banned']; ?>');
    <? if($overdue_count_within30 > 0):?> 
        $("#overdue_count_within30").html("<a onclick=\"$('#vis_workpanel_div').visExecution('load_module','Overdue tickets',{'vis_module':'ticket','vis_operation':'filter_ticket', 'vis_filter_id':'<? echo $overdue_filter_30; ?>'});\"><h4><? echo $overdue_count_within30 ; ?></h4></a><p><? echo $vis_language['TXTTHIRTYMINUTES']; ?></p>"); $("#overdue_count_within30").addClass('vis-pointer');
    <? else:?>
           $("#overdue_count_within30").html("<a><h4><? echo $overdue_count_within30 ; ?></h4></a><p><? echo $vis_language['TXTTHIRTYMINUTES']; ?></p>");
    <? endif; ?>
    <? if($overdue_count_within60 > 0):?> 
        $("#overdue_count_within60").html("<a onclick=\"$('#vis_workpanel_div').visExecution('load_module','Overdue tickets',{'vis_module':'ticket','vis_operation':'filter_ticket', 'vis_filter_id':'<? echo $overdue_filter_60; ?>'});\"><h4><? echo $overdue_count_within60 ; ?></h4></a><p><? echo $vis_language['TXTSIXTYMINUTES']; ?></p>"); $("#overdue_count_within60").addClass('vis-pointer');
    <? else:?>
        $("#overdue_count_within60").html("<a><h4><? echo $overdue_count_within60 ; ?></h4></a><p><? echo $vis_language['TXTSIXTYMINUTES']; ?></p>");
    <? endif; ?>
    <? if($overdue_count_within_1day > 0):?> 
        $("#overdue_count_within_1day").html("<a onclick=\"$('#vis_workpanel_div').visExecution('load_module','Overdue tickets',{'vis_module':'ticket','vis_operation':'filter_ticket', 'vis_filter_id':'<? echo $overdue_filter_1day; ?>'});\"><h4><? echo $overdue_count_within_1day ; ?></h4></a><p><? echo $vis_language['TXTONEDAY']; ?></p>"); $("#overdue_count_within_1day").addClass('vis-pointer');
    <? else:?>
        $("#overdue_count_within_1day").html("<a><h4><? echo $overdue_count_within_1day ; ?></h4></a><p><? echo $vis_language['TXTONEDAY']; ?></p>");
    <? endif; ?>
    <? if($quick_view['4'] > 0):?> 
         $("#quick_view4").html('<a href="#/home/view_tasks/In progress/4"><h4><? echo $quick_view['4'];?></h4></a><p><? echo $vis_language['TXTINPROGRESS']; ?></p>'); $("#quick_view4").addClass('vis-pointer');
    <? else:?>
         $("#quick_view4").html('<a><h4><? echo $quick_view['4'];?></h4></a><p><? echo $vis_language['TXTINPROGRESS']; ?></p>');
    <? endif; ?>
    <? if($quick_view['3'] > 0):?> 
        $("#quick_view3").html('<a href="#/home/view_tasks/Assigned task/3"><h4><? echo $quick_view['3'];?></h4></a><p><? echo $vis_language['TXTSELFASSIGNED']; ?></p>'); $("#quick_view3").addClass('vis-pointer');
    <? else:?>
       $("#quick_view3").html('<a><h4><? echo $quick_view['3'];?></h4></a><p><? echo $vis_language['TXTSELFASSIGNED']; ?></p>');
    <? endif; ?>
    <? if($quick_view['5'] > 0):?> 
        $("#quick_view5").html('<a href="#/home/view_tasks/Overdue task/5"><h4><? echo $quick_view['5'];?></h4></a><p><? echo $vis_language['TXTOVERDUE']; ?></p>'); $("#quick_view5").addClass('vis-pointer');
    <? else:?>
      $("#quick_view5").html('<a><h4><? echo $quick_view['5'];?></h4></a><p><? echo $vis_language['TXTOVERDUE']; ?></p>');
    <? endif; ?>
</script>
