【发布时间】:2018-01-24 03:01:28
【问题描述】:
我正在制作一个 OffDayWork 表单,我希望每个员工最多只能申请 12 次休假。我使用this 作为我的参考,但它仍然没有工作。
这是我的结构表:
- tabel_cuti
holID | holEmpId | holName |
---------------------------|
1 | 1 | Ied |
---------------------------|
2 | 3 | exp1 |
---------------------------|
3 | 4 | exp2 |
---------------------------|
4 | 1 | Married |
---------------------------|
我在我的模型中尝试过这个
-
员工模型
public function HolidayRegister($data) { $this->db->insert('tbl_cuti',$data); return true; } public function HitungCuti($data) { $this->db->select('count(table_cuti.holID) as countcuti'); $this->db->from('tabel_cuti'); $this->db->join('tabel_pegawai','tabel_cuti.holEmpId = tabel_pegawai.empID'); $this->db->group_by('table_cuti.holEmpId'); $totalhol = $this->db->get(); }
还有我的控制者(员工)
public function HolidayRegister()
{
if(!empty($_POST))
{
$data = array('holEmpId' => $this->input->post('employee_id'),
'holName' => $this->input->post('holiday_name'),
'holDate' => $this->input->post('holiday_date'),
'holDescription' => $this->input->post('description'),
'created_date' => date('Y-m-d H:i:s'),
);
$result = $this->EmployeeModel->HitungCuti($data);
if($result -> num_rows() < 12)
{
$this->EmployeeModel->HolidayRegister($data);
}
else
{
$data = array('holEmpId' => $this->input->post('employee_id'),
'holName' => $this->input->post('holiday_name'),
'holDate' => $this->input->post('holiday_date'),
'holDescription' => $this->input->post('description'),
'created_date' => date('Y-m-d H:i:s'),
);
$this->session->set_flashdata('SUCCESSMSG','Tidak ada kesempatan cuti');
$data['getEmployee'] = $this->EmployeeModel->getEmployee();
$this->load->view('holiday_register',$data);
}
}
else
{
$this->session->set_flashdata('SUCCESSMSG', "Holiday Register Successfully!!");
redirect('view-holiday');
}
}
这是我第一次尝试 CI,所以我需要你的帮助。
【问题讨论】:
-
解决了吗??
-
@AbdullaNilam 还没有,有什么建议吗?
标签: php mysql codeigniter