|
- {"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 _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/PDFButtonApprovalList.tsx\";\nimport React from 'react';\nimport jsPDF from 'jspdf';\nimport axios from 'axios';\n\nvar PDFButtonApprovalList = /*#__PURE__*/function (_React$Component) {\n _inherits(PDFButtonApprovalList, _React$Component);\n\n function PDFButtonApprovalList(props) {\n var _this;\n\n _classCallCheck(this, PDFButtonApprovalList);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(PDFButtonApprovalList).call(this, props));\n\n _this.createPDF = function () {\n // console.log('Approval List Printing')\n // console.log(this.props)\n var _this$props = _this.props,\n dsId = _this$props.dsId,\n pn = _this$props.pn,\n rev = _this$props.rev; // const part: any = prompt('What is the Part Number?', `${this.props.pn}`);\n // const partNumberEntered: number = parseInt(part);\n // if (part === null) {\n // return null;\n // }\n\n var setOfApprovalListInfo = _this.state.ApprovalLists;\n console.log('ApprovalLists: ', _this.state.ApprovalLists);\n console.log('ApprovalListInfo: ', setOfApprovalListInfo);\n\n if (setOfApprovalListInfo == null || setOfApprovalListInfo == undefined || setOfApprovalListInfo.length == 0) {\n alert('No Data Found');\n return;\n } //const { Header } = this.props;\n // const {\n // headerPartNumber,\n // headerDescription,\n // headerRevisionLevel,\n // headerWorkInstruction,\n // headerReasonForChange,\n // bodyPartNumber,\n // //bodyStatusName,\n // bodyOld,\n // bodyNew,\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 + 1 / 8,\n top: 1,\n bottom: 1.25\n };\n var page = {\n height: 11,\n width: 8.5\n };\n doc.setLineWidth(.01); // doc.line( //Top Line\n // margins.left, \n // margins.top, \n // page.width - margins.right, \n // margins.top\n // )\n // doc.line( //bottom Line\n // margins.left, \n // page.height - margins.bottom, \n // page.width - margins.right, \n // page.height - margins.bottom\n // )\n // doc.line( //left Line\n // margins.left, \n // margins.top, \n // margins.left, \n // page.height - margins.bottom\n // )\n // doc.line( //right Line\n // page.width - margins.right, \n // margins.top, \n // page.width - margins.right, \n // page.height - margins.bottom\n // )\n //PAGE 1\n //const partNumber = '300753'\n //const ern = '1'\n //const description = 'Quick fix for Altorfer ASPS2306'\n //const workInstruction = '10186'\n //Heading \n\n doc.setFontSize(28);\n doc.setFont(\"times\");\n doc.setTextColor(255, 128, 0); //Set font color to orange\n\n doc.text('Approval List', margins.left, 1 + 1 / 4);\n doc.setTextColor(0, 0, 0); //Set font color to black\n\n doc.setFontSize(12);\n doc.setFont(\"times\");\n\n if (setOfApprovalListInfo[0].headerPartNumber != null) {\n doc.text(\"Part Number: \".concat(setOfApprovalListInfo[0].headerPartNumber), margins.left, 1 + 1 / 4 + 3 / 8);\n }\n\n if (setOfApprovalListInfo[0].headerDescription != null) {\n doc.text(\"Description: \".concat(setOfApprovalListInfo[0].headerDescription), margins.left + 2, 1 + 1 / 4 + 3 / 8);\n }\n\n if (setOfApprovalListInfo[0].headerRevisionLevel != null) {\n doc.text(\"ERN: \".concat(setOfApprovalListInfo[0].headerRevisionLevel), margins.left, 1 + 3 / 8 + 1 / 4 + 1 / 4);\n }\n\n if (setOfApprovalListInfo[0].headerWorkInstruction != null) {\n doc.text(\"Work Instruction: \".concat(setOfApprovalListInfo[0].headerWorkInstruction), margins.left + 2, 1 + 3 / 8 + 1 / 4 + 1 / 4);\n }\n\n if (setOfApprovalListInfo[0].headerReasonForChange != null) {\n var reasonForChangeText = setOfApprovalListInfo[0].headerReasonForChange;\n var lines = doc.splitTextToSize(reasonForChangeText, 7.5);\n doc.text('Reason For Change: ', margins.left, 1 + 3 / 8 + 1 / 4 + 1 / 4 + 1 / 4);\n doc.text(lines, margins.left, 1 + 3 / 8 + 1 / 4 + 1 / 4 + 1 / 4 + 1 / 4);\n } //TABLE\n\n\n doc.setTextColor(255, 128, 0); //Set font color to orange\n\n doc.text('Part:', margins.left, 3);\n doc.text('Status:', margins.left + .75, 3);\n doc.text('Old Qty:', margins.left + 1.5, 3);\n doc.text('New Qty:', margins.left + 2.25, 3);\n doc.text('Description:', margins.left + 3, 3);\n doc.setTextColor(0, 0, 0); //Set font color to black\n\n var tableStart = {\n xPos: 1,\n yPos: 3.25\n };\n\n for (var i = 0; i < setOfApprovalListInfo.length; i++) {\n doc.text(\"\".concat(setOfApprovalListInfo[i].bodyPartNumber), margins.left, tableStart.yPos);\n\n if (\"\".concat(setOfApprovalListInfo[i].bodyStatus) == '1' || \"\".concat(setOfApprovalListInfo[i].bodyStatus) == '3') {\n doc.text(\"\\u2713\", margins.left + .75, tableStart.yPos); //Include mark if Status is Active or Approved\n } else {\n doc.text(\" \", margins.left + .75, tableStart.yPos); //Leave blank if not Active or Approved\n } //doc.text(`${setOfApprovalListInfo[i].bodyStatus}`, margins.left + .75, tableStart.yPos)\n\n\n if (setOfApprovalListInfo[i].bodyOld != null) {\n doc.text(\"\".concat(setOfApprovalListInfo[i].bodyOld), margins.left + 1.5, tableStart.yPos);\n }\n\n if (setOfApprovalListInfo[i].bodyNew != null) {\n doc.text(\"\".concat(setOfApprovalListInfo[i].bodyNew), margins.left + 2.25, tableStart.yPos);\n }\n\n if (setOfApprovalListInfo[i].bodyDescription != null) {\n doc.text(\"\".concat(setOfApprovalListInfo[i].bodyDescription), margins.left + 3, tableStart.yPos);\n } //doc.text(tableHeader[3], 4, 2.25)\n\n\n tableStart.yPos = tableStart.yPos + 0.2;\n\n if (i == 20) {\n doc.addPage();\n doc.setPage(2);\n tableStart.yPos = 3.25;\n } //Also moves the focus to the next page \n\n } //Additional Details Section\n //\n\n\n if (setOfApprovalListInfo[0].footerNotes != null) {\n var notes = setOfApprovalListInfo[0].footerNotes;\n var footer = doc.splitTextToSize(notes, 7.0); // doc.text(footer, 1, 3.75)\n\n doc.text(footer, 1, page.height - 4.25);\n } //Create Footer(s)\n\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 today = new Date();\n var formattedDate = \"\".concat(daysOfWeek[today.getDay()], \", \").concat(monthsOfYear[today.getMonth()], \" \").concat(today.getDate(), \", \").concat(today.getFullYear());\n var totalPages = doc.internal.getNumberOfPages();\n\n for (var pg = 1; pg <= totalPages; pg++) {\n //Move to specified Page.\n doc.setPage(pg); //Create the relevant footer text.\n\n doc.text(formattedDate, 1, page.height - margins.bottom);\n doc.text(\"Page \".concat(pg, \" of \").concat(totalPages), page.width - margins.right - 1, page.height - margins.bottom);\n }\n\n doc.save(\"\".concat(setOfApprovalListInfo[0].headerPartNumber, \"R\").concat(setOfApprovalListInfo[0].headerRevisionLevel, \"_ApprovalsList.pdf\"));\n };\n\n _this.state = {\n ApprovalLists: null\n };\n return _this;\n }\n\n _createClass(PDFButtonApprovalList, [{\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, ApprovalLists;\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 _context.next = 5;\n return axios.get(\"/api/designspec/approvalslist/\".concat(dsId, \"/\").concat(pn, \"/\").concat(rev)).then(function (res) {\n ApprovalLists = res.data.items.records ? res.data.items.records : \"\";\n\n _this2.setState({\n ApprovalLists: res.data.items.records ? res.data.items.records : \"\"\n });\n }).catch(function (err) {\n return console.error(err);\n });\n\n case 5:\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 }() //const PDFButtonApprovalList = (props: any) => {\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: 238,\n columnNumber: 13\n }\n }, this.props.text);\n }\n }]);\n\n return PDFButtonApprovalList;\n}(React.Component);\n\nexport default PDFButtonApprovalList;","map":{"version":3,"sources":["/Users/michielcarman/Server Code/Repository/clients-rpm-kit-manager/code/RPM.KitManager/RPM.KitManager.Web/ClientApp/src/shared/components/PDFGeneratorButtons/PDFButtonApprovalList.tsx"],"names":["React","jsPDF","axios","PDFButtonApprovalList","props","createPDF","dsId","pn","rev","setOfApprovalListInfo","state","ApprovalLists","console","log","undefined","length","alert","doc","unit","orientation","format","margins","left","right","top","bottom","page","height","width","setLineWidth","setFontSize","setFont","setTextColor","text","headerPartNumber","headerDescription","headerRevisionLevel","headerWorkInstruction","headerReasonForChange","reasonForChangeText","lines","splitTextToSize","tableStart","xPos","yPos","i","bodyPartNumber","bodyStatus","bodyOld","bodyNew","bodyDescription","addPage","setPage","footerNotes","notes","footer","daysOfWeek","monthsOfYear","today","Date","formattedDate","getDay","getMonth","getDate","getFullYear","totalPages","internal","getNumberOfPages","pg","save","get","then","res","data","items","records","setState","catch","err","error","Component"],"mappings":";;;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,KAAP,MAAkB,OAAlB;AACA,OAAOC,KAAP,MAAkB,OAAlB;;IA0BMC,qB;;;AACF,iCAAYC,KAAZ,EAAwB;AAAA;;AAAA;;AACpB,+FAAMA,KAAN;;AADoB,UAwBxBC,SAxBwB,GAwBZ,YAAM;AACd;AACA;AAFc,wBAGY,MAAKD,KAHjB;AAAA,UAGNE,IAHM,eAGNA,IAHM;AAAA,UAGAC,EAHA,eAGAA,EAHA;AAAA,UAGIC,GAHJ,eAGIA,GAHJ,EAKd;AACA;AACA;AACA;AACA;;AAGA,UAAMC,qBAAqB,GAAG,MAAKC,KAAL,CAAWC,aAAzC;AACAC,MAAAA,OAAO,CAACC,GAAR,CAAY,iBAAZ,EAA+B,MAAKH,KAAL,CAAWC,aAA1C;AACAC,MAAAA,OAAO,CAACC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I,EAAMC,E,gBAAAA,E,EAAIC,G,gBAAAA,G;;uBAIZN,KAAK,CAACoE,GAAN,yCAA2ChE,IAA3C,cAAmDC,EAAnD,cAAyDC,GAAzD,GACD+D,IADC,CACI,UAACC,GAAD,EAAc;AAChB7D,kBAAAA,aAAa,GAAG6D,GAAG,CAACC,IAAJ,CAASC,KAAT,CAAeC,OAAf,GAAyBH,GAAG,CAACC,IAAJ,CAASC,KAAT,CAAeC,OAAxC,GAAkD,EAAlE;;AACA,kBAAA,MAAI,CAACC,QAAL,CAAc;AACVjE,oBAAAA,aAAa,EAAE6D,GAAG,CAACC,IAAJ,CAASC,KAAT,CAAeC,OAAf,GAAyBH,GAAG,CAACC,IAAJ,CAASC,KAAT,CAAeC,OAAxC,GAAkD;AADvD,mBAAd;AAGH,iBANC,EAODE,KAPC,CAOK,UAACC,GAAD;AAAA,yBAAclE,OAAO,CAACmE,KAAR,CAAcD,GAAd,CAAd;AAAA,iBAPL,C;;;;;;;;;;;;;;;QAUV;;;;6BAuLS;AACL,0BACI;AAAK,QAAA,OAAO,EAAE,KAAKzE,SAAnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SACK,KAAKD,KAAL,CAAW6B,IADhB,CADJ;AAIH;;;;EApN+BjC,KAAK,CAACgF,S;;AAwN1C,eAAe7E,qBAAf","sourcesContent":["import React from 'react';\nimport jsPDF from 'jspdf';\nimport axios from 'axios';\n\ninterface PDFBtnProps {\n text: any\n ApprovalLists: []\n}\n\nexport interface ApprovalList {\n headerPartNumber: number,\n headerDescription: string,\n headerRevisionLevel: number,\n headerWorkInstruction: string,\n headerReasonForChange: string,\n bodyPartNumber: number,\n bodyStatus: string,\n bodyOld: string,\n bodyNew: string,\n bodyPartCode: string,\n bodyDescription: string,\n footerNotes: string,\n}\n\nexport interface PackListReportFormState extends ApprovalList {\n ApprovalLists: ApprovalList[],\n}\n\nclass PDFButtonApprovalList extends React.Component<any, any> {\n constructor(props: any) {\n super(props)\n this.state = {\n ApprovalLists: 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\n let ApprovalLists: ApprovalList[];\n\n await axios.get(`/api/designspec/approvalslist/${dsId}/${pn}/${rev}`)\n .then((res: any) => {\n ApprovalLists = res.data.items.records ? res.data.items.records : \"\"\n this.setState({\n ApprovalLists: res.data.items.records ? res.data.items.records : \"\"\n })\n })\n .catch((err: any) => console.error(err))\n }\n\n //const PDFButtonApprovalList = (props: any) => {\n createPDF = () => {\n // console.log('Approval List Printing')\n // console.log(this.props)\n const { dsId, pn, rev } = this.props;\n\n // const part: any = prompt('What is the Part Number?', `${this.props.pn}`);\n // const partNumberEntered: number = parseInt(part);\n // if (part === null) {\n // return null;\n // }\n\n\n const setOfApprovalListInfo = this.state.ApprovalLists;\n console.log('ApprovalLists: ', this.state.ApprovalLists);\n console.log('ApprovalListInfo: ', setOfApprovalListInfo);\n if ((setOfApprovalListInfo == null) || (setOfApprovalListInfo == undefined) || (setOfApprovalListInfo.length == 0)) {\n alert('No Data Found');\n return;\n }\n\n //const { Header } = this.props;\n // const {\n // headerPartNumber,\n // headerDescription,\n // headerRevisionLevel,\n // headerWorkInstruction,\n // headerReasonForChange,\n // bodyPartNumber,\n // //bodyStatusName,\n // bodyOld,\n // bodyNew,\n // bodyPartCode,\n // bodyDescription,\n // footerNotes,\n // } = Header;\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 + (1 / 8),\n top: 1,\n bottom: 1.25\n }\n const page = {\n height: 11,\n width: 8.5\n }\n\n doc.setLineWidth(.01)\n // doc.line( //Top Line\n // margins.left, \n // margins.top, \n // page.width - margins.right, \n // margins.top\n // )\n // doc.line( //bottom Line\n // margins.left, \n // page.height - margins.bottom, \n // page.width - margins.right, \n // page.height - margins.bottom\n // )\n // doc.line( //left Line\n // margins.left, \n // margins.top, \n // margins.left, \n // page.height - margins.bottom\n // )\n // doc.line( //right Line\n // page.width - margins.right, \n // margins.top, \n // page.width - margins.right, \n // page.height - margins.bottom\n // )\n\n //PAGE 1\n //const partNumber = '300753'\n //const ern = '1'\n //const description = 'Quick fix for Altorfer ASPS2306'\n //const workInstruction = '10186'\n\n\n //Heading \n doc.setFontSize(28)\n doc.setFont(\"times\")\n doc.setTextColor(255, 128, 0) //Set font color to orange\n doc.text('Approval List', margins.left, 1 + (1 / 4))\n doc.setTextColor(0, 0, 0); //Set font color to black\n\n doc.setFontSize(12)\n doc.setFont(\"times\")\n if (setOfApprovalListInfo[0].headerPartNumber != null) {\n doc.text(`Part Number: ${setOfApprovalListInfo[0].headerPartNumber}`, margins.left, 1 + (1 / 4) + (3 / 8))\n }\n if (setOfApprovalListInfo[0].headerDescription != null) {\n doc.text(`Description: ${setOfApprovalListInfo[0].headerDescription}`, margins.left + 2, 1 + (1 / 4) + (3 / 8))\n }\n if (setOfApprovalListInfo[0].headerRevisionLevel != null) {\n doc.text(`ERN: ${setOfApprovalListInfo[0].headerRevisionLevel}`, margins.left, 1 + (3 / 8) + (1 / 4) + (1 / 4))\n }\n if (setOfApprovalListInfo[0].headerWorkInstruction != null) {\n doc.text(`Work Instruction: ${setOfApprovalListInfo[0].headerWorkInstruction}`, margins.left + 2, 1 + (3 / 8) + (1 / 4) + (1 / 4))\n }\n\n if (setOfApprovalListInfo[0].headerReasonForChange != null) {\n var reasonForChangeText = setOfApprovalListInfo[0].headerReasonForChange;\n var lines = doc.splitTextToSize(reasonForChangeText, 7.5);\n doc.text('Reason For Change: ', margins.left, 1 + (3 / 8) + (1 / 4) + (1 / 4) + (1 / 4))\n doc.text(lines, margins.left, 1 + (3 / 8) + (1 / 4) + (1 / 4) + (1 / 4) + (1 / 4))\n }\n\n //TABLE\n doc.setTextColor(255, 128, 0) //Set font color to orange\n doc.text('Part:', margins.left, 3)\n doc.text('Status:', margins.left + .75, 3)\n doc.text('Old Qty:', margins.left + 1.5, 3)\n doc.text('New Qty:', margins.left + 2.25, 3)\n doc.text('Description:', margins.left + 3, 3)\n doc.setTextColor(0, 0, 0); //Set font color to black\n\n var tableStart = {\n xPos: 1,\n yPos: 3.25\n }\n\n for (var i = 0; i < setOfApprovalListInfo.length; i++) {\n doc.text(`${setOfApprovalListInfo[i].bodyPartNumber}`, margins.left, tableStart.yPos)\n if (`${setOfApprovalListInfo[i].bodyStatus}` == '1' || `${setOfApprovalListInfo[i].bodyStatus}` == '3') {\n doc.text('\\u2713', margins.left + .75, tableStart.yPos) //Include mark if Status is Active or Approved\n }\n else {\n doc.text(` `, margins.left + .75, tableStart.yPos) //Leave blank if not Active or Approved\n }\n //doc.text(`${setOfApprovalListInfo[i].bodyStatus}`, margins.left + .75, tableStart.yPos)\n if (setOfApprovalListInfo[i].bodyOld != null) {\n doc.text(`${setOfApprovalListInfo[i].bodyOld}`, margins.left + 1.5, tableStart.yPos)\n }\n if (setOfApprovalListInfo[i].bodyNew != null) {\n doc.text(`${setOfApprovalListInfo[i].bodyNew}`, margins.left + 2.25, tableStart.yPos)\n }\n if (setOfApprovalListInfo[i].bodyDescription != null) {\n doc.text(`${setOfApprovalListInfo[i].bodyDescription}`, margins.left + 3, tableStart.yPos)\n }\n //doc.text(tableHeader[3], 4, 2.25)\n tableStart.yPos = tableStart.yPos + 0.2;\n if (i == 20) {\n doc.addPage();\n doc.setPage(2);\n tableStart.yPos = 3.25;\n } //Also moves the focus to the next page \n }\n\n //Additional Details Section\n //\n if (setOfApprovalListInfo[0].footerNotes != null) {\n var notes = setOfApprovalListInfo[0].footerNotes;\n var footer = doc.splitTextToSize(notes, 7.0);\n // doc.text(footer, 1, 3.75)\n doc.text(footer, 1, page.height - 4.25)\n }\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 today = new Date()\n let formattedDate = `${daysOfWeek[today.getDay()]}, ${monthsOfYear[today.getMonth()]} ${today.getDate()}, ${today.getFullYear()}`\n let totalPages = doc.internal.getNumberOfPages()\n for (let pg = 1; pg <= totalPages; pg++) {\n //Move to specified Page.\n doc.setPage(pg)\n //Create the relevant footer text.\n doc.text(formattedDate, 1, page.height - margins.bottom)\n doc.text(`Page ${pg} of ${totalPages}`, page.width - margins.right - 1, page.height - margins.bottom)\n }\n\n doc.save(`${setOfApprovalListInfo[0].headerPartNumber}R${setOfApprovalListInfo[0].headerRevisionLevel}_ApprovalsList.pdf`)\n }\n\n render() {\n return (\n <div onClick={this.createPDF}>\n {this.props.text}\n </div>);\n }\n\n}\n\nexport default PDFButtonApprovalList"]},"metadata":{},"sourceType":"module"}
|