$record_id = getValue("record_id"); $sta_strdate = getValue("sta_strdate", "str", "POST", date("d/m/Y")); $sta_strtime = getValue("sta_strtime", "str", "POST", date("H:i:s")); $sta_date = convertDateTime($sta_strdate, $sta_strtime); #+ checkRowUser($fs_table,$field_id,$record_id,$listing); #+ #+ Goi class generate form $myform = new generate_form(); //Call Class generate_form(); $myform->removeHTML(0); //Loại bỏ chức năng không cho điền tag html trong form #+ #+ Khai bao bang du lieu $myform->addTable($fs_table); // Add table #+ #+ Khai bao thong tin cac truong $myform->add("sta_category_id", "sta_category_id", 1, 0, 0, 1, "Bạn chưa chọn danh mục.", 0, ""); $myform->add("sta_title", "sta_title", 0, 0, "", 1, "Bạn chưa nhập tiêu đề.", 0, ""); $myform->add("sta_order", "sta_order", 1, 0, 0, 1, "Thứ tự phải lớn hơn hoặc bằng 0.", 0, ""); $myform->add("sta_date", "sta_date", 1, 1, 0, 0, "", 0, ""); $myform->add("sta_description", "sta_description", 0, 0, "", 0, "", 0, ""); $myform->add("sta_description1", "sta_description1", 0, 0, "", 0, "", 0, ""); #+ #+ đổi tên trường thành biến và giá trị $myform->evaluate(); #+ #+ Neu nhu co submit form
$myform->add('new_picture', 'image', 0, 1, $image); $myform->add('new_teaser', 'teaser', 0, 1, $teaser); $myform->add('new_tags', 'tag_string', 0, 1, $tag_string); $myform->add('new_date', 'time', 1, 1, $time); $myform->add('new_active', 'active', 1, 1, $active); $myform->removeHTML(0); if (!$myform->checkdata()) { $db_execute_return = new db_execute_return(); $last_id = $db_execute_return->db_execute($myform->generate_insert_SQL()); unset($db_execute_return); if ($last_id) { //cập nhật link lấy thành công $db_update = new db_execute('UPDATE links SET lin_status = ' . LINK_STATUS_SUCCESS . ' WHERE lin_id = ' . $link_id); //insert content vào bảng news detail $myform2 = new generate_form(); $myform2->addTable('news_detail'); $myform2->add('ndt_id', 'last_id', 1, 1, 0, 1, 'Không có ID bài viết'); $myform2->add('ndt_content', 'content', 0, 1, '', 1, 'Content trống'); $myform2->removeHTML(0); if (!$myform2->checkdata()) { $db_insert = new db_execute($myform2->generate_insert_SQL()); unset($db_insert); echo 'Lấy thành công tin : <a href="' . $link_url . '">' . $link_url . '</a>'; reload(30); die; } else { $db_update = new db_execute('UPDATE links SET lin_status = ' . LINK_STATUS_FAIL . ' WHERE lin_id = ' . $link_id); echo 'Dữ liệu trống'; reload(30); die; }
function EditRecord() { //check quyền checkCustomPermission('edit'); //khai bao bien global global $time_end, $time_start; $promo_id = getValue('id', 'int', 'POST', 0); // id chien dich if (!$promo_id) { //lỗi không tồn tại id của khuyến mại $array_return['error'] = 0; $array_return['msg'] = 'Bản ghi không tồn tại'; die(json_encode($array_return)); } // ten chien dich khuyen mai $promo_name = getValue('name', 'str', 'POST', '', 2); if (!$promo_name) { //lỗi chưa nhập tên chiến dịch km $array_return['error'] = 0; $array_return['msg'] = 'Chưa nhập tên chiến dịch khuyến mại'; die(json_encode($array_return)); } $promo_agencies = getValue('agencies', 'int', 'POST', 0, 3); if (!$promo_agencies) { //lỗi chưa nhập tên chiến dịch km $array_return['error'] = 0; $array_return['msg'] = 'Chưa chọn cửa hàng áp dụng khuyến mại'; die(json_encode($array_return)); } // thoi gian bat dau $start_time = getValue('start_date', 'str', 'POST', '', 3); $time_start_h = getValue('time_start_h', 'int', 'POST', 0, 3); $time_start_i = getValue('time_start_i', 'int', 'POST', 0, 3); //thoi gian ket thuc $end_time = getValue('end_date', 'str', 'POST', ''); $time_end_h = getValue('time_end_h', 'int', 'POST', 0, 3); $time_end_i = getValue('time_end_i', 'int', 'POST', 0, 3); // ghi chú $promo_note = getValue('note', 'str', 'POST', ''); $list_menus = getValue('menus', 'arr', 'POST', array()); // dieu kien giam gia $promo_condition = getValue('condition', 'str', 'POST', 0, 3); // gia tri giảm giá hóa đơn dựa vào kiểu giảm giá promo_type có 2 giá trị là % và tiền mặt $promo_value = getValue('promo_value', 'int', 'POST', 0, 3); $promo_type = getValue('promo_type', 'int', 'POST', 0, 3); $time_start = convertDateTime($start_time, $time_start_h . ':' . $time_start_i . ':0'); if (!$time_start) { $array_return['error'] = 0; $array_return['msg'] = 'Chưa nhập thời gian bắt đầu chiến dịch'; die(json_encode($array_return)); } $time_end = convertDateTime($end_time, $time_end_h . ':' . $time_end_i . ':0'); if (!$time_end) { $array_return['error'] = 0; $array_return['msg'] = 'Chưa nhập thời gian kết thúc chiến dịch'; die(json_encode($array_return)); } // ket quả tra ve // update chiến dịch khuyến mãi $myform = new generate_form(); $myform->addTable('promotions'); $myform->add('pms_name', 'name', 0, 0, $promo_name, 1, 'Bạn chưa nhập tên chiến dịch'); $myform->add('pms_agency_id', 'agencies', 1, 0, $promo_agencies, 1, 'Bạn chưa chọn địa điểm áp dụng'); $myform->add('pms_start_time', 'time_start', 0, 1, $time_start, 1, 'Thời gian bắt đầu chưa nhập'); $myform->add('pms_end_time', 'time_end', 0, 1, $time_end, 1, 'Thời gian kết thúc chưa nhập'); $myform->add('pms_value_sale', 'promo_value', 1, 0, $promo_value, 0); $myform->add('pms_type_sale', 'promo_type', 1, 0, $promo_type, 0); $myform->add('pms_condition', 'condition', 1, 0, $promo_condition, 0); $myform->add('pms_note', 'note', 0, 0, $promo_note, 0); if (!$myform->checkdata()) { $db_update = new db_execute($myform->generate_update_SQL('pms_id', $promo_id)); //echo $myform->generate_update_SQL('pms_id', $promo_id); unset($db_update); //log action log_action(ACTION_LOG_ADD, 'Chỉnh sửa bản ghi ' . $promo_id . ' bảng promotions'); } //xóa hết các thực đơn có trong chiến dịch khuyến mãi đang sửa và sau đó insert lại danh sách các thực đơn bổ sung $db_delete = new db_execute('DELETE FROM promotions_menu WHERE pms_id = ' . $promo_id . ''); unset($db_delete); // insert lại những thực đơn cập nhập $db_insert = 'INSERT INTO promotions_menu(pms_id ,pms_menu_id, pms_menu_value, pms_menu_type) VALUES'; //sử dụng id của promotion để insert vào bảng promotions_menu foreach ($list_menus as $menu) { $db_insert .= '( ' . $promo_id . ', ' . $menu['men_id'] . ', ' . $menu['men_value'] . ', ' . $menu['men_type'] . ' ),'; } $db_insert = rtrim($db_insert, ','); $db_insert_menu = new db_execute($db_insert); unset($db_insert_menu); // trả về kết quả thành công $array_return['success'] = 1; $array_return['msg'] = 'Cập nhật thành công'; die(json_encode($array_return)); }
public function openDesk() { //Phần này sẽ trả về json - khai báo biến chứa array kết quả trả về $array_return = array(); //Kiểm tra xem bàn hiện tại đã mở chưa $desk_id = getValue('desk_id', 'int', 'POST', 0); if (!$desk_id) { return; } check_desk_exist($desk_id); $db_query = new db_query('SELECT * FROM current_desk WHERE cud_desk_id = ' . $desk_id); $desk_data = mysqli_fetch_assoc($db_query->result); unset($db_query); if ($desk_data) { //Nếu bàn đang mở thì show ra $this->getCurrentDeskDetail(); return; } //nếu không thì mở bàn //khai báo các giá trị default khi mở bàn $cud_start_time = time(); $cud_note = ''; $cud_desk_id = $desk_id; //id bàn $cud_customer_id = 0; //id khách hàng $cud_staff_id = 0; //id nhân viên phục vụ $cud_extra_fee = 0; //phụ phí tính theo % $cud_vat = 0; //thuế VAT tính theo % $cud_customer_discount = 0; //giảm giá áp dụng cho loại khách $cud_debit = 0; //ghi nợ hay ko? $cud_pay_type = PAY_TYPE_CASH; //loại thanh toán là tiền mặt hay qua thẻ $array_return['cud_start_time'] = $cud_start_time; $array_return['start_time_string'] = date('d/m/Y H:i', $cud_start_time); $array_return['cud_note'] = $cud_note; $array_return['cud_desk_id'] = $cud_desk_id; $array_return['cud_customer_id'] = $cud_customer_id; $array_return['cud_staff_id'] = $cud_staff_id; $array_return['cud_extra_fee'] = $cud_extra_fee; $array_return['cud_vat'] = $cud_vat; $array_return['cud_customer_discount'] = $cud_customer_discount; $array_return['cud_debit'] = $cud_debit; $array_return['cud_pay_type'] = $cud_pay_type; $myform = new generate_form(); $myform->addTable('current_desk'); $myform->add('cud_desk_id', 'cud_desk_id', 1, 1, $cud_desk_id); $myform->add('cud_customer_id', 'cud_customer_id', 1, 1, $cud_customer_id); $myform->add('cud_staff_id', 'cud_staff_id', 1, 1, $cud_staff_id); $myform->add('cud_note', 'cud_note', 0, 1, $cud_note); $myform->add('cud_start_time', 'cud_start_time', 1, 1, $cud_start_time); $myform->add('cud_extra_fee', 'cud_extra_fee', 3, 1, $cud_extra_fee); $myform->add('cud_vat', 'cud_vat', 3, 1, $cud_vat); $myform->add('cud_customer_discount', 'cud_customer_discount', 3, 1, $cud_customer_discount); $myform->add('cud_debit', 'cud_debit', 1, 1, $cud_debit); $myform->add('cud_pay_type', 'cud_pay_type', 1, 1, $cud_pay_type); //insert to current_desk $db_execute = new db_execute($myform->generate_insert_SQL()); unset($db_execute); //lấy ra thông tin về menu mở bàn $list_menu = ''; $this->list->add('', 'Tên thực đơn'); $this->list->add('', 'ĐVT'); $this->list->add('', 'SL'); $this->list->add('', 'Đơn giá'); $this->list->add('', 'Giảm'); $this->list->add('', 'Thành tiền'); $menu_start = array(0); if ($this->start_menu) { foreach ($this->start_menu as $men_id => $men_number) { $menu_start[] = $men_id; } } $menu_start = implode(',', $menu_start); $db_count = new db_count('SELECT count(*) AS count FROM menus WHERE men_id IN(' . $menu_start . ')'); $total = $db_count->total; unset($db_count); $db_listing = new db_query('SELECT * FROM menus WHERE men_id IN(' . $menu_start . ')' . $this->list->limit($total)); $total_row = mysqli_num_rows($db_listing->result); $list_menu .= $this->list->showHeader($total_row); $i = 0; $array_unit = array(); $db_query = new db_query('SELECT * FROM units'); while ($row = mysqli_fetch_assoc($db_query->result)) { $array_unit[$row['uni_id']] = $row['uni_name']; } while ($row = mysqli_fetch_assoc($db_listing->result)) { $i++; $list_menu .= $this->list->start_tr($i, $row['men_id'], 'onclick="selectMenuInDesk(' . $row['men_id'] . ')" class="menu-normal record-item" data-record_id="' . $row['men_id'] . '"'); /* code something */ //Thành tiền - công thức tính bằng giá * (100 - %giảm giá) * số lượng $menu_item_number = $this->start_menu[$row['men_id']]; $menu_item_price = $row['men_price']; $menu_item_discount = 0; $menu_item_total = $menu_item_number * (100 - $menu_item_discount) / 100 * $menu_item_price; $list_menu .= '<td class="text-left" width="200px;">' . $row['men_name'] . '</td>'; $list_menu .= '<td class="center">' . $array_unit[$row['men_unit_id']] . '</td>'; $list_menu .= '<td class="center">' . $menu_item_number . '</td>'; $list_menu .= '<td class="text-right">' . format_number($menu_item_price) . '</td>'; //Giảm giá của menu - theo khuyến mại. hiện tại chưa có quản lý khuyến mại nên để 0 mặc định $list_menu .= '<td class="text-center">0</td>'; $list_menu .= '<td class="text-right">' . format_number($menu_item_total) . '</td>'; $list_menu .= $this->list->end_tr(); //insert thông tin về menu mở bàn vào bảng current_desk_menu $sql = 'INSERT INTO current_desk_menu(cdm_desk_id, cdm_menu_id, cdm_number, cdm_price, cdm_price_type, cdm_create_time, cdm_updated_time) VALUES (' . $desk_id . ',' . $row['men_id'] . ',' . $this->start_menu[$row['men_id']] . ',' . $row['men_price'] . ',"men_price", ' . time() . ', ' . time() . ')'; $db_insert = new db_execute($sql); unset($db_insert); } $list_menu .= $this->list->showFooter(); //log action log_action(ACTION_LOG_ADD, 'Tạo bàn ID: ' . $desk_id); $array_return['list_menu'] = $list_menu; $array_return['array_menu'] = $this->getArrayMenu($desk_id); $array_return['customer_code'] = format_codenumber($array_return['cud_customer_id'], 6, PREFIX_CUSTOMER_CODE); $array_return['customer_name'] = 'Khách lẻ'; $array_return['staff_code'] = format_codenumber($array_return['cud_staff_id'], 6, PREFIX_STAFF_CODE); $array_return['staff_name'] = 'Không chọn nhân viên'; $this->add($array_return); }
$action = getValue('action', 'str', 'POST', ''); $error_msg = ''; if ($action == 'execute') { $myform = new generate_form(); $myform->add('law_cat_id', 'law_cat_id', 1, 0, 0, 1); $myform->add('law_link_cat', 'law_link_cat', 0, 0, '', 1); $myform->add('law_image', 'law_image', 0, 0, '', 0); $myform->add('law_detail_link', 'law_detail_link', 0, 0, '', 1); $myform->add('law_detail_title', 'law_detail_title', 0, 0, '', 1); $myform->add('law_detail_teaser', 'law_detail_teaser', 0, 0, '', 0); $myform->add('law_detail_content', 'law_detail_content', 0, 0, '', 1); $myform->add('law_detail_source', 'law_detail_source', 0, 0, '', 0); $myform->add('law_detail_tag', 'law_detail_tag', 0, 0, '', 0); $myform->add('law_detail_remove', 'law_detail_remove', 0, 0, '', 0); $myform->add('law_status_temp', 'law_status_temp', 1, 0, 0, 0); $myform->addTable('law'); $error_msg = $myform->checkdata(); if (!$error_msg) { $db_execute = new db_execute($myform->generate_insert_SQL()); } } ?> <html> <head> <title>Nhập luật lấy tin</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> </head> <body> <div class="container">
//Call Class generate_form(); $action = getValue('action', 'str', 'POST', ''); if ($action == 'execute') { $old_pass = getValue('old_pass', 'str', 'POST', ''); if (md5($old_pass) != $_SESSION['password']) { $errorMsg .= 'Bạn nhập password cũ không chính xác'; } $new_pass = getValue('new_pass', 'str', 'POST', ''); $check_pass = getValue('check_pass', 'str', 'POST', ''); if ($new_pass != $check_pass) { $errorMsg .= 'Bạn nhập password mới không khớp'; } else { $new_pass = md5($new_pass); } $myform = new generate_form(); $myform->addTable('admin_users'); $myform->add('adm_password', 'new_pass', 0, 1, '', 1, 'Bạn nhập password chưa chính xác'); if ($errorMsg == '') { $db_ex = new db_execute($myform->generate_update_SQL('adm_id', $admin_id)); $success = 'Cập nhật thành công'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Add New</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <link href="../css/bootstrap.css" rel="stylesheet"/> <link href="../css/common.css" rel="stylesheet"/> <link href="../css/template.css" rel="stylesheet"/>
function stock_transfer() { //id nguoi kiem ke $staff_id = getValue('staff_id', 'int', 'POST', 0); if (!$staff_id) { $array_return = array('error' => 0, 'msg' => 'Bạn chưa nhập tên nhân viên'); die(json_encode($array_return)); } $from_store = getValue('from_store', 'int', 'POST', 0); if (!$from_store) { $array_return = array('error' => 0, 'msg' => 'Bạn chưa chọn chuyển từ kho'); die(json_encode($array_return)); } $to_store = getValue('to_store', 'int', 'POST', 0); if (!$to_store) { $array_return = array('error' => 0, 'msg' => 'Bạn chưa chọn chuyển đến kho'); die(json_encode($array_return)); } if ($from_store == $to_store) { $array_return = array('error' => 0, 'msg' => 'Chuyển kho không hợp lệ'); die(json_encode($array_return)); } $note = getValue('note', 'str', 'POST', ''); $products = getValue('products', 'arr', 'POST', ''); if (!$products) { $array_return = array('error' => 0, 'msg' => 'Bạn chưa chọn mặt hàng chuyển kho'); die(json_encode($array_return)); } //thời gian mặc định tạo phiếu $default_time = time(); global $admin_id; // thêm thông tin vào phiếu chuyển kho hàng $myform = new generate_form(); $myform->addTable('stock_transfer'); $myform->add('sto_staff_id', 'staff_id', 1, 0, $staff_id, 1, 'Bạn chưa nhập tên nhân viên'); $myform->add('sto_from_storeid', 'from_store', 1, 0, $from_store, 1, 'Bạn chưa chọn chuyển từ kho'); $myform->add('sto_to_storeid', 'to_store', 1, 0, $to_store, 1, 'Bạn chưa chọn kho chuyển đến'); $myform->add('sto_time', 'sto_time', 1, 0, $default_time, 0); $myform->add('sto_note', 'note', 0, 0, $note, ''); $myform->add('sto_admin_id', 'admin_id', 1, 0, $admin_id, 0); if (!$myform->checkdata()) { $db_insert = new db_execute_return(); $last_id = $db_insert->db_execute($myform->generate_insert_SQL()); unset($db_insert); if (!$last_id) { //lỗi $array_return = array('error' => 0, 'msg' => 'Đã có lỗi xảy ra! Vui lòng thử lại sau'); die(json_encode($array_return)); } // insert sản phẩm được chuyển với số lượng trước khi chuyển và sau khi chuyển $db_product_menu = 'INSERT INTO stock_transfer_products(sto_id ,pro_id, stp_quantity_inventory, stp_quantity_transfer) VALUES'; //sử dụng id của stock_transfer để insert vào bảng stock_transfer_products foreach ($products as $product) { $db_product_menu .= '( ' . $last_id . ', ' . $product['pro_id'] . ', ' . $product['pro_quantity'] . ', ' . $product['pro_quantity_transfer'] . ' ),'; } $db_product_menu = rtrim($db_product_menu, ','); $db_insert_product = new db_execute($db_product_menu); unset($db_insert_product); //log action log_action(ACTION_LOG_ADD, 'Thêm mới danh sách hàng chuyển kho ' . $last_id . ' bảng stock_transfer'); // update lại số lượng trong bảng product_quantity sau khi chuyển kho foreach ($products as $product) { $db_from_store = 'UPDATE product_quantity SET pro_quantity = pro_quantity - ' . $product['pro_quantity_transfer'] . ' WHERE store_id = ' . $from_store . ' AND product_id = ' . $product['pro_id'] . ','; $db_from_store = rtrim($db_from_store, ','); $product_from_store = new db_execute($db_from_store); unset($product_from_store); $db_to_store = 'UPDATE product_quantity SET pro_quantity = pro_quantity + ' . $product['pro_quantity_transfer'] . ' WHERE store_id = ' . $to_store . ' AND product_id = ' . $product['pro_id'] . ','; $db_to_store = rtrim($db_to_store, ','); $product_to_store = new db_execute($db_to_store); unset($product_to_store); } //log action log_action(ACTION_LOG_EDIT, 'Update số lượng hàng với mã phiếu chuyển kho là ' . $last_id . ' bảng product_quantity'); $array_return = array('success' => 1, 'msg' => 'Thêm mới thành công'); die(json_encode($array_return)); } }
$iQuick = getValue("iQuick", "str", "POST", ""); $record_id = getValue("record_id", "arr", "POST", ""); if (!$record_id) { redirect('listing.html'); } if ($iQuick == 'update') { $total_record = count($record_id); if ($total_record > 0) { for ($i = 0; $i < $total_record; $i++) { //Call Class generate_form(); $myform = new generate_form(); //Insert to database $myform->add('cat_name', "cat_name" . $record_id[$i], 0, 0, '', 0, '', 0, ''); $myform->add('cat_order', "cat_order" . $record_id[$i], 1, 0, '', 0, '', 0, ''); //Add table $myform->addTable($bg_table); $errorMsg .= $myform->checkdata($id_field, $record_id[$i]); //Check loi cua tat ca cac ban ghi duoc sua $errorMsgAll .= $errorMsg; if ($errorMsg == "") { $db_ex = new db_execute($myform->generate_update_SQL($id_field, $record_id[$i])); unset($db_ex); } else { echo $record_id[$i] . " : " . $errorMsg . "</br>"; } unset($myform); } } echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'; echo "Đang cập nhật dữ liệu !"; if ($errorMsgAll == "") {
$myform->add('des_name', 'des_name', 0, 0, '', 1, 'Bạn chưa nhập tên bàn'); $myform->add('des_sec_id', 'des_sec_id', 1, 0, 0, 1, 'Bạn chưa chọn khu vực'); $myform->add('des_note', 'des_note', 0, 0, '', 0); if (!$myform->checkdata()) { $db_insert = new db_execute_return(); $last_id = $db_insert->db_execute($myform->generate_insert_SQL()); unset($db_insert); //log action log_action(ACTION_LOG_ADD, 'Thêm mới bàn ăn ID ' . $last_id); redirect('index.php'); } break; case 'edit_desk': $record_id = getValue('record_id', 'int', 'POST', 0); $myform = new generate_form(); $myform->addTable('desks'); $myform->add('des_name', 'des_name', 0, 0, '', 1, 'Bạn chưa nhập tên bàn'); $myform->add('des_sec_id', 'des_sec_id', 1, 0, 0, 1, 'Bạn chưa chọn khu vực'); $myform->add('des_note', 'des_note', 0, 0, '', 0); if (!$myform->checkdata()) { $db_insert = new db_execute($myform->generate_update_SQL('des_id', $record_id)); unset($db_insert); //log action log_action(ACTION_LOG_EDIT, 'Sửa bàn ăn ID ' . $record_id); redirect('index.php'); } break; } } //Phần hiển thị //Khởi tạo
<?php $img = getValue('img', 'str', 'GET', '', 3); $img = explode('/', $img); $img = end($img); $myform = new generate_form(); $myform->add('lei_image', 'img', 0, 1, '', 1, 'error', 1, 'trùng ảnh'); $myform->addTable('log_error_image'); if (!$myform->checkdata()) { $db = new db_execute($myform->generate_insert_SQL()); unset($db); }
<?php require_once 'inc_security.php'; //Phần xử lý $action_modal = getValue('action_modal', 'str', 'POST', '', 2); $action = getValue('action', 'str', 'POST', '', 2); if ($action == 'execute') { switch ($action_modal) { case 'add_category': checkPermission('add'); $myform = new generate_form(); $myform->addTable($cat_table); $myform->add('cat_name', 'cat_name', 0, 0, '', 1, 'Bạn chưa nhập tên danh mục'); $myform->add('cat_type', 'cat_type', 0, 1, ''); $myform->add('cat_desc', 'cat_desc', 0, 0, ''); $myform->add('cat_note', 'cat_note', 0, 0, ''); if (!$myform->checkdata()) { $cat_picture = getValue('cat_picture', 'str', 'POST', ''); if ($cat_picture) { $myform->add('cat_picture', 'cat_picture', 0, 0, ''); //upload ảnh module_upload_picture($cat_picture); } $db_insert = new db_execute_return(); echo $myform->generate_insert_SQL(); $last_id = $db_insert->db_execute($myform->generate_insert_SQL()); unset($db_insert); //log action log_action(ACTION_LOG_ADD, 'Thêm mới danh mục ' . $last_id . ' bảng categories_multi'); redirect('index.php'); }
$adm_access_category .= '[' . str_replace(",","][",$menuid->getAllChildId($value)) . ']'; } $errorMsg = ""; $allow_insert = 1; $myform = new generate_form(); $myform->add("adm_loginname","adm_loginname",0,0,"",1,translate_text("Username is not empty and> 3 characters"),1,translate_text("Administrator account already exists")); $myform->add("adm_password","adm_password",4,0,"",1,translate_text("Password must be greater than 4 characters"),0,""); $myform->add("adm_email","adm_email",2,0,"",1,translate_text("Email is invalid"),0,""); $myform->add("adm_name","adm_name",0,0,"",0,"",0,""); $myform->add("adm_phone","adm_phone",0,0,"",0,"",0,""); $myform->add("adm_all_category","adm_all_category",1,0,0,0,"",0,""); $myform->add("adm_access_category","adm_access_category",0,1,"",0,"",0,""); $myform->add("adm_edit_all","adm_edit_all",1,0,0,0,"",0,""); $myform->add("admin_id","admin_id",1,1,0,0,"",0,""); $myform->addTable("admin_user"); //get vaule from POST $adm_loginname = getValue("adm_loginname","str","POST","",1); //password hash md5 --> only replace \' = ' $adm_password = getValue("adm_password","str","POST","",1); //get Access Module list $module_list = ""; $module_list = getValue("mod_id","arr","POST",""); $user_lang_id_list = getValue("user_lang_id","arr","POST",""); $arelate_select = getValue("arelate_select","arr","POST",""); if ($Action =='insert') { if ($module_list ==""){ $allow_insert = 0; $errorMsg .= translate_text("Please_select_modules!");
//check xem company ton tai chua, neu ton tai roi thi tra ve id $db_query = new db_query('SELECT phg_id FROM pharma_group WHERE phg_name = "' . $phg_name . '"'); if ($row = mysqli_fetch_assoc($db_query->result)) { $api_result = array('success' => 1, 'id' => $row['phg_id']); break; } unset($db_query); //insert company $db_insert = new db_execute_return(); $last_id = $db_insert->db_execute('INSERT INTO pharma_group(phg_name) VALUES("' . $phg_name . '")'); $api_result = array('success' => 1, 'id' => $last_id); break; case 'uploadQuestion': $time = time(); $myform = new generate_form(); $myform->addTable('questions'); $myform->add('que_title', 'que_title', 0, 0, '', 1, 'Tiêu đề trống', 1, 'Tiêu đề trùng'); $myform->add('que_username', 'que_username', 0, 0, '', 1, 'User trống'); $myform->add('que_cat_id', 'que_cat_id', 1, 0, 0); $myform->add('que_question_content', 'que_question_content', 0, 0, '', 1, 'Nội dung câu hỏi trống'); $myform->add('que_answer_content', 'que_answer_content', 0, 0, ''); $myform->add('que_professional', 'que_professional', 0, 0, ''); $myform->add('que_disease', 'que_disease', 0, 0, '', 0, 'Tên bệnh trống'); $myform->add('que_disease_id_local', 'que_disease_id_local', 1, 0, 0, 0, 'ID check bệnh local trống'); $myform->add('que_disease_link', 'que_disease_link', 0, 0, '', 0, 'Link đến list bài viết về bệnh trống'); $myform->add('que_link_origin', 'que_link_origin', 0, 0, '', 1, 'Link gốc của tin trống'); $myform->add('que_image', 'que_image', 0, 0, ''); $myform->add('que_image_profess', 'que_image_profess', 0, 0, ''); $myform->add('que_type', 'que_type', 1, 0, 0); $myform->add('que_status', 'que_status', 1, 0, 0); $myform->add('que_date', 'time', 1, 1, 0);
function ajaxedit($fs_table){ $this->edit_ajax = true; //nếu truong hợp checkbox thì chỉ thay đổi giá trị 0 và 1 thôi $checkbox = getValue("checkbox","int","GET",0); if($checkbox==1){ $record_id = getValue("record_id","int","GET",0); $field = getValue("field","str","GET","dfsfdsfdddddddddddddddd"); if(trim($field) != '' && in_array($field,$this->arrayField)){ $db_query = new db_query("SELECT " . $field . " FROM " . $fs_table . " WHERE " . $this->field_id . "=" . $record_id); if($row = mysql_fetch_assoc($db_query->result)){ $value = ($row[$field]==1) ? 0 : 1; $db_update = new db_execute("UPDATE " . $fs_table . " SET " . $field . " = " . $value . " WHERE " . $this->field_id . "=" . $record_id); unset($db_update); echo '<img src="' . $this->image_path . 'check_' . $value . '.gif" border="0">'; } unset($db_query); } exit(); } //phần sửa đổi giá trị từng trường $ajaxedit = getValue("ajaxedit","int","GET",0); $id = getValue("id","str","POST",""); $value = getValue("value","str","POST",""); $array = trim(getValue("array","str","POST","")); if($ajaxedit == 1){ $arr = explode(",",$id); $id = isset($arr[1]) ? intval($arr[1]) : 0; $field = isset($arr[0]) ? strval($arr[0]) : ''; $type = isset($arr[2]) ? intval($arr[2]) : 0; if($type == 3) $_POST["value"] = str_replace(array("."),"",$value); //print_r($_POST); if($id != 0 && in_array($field,$this->arrayField)){ $myform = new generate_form(); $myform->removeHTML(0); $myform->add($field,"value",$type,0,"",0,"",0,""); $myform->addTable($fs_table); $errorMsg = $myform->checkdata(); if($errorMsg == ""){ $db_ex = new db_execute($myform->generate_update_SQL($this->field_id,$id)); } } if($array!=''){ if(in_array($array,$this->arrayField)){ global $$array; $arr = $$array; $value = isset($arr[$value]) ? $arr[$value] : 'error'; } } echo $value; exit(); } }
} break; } die; } //xử lý $action = getValue('action', 'str', 'POST', ''); if ($action == 'execute') { $myform = new generate_form(); $myform->add('con_restaurant_name', 'con_restaurant_name', 0, 0, ''); $myform->add('con_restaurant_address', 'con_restaurant_address', 0, 0, ''); $myform->add('con_restaurant_phone', 'con_restaurant_phone', 0, 0, ''); $myform->add('con_default_svdesk', 'con_default_svdesk', 1, 0, ''); $myform->add('con_default_agency', 'con_default_agency', 1, 0, ''); $myform->add('con_default_store', 'con_default_store', 1, 0, ''); $myform->addTable('configurations'); if (!$myform->checkdata()) { //kiểm tra xem acc đã được config chưa $db_check = new db_query('SELECT * FROM configurations WHERE con_admin_id = ' . $admin_id); if (mysqli_num_rows($db_check->result) < 1) { $myform->add('con_admin_id', 'admin_id', 1, 1, 0); $db_insert = new db_execute($myform->generate_insert_SQL()); unset($db_insert); } else { $db_update = new db_execute($myform->generate_update_SQL('con_admin_id', $admin_id)); unset($db_update); } //redirect ve index redirect('index.php'); } }
$myform->add('new_cat_id', 'new_cat_id', 1, 0, 0, 1); $myform->add('new_lin_id', 'new_lin_id', 1, 0, 0, 1); $myform->add('new_picture', 'new_picture', 0, 0, ''); $myform->add('new_teaser', 'new_teaser', 0, 0, '', 1); $myform->add('new_tags', 'new_tags', 0, 0, ''); $myform->add('new_date', 'new_date', 1, 0, 0, 1); $myform->add('new_active', 'new_active', 1, 0, 0, 1); if (!$myform->checkdata()) { $db_insert = new db_execute_return(); $last_id = $db_insert->db_execute($myform->generate_insert_SQL()); unset($db_insert); //lưu ảnh if ($last_id) { $path_picture = generate_dir_upload($_POST['new_picture'], 'organic') . $_POST['new_picture']; move_uploaded_file($_FILES['data_picture']['tmp_name'], $path_picture); //lưu chi tiết tin $myform_dt = new generate_form(); $myform_dt->addTable('news_detail'); $myform_dt->add('ndt_id', 'last_id', 1, 1, 0); $myform_dt->add('ndt_content', 'ndt_content', 0, 0, ''); $myform_dt->removeHTML(0); $db_insert = new db_execute($myform_dt->generate_insert_SQL()); $total = $db_insert->total; unset($db_insert); if ($total) { echo $last_id; } else { echo 0; } } }
if (!$get_from_link) { $picture_temp = getValue('ndi_picture', 'str', 'POST', 1); $path_upload = '../../..' . get_picture_dir($picture_temp) . '/' . $picture_temp; rename('../../../temp/' . $picture_temp, $path_upload); } $db_insert = new db_execute_return(); $last_id = $db_insert->db_execute($myform->generate_insert_SQL()); unset($db_insert); /** * something code here */ //redirect if ($last_id) { //insert detail $myform_detail = new generate_form(); $myform_detail->addTable('news_disease_detail'); $myform_detail->add('ndi_id', 'last_id', 1, 1, 0); $myform_detail->add('ndi_detail', 'ndi_detail', 0, 0, '', 1); $myform_detail->removeHTML(0); $db_insert = new db_execute($myform_detail->generate_insert_SQL()); redirect($form_redirect); } } } #Phần hiển thị $rainTpl = new RainTPL(); $rainTpl->assign('load_header', $load_header); $rainTpl->assign('module_name', $module_name); $rainTpl->assign('error_msg', print_error_msg($bg_errorMsg)); $html_page = ''; $form = new form();
$record_id = getValue("record_id", "arr", "POST", ''); //Warning Error! $errorMsg = ""; //Get Action. //Call Class generate_form(); $db_query = new db_query('SELECT MAX(mod_order) as max_order FROM ' . $fs_table); $max_order = mysqli_fetch_assoc($db_query->result); $max_order = $max_order['max_order']; $myform = new generate_form(); $myform->add("mod_name", "mod_name", 0, 0, "", 1, "Bạn chưa nhập tên module", 0, ""); $myform->add("mod_path", "mod_path", 0, 0, "", 0, "", 0, ""); $myform->add("mod_listname", "mod_listname", 0, 0, "", 0, "", 0, ""); $myform->add("mod_listfile", "mod_listfile", 0, 0, "", 0, "", 0, ""); $myform->add("mod_order", "mod_order", 1, 0, 0, 0, "", 0, ""); //Add table $myform->addTable($fs_table); $iQuick = getValue("action", "str", "POST", ""); if ($iQuick == "execute") { $errorMsg = ''; $errorMsg .= $myform->checkdata(); if ($errorMsg == "") { //echo $myform->generate_insert_SQL(); $db_ex = new db_execute($myform->generate_insert_SQL()); unset($db_ex); //Hien thi loi } redirect($_SERVER['REQUEST_URI']); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
<?php require_once 'inc_security.php'; checkPermission('add'); //list thành phố $array_city = array(0 => 'Chọn tỉnh/thành phố'); $db_city = new db_query('SELECT cit_id,cit_name FROM cities ORDER BY cit_name'); while ($row = mysqli_fetch_assoc($db_city->result)) { $array_city[$row['cit_id']] = $row['cit_name']; } #Phần code xử lý $myform = new generate_form(); $myform->addTable($bg_table_district); $myform->add('dis_city_id', 'dis_city_id', 1, 0, 0, 1, 'Bạn chưa chọn tỉnh/thành phố'); $myform->add('dis_name', 'dis_name', 0, 0, '', 1, 'Bạn chưa nhập tên quận/huyện'); $myform->add('dis_static_fee', 'dis_static_fee', 1, 0, 0); $action = getValue('action', 'str', 'POST', ''); if ($action == 'execute') { $bg_errorMsg = $myform->checkdata(); if (!$bg_errorMsg) { $db_insert = new db_execute_return(); $last_id = $db_insert->db_execute($myform->generate_insert_SQL()); $form_redirect = getValue('form_redirect', 'str', 'POST', ''); redirect($form_redirect); } } #Phần hiển thị $rainTpl = new RainTPL(); $rainTpl->assign('load_header', $load_header); $rainTpl->assign('module_name', $module_name); $rainTpl->assign('error_msg', print_error_msg($bg_errorMsg));