<?php
session_start();
$companyname=$_SESSION['companyname'];
$adminemailid=$_SESSION['emailid'];

if(($adminemailid !="")&&($companyname!="")){
require_once('../Control/sales.php');
$objsales=new salesctrl();

$piplestage_res=$objsales->salesselectall($companyname, $adminemailid, "sales_pipe_type", "no");
$g=0;
foreach($piplestage_res as $piplestage_row){
    $percentage==$piplestage_row['pipe_percentage'];
    //$centage=explode("%",$percentage);
    $pipe_name=$piplestage_row['pipe_name']."&&".$piplestage_row['id'];
    $piplepercentage_a[$pipe_name]=substr($piplestage_row['pipe_percentage'],0,2);//$centage[0];
}
//print_r($piplepercentage_a);
asort($piplepercentage_a);
//print_r($piplepercentage_a);
foreach($piplepercentage_a as $key => $value)
{
  $mykey = $key;
  $s1=explode("&&", $mykey);
  $a_percentage_name[$g]=$s1[0];
  $a_percentage_id[$g]=$s1[1];
  $a_pencentage[$g++]=$value;
}

?>
<!doctype html>
<html>
    <head>
    
        <link rel="icon" href="../../Images/cloud-icon-27.png">
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="../../Bootstrap/css/bootstrap.min.css">
        <script src="../../Bootstrap/jquery.min.js"></script>
        <script src="../../Bootstrap/js/bootstrap.min.js"></script>
        <script src="../../Bootbox/bootbox.min.js"></script>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-sweetalert/1.0.1/sweetalert.min.css">
        <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-sweetalert/1.0.1/sweetalert.min.js"></script>
        
    </head>
    
    <body>
        
       <!-- <div class="container">-->
            
            <div class="col-md-8">
                
                <div class="row">
                    
                    <div class="col-md-4">
                        <span style="color:#999;"><center>%</center></span>
                    </div>
                    
                    <div class="col-md-8">
                        <span style="color:#999;"><center>Stage name</center></span>
                    </div>
                    
                </div>
                
                <div class="row">
                    
                    <div class="col-md-4">
                        <span style="color:#999;">
                            <center>
                                <input type="hidden" name="pipe_id1" id="pipe_id1" value="<?php if(count($a_percentage_id)>0){ echo $a_percentage_id[0]; }else{ echo ""; } ;?>" class="form-control" >  
                                <input type="text" name="pipe_stage1" maxlength="2" id="pipe_stage1" value="<?php if(count($a_pencentage)>0){ echo $a_pencentage[0]; }else{ echo ""; } ;?>" class="form-control" >  
                            </center>  
                        </span>
                    </div>
                    
                    <div class="col-md-8">
                        <span style="color:#999;">
                            <center>
                                <input type="text" name="pipe_name1" id="pipe_name1" value="<?php if(count($a_percentage_name)>0){ echo $a_percentage_name[0]; }else{ echo ""; } ;?>" class="form-control" >  
                            </center>
                        </span>
                    </div>
                    
                </div>
                <br>
                <div class="row">
                    
                    <div class="col-md-4">
                        <span style="color:#999;">
                            <center>
                                <input type="hidden" name="pipe_id2" id="pipe_id2" value="<?php if(count($a_percentage_id)>1){ echo $a_percentage_id[1]; }else{ echo ""; } ;?>" class="form-control" >  
                                <input type="text" name="pipe_stage2" maxlength="2" id="pipe_stage2" value="<?php if(count($a_pencentage)>1){ echo $a_pencentage[1]; }else{ echo ""; } ;?>" class="form-control" >  
                            </center> 
                        </span>
                    </div>
                    
                    <div class="col-md-8">
                        <span style="color:#999;">
                            <center> 
                                <input type="text" name="pipe_name2" id="pipe_name2" value="<?php if(count($a_percentage_name)>1){ echo $a_percentage_name[1]; }else{ echo ""; } ;?>" class="form-control" >  
                            </center>
                        </span>
                    </div>
                    
                </div>
                <br>
                <div class="row">
                    
                    <div class="col-md-4">
                        <span style="color:#999;">
                            <center>
                                <input type="hidden" name="pipe_id3" id="pipe_id3" value="<?php if(count($a_percentage_id)>2){ echo $a_percentage_id[2]; }else{ echo ""; } ;?>" class="form-control" >  
                                <input type="text" name="pipe_stage3" maxlength="2" id="pipe_stage3" value="<?php if(count($a_pencentage)>2){ echo $a_pencentage[2]; }else{ echo ""; } ;?>" class="form-control" >  
                            </center> 
                        </span>
                    </div>
                    
                    <div class="col-md-8">
                        <span style="color:#999;">
                            <center> 
                                <input type="text" name="pipe_name3" id="pipe_name3" value="<?php if(count($a_percentage_name)>2){ echo $a_percentage_name[2]; }else{ echo ""; } ;?>" class="form-control" >  
                            </center>
                        </span>
                    </div>
                    
                </div>
                <br>
                <div class="row">
                    
                    <div class="col-md-4">
                        <span style="color:#999;">
                            <center>
                                <input type="hidden" name="pipe_id4" id="pipe_id4" value="<?php if(count($a_percentage_id)>3){ echo $a_percentage_id[3]; }else{ echo ""; } ;?>" class="form-control" > 
                                <input type="text" name="pipe_stage4" maxlength="2" id="pipe_stage4" value="<?php if(count($a_pencentage)>3){ echo $a_pencentage[3]; }else{ echo ""; } ;?>" class="form-control" >  
                            </center> 
                        </span>
                    </div>
                    
                    <div class="col-md-8">
                        <span style="color:#999;">
                            <center>
                                <input type="text" name="pipe_name4" id="pipe_name4" value="<?php if(count($a_percentage_name)>3){ echo $a_percentage_name[3]; }else{ echo ""; } ;?>" class="form-control" >  
                            </center>
                        </span>
                    </div>
                    
                </div>
                <br>
                <div class="row">
                    
                    <div class="col-md-4">
                        <span style="color:#999;">
                            <center>
                                <input type="hidden" name="pipe_id5" id="pipe_id5" value="<?php if(count($a_percentage_id)>4){ echo $a_percentage_id[4]; }else{ echo ""; } ;?>" class="form-control" > 
                                <input type="text" name="pipe_stage5" maxlength="2" id="pipe_stage5" value="<?php if(count($a_pencentage)>4){ echo $a_pencentage[4]; }else{ echo ""; } ;?>" class="form-control" >  
                            </center> 
                        </span>
                    </div>
                    
                    <div class="col-md-8">
                        <span style="color:#999;">
                            <center>
                                <input type="text" name="pipe_name5" id="pipe_name5" value="<?php if(count($a_percentage_name)>4){ echo $a_percentage_name[4]; }else{ echo ""; } ;?>" class="form-control" >  
                            </center>
                        </span>
                    </div>
                    
                </div>
                <br>
                <div class="row">
                    
                    <div class="col-md-4">
                        <span style="color:#999;">
                            <center>
                                <input type="hidden" name="pipe_id6" id="pipe_id6" value="<?php if(count($a_percentage_id)>5){ echo $a_percentage_id[5]; }else{ echo ""; } ;?>" class="form-control" > 
                                <input type="text" name="pipe_stage6" maxlength="2" id="pipe_stage6" value="<?php if(count($a_pencentage)>5){ echo $a_pencentage[5]; }else{ echo ""; } ;?>" class="form-control" >  
                            </center>  
                        </span>
                    </div>
                    
                    <div class="col-md-8">
                        <span style="color:#999;">
                            <center>
                                <input type="text" name="pipe_name6" id="pipe_name6" value="<?php if(count($a_percentage_name)>5){ echo $a_percentage_name[5]; }else{ echo ""; } ;?>" class="form-control" >  
                            </center>
                        </span>
                    </div>
                    
                </div>
                <br>
                <div class="row">
                    
                    <div class="col-md-4">
                        <span style="color:#999;">
                            <center>
                                <input type="hidden" name="pipe_id7"  id="pipe_id7" value="<?php if(count($a_percentage_id)>6){ echo $a_percentage_id[6]; }else{ echo ""; } ;?>" class="form-control" > 
                                <input type="text" name="pipe_stage7" maxlength="2" id="pipe_stage7" value="<?php if(count($a_pencentage)>6){ echo $a_pencentage[6]; }else{ echo ""; } ;?>" class="form-control" >  
                            </center>  
                        </span>
                    </div>
                    
                    <div class="col-md-8">
                        <span style="color:#999;">
                            <center>
                                <input type="text" name="pipe_name7" id="pipe_name7" value="<?php if(count($a_percentage_name)>6){ echo $a_percentage_name[6]; }else{ echo ""; } ;?>" class="form-control" >  
                            </center>
                        </span>
                    </div>
                    
                </div>
                
            </div>
            
            
            <div class="col-md-4">
                <img src="Image/funnel_stages.png" width="100%" height="auto">
                <br>
                
                <div class="edit-stages-info" style="color:#999;">
                    <p>To remove a deal stage, delete the values in the % column.</p>
                    <p>When you remove a deal stage, existing deals in that stage will move to the closest equivalent stage.</p>
                </div>
                
            </div>
            
        <!--</div>-->
        
    </body>
    
</html>
<?php
}else{
echo "<script> location.replace('http://fieldcloud.in/Login.php') </script>";
}?>