c
This commit is contained in:
102
data/product/category.php
Normal file
102
data/product/category.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
use Hura8\Components\Product\AdminController\AProductCategoryController;
|
||||
|
||||
$objAProductCategoryController = new AProductCategoryController();
|
||||
|
||||
$category_collection = $objAProductCategoryController->getAllParent();
|
||||
|
||||
return [
|
||||
'category_list' => get_category_list(0, getRequest("id"), $level=1, $prefix="", $category_collection )
|
||||
];
|
||||
|
||||
|
||||
function get_category_list($parentId=0, $currentCat="",$level=1, $prefix="", $category_collection = array()){
|
||||
|
||||
$categoryTree = "";
|
||||
$extra_space = "";
|
||||
for($i = 1; $i < $level; $i++){
|
||||
$extra_space .= " ";
|
||||
}
|
||||
|
||||
$stt = 0;
|
||||
if(isset($category_collection[$parentId])) {
|
||||
|
||||
foreach($category_collection[$parentId] as $index => $cat_info){
|
||||
$cat_id = $cat_info['id'];
|
||||
|
||||
$stt ++;
|
||||
$imgUrl = (strlen($cat_info["thumbnail"]) > 2) ? " <img src=\"".$cat_info["thumbnail"]."\" style=\"max-width:30px; max-height:30px;\" />" : "";
|
||||
|
||||
if($cat_info["status"]) $status = "<a href=\"javascript:update_status(".$cat_id.",'off')\">Hạ xuống</a>";
|
||||
else $status = "<a href=\"javascript:update_status(".$cat_id.",'on')\" style=\"background-color:#FFCC00;\">Hiển thị</a>";
|
||||
|
||||
$edit_link ="/admin/product/category-form?id=".$cat_id;
|
||||
|
||||
$hide_this = ($parentId > 0) ? "style='display: none;'" : '';
|
||||
|
||||
$show_category_name = $cat_info["title"];
|
||||
|
||||
if(!IS_DEFAULT_LANGUAGE && isset($cat_info["not_translated"]) && $cat_info["not_translated"]) {
|
||||
$show_category_name = "<span style='color: red'>[Chưa dịch]</span> ".$cat_info["title"];
|
||||
}
|
||||
|
||||
if($cat_info['is_parent']) {
|
||||
$show_category_name = "<a href=\"javascript:;\" onclick=\"RowExpand.open_child('parent_".$cat_id."')\">".$show_category_name."</a>";
|
||||
}
|
||||
|
||||
$categoryTree .= "
|
||||
<tr id='row_".$cat_id."' class='parent_".$parentId." row' ". $hide_this ."
|
||||
onmouseover=\"this.className='row-hover parent_".$parentId."'\" onmouseout=\"this.className='parent_".$parentId."'\">
|
||||
|
||||
<td>".$cat_id."</td>
|
||||
|
||||
<td>
|
||||
<a name='cat_".$cat_id."'></a>
|
||||
". $extra_space . $prefix . $stt.". ". $show_category_name . $imgUrl."
|
||||
</td>
|
||||
|
||||
<td>".$cat_info['item_count']." - <a href='/admin/product?category=".$cat_id."'>Xem</a></td>
|
||||
|
||||
<td>
|
||||
<a href='".$cat_info['request_path']."' title='Mở tại website' target='_blank'>Web</a>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<input type=text id=order_".$cat_id." value='".$cat_info["ordering"]."' size=2 onchange=\"update_order(".$cat_id.",this.value)\" />
|
||||
<span class='status-ordering-".$cat_id."'></span>
|
||||
</td>
|
||||
";
|
||||
|
||||
if(IS_DEFAULT_LANGUAGE) {
|
||||
$categoryTree .= "
|
||||
<td>
|
||||
<a href='/admin/product/category-attribute?id=".$cat_id."&popup=1' class='pop-up'>Thuộc tính</a> (".$cat_info['attribute_count'].")
|
||||
</td>
|
||||
<td>
|
||||
<span id=status-".$cat_id.">".$status."</span> |
|
||||
<a href=\"".$edit_link."\">Sửa lại</a> |
|
||||
<span class='status-delete-".$cat_id."'><a href=\"javascript:deleteThis(".$cat_id.")\">Xóa</a></span>
|
||||
</td>
|
||||
";
|
||||
|
||||
}else{
|
||||
$categoryTree .= "
|
||||
<td>
|
||||
<a href=\"".$edit_link."\">Sửa lại</a>
|
||||
</td>
|
||||
";
|
||||
}
|
||||
|
||||
$categoryTree .= "
|
||||
</tr>
|
||||
";
|
||||
|
||||
if($cat_info["is_parent"]) $categoryTree .= get_category_list($cat_id, $currentCat, $level + 1, $prefix . $stt.".", $category_collection);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $categoryTree;
|
||||
}
|
||||
|
||||
18
data/product/category_form.php
Normal file
18
data/product/category_form.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
|
||||
use Hura8\Components\Product\AdminController\AProductCategoryController;
|
||||
|
||||
$objAProductCategoryController = new AProductCategoryController();
|
||||
|
||||
|
||||
$id = (int) getRequest("id");
|
||||
$item_info = ($id > 0) ? $objAProductCategoryController->getFullInfo($id) : null;
|
||||
if(!$item_info) $item_info = $objAProductCategoryController->getEmptyInfo([]);
|
||||
|
||||
|
||||
return [
|
||||
'item_info' => $item_info,
|
||||
'categoryDropBox' => $objAProductCategoryController->getDropBox( $item_info['parent_id'], 0, 1),
|
||||
'update_status' => getRequest("us"),
|
||||
];
|
||||
Reference in New Issue
Block a user