Files
BE_CPONE/application/controllers/v1/su/Portserver-bkp.php
2026-04-27 10:26:26 +07:00

131 lines
4.2 KiB
PHP

<?php
class Portserver extends MY_Controller
{
public function __construct() {
parent::__construct();
$this->db_one = $this->load->database("onedev", true);
}
function raw() {
$param = $this->sys_input;
try {
$instrumentID = $param["instrumentID"];
$data = $param["data"];
$sql = "insert into itf_raw(itf_RawNat_InstrumentID,itf_RawData)
values(?,?)";
$this->db_one->query($sql, array($instrumentID, base64_decode($data)));
echo json_encode(
array("status" => "OK" , "id" => $this->db_one->insert_id() , "message" => "")
);
} catch(exception $e) {
echo json_encode(
array("status" => "ERR" , "id" => 0, "message" => $e.message() )
);
}
}
function result() {
$param = $this->sys_input;
try {
$instrumentID = $param["instrumentID"];
$rawID = $param["rawID"];
$result= $param["result"];
$noreg = $result["nolab"];
$sql = "insert into itf_result(itf_ResultNat_InstrumentID, itf_ResultItf_RawID,
Itf_ResultNoreg, Itf_ResultInstrumentDate, itf_ResultKode, itf_ResultResult, itf_ResultFlag)
values(?,?,?,?,?,?,?)";
foreach($result["result"] as $r) {
$tgl = $r["date"];
$px = $r["px"];
$result = $r["result"];
$this->db_one->query($sql,
array($instrumentID, $rawID, $noreg, $tgl , $px,
$result,$r["flag"]));
}
if ($instrumentID == 1) {
$sql = "call sp_itf_result_alinity(?)";
} else {
$sql = "call sp_itf_result(?)";
}
$this->db->query($sql, array($rawID));
echo json_encode(
array("status" => "OK" , "message" => "")
);
} catch(exception $e) {
echo json_encode(
array("status" => "ERR" , "message" => $e->message() )
);
}
}
function order() {
$param = $this->sys_input;
$sampleID = $param["sampleID"];
$instrumentID = $param["instrumentID"];
$sql = "call sp_itf_order(?,?)";
try {
$qry = $this->db->query($sql, array($instrumentID,$sampleID));
if (isset($qry->result_id->num_rows)) {
$rows = $qry->result_array();
echo json_encode(
array("status" => "OK" , "order" => $rows)
);
} else {
echo json_encode(
array("status" => "OK" , "order" => array())
);
}
} catch(exception $e) {
echo json_encode(
array("status" => "ERR" , "message" => $e->message() )
);
}
}
function update_order() {
$param = $this->sys_input;
$sampleID = $param["sampleID"];
$instrumentID = $param["instrumentID"];
$status = $param["status"];
$sql = "call sp_itf_order_update(?,?,?)";
try {
$qry = $this->db->query($sql, array($instrumentID,$sampleID,$status));
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() )
);
}
}
function reset_order() {
$param = $this->sys_input;
$sampleID = $param["sampleID"];
$instrumentID = $param["instrumentID"];
$status = $param["status"];
$sql = "call sp_itf_order_reset(?,?,?)";
try {
$qry = $this->db->query($sql, array($instrumentID,$sampleID,$status));
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() )
);
}
}
}
?>