*/}}

elarp_operations.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. /*
  2. * eLaRP: A small ERP utility program
  3. * Copyright (C) 2024 Wu Yiming
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include "elarp.h"
  19. ERPMain* erp;
  20. void* erpget_erp(void* unused1, void* unused2){
  21. return erp;
  22. }
  23. void erpui_CustomerListItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  24. laColumn* c=laFirstColumn(uil);
  25. laUiItem* r=laBeginRow(uil,c,0,0);
  26. laShowItemFull(uil,c,This,"nickname",LA_WIDGET_STRING_PLAIN,0,0,0);
  27. laEndRow(uil,r);
  28. }
  29. void erpui_CustomerItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  30. laColumn* c=laFirstColumn(uil),*cl,*cr; laSplitColumn(uil,c,0.5); cl=laLeftColumn(c,10);cr=laRightColumn(c,0);
  31. laShowItemFull(uil,c,This,"nickname",0,0,0,0);
  32. laShowLabel(uil,c,"Details:",0,0);
  33. laShowLabel(uil,cl,"Name:",0,0); laShowItemFull(uil,cr,This,"name",0,0,0,0);
  34. laShowLabel(uil,cl,"Country:",0,0); laShowItemFull(uil,cr,This,"country",0,0,0,0);
  35. laShowLabel(uil,cl,"State:",0,0); laShowItemFull(uil,cr,This,"state",0,0,0,0);
  36. laShowLabel(uil,cl,"City:",0,0); laShowItemFull(uil,cr,This,"city",0,0,0,0);
  37. laShowLabel(uil,cl,"Address:",0,0); laShowItemFull(uil,cr,This,"address",0,0,0,0);
  38. laShowLabel(uil,cl,"Postal Code:",0,0); laShowItemFull(uil,cr,This,"postal_code",0,0,0,0);
  39. laShowLabel(uil,cl,"Telephone:",0,0); laShowItemFull(uil,cr,This,"tel",0,0,0,0);
  40. laShowLabel(uil,cl,"E-Mail:",0,0); laShowItemFull(uil,cr,This,"email",0,0,0,0);
  41. }
  42. void erpui_CustomersPanel(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  43. laColumn* c=laFirstColumn(uil),*cl,*cr; laSplitColumn(uil,c,0.5); cl=laLeftColumn(c,20);cr=laRightColumn(c,0);
  44. laUiItem* r=laBeginRow(uil,c,0,0);
  45. laShowItem(uil,c,0,"ERP_new_customer");
  46. laEndRow(uil,r);
  47. laUiItem* gr=laMakeEmptyGroup(uil,cl,0,0); laUiList* gu=gr->Page; laColumn* gc=laFirstColumn(gu);
  48. gu->HeightCoeff=-1; gr->Flags|=LA_UI_FLAGS_NO_DECAL;
  49. laUiItem* ui=laShowItemFull(gu,gc,0,"erp.customers",0,0,erpui_CustomerListItem,0);
  50. gr=laMakeEmptyGroup(uil,cr,0,0); gu=gr->Page; gc=laFirstColumn(gu);
  51. gu->HeightCoeff=-1; gr->Flags|=LA_UI_FLAGS_NO_DECAL;
  52. ui=laShowItemFull(gu,gc,0,"erp.current_customer",0,0,erpui_CustomerItem,0);
  53. ui->Flags|=LA_UI_COLLECTION_NO_HIGHLIGHT;
  54. }
  55. void erpui_ProductOptionValueItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  56. laColumn* c=laFirstColumn(uil), *cl,*cr; laSplitColumn(uil,c,0.2); cl=laLeftColumn(c,1);cr=laRightColumn(c,0);
  57. laUiItem* r=laBeginRow(uil,cr,1,1);
  58. laShowItemFull(uil,cr,This,"name",0,0,0,0);
  59. laShowItem(uil,cr,This,"price_offset");
  60. laEndRow(uil,r);
  61. laShowItem(uil,cl,This,"__move");
  62. }
  63. void erpui_ProductOptionItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  64. laColumn* c=laFirstColumn(uil), *cl,*cr; laSplitColumn(uil,c,0.2); cl=laLeftColumn(c,1);cr=laRightColumn(c,0);
  65. laUiItem* r=laBeginRow(uil,cr,0,0);
  66. laUiItem* b=laOnConditionToggle(uil,c,0,0,0,0,0);
  67. laShowItemFull(uil,cr,This,"name",0,0,0,0);
  68. laShowSeparator(uil,cr)->Expand=1;
  69. laShowItem(uil,cr,This,"new_value");
  70. laEndRow(uil,r);
  71. laShowItemFull(uil,cr,This,"values",0,0,erpui_ProductOptionValueItem,0);
  72. laElse(uil,b);
  73. laShowItemFull(uil,cr,This,"name",0,0,0,0);
  74. laEndRow(uil,r);
  75. laEndCondition(uil,b);
  76. laShowItem(uil,cl,This,"__move");
  77. }
  78. void erpui_ProductListItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  79. laColumn* c=laFirstColumn(uil);
  80. laUiItem* r=laBeginRow(uil,c,0,0);
  81. laShowItemFull(uil,c,This,"price",LA_WIDGET_INT_PLAIN,0,0,0)->Flags|=LA_UI_FLAGS_NO_LABEL;
  82. laShowItemFull(uil,c,This,"name",LA_WIDGET_STRING_PLAIN,0,0,0);
  83. laEndRow(uil,r);
  84. }
  85. void erpui_ProductItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  86. laColumn* c=laFirstColumn(uil);
  87. laShowItemFull(uil,c,This,"name",0,0,0,0);
  88. laUiItem* r=laBeginRow(uil,c,0,0);
  89. laShowItemFull(uil,c,This,"price",0,0,0,0);
  90. laEndRow(uil,r);
  91. r=laBeginRow(uil,c,0,0);
  92. laUiItem* b=laOnConditionToggle(uil,c,0,0,0,0,0); strSafeSet(&b->ExtraInstructions,"text=Options"); b->Expand=1;
  93. laShowItem(uil,c,This,"new_option");
  94. laEndRow(uil,r);
  95. laShowItemFull(uil,c,This,"available_options",0,0,erpui_ProductOptionItem,0);
  96. laElse(uil,b);
  97. laEndRow(uil,r);
  98. }
  99. void erpui_ProductsPanel(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  100. laColumn* c=laFirstColumn(uil), *cl,*cr; laSplitColumn(uil,c,0.5); cl=laLeftColumn(c,20);cr=laRightColumn(c,0);
  101. laUiItem* r=laBeginRow(uil,c,0,0);
  102. laShowItem(uil,c,0,"ERP_new_product");
  103. laEndRow(uil,r);
  104. laUiItem* gr=laMakeEmptyGroup(uil,cl,0,0); laUiList* gu=gr->Page; laColumn* gc=laFirstColumn(gu);
  105. gu->HeightCoeff=-1; gr->Flags|=LA_UI_FLAGS_NO_DECAL;
  106. laUiItem* ui=laShowItemFull(gu,gc,0,"erp.products",0,0,erpui_ProductListItem,0);
  107. gr=laMakeEmptyGroup(uil,cr,0,0); gu=gr->Page; gc=laFirstColumn(gu);
  108. gu->HeightCoeff=-1; gr->Flags|=LA_UI_FLAGS_NO_DECAL;
  109. ui=laShowItemFull(gu,gc,0,"erp.current_product",0,0,erpui_ProductItem,0);
  110. ui->Flags|=LA_UI_COLLECTION_NO_HIGHLIGHT;
  111. }
  112. void erpui_ProductEntryOptionItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  113. laColumn* c=laFirstColumn(uil), *cl,*cr; laSplitColumn(uil,c,0.2); cl=laLeftColumn(c,1);cr=laRightColumn(c,0);
  114. laColumn* crl,*crr; laSplitColumn(uil,cr,0.8); crl=laLeftColumn(cr,0);crr=laRightColumn(cr,1);
  115. laColumn* crll,*crlr; laSplitColumn(uil,crl,0.5); crll=laLeftColumn(crl,0);crlr=laRightColumn(crl,0);
  116. laShowItem(uil,cl,This,"__move");
  117. laShowItemFull(uil,crll,This,"option",0,0,0,0);
  118. laShowItemFull(uil,crlr,This,"value",0,0,0,0);
  119. }
  120. void erpui_ProductEntryItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  121. laColumn* c=laFirstColumn(uil), *cl,*cr; laSplitColumn(uil,c,0.2); cl=laLeftColumn(c,1);cr=laRightColumn(c,0);
  122. laColumn* crl,*crr; laSplitColumn(uil,cr,0.2); crl=laLeftColumn(cr,1);crr=laRightColumn(cr,0);
  123. laColumn* crrl,*crrr; laSplitColumn(uil,crr,0.5); crrl=laLeftColumn(crr,0);crrr=laRightColumn(crr,7);
  124. laShowItem(uil,cl,This,"__move");
  125. laUiItem* b=laOnConditionToggle(uil,crl,0,0,0,0,0);
  126. laShowItemFull(uil,crrl,This,"product",0,0,erpui_ProductListItem,0);
  127. laShowItem(uil,crrr,This,"new_option");
  128. laShowItemFull(uil,crr,This,"options",0,0,erpui_ProductEntryOptionItem,0);
  129. laElse(uil,b);
  130. laShowItemFull(uil,crr,This,"product",0,0,erpui_ProductListItem,0);
  131. laEndCondition(uil,b);
  132. }
  133. void erpui_OrderListItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  134. laColumn* c=laFirstColumn(uil);
  135. laShowItemFull(uil,c,This,"__uid",LA_WIDGET_STRING_PLAIN,0,0,0);
  136. }
  137. void erpui_OrderItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  138. laColumn* c=laFirstColumn(uil);
  139. laUiItem* r=laBeginRow(uil,c,0,0);
  140. laShowItemFull(uil,c,This,"state",0,0,0,0);
  141. laShowSeparator(uil,c)->Expand=1;
  142. laShowItemFull(uil,c,This,"paid",0,0,0,0);
  143. laShowSeparator(uil,c);
  144. laShowItemFull(uil,c,This,"discount",0,0,0,0);
  145. laEndRow(uil,r);
  146. laShowItemFull(uil,c,This,"customer",LA_WIDGET_COLLECTION_SELECTOR,0,0,0);
  147. r=laBeginRow(uil,c,0,0);
  148. laUiItem* b=laOnConditionToggle(uil,c,0,0,0,0,0); strSafeSet(&b->ExtraInstructions,"text=Product Entries"); b->Expand=1;
  149. laShowItem(uil,c,This,"new_item");
  150. laEndRow(uil,r);
  151. laShowItemFull(uil,c,This,"product_entries",0,0,erpui_ProductEntryItem,0);
  152. laElse(uil,b);
  153. laEndRow(uil,r);
  154. laEndCondition(uil,b);
  155. laShowItemFull(uil,c,This,"packages",0,0,0,0);
  156. laShowItemFull(uil,c,This,"comments",LA_WIDGET_STRING_MULTI,0,0,0)->Extra->HeightCoeff=2;
  157. laShowSeparator(uil,c);
  158. laShowItemFull(uil,c,This,"admin_comments",LA_WIDGET_STRING_MULTI,0,0,0)->Extra->HeightCoeff=2;
  159. }
  160. void erpui_OrdersPanel(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  161. laColumn* c=laFirstColumn(uil), *cl,*cr; laSplitColumn(uil,c,0.5); cl=laLeftColumn(c,20);cr=laRightColumn(c,0);
  162. laUiItem* r=laBeginRow(uil,c,0,0);
  163. laShowItem(uil,c,0,"ERP_new_order");
  164. laEndRow(uil,r);
  165. laUiItem* gr=laMakeEmptyGroup(uil,cl,0,0); laUiList* gu=gr->Page; laColumn* gc=laFirstColumn(gu);
  166. gu->HeightCoeff=-1; gr->Flags|=LA_UI_FLAGS_NO_DECAL;
  167. laUiItem* ui=laShowItemFull(gu,gc,0,"erp.orders",0,0,erpui_OrderListItem,0);
  168. gr=laMakeEmptyGroup(uil,cr,0,0); gu=gr->Page; gc=laFirstColumn(gu);
  169. gu->HeightCoeff=-1; gr->Flags|=LA_UI_FLAGS_NO_DECAL;
  170. ui=laShowItemFull(gu,gc,0,"erp.current_order",0,0,erpui_OrderItem,0);
  171. ui->Flags|=LA_UI_COLLECTION_NO_HIGHLIGHT;
  172. }
  173. ERPOrder* erpNewOrder(){
  174. ERPOrder* o=memAcquireHyper(sizeof(ERPOrder)); lstPushItem(&erp->Orders,o);
  175. laNotifyUsers("erp.orders"); laNotifyUsers("erp.current_order"); memAssignRef(erp,&erp->CurrentOrder,o);
  176. return o;
  177. }
  178. ERPCustomer* erpNewCustomer(){
  179. ERPCustomer* c=memAcquireHyper(sizeof(ERPCustomer)); lstPushItem(&erp->Customers,c);
  180. strSafeSet(&c->Nickname,"New Customer");
  181. laNotifyUsers("erp.customers"); laNotifyUsers("erp.current_customer"); memAssignRef(erp,&erp->CurrentCustomer,c);
  182. return c;
  183. }
  184. ERPProduct* erpNewProduct(){
  185. ERPProduct* p=memAcquireHyper(sizeof(ERPProduct)); lstPushItem(&erp->Products,p);
  186. strSafeSet(&p->Name,"New Product");
  187. laNotifyUsers("erp.products"); laNotifyUsers("erp.current_product"); memAssignRef(erp,&erp->CurrentProduct,p);
  188. return p;
  189. }
  190. ERPProductOption* erpNewProductOption(ERPProduct* p){ if(!p) return 0;
  191. ERPProductOption* po=memAcquire(sizeof(ERPProductOption)); lstAppendItem(&p->AvailableOptions,po);
  192. strSafeSet(&po->Name,"New Option"); laNotifyInstanceUsers(p); memAssignRef(po,&po->Parent,p);
  193. return po;
  194. }
  195. ERPProductOptionValue* erpNewProductOptionValue(ERPProductOption* po){ if(!po) return 0;
  196. ERPProductOptionValue* pov=memAcquire(sizeof(ERPProductOptionValue)); lstAppendItem(&po->Values,pov);
  197. strSafeSet(&pov->Name,"New Value"); laNotifyInstanceUsers(po); memAssignRef(pov,&pov->Parent,po);
  198. return pov;
  199. }
  200. ERPProductEntry* erpNewProductEntry(ERPOrder* o){ if(!o) return 0;
  201. ERPProductEntry* pe=memAcquire(sizeof(ERPProductEntry)); lstAppendItem(&o->ProductEntries,pe);
  202. laNotifyInstanceUsers(o); memAssignRef(pe,&pe->Parent,o);
  203. return pe;
  204. }
  205. ERPProductEntry* erpNewProductEntryOption(ERPProductEntry* pe){ if(!pe) return 0;
  206. ERPProductEntryOption* peo=memAcquire(sizeof(ERPProductEntryOption)); lstAppendItem(&pe->Options,peo);
  207. laNotifyInstanceUsers(pe); memAssignRef(peo,&peo->Parent,pe);
  208. return peo;
  209. }
  210. int erpinv_NewOrder(laOperator* a, laEvent* e){ erpNewOrder();
  211. laRecordDifferences(0,"erp.orders");laRecordDifferences(0,"erp.current_order");laPushDifferences("New Order",0);
  212. return LA_FINISHED;
  213. }
  214. int erpinv_NewCustomer(laOperator* a, laEvent* e){ erpNewCustomer();
  215. laRecordDifferences(0,"erp.customer");laRecordDifferences(0,"erp.customer");laPushDifferences("New Customer",0);
  216. return LA_FINISHED;
  217. }
  218. int erpinv_NewProduct(laOperator* a, laEvent* e){ erpNewProduct();
  219. laRecordDifferences(0,"erp.product");laRecordDifferences(0,"erp.product");laPushDifferences("New Product",0);
  220. return LA_FINISHED;
  221. }
  222. int erpinv_NewProductOption(laOperator* a, laEvent* e){
  223. ERPProduct* p=a->This?a->This->EndInstance:0; if(!p){ return LA_FINISHED; }
  224. ERPProductOption* po=erpNewProductOption(p); if(po){ laRecordInstanceDifferences(p,"erp_product");laPushDifferences("New Product Option",0); }
  225. return LA_FINISHED;
  226. }
  227. int erpinv_NewProductOptionValue(laOperator* a, laEvent* e){
  228. ERPProductOption* po=a->This?a->This->EndInstance:0; if(!po){ return LA_FINISHED; }
  229. ERPProductOptionValue* pov=erpNewProductOptionValue(po); if(pov){ laRecordInstanceDifferences(po,"erp_product_option"); laPushDifferences("New Product Value",0); }
  230. return LA_FINISHED;
  231. }
  232. int erpinv_NewProductEntry(laOperator* a, laEvent* e){
  233. ERPOrder* o=a->This?a->This->EndInstance:0; if(!o){ return LA_FINISHED; }
  234. ERPProductEntry* pe=erpNewProductEntry(o); if(pe){ laRecordInstanceDifferences(o,"erp_order");laPushDifferences("New Product Entry",0); }
  235. return LA_FINISHED;
  236. }
  237. int erpinv_NewProductEntryOption(laOperator* a, laEvent* e){
  238. ERPProductEntry* pe=a->This?a->This->EndInstance:0; if(!pe){ return LA_FINISHED; }
  239. ERPProductEntry* peo=erpNewProductEntryOption(pe); if(peo){ laRecordInstanceDifferences(pe,"erp_product_entry");laPushDifferences("New Product Entry Option",0); }
  240. return LA_FINISHED;
  241. }
  242. void erpset_ProductOptionMove(ERPProductOption* po, int move){
  243. if(move<0 && po->Item.pPrev){ lstMoveUp(&po->Parent->AvailableOptions, po); laNotifyInstanceUsers(po->Parent); }
  244. elif(move>0 && po->Item.pNext){ lstMoveDown(&po->Parent->AvailableOptions, po); laNotifyInstanceUsers(po->Parent); }
  245. }
  246. void erpset_ProductOptionValueMove(ERPProductOptionValue* pov, int move){
  247. if(move<0 && pov->Item.pPrev){ lstMoveUp(&pov->Parent->Values, pov); laNotifyInstanceUsers(pov->Parent); }
  248. elif(move>0 && pov->Item.pNext){ lstMoveDown(&pov->Parent->Values, pov); laNotifyInstanceUsers(pov->Parent); }
  249. }
  250. void erpset_ProductEntryMove(ERPProductEntry* pe, int move){
  251. if(move<0 && pe->Item.pPrev){ lstMoveUp(&pe->Parent->ProductEntries, pe); laNotifyInstanceUsers(pe->Parent); }
  252. elif(move>0 && pe->Item.pNext){ lstMoveDown(&pe->Parent->ProductEntries, pe); laNotifyInstanceUsers(pe->Parent); }
  253. }
  254. void erpset_ProductEntryOptionMove(ERPProductEntryOption* peo, int move){
  255. if(move<0 && peo->Item.pPrev){ lstMoveUp(&peo->Parent->Options, peo); laNotifyInstanceUsers(peo->Parent); }
  256. elif(move>0 && peo->Item.pNext){ lstMoveDown(&peo->Parent->Options, peo); laNotifyInstanceUsers(peo->Parent); }
  257. }
  258. void* erpget_FirstCustomer(void* unused1,void* unused2){ return erp->Customers.pFirst; }
  259. void* erpget_FirstProduct(void* unused1,void* unused2){ return erp->Products.pFirst; }
  260. void* erpget_FirstProductEntryOption(ERPProductEntryOption* peo,void* unused2){ return peo->Parent&&peo->Parent->Product?peo->Parent->Product->AvailableOptions.pFirst:0; }
  261. void* erpget_FirstProductEntryOptionValue(ERPProductEntryOption* peo,void* unused2){ return peo->Option?peo->Option->Values.pFirst:0; }
  262. void erpRegisterEverything(){
  263. laPropContainer* pc; laKeyMapper* km; laProp* p; laSubProp* sp; laOperatorType* at;
  264. laCreateOperatorType("ERP_new_order","New Order","New order",0,0,0,erpinv_NewOrder,0,'+',0);
  265. laCreateOperatorType("ERP_new_customer","New Customer","New customer",0,0,0,erpinv_NewCustomer,0,'+',0);
  266. laCreateOperatorType("ERP_new_product","New Product","New product",0,0,0,erpinv_NewProduct,0,'+',0);
  267. laCreateOperatorType("ERP_new_product_option","New Option","New option",0,0,0,erpinv_NewProductOption,0,'+',0);
  268. laCreateOperatorType("ERP_new_product_option_value","New Value","New value",0,0,0,erpinv_NewProductOptionValue,0,'+',0);
  269. laCreateOperatorType("ERP_new_product_entry","New Product Entry","New product entry",0,0,0,erpinv_NewProductEntry,0,'+',0);
  270. laCreateOperatorType("ERP_new_product_entry_option","New Option","New option",0,0,0,erpinv_NewProductEntryOption,0,'+',0);
  271. pc=laDefineRoot();
  272. laAddSubGroup(pc,"erp","ERP","ERP main","erp_main",0,0,0,-1,erpget_erp,0,0,0,0,0,0,LA_UDF_SINGLE);
  273. pc=laAddPropertyContainer("erp_main","ERP MAIN","ERP root structure",0,0,sizeof(ERPMain),0,0,1);
  274. laAddSubGroup(pc,"current_order","Current Order","Current Order","erp_order",0,0,0,offsetof(ERPMain,CurrentOrder),0,0,0,0,0,0,0,LA_UDF_REFER);
  275. laAddSubGroup(pc,"current_product","Current Product","Current Product","erp_product",0,0,0,offsetof(ERPMain,CurrentProduct),0,0,0,0,0,0,0,LA_UDF_REFER);
  276. laAddSubGroup(pc,"current_customer","Current Customer","Current Customer","erp_customer",0,0,0,offsetof(ERPMain,CurrentCustomer),0,0,0,0,0,0,0,LA_UDF_REFER);
  277. laAddSubGroup(pc,"orders","Orders","All Orders","erp_order",0,0,0,offsetof(ERPMain,CurrentOrder),0,0,0,0,0,0,offsetof(ERPMain,Orders),0);
  278. laAddSubGroup(pc,"products","Products","All Products","erp_product",0,0,0,offsetof(ERPMain,CurrentProduct),0,0,0,0,0,0,offsetof(ERPMain,Products),0);
  279. laAddSubGroup(pc,"customers","Customers","All Customers","erp_customer",0,0,0,offsetof(ERPMain,CurrentCustomer),0,0,0,0,0,0,offsetof(ERPMain,Customers),0);
  280. pc=laAddPropertyContainer("erp_customer","ERP Customer","ERP customer",0,0,sizeof(ERPCustomer),0,0,2);
  281. laAddStringProperty(pc,"nickname","Nickname","Nickname",0,0,0,0,1,offsetof(ERPCustomer,Nickname),0,0,0,0,LA_AS_IDENTIFIER);
  282. laAddStringProperty(pc,"name","Name","Name",0,0,0,0,1,offsetof(ERPCustomer,Name),0,0,0,0,0);
  283. laAddStringProperty(pc,"country","Country","Country",0,0,0,0,1,offsetof(ERPCustomer,Country),0,0,0,0,0);
  284. laAddStringProperty(pc,"state","State","State",0,0,0,0,1,offsetof(ERPCustomer,State),0,0,0,0,0);
  285. laAddStringProperty(pc,"city","City","City",0,0,0,0,1,offsetof(ERPCustomer,City),0,0,0,0,0);
  286. laAddStringProperty(pc,"address","Address","Address",0,0,0,0,1,offsetof(ERPCustomer,Address),0,0,0,0,0);
  287. laAddStringProperty(pc,"postal_code","PostalCode","PostalCode",0,0,0,0,1,offsetof(ERPCustomer,PostalCode),0,0,0,0,0);
  288. laAddStringProperty(pc,"tel","Tel","Tel",0,0,0,0,1,offsetof(ERPCustomer,Tel),0,0,0,0,0);
  289. laAddStringProperty(pc,"email","EMail","EMail",0,0,0,0,1,offsetof(ERPCustomer,EMail),0,0,0,0,0);
  290. pc=laAddPropertyContainer("erp_order","ERP Order","ERP order",0,0,sizeof(ERPOrder),0,0,2);
  291. laAddSubGroup(pc,"customer","Customer","Customer","erp_customer",0,LA_WIDGET_ENUM_SELECTOR,erpui_CustomerListItem,offsetof(ERPOrder,Customer),erpget_FirstCustomer,0,laget_ListNext,0,0,0,0,LA_UDF_REFER);
  292. laAddSubGroup(pc,"product_entries","Product Entries","Product entries","erp_product_entry",0,0,0,-1,0,0,0,0,0,0,offsetof(ERPOrder,ProductEntries),0);
  293. laAddSubGroup(pc,"packages","Packages","Packages","erp_package",0,0,0,-1,0,0,0,0,0,0,offsetof(ERPOrder,Packages),0);
  294. laAddStringProperty(pc,"comments","Comments","Comments about the order",0,0,0,0,1,offsetof(ERPOrder,Comments),0,0,0,0,0);
  295. laAddStringProperty(pc,"admin_comments","Admin comments","Admin comments about the order",0,0,0,0,1,offsetof(ERPOrder,AdminComments),0,0,0,0,0);
  296. p=laAddEnumProperty(pc,"state","State","State of the order",0,0,0,0,0,offsetof(ERPOrder,State),0,0,0,0,0,0,0,0,0,0);
  297. laAddEnumItemAs(p,"PENDING_PACKAGING","Pending Packaging","Pending packaging",ERP_ORDER_STATE_PENDING_PACKAGING,0);
  298. laAddEnumItemAs(p,"PENDING_LABEL","Pending Label","Pending label",ERP_ORDER_STATE_PENDING_LABEL,0);
  299. laAddEnumItemAs(p,"PENDING_SHIPPING","Pending Shipping","Pending shipping",ERP_ORDER_STATE_PENDING_SHIPPING,0);
  300. laAddEnumItemAs(p,"SHIPPED","Shipped","Shipped",ERP_ORDER_STATE_SHIPPED,0);
  301. laAddEnumItemAs(p,"ARRIVED","Arrived","Arrived",ERP_ORDER_STATE_ARRIVED,0);
  302. laAddEnumItemAs(p,"IN_PERSON","In Person","Pending packaging",ERP_ORDER_STATE_IN_PERSON,0);
  303. laAddEnumItemAs(p,"NEEDS_INFO","Needs Information","Pending packaging",ERP_ORDER_STATE_NEED_INFO,0);
  304. laAddIntProperty(pc,"paid","Paid","Paid",0,0,0,0,0,0,0,0,offsetof(ERPOrder,Paid),0,0,0,0,0,0,0,0,0,0,0);
  305. laAddIntProperty(pc,"discount","Discount","Discount",0,0,0,0,0,0,0,0,offsetof(ERPOrder,Discount),0,0,0,0,0,0,0,0,0,0,0);
  306. laAddOperatorProperty(pc,"new_item","New Item","New product entry","ERP_new_product_entry",0,0);
  307. pc=laAddPropertyContainer("erp_package","ERP Package","ERP package",0,0,sizeof(ERPPackage),0,0,1);
  308. laAddStringProperty(pc,"tracking","Tracking","Tracking number",0,0,0,0,1,offsetof(ERPPackage,Tracking),0,0,0,0,LA_AS_IDENTIFIER);
  309. laAddSubGroup(pc,"included_products","Included Products","Included products","erp_included_product",0,0,0,-1,0,0,0,0,0,0,offsetof(ERPPackage,IncludedProducts),0);
  310. pc=laAddPropertyContainer("erp_included_product","ERP Product Entry Option","ERP Product Entry Option",0,0,sizeof(laListItemPointer),0,0,1);
  311. laAddSubGroup(pc,"product","Product","Prduct","erp_product_entry",0,0,0,offsetof(laListItemPointer,p),0,0,0,0,0,0,0,LA_UDF_REFER);
  312. pc=laAddPropertyContainer("erp_product_entry","ERP Product Entry","ERP Product Entry",0,0,sizeof(ERPProductEntry),0,0,1);
  313. laAddIntProperty(pc,"__move","Move","Move slider",LA_WIDGET_HEIGHT_ADJUSTER,0,0,0,0,0,0,0,0,0,erpset_ProductEntryMove,0,0,0,0,0,0,0,0,LA_UDF_IGNORE);
  314. laAddSubGroup(pc,"parent","Parent","Parent order","erp_order",0,0,0,offsetof(ERPProductEntry,Parent),0,0,0,0,0,0,0,LA_UDF_REFER|LA_READ_ONLY);
  315. laAddSubGroup(pc,"product","Product","Product","erp_product",0,LA_WIDGET_COLLECTION_SELECTOR,erpui_ProductListItem,offsetof(ERPProductEntry,Product),erpget_FirstProduct,0,laget_ListNext,0,0,0,0,LA_UDF_REFER);
  316. laAddSubGroup(pc,"options","Options","Product Options","erp_product_entry_option",0,0,0,-1,0,0,0,0,0,0,offsetof(ERPProductEntry,Options),0);
  317. laAddIntProperty(pc,"amount","Amount","Amount",0,0,0,0,0,0,0,0,offsetof(ERPProductEntry,Amount),0,0,0,0,0,0,0,0,0,0,0);
  318. laAddOperatorProperty(pc,"new_option","New Option","New product option","ERP_new_product_entry_option",0,0);
  319. pc=laAddPropertyContainer("erp_product_entry_option","ERP Product Entry Option","ERP Product Entry Option",0,0,sizeof(ERPProductEntryOption),0,0,1);
  320. laAddIntProperty(pc,"__move","Move","Move slider",LA_WIDGET_HEIGHT_ADJUSTER,0,0,0,0,0,0,0,0,0,erpset_ProductEntryOptionMove,0,0,0,0,0,0,0,0,LA_UDF_IGNORE);
  321. laAddSubGroup(pc,"parent","Parent","Parent entry","erp_product_entry",0,0,0,offsetof(ERPProductEntryOption,Parent),0,0,0,0,0,0,0,LA_UDF_REFER|LA_READ_ONLY);
  322. laAddSubGroup(pc,"option","Option","Option","erp_product_option",0,LA_WIDGET_COLLECTION_SELECTOR,laui_IdentifierOnly,offsetof(ERPProductEntryOption,Option),erpget_FirstProductEntryOption,0,laget_ListNext,0,0,0,0,LA_UDF_REFER);
  323. laAddSubGroup(pc,"value","Value","Value","erp_product_option_value",0,LA_WIDGET_COLLECTION_SELECTOR,laui_IdentifierOnly,offsetof(ERPProductEntryOption,Value),erpget_FirstProductEntryOptionValue,0,laget_ListNext,0,0,0,0,LA_UDF_REFER);
  324. pc=laAddPropertyContainer("erp_product","ERP Product","ERP product",0,0,sizeof(ERPOrder),0,0,2);
  325. laAddStringProperty(pc,"name","Name","Name",0,0,0,0,1,offsetof(ERPProduct,Name),0,0,0,0,LA_AS_IDENTIFIER);
  326. laAddSubGroup(pc,"available_options","Available Options","Available options","erp_product_option",0,0,0,-1,0,0,0,0,0,0,offsetof(ERPProduct,AvailableOptions),0);
  327. laAddIntProperty(pc,"price","Price","Price",0,0,0,0,0,0,0,0,offsetof(ERPProduct,Price),0,0,0,0,0,0,0,0,0,0,0);
  328. laAddOperatorProperty(pc,"new_option","New Option","New option for the product","ERP_new_product_option",0,0);
  329. pc=laAddPropertyContainer("erp_product_option","ERP Product Option","ERP Product Option",0,0,sizeof(ERPProductOption),0,0,1);
  330. laAddSubGroup(pc,"parent","Parent","Parent product","erp_product",0,0,0,offsetof(ERPProductOption,Parent),0,0,0,0,0,0,0,LA_UDF_REFER|LA_READ_ONLY);
  331. laAddStringProperty(pc,"name","Name","Name",0,0,0,0,1,offsetof(ERPProductOption,Name),0,0,0,0,LA_AS_IDENTIFIER);
  332. laAddSubGroup(pc,"values","Values","Values","erp_product_option_value",0,0,0,-1,0,0,0,0,0,0,offsetof(ERPProductOption,Values),0);
  333. laAddIntProperty(pc,"__move","Move","Move slider",LA_WIDGET_HEIGHT_ADJUSTER,0,0,0,0,0,0,0,0,0,erpset_ProductOptionMove,0,0,0,0,0,0,0,0,LA_UDF_IGNORE);
  334. laAddOperatorProperty(pc,"new_value","New Value","New value for the option","ERP_new_product_option_value",0,0);
  335. pc=laAddPropertyContainer("erp_product_option_value","ERP Product Option","ERP Product Option Value",0,0,sizeof(ERPProductOptionValue),0,0,1);
  336. laAddSubGroup(pc,"parent","Parent","Parent product option","erp_product_option",0,0,0,offsetof(ERPProductOptionValue,Parent),0,0,0,0,0,0,0,LA_UDF_REFER|LA_READ_ONLY);
  337. laAddStringProperty(pc,"name","Name","Name",0,0,0,0,1,offsetof(ERPProductOptionValue,Name),0,0,0,0,LA_AS_IDENTIFIER);
  338. laAddIntProperty(pc,"__move","Move","Move slider",LA_WIDGET_HEIGHT_ADJUSTER,0,0,0,0,0,0,0,0,0,erpset_ProductOptionValueMove,0,0,0,0,0,0,0,0,LA_UDF_IGNORE);
  339. laAddIntProperty(pc,"price_offset","Price Offset","Price offset",0,0,0,0,0,0,0,0,offsetof(ERPProductOptionValue,PriceOffset),0,0,0,0,0,0,0,0,0,0,0);
  340. laSaveProp("erp.products");
  341. laSaveProp("erp.customers");
  342. laSaveProp("erp.orders");
  343. laRegisterUiTemplate("erp_panel_orders","Orders",erpui_OrdersPanel,0,0,0,0,20,20);
  344. laRegisterUiTemplate("erp_panel_products","Products",erpui_ProductsPanel,0,0,0,0,20,20);
  345. laRegisterUiTemplate("erp_panel_customers","Customers",erpui_CustomersPanel,0,0,0,0,20,20);
  346. }
  347. void erpInit(){
  348. erp=memAcquire(sizeof(ERPMain));
  349. laAddRootDBInst("erp");
  350. }