mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-16 22:42:16 +00:00
Automatically set as accepted all the uploaded documents
- Added migration script 019_dokumentprestudent.php - Added method postSetAccepted to controller Dokumentprestudent - Added method setAccepted to model Dokumentprestudent_model
This commit is contained in:
@@ -24,8 +24,6 @@ class Dokumentprestudent extends APIv1_Controller
|
||||
parent::__construct();
|
||||
// Load model DokumentprestudentModel
|
||||
$this->load->model('crm/dokumentprestudent_model', 'DokumentprestudentModel');
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,7 +70,24 @@ class Dokumentprestudent extends APIv1_Controller
|
||||
}
|
||||
}
|
||||
|
||||
private function _validate($dokumentprestudent = NULL)
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postSetAccepted()
|
||||
{
|
||||
if (isset($this->post()['prestudent_id']) && isset($this->post()['studiengang_kz']))
|
||||
{
|
||||
$result = $this->DokumentprestudentModel->setAccepted($this->post()['prestudent_id'], $this->post()['studiengang_kz']);
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
private function _validate($dokumentprestudent = null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
require_once APPPATH . '/libraries/MigrationLib.php';
|
||||
|
||||
class Migration_Dokumentprestudent extends MigrationLib
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function up()
|
||||
{
|
||||
$this->startUP();
|
||||
|
||||
// Change mitarbeiter_uid could be null
|
||||
$this->execQuery('ALTER TABLE public.tbl_dokumentprestudent ALTER mitarbeiter_uid DROP NOT NULL');
|
||||
|
||||
$this->endUP();
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->startDown();
|
||||
|
||||
// Change mitarbeiter_uid could not be null
|
||||
$this->execQuery('ALTER TABLE public.tbl_dokumentprestudent ALTER mitarbeiter_uid SET NOT NULL');
|
||||
|
||||
$this->endDown();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
class Dokumentprestudent_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@@ -11,4 +11,31 @@ class Dokumentprestudent_model extends DB_Model
|
||||
$this->dbTable = 'public.tbl_dokumentprestudent';
|
||||
$this->pk = array('prestudent_id', 'dokument_kurzbz');
|
||||
}
|
||||
}
|
||||
|
||||
public function setAccepted($prestudent_id, $studiengang_kz)
|
||||
{
|
||||
if (($chkRights = $this->isEntitled("public.tbl_dokumentprestudent", "i", FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
||||
return $chkRights;
|
||||
|
||||
$query = 'INSERT INTO public.tbl_dokumentprestudent (dokument_kurzbz, prestudent_id, insertamum) (
|
||||
SELECT ds.dokument_kurzbz,
|
||||
p.prestudent_id,
|
||||
NOW() AS insertamum
|
||||
FROM (SELECT DISTINCT person_id, dokument_kurzbz FROM public.tbl_akte) a
|
||||
INNER JOIN public.tbl_prestudent p USING(person_id)
|
||||
INNER JOIN public.tbl_dokumentstudiengang ds USING(dokument_kurzbz, studiengang_kz)
|
||||
LEFT JOIN public.tbl_dokumentprestudent dp USING(dokument_kurzbz, prestudent_id)
|
||||
WHERE ds.onlinebewerbung IS TRUE
|
||||
AND (dp.dokument_kurzbz IS NULL AND dp.prestudent_id IS NULL)
|
||||
AND p.prestudent_id = ?
|
||||
AND ds.studiengang_kz = ?
|
||||
)';
|
||||
|
||||
$result = $this->db->query($query, array($prestudent_id, $studiengang_kz));
|
||||
|
||||
if ($result)
|
||||
return $this->_success($result);
|
||||
else
|
||||
return $this->_error($this->db->error(), FHC_DB_ERROR);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user