public function onLoad($param) { parent::onLoad($param); if (!$this->isPostBack) { $app = $this->getApplication(); $usedId = $app->getUser()->getUserID() == null ? 0 : $app->getUser()->getUserID(); $cmd = $this->db->createCommand("SELECT user_id FROM hr_superusers WHERE id={$usedId}"); $data = $cmd->query(); $dataUser = $data->read(); $userId = $dataUser['user_id']; $employee = new employee($userId); $role = $employee->getRole(); if ($role == 'employee' && $userId != $this->Request['userId']) { $this->Response->redirect($this->Service->constructUrl($this->Request['back'])); } $this->employee->DataSource = $this->PersonList; $this->employee->dataBind(); if ($this->employee->getItemCount() && $this->employee->getSelectedValue() == '') { $this->employee->setSelectedIndex(0); } $this->timecode->DataSource = $this->TimeCodeList; $this->timecode->dataBind(); $this->timecode->setEnabled(false); if (isset($this->Request['date'])) { $this->date->Text = $this->Request['date']; } if (isset($this->Request['userId'])) { $this->employee->setSelectedValue($this->Request['userId']); } } }
public function getDepartmentList() { $employee = new employee($this->userId); $role = $employee->getRole(); $department = $employee->getDepartmentId(); $cmd = NULL; if ($role == 'manager' || $role == 'employee') { $cmd = $this->db->createCommand("SELECT name AS Text, id AS Value FROM hr_department WHERE id={$department}"); } else { $cmd = $this->db->createCommand("SELECT name AS Text, id AS Value FROM hr_department ORDER BY name"); } $data = $cmd->query(); $data = $data->readAll(); if ($role == 'rh') { $dataAll[] = array("Value" => 0, "Text" => Prado::localize("--- All ---")); $data = array_merge($dataAll, $data); } return $data; }