$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"/> <link href="../css/font-awesome.min.css" rel="stylesheet"/> <link href="../css/common.css" rel="stylesheet"/> <link href="../css/template.css" rel="stylesheet"/>
<?php require_once 'inc_security.php'; checkPermission('add'); #Phần code xử lý $myform = new generate_form(); $myform->addTable($bg_table); $myform->add('cit_name', 'cit_name', 0, 0, '', 1, 'Bạn chưa nhập tên tỉnh - thành phố'); $myform->add('cit_tw', 'cit_tw', 1, 0, ''); $myform->add('cit_static_fee', 'cit_static_fee', 1, 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()); //insert quận huyện nếu có $array_district = getValue('array_district', 'arr', 'POST', ''); if ($array_district) { $sql_district = 'INSERT INTO ' . $bg_table_district . '(dis_city_id,dis_name) VALUES'; foreach ($array_district as $district) { if (!$district) { continue; } $district = remove_magic_quote($district); $district = removeScript($district); $district = removeHTML($district); $sql_district .= '(' . $last_id . ',"' . $district . '"),'; } $sql_district = rtrim($sql_district, ','); //insert
$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; } } }
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); }
$myform->evaluate(); #+ #+ Neu nhu co submit form if($action == "submitForm"){ #+ #+ Kiểm tra lỗi $errorMsg .= $myform->checkdata(); $errorMsg .= $myform->strErrorField ; //Check Error! if($errorMsg == ""){ #+ #+ Thuc hien query $db_ex = new db_execute_return(); $query = $myform->generate_insert_SQL(); $last_id = $db_ex->db_execute($query); $record_id = $last_id; //echo $query;exit(); $iType = getValue("mnu_type","int","POST",""); $iParent = getValue("mnu_parent_id","str","POST",""); $fs_redirect = $after_save_data. "?record_id=".$record_id."&category=".getValue("sta_category_id","int","POST"); redirect($fs_redirect); exit(); } } #+ #+ Khai bao ten form
function AddRecord() { global $time_end, $time_start; //check quyền checkCustomPermission('add'); // ten chien dich khuyen mai $promo_name = getValue('name', 'str', 'POST', ''); if (!$promo_name) { $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); // 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', '', 3); $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', '', 3); $list_menus = getValue('menus', 'arr', 'POST', array()); // dieu kien giam gia $promo_condition = getValue('condition', 'int', '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)); } if (!$list_menus && !$promo_value) { $array_return['error'] = 0; $array_return['msg'] = 'Chương trình khuyến mại không phù hợp'; die(json_encode($array_return)); } // insert 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_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['error'] = 0; $array_return['msg'] = 'Đã có lỗi xảy ra. Vui lòng thử lại sau'; $array_return['success'] = 1; die(json_encode($array_return)); } $db_promo_menu = '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_promo_menu .= '( ' . $last_id . ', ' . $menu['men_id'] . ', ' . $menu['men_value'] . ', ' . $menu['men_type'] . ' ),'; } $db_promo_menu = rtrim($db_promo_menu, ','); $db_insert_menu = new db_execute($db_promo_menu); unset($db_insert_menu); //log action log_action(ACTION_LOG_ADD, 'Thêm mới chiến dịch ' . $last_id . ' bảng promotions'); $array_return = array('success' => 1, 'msg' => 'Thêm mới 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->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; }