1
我想創建員工在日曆表視圖中作爲附加圖像的離開報告。TinyButStrong創建動態<th>與動態<tr>和循環問題
我有來自控制器取出僱員,並存儲在和陣列。
同樣的方式我提取日期(基於選定的年份和月份)在控制器中並存儲在一個數組中。
基於此員工和日期,我正在獲取每個員工的葉子並將其存儲在數組中。
控制器
$month = 7;
$year = 2015;
for($d=1; $d<=31; $d++)//for dynamic dates as displayed in image
{
$time=mktime(12, 0, 0, $month, $d, $year);
if (date('m', $time)==$month)
$this->data['blk4'][]['date']=date('d', $time);
$this->data['blk5'][]['day']=date('D', $time);
$this->data['blk6'][]['fulldates']=date('Y-m-d',$time);
}
$data['employee'] = $this->teamprofile_model->allTeamMembers('team_profile_full_name', 'ASC');//fetching all amployee
foreach($data['employee'] as $d)//for each employee checking the leave
{
foreach($this->data['blk6'] as $date)//for each date
{
$this->db->where('employee_id',$d['team_profile_id']);
$this->db->where('leave_date',$date['dates']);
$Q=$this->db->get('leave_reports');
if($Q->num_rows() > 0)
{
foreach ($Q->result_array() as $row)
{
$data1[] = $row;
}
}
$this->data['blk8'][]['leave'] = $data1[0]['leave_time'];//stored leave of each employee in this array
$data1="";
}
}
HTML
<table class="footable table table-bordered table-hover" border="1">
<thead>
<tr>
<th>Employee</th>//display employee
<th><!--[blk4.date;block=th;comm]--><br/><!--[blk5.day;block=th;comm]--></th> //display dates as displying in above image
</tr>
</thead>
<tbody class="">
<tr>
<td><!--[blk7.all_team_members;block=tr;comm]--></td>//dynamic employee list
<td>here i want to display the leave stored in [blk8.leave]</td>
</tr>
</tbody>
</table>
但問題是,[blk8.leave]存儲所有員工離開每個日期的,如果我打印爲[blk8 .leave; block = td; comm]然後它將所有數組值打印在一行中。我想打破這陣一個月的結束日期是31
輸出應該是:
嘿非常感謝兄弟非常感謝。但我有一個疑問,那就是HTML代碼是什麼?這裏我想顯示假期小時商店在$ blk7 –
我已經在$ $ this-> data ['blk7'] [] ['leave'] = $ employee; **在HTML中,我寫了** <! - [blk7.leave.all_team_members; block = tr; comm] - > **顯示員工姓名及其作品。但是leave_date是數組的動態元素,所以如何在HTML頁面中寫下休假時間。 –
嘿,我已經完成了。我在html中代替休假時間寫** <! - [blk7.leave.leavetime_ [blk6.dates; block = td;]; block = td; comm] - > **。再次感謝兄弟:) –