*/}}

elarp_operations.c 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904
  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_ProductOptionValueItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  24. laColumn* c=laFirstColumn(uil), *cl,*cr; laSplitColumn(uil,c,0.2); cl=laLeftColumn(c,1);cr=laRightColumn(c,0);
  25. laUiItem* r=laBeginRow(uil,cr,0,0);
  26. laShowItemFull(uil,c,This,"remove",0,0,0,0)->Flags|=LA_UI_FLAGS_ICON;
  27. laShowItemFull(uil,cr,This,"name",0,0,0,0)->Expand=1;
  28. laShowItem(uil,cr,This,"price_offset")->Expand=1;
  29. laEndRow(uil,r);
  30. laShowItem(uil,cl,This,"__move");
  31. }
  32. void erpui_ProductOptionItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  33. laColumn* c=laFirstColumn(uil), *cl,*cr; laSplitColumn(uil,c,0.2); cl=laLeftColumn(c,1);cr=laRightColumn(c,0);
  34. laUiItem* r=laBeginRow(uil,cr,0,0);
  35. laShowItemFull(uil,c,This,"remove",0,0,0,0)->Flags|=LA_UI_FLAGS_ICON;
  36. laShowItemFull(uil,cr,This,"name",0,0,0,0)->Expand=1;
  37. laShowItem(uil,cr,This,"new_value");
  38. laEndRow(uil,r);
  39. laShowItemFull(uil,cr,This,"values",0,0,erpui_ProductOptionValueItem,0);
  40. laShowItem(uil,cl,This,"__move");
  41. }
  42. void erpui_ProductListItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  43. laColumn* c=laFirstColumn(uil), *cl,*cr; laSplitColumn(uil,c,0.4); cl=laLeftColumn(c,2);cr=laRightColumn(c,0);
  44. laShowItemFull(uil,cl,This,"price",LA_WIDGET_INT_PLAIN,0,0,0)->Flags|=LA_UI_FLAGS_NO_LABEL;
  45. laShowItemFull(uil,cr,This,"name",LA_WIDGET_STRING_PLAIN,0,0,0);
  46. }
  47. void erpui_ProductItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  48. laColumn* c=laFirstColumn(uil);
  49. laShowItemFull(uil,c,This,"name",0,0,0,0);
  50. laUiItem* r=laBeginRow(uil,c,1,0);
  51. laShowItemFull(uil,c,This,"price",0,0,0,0);
  52. laShowItemFull(uil,c,This,"discounted_price",0,0,0,0);
  53. laEndRow(uil,r);
  54. laShowItemFull(uil,c,This,"hs_code",0,0,0,0);
  55. r=laBeginRow(uil,c,0,0);
  56. laShowLabel(uil,c,"Options:",0,0);
  57. laShowItem(uil,c,This,"new_option");
  58. laEndRow(uil,r);
  59. laShowItemFull(uil,c,This,"available_options",0,0,erpui_ProductOptionItem,0)->Flags|=LA_UI_FLAGS_NO_DECAL;
  60. laShowSeparator(uil,c);
  61. r=laBeginRow(uil,c,0,0);
  62. laShowSeparator(uil,c)->Expand=1;
  63. laShowItemFull(uil,c,This,"remove",0,0,0,0);
  64. laEndRow(uil,r);
  65. }
  66. void erpui_ProductsPanel(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  67. laColumn* c=laFirstColumn(uil), *cl,*cr; laSplitColumn(uil,c,0.5); cl=laLeftColumn(c,0);cr=laRightColumn(c,0);
  68. laUiItem* r=laBeginRow(uil,c,0,0);
  69. laShowItem(uil,c,0,"ERP_new_product");
  70. laEndRow(uil,r);
  71. laShowColumnAdjuster(uil,c);
  72. laUiItem* gr=laMakeEmptyGroup(uil,cl,0,0); laUiList* gu=gr->Page; laColumn* gc=laFirstColumn(gu);
  73. gu->HeightCoeff=-1; gr->Flags|=LA_UI_FLAGS_NO_DECAL;
  74. laUiItem* ui=laShowItemFull(gu,gc,0,"erp.products",0,0,erpui_ProductListItem,0);
  75. gr=laMakeEmptyGroup(uil,cr,0,0); gu=gr->Page; gc=laFirstColumn(gu);
  76. gu->HeightCoeff=-1; gr->Flags|=LA_UI_FLAGS_NO_DECAL;
  77. ui=laShowItemFull(gu,gc,0,"erp.current_product",0,0,erpui_ProductItem,0);
  78. ui->Flags|=LA_UI_COLLECTION_NO_HIGHLIGHT;
  79. }
  80. void erpui_ProductEntryOptionItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  81. laColumn* c=laFirstColumn(uil), *cl,*cr; laSplitColumn(uil,c,0.2); cl=laLeftColumn(c,1);cr=laRightColumn(c,0);
  82. laColumn* crl,*crr; laSplitColumn(uil,cr,0.8); crl=laLeftColumn(cr,1);crr=laRightColumn(cr,0);
  83. laColumn* crrl,*crrr; laSplitColumn(uil,crr,0.5); crrl=laLeftColumn(crr,0);crrr=laRightColumn(crr,0);
  84. laShowItem(uil,cl,This,"__move");
  85. laShowItemFull(uil,crl,This,"remove",0,0,0,0)->Flags|=LA_UI_FLAGS_ICON;
  86. laShowItemFull(uil,crrl,This,"option",0,0,0,0);
  87. laShowItemFull(uil,crrr,This,"value",0,0,0,0);
  88. }
  89. void erpui_ProductEntryItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  90. laColumn* c=laFirstColumn(uil), *cl,*cr; laSplitColumn(uil,c,0.2); cl=laLeftColumn(c,1);cr=laRightColumn(c,0);
  91. laColumn* crl,*crr; laSplitColumn(uil,cr,0.2); crl=laLeftColumn(cr,4);crr=laRightColumn(cr,0);
  92. laColumn* crrl,*crrr; laSplitColumn(uil,crr,0.5); crrl=laLeftColumn(crr,0);crrr=laRightColumn(crr,0);
  93. laShowItem(uil,cl,This,"__move");
  94. laUiItem* b=laBeginRow(uil,crl,0,0);
  95. laShowItem(uil,crl,This,"remove")->Flags|=LA_UI_FLAGS_ICON;
  96. laUiItem* ui=laShowItem(uil,crl,This,"entry_price");ui->Flags|=LA_UI_FLAGS_NO_LABEL; ui->Expand=1;
  97. laEndRow(uil,b);
  98. laShowItemFull(uil,crrl,This,"product",0,0,erpui_ProductListItem,0);
  99. b=laBeginRow(uil,crrr,0,0);
  100. laUiItem* am=laShowItem(uil,crrr,This,"amount"); am->Expand=1; am->Flags|=LA_UI_FLAGS_NO_LABEL;
  101. laShowItem(uil,crrr,This,"new_option");
  102. laEndRow(uil,b);
  103. laShowItemFull(uil,crr,This,"options",0,0,erpui_ProductEntryOptionItem,0);
  104. }
  105. void erpui_ProductEntryListItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  106. laColumn* c=laFirstColumn(uil), *cl,*cr; laSplitColumn(uil,c,0.4); cl=laLeftColumn(c,2);cr=laRightColumn(c,0);
  107. laUiItem* b=laOnConditionThat(uil,c,laPropExpression(This,"product"));
  108. laShowItemFull(uil,cl,This,"entry_price",LA_WIDGET_INT_PLAIN,0,0,0)->Flags|=LA_UI_FLAGS_NO_LABEL;
  109. laShowItemFull(uil,cr,This,"product.name",LA_WIDGET_STRING_PLAIN,0,0,0);
  110. laElse(uil,b);
  111. laShowLabel(uil,c,"<Empty Product>",0,0);
  112. laEndCondition(uil,b);
  113. }
  114. void erpui_PackageProductItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  115. laColumn* c=laFirstColumn(uil), *cl,*cr; laSplitColumn(uil,c,0.2); cl=laLeftColumn(c,1);cr=laRightColumn(c,0);
  116. laColumn* crl,*crr; laSplitColumn(uil,cr,0.2); crl=laLeftColumn(cr,1);crr=laRightColumn(cr,0);
  117. laShowItemFull(uil,cl,This,"__move",0,0,0,0);
  118. laShowItemFull(uil,crl,This,"remove",0,0,0,0)->Flags|=LA_UI_FLAGS_ICON;
  119. laShowItemFull(uil,crr,This,"product",0,0,0,0);
  120. }
  121. void erpui_PackageItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  122. laColumn* c=laFirstColumn(uil), *cl,*cr; laSplitColumn(uil,c,0.2); cl=laLeftColumn(c,1);cr=laRightColumn(c,0);
  123. laColumn* crl,*crr; laSplitColumn(uil,cr,0.2); crl=laLeftColumn(cr,1);crr=laRightColumn(cr,0);
  124. laColumn* crrl,*crrr; laSplitColumn(uil,crr,0.5); crrl=laLeftColumn(crr,0);crrr=laRightColumn(crr,1);
  125. laShowItem(uil,cl,This,"__move");
  126. laShowItem(uil,crl,This,"remove")->Flags|=LA_UI_FLAGS_ICON;
  127. laUiItem* r=laBeginRow(uil,crr,0,0);
  128. laShowItemFull(uil,crr,This,"tracking",0,0,0,0)->Expand=1;
  129. laShowItem(uil,crrr,This,"new_entry");
  130. laEndRow(uil,r);
  131. laShowItemFull(uil,crr,This,"included_products",0,0,erpui_PackageProductItem,0);
  132. }
  133. void erpui_MessageEntryItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  134. laColumn* c=laFirstColumn(uil), *cl,*cr; laSplitColumn(uil,c,0.2); cl=laLeftColumn(c,1);cr=laRightColumn(c,0);
  135. laColumn* crl,*crr; laSplitColumn(uil,cr,0.2); crl=laLeftColumn(cr,0);crr=laRightColumn(cr,1);
  136. laShowItem(uil,cl,This,"__move");
  137. laShowItem(uil,crl,This,"message");
  138. laShowItem(uil,crr,This,"remove")->Flags|=LA_UI_FLAGS_ICON;
  139. }
  140. void erpui_OrderListItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  141. laColumn* c=laFirstColumn(uil), *cl,*cr; laSplitColumn(uil,c,0.4); cl=laLeftColumn(c,2);cr=laRightColumn(c,0);
  142. laShowItemFull(uil,cl,This,"order_price",LA_WIDGET_INT_PLAIN,0,0,0)->Flags|=LA_UI_FLAGS_NO_LABEL;
  143. laShowItemFull(uil,cr,This,"__uid",LA_WIDGET_STRING_PLAIN,0,0,0);
  144. }
  145. void erpui_OrderItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  146. laColumn* c=laFirstColumn(uil);
  147. laUiItem* r=laBeginRow(uil,c,0,0);
  148. laShowItemFull(uil,c,This,"state",0,0,0,0);
  149. laShowSeparator(uil,c)->Expand=1;
  150. laShowItemFull(uil,c,This,"paid",0,0,0,0);
  151. laShowSeparator(uil,c);
  152. laShowItemFull(uil,c,This,"order_discount",0,0,0,0);
  153. laEndRow(uil,r);
  154. laShowItemFull(uil,c,This,"customer",LA_WIDGET_COLLECTION_SELECTOR,0,0,0);
  155. r=laBeginRow(uil,c,0,0);
  156. laShowItem(uil,c,This,"new_item");
  157. laEndRow(uil,r);
  158. laShowItemFull(uil,c,This,"product_entries",0,0,erpui_ProductEntryItem,0)->Flags|=LA_UI_FLAGS_NO_DECAL;
  159. laShowItemFull(uil,c,This,"order_price",LA_WIDGET_INT_PLAIN,0,0,0)->Flags|=LA_UI_FLAGS_NO_LABEL|LA_TEXT_ALIGN_LEFT;
  160. laShowSeparator(uil,c);
  161. r=laBeginRow(uil,c,0,0);
  162. laShowItem(uil,c,This,"new_package");
  163. laEndRow(uil,r);
  164. laShowItemFull(uil,c,This,"packages",0,0,erpui_PackageItem,0)->Flags|=LA_UI_FLAGS_NO_DECAL;
  165. r=laBeginRow(uil,c,0,0);
  166. laShowItem(uil,c,This,"new_message");
  167. laEndRow(uil,r);
  168. laShowItemFull(uil,c,This,"message_entries",0,0,erpui_MessageEntryItem,0)->Flags|=LA_UI_FLAGS_NO_DECAL;
  169. laShowItemFull(uil,c,This,"comments",LA_WIDGET_STRING_MULTI,0,0,0)->Extra->HeightCoeff=2;
  170. laShowSeparator(uil,c);
  171. laShowItemFull(uil,c,This,"admin_comments",LA_WIDGET_STRING_MULTI,0,0,0)->Extra->HeightCoeff=2;
  172. laShowSeparator(uil,c);
  173. r=laBeginRow(uil,c,0,0);
  174. laShowItemFull(uil,c,This,"print",0,0,0,0);
  175. laShowSeparator(uil,c)->Expand=1;
  176. laShowItemFull(uil,c,This,"remove",0,0,0,0);
  177. laEndRow(uil,r);
  178. }
  179. void erpui_OrdersPanel(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  180. laColumn* c=laFirstColumn(uil), *cl,*cr; laSplitColumn(uil,c,0.5); cl=laLeftColumn(c,0);cr=laRightColumn(c,0);
  181. laUiItem* r=laBeginRow(uil,c,0,0);
  182. laShowItem(uil,c,0,"ERP_new_order");
  183. laEndRow(uil,r);
  184. laShowColumnAdjuster(uil,c);
  185. laUiItem* gr=laMakeEmptyGroup(uil,cl,0,0); laUiList* gu=gr->Page; laColumn* gc=laFirstColumn(gu);
  186. gu->HeightCoeff=-1; gr->Flags|=LA_UI_FLAGS_NO_DECAL;
  187. laUiItem* ui=laShowItemFull(gu,gc,0,"erp.orders",0,0,erpui_OrderListItem,0);
  188. gr=laMakeEmptyGroup(uil,cr,0,0); gu=gr->Page; gc=laFirstColumn(gu);
  189. gu->HeightCoeff=-1; gr->Flags|=LA_UI_FLAGS_NO_DECAL;
  190. ui=laShowItemFull(gu,gc,0,"erp.current_order",0,0,erpui_OrderItem,0);
  191. ui->Flags|=LA_UI_COLLECTION_NO_HIGHLIGHT;
  192. }
  193. void erpui_MessageListItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  194. laColumn* c=laFirstColumn(uil);
  195. laUiItem* r=laBeginRow(uil,c,0,0);
  196. laShowItem(uil,c,This,"is_header")->Flags|=LA_UI_FLAGS_ICON|LA_UI_FLAGS_NO_DECAL;
  197. laShowItemFull(uil,c,This,"description",LA_WIDGET_STRING_PLAIN,0,0,0)->Expand=1;
  198. laEndRow(uil,r);
  199. }
  200. void erpui_MessageItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  201. laColumn* c=laFirstColumn(uil);
  202. laUiItem* r=laBeginRow(uil,c,0,0);
  203. laShowItem(uil,c,This,"is_header")->Flags|=LA_UI_FLAGS_ICON;
  204. laShowItem(uil,c,This,"description")->Expand=1;
  205. laEndRow(uil,r);
  206. laShowItemFull(uil,c,This,"message",LA_WIDGET_STRING_MULTI,0,0,0)->Extra->HeightCoeff=-1;
  207. }
  208. void erpui_CustomerListItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  209. laColumn* c=laFirstColumn(uil);
  210. laUiItem* r=laBeginRow(uil,c,0,0);
  211. laShowItemFull(uil,c,This,"nickname",LA_WIDGET_STRING_PLAIN,0,0,0);
  212. laEndRow(uil,r);
  213. }
  214. void erpui_CustomerItem(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  215. laColumn* c=laFirstColumn(uil),*cl,*cr; laSplitColumn(uil,c,0.5); cl=laLeftColumn(c,10);cr=laRightColumn(c,0);
  216. laShowItemFull(uil,c,This,"nickname",0,0,0,0);
  217. laShowLabel(uil,c,"Details:",0,0);
  218. laShowLabel(uil,cl,"Name:",0,0); laShowItemFull(uil,cr,This,"name",0,0,0,0);
  219. laShowLabel(uil,cl,"Country:",0,0); laShowItemFull(uil,cr,This,"country",0,0,0,0);
  220. laShowLabel(uil,cl,"State:",0,0); laShowItemFull(uil,cr,This,"state",0,0,0,0);
  221. laShowLabel(uil,cl,"City:",0,0); laShowItemFull(uil,cr,This,"city",0,0,0,0);
  222. laShowLabel(uil,cl,"Address:",0,0); laShowItemFull(uil,cr,This,"address",0,0,0,0);
  223. laShowLabel(uil,cl,"Postal Code:",0,0); laShowItemFull(uil,cr,This,"postal_code",0,0,0,0);
  224. laShowLabel(uil,cl,"Telephone:",0,0); laShowItemFull(uil,cr,This,"tel",0,0,0,0);
  225. laShowLabel(uil,cl,"E-Mail:",0,0); laShowItemFull(uil,cr,This,"email",0,0,0,0);
  226. laShowSeparator(uil,c);
  227. laUiItem* r=laBeginRow(uil,c,0,0);
  228. laShowSeparator(uil,c)->Expand=1;
  229. laShowItemFull(uil,c,This,"remove",0,0,0,0);
  230. laEndRow(uil,r);
  231. }
  232. void erpui_CustomersPanel(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  233. laColumn* c=laFirstColumn(uil),*cl,*cr; laSplitColumn(uil,c,0.5); cl=laLeftColumn(c,0);cr=laRightColumn(c,0);
  234. laUiItem* r=laBeginRow(uil,c,0,0);
  235. laShowItem(uil,c,0,"ERP_new_customer");
  236. laEndRow(uil,r);
  237. laShowColumnAdjuster(uil,c);
  238. laUiItem* gr=laMakeEmptyGroup(uil,cl,0,0); laUiList* gu=gr->Page; laColumn* gc=laFirstColumn(gu);
  239. gu->HeightCoeff=-1; gr->Flags|=LA_UI_FLAGS_NO_DECAL;
  240. laUiItem* ui=laShowItemFull(gu,gc,0,"erp.customers",0,0,erpui_CustomerListItem,0);
  241. gr=laMakeEmptyGroup(uil,cr,0,0); gu=gr->Page; gc=laFirstColumn(gu);
  242. gu->HeightCoeff=-1; gr->Flags|=LA_UI_FLAGS_NO_DECAL;
  243. ui=laShowItemFull(gu,gc,0,"erp.current_customer",0,0,erpui_CustomerItem,0);
  244. ui->Flags|=LA_UI_COLLECTION_NO_HIGHLIGHT;
  245. }
  246. void erpui_MessagesPanel(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  247. laColumn* c=laFirstColumn(uil), *cl,*cr; laSplitColumn(uil,c,0.5); cl=laLeftColumn(c,0);cr=laRightColumn(c,0);
  248. laUiItem* r=laBeginRow(uil,c,0,0);
  249. laShowItem(uil,c,0,"ERP_new_message");
  250. laEndRow(uil,r);
  251. laShowColumnAdjuster(uil,c);
  252. laUiItem* gr=laMakeEmptyGroup(uil,cl,0,0); laUiList* gu=gr->Page; laColumn* gc=laFirstColumn(gu);
  253. gu->HeightCoeff=-1; gr->Flags|=LA_UI_FLAGS_NO_DECAL;
  254. laUiItem* ui=laShowItemFull(gu,gc,0,"erp.messages",0,0,erpui_MessageListItem,0);
  255. gr=laMakeEmptyGroup(uil,cr,0,0); gu=gr->Page; gc=laFirstColumn(gu);
  256. gu->HeightCoeff=-1; gr->Flags|=LA_UI_FLAGS_NO_DECAL;
  257. ui=laShowItemFull(gu,gc,0,"erp.current_message",0,0,erpui_MessageItem,0);
  258. ui->Flags|=LA_UI_COLLECTION_NO_HIGHLIGHT;
  259. }
  260. void erp_GetCustomerText(laSafeString** s, ERPCustomer* c){
  261. if(!c){ strSafePrint(s," <Unspecified>\n"); return; }
  262. strSafePrint(s," %-15s : %s\n","Name",SSTR(c->Name));
  263. strSafePrint(s," %-15s : %s\n","Country",SSTR(c->Country));
  264. strSafePrint(s," %-15s : %s\n","State",SSTR(c->State));
  265. strSafePrint(s," %-15s : %s\n","City",SSTR(c->City));
  266. strSafePrint(s," %-15s : %s\n","Address",SSTR(c->Address));
  267. strSafePrint(s," %-15s : %s\n","PostalCode",SSTR(c->PostalCode));
  268. strSafePrint(s," %-15s : %s\n","Tel",SSTR(c->Tel));
  269. strSafePrint(s," %-15s : %s\n","EMail",SSTR(c->EMail));
  270. }
  271. void erp_GetOrderProductsText(laSafeString** s, ERPOrder* o){
  272. if(!o->ProductEntries.pFirst){ strSafePrint(s," <Empty Order>\n"); return; }
  273. strSafePrint(s,"Item | Per Item | Amount | Combined \n");
  274. for(ERPProductEntry* pe=o->ProductEntries.pFirst;pe;pe=pe->Item.pNext){
  275. strSafePrint(s,"%-32s%8d %6d %8d\n",
  276. pe->Product?SSTR(pe->Product->Name):"<Empty Product>",
  277. pe->Product?pe->Product->Price:0, pe->Amount, pe->EntryPrice);
  278. for(ERPProductEntryOption* peo=pe->Options.pFirst;peo;peo=peo->Item.pNext){
  279. strSafePrint(s," %-13s: %-13s %+7d\n",
  280. peo->Option?SSTR(peo->Option->Name):"<Empty Option>",
  281. peo->Value?SSTR(peo->Value->Name):"<Empty Value>",
  282. peo->OptionPriceOffset);
  283. }
  284. }
  285. }
  286. void erp_GetOrderPackagesText(laSafeString** s, ERPOrder* o){
  287. if(!o->ProductEntries.pFirst){ strSafePrint(s," <Empty Order>\n"); return; }
  288. int i=0; for(ERPPackage* p=o->Packages.pFirst;p;p=p->Item.pNext){ i++;
  289. strSafePrint(s," %2d %-32s\n", i,
  290. (p->Tracking&&p->Tracking->Ptr[0]!=0)?SSTR(p->Tracking):"<Unspecified package tracking number>");
  291. int j=0; for(ERPPackageProduct* pp=p->IncludedProducts.pFirst;pp;pp=pp->Item.pNext){ j++;
  292. strSafePrint(s," %2d. %-28s (%8d)\n", j,
  293. (pp->Product&&pp->Product->Product)?SSTR(pp->Product->Product->Name):"<Empty Product>",
  294. pp->Product?pp->Product->EntryPrice:0);
  295. }
  296. }
  297. }
  298. void erp_GetOrderText(laSafeString** s, ERPOrder* o){
  299. int hylevel;
  300. laMemNodeHyper* head=memGetHead(o,&hylevel);
  301. strSafePrint(s,"Order %s\n============================================================\n\nTO:\n",head->NUID.String);
  302. erp_GetCustomerText(s,o->Customer);
  303. strSafePrint(s,"\nProducts ---------------------------------------------------\n\n");
  304. erp_GetOrderProductsText(s, o);
  305. strSafePrint(s,"\nPackages ---------------------------------------------------\n\n");
  306. erp_GetOrderPackagesText(s, o);
  307. }
  308. void erp_GetCustomTest(laSafeString** s, ERPOrder* o){
  309. //strSafePrint(ss);
  310. }
  311. ERPOrder* erpNewOrder(){
  312. ERPOrder* o=memAcquireHyper(sizeof(ERPOrder)); lstPushItem(&erp->Orders,o);
  313. laNotifyUsers("erp.orders"); laNotifyUsers("erp.current_order"); memAssignRef(erp,&erp->CurrentOrder,o);
  314. return o;
  315. }
  316. ERPCustomer* erpNewCustomer(){
  317. ERPCustomer* c=memAcquireHyper(sizeof(ERPCustomer)); lstPushItem(&erp->Customers,c);
  318. strSafeSet(&c->Nickname,"New Customer");
  319. laNotifyUsers("erp.customers"); laNotifyUsers("erp.current_customer"); memAssignRef(erp,&erp->CurrentCustomer,c);
  320. return c;
  321. }
  322. ERPProduct* erpNewProduct(){
  323. ERPProduct* p=memAcquireHyper(sizeof(ERPProduct)); lstPushItem(&erp->Products,p);
  324. strSafeSet(&p->Name,"New Product");
  325. laNotifyUsers("erp.products"); laNotifyUsers("erp.current_product"); memAssignRef(erp,&erp->CurrentProduct,p);
  326. return p;
  327. }
  328. ERPProductOption* erpNewProductOption(ERPProduct* p){ if(!p) return 0;
  329. ERPProductOption* po=memAcquire(sizeof(ERPProductOption)); lstAppendItem(&p->AvailableOptions,po);
  330. strSafeSet(&po->Name,"New Option"); laNotifyInstanceUsers(p); memAssignRef(po,&po->Parent,p);
  331. return po;
  332. }
  333. ERPProductOptionValue* erpNewProductOptionValue(ERPProductOption* po){ if(!po) return 0;
  334. ERPProductOptionValue* pov=memAcquire(sizeof(ERPProductOptionValue)); lstAppendItem(&po->Values,pov);
  335. strSafeSet(&pov->Name,"New Value"); laNotifyInstanceUsers(po); memAssignRef(pov,&pov->Parent,po);
  336. return pov;
  337. }
  338. ERPProductEntry* erpNewProductEntry(ERPOrder* o){ if(!o) return 0;
  339. ERPProductEntry* pe=memAcquire(sizeof(ERPProductEntry)); lstAppendItem(&o->ProductEntries,pe);
  340. laNotifyInstanceUsers(o); memAssignRef(pe,&pe->Parent,o);
  341. return pe;
  342. }
  343. ERPProductEntry* erpNewProductEntryOption(ERPProductEntry* pe){ if(!pe) return 0;
  344. ERPProductEntryOption* peo=memAcquire(sizeof(ERPProductEntryOption)); lstAppendItem(&pe->Options,peo);
  345. laNotifyInstanceUsers(pe); memAssignRef(peo,&peo->Parent,pe);
  346. return peo;
  347. }
  348. ERPPackageProduct* erpNewPackageProduct(ERPPackage* p){ if(!p) return 0;
  349. ERPPackageProduct* pp=memAcquire(sizeof(ERPPackage)); lstAppendItem(&p->IncludedProducts,pp);
  350. laNotifyInstanceUsers(p); memAssignRef(pp,&pp->Parent,p);
  351. return pp;
  352. }
  353. ERPPackage* erpNewPackage(ERPOrder* o){ if(!o) return 0;
  354. ERPPackage* p=memAcquire(sizeof(ERPPackage)); lstAppendItem(&o->Packages,p);
  355. laNotifyInstanceUsers(o); memAssignRef(p,&p->Parent,o);
  356. erpNewPackageProduct(p);
  357. return p;
  358. }
  359. ERPMessage* erpNewMessage(){
  360. ERPMessage* msg=memAcquireHyper(sizeof(ERPMessage)); lstAppendItem(&erp->Messages,msg);
  361. strSafeSet(&msg->Description, "New Message");
  362. laNotifyUsers("erp.messages"); laNotifyUsers("erp.current_message"); memAssignRef(erp,&erp->CurrentMessage,msg);
  363. return msg;
  364. }
  365. ERPMessageEntry* erpNewMessageEntry(ERPOrder* o){ if(!o) return 0;
  366. ERPMessageEntry* me=memAcquire(sizeof(ERPMessageEntry)); lstAppendItem(&o->Messages,me);
  367. laNotifyInstanceUsers(o); memAssignRef(me,&me->Parent,o);
  368. return me;
  369. }
  370. void erpRemoveMessageEntry(ERPOrder* o, ERPMessageEntry* me){
  371. lstRemoveItem(&o->Messages, me); memLeave(me); laNotifyInstanceUsers(o);
  372. }
  373. void erpRemovePackageProduct(ERPPackage* p, ERPPackageProduct* pp){
  374. lstRemoveItem(&p->IncludedProducts,pp); memLeave(pp); laNotifyInstanceUsers(p);
  375. }
  376. void erpRemovePackage(ERPOrder* o, ERPPackage* p){
  377. while(p->IncludedProducts.pFirst){ erpRemovePackageProduct(p,p->IncludedProducts.pFirst); }
  378. lstRemoveItem(&o->Packages,p); strSafeDestroy(&p->Tracking); memLeave(p); laNotifyInstanceUsers(o);
  379. }
  380. void erpRemoveProductEntryOption(ERPProductEntry* pe, ERPProductEntryOption* peo){
  381. lstRemoveItem(&pe->Options,peo); memLeave(peo); laNotifyInstanceUsers(pe);
  382. }
  383. void erpRemoveProductEntry(ERPOrder* o, ERPProductEntry* pe){
  384. while(pe->Options.pFirst){ erpRemoveProductEntryOption(pe,pe->Options.pFirst); }
  385. lstRemoveItem(&o->ProductEntries,pe); memLeave(pe); laNotifyInstanceUsers(o);
  386. }
  387. void erpRemoveOrder(ERPOrder* o){
  388. while(o->Packages.pFirst){ erpRemovePackage(o,o->Packages.pFirst); }
  389. while(o->ProductEntries.pFirst){ erpRemoveProductEntry(o,o->ProductEntries.pFirst); }
  390. while(o->Messages.pFirst){ erpRemoveMessageEntry(o,o->Messages.pFirst); }
  391. strSafeDestroy(&o->Comments); strSafeDestroy(&o->AdminComments);
  392. ERPOrder* cur=o->Item.pNext?o->Item.pNext:o->Item.pPrev;
  393. memAssignRef(erp,&erp->CurrentOrder,cur);
  394. lstRemoveItem(&erp->Orders, o); memLeave(o);
  395. laNotifyUsers("erp.current_order");laNotifyUsers("erp.orders");
  396. }
  397. void erpRemoveCustomer(ERPCustomer* c){
  398. strSafeDestroy(&c->Nickname);
  399. strSafeDestroy(&c->Name);
  400. strSafeDestroy(&c->Country);
  401. strSafeDestroy(&c->State);
  402. strSafeDestroy(&c->City);
  403. strSafeDestroy(&c->Address);
  404. strSafeDestroy(&c->PostalCode);
  405. strSafeDestroy(&c->Tel);
  406. strSafeDestroy(&c->EMail);
  407. ERPCustomer* cur=c->Item.pNext?c->Item.pNext:c->Item.pPrev;
  408. memAssignRef(erp,&erp->CurrentCustomer,cur);
  409. lstRemoveItem(&erp->Customers,c); memLeave(c);
  410. laNotifyUsers("erp.current_customer");laNotifyUsers("erp.customers");
  411. }
  412. void erpRemoveProductOptionValue(ERPProductOption* po, ERPProductOptionValue* pov){
  413. lstRemoveItem(&po->Values,pov); strSafeDestroy(&pov->Name); memLeave(pov);
  414. laNotifyInstanceUsers(po);
  415. }
  416. void erpRemoveProductOption(ERPProduct* p, ERPProductOption* po){
  417. while(po->Values.pFirst){erpRemoveProductOptionValue(po,po->Values.pFirst);}
  418. lstRemoveItem(&p->AvailableOptions,po);
  419. strSafeDestroy(&po->Name); memLeave(po); laNotifyInstanceUsers(p);
  420. }
  421. void erpRemoveProduct(ERPProduct* p){
  422. while(p->AvailableOptions.pFirst){erpRemoveProductOption(p,p->AvailableOptions.pFirst);}
  423. strSafeDestroy(&p->Name); strSafeDestroy(&p->HSCode);
  424. ERPProduct* cur=p->Item.pNext?p->Item.pNext:p->Item.pPrev;
  425. memAssignRef(erp,&erp->CurrentProduct,cur);
  426. lstRemoveItem(&erp->Products,p); memLeave(p);
  427. laNotifyUsers("erp.current_product");laNotifyUsers("erp.products");
  428. }
  429. void erpRemoveMessage(ERPMessage* m){
  430. ERPMessage* nm=m->Item.pNext?m->Item.pNext:m->Item.pPrev;
  431. memAssignRef(erp,&erp->CurrentMessage,nm);
  432. strSafeDestroy(&m->Message); strSafeDestroy(&m->Description);
  433. lstRemoveItem(&erp->Messages, m); memLeave(m);
  434. laNotifyUsers("erp.messages"); laNotifyUsers("erp.current_message");
  435. }
  436. int erpinv_NewOrder(laOperator* a, laEvent* e){ erpNewOrder();
  437. laRecordDifferences(0,"erp.orders");laRecordDifferences(0,"erp.current_order");laPushDifferences("New Order",0);
  438. return LA_FINISHED;
  439. }
  440. int erpinv_NewCustomer(laOperator* a, laEvent* e){ erpNewCustomer();
  441. laRecordDifferences(0,"erp.customers");laRecordDifferences(0,"erp.current_customer");laPushDifferences("New Customer",0);
  442. return LA_FINISHED;
  443. }
  444. int erpinv_NewProduct(laOperator* a, laEvent* e){ erpNewProduct();
  445. laRecordDifferences(0,"erp.products");laRecordDifferences(0,"erp.current_product");laPushDifferences("New Product",0);
  446. return LA_FINISHED;
  447. }
  448. int erpinv_NewProductOption(laOperator* a, laEvent* e){
  449. ERPProduct* p=a->This?a->This->EndInstance:0; if(!p){ return LA_FINISHED; }
  450. ERPProductOption* po=erpNewProductOption(p); if(po){ laRecordInstanceDifferences(p,"erp_product");laPushDifferences("New Product Option",0); }
  451. return LA_FINISHED;
  452. }
  453. int erpinv_NewProductOptionValue(laOperator* a, laEvent* e){
  454. ERPProductOption* po=a->This?a->This->EndInstance:0; if(!po){ return LA_FINISHED; }
  455. ERPProductOptionValue* pov=erpNewProductOptionValue(po); if(pov){ laRecordInstanceDifferences(po,"erp_product_option"); laPushDifferences("New Product Value",0); }
  456. return LA_FINISHED;
  457. }
  458. int erpinv_NewProductEntry(laOperator* a, laEvent* e){
  459. ERPOrder* o=a->This?a->This->EndInstance:0; if(!o){ return LA_FINISHED; }
  460. ERPProductEntry* pe=erpNewProductEntry(o); if(pe){ laRecordInstanceDifferences(o,"erp_order");laPushDifferences("New Product Entry",0); }
  461. return LA_FINISHED;
  462. }
  463. int erpinv_NewProductEntryOption(laOperator* a, laEvent* e){
  464. ERPProductEntry* pe=a->This?a->This->EndInstance:0; if(!pe){ return LA_FINISHED; }
  465. ERPProductEntry* peo=erpNewProductEntryOption(pe); if(peo){ laRecordInstanceDifferences(pe,"erp_product_entry");laPushDifferences("New Product Entry Option",0); }
  466. return LA_FINISHED;
  467. }
  468. int erpinv_NewPackage(laOperator* a, laEvent* e){
  469. ERPOrder* o=a->This?a->This->EndInstance:0; if(!o){ return LA_FINISHED; }
  470. ERPPackage* p=erpNewPackage(o); if(p){ laRecordInstanceDifferences(o,"erp_order");laPushDifferences("New Package",0); }
  471. return LA_FINISHED;
  472. }
  473. int erpinv_NewPackageProduct(laOperator* a, laEvent* e){
  474. ERPPackage* p=a->This?a->This->EndInstance:0; if(!p){ return LA_FINISHED; }
  475. ERPPackageProduct* pp=erpNewPackageProduct(p); if(pp){ laRecordInstanceDifferences(p,"erp_package");laPushDifferences("New Package Product",0); }
  476. return LA_FINISHED;
  477. }
  478. int erpinv_NewMessage(laOperator* a, laEvent* e){ erpNewMessage();
  479. laRecordDifferences(0,"erp.messages");laRecordDifferences(0,"erp.current_message");laPushDifferences("New Message",0);
  480. }
  481. int erpinv_NewMessageEntry(laOperator* a, laEvent* e){
  482. ERPOrder* o=a->This?a->This->EndInstance:0; if(!o){ return LA_FINISHED; }
  483. ERPMessageEntry* me=erpNewMessageEntry(o); if(me){ laRecordInstanceDifferences(o,"erp_order");laPushDifferences("New Message Entry",0); }
  484. return LA_FINISHED;
  485. }
  486. int erpinv_RemoveOrder(laOperator* a, laEvent* e){
  487. ERPOrder* o=a->This?a->This->EndInstance:0; if(!o){ return LA_FINISHED; }
  488. laEnableYesNoPanel(a,0,"Confirm?","Remove order?",e->x,e->y,200,e);
  489. return LA_RUNNING;
  490. }
  491. int erpmod_RemoveOrder(laOperator* a, laEvent* e){
  492. ERPOrder* o=a->This?a->This->EndInstance:0; if(!o){ return LA_FINISHED; }
  493. if (a->ConfirmData){
  494. if (a->ConfirmData->Mode == LA_CONFIRM_OK){ erpRemoveOrder(o);
  495. laRecordDifferences(0,"erp.orders");laRecordDifferences(0,"erp.current_order");laPushDifferences("Remove Order",0);
  496. }
  497. return LA_FINISHED;
  498. } return LA_RUNNING;
  499. }
  500. int erpinv_RemoveProduct(laOperator* a, laEvent* e){
  501. ERPProduct* p=a->This?a->This->EndInstance:0; if(!p){ return LA_FINISHED; }
  502. laEnableYesNoPanel(a,0,"Confirm?","Remove product?",e->x,e->y,200,e);
  503. return LA_RUNNING;
  504. }
  505. int erpmod_RemoveProduct(laOperator* a, laEvent* e){
  506. ERPProduct* p=a->This?a->This->EndInstance:0; if(!p){ return LA_FINISHED; }
  507. if (a->ConfirmData){
  508. if (a->ConfirmData->Mode == LA_CONFIRM_OK){ erpRemoveProduct(p);
  509. laRecordDifferences(0,"erp.products");laRecordDifferences(0,"erp.current_product");laPushDifferences("Remove Product",0);
  510. }
  511. return LA_FINISHED;
  512. } return LA_RUNNING;
  513. }
  514. int erpinv_RemoveCustomer(laOperator* a, laEvent* e){
  515. ERPCustomer* c=a->This?a->This->EndInstance:0; if(!c){ return LA_FINISHED; }
  516. laEnableYesNoPanel(a,0,"Confirm?","Remove customer?",e->x,e->y,200,e);
  517. return LA_RUNNING;
  518. }
  519. int erpmod_RemoveCustomer(laOperator* a, laEvent* e){
  520. ERPCustomer* c=a->This?a->This->EndInstance:0; if(!c){ return LA_FINISHED; }
  521. if (a->ConfirmData){
  522. if (a->ConfirmData->Mode == LA_CONFIRM_OK){ erpRemoveCustomer(c);
  523. laRecordDifferences(0,"erp.customers");laRecordDifferences(0,"erp.current_customer");laPushDifferences("Remove Customer",0);
  524. }
  525. return LA_FINISHED;
  526. } return LA_RUNNING;
  527. }
  528. int erpinv_RemovePackage(laOperator* a, laEvent* e){
  529. ERPPackage* p=a->This?a->This->EndInstance:0; if(!p){ return LA_FINISHED; }
  530. laEnableYesNoPanel(a,0,"Confirm?","Remove package?",e->x,e->y,200,e);
  531. return LA_RUNNING;
  532. }
  533. int erpmod_RemovePackage(laOperator* a, laEvent* e){
  534. ERPPackage* p=a->This?a->This->EndInstance:0; if(!p){ return LA_FINISHED; }
  535. ERPOrder* o=p->Parent;
  536. if (a->ConfirmData){
  537. if (a->ConfirmData->Mode == LA_CONFIRM_OK){ erpRemovePackage(o,p);
  538. laRecordInstanceDifferences(o,"erp_order");
  539. laPushDifferences("Remove Package",0);
  540. }
  541. return LA_FINISHED;
  542. } return LA_RUNNING;
  543. }
  544. int erpinv_RemoveProductOption(laOperator* a, laEvent* e){
  545. ERPProductOption* po=a->This?a->This->EndInstance:0; if(!po){ return LA_FINISHED; }
  546. laEnableYesNoPanel(a,0,"Confirm?","Remove option?",e->x,e->y,200,e);
  547. return LA_RUNNING;
  548. }
  549. int erpmod_RemoveProductOption(laOperator* a, laEvent* e){
  550. ERPProductOption* po=a->This?a->This->EndInstance:0; if(!po){ return LA_FINISHED; }
  551. ERPProduct* p=po->Parent;
  552. if (a->ConfirmData){
  553. if (a->ConfirmData->Mode == LA_CONFIRM_OK){ erpRemoveProductOption(p,po);
  554. laRecordInstanceDifferences(p,"erp_product");
  555. laPushDifferences("Remove Product Option",0);
  556. }
  557. return LA_FINISHED;
  558. } return LA_RUNNING;
  559. }
  560. int erpinv_RemoveProductEntry(laOperator* a, laEvent* e){
  561. ERPProductEntry* pe=a->This?a->This->EndInstance:0; if(!pe){ return LA_FINISHED; }
  562. laEnableYesNoPanel(a,0,"Confirm?","Remove entry?",e->x,e->y,200,e);
  563. return LA_RUNNING;
  564. }
  565. int erpmod_RemoveProductEntry(laOperator* a, laEvent* e){
  566. ERPProductEntry* pe=a->This?a->This->EndInstance:0; if(!pe){ return LA_FINISHED; }
  567. ERPOrder* o=pe->Parent;
  568. if (a->ConfirmData){
  569. if (a->ConfirmData->Mode == LA_CONFIRM_OK){ erpRemoveProductEntry(o,pe);
  570. laRecordInstanceDifferences(o,"erp_order");
  571. laPushDifferences("Remove Product Entry",0);
  572. }
  573. return LA_FINISHED;
  574. } return LA_RUNNING;
  575. }
  576. int erpinv_RemoveProductEntryOption(laOperator* a, laEvent* e){
  577. ERPProductEntryOption* peo=a->This?a->This->EndInstance:0; if(!peo){ return LA_FINISHED; }
  578. ERPProductEntry* pe=peo->Parent;
  579. erpRemoveProductEntryOption(pe,peo);
  580. laRecordInstanceDifferences(pe,"erp_product_entry"); laPushDifferences("Remove Product Entry Option",0);
  581. return LA_FINISHED;
  582. }
  583. int erpinv_RemoveProductOptionValue(laOperator* a, laEvent* e){
  584. ERPProductOptionValue* pov=a->This?a->This->EndInstance:0; if(!pov){ return LA_FINISHED; }
  585. ERPProductOption* po=pov->Parent;
  586. erpRemoveProductOptionValue(po,pov);
  587. laRecordInstanceDifferences(po,"erp_product_option"); laPushDifferences("Remove Product Option Value",0);
  588. return LA_FINISHED;
  589. }
  590. int erpinv_RemovePackageProduct(laOperator* a, laEvent* e){
  591. ERPPackageProduct* pp=a->This?a->This->EndInstance:0; if(!pp){ return LA_FINISHED; }
  592. ERPPackage* p=pp->Parent; if(p->IncludedProducts.pFirst==p->IncludedProducts.pLast){ return LA_FINISHED; }
  593. erpRemovePackageProduct(p,pp);
  594. laRecordInstanceDifferences(p,"erp_package"); laPushDifferences("Remove Package Product",0);
  595. return LA_FINISHED;
  596. }
  597. int erpinv_RemoveMessage(laOperator* a, laEvent* e){
  598. ERPMessage* m=a->This?a->This->EndInstance:0; if(!m){ return LA_FINISHED; }
  599. laEnableYesNoPanel(a,0,"Confirm?","Remove message?",e->x,e->y,200,e);
  600. return LA_RUNNING;
  601. }
  602. int erpmod_RemoveMessage(laOperator* a, laEvent* e){
  603. ERPMessage* m=a->This?a->This->EndInstance:0; if(!m){ return LA_FINISHED; }
  604. if (a->ConfirmData){
  605. if (a->ConfirmData->Mode == LA_CONFIRM_OK){ erpRemoveMessage(m);
  606. laRecordDifferences(0,"erp.messages");laRecordDifferences(0,"erp.current_message");laPushDifferences("Remove Message",0);
  607. }
  608. return LA_FINISHED;
  609. } return LA_RUNNING;
  610. }
  611. int erpinv_RemoveMessageEntry(laOperator* a, laEvent* e){
  612. ERPMessageEntry* me=a->This?a->This->EndInstance:0; if(!me){ return LA_FINISHED; }
  613. laEnableYesNoPanel(a,0,"Confirm?","Remove message?",e->x,e->y,200,e);
  614. return LA_RUNNING;
  615. }
  616. int erpmod_RemoveMessageEntry(laOperator* a, laEvent* e){
  617. ERPMessageEntry* me=a->This?a->This->EndInstance:0; if(!me){ return LA_FINISHED; }
  618. ERPOrder* o=me->Parent;
  619. if (a->ConfirmData){
  620. if (a->ConfirmData->Mode == LA_CONFIRM_OK){ erpRemoveMessageEntry(o,me);
  621. laRecordInstanceDifferences(o,"erp_order");
  622. laPushDifferences("Remove Message Entry",0);
  623. }
  624. return LA_FINISHED;
  625. } return LA_RUNNING;
  626. }
  627. int erpinv_PrintOrderInfo(laOperator* a, laEvent* e){
  628. ERPOrder* o=a->This?a->This->EndInstance:erp->CurrentOrder; if(!o){ return LA_FINISHED; }
  629. laSafeString*s=0; erp_GetOrderText(&s,o);
  630. struct pdf_info info = {
  631. .creator = "Me",
  632. .producer = "eLarp Software",
  633. .title = "Order Info",
  634. .author = "Yiming",
  635. .subject = "Some Subject",
  636. .date = "Today"
  637. };
  638. //struct pdf_doc *pdf = pdf_create(PDF_A4_WIDTH, PDF_A4_HEIGHT, &info);
  639. //pdf_set_font(pdf, "Courier");
  640. //pdf_append_page(pdf);
  641. //pdf_add_text_wrap(pdf, NULL, SSTR(s), 12, 50,PDF_A4_HEIGHT-20, 0,PDF_BLACK,PDF_A4_WIDTH,PDF_ALIGN_LEFT,0);
  642. //pdf_add_line(pdf, NULL, 50, 24, 150, 24, 3, PDF_BLACK);
  643. //pdf_save(pdf, "output.pdf");
  644. //pdf_destroy(pdf);
  645. FILE* f=fopen("order.txt","w");
  646. fprintf(f,"%s\n",SSTR(s));
  647. fclose(f);
  648. printf("%s\n",SSTR(s)); strSafeDestroy(&s);
  649. return LA_FINISHED;
  650. }
  651. void erpset_ProductOptionMove(ERPProductOption* po, int move){
  652. if(move<0 && po->Item.pPrev){ lstMoveUp(&po->Parent->AvailableOptions, po); laNotifyInstanceUsers(po->Parent); }
  653. elif(move>0 && po->Item.pNext){ lstMoveDown(&po->Parent->AvailableOptions, po); laNotifyInstanceUsers(po->Parent); }
  654. }
  655. void erpset_ProductOptionValueMove(ERPProductOptionValue* pov, int move){
  656. if(move<0 && pov->Item.pPrev){ lstMoveUp(&pov->Parent->Values, pov); laNotifyInstanceUsers(pov->Parent); }
  657. elif(move>0 && pov->Item.pNext){ lstMoveDown(&pov->Parent->Values, pov); laNotifyInstanceUsers(pov->Parent); }
  658. }
  659. void erpset_ProductEntryMove(ERPProductEntry* pe, int move){
  660. if(move<0 && pe->Item.pPrev){ lstMoveUp(&pe->Parent->ProductEntries, pe); laNotifyInstanceUsers(pe->Parent); }
  661. elif(move>0 && pe->Item.pNext){ lstMoveDown(&pe->Parent->ProductEntries, pe); laNotifyInstanceUsers(pe->Parent); }
  662. }
  663. void erpset_ProductEntryOptionMove(ERPProductEntryOption* peo, int move){
  664. if(move<0 && peo->Item.pPrev){ lstMoveUp(&peo->Parent->Options, peo); laNotifyInstanceUsers(peo->Parent); }
  665. elif(move>0 && peo->Item.pNext){ lstMoveDown(&peo->Parent->Options, peo); laNotifyInstanceUsers(peo->Parent); }
  666. }
  667. void erpset_PackageMove(ERPPackage* p, int move){
  668. if(move<0 && p->Item.pPrev){ lstMoveUp(&p->Parent->Packages, p); laNotifyInstanceUsers(p->Parent); }
  669. elif(move>0 && p->Item.pNext){ lstMoveDown(&p->Parent->Packages, p); laNotifyInstanceUsers(p->Parent); }
  670. }
  671. void erpset_PackageProductMove(ERPPackageProduct* pp, int move){
  672. if(move<0 && pp->Item.pPrev){ lstMoveUp(&pp->Parent->IncludedProducts, pp); laNotifyInstanceUsers(pp->Parent); }
  673. elif(move>0 && pp->Item.pNext){ lstMoveDown(&pp->Parent->IncludedProducts, pp); laNotifyInstanceUsers(pp->Parent); }
  674. }
  675. void erpset_MessageEntryMove(ERPMessageEntry* me, int move){
  676. if(move<0 && me->Item.pPrev){ lstMoveUp(&me->Parent->Messages, me); laNotifyInstanceUsers(me->Parent); }
  677. elif(move>0 && me->Item.pNext){ lstMoveDown(&me->Parent->Messages, me); laNotifyInstanceUsers(me->Parent); }
  678. }
  679. void* erpget_FirstCustomer(void* unused1,void* unused2){ return erp->Customers.pFirst; }
  680. void* erpget_FirstProduct(void* unused1,void* unused2){ return erp->Products.pFirst; }
  681. void* erpget_FirstMessage(void* unused1,void* unused2){ return erp->Messages.pFirst; }
  682. void* erpget_FirstProductEntryOption(ERPProductEntryOption* peo,void* unused2){ return peo->Parent&&peo->Parent->Product?peo->Parent->Product->AvailableOptions.pFirst:0; }
  683. void* erpget_FirstProductEntryOptionValue(ERPProductEntryOption* peo,void* unused2){ return peo->Option?peo->Option->Values.pFirst:0; }
  684. void* erpget_FirstProductEntryFromPackageProduct(ERPPackageProduct* pp,void* unused2){ return pp->Parent&&pp->Parent->Parent?pp->Parent->Parent->ProductEntries.pFirst:0; }
  685. void* erpgetactive_ProductEntryProduct(ERPProductEntry* pe, void* unused){ return pe->Product; }
  686. void* erpgetactive_MessageEntryMessage(ERPMessageEntry* me, void* unused){ return me->Message; }
  687. void erpRegisterEverything(){
  688. laPropContainer* pc; laKeyMapper* km; laProp* p; laSubProp* sp; laOperatorType* at;
  689. laCreateOperatorType("ERP_new_order","New Order","New order",0,0,0,erpinv_NewOrder,0,'+',0);
  690. laCreateOperatorType("ERP_new_customer","New Customer","New customer",0,0,0,erpinv_NewCustomer,0,'+',0);
  691. laCreateOperatorType("ERP_new_product","New Product","New product",0,0,0,erpinv_NewProduct,0,'+',0);
  692. laCreateOperatorType("ERP_new_product_option","New Option","New option",0,0,0,erpinv_NewProductOption,0,'+',0);
  693. laCreateOperatorType("ERP_new_product_option_value","New Value","New value",0,0,0,erpinv_NewProductOptionValue,0,'+',0);
  694. laCreateOperatorType("ERP_new_product_entry","New Product Entry","New product entry",0,0,0,erpinv_NewProductEntry,0,'+',0);
  695. laCreateOperatorType("ERP_new_product_entry_option","New Option","New option",0,0,0,erpinv_NewProductEntryOption,0,'+',0);
  696. laCreateOperatorType("ERP_new_package","New Package","New package",0,0,0,erpinv_NewPackage,0,'+',0);
  697. laCreateOperatorType("ERP_new_package_product","New Package Product","New package Product",0,0,0,erpinv_NewPackageProduct,0,'+',0);
  698. laCreateOperatorType("ERP_new_message","New Message","New Message",0,0,0,erpinv_NewMessage,0,'+',0);
  699. laCreateOperatorType("ERP_new_message_entry","New Message Entry","New Message Entry",0,0,0,erpinv_NewMessageEntry,0,'+',0);
  700. laCreateOperatorType("ERP_remove_order","Remove Order","Remove order",0,0,0,erpinv_RemoveOrder,erpmod_RemoveOrder,U'🞫',0);
  701. laCreateOperatorType("ERP_remove_product","Remove Product","Remove product",0,0,0,erpinv_RemoveProduct,erpmod_RemoveProduct,U'🞫',0);
  702. laCreateOperatorType("ERP_remove_customer","Remove Customer","Remove customer",0,0,0,erpinv_RemoveCustomer,erpmod_RemoveCustomer,U'🞫',0);
  703. laCreateOperatorType("ERP_remove_package","Remove Package","Remove package",0,0,0,erpinv_RemovePackage,erpmod_RemovePackage,U'🞫',0);
  704. laCreateOperatorType("ERP_remove_product_option","Remove Product Option","Remove product option",0,0,0,erpinv_RemoveProductOption,erpmod_RemoveProductOption,U'🞫',0);
  705. laCreateOperatorType("ERP_remove_product_entry","Remove Product Entry","Remove product entry",0,0,0,erpinv_RemoveProductEntry,erpmod_RemoveProductEntry,U'🞫',0);
  706. laCreateOperatorType("ERP_remove_product_entry_option","Remove Product Entry Option","Remove product entry option",0,0,0,erpinv_RemoveProductEntryOption,0,U'🞫',0);
  707. laCreateOperatorType("ERP_remove_product_option_value","Remove Product Option Value","Remove product option value",0,0,0,erpinv_RemoveProductOptionValue,0,U'🞫',0);
  708. laCreateOperatorType("ERP_remove_package_product","Remove Package Product","Remove package product",0,0,0,erpinv_RemovePackageProduct,0,U'🞫',0);
  709. laCreateOperatorType("ERP_remove_message","Remove Message","Remove Message",0,0,0,erpinv_RemoveMessage,erpmod_RemoveMessage,U'🞫',0);
  710. laCreateOperatorType("ERP_remove_message_entry","Remove Message Entry","Remove Message Entry",0,0,0,erpinv_RemoveMessageEntry,erpmod_RemoveMessageEntry,U'🞫',0);
  711. laCreateOperatorType("ERP_print_order_info","Print Order Info","Print order info",0,0,0,erpinv_PrintOrderInfo,0,0,0);
  712. pc=laDefineRoot();
  713. laAddSubGroup(pc,"erp","ERP","ERP main","erp_main",0,0,0,-1,erpget_erp,0,0,0,0,0,0,LA_UDF_SINGLE);
  714. pc=laAddPropertyContainer("erp_main","ERP MAIN","ERP root structure",0,0,sizeof(ERPMain),0,0,1);
  715. 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);
  716. 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);
  717. 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);
  718. laAddSubGroup(pc,"current_message","Current Message","Current Message","erp_message",0,0,0,offsetof(ERPMain,CurrentMessage),0,0,0,0,0,0,0,LA_UDF_REFER);
  719. laAddSubGroup(pc,"orders","Orders","All Orders","erp_order",0,0,0,offsetof(ERPMain,CurrentOrder),0,0,0,0,0,0,offsetof(ERPMain,Orders),0);
  720. laAddSubGroup(pc,"products","Products","All Products","erp_product",0,0,0,offsetof(ERPMain,CurrentProduct),0,0,0,0,0,0,offsetof(ERPMain,Products),0);
  721. laAddSubGroup(pc,"customers","Customers","All Customers","erp_customer",0,0,0,offsetof(ERPMain,CurrentCustomer),0,0,0,0,0,0,offsetof(ERPMain,Customers),0);
  722. laAddSubGroup(pc,"messages","Messages","All Messages","erp_message",0,0,0,offsetof(ERPMain,CurrentMessage),0,0,0,0,0,0,offsetof(ERPMain,Messages),0);
  723. pc=laAddPropertyContainer("erp_customer","ERP Customer","ERP customer",0,0,sizeof(ERPCustomer),0,0,2);
  724. laAddStringProperty(pc,"nickname","Nickname","Nickname",0,0,0,0,1,offsetof(ERPCustomer,Nickname),0,0,0,0,LA_AS_IDENTIFIER);
  725. laAddStringProperty(pc,"name","Name","Name",0,0,0,0,1,offsetof(ERPCustomer,Name),0,0,0,0,0);
  726. laAddStringProperty(pc,"country","Country","Country",0,0,0,0,1,offsetof(ERPCustomer,Country),0,0,0,0,0);
  727. laAddStringProperty(pc,"state","State","State",0,0,0,0,1,offsetof(ERPCustomer,State),0,0,0,0,0);
  728. laAddStringProperty(pc,"city","City","City",0,0,0,0,1,offsetof(ERPCustomer,City),0,0,0,0,0);
  729. laAddStringProperty(pc,"address","Address","Address",0,0,0,0,1,offsetof(ERPCustomer,Address),0,0,0,0,0);
  730. laAddStringProperty(pc,"postal_code","PostalCode","PostalCode",0,0,0,0,1,offsetof(ERPCustomer,PostalCode),0,0,0,0,0);
  731. laAddStringProperty(pc,"tel","Tel","Tel",0,0,0,0,1,offsetof(ERPCustomer,Tel),0,0,0,0,0);
  732. laAddStringProperty(pc,"email","EMail","EMail",0,0,0,0,1,offsetof(ERPCustomer,EMail),0,0,0,0,0);
  733. laAddOperatorProperty(pc,"remove","Remove","Remove this customer","ERP_remove_customer",0,0);
  734. pc=laAddPropertyContainer("erp_order","ERP Order","ERP order",0,0,sizeof(ERPOrder),0,0,2);
  735. 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);
  736. 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);
  737. laAddSubGroup(pc,"message_entries","Message Entries","Message entries","erp_message_entry",0,0,0,-1,0,0,0,0,0,0,offsetof(ERPOrder,Messages),0);
  738. laAddSubGroup(pc,"packages","Packages","Packages","erp_package",0,0,0,-1,0,0,0,0,0,0,offsetof(ERPOrder,Packages),0);
  739. laAddStringProperty(pc,"comments","Comments","Comments about the order",0,0,0,0,1,offsetof(ERPOrder,Comments),0,0,0,0,0);
  740. laAddStringProperty(pc,"admin_comments","Admin comments","Admin comments about the order",0,0,0,0,1,offsetof(ERPOrder,AdminComments),0,0,0,0,0);
  741. 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);
  742. laAddEnumItemAs(p,"PENDING_PACKAGING","Pending Packaging","Pending packaging",ERP_ORDER_STATE_PENDING_PACKAGING,0);
  743. laAddEnumItemAs(p,"PENDING_LABEL","Pending Label","Pending label",ERP_ORDER_STATE_PENDING_LABEL,0);
  744. laAddEnumItemAs(p,"PENDING_SHIPPING","Pending Shipping","Pending shipping",ERP_ORDER_STATE_PENDING_SHIPPING,0);
  745. laAddEnumItemAs(p,"SHIPPED","Shipped","Shipped",ERP_ORDER_STATE_SHIPPED,0);
  746. laAddEnumItemAs(p,"ARRIVED","Arrived","Arrived",ERP_ORDER_STATE_ARRIVED,0);
  747. laAddEnumItemAs(p,"IN_PERSON","In Person","Pending packaging",ERP_ORDER_STATE_IN_PERSON,0);
  748. laAddEnumItemAs(p,"NEEDS_INFO","Needs Information","Pending packaging",ERP_ORDER_STATE_NEED_INFO,0);
  749. 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);
  750. laAddIntProperty(pc,"order_discount","Order Discount","Order discount",0,0,0,0,0,0,0,0,offsetof(ERPOrder,OrderDiscount),0,0,0,0,0,0,0,0,0,0,0);
  751. laAddIntProperty(pc,"order_price","Order Price","Order price",0,0,0,0,0,0,0,0,offsetof(ERPOrder,OrderPrice),0,0,0,0,0,0,0,0,0,0,LA_READ_ONLY);
  752. laAddOperatorProperty(pc,"new_item","New Item","New product entry","ERP_new_product_entry",0,0);
  753. laAddOperatorProperty(pc,"new_package","New Package","New package for the order","ERP_new_package",0,0);
  754. laAddOperatorProperty(pc,"remove","Remove","Remove this order","ERP_remove_order",0,0);
  755. laAddOperatorProperty(pc,"print","Print","Print out this order","ERP_print_order_info",0,0);
  756. laAddOperatorProperty(pc,"new_message","New Message","New Message","ERP_new_message_entry",0,0);
  757. pc=laAddPropertyContainer("erp_package","ERP Package","ERP package",0,0,sizeof(ERPPackage),0,0,1);
  758. laAddIntProperty(pc,"__move","Move","Move slider",LA_WIDGET_HEIGHT_ADJUSTER,0,0,0,0,0,0,0,0,0,erpset_PackageMove,0,0,0,0,0,0,0,0,LA_UDF_IGNORE);
  759. laAddSubGroup(pc,"parent","Parent","Parent order","erp_order",0,0,0,offsetof(ERPPackage,Parent),0,0,0,0,0,0,0,LA_UDF_REFER|LA_READ_ONLY);
  760. laAddStringProperty(pc,"tracking","Tracking","Tracking number",0,0,0,0,1,offsetof(ERPPackage,Tracking),0,0,0,0,LA_AS_IDENTIFIER);
  761. laAddSubGroup(pc,"included_products","Included Products","Included products","erp_package_product",0,0,0,-1,0,0,0,0,0,0,offsetof(ERPPackage,IncludedProducts),0);
  762. laAddOperatorProperty(pc,"new_entry","New Entry","Add product entry to package","ERP_new_package_product",0,0);
  763. laAddOperatorProperty(pc,"remove","Remove","Remove this package","ERP_remove_package",0,0);
  764. pc=laAddPropertyContainer("erp_package_product","ERP Package Product","ERP package product",0,0,sizeof(ERPPackageProduct),0,0,1);
  765. laAddIntProperty(pc,"__move","Move","Move slider",LA_WIDGET_HEIGHT_ADJUSTER,0,0,0,0,0,0,0,0,0,erpset_PackageProductMove,0,0,0,0,0,0,0,0,LA_UDF_IGNORE);
  766. laAddSubGroup(pc,"parent","Parent","Parent order","erp_package",0,0,0,offsetof(ERPPackageProduct,Parent),0,0,0,0,0,0,0,LA_UDF_REFER|LA_READ_ONLY);
  767. laAddSubGroup(pc,"product","Product","Prduct entry","erp_product_entry",0,LA_WIDGET_COLLECTION_SELECTOR,erpui_ProductEntryListItem,offsetof(ERPPackageProduct,Product),erpget_FirstProductEntryFromPackageProduct,0,laget_ListNext,0,0,0,0,LA_UDF_REFER);
  768. laAddOperatorProperty(pc,"remove","Remove","Remove this product","ERP_remove_package_product",0,0);
  769. pc=laAddPropertyContainer("erp_product_entry","ERP Product Entry","ERP Product Entry",0,0,sizeof(ERPProductEntry),0,0,1);
  770. 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);
  771. 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);
  772. laAddSubGroup(pc,"product","Product","Product","erp_product",0,LA_WIDGET_COLLECTION_SELECTOR,erpui_ProductListItem,offsetof(ERPProductEntry,Product),erpget_FirstProduct,erpgetactive_ProductEntryProduct,laget_ListNext,0,0,0,0,LA_UDF_REFER);
  773. laAddSubGroup(pc,"options","Options","Product Options","erp_product_entry_option",0,0,0,-1,0,0,0,0,0,0,offsetof(ERPProductEntry,Options),0);
  774. 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);
  775. laAddIntProperty(pc,"entry_price","Entry Price","Entry price",LA_WIDGET_INT_PLAIN,0,0,0,0,0,0,0,offsetof(ERPProductEntry,EntryPrice),0,0,0,0,0,0,0,0,0,0,LA_READ_ONLY);
  776. laAddOperatorProperty(pc,"new_option","New Option","New product option","ERP_new_product_entry_option",0,0);
  777. laAddOperatorProperty(pc,"remove","Remove","Remove this entry","ERP_remove_product_entry",0,0);
  778. pc=laAddPropertyContainer("erp_product_entry_option","ERP Product Entry Option","ERP Product Entry Option",0,0,sizeof(ERPProductEntryOption),0,0,1);
  779. 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);
  780. 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);
  781. 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);
  782. 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);
  783. laAddIntProperty(pc,"option_price_offset","Option price Offset","Option price offset",0,0,0,0,0,0,0,0,offsetof(ERPProductEntryOption,OptionPriceOffset),0,0,0,0,0,0,0,0,0,0,0);
  784. laAddOperatorProperty(pc,"remove","Remove","Remove this option","ERP_remove_product_entry_option",0,0);
  785. pc=laAddPropertyContainer("erp_product","ERP Product","ERP product",0,0,sizeof(ERPOrder),0,0,2);
  786. laAddStringProperty(pc,"name","Name","Name",0,0,0,0,1,offsetof(ERPProduct,Name),0,0,0,0,LA_AS_IDENTIFIER);
  787. 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);
  788. 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);
  789. laAddIntProperty(pc,"discounted_price","Discounted Price","Discounted price",0,0,0,0,0,0,0,0,offsetof(ERPProduct,DiscountedPrice),0,0,0,0,0,0,0,0,0,0,0);
  790. laAddOperatorProperty(pc,"new_option","New Option","New option for the product","ERP_new_product_option",0,0);
  791. laAddStringProperty(pc,"hs_code","HS code","EU HS Code",0,0,0,0,1,offsetof(ERPProduct,HSCode),0,0,0,0,0);
  792. laAddOperatorProperty(pc,"remove","Remove","Remove this product","ERP_remove_product",0,0);
  793. pc=laAddPropertyContainer("erp_product_option","ERP Product Option","ERP Product Option",0,0,sizeof(ERPProductOption),0,0,1);
  794. 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);
  795. laAddStringProperty(pc,"name","Name","Name",0,0,0,0,1,offsetof(ERPProductOption,Name),0,0,0,0,LA_AS_IDENTIFIER);
  796. laAddSubGroup(pc,"values","Values","Values","erp_product_option_value",0,0,0,-1,0,0,0,0,0,0,offsetof(ERPProductOption,Values),0);
  797. 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);
  798. laAddOperatorProperty(pc,"new_value","New Value","New value for the option","ERP_new_product_option_value",0,0);
  799. laAddOperatorProperty(pc,"remove","Remove","Remove this product option","ERP_remove_product_option",0,0);
  800. pc=laAddPropertyContainer("erp_product_option_value","ERP Product Option","ERP Product Option Value",0,0,sizeof(ERPProductOptionValue),0,0,1);
  801. 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);
  802. laAddStringProperty(pc,"name","Name","Name",0,0,0,0,1,offsetof(ERPProductOptionValue,Name),0,0,0,0,LA_AS_IDENTIFIER);
  803. 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);
  804. 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);
  805. laAddOperatorProperty(pc,"remove","Remove","Remove this product option value","ERP_remove_product_option_value",0,0);
  806. pc=laAddPropertyContainer("erp_message","ERP Message","ERP message",0,0,sizeof(ERPMessage),0,0,2);
  807. laAddStringProperty(pc,"description","Description","description of the message",0,0,0,0,1,offsetof(ERPMessage,Description),0,0,0,0,LA_AS_IDENTIFIER);
  808. laAddStringProperty(pc,"message","Message","Body of the message",0,0,0,0,1,offsetof(ERPMessage,Message),0,0,0,0,0);
  809. p = laAddEnumProperty(pc,"is_header","Is Header","Put the message on the header",LA_WIDGET_ENUM_HIGHLIGHT,0,0,0,0,offsetof(ERPMessage,IsHeader),0,0,0,0,0,0,0,0,0,0);
  810. laAddEnumItemAs(p,"NONE","None","Put message at the end of the order",0,0);
  811. laAddEnumItemAs(p,"HEADER","Header","Put message at the top of the order",1,U'↑');
  812. pc=laAddPropertyContainer("erp_message_entry","ERP Message Entry","ERP message entry",0,0,sizeof(ERPMessageEntry),0,0,1);
  813. laAddIntProperty(pc,"__move","Move","Move slider",LA_WIDGET_HEIGHT_ADJUSTER,0,0,0,0,0,0,0,0,0,erpset_MessageEntryMove,0,0,0,0,0,0,0,0,LA_UDF_IGNORE);
  814. laAddSubGroup(pc,"parent","Parent","Parent order","erp_order",0,0,0,offsetof(ERPMessageEntry,Parent),0,0,0,0,0,0,0,LA_UDF_REFER|LA_READ_ONLY);
  815. laAddSubGroup(pc,"message","Message","Message","erp_message",0,LA_WIDGET_COLLECTION_SELECTOR,erpui_MessageListItem,offsetof(ERPProductEntry,Product),erpget_FirstMessage,erpgetactive_MessageEntryMessage,laget_ListNext,0,0,0,0,LA_UDF_REFER);
  816. laAddOperatorProperty(pc,"remove","Remove","Remove this message entry","ERP_remove_message_entry",0,0);
  817. laSaveProp("erp.products");
  818. laSaveProp("erp.customers");
  819. laSaveProp("erp.orders");
  820. laSaveProp("erp.messages");
  821. laRegisterUiTemplate("erp_panel_orders","Orders",erpui_OrdersPanel,0,0,0,0,20,20);
  822. laRegisterUiTemplate("erp_panel_products","Products",erpui_ProductsPanel,0,0,0,0,20,20);
  823. laRegisterUiTemplate("erp_panel_customers","Customers",erpui_CustomersPanel,0,0,0,0,20,20);
  824. laRegisterUiTemplate("erp_panel_messages","Messages",erpui_MessagesPanel,0,0,0,0,20,20);
  825. }
  826. void erpInit(){
  827. erp=memAcquire(sizeof(ERPMain));
  828. laAddRootDBInst("erp");
  829. }