umstellung auf shared codeigniter und postgres php8.2
This commit is contained in:
@@ -11,7 +11,7 @@ class mAccounts extends Model {
|
||||
protected $returnType = 'object';
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $allowedFields = ['parent_id','type','bookable','description','LKZ'];
|
||||
protected $allowedFields = ['parent_id','type','bookable','description','lkz'];
|
||||
|
||||
protected $useTimestamps = false;
|
||||
private $mAccountList = array();
|
||||
@@ -65,12 +65,12 @@ class mAccounts extends Model {
|
||||
* liefert DropDown Liste mit gegeben Suchparametern
|
||||
* @param string Kontotyp "InOut,In,Out,Acc"
|
||||
* @param bool ob bookable gesetzt sein muss
|
||||
* @return bool ob LKZ Flag gesetzt sein darf
|
||||
* @return bool ob lkz Flag gesetzt sein darf
|
||||
*/
|
||||
public function getDropDownList($type, $bookable = true, $lkz = false )
|
||||
{
|
||||
if ($bookable == true)
|
||||
$this->where('bookable',1);
|
||||
$this->where('bookable',true);
|
||||
if ($lkz == false) $this->where('lkz',NULL);
|
||||
if ( $type == 'InOut' ) $this->where('type !=','account');
|
||||
elseif ( $type == 'Acc' ) $this->where('type','account');
|
||||
@@ -99,11 +99,11 @@ class mAccounts extends Model {
|
||||
* parent für Vorselektion, subs für Untereinträge
|
||||
* @param string Kontotyp "InOut,In,Out,Acc"
|
||||
* @param bool ob bookable gesetzt sein muss
|
||||
* @return bool ob LKZ Flag gesetzt sein darf
|
||||
* @return bool ob lkz Flag gesetzt sein darf
|
||||
*/
|
||||
public function getDropDownLists($type, $bookable = true, $lkz = false )
|
||||
{
|
||||
if ($bookable == true) $this->where('bookable',1);
|
||||
if ($bookable == true) $this->where('bookable',true);
|
||||
if ($lkz == false) $this->where('lkz',null);
|
||||
if ( $type == 'InOut' ) $this->where('type !=','account');
|
||||
elseif ( $type == 'Acc' ) $this->where('type','account');
|
||||
@@ -119,7 +119,7 @@ class mAccounts extends Model {
|
||||
$id = $element->parent_id;
|
||||
while ( $id > 0 )
|
||||
{
|
||||
if ($this->mAccountList[$id]->LKZ == 1) continue 2;
|
||||
if ($this->mAccountList[$id]->lkz == 1) continue 2;
|
||||
if ($this->mAccountList[$id]->parent_id == 0){
|
||||
if (!array_key_exists($id, $parent))
|
||||
$parent[$id] = (object)['id' => $id,'description' => $this->mAccountList[$id]->description ];
|
||||
@@ -134,7 +134,7 @@ class mAccounts extends Model {
|
||||
$subs = array();
|
||||
$subs[0] = $this->createDropDownList(array());
|
||||
foreach ( $listen as $key => $element ){
|
||||
$subs[$key] = $this->createDropDownList($element,$this->mAccountList[$key]->bookable, $key);
|
||||
$subs[$key] = $this->createDropDownList($element,($this->mAccountList[$key]->bookable=="t"), $key);
|
||||
}
|
||||
return array('parent'=> $this->createDropDownList($parent),'subs'=>(object)$subs);
|
||||
}
|
||||
@@ -188,9 +188,9 @@ class mAccounts extends Model {
|
||||
public function saveAccount($data){
|
||||
$this->set('parent_id',$data['parent']);
|
||||
$this->set('type', $data['type']);
|
||||
$this->set('bookable', array_key_exists('bookable', $data) ? 1 : 0);
|
||||
$this->set('bookable', array_key_exists('bookable', $data) ? true : false);
|
||||
$this->set('description', $data['description']);
|
||||
$this->set('LKZ', (array_key_exists('lkz', $data) ? 1 : null));
|
||||
$this->set('lkz', (array_key_exists('lkz', $data) ? 1 : null));
|
||||
if ($data['id'] == 0)
|
||||
$this->insert();
|
||||
else
|
||||
|
||||
@@ -11,7 +11,7 @@ class mBillDetails extends Model {
|
||||
protected $returnType = 'object';
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $allowedFields = ['bill_id','comment','account_id','subamount','LKZ'];
|
||||
protected $allowedFields = ['bill_id','comment','account_id','subamount','lkz'];
|
||||
|
||||
protected $useTimestamps = false;
|
||||
|
||||
|
||||
@@ -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