123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- <?php
- class timesheetModel extends Staple_Model
- {
- private $db;
- private $userId;
- private $startDate;
- private $month;
- private $nextMonth;
- private $previousMonth;
- private $nextYear;
- private $previousYear;
- private $year;
- private $endDate;
- private $entries;
- /**
- * @return mixed
- */
- public function getUserId()
- {
- return $this->userId;
- }
- /**
- * @param mixed $userId
- */
- public function setUserId($userId)
- {
- $this->userId = $userId;
- }
- /**
- * @return mixed
- */
- public function getStartDate()
- {
- return $this->startDate;
- }
- /**
- * @param mixed $startDate
- */
- public function setStartDate($startDate)
- {
- $this->startDate = $startDate;
- }
- /**
- * @return mixed
- */
- public function getMonth()
- {
- return $this->month;
- }
- /**
- * @param mixed $month
- */
- public function setMonth($month)
- {
- $this->month = $month;
- }
- /**
- * @return mixed
- */
- public function getNextMonth()
- {
- return $this->nextMonth;
- }
- /**
- * @param mixed $nextMonth
- */
- public function setNextMonth($nextMonth)
- {
- $this->nextMonth = $nextMonth;
- }
- /**
- * @return mixed
- */
- public function getPreviousMonth()
- {
- return $this->previousMonth;
- }
- /**
- * @param mixed $previousMonth
- */
- public function setPreviousMonth($previousMonth)
- {
- $this->previousMonth = $previousMonth;
- }
- /**
- * @return mixed
- */
- public function getNextYear()
- {
- return $this->nextYear;
- }
- /**
- * @param mixed $nextYear
- */
- public function setNextYear($nextYear)
- {
- $this->nextYear = $nextYear;
- }
- /**
- * @return mixed
- */
- public function getPreviousYear()
- {
- return $this->previousYear;
- }
- /**
- * @param mixed $previousYear
- */
- public function setPreviousYear($previousYear)
- {
- $this->previousYear = $previousYear;
- }
- /**
- * @return mixed
- */
- public function getYear()
- {
- return $this->year;
- }
- /**
- * @param mixed $year
- */
- public function setYear($year)
- {
- $this->year = $year;
- }
- /**
- * @return mixed
- */
- public function getEndDate()
- {
- return $this->endDate;
- }
- /**
- * @param mixed $endDate
- */
- public function setEndDate($endDate)
- {
- $this->endDate = $endDate;
- }
- /**
- * @return mixed
- */
- public function getEntries()
- {
- return $this->entries;
- }
- /**
- * @param mixed $entries
- */
- public function setEntries($entries)
- {
- $this->entries = $entries;
- }
- function __construct($month = null,$year = null)
- {
- $this->db = Staple_DB::get();
- //Get user ID from Auth
- $user = new userModel();
- $this->userId = $user->getId();
- if ($month == NULL) {
- $month = new DateTime();
- $month = $month->format('n');
- }
- if ($year == NULL) {
- $year = new DateTime();
- $year = $year->format('Y');
- }
- $dateObj = new DateTime();
- $dateObj->setDate($year, $month, 1);
- $end = $dateObj->modify('+24 day');
- $endTime = strtotime($end->format('Y-m-d'));
- $endDate = $end->format('Y-m-d');
- $this->setEndDate($endDate);
- $this->setMonth($end->format('F'));
- $this->setNextMonth($end->modify('+1 month')->format('m'));
- $this->setPreviousMonth($end->modify('-1 month')->format('m'));
- $this->setYear($end->format('Y'));
- $this->setNextYear($end->modify('+1 year')->format('Y'));
- $this->setPreviousYear($end->modify('-1 year')->format('Y'));
- $start = $dateObj->modify('-1 month +1 day');
- $startTime = strtotime($start->format('Y-m-d'));
- $startDate = $start->format('Y-m-d');
- $this->setStartDate($startDate);
- }
- }
- ?>
|