|
|
|
สร้าง Group 2 Group ใน ตาราง group ที่ 2 ไม่ยอม group ตามที่ได้กำหนดไว้ |
|
|
|
|
|
|
|
อยากให้ตารางมันออกมาเป็นแบบนี้
แต่พอทำแล้วตารางมันกลับออกมาเป็นแบบนี้อ่ะค่ะ Group ในคอลัมน์ที่ 2 ไม่ยอม Group ตามที่ต้องการ ออกมาแค่ group เดียว ต้องแก้โค๊ดยังไงดีค่ะ
โค๊ด
Code (PHP)
public function product() {
error_reporting(0);
$response = array();
$this->load->library("table_component_custom");
$report_data = $this->report_query_model3->get_data_product($this->input->post(), $this->input->post("start_record"), $this->page_limit);
if ($report_data != false) {
$header = array("กลุ่ม","ประเภท","รหัส", "ราคา", "จำนวน");
$align = array( "center" ,"center", "left", "right", "right");
$width = array( "150", "200", "400", "150", "150");
$row_count = $this->report_pagging_model2->get_count_product($this->input->post());
$paging_data = $this->pager_model->get_paging_data($row_count, $this->input->post("txtreportcode"), $this->page_limit);
$this->table_component->set_alignment($align);
$this->table_component->set_column_width($width);
$this->table_component_custom->set_table_header($header);
$this->table_component->set_table_content($report_data);
$group_dataz = group_array($report_data, "Protype");
$group_datay = group_array($report_data, "ProGroup");
#sum total
$Sum_sum_ProCount = 0;
$Sum_sum_ProPrice = 0;
foreach ($group_datay as $index => $row) {
#row total
$sum_ProCount = 0;
$sum_ProPrice = 0;
$current_num_row = count($row) + 1;
$rowspan = ' rowspan="' . $current_num_row . '" ';
$Protype= $row[0]["Protype"];
$ProGroup = $row[0]["ProGroup"];
foreach ($row as $step => $value) {
$sum_ProCount += str_replace(",", "", $value["ProCount"]);
$sum_sum_ProPrice+= str_replace(",", "", $value["ProPrice"]);
if ($step == 0) {
$this->table_component_custom->append_content(
'<tr class="content-font">
<td height="25" bgcolor="#ffffff" align="center" ' . $rowspan . '> ' .$ProGroup . '</td>
<td height="25" bgcolor="#ffffff" align="center" ' . $rowspan . '>' . $Protype . '</td>
<td height="25" bgcolor="#ffffff" align="left"> ' . $value["ProID"] . '</td>
<td height="25" bgcolor="#ffffff" align="right" > ' . number_format(str_replace(",", "", $value["ProCount"]), 0) . ' </td>
<td height="25" bgcolor="#ffffff" align="right" > ' . number_format(str_replace(",", "", $value["ProPrice"]), 2) . ' </td>
</tr>'
);
} else {
$this->table_component_custom->append_content(
'<tr class="content-font">
<td height="25" bgcolor="#ffffff" align="left"> ' . $value["ProID"] . '</td>
<td height="25" bgcolor="#ffffff" align="right" > ' . number_format(str_replace(",", "", $value["ProCount"]), 0) . ' </td>
<td height="25" bgcolor="#ffffff" align="right" > ' . number_format(str_replace(",", "", $value["ProCount"]), 2) . ' </td>
</tr>'
);
}
$rowspan = "";
}
$Sum_sum_ProPrice += $sum_ProPrice;
$Sum_sum_ProCount += $sum_ProCount;
$this->table_component_custom->append_content(
'<tr class="content-font">
<td height="25" bgcolor="#eeeeee" align="center" colspan="1">รวมประเภท ' . $Protype . '</b></td>
<td height="25" bgcolor="#ffffff" align="right"><b>' . number_format($sum_ProCount, 0) . '</b> </td>
<td height="25" bgcolor="#ffffff" align="right"><b>' . number_format($sum_DiscountPrice, 2) . '</b> </td>
</tr>'
);
$this->table_component_custom->append_content(
'<tr class="content-font">
<td height="25" bgcolor="#eeeeee" align="center" colspan="3"> <b>รวมกลุ่ม ' . $ProGroup . '</b></td>
<td height="25" bgcolor="#ffffff" align="right"><b>' . number_format($sum_ProCount, 0) . '</b> </td>
<td height="25" bgcolor="#ffffff" align="right"><b>' . number_format($sum_ProPrice, 2) . '</b> </td>
</tr>'
);
$Sum_sum_ProCount += $sum_ProCount;
$Sum_sum_ProPrice += $sum_ProPrice;
}
foreach ( $report_data as $val){
$ProCount=$ProCount+$val["ProCount"] ;
$ProPrice=$ProPrice+$val["ProPrice"] ;
}
$this->table_component_custom->append_content(
'<tr class="content-font">
<td height="25" bgcolor="#eeeeee" align="center" colspan="3"> <b>รวมทั้งหมด</b></td>
<td height="25" bgcolor="#eeeeee" align="center"><b>' . number_format($ProCount, 0) . '</b> </td>
<td height="25" bgcolor="#eeeeee" align="right"><b>' . number_format($ProPrice, 2) . '</b> </td>
</tr>'
);
}
//number_format($avg_lf_all,2 ) . ":" .
$response['content'] = $this->table_component_custom->get_table();
//$response['pager'] = $this->load->view("report/pager_view", $paging_data, true);
echo encode_ajax_data($response);
} else {
$response['content'] = "ไม่พบข้อมูลในช่วงเวลาดังกล่าว";
$response['pager'] = "";
echo encode_ajax_data($response);
}
}
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2013-12-02 09:44:17 |
By :
RKkh |
View :
799 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่มีโค้ดนะครับ แต่จะบอกมาถูกทางแล้วครับ ลองเช็คค่า การบวก ของแต่และช่วงดีดี คงมีผิดพลาด....เล็กน้อย
|
|
|
|
|
Date :
2013-12-02 19:02:11 |
By :
apisitp |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|