mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
Changes to manage the specialization of a prestudent:
- Added method getSpecialization to controller Prestudent - Added method postRmSpecialization to controller Prestudent - Added method postSpecialization to controller Prestudent - Added method getSpecialization to model Notiz_model - Added method rmSpecialization to model Notiz_model - Added method addSpecialization to model Notiz_model
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if (!defined("BASEPATH")) exit("No direct script access allowed");
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Prestudent extends APIv1_Controller
|
||||
{
|
||||
@@ -23,9 +23,9 @@ class Prestudent extends APIv1_Controller
|
||||
{
|
||||
parent::__construct();
|
||||
// Load model PrestudentModel
|
||||
$this->load->model("crm/prestudent_model", "PrestudentModel");
|
||||
$this->load->model('crm/prestudent_model', 'PrestudentModel');
|
||||
// Load library ReihungstestLib
|
||||
$this->load->library("ReihungstestLib");
|
||||
$this->load->library('ReihungstestLib');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,7 +33,7 @@ class Prestudent extends APIv1_Controller
|
||||
*/
|
||||
public function getPrestudent()
|
||||
{
|
||||
$prestudentID = $this->get("prestudent_id");
|
||||
$prestudentID = $this->get('prestudent_id');
|
||||
|
||||
if (isset($prestudentID))
|
||||
{
|
||||
@@ -52,11 +52,80 @@ class Prestudent extends APIv1_Controller
|
||||
*/
|
||||
public function getPrestudentByPersonID()
|
||||
{
|
||||
$person_id = $this->get("person_id");
|
||||
$person_id = $this->get('person_id');
|
||||
|
||||
if (isset($person_id))
|
||||
{
|
||||
$result = $this->PrestudentModel->load(array("person_id" => $person_id));
|
||||
$result = $this->PrestudentModel->load(array('person_id' => $person_id));
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getSpecialization()
|
||||
{
|
||||
$prestudent_id = $this->get('prestudent_id');
|
||||
$titel = $this->get('titel');
|
||||
|
||||
if (isset($prestudent_id) && isset($titel))
|
||||
{
|
||||
// Loads model Notiz_model
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
|
||||
$result = $this->NotizModel->getSpecialization($prestudent_id, $titel);
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postRmSpecialization()
|
||||
{
|
||||
$notiz_id = $this->post()['notiz_id'];
|
||||
|
||||
if (isset($notiz_id))
|
||||
{
|
||||
// Loads model Notiz_model
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
|
||||
$result = $this->NotizModel->rmSpecialization($notiz_id);
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postSpecialization()
|
||||
{
|
||||
$prestudent_id = $this->post()['prestudent_id'];
|
||||
$titel = $this->post()['titel'];
|
||||
$text = $this->post()['text'];
|
||||
|
||||
if (isset($prestudent_id) && isset($titel) && isset($text))
|
||||
{
|
||||
// Loads model Notiz_model
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
|
||||
$result = $this->NotizModel->addSpecialization($prestudent_id, $titel, $text);
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
@@ -75,9 +144,9 @@ class Prestudent extends APIv1_Controller
|
||||
|
||||
if ($this->_validate($prestudent))
|
||||
{
|
||||
if (isset($prestudent["prestudent_id"]))
|
||||
if (isset($prestudent['prestudent_id']))
|
||||
{
|
||||
$result = $this->PrestudentModel->update($prestudent["prestudent_id"], $prestudent);
|
||||
$result = $this->PrestudentModel->update($prestudent['prestudent_id'], $prestudent);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -99,7 +168,7 @@ class Prestudent extends APIv1_Controller
|
||||
{
|
||||
if ($this->_validate($this->delete()))
|
||||
{
|
||||
$result = $this->PrestudentModel->delete($this->delete()["prestudent_id"]);
|
||||
$result = $this->PrestudentModel->delete($this->delete()['prestudent_id']);
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
@@ -118,10 +187,10 @@ class Prestudent extends APIv1_Controller
|
||||
|
||||
if ($this->_validateReihungstest($ddReihungstest))
|
||||
{
|
||||
if(isset($ddReihungstest["new"]) && $ddReihungstest["new"] == true)
|
||||
if(isset($ddReihungstest['new']) && $ddReihungstest['new'] == true)
|
||||
{
|
||||
// Remove new parameter to avoid DB insert errors
|
||||
unset($ddReihungstest["new"]);
|
||||
unset($ddReihungstest['new']);
|
||||
|
||||
$result = $this->reihungstestlib->insertPersonReihungstest($ddReihungstest);
|
||||
}
|
||||
@@ -145,7 +214,7 @@ class Prestudent extends APIv1_Controller
|
||||
{
|
||||
$ddReihungstest = $this->_parseData($this->post());
|
||||
|
||||
if (isset($ddReihungstest["rt_person_id"]))
|
||||
if (isset($ddReihungstest['rt_person_id']))
|
||||
{
|
||||
$result = $this->reihungstestlib->deletePersonReihungstest($ddReihungstest);
|
||||
|
||||
@@ -164,11 +233,11 @@ class Prestudent extends APIv1_Controller
|
||||
|
||||
private function _validateReihungstest($ddReihungstest = NULL)
|
||||
{
|
||||
if (!isset($ddReihungstest["person_id"]) || !isset($ddReihungstest["rt_id"]) || !isset($ddReihungstest["studienplan_id"]))
|
||||
if (!isset($ddReihungstest['person_id']) || !isset($ddReihungstest['rt_id']) || !isset($ddReihungstest['studienplan_id']))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
class Notiz_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@@ -11,4 +11,88 @@ class Notiz_model extends DB_Model
|
||||
$this->dbTable = 'public.tbl_notiz';
|
||||
$this->pk = 'notiz_id';
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Get a specialization for a prestudent
|
||||
*/
|
||||
public function getSpecialization($prestudent_id, $titel)
|
||||
{
|
||||
// Join with the table public.tbl_notizzuordnung using notiz_id
|
||||
$this->addJoin('public.tbl_notizzuordnung', 'notiz_id');
|
||||
|
||||
return $this->NotizModel->loadWhere(array('prestudent_id' => $prestudent_id, 'titel' => $titel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a specialization
|
||||
*/
|
||||
public function rmSpecialization($notiz_id)
|
||||
{
|
||||
// Loads model Notizzuordnung_model
|
||||
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
|
||||
|
||||
// Start DB transaction
|
||||
$this->db->trans_start(false);
|
||||
|
||||
$result = $this->delete(array('notiz_id' => $notiz_id));
|
||||
if (is_object($result) && $result->error == EXIT_SUCCESS)
|
||||
{
|
||||
$result = $this->NotizzuordnungModel->delete(array('notiz_id' => $notiz_id));
|
||||
}
|
||||
|
||||
// Transaction complete!
|
||||
$this->db->trans_complete();
|
||||
|
||||
// Check if everything went ok during the transaction
|
||||
if ($this->db->trans_status() === false || (is_object($result) && $result->error != EXIT_SUCCESS))
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
$result = error($result->msg, EXIT_ERROR);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->trans_commit();
|
||||
$result = success('Specialization successfully removed');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a specialization for a prestudent
|
||||
*/
|
||||
public function addSpecialization($prestudent_id, $titel, $text)
|
||||
{
|
||||
// Loads model Notizzuordnung_model
|
||||
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
|
||||
|
||||
// Start DB transaction
|
||||
$this->db->trans_start(false);
|
||||
|
||||
$result = $this->insert(array('titel' => $titel, 'text' => $text, 'erledigt' => true));
|
||||
$notiz_id = $result->retval;
|
||||
if (is_object($result) && $result->error == EXIT_SUCCESS)
|
||||
{
|
||||
$result = $this->NotizzuordnungModel->insert(array('notiz_id' => $notiz_id, 'prestudent_id' => $prestudent_id));
|
||||
}
|
||||
|
||||
// Transaction complete!
|
||||
$this->db->trans_complete();
|
||||
|
||||
// Check if everything went ok during the transaction
|
||||
if ($this->db->trans_status() === false || (is_object($result) && $result->error != EXIT_SUCCESS))
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
$result = error($result->msg, EXIT_ERROR);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->trans_commit();
|
||||
$result = success($notiz_id);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
}
|
||||
Reference in New Issue
Block a user