biz9-logic 10.0.29 → 10.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/biz9_config +1 -1
  2. package/index.js +321 -423
  3. package/package.json +1 -1
  4. package/test.js +12 -6
package/biz9_config CHANGED
@@ -1,4 +1,4 @@
1
- VERSION='10.2.9'
1
+ VERSION='10.3.5'
2
2
  TITLE='BiZ9-Logic';
3
3
  REPO='git@github.com:biz9framework/biz9-logic.git';
4
4
  BRANCH='main'
package/index.js CHANGED
@@ -35,50 +35,46 @@ class Message {
35
35
  class Item_Logic {
36
36
  static get_new = (title,data_type,option)=>{
37
37
  option = option ? option : {};
38
- const item = DataItem.get_new(data_type,0,{title:title,title_url:Str.get_title_url(title),setting_visible:"1"});
38
+ const item = Data_Logic.get_new(data_type,0,{title:title,title_url:Str.get_title_url(title),setting_visible:"1"});
39
39
  return item;
40
40
  };
41
41
  static copy = (data_type,item)=>{
42
- let copy_item = DataItem.get_new(data_type,0);
42
+ let copy_item = Data_Logic.get_new(data_type,0);
43
43
  const keys = Object.keys(item);
44
- keys.forEach(key => {
45
- if(
46
- key!=Type.FIELD_ID&&
47
- key!=Type.FIELD_SOURCE&&
48
- key!=Type.FIELD_TITLE&&
49
- key!=Type.FIELD_TITLE_URL&&
50
- key!=Type.FIELD_DATE_CREATE&&
51
- key!=Type.FIELD_DATE_SAVE&&
52
- key!=Type.TITLE_OBJ&&
53
- key!=Type.TITLE_USER&&
54
- key!=Type.TITLE_GROUP&&
55
- key!=Type.TITLE_ITEM&&
56
- !Obj.check_is_array(item[key])&&
57
- Obj.check_is_value(item[key])
44
+ keys.forEach(key => {
45
+ if(
46
+ key!=Type.FIELD_ID&&
47
+ key!=Type.FIELD_SOURCE&&
48
+ key!=Type.FIELD_TITLE&&
49
+ key!=Type.FIELD_TITLE_URL&&
50
+ key!=Type.FIELD_DATE_CREATE&&
51
+ key!=Type.FIELD_DATE_SAVE&&
52
+ key!=Type.TITLE_OBJ&&
53
+ key!=Type.TITLE_USER&&
54
+ key!=Type.TITLE_GROUP&&
55
+ key!=Type.TITLE_ITEM&&
56
+ !Obj.check_is_array(item[key])&&
57
+ Obj.check_is_value(item[key])
58
58
  ){
59
- copy_item[key]=item[key];
60
- }
61
- });
59
+ copy_item[key]=item[key];
60
+ }
61
+ });
62
62
  return copy_item;
63
63
  };
64
64
  static bind_child_parent_obj = (child_obj,parent_obj)=>{
65
65
  for(const prop in parent_obj) {
66
66
  child_obj['parent_'+prop] = parent_obj[prop];
67
67
  }
68
- return child_obj;
68
+ return child_obj;
69
69
  };
70
70
  static get_test = (title,data_type,id,option)=>{
71
71
  data_type = data_type ? data_type : Type.DATA_BLANK;
72
72
  id = id ? id : 0;
73
73
  option = Field_Logic.get_option(data_type,option?option:{});
74
- let item = DataItem.get_new(data_type,0,Field_Logic.get_test(title,option));
75
- if(option.get_item){
76
- item.items = Sub_Item_Logic.get_test_items(item,item,option);
77
- item = Sub_Item_Logic.bind_parent_child_items(item,item.items);
78
- }
74
+ let item = Data_Logic.get_new(data_type,0,Field_Logic.get_test(title,option));
79
75
  return item;
80
76
  }
81
- static get_test_items = (data_type,option) =>{
77
+ static get_test_items = (data_type,option) =>{
82
78
  option = Field_Logic.get_option(data_type,option?option:{});
83
79
  let items = [];
84
80
  for(let a=0;a<parseInt(option.item_count)+1;a++){
@@ -147,63 +143,6 @@ class Title {
147
143
  static DESCRIPTION='Description';
148
144
  static TYPE='Type';
149
145
  }
150
- class Demo_Logic {
151
- static get_new_type = (title,option) => {
152
- title = !Str.check_is_null(title)?title:Title.TYPE+" " +Num.get_id(999);
153
- option = option ? option : {get_category:false,category_count:6,categorys:'',category_data_type:Type.DATA_BLANK,get_item:false,items:'',item_data_type:Type.DATA_BLANK,item_count:6}; const item = Item_Logic.get_new(title,Type.DATA_TYPE); //category
154
- if(option.get_category){
155
- item.categorys = [];
156
- let category_titles = [];
157
- if(option.categorys){
158
- category_titles = option.categorys.split(',');
159
- option.category_count = category_titles.length;
160
- }else{
161
- if(!option.category_count){
162
- option.category_count = 1;
163
- }
164
- for(let a = 1;a<parseInt(option.category_count)+1;a++){
165
- category_titles.push(Title.CATEGORY+" "+a);
166
- }
167
- }
168
- category_titles.forEach(cat_item => {
169
- item.categorys.push(Category_Logic.get_new(cat_item,item.title,option.category_data_type));
170
- });
171
- }
172
- //item
173
- if(option.get_item){
174
- let full_items = [];
175
-
176
- let item_titles = [];
177
- if(option.items){
178
- item_titles = option.items.split(',');
179
- option.item_count = item_titles.length;
180
- }else{
181
- for(let b = 1;b<parseInt(option.item_count)+1;b++){
182
- item_titles.push(title+" " +Type.get_title(item.categorys[Num.get_id(option.category_count)].category)+" "+ b);
183
- }
184
- }
185
- for(const child_item_title of item_titles){
186
- const cat_item = item.categorys[Num.get_id(option.category_count)];
187
- if(!cat_item.items){
188
- cat_item.items = [];
189
- }
190
- let child_item = Item_Logic.get_new(child_item_title,option.item_data_type);
191
- if(option.item_data_type == Type.DATA_PRODUCT){
192
- child_item.cost = Num.get_id(9000);
193
- child_item.old_cost = Num.get_id(90000);
194
- }
195
- child_item.type = cat_item.type;
196
- child_item.tag = "Tag "+ Num.get_id() + ", Tag "+Num.get_id() + ", Tag "+ Num.get_id();
197
- child_item.category = cat_item.title;
198
- child_item.description =Title.DESCRIPTION+" "+ String(Num.get_id());
199
- child_item.note = Field_Logic.get_test_note(),
200
- cat_item.items.push(child_item);
201
- full_items.push(child_item);
202
- }
203
- }
204
- return item;
205
- };
206
- }
207
146
  class Type {
208
147
  //app_status
209
148
  static APP_ENV_TEST='test';
@@ -232,7 +171,6 @@ class Type {
232
171
  static DATA_FILE='file_biz';
233
172
  static DATA_GALLERY='gallery_biz';
234
173
  static DATA_IMAGE='image_biz';
235
- static DATA_ITEM='item_biz';
236
174
  static DATA_LINK='link_biz';
237
175
  static DATA_ORDER="order_biz";
238
176
  static DATA_ORDER_ITEM="order_item_biz";
@@ -250,23 +188,23 @@ class Type {
250
188
  static DATA_VIDEO='video_biz';
251
189
 
252
190
  //field
253
- static FIELD_AUTHOR = 'author';
254
- static FIELD_CATEGORY = 'category';
255
- static FIELD_CATEGORY_TYPE = 'category_type';
256
- static FIELD_COST = 'cost';
191
+ static FIELD_AUTHOR = 'author';
192
+ static FIELD_CATEGORY = 'category';
193
+ static FIELD_CATEGORY_TYPE = 'category_type';
194
+ static FIELD_COST = 'cost';
257
195
  static FIELD_DATA_TYPE='data_type';
258
196
  static FIELD_DATE_CREATE='date_create';
259
197
  static FIELD_DATE_SAVE='date_save';
260
198
  static FIELD_DATE = 'date';
261
- static FIELD_DESCRIPTION = 'description';
262
- static FIELD_EDIT_LOCATION = 'edit_location';
199
+ static FIELD_DESCRIPTION = 'description';
200
+ static FIELD_EDIT_LOCATION = 'edit_location';
263
201
  static FIELD_ID='id';
264
- static FIELD_IMAGE_FILENAME = 'image_filename';
265
- static FIELD_LOCATION = 'location';
266
- static FIELD_MEETING_LINK = 'meeting_link';
267
- static FIELD_NOTE = 'note';
268
- static FIELD_OLD_COST = 'old_cost';
269
- static FIELD_PARAM = 'param';
202
+ static FIELD_IMAGE_FILENAME = 'image_filename';
203
+ static FIELD_LOCATION = 'location';
204
+ static FIELD_MEETING_LINK = 'meeting_link';
205
+ static FIELD_NOTE = 'note';
206
+ static FIELD_OLD_COST = 'old_cost';
207
+ static FIELD_PARAM = 'param';
270
208
  static FIELD_PARENT_DATA_TYPE='parent_data_type';
271
209
  static FIELD_PARENT_ID='parent_id';
272
210
  static FIELD_ROLE = 'role';
@@ -275,28 +213,28 @@ class Type {
275
213
  static FIELD_SOURCE_KEY='source_key';
276
214
  static FIELD_SOURCE_ID='source_id';
277
215
  static FIELD_SOURCE_PARENT_ID='source_parent_id';
278
- static FIELD_SETTING_VISIBLE = 'setting_visible';
279
- static FIELD_SETTING_DELETE_PROTECTION = 'setting_delete_protection';
280
- static FIELD_SETTING_SORT_TYPE = 'setting_delete_sort_type';
281
- static FIELD_STOCK = 'stock';
282
- static FIELD_TAG = 'tag';
283
- static FIELD_TIME = 'time';
284
- static FIELD_TITLE='title';
216
+ static FIELD_SETTING_VISIBLE = 'setting_visible';
217
+ static FIELD_SETTING_DELETE_PROTECTION = 'setting_delete_protection';
218
+ static FIELD_SETTING_SORT_TYPE = 'setting_delete_sort_type';
219
+ static FIELD_STOCK = 'stock';
220
+ static FIELD_TAG = 'tag';
221
+ static FIELD_TIME = 'time';
222
+ static FIELD_TITLE='title';
285
223
  static FIELD_TITLE_URL='title_url';
286
- static FIELD_TYPE = 'type';
287
- static FIELD_URL = 'url';
288
- static FIELD_USER_CITY = 'city';
289
- static FIELD_USER_COUNTRY = 'country';
290
- static FIELD_USER_EMAIL = 'email';
291
- static FIELD_USER_FIRST_NAME = 'first_name';
292
- static FIELD_USER_GENDER = 'gender';
224
+ static FIELD_TYPE = 'type';
225
+ static FIELD_URL = 'url';
226
+ static FIELD_USER_CITY = 'city';
227
+ static FIELD_USER_COUNTRY = 'country';
228
+ static FIELD_USER_EMAIL = 'email';
229
+ static FIELD_USER_FIRST_NAME = 'first_name';
230
+ static FIELD_USER_GENDER = 'gender';
293
231
  static FIELD_USER_ID='user_id';
294
- static FIELD_USER_LAST_NAME = 'last_name';
295
- static FIELD_USER_USERNAME = 'username';
296
- static FIELD_USER_PASSWORD = 'password';
297
- static FIELD_USER_STATE = 'state';
298
- static FIELD_VALUE = 'value';
299
- static FIELD_WEBSITE = 'website';
232
+ static FIELD_USER_LAST_NAME = 'last_name';
233
+ static FIELD_USER_USERNAME = 'username';
234
+ static FIELD_USER_PASSWORD = 'password';
235
+ static FIELD_USER_STATE = 'state';
236
+ static FIELD_VALUE = 'value';
237
+ static FIELD_WEBSITE = 'website';
300
238
  //title
301
239
  static TITLE_BLANK='blank';
302
240
  static TITLE_CART_ITEMS='cart_items';
@@ -308,7 +246,7 @@ class Type {
308
246
  static TITLE_N_A='n/a';
309
247
  static TITLE_IMAGES='images';
310
248
  static TITLE_ITEMS='items';
311
- static TITLE_OBJ='obj';
249
+ static TITLE_ONE='one';
312
250
  static TITLE_ORDER_ITEMS='order_items';
313
251
  static TITLE_ORDER_SUB_ITEMS='order_sub_items';
314
252
  static TITLE_PARENT_ITEM='parent_item';
@@ -502,13 +440,13 @@ class Type {
502
440
  //9_get_title
503
441
  static get_title = (type,option)=>{
504
442
  /* option
505
- * get_lowercase = ex. true,false / def. false
506
- * get_plural = ex. true,false / def. false
507
- * get_url = ex. true,false / def. false
508
- */
443
+ * lowercase = ex. true,false / def. false
444
+ * plural = ex. true,false / def. false
445
+ * url = ex. true,false / def. false
446
+ */
509
447
  type = type?type:"";
510
448
  let r_type = "";
511
- option = option ? option : {get_lowercase:false,get_plural:false,get_url:false};
449
+ option = option ? option : {lowercase:false,plural:false,url:false};
512
450
  switch(type){
513
451
  case Type.STAT_CART:
514
452
  r_type = "Cart";
@@ -625,8 +563,6 @@ class Type {
625
563
  case Type.DATA_FILE:
626
564
  case Type.DATA_GALLERY:
627
565
  case Type.DATA_GROUP:
628
- case Type.DATA_ITEM_MAP:
629
- case Type.DATA_ITEM:
630
566
  case Type.DATA_LINK:
631
567
  case Type.DATA_ORDER:
632
568
  case Type.DATA_ORDER_ITEM:
@@ -643,22 +579,22 @@ class Type {
643
579
  case Type.DATA_TYPE:
644
580
  case Type.DATA_USER:
645
581
  case Type.DATA_VIDEO:
646
- r_type = String(Str.get_title(type.replaceAll('_',' ').replaceAll('dt','').replace('biz',''))).trim();
647
- break;
582
+ r_type = String(Str.get_title(type.replaceAll('_',' ').replaceAll('dt','').replace('biz',''))).trim();
583
+ break;
648
584
  default:
649
585
  r_type = "N/A";
650
586
  break;
651
587
  }
652
- if(option.get_plural){
653
- r_type = r_type + 's';
654
- }
655
- if(option.get_lowercase){
656
- r_type = r_type.toLowerCase();
657
- }
658
- if(option.get_url){
659
- r_type = r_type.replace(" ","_").toLowerCase();
660
- }
661
- return r_type;
588
+ if(option.plural){
589
+ r_type = r_type + 's';
590
+ }
591
+ if(option.lowercase){
592
+ r_type = r_type.toLowerCase();
593
+ }
594
+ if(option.url){
595
+ r_type = r_type.replace(" ","_").toLowerCase();
596
+ }
597
+ return r_type;
662
598
  };
663
599
  static get_type_title = (data_type) => {
664
600
  return String(data_type.replaceAll('_',' ').replaceAll('dt','').replace('biz','')).trim();
@@ -666,7 +602,7 @@ class Type {
666
602
  }
667
603
  class Stat_Logic {
668
604
  static get_new = (parent_data_type,parent_id,type,user_id,post_data) => {
669
- let new_stat = DataItem.get_new(Type.DATA_STAT,0,
605
+ let new_stat = Data_Logic.get_new(Type.DATA_STAT,0,
670
606
  {
671
607
  user_id:user_id,
672
608
  type:type,
@@ -681,34 +617,30 @@ class Stat_Logic {
681
617
  static filter_stat = (post_data) =>{
682
618
  let filter_stat = {};
683
619
  for(const prop in post_data) {
684
- const value = post_data[prop];
620
+ const value = post_data[prop];
685
621
  if (!Array.isArray(value)
686
622
  && prop != Type.FIELD_SOURCE
687
623
  && prop != Type.FIELD_DATE_CREATE
688
624
  && prop != Type.FIELD_DATE_SAVE
689
625
  && prop != Type.FIELD_DATA_TYPE
690
- && prop != Type.TITLE_CART_ITEMS
626
+ && prop != Type.TITLE_CART_ITEMS
691
627
  && prop != Type.TITLE_CART_SUB_ITEMS
692
- && prop != Type.TITLE_ORDER_ITEMS
628
+ && prop != Type.TITLE_ORDER_ITEMS
693
629
  && prop != Type.TITLE_ORDER_SUB_ITEMS
694
- && prop != Type.FIELD_SOURCE
630
+ && prop != Type.FIELD_SOURCE
695
631
  && prop != Type.FIELD_SOURCE_ID
696
632
  && prop != Type.FIELD_ID) {
697
- filter_stat[prop] = post_data[prop];
698
- }
699
- }
633
+ filter_stat[prop] = post_data[prop];
634
+ }
635
+ }
700
636
  return filter_stat;
701
637
  }
702
638
  }
703
639
  class Page_Logic {
704
- static get_test = (title,option) =>{
640
+ static get_test = (title,option) =>{
705
641
  [title,option] = Field_Logic.get_option_title(title,option);
706
642
  option = Field_Logic.get_option(Type.DATA_PAGE,option?option:{});
707
- let page = DataItem.get_new(Type.DATA_PAGE,0,Field_Logic.get_test(title,option));
708
- if(option.get_section){
709
- page.items = Sub_Item_Logic.get_test_sections(page,page,option);
710
- page = Sub_Item_Logic.bind_parent_child_items(page,page.items);
711
- }
643
+ let page = Data_Logic.get_new(Type.DATA_PAGE,0,Field_Logic.get_test(title,option));
712
644
  return page;
713
645
  };
714
646
  static get_test_items = (option) =>{
@@ -723,7 +655,7 @@ static get_test = (title,option) =>{
723
655
  class Order_Logic {
724
656
  static get_new = (cart,option) => {
725
657
  option = option?option:{get_payment_plan:false,payment_plan:Title.ORDER_PAYMENT_PLAN_1};
726
- let order = DataItem.get_new(Type.DATA_ORDER,0,{
658
+ let order = Data_Logic.get_new(Type.DATA_ORDER,0,{
727
659
  order_number:Title.ORDER_NUMBER + Num.get_id(99999),
728
660
  parent_data_type:cart.parent_data_type,
729
661
  user_id:cart.user_id,
@@ -736,18 +668,18 @@ class Order_Logic {
736
668
  if(!Str.check_is_null(cart[key])
737
669
  && key != Type.FIELD_ID && key != Type.FIELD_DATA_TYPE
738
670
  && key != Type.TITLE_PARENT_ITEM && key != Type.TITLE_USER
739
- && key != Type.TITLE_CART_ITEMS && key != Type.TITLE_CART_SUB_ITEMS
740
- && key != Type.TITLE_ORDER_ITEMS && key != Type.TITLE_ORDER_SUB_ITEMS
741
- && key != Type.FIELD_SOURCE && key != Type.FIELD_SOURCE_ID
742
- && key != Type.FIELD_DATE_CREATE && key != Type.FIELD_DATE_SAVE){
671
+ && key != Type.TITLE_CART_ITEMS && key != Type.TITLE_CART_SUB_ITEMS
672
+ && key != Type.TITLE_ORDER_ITEMS && key != Type.TITLE_ORDER_SUB_ITEMS
673
+ && key != Type.FIELD_SOURCE && key != Type.FIELD_SOURCE_ID
674
+ && key != Type.FIELD_DATE_CREATE && key != Type.FIELD_DATE_SAVE){
743
675
  order[key] = cart[key];
744
- }
745
- }
676
+ }
677
+ }
746
678
  if(option.get_payment_plan){
747
679
  order.payment_plan = option.payment_plan;
748
680
  }
749
681
  cart.cart_items.forEach(cart_item => {
750
- let order_item = DataItem.get_new(Type.DATA_ORDER_ITEM,0,{
682
+ let order_item = Data_Logic.get_new(Type.DATA_ORDER_ITEM,0,{
751
683
  order_number:order.order_number,
752
684
  parent_data_type:cart_item.parent_data_type,
753
685
  parent_id:cart_item.parent_id,
@@ -756,19 +688,19 @@ class Order_Logic {
756
688
  cost:cart_item.cost?cart_item.cost:0,
757
689
  order_sub_items:[]
758
690
  });
759
- for(const key in cart_item){
760
- if(!Str.check_is_null(cart_item[key])
761
- && key != Type.FIELD_ID && key != Type.FIELD_DATA_TYPE
762
- && key != Type.TITLE_PARENT_ITEM && key != Type.TITLE_USER
763
- && key != Type.TITLE_CART_ITEMS && key != Type.TITLE_CART_SUB_ITEMS
764
- && key != Type.TITLE_ORDER_ITEMS && key != Type.TITLE_ORDER_SUB_ITEMS
765
- && key != Type.FIELD_SOURCE && key != Type.FIELD_SOURCE_ID
766
- && key != Type.FIELD_DATE_CREATE && key != Type.FIELD_DATE_SAVE){
691
+ for(const key in cart_item){
692
+ if(!Str.check_is_null(cart_item[key])
693
+ && key != Type.FIELD_ID && key != Type.FIELD_DATA_TYPE
694
+ && key != Type.TITLE_PARENT_ITEM && key != Type.TITLE_USER
695
+ && key != Type.TITLE_CART_ITEMS && key != Type.TITLE_CART_SUB_ITEMS
696
+ && key != Type.TITLE_ORDER_ITEMS && key != Type.TITLE_ORDER_SUB_ITEMS
697
+ && key != Type.FIELD_SOURCE && key != Type.FIELD_SOURCE_ID
698
+ && key != Type.FIELD_DATE_CREATE && key != Type.FIELD_DATE_SAVE){
767
699
  order_item[key] = cart_item[key];
768
- }
769
- }
700
+ }
701
+ }
770
702
  cart_item.cart_sub_items.forEach(cart_sub_item => {
771
- let order_sub_item = DataItem.get_new(Type.DATA_ORDER_SUB_ITEM,0,{
703
+ let order_sub_item = Data_Logic.get_new(Type.DATA_ORDER_SUB_ITEM,0,{
772
704
  order_number:order.order_number,
773
705
  parent_data_type:cart_sub_item.parent_data_type,
774
706
  parent_id:cart_sub_item.parent_id,
@@ -780,13 +712,13 @@ class Order_Logic {
780
712
  if(!Str.check_is_null(cart_sub_item[key])
781
713
  && key != Type.FIELD_ID && key != Type.DATA_TYPE
782
714
  && key != Type.TITLE_PARENT_ITEM && key != Type.TITLE_USER
783
- && key != Type.TITLE_CART_ITEMS && key != Type.TITLE_CART_SUB_ITEMS
784
- && key != Type.TITLE_ORDER_ITEMS && key != Type.TITLE_ORDER_SUB_ITEMS
785
- && key != Type.FIELD_SOURCE && key != Type.FIELD_SOURCE_ID
786
- && key != Type.FIELD_DATE_CREATE && key != Type.FIELD_DATE_SAVE){
715
+ && key != Type.TITLE_CART_ITEMS && key != Type.TITLE_CART_SUB_ITEMS
716
+ && key != Type.TITLE_ORDER_ITEMS && key != Type.TITLE_ORDER_SUB_ITEMS
717
+ && key != Type.FIELD_SOURCE && key != Type.FIELD_SOURCE_ID
718
+ && key != Type.FIELD_DATE_CREATE && key != Type.FIELD_DATE_SAVE){
787
719
  order_sub_item[key] = cart_sub_item[key];
788
- }
789
- }
720
+ }
721
+ }
790
722
  order_item.order_sub_items.push(order_sub_item);
791
723
  });
792
724
  order.order_items.push(order_item);
@@ -794,7 +726,7 @@ class Order_Logic {
794
726
  return order;
795
727
  };
796
728
  static get_new_order_payment = (order_number,payment_method_type,payment_amount) => {
797
- return DataItem.get_new(Type.DATA_ORDER_PAYMENT,0,
729
+ return Data_Logic.get_new(Type.DATA_ORDER_PAYMENT,0,
798
730
  {
799
731
  order_number:order_number,
800
732
  payment_method_type:payment_method_type,
@@ -802,58 +734,58 @@ class Order_Logic {
802
734
  transaction_id:Title.ORDER_TRANSACTION_ID + Num.get_id(99999)
803
735
  });
804
736
  };
805
- static get_total = (order) => {
806
- let grand_total = 0;
807
- order.order_items.forEach(order_item => {
808
- order_item.sub_total = 0;
809
- if(!isNaN(order_item.cost)){
810
- order_item.sub_total = (order_item.sub_total + order_item.cost) * order_item.quanity;
811
- grand_total = grand_total + order_item.sub_total;
812
- }
813
- order_item.order_sub_items.forEach(order_sub_item => {
814
- order_sub_item.sub_total = 0;
815
- if(!isNaN(order_sub_item.cost)){
816
- order_sub_item.sub_total = (order_sub_item.sub_total + order_sub_item.cost) * order_sub_item.quanity;
817
- grand_total = grand_total + order_sub_item.sub_total;
818
- }
819
- });
820
- });
737
+ static get_total = (order) => {
738
+ let grand_total = 0;
739
+ order.order_items.forEach(order_item => {
740
+ order_item.sub_total = 0;
741
+ if(!isNaN(order_item.cost)){
742
+ order_item.sub_total = (order_item.sub_total + order_item.cost) * order_item.quanity;
743
+ grand_total = grand_total + order_item.sub_total;
744
+ }
745
+ order_item.order_sub_items.forEach(order_sub_item => {
746
+ order_sub_item.sub_total = 0;
747
+ if(!isNaN(order_sub_item.cost)){
748
+ order_sub_item.sub_total = (order_sub_item.sub_total + order_sub_item.cost) * order_sub_item.quanity;
749
+ grand_total = grand_total + order_sub_item.sub_total;
750
+ }
751
+ });
752
+ });
821
753
  order.grand_total = grand_total;
822
- return order;
823
- };
754
+ return order;
755
+ };
824
756
  }
825
757
  class Cart_Logic {
826
758
  static get_new = (parent_data_type,user_id) => {
827
- return DataItem.get_new(Type.DATA_CART,0,{user_id:user_id,cart_number:Title.CART_NUMBER + Num.get_id(99999),parent_data_type:parent_data_type,grand_total:0,cart_items:[]});
759
+ return Data_Logic.get_new(Type.DATA_CART,0,{user_id:user_id,cart_number:Title.CART_NUMBER + Num.get_id(99999),parent_data_type:parent_data_type,grand_total:0,cart_items:[]});
828
760
  };
829
761
  static get_new_cart_item = (parent_data_type,parent_id,cart_number,quanity,cost) =>{
830
- return DataItem.get_new(Type.DATA_CART_ITEM,0,{parent_data_type:parent_data_type,parent_id:parent_id,cart_number:cart_number,quanity:quanity?quanity:0,cost:cost?cost:0,cart_sub_items:[]});
762
+ return Data_Logic.get_new(Type.DATA_CART_ITEM,0,{parent_data_type:parent_data_type,parent_id:parent_id,cart_number:cart_number,quanity:quanity?quanity:0,cost:cost?cost:0,cart_sub_items:[]});
831
763
  };
832
764
  static get_new_cart_sub_item = (parent_data_type,parent_id,cart_number,quanity,cost) =>{
833
- return DataItem.get_new(Type.DATA_CART_SUB_ITEM,0,{parent_data_type:parent_data_type,parent_id:parent_id,cart_number:cart_number,quanity:quanity?quanity:0,cost:cost?cost:0});
834
- };
835
- static get_total = (cart) => {
836
- let grand_total = 0;
837
- cart.cart_items.forEach(cart_item => {
838
- cart_item.sub_total = 0;
839
- if(!isNaN(cart_item.cost)){
840
- cart_item.sub_total = (cart_item.sub_total + cart_item.cost) * cart_item.quanity;
841
- grand_total = grand_total + cart_item.sub_total;
842
- }
843
- cart_item.cart_sub_items.forEach(cart_sub_item => {
844
- cart_sub_item.sub_total = 0;
845
- if(!isNaN(cart_sub_item.cost)){
846
- cart_sub_item.sub_total = (cart_sub_item.sub_total + cart_sub_item.cost) * cart_sub_item.quanity;
847
- grand_total = grand_total + cart_sub_item.sub_total;
848
- }
849
- });
850
- });
765
+ return Data_Logic.get_new(Type.DATA_CART_SUB_ITEM,0,{parent_data_type:parent_data_type,parent_id:parent_id,cart_number:cart_number,quanity:quanity?quanity:0,cost:cost?cost:0});
766
+ };
767
+ static get_total = (cart) => {
768
+ let grand_total = 0;
769
+ cart.cart_items.forEach(cart_item => {
770
+ cart_item.sub_total = 0;
771
+ if(!isNaN(cart_item.cost)){
772
+ cart_item.sub_total = (cart_item.sub_total + cart_item.cost) * cart_item.quanity;
773
+ grand_total = grand_total + cart_item.sub_total;
774
+ }
775
+ cart_item.cart_sub_items.forEach(cart_sub_item => {
776
+ cart_sub_item.sub_total = 0;
777
+ if(!isNaN(cart_sub_item.cost)){
778
+ cart_sub_item.sub_total = (cart_sub_item.sub_total + cart_sub_item.cost) * cart_sub_item.quanity;
779
+ grand_total = grand_total + cart_sub_item.sub_total;
780
+ }
781
+ });
782
+ });
851
783
  cart.grand_total = grand_total;
852
- return cart;
853
- };
784
+ return cart;
785
+ };
854
786
  }
855
787
  class Product_Logic {
856
- static get_new = (title,type,category,option) => {
788
+ static get_new = (title,type,category,option) => {
857
789
  option = option ? option : {};
858
790
  const item = Item_Logic.get_new(title,Type.DATA_PRODUCT);
859
791
  item.type = type;
@@ -893,12 +825,10 @@ static get_new = (title,type,category,option) => {
893
825
  static get_test = (title,option) =>{
894
826
  [title,option] = Field_Logic.get_option_title(title,option);
895
827
  option = Field_Logic.get_option(Type.DATA_PRODUCT,option?option:{});
896
- let product = DataItem.get_new(Type.DATA_PRODUCT,0,Field_Logic.get_test(title,option));
828
+ let product = Data_Logic.get_new(Type.DATA_PRODUCT,0,Field_Logic.get_test(title,option));
897
829
  if(option.get_blank ==false){
898
830
  product.cost = Field_Logic.get_test_cost();
899
831
  product.old_cost = Field_Logic.get_test_cost();
900
- product.cart_count = 0;
901
- product.order_count = 0;
902
832
  product.type = "Type "+String(Num.get_id());
903
833
  product.sub_type = "Sub Type "+String(Num.get_id());
904
834
  product.stock = String(Num.get_id(3-1));
@@ -911,15 +841,12 @@ static get_new = (title,type,category,option) => {
911
841
  product.stock = "";
912
842
  product.tag = "";
913
843
  }
914
- if(option.get_item){
915
- product.items = Sub_Item_Logic.get_test_items(product,product,option);
916
- }
917
844
  return product;
918
845
  };
919
846
  static get_test_cart = (cart_number,user_id,option) =>{
920
847
  [cart_number,option] = ield_Logic.get_option_title(cart_number,option);
921
848
  option = Field_Logic.get_option(Type.DATA_CART,option?option:{});
922
- let cart = DataItem.get_new(Type.DATA_CART,Num.get_guid(),Field_Logic.get_test(cart_number,option));
849
+ let cart = Data_Logic.get_new(Type.DATA_CART,Num.get_guid(),Field_Logic.get_test(cart_number,option));
923
850
  cart.user_id = user_id;
924
851
  cart.cart_number = cart_number;
925
852
  if(option.get_cart_item){
@@ -985,16 +912,13 @@ class Service_Logic {
985
912
  static get_test = (title,option) =>{
986
913
  [title,option] = Field_Logic.get_option_title(title,option);
987
914
  option = Field_Logic.get_option(Type.DATA_SERVICE,option?option:{});
988
- let service = DataItem.get_new(Type.DATA_SERVICE,0,Field_Logic.get_test(title,option));
915
+ let service = Data_Logic.get_new(Type.DATA_SERVICE,0,Field_Logic.get_test(title,option));
989
916
  service.cost = Field_Logic.get_test_cost();
990
917
  service.old_cost = Field_Logic.get_test_cost();
991
918
  service.type = "Type "+String(Num.get_id());
992
919
  service.sub_type = "Sub Type "+String(Num.get_id());
993
920
  service.stock = String(Num.get_id(3-1));
994
921
  service.tag = "Tag "+ Num.get_id() + ", Tag "+Num.get_id() + ", Tag "+ Num.get_id();
995
- if(option.get_item){
996
- service.items = Sub_Item_Logic.get_test_items(service,service,option);
997
- }
998
922
  return service;
999
923
  };
1000
924
  static get_test_items = (option) =>{
@@ -1025,13 +949,7 @@ class Content_Logic {
1025
949
  static get_test = (title,option) =>{
1026
950
  [title,option] = Field_Logic.get_option_title(title,option);
1027
951
  option = Field_Logic.get_option(Type.DATA_CONTENT,option?option:{});
1028
- let content = DataItem.get_new(Type.DATA_CONTENT,0,Field_Logic.get_test(title,option));
1029
- if(option.get_item){
1030
- content.items = Sub_Item_Logic.get_test_sections(content,content,option);
1031
- if(option.get_item_bind){
1032
- content = Sub_Item_Logic.bind_parent_child_items(content,content.items);
1033
- }
1034
- }
952
+ let content = Data_Logic.get_new(Type.DATA_CONTENT,0,Field_Logic.get_test(title,option));
1035
953
  return content;
1036
954
  };
1037
955
  static get_test_items = (option) =>{
@@ -1062,15 +980,30 @@ class Template_Logic {
1062
980
  static get_test = (title,option) =>{
1063
981
  [title,option] = Field_Logic.get_option_title(title,option);
1064
982
  option = Field_Logic.get_option(Type.DATA_TEMPLATE,option?option:{});
1065
- let template = DataItem.get_new(Type.DATA_TEMPLATE,0,Field_Logic.get_test(title,option));
983
+ let template = Data_Logic.get_new(Type.DATA_TEMPLATE,0,Field_Logic.get_test(title,option));
1066
984
  return template;
1067
985
  };
1068
986
  }
987
+ class Blank_Logic {
988
+ static get_test = (title,option) =>{
989
+ [title,option] = Field_Logic.get_option_title(title,option);
990
+ option = Field_Logic.get_option(Type.DATA_BLANK,option?option:{});
991
+ let blog_post = Data_Logic.get_new(Type.DATA_BLANK,0,Field_Logic.get_test(title,option));
992
+ if(!option.get_blank){
993
+ blog_post.field_1="Field 1 "+ Num.get_id();
994
+ blog_post.field_2="Field 2 "+ Num.get_id();
995
+ }else{
996
+ blog_post.field_1="";
997
+ blog_post.field_2 = "";
998
+ }
999
+ return blog_post;
1000
+ };
1001
+ };
1069
1002
  class Blog_Post_Logic {
1070
1003
  static get_test = (title,option) =>{
1071
1004
  [title,option] = Field_Logic.get_option_title(title,option);
1072
1005
  option = Field_Logic.get_option(Type.DATA_BLOG_POST,option?option:{});
1073
- let blog_post = DataItem.get_new(Type.DATA_BLOG_POST,0,Field_Logic.get_test(title,option));
1006
+ let blog_post = Data_Logic.get_new(Type.DATA_BLOG_POST,0,Field_Logic.get_test(title,option));
1074
1007
  if(!option.get_blank){
1075
1008
  blog_post.author="First Name "+ Num.get_id();
1076
1009
  blog_post.tag = "Tag "+ Num.get_id() + ", Tag "+Num.get_id() + ", Tag "+ Num.get_id(), " Tag "+ Num.get_id() + ", Tag "+Num.get_id() + ", Tag "+ Num.get_id();
@@ -1078,9 +1011,6 @@ class Blog_Post_Logic {
1078
1011
  blog_post.author="";
1079
1012
  blog_post.tag = "";
1080
1013
  }
1081
- if(option.get_item){
1082
- blog_post.items = Sub_Item_Logic.get_test_items(blog_post,blog_post,option);
1083
- }
1084
1014
  return blog_post;
1085
1015
  };
1086
1016
  static get_test_items = (option) =>{
@@ -1111,7 +1041,7 @@ class Gallery_Logic {
1111
1041
  static get_test = (title,option) =>{
1112
1042
  [title,option] = Field_Logic.get_option_title(title,option);
1113
1043
  option = Field_Logic.get_option(Type.DATA_GALLERY,option?option:{});
1114
- let gallery = DataItem.get_new(Type.DATA_GALLERY,0,Field_Logic.get_test(title,option));
1044
+ let gallery = Data_Logic.get_new(Type.DATA_GALLERY,0,Field_Logic.get_test(title,option));
1115
1045
  if(!option.get_blank){
1116
1046
  gallery.date = String(String(Num.get_id(2030)) + "-" + String(Num.get_id(13)) + "-" + String(Num.get_id(30))).trim();
1117
1047
  gallery.time = String(Num.get_id(24)) + ":" + String(Num.get_id(59));
@@ -1119,9 +1049,6 @@ class Gallery_Logic {
1119
1049
  }else{
1120
1050
  gallery.website = "";
1121
1051
  }
1122
- if(option.get_item){
1123
- gallery.items = Sub_Item_Logic.get_test_items(gallery,gallery,option);
1124
- }
1125
1052
  return gallery;
1126
1053
  };
1127
1054
  };
@@ -1156,7 +1083,7 @@ class Event_Logic {
1156
1083
  static get_test = (title,option) =>{
1157
1084
  [title,option] = Field_Logic.get_option_title(title,option);
1158
1085
  option = Field_Logic.get_option(Type.DATA_EVENT,option?option:{});
1159
- let event = DataItem.get_new(Type.DATA_EVENT,0,Field_Logic.get_test(title,option));
1086
+ let event = Data_Logic.get_new(Type.DATA_EVENT,0,Field_Logic.get_test(title,option));
1160
1087
  if(!option.get_blank){
1161
1088
  event.cost = Field_Logic.get_test_cost();
1162
1089
  event.old_cost = Field_Logic.get_test_cost();
@@ -1180,9 +1107,6 @@ class Event_Logic {
1180
1107
  event.category ="";
1181
1108
  event.tag = "";
1182
1109
  }
1183
- if(option.get_item){
1184
- event.items = Sub_Item_Logic.get_test_items(event,event,option);
1185
- }
1186
1110
  return event;
1187
1111
  };
1188
1112
  static get_test_items = (option) =>{
@@ -1234,7 +1158,7 @@ class Field_Logic {
1234
1158
  full_prop_str = String(prop + " "+full_prop_str);
1235
1159
  }
1236
1160
  for(let a = 1; a < 75; a++){
1237
- const exists = Str.check_if_str_exist(full_prop_str,"items_value_"+a);
1161
+ const exists = Str.check_if_str_exist(full_prop_str,"items_value_"+a);
1238
1162
  if(exists){
1239
1163
  if(a>max_value_id){
1240
1164
  max_value_id = a;
@@ -1311,7 +1235,7 @@ class Field_Logic {
1311
1235
  return String(Num.get_id(999)) + "." + String(Num.get_id(99));
1312
1236
  }
1313
1237
  static get_test_note = () => {
1314
- return "Note "+String(Num.get_id()) + " Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
1238
+ return "Note "+String(Num.get_id()) + " Lorem Ipsum is simply dummy text of the printing and typesetting industry.";
1315
1239
  }
1316
1240
  static get_test = (title,option) =>{
1317
1241
  option = !Obj.check_is_empty(option) ? option : {};
@@ -1395,13 +1319,10 @@ class Field_Logic {
1395
1319
  };
1396
1320
  static get_option(data_type,option){
1397
1321
  data_type = data_type ? data_type : Type.DATA_BLANK;
1398
- option = !Obj.check_is_empty(option) ? option : {get_value:false,get_item:false,get_image:false,item_count:9,value_count:9};
1322
+ option = !Obj.check_is_empty(option) ? option : {get_value:false,item_count:9,value_count:9};
1399
1323
  option.generate_id = option.generate_id ? option.generate_id : false;
1400
- option.get_image = option.get_image ? true : false;
1401
1324
  option.get_value = option.get_value ? true : false;
1402
- option.get_item = option.get_item ? true : false;
1403
1325
  option.get_blank = option.get_blank ? true : false;
1404
- option.get_item_bind = option.get_item_bind ? true : true;
1405
1326
  option.value_count = option.value_count ? option.value_count : 9;
1406
1327
  option.section_count = option.section_count ? option.section_count : 9;
1407
1328
  option.item_count = option.item_count ? option.item_count : 9;
@@ -1535,46 +1456,9 @@ class Field_Logic {
1535
1456
  return option;
1536
1457
  }
1537
1458
  }
1538
- /*
1539
- class Type.DATA_{
1540
- static APP='app_biz';
1541
- static BLANK='blank_biz';
1542
- static BLOG_POST='blog_post_biz';
1543
- static CART_ITEM="cart_item_biz";
1544
- static CART="cart_biz";
1545
- static CART_ITEM="cart_item_biz";
1546
- static CART_SUB_ITEM="cart_sub_item_biz";
1547
- static CATEGORY='category_biz';
1548
- static CUSTOM_FIELD='custom_field_biz';
1549
- static CONTENT='content_biz';
1550
- static EVENT='event_biz';
1551
- static GROUP='group_biz';
1552
- static FAQ='faq_biz';
1553
- static FAVORITE='favorite_biz';
1554
- static FILE='file_biz';
1555
- static GALLERY='gallery_biz';
1556
- static IMAGE='image_biz';
1557
- static ITEM='item_biz';
1558
- static LINK='link_biz';
1559
- static ORDER="order_biz";
1560
- static ORDER_ITEM="order_item_biz";
1561
- static ORDER_SUB_ITEM="order_sub_item_biz";
1562
- static ORDER_PAYMENT="order_payment_biz";
1563
- static PRODUCT='product_biz';
1564
- static PAGE='page_biz';
1565
- static REVIEW='review_biz';
1566
- static SERVICE='service_biz';
1567
- static SECURITY='security_biz';
1568
- static STAT='stat_biz';
1569
- static TEMPLATE='template_biz';
1570
- static TYPE='type_biz';
1571
- static USER='user_biz';
1572
- static VIDEO='video_biz';
1573
- }
1574
- */
1575
1459
  class Favorite_Logic {
1576
1460
  static get_new = (parent_data_type,parent_id,user_id) =>{
1577
- return DataItem.get_new(Type.DATA_FAVORITE,0,{
1461
+ return Data_Logic.get_new(Type.DATA_FAVORITE,0,{
1578
1462
  parent_data_type:parent_data_type,
1579
1463
  parent_id:parent_id,
1580
1464
  user_id:user_id
@@ -1598,7 +1482,7 @@ class Favorite_Logic {
1598
1482
  }
1599
1483
  class Review_Logic {
1600
1484
  static get_new = (parent_data_type,parent_id,user_id,title,comment,rating) =>{
1601
- return DataItem.get_new(Type.DATA_REVIEW,0,{
1485
+ return Data_Logic.get_new(Type.DATA_REVIEW,0,{
1602
1486
  parent_data_type:parent_data_type,
1603
1487
  parent_id:parent_id,
1604
1488
  user_id:user_id,
@@ -1623,7 +1507,7 @@ class Review_Logic {
1623
1507
  }
1624
1508
  static get_test = (item_data_type,item_id,user_id,option) =>{
1625
1509
  option = Field_Logic.get_option(Type.DATA_REVIEW,option?option:{});
1626
- let review = DataItem.get_new(Type.DATA_REVIEW,0);
1510
+ let review = Data_Logic.get_new(Type.DATA_REVIEW,0);
1627
1511
  if(!option.get_blank){
1628
1512
  review.title = 'Title ' + Num.get_id();
1629
1513
  review.item_data_type = item_data_type;
@@ -1653,10 +1537,10 @@ class Review_Logic {
1653
1537
  class Admin_Logic {
1654
1538
  static get_new = (title,option) =>{
1655
1539
  [title,option] = Field_Logic.get_option_title(title,option);
1656
- return DataItem.get_new_full_item(
1657
- DataItem.get_new(Type.DATA_ADMIN,0),
1658
- DataItem.get_new(Type.DATA_ADMIN,0),
1659
- DataItem.get_new(Type.DATA_ADMIN,0),{
1540
+ return Data_Logic.get_new_full_item(
1541
+ Data_Logic.get_new(Type.DATA_ADMIN,0),
1542
+ Data_Logic.get_new(Type.DATA_ADMIN,0),
1543
+ Data_Logic.get_new(Type.DATA_ADMIN,0),{
1660
1544
  title:title,
1661
1545
  email:"",
1662
1546
  });
@@ -1664,8 +1548,8 @@ class Admin_Logic {
1664
1548
  static get_test = (title,option) =>{
1665
1549
  [title,option] = Field_Logic.get_option_title(title,option);
1666
1550
  option = Field_Logic.get_option(Type.DATA_ADMIN,option?option:{});
1667
- let item = DataItem.get_new(Type.DATA_ADMIN,0);
1668
- let admin = DataItem.get_new(Type.DATA_ADMIN,0,Field_Logic.get_test(title,option));
1551
+ let item = Data_Logic.get_new(Type.DATA_ADMIN,0);
1552
+ let admin = Data_Logic.get_new(Type.DATA_ADMIN,0,Field_Logic.get_test(title,option));
1669
1553
  if(!option.get_blank){
1670
1554
  admin.email="ceo@admin"+Num.get_id()+".com";
1671
1555
  admin.password="1234567";
@@ -1684,14 +1568,6 @@ class Admin_Logic {
1684
1568
  return admin.address_1 + " "+ admin.address_2 + " " + admin.city + " " + admin.state + " " + admin.zip;
1685
1569
  }
1686
1570
  }
1687
- class DataItem {
1688
- static get_new = (data_type,id,option) => {
1689
- return get_new_item_main(data_type,id,option?option:{});
1690
- };
1691
- static get_new_full_item = (item,parent_item,top_item,option) => {
1692
- return get_new_full_item_main(item,parent_item,top_item,option?option:{});
1693
- };
1694
- }
1695
1571
  class Category_Logic {
1696
1572
  static get_new = (title,type,category,option) => {
1697
1573
  option = option ? option : {};
@@ -1703,10 +1579,7 @@ class Category_Logic {
1703
1579
  static get_test = (title,option) =>{
1704
1580
  title = (title) ? title : "Category 1";
1705
1581
  option = Field_Logic.get_option(Type.DATA_CATEGORY,option?option:{});
1706
- let category = DataItem.get_new(Type.DATA_CATEGORY,0,Field_Logic.get_test(title,option));
1707
- if(option.get_item){
1708
- category.items = Sub_Item_Logic.get_test_items(category,category,option);
1709
- }
1582
+ let category = Data_Logic.get_new(Type.DATA_CATEGORY,0,Field_Logic.get_test(title,option));
1710
1583
  return category;
1711
1584
  };
1712
1585
  static get_test_items = (option) =>{
@@ -1721,7 +1594,7 @@ class Category_Logic {
1721
1594
  option = Field_Logic.get_option(Type.DATA_CATEGORY,option);
1722
1595
  let categorys = [];
1723
1596
  for(let a=0;a<option.category_count;a++){
1724
- let category = DataItem.get_new(Type.DATA_CATEGORY,0,Field_Logic.get_test("Category " +String(parseInt(a+1)),option));
1597
+ let category = Data_Logic.get_new(Type.DATA_CATEGORY,0,Field_Logic.get_test("Category " +String(parseInt(a+1)),option));
1725
1598
  category.type = type;
1726
1599
  categorys.push(category);
1727
1600
  }
@@ -1813,11 +1686,11 @@ class User_Logic {
1813
1686
 
1814
1687
  }
1815
1688
  static get_guest(){
1816
- return DataItem.get_new(Type.DATA_USER,0,{is_guest:true,title_url:'guest',first_name:'Guest',last_name:'User',email:'guest@email.com',title:"Guest",country:"United States"});
1689
+ return Data_Logic.get_new(Type.DATA_USER,0,{is_guest:true,title_url:'guest',first_name:'Guest',last_name:'User',email:'guest@email.com',title:"Guest",country:"United States"});
1817
1690
  }
1818
1691
  static get_request_user(req){
1819
1692
  if(!req || !req.session.user){
1820
- let user=DataItem.get_new(Type.DATA_USER,Num.get_id(9999999),{is_guest:true});
1693
+ let user=Data_Logic.get_new(Type.DATA_USER,Num.get_id(9999999),{is_guest:true});
1821
1694
  req.session.user=user;
1822
1695
  }
1823
1696
  return req.session.user;
@@ -1832,7 +1705,7 @@ class User_Logic {
1832
1705
  static get_test = (title,option) =>{
1833
1706
  [title,option] = Field_Logic.get_option_title(title,option);
1834
1707
  option = Field_Logic.get_option(Type.DATA_USER,option?option:{});
1835
- let user = DataItem.get_new(Type.DATA_USER,0,
1708
+ let user = Data_Logic.get_new(Type.DATA_USER,0,
1836
1709
  Field_Logic.get_test(title,option));
1837
1710
  if(option.get_blank){
1838
1711
  user.first_name="";
@@ -1862,51 +1735,125 @@ class User_Logic {
1862
1735
  return items;
1863
1736
  }
1864
1737
  }
1865
- class Sub_Item_Logic {
1866
- static get_test(title,parent_item,top_item,option){
1867
- option = Field_Logic.get_option(Type.DATA_ITEM,option?option:{});
1868
- let item_title =title;
1869
- let item = DataItem.get_new(
1870
- Type.DATA_ITEM,0, {
1871
- top_id:top_item.id?top_item.id:0,
1872
- top_data_type:top_item.data_type?top_item.data_type:Type.DATA_BLANK,
1873
- parent_id:parent_item.id?parent_item.id:0,
1874
- parent_data_type:parent_item.data_type?parent_item.data_type:Type.DATA_BLANK,
1875
- title:item_title,
1876
- title_url:Str.get_title_url(item_title),
1877
- description:"Description "+String(Num.get_id()),
1878
- note:Field_Logic.get_test_note()
1738
+ class Data_Logic {
1739
+ static get_new = (data_type,id,data) => {
1740
+ return get_new_item_main(data_type,id,data?data:{});
1741
+ };
1742
+ static get_biz = (data_type,id,option) => {
1743
+ option = option ? option : {};
1744
+ option.data = option.data ? option.data : {};
1745
+ if(option.test){
1746
+ switch(data_type)
1747
+ {
1748
+ case Type.DATA_CATEGORY:
1749
+ option.data = Obj.merge(Category_Logic.get_test(),option.data);
1750
+ break;
1751
+ case Type.DATA_BLOG_POST:
1752
+ option.data = Obj.merge(Blog_Post_Logic.get_test(),option.data);
1753
+ break;
1754
+ case Type.DATA_SERVICE:
1755
+ option.data = Obj.merge(Service_Logic.get_test(),option.data);
1756
+ break;
1757
+ case Type.DATA_PRODUCT:
1758
+ option.data = Obj.merge(Product_Logic.get_test(),option.data);
1759
+ break;
1760
+ case Type.DATA_BLANK:
1761
+ option.data = Obj.merge(Blank_Logic.get_test(),option.data);
1762
+ break;
1763
+ case Type.DATA_USER:
1764
+ option.data = Obj.merge(User_Logic.get_test(),option.data);
1765
+ break;
1766
+ default:
1767
+ option.data = Obj.merge(Blank_Logic.get_test(),option.data);
1768
+ option.data.data_type = Type.DATA_GROUP;
1769
+ break;
1879
1770
  }
1880
- );
1881
- if(option.get_value){
1882
- item = Field_Logic.get_values(item,option);
1883
1771
  }
1884
- return item;
1885
- }
1886
- static get_test_items(parent_item,top_item,option){
1887
- option = Field_Logic.get_option(Type.DATA_SUB_ITEM,option?option:{});
1888
- let items = [];
1889
- for(let a=0;a<option.item_count;a++){
1890
- let item_title ="Item " + String(parseInt(a+1));
1891
- items.push(Sub_Item_Logic.get_test(item_title,parent_item,top_item,option));
1772
+ if(option.parent){
1773
+ option.data[Type.FIELD_PARENT_DATA_TYPE] = option.parent[Type.FIELD_DATA_TYPE] ? option.parent[Type.FIELD_DATA_TYPE] : Type.DATA_BLANK;
1774
+ option.data[Type.FIELD_PARENT_ID] = option.parent[Type.FIELD_ID] ? option.parent[Type.FIELD_ID] : 0;
1892
1775
  }
1893
- return items;
1894
- }
1895
- static get_test_sections(parent_item,top_item,option){
1896
- let items = [];
1897
- for(let a=0;a<option.section_count;a++){
1898
- let item_title ="Section " + String(parseInt(a+1));
1899
- let item = Sub_Item_Logic.get_test(item_title,parent_item,top_item,option);
1900
- items.push(item);
1776
+ if(option.generate_title){
1777
+ option.title = Type.get_title(data_type) + " " +Num.get_id();
1901
1778
  }
1902
- return items;
1903
- }
1904
- static bind_parent_child_items(item,items){
1905
- for(let a=0;a<items.length;a++){
1906
- item[Str.get_title_url(items[a].title)] = items[a];
1779
+ if(option.title){
1780
+ option.data[Type.FIELD_TITLE] = option.title;
1781
+ option.data[Type.FIELD_TITLE_URL] = Str.get_title_url(option.title);
1782
+ }else{
1783
+ option.data[Type.FIELD_TITLE] = Type.get_title(data_type);
1784
+ option.data[Type.FIELD_TITLE_URL] = Str.get_title_url(Type.get_title(data_type));
1907
1785
  }
1908
- return item;
1786
+ let data = Data_Logic.get_new(data_type,id,option.data?option.data:{});
1787
+ return data;
1788
+ };
1789
+ static get_search = (data_type,filter,sort_by,page_current,page_size) => {
1790
+ return {data_type:data_type,filter:filter,sort_by:sort_by,page_current:page_current,page_size:page_size};
1791
+ }
1792
+ static get_search_group = (option) => {
1793
+ option = option ? option : {};
1794
+ let type = option.type ? option.type : Type.TITLE_ITEMS;
1795
+ let field = option.field ? option.field : {};
1796
+ let title = option.title ? option.title : {};
1797
+ let image = option.image ? option.image : {count:0,sort_by:Type.TITLE_SORT_BY_ASC};
1798
+ let page_current = option.page_current ? option.page_current : 0;
1799
+ let page_size = option.page_size ? option.page_size : 0;
1800
+ return {type:type,field:field,title:title,image:image,page_current:page_current,page_size:page_size};
1909
1801
  }
1802
+ static get_search_foreign = (type,foreign_data_type,foreign_field,parent_field,option) => {
1803
+ option = option ? option : {};
1804
+ type = type ? type : Type.TITLE_ITEMS;
1805
+ foreign_data_type = foreign_data_type ? foreign_data_type : Str.get_title_url(Type.get_title(foreign_data_type,{plural:true}));
1806
+ foreign_field = foreign_field ? foreign_field : Type.FIELD_PARENT_ID;
1807
+ parent_field = parent_field ? parent_field : parent_field;
1808
+ let field = option.field ? option.field : {};
1809
+ let title = option.title ? option.title : Str.get_title_url(Type.get_title(foreign_data_type,{plural:true}));
1810
+ let page_current = option.page_current ? option.page_current : 0;
1811
+ let page_size = option.page_size ? option.page_size : 0;
1812
+ return {type:type,foreign_data_type:foreign_data_type,foreign_field:foreign_field,parent_field:parent_field,type:type,field:field,title:title,page_current:page_current,page_size:page_size};
1813
+ }
1814
+ static get_search_join = (type,search,option) => {
1815
+ option = option ? option : {};
1816
+ type = type ? type : Type.TITLE_ITEMS;
1817
+ search = search ? search : Data_Logic.get_search(Type.DATA_BLANK,{},{},1,0);
1818
+ let field = option.field ? option.field : {};
1819
+ let title = option.title ? option.title : Str.get_title_url(Type.get_title(search.data_type,{plural:true}));
1820
+ let page_current = option.page_current ? option.page_current : 1;
1821
+ let page_size = option.page_size ? option.page_size : 0;
1822
+ return {type:type,search:search,field:field,title:title,page_current:page_current,page_size:page_size};
1823
+ }
1824
+ static get_not_found = (data_type,id,option) =>{
1825
+ option=option?option:{};
1826
+ if(!data_type){
1827
+ data_type = Type.DATA_BLANK;
1828
+ }
1829
+ if(!id){
1830
+ id = 0;
1831
+ }
1832
+ if(data_type != Type.DATA_USER){
1833
+ if(!id){
1834
+ id=0;
1835
+ }
1836
+ let item = Item_Logic.get_test("",data_type,id,{get_blank:true})
1837
+ item.id = 0;
1838
+ item.id_key = id;
1839
+ item.title = "Item Not Found";
1840
+ item.title_url = Str.get_title_url(item.title);
1841
+ item.images = [];
1842
+ item.items = [];
1843
+ return item;
1844
+ }else{
1845
+ let user = User_Logic.get_test("",{get_blank:true})
1846
+ user.id = 0;
1847
+ user.id_key = id;
1848
+ user.title = "User Not Found";
1849
+ user.first_name = "User Not Found";
1850
+ user.title_url = Str.get_title_url(user.title);
1851
+ user.images = [];
1852
+ user.items = [];
1853
+ return user;
1854
+ }
1855
+ };
1856
+
1910
1857
  }
1911
1858
  class App_Logic {
1912
1859
  static get_url = (app_id,host,url,param) => {
@@ -1919,13 +1866,13 @@ class App_Logic {
1919
1866
  for(const prop in user) {
1920
1867
  item['user_'+prop] = user[prop];
1921
1868
  }
1922
- return item;
1869
+ return item;
1923
1870
  };
1924
1871
  static bind_item_parent_users = (items)=>{
1925
1872
  for(let item of items) {
1926
1873
  item = App_Logic.bind_item_parent_user_obj(item);
1927
1874
  }
1928
- return items;
1875
+ return items;
1929
1876
  };
1930
1877
  static bind_item_parent_user_obj = (item)=>{
1931
1878
  if(!item.user){
@@ -1940,7 +1887,7 @@ class App_Logic {
1940
1887
  for(const prop in item.user) {
1941
1888
  item['user_'+prop] = item.user[prop];
1942
1889
  }
1943
- return item;
1890
+ return item;
1944
1891
  };
1945
1892
  static url_dashboard_user_home = (app_id,url,param) => {
1946
1893
  let action_url="dashboard/user_home";
@@ -1952,60 +1899,12 @@ class App_Logic {
1952
1899
  };
1953
1900
  static get_new = (title,user_id,type,option) =>{
1954
1901
  option = Field_Logic.get_option(Type.DATA_APP,option?option:{});
1955
- let app = DataItem.get_new(Type.DATA_APP,0);
1902
+ let app = Data_Logic.get_new(Type.DATA_APP,0);
1956
1903
  app.title = title;
1957
1904
  app.user_id = user_id;
1958
1905
  app.type = type;
1959
1906
  return app;
1960
1907
  }
1961
- static get_search = (data_type,filter,sort_by,page_current,page_size) => {
1962
- return {data_type:data_type,filter:filter,sort_by:sort_by,page_current:page_current,page_size:page_size};
1963
- }
1964
- static get_join = (type,search,field,image,title) => {
1965
- type = type ? type : Type.TITLE_ITEMS;
1966
- search = search ? search : App_Logic.get_search(Type.DATA_BLANK,{},{},1,0);
1967
- field = field ? field : {};
1968
- image = image ? image : {};
1969
- title = title ? title : '';
1970
- return {type:type,search:search,field:field,image:image,title:title};
1971
- }
1972
- static get_foreign = (type,foreign_data_type,foreign_field,parent_field,field,image,title) => {
1973
- type = type ? type : Type.TITLE_ITEMS;
1974
- foreign_data_type = foreign_data_type ? foreign_data_type : DataType.BLANK;
1975
- foreign_field = foreign_field ? foreign_field : Type.FIELD_PARENT_ID;
1976
- parent_field = parent_field ? parent_field : parent_field;
1977
- field = field ? field : {};
1978
- image = image ? image : {};
1979
- title = title ? title : '';
1980
- return {type:type,foreign_data_type:foreign_data_type,parent_field:parent_field,field:field,image:image,title:title};
1981
- }
1982
- static get_not_found = (data_type,id,option) =>{
1983
- option=option?option:{};
1984
- if(data_type != Type.DATA_USER){
1985
- if(!id){
1986
- id=0;
1987
- }
1988
- let item = Item_Logic.get_test("",data_type,id,{get_blank:true})
1989
- item.id = 0;
1990
- item.id_key = id;
1991
- item.title = "Item Not Found";
1992
- item.title_url = Str.get_title_url(item.title);
1993
- item.images = [];
1994
- item.items = [];
1995
- return item;
1996
- }else{
1997
- let user = User_Logic.get_test("",{get_blank:true})
1998
- user.id = 0;
1999
- user.id_key = id;
2000
- user.title = "User Not Found";
2001
- user.first_name = "User Not Found";
2002
- user.title_url = Str.get_title_url(user.title);
2003
- user.images = [];
2004
- user.items = [];
2005
- return user;
2006
- }
2007
-
2008
- };
2009
1908
  static get_search_query(search){
2010
1909
  let url = "";
2011
1910
  if(search.data_type){
@@ -2052,7 +1951,7 @@ class App_Logic {
2052
1951
  filter[query['filter_key_'+a]] = query['filter_value_'+a]
2053
1952
  }
2054
1953
  }
2055
- return App_Logic.get_search(query.data_type,filter,sort_by,query.page_current,query.page_size);
1954
+ return Data_Logic.get_search(query.data_type,filter,sort_by,query.page_current,query.page_size);
2056
1955
  }
2057
1956
  static get_data_search_result = (app_id,data_type,item_count,page_count,filter,items,option) =>{
2058
1957
  return{
@@ -2082,12 +1981,12 @@ class File_Logic {
2082
1981
  return host+"/"+size + "_"+file_filename+param;
2083
1982
  }
2084
1983
  static get_new_by_base64 = (item_file) =>{
2085
- let item = DataItem.get_new(Type.DATA_FILE,0,item_file);
2086
- item.extension = !Str.check_is_null(Str.get_file_type_from_base64(item.file_data)) ? Str.get_file_type_from_base64(item.file_data).extension : 'txt';
2087
- item.file_filename = !Str.check_is_null(Str.get_file_type_from_base64(item.file_data)) ? Str.get_guid()+ "." + item.extension : 'not_found.txt';
2088
- item.buffer = !Str.check_is_null(Str.get_file_type_from_base64(item_file.file_data)) ? Buffer.from(item_file.file_data.split(';base64,').pop(), 'base64') : null;
2089
- return item;
2090
- };
1984
+ let item = Data_Logic.get_new(Type.DATA_FILE,0,item_file);
1985
+ item.extension = !Str.check_is_null(Str.get_file_type_from_base64(item.file_data)) ? Str.get_file_type_from_base64(item.file_data).extension : 'txt';
1986
+ item.file_filename = !Str.check_is_null(Str.get_file_type_from_base64(item.file_data)) ? Str.get_guid()+ "." + item.extension : 'not_found.txt';
1987
+ item.buffer = !Str.check_is_null(Str.get_file_type_from_base64(item_file.file_data)) ? Buffer.from(item_file.file_data.split(';base64,').pop(), 'base64') : null;
1988
+ return item;
1989
+ };
2091
1990
  };
2092
1991
  class Image_Logic {
2093
1992
  static url_post = (app_id,url,param) => {
@@ -2106,12 +2005,12 @@ class Image_Logic {
2106
2005
  return host+"/"+size + "_"+image_filename+param;
2107
2006
  }
2108
2007
  static get_new_by_base64 = (item_image) =>{
2109
- let item = DataItem.get_new(Type.DATA_IMAGE,0,item_image);
2110
- item.extension = !Str.check_is_null(Str.get_file_type_from_base64(item.image_data)) ? Str.get_file_type_from_base64(item.image_data).extension : 'jpeg';
2111
- item.image_filename = !Str.check_is_null(Str.get_file_type_from_base64(item.image_data)) ? Str.get_guid()+ "." + item.extension : 'not_found.jpeg';
2112
- item.buffer = !Str.check_is_null(Str.get_file_type_from_base64(item_image.image_data)) ? Buffer.from(item_image.image_data.split(';base64,').pop(), 'base64') : null;
2113
- return item;
2114
- };
2008
+ let item = Data_Logic.get_new(Type.DATA_IMAGE,0,item_image);
2009
+ item.extension = !Str.check_is_null(Str.get_file_type_from_base64(item.image_data)) ? Str.get_file_type_from_base64(item.image_data).extension : 'jpeg';
2010
+ item.image_filename = !Str.check_is_null(Str.get_file_type_from_base64(item.image_data)) ? Str.get_guid()+ "." + item.extension : 'not_found.jpeg';
2011
+ item.buffer = !Str.check_is_null(Str.get_file_type_from_base64(item_image.image_data)) ? Buffer.from(item_image.image_data.split(';base64,').pop(), 'base64') : null;
2012
+ return item;
2013
+ };
2115
2014
  static get_process_items = (upload_dir,image_filename) =>{
2116
2015
  upload_dir = upload_dir ? upload_dir : "";
2117
2016
  image_filename = image_filename ? image_filename : "";
@@ -2246,12 +2145,12 @@ class Url {
2246
2145
  module.exports = {
2247
2146
  App_Logic,
2248
2147
  Admin_Logic,
2148
+ Blank_Logic,
2249
2149
  Blog_Post_Logic,
2250
2150
  Cart_Logic,
2251
2151
  Category_Logic,
2252
2152
  Content_Logic,
2253
- DataItem,
2254
- Demo_Logic,
2153
+ Data_Logic,
2255
2154
  Event_Logic,
2256
2155
  File_Logic,
2257
2156
  Field_Logic,
@@ -2265,7 +2164,6 @@ module.exports = {
2265
2164
  Product_Logic,
2266
2165
  Review_Logic,
2267
2166
  Service_Logic,
2268
- Sub_Item_Logic,
2269
2167
  Stat_Logic,
2270
2168
  Storage,
2271
2169
  Template_Logic,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "biz9-logic",
3
- "version": "10.0.29",
3
+ "version": "10.0.35",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
package/test.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const series = require('async-series');
2
- const {DataItem,Type,App_Logic} = require('./index');
2
+ const {DataItem,Type,App_Logic,Data_Logic} = require('./index');
3
3
  const {Log,Num,Str,Obj} = require('biz9-utility');
4
4
  const {Scriptz}= require('biz9-scriptz');
5
5
 
@@ -32,13 +32,19 @@ describe("connect", () => {
32
32
  function(call) {
33
33
  console.log('CONNECT-BASE-START');
34
34
  // -->
35
- let parent_item = DataItem.get_new(Type.DATA_PRODUCT,0);
35
+ //let parent_item = DataItem.get_new(Type.DATA_PRODUCT,0);
36
36
  // -->
37
- let join = App_Logic.get_join({},'','',{});
37
+ //let join = App_Logic.get_join({},'','',{});
38
38
  // -->
39
- Log.w('99_join',join);
40
- //Log.w('99_result',parent_item);
41
-
39
+ //let data = Data_Logic.get_biz(Type.DATA_BLANK,0);
40
+ let parent = Data_Logic.get_biz(Type.DATA_SERVICE,0,{test:true,generate_title:true});
41
+ let data = Data_Logic.get_biz(Type.DATA_BLANK,0,{test:true,generate_title:true,parent:parent});
42
+ //let data = Data_Logic.get_biz(Type.DATA_BLANK,0,{title:'cool bean',data:{field_1:'field_1',field_2:'field_2'}});
43
+ //let data = Data_Logic.get_biz(Type.DATA_BLANK,0,{title:'cool bean'});
44
+ //let data = Data_Logic.get_biz(Type.DATA_BLANK,0,{data:{field_1:'field_1',field_2:'field_2'}});
45
+ //let data = Data_Logic.get_biz(Type.DATA_BLANK,0,{test:true});
46
+ //Log.w('99_result_parent',parent);
47
+ //Log.w('99_result_data',data);
42
48
 
43
49
  //Log.w('Title',Type.get_title(Type.ORDER_STATUS_NEW));
44
50
  //Log.w('Title 2',Type.get_title(Type.ORDER_STATUS_COMPLETE));