<?php
$adminemailid=$_POST['adminemailid'];
date_default_timezone_set("Asia/Kolkata");
$companyname=$_POST['companyname'];
$c_id=$_POST['cid'];
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']);
}
//print_r($comp_full_emailid);
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        
<style>
    .row{
        margin-left:0px;
        margin-right:0px;
    }
    /*.col-lg-1, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-sm-1, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-xs-1, .col-xs-10, .col-xs-11, .col-xs-12, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9{
            position: relative;
            min-height: 1px;
            padding-right: 15px;
            padding-left: 0px; 
    }*/
</style>
        <style>
/* The container */
.container1 {
    display: block;
    position: relative;
    padding-left: 35px;
    margin-bottom: 12px;
    cursor: pointer;
    font-size: 22px;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Hide the browser's default checkbox */
.container1 input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

/* Create a custom checkbox */
.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 15px;
    width: 15px;
    background-color: white;
    border-radius: 3px;
}

/* On mouse-over, add a grey background color */
.container1:hover input ~ .checkmark {
    background-color: #ccc;
}

/* When the checkbox is checked, add a blue background */
.container1 input:checked ~ .checkmark {
    background-color: #2196F3;
}

/* Create the checkmark/indicator (hidden when not checked) */
.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

/* Show the checkmark when checked */
.container1 input:checked ~ .checkmark:after {
    display: block;
}

/* Style the checkmark/indicator */
.container1 .checkmark:after {
    left: 5px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 3px 3px 0;
    -webkit-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    transform: rotate(45deg);
}


/* The container */
.container2 {
    display: block;
    position: relative;
    padding-left: 35px;
    /*margin-bottom: 12px;*/
    cursor: pointer;
    font-size: 22px;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Hide the browser's default checkbox */
.container2 input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    margin-top: -18px;
    margin-left: -10px;
}

/* Create a custom checkbox */
.checkmark2 {
    position: absolute;
    top: -17px;
    left: 15px;
    height: 15px;
    width: 15px;
    background-color: white;
    border:1px solid grey;
    border-radius: 3px;
}

/* On mouse-over, add a grey background color */
.container2:hover input ~ .checkmark2 {
    background-color: #ccc;
}

/* When the checkbox is checked, add a blue background */
.container2 input:checked ~ .checkmark2 {
    background-color: #2196F3;
}

/* Create the checkmark/indicator (hidden when not checked) */
.checkmark2:after {
    content: "";
    position: absolute;
    display: none;
}

/* Show the checkmark when checked */
.container2 input:checked ~ .checkmark2:after {
    display: block;
}

/* Style the checkmark/indicator */
.container2 .checkmark2:after {
    left: 5px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 3px 3px 0;
    -webkit-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    transform: rotate(45deg);
}
</style>
    <style>
        .nextaction_date_css{
            background: url(../../Images/tagui11.png);
            background-repeat: no-repeat;
            background-size:80px 20px;
            color:white;
        }
        .nextaction_date1_css{
            background: url(../../Images/tagui10.png);
            background-repeat: no-repeat;
            background-size:80px 20px;
            color:white;
        }
        .nextaction_queued_css{
            background: url(../../Images/tagui9.png);
            background-repeat: no-repeat;
            background-size:80px 20px;
            color:orange;
        }
        .nextaction_asap_css{
            background: url(../../Images/tagui11.png);
            background-repeat: no-repeat;
            background-size:80px 20px;
            color:white;
        }
        .nextaction_waiting_css{
            background: url(../../Images/tagui11.png);
            background-repeat: no-repeat;
            background-size:80px 20px;
            color:white;
        }
        .nextaction_date_css1{
            background: url(../../Images/tagui4.png);
            background-repeat: no-repeat;
            background-size:80px 20px;
            color:white;
        }
        .nextaction_date1_css1{
            background: url(../../Images/tagui5.png);
            background-repeat: no-repeat;
            background-size:80px 20px;
            color:white;
        }
        .nextaction_queued_css1{
            background: url(../../Images/tagui6.png);
            background-repeat: no-repeat;
            background-size:80px 20px;
            color:orange;
        }
        .nextaction_asap_css1{
            background: url(../../Images/tagui4.png);
            background-repeat: no-repeat;
            background-size:80px 20px;
            color:white;
        }
        .nextaction_waiting_css1{
            background: url(../../Images/tagui4.png);
            background-repeat: no-repeat;
            background-size:80px 20px;
            color:white;
        }
    </style>
    
    </head>
    <body>
<?php
$sql2="SELECT * FROM sales_nextaction where cont_id='$c_id' and na_status!='completed' and na_selectedoption!='Queued' and na_assign='$adminemailid' and na_priority='1' and na_delete='no' order by na_priority DESC";
$result2 = $pdo->query($sql2);
$resultcount2=$result2->rowcount();
?>
<div id="next_action" style="background-color:#d9eefc;">
<?php
foreach($result2 as $row2){
    $na_id=$row2['id'];
    $companyname=$row2['companyname'];
    $cont_id=$row2['cont_id'];
    $na_assign=$row2['na_assign'];
    $na_descr=$row2['na_descr'];
    $na_status=$row2['na_status'];
    $na_selectedoption=$row2['na_selectedoption'];
    $na_priority=$row2['na_priority'];
    $na_date=$row2['na_date'];
    $na_time=$row2['na_time'];
    $na_delete=$row2['na_delete'];
    $na_c_datetime=$row2['na_c_datetime'];
    $na_c_by=$row2['na_c_by'];
    $na_c_type=$row2['na_c_type'];
    $na_u_datetime=$row2['na_u_datetime'];
    $na_u_by=$row2['na_u_by'];
    $na_u_type=$row2['na_u_type'];
    $na_d_datetime=$row2['na_d_datetime'];
    $na_d_by=$row2['na_d_by'];
    $na_d_type=$row2['na_d_type'];
}
if($resultcount2<1){
    $sql4='SELECT `id`, `cont_id`, `email_id`, `closingdate`, `closingcomment` FROM `sales_employee_contact` WHERE `cont_id`="'.$c_id.'" and email_id="'.$adminemailid.'"';
    $result4=$pdo->query($sql4);
    $cont_na_closingcomment="";
    $cont_na_closingdate="";
    $cont_nastatus="";
    foreach($result4 as $row4){
        $cont_na_closingcomment=$row4['closingcomment'];
        $cont_na_closingdate=$row4['closingdate'];
    }
    if(($cont_na_closingdate=="0000-00-00 00:00:00")){
        ?>
        
        <script>
            $(document).ready(function(){
                $(".changenextaction").css("visibility","visible");
            })
        </script>
        <div class="row" style="background-color:#d9eefc;border-radius:5px;padding-bottom:10px;">
            <div class="col-md-2"></div>
            <div class="col-md-10">
                <h5><b>Next Action</b>&nbsp;&nbsp;or &nbsp;<a onclick="funclosethenextaction()" style="color:#6699cc;cursor:pointer;">Close</a></h5>
                
                <input type="hidden" id="na_nid_c_id" name="na_nid_c_id" value="">
                <textarea class="form-control" id="na_descr_c_id" rows="5" onchange="functionvisiblenextaction('#na_descr<?php echo $c_id;?>','#savenextaction<?php echo $c_id;?>','#na_date1<?php echo $c_id;?>')"></textarea><br>
                <select name="na_date1" id="na_date1_c_id" style="height:30px;border-radius:5px;" onchange="declaredatepicker('#na_date1_c_id','#na_date_c_id','#na_time_c_id')">
                    <!--<option value="Queued">Queued</option>-->
                    <option value="ASAP">ASAP</option>
                    <option value="Waiting">Waiting for</option>
                    <option value="Date">Date</option>
                    <option value="Dateandtime">Date & Time</option>
                    <option value="Tomorrow">Tomorrow</option>
                    <option value="7 days">7 days Time</option>
                    <option value="2 Weeks Time">2 Weeks Time</option>
                    <option value="30 days Time">30 days Time</option>
                    <option value="31 days Time">31 days Time</option>
                </select>
                <input type="text" name="na_date_c_id" value="0000-00-00" id="na_date_c_id"  readonly style="width:180px;height:30px;border-radius:5px;margin-left:10px;cursor:pointer;display:none;">
                <input type="text" name="na_time_c_id" value="00:00" id="na_time_c_id" readonly style="width:180px;height:30px;border-radius:5px;margin-left:10px;cursor:pointer;display:none;">
                <div class="pull-right">Assign to&nbsp;&nbsp;&nbsp;
                            <select id="na_assign_c_id" name="na_assign_c_id" style="" class="na_assign_c_id">
                                <option value="<?php echo $adminemailid;?>" selected>Me</option>
                                <?php
                                for($kk=0;$kk<count($comp_full_emailid);$kk++){
                                    $emailid11=$comp_full_emailid[$kk];
                                    if($adminemailid==$emailid11){
                                        
                                    }else{
                                        $employeename12=$comp_full_empname[$kk];
                                    ?>
                                        <option value="<?php echo $emailid11;?>"><?php echo $employeename12;?></option>
                                    <?php
                                    }
                                }
                                ?>
                            </select>
                        </div><br><br>
                <div style="padding-bottom:20px;padding-top:15px;">
                <input type="button" class="btn btn-primary" value="save" onclick="fun_save_first_nextaction()" >
                </div>
            </div>
        </div>
        <script>
            $(document).ready(function(){
                $(".na_assign_c_id").selectpicker();
                $(".changenextaction").hide("visibility","hidden" );
            });
        </script>
        <?php
    }else{
        
    ?>
        <div class="row" style="background-color:#d9eefc;border-radius:5px;padding-bottom:10px;" id="closednextaction<?php echo $c_id;?>">
            <div class="col-md-2"></div>
            <div class="col-md-10" style="padding:20px 0px;">
                <b><span style="color:#54585b;">Sales cycle closed</span></b> - <a style="color:#6699cc;cursor:pointer;" onclick="reopenthenextaction()">Reopen</a> or 
                
                <input type="hidden" name="closingdate" id="closingdate" value="<?php echo $cont_na_closingdate;?>">
                <input type="hidden" name="closingcomment" id="closingcomment" value="<?php echo $cont_na_closingcomment;?>">
                <?php 
                if(($cont_na_closingcomment=="")||($cont_na_closingcomment=="no data available")){
                ?>
                <a style="color:#6699cc;cursor:pointer;" onclick="addnewclosingcommentui()"> Add a closing comment</a>
                <?php
                }else{
                ?>
                <a style="color:#6699cc;cursor:pointer;" onclick="editnewclosingcommentui()"> Edit a closing comment</a><br>
                <b><?php echo $cont_na_closingcomment;?></b>
                <?php
                }
                ?><br>
                <span style="color: #666;font-size: 13px;font-family: 'Open Sans Italic', Arial, Helvetica, sans-serif;"><i> Next Action process closed for me on &nbsp;</i> <?php echo $cont_na_closingdate;?></span>
            </div>
            
            <span class="pull-right"  onclick="shownextactionqueue('#newnextactionadd')" >
                <span class="add_new_action" style="margin-right:10px;"></span>
            </span>
        </div>
    <?php
    }
}else{
    ?>
    
    <div class="row" style="background-color:#d9eefc;padding-bottom:10px;" id="<?php echo 'top_next_action_'.$c_id;?>">
        <div class="col-md-2">
            <br>
            <div class="checkbox pull-right" styl e="padding-top:10px;">
                <label class="container1">
                    <input type="checkbox" value="" id="checkbox1<?php echo $na_id;?>" onchange="checkitscompletedtop('#checkbox1<?php echo $na_id;?>','<?php echo $na_id;?>','#na_f_desc<?php echo $na_id;?>', '#na_f_date<?php echo $na_id;?>', '#na_f_time<?php echo $na_id;?>','#na_f_assign<?php echo $na_id;?>','#na_f_select<?php echo $na_id;?>')">
                    <span class="checkmark" ></span>
                </label>
            </div>
        </div>
        <div class="col-md-10">
            <h5>Next Action
            <span class="pull-right" style="color:grey;cursor:pointer;" onclick="editfirstnextaction('na_f_desc<?php echo $na_id;?>', 'na_f_date<?php echo $na_id;?>', 'na_f_time<?php echo $na_id;?>','na_f_assign<?php echo $na_id;?>','na_f_select<?php echo $na_id;?>', '<?php echo $na_id;?>')">Edit</span></h5>
            <input type="hidden" id="na_f_desc<?php echo $na_id;?>" value="<?php echo $na_descr;?>">
            <input type="hidden" id="na_f_date<?php echo $na_id;?>" value="<?php echo $na_date;?>">
            <input type="hidden" id="na_f_time<?php echo $na_id;?>" value="<?php echo $na_time;?>">
            <input type="hidden" id="na_f_select<?php echo $na_id;?>" value="<?php echo $na_selectedoption;?>">
            <input type="hidden" id="na_f_assign<?php echo $na_id;?>" value="<?php echo $na_assign;?>">
            <b><?php echo $na_descr;?></b>
            <div class="row" style="padding:10px 0px 10px 0px;">
                <div class="col-sm-8" style="padding:0px;">
                    <?php  
                     if(($na_selectedoption=="Queued")){
                    ?>
                        <div class="nextaction_queued_css1">
                            <span style="margin-left:10px;">
                                Queued
                            </span>
                        </div>
                    <?php
                    }else if(($na_selectedoption=="ASAP")){
                    ?>
                        <div class="nextaction_asap_css1">
                            <span style="margin-left:10px;">
                                ASAP&nbsp;&nbsp;&nbsp;&nbsp;
                            </span>
                        </div>
                    <?php
                    }else if(($na_selectedoption=="Waiting")){
                    ?>
                        <div class="nextaction_waiting_css1">
                            <span style="margin-left:10px;">
                                Waiting
                            </span>
                        </div>
                    <?php
                    }else if($na_date<date("Y-m-d")){
                    ?>
                        <div class="nextaction_date_css1">
                            <span style="margin-left:10px;">
                                <?php if ($na_date!="0000-00-00") { echo date("M", strtotime($na_date)); echo "&nbsp;&nbsp;".date("d", strtotime($na_date)); }else{ echo "Queued"; }?>
                            </span>
                        </div>
                    <?php 
                    }else{
                    ?>
                        <div class="nextaction_date1_css1">
                            <span style="margin-left:10px;">
                                <?php if ($na_date!="0000-00-00") { echo date("M", strtotime($na_date)); echo "&nbsp;&nbsp;".date("d", strtotime($na_date)); }else{ echo "Queued"; }?>
                            </span>
                        </div>
                    <?php
                    } 
                    ?>
                </div>
                <div class="col-sm-4">
                <span class="pull-right"  onclick="shownextactionqueue('#newnextactionadd')">
                    <span class="add_new_action"></span>
                </span>
                </div>
            </div>
        </div>
    </div>
    <script>
        $(document).ready(function(){
           $(".changenextaction").css("visibility","hidden"); 
        });
    </script>
    <?php
}


?>
</div>
<style>
.add_new_action {
    background: url(../../Images/add_delete.png) no-repeat -35px -94px transparent;
    width: 17px;
    height: 17px;
    display: block;
    position: absolute;
    content: "";
    display: block;
    text-indent: -9999px;
    cursor: pointer;
    -webkit-border-radius: 50%;
    -moz-border-radius: 50%;
    border-radius: 50%;
    position: static;
}
</style>
<?php
$adminemailid1=str_replace(".","_vel_",$adminemailid);
$adminemailid1=str_replace("@","_vel_",$adminemailid1);
?>
<div id="<?php echo $adminemailid1.'_'.$c_id;?>" style="background-color: #f8f8f8;">
<?php
$sql2="SELECT * FROM sales_nextaction where cont_id='$c_id' and na_status!='completed' and na_assign='$adminemailid' and na_priority!='1' and na_delete='no' and na_selectedoption!='Queued' order by na_date ASC";
$result2 = $pdo->query($sql2);
$result2->rowcount();


foreach($result2 as $row2){
    $na_id=$row2['id'];
    $companyname=$row2['companyname'];
    $cont_id=$row2['cont_id'];
    $na_assign=$row2['na_assign'];
    $na_descr=$row2['na_descr'];
    $na_status=$row2['na_status'];
    $na_selectedoption=$row2['na_selectedoption'];
    $na_priority=$row2['na_priority'];
    $na_date=$row2['na_date'];
    $na_time=$row2['na_time'];
    $na_delete=$row2['na_delete'];
    $na_c_datetime=$row2['na_c_datetime'];
    $na_c_by=$row2['na_c_by'];
    $na_c_type=$row2['na_c_type'];
    $na_u_datetime=$row2['na_u_datetime'];
    $na_u_by=$row2['na_u_by'];
    $na_u_type=$row2['na_u_type'];
    $na_d_datetime=$row2['na_d_datetime'];
    $na_d_by=$row2['na_d_by'];
    $na_d_type=$row2['na_d_type'];
    ?>
            <div class="row" style="padding:10px 0px 0px 0px;cursor:pointer;" id="nextactionqueue<?php echo $na_id;?>" onmouseover="functionnextaction_show_icon('#nextaction_icon<?php echo $na_id;?>')" onmouseout="functionnextaction_hide_icon('#nextaction_icon<?php echo $na_id;?>')">
                <div class="col-sm-2">
                    <span class="pull-right">
                        <span class="changenextaction" style="background-color:grey;color:white;border-radius:3px;font-size:10px;cursor:pointer;margin-left:-50px;padding:3px;" onclick="exchangenextaction('<?php echo $na_id;?>','#na_s_desc<?php echo $na_id;?>','#na_s_date<?php echo $na_id;?>','#na_s_time<?php echo $na_id;?>','#na_s_select<?php echo $na_id;?>','#nextactionqueue<?php echo $na_id;?>','#na_s_assign<?php echo $na_id;?>')"><i style="transform: rotate(180deg)" class="fa fa-level-down" aria-hidden="true"></i>&nbsp;&nbsp;next</span>
                    
                        
                        <label class="container2">
                            <input type="checkbox" value="" id="checkbox1_<?php echo $na_id;?>" onchange="checkitscompleted1('#checkbox1_<?php echo $na_id;?>','<?php echo $na_id;?>','#nextaction_desc1_<?php echo $na_id;?>','#nextaction_icon1_<?php echo $na_id;?>')">
                            <span class="checkmark2" ></span>
                        </label>
                    </span>
                    <input type="hidden" id="na_s_desc<?php echo $na_id;?>" value="<?php echo $na_descr;?>">
                    <input type="hidden" id="na_s_date<?php echo $na_id;?>" value="<?php echo $na_date;?>">
                    <input type="hidden" id="na_s_time<?php echo $na_id;?>" value="<?php echo $na_time;?>">
                    <input type="hidden" id="na_s_nid<?php echo $na_id;?>" value="<?php echo $na_id;?>"> 
                    <input type="hidden" id="na_s_assign<?php echo $na_id;?>" value="<?php echo $na_assign;?>">
                    <input type="hidden" id="na_s_select<?php echo $na_id;?>" value="<?php echo $na_selectedoption;?>">
                </div>
                <div class="col-md-10" style="margin-left:0px;">
                    <?php  
                     if($na_selectedoption=="Queued"){
                    ?>
                        <div class="nextaction_queued_css">
                            <span style="margin-left:10px;">
                                Queued
                            </span>&nbsp;&nbsp;&nbsp;&nbsp;<span id="nextaction_desc1_<?php echo $na_id;?>" style="color:grey"><?php echo $na_descr;?>&nbsp;&nbsp;&nbsp;&nbsp;<?php if($na_time!="00:00:00"){ echo $na_time; }?></span>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <span style="display:none;cursor:pointer;color:grey;" id="nextaction_icon<?php echo $na_id;?>">
                                <span id="nextaction_icon1_<?php echo $na_id;?>">
                                    <span style="cursor:pointer;" onclick="functiondeletenextaction('<?php echo $na_id;?>', '#nextactionqueue<?php echo $na_id;?>')" id="nextactiondelete1<?php echo $na_id;?>">
                                        <i class="glyphicon glyphicon-trash"></i>
                                    </span>&nbsp;&nbsp;
                                    
                                    <span style="cursor:pointer;" onclick="editsecondnextaction('na_s_desc<?php echo $na_id;?>','na_s_date<?php echo $na_id;?>','na_s_time<?php echo $na_id;?>','na_s_nid<?php echo $na_id;?>','#nextactionqueue<?php echo $na_id;?>','<?php echo $c_id;?>','na_s_assign<?php echo $na_id;?>','na_s_select<?php echo $na_id;?>')">
                                        <i class="glyphicon glyphicon-pencil"></i>
                                    </span>
                                </span>
                            </span>
                        </div>
                    <?php
                    }else if($na_selectedoption=="ASAP"){
                    ?>
                        <div class="nextaction_asap_css">
                            <span style="margin-left:10px;">
                                <?php echo $na_selectedoption;?>
                            </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span id="nextaction_desc1_<?php echo $na_id;?>" style="color:grey"><?php echo $na_descr;?>&nbsp;&nbsp;&nbsp;&nbsp;<?php if($na_time!="00:00:00"){ echo $na_time; }?></span>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <span style="display:none;cursor:pointer;color:grey;" id="nextaction_icon<?php echo $na_id;?>">
                                <span id="nextaction_icon1_<?php echo $na_id;?>">
                                    <span style="cursor:pointer;" onclick="functiondeletenextaction('<?php echo $na_id;?>', '#nextactionqueue<?php echo $na_id;?>')" id="nextactiondelete1<?php echo $na_id;?>">
                                        <i class="glyphicon glyphicon-trash"></i>
                                    </span>&nbsp;&nbsp;
                                    
                                    <span style="cursor:pointer;" onclick="editsecondnextaction('na_s_desc<?php echo $na_id;?>','na_s_date<?php echo $na_id;?>','na_s_time<?php echo $na_id;?>','na_s_nid<?php echo $na_id;?>','#nextactionqueue<?php echo $na_id;?>','<?php echo $c_id;?>','na_s_assign<?php echo $na_id;?>','na_s_select<?php echo $na_id;?>')">
                                        <i class="glyphicon glyphicon-pencil"></i>
                                    </span>
                                </span>
                            </span>
                        </div>
                    <?php 
                    }else if($na_selectedoption=="Waiting"){
                    ?>
                        <div class="nextaction_waiting_css">
                            <span style="margin-left:10px;">
                                <?php echo $na_selectedoption;?>
                            </span>&nbsp;&nbsp;&nbsp;&nbsp;<span id="nextaction_desc1_<?php echo $na_id;?>" style="color:grey"><?php echo $na_descr;?>&nbsp;&nbsp;&nbsp;&nbsp;<?php if($na_time!="00:00:00"){ echo $na_time; }?></span>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <span style="display:none;cursor:pointer;color:grey;" id="nextaction_icon<?php echo $na_id;?>">
                                <span id="nextaction_icon1_<?php echo $na_id;?>">
                                    <span style="cursor:pointer;" onclick="functiondeletenextaction('<?php echo $na_id;?>', '#nextactionqueue<?php echo $na_id;?>')" id="nextactiondelete1<?php echo $na_id;?>">
                                        <i class="glyphicon glyphicon-trash"></i>
                                    </span>&nbsp;&nbsp;
                                    
                                    <span style="cursor:pointer;" onclick="editsecondnextaction('na_s_desc<?php echo $na_id;?>','na_s_date<?php echo $na_id;?>','na_s_time<?php echo $na_id;?>','na_s_nid<?php echo $na_id;?>','#nextactionqueue<?php echo $na_id;?>','<?php echo $c_id;?>','na_s_assign<?php echo $na_id;?>','na_s_select<?php echo $na_id;?>')">
                                        <i class="glyphicon glyphicon-pencil"></i>
                                    </span>
                                </span>
                            </span>
                        </div>
                    <?php 
                    }else if($na_date<date("Y-m-d")){
                    ?>
                        <div class="nextaction_date_css">
                            <span style="margin-left:10px;">
                                <?php echo date("M", strtotime($na_date)); echo "&nbsp;&nbsp;".date("d", strtotime($na_date));?>
                            </span>&nbsp;&nbsp;&nbsp;&nbsp;<span id="nextaction_desc1_<?php echo $na_id;?>" style="color:grey"><?php echo $na_descr;?>&nbsp;&nbsp;&nbsp;&nbsp;<?php if($na_time!="00:00:00"){ echo $na_time; }?></span>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <span style="display:none;cursor:pointer;color:grey;" id="nextaction_icon<?php echo $na_id;?>">
                                <span id="nextaction_icon1_<?php echo $na_id;?>">
                                    <span style="cursor:pointer;" onclick="functiondeletenextaction('<?php echo $na_id;?>', '#nextactionqueue<?php echo $na_id;?>')" id="nextactiondelete1<?php echo $na_id;?>">
                                        <i class="glyphicon glyphicon-trash"></i>
                                    </span>&nbsp;&nbsp;
                                    
                                    <span style="cursor:pointer;" onclick="editsecondnextaction('na_s_desc<?php echo $na_id;?>','na_s_date<?php echo $na_id;?>','na_s_time<?php echo $na_id;?>','na_s_nid<?php echo $na_id;?>','#nextactionqueue<?php echo $na_id;?>','<?php echo $c_id;?>','na_s_assign<?php echo $na_id;?>','na_s_select<?php echo $na_id;?>')">
                                        <i class="glyphicon glyphicon-pencil"></i>
                                    </span>
                                </span>
                            </span>
                        </div>
                    <?php 
                    }else{
                    ?>
                        <div class="nextaction_date1_css">
                            <span style="margin-left:10px;">
                                <?php echo date("M", strtotime($na_date)); echo "&nbsp;&nbsp;".date("d", strtotime($na_date));?>
                            </span>&nbsp;&nbsp;&nbsp;&nbsp;<span id="nextaction_desc1_<?php echo $na_id;?>" style="color:grey"><?php echo $na_descr;?>&nbsp;&nbsp;&nbsp;&nbsp;<?php if($na_time!="00:00:00"){ echo $na_time; }?></span>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <span style="display:none;cursor:pointer;color:#666;" id="nextaction_icon<?php echo $na_id;?>">
                                <span id="nextaction_icon1_<?php echo $na_id;?>">
                                    <span style="cursor:pointer;" onclick="functiondeletenextaction('<?php echo $na_id;?>', '#nextactionqueue<?php echo $na_id;?>')">
                                        <i class="glyphicon glyphicon-trash"></i>
                                    </span>&nbsp;&nbsp;
                                    
                                    <span style="cursor:pointer;" onclick="editsecondnextaction('na_s_desc<?php echo $na_id;?>','na_s_date<?php echo $na_id;?>','na_s_time<?php echo $na_id;?>','na_s_nid<?php echo $na_id;?>','#nextactionqueue<?php echo $na_id;?>','<?php echo $c_id;?>','na_s_assign<?php echo $na_id;?>','na_s_select<?php echo $na_id;?>')">
                                        <i class="glyphicon glyphicon-pencil"></i>
                                    </span>
                                </span>
                            </span>
                        </div>
                    <?php
                    } 
                    ?>
                </div>
                
                    
            </div>
            
            <?php
}
$sql2="SELECT * FROM sales_nextaction where cont_id='$c_id' and na_status!='completed' and na_assign='$adminemailid' and na_priority!='1' and na_delete='no' and na_selectedoption='Queued' order by na_c_datetime ASC";
$result2 = $pdo->query($sql2);
$result2->rowcount();


foreach($result2 as $row2){
    $na_id=$row2['id'];
    $companyname=$row2['companyname'];
    $cont_id=$row2['cont_id'];
    $na_assign=$row2['na_assign'];
    $na_descr=$row2['na_descr'];
    $na_status=$row2['na_status'];
    $na_selectedoption=$row2['na_selectedoption'];
    $na_priority=$row2['na_priority'];
    $na_date=$row2['na_date'];
    $na_time=$row2['na_time'];
    $na_delete=$row2['na_delete'];
    $na_c_datetime=$row2['na_c_datetime'];
    $na_c_by=$row2['na_c_by'];
    $na_c_type=$row2['na_c_type'];
    $na_u_datetime=$row2['na_u_datetime'];
    $na_u_by=$row2['na_u_by'];
    $na_u_type=$row2['na_u_type'];
    $na_d_datetime=$row2['na_d_datetime'];
    $na_d_by=$row2['na_d_by'];
    $na_d_type=$row2['na_d_type'];
    ?>
            <div class="row" style="padding:10px 0px 0px 0px;cursor:pointer;" id="nextactionqueue<?php echo $na_id;?>" onmouseover="functionnextaction_show_icon('#nextaction_icon<?php echo $na_id;?>')" onmouseout="functionnextaction_hide_icon('#nextaction_icon<?php echo $na_id;?>')">
                <div class="col-sm-2">
                        
                    <span  class="pull-right" >
                        <span class="changenextaction" style="background-color:grey;color:white;border-radius:3px;font-size:10px;cursor:pointer;margin-left:-50px;padding:3px;" onclick="exchangenextaction('<?php echo $na_id;?>','#na_s_desc<?php echo $na_id;?>','#na_s_date<?php echo $na_id;?>','#na_s_time<?php echo $na_id;?>','#na_s_select<?php echo $na_id;?>','#nextactionqueue<?php echo $na_id;?>','#na_s_assign<?php echo $na_id;?>')"><i style="transform: rotate(180deg)" class="fa fa-level-down" aria-hidden="true"></i>&nbsp;&nbsp;next</span>
                        <label class="container2">
                            <input type="checkbox" value="" id="checkbox1_<?php echo $na_id;?>" onchange="checkitscompleted1('#checkbox1_<?php echo $na_id;?>','<?php echo $na_id;?>','#nextaction_desc1_<?php echo $na_id;?>','#nextaction_icon1_<?php echo $na_id;?>')">
                            <span class="checkmark2" ></span>
                        </label>
                        
                    </span>
                    <input type="hidden" id="na_s_desc<?php echo $na_id;?>" value="<?php echo $na_descr;?>">
                    <input type="hidden" id="na_s_date<?php echo $na_id;?>" value="<?php echo $na_date;?>">
                    <input type="hidden" id="na_s_time<?php echo $na_id;?>" value="<?php echo $na_time;?>">
                    <input type="hidden" id="na_s_nid<?php echo $na_id;?>" value="<?php echo $na_id;?>"> 
                    <input type="hidden" id="na_s_assign<?php echo $na_id;?>" value="<?php echo $na_assign;?>">
                    <input type="hidden" id="na_s_select<?php echo $na_id;?>" value="<?php echo $na_selectedoption;?>">
                </div>
                <div class="col-md-10" style="margin-left:0px;">
                    <?php  
                     if($na_selectedoption=="Queued"){
                    ?>
                        <div class="nextaction_queued_css">
                            <span style="margin-left:10px;">
                                Queued
                            </span>&nbsp;&nbsp;&nbsp;&nbsp;<span id="nextaction_desc1_<?php echo $na_id;?>" style="color:grey"><?php echo $na_descr;?>&nbsp;&nbsp;&nbsp;&nbsp;<?php if($na_time!="00:00:00"){ echo $na_time; }?></span>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <span style="display:none;cursor:pointer;color:grey;" id="nextaction_icon<?php echo $na_id;?>">
                                <span id="nextaction_icon1_<?php echo $na_id;?>">
                                    <span style="cursor:pointer;" onclick="functiondeletenextaction('<?php echo $na_id;?>', '#nextactionqueue<?php echo $na_id;?>')" id="nextactiondelete1<?php echo $na_id;?>">
                                        <i class="glyphicon glyphicon-trash"></i>
                                    </span>&nbsp;&nbsp;
                                    
                                    <span style="cursor:pointer;" onclick="editsecondnextaction('na_s_desc<?php echo $na_id;?>','na_s_date<?php echo $na_id;?>','na_s_time<?php echo $na_id;?>','na_s_nid<?php echo $na_id;?>','#nextactionqueue<?php echo $na_id;?>','<?php echo $c_id;?>','na_s_assign<?php echo $na_id;?>','na_s_select<?php echo $na_id;?>')">
                                        <i class="glyphicon glyphicon-pencil"></i>
                                    </span>
                                </span>
                            </span>
                        </div>
                    <?php
                    }else if($na_selectedoption=="ASAP"){
                    ?>
                        <div class="nextaction_asap_css">
                            <span style="margin-left:10px;">
                                <?php echo $na_selectedoption;?>
                            </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span id="nextaction_desc1_<?php echo $na_id;?>" style="color:grey"><?php echo $na_descr;?>&nbsp;&nbsp;&nbsp;&nbsp;<?php if($na_time!="00:00:00"){ echo $na_time; }?></span>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <span style="display:none;cursor:pointer;color:grey;" id="nextaction_icon<?php echo $na_id;?>">
                                <span id="nextaction_icon1_<?php echo $na_id;?>">
                                    <span style="cursor:pointer;" onclick="functiondeletenextaction('<?php echo $na_id;?>', '#nextactionqueue<?php echo $na_id;?>')" id="nextactiondelete1<?php echo $na_id;?>">
                                        <i class="glyphicon glyphicon-trash"></i>
                                    </span>&nbsp;&nbsp;
                                    
                                    <span style="cursor:pointer;" onclick="editsecondnextaction('na_s_desc<?php echo $na_id;?>','na_s_date<?php echo $na_id;?>','na_s_time<?php echo $na_id;?>','na_s_nid<?php echo $na_id;?>','#nextactionqueue<?php echo $na_id;?>','<?php echo $c_id;?>','na_s_assign<?php echo $na_id;?>','na_s_select<?php echo $na_id;?>')">
                                        <i class="glyphicon glyphicon-pencil"></i>
                                    </span>
                                </span>
                            </span>
                        </div>
                    <?php 
                    }else if($na_selectedoption=="Waiting"){
                    ?>
                        <div class="nextaction_waiting_css">
                            <span style="margin-left:10px;">
                                <?php echo $na_selectedoption;?>
                            </span>&nbsp;&nbsp;&nbsp;&nbsp;<span id="nextaction_desc1_<?php echo $na_id;?>" style="color:grey"><?php echo $na_descr;?>&nbsp;&nbsp;&nbsp;&nbsp;<?php if($na_time!="00:00:00"){ echo $na_time; }?></span>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <span style="display:none;cursor:pointer;color:grey;" id="nextaction_icon<?php echo $na_id;?>">
                                <span id="nextaction_icon1_<?php echo $na_id;?>">
                                    <span style="cursor:pointer;" onclick="functiondeletenextaction('<?php echo $na_id;?>', '#nextactionqueue<?php echo $na_id;?>')" id="nextactiondelete1<?php echo $na_id;?>">
                                        <i class="glyphicon glyphicon-trash"></i>
                                    </span>&nbsp;&nbsp;
                                    
                                    <span style="cursor:pointer;" onclick="editsecondnextaction('na_s_desc<?php echo $na_id;?>','na_s_date<?php echo $na_id;?>','na_s_time<?php echo $na_id;?>','na_s_nid<?php echo $na_id;?>','#nextactionqueue<?php echo $na_id;?>','<?php echo $c_id;?>','na_s_assign<?php echo $na_id;?>','na_s_select<?php echo $na_id;?>')">
                                        <i class="glyphicon glyphicon-pencil"></i>
                                    </span>
                                </span>
                            </span>
                        </div>
                    <?php 
                    }else if($na_date<date("Y-m-d")){
                    ?>
                        <div class="nextaction_date_css">
                            <span style="margin-left:10px;">
                                <?php echo date("M", strtotime($na_date)); echo "&nbsp;&nbsp;".date("d", strtotime($na_date));?>
                            </span>&nbsp;&nbsp;&nbsp;&nbsp;<span id="nextaction_desc1_<?php echo $na_id;?>" style="color:grey"><?php echo $na_descr;?>&nbsp;&nbsp;&nbsp;&nbsp;<?php if($na_time!="00:00:00"){ echo $na_time; }?></span>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <span style="display:none;cursor:pointer;color:grey;" id="nextaction_icon<?php echo $na_id;?>">
                                <span id="nextaction_icon1_<?php echo $na_id;?>">
                                    <span style="cursor:pointer;" onclick="functiondeletenextaction('<?php echo $na_id;?>', '#nextactionqueue<?php echo $na_id;?>')" id="nextactiondelete1<?php echo $na_id;?>">
                                        <i class="glyphicon glyphicon-trash"></i>
                                    </span>&nbsp;&nbsp;
                                    
                                    <span style="cursor:pointer;" onclick="editsecondnextaction('na_s_desc<?php echo $na_id;?>','na_s_date<?php echo $na_id;?>','na_s_time<?php echo $na_id;?>','na_s_nid<?php echo $na_id;?>','#nextactionqueue<?php echo $na_id;?>','<?php echo $c_id;?>','na_s_assign<?php echo $na_id;?>','na_s_select<?php echo $na_id;?>')">
                                        <i class="glyphicon glyphicon-pencil"></i>
                                    </span>
                                </span>
                            </span>
                        </div>
                    <?php 
                    }else{
                    ?>
                        <div class="nextaction_date1_css">
                            <span style="margin-left:10px;">
                                <?php echo date("M", strtotime($na_date)); echo "&nbsp;&nbsp;".date("d", strtotime($na_date));?>
                            </span>&nbsp;&nbsp;&nbsp;&nbsp;<span id="nextaction_desc1_<?php echo $na_id;?>" style="color:grey"><?php echo $na_descr;?>&nbsp;&nbsp;&nbsp;&nbsp;<?php if($na_time!="00:00:00"){ echo $na_time; }?></span>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <span style="display:none;cursor:pointer;color:#666;" id="nextaction_icon<?php echo $na_id;?>">
                                <span id="nextaction_icon1_<?php echo $na_id;?>">
                                    <span style="cursor:pointer;" onclick="functiondeletenextaction('<?php echo $na_id;?>', '#nextactionqueue<?php echo $na_id;?>')">
                                        <i class="glyphicon glyphicon-trash"></i>
                                    </span>&nbsp;&nbsp;
                                    
                                    <span style="cursor:pointer;" onclick="editsecondnextaction('na_s_desc<?php echo $na_id;?>','na_s_date<?php echo $na_id;?>','na_s_time<?php echo $na_id;?>','na_s_nid<?php echo $na_id;?>','#nextactionqueue<?php echo $na_id;?>','<?php echo $c_id;?>','na_s_assign<?php echo $na_id;?>','na_s_select<?php echo $na_id;?>')">
                                        <i class="glyphicon glyphicon-pencil"></i>
                                    </span>
                                </span>
                            </span>
                        </div>
                    <?php
                    } 
                    ?>
                </div>
            </div>
                
        <?php
        }
        ?>
    </div>
    
<?php    
for($rh=0;$rh<count($comp_full_emailid);$rh++){
    $ass_emailid=$comp_full_emailid[$rh];
    $ass_empname=$comp_full_emailid[$rh];
    if(strtoupper($ass_emailid)!=strtoupper($adminemailid)){
    $ass_emailid1=str_replace(".","_vel_",$ass_emailid);
    $ass_emailid1=str_replace("@","_vel_",$ass_emailid1);
    
    $sql3="SELECT * FROM sales_nextaction where cont_id='$c_id' and na_status!='completed' and na_assign='$ass_emailid' and na_delete='no' order by na_priority DESC, na_selectedoption ASC, na_date Asc";

    $result3 = $pdo->query($sql3);
    
    $otherempnextcount=$result3->rowcount();
    ?>
    <div id="<?php echo $ass_emailid1.'_'.$c_id;?>"  style="background-color: #f8f8f8;">
        <?php
        if($otherempnextcount>0){
        ?>
        <div class="row" id="<?php echo 'o_'.$ass_emailid1.'_'.$c_id;?>" style="padding:3px;">
            <div class="col-md-2"></div>
            <div class="col-md-10">
                <span style="color:grey"><?php echo $ass_empname;?></span>
            </div>
        </div>
        <?php
        }else{
        ?>
        <div class="row" id="<?php echo 'o_'.$ass_emailid1.'_'.$c_id;?>" style="padding:3px;display:none;">
            <div class="col-md-2"></div>
            <div class="col-md-10">
                <span style="color:grey"><?php echo $ass_empname;?></span>
            </div>
        </div>
        <?php
        }
        ?>
    <?php
    foreach($result3 as $row3){
        $na_id=$row3['id'];
        $companyname=$row3['companyname'];
        $cont_id=$row3['cont_id'];
        $na_assign=$row3['na_assign'];
        $na_descr=$row3['na_descr'];
        $na_status=$row3['na_status'];
        $na_selectedoption=$row3['na_selectedoption'];
        $na_priority=$row3['na_priority'];
        $na_date=$row3['na_date'];
        $na_time=$row3['na_time'];
        $na_delete=$row3['na_delete'];
        $na_c_datetime=$row3['na_c_datetime'];
        $na_c_by=$row3['na_c_by'];
        $na_c_type=$row3['na_c_type'];
        $na_u_datetime=$row3['na_u_datetime'];
        $na_u_by=$row3['na_u_by'];
        $na_u_type=$row3['na_u_type'];
        $na_d_datetime=$row3['na_d_datetime'];
        $na_d_by=$row3['na_d_by'];
        $na_d_type=$row3['na_d_type'];
        ?>
        
            <div class="row" style="padding:10px 0px 0px 0px;cursor:pointer;" id="nextactionqueue<?php echo $na_id;?>" onmouseover="functionnextaction_show_icon('#nextaction_icon<?php echo $na_id;?>')" onmouseout="functionnextaction_hide_icon('#nextaction_icon<?php echo $na_id;?>')">
                <div class="col-sm-2">
                    <span class="pull-right"><img src="../../Images/drag-verticalv2.png">&nbsp;&nbsp;&nbsp;</span>
                    <input type="hidden" id="na_s_desc<?php echo $na_id;?>" value="<?php echo $na_descr;?>">
                    <input type="hidden" id="na_s_date<?php echo $na_id;?>" value="<?php echo $na_date;?>">
                    <input type="hidden" id="na_s_time<?php echo $na_id;?>" value="<?php echo $na_time;?>">
                    <input type="hidden" id="na_s_nid<?php echo $na_id;?>" value="<?php echo $na_id;?>"> 
                    <input type="hidden" id="na_s_assign<?php echo $na_id;?>" value="<?php echo $na_assign;?>">
                    <input type="hidden" id="na_s_select<?php echo $na_id;?>" value="<?php echo $na_selectedoption;?>">
                </div>
                <div class="col-md-10" style="margin-left:0px;">
                    <?php  
                     if($na_selectedoption=="Queued"){
                    ?>
                        <div class="nextaction_queued_css">
                            <span style="margin-left:10px;">
                                Queued
                            </span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:grey"><?php echo $na_descr;?></span>&nbsp;&nbsp;&nbsp;&nbsp;<?php if($na_time!="00:00:00"){ echo $na_time; }?>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <span style="display:none;cursor:pointer;color:grey;" id="nextaction_icon<?php echo $na_id;?>">
                                
                                <span style="cursor:pointer;" id="nextactionedit1<?php echo $na_id;?>" onclick="editsecondnextaction('na_s_desc<?php echo $na_id;?>','na_s_date<?php echo $na_id;?>','na_s_time<?php echo $na_id;?>','na_s_nid<?php echo $na_id;?>','#nextactionqueue<?php echo $na_id;?>','<?php echo $c_id;?>','na_s_assign<?php echo $na_id;?>','na_s_select<?php echo $na_id;?>')">
                                    <i class="glyphicon glyphicon-pencil"></i>
                                </span>
                            </span>
                        </div>
                    <?php
                    }else if($na_selectedoption=="ASAP"){
                    ?>
                        <div class="nextaction_asap_css">
                            <span style="margin-left:10px;">
                                <?php echo $na_selectedoption;?>
                            </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:grey"><?php echo $na_descr;?></span>&nbsp;&nbsp;&nbsp;&nbsp;<?php if($na_time!="00:00:00"){ echo $na_time; }?>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <span style="display:none;cursor:pointer;color:grey;" id="nextaction_icon<?php echo $na_id;?>">
                                
                                <span style="cursor:pointer;" id="nextactionedit1<?php echo $na_id;?>" onclick="editsecondnextaction('na_s_desc<?php echo $na_id;?>','na_s_date<?php echo $na_id;?>','na_s_time<?php echo $na_id;?>','na_s_nid<?php echo $na_id;?>','#nextactionqueue<?php echo $na_id;?>','<?php echo $c_id;?>','na_s_assign<?php echo $na_id;?>','na_s_select<?php echo $na_id;?>')">
                                    <i class="glyphicon glyphicon-pencil"></i>
                                </span>
                            </span>
                        </div>
                    <?php 
                    }else if($na_selectedoption=="Waiting"){
                    ?>
                        <div class="nextaction_waiting_css">
                            <span style="margin-left:10px;">
                                <?php echo $na_selectedoption;?>
                            </span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:grey"><?php echo $na_descr;?></span>&nbsp;&nbsp;&nbsp;&nbsp;<?php if($na_time!="00:00:00"){ echo $na_time; }?>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <span style="display:none;cursor:pointer;color:grey;" id="nextaction_icon<?php echo $na_id;?>">
                                
                                <span style="cursor:pointer;" id="nextactionedit1<?php echo $na_id;?>" onclick="editsecondnextaction('na_s_desc<?php echo $na_id;?>','na_s_date<?php echo $na_id;?>','na_s_time<?php echo $na_id;?>','na_s_nid<?php echo $na_id;?>','#nextactionqueue<?php echo $na_id;?>','<?php echo $c_id;?>','na_s_assign<?php echo $na_id;?>','na_s_select<?php echo $na_id;?>')">
                                    <i class="glyphicon glyphicon-pencil"></i>
                                </span>
                            </span>
                        </div>
                    <?php 
                    }else if($na_date<date("Y-m-d")){
                    ?>
                        <div class="nextaction_date_css">
                            <span style="margin-left:10px;">
                                <?php echo date("M", strtotime($na_date)); echo "&nbsp;&nbsp;".date("d", strtotime($na_date));?>
                            </span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:grey"><?php echo $na_descr;?></span>&nbsp;&nbsp;&nbsp;&nbsp;<?php if($na_time!="00:00:00"){ echo $na_time; }?>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <span style="display:none;cursor:pointer;color:grey;" id="nextaction_icon<?php echo $na_id;?>">
                                
                                <span style="cursor:pointer;" id="nextactionedit1<?php echo $na_id;?>" onclick="editsecondnextaction('na_s_desc<?php echo $na_id;?>','na_s_date<?php echo $na_id;?>','na_s_time<?php echo $na_id;?>','na_s_nid<?php echo $na_id;?>','#nextactionqueue<?php echo $na_id;?>','<?php echo $c_id;?>','na_s_assign<?php echo $na_id;?>','na_s_select<?php echo $na_id;?>')">
                                    <i class="glyphicon glyphicon-pencil"></i>
                                </span>
                            </span>
                        </div>
                    <?php 
                    }else{
                    ?>
                        <div class="nextaction_date1_css">
                            <span style="margin-left:10px;">
                                <?php echo date("M", strtotime($na_date)); echo "&nbsp;&nbsp;".date("d", strtotime($na_date));?>
                            </span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:grey"><?php echo $na_descr;?></span>&nbsp;&nbsp;&nbsp;&nbsp;<?php if($na_time!="00:00:00"){ echo $na_time; }?>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <span style="display:none;cursor:pointer;color:#666;" id="nextaction_icon<?php echo $na_id;?>">
                                
                                <span style="cursor:pointer;" id="nextactionedit1<?php echo $na_id;?>" onclick="editsecondnextaction('na_s_desc<?php echo $na_id;?>','na_s_date<?php echo $na_id;?>','na_s_time<?php echo $na_id;?>','na_s_nid<?php echo $na_id;?>','#nextactionqueue<?php echo $na_id;?>','<?php echo $c_id;?>','na_s_assign<?php echo $na_id;?>','na_s_select<?php echo $na_id;?>')">
                                    <i class="glyphicon glyphicon-pencil"></i>
                                </span>
                            </span>
                        </div>
                    <?php
                    } 
                    ?>
                </div>
            </div>
        
        <?php
        
        
    }
    
    ?>
    </div>
    <?php
    }
}

?>
<!--id
companyname
cont_id
na_assign
na_descr
na_status
na_selectedoption
na_priority
na_date
na_time
na_delete
na_c_datetime
na_c_by
na_c_type
na_u_datetime
na_u_by
na_u_type
na_d_datetime
na_d_by
na_d_type-->


                


                <div class="row" id="newnextactionadd" style="background-color:#dfe6ea;border-radius:5px;padding-top:10px;display:none;">
                    <div class="col-md-2">
                        
                    </div>
                    <div class="col-md-10">
                        Add Action<br>
                        <span  style="padding:10px;">    
                            <textarea class="form-control" id="add_na_sec_descr" rows="5" onchange="function_second_add_nextaction('#na_descr2_<?php echo $c_id;?>','#savenextaction1<?php echo $c_id;?>')"></textarea>
                        </span><br>
                        <select name="na_date11" id="add_na_sec_date1" style="height:30px;border-radius:5px;" onchange="declaredatepicker('#add_na_sec_date1','#add_na_sec_date','#add_na_sec_time')">
                            <option value="Queued">Queued</option>
                            <option value="Date">Date</option>
                            <option value="Dateandtime">Date & Time</option>
                            <option value="Tomorrow">Tomorrow</option>
                            <option value="7 days">7 days Time</option>
                            <option value="2 Weeks Time">2 Weeks Time</option>
                            <option value="30 days Time">30 days Time</option>
                            <option value="31 days Time">31 days Time</option>
                        </select>
                        <input type="text" name="add_na_sec_date" value="0000-00-00" id="add_na_sec_date"  readonly style="width:180px;height:30px;border-radius:5px;margin-left:10px;cursor:pointer;display:none;">
                        <input type="text" name="add_na_sec_time" value="00:00" id="add_na_sec_time" readonly style="width:180px;height:30px;border-radius:5px;margin-left:10px;cursor:pointer;display:none;">
                        <div class="pull-right">Assign to&nbsp;&nbsp;&nbsp;
                            <select id="add_na_sec_assign" name="add_na_sec_assign" style="" class="add_na_sec_assign">
                                <option value="<?php echo $adminemailid;?>" selected>Me</option>
                                <?php
                                for($kk=0;$kk<count($comp_full_emailid);$kk++){
                                    $emailid11=$comp_full_emailid[$kk];
                                    if($adminemailid==$emailid11){
                                        
                                    }else{
                                        $employeename12=$comp_full_empname[$kk];
                                    ?>
                                        <option value="<?php echo $emailid11;?>"><?php echo $employeename12;?></option>
                                    <?php
                                    }
                                }
                                ?>
                            </select>
                        </div><br><br>
                        <input type="button" id="add_na_sec_save" class="btn btn-primary" value="save" onclick="fun_save_sec_nextaction()" >
                        <span style="margin-left:50px;color:grey;cursor:pointer;" onclick="cancelnextactionqueue('#newnextactionadd')">Cancel</span><br><br>
                    </div>
                </div>  
                <script>
                    $(document).ready(function(){
                        $(".add_na_sec_assign").selectpicker();
                    });
                </script>
                
                
                
                
                
                
                <!-- start next action script page -->
                
                        <script>
                            function shownextactionqueue(id){
                                $(id).show();
                            }
                            function cancelnextactionqueue(id){
                                $(id).hide();
                            }
                        </script>
                        <script>
                            function fun_save_sec_nextaction(){
                                
                                var monthNames = ["", "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"];
                        
                                var desc2=$("#add_na_sec_descr").val();
                                var date2=$("#add_na_sec_date").val();
                                var time2=$("#add_na_sec_time").val();
                                var assignid2=$("#add_na_sec_assign").val();
                                var selectoption2=$("#add_na_sec_date1").val();
                                var cid="<?php echo $c_id;?>";
                                
                                if(desc2==""){
                                    $("#add_na_sec_descr").focus();
                                    BootstrapAlert.warning({
                                      title: "Warning!",
                                      message: "Please enter the Next Action"
                                    }); 
                                    return;
                                }
                                if(((selectoption2=="Date")||(selectoption2=="Dateandtime")||(selectoption2=="Tomorrow")||(selectoption2=="7 days")||(selectoption2=="2 Weeks Time")||(selectoption2=="30 days Time")||(selectoption2=="31 days Time"))&&((date2=="")||(date2=="0000-00-00"))){
                                    $("#add_na_sec_date").focus();
                                    BootstrapAlert.warning({
                                      title: "Warning!",
                                      message: "Please Select the date"
                                    }); 
                                    return;
                                }
                                if((selectoption2=="Dateandtime")&&((time2=="")||(time2=="00:00:00")||(time2=="00:00"))){
                                    $("#add_na_sec_time").focus();
                                    BootstrapAlert.warning({
                                      title: "Warning!",
                                      message: "Please Select the Time"
                                    }); 
                                    return;
                                }
                                
                                var empid=new Array();
                                var empname=new Array();
                                empid=<?php echo json_encode($comp_full_emailid);?>;
                                empname=<?php echo json_encode($comp_full_empname);?>;
                                var adminid="<?php echo $adminemailid;?>";
                                var adminid1=assignid2.replace(".", "_vel_");
                                var adminid1=adminid1.replace("@", "_vel_");
                                var append2=adminid1+'_'+cid;
                                var assignname2="";
                                for(rt=0;rt<empid.length;rt++){
                                    if(empid[rt]==assignid2){
                                        assignname2=empname[rt];
                                    }
                                }
                                
                                assign2=assignid2;
                                if(adminid!=assign2){
                                    if((selectoption2=="ASAP")||(selectoption2=="Waiting")){
                                        selectoption2="Queued";
                                    }
                                }
                                if((desc2!="")&&(date2!="")&&(time2!="")){
                                    swal("Next Action Created Successfully","","success");
                                    $.ajax({
                                        url:"activestream_intermediate.php",
                                        type:"post",
                                        data:{insertnextaction:desc2, nextactiondate:date2, nextactiontime:time2, cid:cid, naassign:assignid2, selectoption:selectoption2},
                                        success:function(respond){
                                            var nid1=respond.trim()
                                            var nid_array=nid1.split("#@");
                                            nid2=nid_array[1];
                                            var monthNames = ["", "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"];
                                            var insert1="";
                                            var todate=new Date();
                                            var d=todate.getDate();
                                            var m=todate.getMonth()+1;
                                            var y=todate.getFullYear();
                                            if(m<10){
                                                m="0"+m;
                                            }
                                            var d1=y+"-"+m+"-"+d;
                                            var date3=date2;
                                            var date123=date3.split("-")
                                            var m3=date123[1];
                                            if(m3[0]=="0"){
                                                m1=m3[1];
                                            }else{
                                                m1=m3;
                                            } 
                                            
                                            insert1+='<div class="row" style="padding:0px 0px 5px 0px;cursor:pointer;" id="nextactionqueue'+nid2+'" onmouseover=functionnextaction_show_icon("#nextaction_icon'+nid2+'") onmouseout=functionnextaction_hide_icon("#nextaction_icon'+nid2+'")>'
                                            
                                            insert1+='<div class="col-sm-2">';
                                            if(adminid==assign2){
                                                insert1+='<span class="pull-right">';
                                                insert1+='<span class="changenextaction" style="visibility:hidden; background-color:grey;color:white;border-radius:3px;font-size:10px;cursor:pointer;margin-left:-50px;padding:3px;"  onclick=exchangenextaction("'+nid2+'","#na_s_desc'+nid2+'","#na_s_date'+nid2+'","#na_s_time'+nid2+'","#na_s_select'+nid2+'","#nextactionqueue'+nid2+'","#na_s_assign'+nid2+'")><i style="transform: rotate(180deg);" class="fa fa-level-down" aria-hidden="true"></i>&nbsp;&nbsp;next</span>';
                                                insert1+='<label class="container2">';
                                                    insert1+='<input type="checkbox" value="" id="checkbox1_'+nid2+'" onchange=checkitscompleted1("#checkbox1_'+nid2+'","'+nid2+'","#nextaction_desc1_'+nid2+'","#nextaction_icon1_'+nid2+'")>';
                                                    insert1+='<span class="checkmark2" ></span>';
                                                insert1+='</label>';
                                                insert1+='</span>';
                                                            
                                            }else{
                                                insert1+='<span class="pull-right"><img src="../../Images/drag-verticalv2.png">&nbsp;&nbsp;&nbsp;</span>';
                                            }
                                            insert1+='<input type="hidden" id="na_s_desc'+nid2+'" value="'+desc2+'">';
                                            insert1+='<input type="hidden" id="na_s_date'+nid2+'" value="'+date2+'">';
                                            insert1+='<input type="hidden" id="na_s_time'+nid2+'" value="'+time2+'">';   
                                            insert1+='<input type="hidden" id="na_s_nid'+nid2+'" value="'+nid2+'">';
                                            insert1+='<input type="hidden" id="na_s_assign'+nid2+'" value="'+assign2+'">';
                                            insert1+='<input type="hidden" id="na_s_select'+nid2+'" value="'+selectoption2+'">';
                                            insert1+='</div>';
                                            insert1+='<div class="col-sm-10">';
                                            if(date2=="0000-00-00"){
                                                insert1+='<div class="nextaction_queued_css">';
                                                 insert1+='<span style="margin-left:10px;">';
                                                     insert1+='Queued';
                                            }else if(date2<d1){
                                                insert1+='<div class="nextaction_date_css">';
                                                insert1+='<span style="margin-left:10px;">';
                                                insert1+=monthNames[m1]+'&nbsp;&nbsp;'+date123[2];
                                            }else{
                                                insert1+='<div class="nextaction_date1_css">';
                                                insert1+='<span style="margin-left:10px;">';
                                                insert1+=monthNames[m1]+'&nbsp;&nbsp;'+date123[2];
                                            }
                                            
                                             
                                                 insert1+='</span>&nbsp;&nbsp;&nbsp;&nbsp;<span id="nextaction_desc1_'+nid2+'" style="color:grey">'+desc2+'&nbsp;&nbsp;&nbsp;&nbsp;';
                                                 if((time2!="00:00")&&(time2!="00:00:00")){
                                                    insert1+=time2;
                                                 }
                                                 insert1+='</span>';
                                                 insert1+='&nbsp;&nbsp;&nbsp;&nbsp;';
                                                 insert1+='<span style="display:none;cursor:pointer;color:#666;" id="nextaction_icon'+nid2+'">';
                                                     insert1+='<span id="nextaction_icon1_'+nid2+'">';
                                                     if(adminid==assign2){
                                                         insert1+='<span style="cursor:pointer;"  onclick=functiondeletenextaction("'+nid2+'","nextactionqueue'+nid2+'")>';
                                                             insert1+='<i class="glyphicon glyphicon-trash"></i>';
                                                         insert1+='</span>&nbsp;&nbsp;';
                                                     }  
                                                         insert1+='<span style="cursor:pointer;" onclick=editsecondnextaction("na_s_desc'+nid2+'","na_s_date'+nid2+'","na_s_time'+nid2+'","na_s_nid'+nid2+'","#nextactionqueue'+nid2+'","'+cid+'","na_s_assign'+nid2+'","na_s_select'+nid2+'")>';
                                                             insert1+='<i class="glyphicon glyphicon-pencil"></i>';
                                                         insert1+='</span>';
                                                     insert1+='</span>';
                                                 insert1+='</span>';
                                             insert1+='</div>';
                                             
                                             insert1+='</div>';
                                                        
                                            
                                            insert1+='</div>';
                                            $("#"+append2).append(insert1);
                                            $("#o_"+append2).show();
                                            $("#add_na_sec_descr").val("");
                                            $("#add_na_sec_date").val("0000-00-00");
                                            $("#add_na_sec_time").val("00:00:00");
                                            $("#add_na_sec_date").hide();
                                            $("#add_na_sec_time").hide();
                                            $("#add_na_sec_date1").val($("#add_na_sec_date1 option:first").val());
                                            $("#add_na_sec_assign").val($("#add_na_sec_assign option:first").val());
                                            $("#add_na_sec_assign").selectpicker("refresh");
                                            $("#newnextactionadd").hide();
                                        }
                                    });
                        
                                }
                            }
                        </script>
                        
                <script>
                    function checkitscompletedtop(id1, nid, desc, date1, time1, assign, selectoption){
                        var desc2=$(desc).val();
                        var date2=$(date1).val();
                        var time2=$(time1).val();
                        var assign2=$(assign).val();
                        var selectoption2=$(selectoption).val();
                        
                        if($(id1).is(':checked')){
                            status="completed";
                            $.ajax({
                                url:"activestream_intermediate.php",
                                type:"post",
                                data:{completednextaction:nid, status:status},
                                success:function(respond){
                                        
                                    var emailid1=<?php echo json_encode($comp_full_emailid);?>;
                                    var employeename1=<?php echo json_encode($comp_full_empname);?>;
                                    var adminemailid="<?php echo $adminemailid;?>";
                                    var insert='';
                                    insert+='<div class="row" style="padding:10px;">';
                                    insert+='<div class="col-sm-2"></div>';
                                    insert+='<div class="col-sm-10">';
                                    insert+='<span  style="padding:10px 0px;"><b>Next Action</b> &nbsp;&nbsp;or &nbsp;<a onclick="funclosethenextaction()" style="color:#6699cc;cursor:pointer;">Close</a><br>';   
                                    insert+='<textarea class="form-control" id="na_descr_c_id" rows="5"></textarea>';
                                    insert+='</span><br>';
                                    insert+='<input type="hidden" id="desc_'+nid+'" name="desc_'+nid+'" value="'+desc2+'">';
                                    insert+='<input type="hidden" id="date_'+nid+'" name="date_'+nid+'" value="'+date2+'">';
                                    insert+='<input type="hidden" id="time_'+nid+'" name="time_'+nid+'" value="'+time2+'">';
                                    insert+='<input type="hidden" id="assign_'+nid+'" name="assign_'+nid+'" value="'+assign2+'">';
                                    insert+='<input type="hidden" id="selectoption_'+nid+'" name="selectoption_'+nid+'" value="'+selectoption2+'">';
                                    insert+='<input type="hidden" id="na_nid_c_id" name="na_nid_c_id" value="">';
                                    insert+='<div class="row">';
                                    insert+='<select name="na_reopen_date1" id="na_date1_c_id" onchange=declaredatepicker("#na_date1_c_id","#na_date_c_id","#na_time_c_id") style="height:30px;border-radius:5px;">';
                                    insert+='<option value="ASAP">ASAP</option>';
                                    insert+='<option value="Waiting">Waiting</option>';
                                    insert+='<option value="Date">Date</option>';
                                    insert+='<option value="Dateandtime">Date & Time</option>';
                                    insert+='<option value="Tomorrow">Tomorrow</option>';
                                    insert+='<option value="7 days">7 days Time</option>';
                                    insert+='<option value="2 Weeks Time">2 Weeks Time</option>';
                                    insert+='<option value="30 days Time">30 days Time</option>';
                                    insert+='<option value="31 days Time">31 days Time</option>';
                                    insert+='</select>';
                                    insert+='<input type="text" name="na_date" value="0000-00-00" id="na_date_c_id"  readonly style="width:180px;height:30px;border-radius:5px;margin-left:10px;cursor:pointer;display:none;">';
                                    insert+='<input type="text" name="na_time" value="00:00" id="na_time_c_id" readonly style="width:180px;height:30px;border-radius:5px;margin-left:10px;cursor:pointer;display:none;">';
                                    insert+='<span class="pull-right">Assign to&nbsp;&nbsp';
                                    insert+='<select name="na_reopen_assign" id="na_assign_c_id" style="height:30px;border-radius:5px;">';
                                    for(var i=0;i<emailid1.length;i++){
                                        if(adminemailid==emailid1[i]){
                                            insert+='<option value="'+emailid1[i]+'" selected>Me</option>';
                                        }else{
                                            insert+='<option value="'+emailid1[i]+'">'+employeename1[i]+'</option>';
                                        }
                                    }
                                    insert+='</select>';
                                    insert+='</span></div>';
                                    insert+='<span style="text-decoration:line-through;color:grey;">'+desc2+'</span><br>';
                                    insert+='<input type="button" id="savereopennextaction" class="btn btn-primary" value="Save" onclick="fun_save_first_nextaction()">';
                                    insert+='<span style="margin-left:50px;color:grey;cursor:pointer;" onclick=canceltopnextactioncompleted("'+nid+'","#desc_'+nid+'","#date_'+nid+'","#time_'+nid+'","#assign_'+nid+'","#selectoption_'+nid+'")>Cancel</span>';
                                    
                                    insert+='</div>';
                                    insert+='</div>';
                                    $("#next_action").html(insert);
                                    $("#na_reopen_assign").selectpicker();
                                }
                            });
                                $(".changenextaction").css("visibility","visible");
                        }
                    }
                </script>
                        <script>
                            function fun_save_first_nextaction(){
                                
                                var monthNames = ["", "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"];
                                
                                var cid="<?php echo $c_id;?>";
                                var desc2=$("#na_descr_c_id").val();
                                var date2=$("#na_date_c_id").val();
                                var time2=$("#na_time_c_id").val();
                                var assignid2=$("#na_assign_c_id").val();
                                var selectoption2=$("#na_date1_c_id").val();
                                var nid=$("#na_nid_c_id").val();
                                if(desc2==""){
                                    $("#add_na_sec_descr").focus();
                                    BootstrapAlert.warning({
                                      title: "Warning!",
                                      message: "Please enter the Next Action"
                                    }); 
                                    return;
                                }
                                if(((selectoption2=="Date")||(selectoption2=="Dateandtime")||(selectoption2=="Tomorrow")||(selectoption2=="7 days")||(selectoption2=="2 Weeks Time")||(selectoption2=="30 days Time")||(selectoption2=="31 days Time"))&&((date2=="")||(date2=="0000-00-00"))){
                                    $("#add_na_sec_date").focus();
                                    BootstrapAlert.warning({
                                      title: "Warning!",
                                      message: "Please Select the date"
                                    }); 
                                    return;
                                }
                                if((selectoption2=="Dateandtime")&&((time2=="")||(time2=="00:00:00")||(time2=="00:00"))){
                                    $("#add_na_sec_time").focus();
                                    BootstrapAlert.warning({
                                      title: "Warning!",
                                      message: "Please Select the Time"
                                    }); 
                                    return;
                                }
                                
                                var empid=new Array();
                                var empname=new Array();
                                empid=<?php echo json_encode($comp_full_emailid);?>;
                                empname=<?php echo json_encode($comp_full_empname);?>;
                                var adminid="<?php echo $adminemailid;?>";
                                var adminid1=assignid2.replace(".", "_vel_");
                                var adminid1=adminid1.replace("@", "_vel_");
                                var append2=adminid1+'_'+cid;
                                var assignname2="";
                                for(rt=0;rt<empid.length;rt++){
                                    if(empid[rt]==assignid2){
                                        assignname2=empname[rt];
                                    }
                                }
                                
                                assign2=assignid2;
                                                    
                                if((nid=="")||(nid=="undefined")){            
                                if((desc2!="")&&(date2!="")&&(time2!="")){
                                    swal("Next Action Created Successfully","","success");
                                    $.ajax({
                                        url:"activestream_intermediate.php",
                                        type:"post",
                                        data:{insertnextaction1:desc2, nextactiondate:date2, nextactiontime:time2, cid:cid, naassign:assignid2, selectoption:selectoption2},
                                        success:function(respond){
                                            var nid1=respond.trim()
                                            var nid_array=nid1.split("#@");
                                            nid2=nid_array[1];
                                            var monthNames = ["", "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"];
                                            var insert1="";
                                            var todate=new Date();
                                            var d=todate.getDate();
                                            var m=todate.getMonth()+1;
                                            var y=todate.getFullYear();
                                            if(m<10){
                                                m="0"+m;
                                            }
                                            var d1=y+"-"+m+"-"+d;
                                            var date3=date2;
                                            var date123=date3.split("-")
                                            var m3=date123[1];
                                            if(m3[0]=="0"){
                                                m1=m3[1];
                                            }else{
                                                m1=m3;
                                            } 
                                            var date5="<?php echo date('Y-m-d');?>";
                                            
                                        //nid2="12";
                                            if(adminid==assignid2){
                                            $(".changenextaction").css("visibility","hidden");
                                            var insert1="";
                                            
                                            insert1+='<div class="row" style="background-color:#d9eefc;border-radius:5px;padding-bottom:10px;">';
                                                insert1+='<div class="col-md-2">';
                                                    insert1+='<br>';
                                                    insert1+='<div class="checkbox pull-right" style="padding-top:10px;">';
                                                        insert1+='<label class="container1">';
                                                            insert1+='<input type="checkbox" value="" id="checkbox_id" onchange=checkitscompletedtop("#checkbox_id","'+nid2+'","#na_f_desc'+nid2+'","#na_f_date'+nid2+'","#na_f_time'+nid2+'","#na_f_assign'+nid2+'","#na_f_select'+nid2+'")>';
                                                            insert1+='<span class="checkmark" ></span>';
                                                        insert1+='</label>';
                                                    insert1+='</div>';
                                                insert1+='</div>';
                                                insert1+='<div class="col-md-10">';
                                                    insert1+='<h5>Next Action';
                                                    insert1+='<span class="pull-right" style="color:grey;cursor:pointer;" onclick=editfirstnextaction("na_f_desc'+nid2+'","na_f_date'+nid2+'","na_f_time'+nid2+'","na_f_assign'+nid2+'","na_f_select'+nid2+'","'+nid2+'")>Edit</span></h5>';
                                                    insert1+='<input type="hidden" id="na_f_desc'+nid2+'" value="'+desc2+'">';
                                                    insert1+='<input type="hidden" id="na_f_date'+nid2+'" value="'+date2+'">';
                                                    insert1+='<input type="hidden" id="na_f_time'+nid2+'" value="'+time2+'">';
                                                    insert1+='<input type="hidden" id="na_f_select'+nid2+'" value="'+selectoption2+'">';
                                                    insert1+='<input type="hidden" id="na_f_assign'+nid2+'" value="'+assignid2+'">';
                                                    insert1+='<b>'+desc2+'</b>';
                                                    insert1+='<div class="row" style="padding:10px 0px 10px 0px;">';
                                                        insert1+='<div class="col-sm-8" style="padding:0px;">';
                                                             if((selectoption2=="Queued")){
                                                                insert1+='<div class="nextaction_queued_css1">';
                                                                    insert1+='<span style="margin-left:10px;">';
                                                                        insert1+='Queued';
                                                                    insert1+='</span>';
                                                                insert1+='</div>';
                                                            }else if((selectoption2=="ASAP")){
                                                                insert1+='<div class="nextaction_asap_css1">';
                                                                    insert1+='<span style="margin-left:10px;">';
                                                                        insert1+='ASAP&nbsp;&nbsp;&nbsp;&nbsp;';
                                                                    insert1+='</span>';
                                                                insert1+='</div>';
                                                            }else if((selectoption2=="Waiting")){
                                                                insert1+='<div class="nextaction_waiting_css1">';
                                                                    insert1+='<span style="margin-left:10px;">';
                                                                        insert1+='Waiting';
                                                                    insert1+='</span>';
                                                                insert1+='</div>';
                                                            }else if(date2<date5){
                                                                insert1+='<div class="nextaction_date_css1">';
                                                                    insert1+='<span style="margin-left:10px;">';
                                                                        if (date2!="0000-00-00") {
                                                                            insert1+=monthNames[m1]; 
                                                                            insert1+="&nbsp;&nbsp;"+d; 
                                                                        }else{ 
                                                                            insert1+="Queued"; 
                                                                        }
                                                                    insert1+='</span>';
                                                                insert1+='</div>';
                                                            }else{
                                                                insert1+='<div class="nextaction_date1_css1">';
                                                                    insert1+='<span style="margin-left:10px;">';
                                                                        if (date2!="0000-00-00") {
                                                                            insert1+=monthNames[m1];
                                                                            insert1+="&nbsp;&nbsp;"+d; 
                                                                        }else{ 
                                                                            insert1+="Queued"; 
                                                                        }
                                                                    insert1+='</span>';
                                                                insert1+='</div>';
                                                            } 
                                                        insert1+='</div>';
                                                        insert1+='<div class="col-sm-4">';
                                                        insert1+='<span class="pull-right"  onclick=shownextactionqueue("#newnextactionadd")>';
                                                            insert1+='<span class="add_new_action"></span>';
                                                        insert1+='</span>';
                                                        insert1+='</div>';
                                                    insert1+='</div>';
                                                insert1+='</div>';
                                            insert1+='</div>';
                                                $("#next_action").html(insert1);
                                            }else{
                                            $(".changenextaction").css("visibility","visible");
                                                
                                            insert1+='<div class="row" style="padding:10px 0px 10px 0px;cursor:pointer;" id="nextactionqueue'+nid2+'" onmouseover=functionnextaction_show_icon("#nextaction_icon'+nid2+'") onmouseout=functionnextaction_hide_icon("#nextaction_icon'+nid2+'")>'
                                            
                                            insert1+='<div class="col-sm-2">';
                                            if(adminid==assign2){
                                                insert1+='<span class="pull-right">';
                                                insert1+='<span class="changenextaction" style="visibility:hidden; background-color:grey;color:white;border-radius:3px;font-size:10px;cursor:pointer;margin-left:-50px;padding:3px;"  onclick=exchangenextaction("'+nid2+'","#na_s_desc'+nid2+'","#na_s_date'+nid2+'","#na_s_time'+nid2+'","#na_s_select'+nid2+'","#nextactionqueue'+nid2+'","#na_s_assign'+nid2+'")><i style="transform: rotate(180deg);" class="fa fa-level-down" aria-hidden="true"></i>&nbsp;&nbsp;next</span>';
                                                insert1+='<label class="container2">';
                                                    insert1+='<input type="checkbox" value="" id="checkbox1_'+nid2+'" onchange=checkitscompleted1("#checkbox1_'+nid2+'","'+nid2+'","#nextaction_desc1_'+nid2+'","#nextaction_icon1_'+nid2+'")>';
                                                    insert1+='<span class="checkmark2" ></span>';
                                                insert1+='</label>';
                                                insert1+='</span>';
                                                            
                                            }else{
                                                insert1+='<span class="pull-right" ><img src="../../Images/drag-verticalv2.png">&nbsp;&nbsp;&nbsp;</span>';
                                            }
                                            insert1+='<input type="hidden" id="na_s_desc'+nid2+'" value="'+desc2+'">';
                                            insert1+='<input type="hidden" id="na_s_date'+nid2+'" value="'+date2+'">';
                                            insert1+='<input type="hidden" id="na_s_time'+nid2+'" value="'+time2+'">';   
                                            insert1+='<input type="hidden" id="na_s_nid'+nid2+'" value="'+nid2+'">';
                                            insert1+='<input type="hidden" id="na_s_assign'+nid2+'" value="'+assign2+'">';
                                            insert1+='<input type="hidden" id="na_s_select'+nid2+'" value="'+selectoption2+'">';
                                            insert1+='</div>';
                                            insert1+='<div class="col-sm-10">';
                                            if(date2=="0000-00-00"){
                                                insert1+='<div class="nextaction_queued_css">';
                                                 insert1+='<span style="margin-left:10px;">';
                                                     insert1+='Queued';
                                            }else if(date2<d1){
                                                insert1+='<div class="nextaction_date_css">';
                                                insert1+='<span style="margin-left:10px;">';
                                                insert1+=monthNames[m1]+'&nbsp;&nbsp;'+date123[2];
                                            }else{
                                                insert1+='<div class="nextaction_date1_css">';
                                                insert1+='<span style="margin-left:10px;">';
                                                insert1+=monthNames[m1]+'&nbsp;&nbsp;'+date123[2];
                                            }
                                            
                                             
                                                 insert1+='</span>&nbsp;&nbsp;&nbsp;&nbsp;<span id="nextaction_desc1_'+nid2+'" style="color:grey">'+desc2+'&nbsp;&nbsp;&nbsp;&nbsp;';
                                                 if((time2!="00:00")&&(time2!="00:00:00")){
                                                    insert1+=time2;
                                                 }
                                                 insert1+='</span>';
                                                 insert1+='&nbsp;&nbsp;&nbsp;&nbsp;';
                                                 insert1+='<span style="display:none;cursor:pointer;color:#666;" id="nextaction_icon'+nid2+'">';
                                                     insert1+='<span id="nextaction_icon1_'+nid2+'">';
                                                     if(adminid==assign2){
                                                         insert1+='<span style="cursor:pointer;"  onclick=functiondeletenextaction("'+nid2+'","nextactionqueue'+nid2+'")>';
                                                             insert1+='<i class="glyphicon glyphicon-trash"></i>';
                                                         insert1+='</span>&nbsp;&nbsp;';
                                                     }  
                                                         insert1+='<span style="cursor:pointer;" onclick=editsecondnextaction("na_s_desc'+nid2+'","na_s_date'+nid2+'","na_s_time'+nid2+'","na_s_nid'+nid2+'","#nextactionqueue'+nid2+'","'+cid+'","na_s_assign'+nid2+'","na_s_select'+nid2+'")>';
                                                             insert1+='<i class="glyphicon glyphicon-pencil"></i>';
                                                         insert1+='</span>';
                                                     insert1+='</span>';
                                                 insert1+='</span>';
                                             insert1+='</div>';
                                             
                                             insert1+='</div>';
                                                        
                                            
                                            insert1+='</div>';
                                            $("#"+append2).append(insert1);
                                            $("#o_"+append2).show();
                                            }
                                            $("#na_descr_c_id").val("");
                                            $("#na_date_c_id").val("0000-00-00");
                                            $("#na_time_c_id").val("00:00:00");
                                            $("#na_date_c_id").hide();
                                            $("#na_time_c_id").hide();
                                            $("#na_assign_c_id").val($("#na_assign_c_id option:first").val());
                                            $("#na_assign_c_id").selectpicker("refresh");
                                            $("#na_date1_c_id").val($("#na_date1_c_id option:first").val());
                                            
                                        }
                                    });
                        
                                }
                                }else{
                                if((desc2!="")&&(date2!="")&&(time2!="")){
                                    swal("Next Action Updated Successfully","","success");
                                    $.ajax({
                                        url:"activestream_intermediate.php",
                                        type:"post",
                                        data:{updatenextaction1:desc2,nid:nid, nextactiondate:date2, nextactiontime:time2, cid:cid, naassign:assignid2, selectoption:selectoption2},
                                        success:function(respond){
                                            nid2=nid;
                                            var monthNames = ["", "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"];
                                            var insert1="";
                                            var todate=new Date();
                                            var d=todate.getDate();
                                            var m=todate.getMonth()+1;
                                            var y=todate.getFullYear();
                                            if(m<10){
                                                m="0"+m;
                                            }
                                            var d1=y+"-"+m+"-"+d;
                                            var date3=date2;
                                            var date123=date3.split("-")
                                            var m3=date123[1];
                                            if(m3[0]=="0"){
                                                m1=m3[1];
                                            }else{
                                                m1=m3;
                                            } 
                                            
                                                date5="<?php echo date('Y-m-d');?>";
                                        //nid2="12";
                                            if(adminid==assignid2){
                                            $(".changenextaction").css("visibility","hidden");
                                                
                                            var insert1="";
                                            
                                            insert1+='<div class="row" style="background-color:#d9eefc;border-radius:5px;padding-bottom:10px;">';
                                                insert1+='<div class="col-md-2">';
                                                    insert1+='<br>';
                                                    insert1+='<div class="checkbox pull-right" style="padding-top:10px;">';
                                                        insert1+='<label class="container1">';
                                                            insert1+='<input type="checkbox" value="" id="checkbox_id" onchange=checkitscompletedtop("#checkbox_id","'+nid2+'","#na_f_desc'+nid2+'","#na_f_date'+nid2+'","#na_f_time'+nid2+'","#na_f_assign'+nid2+'","#na_f_select'+nid2+'")>';
                                                            insert1+='<span class="checkmark" ></span>';
                                                        insert1+='</label>';
                                                    insert1+='</div>';
                                                insert1+='</div>';
                                                insert1+='<div class="col-md-10">';
                                                    insert1+='<h5>Next Action';
                                                    insert1+='<span class="pull-right" style="color:grey;cursor:pointer;" onclick=editfirstnextaction("na_f_desc'+nid2+'","na_f_date'+nid2+'","na_f_time'+nid2+'","na_f_assign'+nid2+'","na_f_select'+nid2+'","'+nid2+'")>Edit</span></h5>';
                                                    insert1+='<input type="hidden" id="na_f_desc'+nid2+'" value="'+desc2+'">';
                                                    insert1+='<input type="hidden" id="na_f_date'+nid2+'" value="'+date2+'">';
                                                    insert1+='<input type="hidden" id="na_f_time'+nid2+'" value="'+time2+'">';
                                                    insert1+='<input type="hidden" id="na_f_select'+nid2+'" value="'+selectoption2+'">';
                                                    insert1+='<input type="hidden" id="na_f_assign'+nid2+'" value="'+assignid2+'">';
                                                    insert1+='<b>'+desc2+'</b>';
                                                    insert1+='<div class="row" style="padding:10px 0px 10px 0px;">';
                                                        insert1+='<div class="col-sm-8" style="padding:0px;">';
                                                             if((selectoption2=="Queued")){
                                                                insert1+='<div class="nextaction_queued_css1">';
                                                                    insert1+='<span style="margin-left:10px;">';
                                                                        insert1+='Queued';
                                                                    insert1+='</span>';
                                                                insert1+='</div>';
                                                            }else if((selectoption2=="ASAP")){
                                                                insert1+='<div class="nextaction_asap_css1">';
                                                                    insert1+='<span style="margin-left:10px;">';
                                                                        insert1+='ASAP&nbsp;&nbsp;&nbsp;&nbsp;';
                                                                    insert1+='</span>';
                                                                insert1+='</div>';
                                                            }else if((selectoption2=="Waiting")){
                                                                insert1+='<div class="nextaction_waiting_css1">';
                                                                    insert1+='<span style="margin-left:10px;">';
                                                                        insert1+='Waiting';
                                                                    insert1+='</span>';
                                                                insert1+='</div>';
                                                            }else if(date2<date5){
                                                                insert1+='<div class="nextaction_date_css1">';
                                                                    insert1+='<span style="margin-left:10px;">';
                                                                        if (date2!="0000-00-00") {
                                                                            insert1+=monthNames[m1]; 
                                                                            insert1+="&nbsp;&nbsp;"+d; 
                                                                        }else{ 
                                                                            insert1+="Queued"; 
                                                                        }
                                                                    insert1+='</span>';
                                                                insert1+='</div>';
                                                            }else{
                                                                insert1+='<div class="nextaction_date1_css1">';
                                                                    insert1+='<span style="margin-left:10px;">';
                                                                        if (date2!="0000-00-00") {
                                                                            insert1+=monthNames[m1];
                                                                            insert1+="&nbsp;&nbsp;"+d; 
                                                                        }else{ 
                                                                            insert1+="Queued"; 
                                                                        }
                                                                    insert1+='</span>';
                                                                insert1+='</div>';
                                                            } 
                                                        insert1+='</div>';
                                                        insert1+='<div class="col-sm-4">';
                                                        insert1+='<span class="pull-right"  onclick=shownextactionqueue("#newnextactionadd")>';
                                                            insert1+='<span class="add_new_action"></span>';
                                                        insert1+='</span>';
                                                        insert1+='</div>';
                                                    insert1+='</div>';
                                                insert1+='</div>';
                                            insert1+='</div>';
                                                $("#next_action").html(insert1);
                                            }else{
                                            $(".changenextaction").css("visibility","visible");
                                                
                                            insert1+='<div class="row" style="padding:10px 0px 10px 0px;cursor:pointer;" id="nextactionqueue'+nid2+'" onmouseover=functionnextaction_show_icon("#nextaction_icon'+nid2+'") onmouseout=functionnextaction_hide_icon("#nextaction_icon'+nid2+'")>'
                                            
                                            insert1+='<div class="col-sm-2">';
                                            if(adminid==assign2){
                                                insert1+='<span class="pull-right">';
                                                insert1+='<span class="changenextaction" style="visibility:hidden; background-color:grey;color:white;border-radius:3px;font-size:10px;cursor:pointer;margin-left:-50px;padding:3px;"  onclick=exchangenextaction("'+nid2+'","#na_s_desc'+nid2+'","#na_s_date'+nid2+'","#na_s_time'+nid2+'","#na_s_select'+nid2+'","#nextactionqueue'+nid2+'","#na_s_assign'+nid2+'")><i style="transform: rotate(180deg);" class="fa fa-level-down" aria-hidden="true"></i>&nbsp;&nbsp;next</span>';
                                                insert1+='<label class="container2">';
                                                    insert1+='<input type="checkbox" value="" id="checkbox1_'+nid2+'" onchange=checkitscompleted1("#checkbox1_'+nid2+'","'+nid2+'","#nextaction_desc1_'+nid2+'","#nextaction_icon1_'+nid2+'")>';
                                                    insert1+='<span class="checkmark2" ></span>';
                                                insert1+='</label>';
                                                insert1+='</span>';
                                                            
                                            }else{
                                                insert1+='<span class="pull-right" ><img src="../../Images/drag-verticalv2.png">&nbsp;&nbsp;&nbsp;</span>';
                                            }
                                            insert1+='<input type="hidden" id="na_s_desc'+nid2+'" value="'+desc2+'">';
                                            insert1+='<input type="hidden" id="na_s_date'+nid2+'" value="'+date2+'">';
                                            insert1+='<input type="hidden" id="na_s_time'+nid2+'" value="'+time2+'">';   
                                            insert1+='<input type="hidden" id="na_s_nid'+nid2+'" value="'+nid2+'">';
                                            insert1+='<input type="hidden" id="na_s_assign'+nid2+'" value="'+assign2+'">';
                                            insert1+='<input type="hidden" id="na_s_select'+nid2+'" value="'+selectoption2+'">';
                                            insert1+='</div>';
                                            insert1+='<div class="col-sm-10">';
                                            if(date2=="0000-00-00"){
                                                insert1+='<div class="nextaction_queued_css">';
                                                 insert1+='<span style="margin-left:10px;">';
                                                     insert1+='Queued';
                                            }else if(date2<d1){
                                                insert1+='<div class="nextaction_date_css">';
                                                insert1+='<span style="margin-left:10px;">';
                                                insert1+=monthNames[m1]+'&nbsp;&nbsp;'+date123[2];
                                            }else{
                                                insert1+='<div class="nextaction_date1_css">';
                                                insert1+='<span style="margin-left:10px;">';
                                                insert1+=monthNames[m1]+'&nbsp;&nbsp;'+date123[2];
                                            }
                                            
                                             
                                                 insert1+='</span>&nbsp;&nbsp;&nbsp;&nbsp;<span id="nextaction_desc1_'+nid2+'" style="color:grey">'+desc2+'&nbsp;&nbsp;&nbsp;&nbsp;';
                                                 if((time2!="00:00")&&(time2!="00:00:00")){
                                                    insert1+=time2;
                                                 }
                                                 insert1+='</span>';
                                                 insert1+='&nbsp;&nbsp;&nbsp;&nbsp;';
                                                 insert1+='<span style="display:none;cursor:pointer;color:#666;" id="nextaction_icon'+nid2+'">';
                                                     insert1+='<span id="nextaction_icon1_'+nid2+'">';
                                                     if(adminid==assign2){
                                                         insert1+='<span style="cursor:pointer;"  onclick=functiondeletenextaction("'+nid2+'","nextactionqueue'+nid2+'")>';
                                                             insert1+='<i class="glyphicon glyphicon-trash"></i>';
                                                         insert1+='</span>&nbsp;&nbsp;';
                                                     }  
                                                         insert1+='<span style="cursor:pointer;" onclick=editsecondnextaction("na_s_desc'+nid2+'","na_s_date'+nid2+'","na_s_time'+nid2+'","na_s_nid'+nid2+'","#nextactionqueue'+nid2+'","'+cid+'","na_s_assign'+nid2+'","na_s_select'+nid2+'")>';
                                                             insert1+='<i class="glyphicon glyphicon-pencil"></i>';
                                                         insert1+='</span>';
                                                     insert1+='</span>';
                                                 insert1+='</span>';
                                             insert1+='</div>';
                                             
                                             insert1+='</div>';
                                                        
                                            
                                            insert1+='</div>';
                                            $("#"+append2).append(insert1);
                                            $("#o_"+append2).show();
                                            }
                                            $("#na_descr_c_id").val("");
                                            $("#na_date_c_id").val("0000-00-00");
                                            $("#na_time_c_id").val("00:00:00");
                                            $("#na_date_c_id").hide();
                                            $("#na_time_c_id").hide();
                                            $("#na_assign_c_id").val($("#na_assign_c_id option:first").val());
                                            $("#na_assign_c_id").selectpicker("refresh");
                                            $("#na_date1_c_id").val($("#na_date1_c_id option:first").val());
                                            
                                        }
                                    });
                        
                                }
                                }
                            }
                        </script>
                        
<script>
    function editsecondnextaction(desc, date1, time1, nid, show, cid, assign, selectoption){
        var empid=new Array();
        var empname=new Array();
        empid=<?php echo json_encode($comp_full_emailid);?>;
        empname=<?php echo json_encode($comp_full_empname);?>;
        var adminid="<?php echo $adminemailid;?>";
        
        var desc2=$("#"+desc).val();
        var date2=$("#"+date1).val();
        var time2=$("#"+time1).val();
        var nid2=$("#"+nid).val();
        var assign2=$("#"+assign).val();
        var selectoption2=$("#"+selectoption).val();
        
        var insert="";
        insert+='<div class="col-md-2">';
        insert+='<span class="pull-right" style="margin-top:50px;"><img src="../../Images/drag-verticalv2.png">&nbsp;&nbsp;&nbsp;</span>';
        insert+='<input type="hidden" id="csed1" value="'+desc2+'">';
        insert+='<input type="hidden" id="etad1" value="'+date2+'">';
        insert+='<input type="hidden" id="emit1" value="'+time2+'">';
        insert+='<input type="hidden" id="dic1" value="'+cid+'">';
        insert+='<input type="hidden" id="wohs1" value="'+show+'">';
        insert+='<input type="hidden" id="din1" value="'+nid2+'">';
        insert+='<input type="hidden" id="ngissa1" value="'+assign2+'">';
        insert+='<input type="hidden" id="selectoption1" value="'+selectoption2+'">';
        insert+='</div>';
		insert+='<div class="col-md-10">';
		insert+='<h5><b>Next Action</b>&nbsp;&nbsp;</h5>';

        insert+='<input type="hidden" id="na_id_s_e" value="'+nid2+'">';
		insert+='<textarea class="form-control" id="na_descr_s_e'+nid2+'" rows="5" onchange=functionvisiblenextaction("#na_descr_s_e'+nid2+'","#updatenextaction_s_e","#na_date1_e'+nid2+'")>'+desc2+'</textarea><br>';
		insert+='<select name="na_date1" id="na_date1_e'+nid2+'" style="height:30px;border-radius:5px;" onchange=declaredatepicker("#na_date1_e'+nid2+'","#na_date_s_e'+nid2+'","#na_time_s_e'+nid2+'")>';
		if(selectoption2=="Queued"){
		    insert+='<option value="Queued" selected>Queued</option>';
		}else{
		    insert+='<option value="Queued">Queued</option>';
		}
		if(selectoption2=="ASAP"){
		    insert+='<option value="ASAP" selected>ASAP</option>';
		}
		if(selectoption2=="Waiting"){
		    insert+='<option value="Waiting" selected>Waiting for</option>';
		}
		if(selectoption2=="Date"){
		    insert+='<option value="Date" selected>Date</option>';
		}else{
		    insert+='<option value="Date" >Date</option>';
		}
		if(selectoption2=="Dateandtime"){
		    insert+='<option value="Dateandtime" selected>Date & Time</option>';
		}else{
		    insert+='<option value="Dateandtime" >Date & Time</option>';
		}
		insert+='<option value="Tomorrow">Tomorrow</option>';
		insert+='<option value="7 days">7 days Time</option>';
		insert+='<option value="2 Weeks Time">2 Weeks Time</option>';
		insert+='<option value="30 days Time">30 days Time</option>';
		insert+='<option value="31 days Time">31 days Time</option>';
		insert+='</select>';
		if(date2!="0000-00-00"){
        insert+='<input type="text" name="na_date" value="'+date2+'" id="na_date_s_e'+nid2+'" readonly style="width:180px;height:30px;border-radius:5px;margin-left:10px;cursor:pointer;">';
        }else{
		insert+='<input type="text" name="na_date" value="'+date2+'" id="na_date_s_e'+nid2+'" readonly style="width:180px;height:30px;border-radius:5px;margin-left:10px;cursor:pointer;display:none;">';
		}
		if((time2!="00:00:00")&&(time2!="00:00")){
		insert+='<input type="text" name="na_time" value="'+time2+'" id="na_time_s_e'+nid2+'" readonly style="width:180px;height:30px;border-radius:5px;margin-left:10px;cursor:pointer;">';
		}else{
		insert+='<input type="text" name="na_time" value="'+time2+'" id="na_time_s_e'+nid2+'" readonly style="width:180px;height:30px;border-radius:5px;margin-left:10px;cursor:pointer;display:none;">';
		}
		insert+='<span class="pull-right">';
		insert+='<select id="na_assign_id'+nid2+'" class="selectpicker_edit_nextaction">';
        for(h=0;h<empid.length;h++){
        empid1=empid[h];
        if(empid1==adminid){
            employeename11="Me";
        }else{
            employeename11=empname[h];
        }
        if(empid1==assign2){
        insert+='<option value="'+empid1+'" selected>'+employeename11+'</option>';
        }else{
        
        insert+='<option value="'+empid1+'">'+employeename11+'</option>';
        }
        }
		insert+='</select>';
		insert+='</span>';
		insert+='<br><br>';
		insert+='<input type="button" id="updatenextaction_s_e" class="btn btn-primary" value="Update" onclick=funnextactionupdate1("'+nid2+'","#na_descr_s_e'+nid2+'","#na_date_s_e'+nid2+'","#na_time_s_e'+nid2+'","#na_assign_id'+nid2+'","#na_date1_e'+nid2+'","'+show+'","#ngissa1") >';
		insert+='<span style="margin-left:50px;color:grey;cursor:pointer;" onclick=cancelsecondnextaction("#csed1","#etad1","#emit1","#dic1","#wohs1","#din1","#ngissa1","#selectoption1")>Cancel</span>';

		insert+='<br></div>';
        
        $(show).empty();
        $(show).append(insert);
        callpicker("#na_date_s_e"+nid2, "#na_time_s_e"+nid2);
        $(".selectpicker_edit_nextaction").selectpicker();
    }
</script>     
<script>
    function funnextactionupdate1(nid2, desc, date1, time1, assign, selectoption, showid,assignid1){
        var desc2=$(desc).val();
        var date2=$(date1).val();
        var time2=$(time1).val();
        var assign2=$(assign).val();
        var assign3=$(assignid1).val();
        var selectoption2=$(selectoption).val();
        assignid2=assign2;
        var monthNames = ["", "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"];

        var cid="<?php echo $c_id;?>";
        
        if(desc2==""){
            $(desc).focus();
            BootstrapAlert.warning({
              title: "Warning!",
              message: "Please enter the Next Action"
            }); 
            return;
        }
        if(((selectoption2=="Date")||(selectoption2=="Dateandtime")||(selectoption2=="Tomorrow")||(selectoption2=="7 days")||(selectoption2=="2 Weeks Time")||(selectoption2=="30 days Time")||(selectoption2=="31 days Time"))&&((date2=="")||(date2=="0000-00-00"))){
            $(date1).focus();
            BootstrapAlert.warning({
              title: "Warning!",
              message: "Please Select the date"
            }); 
            return;
        }
        if((selectoption2=="Dateandtime")&&((time2=="")||(time2=="00:00:00")||(time2=="00:00"))){
            $("#time1").focus();
            BootstrapAlert.warning({
              title: "Warning!",
              message: "Please Select the Time"
            }); 
            return;
        }
        
        var empid=new Array();
        var empname=new Array();
        empid=<?php echo json_encode($comp_full_emailid);?>;
        empname=<?php echo json_encode($comp_full_empname);?>;
        var adminid="<?php echo $adminemailid;?>";
        var adminid1=assignid2.replace(".", "_vel_");
        var adminid1=adminid1.replace("@", "_vel_");
        var append2=adminid1+'_'+cid;
        var assignname2="";
        for(rt=0;rt<empid.length;rt++){
            if(empid[rt]==assignid2){
                assignname2=empname[rt];
            }
        }
        if((desc2!="")&&(date2!="")&&(time2!="")){
            swal("Next Action Update Successfully","","success");
            $.ajax({
                url:"activestream_intermediate.php",
                type:"post",
                data:{updatenextaction:desc2, nextactiondate:date2, nextactiontime:time2, cid:cid, nid:nid2, naassign:assignid2, selectoption:selectoption2},
                success:function(respond){
                    var monthNames = ["", "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"];
                    var insert1="";
                    var todate=new Date();
                    var d=todate.getDate();
                    var m=todate.getMonth()+1;
                    var y=todate.getFullYear();
                    if(m<10){
                        m="0"+m;
                    }
                    var d1=y+"-"+m+"-"+d;
                    var date3=date2;
                    var date123=date3.split("-")
                    var m3=date123[1];
                    if(m3[0]=="0"){
                        m1=m3[1];
                    }else{
                        m1=m3;
                    } 
                    if(assign3!=assignid2){
                    insert1+='<div class="row" style="padding:0px 0px 5px 0px;cursor:pointer;" id="nextactionqueue'+nid2+'" onmouseover=functionnextaction_show_icon("#nextaction_icon'+nid2+'") onmouseout=functionnextaction_hide_icon("#nextaction_icon'+nid2+'")>'
                    }
                    insert1+='<div class="col-sm-2">';
                    if(adminid==assign2){
                        insert1+='<span class="pull-right">';
                        insert1+='<span class="changenextaction" style="visibility:hidden; background-color:grey;color:white;border-radius:3px;font-size:10px;cursor:pointer;margin-left:-50px;padding:3px;"  onclick=exchangenextaction("'+nid2+'","#na_s_desc'+nid2+'","#na_s_date'+nid2+'","#na_s_time'+nid2+'","#na_s_select'+nid2+'","#nextactionqueue'+nid2+'","#na_s_assign'+nid2+'")><i style="transform: rotate(180deg);" class="fa fa-level-down" aria-hidden="true"></i>&nbsp;&nbsp;next</span>';
                        insert1+='<label class="container2">';
                            insert1+='<input type="checkbox" value="" id="checkbox1_'+nid2+'" onchange=checkitscompleted1("#checkbox1_'+nid2+'","'+nid2+'","#nextaction_desc1_'+nid2+'","#nextaction_icon1_'+nid2+'")>';
                            insert1+='<span class="checkmark2" ></span>';
                        insert1+='</label>';
                        insert1+='</span>';
                                    
                    }else{
                        insert1+='<span class="pull-right"><img src="../../Images/drag-verticalv2.png">&nbsp;&nbsp;&nbsp;</span>';
                    }
                    insert1+='<input type="hidden" id="na_s_desc'+nid2+'" value="'+desc2+'">';
                    insert1+='<input type="hidden" id="na_s_date'+nid2+'" value="'+date2+'">';
                    insert1+='<input type="hidden" id="na_s_time'+nid2+'" value="'+time2+'">';   
                    insert1+='<input type="hidden" id="na_s_nid'+nid2+'" value="'+nid2+'">';
                    insert1+='<input type="hidden" id="na_s_assign'+nid2+'" value="'+assign2+'">';
                    insert1+='<input type="hidden" id="na_s_select'+nid2+'" value="'+selectoption2+'">';
                    insert1+='</div>';
                    insert1+='<div class="col-sm-10">';
                    if(date2=="0000-00-00"){
                        insert1+='<div class="nextaction_queued_css">';
                         insert1+='<span style="margin-left:10px;">';
                             insert1+='Queued';
                    }else if(date2<d1){
                        insert1+='<div class="nextaction_date_css">';
                        insert1+='<span style="margin-left:10px;">';
                        insert1+=monthNames[m1]+'&nbsp;&nbsp;'+date123[2];
                    }else{
                        insert1+='<div class="nextaction_date1_css">';
                        insert1+='<span style="margin-left:10px;">';
                        insert1+=monthNames[m1]+'&nbsp;&nbsp;'+date123[2];
                    }
                    
                     
                         insert1+='</span>&nbsp;&nbsp;&nbsp;&nbsp;<span id="nextaction_desc1_'+nid2+'" style="color:grey">'+desc2+'&nbsp;&nbsp;&nbsp;&nbsp;';
                         if((time2!="00:00")&&(time2!="00:00:00")){
                            insert1+=time2;
                         }
                         insert1+='</span>';
                         insert1+='&nbsp;&nbsp;&nbsp;&nbsp;';
                         insert1+='<span style="display:none;cursor:pointer;color:#666;" id="nextaction_icon'+nid2+'">';
                             insert1+='<span id="nextaction_icon1_'+nid2+'">';
                             if(adminid==assign2){
                                 insert1+='<span style="cursor:pointer;"  onclick=functiondeletenextaction("'+nid2+'","nextactionqueue'+nid2+'")>';
                                     insert1+='<i class="glyphicon glyphicon-trash"></i>';
                                 insert1+='</span>&nbsp;&nbsp;';
                             }  
                                 insert1+='<span style="cursor:pointer;" onclick=editsecondnextaction("na_s_desc'+nid2+'","na_s_date'+nid2+'","na_s_time'+nid2+'","na_s_nid'+nid2+'","#nextactionqueue'+nid2+'","'+cid+'","na_s_assign'+nid2+'","na_s_select'+nid2+'")>';
                                     insert1+='<i class="glyphicon glyphicon-pencil"></i>';
                                 insert1+='</span>';
                             insert1+='</span>';
                         insert1+='</span>';
                     insert1+='</div>';
                     
                     insert1+='</div>';
                                
                    if(assign3==assignid2){
                        $(showid).html(insert1);
                    }else{
                        $(showid).html("");
                        $(showid).remove();
                        insert1+='</div>';
                        $("#"+append2).append(insert1);
                        $("#o_"+append2).show();
                    }
                }
            });

        }
                            
    }
</script>
<script>
    function cancelsecondnextaction(desc, date1, time1, cid, append1, nid, assign, selectoption){
        var empid=new Array();
        var empname=new Array();
        empid=<?php echo json_encode($emailid1);?>;
        empname=<?php echo json_encode($employeename1);?>;
        var adminid="<?php echo $adminemailid;?>";
        var desc2=$(desc).val();
        var date2=$(date1).val();
        var time2=$(time1).val();
        var nid2=$(nid).val();
        var assign2=$(assign).val();
        var selectoption2=$(selectoption).val();
        var append2=$(append1).val();
        
        $(append2).empty();
        var monthNames = ["", "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"];
        var insert1="";
        var todate=new Date();
        var d=todate.getDate();
        var m=todate.getMonth()+1;
        var y=todate.getFullYear();
        if(m<10){
            m="0"+m;
        }
        var d1=y+"-"+m+"-"+d;
        var date3=date2;
        var date123=date3.split("-")
        var m3=date123[1];
        if(m3[0]=="0"){
            m1=m3[1];
        }else{
            m1=m3;
        }
        insert1+='<div class="col-sm-2">';
        if(adminid==assign2){
            insert1+='<span  class="pull-right" >';
            insert1+='<span class="changenextaction" style="visibility:hidden; background-color:grey;color:white;border-radius:3px;font-size:10px;cursor:pointer;margin-left:-50px;padding:3px;"  onclick=exchangenextaction("'+nid2+'","#na_s_desc'+nid2+'","#na_s_date'+nid2+'","#na_s_time'+nid2+'","#na_s_select'+nid2+'","#nextactionqueue'+nid2+'","#na_s_assign'+nid2+'")><i style="transform: rotate(180deg)" class="fa fa-level-down" aria-hidden="true"></i>&nbsp;&nbsp;next</span>';
            insert1+='<label class="container2">';
                insert1+='<input type="checkbox" value="" id="checkbox1_'+nid2+'" onchange=checkitscompleted1("#checkbox1_'+nid2+'","'+nid2+'","#nextaction_desc1_'+nid2+'","#nextaction_icon1_'+nid2+'")>';
                insert1+='<span class="checkmark2" ></span>';
            insert1+='</label>';
            insert1+='</span>';
                        
        }else{
            insert1+='<span class="pull-right"><img src="../../Images/drag-verticalv2.png">&nbsp;&nbsp;&nbsp;</span>';
        }
        insert1+='<input type="hidden" id="na_s_desc'+nid2+'" value="'+desc2+'">';
        insert1+='<input type="hidden" id="na_s_date'+nid2+'" value="'+date2+'">';
        insert1+='<input type="hidden" id="na_s_time'+nid2+'" value="'+time2+'">';   
        insert1+='<input type="hidden" id="na_s_nid'+nid2+'" value="'+nid2+'">';
        insert1+='<input type="hidden" id="na_s_assign'+nid2+'" value="'+assign2+'">';
        insert1+='<input type="hidden" id="na_s_select'+nid2+'" value="'+selectoption2+'">';
        insert1+='</div>';
        insert1+='<div class="col-sm-10">';
        if(selectoption2=="Queued"){
            insert1+='<div class="nextaction_queued_css">';
             insert1+='<span style="margin-left:10px;">';
                 insert1+='Queued';
        }else if(selectoption2=="ASAP"){
            insert1+='<div class="nextaction_date_css">';
             insert1+='<span style="margin-left:10px;">';
                 insert1+='ASAP&nbsp;&nbsp;&nbsp;&nbsp;';
        }else if(selectoption2=="Waiting"){
            insert1+='<div class="nextaction_date_css">';
             insert1+='<span style="margin-left:10px;">';
                 insert1+='Waiting';
        }else if(date2<d1){
            insert1+='<div class="nextaction_date_css">';
                insert1+='<span style="margin-left:10px;">';
                    insert1+=monthNames[m1]+'&nbsp;&nbsp;'+date123[2];
        }else{
            insert1+='<div class="nextaction_date1_css">';
             insert1+='<span style="margin-left:10px;">';
                 insert1+=monthNames[m1]+'&nbsp;&nbsp;'+date123[2];
        }
        
         
             insert1+='</span>&nbsp;&nbsp;&nbsp;&nbsp;<span id="nextaction_desc1_'+nid2+'" style="color:grey">'+desc2+'&nbsp;&nbsp;&nbsp;&nbsp;';
             if((time2!="00:00")&&(time2!="00:00:00")){
                insert1+=time2;
             }
             insert1+='</span>';
             insert1+='&nbsp;&nbsp;&nbsp;&nbsp;';
             insert1+='<span style="display:none;cursor:pointer;color:#666;" id="nextaction_icon'+nid2+'">';
                 insert1+='<span id="nextaction_icon1_'+nid2+'">';
                 if(adminid==assign2){
                     insert1+='<span style="cursor:pointer;"  onclick=functiondeletenextaction("'+nid2+'","'+append2+'")>';
                         insert1+='<i class="glyphicon glyphicon-trash"></i>';
                     insert1+='</span>&nbsp;&nbsp;';
                 }  
                     insert1+='<span style="cursor:pointer;" onclick=editsecondnextaction("na_s_desc'+nid2+'","na_s_date'+nid2+'","na_s_time'+nid2+'","na_s_nid'+nid2+'","#nextactionqueue'+nid2+'","'+cid+'","na_s_assign'+nid2+'","na_s_select'+nid2+'")>';
                         insert1+='<i class="glyphicon glyphicon-pencil"></i>';
                     insert1+='</span>';
                 insert1+='</span>';
             insert1+='</span>';
         insert1+='</div>';
                    
        
        insert1+='</div>';
        
        $(append2).html(insert1);
                
    }
</script>     
<script>
    function callpicker(id, id1){
        $(id).datepicker({ 
            format : "yyyy-mm-dd",
            autoclose: true, 
            todayHighlight: true
        });
        $(id1).clockpicker({
            placement: 'top',
            align: 'left',
            autoclose: true
        });
	}
</script>

                    <script>
                        function checkitscompleted1(id1, nextid, desc, editicon){
                            if($(id1).is(':checked')){
                                status="completed";
                                $.ajax({
                                    url:"activestream_intermediate.php",
                                    type:"post",
                                    data:{completednextaction:nextid, status:status},
                                    success:function(respond){
                                        $(desc).css("text-decoration","line-through");
                                        $(desc).css("color","grey");
                                        $(editicon).hide();
                                    }
                                });
                            }else{
                                status="pending";
                                $.ajax({
                                    url:"activestream_intermediate.php",
                                    type:"post",
                                    data:{completednextaction:nextid, status:status},
                                    success:function(respond){
                                        //swal("Next Action InCompleted Successfully","","success");
                                        $(desc).css("text-decoration","none");
                                        $(editicon).show();
                                    }
                                });
                            }
                        }
                    </script>  
                    
<script>
    function declaredatepicker(dateselect, date, time1) {
        
        var value1=$(dateselect).val();
        $(date).datepicker({ 
            format : "yyyy-mm-dd",
            autoclose: true, 
            todayHighlight: true
        }).datepicker('update', new Date());
        
        $(time1).clockpicker({
            placement: 'top',
            align: 'left',
            autoclose: true,
            'default': 'now'
        });
        if(value1=="Queued"){
            $(date).val("0000-00-00");
            $(time1).val("00:00");
            $(date).hide();
            $(time1).hide();
        }else if(value1=="Date"){
            var date1 = new Date()
            date1.setDate(date1.getDate());
            var d=date1.getDate();
            var m=date1.getMonth()+1;
            var y=date1.getFullYear();
            if(d<10) { d='0'+d } if(m<10) { m='0'+m }
            var date2=y+"-"+m+"-"+d;
            $(date).val(date2);
            $(time1).val("00:00");
            $(date).show();
            $(time1).hide();
        }else if(value1=="Dateandtime"){
            var date1 = new Date()
            date1.setDate(date1.getDate());
            var d=date1.getDate();
            var m=date1.getMonth()+1;
            var y=date1.getFullYear();
            var h=date1.getHours();
            var i=date1.getMinutes();
            if(i<10){
                i="0"+i;
            }
            if(h<10){
                h="0"+h;
            }
            var t=h+":"+i;
            if(d<10) { d='0'+d } if(m<10) { m='0'+m }
            var date2=y+"-"+m+"-"+d;
            $(date).val(date2);
            $(time1).val(t);
            $(date).show();
            $(time1).show();
        }else if(value1=="Tomorrow"){
            var date1 = new Date()
            date1.setDate(date1.getDate() + 1);
            var d=date1.getDate();
            var m=date1.getMonth()+1;
            var y=date1.getFullYear();
            if(d<10) { d='0'+d } if(m<10) { m='0'+m }
            var date2=y+"-"+m+"-"+d;
            $(date).val(date2);
            $(time1).val("00:00");
            $(date).show();
            $(time1).hide();
        }else if(value1=="7 days"){
            var date1 = new Date()
            date1.setDate(date1.getDate() + 7);
            var d=date1.getDate();
            var m=date1.getMonth()+1;
            var y=date1.getFullYear();
            if(d<10) { d='0'+d } if(m<10) { m='0'+m }
            var date2=y+"-"+m+"-"+d;
            $(date).val(date2);
            $(time1).val("00:00");
            $(date).show();
            $(time1).hide();
        }else if(value1=="2 Weeks Time"){
            var date1 = new Date()
            date1.setDate(date1.getDate() + 14);
            var d=date1.getDate();
            var m=date1.getMonth()+1;
            var y=date1.getFullYear();
            if(d<10) { d='0'+d } if(m<10) { m='0'+m }
            var date2=y+"-"+m+"-"+d;
            $(date).val(date2);
            $(time1).val("00:00");
            $(date).show();
            $(time1).hide();
        }else if(value1=="30 days Time"){
            var date1 = new Date()
            date1.setDate(date1.getDate() + 30);
            var d=date1.getDate();
            var m=date1.getMonth()+1;
            var y=date1.getFullYear();
            if(d<10) { d='0'+d } if(m<10) { m='0'+m }
            var date2=y+"-"+m+"-"+d;
            $(date).val(date2);
            $(time1).val("00:00");
            $(date).show();
            $(time1).hide();
        }else if(value1=="31 days Time"){
            var date1 = new Date()
            date1.setDate(date1.getDate() + 31);
            var d=date1.getDate();
            var m=date1.getMonth()+1;
            var y=date1.getFullYear();
            if(d<10) { d='0'+d } if(m<10) { m='0'+m }
            var date2=y+"-"+m+"-"+d;
            $(date).val(date2);
            $(time1).val("00:00");
            $(date).show();
            $(time1).hide();
        }else if(value1=="ASAP"){
            $(date).val("0000-00-00");
            $(time1).val("00:00");
            $(date).hide();
            $(time1).hide();
        }else if(value1=="Waiting"){
            $(date).val("0000-00-00");
            $(time1).val("00:00");
            $(date).hide();
            $(time1).hide();
        }
            
    }

</script>               
<script>
    function functionnextaction_show_icon(id){
        $(id).show();
    }
    function functionnextaction_hide_icon(id){
        $(id).hide();
    }
</script>

<script>
    function functiondeletenextaction(id, hideid){
       
        swal("Next Action Deleted Successfully","","success");
        $.ajax({
           url:"activestream_intermediate.php",
           type:"post",
           data:{deletenextaction:id},
           success:function(respond){
                /*BootstrapAlert.success({
                  title: "Success!",
                  message: "Next Action Deleted Successfully"
                });*/ 
               $(hideid).hide();
           }
        });
    }
</script>

        <script>
            function editfirstnextaction(desc,date1, time1, assign, selectoption, nid){
                
                var empid=new Array();
                var empname=new Array();
                empid=<?php echo json_encode($comp_full_emailid);?>;
                empname=<?php echo json_encode($comp_full_empname);?>;
                var adminid="<?php echo $adminemailid;?>";
                
                var desc2=$("#"+desc).val();
                var date2=$("#"+date1).val();
                var time2=$("#"+time1).val();
                var nid2=nid;
                var assign2=$("#"+assign).val();
                var selectoption2=$("#"+selectoption).val();
                
                var insert="";
                insert+='<div class="row">';
                insert+='<div class="col-md-2">';
                insert+='<span class="pull-right" style="margin-top:50px;"><img src="../../Images/drag-verticalv2.png">&nbsp;&nbsp;&nbsp;</span>';
                insert+='<input type="hidden" id="csed1" value="'+desc2+'">';
                insert+='<input type="hidden" id="etad1" value="'+date2+'">';
                insert+='<input type="hidden" id="emit1" value="'+time2+'">';
                insert+='<input type="hidden" id="ngissa1" value="'+assign2+'">';
                insert+='<input type="hidden" id="noitpotceles1" value="'+selectoption2+'">';
                insert+='</div>';
        		insert+='<div class="col-md-10">';
        		insert+='<h5><b>Next Action</b>';
                
                insert+='<input type="hidden" id="na_id_f_e'+nid2+'" value="'+nid2+'">';
        		insert+='<textarea class="form-control" id="na_descr_f_e'+nid2+'" rows="5" onchange=functionvisiblenextaction("#na_descr_s_e'+nid2+'","#updatenextaction_s_e","#na_date1_e'+nid2+'")>'+desc2+'</textarea><br>';
        		insert+='<select name="na_date1" id="na_date1_f_e'+nid2+'" style="height:30px;border-radius:5px;" onchange=declaredatepicker("#na_date1_f_e'+nid2+'","#na_date_f_e'+nid2+'","#na_time_f_e'+nid2+'")>';
        		if(selectoption2=="ASAP"){
        		    insert+='<option value="ASAP" selected>ASAP</option>';
        		}else{
        		    insert+='<option value="ASAP" >ASAP</option>';
        		}
        		if(selectoption2=="Waiting"){
        		    insert+='<option value="Waiting" selected>Waiting for</option>';
        		}else{
        		    insert+='<option value="Waiting" >Waiting for</option>';
        		}
        		if(selectoption2=="Date"){
        		    insert+='<option value="Date" selected>Date</option>';
        		}else{
        		    insert+='<option value="Date" >Date</option>';
        		}
        		if(selectoption2=="Dateandtime"){
        		    insert+='<option value="Dateandtime" selected>Date & Time</option>';
        		}else{
        		    insert+='<option value="Dateandtime" >Date & Time</option>';
        		}
        		insert+='<option value="Tomorrow">Tomorrow</option>';
        		insert+='<option value="7 days">7 days Time</option>';
        		insert+='<option value="2 Weeks Time">2 Weeks Time</option>';
        		insert+='<option value="30 days Time">30 days Time</option>';
        		insert+='<option value="31 days Time">31 days Time</option>';
        		insert+='</select>';
        		if(date2!="0000-00-00"){
                insert+='<input type="text" name="na_date" value="'+date2+'" id="na_date_f_e'+nid2+'" readonly style="width:180px;height:30px;border-radius:5px;margin-left:10px;cursor:pointer;">';
                }else{
        		insert+='<input type="text" name="na_date" value="'+date2+'" id="na_date_f_e'+nid2+'" readonly style="width:180px;height:30px;border-radius:5px;margin-left:10px;cursor:pointer;display:none;">';
        		}
        		if((time2!="00:00:00")&&(time2!="00:00")){
        		insert+='<input type="text" name="na_time" value="'+time2+'" id="na_time_f_e'+nid2+'" readonly style="width:180px;height:30px;border-radius:5px;margin-left:10px;cursor:pointer;">';
        		}else{
        		insert+='<input type="text" name="na_time" value="'+time2+'" id="na_time_f_e'+nid2+'" readonly style="width:180px;height:30px;border-radius:5px;margin-left:10px;cursor:pointer;display:none;">';
        		}
        		
        		insert+='<span class="pull-right">';
        		insert+='<select id="na_assign_id'+nid2+'" class="selectpicker_edit_nextaction">';
                for(h=0;h<empid.length;h++){
                empid1=empid[h];
                if(empid1==assign2){
                employeename11="Me";
                insert+='<option value="'+empid1+'" selected>'+employeename11+'</option>';
                }else{
                employeename11=empname[h];
                insert+='<option value="'+empid1+'">'+employeename11+'</option>';
                }
                }
        		insert+='</select>';
        		insert+='</span>';
        		insert+='<br><br>';
        		insert+='<input type="button" class="btn btn-primary" value="Update" onclick=updatetopnextaction("na_id_f_e'+nid2+'","na_descr_f_e'+nid2+'","na_date1_f_e'+nid2+'","na_date_f_e'+nid2+'","na_time_f_e'+nid2+'","na_assign_id'+nid2+'")>';
        		insert+='<span style="margin-left:50px;color:grey;cursor:pointer;" onclick=cancelfirstnextaction("'+nid2+'","#csed1","#etad1","#emit1","#ngissa1","#noitpotceles1")>Cancel</span>';
        
        		insert+='<br></div></div>';
                $("#next_action").html(insert);
                callpicker("#na_date_f_e"+nid2, "#na_time_f_e"+nid2);
                $(".selectpicker_edit_nextaction").selectpicker();
            }
        </script>
        <script>
            function updatetopnextaction(nid, desc, selectoption, date1, time1, assign1){
                var cid="<?php echo $c_id;?>";
                var nid2=$("#"+nid).val();
                var desc2=$("#"+desc).val();
                var selectoption2=$("#"+selectoption).val();
                var date2=$("#"+date1).val();
                var time2=$("#"+time1).val();
                var assign2=$("#"+assign1).val();
                var assignid2=assign2;
                if(desc2==""){
                    $("#add_na_sec_descr").focus();
                    BootstrapAlert.warning({
                      title: "Warning!",
                      message: "Please enter the Next Action"
                    }); 
                    return;
                }
                if(((selectoption2=="Date")||(selectoption2=="Dateandtime")||(selectoption2=="Tomorrow")||(selectoption2=="7 days")||(selectoption2=="2 Weeks Time")||(selectoption2=="30 days Time")||(selectoption2=="31 days Time"))&&((date2=="")||(date2=="0000-00-00"))){
                    $("#add_na_sec_date").focus();
                    BootstrapAlert.warning({
                      title: "Warning!",
                      message: "Please Select the date"
                    }); 
                    return;
                }
                if((selectoption2=="Dateandtime")&&((time2=="")||(time2=="00:00:00")||(time2=="00:00"))){
                    $("#add_na_sec_time").focus();
                    BootstrapAlert.warning({
                      title: "Warning!",
                      message: "Please Select the Time"
                    }); 
                    return;
                }
                
                var empid=new Array();
                var empname=new Array();
                empid=<?php echo json_encode($comp_full_emailid);?>;
                empname=<?php echo json_encode($comp_full_empname);?>;
                var adminid="<?php echo $adminemailid;?>";
                var adminid1=assignid2.replace(".", "_vel_");
                var adminid1=adminid1.replace("@", "_vel_");
                var append2=adminid1+'_'+cid;
                var assignname2="";
                for(rt=0;rt<empid.length;rt++){
                    if(empid[rt]==assignid2){
                        assignname2=empname[rt];
                    }
                }
                assign2=assignid2;
                if(adminid!=assign2){
                    if((selectoption2=="ASAP")||(selectoption2=="Waiting")){
                        selectoption2="Queued";
                    }
                }
                var monthNames = ["", "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"];
                    if(adminid==assign2){
                        
                        swal("Next Action updated Successfully","","success");
                        $.ajax({
                            url:"activestream_intermediate.php",
                            type:"post",
                            data:{updatenextaction:desc2, nextactiondate:date2, nextactiontime:time2, cid:cid, nid:nid2, naassign:assignid2, selectoption:selectoption2},
                            success:function(respond){
                                //alert("respond"+respond);
                                BootstrapAlert.success({
                                  title: "Success!",
                                  message: "Next Action Updated Successfully"
                                }); 
                                var cccc=respond.trim();
                                var cccc1=cccc.split("#@");
                                var insert="";
                                var insert1="";
                                var todate=new Date();
                                var d=todate.getDate();
                                var m=todate.getMonth()+1;
                                var y=todate.getFullYear();
                                if(m<10){
                                    m="0"+m;
                                }
                                var d1=y+"-"+m+"-"+d;
                                var date3=date2;
                                var date123=date3.split("-")
                                var m3=date123[1];
                                if(m3[0]=="0"){
                                    m1=m3[1];
                                }else{
                                    m1=m3;
                                }
                                date5="<?php echo date('Y-m-d');?>";
                                
                                if(cccc1[1]=="yes"){
                                    
                                    insert1+='<div class="row">';
                                        insert1+='<div class="col-md-2">';
                                            insert1+='<br>';
                                            insert1+='<div class="checkbox pull-right" style="padding-top:10px;">';
                                                insert1+='<label class="container1">';
                                                    insert1+='<input type="checkbox" value="" id="checkbox_id" onchange=checkitscompletedtop("#checkbox_id","'+nid2+'","#na_f_desc'+nid2+'","#na_f_date'+nid2+'","#na_f_time'+nid2+'","#na_f_assign'+nid2+'","#na_f_select'+nid2+'")>';
                                                    insert1+='<span class="checkmark" ></span>';
                                                insert1+='</label>';
                                            insert1+='</div>';
                                        insert1+='</div>';
                                        insert1+='<div class="col-md-10">';
                                            insert1+='<h5>Next Action';
                                            insert1+='<span class="pull-right" style="color:grey;cursor:pointer;" onclick=editfirstnextaction("na_f_desc'+nid2+'","na_f_date'+nid2+'","na_f_time'+nid2+'","na_f_assign'+nid2+'","na_f_select'+nid2+'","'+nid2+'")>Edit</span></h5>';
                                            insert1+='<input type="hidden" id="na_f_desc'+nid2+'" value="'+desc2+'">';
                                            insert1+='<input type="hidden" id="na_f_date'+nid2+'" value="'+date2+'">';
                                            insert1+='<input type="hidden" id="na_f_time'+nid2+'" value="'+time2+'">';
                                            insert1+='<input type="hidden" id="na_f_select'+nid2+'" value="'+selectoption2+'">';
                                            insert1+='<input type="hidden" id="na_f_assign'+nid2+'" value="'+assignid2+'">';
                                            insert1+='<b>'+desc2+'</b>';
                                            insert1+='<div class="row" style="padding:10px 0px 10px 0px;">';
                                                insert1+='<div class="col-sm-8" style="padding:0px;">';
                                                     if(selectoption2=="Queued"){
                                                        insert1+='<div class="nextaction_queued_css1">';
                                                            insert1+='<span style="margin-left:10px;">';
                                                                insert1+='Queued';
                                                            insert1+='</span>';
                                                        insert1+='</div>';
                                                    }else if(selectoption2=="ASAP"){
                                                        insert1+='<div class="nextaction_asap_css1">';
                                                            insert1+='<span style="margin-left:10px;">';
                                                                insert1+='ASAP&nbsp;&nbsp;&nbsp;&nbsp;';
                                                            insert1+='</span>';
                                                        insert1+='</div>';
                                                    }else if(selectoption2=="Waiting"){
                                                        insert1+='<div class="nextaction_waiting_css1">';
                                                            insert1+='<span style="margin-left:10px;">';
                                                                insert1+='Waiting';
                                                            insert1+='</span>';
                                                        insert1+='</div>';
                                                    }else if(date2<date5){
                                                        var monthNames = ["", "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"];
                                                        var todate=new Date();
                                                        var d=todate.getDate();
                                                        var m=todate.getMonth()+1;
                                                        var y=todate.getFullYear();
                                                        if(m<10){
                                                            m="0"+m;
                                                        }
                                                        var d1=y+"-"+m+"-"+d;
                                                        var date3=date2;
                                                        var date123=date3.split("-")
                                                        var m3=date123[1];
                                                        if(m3[0]=="0"){
                                                            m1=m3[1];
                                                        }else{
                                                            m1=m3;
                                                        }
                                                        insert1+='<div class="nextaction_date_css1">';
                                                            insert1+='<span style="margin-left:10px;">';
                                                                if (date2!="0000-00-00") {
                                                                    insert1+=monthNames[m1]; 
                                                                    insert1+="&nbsp;&nbsp;"+d; 
                                                                }else{ 
                                                                    insert1+="Queued"; 
                                                                }
                                                            insert1+='</span>';
                                                        insert1+='</div>';
                                                    }else{
                                                    
                                                        var monthNames = ["", "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"];
                                                        var todate=new Date();
                                                        var d=todate.getDate();
                                                        var m=todate.getMonth()+1;
                                                        var y=todate.getFullYear();
                                                        if(m<10){
                                                            m="0"+m;
                                                        }
                                                        var d1=y+"-"+m+"-"+d;
                                                        var date3=date2;
                                                        var date123=date3.split("-")
                                                        var m3=date123[1];
                                                        if(m3[0]=="0"){
                                                            m1=m3[1];
                                                        }else{
                                                            m1=m3;
                                                        }
                                                        insert1+='<div class="nextaction_date1_css1">';
                                                            insert1+='<span style="margin-left:10px;">';
                                                                if (date2!="0000-00-00") {
                                                                    insert1+=monthNames[m1];
                                                                    insert1+="&nbsp;&nbsp;"+d; 
                                                                }else{ 
                                                                    insert1+="Queued"; 
                                                                }
                                                            insert1+='</span>';
                                                        insert1+='</div>';
                                                    } 
                                                insert1+='</div>';
                                                insert1+='<div class="col-sm-4">';
                                                insert1+='<span class="pull-right"  onclick=shownextactionqueue("#newnextactionadd")>';
                                                    insert1+='<span class="add_new_action"></span>';
                                                insert1+='</span>';
                                                insert1+='</div>';
                                            insert1+='</div>';
                                        insert1+='</div>';
                                    insert1+='</div>';
                                    $("#next_action").html(insert1);
                                    
                                }
                            }
                        });
                    }else{
                        
                    var insert="";
                    swal("Next Action updated Successfully","","success");
                    $.ajax({
                        url:"activestream_intermediate.php",
                        type:"post",
                        data:{updatenextaction:desc2, nextactiondate:date2, nextactiontime:time2, cid:cid, nid:nid2, naassign:assignid2, selectoption:selectoption2},
                        success:function(respond){
                            /*
                            BootstrapAlert.success({
                              title: "Success!",
                              message: "Next Action Updated Successfully"
                            });*/ 
                            var cccc=respond.trim()
                            var cccc1=cccc.split("#@");
                            var insert="";
                            var todate=new Date();
                            var d=todate.getDate();
                            var m=todate.getMonth()+1;
                            var y=todate.getFullYear();
                            if(m<10){
                                m="0"+m;
                            }
                            var d1=y+"-"+m+"-"+d;
                            var date3=date2;
                            var date123=date3.split("-")
                            var m3=date123[1];
                            if(m3[0]=="0"){
                                m1=m3[1];
                            }else{
                                m1=m3;
                            }
                            
                            if(cccc1[1]=="yes"){
                                var insert1="";
                                insert1+='<div class="col-sm-2">';
                                if(adminid==assign2){
                                    insert1+='<span  class="pull-right" >';
                                    insert1+='<span class="changenextaction" style="visibility:hidden; background-color:grey;color:white;border-radius:3px;font-size:10px;cursor:pointer;margin-left:-50px;padding:3px;"  onclick=exchangenextaction("'+nid2+'","#na_s_desc'+nid2+'","#na_s_date'+nid2+'","#na_s_time'+nid2+'","#na_s_select'+nid2+'","#nextactionqueue'+nid2+'","#na_s_assign'+nid2+'")><i style="transform: rotate(180deg)" class="fa fa-level-down" aria-hidden="true"></i>&nbsp;&nbsp;next</span>';
                                    insert1+='<label class="container2">';
                                        insert1+='<input type="checkbox" value="" id="checkbox1_'+nid2+'" onchange=checkitscompleted1("#checkbox1_'+nid2+'","'+nid2+'","#nextaction_desc1_'+nid2+'","#nextaction_icon1_'+nid2+'")>';
                                        insert1+='<span class="checkmark2" ></span>';
                                    insert1+='</label>';
                                    insert1+='</span>';
                                                
                                }else{
                                    insert1+='<span class="pull-right"><img src="../../Images/drag-verticalv2.png">&nbsp;&nbsp;&nbsp;</span>';
                                }
                                insert1+='<input type="hidden" id="na_s_desc'+nid2+'" value="'+desc2+'">';
                                insert1+='<input type="hidden" id="na_s_date'+nid2+'" value="'+date2+'">';
                                insert1+='<input type="hidden" id="na_s_time'+nid2+'" value="'+time2+'">';   
                                insert1+='<input type="hidden" id="na_s_nid'+nid2+'" value="'+nid2+'">';
                                insert1+='<input type="hidden" id="na_s_select'+nid2+'" value="'+selectoption2+'">';
                                insert1+='<input type="hidden" id="na_s_assign'+nid2+'" value="'+assign2+'">';
                                insert1+='</div>';
                                insert1+='<div class="col-sm-10">';
                                if(selectoption2=="Queued"){
                                    insert1+='<div class="nextaction_queued_css">';
                                     insert1+='<span style="margin-left:10px;">';
                                         insert1+='Queued';
                                }else if(selectoption2=="ASAP"){
                                    insert1+='<div class="nextaction_queued_css">';
                                     insert1+='<span style="margin-left:10px;">';
                                         insert1+='ASAP&nbsp;&nbsp;&nbsp;&nbsp;';
                                }else if(selectoption2=="Waiting"){
                                    insert1+='<div class="nextaction_queued_css">';
                                     insert1+='<span style="margin-left:10px;">';
                                         insert1+='Waiting';
                                }else if(date2<d1){
                                    insert1+='<div class="nextaction_date_css">';
                                     insert1+='<span style="margin-left:10px;">';
                                         insert1+=monthNames[m1]+'&nbsp;&nbsp;'+date123[2];
                                }else{
                                    insert1+='<div class="nextaction_date1_css">';
                                     insert1+='<span style="margin-left:10px;">';
                                         insert1+=monthNames[m1]+'&nbsp;&nbsp;'+date123[2];
                                }
                                
                                 
                                     insert1+='</span>&nbsp;&nbsp;&nbsp;&nbsp;<span id="nextaction_desc1_'+nid2+'" style="color:grey">'+desc2+'&nbsp;&nbsp;&nbsp;&nbsp;';
                                     if((time2!="00:00")&&(time2!="00:00:00")){
                                        insert1+=time2;
                                     }
                                     insert1+='</span>';
                                     insert1+='&nbsp;&nbsp;&nbsp;&nbsp;';
                                     insert1+='<span style="display:none;cursor:pointer;color:#666;" id="nextaction_icon'+nid2+'">';
                                         insert1+='<span id="nextaction_icon1_'+nid2+'">';
                                         if(adminid==assign2){
                                             insert1+='<span style="cursor:pointer;"  onclick=functiondeletenextaction("'+nid2+'","'+append2+'")>';
                                                 insert1+='<i class="glyphicon glyphicon-trash"></i>';
                                             insert1+='</span>&nbsp;&nbsp;';
                                         }  
                                             insert1+='<span style="cursor:pointer;" onclick=editsecondnextaction("na_s_desc'+nid2+'","na_s_date'+nid2+'","na_s_time'+nid2+'","na_s_nid'+nid2+'","#nextactionqueue'+nid2+'","'+cid+'","na_s_assign'+nid2+'","na_s_select'+nid2+'")>';
                                                 insert1+='<i class="glyphicon glyphicon-pencil"></i>';
                                             insert1+='</span>';
                                         insert1+='</span>';
                                     insert1+='</span>';
                                 insert1+='</div>';
                                            
                                
                                insert1+='</div>';
                                $("#"+append2).html(insert1);
                                $("#o_"+append2).show();/*
                                $("#"+nid).val(nid2);
                                $("#"+desc).val("");
                                $("#"+date1).val("0000-00-00");
                                $("#"+time1).val("00:00:00");
                                $("#"+assign1).val();
                                $("#"+selectoption).val();
                                $("#"+assign1).val($("#"+assign1+" option:first").val());
                                $("#"+selectoption).val($("#"+selectoption+" option:first").val());*/
                                addtopnext_action();
                            }
                        }
                    });
                    }
            }
        </script>
        <script>
            function cancelfirstnextaction(nid2,desc,date1,time1,assign,selectoption ){
                
                var desc2=$(desc).val();
                var date2=$(date1).val();
                var time2=$(time1).val();
                var assignid2=$(assign).val();
                var selectoption2=$(selectoption).val();
                var date5="<?php echo date('Y-m-d');?>";
                var insert1="";
                insert1+='<div class="row">';
                    insert1+='<div class="col-md-2">';
                        insert1+='<br>';
                        insert1+='<div class="checkbox pull-right" style="padding-top:10px;">';
                            insert1+='<label class="container1">';
                                insert1+='<input type="checkbox" value="" id="checkbox_id" onchange=checkitscompletedtop("#checkbox_id","'+nid2+'","#na_f_desc'+nid2+'","#na_f_date'+nid2+'","#na_f_time'+nid2+'","#na_f_assign'+nid2+'","#na_f_select'+nid2+'")>';
                                insert1+='<span class="checkmark" ></span>';
                            insert1+='</label>';
                        insert1+='</div>';
                    insert1+='</div>';
                    insert1+='<div class="col-md-10">';
                        insert1+='<h5>Next Action';
                        insert1+='<span class="pull-right" style="color:grey;cursor:pointer;" onclick=editfirstnextaction("na_f_desc'+nid2+'","na_f_date'+nid2+'","na_f_time'+nid2+'","na_f_assign'+nid2+'","na_f_select'+nid2+'","'+nid2+'")>Edit</span></h5>';
                        insert1+='<input type="hidden" id="na_f_desc'+nid2+'" value="'+desc2+'">';
                        insert1+='<input type="hidden" id="na_f_date'+nid2+'" value="'+date2+'">';
                        insert1+='<input type="hidden" id="na_f_time'+nid2+'" value="'+time2+'">';
                        insert1+='<input type="hidden" id="na_f_select'+nid2+'" value="'+selectoption2+'">';
                        insert1+='<input type="hidden" id="na_f_assign'+nid2+'" value="'+assignid2+'">';
                        insert1+='<b>'+desc2+'</b>';
                        insert1+='<div class="row" style="padding:10px 0px 10px 0px;">';
                            insert1+='<div class="col-sm-8" style="padding:0px;">';
                                 if(selectoption2=="Queued"){
                                    insert1+='<div class="nextaction_queued_css1">';
                                        insert1+='<span style="margin-left:10px;">';
                                            insert1+='Queued';
                                        insert1+='</span>';
                                    insert1+='</div>';
                                }else if(selectoption2=="ASAP"){
                                    insert1+='<div class="nextaction_asap_css1">';
                                        insert1+='<span style="margin-left:10px;">';
                                            insert1+='ASAP&nbsp;&nbsp;&nbsp;&nbsp;';
                                        insert1+='</span>';
                                    insert1+='</div>';
                                }else if(selectoption2=="Waiting"){
                                    insert1+='<div class="nextaction_waiting_css1">';
                                        insert1+='<span style="margin-left:10px;">';
                                            insert1+='Waiting';
                                        insert1+='</span>';
                                    insert1+='</div>';
                                }else if(date2<date5){
                                    var monthNames = ["", "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"];
                                    var todate=new Date();
                                    var d=todate.getDate();
                                    var m=todate.getMonth()+1;
                                    var y=todate.getFullYear();
                                    if(m<10){
                                        m="0"+m;
                                    }
                                    var d1=y+"-"+m+"-"+d;
                                    var date3=date2;
                                    var date123=date3.split("-")
                                    var m3=date123[1];
                                    if(m3[0]=="0"){
                                        m1=m3[1];
                                    }else{
                                        m1=m3;
                                    }
                                    insert1+='<div class="nextaction_date_css1">';
                                        insert1+='<span style="margin-left:10px;">';
                                            if (date2!="0000-00-00") {
                                                insert1+=monthNames[m1]; 
                                                insert1+="&nbsp;&nbsp;"+d; 
                                            }else{ 
                                                insert1+="Queued"; 
                                            }
                                        insert1+='</span>';
                                    insert1+='</div>';
                                }else{
                                
                                    var monthNames = ["", "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"];
                                    var todate=new Date();
                                    var d=todate.getDate();
                                    var m=todate.getMonth()+1;
                                    var y=todate.getFullYear();
                                    if(m<10){
                                        m="0"+m;
                                    }
                                    var d1=y+"-"+m+"-"+d;
                                    var date3=date2;
                                    var date123=date3.split("-")
                                    var m3=date123[1];
                                    if(m3[0]=="0"){
                                        m1=m3[1];
                                    }else{
                                        m1=m3;
                                    }
                                    insert1+='<div class="nextaction_date1_css1">';
                                        insert1+='<span style="margin-left:10px;">';
                                            if (date2!="0000-00-00") {
                                                insert1+=monthNames[m1];
                                                insert1+="&nbsp;&nbsp;"+d; 
                                            }else{ 
                                                insert1+="Queued"; 
                                            }
                                        insert1+='</span>';
                                    insert1+='</div>';
                                } 
                            insert1+='</div>';
                            insert1+='<div class="col-sm-4">';
                            insert1+='<span class="pull-right"  onclick=shownextactionqueue("#newnextactionadd")>';
                            insert1+='<span class="add_new_action"></span>';
                            insert1+='</span>';
                            insert1+='</div>';
                        insert1+='</div>';
                    insert1+='</div>';
                insert1+='</div>';
                $("#next_action").html(insert1);
            }
        </script>
        
        <script>
            function addtopnext_action(){
                var empid=new Array();
                var empname=new Array();
                var cid="<?php echo $c_id;?>";
                var admin="<?php echo $adminemailid;?>";
                empid=<?php echo json_encode($comp_full_emailid);?>;
                empname=<?php echo json_encode($comp_full_empname);?>;
                var insert="";
                insert+='<div class="row" style="background-color:#d9eefc;border-radius:5px;padding-bottom:10px;">';
                    insert+='<div class="col-md-2"></div>';
                    insert+='<div class="col-md-10">';
                        insert+='<h5><b>Next Action</b>&nbsp;&nbsp;or &nbsp;<a onclick=funclosethenextaction() style="color:#6699cc;cursor:pointer;">Close</a></h5></h5>';
                        
                        insert+='<input type="hidden" id="na_nid_c_id" name="na_nid_c_id" value="">';
                        insert+='<textarea class="form-control" id="na_descr_c_id" rows="5"></textarea><br>';
                        insert+='<select name="na_date1" id="na_date1_c_id" style="height:30px;border-radius:5px;" onchange=declaredatepicker("#na_date1_c_id","#na_date_c_id","#na_time_c_id")>';
                            insert+='<option value="ASAP">ASAP</option>';
                            insert+='<option value="Waiting">Waiting for</option>';
                            insert+='<option value="Date">Date</option>';
                            insert+='<option value="Dateandtime">Date & Time</option>';
                            insert+='<option value="Tomorrow">Tomorrow</option>';
                            insert+='<option value="7 days">7 days Time</option>';
                            insert+='<option value="2 Weeks Time">2 Weeks Time</option>';
                            insert+='<option value="30 days Time">30 days Time</option>';
                            insert+='<option value="31 days Time">31 days Time</option>';
                        insert+='</select>';
                        insert+='<input type="text" name="na_date" value="" id="na_date_c_id" readonly style="display:none;width:180px;height:30px;border-radius:5px;margin-left:10px;cursor:pointer;">';
                        insert+='<input type="text" name="na_time" value="" id="na_time_c_id" readonly style="display:none;width:180px;height:30px;border-radius:5px;margin-left:10px;cursor:pointer;">';
                		
                		insert+='<span class="pull-right">';
                		insert+='<select id="na_assign_c_id" class="selectpicker_edit_nextaction">';
                        for(h=0;h<empid.length;h++){
                        empid1=empid[h];
                        if(empid1==admin){
                        employeename11="Me";
                        insert+='<option value="'+empid1+'" selected>'+employeename11+'</option>';
                        }else{
                        employeename11=empname[h];
                        insert+='<option value="'+empid1+'">'+employeename11+'</option>';
                        }
                        }
                		insert+='</select>';
                		insert+='</span>';
                        insert+='<div style="padding-bottom:20px;padding-top:15px;">';
                        insert+='<input type="button" class="btn btn-primary" value="save" onclick="fun_save_first_nextaction()" >';
                        insert+='</div>';
                    insert+='</div>';
                insert+='</div>';
                $(".selectpicker_edit_nextaction").selectpicker();
                $("#next_action").html(insert);
                $(".changenextaction").css("visibility","visible");
            }
        </script>
        
                <script>
                    function reopenthenextaction(){
                        var cid="<?php echo $c_id;?>";
                        var closingcomment=$("#closingcomment").val();
                        if(closingcomment=="undefined"){
                            closingcomment="";
                        }
                        if(closingcomment=="no data available"){
                            closingcomment="";
                        }
                        var closingdate=$("#closingdate").val();
                        var emailid1=<?php echo json_encode($comp_full_emailid);?>;
                        var employeename1=<?php echo json_encode($comp_full_empname);?>;
                        var adminemailid="<?php echo $adminemailid;?>";
                        var insert='';
                        insert+='<div class="row" style="padding:10px;">';
                        insert+='<div class="col-sm-2"></div>';
                        insert+='<div class="col-sm-10">';
                        insert+='<span  style="padding:10px 0px;"><b>Next Action</b>&nbsp;&nbsp;or &nbsp;<a onclick="funclosethenextaction()" style="color:#6699cc;cursor:pointer;">Close</a><br>';   
                        insert+='<textarea class="form-control" id="na_descr_c_id" rows="5"></textarea>';
                        insert+='</span><br>';
                        insert+='<input type="hidden" id="na_nid_c_id" name="na_nid_c_id" value="">';
                        insert+='<input type="hidden" id="closingcomment" name="closingcomment" value="'+closingcomment+'">';
                        insert+='<input type="hidden" id="closingdate" name="closingdate" value="'+closingdate+'">';
                        insert+='<div class="row">';
                        insert+='<select name="na_reopen_date1" id="na_date1_c_id" onchange=declaredatepicker("#na_date1_c_id","#na_date_c_id","#na_time_c_id") style="height:30px;border-radius:5px;">';
                        insert+='<option value="ASAP">ASAP</option>';
                        insert+='<option value="Waiting">Waiting</option>';
                        insert+='<option value="Date">Date</option>';
                        insert+='<option value="Dateandtime">Date & Time</option>';
                        insert+='<option value="Tomorrow">Tomorrow</option>';
                        insert+='<option value="7 days">7 days Time</option>';
                        insert+='<option value="2 Weeks Time">2 Weeks Time</option>';
                        insert+='<option value="30 days Time">30 days Time</option>';
                        insert+='<option value="31 days Time">31 days Time</option>';
                        insert+='</select>';
                        insert+='<input type="text" name="na_date" value="0000-00-00" id="na_date_c_id"  readonly style="width:180px;height:30px;border-radius:5px;margin-left:10px;cursor:pointer;display:none;">';
                        insert+='<input type="text" name="na_time" value="00:00" id="na_time_c_id" readonly style="width:180px;height:30px;border-radius:5px;margin-left:10px;cursor:pointer;display:none;">';
                        insert+='<span class="pull-right">Assign to&nbsp;&nbsp';
                        insert+='<select name="na_reopen_assign" id="na_assign_c_id" style="height:30px;border-radius:5px;">';
                        for(var i=0;i<emailid1.length;i++){
                            if(adminemailid==emailid1[i]){
                                insert+='<option value="'+emailid1[i]+'" selected>Me</option>';
                            }else{
                                insert+='<option value="'+emailid1[i]+'">'+employeename1[i]+'</option>';
                            }
                        }
                        insert+='</select>';
                        insert+='</span></div>';
                        //insert+='<input type="button" id="savereopennextaction" class="btn btn-primary" value="Save" onclick="savereopennextaction()">';
                        insert+='<input type="button" id="savereopennextaction" class="btn btn-primary" value="Save" onclick="fun_save_first_nextaction()">';
                        insert+='<span style="margin-left:50px;color:grey;cursor:pointer;" id="cancelclosecomment" onclick="cancelreopenfunction()">Cancel</span>';
                        
                        insert+='</div>';
                        insert+='</div>';
                        $("#next_action").html(insert);
                        $("#na_reopen_assign").selectpicker();
                    }
                </script>
                <script>
                    function exchangenextaction(nid, desc, date1, time1, selectoption, hideid, assign){
                    var d = new Date();

                    var month = d.getMonth()+1;
                    var day = d.getDate();
                    
                    var output = d.getFullYear() + '-' +
                        (month<10 ? '0' : '') + month + '-' +
                        (day<10 ? '0' : '') + day;
                        var desc2=$(desc).val();
                        var date2=$(date1).val();
                        var time2=$(time1).val();
                        var selectoption2=$(selectoption).val();
                        var assign2=$(assign).val();
                        $(hideid).hide();
                        if((date2!="0000-00-00")&&(date2!="")){
                            $("#na_date_c_id").show();
                        }
                        if((time2!="00:00:00")&&(time2!="")&&(time2!="00:00")){
                            $("#na_descr_c_id").show();
                        }
                        if(selectoption2=="Queued"){
                            date2=output;
                            $("#na_date_c_id").show();
                            selectoption2="Date";
                        }
                        var sel="<option value='"+selectoption2+"' selected>"+selectoption2+"</option>";
                        $("#na_descr_c_id").val(desc2);
                        $("#na_date_c_id").val(date2);
                        $("#na_time_c_id").val(time2);
                        $("#na_date1_c_id").append(sel);
                        $("#na_nid_c_id").val(nid);
                    }
                </script>
                <script>
                    function cancelreopenfunction(){
                        var cid="<?php echo $c_id;?>";
                        var closingcomment=$("#closingcomment").val();
                        if(closingcomment=="undefined"){
                            closingcomment="";
                        }
                        if(closingcomment=="no data available"){
                            closingcomment="";
                        }
                        var closingdate=$("#closingdate").val();
                        
                        var insert="";
                        insert+='<div class="row">';
                            insert+='<div class="col-md-2"></div>';
                            insert+='<div class="col-md-10" style="padding:20px 0px;">';
                                insert+='<b><span style="color:#54585b;">Sales cycle closed</span></b> - <a style="color:#6699cc;cursor:pointer;" onclick="reopenthenextaction()">Reopen</a> or'; 
                                if(closingcomment!=""){
                                    insert+='<a style="color:#6699cc;cursor:pointer;" onclick="editnewclosingcommentui()"> Edit closing comment</a>';
                                    insert+='<br>';
                                    insert+='<b>'+closingcomment+'</b><br>';
                                }else{
                                    insert+='<a style="color:#6699cc;cursor:pointer;" onclick="addnewclosingcommentui()"> Add a closing comment</a>';
                                    insert+='<br>';
                                }
                            insert+='<span style="color: #666;font-size: 13px;font-family: Open Sans Italic, Arial, Helvetica, sans-serif;"><i> Next Action process closed for me on &nbsp;</i>'+closingdate+'</span>';
                            insert+='</div>';
                            insert+="<input type='hidden' id='closingdate' name='closingdate' value='"+closingdate+"'>";
                            insert+='<input type="hidden" id="closingcomment" value="'+closingcomment+'">';
                            insert+='<span class="pull-right"  onclick=shownextactionqueue("#newnextactionadd") >';
                                insert+='<span class="add_new_action" style="margin-right:10px;"></span>';
                            insert+='</span>';
                        insert+='</div>';
                        $("#next_action").html(insert);
                    }
                </script>
                <script>
                    function savereopennextaction(){
                        
                                
                                var monthNames = ["", "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"];
                                
                                var cid="<?php echo $c_id;?>";
                                var desc2=$("#na_reopen_descr").val();
                                var date2=$("#na_reopen_date").val();
                                var time2=$("#na_reopen_time").val();
                                var assignid2=$("#na_reopen_assign").val();
                                var selectoption2=$("#na_reopen_date1").val();
                                
                                if(desc2==""){
                                    $("#add_na_sec_descr").focus();
                                    BootstrapAlert.warning({
                                      title: "Warning!",
                                      message: "Please enter the Next Action"
                                    }); 
                                    return;
                                }
                                if(((selectoption2=="Date")||(selectoption2=="Dateandtime")||(selectoption2=="Tomorrow")||(selectoption2=="7 days")||(selectoption2=="2 Weeks Time")||(selectoption2=="30 days Time")||(selectoption2=="31 days Time"))&&((date2=="")||(date2=="0000-00-00"))){
                                    $("#add_na_sec_date").focus();
                                    BootstrapAlert.warning({
                                      title: "Warning!",
                                      message: "Please Select the date"
                                    }); 
                                    return;
                                }
                                if((selectoption2=="Dateandtime")&&((time2=="")||(time2=="00:00:00")||(time2=="00:00"))){
                                    $("#add_na_sec_time").focus();
                                    BootstrapAlert.warning({
                                      title: "Warning!",
                                      message: "Please Select the Time"
                                    }); 
                                    return;
                                }
                                
                                var empid=new Array();
                                var empname=new Array();
                                empid=<?php echo json_encode($comp_full_emailid);?>;
                                empname=<?php echo json_encode($comp_full_empname);?>;
                                var adminid="<?php echo $adminemailid;?>";
                                var adminid1=assignid2.replace(".", "_vel_");
                                var adminid1=adminid1.replace("@", "_vel_");
                                var append2=adminid1+'_'+cid;
                                var assignname2="";
                                for(rt=0;rt<empid.length;rt++){
                                    if(empid[rt]==assignid2){
                                        assignname2=empname[rt];
                                    }
                                }
                                
                                assign2=assignid2;
                                                    
                                            
                                if((desc2!="")&&(date2!="")&&(time2!="")){
                                    swal("Next Action Created Successfully","","success");
                                    $.ajax({
                                        url:"activestream_intermediate.php",
                                        type:"post",
                                        data:{insertnextaction1:desc2, nextactiondate:date2, nextactiontime:time2, cid:cid, naassign:assignid2, selectoption:selectoption2},
                                        success:function(respond){
                                            var nid1=respond.trim()
                                            var nid_array=nid1.split("#@");
                                            nid2=nid_array[1];
                                            var monthNames = ["", "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"];
                                            var insert1="";
                                            var todate=new Date();
                                            var d=todate.getDate();
                                            var m=todate.getMonth()+1;
                                            var y=todate.getFullYear();
                                            if(m<10){
                                                m="0"+m;
                                            }
                                            var d1=y+"-"+m+"-"+d;
                                            var date3=date2;
                                            var date123=date3.split("-")
                                            var m3=date123[1];
                                            if(m3[0]=="0"){
                                                m1=m3[1];
                                            }else{
                                                m1=m3;
                                            } 
                                            var date5="<?php echo date('Y-m-d');?>";
                                        //nid2="12";
                                            if(adminid==assignid2){
                                            var insert1="";
                                            
                                            insert1+='<div class="row" style="background-color:#d9eefc;border-radius:5px;padding-bottom:10px;">';
                                                insert1+='<div class="col-md-2">';
                                                    insert1+='<br>';
                                                    insert1+='<div class="checkbox pull-right" style="padding-top:10px;">';
                                                        insert1+='<label class="container1">';
                                                            insert1+='<input type="checkbox" value="" id="checkbox_id" onchange=checkitscompletedtop("#checkbox_id","'+nid2+'","#na_f_desc'+nid2+'","#na_f_date'+nid2+'","#na_f_time'+nid2+'","#na_f_assign'+nid2+'","#na_f_select'+nid2+'")>';
                                                            insert1+='<span class="checkmark" ></span>';
                                                        insert1+='</label>';
                                                    insert1+='</div>';
                                                insert1+='</div>';
                                                insert1+='<div class="col-md-10">';
                                                    insert1+='<h5>Next Action';
                                                    insert1+='<span class="pull-right" style="color:grey;cursor:pointer;" onclick=editfirstnextaction("na_f_desc'+nid2+'","na_f_date'+nid2+'","na_f_time'+nid2+'","na_f_assign'+nid2+'","na_f_select'+nid2+'","'+nid2+'")>Edit</span></h5>';
                                                    insert1+='<input type="hidden" id="na_f_desc'+nid2+'" value="'+desc2+'">';
                                                    insert1+='<input type="hidden" id="na_f_date'+nid2+'" value="'+date2+'">';
                                                    insert1+='<input type="hidden" id="na_f_time'+nid2+'" value="'+time2+'">';
                                                    insert1+='<input type="hidden" id="na_f_select'+nid2+'" value="'+selectoption2+'">';
                                                    insert1+='<input type="hidden" id="na_f_assign'+nid2+'" value="'+assignid2+'">';
                                                    insert1+='<b>'+desc2+'</b>';
                                                    insert1+='<div class="row" style="padding:10px 0px 10px 0px;">';
                                                        insert1+='<div class="col-sm-8" style="padding:0px;">';
                                                             if((selectoption2=="Queued")){
                                                                insert1+='<div class="nextaction_queued_css1">';
                                                                    insert1+='<span style="margin-left:10px;">';
                                                                        insert1+='Queued';
                                                                    insert1+='</span>';
                                                                insert1+='</div>';
                                                            }else if((selectoption2=="ASAP")){
                                                                insert1+='<div class="nextaction_asap_css1">';
                                                                    insert1+='<span style="margin-left:10px;">';
                                                                        insert1+='ASAP&nbsp;&nbsp;&nbsp;&nbsp;';
                                                                    insert1+='</span>';
                                                                insert1+='</div>';
                                                            }else if((selectoption2=="Waiting")){
                                                                insert1+='<div class="nextaction_waiting_css1">';
                                                                    insert1+='<span style="margin-left:10px;">';
                                                                        insert1+='Waiting';
                                                                    insert1+='</span>';
                                                                insert1+='</div>';
                                                            }else if(date2<date5){
                                                                insert1+='<div class="nextaction_date_css1">';
                                                                    insert1+='<span style="margin-left:10px;">';
                                                                        if (date2!="0000-00-00") {
                                                                            insert1+=monthNames[m1]; 
                                                                            insert1+="&nbsp;&nbsp;"+d; 
                                                                        }else{ 
                                                                            insert1+="Queued"; 
                                                                        }
                                                                    insert1+='</span>';
                                                                insert1+='</div>';
                                                            }else{
                                                                insert1+='<div class="nextaction_date1_css1">';
                                                                    insert1+='<span style="margin-left:10px;">';
                                                                        if (date2!="0000-00-00") {
                                                                            insert1+=monthNames[m1];
                                                                            insert1+="&nbsp;&nbsp;"+d; 
                                                                        }else{ 
                                                                            insert1+="Queued"; 
                                                                        }
                                                                    insert1+='</span>';
                                                                insert1+='</div>';
                                                            } 
                                                        insert1+='</div>';
                                                        insert1+='<div class="col-sm-4">';
                                                        insert1+='<span class="pull-right"  onclick=shownextactionqueue("#newnextactionadd")>';
                                                            insert1+='<span class="add_new_action"></span>';
                                                        insert1+='</span>';
                                                        insert1+='</div>';
                                                    insert1+='</div>';
                                                insert1+='</div>';
                                            insert1+='</div>';
                                                $("#next_action").html(insert1);
                                            }else{
                                                
                                            insert1+='<div class="row" style="padding:10px 0px 10px 0px;cursor:pointer;" id="nextactionqueue'+nid2+'" onmouseover=functionnextaction_show_icon("#nextaction_icon'+nid2+'") onmouseout=functionnextaction_hide_icon("#nextaction_icon'+nid2+'")>'
                                            
                                            insert1+='<div class="col-sm-2">';
                                            if(adminid==assign2){
                                                insert1+='<span class="pull-right">';
                                                insert1+='<span class="changenextaction" style="visibility:hidden; background-color:grey;color:white;border-radius:3px;font-size:10px;cursor:pointer;margin-left:-50px;padding:3px;"  onclick=exchangenextaction("'+nid2+'","#na_s_desc'+nid2+'","#na_s_date'+nid2+'","#na_s_time'+nid2+'","#na_s_select'+nid2+'","#nextactionqueue'+nid2+'","#na_s_assign'+nid2+'")><i style="transform: rotate(180deg);" class="fa fa-level-down" aria-hidden="true"></i>&nbsp;&nbsp;next</span>';
                                                insert1+='<label class="container2">';
                                                    insert1+='<input type="checkbox" value="" id="checkbox1_'+nid2+'" onchange=checkitscompleted1("#checkbox1_'+nid2+'","'+nid2+'","#nextaction_desc1_'+nid2+'","#nextaction_icon1_'+nid2+'")>';
                                                    insert1+='<span class="checkmark2" ></span>';
                                                insert1+='</label>';
                                                insert1+='</span>';
                                                            
                                            }else{
                                                insert1+='<span class="pull-right"><img src="../../Images/drag-verticalv2.png">&nbsp;&nbsp;&nbsp;</span>';
                                            }
                                            insert1+='<input type="hidden" id="na_s_desc'+nid2+'" value="'+desc2+'">';
                                            insert1+='<input type="hidden" id="na_s_date'+nid2+'" value="'+date2+'">';
                                            insert1+='<input type="hidden" id="na_s_time'+nid2+'" value="'+time2+'">';   
                                            insert1+='<input type="hidden" id="na_s_nid'+nid2+'" value="'+nid2+'">';
                                            insert1+='<input type="hidden" id="na_s_assign'+nid2+'" value="'+assign2+'">';
                                            insert1+='<input type="hidden" id="na_s_select'+nid2+'" value="'+selectoption2+'">';
                                            insert1+='</div>';
                                            insert1+='<div class="col-sm-10">';
                                            if(date2=="0000-00-00"){
                                                insert1+='<div class="nextaction_queued_css">';
                                                 insert1+='<span style="margin-left:10px;">';
                                                     insert1+='Queued';
                                            }else if(date2<d1){
                                                insert1+='<div class="nextaction_date_css">';
                                                insert1+='<span style="margin-left:10px;">';
                                                insert1+=monthNames[m1]+'&nbsp;&nbsp;'+date123[2];
                                            }else{
                                                insert1+='<div class="nextaction_date1_css">';
                                                insert1+='<span style="margin-left:10px;">';
                                                insert1+=monthNames[m1]+'&nbsp;&nbsp;'+date123[2];
                                            }
                                            
                                             
                                                 insert1+='</span>&nbsp;&nbsp;&nbsp;&nbsp;<span id="nextaction_desc1_'+nid2+'" style="color:grey">'+desc2+'&nbsp;&nbsp;&nbsp;&nbsp;';
                                                 if((time2!="00:00")&&(time2!="00:00:00")){
                                                    insert1+=time2;
                                                 }
                                                 insert1+='</span>';
                                                 insert1+='&nbsp;&nbsp;&nbsp;&nbsp;';
                                                 insert1+='<span style="display:none;cursor:pointer;color:#666;" id="nextaction_icon'+nid2+'">';
                                                     insert1+='<span id="nextaction_icon1_'+nid2+'">';
                                                     if(adminid==assign2){
                                                         insert1+='<span style="cursor:pointer;"  onclick=functiondeletenextaction("'+nid2+'","nextactionqueue'+nid2+'")>';
                                                             insert1+='<i class="glyphicon glyphicon-trash"></i>';
                                                         insert1+='</span>&nbsp;&nbsp;';
                                                     }  
                                                         insert1+='<span style="cursor:pointer;" onclick=editsecondnextaction("na_s_desc'+nid2+'","na_s_date'+nid2+'","na_s_time'+nid2+'","na_s_nid'+nid2+'","#nextactionqueue'+nid2+'","'+cid+'","na_s_assign'+nid2+'","na_s_select'+nid2+'")>';
                                                             insert1+='<i class="glyphicon glyphicon-pencil"></i>';
                                                         insert1+='</span>';
                                                     insert1+='</span>';
                                                 insert1+='</span>';
                                             insert1+='</div>';
                                             
                                             insert1+='</div>';
                                                        
                                            
                                            insert1+='</div>';
                                            $("#"+append2).append(insert1);
                                            $("#o_"+append2).show();
                                            }
                                            $("#na_reopen_descr").val("");
                                            $("#na_reopen_date").val("0000-00-00");
                                            $("#na_reopen_time").val("00:00:00");
                                            $("#na_reopen_date").hide();
                                            $("#na_reopen_time").hide();
                                            $("#na_reopen_assign").val($("#na_reopen_assign option:first").val());
                                            $("#na_reopen_assign").selectpicker("refresh");
                                            $("#na_reopen_date1").val($("#na_reopen_date1 option:first").val());
                                            
                                        }
                                    });
                        
                                }
                            
                    }
                </script>
                <style>
                    .clockpicker-popover{
                        top:0px;
                    }
                </style>
                
        <script>
            function funclosethenextaction(){
                var cid="<?php echo $c_id;?>";
                var admin="<?php echo $adminemailid;?>";
                
                $.ajax({
                    url:"activestream_intermediate.php",
                    type:"post",
                    data:{totalnextaction:cid, emp:admin},
                    success:function(respond){
                        var r=respond.trim();
                        var s=r.split("#@");
                        if(s[1]>0){
                            BootstrapAlert.warning({
                              title: "Warning!",
                              message: "Please Complete All the Next Action"
                            }); 
                        }else{
                            $.ajax({
                                url:"activestream_intermediate.php",
                                type:"post",
                                data:{close_contact:cid},
                                success:function(respond){
                                    BootstrapAlert.success({
                                      title: "Success!",
                                      message: "Next Action Closed For You"
                                    }); 
                                    var date1=respond.trim();
                                    var date2=date1.split("#@");
                                    var date3=date2[1];
                                    var insert="";
                                    insert+='<div class="row">';
                                        insert+='<div class="col-md-2"></div>';
                                        insert+='<div class="col-md-10" style="padding:20px 0px;">';
                                            insert+='<b><span style="color:#54585b;">Sales cycle closed</span></b> - <a style="color:#6699cc;cursor:pointer;" onclick="reopenthenextaction()">Reopen</a> or'; 
                                            insert+='<a style="color:#6699cc;cursor:pointer;" onclick="addnewclosingcommentui()"> Add a closing comment</a>';
                                            insert+='<br>';
                                            insert+='<span style="color: #666;font-size: 13px;font-family: Open Sans Italic, Arial, Helvetica, sans-serif;"><i> Next Action process closed for me on &nbsp;</i>'+date3+'</span>';
                                        insert+='</div>';
                                        insert+='<input type="hidden" id="closingdate" value="'+date3+'">';
                                        insert+='<input type="hidden" id="closingcomment" value="">';
                                        insert+='<span class="pull-right"  onclick=shownextactionqueue("#newnextactionadd") >';
                                            insert+='<span class="add_new_action" style="margin-right:10px;"></span>';
                                        insert+='</span>';
                                    insert+='</div>';
                                    $("#next_action").html(insert);
                                    
                                }
                            });
                        }
                    }
                });
            }
        </script>
        
                
                <script>
                    function editnewclosingcommentui(){
                        var closingdate=$("#closingdate").val();
                        var closingcomment=$("#closingcomment").val();
                        if(closingcomment=="undefined"){
                            closingcomment="";
                        }
                        if(closingcomment=="no data available"){
                            closingcomment="";
                        }
                        var closeid="closednextaction<?php echo $c_id;?>";
                        var cid="<?php echo $c_id;?>";
                        var insert="";
                        insert+="<div class='row'>";
                        insert+="<div class='col-md-2'>";
                        insert+="</div>";
                        insert+="<div class='col-md-10'>";
                        insert+="<div  style='padding:10px;'>";
                        insert+="<b>Closing comment</b><br><br>";
                        insert+='<input type="hidden" id="closingcomment" name="closedcomment" value="'+closingcomment+'">';
                        insert+='<input type="hidden" id="closingdate" name="closingdate" value="'+closingdate+'">';
                        insert+="<input type='text' class='form-control' name='closingcomment' id='edit_closingcomment' value='"+closingcomment+"'><br>";
                        insert+="<input type='button' name='editclosecomment1' id='editclosecomment1' onclick='editcommentsavefunction()' value='Save' class='btn btn-primary'>";
                        insert+="&nbsp;&nbsp;&nbsp;<span id='cancelclosecomment' style='cursor:pointer;' onclick='cancelreopenfunction()'>Cancel</span><br>";
                        insert+="</div>";
                        insert+="</div>";
                        insert+="</div>";
                        $("#next_action").html(insert);
                    }
                </script>
                
                <script>
                    function editcommentsavefunction(){
                        var cid="<?php echo $c_id;?>";
                        var closingcomment=$("#edit_closingcomment").val();
                        var closingdate=$("#closingdate").val();
                        if(closingcomment!=""){
                            $.ajax({
                                url:"activestream_intermediate.php",
                                type:"post",
                                data:{comment_contact:cid, comment:closingcomment},
                                success:function(respond){
                                    BootstrapAlert.success({
                                      title: "Success!",
                                      message: "Next Action Close Comment updated Successfully"
                                    }); 
                                   
                                    var insert="";
                                    insert+='<div class="row">';
                                        insert+='<div class="col-md-2"></div>';
                                        insert+='<div class="col-md-10" style="padding:20px 0px;">';
                                            insert+='<b><span style="color:#54585b;">Sales cycle closed</span></b> - <a style="color:#6699cc;cursor:pointer;" onclick="reopenthenextaction()">Reopen</a> or'; 
                                            insert+='<a style="color:#6699cc;cursor:pointer;" onclick="editnewclosingcommentui()"> Edit closing comment</a>';
                                            insert+='<br>';
                                            if(closingcomment!=""){
                                                insert+='<b>'+closingcomment+'</b><br>';   
                                            }
                                            insert+='<span style="color: #666;font-size: 13px;font-family: Open Sans Italic, Arial, Helvetica, sans-serif;"><i>Next Action process closed for me on &nbsp;</i>'+closingdate+'</span>';
                                        insert+='</div>';
                                        insert+='<input type="hidden" id="closingdate" value="'+closingdate+'">';
                                        insert+='<input type="hidden" id="closingcomment" value="'+closingcomment+'">';
                                        insert+='<span class="pull-right"  onclick=shownextactionqueue("#newnextactionadd") >';
                                            insert+='<span class="add_new_action" style="margin-right:10px;"></span>';
                                        insert+='</span>';
                                    insert+='</div>';
                                    $("#next_action").html(insert);
                                }
                            });
                        }else{
                            $("#edit_closingcomment").focus();
                            BootstrapAlert.warning({
                              title: "Warning!",
                              message: "Please enter the comment"
                            }); 
                        }
                    };
                </script>
                <script>
                    function addnewclosingcommentui(){
                        var cid="<?php echo $c_id;?>";
                        var closingdate=$("#closingdate").val();
                        var insert="";
                        insert+="<div class='row'>";
                        insert+="<div class='col-md-2'>";
                        insert+="</div>";
                        insert+="<div class='col-md-10'>";
                        insert+="<div  style='padding:10px;'>";
                        insert+="<b>Closing comment</b><br>";
                        insert+="<input type='hidden' class='form-control' name='closingdate' id='closingdate' value='"+closingdate+"'>";
                        insert+="<input type='hidden' class='form-control' name='closingcomment' id='closingcomment' value=''><br>";
                        insert+="<input type='text' class='form-control' name='closecomment' id='closecomment' value=''><br>";
                        insert+="<input type='button' name='addclosecomment' id='addclosecomment' onclick='saveclosingcomment()' value='Save' class='btn btn-primary'>";
                        insert+="&nbsp;&nbsp;&nbsp;<span id='cancelclosecomment' style='cursor:pointer;' onclick='cancelreopenfunction()'>Cancel</span><br>";
                        insert+="</div>";
                        insert+="</div>";
                        insert+="</div>";
                        $("#next_action").html(insert);
                    }
                </script>
                <script>
                    function saveclosingcomment(){
                        var cid="<?php echo $c_id;?>";
                        var closingdate=$("#closingdate").val();
                        var closingcomment=$("#closecomment").val();
                        if(closingcomment!=""){
                            $.ajax({
                                url:"activestream_intermediate.php",
                                type:"post",
                                data:{comment_contact:cid, comment:closingcomment},
                                success:function(respond){
                                    BootstrapAlert.success({
                                      title: "Success!",
                                      message: "Next Action Closed Comment add Successfully"
                                    }); 
                                    
                                    var insert="";
                                    insert+='<div class="row">';
                                        insert+='<div class="col-md-2"></div>';
                                        insert+='<div class="col-md-10" style="padding:20px 0px;">';
                                            insert+='<b><span style="color:#54585b;">Sales cycle closed</span></b> - <a style="color:#6699cc;cursor:pointer;" onclick="reopenthenextaction()">Reopen</a> or'; 
                                            insert+='<a style="color:#6699cc;cursor:pointer;" onclick="editnewclosingcommentui()"> Edit closing comment</a>';
                                            insert+='<br>';
                                            if(closingcomment!=""){
                                                insert+='<b>'+closingcomment+'</b><br>';   
                                            }
                                            insert+='<span style="color: #666;font-size: 13px;font-family: Open Sans Italic, Arial, Helvetica, sans-serif;"><i>Next Action process closed for me on &nbsp;</i>'+closingdate+'</span>';
                                        insert+='</div>';
                                        insert+='<input type="hidden" id="closingdate" value="'+closingdate+'">';
                                        insert+='<input type="hidden" id="closingcomment" value="'+closingcomment+'">';
                                        insert+='<span class="pull-right"  onclick=shownextactionqueue("#newnextactionadd") >';
                                            insert+='<span class="add_new_action" style="margin-right:10px;"></span>';
                                        insert+='</span>';
                                    insert+='</div>';
                                    $("#next_action").html(insert);
                                }
                            });
                        }else{
                            $("#closecomment").focus();
                            BootstrapAlert.warning({
                              title: "Warning!",
                              message: "Please enter the comment"
                            }); 
                        }
                    }
                </script>
                <script>
                    function canceltopnextactioncompleted(nid2,desc,date1,time1,assign,selectoption){
                        
                        status="pending";
                        $.ajax({
                            url:"activestream_intermediate.php",
                            type:"post",
                            data:{pendingnextaction:nid2, status:status},
                            success:function(respond){
                                //swal("Next Action InCompleted Successfully","","success");
                                
                            }
                        });
                
                        var desc2=$(desc).val();
                        var date2=$(date1).val();
                        var time2=$(time1).val();
                        var assignid2=$(assign).val();
                        var selectoption2=$(selectoption).val();
                        var date5="<?php echo date('Y-m-d');?>";
                        var insert1="";
                        insert1+='<div class="row">';
                            insert1+='<div class="col-md-2">';
                                insert1+='<br>';
                                insert1+='<div class="checkbox pull-right" style="padding-top:10px;">';
                                    insert1+='<label class="container1">';
                                        insert1+='<input type="checkbox" value="" id="checkbox_id" onchange=checkitscompletedtop("#checkbox_id","'+nid2+'","#na_f_desc'+nid2+'","#na_f_date'+nid2+'","#na_f_time'+nid2+'","#na_f_assign'+nid2+'","#na_f_select'+nid2+'")>';
                                        insert1+='<span class="checkmark" ></span>';
                                    insert1+='</label>';
                                insert1+='</div>';
                            insert1+='</div>';
                            insert1+='<div class="col-md-10">';
                                insert1+='<h5>Next Action';
                                insert1+='<span class="pull-right" style="color:grey;cursor:pointer;" onclick=editfirstnextaction("na_f_desc'+nid2+'","na_f_date'+nid2+'","na_f_time'+nid2+'","na_f_assign'+nid2+'","na_f_select'+nid2+'","'+nid2+'")>Edit</span></h5>';
                                insert1+='<input type="hidden" id="na_f_desc'+nid2+'" value="'+desc2+'">';
                                insert1+='<input type="hidden" id="na_f_date'+nid2+'" value="'+date2+'">';
                                insert1+='<input type="hidden" id="na_f_time'+nid2+'" value="'+time2+'">';
                                insert1+='<input type="hidden" id="na_f_select'+nid2+'" value="'+selectoption2+'">';
                                insert1+='<input type="hidden" id="na_f_assign'+nid2+'" value="'+assignid2+'">';
                                insert1+='<b>'+desc2+'</b>';
                                insert1+='<div class="row" style="padding:10px 0px 10px 0px;">';
                                    insert1+='<div class="col-sm-8" style="padding:0px;">';
                                         if(selectoption2=="Queued"){
                                            insert1+='<div class="nextaction_queued_css1">';
                                                insert1+='<span style="margin-left:10px;">';
                                                    insert1+='Queued';
                                                insert1+='</span>';
                                            insert1+='</div>';
                                        }else if(selectoption2=="ASAP"){
                                            insert1+='<div class="nextaction_asap_css1">';
                                                insert1+='<span style="margin-left:10px;">';
                                                    insert1+='ASAP&nbsp;&nbsp;&nbsp;&nbsp;';
                                                insert1+='</span>';
                                            insert1+='</div>';
                                        }else if(selectoption2=="Waiting"){
                                            insert1+='<div class="nextaction_waiting_css1">';
                                                insert1+='<span style="margin-left:10px;">';
                                                    insert1+='Waiting';
                                                insert1+='</span>';
                                            insert1+='</div>';
                                        }else if(date2<date5){
                                            var monthNames = ["", "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"];
                                            var todate=new Date();
                                            var d=todate.getDate();
                                            var m=todate.getMonth()+1;
                                            var y=todate.getFullYear();
                                            if(m<10){
                                                m="0"+m;
                                            }
                                            var d1=y+"-"+m+"-"+d;
                                            var date3=date2;
                                            var date123=date3.split("-")
                                            var m3=date123[1];
                                            if(m3[0]=="0"){
                                                m1=m3[1];
                                            }else{
                                                m1=m3;
                                            }
                                            insert1+='<div class="nextaction_date_css1">';
                                                insert1+='<span style="margin-left:10px;">';
                                                    if (date2!="0000-00-00") {
                                                        insert1+=monthNames[m1]; 
                                                        insert1+="&nbsp;&nbsp;"+d; 
                                                    }else{ 
                                                        insert1+="Queued"; 
                                                    }
                                                insert1+='</span>';
                                            insert1+='</div>';
                                        }else{
                                        
                                            var monthNames = ["", "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"];
                                            var todate=new Date();
                                            var d=todate.getDate();
                                            var m=todate.getMonth()+1;
                                            var y=todate.getFullYear();
                                            if(m<10){
                                                m="0"+m;
                                            }
                                            var d1=y+"-"+m+"-"+d;
                                            var date3=date2;
                                            var date123=date3.split("-")
                                            var m3=date123[1];
                                            if(m3[0]=="0"){
                                                m1=m3[1];
                                            }else{
                                                m1=m3;
                                            }
                                            insert1+='<div class="nextaction_date1_css1">';
                                                insert1+='<span style="margin-left:10px;">';
                                                    if (date2!="0000-00-00") {
                                                        insert1+=monthNames[m1];
                                                        insert1+="&nbsp;&nbsp;"+d; 
                                                    }else{ 
                                                        insert1+="Queued"; 
                                                    }
                                                insert1+='</span>';
                                            insert1+='</div>';
                                        } 
                                    insert1+='</div>';
                                    insert1+='<div class="col-sm-4">';
                                    insert1+='<span class="pull-right"  onclick=shownextactionqueue("#newnextactionadd")>';
                                    insert1+='<span class="add_new_action"></span>';
                                    insert1+='</span>';
                                    insert1+='</div>';
                                insert1+='</div>';
                            insert1+='</div>';
                        insert1+='</div>';
                        $("#next_action").html(insert1);
                    
                    }
                </script>
                <!-- end next action script page -->
    </body>
</html>