129 lines
4.1 KiB
PHP
129 lines
4.1 KiB
PHP
<?php
|
|
class Interface extends MY_Controller
|
|
{
|
|
public function __construct() {
|
|
parent::__construct();
|
|
$this->db_one = $this->load->database("one", true);
|
|
$this->db_one->query("use one_bb");
|
|
}
|
|
function raw() {
|
|
$param = $this->sys_input;
|
|
try {
|
|
$instrumentID = $param["instrumentID"];
|
|
$data = $param["data"];
|
|
$sql = "insert into bb_raw(bb_RawInstrumentID,bb_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 bb_result(Bb_ResultNat_InstrumentID, Bb_ResultBb_RawID,
|
|
Bb_ResultNoreg, Bb_ResultInstrumentDate, Bb_ResultKode, Bb_ResultResult, Bb_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"]));
|
|
}
|
|
|
|
//TODO
|
|
// Proses ke result
|
|
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_bb_order_v2(?,?)";
|
|
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_v2(?,?,?)";
|
|
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() )
|
|
);
|
|
}
|
|
}
|
|
}
|
|
?>
|