/
home
/
efamember
/
domains
/
efa-member.com
/
public_html
/
main
/
ajax
/
account_receipt
/
up file
home
<?php session_start(); include('../../../config/main_function.php'); $secure = "cAh3DrJACzw4RbU"; $connection = connectDB($secure); if ($connection) { //// head $receipt_id = getRandomID2(10, 'tbl_receipt_head', 'receipt_id'); $receipt_no = getRunNO($size = 4, "REC" . $text = date('y') + 43. . date('m'), 'tbl_receipt_head', 'receipt_no'); $create_user_id = mysqli_real_escape_string($connection, $_POST['create_user_id']); $temp_id = explode(".", $create_user_id); $create_user_id = bigsara_decode($temp_id[0], $temp_id[1]); $receipt_date = date_picker(mysqli_real_escape_string($connection, $_POST['receipt_date'])); $ref_number = mysqli_real_escape_string($connection, $_POST['ref_number']); $customer_name = mysqli_real_escape_string($connection, $_POST['customer_name']); $customer_tax_no = mysqli_real_escape_string($connection, $_POST['tax_number']); $customer_phone = mysqli_real_escape_string($connection, $_POST['customer_phone']); $customer_address = mysqli_real_escape_string($connection, $_POST['customer_address']); $customer_email = mysqli_real_escape_string($connection, $_POST['customer_email']); $recipt_remark = mysqli_real_escape_string($connection, $_POST['recipt_remark']); $member_id = mysqli_real_escape_string($connection, $_POST['get_member']); // get payment $sql = "SELECT pack.unit_price ,coup.discount_amount ,coup.discount_type FROM tbl_member mem LEFT JOIN tbl_package_price pack ON pack.member_type = mem.register_level LEFT JOIN tbl_member_payment pay ON pay.member_id = mem.member_id LEFT JOIN tbl_discount_coupon coup ON coup.coupon_id = pay.coupon_id WHERE mem.member_id = '$member_id'"; $res = mysqli_query($connection, $sql); $row = mysqli_fetch_assoc($res); if ($row['register_level'] == 'g9k1s') { $member_level = 'ทั่วไป'; } elseif ($row['register_level'] == 'kki22') { $member_level = 'วิสามัญ'; } elseif ($row['register_level'] == 'x9fkq') { $member_level = 'สามัญ.'; } //// detail $receipt_detail_id = getRandomID(10, 'tbl_receipt_detail', 'receipt_detail_id'); $product_name = "ค่าสมัครสมาชิกระดับ" . $member_level; // $product_description = $unit = 'รายการ'; $quantity = '1'; $cost_per_unit = $row['unit_price']; $discount_per_unit = ($row['discount_amount'] != "" ? $row['discount_amount'] : "0"); $discount_type = $row['discount_type']; $total_amount = $row['unit_price'] - $row['discount_amount']; $list_order = list_order("tbl_receipt_detail", "list_order", "WHERE receipt_id = ' . $receipt_id. '"); $sql_head = "INSERT INTO tbl_receipt_head SET receipt_id = '$receipt_id ', create_user_id = '$create_user_id', receipt_no = '$receipt_no', receipt_date = '$receipt_date', member_id = '$member_id', ref_invoice_id = '$ref_number', customer_name = '$customer_name', customer_tax_no = '$customer_tax_no', customer_phone = '$customer_phone', customer_address = '$customer_address', customer_email = '$customer_email', discount_amount = '$discount_per_unit', discount_type = '$discount_type', total_amount = '$total_amount', remark = '$recipt_remark' "; $res_head = mysqli_query($connection, $sql_head) or die($connection->error); if ($res_head) { $sql_detail = "INSERT INTO tbl_receipt_detail SET receipt_detail_id = '$receipt_detail_id', receipt_id = '$receipt_id', product_name = '$product_name', unit = '$unit', quantity = '$quantity', cost_per_unit = '$cost_per_unit', discount_per_unit = '$discount_per_unit', discount_type = '$discount_type', total_amount = '$total_amount', list_order = '$list_order' "; $res_detail = mysqli_query($connection, $sql_detail) or die($connection->error); if ($res_detail) { $arr['result'] = 1; } else { $arr['result'] = 0; } } else { $arr['result'] = 0; } } else { $arr['result'] = 9; } echo json_encode($arr); ?>