File indexing completed on 2025-05-04 05:29:03

0001 <?php 
0002 /**
0003  *  ocs-webserver
0004  *
0005  *  Copyright 2016 by pling GmbH.
0006  *
0007  *    This file is part of ocs-webserver.
0008  *
0009  *    This program is free software: you can redistribute it and/or modify
0010  *    it under the terms of the GNU Affero General Public License as
0011  *    published by the Free Software Foundation, either version 3 of the
0012  *    License, or (at your option) any later version.
0013  *
0014  *    This program is distributed in the hope that it will be useful,
0015  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
0016  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017  *    GNU Affero General Public License for more details.
0018  *
0019  *    You should have received a copy of the GNU Affero General Public License
0020  *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
0021  **/
0022 ?>
0023 <link rel="stylesheet" href="//cdn.jsdelivr.net/jquery.validationengine/2.6.4/css/template.css">
0024 <link rel="stylesheet" href="//cdn.jsdelivr.net/jquery.validationengine/2.6.4/css/validationEngine.jquery.css">
0025 <script src="//cdn.jsdelivr.net/jquery.validationengine/2.6.4/js/jquery.validationEngine.min.js"></script>
0026 <script src="//cdn.jsdelivr.net/jquery.validationengine/2.6.4/languages/jquery.validationEngine-en.js"></script>
0027 
0028 <style>
0029     .highlight {
0030         background-color: #fefff3;
0031     }
0032 </style>
0033 <div class="messages">
0034     <?php foreach (Zend_Controller_Action_HelperBroker::getStaticHelper('flashMessenger')
0035                        ->getCurrentMessages() as $message) : ?>
0036         <p><?php echo $this->escape($message); ?></p>
0037     <?php endforeach; ?>
0038 
0039     <div class="alert alert-danger alert-dismissible fade in"
0040          role="alert"
0041          style="width: 95%; display: none;">
0042         <button aria-label="Close" class="close" type="button"><span aria-hidden="true">×</span></button>
0043         <div class="alert-body">
0044             <span class='error'>Operation not possible.</span>
0045         </div>
0046     </div>
0047 
0048     <div class="alert alert-success alert-dismissible fade in"
0049          role="alert"
0050          style="width: 95%; display: none;">
0051         <button aria-label="Close" class="close" type="button"><span aria-hidden="true">×</span></button>
0052         <div class="alert-body">
0053             <span class='success'>Operation successfully completed.</span>
0054         </div>
0055     </div>
0056 
0057 </div>
0058 
0059 <div class="filtering">
0060     <form>
0061         <span style="margin-right: 0.9em;">hide deleted records: <input type="checkbox" name="filter_deleted"
0062                                                                         id="filter_deleted" value="1" checked="checked"/></span>
0063         <div style="display:inline-block; text-align: right;width: 95%;">
0064             <button type="submit" id="LoadRecordsButton"><?= $this->translate('Load records'); ?></button>
0065           
0066         </div>
0067     </form>
0068 </div>
0069 
0070 <div id="TableContainer"></div>
0071 
0072 
0073 
0074 <script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
0075 <!-- <script src="//cdn.tinymce.com/4/jquery.tinymce.min.js"></script> -->
0076 <script type="text/javascript">
0077     $(document).ready(function () {
0078         // Prevent jQuery UI dialog from blocking focusin
0079         $(document).on('focusin', function(e) {
0080             if ($(e.target).closest(".mce-window, .moxman-window").length) {
0081                 e.stopImmediatePropagation();
0082             }
0083         });
0084 
0085         $('#TableContainer').jtable({
0086             jqueryuiTheme: true,
0087             paging: true,
0088             title: 'Table of Categories and the Section',
0089             actions: {
0090                  listAction: '/backend/sectioncategories/list',
0091                 /*               
0092                 deleteAction: '/backend/categories/delete',
0093                 createAction: '/backend/categories/create',                                
0094                 */                                
0095                 updateAction: function (postData) {
0096                     return $.Deferred(function ($dfd) {
0097                         $.ajax({
0098                             url: '/backend/sectioncategories/update',
0099                             type: 'POST',
0100                             dataType: 'json',
0101                             data: postData,
0102                             success: function (data) {
0103                                 $dfd.resolve(data);
0104                                 $('#TableContainer').jtable('reload');
0105                             },
0106                             error: function () {
0107                                 $dfd.reject();
0108                             }
0109                         });
0110                     });
0111                 },
0112                
0113             },
0114             fields: {
0115                 project_category_id: {
0116                     title: 'Cat ID',
0117                     key: true,
0118                     create: false,
0119                     edit: false,
0120                     width: '5%'
0121                 },
0122                 lft: {
0123                     title: 'left',
0124                     create: false,
0125                     edit: false,
0126                     list: false,
0127                     width: '3%'
0128                 },
0129                 rgt: {
0130                     title: 'right',
0131                     create: false,
0132                     edit: false,
0133                     list: false,
0134                     width: '3%'
0135                 },
0136                 title: {
0137                     title: 'Category-Name',
0138                     type: 'input',
0139                     list: false,
0140                     width: '30%',
0141                     inputClass: 'validate[required]'
0142                 },
0143                 title_show: {
0144                     title: 'Category-Name',
0145                     type: 'input',
0146                     create: false,
0147                     edit: false,
0148                     width: '30%'
0149                 },
0150                 section_name: {
0151                     title: 'Section-Name',
0152                     type: 'textarea',
0153                     create: false,
0154                     edit: false,
0155                     width: '30%'
0156                 }, 
0157                 section_id: {
0158                     title: 'Section',
0159                     type: 'multiselectddl',
0160                     create: true,
0161                     edit: true,
0162                     list: false,
0163                     options: function (data) {
0164                         data.clearCache();                        
0165                         return '/backend/sectioncategories/allsections';
0166                     }
0167                 }
0168                 
0169                 
0170                                                         
0171             },
0172 
0173             //Initialize validation logic when a form is created
0174             formCreated: function (event, data) {
0175                 data.form.validationEngine();
0176                 
0177                 $('#jtable-create-form').attr('style', 'padding:5%');
0178                 $('#jtable-edit-form').find('#Edit-title').prop("disabled", true);
0179                 
0180             },
0181             //Validate form when it is being submitted
0182             formSubmitting: function (event, data) {
0183                 return data.form.validationEngine('validate');
0184             },
0185             //Dispose validation logic when form is closed
0186             formClosed: function (event, data) {
0187                 data.form.validationEngine('hide');
0188                 data.form.validationEngine('detach');
0189             },
0190             recordsLoaded: function () {
0191                 $(".jtable").attr('style', 'position:inherit;'); // corrects the position for dragged element.
0192                 $(".jtable tbody").sortable({
0193                     cursor: 'move',
0194                     opacity: 0.9,
0195                     axis: 'y',
0196                     containment: 'parent'
0197                 }).disableSelection();
0198                 $('tr.jtable-data-row').hover(function () {
0199                     $(this).addClass('highlight');
0200                 }, function () {
0201                     $(this).removeClass('highlight');
0202                 });
0203 
0204             }
0205         });
0206 
0207         $('#TableContainer').jtable('load', {
0208             filter_deleted: $('#filter_deleted').is(':checked') ? $('#filter_deleted').val() : 0
0209         });
0210 
0211         //Re-load records when user click 'load records' button.
0212         $('#LoadRecordsButton').click(function (e) {
0213             e.preventDefault();
0214             $('#TableContainer').jtable('load', {
0215                 filter_deleted: $('#filter_deleted').is(':checked') ? $('#filter_deleted').val() : 0
0216             });
0217         });
0218 
0219         //Re-load records when user click 'remove filter' button.
0220         $('#RemoveFilterButton').click(function (e) {
0221             e.preventDefault();
0222             $('#TableContainer').jtable('load', {
0223                 filter_deleted: 0,
0224             });
0225         });
0226 
0227     });
0228 </script>