| Server IP : 103.161.17.216 / Your IP : 216.73.216.1 Web Server : nginx/1.18.0 System : Linux tipsysaigoncharming 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 7.4.3-4ubuntu2.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/app.houseland.info/application/libraries/pdf/ |
Upload File : |
<?php
defined('BASEPATH') or exit('No direct script access allowed');
trait PDF_Signature
{
public function processSignature()
{
return $this->process_signature();
}
public function process_signature()
{
$dimensions = $this->getPageDimensions();
$leftColumnExists = false;
$companySignature = $this->getCompanySignature();
if ($companySignature) {
$this->MultiCell(($dimensions['wk'] / 2) - $dimensions['lm'], 0, _l('authorized_signature_text') . ' ' . $companySignature, 0, 'J', 0, 0, '', '', true, 0, true, true, 0);
$leftColumnExists = true;
}
// Customer signature
$record = $this->getSignatureableInstance();
$path = $this->getSignaturePath();
if (!empty($path) && file_exists($path)) {
$signature = _l('document_customer_signature_text');
if ($this->type() == 'contract') {
$signature .= '<br /><br /><span style="font-weight:bold;text-align: right;">';
$signature .= _l('contract_signed_by') . ": {$record->acceptance_firstname} {$record->acceptance_lastname}<br />";
$signature .= _l('contract_signed_date') . ': ' . _dt($record->acceptance_date) . '<br />';
$signature .= _l('contract_signed_ip') . ": {$record->acceptance_ip}";
$signature .= '</span><br />';
}
if ($this->type() == 'proposal' || $this->type() == 'estimate') {
$signature .= '<br /><br /><span style="font-weight:bold;text-align: right;">';
$signature .= _l('proposal_signed_by') . ": {$record->acceptance_firstname} {$record->acceptance_lastname}<br />";
$signature .= _l('proposal_signed_date') . ': ' . _dt($record->acceptance_date) . '<br />';
$signature .= _l('proposal_signed_ip') . ": {$record->acceptance_ip}";
$signature .= '</span><br />';
}
$signature .= str_repeat(
'<br />',
hooks()->apply_filters('pdf_signature_break_lines', 1)
);
$width = ($dimensions['wk'] / 2) - $dimensions['rm'];
if (!$leftColumnExists) {
$width = $dimensions['wk'] - ($dimensions['rm'] + $dimensions['lm']);
$this->ln(13);
}
$hookData = [
'pdf_instance' => $this,
'type' => $this->type(),
'signatureCellWidth' => $width,
];
hooks()->do_action('before_customer_pdf_signature', $hookData);
$imageData = file_get_contents($path);
$this->MultiCell($width, 0, $signature, 0, 'R', 0, 1, '', '', true, 0, true, false, 0);
$customerSignatureSize = hooks()->apply_filters('customer_pdf_signature_size', 0);
$this->Image('@' . $imageData, $this->getX(), $this->getY(), $customerSignatureSize, 0, 'PNG', '', 'R', true, 300, 'R', false, false, 0, true);
hooks()->do_action('after_customer_pdf_signature', $hookData);
}
}
public function getCompanySignature()
{
if (($this->type() == 'invoice' && get_option('show_pdf_signature_invoice') == 1)
|| ($this->type() == 'estimate' && get_option('show_pdf_signature_estimate') == 1)
|| ($this->type() == 'contract' && get_option('show_pdf_signature_contract') == 1)
|| ($this->type() == 'proposal' && get_option('show_pdf_signature_proposal') == 1)
|| ($this->type() == 'credit_note') && get_option('show_pdf_signature_credit_note') == 1) {
$signatureImage = get_option('signature_image');
$signaturePath = FCPATH . 'uploads/company/' . $signatureImage;
$signatureExists = file_exists($signaturePath);
$blankSignatureLine = hooks()->apply_filters('blank_signature_line', '_________________________');
if ($signatureImage != '' && $signatureExists) {
$blankSignatureLine = '';
}
$this->ln(13);
if ($signatureImage != '' && $signatureExists) {
$imageData = base64_encode(file_get_contents($signaturePath));
$blankSignatureLine .= str_repeat('<br />', hooks()->apply_filters('pdf_signature_break_lines', 1)) . '<img src="@' . $imageData . '" / />';
}
return $blankSignatureLine;
}
return false;
}
public function getSignaturePath()
{
$instance = $this->getSignatureableInstance();
if (!$instance) {
return '';
}
$path = get_upload_path_by_type($this->type()) . $instance->id . '/' . $instance->signature;
return hooks()->apply_filters(
'pdf_customer_signature_image_path',
$path,
$this->type()
);
}
public function getSignatureableInstance()
{
if (isset($GLOBALS['estimate_pdf']) && !empty($GLOBALS['estimate_pdf']->signature)) {
return $GLOBALS['estimate_pdf'];
} elseif (isset($GLOBALS['proposal_pdf']) && !empty($GLOBALS['proposal_pdf']->signature)) {
return $GLOBALS['proposal_pdf'];
} elseif (isset($GLOBALS['contract_pdf']) && !empty($GLOBALS['contract_pdf']->signature)) {
return $GLOBALS['contract_pdf'];
}
}
public function hasAnySignature()
{
return $this->getSignaturePath() || $this->getCompanySignature();
}
}