<?php
session_start();
$companyname=$_SESSION['companyname'];//;
$adminemailid=$_SESSION['emailid'];//;
$companymailid=$_SESSION['companymailid'];
include('sesssion_clear.php');
include('../Model/configuration.php');
if(($adminemailid !="")&&($companyname!="")){
require_once('../Control/sales.php');
$objsales=new salesctrl();
require_once('../Control/pipeline.php');
$objpipeline=new pipelinectrl();
$pipelinetype_res=$objsales->salesselectall($companyname, $companymailid, "sales_pipe_type", "no");
$i=0;
$pipe_name=array();
$pipe_percentage=array();
foreach($pipelinetype_res as $pipelinetype_row){
    $pipe_id[$i]=$pipelinetype_row['id'];
    $pipe_name[$i]=$pipelinetype_row['pipe_name'];
    $pipe_percentage[$i]=$pipelinetype_row['pipe_percentage'];
    //echo $pipelinetype_row['pipe_percentage'];
    $i++;
}
//print_r($pipe_name);

/*$pipelinetype_res=$objpipeline->salespipelinedeal($companyname,"");
$emp_res=$objsales->salesselectall($companyname, $adminemailid, "signupdetails", "no");
//print_r($emp_res);
$j=0;*/
/*foreach($emp_res as $emp_row){
 $emp_emailid_a[$j++]=$emp_row['emailid'];   
}*/
$emp_emailid_a[0]=$adminemailid;
$emp_count= count($emp_emailid_a);
//print_r($emp_emailid_a);
?>

<!doctype html>
<html>
    <head>
    
        <link rel="icon" href="../../Images/cloud-icon-27.png">
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="../../Bootstrap/css/bootstrap.min.css">
        <script src="../../Bootstrap/jquery.min.js"></script>
        <script src="../../Bootstrap/js/bootstrap.min.js"></script>
        <script src="../../Bootbox/bootbox.min.js"></script>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-sweetalert/1.0.1/sweetalert.min.css">
        <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-sweetalert/1.0.1/sweetalert.min.js"></script>
        
    <!-- data Table -->
<link rel="stylesheet" type="text/css" href="http://www.fieldcloud.in/Web/DataTable/Css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="http://www.fieldcloud.in/Web/DataTable/Css/buttons.bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="http://www.fieldcloud.in/Web/DataTable/Css/dataTables.bootstrap.min.css"/>


<link rel="stylesheet" type="text/css" href="http://www.fieldcloud.in/Web/DataTable/hide/responsive.bootstrap.min.css"/>

<script type="text/javascript" src="http://www.fieldcloud.in/Web/DataTable/Js/jquery-1.12.4.js"></script>
<script type="text/javascript" src="http://www.fieldcloud.in/Web/DataTable/Js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="http://www.fieldcloud.in/Web/DataTable/Js/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src="http://www.fieldcloud.in/Web/DataTable/Js/dataTables.buttons.min.js"></script>
<script type="text/javascript" src="http://www.fieldcloud.in/Web/DataTable/Js/buttons.bootstrap.min.js"></script>
<script type="text/javascript" src="http://www.fieldcloud.in/Web/DataTable/Js/jszip.min.js"></script>
<script type="text/javascript" src="http://www.fieldcloud.in/Web/DataTable/Js/pdfmake.min.js"></script>
<script type="text/javascript" src="http://www.fieldcloud.in/Web/DataTable/Js/vfs_fonts.js"></script>
<script type="text/javascript" src="http://www.fieldcloud.in/Web/DataTable/Js/buttons.html5.min.js"></script>
<script type="text/javascript" src="http://www.fieldcloud.in/Web/DataTable/Js/buttons.print.min.js"></script>
<script type="text/javascript" src="http://www.fieldcloud.in/Web/DataTable/Js/buttons.colVis.min.js"></script>
   
<style>
    #pipeline1{
        background: #db1b56;
        height: 40px;
        display: block;
        color: #ffffff;
        font-size: 21px;
        font-family: "Open Sans Bold", Arial, Helvetica, sans-serif;
        font-weight: normal;
        line-height: 0.7;
        padding: 9px 0 0px 0;
        margin: 0 -10px;
        -webkit-border-radius: 4px;
        -moz-border-radius: 4px;
        border-radius: 4px;
        box-sizing: border-box;
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        -ms-box-sizing: border-box;
    }
    #pipeline2{
        background: #9999cc;
        height: 50px;
        display: block;
        color: #ffffff;
        font-size: 21px;
        font-family: "Open Sans Bold", Arial, Helvetica, sans-serif;
        font-weight: normal;
        line-height: 0.6;
        padding: 9px 0 0px 0;
        margin: 0 -10px;
        -webkit-border-radius: 4px;
        -moz-border-radius: 4px;
        border-radius: 4px;
        box-sizing: border-box;
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        -ms-box-sizing: border-box;
    }
    #pipeline3{
        background: #c6c3be;
        height: 40px;
        display: block;
        color: #ffffff;
        font-size: 21px;
        font-family: "Open Sans Bold", Arial, Helvetica, sans-serif;
        font-weight: normal;
        line-height: 0.6;
        padding: 9px 0 0px 0;
        margin: 0 -10px;
        -webkit-border-radius: 4px;
        -moz-border-radius: 4px;
        border-radius: 4px;
        box-sizing: border-box;
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        -ms-box-sizing: border-box;
    }
</style>    
<style>
	.modal.left .modal-dialog,
	.modal.right .modal-dialog {
		position: fixed;
		margin: auto;
		padding-top:50px;
		width: 80%;
		height: 98%;
		-webkit-transform: translate3d(0%, 0, 0);
		    -ms-transform: translate3d(0%, 0, 0);
		     -o-transform: translate3d(0%, 0, 0);
		        transform: translate3d(0%, 0, 0);
	}

	.modal.left .modal-content,
	.modal.right .modal-content {
		height: 100%;
		overflow-y: auto;
	}
	
	.modal.left .modal-body,
	.modal.right .modal-body {
		padding: 15px 15px 80px;
	}

        
/*Right*/
	.modal.right.fade .modal-dialog {
		right: -80%;
		-webkit-transition: opacity 0.3s linear, right 0.3s ease-out;
		   -moz-transition: opacity 0.3s linear, right 0.3s ease-out;
		     -o-transition: opacity 0.3s linear, right 0.3s ease-out;
		        transition: opacity 0.3s linear, right 0.3s ease-out;
	}
	
	.modal.right.fade.in .modal-dialog {
		right: 0;
	}


</style>

        <style>
            body {
                min-width: 1030px;
                height: 97%;
                width: 100%;
            }
            
            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;
            }
            .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 style="padding-top:50px;background-color:#f6f6f6">
       
        <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="employee_dashboard.php">Action Stream</a>
                    </li>
                    <li>
                        <a class="page-scroll pull-left" href="employee_dashboard_contact.php">Contact</a>
                    </li>
                    <li class="sales">
                        <a style="top:5px;color:white;">Pipeline</a>
                    </li>
                    <li class="activity">
                        <a style="top:5px;" href="employee_activity_all.php" >Activity</a>
                    </li>
                    
                    
                    <li>
                    <a href="logout.php">Logout</a>
                    </li>
                    
                    <li>
                    <?php if((strpos($companytype,'Project') !== false) || (strpos($companytype,'Service') !== false)){ ?>
                    <li>
                    <a  href="../../../home.php">Switch to Home</a>
                    </li>
                    <?php } ?>
                    </ul>
                    
                    </li>
                    </ul>
            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container-fluid -->
    </nav>
<!-- Modal -->
<div id="modalpipeline" class="modal fade" role="dialog">
  <div class="modal-dialog modal-lg">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-body">
          <div class="row">
            <div class="col-md-7">
                <span style="font-size:20px;font-family: 'Times New Roman', Times, serif;"><b><center>Add/Edit funnel stages</center></b></span>
            </div>
            <div class="col-md-5">
             <button type="button" class="close" data-dismiss="modal">&times;</button>
            </div>
         </div>
        <div id="addpipelineeditpage" ></div>
        <br><br>
        <center>
            <input type="submit" class="btn btn-primary" onclick="submitpipelineedit()" value="Save">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </center>
      </div>
    </div>

  </div>
</div>

<script>
    function submitpipelineedit(){
        /*pipe_id4 pipe_stage4 pipe_name4
        if()*/
    }
</script>

        <script>
            function modelboxpipeline(){
                $("#addpipelineeditpage").load('pipeline_edit.php');
            }
        </script>
        <!--<div class="row" style="padding-top: 30px;height: 72px;padding-left:100px;padding-right:100px;border-bottom:2px solid grey">
            <span class="pull-right" >
                <span onclick="modelboxpipeline()"  data-toggle="modal" data-target="#modalpipeline" style="color:#999;"><i class="glyphicon glyphicon-pencil"></i> &nbsp;Edit</span>
            </span>
        </div>-->
        
        <script>
            function funcshowrecord1(id1, id2, id3){
                $(id1).show();
                $(id2).hide();
                $(id3).hide();
                $("#btnm1").addClass("active");
                $("#btnm2").removeClass("active");
                $("#btnm3").removeClass("active");
                
            }
            
            function funcshowrecord2(id1, id2, id3){
                $(id1).show();
                $(id2).hide();
                $(id3).hide();
                $("#btnm2").addClass("active");
                $("#btnm1").removeClass("active");
                $("#btnm3").removeClass("active");
                
            }
            
            function funcshowrecord3(id1, id2, id3){
                $(id1).show();
                $(id2).hide();
                $(id3).hide();
                $("#btnm3").addClass("active");
                $("#btnm2").removeClass("active");
                $("#btnm1").removeClass("active");
                
            }
        </script>
<?php

$mon=date('m');
$yea=date('Y');


$month=date('M');
$year=date('Y');
$months=$year."-".$month."-01";

?>
        <div style="background-color:#f6f6f6">
            
            <div class="summary" style="padding: 0px 100px ;">
                
                
                <div style="border:1px solid #D5D5D5;padding:5px;">  
                    <div class="row">
                        <div class="col-sm-3"style="padding-top:5px;font-size:25px;">
                           <center> Months </center>
                            <!--<button onclick="funcshowrecord1('#monthlyshow','#quarterlyshow','#yearlyshow')" id="btnm1" class="btn btn-default active" style="margin-left:0px">Month</button>
                            <button onclick="funcshowrecord2('#quarterlyshow','#monthlyshow','#yearlyshow')" id="btnm2" class="btn btn-default" style="margin-left:-6px">Quarter</button>
                            <button onclick="funcshowrecord3('#yearlyshow','#quarterlyshow','#monthlyshow')" id="btnm3" class="btn btn-default" style="margin-left:-6px">Year</button>-->
                        </div>
                        <div class="col-sm-9" id="monthlyshow">
                              <div id="my-month">
                            <div class="col-sm-2" style="padding:5px 0px;border-right:1px solid #D5D5D5;">
                                <button id="m1" class="btn btn-default pull-right" next_month="<?php echo date('M',strtotime('-2 month')); ?>" my_year="<?php echo date('Y',strtotime('-2 month'));?>"  style="display:inline;padding:5px;border:none;background-color:#f6f6f6;"><b><?php echo date('M',strtotime('-2 month')); ?>&nbsp;&nbsp;<?php echo date('Y',strtotime('-2 month'));?></b></button>
                                <button class="btn btn-primary pull-left" onclick="previewsrecordmonth()" style="display:inline;padding:5px;"><i class="glyphicon glyphicon-triangle-left"></i></button>
                            </div>
                            <div class="col-sm-2" style="padding:5px 0px;border-right:1px solid #D5D5D5;">
                                <center><button id="m2" class="btn btn-default"  style="display:inline;padding:5px;border:none;background-color:#f6f6f6;"><b><?php echo date('M', strtotime('-1 month')); ?>&nbsp;&nbsp;<?php echo date('Y', strtotime('-1 month')); ?></b></button></center>
                            </div>
                            <div class="col-sm-2" style="padding:5px 0px;border-right:1px solid #D5D5D5;">
                                <center><button id="m3" class="btn btn-default" style="display:inline;padding:5px;border:none;background-color:#f6f6f6;"><b><?php echo date("M"); ?>&nbsp;&nbsp;<?php echo date('Y'); ?></b></button></center>
                            </div>
                            <div class="col-sm-2" style="padding:5px 0px;border-right:1px solid #D5D5D5;">
                                <center><button id="m4" class="btn btn-default" style="display:inline;padding:5px;border:none;background-color:#f6f6f6;"><b><?php echo date('M', strtotime($month .'+1 month')); ?>&nbsp;&nbsp;<?php echo date('Y', strtotime($months .'+1 month')); ?></b></button></center>
                            </div>
                            <div class="col-sm-2" style="padding:5px 0px;border-right:1px solid #D5D5D5;">
                                <center><button id="m5" class="btn btn-default" style="display:inline;padding:5px;border:none;background-color:#f6f6f6;"><b><?php echo date('M', strtotime($month .'+2 month')); ?>&nbsp;&nbsp;<?php echo date('Y', strtotime($months .'+2 month')); ?></b></button></center>
                            </div>
                            <div class="col-sm-2" style="padding:5px 0px;">
                                <center><button id="m6" class="btn btn-default pull-left" style="display:inline;padding:5px;border:none;background-color:#f6f6f6;"><b><?php echo date('M', strtotime($month .'+3 month')); ?>&nbsp;&nbsp;<?php echo date('Y', strtotime($months .'+3 month')); ?></b></button></center>
                                <button  class="btn btn-primary pull-right" onclick="nextrecordmonth()" style="display:inline;padding:5px;"><i class="glyphicon glyphicon-triangle-right"></i></button>
                            </div>
                            </div>
                        </div>
                        <?php
                        $mm=date('m');
                        $yy=date('Y');
                        if($mm<7){
                            $Q11="Q1 ".$yy;
                            $Q12="Q2 ".$yy;
                            $Q13="Q3 ".$yy;
                            $Q14="Q4 ".$yy;
                            $Q15="Q1 ".($yy+1);
                            $Q16="Q2 ".($yy+1);
                        }else{
                            $Q11="Q3 ".$yy;
                            $Q12="Q4 ".$yy;
                            $Q13="Q1 ".($yy+1);
                            $Q14="Q2 ".($yy+1);
                            $Q15="Q3 ".($yy+1);
                            $Q16="Q4 ".($yy+1);
                        }
                        ?>
                        <div class="col-sm-9" id="quarterlyshow" style="display:none;">
                            <div class="col-sm-2" style="padding:5px 0px;border-right:1px solid #D5D5D5;">
                                <button id="q1" class="btn btn-default pull-right" style="display:inline;padding:5px;border:none;background-color:#f6f6f6;"><b><?php echo $Q11;?></b></button>
                                <button class="btn btn-primary pull-left" onclick="perviewsqrecord();" style="display:inline;padding:5px;"><i class="glyphicon glyphicon-triangle-left"></i></button>
                            </div>
                            <div class="col-sm-2" style="padding:5px 0px;border-right:1px solid #D5D5D5;">
                                <center><button id="q2" class="btn btn-default" style="display:inline;padding:5px;border:none;background-color:#f6f6f6;"><b><?php echo $Q12?></b></button></center>
                            </div>
                            <div class="col-sm-2" style="padding:5px 0px;border-right:1px solid #D5D5D5;">
                                <center><button id="q3" class="btn btn-default" style="display:inline;padding:5px;border:none;background-color:#f6f6f6;"><b><?php echo $Q13;?></b></button></center>
                            </div>
                            <div class="col-sm-2" style="padding:5px 0px;border-right:1px solid #D5D5D5;">
                                <center><button id="q4" class="btn btn-default" style="display:inline;padding:5px;border:none;background-color:#f6f6f6;"><b><?php echo $Q14;?></b></button></center>
                            </div>
                            <div class="col-sm-2" style="padding:5px 0px;border-right:1px solid #D5D5D5;">
                                <center><button id="q5" class="btn btn-default" style="display:inline;padding:5px;border:none;background-color:#f6f6f6;"><b><?php echo $Q15;?></b></button></center>
                            </div>
                            <div class="col-sm-2" style="padding:5px 0px;">
                                <center><button id="q6" class="btn btn-default pull-left" style="display:inline;padding:5px;border:none;background-color:#f6f6f6;"><b><?php echo $Q16;?></b></button></center>
                                <button  class="btn btn-primary pull-right" onclick="nextqrecord();" style="display:inline;padding:5px;"><i class="glyphicon glyphicon-triangle-right"></i></button>
                            </div>
                        </div>
                        <script>
                            function perviewsqrecord(){
                                var mm=$("#startQmonth").val();
                                var yy=$("#startQyear").val();
                                if(mm==1){
                                    var q1="Q3 "+Number(yy-2);
                                    var q2="Q4 "+Number(yy-2);
                                    var q3="Q1 "+Number(yy-1);
                                    var q4="Q2 "+Number(yy-1);
                                    var q5="Q3 "+Number(yy-1);
                                    var q6="Q4 "+Number(yy-1);
                                    $("#q1").html("<b>"+q1+"</b>");
                                    $("#q2").html("<b>"+q2+"</b>");
                                    $("#q3").html("<b>"+q3+"</b>");
                                    $("#q4").html("<b>"+q4+"</b>");
                                    $("#q5").html("<b>"+q5+"</b>");
                                    $("#q6").html("<b>"+q6+"</b>");
                                    $("#startQmonth").val(2);
                                    $("#startQyear").val(Number(yy-2));
                                    $("#endQmonth").val(1);
                                    $("#endQyear").val(Number(yy-1));
                                }else{
                                    var q1="Q1 "+Number(yy-1);
                                    var q2="Q2 "+Number(yy-1);
                                    var q3="Q3 "+Number(yy-1);
                                    var q4="Q4 "+Number(yy-1);
                                    var q5="Q1 "+(Number(yy));
                                    var q6="Q2 "+(Number(yy));
                                    $("#q1").html("<b>"+q1+"</b>");
                                    $("#q2").html("<b>"+q2+"</b>");
                                    $("#q3").html("<b>"+q3+"</b>");
                                    $("#q4").html("<b>"+q4+"</b>");
                                    $("#q5").html("<b>"+q5+"</b>");
                                    $("#q6").html("<b>"+q6+"</b>");
                                    $("#startQmonth").val(1);
                                    $("#startQyear").val(Number(yy-1));
                                    $("#endQmonth").val(2);
                                    $("#endQyear").val(Number(yy));
                                }
                            }
                            
                            function nextqrecord(){
                                var mm=$("#endQmonth").val();
                                var yy=$("#endQyear").val();
                                if(mm==2){
                                    var q1="Q3 "+(Number(yy));
                                    var q2="Q4 "+(Number(yy));
                                    var q3="Q1 "+(Number(yy)+Number(1));
                                    var q4="Q2 "+(Number(yy)+Number(1));
                                    var q5="Q3 "+(Number(yy)+Number(1));
                                    var q6="Q4 "+(Number(yy)+Number(1));
                                    $("#q1").html("<b>"+q1+"</b>");
                                    $("#q2").html("<b>"+q2+"</b>");
                                    $("#q3").html("<b>"+q3+"</b>");
                                    $("#q4").html("<b>"+q4+"</b>");
                                    $("#q5").html("<b>"+q5+"</b>");
                                    $("#q6").html("<b>"+q6+"</b>");
                                    $("#startQmonth").val(2);
                                    $("#startQyear").val(Number(yy));
                                    $("#endQmonth").val(1);
                                    $("#endQyear").val((Number(yy)+Number(1)));
                                }else{
                                    var q1="Q1 "+(Number(yy)+Number(1));
                                    var q2="Q2 "+(Number(yy)+Number(1));
                                    var q3="Q3 "+(Number(yy)+Number(1));
                                    var q4="Q4 "+(Number(yy)+Number(1));
                                    var q5="Q1 "+(Number(yy)+Number(2));
                                    var q6="Q2 "+(Number(yy)+Number(2));
                                    $("#q1").html("<b>"+q1+"</b>");
                                    $("#q2").html("<b>"+q2+"</b>");
                                    $("#q3").html("<b>"+q3+"</b>");
                                    $("#q4").html("<b>"+q4+"</b>");
                                    $("#q5").html("<b>"+q5+"</b>");
                                    $("#q6").html("<b>"+q6+"</b>");
                                    $("#startQmonth").val(1);
                                    $("#startQyear").val((Number(yy)+Number(1)));
                                    $("#endQmonth").val(2);
                                    $("#endQyear").val((Number(yy)+Number(2)));
                                }
                            }
                        </script>
                        <div class="col-sm-9" id="yearlyshow" style="display:none;" >
                            <div class="col-sm-2" style="padding:5px 0px;border-right:1px solid #D5D5D5;">
                                <button id="y1" class="btn btn-default pull-right" style="display:inline;padding:5px;border:none;background-color:#f6f6f6;"><b><?php echo $prevmonth = date('Y', strtotime('-1 years'));?></b></button>
                                <button class="btn btn-primary pull-left" onclick="perviewsrecordyear()" style="display:inline;padding:5px;"><i class="glyphicon glyphicon-triangle-left"></i></button>
                            </div>
                            <div class="col-sm-2" style="padding:5px 0px;border-right:1px solid #D5D5D5;">
                                <center><button id="y2" class="btn btn-default" style="display:inline;padding:5px;border:none;background-color:#f6f6f6;"><b><?php echo $prevmonth = date('Y');?></b></button></center>
                            </div>
                            <div class="col-sm-2" style="padding:5px 0px;border-right:1px solid #D5D5D5;">
                                <center><button id="y3" class="btn btn-default" style="display:inline;padding:5px;border:none;background-color:#f6f6f6;"><b><?php echo $prevmonth = date('Y', strtotime('1 years'));?></b></button></center>
                            </div>
                            <div class="col-sm-2" style="padding:5px 0px;border-right:1px solid #D5D5D5;">
                                <center><button id="y4" class="btn btn-default" style="display:inline;padding:5px;border:none;background-color:#f6f6f6;"><b><?php echo $prevmonth = date('Y', strtotime('2 years'));?></b></button></center>
                            </div>
                            <div class="col-sm-2" style="padding:5px 0px;border-right:1px solid #D5D5D5;">
                                <center><button id="y5" class="btn btn-default" style="display:inline;padding:5px;border:none;background-color:#f6f6f6;"><b><?php echo $prevmonth = date('Y', strtotime('3 years'));?></b></button></center>
                            </div>
                            <div class="col-sm-2" style="padding:5px 0px;">
                                <center><button id="y6" class="btn btn-default pull-left" style="display:inline;padding:5px;border:none;background-color:#f6f6f6;"><b><?php echo $prevmonth = date('Y', strtotime('4 years'));?></b></button></center>
                                <button  class="btn btn-primary pull-right" onclick="nextrecordyear()" style="display:inline;padding:5px;"><i class="glyphicon glyphicon-triangle-right"></i></button>
                            </div>
                        </div>
                    </div>
                    <script>
                        function perviewsrecordyear(){
                            var year=$("#startyear").val();
                            //alert(year);
                            var y1=Number(year-6);
                            var y2=Number(year-5);
                            var y3=Number(year-4);
                            var y4=Number(year-3);
                            var y5=Number(year-2);
                            var y6=Number(year-1);
                            $("#y1").html("<b>"+y1+"</b>");
                            $("#y2").html("<b>"+y2+"</b>");
                            $("#y3").html("<b>"+y3+"</b>");
                            $("#y4").html("<b>"+y4+"</b>");
                            $("#y5").html("<b>"+y5+"</b>");
                            $("#y6").html("<b>"+y6+"</b>");
                            $("#startyear").val(Number(year-6));
                            $("#endyear").val(Number(year-1));
                        }
                        function nextrecordyear(){
                            var year=Number($("#endyear").val());
                            //alert(year);
                            var y1=Number(year)+Number(1);
                            var y2=Number(year)+Number(2);
                            var y3=Number(year)+Number(3);
                            var y4=Number(year)+Number(4);
                            var y5=Number(year)+Number(5);
                            var y6=Number(year)+Number(6);
                            $("#y1").html("<b>"+y1+"</b>");
                            $("#y2").html("<b>"+y2+"</b>");
                            $("#y3").html("<b>"+y3+"</b>");
                            $("#y4").html("<b>"+y4+"</b>");
                            $("#y5").html("<b>"+y5+"</b>");
                            $("#y6").html("<b>"+y6+"</b>");
                            $("#startyear").val(Number(year+1));
                            $("#endyear").val(Number(year+6));
                        }
                    </script>
                    
                    <input type="hidden" id="startQmonth" name="startQmonth" value="<?php if(date('m')<7){ echo 1; }else{ echo 2;} ?>">
                    <input type="hidden" id="startQyear" name="startQyear" value="<?php echo date('Y');?>">
                    
                    <input type="hidden" id="endQmonth" name="endQmonth" value="<?php if(date('m')<7){ echo 2; }else{ echo 1;} ?>">
                    <input type="hidden" id="endQyear" name="endQyear" value="<?php echo date('Y', strtotime('1 years'));?>">
                    
                    <input type="hidden" id="startyear" name="startyear" value="<?php echo $prevmonth = date('Y', strtotime('-1 years'));?>">
                    <input type="hidden" id="endyear" name="endyear" value="<?php echo $prevmonth = date('Y', strtotime('4 years'));?>">
                    
                </div>
                
                   <script>
                       function fetch_won(){
                           $('#wonpending').val("won");  
                           var whattype=$("#whattype").val();
                           if(whattype=="monthly"){
                               var startmonth=$("#startmonth").val();
                               $.post("employee_date_intermediate1.php",{expected_won:startmonth},function myresult(data){
                                  $('#mycontent').html('Total Won');
                                   $('#exe_result').html(data);
                               });
                           }
                           var value=$.trim(value1);
                   //alert(value);
                       }
                       
                       function fetch_won_expected(){
                           $('#wonpending').val("wonpending");  
                           var whattype=$("#whattype").val();
                           if(whattype=="monthly"){ 
                               var startmonth=$("#startmonth").val();
                               $.post("employee_date_intermediate1.php",{expected_won_pending:startmonth},function myresult(data1){
                                  $('#mycontent').html('Won+Pending');
                                   $('#exe_result').html(data1);
                               }); 
                           }
                       }
                       function headmonth(month,year){
                            var month_array = ["","Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul","Aug", "Sep", "Oct", "Nov", "Dec"];
                           month=parseInt(month);
                           year=parseInt(year);
                            if(month==1){
                                m1=month_array[1];m2=month_array[2];m3=month_array[3];m4=month_array[4];m5=month_array[5];m6=month_array[6];
                                y1=year;y2=year;y3=year;y4=year;y5=year;y6=year;
                            }
                            if(month==2){
                                m1=month_array[2];m2=month_array[3];m3=month_array[4];m4=month_array[5];m5=month_array[6];m6=month_array[7];
                                y1=year;y2=year;y3=year;y4=year;y5=year;y6=year;
                            }
                            if(month==3){
                                m1=month_array[3];m2=month_array[4];m3=month_array[5];m4=month_array[6];m5=month_array[7];m6=month_array[8];
                                y1=year;y2=year;y3=year;y4=year;y5=year;y6=year;
                            }
                            if(month==4){
                                m1=month_array[4];m2=month_array[5];m3=month_array[6];m4=month_array[7];m5=month_array[8];m6=month_array[9];
                                y1=year;y2=year;y3=year;y4=year;y5=year;y6=year;
                            }
                            if(month==5){
                                m1=month_array[5];m2=month_array[6];m3=month_array[7];m4=month_array[8];m5=month_array[9];m6=month_array[10];
                                y1=year;y2=year;y3=year;y4=year;y5=year;y6=year;
                            }
                            if(month==6){
                                m1=month_array[6];m2=month_array[7];m3=month_array[8];m4=month_array[9];m5=month_array[10];m6=month_array[11];
                                y1=year;y2=year;y3=year;y4=year;y5=year;y6=year;
                            }
                            if(month==7){
                                m1=month_array[7];m2=month_array[8];m3=month_array[9];m4=month_array[10];m5=month_array[11];m6=month_array[12];
                                y1=year;y2=year;y3=year;y4=year;y5=year;y6=year;
                            }
                            if(month==8){
                                m1=month_array[8];m2=month_array[9];m3=month_array[10];m4=month_array[11];m5=month_array[12];m6=month_array[1];
                                y1=year;y2=year;y3=year;y4=year;y5=year;y6=year+1;
                            }
                            if(month==9){
                                m1=month_array[9];m2=month_array[10];m3=month_array[11];m4=month_array[12];m5=month_array[1];m6=month_array[2];
                                y1=year;y2=year;y3=year;y4=year;y5=year+1;y6=year+1;
                            }
                            if(month==10){
                                m1=month_array[10];m2=month_array[11];m3=month_array[12];m4=month_array[1];m5=month_array[2];m6=month_array[3];
                                y1=year;y2=year;y3=year;y4=year+1;y5=year+1;y6=year+1;
                            }
                            if(month==11){
                                m1=month_array[11];m2=month_array[12];m3=month_array[1];m4=month_array[2];m5=month_array[3];m6=month_array[4];
                                y1=year;y2=year;y3=year+1;y4=year+1;y5=year+1;y6=year+1;
                            }
                            if(month==12){
                                m1=month_array[12];m2=month_array[1];m3=month_array[2];m4=month_array[3];m5=month_array[4];m6=month_array[5];
                                y1=year;y2=year+1;y3=year+1;y4=year+1;y5=year+1;y6=year+1;
                            }
                            m1="<b>"+m1+"&nbsp;&nbsp;"+y1+"</b>";
                            $("#m1").html(m1);
                            m2="<b>"+m2+"&nbsp;&nbsp;"+y2+"</b>";
                            $("#m2").html(m2);
                            m3="<b>"+m3+"&nbsp;&nbsp;"+y3+"</b>";
                            $("#m3").html(m3);
                            m4="<b>"+m4+"&nbsp;&nbsp;"+y4+"</b>";
                            $("#m4").html(m4);
                            m5="<b>"+m5+"&nbsp;&nbsp;"+y5+"</b>";
                            $("#m5").html(m5);
                            m6="<b>"+m6+"&nbsp;&nbsp;"+y6+"</b>";
                            $("#m6").html(m6);
                            
                       }
                       function previewsrecordmonth(){
                            var startmonth=$("#startmonth").val();
                            date=""+startmonth[8]+startmonth[9];
                            month=parseInt(startmonth[5]+startmonth[6])-1;
                            year=""+startmonth[0]+startmonth[1]+startmonth[2]+startmonth[3];
                            if(month==0){
                            year=parseInt(year)-1;
                            month=12;
                            }
                            headmonth(month,year);
                            if(month<10){
                            makeDate=year+"-0"+month+"-"+date;
                            }else{
                            makeDate=year+"-"+month+"-"+date;
                            }
                            $("#startmonth").val(makeDate);
                            var wonpending=$("#wonpending").val();
                            if(wonpending=="wonpending"){
                                $.post("employee_date_intermediate1.php",{expected_won_pending:makeDate},function myresult(data1){
                                  $('#mycontent').html('Won+Pending');
                                   $('#exe_result').html(data1);
                               }); 
                            }else{
                                $.post("employee_date_intermediate1.php",{expected_won:makeDate},function myresult(data){
                                    $('#mycontent').html('Total Won');
                                    $('#exe_result').html(data);
                               });
                            }
                            $.post("employee_date_intermediate1.php",{monthly_body:makeDate},function myresult(data1){
                              $('#mycontent').html('Won+Pending');
                               $('#per_result').html(data1);
                           });
                            $.post("employee_date_intermediate1.php",{monthly_tot_pending:makeDate},function myresult(data1){
                              $('#mycontent').html('Won+Pending');
                               $('#pending_tot').html(data1);
                           }); 
                            $.post("employee_date_intermediate1.php",{monthly_target:makeDate},function myresult(data1){
                               $('#monthly_target_response').html(data1);
                           }); 
                       }
                       
                       function nextrecordmonth(){
                            var startmonth=$("#startmonth").val();
                            date=""+startmonth[8]+startmonth[9];
                            month=parseInt(startmonth[5]+startmonth[6])+1;
                            year=""+startmonth[0]+startmonth[1]+startmonth[2]+startmonth[3];
                            if(month==13){
                            year=parseInt(year)+1;
                            month=1;
                            }
                            headmonth(month,year);
                            if(month<10){
                            makeDate=year+"-0"+month+"-"+date;
                            }else{
                            makeDate=year+"-"+month+"-"+date;
                            }
                            $("#startmonth").val(makeDate);
                            var wonpending=$("#wonpending").val();
                            if(wonpending=="wonpending"){
                                $.post("employee_date_intermediate1.php",{expected_won_pending:makeDate},function myresult(data1){
                                  $('#mycontent').html('Won+Pending');
                                   $('#exe_result').html(data1);
                               }); 
                            }else{
                                $.post("employee_date_intermediate1.php",{expected_won:makeDate},function myresult(data){
                                    $('#mycontent').html('Total Won');
                                    $('#exe_result').html(data);
                               });
                            }
                            $.post("employee_date_intermediate1.php",{monthly_body:makeDate},function myresult(data1){
                               $('#per_result').html(data1);
                           });
                            $.post("employee_date_intermediate1.php",{monthly_tot_pending:makeDate},function myresult(data1){
                               $('#pending_tot').html(data1);
                           }); 
                            $.post("employee_date_intermediate1.php",{monthly_target:makeDate},function myresult(data1){
                               $('#monthly_target_response').html(data1);
                           }); 
                       }
                   </script>
                    
                <input type="hidden" id="wonpending" name="wonpending" value="wonpending">
                <input type="hidden" id="whattype" name="whattype" value="monthly">
                 
                <input type="hidden" id="startmonth" name="startmonth" value="<?php echo date('Y-m-24', strtotime("-2 months"));?>">
                <br>
                
                <div style="padding:3px 0px;">
                    <div class="row" style="height:50px;">
                        <div class="col-md-3" style="background-color:#f6f6f6;">
                            <center><span id="pipeline2">
                                <span class="dropdown">
                                    <span class="dropdown-toggle" data-toggle="dropdown">
                                    <span class="col-xs-10"><b><span style="font-size:16px;"><center>Expected Total</center></span> </b><br><span style="font-size:12px;">Won + Pending</span></span>
                                    <span class="col-xs-2" style="padding-top:10px;"> <span class="caret"></span></span></span> 
                                    <ul class="dropdown-menu">
                                        <li><a>Total Won</a></li>
                                        <li><a>Expected(Won + Pending)</a></li>
                                    </ul>
                                </span>
                            </span></center>
                        </div>
                        <div class="col-md-9" id="exe_result" style="height:50px;">
                            <?php
                            $date1=date("Y-m-d");
                            for($iiiii=-2;$iiiii<4;$iiiii++){
                                $months= date('m', strtotime($date1 .'+'.$iiiii.' month'));
                                $year=date('Y', strtotime($date1 .'+'.$iiiii.' month'));
                                $sqlans1='SELECT sum( case when `d_stage`="Won" then `d_amount` else (d_amount * cast(REPLACE(sales_pipeline_type.pipe_percentage, "%", "") as UNSIGNED INTEGER) / 100) end) as total_amount FROM `sales_deal_pipeline` left join sales_pipeline_type on sales_pipeline_type.id=sales_deal_pipeline.d_stage WHERE sales_deal_pipeline.`companyname`="'.$companyname.'" and Month(d_date)="'.$months.'" and YEAR(`d_date`)="'.$year.'" and `d_stage`!="loss" and d_deal_by="'.$adminemailid.'"';
                                $resultans1 = $pdo->query($sqlans1);
                                $total_amount=0;
                                foreach($resultans1 as $rowans1){
                                    $total_amount=$rowans1['total_amount'];
                                }
                                $total_amount=round($total_amount);
                            ?>   
                            
                                    <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;<?php if($i!=6){ ?>border-right:1px solid #ddd; <?php } ?>">
                                        <?php if($total_amount!=""){ ?>
                                        <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_total_deal_month('<?php echo $companyname;?>','<?php echo $months;?>','<?php echo $year;?>')"><center>&#8360&nbsp;<b><?php echo $total_amount;?></b></center></a>
                                        <?php }else{ ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                        <?php } ?>
                                    </div>     
                            <?php
                            }
                            ?>
                        </div>
                    </div>
                </div>
                
                <?php
                $year=date('Y');
                $months=date('m');
                $month=$year."-".$months."-01";
                ?>
                <div style="padding:3px 0px;">
                    <div class="row" style="height:40px;">
                        <div class="col-md-3" style="background-color:#f6f6f6;">
                            <center>
                                <span id="pipeline3">
                                    <!--<span class="col-xs-6"><b>Target</b></span>
                                    <span class="col-xs-6">
                                        <span class="pull-right" data-toggle="modal" data-target="#myModal_view_set_target" onclick="show_pipeline_set_target('<?php echo $companyname;?>','<?php echo $month;?>','<?php echo $year;?>')" style="font-size:12px;padding-top:5px;cursor:pointer;">Edit</span>
                                    </span>-->
                                    <b>Target</b>
                                </span>
                            </center>
                        </div>
                        <div class="col-md-9" style="height:40px;"  id="monthly_target_response">
                            
                            <?php
                            $date1=date('Y-m-d');
                            
                            for($iiiii=-2;$iiiii<4;$iiiii++){
                                $months= date('m', strtotime($date1.'+'.$iiiii.' month'));
                                $year=date('Y', strtotime($date1.'+'.$iiiii.' month')); 
                                $sql21='SELECT count(*) as count1 FROM `sales_employee_target1` WHERE `t_company`="'.$companyname.'" and `t_year`="'.$year.'" and t_emp_id="'.$adminemailid.'"';
                                $resultans21 = $pdo->query($sql21);
                                foreach($resultans21 as $rowans21){
                                    $count1=$rowans21['count1'];
                                }
                                if(intval($count1)<1){
                                    $mail=$email_array[$rft];
                                    $sqlfun="select sales_generate_employee_target('".$companyname."','".$adminemailid."','".$year."')";
                                    $resultansfun = $pdo->query($sqlfun);
                                }
                                if(intval($months)==1){
                                    $sqlans1='SELECT sum(t_1) as amount FROM `sales_employee_target1` WHERE `t_company`="'.$companyname.'" and `t_year`="'.$year.'" and t_emp_id="'.$adminemailid.'"';
                                }else if(intval($months)==2){
                                    $sqlans1='SELECT sum(t_2) as amount FROM `sales_employee_target1` WHERE `t_company`="'.$companyname.'" and `t_year`="'.$year.'" and t_emp_id="'.$adminemailid.'"';
                                }else if(intval($months)==3){
                                    $sqlans1='SELECT sum(t_3) as amount FROM `sales_employee_target1` WHERE `t_company`="'.$companyname.'" and `t_year`="'.$year.'" and t_emp_id="'.$adminemailid.'"';
                                }else if(intval($months)==4){
                                    $sqlans1='SELECT sum(t_4) as amount FROM `sales_employee_target1` WHERE `t_company`="'.$companyname.'" and `t_year`="'.$year.'" and t_emp_id="'.$adminemailid.'"';
                                }else if(intval($months)==5){
                                    $sqlans1='SELECT sum(t_5) as amount FROM `sales_employee_target1` WHERE `t_company`="'.$companyname.'" and `t_year`="'.$year.'" and t_emp_id="'.$adminemailid.'"';
                                }else if(intval($months)==6){
                                    $sqlans1='SELECT sum(t_6) as amount FROM `sales_employee_target1` WHERE `t_company`="'.$companyname.'" and `t_year`="'.$year.'" and t_emp_id="'.$adminemailid.'"';
                                }else if(intval($months)==7){
                                    $sqlans1='SELECT sum(t_7) as amount FROM `sales_employee_target1` WHERE `t_company`="'.$companyname.'" and `t_year`="'.$year.'" and t_emp_id="'.$adminemailid.'"';
                                }else if(intval($months)==8){
                                    $sqlans1='SELECT sum(t_8) as amount FROM `sales_employee_target1` WHERE `t_company`="'.$companyname.'" and `t_year`="'.$year.'" and t_emp_id="'.$adminemailid.'"';
                                }else if(intval($months)==9){
                                    $sqlans1='SELECT sum(t_9) as amount FROM `sales_employee_target1` WHERE `t_company`="'.$companyname.'" and `t_year`="'.$year.'" and t_emp_id="'.$adminemailid.'"';
                                }else if(intval($months)==10){
                                    $sqlans1='SELECT sum(t_10) as amount FROM `sales_employee_target1` WHERE `t_company`="'.$companyname.'" and `t_year`="'.$year.'" and t_emp_id="'.$adminemailid.'"';
                                }else if(intval($months)==11){
                                    $sqlans1='SELECT sum(t_11) as amount FROM `sales_employee_target1` WHERE `t_company`="'.$companyname.'" and `t_year`="'.$year.'" and t_emp_id="'.$adminemailid.'"';
                                }else{
                                    $sqlans1='SELECT sum(t_12) as amount FROM `sales_employee_target1` WHERE `t_company`="'.$companyname.'" and `t_year`="'.$year.'" and t_emp_id="'.$adminemailid.'"';
                                } 
                                $resultans1 = $pdo->query($sqlans1);
                                $traget_amount="";
                                foreach($resultans1 as $rowans1){
                                    $traget_amount=$rowans1['amount'];
                                }
                                $traget_amount=round($traget_amount);
                                    
                            ?>  
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;border-right:1px solid #ddd;">
                                    <span style="color:grey;font-size:14px;"><center>&#8360&nbsp;<b><?php echo $traget_amount;?></b></center></span>
                                </div>
                            
                            <?php
                            }
                            ?>
                        </div>
                    </div>
                </div>
                
               
                <br>

<div style="padding:3px 0px;" id="per_result">
<?php //$pipe_percentage $pipe_name
for($i1=0;$i1<count($pipe_percentage);$i1++){
        $j=100-($i1*10)."%";
        $stage=$pipe_id[$i1];
        $percentage=$pipe_percentage[$i1];
        $p_name=$pipe_name[$i1];
?>
                <div style="padding:3px 0px;">
                    <div class="row" style="height:40px;">
                        <div class="col-md-3" style="background-color:#f6f6f6;">
                            <center><span id="pipeline1" style="width:<?php echo $j;?>"><span ><?php echo $percentage;?><br><span style="font-size:12px;"><?php echo $p_name;?></span></span></span></center>
                        </div>
                        <div class="col-md-9" style="height:40px;">
                            <?php
                            $date1= date('Y-m-d');
                            for($iiiii=-2;$iiiii<4;$iiiii++){
                                $months= date('m', strtotime($date1.'+'.$iiiii.' month'));
                                $year=date('Y', strtotime($date1.'+'.$iiiii.' month')); 
                                $sqlans1='SELECT sum( case when `d_stage`="Won" then `d_amount` else (d_amount * cast(REPLACE(sales_pipeline_type.pipe_percentage, "%", "") as UNSIGNED INTEGER) / 100) end) as total_amount FROM `sales_deal_pipeline` left join sales_pipeline_type on sales_pipeline_type.id=sales_deal_pipeline.d_stage WHERE sales_deal_pipeline.`companyname`="'.$companyname.'" and Month(d_date)="'.$months.'" and YEAR(`d_date`)="'.$year.'" and `d_stage`!="loss" and `d_stage`="'.$stage.'" and d_deal_by="'.$adminemailid.'"';
                                $resultans1 = $pdo->query($sqlans1);
                                $total_amount="";
                                foreach($resultans1 as $rowans1){
                                    $total_amount=$rowans1['total_amount'];
                                }
                                $total_amount=round($total_amount);
                            ?>   
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($iiiii!=4){ ?>border-right:1px solid #ddd; <?php } ?>">
                                    <?php if($total_amount!=0){ ?>
                                        <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_deal_stage_month('<?php echo $companyname;?>','<?php echo $months;?>','<?php echo $year;?>','<?php echo $stage;?>')"><center>&#8360&nbsp;<?php echo $total_amount;?></center></a>
                                    <?php }else{ ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                    <?php } ?>
                                </div>
                            <?php
                            }
                            ?>
                           
                        </div>
                    </div>
                </div>
                
<?php
}
?>
</div>
                <br>
                
                
                <div style="padding:3px 0px;">
                    <div class="row" style="height:40px;">
                        <div class="col-md-3" style="background-color:#db1b56;border-radius:5px;">
                            <center><span id="pipeline1"><b>Total pending</b></span></center>
                        </div>
                        <div class="col-md-9" id="pending_tot" style="height:40px;">
                            <?php
                            $date1=date('Y-m-d');
                            for($iiii=-2;$iiii<4;$iiii++){
                                $i= date('m', strtotime($date1 .'+'.$iiii.' month'));
                                $year= date('Y', strtotime($date1 .'+'.$iiii.' month'));
                                $sqlans1='SELECT sum(d_amount * cast(REPLACE(sales_pipeline_type.pipe_percentage, "%", "") as UNSIGNED INTEGER) / 100) as total_amount FROM `sales_deal_pipeline` left join sales_pipeline_type on sales_pipeline_type.id=sales_deal_pipeline.d_stage WHERE sales_deal_pipeline.`companyname`="'.$companyname.'" and Month(d_date)="'.$i.'" and YEAR(`d_date`)="'.$year.'" and `d_stage`!="loss" and `d_stage`!="won" and d_deal_by="'.$adminemailid.'"';
                                $resultans1 = $pdo->query($sqlans1);
                                $total_amount="";
                                foreach($resultans1 as $rowans1){
                                    $total_amount=$rowans1['total_amount'];
                                }
                                $total_amount=round($total_amount);
                                    
                            ?>   
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($iiii!=4){ ?>border-right:1px solid #ddd; <?php } ?>">
                                    <center><span style="color: #db1b56;font-size:14px;text-decoration: none;">&#8360&nbsp;<b><?php echo $total_amount;?></b></span></center>
                                </div>
                            <?php
                            }
                            ?>
                           
                        </div>
                    </div>
                </div>
                
                
            </div>
            
        </div>
        
        <script>
            function show_pipeline_deal_stage_month(companyname, month, year, stage){
                //alert(month);
                $.ajax({
                   url:"pipeline_total_month_stage_data.php",
                   data:{companyname:companyname, month:month, year:year, stage:stage},
                   type:"post",
                   success:function(respond){
                       $("#show_pipe_deal").html(respond);
                   }
                });
            }
        </script>
        
        <script>
            function show_pipeline_total_deal_month(companyname, month, year){
                //alert(month);
                $.ajax({
                   url:"pipeline_total_month_data.php",
                   data:{companyname:companyname, month:month, year:year},
                   type:"post",
                   success:function(respond){
                       $("#show_pipe_deal").html(respond);
                   }
                });
            }
        </script>
	<!-- Modal -->
	<div class="modal right fade" id="myModal_view_pipeline_deal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2">
		<div class="modal-dialog" role="document">
			<div class="modal-content">


				<div class="modal-body">
					<button type="button" class="close pull-left" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
					<h4 class="modal-title" id="myModalLabel2"><center>Deal</center></h4>
					<span id="show_pipe_deal"></span>
				</div>

			</div><!-- modal-content -->
		</div><!-- modal-dialog -->
	</div><!-- modal -->
	<!-- Modal -->
	
                
                <script>
                    function show_pipeline_set_target(companyname, year, month){
                        //alert("companyname:"+companyname);
                        var empid=new Array();
                        empid=<?php echo json_encode($emp_emailid_a);?>;
                        /*alert("empid:"+empid.length);
                        alert("year:"+year);
                        alert("month:"+month);*/
                        $.ajax({
                           url:"pipeline_employee_traget_data.php",
                           data:{companyname:companyname, empid:empid, month:month, year:year},
                           type:"post",
                           success:function(respond){
                               $("#show_target_view").html(respond);
                           }
                        });
                    }
                </script>
	<div class="modal right fade" id="myModal_view_set_target" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2">
		<div class="modal-dialog" role="document">
			<div class="modal-content">


				<div class="modal-body">
					<button type="button" class="close pull-left" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
					<h4 class="modal-title" id="myModalLabel2"><center>Edit Employee Target</center></h4>
					<span id="show_target_view"></span>
				</div>

			</div><!-- modal-content -->
		</div><!-- modal-dialog -->
	</div><!-- modal -->
        
        <script>
            $(document).ready(function(){
                var s="";
                $.ajax({
                   url:"pipeline_data.php",
                   data:{s:s},
                   type:"post",
                   success:function(respond){
                       $("#pipelinedeallistview").html(respond);
                   }
                });
               
            });
        </script>
        <div style="background-color:#ffffff;padding:10px 100px">
            
            <div style="background-color:#f6f6f6;">
                <br>
                <span style="padding:0px 5px;font-size:20px;"><b>DEAL LIST</b></span><br>
                <div id="pipelinedeallistview"></div> 
                
            </div>
            
            
        </div>
    </body>
    
</html>
<?php
}else{
echo "<script> location.replace('http://fieldcloud.in/signin.php') </script>";
}?>