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

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 <style>
0024     .jtable-toolbar-item-add-record {
0025         display: none !important;
0026     }
0027 </style>
0028 <div class="messages">
0029     <?php foreach (Zend_Controller_Action_HelperBroker::getStaticHelper('flashMessenger')
0030                        ->getCurrentMessages() as $message) : ?>
0031         <p><?php echo $this->escape($message); ?></p>
0032     <?php endforeach; ?>
0033 </div>
0034 <div id="TableContainer"></div>
0035 <div id="dialog-form" title="Object Details"></div>
0036 <script type="text/javascript">
0037     $(document).ready(function () {
0038         $('#TableContainer').jtable({
0039             jqueryuiTheme: true,
0040             paging: true,
0041             title: 'Table of Comment Reports',
0042             sorting: true, //Enable sorting
0043             defaultSorting: 'last_reported_at DESC', //Set default sorting
0044             actions: {
0045                 listAction: '/backend/reportcomments/list',
0046                 //createAction: '/backend/reportcomments/create',
0047                 //updateAction: '/backend/reportcomments/update',
0048                 //deleteAction: '/backend/reportcomments/delete'
0049             },
0050             fields: {
0051                 report_id: {
0052                     key: true,
0053                     create: false,
0054                     edit: false,
0055                     list: false
0056                 },
0057                 project_id: {
0058                     title: 'Project ID',
0059                     width: '5%',
0060                     edit: false
0061                 },
0062                 comment_id: {
0063                     title: 'Comment ID',
0064                     width: '5%',
0065                     edit: false
0066                 },
0067                 comment_created_at: {
0068                     title: 'Comment Created At',
0069                     width: '5%',
0070                     type: 'date',
0071                     create: false,
0072                     edit: false
0073                 },
0074                 comment_text: {
0075                     title: 'Comment Text',
0076                     width: '20%',
0077                     edit: false
0078                 },
0079                 comment_deleted_at: {
0080                     title: 'Comment Deleted At',
0081                     width: '5%',
0082                     type: 'date',
0083                     create: false,
0084                     edit: false
0085                 },
0086                 counter: {
0087                     title: 'Total Reports',
0088                     width: '5%',
0089                     create: false,
0090                     edit: false
0091                 },
0092                 last_reported_at: {
0093                     title: 'Last Reported At',
0094                     width: '5%',
0095                     type: 'date',
0096                     create: false,
0097                     edit: false
0098                 },
0099                 hide: {
0100                     title: '',
0101                     width: '1%',
0102                     sorting: false,
0103                     create: false,
0104                     edit: false,
0105                     list: true,
0106                     display: function (data) {
0107                         if (data.record.comment_active) {
0108                             if (data.record.comment_active == 0) {
0109                                 btn_title = 'Show Comment';
0110                             } else {
0111                                 btn_title = 'Hide Comment';
0112                             }
0113                             return '<a role="button" title="' + btn_title + ' this comment" class="btn btn-warning btn-xs toggle-status pull-right" style="color:white;"  data-record="' + data.record.comment_id + '"><span>' + btn_title + '</span></a>'
0114                                 ;
0115                         }
0116                     }
0117                 }
0118 
0119             }
0120         });
0121 
0122         $('#TableContainer').jtable('load');
0123 
0124         $("#dialog-form").dialog({
0125             autoOpen: false,
0126             //height: 350,
0127             width: 600,
0128             modal: true,
0129             buttons: {
0130                 Close: function () {
0131                     $(this).dialog("close");
0132                 }
0133             }
0134         });
0135         
0136         $('body').on("click", 'a.toggle-status', function (event) {
0137             event.preventDefault();
0138             event.stopImmediatePropagation();
0139 
0140             var elementRecord = $(this).data("record");
0141 
0142             jQuery.ajax({
0143                 data: {'c': elementRecord},
0144                 url: '/backend/reportcomments/status/',
0145                 type: 'post',
0146                 error: function () {
0147                     alert("<span class='error'>Service is temporarily unavailable. Our engineers are working quickly to resolve this issue. <br/>Find out why you may have encountered this error.</span>");
0148                     return false;
0149                 },
0150                 success: function (results) {
0151                     $('#TableContainer').jtable('reload');
0152                     return false;
0153                 }
0154             });
0155 
0156             return false;
0157         });
0158 
0159         
0160 
0161     });
0162 </script>