Merge pull request 'added API for itemcode' (#21) from paulcortezl5 into main

Reviewed-on: #21
pull/22/head
paul 5 months ago
commit 826a7c3495

@ -54,6 +54,7 @@ $route['exec/(:any)'] = 'executive_view/$1';
$route['api/sf'] = 'api/StoreFrontAPIController/index';
$route['api/sfmodel/(:any)'] = 'api/StoreFrontAPIController/itemModel/$1';
$route['api/sficode/(:any)'] = 'api/StoreFrontAPIController/itemCode/$1';
$route['(:any)'] = 'pages/$1';
$route['default_controller'] = 'pages/dashboard';

@ -25,10 +25,68 @@ class StoreFrontAPIController extends RestController
$this->load->model("Items");
$this->load->model("BranchItemLedger");
$row = $this->Items->getItemByModelNo('DB-422');
// testing mode
//$row = $this->Items->getItemByModelNo('DB-422');
// disabled during testing
//$result = $this->Items->getItemByModelNo($modelno);
$row = $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);
}
public function itemCode_get($itemcode) {
$this->load->model("Items");
$this->load->model("BranchItemLedger");
//$row = $this->Items->getItemByItemcode(1093218);
// disabled during testing
$row = $this->Items->getItemByItemcode($itemcode);
if($row != null)
{

@ -41,6 +41,12 @@ class Items extends CI_Model
return $result->row();
}
public function getItemByItemcode($itemcode)
{
$result = $this->db->get_where("items", array("itemcode"=>$itemcode));
return $result->row();
}
public function getItemBySeriesNo($series)
{
$result = $this->db->get_where("items", array("seriescode"=>$series));

Loading…
Cancel
Save