コード例 #1
0
<?php

require_once 'inc_security.php';
//kiểm tra quyền nhập hàng
checkCustomPermission('add');
//Đếm tất cả số mặt hàng đang có
$db_count = new db_count('SELECT count(*) AS count FROM products');
$all_count = $db_count->total;
unset($db_count);
//Lấy danh mục mặt hàng
$pro_cat_id = array('' => 'Tất cả (' . $all_count . ')');
$db_query = new db_query('SELECT * FROM categories_multi WHERE cat_type = "products"');
while ($row = mysqli_fetch_assoc($db_query->result)) {
    //đếm số mặt hàng trong cate này
    $db_count = new db_count('SELECT count(*) AS count FROM products WHERE pro_cat_id = ' . $row['cat_id']);
    $pro_count = $db_count->total;
    unset($db_count);
    $pro_cat_id[$row['cat_id']] = $row['cat_name'] . ' (' . $pro_count . ')';
}
unset($db_query);
$left_column = '';
$right_column = '';
$left_column .= '
<div class="text-center section-title">Danh sách mặt hàng</div>
<div id="mindow-listing-product">';
/*
    Phần hiển thị danh sách mặt hàng
*/
$listing_menu = '';
$list = new dataGrid('pro_id', 30, '#mindow-listing-product');
$list->add('pro_name', 'Tên mặt hàng', 'string', 1, 0);
コード例 #2
0
ファイル: ajax.php プロジェクト: virutmath/crm_local
 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));
 }
コード例 #3
0
ファイル: index.php プロジェクト: virutmath/crm_local
     if (!$mep_quantity) {
         add_error_msg('Số lượng không hợp lệ');
     }
     if (!$bg_errorMsg) {
         $db = new db_execute('INSERT INTO menu_products (mep_menu_id, mep_product_id, mep_quantity)
                               VALUES (' . $mep_menu_id . ', ' . $mep_product_id . ', ' . $mep_quantity . ')
                               ON DUPLICATE KEY UPDATE
                               mep_quantity = ' . $mep_quantity);
         log_action(ACTION_LOG_ADD, 'Thêm nguyên liệu pro_id ' . $mep_product_id . ' số lượng ' . $mep_quantity . ' vào thực đơn ' . $mep_menu_id);
         redirect('index.php');
     }
     break;
 case 'edit_menu_product':
     //quyền đặc biệt : công thức chế biến
     $custom_permission = 'CONG_THUC_CHE_BIEN';
     checkCustomPermission($custom_permission);
     $mep_menu_id = getValue('mep_menu_id', 'int', 'POST', 0);
     $mep_product_id = getValue('mep_product_id', 'int', 'POST', 0);
     $mep_quantity = getValue('mep_quantity', 'flo', 'POST', 0);
     //check dữ liệu
     if (!$mep_menu_id) {
         add_error_msg('Không có thực đơn nào được chọn');
     }
     if (!$mep_product_id) {
         add_error_msg('Không có sản phẩm nào được chọn');
     }
     if (!$mep_quantity) {
         add_error_msg('Số lượng không hợp lệ');
     }
     if (!$bg_errorMsg) {
         $db = new db_execute('UPDATE menu_products
コード例 #4
0
ファイル: ajax.php プロジェクト: virutmath/crm_local
 function loadFormEditMenuProduct()
 {
     //Kiểm tra quyền
     checkCustomPermission('CONG_THUC_CHE_BIEN');
     //lấy ra id thực đơn
     $menu_id = getValue('menu', 'int', 'POST', 0);
     //lấy ra id của nguyên liệu
     $record_id = getValue('record_id', 'int', 'POST', 0);
     //open modal
     $this->openModal();
     //...add more and morestring
     //lấy chi tiết nguyên liệu
     $db_query = new db_query('SELECT pro_name, uni_name, mep_quantity
                               FROM menu_products
                               LEFT JOIN products ON mep_product_id = pro_id
                               LEFT JOIN units ON uni_id = pro_unit_id
                               WHERE pro_id = ' . $record_id . '
                               AND mep_menu_id = ' . $menu_id . '
                               LIMIT 1');
     $row = mysqli_fetch_assoc($db_query->result);
     unset($db_query);
     $this->add($this->form->hidden(array('name' => 'mep_menu_id', 'id' => 'mep_menu_id', 'value' => $menu_id)));
     $this->add($this->form->hidden(array('name' => 'mep_product_id', 'id' => 'mep_product_id', 'value' => $record_id)));
     $this->add($this->form->staticInput(array('label' => 'Nguyên liệu', 'value' => $row['pro_name'])));
     $this->add($this->form->number(array('label' => 'Số lượng', 'name' => 'mep_quantity', 'id' => 'mep_quantity', 'addon' => $row['uni_name'], 'value' => $row['mep_quantity'])));
     //...
     //close modal
     $this->closeModal('edit_menu_product');
 }
コード例 #5
0
ファイル: import.php プロジェクト: virutmath/crm_local
<?php

require_once 'inc_security.php';
//kiểm tra quyền nhập hàng
checkCustomPermission('NHAP_HANG');
//Đếm tất cả số thực đơn đang có
$db_count = new db_count('SELECT count(*) AS count FROM products');
$all_count = $db_count->total;
unset($db_count);
//Lấy danh mục thực đơn
$pro_cat_id = array('' => 'Tất cả (' . $all_count . ')');
$db_query = new db_query('SELECT * FROM categories_multi WHERE cat_type = "products"');
while ($row = mysqli_fetch_assoc($db_query->result)) {
    //đếm số thực đơn trong cate này
    $db_count = new db_count('SELECT count(*) AS count FROM products WHERE pro_cat_id = ' . $row['cat_id']);
    $pro_count = $db_count->total;
    unset($db_count);
    $pro_cat_id[$row['cat_id']] = $row['cat_name'] . ' (' . $pro_count . ')';
}
$mindow_title = 'Nhập hàng vào kho';
$left_column = '';
$right_column = '';
$left_column .= '
<div class="text-center section-title">Danh sách mặt hàng</div>
<div id="mindow-listing-product">';
//Danh sách mặt hàng
$listing_product = '';
$list_product_array = array();
$list = new dataGrid('pro_id', $listing_product_size, '#mindow-listing-product');
$list->add('pro_name', 'Tên mặt hàng', 'string', 1, 0);
$list->add('', 'ĐVT');
コード例 #6
0
ファイル: order.php プロジェクト: virutmath/crm_local
<?php

require_once 'inc_security.php';
checkCustomPermission('IN_CHE_BIEN');
if (!$_list_desk) {
    exit('Chi nhánh hiện tại chưa tạo bàn nào');
}
$desk_id = getValue('desk_id', 'int', 'GET', 0);
$list_desk = array();
//lấy ra chi tiết bàn
$desk_detail = array();
foreach ($_list_desk as $desk) {
    $list_desk[] = $desk['des_id'];
    if ($desk['des_id'] == $desk_id) {
        $desk['desk_name'] = $desk['sec_name'] . ' - ' . $desk['des_name'];
        $desk_detail = $desk;
    }
}
if (!$desk_detail) {
    exit('Bàn chưa được mở hoặc không khả dụng');
}
$list_desk = implode(',', $list_desk);
//kiểm tra xem bàn có mở hay không
$sql_check_table = 'SELECT cdm_desk_id
                    FROM current_desk_menu
                    WHERE cdm_desk_id = ' . $desk_id . '
                    LIMIT 1';
$db_check_table = new db_query($sql_check_table);
if (!mysqli_num_rows($db_check_table->result)) {
    exit('Không thể in thực đơn cho bàn trống');
}
コード例 #7
0
ファイル: ajax.php プロジェクト: virutmath/crm_local
 function importProduct()
 {
     //check quyền
     checkCustomPermission('NHAP_HANG');
     global $admin_id, $configuration;
     $array_return = array();
     //kiểm tra xem có hóa đơn nào thực hiện ko, nếu có thì exit luôn
     $db_trigger = new db_query('SELECT tri_status FROM triggers WHERE tri_key = "billSubmit" LIMIT 1');
     $trigger = mysqli_fetch_assoc($db_trigger->result);
     unset($db_trigger);
     if ($trigger['tri_status'] == 1) {
         //đang có hóa đơn được thanh toán, exit luôn
         $array_return['error'] = 'Đang có hóa đơn khác được thanh toán, bạn vui lòng thử lại trong giây lát!';
         $this->add($array_return);
         return false;
     }
     //Không có hóa đơn nào đang được xử lý - cập nhật trigger status thành 1 để bắt đầu vào hàm
     $db_update = new db_execute('UPDATE triggers SET tri_status = 1 WHERE tri_key = "billSubmit" LIMIT 1');
     unset($db_update);
     $list_product = getValue('products', 'arr', 'POST', array());
     //loại thanh toán
     $pay_type = getValue('pay_type', 'int', 'POST', 0);
     if ($pay_type !== PAY_TYPE_CASH) {
         $pay_type = PAY_TYPE_CARD;
     }
     //tính tổng tiền cần thanh toán của hóa đơn
     $bio_total_money = 0;
     foreach ($list_product as $product) {
         $bio_total_money += $product['pro_number'] * $product['pro_price'];
     }
     //insert vào bảng hóa đơn nhập hàng bill_out
     //thời gian nhập hàng
     $bio_start_time = getValue('start_date', 'int', 'POST', 0);
     //kho hàng
     $bio_store_id = getValue('store_id', 'int', 'POST', 0);
     //Trạng thái hóa đơn - ghi nợ hay đã thanh toán đủ
     $is_debit = getValue('is_debit', 'int', 'POST', 0);
     $money_debit = getValue('money_debit', 'int', 'POST', 0);
     $date_debit = getValue('date_debit', 'str', 'POST', 0, 3);
     $date_debit_convert = convertDateTime($date_debit);
     if ($is_debit) {
         if ($date_debit_convert <= time()) {
             //thời gian trả nợ không phù hợp
             $array_return['error'] = 'Thời gian hẹn trả không phù hợp!';
             $this->add($array_return);
             return false;
         }
         if ($money_debit <= 0 || $money_debit > $bio_total_money) {
             $array_return['error'] = 'Số tiền trả trước không phù hợp!';
             $this->add($array_return);
             return false;
         }
         if ($money_debit == $bio_total_money) {
             //thanh toán hết
             $is_debit = 0;
         }
     }
     //trạng thái thanh toán hóa đơn
     $bio_status = $is_debit ? BILL_STATUS_DEBIT : BILL_STATUS_SUCCESS;
     if ($bio_status == BILL_STATUS_DEBIT) {
         //gửi lên money_debit là số tiền trả trước
         //khi lưu vào bio_money_debit ta lưu số tiền còn nợ
         $bio_money_debit = $bio_total_money - $money_debit;
         $bio_date_debit = $date_debit_convert;
     } else {
         $bio_money_debit = 0;
         $bio_date_debit = 0;
     }
     //nhà cung cấp
     $bio_supplier_id = getValue('supplier', 'int', 'POST', 0);
     //check nhà cung cấp
     if (!$bio_supplier_id) {
         $array_return['error'] = 'Bạn chưa chọn nhà cung cấp!';
         $this->add($array_return);
         return false;
     }
     //ghi chú
     $bio_note = getValue('note', 'str', 'POST', '', 3);
     //người nhập hàng
     $bio_admin_id = $admin_id;
     $sql_insert = 'INSERT INTO bill_out (bio_start_time,
                                          bio_store_id,
                                          bio_status,
                                          bio_total_money,
                                          bio_supplier_id,
                                          bio_note,
                                          bio_type,
                                          bio_admin_id,
                                          bio_money_debit,
                                          bio_date_debit)
                    VALUES (
                    ' . $bio_start_time . ',
                    ' . $bio_store_id . ',
                    ' . $bio_status . ',
                    ' . $bio_total_money . ',
                    ' . $bio_supplier_id . ',
                    "' . $bio_note . '",
                    ' . $pay_type . ',
                    ' . $bio_admin_id . ',
                    ' . $bio_money_debit . ',
                    ' . $bio_date_debit . '
                    )';
     $db_insert = new db_execute_return();
     //echo $sql_insert;
     $last_id = $db_insert->db_execute($sql_insert);
     unset($db_insert);
     if (!$last_id) {
         //lỗi
         $array_return = array('error' => 'Đã có lỗi xảy ra! Vui lòng thử lại sau');
         echo json_encode($array_return);
         exit;
     }
     //sử dụng id của hóa đơn để insert vào bảng bill_out_detail
     foreach ($list_product as $product) {
         //mã hóa đơn
         $bid_bill_id = $last_id;
         //mã mặt hàng
         $bid_pro_id = $product['pro_id'];
         //số lượng
         $bid_pro_number = $product['pro_number'];
         //giá nhập
         $bid_pro_price = $product['pro_price'];
         $sql_insert = 'INSERT INTO bill_out_detail (bid_bill_id, bid_pro_id, bid_pro_number, bid_pro_price)
                        VALUES (
                        ' . $bid_bill_id . ',
                        ' . $bid_pro_id . ',
                        ' . $bid_pro_number . ',
                        ' . $bid_pro_price . '
                        )';
         $db_insert = new db_execute($sql_insert);
         unset($db_insert);
         //cộng số lượng vào kho
         //nếu không có bản ghi nào thì insert, không thì update
         $db_update = new db_execute('INSERT INTO product_quantity (product_id,store_id,pro_quantity)
                                      VALUES(' . $bid_pro_id . ',' . $bio_store_id . ',' . $bid_pro_number . ')
                                      ON DUPLICATE KEY UPDATE pro_quantity = pro_quantity + ' . $bid_pro_number);
         unset($db_update);
     }
     //insert 1 phiếu chi
     $fin_date = time();
     $fin_updated_time = time();
     //số tiền chi
     $fin_money = $bio_total_money;
     //nếu ghi nợ thì số tiền chi bằng số tiền trả trước
     if ($bio_status == BILL_STATUS_DEBIT) {
         $fin_money = $money_debit;
     }
     //lý do chi
     $fin_reason_other = 'Nhập hàng';
     //mã hóa đơn nhập hàng
     $fin_billcode = $last_id;
     //lấy thong tin nhà cung cấp
     $db_sup = new db_query('SELECT * FROM suppliers WHERE sup_id = ' . $bio_supplier_id . ' LIMIT 1');
     $supplier_data = mysqli_fetch_assoc($db_sup->result);
     unset($db_sup);
     $fin_username = $supplier_data['sup_name'];
     $fin_address = $supplier_data['sup_address'];
     $fin_cat_id = FINANCIAL_CAT_NHAP_HANG;
     $fin_pay_type = $pay_type;
     $fin_note = $bio_note;
     $fin_admin_id = $admin_id;
     $fin_agency_id = $configuration['con_default_agency'];
     //insert vào bảng financial
     $sql_insert = 'INSERT INTO financial (fin_date, fin_updated_time, fin_money, fin_reason_other, fin_billcode, fin_username, fin_address, fin_cat_id, fin_pay_type, fin_note, fin_admin_id, fin_agency_id)
                    VALUES (
                    ' . $fin_date . ',
                    ' . $fin_updated_time . ',
                    ' . $fin_money . ',
                    "' . $fin_reason_other . '",
                    "' . $fin_billcode . '",
                    "' . $fin_username . '",
                    "' . $fin_address . '",
                    ' . $fin_cat_id . ',
                    ' . $fin_pay_type . ',
                    "' . $fin_note . '",
                    ' . $fin_admin_id . ',
                    ' . $fin_agency_id . '
                    )';
     $db_insert = new db_execute_return();
     $fin_insert_id = $db_insert->db_execute($sql_insert);
     //thực hiện update trigger về 0 để giải phóng function
     $db_update = new db_execute('UPDATE triggers SET tri_status = 0 WHERE tri_key = "billSubmit" LIMIT 1');
     unset($db_update);
     if (!$fin_insert_id) {
         //lỗi
         $array_return = array('error' => 'Đã có lỗi xảy ra! Vui lòng thử lại sau');
         echo json_encode($array_return);
         exit;
     } else {
         $array_return = array('success' => 1, 'fin_id' => $fin_insert_id, 'bio_id' => $last_id);
         echo json_encode($array_return);
         exit;
     }
 }
コード例 #8
0
ファイル: edit.php プロジェクト: virutmath/crm_local
<?php

require_once 'inc_security.php';
//kiểm tra quyền nhập hàng
checkCustomPermission('edit');
// lấy record_id bảng promotion
$record_id = getValue('record_id', 'int', 'GET', 0);
//Đếm tất cả số thực đơn đang có
$db_count = new db_count('SELECT count(*) AS count FROM menus');
$all_count = $db_count->total;
unset($db_count);
//Lấy danh mục thực đơn
$men_cat_id = array('' => 'Tất cả (' . $all_count . ')');
$db_query = new db_query('SELECT * FROM categories_multi WHERE cat_type = "menus"');
while ($row = mysqli_fetch_assoc($db_query->result)) {
    //đếm số thực đơn trong cate này
    $db_count = new db_count('SELECT count(*) AS count FROM menus WHERE men_cat_id = ' . $row['cat_id']);
    $men_count = $db_count->total;
    unset($db_count);
    $men_cat_id[$row['cat_id']] = $row['cat_name'] . ' (' . $men_count . ')';
}
$left_column = '';
$right_column = '';
$left_column .= '
<div class="text-center section-title">Danh sách thực đơn</div>
<div id="mindow-listing-menu">';
//Danh sách mặt hàng
$listing_menu = '';
$list = new dataGrid('men_id', 100, '#mindow-listing-menu');
$list->add('men_name', 'Tên thực đơn', 'string', 1, 0);
$list->add('', 'ĐVT');