function do_add_menu() { global $ttH; $include_js = $ttH->func->include_js($ttH->dir_temp . 'js/' . $this->modules . '/' . $this->modules . '.js'); $cur_group = isset($ttH->input['group_id']) ? $ttH->input['group_id'] : 'menu_header'; $temp = 'menu_add'; $name_action = isset($ttH->get['name_action']) ? $ttH->get['name_action'] : ''; $link_action = $ttH->admin->get_link_admin_popup('layout', 'menu', 'add_menu', array("name_action" => $name_action)); $arr_name_action = explode(',', $name_action); $data = array(); $arr_isset = array('group_id', 'parent_id', 'link_type', 'target'); foreach ($arr_isset as $tmp) { $data[$tmp] = isset($data[$tmp]) ? $data[$tmp] : ''; } $data['include_js'] = $include_js; $data["name_action"] = $name_action; $data["link_action"] = $link_action; //$data["list_group"] = list_group ("group_id", $cur_group, " class=\"form-control\" onchange=\"window.location.href='".$data["link_action"]."&group_id='+this.value;\""); $data["list_group"] = list_group("group_id", $cur_group, " class=\"form-control\" id=\"menu_group_id\" data-menu_list=\"menu_parent_id\""); //$data['group_name'] = $ttH->data["menu_group"][$cur_group]; $data["list_menu"] = list_menu($cur_group, "parent_id", $data['parent_id'], " class=\"form-control\" id=\"menu_parent_id\"", array("title" => $ttH->lang['global']['select_title'])); $ttH->temp_act->assign('data', $data); $ttH->temp_act->parse($temp); return $ttH->temp_act->text($temp); }
function count_group() { return count(list_group()); }
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(); $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]]; $ok = $ttH->db->do_update("menu", $dup, "menu_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("menu", $dup, "menu_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("menu", $dup, "menu_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; $group_id = $this->cur_group; $date_begin = isset($ttH->input["date_begin"]) ? $ttH->input["date_begin"] : ""; $date_end = isset($ttH->input["date_end"]) ? $ttH->input["date_end"] : ""; $search = isset($ttH->input["search"]) ? $ttH->input["search"] : "id"; $keyword = isset($ttH->input["keyword"]) ? $ttH->input["keyword"] : ""; $where = " "; $ext = ""; if ($is_show == "trash") { //$where .= " AND is_show=0 "; } else { $where .= " AND is_show=1 "; } if (!empty($group_id)) { $where .= " and group_id='" . $group_id . "' "; $ext .= "&group_id=" . $group_id; } if ($date_begin || $date_end) { $tmp1 = @explode("/", $date_begin); $time_begin = @mktime(0, 0, 0, $tmp1[1], $tmp1[0], $tmp1[2]); $tmp2 = @explode("/", $date_end); $time_end = @mktime(23, 59, 59, $tmp2[1], $tmp2[0], $tmp2[2]); $where .= " AND (date_add BETWEEN {$time_begin} AND {$time_end} ) "; $ext .= "&date_begin=" . $date_begin . "&date_end=" . $date_end; } if (!empty($keyword)) { switch ($search) { case "id": $where .= " and id = {$keyword} "; break; default: $where .= " and {$search} like '%{$keyword}%' "; break; } $ext .= "&search=" . $search . "&keyword=" . $keyword; } $num_total = 0; $res_num = $ttH->db->query("select a.menu_id \n\t\t\t\t\t\tfrom menu a, menu_lang al \n\t\t\t\t\t\twhere a.menu_id=al.menu_id \n\t\t\t\t\t\tand parent_id=0 \n\t\t\t\t\t\tand lang='" . $ttH->conf["lang_cur"] . "' \n\t\t\t\t\t\t" . $where . " "); $num_total = $ttH->db->num_rows($res_num); $n = $ttH->conf["n_list"] ? $ttH->conf["n_list"] : 30; $num_menus = ceil($num_total / $n); if ($p > $num_menus) { $p = $num_menus; } 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("name_action" => array("title" => $ttH->lang["global"]["name_action"], "link" => $link_action . "&p=" . $p . $ext . "&sort=name_action-desc", "class" => ""), "show_order" => array("title" => $ttH->lang["global"]["show_order"], "link" => $link_action . "&p=" . $p . $ext . "&sort=show_order-desc", "class" => ""), "title" => array("title" => $ttH->lang["global"]["title"], "link" => $link_action . "&p=" . $p . $ext . "&sort=title-desc", "class" => ""), "link" => array("title" => $ttH->lang["global"]["link"], "link" => $link_action . "&p=" . $p . $ext . "&sort=link-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] == "menu_id" ? "a.menu_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 show_order desc, date_create asc"; } //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 menu a, menu_lang al \n\t\t\t\t\t\twhere a.menu_id=al.menu_id \n\t\t\t\t\t\tand lang='" . $ttH->conf["lang_cur"] . "' \n\t\t\t\t\t\tand parent_id=0 \n\t\t\t\t\t\t" . $where . " \n\t\t\t\t\t\tlimit {$start},{$n}"; //echo $sql; $nav = $ttH->admin->admin_paginate($link_action, $num_total, $n, $ext, $p); $result = $ttH->db->query($sql); $i = 0; $data['row_item'] = ''; $html_row = ""; if ($num = $ttH->db->num_rows($result)) { while ($row = $ttH->db->fetch_row($result)) { $i++; $data['row_item'] .= $this->manage_row($row, $is_show); $data['row_item'] .= $this->manage_sub($row['menu_id'], $where, $is_show); } } 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['date_begin'] = $date_begin; $data['date_end'] = $date_end; //$data["list_search"] = list_search_domain ("search", $search); $data['keyword'] = $keyword; $data["list_group"] = list_group("group_id", $group_id, " class=\"form-control\" onchange=\"window.location.href='" . $link_action . "&group_id='+this.value;\""); 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"); }
$nb_pret = 0; $requete = "SELECT count( pret_idempr ) as nb_pret FROM empr_groupe,pret where groupe_id={$rgroup->id_groupe} and empr_id = pret_idempr"; $res_pret = pmb_mysql_query($requete, $dbh); if (pmb_mysql_num_rows($res_pret)) { $rpret = pmb_mysql_fetch_object($res_pret); $nb_pret = $rpret->nb_pret; } $nb_resa = 0; $requete = "SELECT count( resa_idempr ) as nb_resa FROM empr_groupe,resa where groupe_id={$rgroup->id_groupe} and empr_id = resa_idempr"; $res_resa = pmb_mysql_query($requete, $dbh); if (pmb_mysql_num_rows($res_resa)) { $rresa = pmb_mysql_fetch_object($res_resa); $nb_resa = $rresa->nb_resa; } $tr_javascript = " onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='{$pair_impair}'\" onmousedown=\"document.location='./circ.php?categ=groups&action=showgroup&groupID={$rgroup->id_groupe}';\" "; $group_list .= "<tr class='{$pair_impair}' {$tr_javascript} style='cursor: pointer'>\n\t\t \t\t\t<td>{$rgroup->libelle_groupe}</td>\n\t\t\t\t\t<td>{$rgroup->resp_name}</td>\n\t\t\t\t\t<td>{$rgroup->nb_empr}</td>\n\t\t\t\t\t<td>{$nb_pret}</td>\n\t\t\t\t\t<td>{$nb_resa}</td>\n\t\t\t\t\t</tr>"; } pmb_mysql_free_result($res); $nav_bar = aff_pagination("{$PHP_SELF}?categ=groups&action=listgroups", $nbr_lignes, $nb_per_page, $page, 10, false, true); // affichage du résultat list_group($group_query, $filter_list, $group_list, $nav_bar, $nbr_lignes); } else { $rgroup = $rgroup = pmb_mysql_fetch_object($res); $groupID = $rgroup->id_groupe; include './circ/groups/show_group.inc.php'; } } else { // la requête n'a produit aucun résultat print pmb_bidi($group_search); error_message($msg[917], str_replace('!!group_cle!!', htmlentities(stripslashes($group_query), ENT_QUOTES, $charset), $msg[918]), 0, './circ.php?categ=groups'); }
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'] = isset($arr_is_focus[$up_id[$i]]) ? $arr_is_focus[$up_id[$i]] : 0; $ok = $ttH->db->do_update("video", $dup, "item_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("video", $dup, "item_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("video", $dup, "item_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_title = isset($ttH->input["search_title"]) ? $ttH->input["search_title"] : ""; $where = " "; $ext = ""; $is_search = 0; if ($is_show == "trash") { $where .= " AND is_show=0 "; } else { $where .= " AND 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 group_id='" . $search_group_id . "' "; $ext .= "&search_group_id=" . $search_group_id; $is_search = 1; } if (!empty($search_title)) { $where .= " and (a.item_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 a.item_id \r\r\n\t\t\t\t\t\tfrom video a, video_lang al \r\r\n\t\t\t\t\t\twhere a.item_id=al.item_id \r\r\n\t\t\t\t\t\tand lang='" . $ttH->conf["lang_cur"] . "' \r\r\n\t\t\t\t\t\t" . $where . " "); $num_total = $ttH->db->num_rows($res_num); $n = $ttH->conf["n_list"] ? $ttH->conf["n_list"] : 30; $num_pages = ceil($num_total / $n); if ($p > $num_pages) { $p = $num_pages; } 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("item_id" => array("title" => $ttH->lang["global"]["id"], "link" => $link_action . "&p=" . $p . $ext . "&sort=item_id-desc", "class" => ""), "show_order" => array("title" => $ttH->lang["global"]["show_order"], "link" => $link_action . "&p=" . $p . $ext . "&sort=show_order-desc", "class" => ""), "title" => array("title" => $ttH->lang["global"]["title"], "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] == "item_id" ? "a.item_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 video a, video_lang al \r\r\n\t\t\t\t\t\twhere a.item_id=al.item_id \r\r\n\t\t\t\t\t\tand lang='" . $ttH->conf["lang_cur"] . "' \r\r\n\t\t\t\t\t\t" . $where . " \r\r\n\t\t\t\t\t\tlimit {$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['item_id'])); $row["link_trash"] = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub, array("do_action" => "do_trash", "id" => $row['item_id'])); $row["link_restore"] = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub, array("do_action" => "do_restore", "id" => $row['item_id'])); $row["link_del"] = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub, array("do_action" => "do_del", "id" => $row['item_id'])); 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'] = (isset($ttH->data["modules"][$this->modules]["arr_friendly_link"][$ttH->conf['lang_cur']])) ? $ttH->data["modules"][$this->modules]["arr_friendly_link"][$ttH->conf['lang_cur']] : ''; $row['link'] .= '/'.$row["friendly_link"].'.html';*/ $row['link'] = $row["friendly_link"] . '.html'; $row['group_name'] = get_group_name($row['group_id']); $row['is_focus_checked'] = $row['is_focus'] == 1 ? ' checked="checked"' : ''; $row['date_create'] = date('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["list_group_search"] = list_group("search_group_id", $search_group_id, " class=\"form-control\"", array("title" => $ttH->lang['global']['select_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 do_add_menu() { global $ttH; $cur_group = isset($ttH->input['group_id']) ? $ttH->input['group_id'] : 'menu_header'; $temp = 'menu_add'; $name_action = isset($ttH->get['name_action']) ? $ttH->get['name_action'] : ''; $link_action = $ttH->admin->get_link_admin_popup('layout', 'menu', 'add_menu', array("name_action" => $name_action)); $tmp = explode('-', $name_action); $table = $tmp[1] != 'item' ? $tmp[0] . '_' . $tmp[1] : $tmp[0]; $table_key = $tmp[1] . '_id'; $table_id = $tmp[2]; $sql = "select * from " . $table . " a, " . $table . "_lang al \r\r\n\t\t\t\t\t\twhere a." . $table_key . "=al." . $table_key . " \r\r\n\t\t\t\t\t\tand lang='" . $ttH->conf['lang_cur'] . "' \r\r\n\t\t\t\t\t\tand a." . $table_key . "='" . $table_id . "'"; $result = $ttH->db->query($sql); if ($table_info = $ttH->db->fetch_row($result)) { } $data = array(); $err = ""; if (isset($ttH->post['do_submit'])) { /*print_arr($ttH->post); die();*/ $name_action = $ttH->func->get_friendly_link($ttH->post["name_action"]); if (empty($ttH->post["title"])) { $err = $ttH->html->html_alert($ttH->lang["global"]["err_invalid_title"], "error"); } if (empty($err)) { $col = array(); $col["group_id"] = $cur_group; $col["parent_id"] = $ttH->post["parent_id"]; $col["name_action"] = $name_action; $col["target"] = $ttH->post["target"]; $col["show_mod"] = isset($ttH->post["show_mod"]) ? get_input_show($ttH->post["show_mod"]) : ""; $col["show_act"] = isset($ttH->post["show_act"]) ? get_input_show($ttH->post["show_act"]) : ""; $col["show_order"] = 0; $col["is_show"] = 1; $col["date_create"] = time(); $col["date_update"] = time(); $ok = $ttH->db->do_insert("menu", $col); if ($ok) { $menu_id = $ttH->db->insertid(); $col_l = array(); $col_l["menu_id"] = $menu_id; $col_l["title"] = $ttH->post["title"]; $col_l["link_type"] = $ttH->post["link_type"]; $col_l["link"] = $ttH->post["link"]; foreach ($ttH->data["lang"] as $lang_id => $lang_row) { $col_l["lang"] = $lang_row["name"]; $ttH->db->do_insert("menu_lang", $col_l); } //update group_nav $col = array(); $col["menu_nav"] = get_menu_nav($ttH->post["parent_id"], $menu_id); $col["menu_level"] = substr_count($col['menu_nav'], ',') + 1; $ok = $ttH->db->do_update("menu", $col, " menu_id='" . $menu_id . "'"); if ($ok) { built_menu_nav_sub($menu_id, $col["menu_nav"]); } $data = array(); $err = $ttH->html->html_alert($ttH->lang["global"]["add_success"], "success"); } else { $data = $ttH->post; $err = $ttH->html->html_alert($ttH->lang["global"]["add_false"], "error"); } } else { $data = $ttH->post; } } $data["err"] = $err; $arr_isset = array('group_id', 'parent_id', 'link_type', 'target'); foreach ($arr_isset as $tmp) { $data[$tmp] = isset($data[$tmp]) ? $data[$tmp] : ''; } $data['show_mod'] = isset($data['show_mod']) ? @implode(',', $data['show_mod']) : ''; $data['name_action'] = $name_action; $data['title'] = isset($data['title']) ? $data['title'] : $table_info['title']; $data['link'] = isset($data['link']) ? $data['link'] : $table_info['friendly_link']; $data["link_action"] = $link_action; $data["list_group"] = list_group("group_id", $cur_group, " class=\"form-control\" onchange=\"window.location.href='" . $data["link_action"] . "&group_id='+this.value;\""); //$data['group_name'] = $ttH->data["menu_group"][$cur_group]; $data["list_menu"] = list_menu($cur_group, "parent_id", $data['parent_id'], " class=\"form-control\"", array("title" => $ttH->lang['global']['select_title'])); $data["list_link_type"] = $ttH->admin->list_link_type("link_type", $data['link_type'], " class=\"form-control\""); $data["list_target"] = $ttH->admin->list_target("target", $data['target'], " class=\"form-control\""); $data["list_module"] = list_module("show_mod[]", $data['show_mod'], " class=\"form-control\"", array('title' => $ttH->lang["global"]["select_all"])); $ttH->temp_act->assign('data', $data); $ttH->temp_act->parse($temp); return $ttH->temp_act->text($temp); }
function get_list_type() { global $ttH; $output = ""; switch ($this->type) { case "group": $link = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub); $ext = "onchange=\"go_link('" . $link . "&type=" . $this->type . "&type_id='+this.value)\""; if ($this->sub == 'edit') { $ext = ''; } $output = list_group("type_id", $this->type_id, " class=\"form-control\" " . $ext, array("title" => $ttH->lang['global']['select_title'])); break; case "item": $link = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub); $ext = "onchange=\"go_link('" . $link . "&type=" . $this->type . "&type_id='+this.value)\""; if ($this->sub == 'edit') { $ext = ''; } $output = list_product("type_id", $this->type_id, " class=\"form-control\" " . $ext, array("title" => $ttH->lang['global']['select_title'])); break; } return $output; }
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(); $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]]; $ok = $ttH->db->do_update("banner", $dup, "banner_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("banner", $dup, "banner_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("banner", $dup, "banner_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; $group_id = $this->cur_group; $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_show_mod = isset($ttH->input["search_show_mod"]) ? $ttH->input["search_show_mod"] : ''; $search_title = isset($ttH->input["search_title"]) ? $ttH->input["search_title"] : ""; $where = " where lang='" . $ttH->conf['lang_cur'] . "' "; $ext = ""; $is_search = 0; if ($is_show == "trash") { $where .= " and is_show=0 "; } else { $where .= " and is_show=1 "; } if (!empty($group_id)) { $where .= " and group_id='" . $group_id . "' "; $ext .= "&group_id=" . $group_id; } 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_show_mod)) { $where .= " and (show_mod='' or find_in_set('" . $search_show_mod . "',show_mod)) "; $ext .= "&search_show_mod=" . $search_show_mod; $is_search = 1; } if (!empty($search_title)) { $where .= " and (menu_id='{$search_title}' or title like '%{$search_title}%' or link like '%{$search_title}%') "; $ext .= "&search_title=" . $search_title; $is_search = 1; } $num_total = 0; $res_num = $ttH->db->query("select banner_id from banner " . $where . " "); $num_total = $ttH->db->num_rows($res_num); $n = $ttH->conf["n_list"] ? $ttH->conf["n_list"] : 30; $num_banners = ceil($num_total / $n); if ($p > $num_banners) { $p = $num_banners; } 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("banner_id" => array("title" => $ttH->lang["global"]["id"], "link" => $link_action . "&p=" . $p . $ext . "&sort=banner_id-desc", "class" => ""), "show_order" => array("title" => $ttH->lang["global"]["show_order"], "link" => $link_action . "&p=" . $p . $ext . "&sort=show_order-desc", "class" => ""), "title" => array("title" => $ttH->lang["global"]["title"], "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] == "banner_id" ? "banner_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 banner " . $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['banner_id'])); $row["link_trash"] = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub, array("do_action" => "do_trash", "id" => $row['banner_id'])); $row["link_restore"] = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub, array("do_action" => "do_restore", "id" => $row['banner_id'])); $row["link_del"] = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub, array("do_action" => "do_del", "id" => $row['banner_id'])); if ($row['type'] == 'image' && !empty($row["content"])) { //$row["content"] = '<img alt="'.$row["content"].'" src="'.DIR_UPLOAD.$row["content"].'"/>'; $row["content"] = '<a class="fancybox-effects-a" title="' . $row["content"] . '" href="' . DIR_UPLOAD . $row["content"] . '"> ' . $ttH->func->get_pic_mod($row["content"], 300, 100, '', 1, 0, array('fix_max' => 1)) . ' </a>'; } $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["list_group"] = list_group("group_id", $group_id, " class=\"form-control\" onchange=\"window.location.href='" . $link_action . "&group_id='+this.value;\""); $data['search_date_begin'] = $search_date_begin; $data['search_date_end'] = $search_date_end; $data['search_title'] = $search_title; $data["list_module_search"] = list_module("search_show_mod", $search_show_mod, " class=\"form-control\"", array('title' => $ttH->lang["global"]["select_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"); }
<?php $request = $_REQUEST; $request = sanitize($request); $query = $request['q']; switch ($query) { case 'list_user': $data = list_user(); break; case 'list_group': $data = list_group(); break; case 'list_user_group': $data = list_user_group(); break; case 'list_incident': $data = list_incident(); break; default: // not a valid request $data = false; return; }
function do_edit() { global $ttH; $err = ""; $id = $ttH->input["id"]; if (isset($ttH->post['do_submit'])) { /*print_arr($ttH->post); die();*/ $username = $ttH->post["username"]; $full_name = $ttH->post["full_name"]; $email = $ttH->post["email"]; $password = $ttH->func->md25($ttH->post["password"]); if (empty($err) && empty($username)) { $err = $ttH->html->html_alert($ttH->lang["admin"]["err_username_invalid"], "error"); } if (empty($err) && empty($full_name)) { $err = $ttH->html->html_alert($ttH->lang["admin"]["err_full_name_invalid"], "error"); } if (empty($err) && empty($email)) { $err = $ttH->html->html_alert($ttH->lang["admin"]["err_email_invalid"], "error"); } if (empty($err)) { $res_ck = $ttH->db->query("select username,email from admin where (username='******' or email='" . $email . "') AND id !=" . $id); if ($row_ck = $ttH->db->fetch_row($res_ck)) { if (empty($err) && $row_ck["email"] == $email) { $err = $ttH->func->html_err($ttH->lang["admin"]["err_email_existed"]); } if (empty($err) && $row_ck["username"] == $username) { $err = $ttH->func->html_err($ttH->lang["admin"]["err_username_existed"]); } } } if (empty($err)) { $col = array(); $col["group_id"] = $ttH->post["group_id"]; $col["username"] = $username; if (!empty($ttH->post["password"])) { $col["password"] = $password; } $col["picture"] = $ttH->func->get_input_pic($ttH->post["picture"]); $col["full_name"] = $full_name; $col["email"] = $email; $ok = $ttH->db->do_update("admin", $col, " id='" . $id . "'"); if ($ok) { if ($_SESSION[$ttH->conf["admin_ses"]]["userid"] == $id && !empty($ttH->post["password"])) { $_SESSION[$ttH->conf["admin_ses"]]["password"] = $password; } $err = $ttH->html->html_alert($ttH->lang["global"]["edit_success"], "success"); } else { $err = $ttH->html->html_alert($ttH->lang["global"]["edit_false"], "error"); } } } $sql = "select * from admin where id=" . $id; $result = $ttH->db->query($sql); if ($data = $ttH->db->fetch_row($result)) { } $data["err"] = $err; $data["link_action"] = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub, array("id" => $id)); $data['picture'] = $ttH->admin->get_form_pic('picture', $data['picture'], $this->folder_upload, $this->dir); $data["list_group"] = list_group("group_id", $data['group_id'], " class=\"form-control\"", array("title" => $ttH->lang['global']['select_title'])); $ttH->temp_act->assign('data', $data); $ttH->temp_act->parse("edit"); return $ttH->temp_act->text("edit"); }
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'] = isset($arr_is_focus[$up_id[$i]]) ? $arr_is_focus[$up_id[$i]] : 0; $ok = $ttH->db->do_update("product", $dup, "item_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_duplicate": if (isset($ttH->input['id'])) { $list_duplicate = $ttH->input['id']; } elseif (isset($ttH->post['selected_id']) && is_array($ttH->post['selected_id'])) { $list_duplicate = @implode(',', $ttH->post['selected_id']); } $err = $this->do_duplicate($list_duplicate); 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", $dup, "item_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", $dup, "item_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 .= " AND is_show=0 "; } else { $where .= " AND 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.item_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 a.item_id \n\t\t\t\t\t\tfrom product a, product_lang al \n\t\t\t\t\t\twhere a.item_id=al.item_id \n\t\t\t\t\t\tand lang='" . $ttH->conf["lang_cur"] . "' \n\t\t\t\t\t\t" . $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_call, $this->action, $this->sub); //Sort $arr_title = array("item_id" => array("title" => $ttH->lang["global"]["id"], "link" => $link_action . "&p=" . $p . $ext . "&sort=item_id-desc", "class" => ""), "item_code" => array("title" => $ttH->lang["global"]["series"], "link" => $link_action . "&p=" . $p . $ext . "&sort=item_code-desc", "class" => ""), "show_order" => array("title" => $ttH->lang["global"]["show_order"], "link" => $link_action . "&p=" . $p . $ext . "&sort=show_order-desc", "class" => ""), "picture" => array("title" => $ttH->lang["global"]["picture"], "link" => $link_action . "&p=" . $p . $ext . "&sort=picture-desc", "class" => ""), "title" => array("title" => 'Tên sản phẩm', "link" => $link_action . "&p=" . $p . $ext . "&sort=title-desc", "class" => ""), "price_import" => array("title" => 'Giá nhập', "link" => $link_action . "&p=" . $p . $ext . "&sort=price_import-desc", "class" => ""), "price" => array("title" => 'Giá bán', "link" => $link_action . "&p=" . $p . $ext . "&sort=price-desc", "class" => ""), "in_stock" => array("title" => 'Nhập kho', "link" => $link_action . "&p=" . $p . $ext . "&sort=import_stock-desc", "class" => ""), "out_stock" => array("title" => 'Xuất kho', "link" => $link_action . "&p=" . $p . $ext . "&sort=out_stock-desc", "class" => ""), "has_stock" => array("title" => 'Tồn kho', "link" => $link_action . "&p=" . $p . $ext . "&sort=in_stock-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] == "item_id" ? "a.item_id" : $tmp[0]; $order_tmp = $tmp[0] == "import_stock" ? "(in_stock+out_stock)" : $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 a, product_lang al \n\t\t\t\t\t\twhere a.item_id=al.item_id \n\t\t\t\t\t\tand lang='" . $ttH->conf["lang_cur"] . "' \n\t\t\t\t\t\t" . $where . " \n\t\t\t\t\t\tlimit {$start},{$n}"; //die($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['stt'] = $start + $i; $html_row .= $this->manage_row($row, $is_show); } } 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["list_group_search"] = list_group('product', "search_group_id", $search_group_id, " class=\"form-control\"", array("title" => $ttH->lang['global']['select_title'])); $data["list_brand_search"] = list_brand("search_brand_id", $search_brand_id, " class=\"form-control\"", array("title" => $ttH->lang['global']['select_title'])); $data['form_search_class'] = $is_search == 1 ? ' expand' : ''; $ttH->temp_act->assign('data', $data); $ttH->temp_act->parse("manage"); return $ttH->temp_act->text("manage"); }