<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
$pdo = db_connect();

$month = $_POST['month'];
$year = $_POST['year'];
$dateType = $_POST['dateType']; // 'outdate'

$data_order = array();

try {
    $stmh = $pdo->prepare("SELECT num, con_num, outdate, indate, outworkplace, orderman, outputplace, receiver, phone, comment, root, steel, motor, delivery, regist_state, bend_state, motor_state, searchtag, update_log, screen, screen_state, screen_su, screen_m2, screenlist, slatlist, slat, slat_state, slat_su, slat_m2, updatecomment, secondord
                         FROM " . $DB . ".output 
                         WHERE (is_deleted IS NULL or is_deleted = '0')  and (devMode <> '1' OR devMode IS NULL) 
                         AND MONTH($dateType) = :month 
                         AND YEAR($dateType) = :year");

    $stmh->bindValue(':month', $month);
    $stmh->bindValue(':year', $year);
    $stmh->execute();

    while ($row = $stmh->fetch(PDO::FETCH_ASSOC)) {
        array_push($data_order, $row);
    }

    $data_order = array(
        "data_order" => $data_order,
        "month" => $month,
        "dateType" => $dateType,
        "year" => $year		
    );

    echo json_encode($data_order, JSON_UNESCAPED_UNICODE);

} catch (PDOException $Exception) {
    print "오류: " . $Exception->getMessage();
}
?>
