IVYREPOR.MOD 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. IMPLEMENTATION MODULE IvyReports;
  2. (*
  3. * ModBase
  4. * Release 3.0
  5. * (c) Copyright 1986 - 1991 PMI
  6. * P.O. Box 8402
  7. * Green Bay Wi 53308
  8. * All Rights Reserved
  9. * by Ed Ross
  10. *)
  11. FROM DBFInvtry IMPORT InvtryRec,OpenInvtryDBF,InvtryDBF,
  12. CloseInvtryDBF,MoveInvtryFromDBF,InvcodeIdx,FindInvtryByInvcode,
  13. MoveInvtryToDBF;
  14. FROM PosUtils IMPORT Equal,Pos;
  15. FROM PriceTable IMPORT GetPriceTable;
  16. FROM PMIGlobals IMPORT Today,TodayDays,Config,NormalTitle,
  17. OpenReportDevice,CloseReportDevice;
  18. FROM DBUtils IMPORT GetDateRange,PrintFrame,SelectFromScreen,
  19. GetSelected;
  20. FROM DBStuff IMPORT MakeKey,FindAll,ReadAllRecs,ConditionType,MakeSeqNbr;
  21. FROM GenLists IMPORT GenList,ListInsert,DisposeList,
  22. GetElmt,GetElmtAdr,NewList,ListLength,SortList,ListDelete;
  23. FROM StrConv IMPORT RealToStr,CardinalToStr;
  24. FROM StrEdit IMPORT CrunchBlanks,DeleteRightJustified,Append,
  25. CAPstr,OverWrite,RightJustify,Center,SetLength,CutLeadingChars;
  26. FROM ModBase3 IMPORT ReadDBRec,CloseDBF,WriteDBRec;
  27. FROM M2Strings IMPORT Length,CompareStr;
  28. FROM LowLevel IMPORT Fill;
  29. FROM NumTypes IMPORT Real8;
  30. IMPORT VWindows;
  31. FROM ScrnUtl2 IMPORT CloseDisplayFrame;
  32. FROM ScrnUtl1 IMPORT GetFieldRec,PutFieldRec,FieldNum,FieldListTotal;
  33. FROM ScrnTypes IMPORT DisplayFrame,InitDisplayFrame,AFrameName,
  34. DispCode,ContinueInput,CancelInput,SubmitInput,InputFieldRecord;
  35. FROM FramePainter IMPORT ShowDisplayFrame,RedrawField;
  36. FROM ControlUtils IMPORT Control,AddStrField,AddMenuItem;
  37. FROM Prompts IMPORT Prompt,PromptStr,PromptYN;
  38. FROM ScrnTypes IMPORT AFrameName, InitDisplayFrame,DisplayFile;
  39. FROM SYSTEM IMPORT ADDRESS,ADR,SIZE;
  40. FROM VStorage IMPORT DosAlloc;
  41. PROCEDURE SortInv(A1 : ADDRESS; Size1 :CARDINAL;
  42. A2 : ADDRESS; Size2 : CARDINAL): INTEGER;
  43. VAR
  44. I1, I2 : POINTER TO InvtryRec;
  45. BEGIN
  46. I1 := A1;
  47. I2 := A2;
  48. RETURN CompareStr(I1^.INVCODE,I2^.INVCODE);
  49. END SortInv;
  50. (* # call(reg_param=>(ax,bx,cx,dx,st0,st6,st5,st4,st3) ) *)
  51. PROCEDURE ReadInvRec(VAR A: ADDRESS; VAR Size : CARDINAL);
  52. VAR
  53. InvRec : POINTER TO InvtryRec;
  54. BEGIN
  55. Size := SIZE(InvtryRec);
  56. DosAlloc(InvRec,Size);
  57. MoveInvtryFromDBF(InvRec^);
  58. A := InvRec;
  59. END ReadInvRec;
  60. PROCEDURE TotalInventory();
  61. VAR
  62. Str : ARRAY[0..20] OF CHAR;
  63. InvList : GenList;
  64. J : CARDINAL;
  65. Line : ARRAY[0..80] OF CHAR;
  66. DF : DisplayFrame;
  67. FieldRec : InputFieldRecord;
  68. Inventory : InvtryRec;
  69. Code : CARDINAL;
  70. Value : Real8;
  71. Handle : CARDINAL;
  72. Cost : Real8;
  73. P1,P2,P3,P4 : Real8;
  74. Q1,Q2,Q3,Q4 : CARDINAL;
  75. BEGIN
  76. Str := '';
  77. PromptStr('Enter Inventory Code (or partial Code)',Str);
  78. MakeKey(Str);
  79. OpenInvtryDBF(TRUE);
  80. FindAll(InvcodeIdx,Str,BeginsWith,InvList);
  81. ReadAllRecs(InvtryDBF,ReadInvRec,InvList);
  82. CloseInvtryDBF();
  83. InitDisplayFrame(DF,VWindows.CurrentWindow);
  84. AddStrField(DF,2,2,
  85. ' Code Description On Hand Purch Price Cost Value ',78);
  86. GetFieldRec(DF,1,FieldRec);
  87. FieldRec.typ := DispCode; (* headline = display code *)
  88. PutFieldRec(FieldRec,DF,1);
  89. DF^.headline := 2;
  90. Cost := 0.0;
  91. Value := 0.0;
  92. SortList(InvList,SortInv);
  93. FOR J := 1 TO ListLength(InvList) DO
  94. GetElmt(InvList,J,Inventory,Code);
  95. Fill(ADR(Line),SIZE(Line),' ');
  96. Line[77] := 0C;
  97. OverWrite(Inventory.INVCODE,Line,1);
  98. OverWrite(Inventory.DESC,Line,8);
  99. RealToStr(Inventory.ONHAND,2,8,Str);
  100. OverWrite(Str,Line,42);
  101. RealToStr(Inventory.PURPRICE,2,8,Str);
  102. OverWrite(Str,Line,51);
  103. RealToStr(Inventory.PURPRICE * Inventory.ONHAND,2,8,Str);
  104. Cost := Cost + (Inventory.PURPRICE * Inventory.ONHAND);
  105. OverWrite(Str,Line,61);
  106. IF Inventory.PRICETBL > 0
  107. THEN
  108. GetPriceTable(Inventory.PRICETBL,Q1,Q2,Q3,Q4,Inventory.UNITPRICE,P2,P3,P4);
  109. (* make up a unit price for value *)
  110. END;
  111. RealToStr(Inventory.UNITPRICE * Inventory.ONHAND,2,8,Str);
  112. Value := Value + (Inventory.UNITPRICE * Inventory.ONHAND);
  113. OverWrite(Str,Line,70);
  114. AddMenuItem(DF,2,J+2,Line,78,0,' ');
  115. END; (* end of for J *)
  116. DisposeList(InvList);
  117. ShowDisplayFrame(DF,1,1,80,24);
  118. Control(DF);
  119. IF PromptYN(' Print Report ',DF)
  120. THEN
  121. Line := 'Inventory Sorted by Item Code';
  122. NormalTitle(Line);
  123. Handle := OpenReportDevice();
  124. PrintFrame(DF,Handle);
  125. CloseReportDevice(Handle);
  126. END;
  127. CloseDisplayFrame(DF);
  128. DisposeList(InvList);
  129. END TotalInventory;
  130. PROCEDURE ReorderInventory();
  131. VAR
  132. Str : ARRAY[0..20] OF CHAR;
  133. InvList : GenList;
  134. OrderList : GenList;
  135. LineCnt : CARDINAL;
  136. J,K : CARDINAL;
  137. Line : ARRAY[0..80] OF CHAR;
  138. DF : DisplayFrame;
  139. Handle : CARDINAL;
  140. FieldRec : InputFieldRecord;
  141. Inventory : InvtryRec;
  142. Code : CARDINAL;
  143. BEGIN
  144. Str := '';
  145. PromptStr('Enter Inventory Code (or partial Code)',Str);
  146. MakeKey(Str);
  147. OpenInvtryDBF(TRUE);
  148. FindAll(InvcodeIdx,Str,BeginsWith,InvList);
  149. ReadAllRecs(InvtryDBF,ReadInvRec,InvList);
  150. InitDisplayFrame(DF,VWindows.CurrentWindow);
  151. AddStrField(DF,2,2,
  152. 'Code Description Units On Hand On Ord Reorder Qnt ',67);
  153. GetFieldRec(DF,1,FieldRec);
  154. FieldRec.typ := DispCode; (* headline = display code *)
  155. PutFieldRec(FieldRec,DF,1);
  156. DF^.headline := 2;
  157. LineCnt := 3;
  158. J := ListLength(InvList);
  159. LOOP
  160. (* FOR J := ListLength(InvList) DOWNTO 1 BY -1 DO *)
  161. IF J = 0
  162. THEN EXIT;
  163. END;
  164. GetElmt(InvList,J,Inventory,Code); (* Only take those <= reorder level*)
  165. DEC(J);
  166. IF (Inventory.STOCKED) AND (TRUNC(Inventory.ONHAND) <= Inventory.REORDER)
  167. THEN
  168. Fill(ADR(Line),SIZE(Line),' ');
  169. Line[78] := 0C;
  170. OverWrite(Inventory.INVCODE,Line,3);
  171. OverWrite(Inventory.DESC,Line,11);
  172. OverWrite(Inventory.UNITS,Line,44);
  173. RealToStr(Inventory.ONHAND,2,8,Str);
  174. OverWrite(Str,Line,52);
  175. OverWrite(Inventory.ONORDER,Line,63);
  176. RealToStr(Inventory.REORDAMT,2,8,Str);
  177. OverWrite(Str,Line,70);
  178. AddMenuItem(DF,2,LineCnt,Line,78,0,Inventory.INVCODE);
  179. INC(LineCnt);
  180. (* ELSE
  181. ListDelete(InvList,J,1); *) (* didn't need to reorder *)
  182. END; (* end if need to reorder *)
  183. END; (* end of loop *)
  184. SelectFromScreen(DF);
  185. GetSelected(OrderList,DF);
  186. CloseDisplayFrame(DF);
  187. InitDisplayFrame(DF,VWindows.CurrentWindow);
  188. AddStrField(DF,2,2,
  189. ' Code Units Description Quantity ',67);
  190. GetFieldRec(DF,1,FieldRec);
  191. FieldRec.typ := DispCode; (* headline = display code *)
  192. PutFieldRec(FieldRec,DF,1);
  193. DF^.headline := 2;
  194. LineCnt := 3;
  195. (* go through the order list and find the item in the invlist *)
  196. (* make printable - and create string fields *)
  197. J := ListLength(OrderList);
  198. LOOP
  199. IF J = 0
  200. THEN EXIT;
  201. END;
  202. GetElmt(OrderList,J,Inventory.INVCODE,Code);
  203. DEC(J);
  204. IF FindInvtryByInvcode(Inventory.INVCODE)
  205. THEN
  206. Inventory.ONORDER := 'Y';
  207. MoveInvtryToDBF(Inventory);
  208. WriteDBRec(InvtryDBF);
  209. END;
  210. Fill(ADR(Line),SIZE(Line),' ');
  211. Line[77] := 0C;
  212. OverWrite(Inventory.INVCODE,Line,3);
  213. OverWrite(Inventory.UNITS,Line,11);
  214. OverWrite(Inventory.DESC,Line,20);
  215. RealToStr(Inventory.REORDAMT,2,8,Str);
  216. OverWrite(Str,Line,63);
  217. AddStrField(DF,2,LineCnt,Line,78);
  218. INC(LineCnt);
  219. END; (* end for J *)
  220. ShowDisplayFrame(DF,1,1,80,24);
  221. Control(DF);
  222. IF PromptYN(' Print Report ',DF)
  223. THEN
  224. Line := 'Purchase Order Number ';
  225. MakeSeqNbr('POSEQ',Config.PurchOrdPre,Str);
  226. Append(Line,Str);
  227. NormalTitle(Line);
  228. Handle := OpenReportDevice();
  229. PrintFrame(DF,Handle);
  230. CloseReportDevice(Handle);
  231. END;
  232. CloseDisplayFrame(DF);
  233. CloseInvtryDBF();
  234. DisposeList(InvList);
  235. DisposeList(OrderList);
  236. END ReorderInventory;
  237. END IvyReports.
  238.