commitall
This commit is contained in:
68
account/application/models/MAttendance.php
Normal file
68
account/application/models/MAttendance.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
class MAttendance extends CI_Model
|
||||
{
|
||||
function getAttendance()
|
||||
{
|
||||
//echo "select * from tbl_attendances where attendance_date='".date('Y-m-d')."' and status='1'";
|
||||
$TableData=$this->db->query("select * from tbl_attendances where attendance_date='".date('Y-m-d')."' and status=1")->result();
|
||||
//pre($TableData);die;
|
||||
return $TableData;
|
||||
}
|
||||
function getAttendance1()
|
||||
{
|
||||
//echo "select * from tbl_attendances where attendance_date='".date('Y-m-d')."' and status='1'";
|
||||
if(isset($_GET['attendance_date'])){
|
||||
|
||||
$adate=NepaliToEnglishDate($_GET['attendance_date']);
|
||||
}else {
|
||||
$adate=date('Y-m-d');
|
||||
}
|
||||
$TableData=$this->db->query("select * from tbl_attendances where attendance_date='".$adate."'")->result();
|
||||
//pre($TableData);die;
|
||||
return $TableData;
|
||||
}
|
||||
function insertAttendance($TableData1)
|
||||
{
|
||||
|
||||
$this->db->insert('tbl_attendances',$TableData1);
|
||||
}
|
||||
|
||||
function getDateRangeAttendance($from,$to,$id){
|
||||
|
||||
$TableData=$this->db->query("select * from tbl_attendances where attendance_date>='".$from."' and attendance_date<='".$to."' and employee_id=$id group by attendance_date")->result();
|
||||
// foreach($TableData as $tabledata){
|
||||
// $tabledata->employee=$this->db->query("select * from tbl_employees where employee_id=".$tabledata->employee_id)->row();
|
||||
// }
|
||||
//pre($TableData);die;
|
||||
return $TableData;
|
||||
|
||||
}
|
||||
|
||||
function getPresentDateRangeAttendance($from,$to,$id){
|
||||
|
||||
$TableData=$this->db->query("select * from tbl_attendances where attendance_date>='".$from."' and attendance_date<='".$to."' and employee_id=$id and attendance=1 and status=1")->result();
|
||||
// foreach($TableData as $tabledata){
|
||||
// $tabledata->employee=$this->db->query("select * from tbl_employees where employee_id=".$tabledata->employee_id)->row();
|
||||
// }
|
||||
//pre($TableData);die;
|
||||
return $TableData;
|
||||
|
||||
}
|
||||
function getAbsentDateRangeAttendance($from,$to,$id){
|
||||
|
||||
$TableData=$this->db->query("select * from tbl_attendances where attendance_date>='".$from."' and attendance_date<='".$to."' and employee_id=$id and attendance=0 and status=1")->result();
|
||||
// foreach($TableData as $tabledata){
|
||||
// $tabledata->employee=$this->db->query("select * from tbl_employees where employee_id=".$tabledata->employee_id)->row();
|
||||
// }
|
||||
//pre($TableData);die;
|
||||
return $TableData;
|
||||
|
||||
}
|
||||
function getDaysOfRangeAttendance($from,$to){
|
||||
// $t="select * from tbl_attendances where attendance_date>='".$from."' and attendance_date<='".$to."' GROUP BY attendance_date ";
|
||||
//echo $t;die;
|
||||
$TableData=$this->db->query("select * from tbl_attendances where attendance_date>='".$from."' and attendance_date<='".$to."' GROUP BY attendance_date ")->result();
|
||||
return $TableData;
|
||||
}
|
||||
|
||||
}
|
55
account/application/models/MEmployees.php
Normal file
55
account/application/models/MEmployees.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
class MEmployees extends CI_Model
|
||||
{
|
||||
function getDepartments()
|
||||
{
|
||||
$TableData=$this->db->query("select * from tbl_departments where status='1'")->result();
|
||||
return $TableData;
|
||||
}
|
||||
function getDepartmentByAlias($department_alias)
|
||||
{
|
||||
$department_alias=str_replace("_","-",$department_alias);
|
||||
$t="SELECT * FROM tbl_departments WHERE department_alias='$department_alias'";
|
||||
// echo $t;
|
||||
$TableData=$this->db->query($t)->row();
|
||||
return $TableData;
|
||||
}
|
||||
function prepareEmployee($Employee)
|
||||
{
|
||||
$Employee->Type=$this->db->query("select * from tbl_employeetype where employeetype_id='$Employee->employeetype_id'")->row();
|
||||
$Employee->Department=$this->db->query("select * from tbl_departments where department_id='$Employee->department_id'")->row();
|
||||
return $Employee;
|
||||
}
|
||||
function getEmployee($employee_id)
|
||||
{
|
||||
$TableData=$this->db->query("select * from tbl_employees where employee_id='$employee_id'")->row();
|
||||
return $this->prepareEmployee($TableData);
|
||||
}
|
||||
function getEmployees($employeetype_id="",$department_id="")
|
||||
{
|
||||
$t="select * from tbl_employees where status=1";
|
||||
if($employeetype_id!="") $t.=" and employeetype_id='$employeetype_id'";
|
||||
if($department_id!="") $t.=" and department_id='$department_id'";
|
||||
$TableData=$this->db->query($t)->result();
|
||||
foreach ($TableData as $T)
|
||||
{
|
||||
$T=$this->prepareEmployee($T);
|
||||
}
|
||||
return $TableData;
|
||||
}
|
||||
function getSalaryAllocations()
|
||||
{
|
||||
$TableData= $this->db->query("select * from tbl_salaryallocations where status=1")->result();
|
||||
foreach($TableData as $T)
|
||||
{
|
||||
$T->Employee=$this->prepareEmployee($this->getEmployee($T->employee_id));
|
||||
$T->SalaryType=$this->db->query("select * from tbl_salarytypes where salarytype_id='$T->salarytype_id'")->row();
|
||||
}
|
||||
return $TableData;
|
||||
}
|
||||
function getWorkshifts()
|
||||
{
|
||||
$TableData= $this->db->query("select * from tbl_workshifts where status=1")->result();
|
||||
return $TableData;
|
||||
}
|
||||
}
|
62
account/application/models/MHelper.php
Normal file
62
account/application/models/MHelper.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
class MHelper extends CI_Model{
|
||||
function checkIfAliasExist($alias,$alias_name,$table){
|
||||
$this->db->where($alias_name,$alias);
|
||||
$exist=$this->db->get($table);
|
||||
if ($exist->num_rows()>0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
function getMaxDisplayOrder($table){
|
||||
$this->db->select_max('display_order');
|
||||
return $this->db->get($table)->row()->display_order;
|
||||
}
|
||||
|
||||
function getHolidayByDaterangeInFactory($from_date,$to_date){
|
||||
$t="select * from tbl_factorycalendar where day_work=0 and day_ad>='$from_date' and day_ad<='$to_date' ";
|
||||
//echo $t;die;
|
||||
|
||||
return $this->db->query($t)->result();
|
||||
}
|
||||
function getTotalDaysByDaterange($from_date,$to_date){
|
||||
$t="select * from tbl_factorycalendar where day_ad>='$from_date' and day_ad<='$to_date' ";
|
||||
//echo $t;die;
|
||||
|
||||
return $this->db->query($t)->result();
|
||||
}
|
||||
function getTotalPresentsDaysByDaterange($from_date,$to_date,$id){
|
||||
$t="select * from tbl_attendances where attendance=1 and employee_id=$id and attendance_date>='$from_date' and attendance_date<='$to_date' group by attendance_date";
|
||||
//echo $t;die;
|
||||
//echo $t;die;
|
||||
|
||||
return $this->db->query($t)->result();
|
||||
}
|
||||
function getTotalPaidLeavesByDaterange($from_date,$to_date,$id){
|
||||
$t="select * from tbl_attendances where attendance=0 and reason='PL' and employee_id=$id and attendance_date>='$from_date' and attendance_date<='$to_date' group by attendance_date";
|
||||
//echo $t;die;
|
||||
//echo $t;die;
|
||||
|
||||
return $this->db->query($t)->result();
|
||||
}
|
||||
function getTotalUnPaidLeavesByDaterange($from_date,$to_date,$id){
|
||||
$t="select * from tbl_attendances where attendance=0 and reason='Off' and employee_id=$id and attendance_date>='$from_date' and attendance_date<='$to_date' group by attendance_date";
|
||||
//echo $t;die;
|
||||
//echo $t;die;
|
||||
|
||||
return $this->db->query($t)->result();
|
||||
}
|
||||
function getTotalAnnualLeavesByDaterange($from_date,$to_date,$id){
|
||||
$t="select * from tbl_attendances where attendance=0 and reason='SV' and employee_id=$id and attendance_date>='$from_date' and attendance_date<='$to_date' group by attendance_date";
|
||||
//echo $t;die;
|
||||
//echo $t;die;
|
||||
|
||||
return $this->db->query($t)->result();
|
||||
}
|
||||
function getTotalSickLeavesByDaterange($from_date,$to_date,$id){
|
||||
$t="select * from tbl_attendances where attendance=0 and reason='SL' and employee_id=$id and attendance_date>='$from_date' and attendance_date<='$to_date' group by attendance_date";
|
||||
//echo $t;die;
|
||||
//echo $t;die;
|
||||
|
||||
return $this->db->query($t)->result();
|
||||
}
|
||||
}
|
0
account/application/models/MPassword.php
Normal file
0
account/application/models/MPassword.php
Normal file
65
account/application/models/MPurchases.php
Normal file
65
account/application/models/MPurchases.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
class MPurchases extends CI_Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function getTotalPurchaseAmount($purchase_id)
|
||||
{
|
||||
$PurchaseRecords = $this->db->where("status", 1)->where("purchases_id", $purchase_id)->get("tbl_purchasedetails")->result();
|
||||
$total = 0;
|
||||
foreach ($PurchaseRecords as $PurchaseRecord) {
|
||||
$total = $total + ($PurchaseRecord->qty) * ($PurchaseRecord->rate);
|
||||
}
|
||||
return $total;
|
||||
}
|
||||
public function getPurchase()
|
||||
{
|
||||
$Purchase = $this->db->where("status", 1)->get("tbl_purchases")->result();
|
||||
foreach ($Purchase as $Sale) {
|
||||
$Sale->Details = $this->getPurchaseDetails($Sale->purchase_id);
|
||||
}
|
||||
return $Purchase;
|
||||
}
|
||||
public function getPurchaseDetails($purchase_id = 0)
|
||||
{
|
||||
$this->db->where("status", 1);
|
||||
if ($purchase_id != 0) {
|
||||
$this->db->where("purchases_id", $purchase_id);
|
||||
}
|
||||
$PurchaseRecords = $this->db->get("tbl_purchasedetails")->result();
|
||||
$total = 0;
|
||||
foreach ($PurchaseRecords as $PurchaseRecord) {
|
||||
$PurchaseRecord->Purchase = $this->db->where("purchase_id", $PurchaseRecord->purchases_id)->get("tbl_purchases")->row();
|
||||
$PurchaseRecord->Item = $this->db->where("item_id", $PurchaseRecord->items_id)->get("tbl_items")->row();
|
||||
$PurchaseRecord->Account = $this->db->where("account_id", $PurchaseRecord->Purchase->accounts_id)->get("tbl_accounts")->row();
|
||||
$total = $total + ($PurchaseRecord->qty) * ($PurchaseRecord->rate);
|
||||
$PurchaseRecord->TotalPurchase = $total;
|
||||
}
|
||||
return $PurchaseRecords;
|
||||
}
|
||||
public function getPurchaseRecords()
|
||||
{
|
||||
$PurchaseRecords = $this->db->where("status", 1)->get("tbl_purchases")->result();
|
||||
foreach ($PurchaseRecords as $PurchaseRecord) {
|
||||
$PurchaseRecord->Details = $this->getPurchaseDetails($PurchaseRecord->purchase_id);
|
||||
$PurchaseRecord->TotalPurchase = $this->getTotalPurchaseAmount($PurchaseRecord->purchase_id);
|
||||
}
|
||||
return $PurchaseRecords;
|
||||
}
|
||||
public function getItemPurchases($item_id = 0)
|
||||
{
|
||||
$this->db->where("status", 1);
|
||||
if ($item_id != 0) {
|
||||
$this->db->where("items_id", $item_id);
|
||||
}
|
||||
$this->db->select('items_id, AVG(rate) as average_rate, SUM(qty) as total_qty, SUM(rate * qty) as line_total');
|
||||
$this->db->group_by('items_id');
|
||||
$PurchaseRecords = $this->db->get('tbl_purchasedetails')->result();
|
||||
foreach ($PurchaseRecords as $PurchaseRecord) {
|
||||
$PurchaseRecord->Item = $this->db->where("item_id", $PurchaseRecord->items_id)->get("tbl_items")->row();
|
||||
}
|
||||
return $PurchaseRecords;
|
||||
}
|
||||
}
|
66
account/application/models/MSales.php
Normal file
66
account/application/models/MSales.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
class MSales extends CI_Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function getTotalSalesAmount($sales_id)
|
||||
{
|
||||
$SalesRecords = $this->db->where("status", 1)->where("sales_id", $sales_id)->get("tbl_salesdetails")->result();
|
||||
$total = 0;
|
||||
foreach ($SalesRecords as $SalesRecord) {
|
||||
$total = $total + ($SalesRecord->qty) * ($SalesRecord->rate);
|
||||
}
|
||||
return $total;
|
||||
}
|
||||
public function getSales()
|
||||
{
|
||||
$Sales = $this->db->where("status", 1)->get("tbl_sales")->result();
|
||||
foreach ($Sales as $Sale) {
|
||||
$Sale->Details = $this->getSalesDetails($Sale->sales_id);
|
||||
}
|
||||
return $Sales;
|
||||
}
|
||||
public function getSalesDetails($sales_id = 0)
|
||||
{
|
||||
$this->db->where("status", 1);
|
||||
if ($sales_id != 0) {
|
||||
$this->db->where("sales_id", $sales_id);
|
||||
}
|
||||
$SalesRecords = $this->db->get("tbl_salesdetails")->result();
|
||||
$total = 0;
|
||||
foreach ($SalesRecords as $SalesRecord) {
|
||||
$SalesRecord->Sales = $this->db->where("sales_id", $SalesRecord->sales_id)->get("tbl_sales")->row();
|
||||
$SalesRecord->Account = $this->db->where("account_id", $SalesRecord->Sales->accounts_id)->get("tbl_accounts")->row();
|
||||
$SalesRecord->Item = $this->db->where("item_id", $SalesRecord->items_id)->get("tbl_items")->row();
|
||||
$total = $total + ($SalesRecord->qty) * ($SalesRecord->rate);
|
||||
$SalesRecord->TotalSales = $total;
|
||||
}
|
||||
return $SalesRecords;
|
||||
}
|
||||
public function getSalesRecords()
|
||||
{
|
||||
$SalesRecords = $this->db->where("status", 1)->get("tbl_sales")->result();
|
||||
foreach ($SalesRecords as $SalesRecord) {
|
||||
$SalesRecord->Details = $this->getSalesDetails($SalesRecord->sales_id);
|
||||
$SalesRecord->totalsales = $this->getTotalSalesAmount($SalesRecord->sales_id);
|
||||
}
|
||||
return $SalesRecords;
|
||||
}
|
||||
public function getItemSales($sales_id = 0)
|
||||
{
|
||||
$this->db->select('items_id, AVG(rate) as average_rate, SUM(qty) as total_qty, SUM(qty * rate) as line_total');
|
||||
$this->db->from('tbl_salesdetails');
|
||||
if ($sales_id != 0) {
|
||||
$this->db->where('sales_id', $sales_id);
|
||||
}
|
||||
$this->db->group_by('items_id');
|
||||
$query = $this->db->get();
|
||||
$SalesRecords=$query->result();
|
||||
foreach ($SalesRecords as $SalesRecord) {
|
||||
$SalesRecord->Item = $this->db->where("item_id", $SalesRecord->items_id)->get("tbl_items")->row();
|
||||
}
|
||||
return $SalesRecords;
|
||||
}
|
||||
}
|
211
account/application/models/MStocks.php
Normal file
211
account/application/models/MStocks.php
Normal file
@@ -0,0 +1,211 @@
|
||||
<?php
|
||||
class MStocks extends CI_Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function isDeleteable($item_id)
|
||||
{
|
||||
$this->db->where("items_id", $item_id);
|
||||
$t = $this->db->get("tbl_salesdetails")->row();
|
||||
if ($t) return false;
|
||||
$this->db->where("items_id", $item_id);
|
||||
$t = $this->db->get("tbl_purchasedetails")->row();
|
||||
if ($t) return false;
|
||||
return true;
|
||||
}
|
||||
public function deleteOpeningStock($item_id)
|
||||
{
|
||||
$this->db->where("items_id", $item_id);
|
||||
$this->db->delete("tbl_stocks");
|
||||
}
|
||||
public function updateOpeningStock($item_id, $qty, $rate)
|
||||
{
|
||||
$this->db->where("items_id", $item_id);
|
||||
$this->db->delete("tbl_stocks");
|
||||
$this->db->insert("tbl_stocks", [
|
||||
'stocklocations_id' => 1,
|
||||
'ref_id' => 0,
|
||||
"title" => "Opening Stock",
|
||||
"items_id" => $item_id,
|
||||
"qty" => $qty,
|
||||
'price' => $rate,
|
||||
'status' => 1,
|
||||
'created_on' => date("y-m-d H:i:s")
|
||||
]);
|
||||
}
|
||||
public function addOpeningStock($item_id, $qty, $rate)
|
||||
{
|
||||
$this->db->insert("tbl_stocks", [
|
||||
'stocklocations_id' => 1,
|
||||
'ref_id' => 0,
|
||||
"title" => "Opening Stock",
|
||||
"items_id" => $item_id,
|
||||
"qty" => $qty,
|
||||
'price' => $rate,
|
||||
'status' => 1,
|
||||
'created_on' => date("y-m-d H:i:s")
|
||||
]);
|
||||
}
|
||||
public function getSellableItems()
|
||||
{
|
||||
$subquery = "(SELECT SUM(qty) FROM tbl_stocks WHERE item_id = tbl_items.item_id) AS total_qty";
|
||||
$this->db->select("tbl_items.*, $subquery", false);
|
||||
$this->db->having('total_qty >', 0);
|
||||
return $this->db->get("tbl_items")->result();
|
||||
}
|
||||
|
||||
public function getItemSalesStock($item_id)
|
||||
{
|
||||
|
||||
$this->db->where("status", 1);
|
||||
$this->db->where("items_id", $item_id);
|
||||
// $this->db->where("title='Opening Stock'");
|
||||
$Items = $this->db->get("tbl_salesdetails")->result();
|
||||
$qty = 0;
|
||||
$rate = 0;
|
||||
$nos = 0;
|
||||
foreach ($Items as $Item) {
|
||||
$qty += $Item->qty;
|
||||
$nos++;
|
||||
$rate += $Item->rate;
|
||||
}
|
||||
if($nos!=0) $rate = $rate / $nos;
|
||||
|
||||
$SalesStock = new stdClass;
|
||||
$SalesStock->qty = $qty;
|
||||
$SalesStock->rate = $rate;
|
||||
$SalesStock->amount = $qty * $rate;
|
||||
return $SalesStock;
|
||||
}
|
||||
public function getItemPurchaseStock($item_id)
|
||||
{
|
||||
|
||||
$this->db->where("status", 1);
|
||||
$this->db->where("items_id", $item_id);
|
||||
// $this->db->where("title='Opening Stock'");
|
||||
$Items = $this->db->get("tbl_purchasedetails")->result();
|
||||
$qty = 0;
|
||||
$rate = 0;
|
||||
$nos = 0;
|
||||
foreach ($Items as $Item) {
|
||||
$qty += $Item->qty;
|
||||
$nos++;
|
||||
$rate += $Item->rate;
|
||||
}
|
||||
if($nos!=0) $rate = $rate / $nos;
|
||||
$PurchaseStock = new stdClass;
|
||||
$PurchaseStock->qty = $qty;
|
||||
$PurchaseStock->rate = $rate;
|
||||
$PurchaseStock->amount = $qty * $rate;
|
||||
return $PurchaseStock;
|
||||
}
|
||||
|
||||
public function getOpeningStock($item_id)
|
||||
{
|
||||
$this->db->where("status", 1);
|
||||
$this->db->where("items_id", $item_id);
|
||||
$this->db->where("title='Opening Stock'");
|
||||
$Items = $this->db->get("tbl_stocks")->result();
|
||||
$qty = 0;
|
||||
$rate = 0;
|
||||
$nos = 0;
|
||||
foreach ($Items as $Item) {
|
||||
$qty += $Item->qty;
|
||||
$nos++;
|
||||
$rate += $Item->price;
|
||||
}
|
||||
if($nos!=0) $rate = $rate / $nos;
|
||||
$OpeningStock = new stdClass;
|
||||
$OpeningStock->qty = $qty;
|
||||
$OpeningStock->rate = $rate;
|
||||
$OpeningStock->amount = $qty * $rate;
|
||||
return $OpeningStock;
|
||||
}
|
||||
public function getClosingStock($item_id)
|
||||
{
|
||||
$OpeningStock=$this->getOpeningStock($item_id);
|
||||
$PurchaseStock=$this->getItemPurchaseStock($item_id);
|
||||
$SalesStock=$this->getItemSalesStock($item_id);
|
||||
$ClosingStock = new stdClass;
|
||||
$ClosingStock->qty =$PurchaseStock->qty+$OpeningStock->qty-$SalesStock->qty;
|
||||
$ClosingStock->rate = $PurchaseStock->rate+$OpeningStock->rate-$SalesStock->rate;
|
||||
$ClosingStock->amount = $ClosingStock->qty * $ClosingStock->rate;
|
||||
return $ClosingStock;
|
||||
}
|
||||
public function getStockItemSummary($item_id)
|
||||
{
|
||||
$this->db->where("status", 1);
|
||||
$this->db->where("items_id", $item_id);
|
||||
$Item = $this->db->get("tbl_stocks")->row();
|
||||
$qty = 0;
|
||||
$price = 0;
|
||||
$Item->Item = $this->db->where("item_id", $item_id)->get("tbl_items")->row();
|
||||
$Item->qty = $this->db->where("items_id", $item_id)->select("sum(qty) as qty")->get("tbl_stocks")->row()->qty;
|
||||
$Item->amount = $this->db->where("items_id", $item_id)->select("sum(price * qty) as amount")->get("tbl_stocks")->row()->amount;
|
||||
$Item->Opening = $this->getOpeningStock($item_id);
|
||||
$Item->Purchase = $this->getItemPurchaseStock($item_id);
|
||||
$Item->Sales = $this->getItemSalesStock($item_id);
|
||||
$Item->Closing = $this->getClosingStock($item_id);
|
||||
return $Item;
|
||||
}
|
||||
public function getStockSummary($stocklocation_id = 0)
|
||||
{
|
||||
$this->db->where("status", 1);
|
||||
if ($stocklocation_id != 0) {
|
||||
$this->db->where("stocklocations_id", $stocklocation_id);
|
||||
}
|
||||
$StockRecords = $this->db->select("distinct(items_id) as items_id")->get("tbl_stocks")->result();
|
||||
foreach ($StockRecords as $StockRecord) {
|
||||
$StockRecord->Summary = $this->getStockItemSummary($StockRecord->items_id);
|
||||
// $StockRecord->StockLocation = $this->db->where("stocklocation_id", $StockRecord->stocklocations_id)->get("tbl_stocklocations")->row();
|
||||
$StockRecord->Item = $this->db->where("item_id", $StockRecord->items_id)->get("tbl_items")->row();
|
||||
}
|
||||
return $StockRecords;
|
||||
}
|
||||
public function getStockRecords($stocklocation_id = 0)
|
||||
{
|
||||
$this->db->where("status", 1);
|
||||
if ($stocklocation_id != 0) {
|
||||
$this->db->where("stocklocations_id", $stocklocation_id);
|
||||
}
|
||||
$StockRecords = $this->db->get("tbl_stocks")->result();
|
||||
foreach ($StockRecords as $StockRecord) {
|
||||
$StockRecord->StockLocation = $this->db->where("stocklocation_id", $StockRecord->stocklocations_id)->get("tbl_stocklocations")->row();
|
||||
$StockRecord->Item = $this->db->where("item_id", $StockRecord->items_id)->get("tbl_items")->row();
|
||||
$StockRecord->Item->Unit = $this->db->where("unit_id", $StockRecord->Item->units_id)->get("tbl_units")->row();
|
||||
}
|
||||
return $StockRecords;
|
||||
}
|
||||
public function addPurchaseToStock($PurchaseDetails)
|
||||
{
|
||||
foreach ($PurchaseDetails as $PurchaseDetail) {
|
||||
$TableData = array(
|
||||
'stocklocations_id' => 1,
|
||||
'ref_id' => $PurchaseDetail->purchases_id,
|
||||
'title' => "Purchase",
|
||||
'items_id' => $PurchaseDetail->items_id,
|
||||
'qty' => $PurchaseDetail->qty,
|
||||
'price' => $PurchaseDetail->rate,
|
||||
'status' => 1,
|
||||
);
|
||||
$this->db->insert("tbl_stocks", $TableData);
|
||||
}
|
||||
}
|
||||
public function addSalesToStock($SalesDetails)
|
||||
{
|
||||
foreach ($SalesDetails as $SalesDetail) {
|
||||
$TableData = array(
|
||||
'stocklocations_id' => 1,
|
||||
'ref_id' => $SalesDetail->sales_id,
|
||||
'title' => "Sales",
|
||||
'items_id' => $SalesDetail->items_id,
|
||||
'qty' => (-$SalesDetail->qty),
|
||||
'price' => $SalesDetail->rate,
|
||||
'status' => 1,
|
||||
);
|
||||
$this->db->insert("tbl_stocks", $TableData);
|
||||
}
|
||||
}
|
||||
}
|
33
account/application/models/MUsers.php
Normal file
33
account/application/models/MUsers.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
class MUsers extends CI_Model{
|
||||
function addUser($input){
|
||||
$this->db->insert('tbl_users',$input);
|
||||
}
|
||||
function updateUser($input,$id){
|
||||
$this->db->where('user_id',$id);
|
||||
$this->db->update('tbl_users',$input);
|
||||
}
|
||||
function getUsers($id=''){
|
||||
if ($id!=''){
|
||||
$this->db->where('user_id',$id);
|
||||
}
|
||||
$this->db->where('status', 1);
|
||||
$this->db->or_where('status', 2);
|
||||
$result=$this->db->get('tbl_users');
|
||||
if ($id!=''){
|
||||
return $result->row();
|
||||
}
|
||||
return $result->result();
|
||||
}
|
||||
function getUserById($id){
|
||||
$this->db->where('user_id',$id);
|
||||
return $this->db->get('tbl_users')->row();
|
||||
}
|
||||
function deleteuser($id){
|
||||
$table="tbl_users";
|
||||
$this->db->where('user_id',$id);
|
||||
$input['status']=0;
|
||||
$this->db->update($table,$input);
|
||||
}
|
||||
}
|
11
account/application/models/index.html
Normal file
11
account/application/models/index.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user