Pdf builder for invoices
This commit is contained in:
1 parent
5416bdb840
commit
7228bb2922
6 files changed
+104
-6
No files matched your search
Vendored
+1
-1
@@ -3099,7 +3099,7 @@ var ModuleBase = /*#__PURE__*/function () {
|
||||
}
|
||||
}
|
||||
}catch(e){
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
*/
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"sources":["node_modules/browser-pack/_prelude.js","extensions/invoices/web/js/index.js","extensions/invoices/web/js/lib.js","node_modules/process/browser.js","web/api-common/RequestCache.js","web/api/AdapterBase.js","web/api/FormValidation.js","web/api/IceApiClient.js","web/api/IceDataPipe.js","web/api/MasterDataReader.js","web/api/ModuleBase.js","web/api/ReactModalAdapterBase.js","web/components/IceColorPick.js","web/components/IceDataGroup.js","web/components/IceForm.js","web/components/IceFormModal.js","web/components/IceLabel.js","web/components/IceSelect.js","web/components/IceSignature.js","web/components/IceStepForm.js","web/components/IceStepFromModal.js","web/components/IceTable.js","web/components/IceUpload.js","web/node_modules/@icons/material/CheckIcon.js","web/node_modules/@icons/material/UnfoldMoreHorizontalIcon.js","web/node_modules/axios/index.js","web/node_modules/axios/lib/adapters/xhr.js","web/node_modules/axios/lib/axios.js","web/node_modules/axios/lib/cancel/Cancel.js","web/node_modules/axios/lib/cancel/CancelToken.js","web/node_modules/axios/lib/cancel/isCancel.js","web/node_modules/axios/lib/core/Axios.js","web/node_modules/axios/lib/core/InterceptorManager.js","web/node_modules/axios/lib/core/buildFullPath.js","web/node_modules/axios/lib/core/createError.js","web/node_modules/axios/lib/core/dispatchRequest.js","web/node_modules/axios/lib/core/enhanceError.js","web/node_modules/axios/lib/core/mergeConfig.js","web/node_modules/axios/lib/core/settle.js","web/node_modules/axios/lib/core/transformData.js","web/node_modules/axios/lib/defaults.js","web/node_modules/axios/lib/helpers/bind.js","web/node_modules/axios/lib/helpers/buildURL.js","web/node_modules/axios/lib/helpers/combineURLs.js","web/node_modules/axios/lib/helpers/cookies.js","web/node_modules/axios/lib/helpers/isAbsoluteURL.js","web/node_modules/axios/lib/helpers/isURLSameOrigin.js","web/node_modules/axios/lib/helpers/normalizeHeaderName.js","web/node_modules/axios/lib/helpers/parseHeaders.js","web/node_modules/axios/lib/helpers/spread.js","web/node_modules/axios/lib/utils.js","web/node_modules/lodash/_DataView.js","web/node_modules/lodash/_Hash.js","web/node_modules/lodash/_ListCache.js","web/node_modules/lodash/_Map.js","web/node_modules/lodash/_MapCache.js","web/node_modules/lodash/_Promise.js","web/node_modules/lodash/_Set.js","web/node_modules/lodash/_SetCache.js","web/node_modules/lodash/_Stack.js","web/node_modules/lodash/_Symbol.js","web/node_modules/lodash/_Uint8Array.js","web/node_modules/lodash/_WeakMap.js","web/node_modules/lodash/_apply.js","web/node_modules/lodash/_arrayEach.js","web/node_modules/lodash/_arrayFilter.js","web/node_modules/lodash/_arrayLikeKeys.js","web/node_modules/lodash/_arrayMap.js","web/node_modules/lodash/_arrayPush.js","web/node_modules/lodash/_arraySome.js","web/node_modules/lodash/_assignMergeValue.js","web/node_modules/lodash/_assignValue.js","web/node_modules/lodash/_assocIndexOf.js","web/node_modules/lodash/_baseAssign.js","web/node_modules/lodash/_baseAssignIn.js","web/node_modules/lodash/_baseAssignValue.js","web/node_modules/lodash/_baseClone.js","web/node_modules/lodash/_baseCreate.js","web/node_modules/lodash/_baseEach.js","web/node_modules/lodash/_baseFor.js","web/node_modules/lodash/_baseForOwn.js","web/node_modules/lodash/_baseGet.js","web/node_modules/lodash/_baseGetAllKeys.js","web/node_modules/lodash/_baseGetTag.js","web/node_modules/lodash/_baseHasIn.js","web/node_modules/lodash/_baseIsArguments.js","web/node_modules/lodash/_baseIsEqual.js","web/node_modules/lodash/_baseIsEqualDeep.js","web/node_modules/lodash/_baseIsMap.js","web/node_modules/lodash/_baseIsMatch.js","web/node_modules/lodash/_baseIsNative.js","web/node_modules/lodash/_baseIsSet.js","web/node_modules/lodash/_baseIsTypedArray.js","web/node_modules/lodash/_baseIteratee.js","web/node_modules/lodash/_baseKeys.js","web/node_modules/lodash/_baseKeysIn.js","web/node_modules/lodash/_baseMap.js","web/node_modules/lodash/_baseMatches.js","web/node_modules/lodash/_baseMatchesProperty.js","web/node_modules/lodash/_baseMerge.js","web/node_modules/lodash/_baseMergeDeep.js","web/node_modules/lodash/_baseProperty.js","web/node_modules/lodash/_basePropertyDeep.js","web/node_modules/lodash/_baseRest.js","web/node_modules/lodash/_baseSetToString.js","web/node_modules/lodash/_baseTimes.js","web/node_modules/lodash/_baseToString.js","web/node_modules/lodash/_baseUnary.js","web/node_modules/lodash/_cacheHas.js","web/node_modules/lodash/_castFunction.js","web/node_modules/lodash/_castPath.js","web/node_modules/lodash/_cloneArrayBuffer.js","web/node_modules/lodash/_cloneBuffer.js","web/node_modules/lodash/_cloneDataView.js","web/node_modules/lodash/_cloneRegExp.js","web/node_modules/lodash/_cloneSymbol.js","web/node_modules/lodash/_cloneTypedArray.js","web/node_modules/lodash/_copyArray.js","web/node_modules/lodash/_copyObject.js","web/node_modules/lodash/_copySymbols.js","web/node_modules/lodash/_copySymbolsIn.js","webLine truncated
|
||||
{"version":3,"sources":["node_modules/browser-pack/_prelude.js","extensions/invoices/web/js/index.js","extensions/invoices/web/js/lib.js","node_modules/process/browser.js","web/api-common/RequestCache.js","web/api/AdapterBase.js","web/api/FormValidation.js","web/api/IceApiClient.js","web/api/IceDataPipe.js","web/api/MasterDataReader.js","web/api/ModuleBase.js","web/api/ReactModalAdapterBase.js","web/components/IceColorPick.js","web/components/IceDataGroup.js","web/components/IceForm.js","web/components/IceFormModal.js","web/components/IceLabel.js","web/components/IceSelect.js","web/components/IceSignature.js","web/components/IceStepForm.js","web/components/IceStepFromModal.js","web/components/IceTable.js","web/components/IceUpload.js","web/node_modules/@icons/material/CheckIcon.js","web/node_modules/@icons/material/UnfoldMoreHorizontalIcon.js","web/node_modules/axios/index.js","web/node_modules/axios/lib/adapters/xhr.js","web/node_modules/axios/lib/axios.js","web/node_modules/axios/lib/cancel/Cancel.js","web/node_modules/axios/lib/cancel/CancelToken.js","web/node_modules/axios/lib/cancel/isCancel.js","web/node_modules/axios/lib/core/Axios.js","web/node_modules/axios/lib/core/InterceptorManager.js","web/node_modules/axios/lib/core/buildFullPath.js","web/node_modules/axios/lib/core/createError.js","web/node_modules/axios/lib/core/dispatchRequest.js","web/node_modules/axios/lib/core/enhanceError.js","web/node_modules/axios/lib/core/mergeConfig.js","web/node_modules/axios/lib/core/settle.js","web/node_modules/axios/lib/core/transformData.js","web/node_modules/axios/lib/defaults.js","web/node_modules/axios/lib/helpers/bind.js","web/node_modules/axios/lib/helpers/buildURL.js","web/node_modules/axios/lib/helpers/combineURLs.js","web/node_modules/axios/lib/helpers/cookies.js","web/node_modules/axios/lib/helpers/isAbsoluteURL.js","web/node_modules/axios/lib/helpers/isURLSameOrigin.js","web/node_modules/axios/lib/helpers/normalizeHeaderName.js","web/node_modules/axios/lib/helpers/parseHeaders.js","web/node_modules/axios/lib/helpers/spread.js","web/node_modules/axios/lib/utils.js","web/node_modules/lodash/_DataView.js","web/node_modules/lodash/_Hash.js","web/node_modules/lodash/_ListCache.js","web/node_modules/lodash/_Map.js","web/node_modules/lodash/_MapCache.js","web/node_modules/lodash/_Promise.js","web/node_modules/lodash/_Set.js","web/node_modules/lodash/_SetCache.js","web/node_modules/lodash/_Stack.js","web/node_modules/lodash/_Symbol.js","web/node_modules/lodash/_Uint8Array.js","web/node_modules/lodash/_WeakMap.js","web/node_modules/lodash/_apply.js","web/node_modules/lodash/_arrayEach.js","web/node_modules/lodash/_arrayFilter.js","web/node_modules/lodash/_arrayLikeKeys.js","web/node_modules/lodash/_arrayMap.js","web/node_modules/lodash/_arrayPush.js","web/node_modules/lodash/_arraySome.js","web/node_modules/lodash/_assignMergeValue.js","web/node_modules/lodash/_assignValue.js","web/node_modules/lodash/_assocIndexOf.js","web/node_modules/lodash/_baseAssign.js","web/node_modules/lodash/_baseAssignIn.js","web/node_modules/lodash/_baseAssignValue.js","web/node_modules/lodash/_baseClone.js","web/node_modules/lodash/_baseCreate.js","web/node_modules/lodash/_baseEach.js","web/node_modules/lodash/_baseFor.js","web/node_modules/lodash/_baseForOwn.js","web/node_modules/lodash/_baseGet.js","web/node_modules/lodash/_baseGetAllKeys.js","web/node_modules/lodash/_baseGetTag.js","web/node_modules/lodash/_baseHasIn.js","web/node_modules/lodash/_baseIsArguments.js","web/node_modules/lodash/_baseIsEqual.js","web/node_modules/lodash/_baseIsEqualDeep.js","web/node_modules/lodash/_baseIsMap.js","web/node_modules/lodash/_baseIsMatch.js","web/node_modules/lodash/_baseIsNative.js","web/node_modules/lodash/_baseIsSet.js","web/node_modules/lodash/_baseIsTypedArray.js","web/node_modules/lodash/_baseIteratee.js","web/node_modules/lodash/_baseKeys.js","web/node_modules/lodash/_baseKeysIn.js","web/node_modules/lodash/_baseMap.js","web/node_modules/lodash/_baseMatches.js","web/node_modules/lodash/_baseMatchesProperty.js","web/node_modules/lodash/_baseMerge.js","web/node_modules/lodash/_baseMergeDeep.js","web/node_modules/lodash/_baseProperty.js","web/node_modules/lodash/_basePropertyDeep.js","web/node_modules/lodash/_baseRest.js","web/node_modules/lodash/_baseSetToString.js","web/node_modules/lodash/_baseTimes.js","web/node_modules/lodash/_baseToString.js","web/node_modules/lodash/_baseUnary.js","web/node_modules/lodash/_cacheHas.js","web/node_modules/lodash/_castFunction.js","web/node_modules/lodash/_castPath.js","web/node_modules/lodash/_cloneArrayBuffer.js","web/node_modules/lodash/_cloneBuffer.js","web/node_modules/lodash/_cloneDataView.js","web/node_modules/lodash/_cloneRegExp.js","web/node_modules/lodash/_cloneSymbol.js","web/node_modules/lodash/_cloneTypedArray.js","web/node_modules/lodash/_copyArray.js","web/node_modules/lodash/_copyObject.js","web/node_modules/lodash/_copySymbols.js","web/node_modules/lodash/_copySymbolsIn.js","webLine truncated
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"label": "Invoices",
|
||||
"menu": ["Invoices", "fa-file"],
|
||||
"icon": "fa-file",
|
||||
"icon": "fa-file-invoice",
|
||||
"user_levels": [
|
||||
"Admin",
|
||||
"Manager",
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
namespace Invoices;
|
||||
|
||||
use Classes\Authorizable;
|
||||
use Classes\BaseService;
|
||||
use Classes\FileService;
|
||||
use Classes\IceResponse;
|
||||
use Classes\Pdf\PdfBuilder;
|
||||
use Employees\Common\Model\Employee;
|
||||
use Invoices\Pdf\InvoicePdf;
|
||||
|
||||
|
||||
class InvoicePDFBuilder implements Authorizable, PdfBuilder
|
||||
{
|
||||
|
||||
protected $formId;
|
||||
|
||||
public function __construct($formId)
|
||||
{
|
||||
$this->formId = $formId;
|
||||
}
|
||||
|
||||
public function granted(): bool
|
||||
{
|
||||
$empForm = new EmployeeForm();
|
||||
$empForm->Load("id = ?", array($this->formId));
|
||||
|
||||
$currentEmployeeId = BaseService::getInstance()->getCurrentProfileId();
|
||||
$user = BaseService::getInstance()->getCurrentUser();
|
||||
return ($currentEmployeeId == $empForm->employee
|
||||
|| $user->user_level === 'Admin'
|
||||
|| BaseService::getInstance()->isSubordinateEmployee($currentEmployeeId, $empForm->employee)
|
||||
);
|
||||
}
|
||||
|
||||
public function createPdf()
|
||||
{
|
||||
$response = FormsActionManager::getFormDataById($this->formId);
|
||||
if ($response->getStatus() === IceResponse::ERROR) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$form = $response->getData()['form'];
|
||||
$employeeForm = $response->getData()['data'];
|
||||
|
||||
$employee = new Employee();
|
||||
$employee->Load('id = ?', [$employeeForm->employee]);
|
||||
$employee = FileService::getInstance()->updateSmallProfileImage($employee);
|
||||
|
||||
$pdf = new InvoicePdf($invoice);
|
||||
$pdf->initialize($form->name);
|
||||
$pdf->process();
|
||||
|
||||
return $pdf;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
namespace Invoices\Pdf;
|
||||
|
||||
use Classes\Pdf\BasePdfTemplate;
|
||||
use Invoices\Model\Invoice;
|
||||
|
||||
class InvoicePdf extends BasePdfTemplate
|
||||
{
|
||||
|
||||
protected $invoice;
|
||||
|
||||
public function __construct(Invoice $invoice)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->invoice = $invoice;
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
$this->addH3($this->form->name, 'B', 'L');
|
||||
$this->addBorderedText($this->invoice->description);
|
||||
}
|
||||
|
||||
// protected function addFormItems()
|
||||
// {
|
||||
// $signatures = [];
|
||||
// $fields = json_decode($this->form->items);
|
||||
// foreach ($fields as $field) {
|
||||
// if ($field->field_type === 'signature') {
|
||||
// $signatures[$field->field_label] = $this->employeeForm->{$field->name};
|
||||
// } elseif ($field->field_type === 'fileupload') {
|
||||
// // ignore
|
||||
// } else {
|
||||
// $this->addKeyValue($field->field_label, $this->employeeForm->{$field->name}, $field->field_type);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// foreach ($signatures as $name => $data) {
|
||||
// $this->addSignature($name, $data);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
Reference in new issue
Block a user