function display_date_ordered() { $orderInfo = array(); if (!User::is_login()) { $json['error'] = "not_login"; echo json_encode($json); exit; } if (User::is_block()) { $json['error'] = "no_permission"; echo json_encode($json); exit; } $user = User::$current->data; $cat_id = Url::get('cat_id', 0); if ($cat_id) { $arrCat = DB::select_all('item_vip', "(catid={$cat_id} OR level_1_catid = {$cat_id}) AND status = 1 AND time_end > " . TIME_NOW); if (is_array($arrCat) && count($arrCat) > 0) { $cout = 0; for ($i = 1; $i <= 7; $i++) { $j = 0; $time = TIME_NOW + $i * 86400; foreach ($arrCat as $key => $val) { if ($val['time_start'] <= $time && $val['time_end'] >= $time) { $j++; } } if ($j < 2) { $orderInfo[$cout] = array('title' => "Còn chỗ", 'start' => date("Y/m/d", $time), 'end' => date("Y/m/d", $time)); $cout++; } else { $orderInfo[$cout] = array('title' => "Hết chỗ", 'className' => 'book', 'start' => date("Y/m/d", $time), 'end' => date("Y/m/d", $time)); $cout++; } } } else { $cout = 0; for ($i = 1; $i <= 7; $i++) { $time = TIME_NOW + $i * 86400; $orderInfo[$cout] = array('title' => "Còn trống", 'start' => date("Y/m/d", $time), 'end' => date("Y/m/d", $time)); $cout++; } } echo json_encode($orderInfo); } }
function ManageBookingVip($row) { Module::Module($row); if (User::have_permit(ADMIN_VIP_ITEM) || User::have_permit(ADMICRO_BOOKING_VIP)) { $cmd = Url::get('cmd'); switch ($cmd) { case '': require_once 'forms/ManageBookingVip.php'; $this->add_form(new ManageBookingVipForm()); break; case 'add': require_once 'forms/AddBookingVip.php'; $this->add_form(new AddBookingVipForm()); break; case 'active': if (User::have_permit(ADMIN_VIP_ITEM)) { $id = (int) Url::get("id", 0); if ($id) { $booking_vip = DB::select("bookings_vip", "id={$id}"); } $booking_vip['top_cat'] != 0 ? $cat_id = $booking_vip['top_cat'] : ($cat_id = $booking_vip['cat_id']); $item_vip = DB::select_all('item_vip', "(catid = {$cat_id} OR level_1_catid = {$cat_id}) AND status = 1"); $i = 0; $sa = $booking_vip['time_start']; $ea = $booking_vip['time_end']; foreach ($item_vip as $itemv) { if ($sa > $itemv['time_start'] && $sa < $itemv['time_end']) { $i++; } elseif ($ea > $itemv['time_start'] && $ea < $itemv['time_end']) { $i++; } elseif ($sa < $itemv['time_start'] && $ea > $itemv['time_end']) { $i++; } } $priority = 1; $arrItemVip = array('item_id' => $booking_vip['item_id'], 'note' => "Add từ bảng booking vip cho [{$booking_vip['user_add']}]", 'time_start' => $booking_vip['time_start'], 'time_end' => $booking_vip['time_end'], 'time_add' => TIME_NOW, 'user_add' => User::user_name(), 'time_modify' => TIME_NOW, 'user_modify' => User::user_name(), 'catid' => $booking_vip['cat_id'], 'level_1_catid' => $booking_vip['top_cat'], 'num_contract' => $booking_vip['num_contract'], 'priority' => $priority); //insert $idVip = DB::insert("item_vip", $arrItemVip); if ($idVip) { $item_id = $booking_vip['item_id']; $item = Item::get_item($item_id); if ($booking_vip['time_start'] >= TIME_NOW || $booking_vip['time_end'] <= TIME_NOW) { $priority = 0; } DB::update("item", array("sticky" => $priority), "id={$item_id}"); if (MEMCACHE_ON) { $item['sticky'] = $priority; AZMemcache::do_put("item:{$item_id}", $item); AZMemcache::do_remove("id_vip:{$item['category_id']}"); AZMemcache::do_remove("id_vip:{$item['level_1_catid']}"); } } //update status DB::update('bookings_vip', array("status" => 1, "time_update_status" => TIME_NOW, "user_update_status" => User::user_name()), "id={$id}"); } Url::redirect_current(); break; case 'update_status': if (User::have_permit(ADMIN_VIP_ITEM)) { $id = (int) Url::get("id", 0); DB::update('bookings_vip', array("status" => 1, "time_update_status" => TIME_NOW, "user_update_status" => User::user_name()), "id={$id}"); } Url::redirect_current(); break; case 'edit': require_once 'forms/EditBookingVip.php'; $this->add_form(new EditBookingVipForm()); break; case 'delete': $id = (int) Url::get("id", 0); $booking_vip = array(); if ($id) { $booking_vip = DB::select("bookings_vip", "id={$id}"); } if ($booking_vip && $booking_vip['status'] != 1) { if (User::user_name() == $booking_vip['user_add'] || User::have_permit(ADMIN_VIP_ITEM)) { DB::update('bookings_vip', array("status" => -1, "time_del" => TIME_NOW, "user_del" => User::user_name()), "id={$id}"); } } Url::redirect_current(); break; default: Url::redirect_current(); break; } } else { Url::access_denied(); } }
function check_register_service() { $json['error'] = ""; $json['user_group'] = 0; $json['id'] = 0; if (!User::is_login()) { $json['error'] = "not_login"; echo json_encode($json); exit; } if (User::is_block()) { $json['error'] = "no_permission"; echo json_encode($json); exit; } $user_name = User::user_name(); //kiểm tra xem user có thuộc nhóm premium hay không. if (User::isPremium()) { $json['user_group'] = 1; } //end $service_name = Url::get('service_name', ''); $aryOrder = array(); $aryOrder = DB::select_all('order_services', "user_use='" . $user_name . "' AND (active = 1 OR active = 0 OR active = -4)"); if (count($aryOrder) > 0 && !User::is_root()) { foreach ($aryOrder as $val) { if ($service_name == $val['type_scs']) { $json['error'] = "exist_service_order"; echo json_encode($json); exit; } if ($val['payment_status'] == 1) { $json['error'] = "over_reg_scs_payment"; } else { if ($val['active'] == 1) { $json['error'] = "over_reg_scs_active"; } elseif ($val['active'] == -3 || $val['active'] == 0 || $val['active'] == -4) { $json['error'] = "confirm_cancel_reg_scs"; $json['id'] = $val['id']; } } } echo json_encode($json); exit; } else { $json['error'] = "success"; echo json_encode($json); exit; } }
function draw() { global $display; $this->beginForm(); AZLib::getCats(); $items = array(); $item_bookings = array(); $where = ''; $order = 'id DESC'; $catid = Url::get('catid', 0); $item_id = Url::get('item_id', 0); $user_add = Url::get('user_add', ''); $num_contract = Url::get('num_contract', ''); $status = Url::get('status', 0); $time_start = 0; $time_end = 0; $date_start = Url::get('date_start'); $date_end = Url::get('date_end'); if ($date_start) { $arr = explode('-', $date_start); $time_start = mktime(0, 0, 0, $arr[1], $arr[0], $arr[2]); } if ($date_end) { $arr = explode('-', $date_end); $time_end = mktime(23, 59, 59, $arr[1], $arr[0], $arr[2]); } if ($time_start >= $time_end) { $date_end = ''; $time_end = 0; } if ($time_start) { $where .= ($where != '' ? ' AND ' : 'WHERE ') . " time_start >= {$time_start}"; $order = 'time_start ASC, id DESC'; } if ($time_end) { $where .= ($where != '' ? ' AND ' : 'WHERE ') . " time_start <= {$time_end}"; } $display->add('date_start', $date_start); $display->add('date_end', $date_end); $time_start2 = 0; $time_end2 = 0; $date_start2 = Url::get('date_start2'); $date_end2 = Url::get('date_end2'); if ($date_start2) { $arr = explode('-', $date_start2); $time_start2 = mktime(0, 0, 0, $arr[1], $arr[0], $arr[2]); } if ($date_end2) { $arr = explode('-', $date_end2); $time_end2 = mktime(23, 59, 59, $arr[1], $arr[0], $arr[2]); } if ($time_start2 >= $time_end2) { $date_end2 = ''; $time_end2 = 0; } if ($time_start2) { $where .= ($where != '' ? ' AND ' : 'WHERE ') . " time_end >= {$time_start2}"; if ($order != 'time_start ASC, id DESC') { $order = 'time_end ASC, id DESC'; } } if ($time_end2) { $where .= ($where != '' ? ' AND ' : 'WHERE ') . " time_end <= {$time_end2}"; } $display->add('date_start2', $date_start2); $display->add('date_end2', $date_end2); if ($status != 3) { $where .= ($where != '' ? ' AND ' : 'WHERE ') . " status = {$status}"; } elseif ($status == 3) { $where .= ($where != '' ? ' AND ' : 'WHERE ') . " status in (0,1)"; } if ($item_id) { $where .= ($where != '' ? ' AND ' : 'WHERE ') . " item_id = {$item_id}"; } if ($user_add != '') { $where .= ($where != '' ? ' AND ' : 'WHERE ') . " user_add = '{$user_add}'"; } if ($num_contract != '') { $where .= ($where != '' ? ' AND ' : 'WHERE ') . " num_contract = '{$num_contract}'"; } $zone_id = Url::get("zone_id", 0); $arr = array(0 => "-- Tất cả Zone --"); foreach (CGlobal::$allZones as $zone) { $arr[$zone['id']] = $zone['name']; } $display->add('zone_option', AZLib::getOption($arr, $zone_id)); $arr = array(0 => "-- Tất cả Danh mục --"); if (isset(CGlobal::$allCategories[$catid])) { if (CGlobal::$allCategories[$catid]['parent_id']) { $where .= ($where != '' ? ' AND ' : 'WHERE ') . " cat_id = {$catid}"; } else { if (isset(CGlobal::$subCategories[$catid]) && CGlobal::$subCategories[$catid]) { $where .= ($where != '' ? ' AND ' : 'WHERE ') . " (top_cat = {$catid} OR cat_id IN(" . implode(",", array_keys(CGlobal::$subCategories[$catid])) . "))"; } else { $where .= ($where != '' ? ' AND ' : 'WHERE ') . " top_cat = {$catid}"; } } } if (CGlobal::$allCategories && CGlobal::$subCategories) { foreach (CGlobal::$subCategories as $topid => $subcats) { if (!$zone_id || $zone_id && isset(CGlobal::$allCategories[$topid]) && in_array($zone_id, CGlobal::$allCategories[$topid]['zones'])) { if (isset(CGlobal::$allCategories[$topid])) { $arr[$topid] = CGlobal::$allCategories[$topid]['name'] . " ({$topid})"; } else { $arr[$topid] = "({$topid})"; } foreach ($subcats as $cid => $cat) { $arr[$cid] = "--------{$cat['name']} ({$cid})"; } } } } $display->add('cat_option', AZLib::getOption($arr, $catid)); $display->add('item_id', $item_id); $display->add('status', $status); $display->add('user_add', $user_add); $display->add('num_contract', $num_contract); $re = DB::query("SELECT * FROM bookings_vip {$where} ORDER BY {$order}"); $item_ids = ''; if ($re) { while ($v_item = mysql_fetch_assoc($re)) { $zid = 0; $zone_name = 0; $topcid = 0; $cid = 0; if ($v_item['cat_id']) { $cid = $v_item['cat_id']; if (isset(CGlobal::$allCategories[$cid])) { $topcid = CGlobal::$allCategories[$cid]['parent_id']; } } elseif ($v_item['top_cat']) { $topcid = $v_item['top_cat']; } if (!$topcid && $cid) { if (isset(CGlobal::$allCategories[$cid])) { $topcid = CGlobal::$allCategories[$cid]['parent_id']; } } if ($topcid) { if (isset(CGlobal::$allCategories[$topcid])) { foreach (CGlobal::$allCategories[$topcid]['zones'] as $zoneid) { if ($zoneid) { $zid = $zoneid; break; } } } } $zone_name = "[{$zid}] "; if ($zid && isset(CGlobal::$allZones[$zid])) { $zone_name .= CGlobal::$allZones[$zid]['name']; } if (!$zone_id || $zone_id && $zid == $zone_id) { $v_item['zone'] = $zone_name; $v_item['time'] = "<b>Tạo:</b> " . date("d/m/Y H:i", $v_item['time_add']) . " bởi <b>" . $v_item['user_add'] . "</b>"; if ($v_item['time_add'] != $v_item['time_edit']) { $v_item['time'] .= "<br /><b>Sửa:</b> " . date("d/m/Y H:i", $v_item['time_edit']) . " bởi <b>" . $v_item['user_edit'] . "</b>"; } if ($v_item['user_update_status'] != '' && $v_item['time_update_status'] != 0) { $v_item['time'] .= "<br /><b>Update:</b> " . date("d/m/Y H:i", $v_item['time_update_status']) . " bởi <b>" . $v_item['user_update_status'] . "</b>"; } switch ($v_item['status']) { case -1: $v_item['str_status'] = "<font color=red><b>Đã xóa <br/>{$v_item['user_del']}</b></font>"; break; case 1: $v_item['str_status'] = "<font color=black><b>Đã xử lý</b></font>"; break; default: $v_item['str_status'] = "<font color=green><b>Chưa xử lý</b></font>"; $v_item['permis'] = 0; if (User::have_permit(ADMIN_VIP_ITEM)) { $v_item['permis'] = 1; $v_item['update_status'] = Url::build_current(array('cmd' => 'update_status', 'id' => $v_item['id'])); $v_item['active'] = Url::build_current(array('cmd' => 'active', 'id' => $v_item['id'])); } $v_item['edit'] = Url::build_current(array('cmd' => 'edit', 'id' => $v_item['id'])); $v_item['delete'] = Url::build_current(array('cmd' => 'delete', 'id' => $v_item['id'])); break; } if ($v_item['time_start'] > TIME_NOW) { $v_item['time_start'] = '<font color="#c00"><b>' . date("d/m/Y", $v_item['time_start']) . '</b></font>'; } else { $v_item['time_start'] = date("d/m/Y", $v_item['time_start']); } if ($v_item['time_end']) { if ($v_item['time_end'] < TIME_NOW) { $v_item['time_end'] = '<font color="#f00"><b>' . date("d/m/Y", $v_item['time_end']) . '</b></font>'; } else { $v_item['time_end'] = date("d/m/Y", $v_item['time_end']); } } else { $v_item['time_end'] = ''; } $item_ids .= ($item_ids != '' ? ',' : '') . $v_item['item_id']; //check vi tri vip $v_item['top_cat'] != 0 ? $cat_id = $v_item['top_cat'] : ($cat_id = $v_item['cat_id']); $item_vip = DB::select_all('item_vip', "(catid = {$cat_id} OR level_1_catid = {$cat_id}) AND status = 1 AND time_end >" . TIME_NOW); $i = 0; $sa = $v_item['time_start']; $ea = $v_item['time_end']; foreach ($item_vip as $item) { if ($sa > $item['time_start'] && $sa < $item['time_end']) { $i++; } elseif ($ea > $item['time_start'] && $ea < $item['time_end']) { $i++; } elseif ($sa < $item['time_start'] && $ea > $item['time_end']) { $i++; } } $v_item['over_slot'] = 0; if ($i >= 2) { $v_item['over_slot'] = 1; } //end check vi tri //check trung ID $v_item['exist_id'] = 0; foreach ($item_vip as $item) { if ($v_item['item_id'] == $item['item_id']) { $v_item['exist_id'] = 1; } } //end check trung ID $item_bookings[$v_item['id']] = $v_item; } } } if ($item_ids != '') { $re = DB::query("SELECT * FROM item WHERE id IN({$item_ids})"); if ($re) { while ($item = mysql_fetch_assoc($re)) { $item['item_link'] = Url::build('item_detail', array('id' => $item['id'], 'ebname' => AZLib::safe_title($item['name']))); $items[$item['id']] = $item; } } } foreach ($item_bookings as &$v_item) { if (isset($items[$v_item['item_id']])) { $v_item['item_link'] = $items[$v_item['item_id']]['item_link']; $v_item['item_name'] = stripslashes($items[$v_item['item_id']]['name']); if ($items[$v_item['item_id']]['status'] == -1) { $v_item['item_name'] .= ' <font color="#c00">Tin xoá</font>'; } elseif ($items[$v_item['item_id']]['status'] != 1) { $v_item['item_name'] .= ' <font color="#c00">KD</font>'; } $top_catid = $items[$v_item['item_id']]['level_1_catid']; $catid = $items[$v_item['item_id']]['category_id']; $v_item['top_cat_name'] = $v_item['top_cat'] ? CGlobal::$allCategories[$v_item['top_cat']]['name'] : ''; $v_item['cat_name'] = $v_item['cat_id'] ? CGlobal::$allCategories[$v_item['cat_id']]['name'] : ''; if ($v_item['cat_id'] && $v_item['cat_id'] != $catid) { $v_item['wrong_cat'] = '<font color="red">(sai chủng loại)</font>'; } $v_item['item_cat_name'] = "<font color=blue>" . CGlobal::$allCategories[$top_catid]['name'] . '</font> /<br /><font color=green>' . CGlobal::$allCategories[$catid]['name'] . '</font>'; if (isset(CGlobal::$allCategories[$v_item['cat_id']])) { $v_item['cat_vip'] = CGlobal::$allCategories[$v_item['cat_id']]['name']; } else { $v_item['cat_vip'] = ''; } } else { $v_item['item_name'] = 'Tin không tồn tại'; $v_item['cat_name'] = ''; } } $display->add('items', $item_bookings); $display->output('ManageBookingVip'); $this->endForm(); }