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

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 <style>
0025     .cell-default {
0026         line-height: 4em;
0027         vertical-align: middle;
0028     }
0029     
0030     .row-total {
0031         border-top: #1595ee solid thin;
0032         padding-top: 1em;
0033         padding-bottom: 1em;
0034         line-height: 30px;
0035         margin-left: 0px;
0036         margin-right: 0px;
0037     }
0038     
0039     .popover {
0040         min-width:350px;
0041     }
0042     
0043     .popover-title { 
0044         text-transform: none;
0045         font-size: 11pt;
0046     }
0047     
0048     .popover-content { 
0049         text-transform: none;
0050         font-size: 11pt;
0051     }
0052 </style>
0053 <ul class="nav nav-tabs margin-bottom-10">
0054 <?php
0055     
0056 $isCurrentMonth = false;
0057 $modelDownload = new Default_Model_StatDownload();
0058 $yearmonth = null;
0059 
0060 if(isset($this->yearmonth)) {
0061     $yearmonth = $this->yearmonth;
0062 }
0063 ?>
0064 
0065 <div class="tab-content">
0066 <?php
0067 $helperUserRole = new Backend_View_Helper_UserRole();
0068 $userRoleName = $helperUserRole->userRole();
0069 
0070 $helperBuildProductUrl = new Default_View_Helper_BuildProductUrl();
0071 $helpImage = new Default_View_Helper_Image();
0072 $css_active = ' in active';
0073 $has_paypal = false;
0074 $currency = new Zend_Currency('en_US');
0075 
0076 $currentDate = date("Ym",time());
0077 $printCurrentMonth = new DateTime($currentDate.'01');
0078 
0079 $printMonth = new DateTime($yearmonth.'01');
0080 $printDate = $printMonth->format('M Y');
0081 
0082 $allAffiliates = $modelDownload->getUserAffiliatesForMonth($this->member->member_id, $yearmonth);
0083 $countDownloadsOverall = count($allAffiliates);
0084 
0085 if ($countDownloadsOverall > 0) {
0086     $firstProduct = $allAffiliates[0];
0087     if ($firstProduct) {
0088         $printMonth = new DateTime($firstProduct['yearmonth'].'01');
0089         $printCurrentMonth = new DateTime($currentDate.'01');
0090         
0091         if($printMonth == $printCurrentMonth) {
0092             $isCurrentMonth = true;
0093         } else {
0094             $isCurrentMonth = false;
0095         }
0096         $sum_total_text = '';
0097         $sum_total_payout = 0;
0098         
0099         ?>
0100         <div class="tab-pane fade <?=$css_active?>" id="<?=$firstProduct['yearmonth']?>">
0101             <?php
0102             $css_active = '';
0103 
0104             foreach ($allAffiliates as $section) { 
0105                 $sum_total_payout += $section['sum_donations']*$section['affiliate_percent'];
0106                 ?>
0107                 <div class="row margin-bottom-12"  style="padding-left: 0; padding-right: 0; margin-bottom: 10px;">
0108                     <div class="col-md-2 text-left cell-default">
0109                         <a href="/member/<?= $this->member->member_id ?>/sectionaffiliatesmonthdetailajax?yearmonth=<?= $section['yearmonth'] ?>" data-toggle="sectiondetailajax" data-target="#affiliate-content-<?= $section['yearmonth'] ?>" id="sec_<?= $section['yearmonth'] ?>">Show/Hide</a>
0110                     </div>
0111                     
0112                     <div class="col-md-1 text-right cell-default" style="min-width: 190px;">
0113                         <span><?= $section['count_supporters'] ?></span>
0114                     </div>
0115                     <div class="col-md-1 text-right cell-default" style="min-width: 190px;">
0116                         <span><?php print($currency->toCurrency($section['sum_donations'])); ?></span>
0117                     </div>
0118                     
0119                     <div class="col-md-1 text-right cell-default" style="min-width: 190px;">
0120                         <span><?php print($section['affiliate_percent']); ?></span>
0121                     </div>
0122                     <div class="col-md-1 text-right cell-default" style="min-width: 190px;">
0123                         <span><?php print($currency->toCurrency($section['sum_donations']*$section['affiliate_percent'])); ?></span>
0124                     </div>
0125                 </div>
0126                 <div class="row margin-bottom-12"  style="padding-left: 0; padding-right: 0; margin-bottom: 10px;padding-left: 80px;font-size: small;">
0127                     <div class="col-md-1 text-right cell-default"></div>
0128                     <div class="col-md-11 text-right cell-default">
0129                         <div id="affiliate-content-<?= $section['yearmonth'] ?>" class="hidden"></div>
0130                     </div>
0131                     
0132                 </div>
0133                     
0134             
0135             
0136                 <?php
0137                 
0138                 
0139                 $sum_total_text = 'Possible payout for this month (<span style="font-size: smaller;">*</span>):';
0140                 
0141             }
0142 
0143             ?>
0144             <div class='row row-total'>
0145                 <div class='col-md-2 text-right' style="min-width: 503px;"><?=$sum_total_text?></div>
0146                 <div class='col-md-1 text-right' style="min-width: 190px;"></div>
0147                 <div class='col-md-1 text-right' style="min-width: 190px;"></div>
0148                 <div class='col-md-1 text-right' style="min-width: 190px;"><strong><?php print($currency->toCurrency($sum_total_payout)); ?>**</strong></div>
0149             </div>
0150             
0151             
0152             
0153             <?php 
0154 
0155 
0156             $currentDate = date("Ym",time());
0157             $viewDate = $firstProduct['yearmonth']."";
0158             $paypalWarning = '';
0159             if($currentDate == $viewDate) {
0160                 $member = $this->view_member;
0161                 if(!isset($member['paypal_mail']) || $member['paypal_mail'] == '') {
0162                     $has_paypal = false;
0163                     $paypalWarning = 'You have no PayPal account configured. Please go to your settings page <a href="/settings#form-payment-panel">here</a>.';
0164                 } else {
0165                     $has_paypal = true;
0166                 }
0167             } else {
0168                 $paypalWarning = 'We found no valid Paypal account for this month. That\'s why we could not pay you any money. In order to receive money for the current month, please make sure that a paypal account is registered. Go to your settings page <a href="/settings#form-payment-panel">here</a>.';
0169             }
0170             if (false == $has_paypal) {
0171                 echo '<div class="alert alert-danger" role="alert">'.$paypalWarning.'</div>';
0172             }
0173 
0174             if (($sum_total_payout) < 1) {
0175                 echo '<div class="alert alert-warning" role="alert">We only pay out money if the total sum is over $1.</div>';
0176             }
0177 ?>
0178             
0179         </div>
0180 <?php
0181     }
0182 } else {
0183     
0184     echo '<div class="tab-pane fade in active" id="'.$printDate.'">';
0185     echo '    <div style="text-align: center;" class="row margin-bottom-12"><div class="col-md-8 cell-default">No Data</div></div>';
0186     echo '    <div class="row row-total">';
0187     echo '        <div class="col-md-1 text-right" style="min-width: 150px;"></div><div class="col-md-4 text-right"></div><div class="col-md-3 text-right" style="min-width: 570px;">Possible payout for this month (<span style="font-size: smaller;">*</span>):</div><div class="col-md-1 text-right" style="min-width: 190px;"><strong>$0.00</strong></div>';
0188     echo '    </div>';
0189     echo '</div>';
0190 }
0191     
0192     
0193 ?>
0194 
0195 <?php /*    
0196     <div id="le-alert"  class="alert alert-warning alert-block" role="alert">
0197         <p>(**) The Payout is planned to become active on May 2019.</p>
0198     </div>
0199 */ ?>
0200 
0201     <div id="le-alert"  class="alert alert-warning alert-block" role="alert">
0202         <p>(*) Info:</p>
0203         <p>This service will become active on May, 1st 2017. All previous months are shown for internal testing only.
0204         </p>
0205         <p>This service is considered Beta until otherwise announced.</p>
0206         <br>
0207         <p>For the full Terms of Service, please read here: <a href="/terms/payout">Payout T&C</a></p> 
0208         <br><br>
0209         <p>**Paypal might deduct general fees and conversion rate from this sum.</p>
0210             
0211     </div>
0212 </div>    
0213     
0214 <script>
0215 $(document).ready(function(){ 
0216     
0217     $('[data-toggle="sectiondetailajax"]').click(function(e) {
0218         var $this = $(this),
0219             loadurl = $this.attr('href'),
0220             targ = $this.attr('data-target');
0221         
0222         if($(targ).hasClass('hidden')) {
0223             $(targ).html('<i class="fa fa-spinner"></i>');
0224             $(targ).removeClass('hidden');
0225             $(targ).addClass('shown');
0226 
0227             $.get(loadurl, function(data) {
0228                 $(targ).html(data);
0229             });
0230         } else {
0231             $(targ).removeClass('shown');
0232             $(targ).addClass('hidden');
0233         }
0234             
0235 
0236         return false;
0237     });
0238 
0239     
0240     $('#payout_info').click(function (event ) {
0241         event.preventDefault();
0242         $('#le-alert').addClass('in'); // shows alert with Bootstrap CSS3 implem
0243     });
0244 
0245     $('.close').click(function () {
0246         $(this).parent().removeClass('in'); // hides alert with Bootstrap CSS3 implem
0247     });
0248     
0249     $(function(){
0250         // Enables popover
0251         $(".payout-popover-info").popover({
0252             html : true,
0253             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>'
0254         });
0255         $(".payout-popover-warning").popover({
0256             html : true,
0257             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>'
0258         });
0259         $(".payout-popover-success").popover({
0260             html : true,
0261             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>'
0262         });
0263         $(".payout-popover-danger").popover({
0264             html : true,
0265             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>'
0266         });
0267         $(".msg-popover-danger").popover({
0268             html : true,
0269             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>'
0270         });
0271     });
0272 
0273 });        
0274 
0275 </script> 
0276 
0277 <?php $this->inlineScript()->appendScript(
0278     '    $(document).ready(function(){
0279             $(\'[data-toggle="popover"]\').popover();
0280         });
0281     ');