initial commit
This commit is contained in:
@@ -0,0 +1,143 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/** Bestedingen_model januari 2016 */
|
||||
|
||||
class Bestedingen_model extends MY_Model{
|
||||
|
||||
|
||||
protected $tablename = 'tb_bestedingen';
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$models = array('monpas/Bestemmingslabels_model');
|
||||
$this->load->model($models);
|
||||
}
|
||||
|
||||
function getbestedingen($orgid,$jaarnr){
|
||||
$this->sql= "SELECT id, TRUNCATE((bedrag/100),2) AS bedrag, soort , omschrijving, labelnr
|
||||
FROM tb_bestedingen
|
||||
WHERE orgid ={$orgid}
|
||||
AND kalenderjaarnr = {$jaarnr}
|
||||
ORDER BY labelnr";
|
||||
return $this->get_query_result();
|
||||
}
|
||||
function getbesteding($id){
|
||||
$this->sql= "SELECT id,TRUNCATE((bedrag/100),2) AS bedrag, soort , omschrijving, labelnr
|
||||
FROM tb_bestedingen
|
||||
WHERE id ={$id}";
|
||||
return $this->get_query_row();
|
||||
}
|
||||
function getschoolbestedingen($orgid, $jaarnr){
|
||||
$this->sql="SELECT soort, B.labelnr, B.omschrijving, bedrag , BL.omschrijving as naam
|
||||
FROM tb_bestedingen B
|
||||
JOIN tb_bestemmingslabels BL on BL.id = B.labelnr
|
||||
WHERE orgid = {$orgid}
|
||||
AND kalenderjaarnr = {$jaarnr}
|
||||
ORDER BY B.soort, B.labelnr";
|
||||
return $this->get_query_result();
|
||||
}
|
||||
|
||||
function getschoolbestedingenpersoort($orgid, $jaarnr,$soort){
|
||||
$this->sql="SELECT soort, B.labelnr, B.omschrijving, bedrag , BL.omschrijving as naam
|
||||
FROM tb_bestedingen B
|
||||
JOIN tb_bestemmingslabels BL on BL.id = B.labelnr
|
||||
WHERE orgid = {$orgid}
|
||||
AND kalenderjaarnr = {$jaarnr}
|
||||
AND B.soort = {$soort}
|
||||
ORDER BY B.labelnr";
|
||||
return $this->get_query_result();
|
||||
}
|
||||
function getsom($bedragenarray, $budgetten,$labels, $wat){
|
||||
$returnarray = array();
|
||||
switch ($wat){
|
||||
case 1: $returnarray['budget'] = $budgetten->basis;
|
||||
$returnarray['soort'] = 1;
|
||||
$returnarray['naam'] = 'Basisondersteuning';
|
||||
break;
|
||||
case 2: $returnarray['budget'] = $budgetten->extra;
|
||||
$returnarray['soort'] = 2;
|
||||
$returnarray['naam'] = 'Extra ondersteuning';
|
||||
break;
|
||||
case 3: $returnarray['budget'] = $budgetten->som;
|
||||
$returnarray['soort'] = 3;
|
||||
$returnarray['naam'] = 'Ondersteuning';
|
||||
break;
|
||||
case 4: $returnarray['budget'] = $budgetten->overig;
|
||||
$returnarray['soort'] = 4;
|
||||
$returnarray['naam'] = 'Overig';
|
||||
break;
|
||||
};// switch
|
||||
$returnarray['totsoort'] = 0;
|
||||
|
||||
if ($bedragenarray){
|
||||
$returnarray['labels'] = array();
|
||||
foreach ($labels as $label){
|
||||
$returnarray['labels'][$label->labelnr]['nr'] =$label->labelnr;
|
||||
$returnarray['labels'][$label->labelnr]['naam'] = $label->omschrijving;
|
||||
$returnarray['labels'][$label->labelnr]['som'] = 0;
|
||||
$returnarray['labels'][$label->labelnr]['details'] = array();
|
||||
};
|
||||
foreach ($bedragenarray as $regel){
|
||||
$returnarray['totsoort'] += $regel->bedrag;
|
||||
$returnarray['labels'][$regel->labelnr]['som'] += $regel->bedrag;
|
||||
$returnarray['labels'][$regel->labelnr]['details'][]= $regel;
|
||||
};// foreach bedragenarray
|
||||
}; // if bedragenarray
|
||||
|
||||
$returnarray['verschil'] = number_format($returnarray['budget'] - $returnarray['totsoort'], 2,'.' , ',');
|
||||
return $returnarray;
|
||||
}
|
||||
|
||||
|
||||
function sumschoolbedragen($bedragenarray,$budgetten){
|
||||
$labels = $this->Bestemmingslabels_model->getsoorten();
|
||||
$somtotaal = 0;
|
||||
if ($bedragenarray){
|
||||
foreach($bedragenarray as $regel){
|
||||
if (!isset($sompersoort[$regel->soort]) ){
|
||||
$sompersoort[$regel->soort] = array();
|
||||
$sompersoort[$regel->soort]['som'] = 0;
|
||||
$sompersoort[$regel->soort]['labels']= array();
|
||||
switch ($regel->soort){
|
||||
case 1: $sompersoort[$regel->soort]['budget'] = $budgetten->basis; break;
|
||||
case 2: $sompersoort[$regel->soort]['budget'] = $budgetten->extra;break;
|
||||
case 3: $sompersoort[$regel->soort]['budget'] = $budgetten->som; break;
|
||||
case 4: $sompersoort[$regel->soort]['budget'] = $budgetten->overig; break;
|
||||
};// switch
|
||||
foreach ($labels as $label){
|
||||
$sompersoort[$regel->soort]['labels'][$label->labelnr]['nr'] =$label->labelnr;
|
||||
$sompersoort[$regel->soort]['labels'][$label->labelnr]['naam'] = $label->omschrijving;
|
||||
$sompersoort[$regel->soort]['labels'][$label->labelnr]['som'] = 0;
|
||||
};
|
||||
}
|
||||
$sompersoort[$regel->soort]['som'] +=$regel->bedrag;
|
||||
|
||||
if (!isset($sompersoort[$regel->soort]['labels'][$regel->labelnr])){
|
||||
$sompersoort[$regel->soort]['labels'][$regel->labelnr]['som']=0;
|
||||
}
|
||||
$sompersoort[$regel->soort]['labels'][$regel->labelnr]['som'] += $regel->bedrag;
|
||||
$sompersoort[$regel->soort]['labels'][$regel->labelnr]['details'][]= $regel;
|
||||
$somtotaal += $regel->bedrag;
|
||||
}; // foreach
|
||||
}; //if
|
||||
return array('totaal' => $somtotaal, 'sompersoort'=>$sompersoort);
|
||||
}
|
||||
function getsompersoort($orgid, $jaarnr){
|
||||
$this->sql ="SELECT soort, sum(bedrag) AS bedrag
|
||||
FROM tb_bestedingen
|
||||
WHERE orgid = {$orgid}
|
||||
AND kalenderjaarnr = {$jaarnr}
|
||||
GROUP BY soort";
|
||||
return $this->get_query_result();
|
||||
}
|
||||
function getsompersoortoverorgs($orgids, $jaarnr){
|
||||
$this->sql ="SELECT soort, sum(bedrag) AS bedrag,T.basisextra
|
||||
FROM tb_bestedingen B
|
||||
JOIN tb_toewijzingen T ON (T.orgid = B.orgid)
|
||||
WHERE B.orgid in ({$orgids})
|
||||
AND B.kalenderjaarnr = {$jaarnr}
|
||||
AND T.kalenderjaarnr = {$jaarnr}
|
||||
GROUP BY soort";
|
||||
return $this->get_query_result();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user