function listCatTable($items, $space = '', $parent = 0) { //$menu_obj = new category(); $table_html = ''; if ($parent == 0) { $space = ''; } else { $space .= "- "; } foreach ($items as $item) { if ($item['parent_id'] == $parent) { $table_html .= "<tr>"; $table_html .= "<td>" . $space . $item['cat_name'] . "</td>"; $table_html .= '<td class="numeric" align="center">' . $item['position'] . "</td>"; $table_html .= ' <form action=" ' . asset('admin/delete-cat') . ' " method="post"> <td class="numeric">'; $table_html .= "<a href=" . route('sendIdCat', [$item->cat_id]) . " class='btn default btn-xs purple'><i class='fa fa-edit'></i>Sửa</a>\n </td>"; $table_html .= '<td class="numeric"> <input type="hidden" name="id" value=" ' . $item->cat_id . ' " /> <input type="submit" value="Xóa" /></a></td> </form> </tr>'; $table_html .= listCatTable($items, $space, $item['cat_id']); } } return $table_html; }
function listCatTable($items, $space = '', $parent = 0) { //$menu_obj = new category(); $table_html = ''; if ($parent == 0) { $space = ''; } else { $space .= "- "; } foreach ($items as $item) { if ($item['parent_id'] == $parent) { $table_html .= "<tr>"; $table_html .= "<td>" . $space . $item['cat_name'] . "</td>"; $table_html .= '<td class="numeric" align="center">' . $item['position'] . "</td>"; $table_html .= ' <form action="control/proccess-cat.php" method="post"> <td class="numeric">'; $table_html .= '<a href="index.php?view=form-cat&act=update&id=' . $item['cat_id'] . '" class="btn default btn-xs purple"><i class="fa fa-edit"></i> Sửa</a></td>'; $table_html .= '<td class="numeric"> <input type="hidden" name="act" value="xoa" /> <input type="hidden" name="id" value="' . $item['cat_id'] . '" /> <input type="hidden" name="parent_id" value="' . $item['parent_id'] . '" /> <input onclick="return confirmBox()" type="submit" value="Xóa" /></a></td> </form> </tr>'; $table_html .= listCatTable($items, $space, $item['cat_id']); } } return $table_html; }