
<?php
session_start();
  include_once 'config.php';
 
  if($_POST['tag']=='projectList')
  {
    $query = "select distinct PROJECT as PROJECT from master_process_copy ORDER BY PROJECT ASC";
 
    $result = mysqli_query($con,$query);
 
    $arr =[];
    $i=0;
 
    while($row = mysqli_fetch_assoc($result))
    {
      $arr[$i] = $row;
      $i++;
    }
 
    echo json_encode($arr);

  }

 
  // Getting item list on the basis of company_id
  if($_POST['tag']=='categoryList')
  {


    $project = $_POST['PROJECT'];
    $_SESSION['PROJECT'] = $project;
    //$category = $_POST['CATEGORY'];
 
    $query = "select distinct CATEGORY from master_process_copy where PROJECT ='".$project."'  ORDER BY CATEGORY ASC"   ;
 
    $result = mysqli_query($con,$query);
    
    $arr =[];
    $i=0;
 
    while($row = mysqli_fetch_assoc($result))
    {
      $arr[$i] = $row;
      $i++;
    }
 
    echo json_encode($arr);
  }
 
  // Getting model list on the basis of item_id
  // if($_POST['tag']=='stageList')
  // {
  //   //  $project = $_POST['PROJECT']; 

  //   $category = $_POST['CATEGORY'];
  //   $_SESSION['CATEGORY']=$category;
 
  //   $query = "select distinct STAGE from master_process where CATEGORY = '".$category."' AND PROJECT= '" . $_SESSION['PROJECT']."' ORDER BY STAGE ASC" ;
  
  //   $result = mysqli_query($con,$query);
 
  //   $arr =[];
  //   $i=0;
 
  //   while($row = mysqli_fetch_assoc($result))
  //   {
  //     $arr[$i] = $row;
  //     $i++;
  //   }
 
  //   echo json_encode($arr);
  // }
 

  if($_POST['tag']=='processList')
  {
    //  $project = $_POST['PROJECT']; 

    $category = $_POST['CATEGORY'];

    $_SESSION['CATEGORY']=$category;
 
    $query = "select distinct PROCESS from master_process_copy where CATEGORY = '".$category."' AND PROJECT= '" . $_SESSION['PROJECT']."' ORDER BY PROCESS ASC" ;
  
    $result = mysqli_query($con,$query);
 
    $arr =[];

    $i=0;
 
    while($row = mysqli_fetch_assoc($result))
    {
      $arr[$i] = $row;

      $i++;
    }
 
    
    echo json_encode($arr);
  }
   
  
  // if($_POST['tag']=='subprocessList')
  // {
  //   //  $project = $_POST['PROJECT']; 

  //   $process = $_POST['PROCESS'];
 
  //   $query = "select distinct SUBPROCESS from master_process where PROCESS='".$process."' AND STAGE= '". $_SESSION['STAGE']."' AND CATEGORY = '".$_SESSION['CATEGORY']."' AND PROJECT = '" . $_SESSION['PROJECT']."' ORDER BY SUBPROCESS ASC" ;
  
  //   $result = mysqli_query($con,$query);
 
  //   $arr =[];
  //   $i=0;
 
  //   while($row = mysqli_fetch_assoc($result))
  //   {
  //     $arr[$i] = $row;
  //     $i++;
  //   }
 
  //   echo json_encode($arr);
  // }
?>