Beispiel #1
0
?>
/>
			<input type='hidden' id='mm-is_recurring_val' value='<?php 
echo $product->isRecurring() ? '1' : '0';
?>
' />
		</td>
	</tr>
	<tr>
		<td></td>
		<td>
			<div id='mm_rebill_row' style='display:none;'>
				<p style="margin:5px 0px 0px 0px;">
					Rebill Period
					<input type='text' id='mm-rebill_period' value='<?php 
echo $product->getRebillPeriod();
?>
'  style='margin-left: 10px; width: 50px' <?php 
echo $hasBeenPurchased ? "disabled" : "";
?>
/> 
					<select id='mm-rebill_frequency' style='width:100px;' <?php 
echo $hasBeenPurchased ? "disabled" : "";
?>
>
					<?php 
echo $rebillFrequencyList;
?>
				</select>
				</p>
				<p style="margin:5px 0px 5px 0px;">
Beispiel #2
0
 public static function getNextPaymentDate($startDate, $productId)
 {
     $product = new MM_Product($productId);
     $start = strtotime($startDate);
     if ($product->isRecurring(false)) {
         $period = $product->getRebillPeriod();
         $freq = $product->getRebillFrequency();
         $newdate = null;
         switch ($freq) {
             case "months":
                 $months = floor((mktime() - $start) / 2628000);
                 $newStart = strtotime($months . ' month', strtotime($start));
                 $newdate = strtotime($period . ' month', strtotime($newStart));
                 break;
             case "days":
                 $days = self::countDays(Date("Y-m-d h:i:s"), $startDate);
                 $diff = $days > $period ? intval($days / $period) : 1;
                 $newStart = strtotime($diff . ' day', strtotime($start));
                 $newdate = strtotime($period . ' day', strtotime($newStart));
                 break;
             case "weeks":
                 $days = self::countDays(Date("Y-m-d h:i:s"), $startDate);
                 $weeks = $days > 7 ? intval($days / 7) : 1;
                 $diff = $weeks > $period ? intval($weeks / $period) : 1;
                 $newStart = strtotime($diff . ' week', strtotime($start));
                 $newdate = strtotime($period . ' week', strtotime($newStart));
                 break;
             case "years":
                 $days = self::countDays(Date("Y-m-d h:i:s"), $startDate);
                 $years = $days > 365 ? intval($days / 365) : 1;
                 $diff = $years > $period ? intval($years / $period) : 1;
                 $newStart = strtotime($diff . ' year', strtotime($start));
                 $newdate = strtotime($period . ' year', strtotime($newStart));
                 break;
         }
         if (!is_null($newdate)) {
             return $newdate;
         }
     }
     return false;
 }