Files
2021-07-10 16:25:16 +02:00

130 lines
4.7 KiB
PHP

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Agenda extends MY_controller {
function __construct(){
parent::__construct();
$models = array('ijkpartituur/ModAgenda',
'ijkpartituur/ModPartPijlers',
"ijkpartituur/Partituurs_model",
"ijkpartituur/Modpartactiviteiten");
$this->load->model($models);
if ( ! $this->check_online_status() ) {
echo json_encode( array('offline' => TRUE) );
die;
};// if
}
public function index(){
}
public function getPijlers(){
$where=array("partituur_actief" => 1, 'partituur_organisatie_id' =>$this->globorgid);
$partituur= $this->Partituurs_model->get_records_where($where,TRUE,FALSE);
if ($partituur) {
$partID=$partituur->id;
$pijlers=$this->ModPartPijlers->get_pijlers_per_partituur($partID);
}else{
$partID=FALSE;
$pijlers=FALSE;
}
echo json_encode(array("pijlers" =>$pijlers,
"partID" =>$partID));
}
public function getActiviteiten(){
if (!$this->userid) return;
$pijlerID = $this->clean_input("pijlerid");
$activiteiten = $this->Modpartactiviteiten->get_taaklijst($pijlerID);
echo json_encode(array("activiteiten" => $activiteiten));
}
public function getActiviteitenPerDag(){
if (!$this->userid) return;
$pijlerID = $this->clean_input("pijlerID");
$dag = $this->clean_input('dag');
$maand = $this->clean_input('maand');
$jaar = $this->clean_input('jaar');
$activiteiten = $this->Modpartactiviteiten->get_taaklijst($pijlerID, $dag, $maand, $jaar);
echo json_encode(array('activiteiten' => $activiteiten));
}
public function getItems(){
if (!$this->userid) return;
$pijlerID = $this->clean_input("PijlerID");
$activiteitID = $this->clean_input("ActiviteitID");
$maand = $this->clean_input("Maand");
$jaar = $this->clean_input("Jaar");
$items = $this->ModAgenda->get_items($pijlerID, $activiteitID, $maand, $jaar);
echo json_encode(array('items' => $items));
}
public function saveEvent(){
if (!$this->userid) return;
$eventID = $this->clean_input("id");
$data = array("toegang" => $this->clean_input('toegang') ,
'wijzig' => $this->clean_input('wijzig') ,
'pijlerID' => $this->clean_input('pijlerID') ,
'activiteitID' => $this->clean_input('activiteitID') ,
'colorcode' => $this->clean_input('color') ,
'startUur' => $this->clean_input('startUur') ,
'startMinuut' => $this->clean_input('startMinuut') ,
'eindUur' => $this->clean_input('eindUur') ,
'eindMinuut' => $this->clean_input('eindMinuut') ,
'titel' => $this->clean_input('titel') ,
'opmerking' => $this->clean_input('opmerking') ,
);
$this->ModAgenda->update_record($data, $eventID);
}
function newAfspraak(){
if (!$this->userid) return;
$data = array( "orgid" => $this->globorgid,
"owner" => $this->userid,
'dag' => $this->clean_input('dag'),
'maand' => $this->clean_input('maand'),
'jaar' => $this->clean_input('jaar'),
"toegang" => $this->clean_input('toegang') ,
'wijzig' => $this->clean_input('wijzig') ,
'pijlerID' => $this->clean_input('pijlerID') ,
'activiteitID' => $this->clean_input('activiteitID') ,
'colorcode' => $this->clean_input('colorcode') ,
'startUur' => $this->clean_input('startUur') ,
'startMinuut' => $this->clean_input('startMinuut') ,
'eindUur' => $this->clean_input('eindUur') ,
'eindMinuut' => $this->clean_input('eindMinuut') ,
'titel' => $this->clean_input('titel') ,
'opmerking' => $this->clean_input('opmerking') ,
);
$newID = $this->ModAgenda->insert_record($data);
$newItem = $this->ModAgenda->get_record_by_id($newID);
$newItem->schrijf = 1;
echo json_encode(array("items" =>$newItem));
}
function deleteAfspraak(){
if (!$this->userid) return;
$id = $this->clean_input("itemid");
$this->ModAgenda->delete_record($id);
}
function getMinDag(){
if (!$this->userid) return;
$pijlerID = $this->uri->segment(4);
$mindag = $this->ModAgenda->find_min_dag($pijlerID);
echo json_encode($mindag);
}
function getMaxDag(){
if (!$this->userid) return;
$pijlerID = $this->uri->segment(4);
$maxdag = $this->ModAgenda->find_max_dag($pijlerID);
echo json_encode($maxdag);
}
function getMinMaxDagActiviteit(){
if (!$this->userid) return;
$pijlerID = $this->uri->segment(4);
$actID = $this->uri->segment(5);
$minmaxdag = $this->ModAgenda->find_minmax_dag($pijlerID,$actID);
echo json_encode($minmaxdag);
}
function findEntries(){
if (!$this->userid) return;
$actID = $this->uri->segment(4);
$where=array("activiteitID" => $actID);
$items = $this->ModAgenda->check_for_record($where);
echo json_encode($items);
}
} // einde class Agenda