<?php
session_start();
include ('sesssion_clear.php');
$adminemailid=$_SESSION['emailid'];
$companyname=$_SESSION['companyname'];
$companytype=$_SESSION['companytype'];
$employeetype=$_SESSION['employeetype'];
require_once ('../Control/sales.php');
$sales_ctrl_obj=new salesctrl();
$sales_sign_res=$sales_ctrl_obj->salesselectall($companyname, $adminemailid, "signupdetails", "no");
$sales_status_res=$sales_ctrl_obj->salesselectall($companyname, $adminemailid, "sales_status", "no");
$sales_lead_res=$sales_ctrl_obj->salesselectall($companyname, $adminemailid, "sales_lead_source", "no");
$sales_tag_res=$sales_ctrl_obj->salesselectall($companyname, $adminemailid, "sales_tag", "no");
$sales_filter_res=$sales_ctrl_obj->salesselectall($companyname, $adminemailid, "sales_filter", "no");
?>
<html>
    
    <head>
        
        <link rel="icon" href="../../Images/cloud-icon-27.png">
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="../../Bootstrap/css/bootstrap.min.css">
        <script src="../../Bootstrap/jquery.min.js"></script>
        <script src="../../Bootstrap/js/bootstrap.min.js"></script>
        <script src="../../Bootbox/bootbox.min.js"></script>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-sweetalert/1.0.1/sweetalert.min.css">
        <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-sweetalert/1.0.1/sweetalert.min.js"></script>
        <script src="../../Js/bootstrapAlert.js"></script>
        <link href="../../font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet">
        <link href="deal_action_stream.css" rel="stylesheet">
        <script src="deal_action_stream.js"></script>
        
        <link href="../../Clockpicker/bootstrap-clockpicker.min.css" rel="stylesheet" type="text/css" />
        <link href="../../Clockpicker/github.min.css" rel="stylesheet" type="text/css" />
        <script src="../../Clockpicker/jquery-clockpicker.min.js"></script>
    
        <link href="../../Datepicker/bootstrap-datepicker.css" rel="stylesheet" type="text/css" />
        <script src="../../Datepicker/bootstrap-datepicker.js"></script>
    
        
        <link rel="stylesheet" href="../../Selectpicker/bootstrap-select.min.css">
        <link rel="stylesheet" href="../../Selectpicker/bootstrap-select.css.map">
        <script src="../../Selectpicker/bootstrap-select.js"></script>
        <script src="../../Selectpicker/bootstrap-select.js.map"></script>
        
        <style>
::-webkit-scrollbar {
    width: .1em;
    height: .1em
}
            body {
                min-width: 1030px;
                overflow: hidden;
            }
            
            html, body {
                margin: 0;
                padding: 0;
                width: 100%;
                height: 95%;
                font-family: "Open Sans", Arial, Helvetica, sans-serif;
                font-size: 14px;
                line-height: 130%;
                color: #333;
                background-color: #fff;
                -webkit-user-select: auto;
            }
             .menu>li.sales a:hover:before{
                background-position: -40px 0;
            }
            .menu>li.sales a.active:before {
                background-position: -40px 0;
            }
             .menu>li.sales a:before {
                width: 13px;
                height: 11px;
                background-position: -20px 0;
                top: 5px;
                left: 27px;
            }
             .menu>li.sales a:after {
                width: 13px;
                height: 11px;
                background-position: -20px 0;
                top: 5px;
                left: 27px;
            }
             .menu>li.activity a:hover:before{
                background-position: -80px 0;
            }
            .menu>li.activity a.active:before {
                background-position: -80px 0;
            }
             .menu>li.activity a:before {
                width: 13px;
                height: 11px;
                background-position: -20px 0;
                top: 3px;
                left: 23px;
            }
            .menu>li.sales a:before {
                background: url(Image/pipelinemenu.png) no-repeat 0 0 transparent;
                width: 18px;
                height: 18px;
                display: block;
                position: absolute;
                content: "";
                background-position: -20px 0;
            }
            .menu>li.activity a:before {
                background: url(Image/pipelinemenu.png) no-repeat 0 0 transparent;
                width: 18px;
                height: 18px;
                display: block;
                position: absolute;
                content: "";
                background-position: -60px 0px;
            }
             .menu>li.user a:hover:before{
                background-position: -80px 0;
            }
            .menu>li.user a.active:before {
                background-position: -80px 0;
            }
             .menu>li.user a:before {
                width: 13px;
                height: 11px;
                background-position: -20px 0;
                top: 3px;
                left: 23px;
            }
            .menu>li.user a:before {
                background: url(Image/activity_icons.png) no-repeat 0 0 transparent;
                width: 18px;
                height: 18px;
                display: block;
                position: absolute;
                content: "";
                background-position: -16px -61px;
            }
            .left-link {
                width: 183px;
                padding: 7px 0px 7px 0px;
                width: 135px;
                display: block;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
            }
            .left-link:hover{
                background: #ecf6fd;
                cursor:pointer;
            }
            .my_team{
                max-height:100%;
                background-color: #F5F5F5;
            }
             iframe
            {
                border:none;
                overflow-x: hidden;
            }
            @media only screen and (max-width: 1000px)  {
                body {
                    overflow-x: visible;
                }
            }
        </style>
    </head>
    
    <body scrolling="no">
        <nav id="mainNav" class="navbar navbar-inverse  navbar-fixed-top">
        <div class="container">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header page-scroll">
                 <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>                        
      </button>
                <a href="#page-top"><img alt="Cloud" src="http://fieldcloud.in/Web/Images/cloud-icon-27.png" width="50px" height="50px"> <span style="font-size:2em;color: White;"> Field</span><span style="font-size:2em;color: orange;">Cloud</span></a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                
                 <ul class="nav navbar-nav navbar-right menu">
                    <li>
                        <a class="page-scroll pull-left" href="dashboard.php">Action Stream</a>
                    </li>
                    <li>
                        <a class="page-scroll pull-left" style="color:white;">Contact</a>
                    </li>
                    <li class="sales">
                        <a style="top:5px;" href="pipeline_view.php">Pipeline</a>
                    </li>
                    <li class="activity">
                        <a style="top:5px;"  href="activity_all.php">Activity</a>
                    </li>
                    <?php
                    if($employeetype=="admin"){
                    ?>
                    <li class="user">
                        <a style="top:5px;"  href="user_dashboard.php">User</a>
                    </li>
                    <?php
                    }
                    ?>
                    
                    
                    <li>
                    <a href="logout.php">Logout</a>
                    </li>
                    <?php
                    if((strpos($companytype, 'Service') !== false)||(strpos($companytype, 'Project') !== false)||(strpos($companytype, 'Task') !== false)){
                    ?>
                    <li>
                    <a  href="../../../home.php">Switch to Home</a>
                    </li>
                    <?php
                    }
                    ?>
                    </ul>
                    
                    </li>
                    </ul>
            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container-fluid -->
    </nav>
        <div class="" style="">
            <div class="row" style="height:100%;width:100%;margin-top:60px;">
                <div class="col-md-1 hidden-sm"></div>
                <div class="col-xs-2">
                    <div class="navbar-header page-scroll">
                        <input type="button" name="addcontact" id="addcontact" class="btn btn-default" value="Add Contact"> 
                        <span class="my_team">
                            <div class="left-link" id="allcontact"><b>All Contact</b></div>
                            <div class="left-link" id="asapcontact">ASAP</div>
                            <div class="left-link" id="waitingcontact">Waiting</div>
                            <div class="left-link" id="starcontact">Starred</div>
                            <div class="left-link" id="showteamicon"><i class="fa fa-caret-right" aria-hidden="true"></i>Team's Contact</div>
                            <div class="left-link" style="display:none;" id="hideteamicon"><i class="fa fa-caret-down" aria-hidden="true"></i>&nbsp;Team's Contact</div>
                            <div id="showteam" style="margin-left:8px;display:none;" >
                                <?php
                    		    foreach($sales_sign_res as $sales_sign_row){
                    		        $status_name=$sales_sign_row['employeename'];
                    		        $s_id=$sales_sign_row['emailid'];
                                    $status_res=$sales_ctrl_obj->salesselectstatustagleadsourceteamstream("teamstream", $s_id);
                                    $c=$status_res->rowCount();
                    		    ?>
                    			<div class="left-link" onclick="SideMenuFunctionsales('teamstream','<?php echo $s_id?>','<?php echo $c?>')"><?php echo $status_name?>&nbsp;&nbsp;(<?php echo $c?>)</div>
                    		    <?php
                    		    }
                     		    ?>
                     		    
                            </div>
                            <div class="left-link" id="showstatusicon">
                                <i class="fa fa-caret-right" aria-hidden="true"></i>Status
                            </div>
                            <div class="left-link" id="hidestatusicon" style="display:none;">
                                <i class="fa fa-caret-down" aria-hidden="true"></i>&nbsp;Status
                            </div>
                            <div id="showstatus" style="margin-left:8px;display:none;" >
                                <?php
                    		    foreach($sales_status_res as $sales_status_row){
                    		        $status_name=$sales_status_row['status_name'];
                    		        $s_id=$sales_status_row['id'];
                                    $status_res=$sales_ctrl_obj->salesselectstatustagleadsourceteamstream("status", $s_id);
                                    $c=$status_res->rowCount();
                    		    ?>
                    			<div class="left-link" onclick="SideMenuFunctionsales('status','<?php echo $s_id?>','<?php echo $c?>')"><?php echo $status_name?>(<?php echo $c?>)</div>
                    		    <?php
                    		    }
                     		    ?>
                                <div class="left-link"><a onclick="SideMenuFunctionstatusmanger()">Manage...</a></div>
                            </div>
                            <div class="left-link" id="showtagicon">
                                <i class="fa fa-caret-right" aria-hidden="true"></i>Tag
                            </div>
                            <div class="left-link" id="hidetagicon" style="display:none;">
                                <i class="fa fa-caret-down" aria-hidden="true"></i>&nbsp;Tag
                            </div>
                            <div id="showtag" style="margin-left:8px;display:none;" >
                                <?php
                    		    foreach($sales_tag_res as $sales_tag_row){
                    		        $tag_name=$sales_tag_row['tag_name'];
                    		        $t_id=$sales_tag_row['id'];
                                    $tag_res=$sales_ctrl_obj->salesselectstatustagleadsourceteamstream("tag", $t_id);
                                    $t=$tag_res->rowCount();
                    		    ?>
                    			<div class="left-link" onclick="SideMenuFunctionsales('tag','<?php echo $t_id?>','<?php echo $t?>')"><?php echo $tag_name?>(<?php echo $t?>)</div>
                    		    <?php
                    		    }
                     		    ?>
                                <div class="left-link"><a onclick="SideMenuFunctiontagmanger()">Manage...</a></div>
                            </div>
                            <div class="left-link" id="showleadicon"><i class="fa fa-caret-right" aria-hidden="true"></i>Lead Source</div>
                            <div class="left-link"  style="display:none;" id="hideleadicon"><i class="fa fa-caret-down" aria-hidden="true"></i>&nbsp;Lead Source</div>
                            <div id="showlead" style="margin-left:8px;display:none;" >
                                <?php
                                foreach($sales_lead_res as $sales_lead_row){
                                    $lead_name=$sales_lead_row['lead_name'];
                                    $l_id=$sales_lead_row['id'];
                                    $lead_res=$sales_ctrl_obj->salesselectstatustagleadsourceteamstream("leadsource", $l_id);
                                    $l=$lead_res->rowCount();
                                ?>
                            	<div class="left-link" onclick="SideMenuFunctionsales('lead source','<?php echo $l_id?>','<?php echo $l?>')"><?php echo $lead_name?>(<?php echo $l?>)</div>
                                <?php
                                }
                                ?>
                                <div class="left-link"><a onclick="SideMenuFunctionleadsourcemanger()">Manage...</a></div>
                            </div>
                            <div class="left-link" id="showfiltericon"><i class="fa fa-caret-right" aria-hidden="true"></i>Filter</div>
                            <div class="left-link" style="display:none;" id="hidefiltericon"><i class="fa fa-caret-down" aria-hidden="true"></i>&nbsp;Filter</div>
                            <div id="showfilter" style="margin-left:8px;display:none;" >
                                <?php
                        	    foreach($sales_filter_res as $sales_filter_row){
                        	        $filter_name=$sales_filter_row['filter_name'];
                        	        $filtersql=$sales_filter_row['id'];
                        	    ?>
                        		<div class="left-link" onclick=SideMenuFunctionsales1('filter','<?php echo $filtersql?>')><?php echo $filter_name?></div>
                        	    <?php
                        	    }
                         	    ?>
                                <div class="left-link"><a onclick="SideMenuFunctionfiltermanger()">Manage...</a></div>
                            </div>
                        </span>
                    </div>
                </div>
                <div class="col-md-9 col-xs-10">
                    <iframe  height="98%" width="100%" src="contactlist.php" name="loadpage" id="loadpage"></iframe>
                </div>
            </div>
        </div>
        
<script>
    function SideMenuFunctionsales(check, sid, value){
        $("#mymodal_service").modal('hide');
        $("#mymodal_hcm").modal('hide');
        $("#mymodal_sales").modal('hide'); 
        $("#mymodal_project").modal('hide');
        $("#mymodal_profile").modal('hide');
        if(value!=0){
            if(check=="teamstream"){
                var path="employee_active_stream.php?sid="+sid;
                $("#loadpage").attr("src", path);
            }
            if(check=="status"){
                var path="status_active_stream.php?sid="+sid;
                $("#loadpage").attr("src", path);
            }
            if(check=="tag"){
                var path="tag_active_stream.php?sid="+sid;
                $("#loadpage").attr("src", path);
            }
            if(check=="lead source"){
                var path="lead_active_stream.php?sid="+sid;
                $("#loadpage").attr("src", path);
            }
        }
    }
</script>   
        
<script>
    function SideMenuFunctionsales1(check, sid){
        $("#mymodal_service").modal('hide');
        $("#mymodal_hcm").modal('hide');
        $("#mymodal_sales").modal('hide'); 
        $("#mymodal_project").modal('hide');
        $("#mymodal_profile").modal('hide');
        if(check=="filter"){
            var path="filter_view.php?sid="+sid;
            $("#loadpage").attr("src", path);
        }
    }
</script>    
<script>
    function SideMenuFunctionstatusmanger(){
        var path="updatestatus.php";
        $("#loadpage").attr("src", path);
    }
    function SideMenuFunctiontagmanger(){
        var path="updatetag.php";
        $("#loadpage").attr("src", path);
    }
    function SideMenuFunctionleadsourcemanger(){
        var path="updateleadsource.php";
        $("#loadpage").attr("src", path);
    }
    function SideMenuFunctionfiltermanger(){
        var path="filter_add.php";
        $("#loadpage").attr("src", path);
    }
    function SideMenuFunctionusermanger(){
        /*var path="filter_view.php";
        $("#loadpage").attr("src", path);*/
    }
</script>
        
        <script>
            $(document).on("click", "#addcontact", function(){
                $("#loadpage").attr("src", "addcontact.php");
            });
            $(document).on("click", "#allcontact", function(){
                $("#loadpage").attr("src", "contactlist.php");
            });
            $(document).on("click", "#starcontact", function(){
                $("#loadpage").attr("src", "star_active_stream.php");
            });
            $(document).on("click", "#waitingcontact", function(){
                $("#loadpage").attr("src", "waiting_active_stream.php");
            });
            $(document).on("click", "#asapcontact", function(){
                $("#loadpage").attr("src", "asap_active_stream.php");
            });
        </script>
        <script>
            $(document).on("click", "#showteamicon", function(){
                $("#showteamicon").hide();
                $("#hideteamicon").show();
                $("#showteam").show();
                
                $("#hidestatusicon").hide();
                $("#showstatusicon").show();
                $("#showstatus").hide();
                
                $("#hideleadicon").hide();
                $("#showleadicon").show();
                $("#showlead").hide();
                
                $("#hidetagicon").hide();
                $("#showtagicon").show();
                $("#showtag").hide();
                
                $("#hidefiltericon").hide();
                $("#showfiltericon").show();
                $("#showfilter").hide();
            });
            $(document).on("click", "#hideteamicon", function(){
                $("#hideteamicon").hide();
                $("#showteamicon").show();
                $("#showteam").hide();
            });
            $(document).on("click", "#showstatusicon", function(){
                $("#showstatusicon").hide();
                $("#hidestatusicon").show();
                $("#showstatus").show();
                
                $("#hideteamicon").hide();
                $("#showteamicon").show();
                $("#showteam").hide();
                
                $("#hideleadicon").hide();
                $("#showleadicon").show();
                $("#showlead").hide();
                
                $("#hidetagicon").hide();
                $("#showtagicon").show();
                $("#showtag").hide();
                
                $("#hidefiltericon").hide();
                $("#showfiltericon").show();
                $("#showfilter").hide();
            });
            $(document).on("click", "#hidestatusicon", function(){
                $("#hidestatusicon").hide();
                $("#showstatusicon").show();
                $("#showstatus").hide();
            });
            $(document).on("click", "#showleadicon", function(){
                $("#showleadicon").hide();
                $("#hideleadicon").show();
                $("#showlead").show();
                
                $("#hidestatusicon").hide();
                $("#showstatusicon").show();
                $("#showstatus").hide();
                
                $("#hideteamicon").hide();
                $("#showteamicon").show();
                $("#showteam").hide();
                
                $("#hidetagicon").hide();
                $("#showtagicon").show();
                $("#showtag").hide();
                
                $("#hidefiltericon").hide();
                $("#showfiltericon").show();
                $("#showfilter").hide();
            });
            $(document).on("click", "#hideleadicon", function(){
                $("#hideleadicon").hide();
                $("#showleadicon").show();
                $("#showlead").hide();
            });
            $(document).on("click", "#showtagicon", function(){
                $("#showtagicon").hide();
                $("#hidetagicon").show();
                $("#showtag").show();
                
                $("#hidestatusicon").hide();
                $("#showstatusicon").show();
                $("#showstatus").hide();
                
                $("#hideleadicon").hide();
                $("#showleadicon").show();
                $("#showlead").hide();
                
                $("#hideteamicon").hide();
                $("#showteamicon").show();
                $("#showteam").hide();
                
                $("#hidefiltericon").hide();
                $("#showfiltericon").show();
                $("#showfilter").hide();
            });
            $(document).on("click", "#hidetagicon", function(){
                $("#hidetagicon").hide();
                $("#showtagicon").show();
                $("#showtag").hide();
            });
            $(document).on("click", "#showfiltericon", function(){
                $("#showfiltericon").hide();
                $("#hidefiltericon").show();
                $("#showfilter").show();
                
                $("#hidestatusicon").hide();
                $("#showstatusicon").show();
                $("#showstatus").hide();
                
                $("#hideleadicon").hide();
                $("#showleadicon").show();
                $("#showlead").hide();
                
                $("#hidetagicon").hide();
                $("#showtagicon").show();
                $("#showtag").hide();
                
                $("#hideteamicon").hide();
                $("#showteamicon").show();
                $("#showteam").hide();
            });
            $(document).on("click", "#hidefiltericon", function(){
                $("#hidefiltericon").hide();
                $("#showfiltericon").show();
                $("#showfilter").hide();
            });
        </script>
    </body>
</html>