|
@@ -188,13 +188,13 @@ const C_zip = "zip";
|
|
|
// generated-code:end
|
|
// generated-code:end
|
|
|
|
|
|
|
|
local globals = getroottable();
|
|
local globals = getroottable();
|
|
|
-if(!globals.rawget("APP_CODE_FOLDER", false)) ::APP_CODE_FOLDER <- ".";
|
|
|
|
|
|
|
+if(!table_rawget(globals, "APP_CODE_FOLDER", false)) ::APP_CODE_FOLDER <- ".";
|
|
|
|
|
|
|
|
local constants = getconsttable();
|
|
local constants = getconsttable();
|
|
|
|
|
|
|
|
local function getOurbizDBFileName(){
|
|
local function getOurbizDBFileName(){
|
|
|
- if(globals.rawget("jniLog", false)) return APP_CODE_FOLDER + "/ourbiz.db";
|
|
|
|
|
- if(globals.rawget("WIN32", false)) return APP_CODE_FOLDER + "/../../ourbiz-uk/ourbiz.db";
|
|
|
|
|
|
|
+ if(table_rawget(globals, "jniLog", false)) return APP_CODE_FOLDER + "/ourbiz.db";
|
|
|
|
|
+ if(table_rawget(globals, "WIN32", false)) return APP_CODE_FOLDER + "/../../ourbiz-uk/ourbiz.db";
|
|
|
return "/home/mingo/dev/FrontAccountLua/ourbiz.db";
|
|
return "/home/mingo/dev/FrontAccountLua/ourbiz.db";
|
|
|
//return "file:ourbiz_db?mode=memory&cache=shared";
|
|
//return "file:ourbiz_db?mode=memory&cache=shared";
|
|
|
}
|
|
}
|
|
@@ -206,7 +206,7 @@ local function getOurbizDB(){
|
|
|
//return checkCachedDB(APP_CODE_FOLDER + "/ourbiz.db");
|
|
//return checkCachedDB(APP_CODE_FOLDER + "/ourbiz.db");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-if(globals.rawget("AT_DEV_DBG", false) || !globals.rawget("PdfSqlTable", false)) {
|
|
|
|
|
|
|
+if(table_rawget(globals, "AT_DEV_DBG", false) || !table_rawget(globals, "PdfSqlTable", false)) {
|
|
|
dofile(APP_CODE_FOLDER + "/pdf-table.nut");
|
|
dofile(APP_CODE_FOLDER + "/pdf-table.nut");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -225,7 +225,7 @@ local function escape_sql_like_search_str(str){
|
|
|
local function mkEmptyWhenZero(tbl, key){
|
|
local function mkEmptyWhenZero(tbl, key){
|
|
|
if (type(key) == "array"){
|
|
if (type(key) == "array"){
|
|
|
foreach( v in key ) {
|
|
foreach( v in key ) {
|
|
|
- if (tbl.rawget(v, false) == "0") tbl[v] = "";
|
|
|
|
|
|
|
+ if (table_rawget(tbl, v, false) == "0") tbl[v] = "";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
else if (tbl[key] == 0) tbl[key] = "";
|
|
else if (tbl[key] == 0) tbl[key] = "";
|
|
@@ -240,8 +240,9 @@ local function mytofloat(val){
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+local sqlNull = SQLite3.Null;
|
|
|
local function add2sle(out_result, str){
|
|
local function add2sle(out_result, str){
|
|
|
- str = str.tostring();
|
|
|
|
|
|
|
+ str = (str == sqlNull ? "" : str).tostring();
|
|
|
out_result.write(get_sle_size(str.len()), str);
|
|
out_result.write(get_sle_size(str.len()), str);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -285,7 +286,7 @@ local function mkSLEArray(str_buf, header, body, doAppend=false)
|
|
|
str_buf.write("]]");
|
|
str_buf.write("]]");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-constants.rawdelete("TimePeriode");
|
|
|
|
|
|
|
+table_rawdelete(constants, "TimePeriode");
|
|
|
|
|
|
|
|
//enum do not does autonumber with initialization
|
|
//enum do not does autonumber with initialization
|
|
|
enum TimePeriode {is_years = 1, is_months = 2, is_weeks = 3, is_days = 4};
|
|
enum TimePeriode {is_years = 1, is_months = 2, is_weeks = 3, is_days = 4};
|
|
@@ -326,17 +327,17 @@ local function get_sql_bar_chart_statistics_periodes (periode_count, periode_typ
|
|
|
|
|
|
|
|
local function getOptionsFromMap(map){
|
|
local function getOptionsFromMap(map){
|
|
|
local opt = {};
|
|
local opt = {};
|
|
|
- opt.search_str <- map.rawget("search_str", null);
|
|
|
|
|
- opt.select_fields <- map.rawget("select_fields", null);
|
|
|
|
|
- opt.search_on <- map.rawget("search_on", "1"); //to make easy on html interface
|
|
|
|
|
|
|
+ opt.search_str <- table_rawget(map, "search_str", null);
|
|
|
|
|
+ opt.select_fields <- table_rawget(map, "select_fields", null);
|
|
|
|
|
+ opt.search_on <- table_rawget(map, "search_on", "1"); //to make easy on html interface
|
|
|
local CHECK_BOOL = function(field){
|
|
local CHECK_BOOL = function(field){
|
|
|
- local value = map.rawget(field, null);
|
|
|
|
|
|
|
+ local value = table_rawget(map, field, null);
|
|
|
if (value == "1") opt[field] <- "1";
|
|
if (value == "1") opt[field] <- "1";
|
|
|
else opt[field] <- null;
|
|
else opt[field] <- null;
|
|
|
}
|
|
}
|
|
|
local math_floor = math.floor;
|
|
local math_floor = math.floor;
|
|
|
local CHECK_INT_DFLT = function(field, dflt) {
|
|
local CHECK_INT_DFLT = function(field, dflt) {
|
|
|
- local value = map.rawget(field, dflt).tointeger();
|
|
|
|
|
|
|
+ local value = table_rawget(map, field, dflt).tointeger();
|
|
|
opt[field] <- math_floor(value);
|
|
opt[field] <- math_floor(value);
|
|
|
}
|
|
}
|
|
|
local CHECK_INT = function(field) {CHECK_INT_DFLT(field, 0) };
|
|
local CHECK_INT = function(field) {CHECK_INT_DFLT(field, 0) };
|
|
@@ -378,7 +379,7 @@ local function getOptionsFromMap(map){
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
local function checkQueryStringSAB(qs_tbl, so=null){
|
|
local function checkQueryStringSAB(qs_tbl, so=null){
|
|
|
- local qs_sab = qs_tbl.rawget("sab", null);
|
|
|
|
|
|
|
+ local qs_sab = table_rawget(qs_tbl, "sab", null);
|
|
|
if (qs_sab){
|
|
if (qs_sab){
|
|
|
if (qs_sab == "S") {
|
|
if (qs_sab == "S") {
|
|
|
if(so) so.sales <- true;
|
|
if(so) so.sales <- true;
|
|
@@ -396,7 +397,7 @@ local function checkQueryStringSAB(qs_tbl, so=null){
|
|
|
local function get_search_options(req){
|
|
local function get_search_options(req){
|
|
|
local search_opt = getOptionsFromMap(req);
|
|
local search_opt = getOptionsFromMap(req);
|
|
|
|
|
|
|
|
- local sab = req.rawget("sab", null);
|
|
|
|
|
|
|
+ local sab = table_rawget(req, "sab", null);
|
|
|
if (sab && sab.len() > 0){
|
|
if (sab && sab.len() > 0){
|
|
|
local c = sab.toupper();
|
|
local c = sab.toupper();
|
|
|
if (c == "S") search_opt.sales <- true;
|
|
if (c == "S") search_opt.sales <- true;
|
|
@@ -432,7 +433,7 @@ local DB_Manager = class {
|
|
|
mf.write("insert into ", table_name, "(")
|
|
mf.write("insert into ", table_name, "(")
|
|
|
local isFirst = true;
|
|
local isFirst = true;
|
|
|
foreach( k,v in editable_fields) {
|
|
foreach( k,v in editable_fields) {
|
|
|
- if (data.rawget(v, false)){
|
|
|
|
|
|
|
+ if (table_rawget(data, v, false)){
|
|
|
if (isFirst) isFirst = false;
|
|
if (isFirst) isFirst = false;
|
|
|
else mf.write(",");
|
|
else mf.write(",");
|
|
|
mf.write(v);
|
|
mf.write(v);
|
|
@@ -441,7 +442,7 @@ local DB_Manager = class {
|
|
|
mf.write(") values(");
|
|
mf.write(") values(");
|
|
|
isFirst = true;
|
|
isFirst = true;
|
|
|
foreach( k,v in editable_fields) {
|
|
foreach( k,v in editable_fields) {
|
|
|
- if (data.rawget(v, false)){
|
|
|
|
|
|
|
+ if (table_rawget(data, v, false)){
|
|
|
if (isFirst) isFirst = false;
|
|
if (isFirst) isFirst = false;
|
|
|
else mf.write(",");
|
|
else mf.write(",");
|
|
|
mf.write("?");
|
|
mf.write("?");
|
|
@@ -452,7 +453,7 @@ local DB_Manager = class {
|
|
|
local stmt = db.prepare(mf.tostring());
|
|
local stmt = db.prepare(mf.tostring());
|
|
|
local x = 0;
|
|
local x = 0;
|
|
|
foreach( k,v in editable_fields) {
|
|
foreach( k,v in editable_fields) {
|
|
|
- if (data.rawget(v, false)){
|
|
|
|
|
|
|
+ if (table_rawget(data, v, false)){
|
|
|
stmt.bind_empty_null(++x, data[v]);
|
|
stmt.bind_empty_null(++x, data[v]);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -467,7 +468,7 @@ local DB_Manager = class {
|
|
|
mf.write("update ", table_name, " set ");
|
|
mf.write("update ", table_name, " set ");
|
|
|
local isFirst = true;
|
|
local isFirst = true;
|
|
|
foreach( k,v in editable_fields) {
|
|
foreach( k,v in editable_fields) {
|
|
|
- if (data.rawget(v, false)){
|
|
|
|
|
|
|
+ if (table_rawget(data, v, false)){
|
|
|
if (isFirst) isFirst = false;
|
|
if (isFirst) isFirst = false;
|
|
|
else mf.write(",");
|
|
else mf.write(",");
|
|
|
mf.write(v, "=?");
|
|
mf.write(v, "=?");
|
|
@@ -481,7 +482,7 @@ local DB_Manager = class {
|
|
|
local stmt = db.prepare(mf.tostring());
|
|
local stmt = db.prepare(mf.tostring());
|
|
|
local x = 0;
|
|
local x = 0;
|
|
|
foreach( k,v in editable_fields) {
|
|
foreach( k,v in editable_fields) {
|
|
|
- if (data.rawget(v, false)) {
|
|
|
|
|
|
|
+ if (table_rawget(data, v, false)) {
|
|
|
stmt.bind_empty_null(++x, data[v]);
|
|
stmt.bind_empty_null(++x, data[v]);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -550,13 +551,13 @@ WHERE entity_id = ]==], aId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function save_image (db, tbl_qs, tbl, sle_buf) {
|
|
function save_image (db, tbl_qs, tbl, sle_buf) {
|
|
|
- local thumbnail = tbl_qs.rawget("thumbnail", null);
|
|
|
|
|
|
|
+ local thumbnail = table_rawget(tbl_qs, "thumbnail", null);
|
|
|
if(thumbnail)
|
|
if(thumbnail)
|
|
|
{
|
|
{
|
|
|
- local image = tbl_qs.rawget("image", null);
|
|
|
|
|
- local mime_type = tbl_qs.rawget("mime_type", null);
|
|
|
|
|
|
|
+ local image = table_rawget(tbl_qs, "image", null);
|
|
|
|
|
+ local mime_type = table_rawget(tbl_qs, "mime_type", null);
|
|
|
|
|
|
|
|
- local id = tbl_qs.rawget("__id__", 0);
|
|
|
|
|
|
|
+ local id = table_rawget(tbl_qs, "__id__", 0);
|
|
|
local isNewRecord = id == 0;
|
|
local isNewRecord = id == 0;
|
|
|
if(isNewRecord) id = db.last_row_id(); //new record get last_insert_rowid
|
|
if(isNewRecord) id = db.last_row_id(); //new record get last_insert_rowid
|
|
|
if(id)
|
|
if(id)
|
|
@@ -1533,30 +1534,30 @@ local DB_Entities = class extends DB_Manager {
|
|
|
|
|
|
|
|
function sql_list(qs_tbl, post_tbl){
|
|
function sql_list(qs_tbl, post_tbl){
|
|
|
local entity_id;
|
|
local entity_id;
|
|
|
- if (qs_tbl.rawget("search", false)) return entities_sql_search_list(qs_tbl, post_tbl);
|
|
|
|
|
- else if (qs_tbl.rawget("past_products", false)) return entity_past_products_get_sql(qs_tbl.past_products.tointeger());
|
|
|
|
|
- else if ( (entity_id = qs_tbl.rawget("history", 0)) ){
|
|
|
|
|
- local htype = qs_tbl.rawget("htype", 0);
|
|
|
|
|
|
|
+ if (table_rawget(qs_tbl, "search", false)) return entities_sql_search_list(qs_tbl, post_tbl);
|
|
|
|
|
+ else if (table_rawget(qs_tbl, "past_products", false)) return entity_past_products_get_sql(qs_tbl.past_products.tointeger());
|
|
|
|
|
+ else if ( (entity_id = table_rawget(qs_tbl, "history", 0)) ){
|
|
|
|
|
+ local htype = table_rawget(qs_tbl, "htype", 0);
|
|
|
local query_limit = table_get(qs_tbl, C_query_limit, 50).tointeger();
|
|
local query_limit = table_get(qs_tbl, C_query_limit, 50).tointeger();
|
|
|
return entity_sales_history_sql(htype, query_limit, entity_id.tointeger());
|
|
return entity_sales_history_sql(htype, query_limit, entity_id.tointeger());
|
|
|
}
|
|
}
|
|
|
- else if ( (entity_id = qs_tbl.rawget("statistics", 0)) ){
|
|
|
|
|
|
|
+ else if ( (entity_id = table_rawget(qs_tbl, "statistics", 0)) ){
|
|
|
local periode_count = table_get(qs_tbl, C_periode_count, 12).tointeger();
|
|
local periode_count = table_get(qs_tbl, C_periode_count, 12).tointeger();
|
|
|
local periode_type = getStatisticsPeriodeType(table_get(qs_tbl, C_periode_type, C_months));
|
|
local periode_type = getStatisticsPeriodeType(table_get(qs_tbl, C_periode_type, C_months));
|
|
|
- local sab = qs_tbl.rawget("sab", "S");
|
|
|
|
|
|
|
+ local sab = table_rawget(qs_tbl, "sab", "S");
|
|
|
return entity_bar_chart_statistics_sql(entity_id.tointeger(), sab, periode_count, periode_type);
|
|
return entity_bar_chart_statistics_sql(entity_id.tointeger(), sab, periode_count, periode_type);
|
|
|
}
|
|
}
|
|
|
- else if (qs_tbl.rawget("print_list", false)){
|
|
|
|
|
|
|
+ else if (table_rawget(qs_tbl, "print_list", false)){
|
|
|
return entities_list_sql();
|
|
return entities_list_sql();
|
|
|
}
|
|
}
|
|
|
- else if (qs_tbl.rawget("pdf", false)){
|
|
|
|
|
|
|
+ else if (table_rawget(qs_tbl, "pdf", false)){
|
|
|
qs_tbl._doc_pdf_ <- get_pdf_list(qs_tbl);
|
|
qs_tbl._doc_pdf_ <- get_pdf_list(qs_tbl);
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function get_pdf_list(tbl_qs){
|
|
function get_pdf_list(tbl_qs){
|
|
|
- local clipped = tbl_qs.rawget("clipped", false);
|
|
|
|
|
|
|
+ local clipped = table_rawget(tbl_qs, "clipped", false);
|
|
|
local pdf = new PdfSqlTable();
|
|
local pdf = new PdfSqlTable();
|
|
|
pdf.page_title = "Entities List";
|
|
pdf.page_title = "Entities List";
|
|
|
pdf.water_mark = "T H I S I S A D E M O";
|
|
pdf.water_mark = "T H I S I S A D E M O";
|
|
@@ -1576,18 +1577,18 @@ order by name
|
|
|
|
|
|
|
|
function sql_get_one(tbl_qs){
|
|
function sql_get_one(tbl_qs){
|
|
|
local id = table_get(tbl_qs, table_name, 0).tointeger();
|
|
local id = table_get(tbl_qs, table_name, 0).tointeger();
|
|
|
- if(tbl_qs.rawget("for_order", false))
|
|
|
|
|
|
|
+ if(table_rawget(tbl_qs, "for_order", false))
|
|
|
{
|
|
{
|
|
|
return entity_for_order_get_one(id);
|
|
return entity_for_order_get_one(id);
|
|
|
}
|
|
}
|
|
|
- else if(tbl_qs.rawget("with_thumbnail", false))
|
|
|
|
|
|
|
+ else if(table_rawget(tbl_qs, "with_thumbnail", false))
|
|
|
{
|
|
{
|
|
|
return [==[
|
|
return [==[
|
|
|
select e.*, i.thumbnail, i.mime_type
|
|
select e.*, i.thumbnail, i.mime_type
|
|
|
from entities e left join images i
|
|
from entities e left join images i
|
|
|
on e.image_id = i.id where e.id=?]==];
|
|
on e.image_id = i.id where e.id=?]==];
|
|
|
}
|
|
}
|
|
|
- else if(tbl_qs.rawget("pdf", false))
|
|
|
|
|
|
|
+ else if(table_rawget(tbl_qs, "pdf", false))
|
|
|
{
|
|
{
|
|
|
return get_pdf_list(tbl_qs);
|
|
return get_pdf_list(tbl_qs);
|
|
|
}
|
|
}
|
|
@@ -1610,7 +1611,7 @@ db_ourbiz_tables.entities <- new DB_Entities();
|
|
|
// orders
|
|
// orders
|
|
|
//
|
|
//
|
|
|
|
|
|
|
|
-if(globals.rawget("AT_DEV_DBG", false) || !globals.rawget("PDF_Order", false)) {
|
|
|
|
|
|
|
+if(table_rawget(globals, "AT_DEV_DBG", false) || !table_rawget(globals, "PDF_Order", false)) {
|
|
|
dofile(APP_CODE_FOLDER + "/pdf-order.nut");
|
|
dofile(APP_CODE_FOLDER + "/pdf-order.nut");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2141,32 +2142,32 @@ local DB_Orders = class extends DB_Manager {
|
|
|
|
|
|
|
|
function sql_list(qs_tbl, post_tbl){
|
|
function sql_list(qs_tbl, post_tbl){
|
|
|
local order_id
|
|
local order_id
|
|
|
- if (qs_tbl.rawget("search", false)) return orders_sql_search_list(qs_tbl, post_tbl);
|
|
|
|
|
- else if( (order_id = qs_tbl.rawget("lines", 0)) )
|
|
|
|
|
|
|
+ if (table_rawget(qs_tbl, "search", false)) return orders_sql_search_list(qs_tbl, post_tbl);
|
|
|
|
|
+ else if( (order_id = table_rawget(qs_tbl, "lines", 0)) )
|
|
|
{
|
|
{
|
|
|
return orders_lines_sql_for_order(order_id.tointeger());
|
|
return orders_lines_sql_for_order(order_id.tointeger());
|
|
|
}
|
|
}
|
|
|
- else if( (order_id = qs_tbl.rawget("sum", 0)) )
|
|
|
|
|
|
|
+ else if( (order_id = table_rawget(qs_tbl, "sum", 0)) )
|
|
|
{
|
|
{
|
|
|
- local query_limit = qs_tbl.rawget("query_limit", 50);
|
|
|
|
|
|
|
+ local query_limit = table_rawget(qs_tbl, "query_limit", 50);
|
|
|
return orders_sum_search_sql(query_limit);
|
|
return orders_sum_search_sql(query_limit);
|
|
|
}
|
|
}
|
|
|
- else if( (order_id = qs_tbl.rawget("lines_onhand", 0)) )
|
|
|
|
|
|
|
+ else if( (order_id = table_rawget(qs_tbl, "lines_onhand", 0)) )
|
|
|
{
|
|
{
|
|
|
return order_lines_onhand_get_sql(order_id.tointeger());
|
|
return order_lines_onhand_get_sql(order_id.tointeger());
|
|
|
}
|
|
}
|
|
|
- else if (qs_tbl.rawget("history", false)){
|
|
|
|
|
- local htype = qs_tbl.rawget("htype", 0).tointeger();
|
|
|
|
|
- local query_limit = qs_tbl.rawget("query_limit", 50).tointeger();
|
|
|
|
|
|
|
+ else if (table_rawget(qs_tbl, "history", false)){
|
|
|
|
|
+ local htype = table_rawget(qs_tbl, "htype", 0).tointeger();
|
|
|
|
|
+ local query_limit = table_rawget(qs_tbl, "query_limit", 50).tointeger();
|
|
|
return orders_sales_history_sql(htype, query_limit, qs_tbl.history);
|
|
return orders_sales_history_sql(htype, query_limit, qs_tbl.history);
|
|
|
}
|
|
}
|
|
|
- else if (qs_tbl.rawget("statistics", false)){
|
|
|
|
|
|
|
+ else if (table_rawget(qs_tbl, "statistics", false)){
|
|
|
local periode_count = table_get(qs_tbl, C_periode_count, 12).tointeger();
|
|
local periode_count = table_get(qs_tbl, C_periode_count, 12).tointeger();
|
|
|
- local periode_type = getStatisticsPeriodeType(qs_tbl.rawget("periode_type", "months"));
|
|
|
|
|
- local sab = qs_tbl.rawget("sab", "S");
|
|
|
|
|
|
|
+ local periode_type = getStatisticsPeriodeType(table_rawget(qs_tbl, "periode_type", "months"));
|
|
|
|
|
+ local sab = table_rawget(qs_tbl, "sab", "S");
|
|
|
return sql_bar_chart_statistics(sab, periode_count, periode_type);
|
|
return sql_bar_chart_statistics(sab, periode_count, periode_type);
|
|
|
}
|
|
}
|
|
|
- else if (qs_tbl.rawget("print_list", false)){
|
|
|
|
|
|
|
+ else if (table_rawget(qs_tbl, "print_list", false)){
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2174,7 +2175,7 @@ local DB_Orders = class extends DB_Manager {
|
|
|
{
|
|
{
|
|
|
_calc_line.reset();
|
|
_calc_line.reset();
|
|
|
local product_id = table_get(tbl_qs, C_product_id, 0).tointeger();
|
|
local product_id = table_get(tbl_qs, C_product_id, 0).tointeger();
|
|
|
- local order_id = tbl_qs.rawget("__id__", 0).tointeger();
|
|
|
|
|
|
|
+ local order_id = table_rawget(tbl_qs, "__id__", 0).tointeger();
|
|
|
if(product_id && order_id)
|
|
if(product_id && order_id)
|
|
|
{
|
|
{
|
|
|
local db = getOurbizDB();
|
|
local db = getOurbizDB();
|
|
@@ -2264,11 +2265,11 @@ where o.id = %d and p.id = %d]==], order_id, product_id));
|
|
|
|
|
|
|
|
function sql_get_one(tbl_qs) {
|
|
function sql_get_one(tbl_qs) {
|
|
|
local id = table_get(tbl_qs, table_name, 0).tointeger();
|
|
local id = table_get(tbl_qs, table_name, 0).tointeger();
|
|
|
- if(tbl_qs.rawget("line", false))
|
|
|
|
|
|
|
+ if(table_rawget(tbl_qs, "line", false))
|
|
|
{
|
|
{
|
|
|
orders_lines_get_one(id);
|
|
orders_lines_get_one(id);
|
|
|
}
|
|
}
|
|
|
- else if(tbl_qs.rawget("line_calculated", false))
|
|
|
|
|
|
|
+ else if(table_rawget(tbl_qs, "line_calculated", false))
|
|
|
{
|
|
{
|
|
|
local db = getOurbizDB();
|
|
local db = getOurbizDB();
|
|
|
local stmt = db.prepare(orders_lines_get_one(id));
|
|
local stmt = db.prepare(orders_lines_get_one(id));
|
|
@@ -2279,7 +2280,7 @@ where o.id = %d and p.id = %d]==], order_id, product_id));
|
|
|
calc_order_line(tbl_qs, buf, rec_map);
|
|
calc_order_line(tbl_qs, buf, rec_map);
|
|
|
return buf;
|
|
return buf;
|
|
|
}
|
|
}
|
|
|
- else if (tbl_qs.rawget("with_lines", false)){
|
|
|
|
|
|
|
+ else if (table_rawget(tbl_qs, "with_lines", false)){
|
|
|
local db = getOurbizDB();
|
|
local db = getOurbizDB();
|
|
|
local buf = blob(0, 8192);
|
|
local buf = blob(0, 8192);
|
|
|
|
|
|
|
@@ -2306,7 +2307,7 @@ where o.id = %d and p.id = %d]==], order_id, product_id));
|
|
|
buf.write(stmt.asSleArray());
|
|
buf.write(stmt.asSleArray());
|
|
|
return buf;
|
|
return buf;
|
|
|
}
|
|
}
|
|
|
- else if (tbl_qs.rawget("pdf", false)){
|
|
|
|
|
|
|
+ else if (table_rawget(tbl_qs, "pdf", false)){
|
|
|
local db = getOurbizDB();
|
|
local db = getOurbizDB();
|
|
|
local calc_order = new MyCalcOrderTotals(db);
|
|
local calc_order = new MyCalcOrderTotals(db);
|
|
|
tbl_qs._doc_pdf_ <- calc_order.getPdfOrder(id, "en");
|
|
tbl_qs._doc_pdf_ <- calc_order.getPdfOrder(id, "en");
|
|
@@ -2317,7 +2318,7 @@ where o.id = %d and p.id = %d]==], order_id, product_id));
|
|
|
|
|
|
|
|
function db_action(db, data){
|
|
function db_action(db, data){
|
|
|
//dbg_dump_map(p.post_map);
|
|
//dbg_dump_map(p.post_map);
|
|
|
- local action = data.rawget("__action__", false);
|
|
|
|
|
|
|
+ local action = table_rawget(data, "__action__", false);
|
|
|
|
|
|
|
|
if(action == "calc_line" || action == "calc_order_line")
|
|
if(action == "calc_line" || action == "calc_order_line")
|
|
|
{
|
|
{
|
|
@@ -2327,8 +2328,8 @@ where o.id = %d and p.id = %d]==], order_id, product_id));
|
|
|
}
|
|
}
|
|
|
else if(action == "order_numbering")
|
|
else if(action == "order_numbering")
|
|
|
{
|
|
{
|
|
|
- local order_id = data.rawget("__id__", 0).tointeger();
|
|
|
|
|
- local version = data.rawget("__version__", 0).tointeger();
|
|
|
|
|
|
|
+ local order_id = table_rawget(data, "__id__", 0).tointeger();
|
|
|
|
|
+ local version = table_rawget(data, "__version__", 0).tointeger();
|
|
|
db.exec_dml("begin;");
|
|
db.exec_dml("begin;");
|
|
|
try {
|
|
try {
|
|
|
if(db.exec_dml(orders_numbering_get_sql(order_id, version)) < 1)
|
|
if(db.exec_dml(orders_numbering_get_sql(order_id, version)) < 1)
|
|
@@ -2359,9 +2360,9 @@ where o.id = %d and p.id = %d]==], order_id, product_id));
|
|
|
|
|
|
|
|
function do_db_action2(db, data){
|
|
function do_db_action2(db, data){
|
|
|
/*
|
|
/*
|
|
|
- local action = data.rawget("__action__", false);
|
|
|
|
|
- local order_id = data.rawget("__id__", 0).tointeger();
|
|
|
|
|
- local version = data.rawget("__version__", 0).tointeger();
|
|
|
|
|
|
|
+ local action = table_rawget(data, "__action__", false);
|
|
|
|
|
+ local order_id = table_rawget(data, "__id__", 0).tointeger();
|
|
|
|
|
+ local version = table_rawget(data, "__version__", 0).tointeger();
|
|
|
|
|
|
|
|
local line_id, entity_id, order_type_id, changes = 0;
|
|
local line_id, entity_id, order_type_id, changes = 0;
|
|
|
map_str_t order_type_map;
|
|
map_str_t order_type_map;
|
|
@@ -2591,14 +2592,14 @@ local Product_Calc_price = class
|
|
|
function calc_over_sales_by_map(map)
|
|
function calc_over_sales_by_map(map)
|
|
|
{
|
|
{
|
|
|
//dbg_dump_map(map);
|
|
//dbg_dump_map(map);
|
|
|
- local trigger = map.get(C_trigger, null);
|
|
|
|
|
|
|
+ local trigger = table_get(map, C_trigger, null);
|
|
|
local result_fields = [C_sell_markup, C_discount_over_sales, C_sell_price2];
|
|
local result_fields = [C_sell_markup, C_discount_over_sales, C_sell_price2];
|
|
|
- foreach(k in result_fields) this[k] = map.get(k, 0.0);
|
|
|
|
|
- buy_price = map.get(C_buy_price, 0.0);
|
|
|
|
|
- buy_discount = map.get(C_buy_discount, 0.0);
|
|
|
|
|
- buy_other_costs = map.get(C_buy_other_costs, 0.0);
|
|
|
|
|
- sell_price = map.get(C_sell_price, 0.0);
|
|
|
|
|
- price_decimals = map.get(C_price_decimals, 2).tointeger();
|
|
|
|
|
|
|
+ foreach(k in result_fields) this[k] = table_get(map, k, 0.0);
|
|
|
|
|
+ buy_price = table_get(map, C_buy_price, 0.0);
|
|
|
|
|
+ buy_discount = table_get(map, C_buy_discount, 0.0);
|
|
|
|
|
+ buy_other_costs = table_get(map, C_buy_other_costs, 0.0);
|
|
|
|
|
+ sell_price = table_get(map, C_sell_price, 0.0);
|
|
|
|
|
+ price_decimals = table_get(map, C_price_decimals, 2).tointeger();
|
|
|
|
|
|
|
|
local result = calc_over_sales(trigger);
|
|
local result = calc_over_sales(trigger);
|
|
|
foreach(k in result_fields) map[k] = this[k];
|
|
foreach(k in result_fields) map[k] = this[k];
|
|
@@ -2609,18 +2610,18 @@ local Product_Calc_price = class
|
|
|
function calc_by_map(map)
|
|
function calc_by_map(map)
|
|
|
{
|
|
{
|
|
|
//dbg_dump_map(map);
|
|
//dbg_dump_map(map);
|
|
|
- local trigger = map.get(C_trigger, C_sell_markup);
|
|
|
|
|
|
|
+ local trigger = table_get(map, C_trigger, C_sell_markup);
|
|
|
local result_fields = [C_buy_price, C_buy_discount, C_buy_other_costs, C_sell_price,
|
|
local result_fields = [C_buy_price, C_buy_discount, C_buy_other_costs, C_sell_price,
|
|
|
C_sell_price2, C_sell_markup, C_markup_to_discount];
|
|
C_sell_price2, C_sell_markup, C_markup_to_discount];
|
|
|
- price_decimals = map.get(C_price_decimals, 2).tointeger();
|
|
|
|
|
|
|
+ price_decimals = table_get(map, C_price_decimals, 2).tointeger();
|
|
|
|
|
|
|
|
foreach(k in result_fields) {
|
|
foreach(k in result_fields) {
|
|
|
- //debug_print("\n", k, ":", map.get(k, 0.0));
|
|
|
|
|
- this[k] = mytofloat(map.get(k, 0.0));
|
|
|
|
|
|
|
+ //debug_print("\n", k, ":", table_get(map, k, 0.0));
|
|
|
|
|
+ this[k] = mytofloat(table_get(map, k, 0.0));
|
|
|
}
|
|
}
|
|
|
local result = calc(trigger);
|
|
local result = calc(trigger);
|
|
|
foreach(k in result_fields) {
|
|
foreach(k in result_fields) {
|
|
|
- //debug_print("\n", k, ":", this[k], ":", map.get(k, 0));
|
|
|
|
|
|
|
+ //debug_print("\n", k, ":", this[k], ":", table_get(map, k, 0));
|
|
|
map[k] <- this[k];
|
|
map[k] <- this[k];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2720,13 +2721,13 @@ local DB_Products = class extends DB_Manager {
|
|
|
_calc_prices = Product_Calc_price();
|
|
_calc_prices = Product_Calc_price();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function db_action(db, data){
|
|
|
|
|
|
|
+ /*function db_action(db, data){
|
|
|
mkEmptyWhenZero(data, [C_warranty_id, C_group_id, C_measure_unit_id, C_image_id, C_sales_tax_id]);
|
|
mkEmptyWhenZero(data, [C_warranty_id, C_group_id, C_measure_unit_id, C_image_id, C_sales_tax_id]);
|
|
|
return base.db_action(db, data);
|
|
return base.db_action(db, data);
|
|
|
- }
|
|
|
|
|
|
|
+ }*/
|
|
|
|
|
|
|
|
function getPdfList(qs_tbl){
|
|
function getPdfList(qs_tbl){
|
|
|
- local clipped = qs_tbl.rawget("clipped", false);
|
|
|
|
|
|
|
+ local clipped = table_rawget(qs_tbl, "clipped", false);
|
|
|
local pdf = new PdfSqlTable();
|
|
local pdf = new PdfSqlTable();
|
|
|
pdf.page_title = "Products List";
|
|
pdf.page_title = "Products List";
|
|
|
pdf.water_mark = "T H I S I S A D E M O";
|
|
pdf.water_mark = "T H I S I S A D E M O";
|
|
@@ -2741,26 +2742,26 @@ local DB_Products = class extends DB_Manager {
|
|
|
|
|
|
|
|
function sql_list(qs_tbl, post_tbl){
|
|
function sql_list(qs_tbl, post_tbl){
|
|
|
local product_id;
|
|
local product_id;
|
|
|
- if (qs_tbl.rawget("search", false)) return products_sql_search_list(qs_tbl, post_tbl);
|
|
|
|
|
- else if ( (product_id = qs_tbl.rawget("prices_by_quantity", 0)) ) return product_prices_list_sql(product_id.tointeger());
|
|
|
|
|
- else if ( (product_id = qs_tbl.rawget("past_products", 0)) ) return entity_past_products_get_sql(product_id.tointeger());
|
|
|
|
|
- else if ( (product_id = qs_tbl.rawget("last_order_lines", 0)) ) return last_product_order_lines_get_sql(product_id.tointeger());
|
|
|
|
|
- else if ( (product_id = qs_tbl.rawget("appear_together", 0)) ) return product_appear_together_get_sql(product_id.tointeger());
|
|
|
|
|
- else if ( (product_id = qs_tbl.rawget("history", 0)) ) {
|
|
|
|
|
- local htype = qs_tbl.rawget("htype", 0).tointeger();
|
|
|
|
|
- local query_limit = qs_tbl.get(C_query_limit, 50).tointeger();
|
|
|
|
|
|
|
+ if (table_rawget(qs_tbl, "search", false)) return products_sql_search_list(qs_tbl, post_tbl);
|
|
|
|
|
+ else if ( (product_id = table_rawget(qs_tbl, "prices_by_quantity", 0)) ) return product_prices_list_sql(product_id.tointeger());
|
|
|
|
|
+ else if ( (product_id = table_rawget(qs_tbl, "past_products", 0)) ) return entity_past_products_get_sql(product_id.tointeger());
|
|
|
|
|
+ else if ( (product_id = table_rawget(qs_tbl, "last_order_lines", 0)) ) return last_product_order_lines_get_sql(product_id.tointeger());
|
|
|
|
|
+ else if ( (product_id = table_rawget(qs_tbl, "appear_together", 0)) ) return product_appear_together_get_sql(product_id.tointeger());
|
|
|
|
|
+ else if ( (product_id = table_rawget(qs_tbl, "history", 0)) ) {
|
|
|
|
|
+ local htype = table_rawget(qs_tbl, "htype", 0).tointeger();
|
|
|
|
|
+ local query_limit = table_get(qs_tbl, C_query_limit, 50).tointeger();
|
|
|
return product_sales_history_sql(htype, query_limit, product_id.tointeger());
|
|
return product_sales_history_sql(htype, query_limit, product_id.tointeger());
|
|
|
}
|
|
}
|
|
|
- else if ( (product_id = qs_tbl.rawget("statistics", 0)) ){
|
|
|
|
|
- local periode_count = qs_tbl.get(C_periode_count, 12).tointeger();
|
|
|
|
|
|
|
+ else if ( (product_id = table_rawget(qs_tbl, "statistics", 0)) ){
|
|
|
|
|
+ local periode_count = table_get(qs_tbl, C_periode_count, 12).tointeger();
|
|
|
local periode_type = getStatisticsPeriodeType(qs_tbl.periode_type);
|
|
local periode_type = getStatisticsPeriodeType(qs_tbl.periode_type);
|
|
|
- local sab = qs_tbl.rawget("sab", "S");
|
|
|
|
|
|
|
+ local sab = table_rawget(qs_tbl, "sab", "S");
|
|
|
return product_bar_chart_statistics_sql(product_id.tointeger(), sab, periode_count, periode_type);
|
|
return product_bar_chart_statistics_sql(product_id.tointeger(), sab, periode_count, periode_type);
|
|
|
}
|
|
}
|
|
|
- else if (qs_tbl.rawget("print_list", false)){
|
|
|
|
|
|
|
+ else if (table_rawget(qs_tbl, "print_list", false)){
|
|
|
return products_list_sql();
|
|
return products_list_sql();
|
|
|
}
|
|
}
|
|
|
- else if (qs_tbl.rawget("pdf", false)){
|
|
|
|
|
|
|
+ else if (table_rawget(qs_tbl, "pdf", false)){
|
|
|
return getPdfList(qs_tbl);
|
|
return getPdfList(qs_tbl);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -2774,25 +2775,25 @@ where p.id=?]==];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function sql_get_one(tbl_qs) {
|
|
function sql_get_one(tbl_qs) {
|
|
|
- local id = tbl_qs.get(table_name, 0).tointeger();
|
|
|
|
|
|
|
+ local id = table_get(tbl_qs, table_name, 0).tointeger();
|
|
|
|
|
|
|
|
- if(tbl_qs.rawget("discount_by_quantity", false))
|
|
|
|
|
|
|
+ if(table_rawget(tbl_qs, "discount_by_quantity", false))
|
|
|
{
|
|
{
|
|
|
- local quantity = tbl_qs.get(C_quantity, 0);
|
|
|
|
|
|
|
+ local quantity = table_get(tbl_qs, C_quantity, 0);
|
|
|
if(!quantity) return;
|
|
if(!quantity) return;
|
|
|
return discount_by_quantity_get_one(id, quantity);
|
|
return discount_by_quantity_get_one(id, quantity);
|
|
|
}
|
|
}
|
|
|
- else if(tbl_qs.rawget("price_for_calc", false))
|
|
|
|
|
|
|
+ else if(table_rawget(tbl_qs, "price_for_calc", false))
|
|
|
{
|
|
{
|
|
|
return get_one_record_sql( _table_name, id,
|
|
return get_one_record_sql( _table_name, id,
|
|
|
"buy_price, buy_discount, buy_other_costs, sell_price, price_decimals");
|
|
"buy_price, buy_discount, buy_other_costs, sell_price, price_decimals");
|
|
|
}
|
|
}
|
|
|
- else if (tbl_qs.rawget("product_for_edit", false)){
|
|
|
|
|
|
|
+ else if (table_rawget(tbl_qs, "product_for_edit", false)){
|
|
|
local db = getOurbizDB();
|
|
local db = getOurbizDB();
|
|
|
local buf = blob(0, 8192);
|
|
local buf = blob(0, 8192);
|
|
|
local sql;
|
|
local sql;
|
|
|
|
|
|
|
|
- if(tbl_qs.rawget("with_thumbnail", false)){
|
|
|
|
|
|
|
+ if(table_rawget(tbl_qs, "with_thumbnail", false)){
|
|
|
sql = getOneSqlWithThumbnail();
|
|
sql = getOneSqlWithThumbnail();
|
|
|
} else {
|
|
} else {
|
|
|
sql = base.sql_get_one(tbl_qs)
|
|
sql = base.sql_get_one(tbl_qs)
|
|
@@ -2817,7 +2818,7 @@ where p.id=?]==];
|
|
|
|
|
|
|
|
return buf;
|
|
return buf;
|
|
|
}
|
|
}
|
|
|
- else if(tbl_qs.rawget("product_aux_data", false))
|
|
|
|
|
|
|
+ else if(table_rawget(tbl_qs, "product_aux_data", false))
|
|
|
{
|
|
{
|
|
|
local db = getOurbizDB();
|
|
local db = getOurbizDB();
|
|
|
local buf = blob(0, 8192);
|
|
local buf = blob(0, 8192);
|
|
@@ -2833,11 +2834,11 @@ where p.id=?]==];
|
|
|
|
|
|
|
|
return buf;
|
|
return buf;
|
|
|
}
|
|
}
|
|
|
- else if(tbl_qs.rawget("pdf", false))
|
|
|
|
|
|
|
+ else if(table_rawget(tbl_qs, "pdf", false))
|
|
|
{
|
|
{
|
|
|
return getPdfList(qs_tbl);
|
|
return getPdfList(qs_tbl);
|
|
|
}
|
|
}
|
|
|
- else if(tbl_qs.rawget("with_thumbnail", false)){
|
|
|
|
|
|
|
+ else if(table_rawget(tbl_qs, "with_thumbnail", false)){
|
|
|
return getOneSqlWithThumbnail().replace("?", id.tostring());
|
|
return getOneSqlWithThumbnail().replace("?", id.tostring());
|
|
|
}
|
|
}
|
|
|
else return base.sql_get_one(tbl_qs);
|
|
else return base.sql_get_one(tbl_qs);
|
|
@@ -2845,10 +2846,10 @@ where p.id=?]==];
|
|
|
|
|
|
|
|
function db_action(db, data)
|
|
function db_action(db, data)
|
|
|
{
|
|
{
|
|
|
- local str = data.rawget("__action__", false);
|
|
|
|
|
|
|
+ local str = table_rawget(data, "__action__", false);
|
|
|
if(str == "calc_price_by_quantity")
|
|
if(str == "calc_price_by_quantity")
|
|
|
{
|
|
{
|
|
|
- local id = data.rawget("__id__", 0);
|
|
|
|
|
|
|
+ local id = table_rawget(data, "__id__", 0);
|
|
|
if(!id) return;
|
|
if(!id) return;
|
|
|
|
|
|
|
|
_calc_prices.clear();
|
|
_calc_prices.clear();
|
|
@@ -2933,7 +2934,7 @@ local DB_Images = class extends DB_Manager {
|
|
|
function sql_get_one(req){
|
|
function sql_get_one(req){
|
|
|
local mf = blob();
|
|
local mf = blob();
|
|
|
mf.write("select id, _version_, mime_type, name, description, group_set, cdate, mdate, length(image) as img_size ");
|
|
mf.write("select id, _version_, mime_type, name, description, group_set, cdate, mdate, length(image) as img_size ");
|
|
|
- if (req.rawget("image_and_size", false)) mf.write(", image ");
|
|
|
|
|
|
|
+ if (table_rawget(req, "image_and_size", false)) mf.write(", image ");
|
|
|
mf.write("from ", table_name ," where id=?");
|
|
mf.write("from ", table_name ," where id=?");
|
|
|
return mf.tostring();
|
|
return mf.tostring();
|
|
|
}
|
|
}
|
|
@@ -2951,9 +2952,9 @@ local DB_order_types = class extends DB_Manager {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function sql_list(qs_tbl, post_tbl){
|
|
function sql_list(qs_tbl, post_tbl){
|
|
|
- if (qs_tbl.rawget("short_list", false)){
|
|
|
|
|
|
|
+ if (table_rawget(qs_tbl, "short_list", false)){
|
|
|
local sql = "select id, description from order_types where is_active = 1 ";
|
|
local sql = "select id, description from order_types where is_active = 1 ";
|
|
|
- local group_order = qs_tbl.rawget("group_order", false);
|
|
|
|
|
|
|
+ local group_order = table_rawget(qs_tbl, "group_order", false);
|
|
|
if (group_order && (group_order == "S" || group_order == "B")){
|
|
if (group_order && (group_order == "S" || group_order == "B")){
|
|
|
sql = format("%s and group_order='%s' ", sql, group_order);
|
|
sql = format("%s and group_order='%s' ", sql, group_order);
|
|
|
}
|
|
}
|
|
@@ -3130,22 +3131,22 @@ local function ourbizDbGetList(request){
|
|
|
if (query_string){
|
|
if (query_string){
|
|
|
local db = getOurbizDB();
|
|
local db = getOurbizDB();
|
|
|
local qs_tbl = parse_qs_to_table(query_string);
|
|
local qs_tbl = parse_qs_to_table(query_string);
|
|
|
- local list = qs_tbl.rawget("list", null);
|
|
|
|
|
- local sab = qs_tbl.rawget("sab", "S");
|
|
|
|
|
|
|
+ local list = table_rawget(qs_tbl, "list", null);
|
|
|
|
|
+ local sab = table_rawget(qs_tbl, "sab", "S");
|
|
|
local isPost = request.info.request_method == "POST";
|
|
local isPost = request.info.request_method == "POST";
|
|
|
local sql, post_tbl, data;
|
|
local sql, post_tbl, data;
|
|
|
if (isPost) post_tbl = get_post_fields(request, 1024);
|
|
if (isPost) post_tbl = get_post_fields(request, 1024);
|
|
|
else post_tbl = {};
|
|
else post_tbl = {};
|
|
|
|
|
|
|
|
- if (!post_tbl.rawget("query_limit", false)) post_tbl.query_limit <- 50;
|
|
|
|
|
|
|
+ if (!table_rawget(post_tbl, "query_limit", false)) post_tbl.query_limit <- 50;
|
|
|
gmFile.clear();
|
|
gmFile.clear();
|
|
|
|
|
|
|
|
if (list == "entity_groups") db_ourbiz_tables.entity_groups.get_list(db, gmFile);
|
|
if (list == "entity_groups") db_ourbiz_tables.entity_groups.get_list(db, gmFile);
|
|
|
else if (list == "product_groups") db_ourbiz_tables.product_groups.get_list(db, gmFile);
|
|
else if (list == "product_groups") db_ourbiz_tables.product_groups.get_list(db, gmFile);
|
|
|
else if (list == "config") sql = "select id, key,value from config";
|
|
else if (list == "config") sql = "select id, key,value from config";
|
|
|
- else if (db_ourbiz_tables.get(list, false)){
|
|
|
|
|
|
|
+ else if (table_get(db_ourbiz_tables, list, false)){
|
|
|
sql = db_ourbiz_tables[list].sql_list(qs_tbl, post_tbl);
|
|
sql = db_ourbiz_tables[list].sql_list(qs_tbl, post_tbl);
|
|
|
- local doc_pdf = qs_tbl.rawget("_doc_pdf_", false);
|
|
|
|
|
|
|
+ local doc_pdf = table_rawget(qs_tbl, "_doc_pdf_", false);
|
|
|
if (doc_pdf){
|
|
if (doc_pdf){
|
|
|
request.print(format([==[
|
|
request.print(format([==[
|
|
|
HTTP/1.1 200 OK
|
|
HTTP/1.1 200 OK
|
|
@@ -3198,9 +3199,9 @@ local function ourbizDbGetOne(request){
|
|
|
gmFile.clear()
|
|
gmFile.clear()
|
|
|
|
|
|
|
|
if (tbl == "config") sql = "select * from config where id=?";
|
|
if (tbl == "config") sql = "select * from config where id=?";
|
|
|
- else if (db_ourbiz_tables.get(tbl, false)) sql = db_ourbiz_tables[tbl].sql_get_one(tbl_qs);
|
|
|
|
|
|
|
+ else if (table_get(db_ourbiz_tables, tbl, false)) sql = db_ourbiz_tables[tbl].sql_get_one(tbl_qs);
|
|
|
|
|
|
|
|
- local doc_pdf = tbl_qs.rawget("_doc_pdf_", false);
|
|
|
|
|
|
|
+ local doc_pdf = table_rawget(tbl_qs, "_doc_pdf_", false);
|
|
|
if (doc_pdf){
|
|
if (doc_pdf){
|
|
|
request.print(format([==[
|
|
request.print(format([==[
|
|
|
HTTP/1.1 200 OK
|
|
HTTP/1.1 200 OK
|
|
@@ -3246,7 +3247,7 @@ local function ourbizDbGetBin(request){
|
|
|
local db = getOurbizDB();
|
|
local db = getOurbizDB();
|
|
|
local image = request.get_var(query_string, "image");
|
|
local image = request.get_var(query_string, "image");
|
|
|
local thumbnail = request.get_var(query_string, "thumbnail");
|
|
local thumbnail = request.get_var(query_string, "thumbnail");
|
|
|
- local etag = request.info.http_headers.rawget("If-None-Match", false);
|
|
|
|
|
|
|
+ local etag = table_rawget(request.info.http_headers, "If-None-Match", false);
|
|
|
local stmt;
|
|
local stmt;
|
|
|
gmFile.clear();
|
|
gmFile.clear();
|
|
|
|
|
|
|
@@ -3303,12 +3304,12 @@ local function ourbizDbAction(request) {
|
|
|
if (isPost){
|
|
if (isPost){
|
|
|
local data = get_post_fields(request, 10*1024);
|
|
local data = get_post_fields(request, 10*1024);
|
|
|
local db = getOurbizDB();
|
|
local db = getOurbizDB();
|
|
|
- local tbl = data.rawget("__table__", null);
|
|
|
|
|
- local action = data.rawget("__action__", null);
|
|
|
|
|
|
|
+ local tbl = table_rawget(data, "__table__", null);
|
|
|
|
|
+ local action = table_rawget(data, "__action__", null);
|
|
|
local result;
|
|
local result;
|
|
|
//debug_print(tbl, "\n", action, "\n", data.__id__, "\n")
|
|
//debug_print(tbl, "\n", action, "\n", data.__id__, "\n")
|
|
|
gmFile.clear();
|
|
gmFile.clear();
|
|
|
- local db_manager = db_ourbiz_tables.get(tbl, null);
|
|
|
|
|
|
|
+ local db_manager = table_get(db_ourbiz_tables, tbl, null);
|
|
|
if (db_manager){
|
|
if (db_manager){
|
|
|
result = db_manager.db_action(db, data);
|
|
result = db_manager.db_action(db, data);
|
|
|
}
|
|
}
|