diff --git a/application/controllers/Pages.php b/application/controllers/Pages.php index e827ad2..9f3cbf9 100644 --- a/application/controllers/Pages.php +++ b/application/controllers/Pages.php @@ -1332,6 +1332,64 @@ class Pages extends CI_controller $result = $this->Items->getItemInfoByModelNo($this->input->post("modelno")); + if($result->num_rows() > 0) + { + $row = $result->row(); + + $resultBranches = $this->BranchItemLedger->getDataByItemcodeAllBranchWithBranchExcempt($row->itemcode); + + $kwhRow = $this->ItemLedger->getItemLedgerOfKWHByItemcode($row->itemcode); + //$kwhRow = $resultKWH->row(); + + $resultKWHStockReceived = $this->StockReceivingView->getDtlDataByItemcode($row->itemcode); + $kwhStockReceivedRow = $resultKWHStockReceived->row(); + + // Log searched item + $this->ItemInquiryLog->itemcode = $row->itemcode; + $this->ItemInquiryLog->modelno = $row->modelno; + $this->ItemInquiryLog->catCode = $row->catCode; + $this->ItemInquiryLog->brCode = $this->session->user["branch"]; + $this->ItemInquiryLog->searchedBy = $this->session->user["username"]; + $this->ItemInquiryLog->dateSearched = date('Y-m-d'); + $this->ItemInquiryLog->addNewData(); + // --- END --- Log searched item + + $htmlTable = ""; + $htmlListOfBranchWithNoItem = ""; + + foreach($resultBranches->result() as $rowBranches ) + { + if($rowBranches->itemcode == null) + $htmlListOfBranchWithNoItem .= "" . $rowBranches->brCode . "" . $rowBranches->brDesc . ""; + else + $htmlTable .= "" . $rowBranches->brCode . "" . $rowBranches->itemcode . "" . $rowBranches->endingqty . ""; + } + + echo json_encode(array("success"=>true, + "data" => $row, + "htmlTable" => $htmlTable, + "KWHData" => $kwhRow, + "KWHStockReceived" => $kwhStockReceivedRow, + "htmlListOfBranchWithNoItem" => $htmlListOfBranchWithNoItem + )); + } + else + echo json_encode(array("success"=>false, "data" => "No Record")); + } + + public function getItemInfoByItemcode() + { + if(!$this->isLogged()) + redirect('login', 'refresh'); + + $this->load->model("Items"); + $this->load->model("BranchItemLedger"); + $this->load->model("ItemLedger"); + $this->load->model("ItemInquiryLog"); + $this->load->model("StockReceivingView"); + + $result = $this->Items->getItemInfoByItemcode($this->input->post("itemcode")); + if($result->num_rows() > 0) { $row = $result->row(); diff --git a/application/controllers/api/StoreFrontAPIController.php b/application/controllers/api/StoreFrontAPIController.php index 3a8abd2..c1b24c0 100644 --- a/application/controllers/api/StoreFrontAPIController.php +++ b/application/controllers/api/StoreFrontAPIController.php @@ -59,7 +59,7 @@ class StoreFrontAPIController extends RestController 'cts' => $row->cts, 'SRP' => number_format($row->srp, 2), //'mrp' => $row->mrp, - 'MRP' => '0.00', + //'MRP' => '0.00', ---------- requested to remove MRP 'pic' => $baseImgUrl.basename(str_replace('\\', '/', $row->pic)), 'Category' => $row->catCode, 'Gold ID' => $row->goldID, @@ -117,7 +117,7 @@ class StoreFrontAPIController extends RestController 'cts' => $row->cts, 'SRP' => number_format($row->srp, 2), //'mrp' => $row->mrp, - 'MRP' => '0.00', + //'MRP' => '0.00', ---------- requested to remove MRP 'pic' => $baseImgUrl.basename(str_replace('\\', '/', $row->pic)), 'Category' => $row->catCode, 'Gold ID' => $row->goldID, diff --git a/application/models/BranchItemLedger.php b/application/models/BranchItemLedger.php index 70d5c22..5265ba3 100644 --- a/application/models/BranchItemLedger.php +++ b/application/models/BranchItemLedger.php @@ -37,6 +37,16 @@ class BranchItemLedger extends CI_Model return $this->db->get_where("branchitemledger"); } + public function getDataByItemcodeAllBranchWithBranchExcempt($itemcode) + { + $this->db->select("branch.brCode AS brCode, branch.brDesc AS brDesc, branchitemledger.itemcode AS itemcode, branchitemledger.endingqty AS endingqty"); + $this->db->from("branch"); + $this->db->join("branchitemledger", "branch.brCode=branchitemledger.brCode AND branchitemledger.itemcode=".$itemcode, "left"); + $this->db->where("branch.brCode NOT IN (SELECT brCode FROM branchexemption)"); + + return $this->db->get(); + } + public function getDataByBrCodeItemcode($brCode, $itemcode) { $result = $this->db->get_where("branchitemledger", array("brCode"=>$brCode, "itemcode"=>$itemcode)); diff --git a/application/models/Items.php b/application/models/Items.php index a8eb060..1a999e5 100644 --- a/application/models/Items.php +++ b/application/models/Items.php @@ -35,6 +35,12 @@ class Items extends CI_Model return $this->db->get_where("items", array("modelno"=>$modelno)); } + public function getItemInfoByItemcode($itemcode) + { + $this->db->select("itemcode, modelno, seriescode, item_desc, karat, size, grams, cts, srp, pic, manref, catCode, goldID, supCode, modifieddate, sourceDate"); + return $this->db->get_where("items", array("itemcode"=>$itemcode)); + } + public function getItemByModelNo($modelno) { $result = $this->db->get_where("items", array("modelno"=>$modelno)); diff --git a/application/views/pages/dashboard.php b/application/views/pages/dashboard.php index f483458..2620bc4 100644 --- a/application/views/pages/dashboard.php +++ b/application/views/pages/dashboard.php @@ -163,6 +163,7 @@
  • Search by Model No.
  • Search by Series
  • Search by Description
  • +
  • Search by Itemcode
  • @@ -187,7 +188,7 @@
    - +
    @@ -211,6 +212,21 @@
    +
    +

    Search for an item by Itemcode

    +
    +
    + +
    + +
    +
    + +
    +
    +
    +
    +
    @@ -399,7 +415,7 @@ ' '; } - function showIteminquiredInformation(data, htmlTable, KWHData, KWHStockReceived) + function showIteminquiredInformation(data, htmlTable, KWHData, KWHStockReceived, htmlListOfBranchWithNoItem) { return '
    ' + '
    ' + @@ -432,11 +448,20 @@ '
    ' + '
    ' + ' ' + - ' ' + + ' ' + ' ' + htmlTable + '' + '
    ItemcodeBranchQty
    BranchItemcodeQty
    ' + '
    ' + '
    ' + + '

    List of branches where there is no item supplied

    ' + + '
    ' + + '
    ' + + ' ' + + ' ' + + ' ' + htmlListOfBranchWithNoItem + '' + + '
    Branch CodeDescription
    ' + + '
    ' + + '
    ' + '

    Beginning quantity: ' + ((KWHStockReceived == null) ? "0" : KWHStockReceived["qty"]) + '

    ' + '

    Quantity Remaining in Warehouse: ' + KWHData["endingqty"] + '

    ' + '
    ' + @@ -475,7 +500,7 @@ modelno: $("#txtModelNoInquiry").val() }, function(data) { if (data["success"] == true) { - $("#resultContainerStoreInquiry").prepend(showIteminquiredInformation(data["data"], data["htmlTable"], data["KWHData"], data["KWHStockReceived"])); + $("#resultContainerStoreInquiry").prepend(showIteminquiredInformation(data["data"], data["htmlTable"], data["KWHData"], data["KWHStockReceived"], data["htmlListOfBranchWithNoItem"])); } else { $("#resultContainerStoreInquiry").prepend(errorMessage(data["data"])); } @@ -509,6 +534,20 @@ } }, "json"); }); + + $("#frmItemcodeInquiry").on("submit", function(e) { + e.preventDefault(); + + $.post("getItemInfoByItemcode", { + itemcode: $("#txtItemcodeInquiry").val() + }, function(data) { + if (data["success"] == true) { + $("#resultContainerStoreInquiry").prepend(showIteminquiredInformation(data["data"], data["htmlTable"], data["KWHData"], data["KWHStockReceived"])); + } else { + $("#resultContainerStoreInquiry").prepend(errorMessage(data["data"])); + } + }, "json"); + }); // ------- /.Item Search Area ------- $(document).on("click", "#btnRenewCard", function() {