search by series and desc

Added search by series and description to dashboard
pull/15/head
paulcortez 9 months ago
parent 759d979558
commit 01a4ab6e93

@ -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 .= "<tr><td>" . $rowBranches->itemcode . "</td><td>" . $rowBranches->brCode . "</td><td>" . $rowBranches->endingqty . "</td></tr>";
}
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 .= "<tr><td>" . $rowItems->itemcode .
"</td><td>" . $rowItems->modelno .
"</td><td>" . $rowItems->seriescode .
"</td><td>" . $rowItems->item_desc .
"</td><td>" . $rowItems->brCode .
"</td><td>" . $rowItems->endingqty . "</td></tr>";
}
$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 .= "<tr><td>" . $rowBranches->itemcode . "</td><td>" . $rowBranches->brCode . "</td><td>" . $rowBranches->endingqty . "</td></tr>";
$htmlTable .= "<tr><td>" . $rowItems->itemcode .
'</td><td><a href="itemmovementhistory?mts='.$rowItems->modelno.'">' . $rowItems->modelno .
"</a></td><td>" . $rowItems->seriescode .
"</td><td>" . $rowItems->item_desc .
"</td><td>" . $rowItems->brCode .
"</td><td>" . $rowItems->endingqty . "</td></tr>";
}
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"));
}

@ -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"));

@ -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();
}
}

@ -157,17 +157,67 @@
</div>
</div>
<div class="box-body">
<form class="form-horizontal" id="frmModelNoInquiry" name="frmModelNoInquiry">
<div class="form-group">
<label for="txtModelNoInquiry" class="col-lg-2 control-label">Model No:</label>
<div class="col-lg-9">
<input type="text" id="txtModelNoInquiry" name="txtModelNoInquiry" class="form-control" placeholder="Enter Model Number">
<!-- Custom Tabs -->
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li class="active"><a href="#tab_1" data-toggle="tab">Search by Model No.</a></li>
<li><a href="#tab_2" data-toggle="tab">Search by Series</a></li>
<li><a href="#tab_3" data-toggle="tab">Search by Description</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab_1">
<p>Search for an item by Model No.</p>
<form class="form-horizontal" id="frmModelNoInquiry" name="frmModelNoInquiry">
<div class="form-group">
<label for="txtModelNoInquiry" class="col-lg-2 control-label">Model No:</label>
<div class="col-lg-9">
<input type="text" id="txtModelNoInquiry" name="txtModelNoInquiry" class="form-control" placeholder="Enter Model Number">
</div>
<div class="col-lg-1">
<button type="submit" class="btn btn-primary">Search</button>
</div>
</div>
</form>
</div>
<div class="col-lg-1">
<button type="submit" class="btn btn-primary">Search</button>
<!-- /.tab-pane -->
<div class="tab-pane" id="tab_2">
<p>Search for an item by Series Number</p>
<form class="form-horizontal" id="frmSeriesNoInquiry" name="frmSeriesNoInquiry">
<div class="form-group">
<label for="txtSeriesNoInquiry" class="col-lg-2 control-label">Series No:</label>
<div class="col-lg-9">
<input type="text" id="txtSeriesNoInquiry" name="txtSeriesNoInquiry" class="form-control" placeholder="Enter Model Number">
</div>
<div class="col-lg-1">
<button type="submit" class="btn btn-primary">Search</button>
</div>
</div>
</form>
</div>
<!-- /.tab-pane -->
<div class="tab-pane" id="tab_3">
<p>Search for an item by Description</p>
<form class="form-horizontal" id="frmDescriptionInquiry" name="frmDescriptionInquiry">
<div class="form-group">
<label for="txtDescriptionInquiry" class="col-lg-2 control-label">Description:</label>
<div class="col-lg-9">
<input type="text" id="txtDescriptionInquiry" name="txtDescriptionInquiry" class="form-control" placeholder="Enter Model Number">
</div>
<div class="col-lg-1">
<button type="submit" class="btn btn-primary">Search</button>
</div>
</div>
</form>
</div>
<!-- /.tab-pane -->
</div>
</form>
<!-- /.tab-content -->
</div>
<!-- nav-tabs-custom -->
</div><!-- /.box-body -->
<div class="box-footer">
@ -325,6 +375,30 @@
' </div><!-- /.box -->';
}
function showItemListFromInquiry(htmlTable)
{
return '<div class="box">' +
' <div class="box-header with-border">' +
' <h3 class="box-title">Item Information</h3>' +
' <div class="box-tools pull-right">' +
' <button class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove"><i class="fa fa-times"></i></button>' +
' </div>' +
' </div>' +
' <div class="box-body">' +
' <h3>List of items that matches with the series code in the inquiry</h3>' +
' <div class="row">' +
' <div class="col-lg-12">' +
' <table id="dtItemListMatchedSeries" class="table table-bordered table-striped">' +
' <thead><th>Itemcode</th><th>Model</th><th>Series</th><th>Description</th><th>Branch</th><th>Qty</th></thead>' +
' <tbody>' + htmlTable + '</tbody>' +
' </table>' +
' </div>' +
' </div>' +
' </div>' +
' </div>';
}
function showIteminquiredInformation(data, htmlTable, KWHData, KWHStockReceived)
{
return '<div class="box">' +
@ -393,10 +467,11 @@
}, "json");
});
// ------- Item Search Area -------
$("#frmModelNoInquiry").on("submit", function(e) {
e.preventDefault();
$.post("getItemInfo", {
$.post("getItemInfoByModelNo", {
modelno: $("#txtModelNoInquiry").val()
}, function(data) {
if (data["success"] == true) {
@ -407,6 +482,35 @@
}, "json");
});
$("#frmSeriesNoInquiry").on("submit", function(e) {
e.preventDefault();
$.post("getItemInfoBySeries", {
series: $("#txtSeriesNoInquiry").val()
}, function(data) {
if (data["success"] == true) {
$("#resultContainerStoreInquiry").prepend(showItemListFromInquiry(data["htmlTable"]));
} else {
$("#resultContainerStoreInquiry").prepend(errorMessage(data["data"]));
}
}, "json");
});
$("#frmDescriptionInquiry").on("submit", function(e) {
e.preventDefault();
$.post("getItemInfoByDescription", {
series: $("#txtDescriptionInquiry").val()
}, function(data) {
if (data["success"] == true) {
$("#resultContainerStoreInquiry").prepend(showItemListFromInquiry(data["htmlTable"]));
} else {
$("#resultContainerStoreInquiry").prepend(errorMessage(data["data"]));
}
}, "json");
});
// ------- /.Item Search Area -------
$(document).on("click", "#btnRenewCard", function() {
$("#mdlRenewCustomerCard").modal("show");

@ -30,7 +30,7 @@
<li>
<a href="<?php echo site_url(); ?>">
<i class="fa fa-dashboard"></i>
<span>Dashboard</span>
<span>Product Inquiry</span>
</a>
</li>
<li>

Loading…
Cancel
Save