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->tab = 'affiliates';
0024 $this->countDownloadsOverall = 0;
0025 
0026 $currentDate = date("Ym",time());
0027 $currentYear = date("Y",time());
0028 
0029 $modelDownload = new Default_Model_StatDownload();
0030 $downloadYears = $modelDownload->getUserAffiliatesYears($this->member->member_id);
0031 #$this->countDownloadsOverall = count($this->downloads);
0032 ?>
0033 
0034 
0035 <main class="user-admin-page">
0036     <?php echo $this->render('user/partials/userHeader_top.phtml'); ?>
0037     <section class="body-wrap">
0038         <section class="wrapper product-page">
0039             <!-- PAGE BODY -->
0040             <section class="my-products-page">
0041                 <!-- NAVIGATION -->
0042                 <?php echo $this->render('user/partials/userHeader.phtml'); ?>
0043                 <!-- /NAVIGATION -->
0044                 <div class="my-products-heading" style="border-bottom: none; padding-bottom: 0px;">
0045                     <h1 class="page-title left"><?= $this->translate('Affiliates') ?></h1>
0046                 </div>
0047                 
0048                 <!-- year tabs nav -->
0049                 <div class="pling-nav-tabs" style="padding-bottom: 20px;">
0050                     <ul class="nav nav-tabs" id="yeartablist">
0051                         <?php
0052                             if(count($downloadYears) == 0 ||  $downloadYears[0]['year'] != $currentYear) {
0053                                 //Current year
0054                                 echo '<li role="presentation" class="yeartabs">';
0055                                 echo '    <a style="font-size: 18px;" data-year="'.$currentYear.'" data-toggle="yeartabajax" href="/member/'.$this->member->member_id.'/affiliatesajax?year='.$currentYear.'" data-target="#my-payout-list" id="tab_year_'.$currentYear.'">'.$currentYear.'</a>';
0056                                 echo '</li>';
0057                             }
0058 
0059                             foreach ($downloadYears as $yearobj) {
0060                                 echo '<li role="presentation" class="yeartabs">';
0061                                 echo '    <a style="font-size: 18px;" data-year="'.$yearobj['year'].'" data-toggle="yeartabajax" href="/member/'. $this->member->member_id.'/affiliatesajax?year='.$yearobj['year'].'" data-target="#my-payout-list" id="tab_year_'.$yearobj['year'].'">'.$yearobj['year'].'</a>';
0062                                 echo '</li>';
0063                             }
0064                         ?>
0065                     </ul>
0066                 </div>
0067                 <section>
0068                 <?php
0069                     $member = $this->view_member;
0070                     if($member->paypal_valid_status > 100) {
0071                         $status = $this->paypal_valid_status;
0072                         if($status->color == 'red') {
0073                             echo '<div class="alert alert-danger" role="alert">'.$status->description.'</div>';
0074                         }
0075                         if($status->color == 'yellow') {
0076                             echo '<div class="alert alert-warning" role="alert">'.$status->description.'</div>';
0077                         }
0078                         if($status->color == 'blue') {
0079                             echo '<div class="alert alert-info" role="alert">'.$status->description.'</div>';
0080                         }
0081                         if($status->color == 'green') {
0082                             echo '<div class="alert alert-success" role="alert">'.$status->description.'</div>';
0083                         }
0084                     }
0085                 ?>
0086                 </section>
0087                 
0088                 <?php
0089                     if($member->pling_excluded == 0 || (Zend_Auth::getInstance()->hasIdentity() AND Zend_Auth::getInstance()->getIdentity()->roleName == 'admin')) {        
0090                         echo "<script>";
0091                         echo "var yearList = new Array();";
0092                         
0093                         if(count($downloadYears) == 0 ||  $downloadYears[0]['year'] != $currentYear) {
0094                             //Current year
0095                             echo "var yearListObj = new Array();";
0096                             echo "yearListObj['maxMonth'] = '".$currentDate."';";
0097                             echo "yearListObj['sum'] = '0';";
0098                             echo "yearList['".$currentYear."'] = yearListObj;";
0099                         }
0100                         
0101                         foreach ($downloadYears as $yearobj) {
0102                             echo "var yearListObj = new Array();";
0103                             echo "yearListObj['maxMonth'] = '".$yearobj['max_yearmonth']."';";
0104                             echo "yearListObj['sum'] = '".$yearobj['sum_amount']."';";
0105                             echo "yearList['".$yearobj['year']."'] = yearListObj;";
0106                         }
0107                         echo "</script>";
0108                 ?>  
0109                 <div class="my-products-list" id="my-payout-list">
0110                     <div id="plingsyear">
0111                         <i class="fa fa-spinner"></i>
0112                     </div>
0113                 </div>
0114                 <?php
0115                     }
0116                 ?>
0117             </section>
0118             <!-- /PAGE BODY -->
0119         </section>
0120     </section>
0121 </main>
0122 
0123 <script>
0124 $(document).ready(function(){
0125     
0126     
0127     //Load pling for year
0128     $('[data-toggle="yeartabajax"]').click(function(e) {
0129                
0130         var $this = $(this);
0131         var year = $this.attr('data-year');
0132         var loadurl = $this.attr('href');
0133         var targ = $('#plingsyear');
0134         
0135         $('.yeartabs').removeClass('active');
0136         $this.parent().addClass('active');
0137         
0138         $(targ).html('<i class="fa fa-spinner"></i>');
0139 
0140         $.get(loadurl, function(data) {
0141             
0142             $('#plingsyear').html(data);
0143             $('[data-toggle="popover"]').popover();
0144             
0145             
0146             //Init tabs
0147             $('[data-toggle="tabajax"]').click(function(e) {
0148                 var $this = $(this),
0149                     loadurl = $this.attr('href'),
0150                     targ = $this.attr('data-target');
0151                 $(targ).html('<i class="fa fa-spinner"></i>');
0152 
0153                 $.get(loadurl, function(data) {
0154                     $(targ).html(data);
0155                 });
0156 
0157                 $this.tab('show');
0158                 
0159                 return false;
0160             });
0161             
0162             //Load first Tab
0163             var month = yearList[year]['maxMonth'];
0164             var $this = $('#tab_'+month),
0165             loadurl = $this.attr('href'),
0166             targ = $this.attr('data-target');
0167 
0168             $.get(loadurl, function(data) {
0169                 $(targ).html(data);
0170             });
0171 
0172             $this.tab('show');
0173             
0174         });
0175 
0176         $(targ).show();
0177         return false;
0178     });
0179          
0180     //Init View on first load     
0181     var year = <?= $currentYear ?>;
0182     var currentyeartab = $('#tab_year_'+year);
0183     $('.yeartabs').removeClass('active');
0184     
0185     currentyeartab.parent().addClass('active');
0186     
0187     var loadurl = currentyeartab.attr('href');
0188     $.get(loadurl, function(data) {
0189         $('#plingsyear').html(data);
0190         $('[data-toggle="popover"]').popover();
0191         
0192         
0193         //Init tabs
0194         $('[data-toggle="tabajax"]').click(function(e) {
0195             var $this = $(this),
0196                 loadurl = $this.attr('href'),
0197                 targ = $this.attr('data-target');
0198             $(targ).html('<i class="fa fa-spinner"></i>');
0199 
0200             $.get(loadurl, function(data) {
0201                 $(targ).html(data);
0202             });
0203 
0204             $this.tab('show');
0205             return false;
0206         });
0207         
0208         
0209         var $this = $('#tab_' + yearList[year]['maxMonth']),
0210             loadurl = $this.attr('href'),
0211             targ = $this.attr('data-target');
0212 
0213         $.get(loadurl, function(data) {
0214             $(targ).html(data);
0215         });
0216 
0217         $this.tab('show');
0218         
0219 
0220         return false;
0221     });
0222     
0223     
0224     $('[data-toggle="tabajax"]').click(function(e) {
0225                
0226         var $this = $(this),
0227             loadurl = $this.attr('href'),
0228             targ = $this.attr('data-target');
0229         $(targ).html('<i class="fa fa-spinner"></i>');
0230 
0231         $.get(loadurl, function(data) {
0232             $(targ).html(data);
0233         });
0234 
0235         $this.tab('show');
0236         return false;
0237     });
0238             
0239 });
0240 
0241     $('#payout_info').click(function (event ) {
0242         event.preventDefault();
0243         $('#le-alert').addClass('in'); // shows alert with Bootstrap CSS3 implem
0244     });
0245 
0246     $('.close').click(function () {
0247         $(this).parent().removeClass('in'); // hides alert with Bootstrap CSS3 implem
0248     });
0249     
0250     $(function(){
0251         // Enables popover
0252         $(".payout-popover-info").popover({
0253             html : true,
0254             template : '<div class="popover alert alert-info alert-block" role="tooltip"><div class="popover-arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
0255         });
0256         $(".payout-popover-warning").popover({
0257             html : true,
0258             template : '<div class="popover alert alert-warning alert-block" role="tooltip"><div class="popover-arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
0259         });
0260         $(".payout-popover-success").popover({
0261             html : true,
0262             template : '<div class="popover alert alert-success alert-block" role="tooltip"><div class="popover-arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
0263         });
0264         $(".payout-popover-danger").popover({
0265             html : true,
0266             template : '<div class="popover alert alert-danger alert-block" role="tooltip"><div class="popover-arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
0267         });
0268         $(".msg-popover-danger").popover({
0269             html : true,
0270             template : '<div class="popover alert alert-danger alert-block" role="tooltip"><div class="popover-arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
0271         });
0272     });
0273 
0274 </script>