Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW functionality for display codebar on pdf files #29623

Merged
merged 19 commits into from
May 22, 2024

Conversation

lamrani002
Copy link
Contributor

@lamrani002 lamrani002 commented May 6, 2024

NEW|New functionality for display qrcode if this option is checked on pdf config

qrcode

if (class_exists($classname)) {
$module = new $classname($db);
if ($module->encodingIsSupported($obj->code)) {
$result = $module->writeBarCode($object->ref, $encoding);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To represent url, it is better to use a QR code, you can get it by replacing param $encoding into 'QRCODE'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, done

$sql = 'SELECT rowid, code,coder FROM '.MAIN_DB_PREFIX.'c_barcode_type';
$sql .= ' WHERE rowid='.((int) (getDolGlobalString('GENBARCODE_BARCODETYPE_THIRDPARTY')));
$sql .= ' AND entity = 1';
$resql = $db->query($sql);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inside a class, you should use $this->db instead of $db.

@eldy eldy added the PR to fix or conflict to solve PR needs to be fixed to be integrated (except for conflicts, a comment describes the fix to do) label May 7, 2024
}

if ($result > 0) {
$pdf->Image($barcode_path, $this->marge_gauche, $this->marge_haute +80 -5, 20, 20);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not $pdf->write2DBarcode ?

Copy link
Member

@eldy eldy May 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not $pdf->write2DBarcode ?

We want to get barcode using an intermediate image using ->writeBarCode() because ->writeBarCode() is an abstraction class that is common to different barcode generator (phpbarcode and tcpdfbarcode, and more in future if we need).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the remark because seems more complicated to make first png using TCPDF and then use image iso of using TCPDF to write barcode in pdf. For object->ref not big issue, but if it is a big QR, QR quality coud be less by the image resize.

Copy link
Member

@eldy eldy May 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the remark because seems more complicated to make first png using TCPDF and then use image iso of using TCPDF to write barcode in pdf. For object->ref not big issue, but if it is a big QR, QR quality coud be less by the image resize.

Not the same if you use $pdf->write2DBarcode() ?
I suppose that tcpdf also generates an intermediate image of the barcode, or is it directly saved as pdf instruction ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$pdf->write2DBarcode() draws barcode pixel on pdf:

// draw a single barcode cell

No intermediate image involved.
$modTcpdfbarcode->writeBarCode() is more for showing barcode on screen.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. We should enhance this by adding a method
function pdf_barcode(&$pdf, ...)
into file pdf.lib.php
with all content inside the
if (isModEnabled('barcode') && getDolGlobalString('BARCODE_RECEPTION_INVOICE')) { ... }

So we will be able to replace current code with a more opmitised version

@eldy eldy merged commit 4f0cbb6 into Dolibarr:develop May 22, 2024
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR to fix or conflict to solve PR needs to be fixed to be integrated (except for conflicts, a comment describes the fix to do)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants