<?php
session_start();
$companyname=$_SESSION['companyname'];//;
$adminemailid=$_SESSION['emailid'];//;
if(isset($_POST['mon'])){
$mon= $_POST['mon'];
$yea= $_POST['yea']; 
$m=$yea."-".$mon."-01";
require_once('../Control/pipeline.php');
$objpipeline=new pipelinectrl();
                             $month= $mon;
                              $year=$yea;
                             $myresult=$objpipeline->salespipelineexpected_total($companyname,$month,$year);
                            $percentage=$objpipeline->salespipelinestage_total($companyname,$month,$year);
                                $stage_value=0;
                                foreach($percentage as $r){
                                    $percentage_stage=$r['d_stage'];
                                    if($percentage_stage!="won"){
                                        $percentage_value=$objpipeline->salespipeline_find_percentage($percentage_stage);
                                        $percent=explode("%",$percentage_value);
                                        $percent1=$percent[0];
                                        $amount=$r['d_amount'];    
                                        $percentage_amount_value=(($amount*$percent1)/100);
                                        $stage_value=$stage_value+$percentage_amount_value+$amount;
                                    }if($percentage_stage=="Won"){
                                        $amount=$r['d_amount'];
                                        $stage_value=$stage_value+$amount;
                                    }
                                }
                                $myresult=$stage_value-$myresult;                   
                                
                            ?>
                            
                            
                             <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                        <?php if($myresult!=""){ ?>
                                        <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 $month;?>','<?php echo $year;?>')"><center>&#8360&nbsp;<b><?php echo $myresult; ?></b></center></a>
                                        <?php } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                        <?php } ?>
                            </div> 
                            
                            <?php
                             
                             $months= date('m', strtotime($m.'+1 month'));
                              $year=date('Y', strtotime($m.'+1 month'));
                             $myresult=$objpipeline->salespipelineexpected_total($companyname,$months,$year);
                             $percentage=$objpipeline->salespipelinestage_total($companyname,$months,$year);
                                $stage_value=0;
                                foreach($percentage as $r){
                                    $percentage_stage=$r['d_stage'];
                                    if($percentage_stage!="won"){
                                        $percentage_value=$objpipeline->salespipeline_find_percentage($percentage_stage);
                                        $percent=explode("%",$percentage_value);
                                        $percent1=$percent[0];
                                        $amount=$r['d_amount'];    
                                        $percentage_amount_value=(($amount*$percent1)/100);
                                        $stage_value=$stage_value+$percentage_amount_value+$amount;
                                    }if($percentage_stage=="Won"){
                                        $amount=$r['d_amount'];
                                        $stage_value=$stage_value+$amount;
                                    }
                                }
                                $myresult=$stage_value-$myresult;                   
                            ?>
                            
                            <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                        <?php if($myresult!=""){ ?>
                                        <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 $myresult; ?></b></center></a>
                                        <? } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                        <?php } ?>
                            </div> 
                            
                            <?php
                             $months= date('m', strtotime($m.'+2 month'));
                              $year=date('Y', strtotime($m.'+2 month'));
                             $myresult=$objpipeline->salespipelineexpected_total($companyname,$months,$year);
                             $percentage=$objpipeline->salespipelinestage_total($companyname,$months,$year);
                                $stage_value=0;
                                foreach($percentage as $r){
                                    $percentage_stage=$r['d_stage'];
                                    if($percentage_stage!="won"){
                                        $percentage_value=$objpipeline->salespipeline_find_percentage($percentage_stage);
                                        $percent=explode("%",$percentage_value);
                                        $percent1=$percent[0];
                                        $amount=$r['d_amount'];    
                                        $percentage_amount_value=(($amount*$percent1)/100);
                                        $stage_value=$stage_value+$percentage_amount_value+$amount;
                                    }if($percentage_stage=="Won"){
                                        $amount=$r['d_amount'];
                                        $stage_value=$stage_value+$amount;
                                    }
                                }
                                $myresult=$stage_value-$myresult;                   
                            ?>
                            <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                        <?php if($myresult!=""){ ?>
                                        <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 $myresult; ?></b></center></a>
                                        <?php } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                        <?php } ?>
                            </div> 
                            
                            <?php
                             $months= date('m', strtotime($m.'+3 month'));
                              $year=date('Y', strtotime($m.'+3 month'));
                             $myresult=$objpipeline->salespipelineexpected_total($companyname,$months,$year);
                             $percentage=$objpipeline->salespipelinestage_total($companyname,$months,$year);
                                $stage_value=0;
                                foreach($percentage as $r){
                                    $percentage_stage=$r['d_stage'];
                                    if($percentage_stage!="won"){
                                        $percentage_value=$objpipeline->salespipeline_find_percentage($percentage_stage);
                                        $percent=explode("%",$percentage_value);
                                        $percent1=$percent[0];
                                        $amount=$r['d_amount'];    
                                        $percentage_amount_value=(($amount*$percent1)/100);
                                        $stage_value=$stage_value+$percentage_amount_value+$amount;
                                    }if($percentage_stage=="Won"){
                                        $amount=$r['d_amount'];
                                        $stage_value=$stage_value+$amount;
                                    }
                                }
                                $myresult=$stage_value-$myresult;                   
                            ?>
                            
                            <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                        <?php if($myresult!=""){ ?>
                                        <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 $myresult; ?></b></center></a>
                                        <?php } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                        <?php } ?>
                            </div> 
                            
                            <?php
                             $months= date('m', strtotime($m.'+4 month'));
                              $year=date('Y', strtotime($m.'+4 month'));
                             $myresult=$objpipeline->salespipelineexpected_total($companyname,$months,$year);
                             $percentage=$objpipeline->salespipelinestage_total($companyname,$months,$year);
                                $stage_value=0;
                                foreach($percentage as $r){
                                    $percentage_stage=$r['d_stage'];
                                    if($percentage_stage!="won"){
                                        $percentage_value=$objpipeline->salespipeline_find_percentage($percentage_stage);
                                        $percent=explode("%",$percentage_value);
                                        $percent1=$percent[0];
                                        $amount=$r['d_amount'];    
                                        $percentage_amount_value=(($amount*$percent1)/100);
                                        $stage_value=$stage_value+$percentage_amount_value+$amount;
                                    }if($percentage_stage=="Won"){
                                        $amount=$r['d_amount'];
                                        $stage_value=$stage_value+$amount;
                                    }
                                }
                                $myresult=$stage_value-$myresult;                   
                            ?>
                            <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                        <?php if($myresult!=""){ ?>
                                        <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 $myresult; ?></b></center></a>
                                        <?php } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                        <?php } ?>
                            </div> 
                            
                            <?php
                             $months= date('m', strtotime($m.'+5 month'));
                             $year=date('Y', strtotime($m.'+5 month'));
                             $myresult=$objpipeline->salespipelineexpected_total($companyname,$months,$year);
                             $percentage=$objpipeline->salespipelinestage_total($companyname,$months,$year);
                                $stage_value=0;
                                foreach($percentage as $r){
                                    $percentage_stage=$r['d_stage'];
                                    if($percentage_stage!="won"){
                                        $percentage_value=$objpipeline->salespipeline_find_percentage($percentage_stage);
                                        $percent=explode("%",$percentage_value);
                                        $percent1=$percent[0];
                                        $amount=$r['d_amount'];    
                                        $percentage_amount_value=(($amount*$percent1)/100);
                                        $stage_value=$stage_value+$percentage_amount_value+$amount;
                                    }if($percentage_stage=="Won"){
                                        $amount=$r['d_amount'];
                                        $stage_value=$stage_value+$amount;
                                    }
                                }
                                $myresult=$stage_value-$myresult;                   
                            ?>
                            <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                        <?php if($myresult!=""){ ?>
                                        <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 $myresult; ?></b></center></a>
                                        <?php } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                        <?php } ?>
                            </div> 
                        
<?php } ?>  
<?php
if(isset($_POST['tar_mon'])){
$mm=$_POST['tar_mon'];
$yy=$_POST['tar_yea'];
require_once('../Control/sales.php');
$objsales=new salesctrl();
require_once('../Control/pipeline.php');
$objpipeline=new pipelinectrl();

$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_count= count($emp_emailid_a);

                            $months=$mm;
                            $year=$yy;
                            $month=$year."-".$months."-01";
                             $traget_amount=0;
                                    for($g=0;$g<$emp_count;$g++){
                                        $email=$emp_emailid_a[$g];
                                        $totaldeal_res=$objpipeline->salespipelineemployeetarget($companyname,$email,$year,$months);
                                        $totaldealwon=0;
                                        if($totaldeal_res->rowCount()>0){
                                        foreach($totaldeal_res as $totaldeal_row){
                                                $totaldealwon=$totaldeal_row['amount'];
                                        }
                                        $traget_amount=$traget_amount+$totaldealwon;
                                        }else{
                                            $traget_amount=$traget_amount+5000;
                                        }
                                    }
                                   
                            ?>
                             <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
                            $year=date('Y');
                            $months= date('m', strtotime($month.'+1 month'));
                             $traget_amount=0;
                                    for($g=0;$g<$emp_count;$g++){
                                        $email=$emp_emailid_a[$g];
                                        $totaldeal_res=$objpipeline->salespipelineemployeetarget($companyname,$email,$year,$months);
                                        $totaldealwon=0;
                                        if($totaldeal_res->rowCount()>0){
                                        foreach($totaldeal_res as $totaldeal_row){
                                                $totaldealwon=$totaldeal_row['amount'];
                                        }
                                        $traget_amount=$traget_amount+$totaldealwon;
                                        }else{
                                            $traget_amount=$traget_amount+5000;
                                        }
                                    }
                                   
                            ?>
                             <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
                            $year=date('Y');
                            $months= date('m', strtotime($month.'+2 month'));
                             $traget_amount=0;
                                    for($g=0;$g<$emp_count;$g++){
                                        $email=$emp_emailid_a[$g];
                                        $totaldeal_res=$objpipeline->salespipelineemployeetarget($companyname,$email,$year,$months);
                                        $totaldealwon=0;
                                        if($totaldeal_res->rowCount()>0){
                                        foreach($totaldeal_res as $totaldeal_row){
                                                $totaldealwon=$totaldeal_row['amount'];
                                        }
                                        $traget_amount=$traget_amount+$totaldealwon;
                                        }else{
                                            $traget_amount=$traget_amount+5000;
                                        }
                                    }
                                   
                            ?>
                             <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
                            $year=date('Y');
                            $months= date('m', strtotime($month.'+3 month'));
                             $traget_amount=0;
                                    for($g=0;$g<$emp_count;$g++){
                                        $email=$emp_emailid_a[$g];
                                        $totaldeal_res=$objpipeline->salespipelineemployeetarget($companyname,$email,$year,$months);
                                        $totaldealwon=0;
                                        if($totaldeal_res->rowCount()>0){
                                        foreach($totaldeal_res as $totaldeal_row){
                                                $totaldealwon=$totaldeal_row['amount'];
                                        }
                                        $traget_amount=$traget_amount+$totaldealwon;
                                        }else{
                                            $traget_amount=$traget_amount+5000;
                                        }
                                    }
                                   
                            ?>
                             <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
                            $year=date('Y');
                            $months= date('m', strtotime($month.'+4 month'));
                             $traget_amount=0;
                                    for($g=0;$g<$emp_count;$g++){
                                        $email=$emp_emailid_a[$g];
                                        $totaldeal_res=$objpipeline->salespipelineemployeetarget($companyname,$email,$year,$months);
                                        $totaldealwon=0;
                                        if($totaldeal_res->rowCount()>0){
                                        foreach($totaldeal_res as $totaldeal_row){
                                                $totaldealwon=$totaldeal_row['amount'];
                                        }
                                        $traget_amount=$traget_amount+$totaldealwon;
                                        }else{
                                            $traget_amount=$traget_amount+5000;
                                        }
                                    }
                                   
                            ?>
                             <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
                            $year=date('Y');
                            $months= date('m', strtotime($month.'+5 month'));
                             $traget_amount=0;
                                    for($g=0;$g<$emp_count;$g++){
                                        $email=$emp_emailid_a[$g];
                                        $totaldeal_res=$objpipeline->salespipelineemployeetarget($companyname,$email,$year,$months);
                                        $totaldealwon=0;
                                        if($totaldeal_res->rowCount()>0){
                                        foreach($totaldeal_res as $totaldeal_row){
                                                $totaldealwon=$totaldeal_row['amount'];
                                        }
                                        $traget_amount=$traget_amount+$totaldealwon;
                                        }else{
                                            $traget_amount=$traget_amount+5000;
                                        }
                                    }
                                   
                            ?>
                             <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 } ?>

<?php
if(isset($_POST['per_mon'])) {
$per_mon=$_POST['per_mon'];
$per_year=$_POST['per_yea'];
$a_mon=$per_mon;
$a_year=$per_year;
$m=$per_year."-".$per_mon."-01";
require_once('../Control/sales.php');
$objsales=new salesctrl();
$pipelinetype_res=$objsales->salesselectall($companyname, $adminemailid, "sales_pipe_type", "no");
$i=0;
$pipe_id=array();
$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++;
}

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 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
                                $per_result=$objsales->sales_per_select($companyname,$stage,$a_mon,$a_year);
                                $per_result=(($per_result*$percentage)/100);
                                $per_mon1=$a_year."-".$a_mon."-01";
                            ?>
                           
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=6){ ?>border-right:1px solid #ddd; <?php } ?>">
                                   <?php if($per_result!=""){ ?>
                                        <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 $per_mon;?>','<?php echo $per_year;?>','<?php echo $stage;?>')"><center>&#8360&nbsp;<?php echo $per_result;?></center></a>
                                    <?php } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                   <?php } ?>
                                </div>
                            
                            <?php
                                $per_mons=date('m', strtotime($per_mon1.'+1 month'));
                                $per_year=date('Y', strtotime($m.'+1 month'));
                                $per_result=$objsales->sales_per_select($companyname,$stage,$per_mons,$per_year);
                                $per_result=(($per_result*$percentage)/100);
                            ?>
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=6){ ?>border-right:1px solid #ddd; <?php } ?>">
                                     <?php if($per_result!=""){ ?>
                                        <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 $per_mons;?>','<?php echo $per_year;?>','<?php echo $stage;?>')"><center>&#8360&nbsp;<?php echo $per_result;?></center></a>
                                    <?php } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                   <?php } ?>
                                </div>
                            <?php
                            $per_mons=date('m', strtotime($per_mon1.'+2 month'));
                            $per_year=date('Y', strtotime($m.'+2 month'));
                            $per_result=$objsales->sales_per_select($companyname,$stage,$per_mons,$per_year);
                            $per_result=(($per_result*$percentage)/100);
                            ?>
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=6){ ?>border-right:1px solid #ddd; <?php } ?>">
                                    <?php if($per_result!=""){ ?>
                                        <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 $per_mons;?>','<?php echo $per_year;?>','<?php echo $stage;?>')"><center>&#8360&nbsp;<?php echo $per_result;?></center></a>
                                    <?php } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                   <?php } ?>
                                </div>
                            <?php
                            $per_mons=date('m', strtotime($per_mon1.'+3 month'));
                            $per_year=date('Y', strtotime($m.'+3 month'));
                            $per_result=$objsales->sales_per_select($companyname,$stage,$per_mons,$per_year);
                            $per_result=(($per_result*$percentage)/100);
                            ?>    
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=6){ ?>border-right:1px solid #ddd; <?php } ?>">
                                    <?php if($per_result!=""){ ?>
                                        <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 $per_mons;?>','<?php echo $per_year;?>','<?php echo $stage;?>')"><center>&#8360&nbsp;<?php echo $per_result;?></center></a>
                                    <?php } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                   <?php } ?>
                                </div>
                            <?php
                            $per_mons=date('m', strtotime($per_mon1.'+4 month'));
                            $per_year=date('Y', strtotime($m.'+4 month'));
                            $per_result=$objsales->sales_per_select($companyname,$stage,$per_mons,$per_year);
                            $per_result=(($per_result*$percentage)/100);
                            ?>    
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=6){ ?>border-right:1px solid #ddd; <?php } ?>">
                                    <?php if($per_result!=""){ ?>
                                        <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 $per_mons;?>','<?php echo $per_year;?>','<?php echo $stage;?>')"><center>&#8360&nbsp;<?php echo $per_result;?></center></a>
                                    <?php } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                   <?php } ?>
                                </div>
                            <?php
                            $per_mons=date('m', strtotime($per_mon1.'+5 month'));
                            $per_year=date('Y', strtotime($m.'+5 month'));
                            $per_result=$objsales->sales_per_select($companyname,$stage,$per_mons,$per_year);
                            $per_result=(($per_result*$percentage)/100);
                            ?>
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=12){ ?>border-right:1px solid #ddd; <?php } ?>">
                                    <?php if($per_result!=""){ ?>
                                        <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 $per_mons;?>','<?php echo $per_year;?>','<?php echo $stage;?>')"><center>&#8360&nbsp;<?php echo $per_result;?></center></a>
                                    <?php } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                   <?php } ?>
                                </div>
                        </div>   
                
                </div><br>
                        

<?php } 
} ?>


<?php
session_start();
$companyname=$_SESSION['companyname'];//;
$adminemailid=$_SESSION['emailid'];//;
if(isset($_POST['pending_mon'])){
    $mo=$_POST['pending_mon'];
    $ye=$_POST['pending_yea'];
    
    require_once('../Control/pipeline.php');
$objpipeline=new pipelinectrl();

?>

                            <?php
                            
                                    $totaldealwon1=0;
                                    $totaldeal_res=$objpipeline->salestotalpendingdealamount($companyname,$mo,$ye);
                                    $mo=$ye."-".$mo."-01";
                                    foreach($totaldeal_res as $totaldeal_row){
                                        $stage1=$totaldeal_row['stage'];
                                        $stage2=explode("%",$stage1);
                                        $stage121=$stage2[0];
                                            $totaldealwon1=$totaldealwon1+($totaldeal_row['amount']*$stage121/100);
                                    }
                                    
                            ?>   
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=6){ ?>border-right:1px solid #ddd; <?php } ?>">
                                    <center><span style="color: #db1b56;font-size:14px;text-decoration: none;">&#8360&nbsp;<b><?php echo $totaldealwon1;?></b></span></center>
                                </div>
                            <?php
                                    $totaldealwon2=0;    
                                      $mos=date('m', strtotime($mo.'+1 month'));
                                        $ye=date('Y', strtotime($mo.'+1 month'));
                                    $totaldeal_res=$objpipeline->salestotalpendingdealamount($companyname,$mos,$ye);
                                    
                                    foreach($totaldeal_res as $totaldeal_row){
                                        $stage1=$totaldeal_row['stage'];
                                        $stage2=explode("%",$stage1);
                                        $stage121=$stage2[0];
                                            $totaldealwon2=$totaldealwon2+($totaldeal_row['amount']*$stage121/100);
                                    }
                                    
                            ?>   
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=12){ ?>border-right:1px solid #ddd; <?php } ?>">
                                    <center><span style="color: #db1b56;font-size:14px;text-decoration: none;">&#8360 <b>&nbsp;<?php echo $totaldealwon2;?></b></span></center>
                                </div>
                                
                             <?php
                                    $totaldealwon3=0;
                                      $mos=date('m', strtotime($mo.'+2 month'));
                                        $ye=date('Y', strtotime($mo.'+2 month'));
                                    $totaldeal_res=$objpipeline->salestotalpendingdealamount($companyname,$mos,$ye);
                                    
                                    foreach($totaldeal_res as $totaldeal_row){
                                        $stage1=$totaldeal_row['stage'];
                                        $stage2=explode("%",$stage1);
                                        $stage121=$stage2[0];
                                            $totaldealwon3=$totaldealwon3+($totaldeal_row['amount']*$stage121/100);
                                    }
                                    
                            ?>   
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=12){ ?>border-right:1px solid #ddd; <?php } ?>">
                                    <center><span style="color: #db1b56;font-size:14px;text-decoration: none;">&#8360 <b>&nbsp;<?php echo $totaldealwon3;?></b></span></center>
                                </div>
                            
                            <?php
                                    $totaldealwon4=0;
                                      $mos=date('m', strtotime($mo.'+3 month'));
                                        $ye=date('Y', strtotime($mo.'+3 month'));
                                    $totaldeal_res=$objpipeline->salestotalpendingdealamount($companyname,$mos,$ye);
                                    
                                    foreach($totaldeal_res as $totaldeal_row){
                                        $stage1=$totaldeal_row['stage'];
                                        $stage2=explode("%",$stage1);
                                        $stage121=$stage2[0];
                                            $totaldealwon4=$totaldealwon4+($totaldeal_row['amount']*$stage121/100);
                                    }
                                    
                            ?>   
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=12){ ?>border-right:1px solid #ddd; <?php } ?>">
                                    <center><span style="color: #db1b56;font-size:14px;text-decoration: none;">&#8360 <b>&nbsp;<?php echo $totaldealwon4;?></b></span></center>
                                </div>
                                
                            <?php
                                    $totaldealwon5=0;
                                      $mos=date('m', strtotime($mo.'+4 month'));
                                        $ye=date('Y', strtotime($mo.'+4 month'));
                                    $totaldeal_res=$objpipeline->salestotalpendingdealamount($companyname,$mos,$ye);
                                    
                                    foreach($totaldeal_res as $totaldeal_row){
                                        $stage1=$totaldeal_row['stage'];
                                        $stage2=explode("%",$stage1);
                                        $stage121=$stage2[0];
                                            $totaldealwon5=$totaldealwon5+($totaldeal_row['amount']*$stage121/100);
                                    }
                                    
                            ?>   
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=12){ ?>border-right:1px solid #ddd; <?php } ?>">
                                    <center><span style="color: #db1b56;font-size:14px;text-decoration: none;">&#8360 <b>&nbsp;<?php echo $totaldealwon5;?></b></span></center>
                                </div>
                                
                             <?php
                                    $totaldealwon6=0;
                                      $mos=date('m', strtotime($mo.'+5 month'));
                                        $ye=date('Y', strtotime($mo.'+5 month'));
                                    $totaldeal_res=$objpipeline->salestotalpendingdealamount($companyname,$mos,$ye);
                                    
                                    foreach($totaldeal_res as $totaldeal_row){
                                        $stage1=$totaldeal_row['stage'];
                                        $stage2=explode("%",$stage1);
                                        $stage121=$stage2[0];
                                            $totaldealwon6=$totaldealwon6+($totaldeal_row['amount']*$stage121/100);
                                    }
                                    
                            ?>   
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=12){ ?>border-right:1px solid #ddd; <?php } ?>">
                                    <center><span style="color: #db1b56;font-size:14px;text-decoration: none;">&#8360 <b>&nbsp;<?php echo $totaldealwon6;?></b></span></center>
                                </div>

<?php
} ?>


<?php
if(isset($_POST['expected_won'])){
    $val=$_POST['expected_won'];
    $mon= substr($val,0,3);
    $yea=substr($val,4);
    
    $m=$yea."-".$mon."-01";
    $mon= date('m',strtotime($m));
    require_once('../Control/pipeline.php');
$objpipeline=new pipelinectrl();
?>

<?php
                            
                             $month= $mon;
                              $year=date('Y',strtotime($m));
                             
                                $percentage=$objpipeline->salespipelinestage_total($companyname,$month,$year);
                                $stage_value=0;
                                foreach($percentage as $r){
                                    $percentage_stage=$r['d_stage'];
                             if($percentage_stage=="Won"){
                                        $amount=$r['d_amount'];
                                        $stage_value=$stage_value+$amount;
                                    }
                                }
                                $myresult=$stage_value;                   
                           
                            ?>
                            
                             <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                        <?php if($myresult!=""){ ?>
                                        <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 $month;?>','<?php echo $year;?>')"><center>&#8360&nbsp;<b><?php echo $myresult; ?></b></center></a>
                                        <?php  } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                        <?php } ?>
                            </div> 
                            
                                
                            <?php
                            $month=$year."-".$mon."-01";
                             $months= date('m', strtotime($month.'+1 month'));
                             
                              $year=date('Y', strtotime($month.'+1 month'));
                        
                             $percentage=$objpipeline->salespipelinestage_total($companyname,$months,$year);
                                $stage_value=0;
                                foreach($percentage as $r){
                                    $percentage_stage=$r['d_stage'];
                        if($percentage_stage=="Won"){
                                        $amount=$r['d_amount'];
                                        $stage_value=$stage_value+$amount;
                                    }
                                }
                                    $myresult=$stage_value;  
                            ?>
                            
                            <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                         <?php if($myresult!=""){ ?>
                                        <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 $myresult; ?></b></center></a>
                                        <?php  } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                        <?php } ?>
                            </div> 
                        
                        
                            <?php
                            
                             $months= date('m', strtotime($month.'+2 month'));
                             
                              $year=date('Y', strtotime($month.'+2 month'));
                        
                             $percentage=$objpipeline->salespipelinestage_total($companyname,$months,$year);
                                $stage_value=0;
                                foreach($percentage as $r){
                                    $percentage_stage=$r['d_stage'];
                        if($percentage_stage=="Won"){
                                        $amount=$r['d_amount'];
                                        $stage_value=$stage_value+$amount;
                                    }
                                }
                                    $myresult=$stage_value;  
                            ?>
                            
                            <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                         <?php if($myresult!=""){ ?>
                                        <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 $myresult; ?></b></center></a>
                                        <?php  } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                        <?php } ?>
                            </div> 
                        
                            <?php
                            
                             $months= date('m', strtotime($month.'+3 month'));
                             
                              $year=date('Y', strtotime($month.'+3 month'));
                        
                             $percentage=$objpipeline->salespipelinestage_total($companyname,$months,$year);
                                $stage_value=0;
                                foreach($percentage as $r){
                                    $percentage_stage=$r['d_stage'];
                        if($percentage_stage=="Won"){
                                        $amount=$r['d_amount'];
                                        $stage_value=$stage_value+$amount;
                                    }
                                }
                                    $myresult=$stage_value;  
                            ?>
                            
                            <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                         <?php if($myresult!=""){ ?>
                                        <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 $myresult; ?></b></center></a>
                                        <?php  } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                        <?php } ?>
                            </div> 
                            
                
                            <?php
                            
                             $months= date('m', strtotime($month.'+4 month'));
                             
                              $year=date('Y', strtotime($month.'+4 month'));
                        
                             $percentage=$objpipeline->salespipelinestage_total($companyname,$months,$year);
                                $stage_value=0;
                                foreach($percentage as $r){
                                    $percentage_stage=$r['d_stage'];
                        if($percentage_stage=="Won"){
                                        $amount=$r['d_amount'];
                                        $stage_value=$stage_value+$amount;
                                    }
                                }
                                    $myresult=$stage_value;  
                            ?>
                            
                            <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                         <?php if($myresult!=""){ ?>
                                        <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 $myresult; ?></b></center></a>
                                        <?php  } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                        <?php } ?>
                            </div> 
                                    
                
                            <?php
                            
                             $months= date('m', strtotime($month.'+5 month'));
                             
                              $year=date('Y', strtotime($month.'+5 month'));
                        
                             $percentage=$objpipeline->salespipelinestage_total($companyname,$months,$year);
                                $stage_value=0;
                                foreach($percentage as $r){
                                    $percentage_stage=$r['d_stage'];
                        if($percentage_stage=="Won"){
                                        $amount=$r['d_amount'];
                                        $stage_value=$stage_value+$amount;
                                    }
                                }
                                    $myresult=$stage_value;  
                            ?>
                            
                            <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                         <?php if($myresult!=""){ ?>
                                        <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 $myresult; ?></b></center></a>
                                        <?php  } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                        <?php } ?>
                            </div> 
                                            
<?php
}
?>

<?php
if(isset($_POST['expected_won_pending'])){
    
  $val=$_POST['expected_won_pending'];
    $mon= substr($val,0,3);
    $yea=substr($val,4);
    $m=$yea."-".$mon."-01";
    $mon= date('m',strtotime($m));
    require_once('../Control/pipeline.php');
$objpipeline=new pipelinectrl();
?>
<?php
                            
                             $month= $mon;
                              $year=date('Y',strtotime($m));
                             $myresult=$objpipeline->salespipelineexpected_total($companyname,$month,$year);
                                $percentage=$objpipeline->salespipelinestage_total($companyname,$month,$year);
                                $stage_value=0;
                                foreach($percentage as $r){
                                    $percentage_stage=$r['d_stage'];
                                    if($percentage_stage!="won"){
                                        $percentage_value=$objpipeline->salespipeline_find_percentage($percentage_stage);
                                        $percent=explode("%",$percentage_value);
                                        $percent1=$percent[0];
                                        $amount=$r['d_amount'];    
                                        $percentage_amount_value=(($amount*$percent1)/100);
                                        $stage_value=$stage_value+$percentage_amount_value+$amount;
                                    }if($percentage_stage=="Won"){
                                        $amount=$r['d_amount'];
                                        $stage_value=$stage_value+$amount;
                                    }
                                }
                                $myresult=$stage_value-$myresult;                   
                           
                            ?>
                            
                             <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                        <?php if($myresult!=""){ ?>
                                        <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 $month;?>','<?php echo $year;?>')"><center>&#8360&nbsp;<b><?php echo $myresult; ?></b></center></a>
                                        <?php  } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                        <?php } ?>
                            </div> 
                            
                            <?php
                            $month=$year."-".$mon."-01";
                             $months= date('m', strtotime($month.'+1 month'));
                             
                              $year=date('Y', strtotime($month.'+1 month'));
                             $myresult=$objpipeline->salespipelineexpected_total($companyname,$months,$year);
                             $percentage=$objpipeline->salespipelinestage_total($companyname,$months,$year);
                                $stage_value=0;
                                foreach($percentage as $r){
                                    $percentage_stage=$r['d_stage'];
                                    if($percentage_stage!="won"){
                                        $percentage_value=$objpipeline->salespipeline_find_percentage($percentage_stage);
                                        $percent=explode("%",$percentage_value);
                                        $percent1=$percent[0];
                                        $amount=$r['d_amount'];    
                                        $percentage_amount_value=(($amount*$percent1)/100);
                                        $stage_value=$stage_value+$percentage_amount_value+$amount;
                                    }if($percentage_stage=="Won"){
                                        $amount=$r['d_amount'];
                                        $stage_value=$stage_value+$amount;
                                    }
                                }
                                    $myresult=$stage_value-$myresult;  
                            ?>
                            
                            <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                         <?php if($myresult!=""){ ?>
                                        <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 $myresult; ?></b></center></a>
                                        <?php  } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                        <?php } ?>
                            </div> 
                            
                            <?php
                           
                             $months= date('m', strtotime($month.'+2 month'));
                              $year=date('Y', strtotime($month.'+2 month'));
                             $myresult=$objpipeline->salespipelineexpected_total($companyname,$months,$year);
                             $percentage=$objpipeline->salespipelinestage_total($companyname,$months,$year);
                                $stage_value=0;
                                foreach($percentage as $r){
                                    $percentage_stage=$r['d_stage'];
                                    if($percentage_stage!="won"){
                                        $percentage_value=$objpipeline->salespipeline_find_percentage($percentage_stage);
                                        $percent=explode("%",$percentage_value);
                                        $percent1=$percent[0];
                                        $amount=$r['d_amount'];    
                                        $percentage_amount_value=(($amount*$percent1)/100);
                                        $stage_value=$stage_value+$percentage_amount_value+$amount;
                                    }if($percentage_stage=="Won"){
                                        $amount=$r['d_amount'];
                                        $stage_value=$stage_value+$amount;
                                    }
                                }
                                    $myresult=$stage_value-$myresult;  
                            ?>
                            <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                         <?php if($myresult!=""){ ?>
                                        <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 $myresult; ?></b></center></a>
                                        <?php  } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                        <?php } ?>
                            </div> 
                            
                            <?php
                           
                             $months= date('m', strtotime($month.'+3 month'));
                              $year=date('Y', strtotime($month.'+3 month'));
                             $myresult=$objpipeline->salespipelineexpected_total($companyname,$months,$year);
                             $percentage=$objpipeline->salespipelinestage_total($companyname,$months,$year);
                                $stage_value=0;
                                foreach($percentage as $r){
                                    $percentage_stage=$r['d_stage'];
                                    if($percentage_stage!="won"){
                                        $percentage_value=$objpipeline->salespipeline_find_percentage($percentage_stage);
                                        $percent=explode("%",$percentage_value);
                                        $percent1=$percent[0];
                                        $amount=$r['d_amount'];    
                                        $percentage_amount_value=(($amount*$percent1)/100);
                                        $stage_value=$stage_value+$percentage_amount_value+$amount;
                                    }if($percentage_stage=="Won"){
                                        $amount=$r['d_amount'];
                                        $stage_value=$stage_value+$amount;
                                    }
                                }
                                    $myresult=$stage_value-$myresult;  
                            ?>
                            
                            <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                         <?php if($myresult!=""){ ?>
                                        <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 $myresult; ?></b></center></a>
                                        <?php  } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                        <?php } ?>
                            </div> 
                            
                            <?php
                            
                             $months= date('m', strtotime($month.'+4 month'));
                              $year=date('Y', strtotime($month.'+4 month'));
                             $myresult=$objpipeline->salespipelineexpected_total($companyname,$months,$year);
                             $percentage=$objpipeline->salespipelinestage_total($companyname,$months,$year);
                                $stage_value=0;
                                foreach($percentage as $r){
                                    $percentage_stage=$r['d_stage'];
                                    if($percentage_stage!="won"){
                                        $percentage_value=$objpipeline->salespipeline_find_percentage($percentage_stage);
                                        $percent=explode("%",$percentage_value);
                                        $percent1=$percent[0];
                                        $amount=$r['d_amount'];    
                                        $percentage_amount_value=(($amount*$percent1)/100);
                                        $stage_value=$stage_value+$percentage_amount_value+$amount;
                                    }if($percentage_stage=="Won"){
                                        $amount=$r['d_amount'];
                                        $stage_value=$stage_value+$amount;
                                    }
                                }
                                    $myresult=$stage_value-$myresult;  
                            ?>
                            <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                         <?php if($myresult!=""){ ?>
                                        <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 $myresult; ?></b></center></a>
                                        <?php  } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                        <?php } ?>
                            </div> 
                            
                            <?php
                            
                             $months= date('m', strtotime($month.'+5 month'));
                              $year=date('Y', strtotime($month.'+5 month'));
                             $myresult=$objpipeline->salespipelineexpected_total($companyname,$months,$year);
                             $percentage=$objpipeline->salespipelinestage_total($companyname,$months,$year);
                                $stage_value=0;
                                foreach($percentage as $r){
                                    $percentage_stage=$r['d_stage'];
                                    if($percentage_stage!="won"){
                                        $percentage_value=$objpipeline->salespipeline_find_percentage($percentage_stage);
                                        $percent=explode("%",$percentage_value);
                                        $percent1=$percent[0];
                                        $amount=$r['d_amount'];    
                                        $percentage_amount_value=(($amount*$percent1)/100);
                                        $stage_value=$stage_value+$percentage_amount_value+$amount;
                                    }if($percentage_stage=="Won"){
                                        $amount=$r['d_amount'];
                                        $stage_value=$stage_value+$amount;
                                    }
                                }
                                    $myresult=$stage_value-$myresult;  
                            ?>
                            <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                         <?php if($myresult!=""){ ?>
                                        <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 $myresult; ?></b></center></a>
                                        <?php  } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                        <?php } ?>
                            </div> 
                            
<?php } ?>

<?php
if(isset($_POST['expected_yea'])) {
    require_once('../Control/pipeline.php');
$objpipeline=new pipelinectrl();
    $expected_yearly=$_POST['expected_yea'];
   
?>

                            <?php
                            
                              $year=$expected_yearly;
                             $myresult=$objpipeline->salespipelineexpected_yearly_total($companyname,$year);
                            
                            ?>
                            
                             <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                        
                                        <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_total_deal_year('<?php echo $companyname;?>','<?php echo $year;?>')"><center>&#8360&nbsp;<b><?php echo $myresult; ?></b></center></a>
                                        <?php if($myresult==""){ ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;</span></center>
                                        <?php } ?>
                            </div> 
                            
                            <?php
                            $year=$expected_yearly."-06-01";
                              $years=date('Y',strtotime($year.'+1 years'));
                             $myresult=$objpipeline->salespipelineexpected_yearly_total($companyname,$years);
                            ?>
                            
                            <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                        
                                        <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_total_deal_year('<?php echo $companyname;?>','<?php echo $years;?>')"><center>&#8360&nbsp;<b><?php echo $myresult; ?></b></center></a>
                                        <?php if($myresult==""){ ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;</span></center>
                                        <?php } ?>
                            </div> 
                            
                           <?php
                              $years=date('Y',strtotime($year.'+2 years'));
                             $myresult=$objpipeline->salespipelineexpected_yearly_total($companyname,$years);
                            ?>
                            <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                        
                                        <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_total_deal_year('<?php echo $companyname;?>','<?php echo $years;?>')"><center>&#8360&nbsp;<b><?php echo $myresult; ?></b></center></a>
                                        <?php if($myresult==""){ ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;</span></center>
                                        <?php } ?>
                            </div> 
                            
                            <?php
                              $years=date('Y',strtotime($year.'+3 years'));
                             $myresult=$objpipeline->salespipelineexpected_yearly_total($companyname,$years);
                            ?>
                            
                            <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                        
                                        <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_total_deal_year('<?php echo $companyname;?>','<?php echo $years;?>')"><center>&#8360&nbsp;<b><?php echo $myresult; ?></b></center></a>
                                        <?php if($myresult==""){ ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;</span></center>
                                        <?php } ?>
                            </div> 
                            
                            <?php
                              $years=date('Y',strtotime($year.'+4 years'));
                             $myresult=$objpipeline->salespipelineexpected_yearly_total($companyname,$years);
                            ?>
                            <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                        
                                        <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_total_deal_year('<?php echo $companyname;?>','<?php echo $years;?>')"><center>&#8360&nbsp;<b><?php echo $myresult; ?></b></center></a>
                                        <?php if($myresult==""){ ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;</span></center>
                                        <?php } ?>
                            </div> 
                            
                             <?php
                              $years=date('Y',strtotime($year.'+5 years'));
                             $myresult=$objpipeline->salespipelineexpected_yearly_total($companyname,$years);
                            ?>
                            <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                        
                                        <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_total_deal_year('<?php echo $companyname;?>','<?php echo $years;?>')"><center>&#8360&nbsp;<b><?php echo $myresult; ?></b></center></a>
                                        <?php if($myresult==""){ ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;</span></center>
                                        <?php } ?>
                            </div> 
                                
                        

<?php } ?>


<?php
if(isset($_POST['per_result_yearly'])) {
    $percent_year=$_POST['per_result_yearly'];
require_once('../Control/sales.php');
$objsales=new salesctrl();
$pipelinetype_res=$objsales->salesselectall($companyname, $adminemailid, "sales_pipe_type", "no");
$i=0;
$pipe_id=array();
$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++;
}
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 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
                               
                                $year=$percent_year;
                                $per_result=$objsales->sales_per_yearly_select($companyname,$stage,$year);
                                
                            ?>
                           
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=6){ ?>border-right:1px solid #ddd; <?php } ?>">
                                   <?php if($per_result!=""){ ?>
                                        <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_deal_stage_year('<?php echo $companyname;?>','<?php echo $year;?>','<?php echo $stage;?>')"><center>&#8360&nbsp;<?php echo $per_result;?></center></a>
                                    <?php } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                   <?php } ?>
                                </div>
                            
                             <?php
                                $year=$percent_year."-06-01";
                                 $years=date('Y',strtotime($year.'+1 years'));
                                $per_result=$objsales->sales_per_yearly_select($companyname,$stage,$years);
                                
                            ?>
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=6){ ?>border-right:1px solid #ddd; <?php } ?>">
                                     <?php if($per_result!=""){ ?>
                                        <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_deal_stage_year('<?php echo $companyname;?>','<?php echo $years;?>','<?php echo $stage;?>')"><center>&#8360&nbsp;<?php echo $per_result;?></center></a>
                                    <?php } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                   <?php } ?>
                                </div>
                            <?php
                               
                                 $years=date('Y',strtotime($year.'+2 years'));
                                $per_result=$objsales->sales_per_yearly_select($companyname,$stage,$years);
                                
                            ?>
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=6){ ?>border-right:1px solid #ddd; <?php } ?>">
                                    <?php if($per_result!=""){ ?>
                                        <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_deal_stage_year('<?php echo $companyname;?>','<?php echo $years;?>','<?php echo $stage;?>')"><center>&#8360&nbsp;<?php echo $per_result;?></center></a>
                                    <?php } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                   <?php } ?>
                                </div>
                             <?php
                               
                                 $years=date('Y',strtotime($year.'+3 years'));
                                $per_result=$objsales->sales_per_yearly_select($companyname,$stage,$years);
                                
                            ?>
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=6){ ?>border-right:1px solid #ddd; <?php } ?>">
                                    <?php if($per_result!=""){ ?>
                                        <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_deal_stage_year('<?php echo $companyname;?>','<?php echo $years;?>','<?php echo $stage;?>')"><center>&#8360&nbsp;<?php echo $per_result;?></center></a>
                                    <?php } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                   <?php } ?>
                                </div>
                            <?php
                               
                                 $years=date('Y',strtotime($year.'+4 years'));
                                $per_result=$objsales->sales_per_yearly_select($companyname,$stage,$years);
                                
                            ?>
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=6){ ?>border-right:1px solid #ddd; <?php } ?>">
                                    <?php if($per_result!=""){ ?>
                                        <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_deal_stage_year('<?php echo $companyname;?>','<?php echo $years;?>','<?php echo $stage;?>')"><center>&#8360&nbsp;<?php echo $per_result;?></center></a>
                                    <?php } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                   <?php } ?>
                                </div>
                            <?php
                               
                                 $years=date('Y',strtotime($year.'+5 years'));
                                $per_result=$objsales->sales_per_yearly_select($companyname,$stage,$years);
                                
                            ?>
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=12){ ?>border-right:1px solid #ddd; <?php } ?>">
                                    <?php if($per_result!=""){ ?>
                                        <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_deal_stage_year('<?php echo $companyname;?>','<?php echo $years;?>','<?php echo $stage;?>')"><center>&#8360&nbsp;<?php echo $per_result;?></center></a>
                                    <?php } else { ?>
                                        <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                                   <?php } ?>
                                </div>
                        </div>   
                
                </div><br>

<?php } } ?>


<?php
if(isset($_POST['pending_result_yearly'])) {
    $yer=$_POST['pending_result_yearly'];
     require_once('../Control/pipeline.php');
$objpipeline=new pipelinectrl();
?>
  <?php
                            
                                    $ye=date('Y');
                                    $totaldeal_res=$objpipeline->salestotalpendingdealamountyearly($companyname,$ye);
                                   
                                    foreach($totaldeal_res as $totaldeal_row){
                                        $stage1=$totaldeal_row['stage'];
                                        $stage2=explode("%",$stage1);
                                        $stage121=$stage2[0];
                                            $totaldealwon1=$totaldealwon1+($totaldeal_row['amount']*$stage121/100);
                                    }
                                    
                            ?>   
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=6){ ?>border-right:1px solid #ddd; <?php } ?>">
                                    <center><span style="color: #db1b56;font-size:14px;text-decoration: none;">&#8360&nbsp;<b><?php echo $totaldealwon1;?></b></span></center>
                                </div>
                            <?php
                            
                                        $ye=date('Y',strtotime($yrs.'+1 years'));
                                    $totaldeal_res=$objpipeline->salestotalpendingdealamountyearly($companyname,$ye);
                                    
                                    foreach($totaldeal_res as $totaldeal_row){
                                        $stage1=$totaldeal_row['stage'];
                                        $stage2=explode("%",$stage1);
                                        $stage121=$stage2[0];
                                            $totaldealwon2=$totaldealwon1+($totaldeal_row['amount']*$stage121/100);
                                    }
                                    
                            ?>   
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=12){ ?>border-right:1px solid #ddd; <?php } ?>">
                                    <center><span style="color: #db1b56;font-size:14px;text-decoration: none;">&#8360 <b>&nbsp;<?php echo $totaldealwon2;?></b></span></center>
                                </div>
                                
                             <?php
                            
                                      $ye=date('Y',strtotime($yrs.'+2 years'));
                                    $totaldeal_res=$objpipeline->salestotalpendingdealamountyearly($companyname,$ye);
                                    
                                    foreach($totaldeal_res as $totaldeal_row){
                                        $stage1=$totaldeal_row['stage'];
                                        $stage2=explode("%",$stage1);
                                        $stage121=$stage2[0];
                                            $totaldealwon3=$totaldealwon1+($totaldeal_row['amount']*$stage121/100);
                                    }
                                    
                            ?>   
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=12){ ?>border-right:1px solid #ddd; <?php } ?>">
                                    <center><span style="color: #db1b56;font-size:14px;text-decoration: none;">&#8360 <b>&nbsp;<?php echo $totaldealwon3;?></b></span></center>
                                </div>
                            
                            <?php
                                     $ye=date('Y',strtotime($yrs.'+3 years'));
                                    $totaldeal_res=$objpipeline->salestotalpendingdealamountyearly($companyname,$ye);
                                    
                                    foreach($totaldeal_res as $totaldeal_row){
                                        $stage1=$totaldeal_row['stage'];
                                        $stage2=explode("%",$stage1);
                                        $stage121=$stage2[0];
                                            $totaldealwon4=$totaldealwon1+($totaldeal_row['amount']*$stage121/100);
                                    }
                                    
                            ?>   
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=12){ ?>border-right:1px solid #ddd; <?php } ?>">
                                    <center><span style="color: #db1b56;font-size:14px;text-decoration: none;">&#8360 <b>&nbsp;<?php echo $totaldealwon4;?></b></span></center>
                                </div>
                                
                            <?php
                            
                                       $ye=date('Y',strtotime($yrs.'+4 years'));
                                    $totaldeal_res=$objpipeline->salestotalpendingdealamountyearly($companyname,$ye);
                                    
                                    foreach($totaldeal_res as $totaldeal_row){
                                        $stage1=$totaldeal_row['stage'];
                                        $stage2=explode("%",$stage1);
                                        $stage121=$stage2[0];
                                            $totaldealwon5=$totaldealwon1+($totaldeal_row['amount']*$stage121/100);
                                    }
                                    
                            ?>   
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=12){ ?>border-right:1px solid #ddd; <?php } ?>">
                                    <center><span style="color: #db1b56;font-size:14px;text-decoration: none;">&#8360 <b>&nbsp;<?php echo $totaldealwon5;?></b></span></center>
                                </div>
                                
                             <?php
                            
                                     $ye=date('Y',strtotime($yrs.'+5 years'));
                                    $totaldeal_res=$objpipeline->salestotalpendingdealamountyearly($companyname,$ye);
                                    
                                    foreach($totaldeal_res as $totaldeal_row){
                                        $stage1=$totaldeal_row['stage'];
                                        $stage2=explode("%",$stage1);
                                        $stage121=$stage2[0];
                                            $totaldealwon6=$totaldealwon1+($totaldeal_row['amount']*$stage121/100);
                                    }
                                    
                            ?>   
                                <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=12){ ?>border-right:1px solid #ddd; <?php } ?>">
                                    <center><span style="color: #db1b56;font-size:14px;text-decoration: none;">&#8360 <b>&nbsp;<?php echo $totaldealwon6;?></b></span></center>
                                </div>



<?php } ?>

<?php
if(isset($_POST['total_mon'])){
    $quart_month= $_POST['total_mon'];
    $quart_year= $_POST['total_year'];
      require_once('../Control/pipeline.php');
$objpipeline=new pipelinectrl();
?>
  
                    <?php
                        $m_q=$quart_month;
                        $y_q=$quart_year;
                         $moq=$y_q."-".$m_q."-01";
                        if($m_q<=3){
                            $id="01";
                     $myresult=$objpipeline->salespipelineexpected_quartely_total($companyname,01,$y_q);
                        }
                        if($m_q>=4 && $m_q <=6){
                            $id="02";
                     $myresult=$objpipeline->salespipelineexpected_quartely_total($companyname,02,$y_q);
                        }
                        if($m_q>=7 && $m_q <=9){
                            $id="03";
                     $myresult=$objpipeline->salespipelineexpected_quartely_total($companyname,03,$y_q);
                        }
                        if($m_q>=10 && $m_q <=12){
                            $id="04";
                     $myresult=$objpipeline->salespipelineexpected_quartely_total($companyname,04,$y_q);
                        }
                       
                    ?>
                    
                     <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                
                                <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_total_deal_quart('<?php echo $companyname;?>','<?php echo $id;?>','<?php echo $y_q;?>')"><center>&#8360&nbsp;<b><?php print_r($myresult); ?></b></center></a>
                                <?php if($myresult==""){ ?>
                                <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;</span></center>
                                <?php } ?>
                    </div> 
                    
                    <?php
                          $m_qs=$quart_month;
                        $y_qs=$quart_year;
                        $moqs="$y_qs-$m_qs-01";
                         $m_q=date('m',strtotime($moqs.'+3 months'));
                        $y_q=date('Y', strtotime($moqs.'+3 months'));
                        
                       if($m_q<=3){
                            $id="01";
                     $myresult=$objpipeline->salespipelineexpected_quartely_total($companyname,01,$y_q);
                        }
                        if($m_q>=4 && $m_q <=6){
                            $id="02";
                     $myresult=$objpipeline->salespipelineexpected_quartely_total($companyname,02,$y_q);
                        }
                        if($m_q>=7 && $m_q <=9){
                            $id="03";
                     $myresult=$objpipeline->salespipelineexpected_quartely_total($companyname,03,$y_q);
                        }
                        if($m_q>=10 && $m_q <=12){
                            $id="04";
                     $myresult=$objpipeline->salespipelineexpected_quartely_total($companyname,04,$y_q);
                        }
                    ?>
                    
                    <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                
                                <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_total_deal_quart('<?php echo $companyname;?>','<?php echo $id;?>','<?php echo $y_q;?>')"><center>&#8360&nbsp;<b><?php print_r($myresult); ?></b></center></a>
                                <?php if($myresult==""){ ?>
                                <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;</span></center>
                                <?php } ?>
                    </div> 
                    
                    <?php
                          $m_qs=$quart_month;
                        $y_qs=$quart_year;
                        $moqs="$y_qs-$m_qs-01";
                         $m_q=date('m',strtotime($moqs.'+6 months'));
                        $y_q=date('Y', strtotime($moqs.'+6 months'));
                       if($m_q<=3){
                            $id="01";
                     $myresult=$objpipeline->salespipelineexpected_quartely_total($companyname,01,$y_q);
                        }
                        if($m_q>=4 && $m_q <=6){
                            $id="02";
                     $myresult=$objpipeline->salespipelineexpected_quartely_total($companyname,02,$y_q);
                        }
                        if($m_q>=7 && $m_q <=9){
                            $id="03";
                     $myresult=$objpipeline->salespipelineexpected_quartely_total($companyname,03,$y_q);
                        }
                        if($m_q>=10 && $m_q <=12){
                            $id="04";
                     $myresult=$objpipeline->salespipelineexpected_quartely_total($companyname,04,$y_q);
                        }
                 
                        
                    
                    ?>
                    <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                
                                <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_total_deal_quart('<?php echo $companyname;?>','<?php echo $id;?>','<?php echo $y_q;?>')"><center>&#8360&nbsp;<b><?php print_r($myresult); ?></b></center></a>
                                <?php if($myresult==""){ ?>
                                <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;</span></center>
                                <?php } ?>
                    </div> 
                    
                      <?php
                          $m_qs=$quart_month;
                        $y_qs=$quart_year;
                        $moqs="$y_qs-$m_qs-01";
                         $m_q=date('m',strtotime($moqs.'+9 months'));
                        $y_q=date('Y', strtotime($moqs.'+9 months'));
                        if($m_q<=3){
                            $id="01";
                     $myresult=$objpipeline->salespipelineexpected_quartely_total($companyname,01,$y_q);
                        }
                        if($m_q>=4 && $m_q <=6){
                            $id="02";
                     $myresult=$objpipeline->salespipelineexpected_quartely_total($companyname,02,$y_q);
                        }
                        if($m_q>=7 && $m_q <=9){
                            $id="03";
                     $myresult=$objpipeline->salespipelineexpected_quartely_total($companyname,03,$y_q);
                        }
                        if($m_q>=10 && $m_q <=12){
                            $id="04";
                     $myresult=$objpipeline->salespipelineexpected_quartely_total($companyname,04,$y_q);
                        }
                 
                        
                    
                    ?>
                    
                    <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                
                                <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_total_deal_quart('<?php echo $companyname;?>','<?php echo $id;?>','<?php echo $y_q;?>')"><center>&#8360&nbsp;<b><?php print_r($myresult); ?></b></center></a>
                                <?php if($myresult==""){ ?>
                                <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;</span></center>
                                <?php } ?>
                    </div> 
                     <?php
                          $m_qs=$quart_month;
                        $y_qs=$quart_year;
                        $moqs="$y_qs-$m_qs-01";
                         $m_q=date('m',strtotime($moqs.'+12 months'));
                        $y_q=date('Y', strtotime($moqs.'+12 months'));
                       if($m_q<=3){
                            $id="01";
                     $myresult=$objpipeline->salespipelineexpected_quartely_total($companyname,01,$y_q);
                        }
                        if($m_q>=4 && $m_q <=6){
                            $id="02";
                     $myresult=$objpipeline->salespipelineexpected_quartely_total($companyname,02,$y_q);
                        }
                        if($m_q>=7 && $m_q <=9){
                            $id="03";
                     $myresult=$objpipeline->salespipelineexpected_quartely_total($companyname,03,$y_q);
                        }
                        if($m_q>=10 && $m_q <=12){
                            $id="04";
                     $myresult=$objpipeline->salespipelineexpected_quartely_total($companyname,04,$y_q);
                        }
                 
                        
                    
                    ?>
                    <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                
                                <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_total_deal_quart('<?php echo $companyname;?>','<?php echo $id;?>','<?php echo $y_q;?>')"><center>&#8360&nbsp;<b><?php print_r($myresult); ?></b></center></a>
                                <?php if($myresult==""){ ?>
                                <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;</span></center>
                                <?php } ?>
                    </div> 
                    
                    <?php
                          $m_qs=$quart_month;
                        $y_qs=$quart_year;
                        $moqs="$y_qs-$m_qs-01";
                         $m_q=date('m',strtotime($moqs.'+15 months'));
                        $y_q=date('Y', strtotime($moqs.'+15 months'));
                       if($m_q<=3){
                            $id="01";
                     $myresult=$objpipeline->salespipelineexpected_quartely_total($companyname,01,$y_q);
                        }
                        if($m_q>=4 && $m_q <=6){
                            $id="02";
                     $myresult=$objpipeline->salespipelineexpected_quartely_total($companyname,02,$y_q);
                        }
                        if($m_q>=7 && $m_q <=9){
                            $id="03";
                     $myresult=$objpipeline->salespipelineexpected_quartely_total($companyname,03,$y_q);
                        }
                        if($m_q>=10 && $m_q <=12){
                            $id="04";
                     $myresult=$objpipeline->salespipelineexpected_quartely_total($companyname,04,$y_q);
                        }
                 
                        
                    
                    ?>
                    <div class="col-md-2" style="color:black;cursor:pointer;padding-top:15px;height:50px;background-color:#fff;border-right:1px solid #ddd;">
                                
                                <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_total_deal_quart('<?php echo $companyname;?>','<?php echo $id;?>','<?php echo $y_q;?>')"><center>&#8360&nbsp;<b><?php print_r($myresult); ?></b></center></a>
                                <?php if($myresult==""){ ?>
                                <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;</span></center>
                                <?php } ?>
                    </div> 
                        
                
<?php } ?>


<?php
session_start();
$companyname=$_SESSION['companyname'];//;
$adminemailid=$_SESSION['emailid'];//;
if(isset($_POST['stage_mon'])) {
     $quart_month= $_POST['stage_mon'];
    $quart_year= $_POST['stage_year'];
     require_once('../Control/pipeline.php');
$objpipeline=new pipelinectrl();
require_once('../Control/sales.php');
$objsales=new salesctrl();
$pipelinetype_res=$objsales->salesselectall($companyname, $adminemailid, "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++;
}
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 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
                         $m_q=$quart_month;
                        $y_q=$quart_year;
                         $moq=$y_q."-".$m_q."-01";
                        if($m_q<=3){
                                $id="01";
                         $per_result=$objpipeline->sales_per_quartely_select($companyname,$stage,01,$y_q);
                            }
                            if($m_q>=4 && $m_q <=6){
                                    $id="02";
                         $per_result=$objpipeline->sales_per_quartely_select($companyname,$stage,02,$y_q);
                            }
                            if($m_q>=7 && $m_q <=9){
                                    $id="03";
                         $per_result=$objpipeline->sales_per_quartely_select($companyname,$stage,03,$y_q);
                            }
                            if($m_q>=10 && $m_q <=12){
                                    $id="04";
                         $per_result=$objpipeline->sales_per_quartely_select($companyname,$stage,04,$y_q);
                            }
                        
                       
                    ?>
                   
                        <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=6){ ?>border-right:1px solid #ddd; <?php } ?>">
                           
                                <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_deal_stage_quart('<?php echo $companyname;?>','<?php echo $id;?>','<?php echo $y_q;?>','<?php echo $stage;?>')"><center>&#8360&nbsp;<?php print_r( $per_result);?></center></a>
                          
                                <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                           
                        </div>
                    
                    <?php
                       
                       $m_qs=$quart_month;
                        $y_qs=$quart_year;
                        $moqs="$y_qs-$m_qs-01";
                         $m_q=date('m',strtotime($moqs.'+3 months'));
                        $y_q=date('Y', strtotime($moqs.'+3 months'));
                        
                        if($m_q<=3){
                                $id="01";
                         $per_result=$objpipeline->sales_per_quartely_select($companyname,$stage,01,$y_q);
                            }
                            if($m_q>=4 && $m_q <=6){
                                    $id="02";
                         $per_result=$objpipeline->sales_per_quartely_select($companyname,$stage,02,$y_q);
                            }
                            if($m_q>=7 && $m_q <=9){
                                    $id="03";
                         $per_result=$objpipeline->sales_per_quartely_select($companyname,$stage,03,$y_q);
                            }
                            if($m_q>=10 && $m_q <=12){
                                    $id="04";
                         $per_result=$objpipeline->sales_per_quartely_select($companyname,$stage,04,$y_q);
                            }
                        
                        
                    ?>
                        <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=6){ ?>border-right:1px solid #ddd; <?php } ?>">
                           
                                <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_deal_stage_quart('<?php echo $companyname;?>','<?php echo $id;?>','<?php echo $y_q;?>','<?php echo $stage;?>')"><center>&#8360&nbsp;<?php echo $per_result;?></center></a>
                          
                                <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                           
                        </div>
                    <?php
                     $m_qs=$quart_month;
                        $y_qs=$quart_year;
                        $moqs="$y_qs-$m_qs-01";
                         $m_q=date('m',strtotime($moqs.'+6 months'));
                        $y_q=date('Y', strtotime($moqs.'+6 months'));
                        
                       if($m_q<=3){
                                $id="01";
                         $per_result=$objpipeline->sales_per_quartely_select($companyname,$stage,01,$y_q);
                            }
                            if($m_q>=4 && $m_q <=6){
                                    $id="02";
                         $per_result=$objpipeline->sales_per_quartely_select($companyname,$stage,02,$y_q);
                            }
                            if($m_q>=7 && $m_q <=9){
                                    $id="03";
                         $per_result=$objpipeline->sales_per_quartely_select($companyname,$stage,03,$y_q);
                            }
                            if($m_q>=10 && $m_q <=12){
                                    $id="04";
                         $per_result=$objpipeline->sales_per_quartely_select($companyname,$stage,04,$y_q);
                            }
                    
                    ?>
                        <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=6){ ?>border-right:1px solid #ddd; <?php } ?>">
                           
                                <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_deal_stage_quart('<?php echo $companyname;?>','<?php echo $id;?>','<?php echo $y_q;?>','<?php echo $stage;?>')"><center>&#8360&nbsp;<?php echo $per_result;?></center></a>
                          
                                <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                           
                        </div>
                    <?php
                    $m_qs=$quart_month;
                        $y_qs=$quart_year;
                        $moqs="$y_qs-$m_qs-01";
                         $m_q=date('m',strtotime($moqs.'+9 months'));
                        $y_q=date('Y', strtotime($moqs.'+9 months'));
                       if($m_q<=3){
                                $id="01";
                         $per_result=$objpipeline->sales_per_quartely_select($companyname,$stage,01,$y_q);
                            }
                            if($m_q>=4 && $m_q <=6){
                                    $id="02";
                         $per_result=$objpipeline->sales_per_quartely_select($companyname,$stage,02,$y_q);
                            }
                            if($m_q>=7 && $m_q <=9){
                                    $id="03";
                         $per_result=$objpipeline->sales_per_quartely_select($companyname,$stage,03,$y_q);
                            }
                            if($m_q>=10 && $m_q <=12){
                                    $id="04";
                         $per_result=$objpipeline->sales_per_quartely_select($companyname,$stage,04,$y_q);
                            }
                    
                    ?>    
                        <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=6){ ?>border-right:1px solid #ddd; <?php } ?>">
                           
                                <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_deal_stage_quart('<?php echo $companyname;?>','<?php echo $id;?>','<?php echo $y_q;?>','<?php echo $stage;?>')"><center>&#8360&nbsp;<?php echo $per_result;?></center></a>
                          
                                <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                           
                        </div>
                    <?php
                     $m_qs=$quart_month;
                        $y_qs=$quart_year;
                        $moqs="$y_qs-$m_qs-01";
                         $m_q=date('m',strtotime($moqs.'+12 months'));
                        $y_q=date('Y', strtotime($moqs.'+12 months'));
                       if($m_q<=3){
                                $id="01";
                         $per_result=$objpipeline->sales_per_quartely_select($companyname,$stage,01,$y_q);
                            }
                            if($m_q>=4 && $m_q <=6){
                                    $id="02";
                         $per_result=$objpipeline->sales_per_quartely_select($companyname,$stage,02,$y_q);
                            }
                            if($m_q>=7 && $m_q <=9){
                                    $id="03";
                         $per_result=$objpipeline->sales_per_quartely_select($companyname,$stage,03,$y_q);
                            }
                            if($m_q>=10 && $m_q <=12){
                                    $id="04";
                         $per_result=$objpipeline->sales_per_quartely_select($companyname,$stage,04,$y_q);
                            }
                    
                    ?>    
                        <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=6){ ?>border-right:1px solid #ddd; <?php } ?>">
                           
                                <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_deal_stage_quart('<?php echo $companyname;?>','<?php echo $id;?>','<?php echo $y_q;?>','<?php echo $stage;?>')"><center>&#8360&nbsp;<?php echo $per_result;?></center></a>
                          
                                <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                           
                        </div>
                    <?php
                    
                     $m_qs=$quart_month;
                        $y_qs=$quart_year;
                        $moqs="$y_qs-$m_qs-01";
                         $m_q=date('m',strtotime($moqs.'+15 months'));
                        $y_q=date('Y', strtotime($moqs.'+15 months'));
                        if($m_q<=3){
                                $id="01";
                         $per_result=$objpipeline->sales_per_quartely_select($companyname,$stage,01,$y_q);
                            }
                            if($m_q>=4 && $m_q <=6){
                                    $id="02";
                         $per_result=$objpipeline->sales_per_quartely_select($companyname,$stage,02,$y_q);
                            }
                            if($m_q>=7 && $m_q <=9){
                                    $id="03";
                         $per_result=$objpipeline->sales_per_quartely_select($companyname,$stage,03,$y_q);
                            }
                            if($m_q>=10 && $m_q <=12){
                                    $id="04";
                         $per_result=$objpipeline->sales_per_quartely_select($companyname,$stage,04,$y_q);
                            }
                    
                    ?>
                        <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=12){ ?>border-right:1px solid #ddd; <?php } ?>">
                           
                                <a style="color:black;font-size:14px;" data-toggle="modal" data-target="#myModal_view_pipeline_deal" onclick="show_pipeline_deal_stage_quart('<?php echo $companyname;?>','<?php echo $id;?>','<?php echo $y_q;?>','<?php echo $stage;?>')"><center>&#8360&nbsp;<?php echo $per_result;?></center></a>
                          
                                <center><span style="color: #ccc;text-decoration: none;">&#8360&nbsp;0</span></center>
                         
                        </div>
                       
                </div>
            </div>
            <br>
<?php } }?>


<?php
session_start();
$companyname=$_SESSION['companyname'];//;
$adminemailid=$_SESSION['emailid'];//;
if(isset($_POST['pen_mon'])){
    $quart_month=$_POST['pen_mon'];
    $quart_year=$_POST['pen_year'];
    require_once('../Control/pipeline.php');
$objpipeline=new pipelinectrl();
?>
 
                    
                    <?php
                    
                       $m_q=$quart_month;
                        $y_q=$quart_year;
                         $moq=$y_q."-".$m_q."-01";
                        if($m_q<=3){
                     $totaldeal_res=$objpipeline->salestotalpendingdealamountquartely($adminemailid,01,$y_q);
                        }
                        if($m_q>=4 && $m_q <=6){
                     $totaldeal_res=$objpipeline->salestotalpendingdealamountquartely($adminemailid,02,$y_q);
                        }
                        if($m_q>=7 && $m_q <=9){
                     $totaldeal_res=$objpipeline->salestotalpendingdealamountquartely($adminemailid,03,$y_q);
                        }
                        if($m_q>=10 && $m_q <=12){
                     $totaldeal_res=$objpipeline->salestotalpendingdealamountquartely($adminemailid,04,$y_q);
                        }
                           
                            foreach($totaldeal_res as $totaldeal_row){
                                $stage1=$totaldeal_row['stage'];
                                $stage2=explode("%",$stage1);
                                $stage121=$stage2[0];
                                    $totaldealwon_quar1=$totaldealwon1+($totaldeal_row['amount']*$stage121/100);
                            }
                            
                    ?>   
                        <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=6){ ?>border-right:1px solid #ddd; <?php } ?>">
                            <center><span style="color: #db1b56;font-size:14px;text-decoration: none;">&#8360&nbsp;<b><?php  print_r($totaldealwon_quar1);?></b></span></center>
                        </div>
                    <?php
                    
                         $m_qs=$quart_month;
                        $y_qs=$quart_year;
                        $moqs="$y_qs-$m_qs-01";
                         $m_q=date('m',strtotime($moqs.'+3 months'));
                        $y_q=date('Y', strtotime($moqs.'+3 months'));
                               if($m_q<=3){
                     $totaldeal_res=$objpipeline->salestotalpendingdealamountquartely($adminemailid,01,$y_q);
                        }
                        if($m_q>=4 && $m_q <=6){
                     $totaldeal_res=$objpipeline->salestotalpendingdealamountquartely($adminemailid,02,$y_q);
                        }
                        if($m_q>=7 && $m_q <=9){
                     $totaldeal_res=$objpipeline->salestotalpendingdealamountquartely($adminemailid,03,$y_q);
                        }
                        if($m_q>=10 && $m_q <=12){
                     $totaldeal_res=$objpipeline->salestotalpendingdealamountquartely($adminemailid,04,$y_q);
                        }
                            foreach($totaldeal_res as $totaldeal_row){
                                $stage1=$totaldeal_row['stage'];
                                $stage2=explode("%",$stage1);
                                $stage121=$stage2[0];
                                    $totaldealwon_quar2=$totaldealwon1+($totaldeal_row['amount']*$stage121/100);
                            }
                            
                    ?>   
                        <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=12){ ?>border-right:1px solid #ddd; <?php } ?>">
                            <center><span style="color: #db1b56;font-size:14px;text-decoration: none;">&#8360 <b>&nbsp;<?php echo $totaldealwon_quar2;?></b></span></center>
                        </div>
                        
                     <?php
                    
                            $m_qs=$quart_month;
                        $y_qs=$quart_year;
                        $moqs="$y_qs-$m_qs-01";
                         $m_q=date('m',strtotime($moqs.'+6 months'));
                        $y_q=date('Y', strtotime($moqs.'+6 months'));
                                if($m_q<=3){
                     $totaldeal_res=$objpipeline->salestotalpendingdealamountquartely($adminemailid,01,$y_q);
                        }
                        if($m_q>=4 && $m_q <=6){
                     $totaldeal_res=$objpipeline->salestotalpendingdealamountquartely($adminemailid,02,$y_q);
                        }
                        if($m_q>=7 && $m_q <=9){
                     $totaldeal_res=$objpipeline->salestotalpendingdealamountquartely($adminemailid,03,$y_q);
                        }
                        if($m_q>=10 && $m_q <=12){
                     $totaldeal_res=$objpipeline->salestotalpendingdealamountquartely($adminemailid,04,$y_q);
                        }
                            foreach($totaldeal_res as $totaldeal_row){
                                $stage1=$totaldeal_row['stage'];
                                $stage2=explode("%",$stage1);
                                $stage121=$stage2[0];
                                    $totaldealwon_quar3=$totaldealwon1+($totaldeal_row['amount']*$stage121/100);
                            }
                            
                    ?>   
                        <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=12){ ?>border-right:1px solid #ddd; <?php } ?>">
                            <center><span style="color: #db1b56;font-size:14px;text-decoration: none;">&#8360 <b>&nbsp;<?php echo $totaldealwon_quar3;?></b></span></center>
                        </div>
                    
                    <?php
                            $m_qs=$quart_month;
                        $y_qs=$quart_year;
                        $moqs="$y_qs-$m_qs-01";
                         $m_q=date('m',strtotime($moqs.'+9 months'));
                        $y_q=date('Y', strtotime($moqs.'+9 months'));
                               if($m_q<=3){
                     $totaldeal_res=$objpipeline->salestotalpendingdealamountquartely($adminemailid,01,$y_q);
                        }
                        if($m_q>=4 && $m_q <=6){
                     $totaldeal_res=$objpipeline->salestotalpendingdealamountquartely($adminemailid,02,$y_q);
                        }
                        if($m_q>=7 && $m_q <=9){
                     $totaldeal_res=$objpipeline->salestotalpendingdealamountquartely($adminemailid,03,$y_q);
                        }
                        if($m_q>=10 && $m_q <=12){
                     $totaldeal_res=$objpipeline->salestotalpendingdealamountquartely($adminemailid,04,$y_q);
                        }
                            foreach($totaldeal_res as $totaldeal_row){
                                $stage1=$totaldeal_row['stage'];
                                $stage2=explode("%",$stage1);
                                $stage121=$stage2[0];
                                    $totaldealwon_quar4=$totaldealwon1+($totaldeal_row['amount']*$stage121/100);
                            }
                            
                    ?>   
                        <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=12){ ?>border-right:1px solid #ddd; <?php } ?>">
                            <center><span style="color: #db1b56;font-size:14px;text-decoration: none;">&#8360 <b>&nbsp;<?php echo $totaldealwon_quar4;?></b></span></center>
                        </div>
                        
                    <?php
                    
                         $m_qs=$quart_month;
                        $y_qs=$quart_year;
                        $moqs="$y_qs-$m_qs-01";
                         $m_q=date('m',strtotime($moqs.'+12 months'));
                        $y_q=date('Y', strtotime($moqs.'+12 months'));
                             if($m_q<=3){
                     $totaldeal_res=$objpipeline->salestotalpendingdealamountquartely($adminemailid,01,$y_q);
                        }
                        if($m_q>=4 && $m_q <=6){
                     $totaldeal_res=$objpipeline->salestotalpendingdealamountquartely($adminemailid,02,$y_q);
                        }
                        if($m_q>=7 && $m_q <=9){
                     $totaldeal_res=$objpipeline->salestotalpendingdealamountquartely($adminemailid,03,$y_q);
                        }
                        if($m_q>=10 && $m_q <=12){
                     $totaldeal_res=$objpipeline->salestotalpendingdealamountquartely($adminemailid,04,$y_q);
                        }
                            foreach($totaldeal_res as $totaldeal_row){
                                $stage1=$totaldeal_row['stage'];
                                $stage2=explode("%",$stage1);
                                $stage121=$stage2[0];
                                    $totaldealwon_quar5=$totaldealwon1+($totaldeal_row['amount']*$stage121/100);
                            }
                            
                    ?>   
                        <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=12){ ?>border-right:1px solid #ddd; <?php } ?>">
                            <center><span style="color: #db1b56;font-size:14px;text-decoration: none;">&#8360 <b>&nbsp;<?php echo $totaldealwon_quar5;?></b></span></center>
                        </div>
                        
                     <?php
                    
                             $m_qs=$quart_month;
                        $y_qs=$quart_year;
                        $moqs="$y_qs-$m_qs-01";
                         $m_q=date('m',strtotime($moqs.'+15 months'));
                        $y_q=date('Y', strtotime($moqs.'+15 months'));  
                             if($m_q<=3){
                     $totaldeal_res=$objpipeline->salestotalpendingdealamountquartely($adminemailid,01,$y_q);
                        }
                        if($m_q>=4 && $m_q <=6){
                     $totaldeal_res=$objpipeline->salestotalpendingdealamountquartely($adminemailid,02,$y_q);
                        }
                        if($m_q>=7 && $m_q <=9){
                     $totaldeal_res=$objpipeline->salestotalpendingdealamountquartely($adminemailid,03,$y_q);
                        }
                        if($m_q>=10 && $m_q <=12){
                     $totaldeal_res=$objpipeline->salestotalpendingdealamountquartely($adminemailid,04,$y_q);
                        }
                            foreach($totaldeal_res as $totaldeal_row){
                                $stage1=$totaldeal_row['stage'];
                                $stage2=explode("%",$stage1);
                                $stage121=$stage2[0];
                                    $totaldealwon_quar6=$totaldealwon1+($totaldeal_row['amount']*$stage121/100);
                            }
                            
                    ?>   
                        <div class="col-md-2" style="color:black;cursor:pointer;padding-top:10px;height:40px;background-color:#fff;<?php if($i!=12){ ?>border-right:1px solid #ddd; <?php } ?>">
                            <center><span style="color: #db1b56;font-size:14px;text-decoration: none;">&#8360 <b>&nbsp;<?php echo $totaldealwon_quar6;?></b></span></center>
                        </div>
                

<?php } ?>