diff --git a/application/controllers/Pages.php b/application/controllers/Pages.php
index 656f9e7..c05845f 100644
--- a/application/controllers/Pages.php
+++ b/application/controllers/Pages.php
@@ -1319,7 +1319,7 @@ class Pages extends CI_controller
* Store Item Inquiry Methods
*/
- public function getItemInfo()
+ public function getItemInfoByModelNo()
{
if(!$this->isLogged())
redirect('login', 'refresh');
@@ -1331,35 +1331,92 @@ class Pages extends CI_controller
$this->load->model("StockReceivingView");
$result = $this->Items->getItemInfoByModelNo($this->input->post("modelno"));
- $row = $result->row();
+
+ if($result->num_rows() > 0)
+ {
+ $row = $result->row();
+
+ $resultBranches = $this->BranchItemLedger->getDataByItemcodeWithBranchExcempt($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('m/d/Y');
+ $this->ItemInquiryLog->addNewData();
+ // --- END --- Log searched item
+
+ $htmlTable = "";
+
+ foreach($resultBranches->result() as $rowBranches )
+ {
+ $htmlTable .= "
" . $rowBranches->itemcode . " | " . $rowBranches->brCode . " | " . $rowBranches->endingqty . " |
";
+ }
+
+ echo json_encode(array("success"=>true, "data" => $row, "htmlTable" => $htmlTable, "KWHData" => $kwhRow, "KWHStockReceived" => $kwhStockReceivedRow));
+ }
+ else
+ echo json_encode(array("success"=>false, "data" => "No Record"));
+ }
+
+ public function getItemInfoBySeries()
+ {
+ if(!$this->isLogged())
+ redirect('login', 'refresh');
+
+ $this->load->model("ItemLedger");
- $resultBranches = $this->BranchItemLedger->getDataByItemcodeWithBranchExcempt($row->itemcode);
+ $result = $this->ItemLedger->getBranchesBySeriesCodeWithBranchExcempt($this->input->post("series"), false);
+
+ $htmlTable = "";
- $kwhRow = $this->ItemLedger->getItemLedgerOfKWHByItemcode($row->itemcode);
- //$kwhRow = $resultKWH->row();
+ foreach($result->result() as $rowItems )
+ {
+ $htmlTable .= "" . $rowItems->itemcode .
+ " | " . $rowItems->modelno .
+ " | " . $rowItems->seriescode .
+ " | " . $rowItems->item_desc .
+ " | " . $rowItems->brCode .
+ " | " . $rowItems->endingqty . " |
";
+ }
- $resultKWHStockReceived = $this->StockReceivingView->getDtlDataByItemcode($row->itemcode);
- $kwhStockReceivedRow = $resultKWHStockReceived->row();
+ if($result->num_rows() > 0)
+ echo json_encode(array("success"=>true, "htmlTable" => $htmlTable));
+ else
+ echo json_encode(array("success"=>false, "data" => "No Record"));
+ }
- // 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('m/d/Y');
- $this->ItemInquiryLog->addNewData();
- // --- END --- Log searched item
+ public function getItemInfoByDescription()
+ {
+ if(!$this->isLogged())
+ redirect('login', 'refresh');
+
+ $this->load->model("ItemLedger");
+ $result = $this->ItemLedger->getBranchesByDescWithBranchExcempt($this->input->post("series"), false);
+
$htmlTable = "";
- foreach($resultBranches->result() as $rowBranches )
+ foreach($result->result() as $rowItems )
{
- $htmlTable .= "" . $rowBranches->itemcode . " | " . $rowBranches->brCode . " | " . $rowBranches->endingqty . " |
";
+ $htmlTable .= "" . $rowItems->itemcode .
+ ' | ' . $rowItems->modelno .
+ " | " . $rowItems->seriescode .
+ " | " . $rowItems->item_desc .
+ " | " . $rowItems->brCode .
+ " | " . $rowItems->endingqty . " |
";
}
if($result->num_rows() > 0)
- echo json_encode(array("success"=>true, "data" => $row, "htmlTable" => $htmlTable, "KWHData" => $kwhRow, "KWHStockReceived" => $kwhStockReceivedRow));
+ echo json_encode(array("success"=>true, "htmlTable" => $htmlTable));
else
echo json_encode(array("success"=>false, "data" => "No Record"));
}
diff --git a/application/models/ItemLedger.php b/application/models/ItemLedger.php
index 3cc4bb3..3f7865b 100644
--- a/application/models/ItemLedger.php
+++ b/application/models/ItemLedger.php
@@ -26,6 +26,41 @@ class ItemLedger extends CI_Model
return $this->db->get_where("itemledger", array("itemcode"=>$itemcode));
}
+ public function getBranchesBySeriesCode($seriescode, $includeKWH)
+ {
+ $this->db->select("itemledger.*, items.*");
+ $this->db->from("itemledger");
+ $this->db->join("items", "itemledger.itemcode = items.itemcode", "left");
+ $this->db->where("items.seriescode", $seriescode);
+ if(!$includeKWH) $this->db->where("itemledger.brCode != 'KWH'"); // exclude KWH
+ $this->db->where("itemledger.endingqty > 0");
+ return $this->db->get();
+ }
+
+ public function getBranchesBySeriesCodeWithBranchExcempt($seriescode, $includeKWH)
+ {
+ $this->db->select("itemledger.*, items.*");
+ $this->db->from("itemledger");
+ $this->db->join("items", "itemledger.itemcode = items.itemcode", "left");
+ $this->db->where("items.seriescode", $seriescode);
+ $this->db->where("itemledger.endingqty > 0");
+ if(!$includeKWH) $this->db->where("itemledger.brCode != 'KWH'"); // exclude KWH
+ $this->db->where("itemledger.brCode NOT IN (SELECT brCode FROM branchexemption)");
+ return $this->db->get();
+ }
+
+ public function getBranchesByDescWithBranchExcempt($itemdesc, $includeKWH)
+ {
+ $this->db->select("itemledger.*, items.*");
+ $this->db->from("itemledger");
+ $this->db->join("items", "itemledger.itemcode = items.itemcode", "left");
+ $this->db->like("items.item_desc", $itemdesc);
+ $this->db->where("itemledger.endingqty > 0");
+ if(!$includeKWH) $this->db->where("itemledger.brCode != 'KWH'"); // exclude KWH
+ $this->db->where("itemledger.brCode NOT IN (SELECT brCode FROM branchexemption)");
+ return $this->db->get();
+ }
+
public function getItemLedgerOfKWHByItemcode($itemcode)
{
$result = $this->db->get_where("itemledger", array("itemcode"=>$itemcode, "brCode"=>"KWH"));
diff --git a/application/models/Items.php b/application/models/Items.php
index 218981d..950f9d2 100644
--- a/application/models/Items.php
+++ b/application/models/Items.php
@@ -40,4 +40,10 @@ class Items extends CI_Model
$result = $this->db->get_where("items", array("modelno"=>$modelno));
return $result->row();
}
+
+ public function getItemBySeriesNo($series)
+ {
+ $result = $this->db->get_where("items", array("seriescode"=>$series));
+ return $result->row();
+ }
}
\ No newline at end of file
diff --git a/application/views/pages/dashboard.php b/application/views/pages/dashboard.php
index 07bf545..f483458 100644
--- a/application/views/pages/dashboard.php
+++ b/application/views/pages/dashboard.php
@@ -157,17 +157,67 @@