diff --git a/application/controllers/system/UDF.php b/application/controllers/system/UDF.php index c3170d6aa..45bd50479 100644 --- a/application/controllers/system/UDF.php +++ b/application/controllers/system/UDF.php @@ -8,11 +8,15 @@ class UDF extends VileSci_Controller { parent::__construct(); + // Load session library + $this->load->library('session'); + // Loads the widget library $this->load->library('WidgetLib'); // $this->load->model('person/Person_model', 'PersonModel'); + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); } /** @@ -21,19 +25,94 @@ class UDF extends VileSci_Controller public function index() { $person_id = $this->input->get('person_id'); + if (isset($this->session->person_id)) + { + if (!isset($person_id)) + { + $person_id = $this->session->person_id; + } + unset($this->session->person_id); + } + + $prestudent_id = $this->input->get('prestudent_id'); + if (isset($this->session->prestudent_id)) + { + if (!isset($prestudent_id)) + { + $prestudent_id = $this->session->prestudent_id; + } + unset($this->session->prestudent_id); + } + + $result = null; + if (isset($this->session->result)) + { + $result = clone $this->session->result; + $this->session->set_userdata('result', null); + } $person = $this->PersonModel->load($person_id); + $prestudent = $this->PrestudentModel->load($prestudent_id); - $udfs = $this->PersonModel->getUDFs(); + $personUdfs = $this->PersonModel->getUDFs(); + $prestudentUdfs = $this->PrestudentModel->getUDFs(); - $udfs['person_id'] = 1; - $udfs['prestudent_id'] = 1; - $udfs['caller'] = 'system/UDF?person_id=1'; + $personUdfs['person_id'] = $person_id; + $prestudentUdfs['prestudent_id'] = $prestudent_id; $data = array( - 'udfs' => $udfs + 'personUdfs' => $personUdfs, + 'prestudentUdfs' => $prestudentUdfs, + 'result' => $result ); $this->load->view('system/udf', $data); } + + /** + * + */ + public function saveUDF() + { + $udfs = $this->input->post(); + $validation = $this->_validate($udfs); + + $userdata = array( + 'person_id' => $udfs['person_id'], + 'prestudent_id' => $udfs['prestudent_id'] + ); + + if (isSuccess($validation)) + { + // Load model UDF_model + $this->load->model('system/UDF_model', 'UDFModel'); + + $result = $this->UDFModel->saveUDFs($udfs); + + $userdata['result'] = $result; + } + else + { + $userdata['result'] = $validation; + } + + $this->session->set_userdata($userdata); + redirect('system/UDF'); + } + + /** + * + */ + private function _validate($udfs) + { + $validation = error('person_id or prestudent_id is missing'); + + if((isset($udfs['person_id']) && !(is_null($udfs['person_id'])) && ($udfs['person_id'] != '')) + || (isset($udfs['prestudent_id']) && !(is_null($udfs['prestudent_id'])) && ($udfs['prestudent_id'] != ''))) + { + $validation = success(true); + } + + return $validation; + } } \ No newline at end of file diff --git a/application/models/system/UDF_model.php b/application/models/system/UDF_model.php index 86b2f7dc8..537dacd10 100644 --- a/application/models/system/UDF_model.php +++ b/application/models/system/UDF_model.php @@ -49,27 +49,27 @@ class UDF_model extends DB_Model $resultPerson = success('person'); $resultPrestudent = success('prestudent'); + $person_id = $udfs['person_id']; + unset($udfs['person_id']); + + $prestudent_id = $udfs['prestudent_id']; + unset($udfs['prestudent_id']); + // - if (isset($udfs['person_id'])) + if (isset($person_id)) { // Load model Person_model $this->load->model('person/Person_model', 'PersonModel'); - $person_id = $udfs['person_id']; - unset($udfs['person_id']); - $resultPerson = $this->PersonModel->update($person_id, $udfs); } // - if (isset($udfs['prestudent_id'])) + if (isset($prestudent_id)) { // Load model Prestudent_model $this->load->model('crm/Prestudent_model', 'PrestudentModel'); - $prestudent_id = $udfs['prestudent_id']; - unset($udfs['prestudent_id']); - $resultPrestudent = $this->PrestudentModel->update($prestudent_id, $udfs); } diff --git a/application/views/system/udf.php b/application/views/system/udf.php index 89ea770bb..12405b558 100644 --- a/application/views/system/udf.php +++ b/application/views/system/udf.php @@ -1,28 +1,109 @@ load->view("templates/header", array("title" => "UDF")); ?> -
+ - diff --git a/content/student/studentoverlay.js.php b/content/student/studentoverlay.js.php index 6ce82f4ed..580da0970 100644 --- a/content/student/studentoverlay.js.php +++ b/content/student/studentoverlay.js.php @@ -1539,6 +1539,12 @@ function StudentAuswahl() { document.getElementById('student-messages').setAttribute('src','messages.xul.php?person_id='+person_id); } + + // ***** UDF ***** + if (document.getElementById('student-content-tabs').selectedItem == document.getElementById('student-tab-udf')) + { + document.getElementById('student-udf').setAttribute('src', 'udf.xul.php?person_id='+person_id+'&prestudent_id='+prestudent_id); + } // Notizen laden var studentnotiz = document.getElementById('student-box-notizen'); diff --git a/content/udf.js.php b/content/udf.js.php index 53ff71096..0378427e2 100644 --- a/content/udf.js.php +++ b/content/udf.js.php @@ -20,34 +20,6 @@ require_once('../config/vilesci.config.inc.php'); ?> // ********** FUNKTIONEN ********** // -var UDFPersonID = null; -var UDFTreeDatasource = ''; // Datasource des Adressen Trees -var UDFSelectID = ''; -var UDFIFrameIsInitialized = false; - -var UDFTreeSinkObserver = -{ - onBeginLoad : function(pSink) {}, - onInterrupt : function(pSink) {}, - onResume : function(pSink) {}, - onError : function(pSink, pStatus, pError) {}, - onEndLoad : function(pSink) - { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - } -}; - -var UDFTreeListener = -{ - willRebuild : function(builder) { }, - didRebuild : function(builder) - { - //timeout nur bei Mozilla notwendig da sonst die rows - //noch keine values haben. Ab Seamonkey funktionierts auch - //ohne dem setTimeout - //window.setTimeout(KontaktAdressenTreeSelectID,10); - } -}; // **** // * Laedt die Trees @@ -58,10 +30,8 @@ function loadUDF(person_id, prestudent_id) var udfIFrame = document.getElementById('udfIFrame'); - alert(udfIFrame.src); - - if (udfIFrame != null) + if (udfIFrame != null && udfIFrame.getAttribute('src') == 'about:blank') { - udfIFrame.src = '/core/index.ci.php/system/UDF?person_id=' + person_id + '&prestudent_id' + prestudent_id; + udfIFrame.setAttribute('src', '/core/index.ci.php/system/UDF?person_id='+person_id+'&prestudent_id='+prestudent_id); } } \ No newline at end of file diff --git a/content/udf.xul.php b/content/udf.xul.php index a6cc806b9..fec6eb1d9 100644 --- a/content/udf.xul.php +++ b/content/udf.xul.php @@ -65,7 +65,7 @@ echo ']>