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

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             <button type="reset" id="RemoveFilterButton"><?= $this->translate('Remove filter'); ?></button>
0065         </div>
0066     </form>
0067 </div>
0068 
0069 <div id="TableContainer"></div>
0070 
0071 <div id="dialog-cat-about" title="Create/Edit Category About Page">
0072     <form id="edit-cat-about" class="" action="/backend/categories/saveabout" method="post">
0073         <input type="hidden" value="" id="text-cat-id" name="c"/>
0074         <textarea class="" id="text-cat-about" name="ca"></textarea>
0075     </form>
0076 </div>
0077 
0078 <script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
0079 <!-- <script src="//cdn.tinymce.com/4/jquery.tinymce.min.js"></script> -->
0080 <script type="text/javascript">
0081     var curId = 0;
0082     var OcsProps = {
0083         set: function (value) {
0084             curId = value;
0085             $('#TableContainer').jtable('showCreateForm');
0086         }
0087     };
0088 
0089     $(document).ready(function () {
0090         // Prevent jQuery UI dialog from blocking focusin
0091         $(document).on('focusin', function(e) {
0092             if ($(e.target).closest(".mce-window, .moxman-window").length) {
0093                 e.stopImmediatePropagation();
0094             }
0095         });
0096 
0097         tinymce.init({
0098             selector: "#text-cat-about",
0099             width: '100%',
0100             height: 400,
0101             convert_urls: false,
0102             relative_urls : false,
0103             remove_script_host : false,
0104             autoresize_min_height: 400,
0105             autoresize_max_height: 600,
0106             menubar: false,
0107             plugins: [
0108                 'autoresize advlist autolink lists link image charmap print preview anchor textcolor',
0109                 'searchreplace visualblocks code fullscreen',
0110                 'insertdatetime media table contextmenu paste code help wordcount'
0111             ],
0112             toolbar: 'insert | undo redo |  formatselect | bold italic backcolor  | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | help',
0113             content_css: [
0114                 '//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
0115                 '//www.tinymce.com/css/codepen.min.css']
0116         });
0117 
0118         $("#dialog-cat-about").dialog({
0119             autoOpen: false,
0120             height: 480,
0121             width: 640,
0122             modal: true,
0123             open: function (event, ui) {
0124                 tinymce.get("text-cat-about").load();
0125             },
0126             buttons: {
0127                 Cancel: function () {
0128                     $(this).dialog("close");
0129                 },
0130                 Save: function () {
0131                     tinymce.get("text-cat-about").save();
0132                     $('#edit-cat-about').submit();
0133                     $(this).dialog("close");
0134                 }
0135             },
0136             close: function () {
0137             }
0138         });
0139 
0140         $('body').on("submit", '#edit-cat-about', function (event) {
0141             event.preventDefault();
0142             event.stopImmediatePropagation();
0143 
0144             jQuery.ajax({
0145                 data: $(this).serialize(),
0146                 url: this.action,
0147                 type: this.method,
0148                 error: function (jqXHR, textStatus, errorThrown) {
0149                     $(".alert-danger .alert-body").empty().html('<span class="error">Operation not possible.</span>');
0150                     $(".alert-danger").alert().fadeIn('slow');
0151                     return false;
0152                 },
0153                 success: function (data, textStatus, jqXHR) {
0154                     return false;
0155                 }
0156             });
0157 
0158             return false;
0159         });
0160         
0161         
0162         $('.alert .close').on('click', function (e) {
0163             $(this).parent().hide();
0164         });
0165 
0166         var title = $("#subcat-title"),
0167             status = $("#subcat-status"),
0168             allFields = $([]).add(title).add(status),
0169             tips = $(".validateTips");
0170 
0171         $('body').on("click", '.move-category', function (event) {
0172             event.preventDefault();
0173             event.stopImmediatePropagation();
0174 
0175             var direction = $(this).attr("data-direction");
0176             var elementRecord = $(this).data("record");
0177 
0178             jQuery.ajax({
0179                 data: {'direction': direction, 'record': elementRecord},
0180                 url: '/backend/categories/moveelement/',
0181                 type: 'post',
0182                 error: function (jqXHR, textStatus, errorThrown) {
0183                     $(".alert-danger .alert-body").empty().html('<span class="error">Operation not possible.</span>');
0184                     $(".alert-danger").alert().fadeIn('slow');
0185                     return false;
0186                 },
0187                 success: function (data, textStatus, jqXHR) {
0188                     $('#TableContainer').jtable('reload');
0189                     return false;
0190                 },
0191                 complete: function (data, textStatus, errorThrown) {
0192                     return false;
0193                 }
0194             });
0195 
0196             return false;
0197         });
0198 
0199 
0200         $('body').on("click", 'a.create-about', function (event) {
0201             event.preventDefault();
0202             event.stopImmediatePropagation();
0203             var elementRecord = $(this).data("record");
0204 
0205             jQuery.ajax({
0206                 data: {'c': elementRecord},
0207                 url: '/backend/categories/readabout/',
0208                 type: 'post',
0209                 error: function (jqXHR, textStatus, errorThrown) {
0210                     $(".alert-danger .alert-body").empty().html('<span class="error">Operation failed.</span>');
0211                     $(".alert-danger").alert().fadeIn('slow');
0212                     return false;
0213                 },
0214                 success: function (data, textStatus, jqXHR) {
0215 //                    $(".alert-success .alert-body").empty().html('<span class="success">Please find the category about page in : /httpdocs/partials/category-about/'+elementRecord+'.phtml .</span>');
0216 //                    $(".alert-success").alert().fadeIn('slow');
0217                     $('#text-cat-about').val(data.CatAbout);
0218                     $('#text-cat-id').val(data.c);
0219                     $('#dialog-cat-about').dialog('open');
0220                     return false;
0221                 },
0222                 complete: function (data, textStatus, errorThrown) {
0223                     return false;
0224                 }
0225             });
0226 
0227             return false;
0228         });
0229 
0230         $('#TableContainer').jtable({
0231             jqueryuiTheme: true,
0232             paging: true,
0233             title: 'Table of Categories',
0234             actions: {
0235                 listAction: '/backend/categories/list',
0236                 createAction: '/backend/categories/create',
0237                 //updateAction: '/backend/categories/update',
0238                 updateAction: function (postData) {
0239                     return $.Deferred(function ($dfd) {
0240                         $.ajax({
0241                             url: '/backend/categories/update',
0242                             type: 'POST',
0243                             dataType: 'json',
0244                             data: postData,
0245                             success: function (data) {
0246                                 $dfd.resolve(data);
0247                                 $('#TableContainer').jtable('reload');
0248                             },
0249                             error: function () {
0250                                 $dfd.reject();
0251                             }
0252                         });
0253                     });
0254                 },
0255                 deleteAction: '/backend/categories/delete'
0256             },
0257             fields: {
0258                 project_category_id: {
0259                     title: 'Cat ID',
0260                     key: true,
0261                     create: false,
0262                     edit: false,
0263                     width: '5%'
0264                 },
0265                 lft: {
0266                     title: 'left',
0267                     create: false,
0268                     edit: false,
0269                     list: true,
0270                     width: '3%'
0271                 },
0272                 rgt: {
0273                     title: 'right',
0274                     create: false,
0275                     edit: false,
0276                     list: true,
0277                     width: '3%'
0278                 },
0279                 parent: {
0280                     title: 'parent',
0281                     create: true,
0282                     edit: true,
0283                     list: false,
0284                     options: function (data) {
0285                         data.clearCache();
0286                         if (data.source == 'edit') {
0287                             return '/backend/categories/tree?c=' + data.record.project_category_id;
0288                         }
0289                         return '/backend/categories/tree?c=-1';
0290                     }
0291                 },
0292                 title: {
0293                     title: 'Title',
0294                     inputTitle: 'Title*',
0295                     type: 'input',
0296                     list: false,
0297                     width: '30%',
0298                     inputClass: 'validate[required]'
0299                 },
0300                 title_show: {
0301                     title: 'Text (indented according to hierarchy)',
0302                     type: 'textarea',
0303                     create: false,
0304                     edit: false,
0305                     width: '30%'
0306                 },
0307                 xdg_type: {
0308                     title: 'XDG-Type',
0309                     type: 'input',
0310                     create: true,
0311                     edit: true,
0312                     width: '10%'
0313                 },
0314                 name_legacy: {
0315                     title: 'Legacy Name',
0316                     type: 'input',
0317                     create: true,
0318                     edit: true,
0319                     width: '10%'
0320                 },
0321                 dl_pling_factor: {
0322                     title: 'DL Factor',
0323                     type: 'input',
0324                     defaultValue: '1',
0325                     create: true,
0326                     edit: true,
0327                     width: '8%'
0328                 },
0329                 mv_pling_factor: {
0330                     title: 'MV Factor',
0331                     type: 'input',
0332                     defaultValue: '1',
0333                     create: true,
0334                     edit: true,
0335                     width: '8%'
0336                 },
0337                 show_description: {
0338                     title: 'Description',
0339                     inputTitle: 'Show Description*',
0340                     options: {'1': 'Show', '0': 'Do not show'},
0341                     defaultValue: '0',
0342                     width: '8%'
0343                 },
0344                 source_required: {
0345                     title: 'Source',
0346                     inputTitle: 'Source Required*',
0347                     options: {'1': 'Required', '0': 'Not Required'},
0348                     defaultValue: '0',
0349                     width: '8%'
0350                 },
0351                 browse_list_type_name: {
0352                     title: 'Browse-List-Type',
0353                     type: 'textarea',
0354                     create: false,
0355                     edit: false,
0356                     width: '8%'
0357                 }, 
0358                 browse_list_type: {
0359                     title: 'Browse-List-Type',
0360                     type: 'multiselectddl',
0361                     create: true,
0362                     edit: true,
0363                     list: false,
0364                     options: function (data) {
0365                         data.clearCache();                        
0366                         return '/backend/browselisttype/allbrowselisttypes';
0367                     }
0368                 },
0369                 tag_rating_name: {
0370                     title: 'Tag-Rating',                   
0371                     create: false,
0372                     edit: false,
0373                     list:true,
0374                     width: '8%'
0375                 }, 
0376                 tag_rating: {
0377                     title: 'Tag-Rating',                    
0378                     create: true,
0379                     edit: true,
0380                     list: false,
0381                     options: function (data) {
0382                         data.clearCache();                        
0383                         return '/backend/categories/fetchtagratinggroups';
0384                     }
0385                 },
0386                 is_active: {
0387                     title: 'Status',
0388                     inputTitle: 'Status*',
0389                     options: {'1': 'Active', '0': 'Inactive'},
0390                     defaultValue: '1',
0391                     width: '5%'
0392                 },
0393                 is_deleted: {
0394                     title: 'Deleted',
0395                     options: {'0': 'Not Deleted', '1': 'Deleted'},
0396                     defaultValue: '0',
0397                     create: false,
0398                     width: '5%'
0399                 },
0400                 created_at: {
0401                     title: 'Created',
0402                     width: '10%',
0403                     type: 'date',
0404                     create: false,
0405                     edit: false,
0406                     list: false
0407                 },
0408                 changed_at: {
0409                     title: 'Changed',
0410                     width: '10%',
0411                     type: 'date',
0412                     create: false,
0413                     edit: false,
0414                     list: false
0415                 },
0416                 deleted_at: {
0417                     title: 'Deleted',
0418                     width: '10%',
0419                     type: 'date',
0420                     create: false,
0421                     edit: false,
0422                     list: false
0423                 },
0424                 addSubCat: {
0425                     title: '',
0426                     width: '1%',
0427                     sorting: false,
0428                     create: false,
0429                     edit: false,
0430                     list: true,
0431                     display: function (data) {
0432                         if (data.record) {
0433                             return '<a title="add sub category" href="javascript:return false;" role="button" onclick="OcsProps.set(' + data.record.project_category_id + ');"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></a>';
0434                         }
0435                     }
0436                 },
0437                 moveUp: {
0438                     title: '',
0439                     width: '1%',
0440                     sorting: false,
0441                     create: false,
0442                     edit: false,
0443                     list: true,
0444                     display: function (data) {
0445                         if (data.record) {
0446                             return '<a title="move category up" href="javascript:return false;" class="move-category" role="button" data-direction="up" data-record=\'{"project_category_id":' + data.record.project_category_id + ', "lft": ' + data.record.lft + ', "rgt": ' + data.record.rgt + ' }\'><span class="glyphicon glyphicon-arrow-up" aria-hidden="true"></span></a>';
0447                         }
0448                     }
0449                 },
0450                 moveDown: {
0451                     title: '',
0452                     width: '1%',
0453                     sorting: false,
0454                     create: false,
0455                     edit: false,
0456                     list: true,
0457                     display: function (data) {
0458                         if (data.record) {
0459                             return '<a title="move category down" href="javascript:return false;" class="move-category" role="button" data-direction="down" data-record=\'{"project_category_id":' + data.record.project_category_id + ', "lft": ' + data.record.lft + ', "rgt": ' + data.record.rgt + ' }\'><span class="glyphicon glyphicon-arrow-down" aria-hidden="true"></span></a>';
0460                         }
0461                     }
0462                 },
0463                 about: {
0464                     title: '',
0465                     width: '1%',
0466                     sorting: false,
0467                     create: false,
0468                     edit: false,
0469                     list: true,
0470                     display: function (data) {
0471                         if (data.record) {
0472                             return '<a title="create/edit about page" href="javascript:return false;" class="create-about" role="button" data-record=\'' + data.record.project_category_id + ' \'><span class="glyphicon glyphicon-open-file" aria-hidden="true"></span></a>';
0473                         }
0474                     }
0475                 }
0476 
0477             },
0478 
0479             //Initialize validation logic when a form is created
0480             formCreated: function (event, data) {
0481                 data.form.validationEngine();
0482                 if (typeof curId !== 'undefined') {
0483                     console.log(curId);
0484                     $("select[id=Edit-parent] option[value="+curId+"]").attr('selected','selected');
0485                 }
0486                 $('#jtable-create-form').attr('style', 'padding:5%');
0487             },
0488             //Validate form when it is being submitted
0489             formSubmitting: function (event, data) {
0490                 return data.form.validationEngine('validate');
0491             },
0492             //Dispose validation logic when form is closed
0493             formClosed: function (event, data) {
0494                 curId=null;
0495                 data.form.validationEngine('hide');
0496                 data.form.validationEngine('detach');
0497             },
0498             recordsLoaded: function () {
0499                 $(".jtable").attr('style', 'position:inherit;'); // corrects the position for dragged element.
0500                 $('tr.jtable-data-row').hover(function () {
0501                     $(this).addClass('highlight');
0502                 }, function () {
0503                     $(this).removeClass('highlight');
0504                 });
0505 
0506             }
0507         });
0508 
0509         $('#TableContainer').jtable('load', {
0510             filter_deleted: $('#filter_deleted').is(':checked') ? $('#filter_deleted').val() : 0
0511         });
0512 
0513         //Re-load records when user click 'load records' button.
0514         $('#LoadRecordsButton').click(function (e) {
0515             e.preventDefault();
0516             $('#TableContainer').jtable('load', {
0517                 filter_deleted: $('#filter_deleted').is(':checked') ? $('#filter_deleted').val() : 0
0518             });
0519         });
0520 
0521         //Re-load records when user click 'remove filter' button.
0522         $('#RemoveFilterButton').click(function (e) {
0523             e.preventDefault();
0524             $('#TableContainer').jtable('load', {
0525                 filter_deleted: 0,
0526             });
0527         });
0528 
0529     });
0530 </script>