فهرست منبع

More functionality added and bug fixes.

mingodad 13 سال پیش
والد
کامیت
e4fd76e89f
6فایلهای تغییر یافته به همراه285 افزوده شده و 46 حذف شده
  1. 86 19
      SquiLu-ext/sq_fltk.cpp
  2. 1 1
      SquiLu-ourbiz/happyhttp.nut
  3. 15 8
      SquiLu-ourbiz/ourbiz-client.nut
  4. 181 16
      SquiLu-ourbiz/ourbiz-fltk.nut
  5. 1 1
      SquiLu-ourbiz/ourbiz.nut
  6. 1 1
      SquiLu/squilu.cbp

+ 86 - 19
SquiLu-ext/sq_fltk.cpp

@@ -375,15 +375,17 @@ static SQRESULT prefix##funcNAME(HSQUIRRELVM v) \
 	return 1;\
 	return 1;\
 }
 }
 
 
-#define FUNC_SET_INT(prefix, getSelf, funcNAME) \
+#define FUNC_SET_INT_CAST(prefix, getSelf, funcNAME, typeName) \
 static SQRESULT prefix##funcNAME(HSQUIRRELVM v) \
 static SQRESULT prefix##funcNAME(HSQUIRRELVM v) \
 {\
 {\
     getSelf(v);\
     getSelf(v);\
     SQInteger iparam; sq_getinteger(v, 2, &iparam);\
     SQInteger iparam; sq_getinteger(v, 2, &iparam);\
-    self->funcNAME(iparam);\
+    self->funcNAME((typeName)iparam);\
 	return 0;\
 	return 0;\
 }
 }
 
 
+#define FUNC_SET_INT(prefix, getSelf, funcNAME) FUNC_SET_INT_CAST(prefix, getSelf, funcNAME, int)
+
 #define FUNC_SET_STR(prefix, getSelf, funcNAME) \
 #define FUNC_SET_STR(prefix, getSelf, funcNAME) \
 static SQRESULT prefix##funcNAME(HSQUIRRELVM v) \
 static SQRESULT prefix##funcNAME(HSQUIRRELVM v) \
 {\
 {\
@@ -1425,7 +1427,7 @@ FLTK_CONSTRUCTOR(Flu_Combo_Tree);
 
 
 static SQRESULT _Flu_Combo_Tree_tree(HSQUIRRELVM v){
 static SQRESULT _Flu_Combo_Tree_tree(HSQUIRRELVM v){
     SETUP_FLU_COMBO_TREE(v);
     SETUP_FLU_COMBO_TREE(v);
-    return fltk_pushinstance(v, FLTK_TAG(Flu_Tree_Browser), self);
+    return fltk_pushinstance(v, FLTK_TAG(Flu_Tree_Browser), &self->tree);
 }
 }
 
 
 CHEAP_RTTI_FOR(Flu_Combo_Tree);
 CHEAP_RTTI_FOR(Flu_Combo_Tree);
@@ -1438,12 +1440,56 @@ static SQRegFunction flu_combo_tree_obj_funcs[]={
 };
 };
 #undef _DECL_FUNC
 #undef _DECL_FUNC
 
 
+CREATE_TAG(Flu_Tree_Browser_Node);
+#define SETUP_FLU_TREE_BROWSER_NODE_AT(v, idx, Var) SQ_GET_INSTANCE_VAR(v, idx, Flu_Tree_Browser::Node, Var, FLTK_TAG(Flu_Tree_Browser_Node))
+
+static SQRESULT _Flu_Tree_Browser_Node_add(HSQUIRRELVM v){
+    SQ_FUNC_VARS_NO_TOP(v);
+    SETUP_FLU_TREE_BROWSER_NODE_AT(v, 1, self);
+    SQ_GET_STRING(v, 2, label);
+    Flu_Tree_Browser::Node* node = self->add(label);
+    if(node) return fltk_pushinstance(v, FLTK_TAG(Flu_Tree_Browser_Node), node);
+    sq_pushnull(v);
+    return 1;
+}
+
+static SQRESULT _Flu_Tree_Browser_Node_select(HSQUIRRELVM v){
+    SQ_FUNC_VARS_NO_TOP(v);
+    SETUP_FLU_TREE_BROWSER_NODE_AT(v, 1, self);
+    SQ_GET_BOOL(v, 2, bval);
+    self->select(bval);
+    return 0;
+}
+
+static SQRESULT _Flu_Tree_Browser_Node_user_data(HSQUIRRELVM v){
+    SQ_FUNC_VARS(v);
+    SETUP_FLU_TREE_BROWSER_NODE_AT(v, 1, self);
+    if(_top_ > 1){
+        SQ_GET_INTEGER(v, 2, ival);
+        self->user_data((void*)ival);
+        return 0;
+    }
+    sq_pushinteger(v, (SQInteger)self->user_data());
+    return 1;
+}
+
+#define _DECL_FUNC(name,nparams,pmask,isStatic) {_SC(#name),_Flu_Tree_Browser_Node_##name,nparams,pmask,isStatic}
+static SQRegFunction flu_tree_browser_node_obj_funcs[]={
+	_DECL_FUNC(add,2,_SC("xs"),SQFalse),
+	_DECL_FUNC(select,2,_SC("xb"),SQFalse),
+	_DECL_FUNC(user_data,-1,_SC("xi"),SQFalse),
+	{0,0}
+};
+#undef _DECL_FUNC
+
 FLTK_CONSTRUCTOR(Flu_Tree_Browser);
 FLTK_CONSTRUCTOR(Flu_Tree_Browser);
 #define SETUP_FLU_TREE_BROWSER(v) SETUP_FL_KLASS(v, Flu_Tree_Browser)
 #define SETUP_FLU_TREE_BROWSER(v) SETUP_FL_KLASS(v, Flu_Tree_Browser)
 
 
 FUNC_GETSET_BOOL(_Flu_Tree_Browser_, SETUP_FLU_TREE_BROWSER, self->, auto_branches);
 FUNC_GETSET_BOOL(_Flu_Tree_Browser_, SETUP_FLU_TREE_BROWSER, self->, auto_branches);
 FUNC_GETSET_BOOL(_Flu_Tree_Browser_, SETUP_FLU_TREE_BROWSER, self->, show_branches);
 FUNC_GETSET_BOOL(_Flu_Tree_Browser_, SETUP_FLU_TREE_BROWSER, self->, show_branches);
+FUNC_GETSET_BOOL(_Flu_Tree_Browser_, SETUP_FLU_TREE_BROWSER, self->, show_root);
 FUNC_GETSET_BOOL(_Flu_Tree_Browser_, SETUP_FLU_TREE_BROWSER, self->, all_branches_always_open);
 FUNC_GETSET_BOOL(_Flu_Tree_Browser_, SETUP_FLU_TREE_BROWSER, self->, all_branches_always_open);
+FUNC_GETSET_INT(_Flu_Tree_Browser_, SETUP_FLU_TREE_BROWSER, self->, selection_mode, int);
 
 
 static SQRESULT _Flu_Tree_Browser_shaded_entry_colors(HSQUIRRELVM v){
 static SQRESULT _Flu_Tree_Browser_shaded_entry_colors(HSQUIRRELVM v){
     SQ_FUNC_VARS_NO_TOP(v);
     SQ_FUNC_VARS_NO_TOP(v);
@@ -1485,42 +1531,58 @@ static SQRESULT _Flu_Tree_Browser_find_by_user_data(HSQUIRRELVM v){
     SETUP_FLU_TREE_BROWSER(v);
     SETUP_FLU_TREE_BROWSER(v);
     SQ_GET_INTEGER(v, 2, udata);
     SQ_GET_INTEGER(v, 2, udata);
     Flu_Tree_Browser::Node* node = self->find_by_user_data( (void *) udata);
     Flu_Tree_Browser::Node* node = self->find_by_user_data( (void *) udata);
-    sq_pushuserpointer(v, node);
+    if(node) return fltk_pushinstance(v, FLTK_TAG(Flu_Tree_Browser_Node), node);
+    sq_pushnull(v);
     return 1;
     return 1;
 }
 }
 
 
 static SQRESULT _Flu_Tree_Browser_set_hilighted(HSQUIRRELVM v){
 static SQRESULT _Flu_Tree_Browser_set_hilighted(HSQUIRRELVM v){
     SQ_FUNC_VARS_NO_TOP(v);
     SQ_FUNC_VARS_NO_TOP(v);
     SETUP_FLU_TREE_BROWSER(v);
     SETUP_FLU_TREE_BROWSER(v);
-    SQ_GET_USERPOINTER(v, 2, node);
-    self->set_hilighted( (Flu_Tree_Browser::Node*) node);
+    SETUP_FLU_TREE_BROWSER_NODE_AT(v, 2, node);
+    self->set_hilighted(node);
     return 0;
     return 0;
 }
 }
 
 
-static SQRESULT _Flu_Tree_Browser_select(HSQUIRRELVM v){
-    SQ_FUNC_VARS_NO_TOP(v);
+static SQRESULT _Flu_Tree_Browser_clear(HSQUIRRELVM v){
     SETUP_FLU_TREE_BROWSER(v);
     SETUP_FLU_TREE_BROWSER(v);
-    SQ_GET_USERPOINTER(v, 2, node);
-    SQ_GET_BOOL(v, 3, bval);
-    ((Flu_Tree_Browser::Node*)node)->select(bval);
+    self->clear();
     return 0;
     return 0;
 }
 }
 
 
+static SQRESULT _Flu_Tree_Browser_get_root(HSQUIRRELVM v){
+    SETUP_FLU_TREE_BROWSER(v);
+    return fltk_pushinstance(v, FLTK_TAG(Flu_Tree_Browser_Node), self->get_root());
+}
+
+static SQRESULT _Flu_Tree_Browser_add(HSQUIRRELVM v){
+    SQ_FUNC_VARS_NO_TOP(v);
+    SETUP_FLU_TREE_BROWSER(v);
+    SETUP_FLU_TREE_BROWSER_NODE_AT(v, 2, node);
+    SQ_GET_STRING(v, 3, label);
+    Flu_Tree_Browser::Node* new_node = self->add(node, label);
+    return fltk_pushinstance(v, FLTK_TAG(Flu_Tree_Browser_Node), new_node);
+}
+
 CHEAP_RTTI_FOR(Flu_Tree_Browser);
 CHEAP_RTTI_FOR(Flu_Tree_Browser);
 #define _DECL_FUNC(name,nparams,pmask,isStatic) {_SC(#name),_Flu_Tree_Browser_##name,nparams,pmask,isStatic}
 #define _DECL_FUNC(name,nparams,pmask,isStatic) {_SC(#name),_Flu_Tree_Browser_##name,nparams,pmask,isStatic}
-static SQRegFunction flu_combo_tree_browser_obj_funcs[]={
+static SQRegFunction flu_tree_browser_obj_funcs[]={
     CHEAP_RTTI_REG_FUN_FOR(Flu_Tree_Browser)
     CHEAP_RTTI_REG_FUN_FOR(Flu_Tree_Browser)
 	_DECL_FUNC(constructor,-5,FLTK_constructor_Mask, SQFalse),
 	_DECL_FUNC(constructor,-5,FLTK_constructor_Mask, SQFalse),
 	_DECL_FUNC(auto_branches,-1,_SC("xb"),SQFalse),
 	_DECL_FUNC(auto_branches,-1,_SC("xb"),SQFalse),
 	_DECL_FUNC(show_branches,-1,_SC("xb"),SQFalse),
 	_DECL_FUNC(show_branches,-1,_SC("xb"),SQFalse),
+	_DECL_FUNC(show_root,-1,_SC("xb"),SQFalse),
+	_DECL_FUNC(selection_mode,-1,_SC("xi"),SQFalse),
 	_DECL_FUNC(all_branches_always_open,-1,_SC("xb"),SQFalse),
 	_DECL_FUNC(all_branches_always_open,-1,_SC("xb"),SQFalse),
 	_DECL_FUNC(branch_text,4,_SC("xiii"),SQFalse),
 	_DECL_FUNC(branch_text,4,_SC("xiii"),SQFalse),
 	_DECL_FUNC(leaf_text,4,_SC("xiii"),SQFalse),
 	_DECL_FUNC(leaf_text,4,_SC("xiii"),SQFalse),
 	_DECL_FUNC(shaded_entry_colors,3,_SC("xii"),SQFalse),
 	_DECL_FUNC(shaded_entry_colors,3,_SC("xii"),SQFalse),
-	_DECL_FUNC(select,3,_SC("xpb"),SQFalse),
 	_DECL_FUNC(unselect_all,1,_SC("x"),SQFalse),
 	_DECL_FUNC(unselect_all,1,_SC("x"),SQFalse),
-	_DECL_FUNC(set_hilighted,2,_SC("xp"),SQFalse),
+	_DECL_FUNC(clear,1,_SC("x"),SQFalse),
 	_DECL_FUNC(find_by_user_data,2,_SC("xi"),SQFalse),
 	_DECL_FUNC(find_by_user_data,2,_SC("xi"),SQFalse),
+	_DECL_FUNC(set_hilighted,2,_SC("xx"),SQFalse),
+	_DECL_FUNC(get_root,1,_SC("x"),SQFalse),
+	_DECL_FUNC(add,3,_SC("xxs"),SQFalse),
 	{0,0}
 	{0,0}
 };
 };
 #undef _DECL_FUNC
 #undef _DECL_FUNC
@@ -2177,16 +2239,16 @@ static SQRegFunction fl_tabs_obj_funcs[]={
 #define SETUP_FL_BROWSER__GETSET_INT_CAST(funcNAME, typeNAME) FUNC_GETSET_INT(_Fl_Browser__, SETUP_FL_BROWSER_, self->, funcNAME, typeNAME)
 #define SETUP_FL_BROWSER__GETSET_INT_CAST(funcNAME, typeNAME) FUNC_GETSET_INT(_Fl_Browser__, SETUP_FL_BROWSER_, self->, funcNAME, typeNAME)
 
 
 SETUP_FL_BROWSER__GETSET_INT_CAST(textcolor, Fl_Color);
 SETUP_FL_BROWSER__GETSET_INT_CAST(textcolor, Fl_Color);
-SETUP_FL_BROWSER__GETSET_INT_CAST(textfont, int);
-SETUP_FL_BROWSER__GETSET_INT_CAST(textsize, int);
+//SETUP_FL_BROWSER__GETSET_INT_CAST(textfont, int);
+//SETUP_FL_BROWSER__GETSET_INT_CAST(textsize, int);
 
 
 CHEAP_RTTI_FOR(Fl_Browser_);
 CHEAP_RTTI_FOR(Fl_Browser_);
 #define _DECL_FUNC(name,nparams,pmask,isStatic) {_SC(#name),_Fl_Browser__##name,nparams,pmask,isStatic}
 #define _DECL_FUNC(name,nparams,pmask,isStatic) {_SC(#name),_Fl_Browser__##name,nparams,pmask,isStatic}
 static SQRegFunction fl_browser__obj_funcs[]={
 static SQRegFunction fl_browser__obj_funcs[]={
     CHEAP_RTTI_REG_FUN_FOR(Fl_Browser_)
     CHEAP_RTTI_REG_FUN_FOR(Fl_Browser_)
 	_DECL_FUNC(textcolor,-1,_SC("xi"),SQFalse),
 	_DECL_FUNC(textcolor,-1,_SC("xi"),SQFalse),
-	_DECL_FUNC(textfont,-1,_SC("xi"),SQFalse),
-	_DECL_FUNC(textsize,-1,_SC("xi"),SQFalse),
+//	_DECL_FUNC(textfont,-1,_SC("xi"),SQFalse),
+//	_DECL_FUNC(textsize,-1,_SC("xi"),SQFalse),
 	{0,0}
 	{0,0}
 };
 };
 #undef _DECL_FUNC
 #undef _DECL_FUNC
@@ -3913,6 +3975,10 @@ static const struct {
 	INT_CONST(FL_WHITE)
 	INT_CONST(FL_WHITE)
 	INT_CONST(FL_YELLOW)
 	INT_CONST(FL_YELLOW)
 
 
+	INT_CONST(FLU_NO_SELECT)
+	INT_CONST(FLU_SINGLE_SELECT)
+	INT_CONST(FLU_MULTI_SELECT)
+
 	/*line style*/
 	/*line style*/
     INT_CONST(FL_SOLID)
     INT_CONST(FL_SOLID)
     INT_CONST(FL_DASH)
     INT_CONST(FL_DASH)
@@ -4198,7 +4264,8 @@ SQRESULT sqext_register_fltklib(HSQUIRRELVM v)
 	PUSH_FL_CLASS(Flu_Combo_Box, Fl_Group, flu_combo_box_obj_funcs);
 	PUSH_FL_CLASS(Flu_Combo_Box, Fl_Group, flu_combo_box_obj_funcs);
 	PUSH_FL_CLASS(Flu_Combo_List, Flu_Combo_Box, flu_combo_list_obj_funcs);
 	PUSH_FL_CLASS(Flu_Combo_List, Flu_Combo_Box, flu_combo_list_obj_funcs);
 	PUSH_FL_CLASS(Flu_Combo_Tree, Flu_Combo_Box, flu_combo_tree_obj_funcs);
 	PUSH_FL_CLASS(Flu_Combo_Tree, Flu_Combo_Box, flu_combo_tree_obj_funcs);
-	PUSH_FL_CLASS(Flu_Tree_Browser, Fl_Group, flu_combo_tree_browser_obj_funcs);
+	PUSH_FL_CLASS(Flu_Tree_Browser, Fl_Group, flu_tree_browser_obj_funcs);
+    PUSH_FL_CLASS_NO_PARENT(Flu_Tree_Browser_Node, flu_tree_browser_node_obj_funcs);
 
 
 	//Fl_Window class
 	//Fl_Window class
 	PUSH_FL_CLASS(Fl_Window, Fl_Group, fl_window_obj_funcs);
 	PUSH_FL_CLASS(Fl_Window, Fl_Group, fl_window_obj_funcs);

+ 1 - 1
SquiLu-ourbiz/happyhttp.nut

@@ -139,7 +139,7 @@ class HappyHttpConnection {
 
 
 		if( !datawaiting( m_Sock, milisec) ) return;	// recv will block
 		if( !datawaiting( m_Sock, milisec) ) return;	// recv will block
 
 
-		local rc = m_Sock.receive(2048);
+		local rc = m_Sock.receive(8192); //2048
 		switch(rc[1]){
 		switch(rc[1]){
 			case socket.IO_DONE:
 			case socket.IO_DONE:
 			case socket.IO_TIMEOUT:
 			case socket.IO_TIMEOUT:

+ 15 - 8
SquiLu-ourbiz/ourbiz-client.nut

@@ -158,6 +158,7 @@ class HTTPConnAuthBase extends HTTPConnBase
                 {
                 {
                     if(globals.get("Fl", false)) Fl.check();//check_idle();
                     if(globals.get("Fl", false)) Fl.check();//check_idle();
                     pump();
                     pump();
+		    //os.sleep(0.01);
                 }
                 }
                 break;
                 break;
             }
             }
@@ -230,6 +231,13 @@ enum conn_type_e {e_conn_none, e_conn_http, e_conn_dbfile};
 constants.rawdelete("TimePeriode");
 constants.rawdelete("TimePeriode");
 enum TimePeriode {is_years = 1, is_months, is_weeks, is_days};
 enum TimePeriode {is_years = 1, is_months, is_weeks, is_days};
 
 
+function getStatisticsPeriodeType(speriode){
+	if(speriode == "years") return TimePeriode.is_years;
+	else if(speriode == "weeks") return TimePeriode.is_weeks;
+	else if(speriode == "days") return TimePeriode.is_days;
+	return TimePeriode.is_months;
+}
+
 local _the_app_server = null;
 local _the_app_server = null;
 class AppServer
 class AppServer
 {
 {
@@ -557,11 +565,10 @@ class AppServer
     }
     }
 
 
     function entities_get_bar_chart_statistics_list(data, entity_id, sab, periode_count=12,
     function entities_get_bar_chart_statistics_list(data, entity_id, sab, periode_count=12,
-            periode=TimePeriode.is_months)
+            periode="months")
     {
     {
-        local qs = format("&statistics=%d&periode_type=%s&periode_count=%d&sab=%c",
-                           entity_id, getStatisticsPeriodeType(periode),
-                           periode_count, sab);
+        local qs = format("&statistics=%d&periode_type=%s&periode_count=%d&sab=%s",
+                           entity_id, periode, periode_count, sab);
         get_list_data(data, "entities", qs, 0);
         get_list_data(data, "entities", qs, 0);
     }
     }
 
 
@@ -639,10 +646,10 @@ class AppServer
     }
     }
 
 
     function orders_get_bar_chart_statistics_list(data, sab, periode_count=12,
     function orders_get_bar_chart_statistics_list(data, sab, periode_count=12,
-            periode=TimePeriode.is_months, paidUnpaid=false)
+            periode="months", paidUnpaid=false)
     {
     {
         local myUrl = format("&statistics=1&periode_type=%s&periode_count=%d&paid_unpaid=%s&sab=%s", 
         local myUrl = format("&statistics=1&periode_type=%s&periode_count=%d&paid_unpaid=%s&sab=%s", 
-		getStatisticsPeriodeType(periode), periode_count, paidUnpaid ? "1" : "0", sab);
+		periode, periode_count, paidUnpaid ? "1" : "0", sab);
         get_list_data(data, "orders", myUrl, 0);
         get_list_data(data, "orders", myUrl, 0);
     }
     }
 
 
@@ -759,10 +766,10 @@ class AppServer
     }
     }
 
 
     function products_get_bar_chart_statistics_list(data, product_id, sab, periode_count=12,
     function products_get_bar_chart_statistics_list(data, product_id, sab, periode_count=12,
-            periode=TimePeriode.is_months)
+            periode="months")
     {
     {
         local myUrl = format("&statistics=%d&periode_type=%s&periode_count=%d&sab=%s", product_id, 
         local myUrl = format("&statistics=%d&periode_type=%s&periode_count=%d&sab=%s", product_id, 
-		getStatisticsPeriodeType(periode), periode_count, sab);
+		periode, periode_count, sab);
         get_list_data(data, "products", myUrl, 0);
         get_list_data(data, "products", myUrl, 0);
     }
     }
 
 

+ 181 - 16
SquiLu-ourbiz/ourbiz-fltk.nut

@@ -5,7 +5,7 @@ dofile("ourbiz-client.nut");
 dofile("db-updater.nut");
 dofile("db-updater.nut");
 local appServer = AppServer.getAppServer();
 local appServer = AppServer.getAppServer();
 appServer.credentials("mingote", "tr14pink");
 appServer.credentials("mingote", "tr14pink");
-appServer.connect("localhost", 8855);
+appServer.connect("localhost", 8855); //8888);//8855);
 
 
 function _tr(str){ return str;}
 function _tr(str){ return str;}
 
 
@@ -349,6 +349,49 @@ class MyBaseWindow extends Fl_Window {
 			choice->add_item(rec[0].tointeger(), rec[1]);
 			choice->add_item(rec[0].tointeger(), rec[1]);
 		}
 		}
 	}
 	}
+	
+	function insert_group_tree_childs (tree, node, parent, pos, size, data)
+	{
+	    local new_node;
+	    while(pos < size)
+	    {
+		local rec = data[pos];
+		local myparent = rec[1].tointeger();
+		if(myparent != parent) break;
+		local id = rec[0].tointeger();
+
+		local str = rec[2].gsub("/", "\\/");
+		new_node = tree->add(node, str);
+		if(new_node) new_node->user_data(id);
+			else throw ("Try to insert an invalid Tree Node.");
+
+		++pos;
+		pos = insert_group_tree_childs(tree, new_node, id, pos, size, data);
+	    }
+	    return pos;
+	}
+	
+	function setup_tree_browser_for_selection (tree) {
+		tree->show_root(true);
+		tree->auto_branches(true);
+		tree->show_branches(true);
+		tree->all_branches_always_open(true);
+		//tree->selection_mode(FLU_MULTI_SELECT);
+		tree->selection_mode(FLU_SINGLE_SELECT);
+		tree->branch_text(tree->labelcolor(), tree->labelfont(), tree->labelsize());
+		tree->leaf_text(tree->labelcolor(), tree->labelfont(), tree->labelsize());
+		tree->shaded_entry_colors( FL_WHITE, FL_GRAY );
+	}
+	
+	function treeLoadChilds (tree, node, parent, _table_name)
+	{
+		local data = [];
+		tree->clear();
+		appServer.get_list_data(data, _table_name , 0, 0);
+		local pos = 0;
+		if(!node) node = tree->get_root();
+		insert_group_tree_childs(tree, node, 0, pos, data.size(), data);
+	}
 }
 }
 
 
 class Widget_Fill_By_Map {
 class Widget_Fill_By_Map {
@@ -401,7 +444,7 @@ class Widget_Fill_By_Map {
 			local item = wdg->find_by_user_data(value);
 			local item = wdg->find_by_user_data(value);
 			if(item){
 			if(item){
 				wdg->set_hilighted(item);
 				wdg->set_hilighted(item);
-				wdg->select(item, true);
+				item->select(true);
 				//clear changed because Flu_Tree_Browser will set it when select
 				//clear changed because Flu_Tree_Browser will set it when select
 				wdg->clear_changed_all();
 				wdg->clear_changed_all();
 			}
 			}
@@ -555,7 +598,7 @@ class EditWindow extends MyBaseWindow {
 	}
 	}
 	function do_edit(aid){
 	function do_edit(aid){
 		local dbu = dbUpdater();
 		local dbu = dbUpdater();
-		dbu->edit_id = aid;
+		dbu->edit_id = aid.tointeger();
 		dbu->version = 0;
 		dbu->version = 0;
 		dbAction->action(aid ? DbAction_Enum.e_update : DbAction_Enum.e_insert);
 		dbAction->action(aid ? DbAction_Enum.e_update : DbAction_Enum.e_insert);
 		on_Change_dbAction();
 		on_Change_dbAction();
@@ -645,6 +688,8 @@ class Fl_Data_Table extends Flv_Data_Table {
 	}
 	}
 
 
 	function clear_data_rows(){
 	function clear_data_rows(){
+		row(0);
+		rows(0);
 		_data.clear();
 		_data.clear();
 	}
 	}
 	function recalc_data(){
 	function recalc_data(){
@@ -657,6 +702,15 @@ class Fl_Data_Table extends Flv_Data_Table {
 		recalc_data();
 		recalc_data();
 	}
 	}
 
 
+	function set_new_data(data_array){
+		clear_data_rows();
+		_data = data_array;
+		local mycols = _data[0];
+		_data.remove(0);
+		set_cols(mycols);
+		recalc_data();
+	}
+
 	function get_data_value(arow, acol){ return _data[arow][acol];}
 	function get_data_value(arow, acol){ return _data[arow][acol];}
 
 
 	function get_value(arow, acol){
 	function get_value(arow, acol){
@@ -915,6 +969,50 @@ dofile("edit-entity-window.nut");
 dofile("edit-order-window.nut");
 dofile("edit-order-window.nut");
 dofile("list-search-window.nut");
 dofile("list-search-window.nut");
 
 
+class MyBarChart extends BarChartGroup {
+	
+	constructor(){
+		base.constructor();
+	}
+
+	function periode_type ()
+	{
+		return btn_periode_is_years->value() ? "years" :
+		       btn_periode_is_weeks->value() ? "weeks" :
+		       btn_periode_is_days->value() ? "days" :
+		       "months";
+	}
+	
+	function periodes (){
+		local val = periodes_to_show->value();
+		return val.len() ? val.tointeger() : 0;
+	}
+
+	function show_bar_chart(data, byTwo, bySAB)
+	{
+		local cursor_wait = fl_cursor_wait();
+		bar_chart->bar_begin_update();
+		bar_chart->bar_clear();
+		//bar_chart.label(_tr("Sales Statistics"));
+		local cl;
+		for(local i=0, max_count=data.size(); i<max_count;++i)
+		{
+		    local rec = data[i];
+		    if(byTwo){
+			cl = rec[2] == "1" ? FL_BLUE : FL_RED;
+		    }
+		    else if(bySAB){
+			//printf("%s : %s : %s\n", rec[0].c_str(), rec[1].c_str(), rec[2].c_str());
+			cl = rec[2] == "S" ? FL_BLUE : FL_GREEN;
+		    } else {
+			cl = FL_BLUE;
+		    }
+		    bar_chart->bar_add(rec[0], rec[1].tofloat(), cl);
+		}
+		bar_chart->bar_end_update();
+	}
+}
+
 class MyListSearchWindow extends ListSearch {
 class MyListSearchWindow extends ListSearch {
 	_popup = null;
 	_popup = null;
 	_search_options = null;
 	_search_options = null;
@@ -1141,11 +1239,11 @@ class MyEditEntityWindow extends EditEntityWindow {
 	constructor(){
 	constructor(){
 		base.constructor();
 		base.constructor();
 		dbUpdater()->table_name = "entities";
 		dbUpdater()->table_name = "entities";
-		_sab = 'A';
+		_sab = "A";
 		setDbActionControls(dbAction, btnDbAction);
 		setDbActionControls(dbAction, btnDbAction);
 		btnEntitesListContactReport.callback(print_entities_list_contact_report);
 		btnEntitesListContactReport.callback(print_entities_list_contact_report);
 		
 		
-		_ourBarChart = new BarChartGroup();
+		_ourBarChart = new MyBarChart();
 		replace_widget_for(tabChartStatistics, _ourBarChart);
 		replace_widget_for(tabChartStatistics, _ourBarChart);
 		_ourBarChart->btnShowChart.callback(on_show_chart_cb);
 		_ourBarChart->btnShowChart.callback(on_show_chart_cb);
 		
 		
@@ -1163,8 +1261,25 @@ class MyEditEntityWindow extends EditEntityWindow {
 		delayed_focus(db_entities_name);
 		delayed_focus(db_entities_name);
 	}
 	}
 	function on_show_chart_cb(sender, udata){
 	function on_show_chart_cb(sender, udata){
+		this = sender->window();
+		local cursor_wait = fl_cursor_wait();
+		local mydata = [];
+		appServer.entities_get_bar_chart_statistics_list(mydata,
+			dbUpdater()->edit_id, _sab, _ourBarChart->periodes(),
+			_ourBarChart->periode_type());
+		_ourBarChart->show_bar_chart(mydata, false, (_sab == "A"));
 	}
 	}
 	function on_history_cb(sender, udata){
 	function on_history_cb(sender, udata){
+		this = sender->window();
+		local cursor_wait = fl_cursor_wait();
+		local data = [];
+		local tbl = _ourHistory->grid_history;
+		local query_limit = _ourHistory->history_query_limit->value();
+		query_limit = query_limit.len() ? query_limit.tointeger() : 0;
+		appServer.entities_get_sales_history_list(data,
+					_ourHistory->history_choice->value(),
+					query_limit, dbUpdater()->edit_id);
+		tbl->set_new_data(data);
 	}
 	}
 }
 }
 
 
@@ -1322,10 +1437,10 @@ class MyEditProductWindow extends EditProductWindow {
 	constructor(){
 	constructor(){
 		base.constructor();
 		base.constructor();
 		dbUpdater()->table_name = "products";
 		dbUpdater()->table_name = "products";
-		_sab = 'A';
+		_sab = "A";
 		setDbActionControls(dbAction, btnDbAction);
 		setDbActionControls(dbAction, btnDbAction);
 
 
-		_ourBarChart = new BarChartGroup();
+		_ourBarChart = new MyBarChart();
 		replace_widget_for(tabChartStatistics, _ourBarChart);
 		replace_widget_for(tabChartStatistics, _ourBarChart);
 		_ourBarChart->btnShowChart.callback(on_show_chart_cb);
 		_ourBarChart->btnShowChart.callback(on_show_chart_cb);
 		
 		
@@ -1353,9 +1468,9 @@ class MyEditProductWindow extends EditProductWindow {
 		}
 		}
 	}
 	}
 	function load_aux_data(){
 	function load_aux_data(){
-		//local tree = db_products_group_id;
-		//setup_tree_browser_for_selection(tree);
-		//treeLoadChilds(tree, 0, 0, "product_groups");
+		local tree = db_products_group_id;
+		setup_tree_browser_for_selection(tree);
+		treeLoadChilds(tree, 0, 0, "product_groups");
 
 
 		local sales_tax_data = [], measure_units_data = [], warranty_data = [];
 		local sales_tax_data = [], measure_units_data = [], warranty_data = [];
 
 
@@ -1370,9 +1485,27 @@ class MyEditProductWindow extends EditProductWindow {
 
 
 		fill_choice_by_data(db_products_warranty_id, warranty_data);
 		fill_choice_by_data(db_products_warranty_id, warranty_data);
 	}
 	}
+	
 	function on_show_chart_cb(sender, udata){
 	function on_show_chart_cb(sender, udata){
+		this = sender->window();
+		local cursor_wait = fl_cursor_wait();
+		local mydata = [];
+		appServer.products_get_bar_chart_statistics_list(mydata,
+			dbUpdater()->edit_id, _sab, _ourBarChart->periodes(),
+			_ourBarChart->periode_type());
+		_ourBarChart->show_bar_chart(mydata, false, (_sab == "A"));
 	}
 	}
 	function on_history_cb(sender, udata){
 	function on_history_cb(sender, udata){
+		this = sender->window();
+		local cursor_wait = fl_cursor_wait();
+		local data = [];
+		local tbl = _ourHistory->grid_history;
+		local query_limit = _ourHistory->history_query_limit->value();
+		query_limit = query_limit.len() ? query_limit.tointeger() : 0;
+		appServer.products_get_sales_history_list(data,
+					_ourHistory->history_choice->value(),
+					query_limit, dbUpdater()->edit_id);
+		tbl->set_new_data(data);
 	}
 	}
 }
 }
 
 
@@ -1404,7 +1537,7 @@ class ProductsListSearch extends MyListSearchWindow {
 			"image_id|image_id|0",
 			"image_id|image_id|0",
 		];
 		];
 		grid->set_cols(cols_info);
 		grid->set_cols(cols_info);
-		//setFilterComboTree();
+		setFilterComboTree();
 		_search_by_description = create_search_by("Description");
 		_search_by_description = create_search_by("Description");
 		_search_by_notes = create_search_by("Notes");
 		_search_by_notes = create_search_by("Notes");
 		_search_by_reference = create_search_by("Reference");
 		_search_by_reference = create_search_by("Reference");
@@ -1414,6 +1547,14 @@ class ProductsListSearch extends MyListSearchWindow {
 		_search_by_description->setonly();
 		_search_by_description->setonly();
 		_search_by_active->value(1);
 		_search_by_active->value(1);
 		fill_grid();
 		fill_grid();
+		delayed_method_call(this, this.fill_group_filter, 0);
+	}
+
+	function fill_group_filter(udata)
+	{
+		local tree = group_filter->tree();
+		treeLoadChilds(tree, 0, 0, "product_groups");
+		tree->label("----");
 	}
 	}
 
 
 	function get_search_data(data){
 	function get_search_data(data){
@@ -1535,10 +1676,10 @@ class MyEditOrderWindow extends EditOrderWindow {
 		grid_lines->set_cols(cols_info);
 		grid_lines->set_cols(cols_info);
 		
 		
 		dbUpdater()->table_name = "orders";
 		dbUpdater()->table_name = "orders";
-		_sab = 'A';
+		_sab = "A";
 		setDbActionControls(dbAction, btnDbAction);
 		setDbActionControls(dbAction, btnDbAction);
 
 
-		_ourBarChart = new BarChartGroup();
+		_ourBarChart = new MyBarChart();
 		replace_widget_for(tabChartStatistics, _ourBarChart);
 		replace_widget_for(tabChartStatistics, _ourBarChart);
 		_ourBarChart->btnShowChart.callback(on_show_chart_cb);
 		_ourBarChart->btnShowChart.callback(on_show_chart_cb);
 		
 		
@@ -1615,6 +1756,15 @@ class MyEditOrderWindow extends EditOrderWindow {
 		appServer.get_record(_record, _main_table, 0, id, "&with_lines=1");
 		appServer.get_record(_record, _main_table, 0, id, "&with_lines=1");
 	}
 	}
 	
 	
+	function set_decimal_places(dp){
+		db_orders_lines_price->decimal_places(dp);
+		db_orders_lines_first_total->decimal_places(dp);
+		db_orders_lines_discount_amt->decimal_places(dp);
+		db_orders_lines_line_subtotal->decimal_places(dp);
+		db_orders_lines_sales_tax1_amt->decimal_places(dp);
+		db_orders_lines_line_total->decimal_places(dp);
+	}
+	
 	function fill_edit_form_entity(myrec, asBlank=false, setChanged=false){
 	function fill_edit_form_entity(myrec, asBlank=false, setChanged=false){
 	}
 	}
 	
 	
@@ -1640,12 +1790,27 @@ class MyEditOrderWindow extends EditOrderWindow {
 	}
 	}
 	function cb_btnSearchEntity(sender, udata){
 	function cb_btnSearchEntity(sender, udata){
 		this = sender->window();
 		this = sender->window();
-		print("Fl_Pack :", pack_line2->x(), pack_line2->y(), pack_line2->w(), pack_line2->h());
-		print("db_orders_entity_id :", db_orders_entity_id->x(), db_orders_entity_id->y(), db_orders_entity_id->w(), db_orders_entity_id->h());
 	}
 	}
+		
 	function on_show_chart_cb(sender, udata){
 	function on_show_chart_cb(sender, udata){
+		this = sender->window();
+		local paidUpaid = _ourBarChart->chkOpt->value();
+		local cursor_wait = fl_cursor_wait();
+		local mydata = [];
+		appServer.orders_get_bar_chart_statistics_list(mydata, _sab, 
+			_ourBarChart->periodes(), _ourBarChart->periode_type() , paidUpaid);
+		_ourBarChart->show_bar_chart(mydata, paidUpaid, (_sab == "A"));	
 	}
 	}
 	function on_history_cb(sender, udata){
 	function on_history_cb(sender, udata){
+		this = sender->window();
+		local cursor_wait = fl_cursor_wait();
+		local data = [];
+		local tbl = _ourHistory->grid_history;
+		local query_limit = _ourHistory->history_query_limit->value();
+		query_limit = query_limit.len() ? query_limit.tointeger() : 0;
+		appServer.orders_get_sales_history_list(data,
+					_ourHistory->history_choice->value(), query_limit);
+		tbl->set_new_data(data);
 	}
 	}
 }
 }
 
 
@@ -1716,7 +1881,7 @@ class OrdersListSearch extends MyListSearchWindow {
 	function on_popupmenu_cb(sender, udata){
 	function on_popupmenu_cb(sender, udata){
 		//printf("%p : %d : %s\n", sender, popup->value(),
 		//printf("%p : %d : %s\n", sender, popup->value(),
 		//       popup->menu_at(popup->value())->label());
 		//       popup->menu_at(popup->value())->label());
-		this = sender.windw();
+		this = sender.window();
 		local row = grid->row();
 		local row = grid->row();
 		if(row < 0) return;
 		if(row < 0) return;
 		switch(_popup->value()){
 		switch(_popup->value()){

+ 1 - 1
SquiLu-ourbiz/ourbiz.nut

@@ -1243,7 +1243,7 @@ select product_id from orders_lines where order_id in (
 			local periode_count = qs_tbl.get("periode_count", 12).tointeger();
 			local periode_count = qs_tbl.get("periode_count", 12).tointeger();
 			local periode_type = getStatisticsPeriodeType(qs_tbl.periode_type);
 			local periode_type = getStatisticsPeriodeType(qs_tbl.periode_type);
 			local sab = qs_tbl.get("sab", "S");
 			local sab = qs_tbl.get("sab", "S");
-			return DB_Entities.sql_bar_chart_statistics(tonumber(qs_tbl.statistics), sab, periode_count, periode_type);
+			return DB_Entities.sql_bar_chart_statistics(qs_tbl.statistics.tointeger(), sab, periode_count, periode_type);
 		}
 		}
 		else if (qs_tbl.get("print_list", false)){
 		else if (qs_tbl.get("print_list", false)){
 			return [==[
 			return [==[

+ 1 - 1
SquiLu/squilu.cbp

@@ -153,7 +153,7 @@
 					<Add directory="../../dadbiz++/third-party/libharu/include" />
 					<Add directory="../../dadbiz++/third-party/libharu/include" />
 				</Compiler>
 				</Compiler>
 				<Linker>
 				<Linker>
-					<Add library="../zeromq-3.2.2/libzmq3.a" />
+					<Add library="../../zeromq-3.2.2/libzmq3.a" />
 					<Add library="pthread" />
 					<Add library="pthread" />
 					<Add library="rt" />
 					<Add library="rt" />
 					<Add library="dl" />
 					<Add library="dl" />