You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kwmobile/application/controllers/api/StoreFrontAPIController.php

79 lines
2.3 KiB
PHTML

<?php
require APPPATH . 'libraries/RestController.php';
use App\RestServer\RestController;
class StoreFrontAPIController extends RestController
{
public function __construct()
{
parent::__construct();
// Set timezone to Philippines
date_default_timezone_set('Asia/Manila');
}
public function index_get() {
// Fetch data logic here
$data = ['message' => 'GET request received'];
$this->response($data, 200);
}
public function itemModel_get($modelno) {
$this->load->model("Items");
$this->load->model("BranchItemLedger");
$row = $this->Items->getItemByModelNo('DB-422');
// disabled during testing
//$result = $this->Items->getItemByModelNo($modelno);
if($row != null)
{
$branches = [];
$resultBranches = $this->BranchItemLedger->getDataByItemcodeWithBranchExcempt($row->itemcode);
foreach($resultBranches->result() as $rowBranches )
{
$branches[] = [
'itemcode' => $rowBranches->itemcode,
'brCode' => $rowBranches->brCode,
'endingqty' => $rowBranches->endingqty
];
}
$item = [
'itemcode' => $row->itemcode,
'modelno' => $row->modelno,
'seriescode' => $row->seriescode,
'item_desc' => $row->item_desc,
'karat' => $row->karat,
'size' => $row->size,
'grams' => $row->grams,
'cts' => $row->cts,
'srp' => $row->srp,
//'mrp' => $row->mrp,
'mrp' => '0',
'pic' => '',
'catCode' => $row->catCode,
'goldID' => $row->goldID,
'supCode' => $row->supCode,
'modifieddate' => $row->modifieddate,
'others' => '',
'remarks' => '',
'branches' => $branches
];
$data = ['status' => 'FOUND',
'data' => $item];
}
else
$data = ['status' => 'NOTFOUND',
'data' => null];
$this->response($data, 200);
}
}