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 = 'funding';
0024 
0025 
0026 $modelSection = new Default_Model_Section();
0027 $modelSectionSupport = new Default_Model_DbTable_SectionSupport();
0028 
0029 $allSections = $modelSection->fetchAllSections();
0030 $currency = new Zend_Currency('en_US');
0031 ?>
0032 <main class="user-admin-page">
0033     <?php echo $this->render('user/partials/userHeader_top.phtml'); ?>  
0034     <section class="body-wrap">
0035         <section class="wrapper product-page">
0036             <!-- PAGE BODY -->
0037             <section class="my-products-page">
0038                 <!-- NAVIGATION -->
0039                 <?php echo $this->render('user/partials/userHeader.phtml'); ?>
0040                 <!-- /NAVIGATION -->
0041              
0042               <div class="my-products-heading">
0043                    <h1 class="page-title left"><?= $this->translate('Funding') ?></h1> 
0044                    <!--<p>Supporter Level = (S1,S2)</p>-->
0045                </div>
0046                 
0047                 
0048                 
0049 
0050                 <div class="container-fluid margin-bottom-12" style="padding-left: 0; padding-right: 0; padding-bottom: 10px;">
0051                     <div class="row"> 
0052                         <div class="col-md-2 text-left text-uppercase nowrap" style="white-space: nowrap;"><strong>Section</strong></div>
0053                         <div class="col-md-1 text-left text-uppercase nowrap" style="white-space: nowrap;"><strong>Status</strong></div>
0054                         <div class="col-md-1 text-right text-uppercase nowrap" style="white-space: nowrap;"><strong>Amount</strong></div>
0055                         <div class="col-md-1 text-left text-uppercase nowrap" style="white-space: nowrap;"><strong>Paid Since</strong></div>
0056                         <div class="col-md-1 text-left text-uppercase nowrap" style="white-space: nowrap;"><strong>Paid Until</strong></div>
0057                         <div class="col-md-1 text-right text-uppercase nowrap" style="white-space: nowrap;"><strong>Months</strong></div>
0058                         <div class="col-md-1 text-right text-uppercase nowrap" style="white-space: nowrap;"><strong>Total</strong></div>
0059                         <div class="col-md-3 text-left text-uppercase nowrap" style="white-space: nowrap;"><strong>Details</strong></div>
0060                         <?php if (Zend_Auth::getInstance()->hasIdentity() && Zend_Auth::getInstance()->getIdentity()->roleName == 'admin'){ ?>
0061                         <div class="col-md-1 text-left text-uppercase nowrap" style="white-space: nowrap;"><strong>Affiliate of</strong></div>
0062                         <?php } ?>
0063                     </div>
0064                     
0065                 <?php 
0066                     $noData = true;
0067                     foreach ($allSections as $section) { 
0068                         $isFirst = true;
0069                         $supports = $modelSectionSupport->fetchAllSectionSupportsForMember($section['section_id'], $this->view_member->member_id);
0070                         
0071                         if($modelSection->wasMemberSectionSupporter($section['section_id'], $this->view_member->member_id) && !empty($supports)) {
0072                             $noData = false;
0073                             foreach ($supports as $support) {
0074                                 //calc months
0075                                 $now = new DateTime();
0076                                 $months = 0;
0077                                 
0078                                 $from = strtotime($support['active_time']);
0079                                 $to = null;
0080                                 
0081                                 if($support['type_id'] == 0) {
0082                                     $to = strtotime($support['active_time_one_year']);
0083                                 } else {
0084                                     $to = strtotime($support['last_payment_until_time']);
0085                                 }
0086                                 $min_date = min($from, $to);
0087                                 $max_date = max($from, $to);
0088                                 $i = 1;
0089 
0090                                 while (($min_date = strtotime("+1 MONTH", $min_date)) <= $max_date) {
0091                                     $i++;
0092                                 }
0093                                 $months = $i; // 8
0094                                 
0095                                 
0096                                 /*
0097                                 if($support['period'] == 'Y') {
0098                                     
0099                                     $d1 = strtotime($support['active_time']);
0100                                     $d2 = $now->getTimestamp();
0101                                     
0102                                     if($support['active_status'] == 'inactive') {
0103                                         
0104                                         if($support['type_id'] == 1) {
0105                                             if(strtotime($support['last_payment_until_time']) < $now->getTimestamp()) {
0106                                                 $d2 = strtotime($support['last_payment_until_time']);
0107                                             }
0108                                         } else {
0109                                             if(strtotime($support['active_time_one_year']) < $now->getTimestamp()) {
0110                                                 $d2 = strtotime($support['active_time_one_year']);
0111                                             }
0112                                         }
0113                                         
0114                                         
0115                                     }
0116                                     
0117                                     $min_date = min($d1, $d2);
0118                                     $max_date = max($d1, $d2);
0119                                     $i = 1;
0120 
0121                                     while (($min_date = strtotime("+1 MONTH", $min_date)) <= $max_date) {
0122                                         $i++;
0123                                     }
0124                                     $months = $i; // 8
0125                                 } else {
0126                                     $d1 = strtotime($support['active_time']);
0127                                     
0128                                     $d2 = $now->getTimestamp();
0129                                     
0130                                     if(strtotime($support['last_payment_until_time']) < $now->getTimestamp()) {
0131                                         $d2 = strtotime($support['last_payment_until_time']);
0132                                     }
0133                                     
0134                                     $min_date = min($d1, $d2);
0135                                     $max_date = max($d1, $d2);
0136                                     $i = 1;
0137 
0138                                     while (($min_date = strtotime("+1 MONTH", $min_date)) <= $max_date) {
0139                                         $i++;
0140                                     }
0141                                     $months = $i; // 8
0142 
0143                                 }
0144                                 */
0145                                 if($months == 0) {
0146                                     $months = 1;
0147                                 }
0148                                 
0149                                 
0150                 ?>
0151                     
0152                     <div class="row margin-bottom-12"  style="padding-left: 0; padding-right: 0; margin-bottom: 10px;<?php if($isFirst) echo "border-top: 1px solid #ddd;margin-top: 15px;padding-top: 5px;" ?>">
0153                         <!-- Section -->
0154                         <div class="col-md-2 cell-default" style="">
0155                             <?php if($isFirst) { 
0156                                 echo $section['name']; 
0157                             } ?>
0158                         </div>
0159                         
0160                         <!-- Status -->
0161                         <div class="col-md-1 cell-default" style="">
0162                             <?php
0163                             /*
0164                             active, ongoing, green
0165                             active, canceled, yellow
0166                             active, one-time, yellow
0167                             inactive, canceled, red
0168                             inactive, one-time, red
0169                              */
0170                             ?>
0171                             <?php
0172                                 //One-Time-Support
0173                                 if($support['type_id'] == 0) {
0174                                     if($support['active_status'] == 'active') {
0175                                         echo "<span class='label label-warning'>active, one-time</span>";
0176                                     } else {
0177                                         echo "<span class='label label-danger'>inactive, one-time</span>";
0178                                     }
0179                                 } else {
0180                                     //Subscription
0181                                     if($support['status_id'] == 2) {
0182                                         echo "<span class='label label-success'>active, ongoing</span>";
0183                                     } else {
0184                                         //canceld?
0185                                         if(strtotime($support['last_payment_until_time']) > $now->getTimestamp()) {
0186                                             echo "<span class='label label-warning'>active, cancelled</span>";
0187                                         } else {
0188                                             echo "<span class='label label-danger'>inactive, cancelled</span>";
0189                                         }
0190                                     }
0191                                 }
0192                             ?>
0193                         </div>
0194                         
0195                         <!-- Amount -->
0196                         <div class="col-md-1 cell-default text-right" style=""><?php print($currency->toCurrency($support['tier'])); ?></div>
0197 
0198                         <!-- Since -->
0199                         <div class="col-md-1 cell-default" style=""><?= date_format(date_create($support['active_time']),'M Y') ?></div>
0200                         
0201                         <!-- Until -->
0202                         <div class="col-md-1 cell-default" style="">
0203                             <?php
0204                                 if($support['type_id'] == 0) {
0205                                     echo date_format(date_create($support['active_time_one_year']),'M Y');
0206                                 } else {
0207                                     echo date_format(date_create($support['last_payment_until_time']),'M Y');
0208                                 }
0209                             ?>
0210                         </div>
0211                         
0212                         <!-- Months -->
0213                         <div class="col-md-1 cell-default text-right" style="">
0214                             <?= $months ?>
0215                         </div>
0216                         
0217                         <!-- total -->
0218                         <div class="col-md-1 cell-default text-right" style="">
0219                             <?php  print($currency->toCurrency($months * $support['tier'])); ?>
0220                         </div>
0221                         
0222                         
0223                         
0224                         <!-- Desc -->
0225                         <div class="col-md-3 cell-default" style="">
0226                             <?php 
0227                                 $text = "Your ";
0228                                 if($support['type_id'] == 0) {
0229                                     $text .= "One-Time-Payment ";
0230                                 } else {
0231                                     if($support['period'] == 'Y') {
0232                                         $text .= "yearly Subscription ";
0233                                     } else {
0234                                         $text .= "monthly Subscription ";
0235                                     }
0236                                 }
0237                                 $text .= " via ". $support['payment_provider'];
0238                                 if($support['active_status'] == 'active') {
0239                                     $text .= " is active since ". $this->printDate($support['active_time']);
0240                                     if($support['type_id'] == 0) {
0241                                         $text .= " until ". $this->printDate($support['active_time_one_year']);
0242                                     }
0243                                 } else {
0244                                     $text .= " was active from ". $this->printDate($support['active_time']);
0245                                     if($support['type_id'] == 0) {
0246                                         $text .= " to ". $this->printDate($support['active_time_one_year']);
0247                                     } else {
0248                                         $text .= " to ". $this->printDate($support['delete_time']);
0249                                     }
0250                                 }
0251                                 $text .= ". Transaction-Id: ".$support['subscription_id'];
0252                                 
0253                                 
0254                                 echo $text;
0255                                 
0256                                 
0257                                 if (Zend_Auth::getInstance()->hasIdentity() && Zend_Auth::getInstance()->getIdentity()->roleName == 'admin' && !empty($support['project_id'])){
0258                                     echo "<br>Referer: <a href='".$support['referer']."'>".$support['referer']."</a>";
0259                                 }
0260                                 
0261                                 $isFirst = false;
0262 
0263                             ?>
0264                         
0265                         </div>
0266                         
0267                         <?php if (Zend_Auth::getInstance()->hasIdentity() && Zend_Auth::getInstance()->getIdentity()->roleName == 'admin'){ ?>
0268                         <div class="col-md-1 cell-default" style="">
0269                             <a href="<?= $this->buildMemberUrl($support['affiliate_username']) ?>"><?= $support['affiliate_username']; ?></a>
0270                         </div>
0271                         <?php } ?>
0272                     </div>
0273                     
0274                 <?php    
0275                             }
0276                         } else {
0277                             /*
0278                 ?>            
0279                      <div class="row margin-bottom-12"  style="padding-left: 0; padding-right: 0; margin-bottom: 10px;<?php if($isFirst) echo "border-top: 1px solid #ddd;margin-top: 15px;padding-top: 5px;" ?>">
0280                         <!-- Section -->
0281                         <div class="col-md-2 cell-default" style="">
0282                             <?php echo $section['name']; ?>
0283                         </div>
0284                         <div class="col-md-10 cell-default center" style="text-align: center">
0285                             No Data available!
0286                         </div>
0287                      </div>
0288                             
0289                 <?php     */       
0290                         } 
0291                     }
0292                 ?>
0293                     
0294                 <?php
0295                     if($noData) {
0296                 ?>
0297                     <div class="row margin-bottom-12"  style="padding-left: 0; padding-right: 0; margin-bottom: 10px;<?php if($isFirst) echo "border-top: 1px solid #ddd;margin-top: 15px;padding-top: 5px;" ?>">
0298                         <!-- Section -->
0299                         <div class="col-md-12 cell-default center" style="text-align: center;font-size: larger;padding-top: 40px;">
0300                             <a href="/support">Become a supporter</a>
0301                         </div>
0302                     </div>
0303                 <?php
0304                     }
0305                 ?>
0306                     
0307                 </div>
0308             </section>
0309 
0310             <!-- /PAGE BODY -->
0311 
0312         </section>
0313 
0314     </section>
0315 
0316 </main>