diff --git a/application/controllers/system/Templates.php b/application/controllers/system/Vorlage.php similarity index 58% rename from application/controllers/system/Templates.php rename to application/controllers/system/Vorlage.php index 52731cbfc..0cf821488 100755 --- a/application/controllers/system/Templates.php +++ b/application/controllers/system/Vorlage.php @@ -1,9 +1,9 @@ load->library('WidgetLib'); } - + public function index() { - $this->load->view('system/templates.php'); + $this->load->view('system/vorlage/templates.php'); } - + public function table() { - $mimetype = $this->input->post('mimetype', TRUE); + $mimetype = $this->input->post('mimetype'); + if (is_null($mimetype)) $mimetype = 'text/html'; if ($mimetype == '') $mimetype = null; + $vorlage = $this->vorlagelib->getVorlageByMimetype($mimetype); + if ($vorlage->error) show_error($vorlage->retval); - //var_dump($vorlage); - $data = array - ( + $data = array ( 'mimetype' => $mimetype, 'vorlage' => $vorlage->retval ); - $v = $this->load->view('system/templatesList.php', $data); + + $v = $this->load->view('system/vorlage/templatesList.php', $data); } - + public function view($vorlage_kurzbz = null) { - if (empty($vorlage_kurzbz)) - exit; + if (empty($vorlage_kurzbz)) exit; + $vorlagentext = $this->vorlagelib->getVorlagetextByVorlage($vorlage_kurzbz); + if ($vorlagentext->error) show_error($vorlagentext->retval); - //var_dump($vorlagentext); - $data = array - ( + $data = array ( 'vorlage_kurzbz' => $vorlage_kurzbz, 'vorlagentext' => $vorlagentext->retval ); - $v = $this->load->view('system/templatetextList.php', $data); + + $v = $this->load->view('system/vorlage/templatetextList.php', $data); } - + public function edit($vorlage_kurzbz = null) { - if (empty($vorlage_kurzbz)) - exit; + if (empty($vorlage_kurzbz)) exit; + $vorlage = $this->vorlagelib->getVorlage($vorlage_kurzbz); - //var_dump($vorlage); + if ($vorlage->error) show_error($vorlage->retval); + if (count($vorlage->retval) != 1) show_error('Nachricht nicht vorhanden! ID: '.$vorlage_kurzbz); - - $data = array - ( + + $data = array ( 'vorlage' => $vorlage->retval[0] ); - //var_dump($data['message']); - $v = $this->load->view('system/templatesEdit', $data); + + $v = $this->load->view('system/vorlage/templatesEdit', $data); } public function write($vorlage_kurzbz = null) { - $data = array - ( + $data = array ( 'subject' => 'TestSubject', 'body' => 'TestDevelopmentBodyText' - ); - $v = $this->load->view('system/messageWrite', $data); + ); + + $v = $this->load->view('system/vorlage/messageWrite', $data); } public function save() { - $vorlage_kurzbz = $this->input->post('vorlage_kurzbz', TRUE); - $data['bezeichnung'] = $this->input->post('bezeichnung', TRUE); - $data['anmerkung'] = $this->input->post('anmerkung', TRUE); - $data['mimetype'] = $this->input->post('mimetype', TRUE); - $data['attribute'] = $this->input->post('attribute', TRUE); + $vorlage_kurzbz = $this->input->post('vorlage_kurzbz'); + + $data = array( + 'bezeichnung' => $this->input->post('bezeichnung'), + 'anmerkung' => $this->input->post('anmerkung'), + 'mimetype' => $this->input->post('mimetype'), + 'attribute' => $this->input->post('attribute') + ); + $vorlage = $this->vorlagelib->saveVorlage($vorlage_kurzbz, $data); + if ($vorlage->error) show_error($vorlage->retval); + $vorlage_kurzbz = $vorlage->retval; - - redirect('/system/Templates/edit/'.$vorlage_kurzbz); + + redirect('/system/vorlage/edit/'.$vorlage_kurzbz); } - + public function newText() { - $vorlage_kurzbz = $this->input->post('vorlage_kurzbz', true); + $vorlage_kurzbz = $this->input->post('vorlage_kurzbz'); $this->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel'); $this->OrganisationseinheitModel->addLimit(1); $this->OrganisationseinheitModel->addOrder('oe_kurzbz'); + $resultOE = $this->OrganisationseinheitModel->loadWhere(array('aktiv' => true, 'oe_parent_kurzbz' => null)); if ($resultOE->error) @@ -125,105 +134,127 @@ class Templates extends FHC_Controller ); $vorlagetext = $this->vorlagelib->insertVorlagetext($data); + if ($vorlagetext->error) show_error($vorlagetext->retval); $vorlagestudiengang_id = $vorlagetext->retval; - redirect('/system/Templates/editText/'.$vorlagestudiengang_id); + redirect('/system/vorlage/editText/'.$vorlagestudiengang_id); } else { show_error('No valid organisation unit found'); } } - + public function editText($vorlagestudiengang_id) { $vorlagetext = $this->vorlagelib->getVorlagetextById($vorlagestudiengang_id); + if ($vorlagetext->error) show_error($vorlagetext->retval); + $data = $vorlagetext->retval[0]; - + // Preview-Data $schema = $this->vorlagelib->getVorlage($data->vorlage_kurzbz); + $data->schema = $schema->retval[0]->attribute; - - $this->load->view('system/templatetextEdit', $data); + + $this->load->view('system/vorlage/templatetextEdit', $data); } - + public function linkDocuments($vorlagestudiengang_id) { - $this->load->model('system/vorlagedokument_model'); - $return = $this->vorlagedokument_model->loadDokumenteFromVorlagestudiengang($vorlagestudiengang_id); + $data = array(); + + $this->load->model('system/Vorlagedokument_model', 'VorlagedokumentModel'); + + $return = $this->VorlagedokumentModel->loadDokumenteFromVorlagestudiengang($vorlagestudiengang_id); + $data['documents'] = $return->retval; - - $this->load->model('system/dokument_model'); - $this->dokument_model->addOrder("bezeichnung"); - $return = $this->dokument_model->load(); + + $this->load->model('system/Dokument_model', 'DokumentModel'); + $this->DokumentModel->addOrder('bezeichnung'); + + $return = $this->DokumentModel->load(); + $data['allDocuments'] = $return->retval; - $data['vorlagestudiengang_id'] = $vorlagestudiengang_id; - - $this->load->view('system/templateLinkDocuments', $data); + + $this->load->view('system/vorlage/templateLinkDocuments', $data); } - + public function saveDocuments($vorlagestudiengang_id, $dokument_kurzbz, $sort) { - $this->load->model('system/vorlagedokument_model'); + $insert = array(); + $insert['vorlagestudiengang_id'] = $vorlagestudiengang_id; $insert['dokument_kurzbz'] = $dokument_kurzbz; - $insert['sort'] = $sort; - $this->vorlagedokument_model->insert($insert); + $insert['sort'] = $sort; + + $this->load->model('system/Vorlagedokument_model', 'VorlagedokumentModel'); + + $this->VorlagedokumentModel->insert($insert); } - + public function deleteDocumentLink($vorlagestudiengang_id) { - $this->load->model('system/vorlagedokument_model'); - $this->vorlagedokument_model->delete($vorlagestudiengang_id); + $this->load->model('system/Vorlagedokument_model', 'VorlagedokumentModel'); + + $this->VorlagedokumentModel->delete($vorlagestudiengang_id); } - + public function changeSort($vorlagestudiengang_id, $sort) { - $this->load->model('system/vorlagedokument_model'); - $this->vorlagedokument_model->update($vorlagestudiengang_id, array("sort"=>$sort)); + $this->load->model('system/Vorlagedokument_model', 'VorlagedokumentModel'); + + $this->VorlagedokumentModel->update($vorlagestudiengang_id, array('sort' => $sort)); } - + public function saveText() { - $vorlagestudiengang_id = $this->input->post('vorlagestudiengang_id', TRUE); - $data['studiengang_kz'] = $this->input->post('studiengang_kz', TRUE); - $data['version'] = $this->input->post('version', TRUE); - $data['oe_kurzbz'] = $this->input->post('oe_kurzbz', TRUE); + $data = array( + 'studiengang_kz' => $this->input->post('studiengang_kz'), + 'version' => $this->input->post('version'), + 'oe_kurzbz' => $this->input->post('oe_kurzbz'), + 'aktiv' => $this->input->post('aktiv'), + 'text' => $this->input->post('text'), + 'vorlagestudiengang_id' => $this->input->post('vorlagestudiengang_id') + ); + if ($this->input->post('sprache') == '') $data['sprache'] = null; else - $data['sprache'] = $this->input->post('sprache', TRUE); + $data['sprache'] = $this->input->post('sprache'); + if ($this->input->post('orgform_kurzbz') == '') $data['orgform_kurzbz'] = null; else - $data['orgform_kurzbz'] = $this->input->post('orgform_kurzbz', TRUE); - $data['text'] = $this->input->post('text', TRUE); - $data['aktiv'] = $this->input->post('aktiv', TRUE); - $vorlagetext = $this->vorlagelib->updateVorlagetext($vorlagestudiengang_id, $data); + $data['orgform_kurzbz'] = $this->input->post('orgform_kurzbz'); + + $vorlagetext = $this->vorlagelib->updateVorlagetext($data['vorlagestudiengang_id'], $data); + if ($vorlagetext->error) show_error($vorlagetext->retval); - $data['vorlagestudiengang_id'] = $vorlagestudiengang_id; - redirect('/system/Templates/editText/'.$vorlagestudiengang_id); - //$this->load->view('system/templatetextEdit', $data); + + redirect('/system/vorlage/editText/'.$data['vorlagestudiengang_id']); } - + public function preview($vorlagestudiengang_id) { - $formdata = $this->input->post('formdata', FALSE); - $daten = json_decode($formdata, TRUE); + $jsonDecodedForm = json_decode($this->input->post('formdata'), true); + $vorlagetext = $this->vorlagelib->getVorlagetextById($vorlagestudiengang_id); + if ($vorlagetext->error) show_error($vorlagetext->retval); - $data = array - ( - 'text' => $this->vorlagelib->parseVorlagetext($vorlagetext->retval[0]->text, $daten) + + $data = array( + 'text' => $this->vorlagelib->parseVorlagetext($vorlagetext->retval[0]->text, $jsonDecodedForm) ); - $this->load->view('system/templatetextPreview', $data); + + $this->load->view('system/vorlage/templatetextPreview', $data); } -} +} \ No newline at end of file diff --git a/application/libraries/WidgetLib.php b/application/libraries/WidgetLib.php index ed45712ef..52fbd0071 100644 --- a/application/libraries/WidgetLib.php +++ b/application/libraries/WidgetLib.php @@ -713,6 +713,11 @@ class DropdownWidget extends Widget { $widgetData[DropdownWidget::WIDGET_DATA_ELEMENTS_ARRAY_NAME] = $this->elementsArray->retval; + if (!isset($widgetData[DropdownWidget::SELECTED_ELEMENT])) + { + $widgetData[DropdownWidget::SELECTED_ELEMENT] = Widget::HTML_DEFAULT_VALUE; + } + $this->view('widgets/dropdown', $widgetData); } diff --git a/application/models/organisation/Organisationseinheit_model.php b/application/models/organisation/Organisationseinheit_model.php index aca1451da..ccab383cd 100755 --- a/application/models/organisation/Organisationseinheit_model.php +++ b/application/models/organisation/Organisationseinheit_model.php @@ -11,32 +11,38 @@ class Organisationseinheit_model extends DB_Model $this->pk = 'oe_kurzbz'; } - public function getRecursiveList($typ) + public function getRecursiveList($typ = null) { - $qry = "WITH RECURSIVE tree (oe_kurzbz, bezeichnung, path, organisationseinheittyp_kurzbz) AS - ( - SELECT - oe_kurzbz, - bezeichnung||' ('||organisationseinheittyp_kurzbz||')' AS bezeichnung, - oe_kurzbz||'|' AS path, - organisationseinheittyp_kurzbz - FROM tbl_organisationseinheit - WHERE oe_parent_kurzbz IS NULL AND aktiv - UNION ALL - SELECT - oe.oe_kurzbz, - oe.bezeichnung||' ('||oe.organisationseinheittyp_kurzbz||')' AS bezeichnung, - tree.path ||oe.oe_kurzbz||'|' AS path, - oe.organisationseinheittyp_kurzbz - FROM tree - JOIN tbl_organisationseinheit oe ON (tree.oe_kurzbz=oe.oe_parent_kurzbz) + $qry = "WITH RECURSIVE tree (oe_kurzbz, bezeichnung, path, organisationseinheittyp_kurzbz) AS ( + SELECT oe_kurzbz, + bezeichnung || ' (' || organisationseinheittyp_kurzbz || ')' AS bezeichnung, + oe_kurzbz || '|' AS path, + organisationseinheittyp_kurzbz + FROM tbl_organisationseinheit + WHERE oe_parent_kurzbz IS NULL + AND aktiv = true + UNION ALL + SELECT oe.oe_kurzbz, + oe.bezeichnung || ' (' || oe.organisationseinheittyp_kurzbz || ')' AS bezeichnung, + tree.path || oe.oe_kurzbz || '|' AS path, + oe.organisationseinheittyp_kurzbz + FROM tree JOIN tbl_organisationseinheit oe ON (tree.oe_kurzbz = oe.oe_parent_kurzbz) ) - SELECT oe_kurzbz AS value, substring(regexp_replace(path, '[A-z]+\|', '-','g')||bezeichnung,2) AS name, path FROM tree "; - if (!empty($typ)) - $qry .= 'WHERE organisationseinheittyp_kurzbz IN ('.$typ.') '; - $qry .= 'ORDER BY path;'; - - return $this->execQuery($qry); + SELECT oe_kurzbz AS id, + SUBSTRING(REGEXP_REPLACE(path, '[A-z]+\|', '-', 'g') || bezeichnung, 2) AS description + FROM tree"; + + $parametersArray = array(); + + if (is_array($typ) && count($typ) > 0) + { + $parametersArray[] = $typ; + $qry .= ' WHERE organisationseinheittyp_kurzbz IN ?'; + } + + $qry .= ' ORDER BY path'; + + return $this->execQuery($qry, $parametersArray); } /** diff --git a/application/views/system/messageReply.php b/application/views/system/messageReply.php index 6cb77f639..ea98f56fd 100644 --- a/application/views/system/messageReply.php +++ b/application/views/system/messageReply.php @@ -18,7 +18,13 @@
           - widgetlib->widget("Vorlage_widget", array("title" => "Vorlage")); ?> + widgetlib->widget( + 'Vorlage_widget', + null, + array('name' => 'vorlage', 'id' => 'vorlageDnD') + ); + ?>
@@ -34,19 +40,26 @@ $url = str_replace("/system/Messages/reply", "/system/Messages/getVorlage", $_SERVER["REQUEST_URI"]); ?> - function getVorlageText(vorlage_kurzbz) - { - $.ajax({ - dataType: "json", - url: "", - data: {"vorlage_kurzbz": vorlage_kurzbz}, - success: function(data, textStatus, jqXHR) { - tinyMCE.activeEditor.setContent(data.retval[0].text + "body; ?>"); - }, - error: function(jqXHR, textStatus, errorThrown) { - alert(textStatus + " - " + errorThrown); - } - }); - } + $(document).ready(function() { + if ($("#vorlageDnD")) + { + $("#vorlageDnD").change(function() { + if (this.value != '') + { + $.ajax({ + dataType: "json", + url: "", + data: {"vorlage_kurzbz": this.value}, + success: function(data, textStatus, jqXHR) { + tinyMCE.activeEditor.setContent(data.retval[0].text + "body; ?>"); + }, + error: function(jqXHR, textStatus, errorThrown) { + alert(textStatus + " - " + errorThrown); + } + }); + } + }); + } + }); diff --git a/application/views/system/messageWrite.php b/application/views/system/messageWrite.php index 501498811..193403e88 100644 --- a/application/views/system/messageWrite.php +++ b/application/views/system/messageWrite.php @@ -72,7 +72,13 @@
- widgetlib->widget("Vorlage_widget", array("title" => "Vorlage")); ?> + widgetlib->widget( + 'Vorlage_widget', + null, + array('name' => 'vorlage', 'id' => 'vorlageDnD') + ); + ?>   @@ -186,6 +192,31 @@ } }); } + + if ($("#vorlageDnD")) + { + $("#vorlageDnD").change(function() { + if (this.value != '') + { + + + $.ajax({ + dataType: "json", + url: "", + data: {"vorlage_kurzbz": this.value}, + success: function(data, textStatus, jqXHR) { + tinyMCE.get("bodyTextArea").setContent(data.retval[0].text); + $("#subject").val(data.retval[0].subject); + }, + error: function(jqXHR, textStatus, errorThrown) { + alert(textStatus + " - " + errorThrown); + } + }); + } + }); + } }); function tinymcePreviewSetContent() @@ -222,25 +253,5 @@ } }); } - - function getVorlageText(vorlage_kurzbz) - { - - - $.ajax({ - dataType: "json", - url: "", - data: {"vorlage_kurzbz": vorlage_kurzbz}, - success: function(data, textStatus, jqXHR) { - tinyMCE.get("bodyTextArea").setContent(data.retval[0].text); - $("#subject").val(data.retval[0].subject); - }, - error: function(jqXHR, textStatus, errorThrown) { - alert(textStatus + " - " + errorThrown); - } - }); - } - + \ No newline at end of file diff --git a/application/views/system/phraseinhaltEdit.php b/application/views/system/phraseinhaltEdit.php index 8110cd8e5..76771f122 100644 --- a/application/views/system/phraseinhaltEdit.php +++ b/application/views/system/phraseinhaltEdit.php @@ -11,11 +11,43 @@ - + - - + + + + + + + + + + - + diff --git a/application/views/system/templatetextEdit.php b/application/views/system/vorlage/templatetextEdit.php similarity index 60% rename from application/views/system/templatetextEdit.php rename to application/views/system/vorlage/templatetextEdit.php index a2e490fc8..40ebd1599 100644 --- a/application/views/system/templatetextEdit.php +++ b/application/views/system/vorlage/templatetextEdit.php @@ -1,5 +1,5 @@ load->view('templates/header', array('title' => 'TemplateEdit', 'tinymce' => true, 'jsonforms' => true)); + $this->load->view('templates/header', array('title' => 'VorlageEdit', 'tinymce' => true, 'jsonforms' => true)); ?>
@@ -7,9 +7,31 @@

Vorlagetext:

- OE:widgetlib->widget("organisationseinheit_widget", array('oe_kurzbz' => $oe_kurzbz, 'typ' => "'Erhalter','Studienzentrum','Studiengang','Lehrgang'")); ?> - Sprache:widgetlib->widget("sprache_widget", array('sprache' => $sprache)); ?> - OrgForm:widgetlib->widget("orgform_widget", array('orgform' => $orgform_kurzbz)); ?> + + OE: widgetlib->widget( + 'Organisationseinheit_widget', + array( + DropdownWidget::SELECTED_ELEMENT => $oe_kurzbz, + 'typ' => array('Erhalter', 'Studienzentrum', 'Studiengang', 'Lehrgang') + ), + array('name' => 'organisationseinheit', 'id' => 'organisationseinheitDnD') + ); + ?> + Sprache: widgetlib->widget( + 'Sprache_widget', + array(DropdownWidget::SELECTED_ELEMENT => $sprache), + array('name' => 'sprache', 'id' => 'spracheDnD') + ); + ?> + OrgForm: widgetlib->widget( + 'Orgform_widget', + array(DropdownWidget::SELECTED_ELEMENT => $orgform_kurzbz), + array('name' => 'orgform', 'id' => 'orgformDnD') + ); + ?> Version: Aktiv: @@ -21,7 +43,7 @@

Preview-Data

-
+ widgetlib->widget("jsonforms_widget", array('id' => 'dataform', 'schema' => $schema)); ?> @@ -38,6 +60,6 @@ } -
OEwidgetlib->widget("organisationseinheit_widget", array('oe_kurzbz' => $orgeinheit_kurzbz)); ?> + widgetlib->widget( + 'Organisationseinheit_widget', + array(DropdownWidget::SELECTED_ELEMENT => $orgeinheit_kurzbz), + array('name' => 'organisationseinheit', 'id' => 'organisationseinheitDnD') + ); + ?> + Preview
Orgformwidgetlib->widget("orgform_widget", array('orgform_kurzbz' => $orgform_kurzbz)); ?>
Sprachewidgetlib->widget("sprache_widget", array('sprache' => $sprache)); ?>
Orgform + widgetlib->widget( + 'Orgform_widget', + array(DropdownWidget::SELECTED_ELEMENT => $orgform_kurzbz), + array('name' => 'orgform', 'id' => 'orgformDnD') + ); + ?> +
Sprache + widgetlib->widget( + 'Sprache_widget', + array(DropdownWidget::SELECTED_ELEMENT => $sprache), + array('name' => 'sprache', 'id' => 'spracheDnD') + ); + ?> +
Text
diff --git a/application/views/system/templateLinkDocuments.php b/application/views/system/vorlage/templateLinkDocuments.php similarity index 100% rename from application/views/system/templateLinkDocuments.php rename to application/views/system/vorlage/templateLinkDocuments.php diff --git a/application/views/system/templates.php b/application/views/system/vorlage/templates.php similarity index 54% rename from application/views/system/templates.php rename to application/views/system/vorlage/templates.php index bb1d85a63..c2130c267 100644 --- a/application/views/system/templates.php +++ b/application/views/system/vorlage/templates.php @@ -2,17 +2,17 @@ - VileSci - Templates + VileSci - Vorlage - - + + <body bgcolor="#FFFFFF"> This application works only with a frames-enabled browser.<br /> - <a href="TemplatesList">Use without frames</a> + <a href="VorlageList">Use without frames</a> </body> diff --git a/application/views/system/templatesEdit.php b/application/views/system/vorlage/templatesEdit.php similarity index 91% rename from application/views/system/templatesEdit.php rename to application/views/system/vorlage/templatesEdit.php index 46d63a88c..8634b34ab 100644 --- a/application/views/system/templatesEdit.php +++ b/application/views/system/vorlage/templatesEdit.php @@ -1,5 +1,5 @@ load->view('templates/header', array('title' => 'TemplateEdit', 'jsoneditor' => true)); + $this->load->view('templates/header', array('title' => 'VorlageEdit', 'jsoneditor' => true)); ?>
diff --git a/application/views/system/templatesList.php b/application/views/system/vorlage/templatesList.php similarity index 82% rename from application/views/system/templatesList.php rename to application/views/system/vorlage/templatesList.php index 1543a804e..3d517e02d 100644 --- a/application/views/system/templatesList.php +++ b/application/views/system/vorlage/templatesList.php @@ -1,5 +1,5 @@ load->view('templates/header', array('title' => 'TemplatesList', 'tablesort' => true, 'tableid' => 't1', 'headers' => '4:{sorter:false}')); + $this->load->view('templates/header', array('title' => 'VorlageList', 'tablesort' => true, 'tableid' => 't1', 'headers' => '4:{sorter:false}')); ?>
@@ -23,7 +23,7 @@ MimeType
vorlage_kurzbz; ?>
vorlage_kurzbz; ?> bezeichnung; ?> anmerkung; ?> mimetype; ?>