umstellung auf shared codeigniter und postgres php8.2
This commit is contained in:
@@ -13,7 +13,7 @@ class mBills extends Model {
|
||||
protected $returnType = 'object';
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $allowedFields = ['renummer','datum','receiver','source_id','amount','type','comment','validate','LKZ'];
|
||||
protected $allowedFields = ['renummer','datum','receiver','source_id','amount','type','comment','validate','lkz'];
|
||||
|
||||
protected $useTimestamps = false;
|
||||
|
||||
@@ -38,7 +38,7 @@ class mBills extends Model {
|
||||
$this->orWhereIn('id', $keys );
|
||||
$this->groupEnd();
|
||||
}
|
||||
$result = $this->orderBy('datum','desc')->where('LKZ',null)->findAll();
|
||||
$result = $this->orderBy('datum','desc')->where('lkz',null)->findAll();
|
||||
$keys=array();
|
||||
foreach ($result as $value) {
|
||||
$keys[] = intval($value->id);
|
||||
@@ -61,7 +61,7 @@ class mBills extends Model {
|
||||
function getEntries(){
|
||||
$details = model('App\Models\mBillDetails');
|
||||
$quelle = model('App\Models\mAccounts');
|
||||
$result = $this->orderBy('datum','desc')->where('validate',0)->where('LKZ',null)->findAll(10);
|
||||
$result = $this->orderBy('datum','desc')->where('validate',false)->where('lkz',null)->findAll(10);
|
||||
$keys=array();
|
||||
foreach ($result as $value) {
|
||||
$keys[] = intval($value->id);
|
||||
@@ -101,7 +101,7 @@ class mBills extends Model {
|
||||
function getToDos(){
|
||||
$details = model('App\Models\mBillDetails');
|
||||
$quelle = model('App\Models\mAccounts');
|
||||
$result = $this->orderBy('datum','desc')->where('validate',1)->where('LKZ',null)->findAll();
|
||||
$result = $this->orderBy('datum','desc')->where('validate',true)->where('lkz',null)->findAll();
|
||||
$keys=array();
|
||||
foreach ($result as $value) {
|
||||
$keys[] = intval($value->id);
|
||||
@@ -118,48 +118,42 @@ class mBills extends Model {
|
||||
return $result;
|
||||
}
|
||||
function getAccountsBalance(){
|
||||
$this->select('SUM(amount) as amount, source_id as idd, budget_accounts.description',FALSE);
|
||||
$this->groupby('source_id')->asArray();
|
||||
$this->join('budget_accounts', 'budget_accounts.id = budget_bills.source_id', 'left');
|
||||
$this->where('budget_accounts.type','account');
|
||||
$this->where('budget_accounts.LKZ',null);
|
||||
$this->where('budget_bills.validate',0);
|
||||
$result1 = $this->where('budget_bills.LKZ',null)->findAll();
|
||||
$assoc1 = array();
|
||||
foreach ($result1 as $value) {
|
||||
$assoc1[$value['idd']] = $value;
|
||||
}
|
||||
// $this->select('SUM((-1)*amount) as amount, target_id as idd, mw_budget_categories.description',FALSE);
|
||||
// $this->groupby('target_id')->asArray();
|
||||
// $this->join('mw_budget_categories', 'mw_budget_categories.id = mw_budget_bookings.target_id', 'left');
|
||||
// $this->where('mw_budget_categories.type','account');
|
||||
// $this->where('mw_budget_categories.LKZ',NULL);
|
||||
// $result2 = $this->where('mw_budget_bookings.LKZ',NULL)->findAll();
|
||||
// $assoc2 = array();
|
||||
// foreach ($result2 as $value) {
|
||||
// $assoc2[$value['idd']] = $value;
|
||||
// $this->select('SUM(amount) as amount, source_id as idd, budget_accounts.description',FALSE);
|
||||
// $this->groupby('source_id')->asArray();
|
||||
// $this->join('budget_accounts', 'budget_accounts.id = budget_bills.source_id', 'left');
|
||||
// $this->where('budget_accounts.type','account');
|
||||
// $this->where('budget_accounts.lkz',null);
|
||||
// $this->where('budget_bills.validate',false);
|
||||
// $result1 = $this->where('budget_bills.lkz',null)->findAll();
|
||||
// $assoc1 = array();
|
||||
// foreach ($result1 as $value) {
|
||||
// $assoc1[$value['idd']] = $value;
|
||||
// }
|
||||
$details = model('App\Models\mBillDetails');
|
||||
$details->select('SUM((-1)*subamount) as amount, account_id as idd, budget_accounts.description',FALSE);
|
||||
$details->groupby('account_id')->asArray();
|
||||
$details->join('budget_accounts', 'budget_accounts.id = budget_billdetails.account_id', 'left');
|
||||
$details->join('budget_bills', 'budget_bills.id = budget_billdetails.bill_id', 'left');
|
||||
$details->where('budget_accounts.type','account');
|
||||
$details->where('budget_bills.validate',0);
|
||||
$details->where('budget_accounts.LKZ',NULL);
|
||||
$result3 = $details->where('budget_billdetails.LKZ',NULL)->findAll();
|
||||
$assoc3 = array();
|
||||
foreach ($result3 as $value) {
|
||||
$assoc3[$value['idd']] = $value;
|
||||
}
|
||||
$sums = array();
|
||||
foreach (array_keys($assoc1 + $assoc3) as $key) {
|
||||
$obj = new \stdClass;
|
||||
$obj->amount = (isset($assoc1[$key]) ? floatval($assoc1[$key]['amount']) : 0) + (isset($assoc3[$key]) ? floatval($assoc3[$key]['amount']) : 0);
|
||||
$obj->description = isset($assoc1[$key]) ? $assoc1[$key]['description'] : $assoc3[$key]['description'];
|
||||
$sums[] = $obj;
|
||||
}
|
||||
return $sums;
|
||||
|
||||
// $details = model('App\Models\mBillDetails');
|
||||
// $details->select('SUM((-1)*subamount) as amount, account_id as idd, budget_accounts.description',FALSE);
|
||||
// $details->groupby('account_id')->asArray();
|
||||
// $details->join('budget_accounts', 'budget_accounts.id = budget_billdetails.account_id', 'left');
|
||||
// $details->join('budget_bills', 'budget_bills.id = budget_billdetails.bill_id', 'left');
|
||||
// $details->where('budget_accounts.type','account');
|
||||
// $details->where('budget_bills.validate',false);
|
||||
// $details->where('budget_accounts.lkz',NULL);
|
||||
// $result3 = $details->where('budget_billdetails.lkz',NULL)->findAll();
|
||||
// $assoc3 = array();
|
||||
// foreach ($result3 as $value) {
|
||||
// $assoc3[$value['idd']] = $value;
|
||||
// }
|
||||
// $sums = array();
|
||||
// foreach (array_keys($assoc1 + $assoc3) as $key) {
|
||||
// $obj = new \stdClass;
|
||||
// $obj->amount = (isset($assoc1[$key]) ? floatval($assoc1[$key]['amount']) : 0) + (isset($assoc3[$key]) ? floatval($assoc3[$key]['amount']) : 0);
|
||||
// $obj->description = isset($assoc1[$key]) ? $assoc1[$key]['description'] : $assoc3[$key]['description'];
|
||||
// $sums[] = $obj;
|
||||
// }
|
||||
$sums = $this->db->query("SELECT * FROM get_account_balance4()");
|
||||
//$this->from("get_account_balance4()")->findAll();
|
||||
// $this->groupby('source_id')->asArray();
|
||||
return $sums->getResult();
|
||||
}
|
||||
|
||||
public function saveBill($data){
|
||||
@@ -169,10 +163,10 @@ class mBills extends Model {
|
||||
|
||||
$this->set('source_id', $data['source']);
|
||||
$total = floatval($data['total_in'])-floatval($data['total_out']);
|
||||
if ($total == 0)
|
||||
if ( !isset($data['multi']) )
|
||||
$total = floatval($data['input'][0])-floatval($data['output'][0]);
|
||||
$this->set('amount', $total);
|
||||
$this->set('validate', $data['validate']??0);
|
||||
$this->set('validate', $data['validate']??false);
|
||||
if ($data['transfer']==1){
|
||||
$this->set('receiver', $accounts->getDropDownEntry($data['category'][0]));
|
||||
$this->set('type', 'transfer');
|
||||
|
||||
Reference in New Issue
Block a user