<?php
$cate_id = "STS_ORDER";


/*
* @Overview 생산오더별 진행현황
* @History 2024-04-22 / 이원기 / 최초작성
*/

include_once "{$_SERVER['DOCUMENT_ROOT']}/common.inc.php";
include_once _SVC_INC_PATH_ . "/auth_check.php";
include_once _HOME_INC_PATH_ . "/ajax_init.php";

if (!_notAuth("R")) {


  switch ($_REQUEST['mode']) {

    // 생산오더별 진행현황
    case 'getStsList':


      $squl = "USP_P_STS_ORDER_S10";

      $_REQUEST['RS_CODE'] = "";
      $_REQUEST['RS_MSG']  = "";

      $params = array(
        "DATE_ST"   => $_REQUEST["order_date_st"] ?: "",
        "DATE_ED"   => $_REQUEST["order_date_ed"] ?: "",
        "WO_NO"     => $_REQUEST["product_order_pop"] ?: "",
        "ITEM_CD"   => $_REQUEST["product_pop"] ?: "",
        "ITEM_NM"   => $_REQUEST["ITEM_NM"] ?: "",
        "ITEM_GRP"   => $_REQUEST["ITEM_GRP"] ?: "",
//        "OP_CD"     => $_REQUEST["process_pop"] ?: "",
//        "FACLT_CD " => $_REQUEST["facility_pop"] ?: "",
        "BP_NM"     => $_REQUEST["client_pop"] ?: "",
        "PROC_SEQ"  => $_REQUEST["PROC_SEQ"] ?: "",
        "ORD_STATUS"     => $_REQUEST['WO_STATUS'] ?: "",
        "RS_CODE"      => array(&$_REQUEST['RS_CODE'], SQLSRV_PARAM_OUT),
        "RS_MSG"       => array(&$_REQUEST['RS_MSG'], SQLSRV_PARAM_OUT)
      );

      $sql = "USP_P_STS_ORDER_S20";


      $rst = $baseObj->DB->exec($squl, $params);

      $countRst = $baseObj->DB->exec($sql, $params);

      $rows = array();
      $countRows = array();
      if ($rst && $_REQUEST['RS_CODE'] !== 'E') {
        $retval['code'] = true;
        while ($row = $baseObj->DB->fetch_array($rst)) {
          $rows[] = $row;
        };
        while ($row = $baseObj->DB->fetch_array($countRst)) {
          $countRows[] = $row;
        };

        $retval['data']      = $rows;
        $retval['countData'] = $countRows;
        $retval['mesg'] = '정상 동작 되었습니다.';
      } else {
        $retval['code'] = false;
        $retval['mesg'] = $_REQUEST['RS_MSG'];
      }

      break;
  }
}

if (!$_REQUEST['no_echo']) {
  echo json_encode($retval);
  // echo $retval;
}