File indexing completed on 2024-06-23 05:51:19
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 <style> 0028 .highlight { 0029 background-color: #fefff3; 0030 } 0031 </style> 0032 <div class="messages"> 0033 <?php foreach (Zend_Controller_Action_HelperBroker::getStaticHelper('flashMessenger') 0034 ->getCurrentMessages() as $message) : ?> 0035 <p><?php echo $this->escape($message); ?></p> 0036 <?php endforeach; ?> 0037 0038 <div class="alert alert-danger alert-dismissible fade in" 0039 role="alert" 0040 style="width: 95%; display: none;"> 0041 <button aria-label="Close" class="close" type="button"><span aria-hidden="true">×</span></button> 0042 <div class="alert-body"> 0043 <span class='error'>Operation not possible.</span> 0044 </div> 0045 </div> 0046 0047 <div class="alert alert-success alert-dismissible fade in" 0048 role="alert" 0049 style="width: 95%; display: none;"> 0050 <button aria-label="Close" class="close" type="button"><span aria-hidden="true">×</span></button> 0051 <div class="alert-body"> 0052 <span class='success'>Operation successfully completed.</span> 0053 </div> 0054 </div> 0055 0056 </div> 0057 0058 <div class="filtering"> 0059 <form> 0060 <span style="margin-right: 0.9em;">hide deleted records: <input type="checkbox" name="filter_deleted" 0061 id="filter_deleted" value="1" checked="checked"/></span> 0062 <div style="display:inline-block; text-align: right;width: 95%;"> 0063 <button type="submit" id="LoadRecordsButton"><?= $this->translate('Load records'); ?></button> 0064 0065 </div> 0066 </form> 0067 </div> 0068 0069 <div id="TableContainer"></div> 0070 0071 0072 0073 <script src="//cdn.tinymce.com/4/tinymce.min.js"></script> 0074 <!-- <script src="//cdn.tinymce.com/4/jquery.tinymce.min.js"></script> --> 0075 <script type="text/javascript"> 0076 $(document).ready(function () { 0077 // Prevent jQuery UI dialog from blocking focusin 0078 $(document).on('focusin', function(e) { 0079 if ($(e.target).closest(".mce-window, .moxman-window").length) { 0080 e.stopImmediatePropagation(); 0081 } 0082 }); 0083 0084 $('#TableContainer').jtable({ 0085 jqueryuiTheme: true, 0086 paging: true, 0087 title: 'Table of Categories and the Tag-Groups', 0088 actions: { 0089 listAction: '/backend/categorytaggroup/list', 0090 /* 0091 deleteAction: '/backend/categories/delete', 0092 createAction: '/backend/categories/create', 0093 */ 0094 updateAction: function (postData) { 0095 return $.Deferred(function ($dfd) { 0096 $.ajax({ 0097 url: '/backend/categorytaggroup/update', 0098 type: 'POST', 0099 dataType: 'json', 0100 data: postData, 0101 success: function (data) { 0102 $dfd.resolve(data); 0103 $('#TableContainer').jtable('reload'); 0104 }, 0105 error: function () { 0106 $dfd.reject(); 0107 } 0108 }); 0109 }); 0110 }, 0111 0112 }, 0113 fields: { 0114 project_category_id: { 0115 title: 'Cat ID', 0116 key: true, 0117 create: false, 0118 edit: false, 0119 width: '5%' 0120 }, 0121 lft: { 0122 title: 'left', 0123 create: false, 0124 edit: false, 0125 list: false, 0126 width: '3%' 0127 }, 0128 rgt: { 0129 title: 'right', 0130 create: false, 0131 edit: false, 0132 list: false, 0133 width: '3%' 0134 }, 0135 title: { 0136 title: 'Category-Name', 0137 type: 'input', 0138 list: false, 0139 width: '30%', 0140 inputClass: 'validate[required]' 0141 }, 0142 title_show: { 0143 title: 'Category-Name', 0144 type: 'textarea', 0145 create: false, 0146 edit: false, 0147 width: '30%' 0148 }, 0149 0150 tag_group_name: { 0151 title: 'Tag-Groups', 0152 type: 'textarea', 0153 create: true, 0154 edit: true, 0155 width: '30%' 0156 }, 0157 tag_group_id: { 0158 title: 'Tag-Group-IDs', 0159 type: 'textarea', 0160 create: true, 0161 edit: true, 0162 list:false, 0163 width: '30%' 0164 } 0165 , 0166 0167 all_tag_groups: { 0168 title: 'Tag-Groups Helper Click to Select', 0169 type: 'multiselectddl', 0170 create: false, 0171 edit: true, 0172 list: false, 0173 options: function (data) { 0174 data.clearCache(); 0175 return '/backend/categorytaggroup/alltaggroups'; 0176 } 0177 } 0178 0179 0180 0181 }, 0182 0183 //Initialize validation logic when a form is created 0184 formCreated: function (event, data) { 0185 data.form.validationEngine(); 0186 0187 $('#jtable-create-form').attr('style', 'padding:5%'); 0188 $('#jtable-edit-form').find('#Edit-tag_group_name').prop("disabled", true); 0189 $('#jtable-edit-form').find('#Edit-title').prop("disabled", true); 0190 $('#jtable-edit-form').find('#Edit-all_tag_groups').change(function () { 0191 var str = ""; 0192 $( "select#Edit-all_tag_groups option:selected" ).each(function() { 0193 str = $( this ).val() ; 0194 }); 0195 0196 var t = $('#jtable-edit-form').find('#Edit-tag_group_id').val(); 0197 var tids =''; 0198 if($.trim(t)){ 0199 tids = t+','+str; 0200 }else{ 0201 tids = str; 0202 } 0203 0204 $('#jtable-edit-form').find('#Edit-tag_group_id').val(tids); 0205 }) 0206 ; 0207 }, 0208 //Validate form when it is being submitted 0209 formSubmitting: function (event, data) { 0210 return data.form.validationEngine('validate'); 0211 }, 0212 //Dispose validation logic when form is closed 0213 formClosed: function (event, data) { 0214 data.form.validationEngine('hide'); 0215 data.form.validationEngine('detach'); 0216 }, 0217 recordsLoaded: function () { 0218 $(".jtable").attr('style', 'position:inherit;'); // corrects the position for dragged element. 0219 $(".jtable tbody").sortable({ 0220 cursor: 'move', 0221 opacity: 0.9, 0222 axis: 'y', 0223 containment: 'parent', 0224 start: function (event, ui) { 0225 ui.item.startPos = ui.item.index() + 1; 0226 ui.item.lft = $('.jtable tbody tr:nth-child(' + (ui.item.startPos) + ') td:nth-child(2)').text(); 0227 ui.item.rgt = $('.jtable tbody tr:nth-child(' + (ui.item.startPos) + ') td:nth-child(3)').text(); 0228 }, 0229 stop: function (event, ui) { 0230 lft = $('.jtable tbody tr:nth-child(' + (ui.item.index() + 2) + ') td:nth-child(2)').text(); 0231 rgt = $('.jtable tbody tr:nth-child(' + (ui.item.index() + 2) + ') td:nth-child(3)').text(); 0232 newPosition = ui.item.lft; 0233 if (parseInt(lft) > 0) { 0234 newPosition = parseInt(lft); 0235 } 0236 0237 jQuery.ajax({ 0238 data: {'data': {'lft': ui.item.lft, 'rgt': ui.item.rgt}, 'newPosition': newPosition}, 0239 url: '/backend/categorytag/dragdrop/', 0240 type: 'post', 0241 error: function (jqXHR, textStatus, errorThrown) { 0242 $(".alert").alert().fadeIn('slow'); 0243 return false; 0244 }, 0245 success: function (data, textStatus, jqXHR) { 0246 $('#TableContainer').jtable('reload'); 0247 return false; 0248 } 0249 }); 0250 0251 } 0252 0253 }).disableSelection(); 0254 $('tr.jtable-data-row').hover(function () { 0255 $(this).addClass('highlight'); 0256 }, function () { 0257 $(this).removeClass('highlight'); 0258 }); 0259 0260 } 0261 }); 0262 0263 $('#TableContainer').jtable('load', { 0264 filter_deleted: $('#filter_deleted').is(':checked') ? $('#filter_deleted').val() : 0 0265 }); 0266 0267 //Re-load records when user click 'load records' button. 0268 $('#LoadRecordsButton').click(function (e) { 0269 e.preventDefault(); 0270 $('#TableContainer').jtable('load', { 0271 filter_deleted: $('#filter_deleted').is(':checked') ? $('#filter_deleted').val() : 0 0272 }); 0273 }); 0274 0275 //Re-load records when user click 'remove filter' button. 0276 $('#RemoveFilterButton').click(function (e) { 0277 e.preventDefault(); 0278 $('#TableContainer').jtable('load', { 0279 filter_deleted: 0, 0280 }); 0281 }); 0282 0283 }); 0284 </script>