217 lines
8.4 KiB
PHP
217 lines
8.4 KiB
PHP
<?php
|
|
class Masterdata extends MY_Controller
|
|
{
|
|
var $db_inventory;
|
|
var $load;
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_inventory = $this->load->database("inventory", true);
|
|
}
|
|
|
|
function index()
|
|
{
|
|
echo "Tabel Masterdata Inventory";
|
|
// $cek = $this->db_inventory->query("select database() as current_db")->result();
|
|
// print_r($cek);
|
|
}
|
|
|
|
function get_master_data()
|
|
{
|
|
try {
|
|
// if (! $this->isLogin) {
|
|
// $this->sys_error("Invalid Token");
|
|
// exit;
|
|
// }
|
|
$prm = $this->sys_input;
|
|
$last_updated = "2023-01-01 00:00:00";
|
|
if (isset($prm['last_updated'])) {
|
|
$last_updated = trim($prm["last_updated"]);
|
|
}
|
|
|
|
$tabel = "";
|
|
if (isset($prm['tabel'])) {
|
|
$tabel = trim($prm["tabel"]);
|
|
}
|
|
|
|
if ($tabel === "company") {
|
|
$sql_company = "SELECT * FROM company
|
|
WHERE CompanyLastUpdated > ?";
|
|
$qry_company = $this->db_inventory->query($sql_company, array($last_updated));
|
|
if ($qry_company) {
|
|
$rows_company = $qry_company->result_array();
|
|
} else {
|
|
$this->sys_error_db("company error", $this->db_inventory);
|
|
exit;
|
|
}
|
|
|
|
$result = array("company" => $rows_company);
|
|
}
|
|
|
|
if ($tabel === "companyaddress") {
|
|
$sql_companyaddress = "SELECT * FROM companyaddress
|
|
WHERE CompanyAddressLastUpdated > ?";
|
|
$qry_companyaddress = $this->db_inventory->query($sql_companyaddress, array($last_updated));
|
|
if ($qry_companyaddress) {
|
|
$rows_companyaddress = $qry_companyaddress->result_array();
|
|
} else {
|
|
$this->sys_error_db("companyaddress error", $this->db_inventory);
|
|
exit;
|
|
}
|
|
|
|
$result = array("companyaddress" => $rows_companyaddress);
|
|
}
|
|
|
|
if ($tabel === "item") {
|
|
$sql_item = "SELECT * FROM item
|
|
WHERE ItemLastUpdated > ?";
|
|
$qry_item = $this->db_inventory->query($sql_item, array($last_updated));
|
|
if ($qry_item) {
|
|
$rows_item = $qry_item->result_array();
|
|
} else {
|
|
$this->sys_error_db("item error", $this->db_inventory);
|
|
exit;
|
|
}
|
|
|
|
$result = array("item" => $rows_item);
|
|
}
|
|
|
|
if ($tabel === "itembranch") {
|
|
$sql_itembranch = "SELECT * FROM itembranch
|
|
WHERE ItemBranchLastUpdated > ?";
|
|
$qry_itembranch = $this->db_inventory->query($sql_itembranch, array($last_updated));
|
|
if ($qry_itembranch) {
|
|
$rows_itembranch = $qry_itembranch->result_array();
|
|
} else {
|
|
$this->sys_error_db("itembranch error", $this->db_inventory);
|
|
exit;
|
|
}
|
|
|
|
$result = array("itembranch" => $rows_itembranch);
|
|
}
|
|
|
|
if ($tabel === "itembrand") {
|
|
$sql_itembrand = "SELECT * FROM itembrand
|
|
WHERE ItemBrandLastUpdated > ?";
|
|
$qry_itembrand = $this->db_inventory->query($sql_itembrand, array($last_updated));
|
|
if ($qry_itembrand) {
|
|
$rows_itembrand = $qry_itembrand->result_array();
|
|
} else {
|
|
$this->sys_error_db("itembrand error", $this->db_inventory);
|
|
exit;
|
|
}
|
|
|
|
$result = array("itembrand" => $rows_itembrand);
|
|
}
|
|
|
|
if ($tabel === "itemcategory") {
|
|
$sql_itemcategory = "SELECT * FROM itemcategory
|
|
WHERE ItemCategoryLastUpdated > ?";
|
|
$qry_itemcategory = $this->db_inventory->query($sql_itemcategory, array($last_updated));
|
|
if ($qry_itemcategory) {
|
|
$rows_itemcategory = $qry_itemcategory->result_array();
|
|
} else {
|
|
$this->sys_error_db("itemcategory error", $this->db_inventory);
|
|
exit;
|
|
}
|
|
|
|
$result = array("itemcategory" => $rows_itemcategory);
|
|
}
|
|
|
|
if ($tabel === "itemgroup") {
|
|
$sql_itemgroup = "SELECT * FROM itemgroup
|
|
WHERE ItemGroupLastUpdated > ?";
|
|
$qry_itemgroup = $this->db_inventory->query($sql_itemgroup, array($last_updated));
|
|
if ($qry_itemgroup) {
|
|
$rows_itemgroup = $qry_itemgroup->result_array();
|
|
} else {
|
|
$this->sys_error_db("itemgroup error", $this->db_inventory);
|
|
exit;
|
|
}
|
|
|
|
$result = array("itemgroup" => $rows_itemgroup);
|
|
}
|
|
|
|
if ($tabel === "itemmanufacture") {
|
|
$sql_itemmanufacture = "SELECT * FROM itemmanufacture
|
|
WHERE ItemManufactureUpdated > ?";
|
|
$qry_itemmanufacture = $this->db_inventory->query($sql_itemmanufacture, array($last_updated));
|
|
if ($qry_itemmanufacture) {
|
|
$rows_itemmanufacture = $qry_itemmanufacture->result_array();
|
|
} else {
|
|
$this->sys_error_db("itemmanufacture error", $this->db_inventory);
|
|
exit;
|
|
}
|
|
|
|
$result = array("itemmanufacture" => $rows_itemmanufacture);
|
|
}
|
|
|
|
if ($tabel === "itemnumbering") {
|
|
$sql_itemnumbering = "SELECT * FROM itemnumbering
|
|
WHERE ItemNumberingLastUpdated > ?";
|
|
$qry_itemnumbering = $this->db_inventory->query($sql_itemnumbering, array($last_updated));
|
|
if ($qry_itemnumbering) {
|
|
$rows_itemnumbering = $qry_itemnumbering->result_array();
|
|
} else {
|
|
$this->sys_error_db("itemnumbering error", $this->db_inventory);
|
|
exit;
|
|
}
|
|
|
|
$result = array("itemnumbering" => $rows_itemnumbering);
|
|
}
|
|
|
|
if ($tabel === "itemunit") {
|
|
$sql_itemunit = "SELECT * FROM itemunit
|
|
WHERE ItemUnitLastUpdated > ?";
|
|
$qry_itemunit = $this->db_inventory->query($sql_itemunit, array($last_updated));
|
|
if ($qry_itemunit) {
|
|
$rows_itemunit = $qry_itemunit->result_array();
|
|
} else {
|
|
$this->sys_error_db("itemunit error", $this->db_inventory);
|
|
exit;
|
|
}
|
|
|
|
$result = array("itemunit" => $rows_itemunit);
|
|
}
|
|
|
|
if ($tabel === "itemunitconvert") {
|
|
$sql_itemunitconvert = "SELECT * FROM itemunitconvert
|
|
WHERE ItemUnitConvertLastUpdated > ?";
|
|
$qry_itemunitconvert = $this->db_inventory->query($sql_itemunitconvert, array($last_updated));
|
|
if ($qry_itemunitconvert) {
|
|
$rows_itemunitconvert = $qry_itemunitconvert->result_array();
|
|
} else {
|
|
$this->sys_error_db("itemunitconvert error", $this->db_inventory);
|
|
exit;
|
|
}
|
|
|
|
$result = array("itemunitconvert" => $rows_itemunitconvert);
|
|
}
|
|
|
|
if ($tabel === "itemunitmap") {
|
|
$sql_itemunitmap = "SELECT * FROM itemunitmap
|
|
WHERE ItemUnitMapLastUpdated > ?";
|
|
$qry_itemunitmap = $this->db_inventory->query($sql_itemunitmap, array($last_updated));
|
|
if ($qry_itemunitmap) {
|
|
$rows_itemunitmap = $qry_itemunitmap->result_array();
|
|
} else {
|
|
$this->sys_error_db("itemunitmap error", $this->db_inventory);
|
|
exit;
|
|
}
|
|
|
|
$result = array("itemunitmap" => $rows_itemunitmap);
|
|
}
|
|
|
|
// print_r($result);
|
|
$json_result = json_encode(array("status" => "OK", "data" => $result));
|
|
$gz_result = gzcompress($json_result, 9);
|
|
echo $gz_result;
|
|
// print_r($gz_result);
|
|
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
}
|
|
?>
|