public function getCurrentPayPeriods()
    {
        if (!isset($_POST['customDate']) && !isset($_POST['GoBtn']) || isset($_POST['usePayPeriodBtn'])) {
            //what pay period are we currently in?
            $myq = getCurrentPayPeriod();
            $result = getQueryResult($this->config, $myq, $debug = false);
            $ppArray = $result->fetch_assoc();
            /* $ppOffset stands for the number of pay periods to adjust the query by 
             * relative to the current period
             */
            $ppOffset = isset($_POST['ppOffset']) ? $_POST['ppOffset'] : '0';
            if (isset($_POST['prevBtn'])) {
                $ppOffset--;
            } elseif (isset($_POST['nextBtn'])) {
                $ppOffset++;
            }
            $this->startDate = new DateTime($ppArray['PPBEG']);
            if ($ppOffset < 0) {
                //backward in time by $ppOffset number of periods
                $this->startDate->sub(new DateInterval("P" . abs($ppOffset) * 14 . "D"));
            } else {
                //forward in time by $ppOffset number of periods
                $this->startDate->add(new DateInterval("P" . $ppOffset * 14 . "D"));
            }
            $this->startDate = $this->startDate->format('Y-m-d');
            $this->endDate = new DateTime($ppArray['PPEND']);
            if ($ppOffset < 0) {
                //backward in time by $ppOffset number of periods
                $this->endDate->sub(new DateInterval("P" . abs($ppOffset) * 14 . "D"));
            } else {
                //forward in time by $ppOffset number of periods
                $this->endDate->add(new DateInterval("P" . $ppOffset * 14 . "D"));
            }
            $this->endDate = $this->endDate->format('Y-m-d');
            echo '<input type="hidden" name="ppOffset" value="' . $ppOffset . '" />';
            ?>
      
            <p>
            <div style="float:left"><input type="submit" name="prevBtn" value="< Previous" /></div>        
            <div style="float:right"><input type="submit" name="nextBtn" value="Next >" /></div></p>
            <h3><center>Pay Period: <?php 
            echo date('m-d-Y', strtotime($this->startDate));
            ?>
 to <?php 
            echo date('m-d-Y', strtotime($this->endDate));
            ?>
.</center></h3>

            <?php 
        } else {
        }
    }
示例#2
0
 private function getLastPayPeriodEnd()
 {
     //what pay period are we currently in?
     $myq = getCurrentPayPeriod();
     $result = getQueryResult($this->config, $myq, $debug = false);
     $ppArray = $result->fetch_assoc();
     $startDate = $ppArray['PPBEG'];
     $this->lastPayStart = date('Y-m-d', strtotime('-14 days', strtotime($startDate)));
     $endDate = $ppArray['PPEND'];
     $this->lastPayEnd = date('Y-m-d', strtotime('-14 days', strtotime($endDate)));
     return $endDate;
 }