|
@@ -7,6 +7,7 @@ class reportsController extends Staple_Controller
|
|
|
|
|
|
public function _start()
|
|
public function _start()
|
|
{
|
|
{
|
|
|
|
+ $this->_setLayout('main');
|
|
$auth = Staple_Auth::get();
|
|
$auth = Staple_Auth::get();
|
|
$this->authLevel = $auth->getAuthLevel();
|
|
$this->authLevel = $auth->getAuthLevel();
|
|
$user = new userModel();
|
|
$user = new userModel();
|
|
@@ -42,6 +43,29 @@ class reportsController extends Staple_Controller
|
|
$date = new DateTime();
|
|
$date = new DateTime();
|
|
$date->setDate($year, $month, 1);
|
|
$date->setDate($year, $month, 1);
|
|
$this->view->month = $date->format('F');
|
|
$this->view->month = $date->format('F');
|
|
|
|
+
|
|
|
|
+ $printTimeSheetForm = new printTimeSheetForm();
|
|
|
|
+ if($printTimeSheetForm->wasSubmitted())
|
|
|
|
+ {
|
|
|
|
+ $printTimeSheetForm->addData($_POST);
|
|
|
|
+ if($printTimeSheetForm->validate())
|
|
|
|
+ {
|
|
|
|
+ $data = $printTimeSheetForm->exportFormData();
|
|
|
|
+
|
|
|
|
+ $this->layout->addScriptBlock("
|
|
|
|
+ window.open('".$this->_link(array("reports","printpreview",$year,$month,$data['account']))."');
|
|
|
|
+ ");
|
|
|
|
+ $this->view->printTimeSheetForm = $printTimeSheetForm;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ $this->view->printTimeSheetForm = $printTimeSheetForm;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ $this->view->printTimeSheetForm = $printTimeSheetForm;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
public function changeyear()
|
|
public function changeyear()
|
|
@@ -133,4 +157,173 @@ class reportsController extends Staple_Controller
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public function printpreview($year,$month,$uid)
|
|
|
|
+ {
|
|
|
|
+ $this->_setLayout('print');
|
|
|
|
+
|
|
|
|
+ $user = new userModel();
|
|
|
|
+ $account = $user->userInfo($uid);
|
|
|
|
+
|
|
|
|
+ $this->view->firstName = $account['firstName'];
|
|
|
|
+ $this->view->lastName = $account['lastName'];
|
|
|
|
+ $this->view->batchId = $account['batchId'];
|
|
|
|
+ $this->view->year = $year;
|
|
|
|
+ $this->view->month = date('F',$month);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $timesheet = new timesheetModel($year, $month,$uid);
|
|
|
|
+ $this->view->timesheet = $timesheet;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function payperiod($year = null, $month = null)
|
|
|
|
+ {
|
|
|
|
+ if ($year == null) {
|
|
|
|
+ $year = date('Y');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ($month == null) {
|
|
|
|
+ $month = date('m');
|
|
|
|
+ }
|
|
|
|
+ $this->view->year = $year;
|
|
|
|
+
|
|
|
|
+ $date = new DateTime();
|
|
|
|
+ $date->setDate($year,$month,26);
|
|
|
|
+ $date->setTime(0,0,0);
|
|
|
|
+ $this->view->month = $date->format('m');
|
|
|
|
+ $date->modify('-1 month');
|
|
|
|
+ $this->view->previousMonth = $date->format('m');
|
|
|
|
+
|
|
|
|
+ $date2 = new DateTime();
|
|
|
|
+ $date2->setDate($year,$month,25);
|
|
|
|
+ $date2->setTime(24,0,0);
|
|
|
|
+
|
|
|
|
+ $interval = date_diff($date,$date2);
|
|
|
|
+
|
|
|
|
+ $this->view->span = $interval->days;
|
|
|
|
+
|
|
|
|
+ $reports = new reportModel($year, $month);
|
|
|
|
+ $this->view->report = $reports->payPeriodTotals($year, $month);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function payperiodprint($year, $month)
|
|
|
|
+ {
|
|
|
|
+ if($year != null || $month != null)
|
|
|
|
+ {
|
|
|
|
+ $this->_setLayout('print');
|
|
|
|
+ $this->view->year = $year;
|
|
|
|
+
|
|
|
|
+ $date = new DateTime();
|
|
|
|
+ $date->setDate($year,$month,26);
|
|
|
|
+ $date->setTime(0,0,0);
|
|
|
|
+ $this->view->month = $date->format('m');
|
|
|
|
+ $date->modify('-1 month');
|
|
|
|
+ $this->view->previousMonth = $date->format('m');
|
|
|
|
+
|
|
|
|
+ $date2 = new DateTime();
|
|
|
|
+ $date2->setDate($year,$month,25);
|
|
|
|
+ $date2->setTime(24,0,0);
|
|
|
|
+
|
|
|
|
+ $interval = date_diff($date,$date2);
|
|
|
|
+
|
|
|
|
+ $this->view->span = $interval->days;
|
|
|
|
+
|
|
|
|
+ $reports = new reportModel($year, $month);
|
|
|
|
+ $this->view->report = $reports->payPeriodTotals($year, $month);
|
|
|
|
+ $this->view->startDate = $date->format("F jS Y");
|
|
|
|
+ $days = $interval->days - 1;
|
|
|
|
+ $date->modify("+$days days");
|
|
|
|
+ $this->view->endDate = $date->format("F jS Y");
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ header("location:".$this->_link(array('reports','payperiod'))."");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function payroll($year = null, $month = null)
|
|
|
|
+ {
|
|
|
|
+ if($year == null)
|
|
|
|
+ {
|
|
|
|
+ $year = date('Y');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if($month == null)
|
|
|
|
+ {
|
|
|
|
+ $month = date('m');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $this->view->year = $year;
|
|
|
|
+
|
|
|
|
+ $date = new DateTime();
|
|
|
|
+ $date->setDate($year,$month,26);
|
|
|
|
+ $date->setTime(0,0,0);
|
|
|
|
+ $this->view->month = $date->format('m');
|
|
|
|
+ $date->modify('-1 month');
|
|
|
|
+ $this->view->previousMonth = $date->format('m');
|
|
|
|
+
|
|
|
|
+ $date2 = new DateTime();
|
|
|
|
+ $date2->setDate($year,$month,25);
|
|
|
|
+ $date2->setTime(24,0,0);
|
|
|
|
+
|
|
|
|
+ $interval = date_diff($date,$date2);
|
|
|
|
+
|
|
|
|
+ $this->view->span = $interval->days;
|
|
|
|
+
|
|
|
|
+ $reports = new reportModel($year, $month);
|
|
|
|
+ $this->view->report = $reports->payroll($year, $month);
|
|
|
|
+ $this->view->startDate = $date->format("F jS Y");
|
|
|
|
+ $days = $interval->days - 1;
|
|
|
|
+ $date->modify("+$days days");
|
|
|
|
+ $this->view->endDate = $date->format("F jS Y");
|
|
|
|
+
|
|
|
|
+ $codes = new codeModel();
|
|
|
|
+ $this->view->codes = $codes->allCodes();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function payrollprint($year = null, $month = null)
|
|
|
|
+ {
|
|
|
|
+ if($year != null || $month != null) {
|
|
|
|
+ $this->_setLayout('print');
|
|
|
|
+ if ($year == null) {
|
|
|
|
+ $year = date('Y');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ($month == null) {
|
|
|
|
+ $month = date('m');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $this->view->year = $year;
|
|
|
|
+
|
|
|
|
+ $date = new DateTime();
|
|
|
|
+ $date->setDate($year, $month, 26);
|
|
|
|
+ $date->setTime(0, 0, 0);
|
|
|
|
+ $this->view->month = $date->format('m');
|
|
|
|
+ $date->modify('-1 month');
|
|
|
|
+ $this->view->previousMonth = $date->format('m');
|
|
|
|
+
|
|
|
|
+ $date2 = new DateTime();
|
|
|
|
+ $date2->setDate($year, $month, 25);
|
|
|
|
+ $date2->setTime(24, 0, 0);
|
|
|
|
+
|
|
|
|
+ $interval = date_diff($date, $date2);
|
|
|
|
+
|
|
|
|
+ $this->view->span = $interval->days;
|
|
|
|
+
|
|
|
|
+ $reports = new reportModel($year, $month);
|
|
|
|
+ $this->view->report = $reports->payroll($year, $month);
|
|
|
|
+ $this->view->startDate = $date->format("F jS Y");
|
|
|
|
+ $days = $interval->days - 1;
|
|
|
|
+ $date->modify("+$days days");
|
|
|
|
+ $this->view->endDate = $date->format("F jS Y");
|
|
|
|
+
|
|
|
|
+ $codes = new codeModel();
|
|
|
|
+ $this->view->codes = $codes->allCodes();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ header("location:".$this->_link(array('reports','payroll'))."");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|