<?php
session_start();
$companyname=$_SESSION['companyname'];
$adminemailid=$_SESSION['emailid'];
if(($adminemailid !="")&&($companyname!="")){
require_once('../Control/activity.php');
$objactivity=new activityctrl();
require_once('../Control/employee.php');
$objemployee=new employeectrl();
require_once('../Control/sales.php');
$objsales=new salesctrl();
$cid=$_POST['cid'];
$result_activity_count=$objactivity->salesemployeeactivitycount("", "all", $cid, $companyname, $adminemailid);
foreach($result_activity_count as $row_activity_count){
 $allcount= $row_activity_count['count1'];
}
$result_activity_count=$objactivity->salesemployeeactivitycount("", "deal", $cid, $companyname, $adminemailid);
foreach($result_activity_count as $row_activity_count){
 $dealcount= $row_activity_count['count1'];
}
$result_activity_count=$objactivity->salesemployeeactivitycount("", "noteandcall", $cid, $companyname, $adminemailid);
foreach($result_activity_count as $row_activity_count){
 $notecallcount= $row_activity_count['count1'];
}
$result_activity_count=$objactivity->salesemployeeactivitycount("", "nextaction", $cid, $companyname, $adminemailid);
foreach($result_activity_count as $row_activity_count){
 $nextactioncount= $row_activity_count['count1'];
}
$result_activity_count=$objactivity->salesemployeeactivitycount("", "update", $cid, $companyname, $adminemailid);
foreach($result_activity_count as $row_activity_count){
 $updatecount= $row_activity_count['count1'];
}
//echo $updatecount;
/*echo "allcount:".$allcount."<br>";
echo "dealcount:".$dealcount."<br>";
echo "notecallcount:".$notecallcount."<br>";
echo "nextactioncount:".$nextactioncount."<br>";
echo "updatecount:".$updatecount."<br>";*/
$i=0;
$j=0;
$k=0;
$l=0;
$m=0;
$u_dateandtime=array();
$result_activity_all=$objactivity->salesemployeeactivityviewall("", $cid, "0", $companyname, $adminemailid);
//echo $result_activity_all->rowCount();
foreach($result_activity_all as $row_activity_all){
    //echo $i;
    $a_dateandtime[$i]=$row_activity_all['dateandtime'];
    $a_org_id[$i]=$row_activity_all['org_id'];
    $a_created_by[$i]=$row_activity_all['created_by'];
    $empid=$row_activity_all['created_by'];
    $a_created_name[$i]=$objemployee->salesemployeename($empid);
    $a_created_type[$i]=$row_activity_all['created_type'];
    $a_type[$i]=$row_activity_all['type'];
    $a_subtype[$i]=$row_activity_all['subtype'];
    $a_changed[$i]=$row_activity_all['changed'];
    $a_descr[$i]=$row_activity_all['descr'];
    $a_de_name[$i]=$row_activity_all['Name'];
    if(strtoupper($a_changed[$i])==strtoupper("owner")){
        $oid=$row_activity_all['old_descr'];
        $a_old_descr[$i]=$objemployee->salesemployeename($oid);
        $nid=$row_activity_all['new_descr'];
        $a_new_descr[$i]=$objemployee->salesemployeename($nid);
    }else if(strtoupper($a_changed[$i])==strtoupper("tag")){
        $oid=$row_activity_all['old_descr'];
        $a_old_descr[$i]=$objsales->salestagname("sales_tag", $oid);
        $nid=$row_activity_all['new_descr'];
        $a_new_descr[$i]=$objsales->salestagname("sales_tag", $nid);
    }else if(strtoupper($a_changed[$i])==strtoupper("status")){
        $otag=$row_activity_all['old_descr'];
        $a_old_descr[$i]=$objsales->salesstatusname("sales_status", $oid);
        $nid=$row_activity_all['new_descr'];
        $a_new_descr[$i]=$objsales->salesstatusname("sales_status", $nid);
    }else if(strtoupper($a_changed[$i])==strtoupper("lead source")){
        $otag=$row_activity_all['old_descr'];
        $a_old_descr[$i]=$objsales->salesleadname("sales_lead_source", $oid);
        $nid=$row_activity_all['new_descr'];
        $a_new_descr[$i]=$objsales->salesleadname("sales_lead_source", $nid);
    }else if(strtoupper($a_changed[$i]=="stage")){
        //echo $u_changed[$m];
        $oid=$row_activity_all['old_descr'];
        if(($oid!="Won")&&($oid!="Lost")){
            $a_old_descr[$i]=$objsales->salespipelinename("sales_pipeline_type", $oid);
        }else{
            $a_old_descr[$i]=$row_activity['old_descr'];
        }
        $nid=$row_activity_all['new_descr'];
        if(($nid!="Won")&&($nid!="Lost")){
            $a_new_descr[$i]=$objsales->salespipelinename("sales_pipeline_type", $nid);
        }else{
            $a_new_descr[$i]=$row_activity_all['new_descr'];
        }
    }else{
    $a_old_descr[$i]=$row_activity_all['old_descr'];
    $a_new_descr[$i]=$row_activity_all['new_descr'];
    }
    $i++;
}
$result_activity_callnote=$objactivity->salesemployeeactivityviewcallnote("", $cid, "0", $companyname, $adminemailid);
foreach($result_activity_callnote as $row_activity_callnote){
    $cn_dateandtime[$j]=$row_activity_callnote['dateandtime'];
    $cn_org_id[$j]=$row_activity_callnote['org_id'];
    $cn_created_by[$j]=$row_activity_callnote['created_by'];
    $empid=$row_activity_callnote['created_by'];
    $cn_created_name[$j]=$objemployee->salesemployeename($empid);
    $cn_created_type[$j]=$row_activity_callnote['created_type'];
    $cn_type[$j]=$row_activity_callnote['type'];
    $cn_subtype[$j]=$row_activity_callnote['subtype'];
    $cn_changed[$j]=$row_activity_callnote['changed'];
    $cn_descr[$j]=$row_activity_callnote['descr'];
    $cn_old_descr[$j]=$row_activity_callnote['old_descr'];
    $cn_new_descr[$j]=$row_activity_callnote['new_descr'];
        $j++;
}
$result_activity_deal=$objactivity->salesemployeeactivityviewdeal("", $cid, "0", $companyname, $adminemailid);
foreach($result_activity_deal as $row_activity_deal){
        $d_dateandtime[$k]=$row_activity_deal['dateandtime'];
        $d_org_id[$k]=$row_activity_deal['org_id'];
        $d_created_by[$k]=$row_activity_deal['created_by'];
        $empid=$row_activity_deal['created_by'];
        $d_created_name[$k]=$objemployee->salesemployeename($empid);
        $d_created_type[$k]=$row_activity_deal['created_type'];
        $d_type[$k]=$row_activity_deal['type'];
        $d_subtype[$k]=$row_activity_deal['subtype'];
        $d_changed[$k]=$row_activity_deal['changed'];
        $d_descr[$k]=$row_activity_deal['descr'];
        $d_old_descr[$k]=$row_activity_deal['old_descr'];
        $d_new_descr[$k]=$row_activity_deal['new_descr'];
        $d_de_name[$k]=$row_activity_deal['Name'];
        $k++;
    }
$result_activity_nextaction=$objactivity->salesemployeeactivityviewnextaction("", $cid, "0", $companyname, $adminemailid);
foreach($result_activity_nextaction as $row_activity_nextaction){
        $na_dateandtime[$l]=$row_activity_nextaction['dateandtime'];
        $na_org_id[$l]=$row_activity_nextaction['org_id'];
        $na_created_by[$l]=$row_activity_nextaction['created_by'];
        $empid=$row_activity_nextaction['created_by'];
        $na_created_name[$l]=$objemployee->salesemployeename($empid);
        $na_created_type[$l]=$row_activity_nextaction['created_type'];
        $na_type[$l]=$row_activity_nextaction['type'];
        $na_subtype[$l]=$row_activity_nextaction['subtype'];
        $na_changed[$l]=$row_activity_nextaction['changed'];
        $na_descr[$l]=$row_activity_nextaction['descr'];
        $na_old_descr[$l]=$row_activity_nextaction['old_descr'];
        $na_new_descr[$l]=$row_activity_nextaction['new_descr'];
        $l++;
    }
$result_activity_update=$objactivity->salesemployeeactivityviewupdate("", $cid, "0", $companyname, $adminemailid);
foreach($result_activity_update as $row_activity_update){
        $u_dateandtime[$m]=$row_activity_update['dateandtime'];
        $u_org_id[$m]=$row_activity_update['org_id'];
        $u_created_by[$m]=$row_activity_update['created_by'];
        $empid=$row_activity_update['created_by'];
        $u_created_name[$m]=$objemployee->salesemployeename($empid);
        $u_created_type[$m]=$row_activity_update['created_type'];
        $u_type[$m]=$row_activity_update['type'];
        $u_subtype[$m]=$row_activity_update['subtype'];
        $u_changed[$m]=$row_activity_update['changed'];
        $u_descr[$m]=$row_activity_update['descr'];
        $u_de_name[$m]=$row_activity_update['Name'];
        if(strtoupper($u_changed[$m])==strtoupper("owner")){
            $oid=$row_activity_update['old_descr'];
            $u_old_descr[$m]=$objemployee->salesemployeename($oid);
            $nid=$row_activity_update['new_descr'];
            $u_new_descr[$m]=$objemployee->salesemployeename($nid);
        }else if(strtoupper($u_changed[$m])==strtoupper("tag")){
            $oid=$row_activity_update['old_descr'];
            $u_old_descr[$m]=$objsales->salestagname("sales_tag", $oid);
            $nid=$row_activity_update['new_descr'];
            $u_new_descr[$m]=$objsales->salestagname("sales_tag", $nid);
        }else if(strtoupper($u_changed[$m])==strtoupper("status")){
            $otag=$row_activity_update['old_descr'];
            $u_old_descr[$m]=$objsales->salesstatusname("sales_status", $oid);
            $nid=$row_activity_update['new_descr'];
            $u_new_descr[$m]=$objsales->salesstatusname("sales_status", $nid);
        }else if(strtoupper($u_changed[$i])==strtoupper("lead source")){
            $otag=$row_activity_update['old_descr'];
            $u_old_descr[$i]=$objsales->salesleadname("sales_lead_source", $oid);
            $nid=$row_activity_update['new_descr'];
            $u_new_descr[$i]=$objsales->salesleadname("sales_lead_source", $nid);
        }else if(strtoupper($u_changed[$m])==strtoupper("stage")){
            //echo $u_changed[$m];
            $oid=$row_activity_update['old_descr'];
            if(($oid!="Won")&&($oid!="Lost")){
                $u_old_descr[$m]=$objsales->salespipelinename("sales_pipeline_type", $oid);
            }else{
                $u_old_descr[$m]=$row_activity_update['old_descr'];
            }
            $nid=$row_activity_update['new_descr'];
            if(($nid!="Won")&&($nid!="Lost")){
                $u_new_descr[$m]=$objsales->salespipelinename("sales_pipeline_type", $nid);
            }else{
                $u_new_descr[$m]=$row_activity_update['new_descr'];
            }
        }else{
        $u_old_descr[$m]=$row_activity_update['old_descr'];
        $u_new_descr[$m]=$row_activity_update['new_descr'];
        }
        $m++;
    }
?>
<!--<!doctype html>
<html>
    <head>-->
    
        <!--<link rel="icon" href="../../Images/cloud-icon-27.png">
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="../../Bootstrap/css/bootstrap.min.css">
        <script src="../../Bootstrap/jquery.min.js"></script>
        <script src="../../Bootstrap/js/bootstrap.min.js"></script>
        
        <link href="../../font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet">-->
        
        <style>
            .activity-bar {
                background: #9d9a93;
                -webkit-border-radius: 4px;
                -moz-border-radius: 4px;
                border-radius: 4px;
                padding: 10px 10px 10px 10px;
                position: relative;
                clear: both;
                color: #fff;
                height: 50px;
                line-height: 24px;
            }
            .activity_png{
                background: url(Image/activity_icons.png) no-repeat 0 -20px transparent;
                width: 33px;
                height: 27px;
                display: block;
                position: absolute;
                content: "";
                background-size: 128px 94px;
                top: 4px;
                left: 15px;
            }
            .item-filter {
                float: right;
            }
        </style>

<script>
function openCity(evt, cityName) {
    var i, tabcontent, tablinks;
    tabcontent = document.getElementsByClassName("tabcontent");
    for (i = 0; i < tabcontent.length; i++) {
        tabcontent[i].style.display = "none";
    }
    tablinks = document.getElementsByClassName("tablinks");
    for (i = 0; i < tablinks.length; i++) {
        tablinks[i].className = tablinks[i].className.replace(" active", "");
    }
    document.getElementById(cityName).style.display = "block";
    evt.currentTarget.className += " active";
}
</script>
<style>
    .timeline {
        position: relative;
        padding: 15px 0px 0px;
        margin-top: 4px;
        margin-bottom: 10px;
    }
    
    .timeline .line {
        position: absolute;
        width: 4px;
        display: block;
        background: #9d9a93;
        top: 0px;
        bottom: 0px;
        margin-left: 30px;
    }
    
    .timeline .separator {
        border-top: 1px solid #9d9a93;
        padding: 5px;
        padding-left: 40px;
        font-style: italic;
        font-size: .9em;
        margin-left: 30px;
    }
    
    /*.timeline .line::before { top: -4px; }
    .timeline .line::after { bottom: -4px; }
    .timeline .line::before,
    .timeline .line::after {
        content: '';
        position: absolute;
        left: -4px;
        width: 12px;
        height: 12px;
        display: block;
        border-radius: 50%;
        background: #9d9a93;
    }*/
    
    .timeline .panel {
        position: relative;
        margin: 10px 0px 21px 70px;
        clear: both;
    }
    
    .timeline .panel::before {
        position: absolute;
        display: block;
        top: 8px;
        left: -24px;
        content: '';
        width: 0px;
        height: 0px;
        border: inherit;
        border-width: 12px;
        border-top-color: transparent;
        border-bottom-color: transparent;
        border-left-color: transparent;
    }
    
    .icon *{ font-size: 20px; vertical-align: middle; line-height: 40px; }
    .icon {
        position: absolute;
        left: -59px;
        display: block;
        width: 40px;
        height: 40px;
        padding: 0px;
        border-radius: 50%;
        text-align: center;
        float: left;
    }
    .icon1 {
        position: absolute;
        top:15px;
        left: -45px;
        display: block;
        width: 13px;
        height: 13px;
        padding: 0px;
        border-radius: 50%;
        text-align: center;
        float: left;
    }
    
    
    .timeline .panel-outline {
        border-color: transparent;
        background: transparent;
        box-shadow: none;
    }
    
    .timeline .panel-outline .panel-body {
        padding: 10px 0px;
    }
    
    .timeline .panel-outline .panel-heading:not(.icon),
    .timeline .panel-outline .panel-footer {
        display: none;
    }
</style>
<style>
body {font-family: Arial;}

/* Style the tab */
.tab {
    overflow: hidden;
    border: 1px solid #ccc;
    background-color: #f1f1f1;
}

/* Style the buttons inside the tab */
.tab span {
    float: left;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 4px 6px;
    transition: 0.3s;
    font-size: 17px;
}

/* Change background color of buttons on hover */
.tab span:hover {
    background-color: #000;
    border-radius:5px;
}

/* Create an active/current tablink class */
.tab span.active {
    background-color: #000;
    border-radius:5px;
}

/* Style the tab content */
.tabcontent {
    display: none;
    padding: 6px 12px;
   /* border: 1px solid #000;*/
    border-top: none;
}
</style>
    </head>
    <body>
        <div class="activity-bar">
            <span class="activity_png"></span>
            <span class="pull-right">
                
                <span class="tab">
                    <span class="tablinks active" onclick="openCity(event, 'All')">All</span>
                    <span class="tablinks" onclick="openCity(event, 'Notes')">Notes &amp; Calls</span>
                    <span class="tablinks" onclick="openCity(event, 'Deals')">Deals</span>
                    <span class="tablinks" onclick="openCity(event, 'Actions')">Actions</span>
                    <span class="tablinks" onclick="openCity(event, 'Emails')">Emails</span>
                    <span class="tablinks" onclick="openCity(event, 'Updates')">Updates</span>
                </span>
            </span>
        </div>
        
            
        <div id="All" class="tabcontent" style="display:block;">
            
            <div class="timeline" style="top:-10px;">
                
                <div class="line text-muted"></div>
                
                <span id="allviewajax">
                <?php
                //$a_dateandtime $a_org_id $a_created_by $a_created_name $a_created_type $a_type $a_subtype $a_changed $a_descr $a_old_descr $a_new_descr
                //echo count($a_dateandtime);
                for($ii=0;$ii<count($a_dateandtime);$ii++){
                    $rowact=$objactivity->salescontactdetails($cid);
                    foreach($rowact as $row_act){
                        $cont_first_name=$row_act['cont_first_name'];
                        $cont_last_name=$row_act['cont_last_name'];
                        $org_name=$row_act['org_name'];
                    }
                    $lastshow=" for ";
                    if($cont_first_name!=""){
                        $lastshow.=$cont_first_name." ";
                    }
                    $lastshow.=$cont_last_name;
                    if($org_name!=""){
                        $lastshow.=" of ".$org_name;
                    }
                    $lastshownote="";
                    if($cont_first_name!=""){
                        $lastshownote.=$cont_first_name." ";
                    }
                    $lastshownote.=$cont_last_name;
                    $lastshownote.=$cont_last_name;
                    $deal_conatct_person="";
                    if($cont_first_name!=""){
                        $deal_conatct_person.=$cont_first_name." ";
                    }
                    $deal_conatct_person.=$cont_last_name;
                            
                        $note_cont_name="";
                        if($cont_first_name!=""){
                            $note_cont_name.=$cont_first_name." ";
                        }
                        $note_cont_name.=$cont_last_name;
                        if($org_name!=""){
                            $note_cont_name1=$note_cont_name." of ". $org_name." ";
                        }else{
                            $note_cont_name1=$note_cont_name;
                        }
                        $c1=$a_dateandtime[$ii];
                        $c2=$a_created_by[$ii];
                        $c3=$a_created_type[$ii];
                ?>
                
                <?php
                //echo $a_subtype[$ii];
                if(($a_subtype[$ii]=="update")||($a_subtype[$ii]=="updated")){
                ?>
                
                <?php if(($a_type[$ii]=="contact")||($a_type[$ii]=="Contact")){?>
                    <article class="panel panel-default panel-outline">
                
                        <div class="panel-heading icon" style=" border:2px solid #9d9a93;font-size: 17px;vertical-align: middle;line-height: 35px;">
                            <i class="glyphicon glyphicon-user"></i>
                        </div>
                
                        <div class="panel-body" style="background-color:#f8f8f8;">
                            
                            <?php 
                                $c1=$a_dateandtime[$ii];
                                $c2=$a_created_by[$ii];
                                $c3=$a_created_type[$ii];
                                $rowact=$objactivity->salescontactdetails($cid);
                                foreach($rowact as $row_act){
                                    $cont_first_name=$row_act['cont_first_name'];
                                    $cont_last_name=$row_act['cont_last_name'];
                                    $org_name=$row_act['org_name'];
                                }
                                    ?>
                            <strong><?php echo $a_created_name[$ii]; ?>.</strong> 
                            <?php
                            if(($a_changed[$ii]=="Tag")||($a_changed[$ii]=="tag")){
                                echo "changed Tag from ".$a_old_descr[$ii]." to ".$a_new_descr[$ii]." ".$lastshow." - ".$c1 ;
                            }elseif(($a_changed[$ii]=="status")||($a_changed[$ii]=="Status")){
                                echo "changed Status from ".$a_old_descr[$ii]." to ".$a_new_descr[$ii]." ".$lastshow." - ".$c1 ;
                            }elseif(($a_changed[$ii]=="Lead source")||($a_changed[$ii]=="lead source")){
                                echo "changed Lead Source from ".$a_old_descr[$ii]." to ".$a_new_descr[$ii]." ".$lastshow." - ".$c1 ;
                            }elseif(($a_changed[$ii]=="Owner")||($a_changed[$ii]=="owner")){
                                echo "changed Owner ".$a_old_descr[$ii]." to ".$a_new_descr[$ii]." ".$lastshow." - ".$c1 ;
                            }elseif(($a_changed[$ii]=="Firstname")||($a_changed[$ii]=="firstname")){
                                echo "edit firstname ".$lastshow." - ".$c1 ;
                            }else{
                            ?>
                            edit lastname <?php echo $lastshow; ?> - <?php echo $c1; ?>
                            <?php
                            }
                            ?>
                            
                        </div>
                
                    </article>
                    <?php }else if(($a_type[$ii]=="deal")||($a_type[$ii]=="Deal")){ ?>
                            <?php
                            $c1=$a_dateandtime[$ii];
                            $c2=$a_created_by[$ii];
                            $c3=$a_created_type[$ii];
                            ?>
                        <article class="panel panel-default  panel-outline" >
                    
                            <div class="panel-heading icon icon1" style=" border:2px solid #9d9a93;">
                                
                            </div>
                    
                            <div class="panel-body">
                                <strong><?php echo $a_created_name[$ii];?></strong> Changed Deals "<?php echo $a_de_name[$ii];?>" <?php echo $a_changed[$ii];?> from  <?php echo $a_old_descr[$ii];?> to  <?php echo $a_new_descr[$ii];?> for <?php echo $deal_conatct_person;?> - <?php echo $a_dateandtime[$ii];?>
                            </div>
                    
                        </article>
                <?php
                }else if(strtoupper($a_type[$ii])==strtoupper("next action")){
                ?>
                <article class="panel panel-default  panel-outline" >
            
                    <div class="panel-heading icon icon1" style=" border:2px solid #9d9a93;">
                        
                    </div>
            
                    <div class="panel-body">
                        <?php if(strtoupper($a_changed[$ii])==strtoupper("Assigned")){
                            $empid=$a_old_descr[$ii];
                            $olid=$objemployee->salesemployeename($empid);
                            $empid=$a_new_descr[$ii];
                            $newid=$objemployee->salesemployeename($empid);
                            ?>
                            <strong><?php echo $a_created_name[$ii];?></strong>  <?php echo $a_descr[$ii];?>  from <?php echo $olid;?>  to <?php echo $newid;?> <?php echo " for ".$note_cont_name1." - ".$c1;?>
                        <?php }else{?>
                            <strong><?php echo $a_created_name[$ii];?></strong>  <?php echo $a_descr[$ii];?> <?php echo " for ".$note_cont_name1." - ".$c1;?>
                        <?php }?>
                    </div>
            
                </article>
                    <?php }else if(($a_type[$ii]=="note")||($a_type[$ii]=="Note")){ ?>
                <article class="panel panel-default panel-outline">
            
                    <div class="panel-heading icon" style=" border:2px solid #9d9a93;">
                        <i class="glyphicon glyphicon-list-alt"></i>
                    </div>
            
                    <div class="panel-body" style="background-color:#f8f8f8;">
                        
                        <?php 
                            $c1=$a_dateandtime[$ii];
                            $c2=$a_created_by[$ii];
                            $c3=$a_created_type[$ii];
                            $d1="";$d2="";$d3="";
                            $rowact=$objactivity->salesactivitycreatednoteview($cid, $c1, $c2, $c3);
                            foreach($rowact as $row_act){
                                $d1=$row_act['n_descr'];
                                $d2=$row_act['dealname'];
                                $d3=$row_act['n_date'];
                            }
                                ?>
                        <strong><?php echo $a_created_name[$ii]; ?></strong> <?php if($d2!=""){ echo " Note related to \"".$d2."\" :"; } ?> <?php echo $d1; ?><br>
                        <?php echo $lastshownote." - ".$c1; ?>
                        
                    </div>
            
                </article>
                <?php }else if(($a_type[$ii]=="call")||($a_type[$ii]=="Call")){ ?>
                <article class="panel panel-default panel-outline">
            
                    <div class="panel-heading icon" style=" border:2px solid #9d9a93;">
                        <i class="glyphicon glyphicon-earphone"></i>
                    </div>
            
                    <div class="panel-body" style="background-color:#f8f8f8;">
                        <?php 
                            $c1=$a_dateandtime[$ii];
                            $c2=$a_created_by[$ii];
                            $c3=$a_created_type[$ii];
                            $rowact=$objactivity->salesactivitycreatedcallview($cid, $c1, $c2, $c3);
                            foreach($rowact as $row_act){
                                $phone_number=$row_act['phone_number'];
                                $phone_type=$row_act['phone_type'];
                                $c_descr=$row_act['c_descr'];
                                $result_answer=$row_act['result_answer'];
                                $c_date=$row_act['c_date'];
                                $c_time=$row_act['c_time'];
                                $contact_name=$ro_act['contact_name'];
                            }
                        ?>
                            <strong><?php echo $a_created_name[$ii]; ?></strong> <?php 
                            if($result_answer==""){
                            echo "Others";
                            }else if(($result_answer=="Left Message")||($result_answer=="No answer")){
                            echo $result_answer; 
                            }else{
                            echo " Conversation: ".$result_answer; 
                            }?>, Called at <?php echo $c_time; ?> on <?php echo $phone_number; ?> ( <?php echo $phone_type; ?> ) - <?php echo $c_descr; ?>
                            <br><?php echo $lastshownote." - ".$c1; ?>
                    </div>
            
                </article>
                <?php
                }else{
                ?>
                        
                        <article class="panel panel-default  panel-outline" >
                    
                            <div class="panel-heading icon icon1" style=" border:2px solid #9d9a93;">
                                
                            </div>
                    
                            <div class="panel-body">
                                <strong><?php echo $a_created_name[$ii];?></strong>
                                <span style="float: none;display: inline;margin: 0;color: #777;font-family: 'Open Sans', Arial, Helvetica, sans-serif;font-weight: normal;max-width: 78%;">
                                    &nbsp;<?php echo $a_descr[$ii];?> &nbsp;<?php echo $a_changed[$ii];?>&nbsp; from &nbsp;<?php echo $a_old_descr[$ii];?> &nbsp;to &nbsp; <?php echo $a_new_descr[$ii];?>
                                </span>
                            </div>
                    
                        </article>
                <?php
                }    
                }else{
                ?>
                    
                    <?php if(($a_type[$ii]=="contact")||($a_type[$ii]=="Contact")){?>
                        <article class="panel panel-default panel-outline">
                    
                            <div class="panel-heading icon" style=" border:2px solid #9d9a93;font-size: 17px;vertical-align: middle;line-height: 35px;">
                                <i class="glyphicon glyphicon-user"></i>
                            </div>
                    
                            <div class="panel-body" style="background-color:#f8f8f8;">
                                
                                <?php 
                                    $c1=$a_dateandtime[$ii];
                                    $c2=$a_created_by[$ii];
                                    $c3=$a_created_type[$ii];
                                    $rowact=$objactivity->salescontactdetails($cid);
                                    foreach($rowact as $row_act){
                                        $cont_first_name=$row_act['cont_first_name'];
                                        $cont_last_name=$row_act['cont_last_name'];
                                        $org_name=$row_act['org_name'];
                                    }
                                        ?>
                                <strong><?php echo $a_created_name[$ii]; ?>.</strong> 
                                <?php
                                if(($a_changed[$ii]=="Tag")||($a_changed[$ii]=="tag")){
                                    echo "added Tag: ".$a_new_descr[$ii]." ".$lastshow." - ".$c1 ;
                                }elseif(($a_changed[$ii]=="Lead source")||($a_changed[$ii]=="lead source")){
                                    echo "added Lead Source: ".$a_new_descr[$ii]." ".$lastshow." - ".$c1 ;
                                }elseif(($a_changed[$ii]=="Firstname")||($a_changed[$ii]=="firstname")){
                                    echo "added Firstname ".$lastshow." - ".$c1 ;
                                }else{
                                ?>
                                Created contact <?php echo $lastshow; ?> - <?php echo $c1; ?>
                                <?php
                                }
                                ?>
                                
                            </div>
                    
                        </article>
                        <?php }else if(($a_type[$ii]=="deal")||($a_type[$ii]=="Deal")){ ?>
                        <article class="panel panel-default panel-outline">
                    
                                <?php 
                                    $c1=$a_dateandtime[$ii];
                                    $c2=$a_created_by[$ii];
                                    $c3=$a_created_type[$ii];
                                    $rowact=$objactivity->salesactivitycreateddealview($cid, $c1, $c2, $c3);
                                    foreach($rowact as $row_act){
                                        $d1=$row_act['firstname'];
                                        $d2=$row_act['d_deal_name'];
                                        $d3=$row_act['deal_by'];
                                        $d4=$row_act['d_amount'];
                                        $d5=$row_act['d_month'];
                                        $d6=$row_act['d_commission_percentage'];
                                        $d7=$row_act['d_commission_amount'];
                                        $d8=$row_act['d_descr'];
                                        $d9=$row_act['d_stage_name'];
                                        $d10=$row_act['d_date'];
                                        $d11=$row_act['d_closedate'];
                                        $d12=$row_act['orgname'];
                                    }
                                ?>
                            
                                <?php if((strtoupper($d9)!=strtoupper("Won"))&&(strtoupper($d9)!=strtoupper("Lost"))){ ?>    
                                <div class="panel-heading icon" style=" border:2px solid #9d9a93;background-color:grey;color:#fff;">
                                    <i class="fa fa-dollar"></i>
                                </div>
                        
                                <div class="panel-body" style="background-color:#f8f8f8;">
                                    <strong><?php echo $a_created_name[$ii];?></strong>
                                    <span style="color: #db2b5d;"><?php echo $a_descr[$ii];?> &#8360 <?php echo $d4;?> </span> 
                                    (&#8360 <?php if(($d4!=0)&&($d5!=0)){ echo ($d4/$d5);?> x <?php echo $d5;?> months) <?php } echo $d9;?> chance it will close <?php echo $d11;?> "<?php echo $d2;?>"<?php if($a_created_name[$ii]!=$d3){ ?>(Deal Owner - <?php echo $d3; ?>.)<?php } ?><br>
                                    <?php if($d8!=""){ echo $d8."</br>"; }?>
                                    <span style="color: #666;"><?php echo $deal_conatct_person;?> - <?php echo $c1;?></span>
                                </div>
                                <?php } ?>
                                
                                <?php if((strtoupper($d9)==strtoupper("Won"))){ ?>    
                                <div class="panel-heading icon" style=" border:2px solid #9d9a93;background-color:#54b0fe;color:#fff;">
                                    <i class="fa fa-dollar"></i>
                                </div>
                        
                                <div class="panel-body" style="background-color:#f8f8f8;">
                                    <strong><?php echo $a_created_name[$ii];?></strong> <span style="color: #db2b5d;"> Won deal &#8360 <?php echo $d4;?> </span> "<?php echo $d2;?>" <?php if($a_created_name[$ii]!=$d3){ ?>(Deal Owner - <?php echo $d3; ?>.)<?php } ?><br>
                                    <?php if($d8!=""){ echo $d8."</br>"; }?>
                                    <span style="color: #666;"><?php echo $deal_conatct_person;?> - <?php echo $c1;?></span>
                                </div>
                                <?php } ?>
                                
                                <?php if((strtoupper($d9)==strtoupper("Lost"))){ ?>    
                                <div class="panel-heading icon" style=" border:2px solid #9d9a93;background-color:grey;color:#fff;">
                                    <i class="fa fa-dollar"></i>
                                </div>
                        
                                <div class="panel-body" style="background-color:#f8f8f8;">
                                    <strong><?php echo $a_created_name[$ii];?></strong>  Lost deal &#8360 <?php echo $d4;?> "<?php echo $d2;?>" <?php if($a_created_name[$ii]!=$d3){ ?>(Deal Owner - <?php echo $d3; ?>.)<?php } ?><br>
                                    <?php if($d8!=""){ echo $d8."</br>"; }?>
                                    <span style="color: #666;"><?php echo $deal_conatct_person;?> - <?php echo $c1;?></span>
                                </div>
                                <?php } ?>
            					
            					
                        </article>
                    <?php
                    }else if(strtoupper($a_type[$ii])==strtoupper("next action")){
                    ?>
                            
                        <article class="panel panel-default panel-outline">
                    
                            <div class="panel-heading icon" style=" border:2px solid #9d9a93;">
                                <i class="glyphicon glyphicon-ok"></i>
                            </div>
                    
                            <div class="panel-body" style="background-color:#f8f8f8;">
                            <?php
                                $rownext=$objactivity->salesactivitycreatednextactionview($cid, $c1, $c2, $c3);
                                foreach($rownext as $row_next){
                                    $nd1=$row_next['assign_name'];
                                    $d2=$row_next['na_descr'];
                                    $d3=$row_next['na_date'];
                                    $d4=$row_next['na_time'];
                                    $d5=$row_next['na_selectedoption'];
                                }
                                $short = array('','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov', 'Dec');
                                $m_array=explode("-",$d3);
                                $day=$m_array[2];
                                $month=intval($m_array[1]);
                                $year=$m_array[0];
                                
                            ?>
                                <strong><?php echo $a_created_name[$ii];?></strong>  <?php 
                                if(strtoupper($d5)==strtoupper("ASAP")){
                                    echo "Next action: ASAP \"".$d2."\" ";
                                }else if(strtoupper($d5)==strtoupper("Wainting")){
                                    echo "Next action: Waiting \"".$d2."\" ";
                                }else if(strtoupper($d5)==strtoupper("Date")){
                                    echo "Next action: ".$short[$month]." ".$day.", ".$year." \"".$d2."\" ";
                                }else if(strtoupper($d5)==strtoupper("Dateandtime")){
                                    echo "Next action: ".$short[$month]." ".$day.", ".$year." \"".$d4." ".$d2."\" ";
                                }else{
                                    echo "Queued action: \"".$d2."\" ";
                                }
                                if($nd1!=$a_created_name[$ii]){
                                echo " for ". $nd1;
                                }
                                echo "<br>".$note_cont_name." - ".$c1;
                                ?>
                            </div>
                    
                        </article>
                        
                    <?php }else if(($a_type[$ii]=="note")||($a_type[$ii]=="Note")||($a_type[$ii]=="call")||($a_type[$ii]=="Call")){?>
                    
                        <?php if(($a_type[$ii]=="note")||($a_type[$ii]=="Note")){ ?>
                        <article class="panel panel-default panel-outline">
                    
                            <div class="panel-heading icon" style=" border:2px solid #9d9a93;">
                                <i class="glyphicon glyphicon-list-alt"></i>
                            </div>
                    
                            <div class="panel-body" style="background-color:#f8f8f8;">
                                
                                <?php 
                                    $c1=$a_dateandtime[$ii];
                                    $c2=$a_created_by[$ii];
                                    $c3=$a_created_type[$ii];
                                    $d1="";$d2="";$d3="";
                                    $rowact=$objactivity->salesactivitycreatednoteview($cid, $c1, $c2, $c3);
                                    foreach($rowact as $row_act){
                                        $d1=$row_act['n_descr'];
                                        $d2=$row_act['dealname'];
                                        $d3=$row_act['n_date'];
                                    }
                                        ?>
                                <strong><?php echo $a_created_name[$ii]; ?></strong> <?php if($d2!=""){ echo " Note related to \"".$d2."\" :"; } ?> <?php echo $d1; ?><br>
                                 <?php echo $lastshownote." - ".$c1; ?>
                                
                            </div>
                    
                        </article>
                        <?php }else{ ?>
                        <article class="panel panel-default panel-outline">
                    
                            <div class="panel-heading icon" style=" border:2px solid #9d9a93;">
                                <i class="glyphicon glyphicon-earphone"></i>
                            </div>
                    
                            <div class="panel-body" style="background-color:#f8f8f8;">
                                <?php 
                                    $c1=$a_dateandtime[$ii];
                                    $c2=$a_created_by[$ii];
                                    $c3=$a_created_type[$ii];
                                    $rowact=$objactivity->salesactivitycreatedcallview($cid, $c1, $c2, $c3);
                                    foreach($rowact as $row_act){
                                        $phone_number=$row_act['phone_number'];
                                        $phone_type=$row_act['phone_type'];
                                        $c_descr=$row_act['c_descr'];
                                        $result_answer=$row_act['result_answer'];
                                        $c_date=$row_act['c_date'];
                                        $c_time=$row_act['c_time'];
                                        $contact_name=$ro_act['contact_name'];
                                    }
                                ?>
                                    <strong><?php echo $a_created_name[$ii]?></strong> <?php 
                            if($result_answer==""){
                            echo "Others";
                            }else if(($result_answer=="Left Message")||($result_answer=="No answer")){
                            echo $result_answer; 
                            }else{
                            echo " Conversation: ".$result_answer; 
                            }?>, Called at <?php echo $c_time; ?> on <?php echo $phone_number; ?> ( <?php echo $phone_type; ?> ) - <?php echo $c_descr; ?>
                            <br><?php echo $lastshownote." - ".$c1; ?>
                            </div>
                    
                        </article>
                        <?php
                        }
                        ?>
                    <?php
                    }else{
                    ?>
                        
                        <article class="panel panel-default panel-outline">
                    
                            <div class="panel-heading icon" style=" border:2px solid #9d9a93;">
                                <i class="glyphicon glyphicon-ok"></i>
                            </div>
                    
                            <div class="panel-body" style="background-color:#f8f8f8;">
                            <?php
                                $c1=$a_dateandtime[$ii];
                                $c2=$a_created_by[$ii];
                                $c3=$a_created_type[$ii];
                                $rownext=$objactivity->salesactivitycreatednextactionview($cid, $c1, $c2, $c3);
                                foreach($rownext as $row_next){
                                    $nd1=$row_next['assign_name'];
                                    $d2=$row_next['na_descr'];
                                    $d3=$row_next['na_date'];
                                    $d4=$row_next['na_time'];
                                }
                            ?>
                                <strong><?php echo $a_created_name[$ii];?></strong>  <?php echo $a_descr[$ii];?>: <?php echo $d3;?> <?php echo $d4;?> "<?php echo $d2;?>" for <?php echo $nd1;?>
                            </div>
                    
                        </article>
                    <?php
                    }
                    ?>
                <?php
                }
                ?>
                <?php
                }
                ?>
                
                </span>
            </div>
            
            <input type="hidden" value="<?php echo count($a_dateandtime);?>" name="startvalueall1" id="startvalueall1">
            <?php if($allcount>count($a_dateandtime)){?>
            <center><span class="form-control btn btn-lg btn-default" id="hidespanbuttonall" style="padding:5px 20px;width:90%;background-color:#e8e8e8;" onclick="allview('#startvalueall1', '<?php echo $allcount;?>', '<?php echo $cid;?>')">Show More..</span></center> 
            <?php } ?>
    
        </div>
        
        <script>
            function allview(textid, countupdate, cid){
                var value1=$(textid).val();
                /*alert(value1);
                alert(countupdate);*/
               /* alert(Number(value1)<Number(countupdate));*/
                if(Number(value1)<Number(countupdate)){
                var aa=Number(value1)+20;    
                    if(aa<countupdate){
                        $(textid).val(aa);
                    }else{
                        $("#hidespanbuttonall").hide(); 
                    }
                    
                    $.ajax({
                        url:"employee_activity_individual_intermediate.php",
                        type:"post",
                        data:{startvalueall:value1, cid:cid},
                        success:function(respond){
                            //alert(respond);
                            $("#allviewajax").append(respond);
                        }
                    });
                     
                }else{
                   //$("#hidespanbuttonnorecall").hide(); 
                }
            }
        </script>
            
        <div id="Notes" class="tabcontent">
            
            <div class="timeline" style="top:-10px;">
                
                <div class="line text-muted"></div>
                
                <span id="notecallviewajax">
                <?php
                //echo count($cn_dateandtime);
                for($ii=0;$ii<(count($cn_dateandtime));$ii++){
                    $rowact=$objactivity->salescontactdetails($cid);
                    foreach($rowact as $row_act){
                        $cont_first_name=$row_act['cont_first_name'];
                        $cont_last_name=$row_act['cont_last_name'];
                        $org_name=$row_act['org_name'];
                    }
                    $lastshownote="";
                    if($cont_first_name!=""){
                        $lastshownote.=$cont_first_name." ";
                    }
                    $lastshownote.=$cont_last_name;
                    //$cn_dateandtime $cn_org_id $cn_created_by $cn_created_name $cn_created_type
                    //$cn_type $cn_subtype $cn_changed $cn_descr $cn_old_descr $cn_new_descr
                ?>
                
                <?php if(($cn_type[$ii]=="note")||($cn_type[$ii]=="Note")){ ?>
                <article class="panel panel-default panel-outline">
            
                    <div class="panel-heading icon" style=" border:2px solid #9d9a93;">
                        <i class="glyphicon glyphicon-list-alt"></i>
                    </div>
            
                    <div class="panel-body" style="background-color:#f8f8f8;">
                        
                        <?php 
                            $c1=$cn_dateandtime[$ii];
                            $c2=$cn_created_by[$ii];
                            $c3=$cn_created_type[$ii];
                            $d1="";$d2="";$d3="";
                            $rowact=$objactivity->salesactivitycreatednoteview($cid, $c1, $c2, $c3);
                            foreach($rowact as $row_act){
                                $d1=$row_act['n_descr'];
                                $d2=$row_act['dealname'];
                                $d3=$row_act['n_date'];
                            }
                                ?>
                        <strong><?php echo $cn_created_name[$ii]; ?></strong> <?php if($d2!=""){ echo " Note related to \"".$d2."\" :"; } ?> <?php echo $d1; ?><br>
                         <?php echo $lastshownote." - ".$c1; ?>
                        
                    </div>
            
                </article>
                <?php }else{ ?>
                <article class="panel panel-default panel-outline">
            
                    <div class="panel-heading icon" style=" border:2px solid #9d9a93;">
                        <i class="glyphicon glyphicon-earphone"></i>
                    </div>
            
                    <div class="panel-body" style="background-color:#f8f8f8;">
                        <?php 
                            $c1=$cn_dateandtime[$ii];
                            $c2=$cn_created_by[$ii];
                            $c3=$cn_created_type[$ii];
                            $rowact=$objactivity->salesactivitycreatedcallview($cid, $c1, $c2, $c3);
                            foreach($rowact as $row_act){
                                $phone_number=$row_act['phone_number'];
                                $phone_type=$row_act['phone_type'];
                                $c_descr=$row_act['c_descr'];
                                $result_answer=$row_act['result_answer'];
                                $c_date=$row_act['c_date'];
                                $c_time=$row_act['c_time'];
                                $contact_name=$ro_act['contact_name'];
                            }
                        ?>
                            <strong><?php echo $cn_created_name[$ii]; ?></strong> <?php 
                            if($result_answer==""){
                            echo "Others";
                            }else if(($result_answer=="Left Message")||($result_answer=="No answer")){
                            echo $result_answer; 
                            }else{
                            echo " Conversation: ".$result_answer; 
                            }?>, Called at <?php echo $c_time; ?> on <?php echo $phone_number; ?> ( <?php echo $phone_type; ?> ) - <?php echo $c_descr; ?>
                            <br><?php echo $lastshownote." - ".$c1; ?>
                    </div>
            
                </article>
                <?php
                }
                }
                ?>
                </span>
                
            </div>
                <input type="hidden" value="<?php echo count($cn_dateandtime);?>" name="startvaluenotecall1" id="startvaluenotecall1">
                <?php if($notecallcount>count($cn_dateandtime)){?>
                <center><span class="form-control btn btn-lg btn-default" id="hidespanbuttonnorecall" style="padding:5px 20px;width:90%;background-color:#e8e8e8;" onclick="notecallview('#startvaluenotecall1', '<?php echo $notecallcount;?>', '<?php echo $cid;?>')">Show More..</span></center> 
                <?php } ?>
        </div>
        
        <script>
            function notecallview(textid, countupdate, cid){
                var value1=$(textid).val();
                /*alert(value1);
                alert(countupdate);*/
               /* alert(Number(value1)<Number(countupdate));*/
                if(Number(value1)<Number(countupdate)){
                var aa=Number(value1)+20;    
                    if(aa<countupdate){
                        $(textid).val(aa);
                    }else{
                        $("#hidespanbuttonnorecall").hide(); 
                    }
                    
                    $.ajax({
                        url:"employee_activity_individual_intermediate.php",
                        type:"post",
                        data:{startvaluenotecall:value1, cid:cid},
                        success:function(respond){
                            //alert(respond);
                            $("#notecallviewajax").append(respond);
                        }
                    });
                     
                }else{
                   //$("#hidespanbuttonnorecall").hide(); 
                }
            }
        </script>
        
            
        <div id="Deals" class="tabcontent">
            
            <div class="timeline" style="top:-10px;">
                
                <div class="line text-muted"></div>
        
                <span id="viewdealajax">
                <?php
                //print_r($d_dateandtime);
                for($ii=0;$ii<count($d_dateandtime);$ii++){
                    $rowact=$objactivity->salescontactdetails($cid);
                    foreach($rowact as $row_act){
                        $cont_first_name=$row_act['cont_first_name'];
                        $cont_last_name=$row_act['cont_last_name'];
                        $org_name=$row_act['org_name'];
                    }
                    $deal_conatct_person="";
                    if($cont_first_name!=""){
                        $deal_conatct_person.=$cont_first_name." ";
                    }
                    $deal_conatct_person.=$cont_last_name;
                    //$d_dateandtime $d_org_id $d_created_by $d_created_name $d_created_type $d_type $d_subtype $d_changed $d_descr $d_old_descr $d_new_descr
                ?>
                <?php if(($d_subtype[$ii]!="update")&&($d_subtype[$ii]!="updated")){ ?>
                <article class="panel panel-default panel-outline">
            
                        <?php 
                            $c1=$d_dateandtime[$ii];
                            $c2=$d_created_by[$ii];
                            $c3=$d_created_type[$ii];
                            $rowact=$objactivity->salesactivitycreateddealview($cid, $c1, $c2, $c3);
                            foreach($rowact as $row_act){
                                $d1=$row_act['firstname'];
                                $d2=$row_act['d_deal_name'];
                                $d3=$row_act['deal_by'];
                                $d4=$row_act['d_amount'];
                                $d5=$row_act['d_month'];
                                $d6=$row_act['d_commission_percentage'];
                                $d7=$row_act['d_commission_amount'];
                                $d8=$row_act['d_descr'];
                                $d9=$row_act['d_stage_name'];
                                $d10=$row_act['d_date'];
                                $d11=$row_act['d_closedate'];
                                $d12=$row_act['orgname'];
                            }
                        ?>
                            
                                <?php if((strtoupper($d9)!=strtoupper("Won"))&&(strtoupper($d9)!=strtoupper("Lost"))){ ?>    
                                <div class="panel-heading icon" style=" border:2px solid #9d9a93;background-color:grey;color:#fff;">
                                    <i class="fa fa-dollar"></i>
                                </div>
                        
                                <div class="panel-body" style="background-color:#f8f8f8;">
                                    <strong><?php echo $d_created_name[$ii];?></strong>
                                    <span style="color: #db2b5d;"><?php echo $d_descr[$ii];?> &#8360 <?php echo $d4;?> </span> 
                                    (&#8360 <?php if(($d4!=0)&&($d5!=0)){ echo ($d4/$d5);?> x <?php echo $d5;?> months) <?php } echo $d9;?> chance it will close <?php echo $d11;?> "<?php echo $d2;?>"<?php if($d_created_name[$ii]!=$d3){ ?>(Deal Owner - <?php echo $d3; ?>.)<?php } ?><br>
                                    <?php if($d8!=""){ echo $d8."</br>"; }?>
                                    <span style="color: #666;"><?php echo $deal_conatct_person;?> - <?php echo $c1;?></span>
                                </div>
                                <?php } ?>
                                
                                <?php if((strtoupper($d9)==strtoupper("Won"))){ ?>    
                                <div class="panel-heading icon" style=" border:2px solid #9d9a93;background-color:#54b0fe;color:#fff;">
                                    <i class="fa fa-dollar"></i>
                                </div>
                        
                                <div class="panel-body" style="background-color:#f8f8f8;">
                                    <strong><?php echo $d_created_name[$ii];?></strong> <span style="color: #db2b5d;"> Won deal &#8360 <?php echo $d4;?> </span> "<?php echo $d2;?>" <?php if($d_created_name[$ii]!=$d3){ ?>(Deal Owner - <?php echo $d3; ?>.)<?php } ?><br>
                                    <?php if($d8!=""){ echo $d8."</br>"; }?>
                                    <span style="color: #666;"><?php echo $deal_conatct_person;?> - <?php echo $c1;?></span>
                                </div>
                                <?php } ?>
                                
                                <?php if((strtoupper($d9)==strtoupper("Lost"))){ ?>    
                                <div class="panel-heading icon" style=" border:2px solid #9d9a93;background-color:grey;color:#fff;">
                                    <i class="fa fa-dollar"></i>
                                </div>
                        
                                <div class="panel-body" style="background-color:#f8f8f8;">
                                    <strong><?php echo $d_created_name[$ii];?></strong>  Lost deal &#8360 <?php echo $d4;?> "<?php echo $d2;?>" <?php if($d_created_name[$ii]!=$d3){ ?>(Deal Owner - <?php echo $d3; ?>.)<?php } ?><br>
                                    <?php if($d8!=""){ echo $d8."</br>"; }?>
                                    <span style="color: #666;"><?php echo $deal_conatct_person;?> - <?php echo $c1;?></span>
                                </div>
                                <?php } ?>
            
                </article>
                <?php }else{ ?>
                <article class="panel panel-default  panel-outline" >
            
                    <div class="panel-heading icon icon1" style=" border:2px solid #9d9a93;">
                        
                    </div>
            
                    <div class="panel-body">
                        <strong><?php echo $d_created_name[$ii];?></strong> Changed Deals "<?php echo $d_de_name[$ii];?>" <?php echo $d_changed[$ii];?> from  <?php echo $d_old_descr[$ii];?> to  <?php echo $d_new_descr[$ii];?> for <?php echo $deal_conatct_person;?> - <?php echo $c1;?>
                    </div>
            
                </article>
                <?php
                }
                }
                ?>
                </span>
            </div>
            <?php if($dealcount>count($d_dateandtime)){ ?>
                <input type="hidden" value="<?php echo count($d_dateandtime);?>" name="startvalue" id="startvaluedealbtn">
                <center><span class="form-control btn btn-lg btn-default" id="hidespanbuttondealclick" style="padding:5px 20px;width:90%;background-color:#e8e8e8;" onclick="dealfunview('#startvaluedealbtn', '<?php echo $dealcount;?>', '<?php echo $cid;?>')">Show More..</span></center> 
            <?php } ?>
            
    
        </div>
        <script>
            function dealfunview(textid, countupdate, cid){
                var value1=$(textid).val();
                if(Number(value1)<Number(countupdate)){
                //alert(value1);
                var aa=Number(value1)+20;    
                    if(aa<Number(countupdate)){
                        $(textid).val(aa);
                    }else{
                        $("#hidespanbuttondealclick").hide(); 
                    }
                    
                    $.ajax({
                        url:"employee_activity_individual_intermediate.php",
                        type:"post",
                        data:{startvaluedeal:value1, cid:cid},
                        success:function(respond){
                            //alert(respond);
                            $("#viewdealajax").append(respond);
                        }
                    });
                     
                }else{
                   $("#hidespanbuttondealclick").hide(); 
                }
            }
        </script>
            
        <div id="Actions" class="tabcontent">
            
            <div class="timeline" style="top:-10px;">
                
                <div class="line text-muted"></div>
        
                <span id="actionnextviewajax">
                <?php
                //print_r($na_subtype);
                for($ii=0;$ii<count($na_dateandtime);$ii++){
                    $rowact=$objactivity->salescontactdetails($cid);
                    foreach($rowact as $row_act){
                        $cont_first_name=$row_act['cont_first_name'];
                        $cont_last_name=$row_act['cont_last_name'];
                        $org_name=$row_act['org_name'];
                    }
                    $note_cont_name="";
                    if($cont_first_name!=""){
                        $note_cont_name.=$cont_first_name." ";
                    }
                    $note_cont_name.=$cont_last_name;
                    if($org_name!=""){
                        $note_cont_name1=$note_cont_name." of ". $org_name." ";
                    }else{
                        $note_cont_name1=$note_cont_name;
                    }
                    $c1=$na_dateandtime[$ii];
                    $c2=$na_created_by[$ii];
                    $c3=$na_created_type[$ii];
                    //$na_dateandtime $na_org_id $na_created_by $na_created_name $na_created_type $na_type $na_subtype $na_changed $na_descr $na_old_descr $na_new_descr
                ?>
                <?php
                $subty=$na_subtype[$ii];
                if(strtoupper($subty)==strtoupper("created")){
                ?>
                <article class="panel panel-default panel-outline">
            
                    <div class="panel-heading icon" style=" border:2px solid #9d9a93;">
                        <i class="glyphicon glyphicon-ok"></i>
                    </div>
            
                    <div class="panel-body" style="background-color:#f8f8f8;">
                    <?php
                        $rownext=$objactivity->salesactivitycreatednextactionview($cid, $c1, $c2, $c3);
                        foreach($rownext as $row_next){
                            $nd1=$row_next['assign_name'];
                            $d2=$row_next['na_descr'];
                            $d3=$row_next['na_date'];
                            $d4=$row_next['na_time'];
                            $d5=$row_next['na_selectedoption'];
                        }
                        $short = array('','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov', 'Dec');
                        $m_array=explode("-",$d3);
                        $day=$m_array[2];
                        $month=intval($m_array[1]);
                        $year=$m_array[0];
                        
                    ?>
                        <strong><?php echo $na_created_name[$ii];?></strong>  <?php 
                        if(strtoupper($d5)==strtoupper("ASAP")){
                            echo "Next action: ASAP \"".$d2."\" ";
                        }else if(strtoupper($d5)==strtoupper("Wainting")){
                            echo "Next action: Waiting \"".$d2."\" ";
                        }else if(strtoupper($d5)==strtoupper("Date")){
                            echo "Next action: ".$short[$month]." ".$day.", ".$year." \"".$d2."\" ";
                        }else if(strtoupper($d5)==strtoupper("Dateandtime")){
                            echo "Next action: ".$short[$month]." ".$day.", ".$year." \"".$d4." ".$d2."\" ";
                        }else{
                            echo "Queued action: \"".$d2."\" ";
                        }
                        if($nd1!=$na_created_name[$ii]){
                        echo " for ". $nd1;
                        }
                        echo "<br>".$note_cont_name." - ".$c1;
                        ?>
                    </div>
            
                </article>
                
                <?php
                }else{
                ?>
                <article class="panel panel-default  panel-outline" >
            
                    <div class="panel-heading icon icon1" style=" border:2px solid #9d9a93;">
                        
                    </div>
            
                    <div class="panel-body">
                        <?php if(strtoupper($na_changed[$ii])==strtoupper("Assigned")){
                            $empid=$na_old_descr[$ii];
                            $olid=$objemployee->salesemployeename($empid);
                            $empid=$na_new_descr[$ii];
                            $newid=$objemployee->salesemployeename($empid);
                            ?>
                            <strong><?php echo $na_created_name[$ii];?></strong>  <?php echo $na_descr[$ii];?>  from <?php echo $olid;?>  to <?php echo $newid;?> <?php echo " for ".$note_cont_name1." - ".$c1;?>
                        <?php }else{?>
                            <strong><?php echo $na_created_name[$ii];?></strong>  <?php echo $na_descr[$ii];?> <?php echo " for ".$note_cont_name1." - ".$c1;?>
                        <?php }?>
                    </div>
            
                </article>
                
                <?php
                }
                }
                ?>
                </span>
                
            </div>
            <?php if($nextactioncount>count($na_created_name)){ ?>
                <input type="hidden" value="<?php echo count($na_created_name);?>" name="startvalue" id="startvaluenextactionbtn">
                <center><span class="form-control btn btn-lg btn-default" id="hidespanbuttonnextactionclick" style="padding:5px 20px;width:90%;background-color:#e8e8e8;" onclick="nextactionfunview('#startvaluenextactionbtn', '<?php echo $nextactioncount;?>', '<?php echo $cid;?>')">Show More..</span></center> 
            <?php } ?>
        </div>
        
        <script>
            function nextactionfunview(textid, countupdate, cid){
                var value1=$(textid).val();
                //alert(countupdate);
                if(Number(value1)<Number(countupdate)){
                //alert(value1);
                var aa=Number(value1)+20;    
                    if(aa<Number(countupdate)){
                        $(textid).val(aa);
                    }else{
                        $("#hidespanbuttonnextactionclick").hide(); 
                    }
                    
                    $.ajax({
                        url:"employee_activity_individual_intermediate.php",
                        type:"post",
                        data:{startvaluenextaction:value1, cid:cid},
                        success:function(respond){
                            //alert(respond);
                            $("#actionnextviewajax").append(respond);
                        }
                    });
                     
                }else{
                   $("#hidespanbuttonnextactionclick").hide(); 
                }
            }
        </script>
            
        <div id="Emails" class="tabcontent">
            
            <div class="timeline" style="top:-10px;">
                
                <div class="line text-muted"></div>
        
                <article class="panel panel-default panel-outline">
            
                    <div class="panel-heading icon" style=" border:2px solid #9d9a93;">
                        <i class="glyphicon glyphicon-list-alt"></i>
                    </div>
            
                    <div class="panel-body" style="background-color:#f8f8f8;">
                        <strong>Someone4</strong>
                    </div>
            
                </article>
        
                <article class="panel panel-default panel-outline">
            
                    <div class="panel-heading icon" style=" border:2px solid #9d9a93;">
                        <i class="glyphicon glyphicon-earphone"></i>
                    </div>
            
                    <div class="panel-body" style="background-color:#f8f8f8;">
                        <strong>Someone4</strong>
                    </div>
            
                </article>
        
                <article class="panel panel-default panel-outline">
            
                    <div class="panel-heading icon" style=" border:2px solid #9d9a93;">
                        <i class="glyphicon glyphicon-ok"></i>
                    </div>
            
                    <div class="panel-body" style="background-color:#f8f8f8;">
                        <strong>Someone4</strong>
                    </div>
            
                </article>
        
                <article class="panel panel-default panel-outline">
            
                    <div class="panel-heading icon" style=" border:2px solid #9d9a93;background-color:#54b0fe;color:#fff;">
                        <i class="fa fa-dollar"></i>
                    </div>
            
                    <div class="panel-body" style="background-color:#f8f8f8;"
                        <strong>Someone4</strong>
                    </div>
            
                </article>
                
                <article class="panel panel-default  panel-outline" >
            
                    <div class="panel-heading icon icon1" style=" border:2px solid #9d9a93;">
                        
                    </div>
            
                    <div class="panel-body">
                        <strong>Someone4</strong>
                    </div>
            
                </article>
                
            </div>
    
        </div>
        
            
        <div id="Updates" class="tabcontent">
            
            <div class="timeline" style="top:-10px;">
                
                <div class="line text-muted"></div>
                
                <span id="updateviewajax">
                    <?php
                    for($ii=0;$ii<count($u_dateandtime);$ii++){
                        $rowact=$objactivity->salescontactdetails($cid);
                        foreach($rowact as $row_act){
                            $cont_first_name=$row_act['cont_first_name'];
                            $cont_last_name=$row_act['cont_last_name'];
                            $org_name=$row_act['org_name'];
                        }
                        $lastshow=" for ";
                        if($cont_first_name!=""){
                            $lastshow.=$cont_first_name." ";
                        }
                        $lastshow.=$cont_last_name;
                        if($org_name!=""){
                            $lastshow.=" of ".$org_name;
                        }
                        $deal_conatct_person="";
                        if($cont_first_name!=""){
                            $deal_conatct_person.=$cont_first_name." ";
                        }
                        $deal_conatct_person.=$cont_last_name;
                            
                        $note_cont_name="";
                        if($cont_first_name!=""){
                            $note_cont_name.=$cont_first_name." ";
                        }
                        $note_cont_name.=$cont_last_name;
                        if($org_name!=""){
                            $note_cont_name1=$note_cont_name." of ". $org_name." ";
                        }else{
                            $note_cont_name1=$note_cont_name;
                        }
                            $c1=$u_dateandtime[$ii];
                            $c2=$u_created_by[$ii];
                            $c3=$u_created_type[$ii];
                        //$u_org_id $u_created_by $u_created_type $u_type $u_subtype $u_changed $u_descr $u_old_descr $u_new_descr
                    ?>
                <?php if(($u_type[$ii]=="contact")||($u_type[$ii]=="Contact")){?>
                    <article class="panel panel-default panel-outline">
                
                        <div class="panel-heading icon" style=" border:2px solid #9d9a93;font-size: 17px;vertical-align: middle;line-height: 35px;">
                            <i class="glyphicon glyphicon-user"></i>
                        </div>
                
                        <div class="panel-body" style="background-color:#f8f8f8;">
                            
                            <?php 
                                $c1=$u_dateandtime[$ii];
                                $c2=$u_created_by[$ii];
                                $c3=$u_created_type[$ii];
                                $rowact=$objactivity->salescontactdetails($cid);
                                foreach($rowact as $row_act){
                                    $cont_first_name=$row_act['cont_first_name'];
                                    $cont_last_name=$row_act['cont_last_name'];
                                    $org_name=$row_act['org_name'];
                                }
                                    ?>
                            <strong><?php echo $u_created_name[$ii]; ?>.</strong> 
                            <?php
                            if(($u_changed[$ii]=="Tag")||($u_changed[$ii]=="tag")){
                                echo "changed Tag from ".$u_old_descr[$ii]." to ".$u_new_descr[$ii]." ".$lastshow." - ".$c1 ;
                            }elseif(($u_changed[$ii]=="status")||($u_changed[$ii]=="Status")){
                                echo "changed Status from ".$u_old_descr[$ii]." to ".$u_new_descr[$ii]." ".$lastshow." - ".$c1 ;
                            }elseif(($u_changed[$ii]=="Lead source")||($u_changed[$ii]=="lead source")){
                                echo "changed Lead Source from ".$u_old_descr[$ii]." to ".$u_new_descr[$ii]." ".$lastshow." - ".$c1 ;
                            }elseif(($u_changed[$ii]=="Owner")||($u_changed[$ii]=="owner")){
                                echo "changed Owner ".$u_old_descr[$ii]." to ".$u_new_descr[$ii]." ".$lastshow." - ".$c1 ;
                            }elseif(($u_changed[$ii]=="Firstname")||($u_changed[$ii]=="firstname")){
                                echo "edit firstname ".$lastshow." - ".$c1 ;
                            }else{
                            ?>
                            edit lastname <?php echo $lastshow; ?> - <?php echo $c1; ?>
                            <?php
                            }
                            ?>
                            
                        </div>
                
                    </article>
                    <?php }else if(($u_type[$ii]=="deal")||($u_type[$ii]=="Deal")){ ?>
                            <?php
                            $c1=$u_dateandtime[$ii];
                            $c2=$u_created_by[$ii];
                            $c3=$u_created_type[$ii];
                            ?>
                        <article class="panel panel-default  panel-outline" >
                    
                            <div class="panel-heading icon icon1" style=" border:2px solid #9d9a93;">
                                
                            </div>
                    
                            <div class="panel-body">
                                <strong><?php echo $u_created_name[$ii];?></strong> Changed Deals "<?php echo $u_de_name[$ii];?>" <?php echo $u_changed[$ii];?> from  <?php echo $u_old_descr[$ii];?> to  <?php echo $u_new_descr[$ii];?> for <?php echo $deal_conatct_person;?> - <?php echo $u_dateandtime[$ii];?>
                            </div>
                    
                        </article>
                <?php
                }else if(strtoupper($u_type[$ii])==strtoupper("next action")){
                ?>
                <article class="panel panel-default  panel-outline" >
            
                    <div class="panel-heading icon icon1" style=" border:2px solid #9d9a93;">
                        
                    </div>
            
                    <div class="panel-body">
                        <?php if(strtoupper($a_changed[$ii])==strtoupper("Assigned")){
                            $empid=$u_old_descr[$ii];
                            $olid=$objemployee->salesemployeename($empid);
                            $empid=$u_new_descr[$ii];
                            $newid=$objemployee->salesemployeename($empid);
                            ?>
                            <strong><?php echo $u_created_name[$ii];?></strong>  <?php echo $u_descr[$ii];?>  from <?php echo $olid;?>  to <?php echo $newid;?> <?php echo " for ".$note_cont_name1." - ".$c1;?>
                        <?php }else{?>
                            <strong><?php echo $u_created_name[$ii];?></strong>  <?php echo $u_descr[$ii];?> <?php echo " for ".$note_cont_name1." - ".$c1;?>
                        <?php }?>
                    </div>
            
                </article>
                    <?php }else if(($u_type[$ii]=="note")||($u_type[$ii]=="Note")){ ?>
               <!-- <article class="panel panel-default panel-outline">
            
                    <div class="panel-heading icon" style=" border:2px solid #9d9a93;">
                        <i class="glyphicon glyphicon-list-alt"></i>
                    </div>
            
                    <div class="panel-body" style="background-color:#f8f8f8;">
                        
                        <?php 
                            $c1=$u_dateandtime[$ii];
                            $c2=$u_created_by[$ii];
                            $c3=$u_created_type[$ii];
                            $rowact=$objactivity->salesactivitycreatednoteview($cid, $c1, $c2, $c3);
                            foreach($rowact as $row_act){
                                $d1=$row_act['n_descr'];
                                $d2=$row_act['dealname'];
                                $d3=$row_act['n_date'];
                            }
                                ?>
                        <strong><?php echo $u_created_name[$ii]; ?></strong> <?php echo $u_descr[$ii]; ?> "<?php echo $d2; ?>": <?php echo $d1; ?><br>
                         <?php echo $d3; ?>
                        
                    </div>
            
                </article>-->
                <?php }else if(($u_type[$ii]=="call")||($u_type[$ii]=="Call")){ ?>
                <!--<article class="panel panel-default panel-outline">
            
                    <div class="panel-heading icon" style=" border:2px solid #9d9a93;">
                        <i class="glyphicon glyphicon-earphone"></i>
                    </div>
            
                    <div class="panel-body" style="background-color:#f8f8f8;">
                        <?php 
                            $c1=$u_dateandtime[$ii];
                            $c2=$u_created_by[$ii];
                            $c3=$u_created_type[$ii];
                            $rowact=$objactivity->salesactivitycreatedcallview($cid, $c1, $c2, $c3);
                            foreach($rowact as $row_act){
                                $phone_number=$row_act['phone_number'];
                                $phone_type=$row_act['phone_type'];
                                $c_descr=$row_act['c_descr'];
                                $result_answer=$row_act['result_answer'];
                                $c_date=$row_act['c_date'];
                                $c_time=$row_act['c_time'];
                                $contact_name=$ro_act['contact_name'];
                            }
                        ?>
                            <strong><?php echo $u_created_name[$ii]; ?></strong> <?php echo $u_descr[$ii]; ?> <?php echo $result_answer; ?>, Called <?php echo $contact_name; ?> at <?php echo $c_time; ?> on <?php echo $phone_number; ?> ( <?php echo $phone_type; ?> ) - <?php echo $c_descr; ?>
                            <br><?php echo $c_date; ?>
                    </div>
            
                </article>-->
                <?php
                }else{
                ?>
                        
                        <article class="panel panel-default  panel-outline" >
                    
                            <div class="panel-heading icon icon1" style=" border:2px solid #9d9a93;">
                                
                            </div>
                    
                            <div class="panel-body">
                                <strong><?php echo $u_created_name[$ii];?></strong>
                                <span style="float: none;display: inline;margin: 0;color: #777;font-family: 'Open Sans', Arial, Helvetica, sans-serif;font-weight: normal;max-width: 78%;">
                                    &nbsp;<?php echo $u_descr[$ii];?> &nbsp;<?php echo $u_changed[$ii];?>&nbsp; from &nbsp;<?php echo $u_old_descr[$ii];?> &nbsp;to &nbsp; <?php echo $u_new_descr[$ii];?>
                                </span>
                            </div>
                    
                        </article>
                    <?php
                }
                    }
                    ?>
                </span>
            </div>
            <?php if($updatecount>count($u_dateandtime)){ ?>
            <input type="hidden" value="<?php echo count($u_dateandtime);?>" name="startvalue" id="startvalue">
                <center><span class="form-control btn btn-lg btn-default" id="hidespanbuttonupdate" style="padding:5px 20px;width:90%;background-color:#e8e8e8;" onclick="updateview('#startvalue', '<?php echo $updatecount;?>', '<?php echo $cid;?>')">Show More..</span></center> 
            <?php } ?>        
        </div>
        
        <script>
            function updateview(textid, countupdate, cid){
                var value1=$(textid).val();
                /*alert(countupdate);
                alert(value1);*/
                if(Number(value1)<Number(countupdate)){
                var aa=Number(value1)+20;    
                    if(aa<Number(countupdate)){
                        $(textid).val(aa);
                    }else{
                        $("#hidespanbuttonupdate").hide(); 
                    }
                    
                    $.ajax({
                        url:"employee_activity_individual_intermediate.php",
                        type:"post",
                        data:{startvalueupdate:value1, cid:cid},
                        success:function(respond){
                            //alert(respond);
                            $("#updateviewajax").append(respond);
                        }
                    });
                     
                }else{
                   $("#hidespanbuttonupdate").hide(); 
                }
            }
        </script>
        
    </body>
</html>
<?php
}else{
echo "<script> location.replace('http://fieldcloud.in/Login.php') </script>";
}?>