基本上我必须根据每个员工的每月出勤率来计算每个员工的每月膳食津贴,这只让我只有一张桌子,出勤表
餐补的计算很简单,我只需要计算员工参加了多少天,然后用一个数字计算(这个数字应该是动态的或可编辑的)
this is the example of the calculation:
number of attendance * 15.00 (editable number)
这是我的考勤表数据
----------------------------------------------------------------------------
| attendance_id | emp_code | emp_name | date | time_in | time_out |
| 1 | ALB | Albert | 2018.01.01 | 07.00 | 18.00 |
| 2 | GlN | GLENN | 2018.01.01 | 07.00 | 18.00 |
| 3 | ALB | Albert | 2018.01.02 | 07.00 | 18.00 |
| 4 | GLN | GLENN | 2018.01.02 | 07.00 | 18.00 |
| 5 | ALB | Albert | 2018.01.04 | 07.00 | 18.00 |
| 6 | GLN | GLENN | 2018.01.04 | 07.00 | 18.00 |
----------------------------------------------------------------------------
到目前为止,我已经设法计算了每月回顾(通过计算他们参加了多少天),这是我目前的情况:
------------------------------------------------
| emp_code | emp_name | days_attended |
| ALB | Albert | 3 |
| GLN | GLENN | 3 |
-------------------------------------------------
这是我的控制器
public function index(){
$this->load->model('allowance_m');
$data['query'] = $this->allowance_m->calculate();
$this->load->vars($data);
$this->load->view('allowance_v',$data);
}
这是我的模型(allowance_m.php)
public function hitungabsen()
{
$this->db->select('attendance_id,emp_code,emp_name, COUNT(date) as days_attended');
$this->db->from('attendance');
$this->db->group_by('emp_code');
$query = $this->db->get();
return $query->result();
}
这是我的观点allowance_v.php
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th><center>Employee Code</center></th>
<th><center>Employee Name</center></th>
<th><center>Days Attended</center></th>
</tr>
</thead>
<?php
$no = 1;
foreach($query as $row){
?>
<tr>
<td><?php echo $row->emp_code ?></td>
<td><?php echo $row->emp_name ?></td>
<td><?php echo $row->days_attended ?></td>
</tr>
<?php } ?>
</table>
现在我真的需要知道如何计算输入的参加天数的膳食津贴,计算结果后,我需要将结果插入数据库,以便我可以制作一个 pdf 报告。结果应该是这样的:
------------------------------------------------------------------------
| emp_code | emp_name | days_attended | meal allowance |
| ALB | Albert | 3 |(automaticaly updated) |
| GLN | GLENN | 3 |(automaticaly updated) |
------------------------------------------------------------------------
先感谢您!真的需要尽快得到答案,这对我来说意义重大