<?php
namespace Erpadmin\Controller;
use Think\Controller;
use Common\Controller\BaseController;
class ErpadminbaseController extends BaseController {
    public function _initialize(){
        
        parent::_initialize();
        if (!isset($_SESSION['erp_user'])) {
            $this->redirect('Login/index');
        }
        $this->userinfo = session('erp_user');
    }

    public function getThisWeekOf($date){
        $dates = array();
        $time  = strtotime($date.' 12:00:00');
        $w     = date('w', $time);
     
        if($w == 0){
            $nextMonday = 1;
        } else {
            $nextMonday = 7 - $w + 1;
        }
        for($i = $nextMonday; $i<$nextMonday + 7; $i++){
            $dates[] = date('Y-m-d', $time + 3600*24*$i - 3600*24*7);
        }
        return $dates;
    }

    public function getNextWeekOf($date){
        $dates = array();
        $time  = strtotime($date.' 12:00:00');
        $w     = date('w', $time);
     
        if($w == 0){
            $nextMonday = 1;
        } else {
            $nextMonday = 7 - $w + 1;
        }
        for($i = $nextMonday; $i<$nextMonday + 7; $i++){
            $dates[] = date('Y-m-d', $time + 3600*24*$i);
        }
        return $dates;
    }
}
?>