Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

1 rad
32 KiB

  1. {"ast":null,"code":"import _regeneratorRuntime from \"/Users/michielcarman/Server Code/Repository/clients-rpm-kit-manager/code/RPM.KitManager/RPM.KitManager.Web/ClientApp/node_modules/babel-preset-react-app/node_modules/@babel/runtime/regenerator\";\nimport _asyncToGenerator from \"/Users/michielcarman/Server Code/Repository/clients-rpm-kit-manager/code/RPM.KitManager/RPM.KitManager.Web/ClientApp/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/asyncToGenerator\";\nimport _objectDestructuringEmpty from \"/Users/michielcarman/Server Code/Repository/clients-rpm-kit-manager/code/RPM.KitManager/RPM.KitManager.Web/ClientApp/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/objectDestructuringEmpty\";\nimport _classCallCheck from \"/Users/michielcarman/Server Code/Repository/clients-rpm-kit-manager/code/RPM.KitManager/RPM.KitManager.Web/ClientApp/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"/Users/michielcarman/Server Code/Repository/clients-rpm-kit-manager/code/RPM.KitManager/RPM.KitManager.Web/ClientApp/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/createClass\";\nimport _possibleConstructorReturn from \"/Users/michielcarman/Server Code/Repository/clients-rpm-kit-manager/code/RPM.KitManager/RPM.KitManager.Web/ClientApp/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn\";\nimport _getPrototypeOf from \"/Users/michielcarman/Server Code/Repository/clients-rpm-kit-manager/code/RPM.KitManager/RPM.KitManager.Web/ClientApp/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/getPrototypeOf\";\nimport _inherits from \"/Users/michielcarman/Server Code/Repository/clients-rpm-kit-manager/code/RPM.KitManager/RPM.KitManager.Web/ClientApp/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/inherits\";\nvar _jsxFileName = \"/Users/michielcarman/Server Code/Repository/clients-rpm-kit-manager/code/RPM.KitManager/RPM.KitManager.Web/ClientApp/src/shared/components/PDFGeneratorButtons/PDFButtonBuildList.tsx\";\n//http://raw.githack.com/MrRio/jsPDF/master/ to check out the documentation.\nimport React from 'react';\nimport jsPDF from 'jspdf';\nimport axios from 'axios';\n\nvar PDFButtonBuildList = /*#__PURE__*/function (_React$Component) {\n _inherits(PDFButtonBuildList, _React$Component);\n\n function PDFButtonBuildList(props) {\n var _this;\n\n _classCallCheck(this, PDFButtonBuildList);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(PDFButtonBuildList).call(this, props));\n\n _this.createPDF = function () {\n var _this$props = _this.props,\n dsId = _this$props.dsId,\n pn = _this$props.pn,\n rev = _this$props.rev; // Inputs from User\n // const part: any = prompt('What is the Part Number?', `${this.props.pn}`);\n // const PartNumberEntered = parseInt(part);\n // if (PartNumberEntered == null) {\n // return null;\n // }\n //console.log(PartNumberEntered)\n\n var setOfBuildListInfo = _this.state.BuildLists;\n console.log('BuildLists: ', _this.state.BuildLists);\n console.log('BuildListInfo: ', setOfBuildListInfo);\n\n if (setOfBuildListInfo == null || setOfBuildListInfo == undefined || setOfBuildListInfo.length == 0) {\n alert('No Data Found');\n return;\n } // var convertPDFDateToDate = setOfBuildListInfo[0].headerApproveDate.convertPDFDateToDate = function (parmPDFDate) {\n // var year = parseInt(parmPDFDate.substr(2, 4), 10);\n // var month = parseInt(parmPDFDate.substr(6, 2), 10) - 1;\n // var date = parseInt(parmPDFDate.substr(8, 2), 10);\n // var hour = parseInt(parmPDFDate.substr(10, 2), 10);\n // var minutes = parseInt(parmPDFDate.substr(12, 2), 10);\n // var seconds = parseInt(parmPDFDate.substr(14, 2), 10);\n // // var timeZoneHour = parseInt(parmPDFDate.substr(16, 2), 10);\n // // var timeZoneMinutes = parseInt(parmPDFDate.substr(20, 2), 10);\n // var resultingDate = new Date(year, month, date, hour, minutes, seconds, 0);\n // return resultingDate;\n // };\n // const { Header } = this.props;\n // const {\n // headerPartNumber,\n // headerRevisionLevel,\n // headerApproveDate,\n // headerWorkInstruction,\n // headerStatusID,\n // headerFACRequired,\n // headerFACCompleted,\n // bodyPartNumber,\n // bodyQty,\n // bodyPartCode,\n // bodyDescription,\n // footerNotes\n // } = Header;\n // Document Defaults\n\n\n var doc = new jsPDF({\n unit: 'in',\n orientation: 'portrait',\n format: 'letter'\n });\n var margins = {\n left: 1,\n right: 1.25,\n top: 1,\n bottom: 1.25\n };\n var page = {\n height: 11,\n width: 8.5\n }; //SETUP OF HEADER/TITLE INFO\n\n var title = {\n value: \"Build List\",\n xPos: 1,\n yPos: 1.25\n };\n\n function monthConversion(_ref) {\n _objectDestructuringEmpty(_ref);\n\n switch (month) {\n case '01':\n return mon = 'JAN';\n\n case '02':\n return mon = 'FEB';\n\n case '03':\n return mon = 'MAR';\n\n case '04':\n return mon = 'APR';\n\n case '05':\n return mon = 'MAY';\n\n case '06':\n return mon = 'JUN';\n\n case '07':\n return mon = 'JUL';\n\n case '08':\n return mon = 'AUG';\n\n case '09':\n return mon = 'SEP';\n\n case '10':\n return mon = 'OCT';\n\n case '11':\n return mon = 'NOV';\n\n case '12':\n return mon = 'DEC';\n\n default:\n return null;\n }\n }\n\n if (setOfBuildListInfo[0].headerApproveDate != null) {\n var approveDate = setOfBuildListInfo[0].headerApproveDate;\n var year = approveDate.substr(0, 4);\n var month = approveDate.substr(5, 2);\n var date = approveDate.substr(8, 2);\n var mon = '';\n }\n\n var formattedApprovedDate = date + \"-\" + monthConversion(month) + \"-\" + year; //PRINTING HEADER/TITLE INFO\n //doc.setFontSize(18)\n\n doc.setFontSize(25);\n doc.setFont(\"times\");\n doc.setTextColor(255, 128, 0); //Set font color to orange\n\n doc.text(title.value, title.xPos, title.yPos);\n doc.setTextColor(0, 0, 0); //Set font color to black\n\n doc.setFontSize(14);\n doc.setFont(\"times\");\n\n if (setOfBuildListInfo[0].headerPartNumber != null) {\n doc.text(\"Part Number: \".concat(setOfBuildListInfo[0].headerPartNumber), 1, 1.75);\n }\n\n if (setOfBuildListInfo[0].headerRevisionLevel) {\n doc.text(\"ERN: \".concat(setOfBuildListInfo[0].headerRevisionLevel), 3.5, 1.75);\n }\n\n if (formattedApprovedDate != null) {\n doc.text(\"Date Approved: \".concat(formattedApprovedDate), margins.left + 4, 1.75);\n }\n\n if (setOfBuildListInfo[0].headerWorkInstruction != null) {\n doc.text(\"Work Instruction: \".concat(setOfBuildListInfo[0].headerWorkInstruction), margins.left + 4, 2);\n }\n\n var tableHeader = ['Part #', 'Qty', 'Part Code', 'Description'];\n var currentPage = 1;\n var totalPages = 1;\n doc.text(tableHeader[0], 1, 2.25);\n doc.text(tableHeader[1], 2, 2.25);\n doc.text(tableHeader[2], 2.5, 2.25);\n doc.text(tableHeader[3], 3.7, 2.25);\n doc.setFontSize(10);\n var tableStart = {\n xPos: 1,\n yPos: 2.5\n };\n\n for (var i = 0; i < setOfBuildListInfo.length; i++) {\n if (setOfBuildListInfo[i].bodyPartNumber != null) {\n doc.text(\"\".concat(setOfBuildListInfo[i].bodyPartNumber), 1, tableStart.yPos);\n }\n\n if (setOfBuildListInfo[i].bodyQty != null) {\n doc.text(\"\".concat(setOfBuildListInfo[i].bodyQty), 2, tableStart.yPos);\n }\n\n if (setOfBuildListInfo[i].bodyPartCode != null) {\n doc.text(\"\".concat(setOfBuildListInfo[i].bodyPartCode), 2.5, tableStart.yPos);\n }\n\n if (setOfBuildListInfo[i].bodyDescription != null) {\n doc.text(\"\".concat(setOfBuildListInfo[i].bodyDescription), 3.7, tableStart.yPos);\n } //doc.text(tableHeader[3], 4, 2.25)\n\n\n tableStart.yPos = tableStart.yPos + 0.2;\n }\n\n if (setOfBuildListInfo[0].footerNotes != null) {\n doc.text(doc.splitTextToSize(setOfBuildListInfo[0].footerNotes, 7.0), 1, page.height - 4.25);\n } //Signatory Line \n\n\n var builder = 'Person W/ Longer Than average Name';\n var qty = 8;\n var inpector = 'Initials';\n var inspectionDate = new Date();\n var formattedInspectionDate = \"\".concat(inspectionDate.getMonth(), \"/\").concat(inspectionDate.getDate(), \"/\").concat(inspectionDate.getFullYear());\n var prefooterLine = \"Builder ____________________ Qty _________ Inspector ______________ Date____________\";\n doc.setFontSize(10);\n doc.text(prefooterLine, 1, page.height - margins.bottom - 0.5);\n doc.text('Packer_____', 1, page.height - margins.bottom - 0.25); //Create Footer(s)\n\n var daysOfWeek = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];\n var monthsOfYear = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];\n var printDate = new Date(); //This should always be today's date.\n\n var footer = {\n date: \"\".concat(daysOfWeek[printDate.getDay()], \", \").concat(monthsOfYear[printDate.getMonth()], \" \").concat(printDate.getDate(), \", \").concat(printDate.getFullYear()),\n pageCt: \"Page \".concat(currentPage, \" of \").concat(totalPages)\n }; //Draw Footers : Left (date) + right(pagect)\n\n doc.text(footer.date, 1, page.height - margins.bottom);\n doc.text(footer.pageCt, page.width - margins.right - 1, page.height - margins.bottom);\n var rawDate = new Date();\n var formattedDate = \"\".concat(rawDate.getMonth()).concat(rawDate.getDate()).concat(rawDate.getFullYear());\n doc.save(\"\".concat(setOfBuildListInfo[0].headerPartNumber, \"R\").concat(setOfBuildListInfo[0].headerRevisionLevel, \"_BuildList.pdf\"));\n };\n\n _this.rand6digitNumber = function () {\n return Math.floor(Math.random() * 1000000);\n };\n\n _this.state = {\n BuildLists: null,\n PartNumberEntered: null\n };\n return _this;\n }\n\n _createClass(PDFButtonBuildList, [{\n key: \"componentDidMount\",\n value: function () {\n var _componentDidMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {\n var _this2 = this;\n\n var _this$props2, dsId, pn, rev, BuildLists;\n\n return _regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n if (!(this.props.dsId === 'new')) {\n _context.next = 2;\n break;\n }\n\n return _context.abrupt(\"return\");\n\n case 2:\n // skip xhr's if we're working on a new spec (they won't exist anyway) \n _this$props2 = this.props, dsId = _this$props2.dsId, pn = _this$props2.pn, rev = _this$props2.rev;\n console.log('Prompt Entered:', this.state.PartNumberEntered); // console.log(dsId)\n // console.log(pn)\n // console.log(rev)\n\n _context.next = 6;\n return axios.get(\"/api/designspec/buildlist/\".concat(dsId, \"/\").concat(pn, \"/\").concat(rev)).then(function (res) {\n BuildLists = res.data.data.records ? res.data.data.records : \"\";\n\n _this2.setState({\n BuildLists: res.data.data.records ? res.data.data.records : \"\"\n });\n }).catch(function (err) {\n return console.error(err);\n });\n\n case 6:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, this);\n }));\n\n function componentDidMount() {\n return _componentDidMount.apply(this, arguments);\n }\n\n return componentDidMount;\n }()\n }, {\n key: \"render\",\n value: function render() {\n return /*#__PURE__*/React.createElement(\"div\", {\n onClick: this.createPDF,\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 260,\n columnNumber: 13\n }\n }, this.props.text);\n }\n }]);\n\n return PDFButtonBuildList;\n}(React.Component);\n\nexport default PDFButtonBuildList;","map":{"version":3,"sources":["/Users/michielcarman/Server Code/Repository/clients-rpm-kit-manager/code/RPM.KitManager/RPM.KitManager.Web/ClientApp/src/shared/components/PDFGeneratorButtons/PDFButtonBuildList.tsx"],"names":["React","jsPDF","axios","PDFButtonBuildList","props","createPDF","dsId","pn","rev","setOfBuildListInfo","state","BuildLists","console","log","undefined","length","alert","doc","unit","orientation","format","margins","left","right","top","bottom","page","height","width","title","value","xPos","yPos","monthConversion","month","mon","headerApproveDate","approveDate","year","substr","date","formattedApprovedDate","setFontSize","setFont","setTextColor","text","headerPartNumber","headerRevisionLevel","headerWorkInstruction","tableHeader","currentPage","totalPages","tableStart","i","bodyPartNumber","bodyQty","bodyPartCode","bodyDescription","footerNotes","splitTextToSize","builder","qty","inpector","inspectionDate","Date","formattedInspectionDate","getMonth","getDate","getFullYear","prefooterLine","daysOfWeek","monthsOfYear","printDate","footer","getDay","pageCt","rawDate","formattedDate","save","rand6digitNumber","Math","floor","random","PartNumberEntered","get","then","res","data","records","setState","catch","err","error","Component"],"mappings":";;;;;;;;;AAAA;AACA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,KAAP,MAAkB,OAAlB;AACA,OAAOC,KAAP,MAAkB,OAAlB;;IA2BMC,kB;;;AACF,8BAAYC,KAAZ,EAAwB;AAAA;;AAAA;;AACpB,4FAAMA,KAAN;;AADoB,UA4BxBC,SA5BwB,GA4BZ,YAAM;AAAA,wBACY,MAAKD,KADjB;AAAA,UACNE,IADM,eACNA,IADM;AAAA,UACAC,EADA,eACAA,EADA;AAAA,UACIC,GADJ,eACIA,GADJ,EAGd;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,UAAMC,kBAAkB,GAAG,MAAKC,KAAL,CAAWC,UAAtC;AACAC,MAAAA,OAAO,CAACC,GAAR,CAAY,cAAZ,EAA4B,MAAKH,KAAL,CAAWC,UAAvC;AACAC,MAAAA,OAAO,CAACC,GAAR,CAAY,iBAAZ,EAA+BJ,kBAA/B;;AACA,UAAKA,kBAAkB,IAAI,IAAvB,IAAiCA,kBAAkB,IAAIK,SAAvD,IAAsEL,kBAAkB,CAACM,MAAnB,IAA6B,CAAvG,EAA2G;AACvGC,QAAAA,KAAK,CAAC,eAAD,CAAL;AACA;AACH,OAjBa,CAmBd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;;;AACA,UAAIC,GAAG,GAAG,IAAIhB,KAAJ,CAAU;AAChBiB,QAAAA,IAAI,EAAE,IADU;AAEhBC,QAAAA,WAAW,EAAE,UAFG;AAGhBC,QAAAA,MAAM,EAAE;AAHQ,OAAV,CAAV;AA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AAO,CAACC,GAAR,CAAY,iBAAZ,EAA+B,KAAKH,KAAL,CAAWyE,iBAA1C,E,CACA;AACA;AACA;;;uBAGMjF,KAAK,CAACkF,GAAN,qCAAuC9E,IAAvC,cAA+CC,EAA/C,cAAqDC,GAArD,GACD6E,IADC,CACI,UAACC,GAAD,EAAc;AAChB3E,kBAAAA,UAAU,GAAG2E,GAAG,CAACC,IAAJ,CAASA,IAAT,CAAcC,OAAd,GAAwBF,GAAG,CAACC,IAAJ,CAASA,IAAT,CAAcC,OAAtC,GAAgD,EAA7D;;AACA,kBAAA,MAAI,CAACC,QAAL,CAAc;AACV9E,oBAAAA,UAAU,EAAE2E,GAAG,CAACC,IAAJ,CAASA,IAAT,CAAcC,OAAd,GAAwBF,GAAG,CAACC,IAAJ,CAASA,IAAT,CAAcC,OAAtC,GAAgD;AADlD,mBAAd;AAGH,iBANC,EAODE,KAPC,CAOK,UAACC,GAAD;AAAA,yBAAc/E,OAAO,CAACgF,KAAR,CAAcD,GAAd,CAAd;AAAA,iBAPL,C;;;;;;;;;;;;;;;;;;6BAiND;AACL,0BACI;AAAK,QAAA,OAAO,EAAE,KAAKtF,SAAnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SACK,KAAKD,KAAL,CAAWyC,IADhB,CADJ;AAIH;;;;EAxO4B7C,KAAK,CAAC6F,S;;AA4OvC,eAAe1F,kBAAf","sourcesContent":["//http://raw.githack.com/MrRio/jsPDF/master/ to check out the documentation.\nimport React from 'react';\nimport jsPDF from 'jspdf';\nimport axios from 'axios';\n\ninterface PDFBtnProps {\n text: any,\n BuildLists: [],\n PartNumberEntered: number,\n}\n\nexport interface BuildList {\n headerPartNumber: number,\n headerRevisionLevel: number,\n headerApproveDate: Date,\n headerWorkInstruction: string,\n headerStatusID: number,\n headerFACRequired: Boolean,\n headerFACCompleted: Boolean,\n bodyPartNumber: number,\n bodyQty: string,\n bodyPartCode: string,\n bodyDescription: string,\n footerNotes: string,\n}\n\nexport interface PackListReportFormState extends BuildList {\n PackLists: BuildList[],\n}\n\nclass PDFButtonBuildList extends React.Component<any, any>{\n constructor(props: any) {\n super(props)\n this.state = {\n BuildLists: null,\n PartNumberEntered: null,\n }\n }\n\n async componentDidMount() {\n if (this.props.dsId === 'new') return; // skip xhr's if we're working on a new spec (they won't exist anyway) \n const { dsId, pn, rev } = this.props;\n console.log('Prompt Entered:', this.state.PartNumberEntered);\n // console.log(dsId)\n // console.log(pn)\n // console.log(rev)\n let BuildLists: BuildList[];\n\n await axios.get(`/api/designspec/buildlist/${dsId}/${pn}/${rev}`)\n .then((res: any) => {\n BuildLists = res.data.data.records ? res.data.data.records : \"\"\n this.setState({\n BuildLists: res.data.data.records ? res.data.data.records : \"\"\n })\n })\n .catch((err: any) => console.error(err))\n }\n\n\n createPDF = () => {\n const { dsId, pn, rev } = this.props;\n\n // Inputs from User\n // const part: any = prompt('What is the Part Number?', `${this.props.pn}`);\n // const PartNumberEntered = parseInt(part);\n // if (PartNumberEntered == null) {\n // return null;\n // }\n //console.log(PartNumberEntered)\n\n const setOfBuildListInfo = this.state.BuildLists;\n console.log('BuildLists: ', this.state.BuildLists);\n console.log('BuildListInfo: ', setOfBuildListInfo);\n if ((setOfBuildListInfo == null) || (setOfBuildListInfo == undefined) || (setOfBuildListInfo.length == 0)) {\n alert('No Data Found');\n return;\n }\n\n // var convertPDFDateToDate = setOfBuildListInfo[0].headerApproveDate.convertPDFDateToDate = function (parmPDFDate) {\n // var year = parseInt(parmPDFDate.substr(2, 4), 10);\n // var month = parseInt(parmPDFDate.substr(6, 2), 10) - 1;\n // var date = parseInt(parmPDFDate.substr(8, 2), 10);\n // var hour = parseInt(parmPDFDate.substr(10, 2), 10);\n // var minutes = parseInt(parmPDFDate.substr(12, 2), 10);\n // var seconds = parseInt(parmPDFDate.substr(14, 2), 10);\n // // var timeZoneHour = parseInt(parmPDFDate.substr(16, 2), 10);\n // // var timeZoneMinutes = parseInt(parmPDFDate.substr(20, 2), 10);\n // var resultingDate = new Date(year, month, date, hour, minutes, seconds, 0);\n // return resultingDate;\n // };\n\n\n // const { Header } = this.props;\n // const {\n // headerPartNumber,\n // headerRevisionLevel,\n // headerApproveDate,\n // headerWorkInstruction,\n // headerStatusID,\n // headerFACRequired,\n // headerFACCompleted,\n // bodyPartNumber,\n // bodyQty,\n // bodyPartCode,\n // bodyDescription,\n // footerNotes\n // } = Header;\n\n\n // Document Defaults\n var doc = new jsPDF({\n unit: 'in',\n orientation: 'portrait',\n format: 'letter'\n })\n const margins = {\n left: 1,\n right: 1.25,\n top: 1,\n bottom: 1.25\n }\n const page = {\n height: 11,\n width: 8.5\n }\n\n //SETUP OF HEADER/TITLE INFO\n const title = {\n value: \"Build List\",\n xPos: 1,\n yPos: 1.25\n }\n\n function monthConversion({ }) {\n switch (month) {\n case '01': return mon = 'JAN';\n case '02': return mon = 'FEB';\n case '03': return mon = 'MAR';\n case '04': return mon = 'APR';\n case '05': return mon = 'MAY';\n case '06': return mon = 'JUN';\n case '07': return mon = 'JUL';\n case '08': return mon = 'AUG';\n case '09': return mon = 'SEP';\n case '10': return mon = 'OCT';\n case '11': return mon = 'NOV';\n case '12': return mon = 'DEC';\n default: return null;\n }\n }\n\n if (setOfBuildListInfo[0].headerApproveDate != null) {\n const approveDate = setOfBuildListInfo[0].headerApproveDate\n var year = approveDate.substr(0, 4);\n var month = approveDate.substr(5, 2);\n var date = approveDate.substr(8, 2);\n var mon = '';\n }\n\n const formattedApprovedDate = date + `-` + monthConversion(month) + `-` + year;\n\n //PRINTING HEADER/TITLE INFO\n //doc.setFontSize(18)\n doc.setFontSize(25)\n doc.setFont(\"times\")\n doc.setTextColor(255, 128, 0) //Set font color to orange\n doc.text(title.value, title.xPos, title.yPos)\n doc.setTextColor(0, 0, 0); //Set font color to black\n doc.setFontSize(14)\n doc.setFont(\"times\")\n\n if (setOfBuildListInfo[0].headerPartNumber != null) {\n doc.text(`Part Number: ${setOfBuildListInfo[0].headerPartNumber}`, 1, 1.75)\n }\n if (setOfBuildListInfo[0].headerRevisionLevel) {\n doc.text(`ERN: ${setOfBuildListInfo[0].headerRevisionLevel}`, 3.5, 1.75)\n }\n if (formattedApprovedDate != null) {\n doc.text(`Date Approved: ${formattedApprovedDate}`, margins.left + 4, 1.75)\n }\n if (setOfBuildListInfo[0].headerWorkInstruction != null) {\n doc.text(`Work Instruction: ${setOfBuildListInfo[0].headerWorkInstruction}`, margins.left + 4, 2)\n }\n\n const tableHeader = ['Part #', 'Qty', 'Part Code', 'Description']\n\n let currentPage = 1;\n let totalPages = 1;\n\n doc.text(tableHeader[0], 1, 2.25)\n doc.text(tableHeader[1], 2, 2.25)\n doc.text(tableHeader[2], 2.5, 2.25)\n doc.text(tableHeader[3], 3.7, 2.25)\n\n doc.setFontSize(10)\n var tableStart = {\n xPos: 1,\n yPos: 2.5\n }\n\n for (var i = 0; i < setOfBuildListInfo.length; i++) {\n if (setOfBuildListInfo[i].bodyPartNumber != null) {\n doc.text(`${setOfBuildListInfo[i].bodyPartNumber}`, 1, tableStart.yPos)\n }\n if (setOfBuildListInfo[i].bodyQty != null) {\n doc.text(`${setOfBuildListInfo[i].bodyQty}`, 2, tableStart.yPos)\n }\n if (setOfBuildListInfo[i].bodyPartCode != null) {\n doc.text(`${setOfBuildListInfo[i].bodyPartCode}`, 2.5, tableStart.yPos)\n }\n if (setOfBuildListInfo[i].bodyDescription != null) {\n doc.text(`${setOfBuildListInfo[i].bodyDescription}`, 3.7, tableStart.yPos)\n }\n //doc.text(tableHeader[3], 4, 2.25)\n tableStart.yPos = tableStart.yPos + 0.2;\n }\n\n if (setOfBuildListInfo[0].footerNotes != null) {\n doc.text(doc.splitTextToSize(setOfBuildListInfo[0].footerNotes, 7.0), 1, page.height - 4.25)\n }\n\n\n //Signatory Line \n const builder = 'Person W/ Longer Than average Name'\n const qty = 8\n const inpector = 'Initials'\n const inspectionDate = new Date()\n const formattedInspectionDate = `${inspectionDate.getMonth()}/${inspectionDate.getDate()}/${inspectionDate.getFullYear()}`\n\n const prefooterLine = `Builder ____________________ Qty _________ Inspector ______________ Date____________`\n doc.setFontSize(10)\n doc.text(prefooterLine, 1, page.height - margins.bottom - 0.5)\n doc.text('Packer_____', 1, page.height - margins.bottom - 0.25)\n\n //Create Footer(s)\n const daysOfWeek = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']\n const monthsOfYear = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\n const printDate = new Date() //This should always be today's date.\n let footer = {\n date: `${daysOfWeek[printDate.getDay()]}, ${monthsOfYear[printDate.getMonth()]} ${printDate.getDate()}, ${printDate.getFullYear()}`,\n pageCt: `Page ${currentPage} of ${totalPages}`\n }\n //Draw Footers : Left (date) + right(pagect)\n doc.text(footer.date, 1, page.height - margins.bottom)\n doc.text(footer.pageCt, page.width - margins.right - 1, page.height - margins.bottom)\n\n\n\n const rawDate = new Date();\n const formattedDate = `${rawDate.getMonth()}${rawDate.getDate()}${rawDate.getFullYear()}`\n doc.save(`${setOfBuildListInfo[0].headerPartNumber}R${setOfBuildListInfo[0].headerRevisionLevel}_BuildList.pdf`)\n }\n\n rand6digitNumber = () => {\n return Math.floor(Math.random() * 1000000)\n }\n\n render() {\n return (\n <div onClick={this.createPDF}>\n {this.props.text}\n </div>);\n }\n\n}\n\nexport default PDFButtonBuildList "]},"metadata":{},"sourceType":"module"}