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

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 $this->headLink()->appendStylesheet('/theme/flatui/css/stylesheets/general.css');
0024 $this->headLink()->appendStylesheet('/theme/flatui/css/select2.min.css');
0025 $this->headLink()->appendStylesheet('/theme/flatui/css/select2.custmized.css');
0026 $this->inlineScript()->appendFile('/theme/flatui/js/lib/select2.min.js');
0027 
0028 $this->tab = 'collections';
0029 ?>
0030 <link href="/theme/flatui/css/chosen.css" media="screen" rel="stylesheet" type="text/css" />
0031 
0032 <link rel="stylesheet" href="/tools/bootstrap-multiselect/css/bootstrap-multiselect.css" type="text/css">
0033 <script type="text/javascript" src="/tools/bootstrap-multiselect/js/bootstrap-multiselect.js"></script>
0034 
0035 <style type="text/css">
0036     div.datafiledroparea{
0037         overflow-y: scroll !important;
0038         overflow-x: scroll !important;
0039     }
0040     
0041     div.datafiledroparea button.multiselect {
0042             padding-top: 3px;
0043             padding-bottom: 3px;
0044         }
0045 </style>
0046 <main class="user-admin-page">
0047 
0048     <?php echo $this->render('user/partials/userHeader_top.phtml'); ?>
0049 
0050     <section class="body-wrap">
0051 
0052         <section class="wrapper product-page">
0053 
0054             <!-- PAGE BODY -->
0055 
0056             <section class="my-products-page">
0057 
0058                 <!-- NAVIGATION -->
0059 
0060                 <?php echo $this->render('user/partials/userHeader.phtml'); ?>
0061                  <?php echo $this->render('product/partials/header.phtml'); ?>
0062 
0063                 <!-- /NAVIGATION -->
0064 
0065                 <div class="my-products-heading">
0066                     <h1 class="page-title left"><?= $this->translate('Collections') ?></h1>
0067 
0068                     <div class="right light lightgrey num-products">
0069                         <span class="label label-default">
0070                             <?= $this->products->getTotalItemCount() ?> <?= $this->translate('collections') ?>
0071                         </span>
0072                     </div>
0073                 </div>
0074 
0075                 <div class="my-products-list">
0076                     <div class="row">
0077                         <?php echo $this->partialLoop('user/partials/loopMyCollections.phtml', $this->products, null); ?>
0078                     </div>
0079                 </div>
0080 
0081                 <section style="text-align: center;">
0082                     <?php echo $this->paginationControl($this->products, 'Sliding', '/partials/paginationControlBootstrap.phtml',
0083                         array('dom_target' => 'section.my-collections-page')); ?>
0084                 </section>
0085 
0086             </section>
0087 
0088             <!-- /PAGE BODY -->
0089 
0090         </section>
0091 
0092     </section>
0093 
0094 </main>
0095 
0096 <script type="text/javascript">
0097     var myCollections = (function () {
0098         return {
0099             setup: function () {
0100                 this.initBtnPublish();
0101                 this.initUpdatePopup();
0102             },
0103             
0104             initBtnPublish: function () {
0105                 $('body').off('click', 'a[data-target]').on('click', 'a[data-target]', function (event) {
0106                     event.preventDefault();
0107                     var url = this.href;
0108                     var target = $(this).attr("data-target");
0109 
0110                     $(target).empty().html('<img src="/images/system/ajax-loader.gif" style="display: inline;height: 20px; margin: 1px;"/>').load(url + ' ' + target + ' > *', function (response, status, xhr) {
0111                         if (status == "error") {
0112                             $(target).find('#error').html('Sorry, but there was an error. Please try again later.');
0113                             return;
0114                         } else {
0115                             return response;
0116                         }
0117                     });
0118                     return false;
0119                 });
0120             },
0121             
0122             initUpdatePopup: function () {
0123                 
0124                 
0125 
0126                 var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f<e.length){n=e.charCodeAt(f++);r=e.charCodeAt(f++);i=e.charCodeAt(f++);s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(f<e.length){s=this._keyStr.indexOf(e.charAt(f++));o=this._keyStr.indexOf(e.charAt(f++));u=this._keyStr.indexOf(e.charAt(f++));a=this._keyStr.indexOf(e.charAt(f++));n=s<<2|o>>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/\r\n/g,"\n");var t="";for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r)}else if(r>127&&r<2048){t+=String.fromCharCode(r>>6|192);t+=String.fromCharCode(r&63|128)}else{t+=String.fromCharCode(r>>12|224);t+=String.fromCharCode(r>>6&63|128);t+=String.fromCharCode(r&63|128)}}return t},_utf8_decode:function(e){var t="";var n=0;var r=c1=c2=0;while(n<e.length){r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r);n++}else if(r>191&&r<224){c2=e.charCodeAt(n+1);t+=String.fromCharCode((r&31)<<6|c2&63);n+=2}else{c2=e.charCodeAt(n+1);c3=e.charCodeAt(n+2);t+=String.fromCharCode((r&15)<<12|(c2&63)<<6|c3&63);n+=3}}return t}}
0127 
0128                 $('button[rel="tooltip"]').tooltip();
0129 
0130                 var $modalUpdates = $('#modal-updates');
0131 
0132                 $('a[href="#modal-updates"]').off('click').on('click', function (event) {
0133                     event.preventDefault();
0134                     
0135                     $modalUpdates.attr('data-product-id', $(this).attr('data-product-id'));
0136                     $modalUpdates.attr('data-product-title', $(this).attr('data-product-title'));
0137 
0138                     $modalUpdates.find('h3[data-ppload-label]').html('Changelog for ' + $modalUpdates.attr('data-product-tile'));
0139 
0140                     $modalUpdates.find('#update-list').html('');
0141 
0142                     if ($modalUpdates.attr('data-product-id')) {
0143                         getUpdates();
0144                     }
0145 
0146                 });
0147 
0148 
0149                 function getUpdates(page) {
0150                     $modalUpdates.find('#update-list').html('');
0151 
0152                     var productId = $modalUpdates.attr('data-product-id');
0153                     $.ajax({
0154                         url: '/c/'+productId+'/getupdatesajax/',
0155                         type: 'GET',
0156                         data: {
0157                             format: 'json',
0158                             ignore_status_code: 1
0159                         },
0160                         dataType: 'json',
0161                         success: function (data, textStatus, jqXHR) {
0162                             if (data.status != 'success') {
0163                                 return;
0164                             }
0165                             $modalUpdates.find('#update-list').append('<br/><br/><br/>');
0166 
0167                             $.each(data.updates, function () {
0168                                 var id = '';
0169                                 if (this.project_update_id) {
0170                                     id = this.project_update_id;
0171                                 }
0172                                 var title = '';
0173                                 if (this.title) {
0174                                     title = this.title;
0175                                 }
0176                                 var text = '';
0177                                 if (this.text) {
0178                                     text = this.text;
0179                                 }
0180                                 var date = '';
0181                                 if (this.created_at) {
0182                                     date = this.created_at;
0183                                 }
0184 
0185 
0186                                 var divEl = $('<div />');
0187                                 divEl.attr('data-uptdate-id', id);
0188                                 divEl.append(
0189                                          '<a name="anker_'+id+'"></a>'
0190                                         + '<h4>'+title+'</h4>'
0191                                         + '<div class="small light lightgrey product-update-date">'+date+ '</div>'
0192                                         + text + '<br/><br/>'
0193                                     );
0194 
0195                                 var btnEdit = $('<button type="submit" class="btn btn-native btn-sm">Edit</button>');
0196                                 btnEdit.attr('data-change-update-btn',id);
0197                                 btnEdit.attr('data-change-title',title);
0198                                 btnEdit.attr('data-change-text',text);
0199 
0200 
0201                                 var btnDelete = $('<button type="submit" class="btn btn-native btn-sm">Delete</button>');
0202                                 btnDelete.attr('data-delete-update-btn',id);
0203 
0204                                 divEl.append(btnEdit);
0205                                 divEl.append('&nbsp;&nbsp;');
0206                                 divEl.append(btnDelete);
0207                                 divEl.append('<br/><br/><br/><br/>');
0208 
0209                                 $modalUpdates.find('#update-list').append(divEl);
0210 
0211                             });
0212                         },
0213                         error: function (jqXHR, textStatus, errorThrown) {
0214                             return;
0215                         }
0216                     });
0217 
0218                 }
0219 
0220                 $modalUpdates.off('click', 'button[data-add-update-btn]').on('click', 'button[data-add-update-btn]', function (event) {
0221                     //var product_version = $modalPpload.find('#product-version').val();
0222                     var update_id = $modalUpdates.find('#update-id').val();
0223                     var title = $modalUpdates.find('#update-title').val();
0224                     var text = $modalUpdates.find('#update-text').val();
0225                     var productId = $modalUpdates.attr('data-product-id');
0226                     event.preventDefault();
0227 
0228                     $.ajax({
0229                         url: '/c/'+productId+'/saveupdateajax',
0230                         type: 'POST',
0231                         data: {title: title, text: text, update_id: update_id/*, product_version: product_version*/},
0232                         dataType: 'json',
0233                         success: function (data, textStatus, jqXHR) {
0234                             if (data.status != 'success') {
0235                                 return;
0236                             }
0237                             //$modalPpload.find('#product-version').val('');
0238                             $modalUpdates.find('#update-title').val('');
0239                             $modalUpdates.find('#update-text').val('');
0240                             $modalUpdates.find('#update-id').val('');
0241 
0242                             //if(update_id) {
0243                                 getUpdates();
0244                             //} else {
0245                             //  $modalPpload.modal('hide');
0246                             //  location.reload();
0247                             //}
0248                         },
0249                         error: function (jqXHR, textStatus, errorThrown) {
0250                             return;
0251                         }
0252                     });
0253 
0254                 });
0255 
0256 
0257                 $modalUpdates.off('click', 'button[data-delete-update-btn]').on('click', 'button[data-delete-update-btn]', function (event) {
0258                     var updateId = $(this).attr('data-delete-update-btn');
0259                     var productId = $modalUpdates.attr('data-product-id');
0260                         event.preventDefault();
0261 
0262                     $.ajax({
0263                         url: '/c/'+productId+'/deleteupdateajax',
0264                         type: 'POST',
0265                         data: {update_id: updateId},
0266                         dataType: 'json',
0267                         success: function (data, textStatus, jqXHR) {
0268                             if (data.status != 'success') {
0269                                 alert('Update could not be deleted!');
0270                                 return;
0271                             }
0272                             getUpdates();
0273                         },
0274                         error: function (jqXHR, textStatus, errorThrown) {
0275                             return;
0276                         }
0277                     });
0278 
0279                 });
0280 
0281                 $modalUpdates.off('click', 'button[data-change-update-btn]').on('click', 'button[data-change-update-btn]', function (event) {
0282                     var updateId = $(this).attr('data-change-update-btn');
0283                     var title = $(this).attr('data-change-title');
0284                     var text = $(this).attr('data-change-text');
0285 
0286                     $modalUpdates.find('#update-title').val(title);
0287                     $modalUpdates.find('#update-text').val(text);
0288                     $modalUpdates.find('#update-id').val(updateId);
0289 
0290                     $modalUpdates.find('#update-title').focus();
0291 
0292                         event.preventDefault();
0293 
0294                 });
0295 
0296                 $modalUpdates.off('click', 'button[data-updates-cancel-btn]').on('click', 'button[data-updates-cancel-btn]', function (event) {
0297                     event.preventDefault();
0298                     $modalUpdates.modal('hide');
0299                 });
0300                 
0301             }
0302         }
0303     })();
0304 </script>
0305 <!-- updates -->
0306 <div id="modal-updates"
0307      class="modal fade"
0308      role="dialog"
0309      aria-labelledby="modal-updates-label"
0310      data-product-id=""
0311      data-product-title="">
0312     <div class="modal-dialog content-modal" style="width: 95%">
0313         <div class="modal-content">
0314             <div class="modal-header">
0315                 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
0316                 <h3 id="modal-updates-label" data-updates-label=""><?= $this->translate('Changelog') ?></h3>
0317             </div>
0318             <div class="modal-body" style="font-size: small;">
0319                 <div role="form" class="">
0320                     <input type="hidden" id="update-id" data-update-id="" value="">
0321                         <?php /**
0322                     <div class="form-group">
0323                       <label for="tile">Product Version:</label>
0324                       <input type="text" id="product-version" data-product-version="" class="form-control input-sm" placeholder="Product Version Number">
0325                     </div>
0326                          *
0327                          */?>
0328                     <div class="form-group">
0329                       <label for="tile">Changelog Title:</label>
0330                       <input type="text" id="update-title" data-update-title="" class="form-control input-sm" placeholder="Enter a Changelog Title">
0331                     </div>
0332                     <div class="form-group">
0333                       <label for="text">Changelog Text:</label>
0334                       <textarea id="update-text" data-update-text="" class="form-control input-sm" rows="3" placeholder="Enter a Changelog Text"></textarea>
0335                     </div>
0336                     <button class="btn btn-native pull-right btn-xs btn-file-action" data-updates-cancel-btn=""><?= $this->translate('Cancel') ?></button>
0337                     <button type="submit" class="btn btn-native pull-right btn-xs btn-file-action" data-add-update-btn="">Save</button>
0338                 </div>
0339 
0340                 <article id="update-list">
0341                 </article>
0342 
0343 
0344             </div>
0345             <div class="modal-footer">
0346 
0347             </div>
0348         </div>
0349     </div>
0350 </div>
0351 
0352 <script type="text/javascript" src="/theme/flatui/js/lib/chosen.jquery.min.js"></script>
0353 <!-- /ppload -->
0354 
0355 <?php
0356             $this->inlineScript()->appendScript(
0357                 '    $(document).ready(function(){
0358                         TagingLoopMyProducts.setup();
0359                         myCollections.setup();
0360                         Partials.setup();                    
0361                      });
0362                 ');
0363 
0364      ?>