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/models/StoreTransaction.php

76 lines
2.1 KiB
PHTML

2 years ago
<?php
class StoreTransaction extends CI_Model
{
public $recordID;
public $transID;
public $brCode;
public $cash;
public $checque;
public $dollar;
public $ccard;
public $preparedBy;
public $remarks;
public function __construct()
{
parent::__construct();
$this->load->database();
}
public function getStoreTransactionByTransID($transID)
{
return $this->db->get_where("storetransaction", array("transID"=>$transID));
}
public function getNextID($transID)
{
$nextID = 0;
$this->db->select("IFNULL(MAX(CAST(replace(recordID, transID, '') AS UNSIGNED)), 0) + 1 as NextID");
$result = $this->db->get_where("storetransaction", array("transID"=>$transID));
foreach($result->result() as $row)
$nextID = $row->NextID;
return $nextID;
}
public function getStoreTransactionSummaryByTransDate($transDate)
{
$this->db->select("storetransaction.recordID, storetransaction.transID, storetransaction.brCode, branch.brDesc, (storetransaction.cash + storetransaction.checque + storetransaction.dollar + storetransaction.ccard) AS TotalSales, storetransaction.preparedBy, storetransaction.remarks");
$this->db->join('branch', 'branch.brCode = storetransaction.brCode');
2 years ago
$this->db->like('transID', $transDate, 'before');
return $this->db->get('storetransaction');
}
public function addStoreTransaction()
{
return $this->db->insert('storetransaction', $this);
}
public function updateStoreTransaction()
{
$this->db->where(array("recordID"=>$this->recordID));
return $this->db->update("storetransaction",
array(
"cash"=>$this->cash,
"checque"=>$this->checque,
"dollar"=>$this->dollar,
"ccard"=>$this->ccard,
"preparedBy"=>$this->preparedBy,
"remarks"=>$this->remarks)
);
}
public function deleteStoreTransactionByTransId($transid)
{
$this->db->where('transID', $transid);
return $this->db->delete("storetransaction");
}
}