Looking to rewrite some PHP code to include in a .tpl file

Discussion in 'PHP' started by JWRmedia, Oct 13, 2008.

  1. #1
    Is it possible to adjust the following code to work in a .tpl (smarty) file?

      function getinvoicepayuntildate ($nextduedate, $billingcycle, $fulldate = '')
      {
        $year = substr ($nextduedate, 0, 4);
        $month = substr ($nextduedate, 5, 2);
        $day = substr ($nextduedate, 8, 2);
        $daysadjust = 0;
        if (!$fulldate)
        {
          $daysadjust = 1;
        }
    
        if ($billingcycle == 'Monthly')
        {
          $new_time = mktime (0, 0, 0, $month + 1, $day - $daysadjust, $year);
        }
        else
        {
          if ($billingcycle == 'Quarterly')
          {
            $new_time = mktime (0, 0, 0, $month + 3, $day - $daysadjust, $year);
          }
          else
          {
            if ($billingcycle == 'Semi-Annually')
            {
              $new_time = mktime (0, 0, 0, $month + 6, $day - $daysadjust, $year);
            }
            else
            {
              if ($billingcycle == 'Annually')
              {
                $new_time = mktime (0, 0, 0, $month, $day - $daysadjust, $year + 1);
              }
              else
              {
                if ($billingcycle == 'Biennially')
                {
                  $new_time = mktime (0, 0, 0, $month, $day - $daysadjust, $year + 2);
                }
              }
            }
          }
        }
    
        if ($billingcycle != 'One Time')
        {
          $invoicepayuntildate = date ('Y-m-d', $new_time);
        }
    
        return $invoicepayuntildate;
      }
    Code (markup):
    Thanks for any help.
     
    JWRmedia, Oct 13, 2008 IP