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 ?>
0024 
0025 <div class="messages">
0026     <?php foreach (Zend_Controller_Action_HelperBroker::getStaticHelper('flashMessenger')
0027                        ->getCurrentMessages() as $message) : ?>
0028         <p><?php echo $this->escape($message); ?></p>
0029     <?php endforeach; ?>
0030 </div>
0031 <div id="TableContainer"></div>
0032 
0033 <script type="text/javascript">
0034     $(document).ready(function () {
0035         $('#TableContainer').jtable({
0036             jqueryuiTheme: true,
0037             paging: true,
0038             sorting: true,
0039             defaultSorting: 'order asc',
0040             title: 'Table of Sections',
0041             actions: {
0042                 listAction: '/backend/section/list',
0043                 createAction: '/backend/section/create',
0044                 updateAction: function (postData) {
0045                     return $.Deferred(function ($dfd) {
0046                         $.ajax({
0047                             url: '/backend/section/update',
0048                             type: 'POST',
0049                             dataType: 'json',
0050                             data: postData,
0051                             success: function (data) {
0052                                 $dfd.resolve(data);
0053                                 $('#TableContainer').jtable('reload');
0054                             },
0055                             error: function () {
0056                                 $dfd.reject();
0057                             }
0058                         });
0059                     });
0060                 },
0061                 deleteAction: '/backend/section/delete'
0062             },
0063             fields: {
0064                 section_id: {
0065                     key: true,
0066                     create: false,
0067                     edit: false,
0068                     list: true,
0069                     title: 'Id',
0070                     width: '5%',
0071                 },
0072                 name: {
0073                     title: 'Section Name',
0074                     width: '10%',
0075                     list: true,
0076                     create: true,
0077                     inputTitle: 'Section Name <small style="font-weight:normal; font-size: 0.7em">(50 chars)</small>',
0078                     input: function (data) {
0079                         if (data.record) {
0080                             return '<input type="text" name="name" style="width:200px" value="' + data.record.name + '" pattern="[-a-zA-Z0-9_\.]+" /> <span class="small light">[-a-zA-Z0-9_.]</span>';
0081                         } else {
0082                             return '<input type="text" name="name" style="width:200px" pattern="[-a-zA-Z0-9_\.]+" /> <span class="small">[-a-zA-Z0-9_.]</span> ';
0083                         }
0084                     }
0085                 },
0086                 description: {
0087                     title: 'Description',
0088                     width: '20%',
0089                     list: true,
0090                     create: true
0091                 },
0092                 goal_amount: {
0093                     title: 'Goal',
0094                     width: '10%',
0095                     list: true,
0096                     create: true
0097                 },
0098                 order: {
0099                     title: 'Order',
0100                     width: '10%',
0101                     list: true,
0102                     create: true
0103                 },
0104                 hide: {
0105                     title: 'Hide',
0106                     width: '10%',
0107                     list: true,
0108                     create: true,
0109                     type:'radiobutton',
0110                     options:{  
0111                        1:'yes',
0112                        0:'no'
0113                     },
0114                     defaultValue: 0
0115                 },
0116                 sponsors: {
0117                     title: 'Edit Sponsors',
0118                     width: '10%',
0119                     sorting: false,
0120                     edit: false,
0121                     create: false,
0122                     display: function (jTableData) {
0123                         //Create an image that will be used to open child table
0124                         var $img = $('<a><span class="glyphicon glyphicon-tag" aria-hidden="true"></span></a>');
0125                         //Open child table when user clicks the image
0126                         $img.click(function () {
0127                             $('#TableContainer').jtable('openChildTable',
0128                                 $img.closest('tr'),
0129                                 {
0130                                     title: 'Table of Section-Sponsors',
0131                                     actions: {
0132                                         listAction: '/backend/section/childlist?SectionId=' + jTableData.record.section_id,
0133                                         createAction: '/backend/section/childcreate',
0134                                         updateAction: '/backend/section/childupdate',
0135                                         deleteAction: '/backend/section/childdelete'
0136                                     },
0137                                     fields: {
0138                                         section_sponsor_id: {
0139                                             key: true,
0140                                             create: false,
0141                                             edit: false,
0142                                             list: false
0143                                         },
0144                                         section_id: {
0145                                             type: 'hidden',
0146                                             defaultValue: jTableData.record.section_id
0147                                         },
0148                                         sponsor_id: {
0149                                             title: 'Sponsor',
0150                                             type: 'multiselectddl',
0151                                             create: true,
0152                                             edit: true,
0153                                             list: true,
0154                                             options: function (data) {
0155                                                 data.clearCache();                        
0156                                                 return '/backend/sponsor/allsponsors';
0157                                             }
0158                                         },
0159                                         sponsor_fullname: {
0160                                             title: 'Full Name',
0161                                             create: false,
0162                                             edit: false,
0163                                             list: true
0164                                         },
0165                                         sponsor_description: {
0166                                             title: 'Description',
0167                                             create: false,
0168                                             edit: false,
0169                                             list: true
0170                                         },
0171                                         sponsor_amount: {
0172                                             title: 'Amount',
0173                                             create: false,
0174                                             edit: false,
0175                                             list: true
0176                                         },
0177                                         percent_of_sponsoring: {
0178                                             title: '% of the Sponsoring Amount',
0179                                             width: '20%',
0180                                             create: true,
0181                                             edit: true,
0182                                             list: true
0183                                         }
0184                                         
0185                                     }
0186                                 }, function (data) { //opened handler
0187                                     data.childTable.jtable('load');
0188                                 });
0189                         });
0190                         //Return image to show on the person row
0191                         return $img;
0192                     }
0193 
0194                 }
0195             }
0196 
0197             
0198         });
0199         $('#TableContainer').jtable('load');
0200     });
0201 </script>