function do_manage($is_show = "") { global $ttH; $err = ""; //update if (isset($ttH->input['do_action'])) { $up_id = isset($ttH->input["selected_id"]) ? $ttH->input["selected_id"] : array(); switch ($ttH->input["do_action"]) { case "do_edit": $arr_show_order = isset($ttH->post["show_order"]) ? $ttH->post["show_order"] : array(); $arr_is_focus = isset($ttH->post["is_focus"]) ? $ttH->post["is_focus"] : array(); $mess = $ttH->lang['global']['edit_success'] . " ID: <strong>"; $str_mess = ""; for ($i = 0; $i < count($up_id); $i++) { $dup = array(); $dup['show_order'] = $arr_show_order[$up_id[$i]]; $dup['is_focus'] = $arr_is_focus[$up_id[$i]]; $ok = $ttH->db->do_update("product_order", $dup, "order_id=" . $up_id[$i]); if ($ok) { $str_mess .= $str_mess ? ", " : ""; $str_mess .= $up_id[$i]; } else { $mess .= $ttH->lang["global"]['edit_false'] . " ID: <strong>" . $up_id[$i] . "</strong>"; } } $mess .= $str_mess . "</strong>"; $err = $ttH->html->html_alert($mess, "success"); break; case "do_restore": $up_id = isset($ttH->input["id"]) ? array($ttH->input["id"]) : $up_id; $mess = $ttH->lang['global']['restore_success'] . " ID: <strong>"; $str_mess = ""; for ($i = 0; $i < count($up_id); $i++) { $dup = array(); $dup['is_show'] = 1; $ok = $ttH->db->do_update("product_order", $dup, "order_id=" . $up_id[$i]); if ($ok) { $str_mess .= $str_mess ? ", " : ""; $str_mess .= $up_id[$i]; } else { $mess .= $ttH->lang["global"]['restore_false'] . " ID: <strong>" . $up_id[$i] . "</strong>"; } } $mess .= $str_mess . "</strong>"; $err = $ttH->html->html_alert($mess, "success"); break; case "do_trash": $up_id = isset($ttH->input["id"]) ? array($ttH->input["id"]) : $up_id; $mess = $ttH->lang['global']['trash_success'] . " ID: <strong>"; $str_mess = ""; for ($i = 0; $i < count($up_id); $i++) { $dup = array(); $dup['is_show'] = 0; $ok = $ttH->db->do_update("product_order", $dup, "order_id=" . $up_id[$i]); if ($ok) { $str_mess .= $str_mess ? ", " : ""; $str_mess .= $up_id[$i]; } else { $mess .= $ttH->lang["global"]['trash_false'] . " ID: <strong>" . $up_id[$i] . "</strong>"; } } $mess .= $str_mess . "</strong>"; $err = $ttH->html->html_alert($mess, "success"); break; case "do_del": if (isset($ttH->input['id'])) { $list_del = $ttH->input['id']; } elseif (isset($ttH->post['selected_id']) && is_array($ttH->post['selected_id'])) { $list_del = @implode(',', $ttH->post['selected_id']); } $err = $this->do_del($list_del); break; } } $p = isset($ttH->input["p"]) ? $ttH->input["p"] : 1; $search_date_begin = isset($ttH->input["search_date_begin"]) ? $ttH->input["search_date_begin"] : ""; $search_date_end = isset($ttH->input["search_date_end"]) ? $ttH->input["search_date_end"] : ""; $search_group_id = isset($ttH->input["search_group_id"]) ? $ttH->input["search_group_id"] : 0; $search_brand_id = isset($ttH->input["search_brand_id"]) ? $ttH->input["search_brand_id"] : 0; $search_title = isset($ttH->input["search_title"]) ? $ttH->input["search_title"] : ""; $where = " "; $ext = ""; $is_search = 0; if ($is_show == "trash") { $where .= " where is_show=0 "; } else { $where .= " where is_show=1 "; } if ($search_date_begin || $search_date_end) { $tmp1 = @explode("/", $search_date_begin); $time_begin = @mktime(0, 0, 0, $tmp1[1], $tmp1[0], $tmp1[2]); $tmp2 = @explode("/", $search_date_end); $time_end = @mktime(23, 59, 59, $tmp2[1], $tmp2[0], $tmp2[2]); $where .= " AND (date_create BETWEEN {$time_begin} AND {$time_end} ) "; $ext .= "&date_begin=" . $search_date_begin . "&date_end=" . $search_date_end; $is_search = 1; } if (!empty($search_group_id)) { $where .= " and find_in_set('" . $search_group_id . "', group_nav)>0 "; $ext .= "&search_group_id=" . $search_group_id; $is_search = 1; } if (!empty($search_brand_id)) { $where .= " and brand_id='" . $search_brand_id . "' "; $ext .= "&search_brand_id=" . $search_brand_id; $is_search = 1; } if (!empty($search_title)) { $where .= " and (a.order_id='{$search_title}' or title like '%{$search_title}%') "; $ext .= "&search_title=" . $search_title; $is_search = 1; } $num_total = 0; $res_num = $ttH->db->query("select order_id from product_order " . $where . " "); $num_total = $ttH->db->num_rows($res_num); $n = $ttH->conf["n_list"] ? $ttH->conf["n_list"] : 30; $num_products = ceil($num_total / $n); if ($p > $num_products) { $p = $num_products; } if ($p < 1) { $p = 1; } $start = ($p - 1) * $n; $link_action = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub); //Sort $arr_title = array("order_id" => array("title" => $ttH->lang["global"]["id"], "link" => $link_action . "&p=" . $p . $ext . "&sort=order_id-desc", "class" => ""), "show_order" => array("title" => $ttH->lang["global"]["show_order"], "link" => $link_action . "&p=" . $p . $ext . "&sort=show_order-desc", "class" => ""), "is_status" => array("title" => $ttH->lang["product"]["status_order"], "link" => $link_action . "&p=" . $p . $ext . "&sort=is_status-desc", "class" => ""), "d_full_name" => array("title" => 'Người nhận hàng', "link" => $link_action . "&p=" . $p . $ext . "&sort=d_full_name-desc", "class" => ""), "total_order" => array("title" => $ttH->lang["product"]["total_order"], "link" => $link_action . "&p=" . $p . $ext . "&sort=title-desc", "class" => ""), "date_create" => array("title" => $ttH->lang["global"]["date_create"], "link" => $link_action . "&p=" . $p . $ext . "&sort=date_create-desc", "class" => "")); $sort = isset($ttH->input["sort"]) ? $ttH->input["sort"] : ""; if ($sort) { $arr_allow_sort = array(1 => "asc", 2 => "desc"); $tmp = explode("-", $sort); if (array_key_exists($tmp[0], $arr_title) && in_array($tmp[1], $arr_allow_sort)) { $order_tmp = $tmp[0] == "order_id" ? "a.order_id" : $tmp[0]; $where .= " order by " . $order_tmp . " " . $tmp[1]; $arr_title[$tmp[0]]["class"] = $tmp[1]; $arr_title[$tmp[0]]["link"] = $link_action . "&p=" . $p . $ext . "&sort=" . $tmp[0] . "-" . $arr_allow_sort[3 - array_search($tmp[1], $arr_allow_sort)]; } else { $sort = ""; } } if ($sort == "") { $where .= " order by date_create DESC"; } //End sort //Title row foreach ($arr_title as $k => $v) { $class = $v["class"] ? " class='" . $v["class"] . "'" : ""; $data["f_" . $k] = '<a href="' . $v["link"] . '" ' . $class . '>' . $v["title"] . '</a>'; } //End title row $sql = "select * from product_order " . $where . " limit {$start},{$n}"; //echo $sql; $nav = $ttH->admin->admin_paginate($link_action, $num_total, $n, $ext, $p); $result = $ttH->db->query($sql); $i = 0; $html_row = ""; if ($num = $ttH->db->num_rows($result)) { while ($row = $ttH->db->fetch_row($result)) { $i++; $row["link_edit"] = $ttH->admin->get_link_admin($this->modules, $this->action, "edit", array("id" => $row['order_id'])); $row["link_trash"] = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub, array("do_action" => "do_trash", "id" => $row['order_id'])); $row["link_restore"] = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub, array("do_action" => "do_restore", "id" => $row['order_id'])); $row["link_del"] = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub, array("do_action" => "do_del", "id" => $row['order_id'])); $row["link_pic"] = $ttH->admin->get_link_admin($this->modules, $this->action . '_pic', 'manage', array("type" => "item", "type_id" => $row['order_id'])); if (!empty($row["picture"])) { $row["picture"] = '<a class="fancybox-effects-a" title="' . $row["picture"] . '" href="' . DIR_MOD_UPLOAD . $row["picture"] . '"> ' . $ttH->func->get_pic_mod('product/' . $row["picture"], 50, 50, '', 1, 0, array('fix_width' => 1)) . ' </a>'; } $row["status_order"] = status_order_info($row["is_status"]); $row['total_order'] = $ttH->func->get_price_format($row['total_order']); $row['date_create'] = date('H:i:s, d/m/Y', $row['date_create']); $ttH->temp_act->assign('row', $row); if ($is_show == "trash") { $ttH->temp_act->parse("manage.row_item.row_button_manage"); } else { $ttH->temp_act->parse("manage.row_item.row_button_trash"); } $ttH->temp_act->parse("manage.row_item"); } } else { $ttH->temp_act->assign('row', array("mess" => $ttH->lang["global"]["no_have_data"])); $ttH->temp_act->parse("manage.row_empty"); } $data['html_row'] = $html_row; $data['nav'] = $nav; $data['err'] = $err; $data['link_action_search'] = $link_action; $data['link_action'] = $link_action . "&p=" . $p . $ext; $data['search_date_begin'] = $search_date_begin; $data['search_date_end'] = $search_date_end; $data['search_title'] = $search_title; $data['form_search_class'] = $is_search == 1 ? ' expand' : ''; if ($is_show == "trash") { $ttH->temp_act->parse("manage.button_manage"); } else { $ttH->temp_act->parse("manage.button_trash"); } $ttH->temp_act->assign('data', $data); $ttH->temp_act->parse("manage"); return $ttH->temp_act->text("manage"); }
function manage_row($row) { global $ttH; $output = ''; if (!empty($row["picture"])) { $row["picture"] = '<a class="fancybox-effects-a" title="' . $row["picture"] . '" href="' . DIR_UPLOAD . $row["picture"] . '"> ' . $ttH->func->get_pic_mod($row["picture"], 50, 50, '', 1, 0, array('fix_width' => 1)) . ' </a>'; } $row['link'] = $ttH->site->get_link("user", $ttH->setting["user"]["ordering_link"], $row["order_code"]); $row["status_order"] = status_order_info($row["is_status"]); $row['total_order'] = $ttH->func->get_price_format($row['total_order']); $row['date_create'] = date('d/m/Y', $row['date_create']); $ttH->temp_act->assign('row', $row); $ttH->temp_act->parse("manage.row_item"); $output = $ttH->temp_act->text("manage.row_item"); $ttH->temp_act->reset("manage.row_item"); return $output; }