<?php
session_start();
$companyname=$_SESSION['companyname'];
$adminemailid=$_SESSION['emailid'];
$companytype=$_SESSION['companytype'];
//$companytype="HCM,Sales,Service,Project";
if($companytype=="Sales"){
$nav_show=0;}
else{
$nav_show=1;    
}
$company_type_array=explode(",",$companytype);
require_once('../Control/address.php');
$objaddress=new addressctrl();
require_once('../Control/sales.php');
$objsales=new salesctrl();
require_once('../Control/contact.php');
$objcontact=new contactctrl();
if(($adminemailid !="")&&($companyname!="")){
?>

<!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>
        <script src="../../Bootbox/bootbox.min.js"></script>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-sweetalert/1.0.1/sweetalert.min.css">
        <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-sweetalert/1.0.1/sweetalert.min.js"></script>
        <script src="../../Js/bootstrapAlert.js"></script>
        <link href="../../font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet">
        <link href="deal_action_stream.css" rel="stylesheet">
        <script src="deal_action_stream.js"></script>
        
        <!-- clockpicker -->
        <link href="../../Clockpicker/bootstrap-clockpicker.min.css" rel="stylesheet" type="text/css" />
        <link href="../../Clockpicker/github.min.css" rel="stylesheet" type="text/css" />
        <script src="../../Clockpicker/jquery-clockpicker.min.js"></script>
    
        <!--bootstrap datepicker-->
        <link href="../../Datepicker/bootstrap-datepicker.css" rel="stylesheet" type="text/css" />
        <script src="../../Datepicker/bootstrap-datepicker.js"></script>
        <!-- datepicker-->
        <!--<link href="../../Datepicker/jquery-ui.css" rel="stylesheet" type="text/css" />
        <script src="../../Datepicker/jquery-ui.js"></script>-->
    
    <style>
        .checkbox label:after, 
        .radio label:after {
            content: '';
            display: table;
            clear: both;
        }
        
        .checkbox .cr,
        .radio .cr {
            position: relative;
            display: inline-block;
            border: 1px solid #a9a9a9;
            border-radius: .25em;
            width: 1.3em;
            height: 1.3em;
            float: left;
            margin-right: .5em;
        }
        
        .radio .cr {
            border-radius: 50%;
        }
        
        .checkbox .cr .cr-icon,
        .radio .cr .cr-icon {
            position: absolute;
            font-size: .8em;
            line-height: 0;
            top: 50%;
            left: 20%;
        }
        
        .radio .cr .cr-icon {
            margin-left: 0.04em;
        }
        
        .checkbox label input[type="checkbox"],
        .radio label input[type="radio"] {
            display: none;
        }
        
        .checkbox label input[type="checkbox"] + .cr > .cr-icon,
        .radio label input[type="radio"] + .cr > .cr-icon {
            transform: scale(3) rotateZ(-20deg);
            opacity: 0;
            transition: all .3s ease-in;
        }
        
        .checkbox label input[type="checkbox"]:checked + .cr > .cr-icon,
        .radio label input[type="radio"]:checked + .cr > .cr-icon {
            transform: scale(1) rotateZ(0deg);
            opacity: 1;
        }
        
        .checkbox label input[type="checkbox"]:disabled + .cr,
        .radio label input[type="radio"]:disabled + .cr {
            opacity: .5;
        }
    </style>
    
   
<style>
    #loadover{
    width:100%;
    height:100%;
    position:fixed;
    z-index:9999;
    background:url("../../Images/loading.gif") no-repeat center center rgba(0,0,0,0.25)
}
</style>
<script>
    document.onreadystatechange = function () {
  var state = document.readyState
  if (state == 'interactive') {
          $('#contentover').hide();
  } else if (state == 'complete') {
      setTimeout(function(){
         document.getElementById('interactive');
          $('#loadover').hide();
          $('#contentover').show();
      },1000);
  }
}
</script> 
    </head>
    
    <body>
        <?php
    if($nav_show==1){ ?>
    <nav class="navbar navbar-inverse">
      <div class="container-fluid">
        
        <ul class="nav navbar-nav">
          <li class="active"><a href="http://fieldcloud.in/main_dashboard.php">Home</a></li>
      <?php  if(in_array("Project",$company_type_array)){ ?>  <li><a href="http://fieldcloud.in/Web/Task/View/dashboard.php">Project</a></li> <?php } ?>
      <?php  if(in_array("HCM",$company_type_array)){ ?>     <li><a href="http://fieldcloud.in/hcm_dashboard.php">HCM</a></li> <?php } ?>
       <?php  if(in_array("Service",$company_type_array)){ ?>     <li><a href="http://fieldcloud.in/Web/View/dashboard1.php">Service</a></li> <?php } ?>
        </ul>
      </div>
    </nav>
<?php }?>
        <div id="loadover"></div>        
        <div id="contentover"> 
            <div class="view" style="padding-top:20px;">
            <div style="margin:50px 10px 10px 10px;border-style: solid;">
            <div class="navbar-inverse" style="margin-top:-2px;">
                <center><span style="color:white;"><b>Active Stream</b></span></center>
            </div>
            <div class="body" style="padding:30px 30px 10px 30px;">
        <div id="result"></div>
        <div id="activitystream">
            <?php
            $result_contact1=$objsales->salesselectall($companyname, $adminemailid, "viewcontact", "no");
            $cont_id=array();
            $i=0;
            foreach($result_contact1 as $row_contact1){
                $cont_id[$i]=$row_contact1['c_id'];
                $i++;
            }
            
            $i=0;
            $result_contact=$objsales->salesselectall($companyname, $adminemailid, "viewcontact", "no");
            foreach($result_contact as $row_contact){
                $c_companyname=$row_contact['c_companyname'];
                $c_emailid=$row_contact['c_emailid'];
                $c_delete=$row_contact['c_delete']; 
                $c_id=$row_contact['c_id'];
                $c_title=$row_contact['c_title'];
                $c_fname=$row_contact['c_fname'];
                $c_lname=$row_contact['c_lname'];
                $c_jobtitle=$row_contact['c_jobtitle'];
                $c_a_line=$row_contact['c_a_line'];
                $c_a_city=$row_contact['c_a_city'];
                $c_a_state=$row_contact['c_a_state'];
                $c_a_country=$row_contact['c_a_country'];
                $c_a_pincode=$row_contact['c_a_pincode'];
                $c_background=$row_contact['c_background'];
                $c_owner_id=$row_contact['c_owner_id'];
                $c_private=$row_contact['c_private'];
                $c_dob=$row_contact['c_dob'];
                $c_dtime=$row_contact['c_dtime'];
                $c_create_by=$row_contact['c_create_by'];
                $c_create_type=$row_contact['c_create_type'];
                $o_id=$row_contact['o_id'];
                $o_name=$row_contact['o_name'];
                $o_desc=$row_contact['o_desc'];
                $o_phone=$row_contact['o_phone'];
                $o_url=$row_contact['o_url'];
                $o_line=$row_contact['o_line'];
                $o_city=$row_contact['o_city'];
                $o_state=$row_contact['o_state'];
                $o_country=$row_contact['o_country'];
                $o_pincode=$row_contact['o_pincode'];
                $o_create_by=$row_contact['o_create_by'];
                $o_create_type=$row_contact['o_create_type'];
                $s_name=$row_contact['s_name'];
                $s_desc=$row_contact['s_desc'];
                $s_color=$row_contact['s_color'];
                $t_name=$row_contact['t_name'];
                $t_desc=$row_contact['t_desc'];
                $l_name=$row_contact['l_name'];
                $status_id=$row_contact['status_id']; 
                $tag_id=$row_contact['tag_id']; 
                $lead_id=$row_contact['lead_id']; 
                $viewrowid="viewcontact".$c_id;
                $viewrowid1="#viewcontact".$c_id;
                //$value=$c_companyname."#@".$c_emailid."#@".$c_id."#@".$c_title."#@".$c_fname."#@".$c_lname."#@".$c_jobtitle."#@".$c_a_line."#@".$c_a_city."#@".$c_a_state."#@".$c_a_country."#@".$c_a_pincode."#@".$c_background."#@".$c_owner_id."#@".$c_private."#@".$c_dob."#@".$c_dtime."#@".$c_create_by."#@".$c_create_type."#@".$o_id."#@".$o_name."#@".$o_desc."#@".$o_phone."#@".$o_url."#@".$o_line."#@".$o_city."#@".$o_state."#@".$o_country."#@".$o_pincode."#@".$o_create_by."#@".$o_create_type."#@".$s_name."#@".$s_desc."#@".$s_color."#@".$t_name."#@".$t_desc."#@".$l_name."#@".$c_delete."#@".$status_id."#@".$tag_id."#@".$lead_id;
                $value=$c_id; 
                ?>
                <div class="row" style="background-color:#f0f0f0;padding:0px;margin-top:-15px;cursor:pointer;" id="<?php echo $viewrowid;?>" onclick="viewcontact('<?php echo $value;?>')">
                                
                    <span class="checkbox col-md-6" >
                        <label>
                            <input type="checkbox" value="">
                            <span class="cr"><i class="cr-icon fa fa-check"></i></span>
                            <i class="fa fa-star" aria-hidden="true"></i>
                        </label><?php echo "&nbsp;&nbsp;".$c_title."&nbsp;".$c_fname."&nbsp;".$c_lname;?>
                        <span style="color:grey;overflow: hidden;white-space: nowrap;Text-overflow:ellipsis;" title="<?php echo $o_name;?>"><?php echo $o_name;?></span>
                    </span>
                    <span class="col-md-6" style="padding:10px;">
                        <span class="col-md-8">
                        <?php
                        
                            $resnextaction1=$objcontact->salesselectnextactionpending($c_id);
                            $na_id1=array();
                            $na_descr1=array();
                            $na_date1=array();
                            $na_time1=array();
                            $ii=0;
                            foreach($resnextaction1 as $rownextaction1){
                                $na_id1[$ii]=$rownextaction1['na_id'];
                                $na_descr1[$ii]=$rownextaction1['na_descr'];
                                $na_date1[$ii]=$rownextaction1['na_date'];
                                $na_time1[$ii++]=$rownextaction1['na_time'];
                            }
                            if($resnextaction1->rowCount()>0){
                            echo '<span class="col-md-4">';
                            if($na_date1[0]=="0000-00-00"){
                            ?>
                                <div style="background-image: url(../../Images/tagui8.png);background-repeat: no-repeat;background-size:80px 20px;color:orange;">
                                    <span style="margin-left:10px;">
                                        Queued
                                    </span>
                                </div>
                            <?php
                            }else if($na_date1[0]<date("Y-m-d")){
                            ?>
                                <div style="background-image: url(../../Images/tagui1.png);background-repeat: no-repeat;background-size:80px 20px;color:#f8f8f8;">
                                    <span style="margin-left:10px;">
                                        <?php echo date("M", strtotime($na_date1[0])); echo "&nbsp;&nbsp;".date("d", strtotime($na_date1[0]));?>
                                    </span>
                                </div>
                            <?php 
                            }else{
                            ?>
                                <div style="background-image: url(../../Images/tagui2.png);background-repeat: no-repeat;background-size:80px 20px;color:#f8f8f8;">
                                    <span style="margin-left:10px;">
                                        <?php echo date("M", strtotime($na_date1[0])); echo "&nbsp;&nbsp;".date("d", strtotime($na_date1[0]));?>
                                    </span>
                                </div>
                            <?php
                            } 
                            ?>
                            </span>
                            <span class="col-md-8" style="overflow: hidden;white-space: nowrap;Text-overflow:ellipsis;" title="<?php echo $na_descr1[0];?>">
                            <?php if ($na_time1[0]!="00:00:00"){ echo $na_time1[0]."&nbsp;&nbsp;&nbsp;".$na_descr1[0]; } else{ echo $na_descr1[0]; }?>
                            </span>
                        <?php
                        }
                        ?>
                        </span>
                        <span class="col-md-4">
                            <span class="pull-right" style="color:<?php echo $s_color;?>"><?php echo $s_name;?>&nbsp;&nbsp;&nbsp;&nbsp;</span>
                        </span>
                    </span>
                </div><br>
                <?php
            }
            ?>
            </div>
            </div>
            </div>
        </div>
        </div>
        <script> 
            function viewcontact(value){
                var cont_id=new Array();
                cont_id=<?php echo json_encode($cont_id);?>;
                $.ajax({
                   url: "show_contact_activity.php",
                   method: "post",
                   data:{value:value, cont_id:cont_id},
                   beforeSend: function() {
                      $('#loadover').show();
                   },
                   success:function(response){
                       $("#activitystream").hide();
                      $('#loadover').hide();
                       $("#result").show();
                       $("#result").html(response);
                                    
                   }
                });
            }
        </script>
    </body>
  
</html>

<?php
}else{
echo "<script> location.replace('http://fieldcloud.in/Login.php') </script>";
}?>