mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 16:44:28 +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:
@@ -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