<?php
session_start();
include ('sesssion_clear.php');
$companyname=$_SESSION['companyname'];
$adminemailid=$_SESSION['emailid'];
$companytype=$_SESSION['companytype'];
include('../Model/configuration.php');
$sql1="select signupdetails.emailid, signupdetails.employeename from signupdetails where signupdetails.companyname='".$companyname."'";
$result1 = $pdo->query($sql1);
//echo $result1->rowcount();
$comp_full_emailid=array();
$comp_full_empname=array();
foreach($result1 as $row1){
    array_push($comp_full_emailid, $row1['emailid']);
    array_push($comp_full_empname, $row1['employeename']);
}
//$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();
$objcontact=new contactctrl();
require_once('../Control/status.php');
$objstatus=new statusctrl();
require_once('../Control/tag.php');
$objtag=new tagctrl();
require_once('../Control/employee.php');
$objemployee=new employeectrl();
require_once('../Control/leadsource.php');
$objleadsource=new leadsourcectrl();
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 label, .radio label {
                min-height: 20px;
                /* padding-left: 20px; */
                margin-bottom: 0;
                font-weight: 400;
                cursor: pointer;
            }
            
            .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> 
        <style>
            .divshowmoreaction {
                width: 360px;
                height: 45px;
                left: 110px;
                top: 0px;
                background-color: #3d3d3d;
                position: fixed;
                z-index:121;
                -webkit-animation-name: example; /* Safari 4.0 - 8.0 */
                -webkit-animation-duration: 4s; /* Safari 4.0 - 8.0 */
                animation-name: example;
                animation-duration: 2s;
                border-radius:5px;
            }
            @-webkit-keyframes example {
                0%   {background-color:#3d3d3d; left:110px; top:-10px;}
            }
        </style>
        <style>
            .dropbtn {
                background-color: #f2f2f2;
                color: black;
                margin-left:6px;
                margin-top:6px;
                padding: 6px;
                font-size: 14px;
                border: none;
                cursor: pointer;
                border-radius:2px
            }
            
            .dropbtn:hover, .dropbtn:focus {
                background-color: white;
            }
            
            .dropdown {
                position: relative;
                display: inline-block;
            }
            
            .dropdown-content {
            	margin-left:6px;
                display: none;
                position: absolute;
                background-color: #f1f1f1;
                min-width: 80px;
                overflow: auto;
                box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
                z-index: 1;
            }
            
            .dropdown-content a {
                color: black;
                padding: 10px 10px;
                text-decoration: none;
                display: block;
            }
            
            .dropdown a:hover {background-color: #ddd;}
            
            .show {display: block;}
        </style>
    </head>
    
    <body>
        <div id="loadover"></div>   
        <div id="contentover"> 
            <div class="body" style="padding:30px 30px 10px 0px;">
        <div id="result"></div>
        
        <div id="activitystream">
            
            <?php
                $resultstatus=$objstatus->salesselectstatus();
                $resulttag=$objtag->salesselecttag();
                $resultemployee=$objemployee->salesselectemployee();
                $resultleadsource=$objleadsource->salesselectleadsource();
                ?>
                    
            <div class="divshowmoreaction" style="display:none">
                <input type="hidden" id="myDropdownstatusinput" value="0">
                <input type="hidden" id="myDropdowntaginput" value="0">
                <input type="hidden" id="myDropdownownerinput" value="0">
                <input type="hidden" id="myDropdownleadinput" value="0">
                <input type="hidden" id="myDropdownmoreinput" value="0">
                    <button onclick="myFunctiondelete()" class="dropbtn"><i class="fa fa-trash-o"></i></button>
                <div class="dropdown">
                    <button onclick="myFunctionstatus()" class="dropbtn">Status<i class="fa fa-caret-down"></i></button>
                    <div id="myDropdownstatus" class="dropdown-content">
                        <?php
                        foreach($resultstatus as $rowstatus){
                            $statusid=$rowstatus['id'];
                            $statusname=$rowstatus['status_name'];
                        ?>
                        <a onclick="funchangestatusdb('<?php echo $statusid;?>')"><?php echo $statusname;?></a>
                        <?php
                        }
                        ?>
                    </div>
                </div>
                <div class="dropdown">
                    <button onclick="myFunctiontag()" class="dropbtn">Tag<i class="fa fa-caret-down"></i></button>
                    <div id="myDropdowntag" class="dropdown-content">
                        <?php
                        foreach($resulttag as $rowtag){
                            $tagid=$rowtag['id'];
                            $tagname=$rowtag['tag_name'];
                        ?>
                        <a onclick="funchangetagdb('<?php echo $tagid;?>')"><?php echo $tagname;?></a>
                        <?php
                        }
                        ?>
                    </div>
                </div>
                <div class="dropdown">
                    <button onclick="myFunctionowner()" class="dropbtn">Owner<i class="fa fa-caret-down"></i></button>
                    <div id="myDropdownowner" class="dropdown-content">
                        <?php
                        foreach($resultemployee as $rowemployee){
                            $employeeid121313=$rowemployee['emailid'];
                            $employeename=$rowemployee['employeename'];
                        ?>
                        <a onclick="funchangeemployeedb('<?php echo $employeeid121313;?>')"><?php echo $employeename;?></a>
                        <?php
                        }
                        ?>
                    </div>
                </div>
                <div class="dropdown">
                    <button onclick="myFunctionlead()" class="dropbtn">Lead<i class="fa fa-caret-down"></i></button>
                    <div id="myDropdownlead" class="dropdown-content">
                        <?php
                        foreach($resultleadsource as $rowleadsource){
                            $leadsourceid=$rowleadsource['id'];
                            $leadsourcename=$rowleadsource['lead_name'];
                        ?>
                        <a onclick="funchangeleadsourcedb('<?php echo $leadsourceid;?>')"><?php echo $leadsourcename;?></a>
                        <?php
                        }
                        ?>
                    </div>
                </div>
                <div class="dropdown">
                    <button onclick="myFunctionaction()" class="dropbtn" data-toggle="modal" data-target="#myModal">Action</button>
                </div>
                <!--<div class="dropdown">
                    <button onclick="myFunctionmore()" class="dropbtn">More<i class="fa fa-caret-down"></i></button>
                    <div id="myDropdownmore" class="dropdown-content">
                        <a href="#home">Home</a>
                        <a href="#about">About</a>
                        <a href="#contact">Contact</a>
                    </div>
                </div>-->
            </div>
                    
                
            <div class="row" style="padding-bottom:10px;">
                <div class="bulk_select select_all">
                    <label> 
                    
                        <input type="checkbox" class="allcheckbox" name="allcheckbox" id="allcheckbox" style="margin-left:25px" value="bulk_select" autocomplete="off">
                    </label>&nbsp;&nbsp;&nbsp;
                    <span onclick="location. reload(true)" style="cursor:pointer;color:#666674;">
                        <span style="color:#60b4f7;" class="glyphicon glyphicon-repeat"></span>&nbsp; Refresh
                    </span>
                </div>
            </div>    
            <div class="row" style="background-color:#e0f5ff;padding:3px;">
                <span style="color:#333;padding-left:15px;">Filter By </span><b>Starred</b>
            </div><br>
            <?php
            $result_contact1=$objsales->salesselectall($companyname, $adminemailid, "viewcontact", "star");
            $cont_id=array();
            $i=0;
            foreach($result_contact1 as $row_contact1){
                $cont_id[$i]=$row_contact1['c_id'];
                $i++;
            }
            $totalcount_star=$result_contact1->rowcount();
            if($totalcount_star==0){
            ?>
            <div style="padding-top:70px;">
                <center>
                    No Contacts match <b>Starred</b> owned by You<br>
                    View Your <span style="color:#1f79f2;cursor:pointer;" onclick="location.replace('activestream_list_view1.php')">Action Stream</span>
                </center>
            </div>
            <?php
            }else{
            
            //print_r($result_contact1);
            $i=0;
            $cont_id_array=array();
            $result_contact=$objsales->salesselectall($companyname, $adminemailid, "viewcontact", "star");
            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'];
                array_push($cont_id_array,$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'];
                $cont_star=$row_contact['c_star'];
                $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;font-size: small;" id="<?php echo $viewrowid;?>">
                                
                    <span class="checkbox col-xs-6" >
                        <div class="col-xs-2">
                            <span style="margin-left:15px;">
                                <input type="checkbox" class="checkall" name="cont_check_<?php echo $c_id;?>" id="cont_check_<?php echo $c_id;?>" onclick="checkboxckecking('<?php echo $c_id;?>','cont_check_<?php echo $c_id;?>')" autocomplete="off">
                                &nbsp;&nbsp;<span id="star_<?php echo $c_id;?>" onclick="funcstar('<?php echo $cont_star;?>','<?php echo $c_id;?>','#star_<?php echo $c_id;?>')" style="color:<?php if($cont_star==0){ echo 'black'; }else{ echo 'orange'; }?>"><i class="fa fa-star"></i></span>
                            </span>
                        </div>
                        <div class="col-xs-10" style="cursor:pointer;" onclick="viewcontact('<?php echo $value;?>')">
                            <span>
                                <span style="color:grey;overflow: hidden;white-space: nowrap;Text-overflow:ellipsis;" title="<?php echo $o_name;?>"><?php if(($o_name!="")&&($o_name!="no data available")){ echo $o_name."&nbsp;&nbsp;"; }?></span>
                                <?php 
                                if(($c_title!="")&&($c_title!="no data available")){
                                echo $c_title."&nbsp;";
                                }
                                if(($c_fname!="")&&($c_fname!="no data available")){
                                echo $c_fname."&nbsp;";
                                }
                                if(($c_lname!="")&&($c_lname!="no data available")){
                                echo $c_lname;
                                }
                                ?>
                            </span>
                        </div>
                    </span>
                    <span class="col-xs-6" style="padding:10px;"  onclick="viewcontact('<?php echo $value;?>')">
                        <span class="col-xs-8">
                        <?php
                        
                            include('../Model/configuration.php');
                            $sql1="SELECT `id`, `cont_id`, `email_id`, `closingdate`, `closingcomment` FROM `sales_employee_contact` WHERE closingdate!='0000-00-00 00:00:00' and cont_id='".$c_id."' and email_id='".$adminemailid."'";
                            $result1 = $pdo->query($sql1);
                            $closedcount= $result1->rowcount();
                            if($closedcount==1){
                                $closingcomment="";
                                $closingdate="";
                                foreach($result1 as $row1){
                                    $closingcomment= $row1['closingcomment'];
                                    $closingdate=$row1['closingdate'];
                                }
                                if(($closingcomment!="")&&($closingcomment!="no data available")){
                                    echo "<div class='col-md-12'><b>".$closingcomment."</b></div>";
                                }else if($closingdate!=""){
                                    echo "<div class='col-md-12' style='color:grey;font-size:10px;'>Actions exist for this contact";
                                    $sql2="select sales_nextaction.id as na_id, sales_nextaction.na_descr, sales_nextaction.na_date, sales_nextaction.na_time, sales_nextaction.na_assign from sales_nextaction where sales_nextaction.na_status='pending' and  sales_nextaction.na_delete='no' and sales_nextaction.cont_id='".$c_id."' order by sales_nextaction.na_priority DESC, sales_nextaction.na_date ASC limit 1";
                                    $result2 = $pdo->query($sql2);
                                    foreach($result2 as $row2){
                                        $na_assign12= $row2['na_assign'];
                                        for($jkj=0; $jkj<count($comp_full_emailid);$jkj++){
                                            if($comp_full_emailid[$jkj]==$na_assign12){
                                                echo " - assigned to ".$comp_full_empname[$jkj];
                                            }
                                        }
                                    }
                                    echo ".</div>";
                                }else{
                                    
                                }
                            }else{
                                $resnextaction1=$objcontact->salesselectnextactionpending($c_id);
                                $na_id1=array();
                                $na_descr1=array();
                                $na_date1=array();
                                $na_selectedoption1=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'];
                                    $na_selectedoption1[$ii++]=$rownextaction1['na_selectedoption'];
                                }
                                if($resnextaction1->rowCount()>0){
                                ?><span class="col-xs-4"><?php
                                if($na_selectedoption1[0]=="ASAP"){
                                ?>
                                    <div style="background-image: url(../../Images/tagui1.png);background-repeat: no-repeat;background-size:70px 20px;color:white;">
                                        <span style="margin-left:10px;">
                                            ASAP&nbsp;&nbsp;
                                        </span>
                                    </div>
                                <?php
                                }else if($na_selectedoption1[0]=="Waiting"){
                                ?>
                                    <div style="background-image: url(../../Images/tagui1.png);background-repeat: no-repeat;background-size:70px 20px;color:white;">
                                        <span style="margin-left:10px;">
                                            Waiting
                                        </span>
                                    </div>
                                <?php
                                }else if($na_date1[0]=="0000-00-00"){
                                ?>
                                    <div style="background-image: url(../../Images/tagui8.png);background-repeat: no-repeat;background-size:70px 20px;color:orange;">
                                        <span style="margin4-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:70px 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:70px 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-xs-8" style="overflow: hidden;white-space: nowrap;Text-overflow:ellipsis;color:#333;" 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
                            }else{ 
                                
                            }
                        }
                        ?>
                        </span>
                        <span class="col-xs-4">
                            <span class="pull-right">
                                <?php
                                $sql3="SELECT sum(`d_amount`) as dealamount FROM `sales_deal` WHERE `cont_id`='".$c_id."'";
                                $result3 = $pdo->query($sql3);
                                $dealamount="";
                                foreach($result3 as $row3){
                                    $dealamount=$row3['dealamount'];
                                    if(($dealamount!=0)&&($dealamount!="")&&($dealamount!="0")){
                                        echo "<span style='border: 1px solid #db2b5d;color:#db2b5d;font-size:10px;display: inline-block;padding: 0 5px;'>Rs&nbsp;".$dealamount."</span>";
                                    }else{
                                        for($jkj=0; $jkj<count($comp_full_emailid);$jkj++){
                                            if($comp_full_emailid[$jkj]==$c_owner_id){
                                                echo "<span style='color:grey;font-size: small;'>".$comp_full_empname[$jkj]."</spna>";
                                            }
                                        }
                                    }
                                }
                                ?>
                                <span style="color:<?php echo $s_color;?>;font-size: small;"><?php if(($s_name!="")&&($s_name!="no data available")){ echo $s_name; }?></span>
                            </span>
                        </span>
                    </span>
                </div><br>
                <?php
            }
            }
            ?>
            </div>
            </div>
            </div>
            
<input type="hidden" id="check_cont">
        
          <!-- Modal -->
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">
    
      <!-- Modal content-->
      <div class="modal-content">
        
        <div class="modal-body">
            <h4 class="modal-title">Bulk set action<span class="pull-right"><button type="button" class="close" data-dismiss="modal">&times;</button></span></h4>
            <div class="row" style="padding:10px;">
                <div style="padding:20px;background-color:#d9eefc;">
                    Next Action:
                    <input type="text" class="form-control" id="nextactionname"><br>
                    <select name="selectdate" id="selectdate" style="padding: 5px;border-radius: 5px;">
                        <option value="Date" selected>Date</option>
                        <option value="ASAP">ASAP</option>
                        <option value="Waiting for">Waiting for</option>
                        <option value="" disabled><b>Quick Date</b></option>
                        <option value="Tomorrow">&nbsp;&nbsp;Tomorrow</option>
                        <option value="7 days time">&nbsp;&nbsp;7 days time</option>
                        <option value="2 Weeks time">&nbsp;&nbsp;2 Weeks time</option>
                        <option value="30 days time">&nbsp;&nbsp;30 days time</option>
                    </select>
                    <input type="text" name="nextactiondate" id="nextactiondate" readonly style="padding: 5px;border-radius: 5px;" >
                    <?php
                    $resultemployee=$objemployee->salesselectemployee();
                    ?>
                    <span class="pull-right">
                        <select id="nextactionowner" name="nextactionowner" style="padding: 5px;border-radius: 5px;">
                            <?php
                            foreach($resultemployee as $rowemployee){
                                $employeeid121313=$rowemployee['emailid'];
                                $employeename=$rowemployee['employeename'];
                                if($employeeid121313==$createby){
                                ?>
                                <option value="<?php echo $employeeid121313;?>" selected style="padding: 5px;">me(<?php echo $employeename;?>)</option>
                                <?php
                                }else{
                                ?>
                                <option value="<?php echo $employeeid121313;?>" style="padding: 5px;"><?php echo $employeename;?></option>
                                <?php
                                }
                            }
                            ?>
                        </select>
                    </span>
                </div>
            </div>
            
            <input type="button" value="Save" class="btn btn-primary" id="addnextactionformulitple">
            <input type="button" value="Cancel" class="btn btn-default" data-dismiss="modal">
        </div>
        
      </div>
      
    </div>
  </div>
<script>
 $( function() {
    var tomorrow = new Date();
    var d=tomorrow.getDate();
    var m=tomorrow.getMonth();
    var y=tomorrow.getFullYear();
    if(d<10){
        d="0"+d;
    }
    if(m<10){
        m1=m+1;
        m="0"+m1;
    }
    var datee=y+"-"+m+"-"+d;
    var datee1=d+"-"+m+"-"+y;
    $("#nextactiondate").val(datee);
    $( "#nextactiondate").datepicker({ format : 'yyyy-mm-dd', autoclose: true, startDate: datee1} );
 } );
</script>
<script>
    $(document).on("change", "#selectdate", function(){
        var selectdate=$("#selectdate").val();
        var tomorrow = new Date();
        if(selectdate=="Date"){
            var d=tomorrow.getDate();
            var m=tomorrow.getMonth();
            var y=tomorrow.getFullYear();
            if(d<10){
                d="0"+d;
            }
            if(m<10){
                m1=m+1;
                m="0"+m1;
            }
            var datee=y+"-"+m+"-"+d;
            $( "#nextactiondate").show();
            var datee1=d+"-"+m+"-"+y;
            $("#nextactiondate").val(datee);
            $( "#nextactiondate").datepicker({ format : 'yyyy-mm-dd', autoclose: true, startDate: datee1, defaultDate: new Date(datee1)} );
        }else if(selectdate=="ASAP"){
            $( "#nextactiondate").hide();
            //$( "#nextactiondate").datepicker();
        }else if(selectdate=="Waiting for"){
            $( "#nextactiondate").hide();
            //$( "#nextactiondate").datepicker();
        }else if(selectdate=="Tomorrow"){
            tomorrow.setDate(tomorrow.getDate() + 1);
            var d=tomorrow.getDate();
            var m=tomorrow.getMonth();
            var y=tomorrow.getFullYear();
            if(d<10){
                d="0"+d;
            }
            if(m<10){
                m1=m+1;
                m="0"+m1;
            }
            var datee=y+"-"+m+"-"+d;
            $( "#nextactiondate").show();
            var datee1=d+"-"+m+"-"+y;
            $("#nextactiondate").val(datee);
            $( "#nextactiondate").datepicker({ format : 'yyyy-mm-dd', autoclose: true, startDate: datee1, defaultDate: new Date(datee1)} );
        }else if(selectdate=="7 days time"){
            tomorrow.setDate(tomorrow.getDate() + 7);
            var d=tomorrow.getDate();
            var m=tomorrow.getMonth();
            var y=tomorrow.getFullYear();
            if(d<10){
                d="0"+d;
            }
            if(m<10){
                m1=m+1;
                m="0"+m1;
            }
            var datee=y+"-"+m+"-"+d;
            $( "#nextactiondate").show();
            var datee1=d+"-"+m+"-"+y;
            $("#nextactiondate").val(datee);
            $( "#nextactiondate").datepicker({ format : 'yyyy-mm-dd', autoclose: true, startDate: datee1, defaultDate: new Date(datee1)} );
        }else if(selectdate=="2 Weeks time"){
            tomorrow.setDate(tomorrow.getDate() + 14);
            var d=tomorrow.getDate();
            var m=tomorrow.getMonth();
            var y=tomorrow.getFullYear();
            if(d<10){
                d="0"+d;
            }
            if(m<10){
                m1=m+1;
                m="0"+m1;
            }
            var datee=y+"-"+m+"-"+d;
            $( "#nextactiondate").show();
            var datee1=d+"-"+m+"-"+y;
            $("#nextactiondate").val(datee);
            $( "#nextactiondate").datepicker({ format : 'yyyy-mm-dd', autoclose: true, startDate: datee1, defaultDate: new Date(datee1)} );
        }else if(selectdate=="30 days time"){
            tomorrow.setDate(tomorrow.getDate() + 30);
            var d=tomorrow.getDate();
            var m=tomorrow.getMonth();
            var y=tomorrow.getFullYear();
            if(d<10){
                d="0"+d;
            }
            if(m<10){
                m1=m+1;
                m="0"+m1;
            }
            var datee=y+"-"+m+"-"+d;
            $( "#nextactiondate").show();
            var datee1=d+"-"+m+"-"+y;
            $("#nextactiondate").val(datee);
            $( "#nextactiondate").datepicker({ format : 'yyyy-mm-dd', autoclose: true, startDate: datee1, defaultDate: new Date(datee1)} );
        }
    });
 </script>
<script>
    $(document).on("click", "#addnextactionformulitple", function(){
        var nextactionname=$("#nextactionname").val();
        if(nextactionname==""){
            swal("","Please Enter Next Action", "success");
            $("#nextactionname").focus();
        return;
        }
        var nextactionowner=$("#nextactionowner").val();
        if(nextactionowner==""){
            swal("","Please Select Next Action done", "success");
            $("#nextactionowner").focus();
        return;
        }
        var na_assign=$("#nextactionowner").val();
        var na_descr=$("#nextactionname").val();
        var na_selectedoption=$("#selectdate").val();
        var na_date="";
        if((na_selectedoption!="ASAP")&&(na_selectedoption!="Waiting for")){
            na_date=$("#nextactiondate").val();
        }
        var cont1=$("#check_cont").val();
        $.ajax({
           url: "../Control/nextaction.php",
           method: "post",
           data:{insertnextactionmultiple:na_descr, cont:cont1, na_assign:na_assign, na_selectedoption:na_selectedoption, na_date:na_date},
           success:function(response){
                window.location.replace("activestream_list_view1.php");
           }
        });
    });
</script>
        <script> 
            function viewcontact(value){
                var cont_id=new Array();
                cont_id=<?php echo json_encode($cont_id);?>;
                $.ajax({
                   url: "show_contact_activity2.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>
        
        
    <script>
        function showcontactfunc(letter){
            var firstletter=<?php echo json_encode($firstletter_in_array);?>;
            if(letter=="All"){
                for(var f=0;f<firstletter.length;f++){
                     var l=firstletter[f];
                     var id1=".show_body_"+l;
                    $(id1).show();
                     var id1=".show_header_"+l;
                    $(id1).show();
                }
            }else if(firstletter.indexOf(letter)<0){
                
            }else{
                for(var f=0;f<firstletter.length;f++){
                     var l=firstletter[f];
                     var id1=".show_body_"+l;
                    $(id1).hide();
                     var id1=".show_header_"+l;
                    $(id1).hide();
                }
                 var id1=".show_body_"+letter;
                $(id1).show();
                 var id1=".show_header_"+letter;
                $(id1).show();
            }
        }
    </script>
    
    
        <script> 
            function showcontactionformation(value){
                var cont_id=<?php echo json_encode($cont_id_array);?>;
                var page="activestream_list_view1.php";
                $.ajax({
                   url: "show_contact_activity1.php",
                   method: "post",
                   data:{value:value, cont_id:cont_id, page:page},
                   success:function(response){
                       $("#activitystream").hide();
                       $("#result").html("");
                       $("#result").html(response);
                       $("#result").show();
                                    
                   }
                });
            }
        </script>   
        <script>
            $(document).on("click", ".allcheckbox", function(){
                var cont_id=<?php echo json_encode($cont_id_array);?>;
                var check_cont="";
                if($('.allcheckbox').is(':checked')){
                    for(var f=0;f<cont_id.length;f++){
                        var l=cont_id[f];
                        var id1="#cont_check_"+l;
                        $(id1).prop("checked", true);
                        
                        if(check_cont==""){
                            check_cont=cont_id[f];
                        }else{
                            check_cont+="@#"+cont_id[f];
                        }
                    }
                    $(".divshowmoreaction").show();
                    
                    
                }else{
                    for(var f=0;f<cont_id.length;f++){
                         var l=cont_id[f];
                         var id1="#cont_check_"+l;
                        $(id1).prop("checked", false);
                    }
                    $(".divshowmoreaction").hide();
                }
                $("#check_cont").val(check_cont);
            });
        </script>
    
    
        <script>
            function funcstar(value, cid, id){
                if(value==0){
                    var value1=1;
                    $(id).css({ 'color': 'Orange'});
                    $.ajax({
                       url: "../Control/contact.php",
                       method: "post",
                       data:{staron:value1, cont_id:cid},
                       success:function(response){
                        swal("","This Contact marked as star", "success");
                       }
                    });
                }else{
                    var value1=0;
                    $(id).css({ 'color': 'black'});
                    $.ajax({
                       url: "../Control/contact.php",
                       method: "post",
                       data:{staroff:value1, cont_id:cid},
                       success:function(response){
                            swal("","This Contact unmarked as star", "success");
                       }
                    });
                }
                 
            }
        </script>
        
    
        
        <script>
            /* When the user clicks on the button, 
            toggle between hiding and showing the dropdown content */
            function myFunctionstatus() {
                var value1=$("#myDropdownstatusinput").val();
                if(value1==0){
                    $("#myDropdownstatus").show();
                    $("#myDropdownstatusinput").val(1);
                    $("#myDropdowntaginput").val(0);
                    $("#myDropdownownerinput").val(0);
                    $("#myDropdownleadinput").val(0);
                    //$("#myDropdownmoreinput").val(0);
                }else{
                    $("#myDropdownstatus").hide();
                    $("#myDropdownstatusinput").val(0);
                }
                $("#myDropdowntag").hide();
                $("#myDropdownowner").hide();
                $("#myDropdownlead").hide();
                //$("#myDropdownmore").hide();
            }
            function myFunctiontag() { 
                var value1=$("#myDropdowntaginput").val();
                if(value1==0){
                    $("#myDropdowntag").show();
                    $("#myDropdowntaginput").val(1);
                    $("#myDropdownstatusinput").val(0);
                    $("#myDropdownownerinput").val(0);
                    $("#myDropdownleadinput").val(0);
                    //$("#myDropdownmoreinput").val(0);
                }else{
                    $("#myDropdowntag").hide();
                    $("#myDropdowntaginput").val(0);
                }
                $("#myDropdownstatus").hide();
                $("#myDropdownowner").hide();
                $("#myDropdownlead").hide();
                //$("#myDropdownmore").hide();
            }
            function myFunctionowner() {
                var value1=$("#myDropdownownerinput").val();
                if(value1==0){
                    $("#myDropdownowner").show();
                    $("#myDropdownownerinput").val(1);
                    $("#myDropdownstatusinput").val(0);
                    $("#myDropdowntaginput").val(0);
                    $("#myDropdownleadinput").val(0);
                    //$("#myDropdownmoreinput").val(0);
                }else{
                    $("#myDropdownowner").hide();
                    $("#myDropdownownerinput").val(0);
                }
                $("#myDropdownstatus").hide();
                $("#myDropdowntag").hide();
                $("#myDropdownlead").hide();
                //$("#myDropdownmore").hide();
            }
            function myFunctionlead() {
                var value1=$("#myDropdownleadinput").val();
                if(value1==0){
                    $("#myDropdownlead").show();
                    $("#myDropdownleadinput").val(1);
                    $("#myDropdownstatusinput").val(0);
                    $("#myDropdowntaginput").val(0);
                    $("#myDropdownownerinput").val(0);
                    //$("#myDropdownmoreinput").val(0);
                }else{
                    $("#myDropdownlead").hide();
                    $("#myDropdownleadinput").val(0);
                }
                $("#myDropdownstatus").hide();
                $("#myDropdowntag").hide();
                $("#myDropdownowner").hide();
                //$("#myDropdownmore").hide();
            }
            function myFunctionaction(){
                $("#myDropdownleadinput").val(0);
                $("#myDropdownstatusinput").val(0);
                $("#myDropdowntaginput").val(0);
                $("#myDropdownownerinput").val(0);
                
                $("#myDropdownlead").hide();
                $("#myDropdownstatus").hide();
                $("#myDropdowntag").hide();
                $("#myDropdownowner").hide();
                //$("#myDropdownmore").hide();
            }
            
            // Close the dropdown if the user clicks outside of it
            window.onclick = function(event) {
              if (!event.target.matches('.dropbtn')) {
            
                var dropdowns = document.getElementsByClassName("dropdown-content");
                var i;
                for (i = 0; i < dropdowns.length; i++) {
                  var openDropdown = dropdowns[i];
                  if (openDropdown.classList.contains('show')) {
                    openDropdown.classList.remove('show');
                  }
                }
              }
            }
        </script>
        <script>
            function checkboxckecking(value1, id){
                var check_cont=$("#check_cont").val();
                if($("#"+id).is(':checked')){
                    $(".divshowmoreaction").show();
                    if(check_cont==""){
                        check_cont=value1;
                    }else{
                        check_cont+="@#"+value1;
                    }
                    $("#check_cont").val(check_cont);
                }else{
                    var pass="";
                    var result =new Array();
                    result=check_cont.split("@#");
                    for(var i=0;i<result.length;i++){
                        if(value1!=result[i]){
                            if(pass==""){
                                pass=result[i];
                            }else{
                                pass+="@#"+result[i];
                            }
                        }
                    }
                    if(pass==""){
                    $(".divshowmoreaction").hide();
                    }
                    $("#check_cont").val(pass);
                }
                checkcheckbox();
            }
        </script>
        <script>
            function checkcheckbox(){
                var cont_id=<?php echo json_encode($cont_id_array);?>;
                var somethingChecked = false;
                $("input[type=checkbox]").each(function() {
                  if(this).is(':checked')) {
                    somethingChecked = true;
                  }
                });
                if(!somethingChecked) {
                    $(".divshowmoreaction").hide();
                }else{
                    $(".divshowmoreaction").show();
                }
            }
        </script>
        <script>
            function funchangestatusdb(statusid){
                var cont1=$("#check_cont").val();
                $.ajax({
                   url: "../Control/status.php",
                   method: "post",
                   data:{updatestatus:statusid, cont:cont1},
                   success:function(response){
                        window.location.replace("activestream_list_view1.php");
                   }
                });
            }
        </script>
        <script>
            function funchangetagdb(tagid){
                var cont1=$("#check_cont").val();
                $.ajax({
                   url: "../Control/tag.php",
                   method: "post",
                   data:{updatetag:tagid, cont:cont1},
                   success:function(response){
                        window.location.replace("activestream_list_view1.php");
                   }
                });
            }
        </script>
        <script>
            function funchangeemployeedb(employeeid){
                var cont1=$("#check_cont").val();
                $.ajax({
                   url: "../Control/employee.php",
                   method: "post",
                   data:{updateemployee:employeeid, cont:cont1},
                   success:function(response){
                        window.location.replace("activestream_list_view1.php");
                   }
                });
            }
        </script>
        <script>
            function funchangeleadsourcedb(leadsourceid){
                var cont1=$("#check_cont").val();
                $.ajax({
                   url: "../Control/leadsource.php",
                   method: "post",
                   data:{updateleadsource:leadsourceid, cont:cont1},
                   success:function(response){
                        window.location.replace("activestream_list_view1.php");
                   }
                });
            }
        </script>
        <script>
            function myFunctiondelete(){
                var cont1=$("#check_cont").val();
                $.ajax({
                   url: "../Control/contact.php",
                   method: "post",
                   data:{deletecontact:cont1},
                   success:function(response){
                        window.location.replace("activestream_list_view1.php");
                   }
                });
            }
        </script>
        
    </body>
  
</html>

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