<?php
session_start();
$companyname=$_SESSION['companyname'];//;
$adminemailid=$_SESSION['emailid'];//;
require_once('../Control/sales.php');
$objsales=new salesctrl();
require_once('../Control/employee.php');
$objemployee=new employeectrl();
require_once('../Control/pipeline.php');
$objpipeline=new pipelinectrl();
$emp_res=$objsales->salesselectall($companyname, $adminemailid, "signupdetails", "no");
//print_r($emp_res);
//print_r($emp_res);
$j=0;
foreach($emp_res as $emp_row){
 $emp_emailid_a[$j++]=$emp_row['emailid'];   
}


if(isset($_POST['mon'])){
    $ii=$_POST['mon'];
    $year=$_POST['year'];
?>
       <?php
                            $i=$ii;
                                $year=$year;
                                $months=$year."-".$i."-01";
                                //salespipelineemployeetarget($companyname,$email,$year,$month) $emp_emailid_a
                                    $traget_amount=0;
                                        $totaldeal_res=$objpipeline->salespipelineemployeetarget($companyname,$email1,$year,$i);
                                        $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;
                                        }
                                        if($traget_amount==null){
                                            $traget_amount=5000;
                                        }
                            ?> 
                            <div class="col-md-2">
                                <input type="text" class="form-control" name="<?php echo $string.'@@@'.$i.'@@@'.$year;?>" onchange="getinputfunction('<?php echo $email1."@@@".$i."@@@".$year;?>','<?php echo $string."___".$i."___".$year;?>')" id="<?php echo $string.'___'.$i.'___'.$year;?>" value="<?php echo $traget_amount;?>">
                            </div>
                           
                           
                           
                            <?php
                            $i=date('m',strtotime($months.'+1 months'));
                                $year=date('Y',strtotime($months.'+1 months'));
                                
                                //salespipelineemployeetarget($companyname,$email,$year,$month) $emp_emailid_a
                                    $traget_amount=0;
                                        $totaldeal_res=$objpipeline->salespipelineemployeetarget($companyname,$email1,$year,$i);
                                        $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;
                                        }
                                        if($traget_amount==null){
                                            $traget_amount=5000;
                                        }
                            ?> 
                            <div class="col-md-2">
                                <input type="text" class="form-control" name="<?php echo $string.'@@@'.$i.'@@@'.$year;?>" onchange="getinputfunction('<?php echo $email1."@@@".$i."@@@".$year;?>','<?php echo $string."___".$i."___".$year;?>')" id="<?php echo $string.'___'.$i.'___'.$year;?>" value="<?php echo $traget_amount;?>">
                            </div>
                     
                      
                            <?php
                            $i=date('m',strtotime($months.'+2 months'));
                                $year=date('Y',strtotime($months.'+2 months'));
                                
                                //salespipelineemployeetarget($companyname,$email,$year,$month) $emp_emailid_a
                                    $traget_amount=0;
                                        $totaldeal_res=$objpipeline->salespipelineemployeetarget($companyname,$email1,$year,$i);
                                        $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;
                                        }
                                        if($traget_amount==null){
                                            $traget_amount=5000;
                                        }
                            ?> 
                            <div class="col-md-2">
                                <input type="text" class="form-control" name="<?php echo $string.'@@@'.$i.'@@@'.$year;?>" onchange="getinputfunction('<?php echo $email1."@@@".$i."@@@".$year;?>','<?php echo $string."___".$i."___".$year;?>')" id="<?php echo $string.'___'.$i.'___'.$year;?>" value="<?php echo $traget_amount;?>">
                            </div>
                            
                            <?php
                            $i=date('m',strtotime($months.'+3 months'));
                                $year=date('Y',strtotime($months.'+3 months'));
                                
                                //salespipelineemployeetarget($companyname,$email,$year,$month) $emp_emailid_a
                                    $traget_amount=0;
                                        $totaldeal_res=$objpipeline->salespipelineemployeetarget($companyname,$email1,$year,$i);
                                        $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;
                                        }
                                        if($traget_amount==null){
                                            $traget_amount=5000;
                                        }
                            ?> 
                            <div class="col-md-2">
                                <input type="text" class="form-control" name="<?php echo $string.'@@@'.$i.'@@@'.$year;?>" onchange="getinputfunction('<?php echo $email1."@@@".$i."@@@".$year;?>','<?php echo $string."___".$i."___".$year;?>')" id="<?php echo $string.'___'.$i.'___'.$year;?>" value="<?php echo $traget_amount;?>">
                            </div>
                            
                            <?php
                            $i=date('m',strtotime($months.'+4 months'));
                                $year=date('Y',strtotime($months.'+4 months'));
                                
                                //salespipelineemployeetarget($companyname,$email,$year,$month) $emp_emailid_a
                                    $traget_amount=0;
                                        $totaldeal_res=$objpipeline->salespipelineemployeetarget($companyname,$email1,$year,$i);
                                        $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;
                                        }
                                        if($traget_amount==null){
                                            $traget_amount=5000;
                                        }
                            ?> 
                            <div class="col-md-2">
                                <input type="text" class="form-control" name="<?php echo $string.'@@@'.$i.'@@@'.$year;?>" onchange="getinputfunction('<?php echo $email1."@@@".$i."@@@".$year;?>','<?php echo $string."___".$i."___".$year;?>')" id="<?php echo $string.'___'.$i.'___'.$year;?>" value="<?php echo $traget_amount;?>">
                            </div>
                            
                            <?php
                            $i=date('m',strtotime($months.'+5 months'));
                                $year=date('Y',strtotime($months.'+5 months'));
                                
                                //salespipelineemployeetarget($companyname,$email,$year,$month) $emp_emailid_a
                                    $traget_amount=0;
                                        $totaldeal_res=$objpipeline->salespipelineemployeetarget($companyname,$email1,$year,$i);
                                        $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;
                                        }
                                        if($traget_amount==null){
                                            $traget_amount=5000;
                                        }
                            ?> 
                            <div class="col-md-2">
                                <input type="text" class="form-control" name="<?php echo $string.'@@@'.$i.'@@@'.$year;?>" onchange="getinputfunction('<?php echo $email1."@@@".$i."@@@".$year;?>','<?php echo $string."___".$i."___".$year;?>')" id="<?php echo $string.'___'.$i.'___'.$year;?>" value="<?php echo $traget_amount;?>">
                            </div>

<?php
}

?>