//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"> <head> <title>Add New</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <link href="../css/bootstrap.css" rel="stylesheet"/>
VALUES("' . $pha_nhom_duoc_ly . '")'); $myform->add('pha_nhom_duoc_ly_id', 'id_ndl', 1, 1, 0); } $myform->add('pha_thanh_phan', 'pha_thanh_phan', 0, 0, '', 1); $myform->add('pha_ham_luong', 'pha_ham_luong', 0, 0, '', 0); $myform->add('pha_chi_dinh', 'pha_chi_dinh', 0, 0, '', 1); $myform->add('pha_chong_chi_dinh', 'pha_chong_chi_dinh', 0, 0, '', 0); $myform->add('pha_tuong_tac_thuoc', 'pha_tuong_tac_thuoc', 0, 0, '', 0); $myform->add('pha_tac_dung_phu', 'pha_tac_dung_phu', 0, 0, '', 0); $myform->add('pha_chu_y_de_phong', 'pha_chu_y_de_phong', 0, 0, '', 0); $myform->add('pha_lieu_luong', 'pha_lieu_luong', 0, 0, '', 0); $myform->add('pha_bao_quan', 'pha_bao_quan', 0, 0, '', 0); $form_redirect = getValue('form_redirect', 'str', 'POST', ''); $action = getValue('action', 'str', 'POST', ''); if ($action == 'execute') { $bg_errorMsg = $myform->checkdata(); /** * something code here */ if (!$bg_errorMsg) { //update ảnh $pha_image = getValue('pha_image', 'str', 'POST', ''); if ($pha_image) { $myform->add('pha_image', 'pha_image', 0, 1, ''); //move ảnh generate_dir_upload($pha_image, 'organic'); $path_upload = '../../..' . get_picture_dir($pha_image) . '/' . $pha_image; rename('../../../temp/' . $pha_image, $path_upload); } $db_update = new db_execute($myform->generate_update_SQL($id_field, $record_id)); unset($db_update);
$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 == "") { redirect($returnurl);
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(); } }
exit("Xin loi ban ko co quyen"); } //authen valid - get data and save post //var_dump($_FILES['data_picture']); $myform = new generate_form(); $myform->addTable('news'); $myform->add('new_title', 'new_title', 0, 0, '', 1, 'Tiêu đề trống'); $myform->add('new_title_md5', 'new_title_md5', 0, 0, '', 1, ''); $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_ex); } } redirect($ff_redirect_succ); exit(); } } //Edit user password $errorMsgpass = ''; if ($Action =='update_password') { $myform = new generate_form(); $myform->add("adm_password","adm_password",4,0,"",1,translate_text("Please enter new password"),0,""); $myform->addTable($fs_table); $errorMsgpass .= $myform->checkdata(); if($errorMsgpass == ""){ $db_ex = new db_execute($myform->generate_update_SQL("adm_id",$iAdm)); unset($db_ex); echo '<script>alert("' . translate_text("Your_new_password_has_been_updated") . '")</script>'; redirect($ff_redirect_succ); } } //Select access module $acess_module = ""; $arrayAddEdit = array(); $db_access = new db_query("SELECT *
redirect('index.php'); } break; case 'edit_record': $record_id = getValue('record_id', 'int', 'POST', 0); $myform = new generate_form(); $myform->addTable($bg_table); /* code something */ $myform->add('cus_name', 'cus_name', 0, 0, '', 1, 'Bạn chưa nhập tên khách hàng'); $myform->add('cus_address', 'cus_address', 0, 0, '', 1, 'Bạn chưa nhập địa chỉ'); $myform->add('cus_phone', 'cus_phone', 0, 0, '', 0, ''); $myform->add('cus_email', 'cus_email', 0, 0, '', 1, ''); $myform->add('cus_cat_id', 'cus_cat_id', 1, 0, '', 0, ''); $myform->add('cus_code', 'cus_code', 0, 0, '', 0, ''); $myform->add('cus_note', 'cus_note', 0, 0, '', 0, ''); $bg_errorMsg .= $myform->checkdata(); if (!$myform->checkdata()) { $cus_picture = getValue('cus_picture', 'str', 'POST', ''); if ($cus_picture) { $myform->add('cus_picture', 'cus_picture', 0, 0, ''); //upload ảnh module_upload_picture($cus_picture); } $db_insert = new db_execute($myform->generate_update_SQL($id_field, $record_id)); unset($db_insert); //log action log_action(ACTION_LOG_ADD, 'Chỉnh sửa bản ghi ' . $record_id . ' bảng ' . $bg_table); redirect('index.php'); } break; }
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)); }
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)); } }
$myform = new generate_form(); $myform->removeHTML(0); //Warning Error! $errorMsgEmail = ""; //Get Action. $action = getValue("action", "str", "POST", ""); if($action == "update_email"){ $faq_question = getValue("adm_email","str","POST",""); //Insert to database $myform->add("adm_email","adm_email",2,0,"",1,translate_text("Please_enter_your_email"),0,""); //Add table $myform->addTable($fs_table); //Check Error! $errorMsgEmail .= $myform->checkdata(); if($errorMsgEmail == ""){ $db_ex = new db_execute($myform->generate_update_SQL("adm_id", $admin_id)); //echo $myform->generate_update_SQL("adm_id", $admin_id); echo "<script language='javascript'>alert('" . translate_text("information_was_updated_successfully") . "');</script>"; //Redirect to: redirect($fs_redirect); exit(); } } //add form for javacheck $myform->addFormname("change_email"); //Change your password ----------------------------------------> //Get $Errormessage $Errormessage = "";
$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); $myform->removeHTML(0); $error_msg = $myform->checkdata(); if (!$error_msg) { foreach ($_FILES as $key => $image_file) { $path_picture = generate_dir_upload($image_file['name'], 'organic') . $image_file['name']; move_uploaded_file($image_file['tmp_name'], $path_picture); } $db_insert = new db_execute_return(); $last_id = $db_insert->db_execute($myform->generate_insert_SQL()); unset($db_insert); $api_result = array('success' => 1, 'id' => $last_id, 'sql' => $myform->generate_insert_SQL()); } else { $api_result = array('error' => 1, 'msg' => $myform->checkdata() . $myform->generate_insert_SQL()); } break; }
$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"> <div class="form-law col-xs-5">