81 lines
2.5 KiB
PHP
81 lines
2.5 KiB
PHP
<?php
|
|
class Crorder extends MY_Controller
|
|
{
|
|
public function __construct() {
|
|
parent::__construct();
|
|
$this->db_one = $this->load->database("onedev", true);
|
|
}
|
|
function order() {
|
|
$param = $this->sys_input;
|
|
$port = $param["port"];
|
|
$sql = "select * from cr_order where crOrderIsDownloadedA = 'N' and crOrderIsActive = 'Y'";
|
|
switch ($port ) {
|
|
case "A":
|
|
$sql = "select * from cr_order where crOrderIsDownloadedA = 'N' and crOrderIsActive = 'Y'";
|
|
break;
|
|
case "B":
|
|
$sql = "select * from cr_order where crOrderIsDownloadedB = 'N' and crOrderIsActive = 'Y'";
|
|
break;
|
|
case "C":
|
|
$sql = "select * from cr_order where crOrderIsDownloadedC = 'N' and crOrderIsActive = 'Y'";
|
|
break;
|
|
}
|
|
try {
|
|
$qry = $this->db->query($sql);
|
|
if($qry) {
|
|
$rows = $qry->result_array();
|
|
echo json_encode(
|
|
array("status" => "OK" , "order" => $rows)
|
|
);
|
|
} else {
|
|
echo json_encode(
|
|
array("status" => "ERR" , "order" => array())
|
|
);
|
|
}
|
|
} catch(exception $e) {
|
|
echo json_encode(
|
|
array("status" => "ERR" , "message" => $e->message() )
|
|
);
|
|
}
|
|
}
|
|
function update_order() {
|
|
$param = $this->sys_input;
|
|
$maxID = $param["maxID"];
|
|
$port = $param["port"];
|
|
$sql = "update cr_order set crOrderIsDownloadedA = 'Y' where crOrderID <= ?
|
|
and crOrderIsDownloaded = 'N'";
|
|
switch($port) {
|
|
case "A":
|
|
$sql = "update cr_order set crOrderIsDownloadedA = 'Y' where crOrderID <= ?
|
|
and crOrderIsDownloaded = 'N'";
|
|
break;
|
|
case "B":
|
|
$sql = "update cr_order set crOrderIsDownloadedB = 'Y' where crOrderID <= ?
|
|
and crOrderIsDownloaded = 'N'";
|
|
break;
|
|
case "C":
|
|
$sql = "update cr_order set crOrderIsDownloadedC = 'Y' where crOrderID <= ?
|
|
and crOrderIsDownloaded = 'N'";
|
|
break;
|
|
}
|
|
try {
|
|
$qry = $this->db->query($sql, array($maxID));
|
|
if ($qry) {
|
|
echo json_encode(
|
|
array("status" => "OK" , "message" => "")
|
|
);
|
|
} else {
|
|
$msg = print_r($this->db->error(),true);
|
|
echo json_encode(
|
|
array("status" => "OK" , "message" => $msg )
|
|
);
|
|
}
|
|
} catch(exception $e) {
|
|
echo json_encode(
|
|
array("status" => "ERR" , "message" => $e->message() )
|
|
);
|
|
}
|
|
}
|
|
}
|
|
?>
|