Joomshopping Special: Tcpdf html

13.03.2025 11:40
#1
jacobsen
Joomshopping forum user no avatar
Name: john
15.02.2011
Posts: 512
Quote
Joomshopping Special: Tcpdf html

Can somebody please help!

1) When using Joomshopping Special: Tcpdf html
Will it overwrite generete_pdf_order.php ?

2) How can I acces the assons/configuration/Joomshopping PDF html - setting ? I can't find it.

#) If I overwrites can I change (layout.php) in (Joomshopping Special: Tcpdf html) will it be the new invoice?

I need to input this below in the generete_pdf, in the old version I made a user_generete_pdf_order:
// Input start , I proberly need to adjust the location SetXY but no problem.
$y+=6;
$pdf->SetXY(110,$y);

//kredittid = credit time in days
$kredittid = 14;
if (array_key_exists($order->user_id, $kredittider))
$kredittid = $kredittider[$order->user_id];

// Kredittider løbende måned + X dage + = credit time this month + x days for a specifik customer
$kredittider_loeb = array(
186 => 30 // EFG
);
if (array_key_exists($order->user_id, $kredittider_loeb)) {
$kredittid = $kredittider_loeb[$order->user_id];
$invoiceStr = strtotime($order->invoice_date);
$dageTilbage = cal_days_in_month(CAL_GREGORIAN, date('m',$invoiceStr), date('Y', $invoiceStr)) - date('j', $invoiceStr);
$kredittid += $dageTilbage;
}

// Fix betalinger der forfalder i weekenden = move last payment date so it dosen't conflict with the weekend
$ugedag = date('N',strtotime($order->invoice_date)+$kredittid*86400);
if ($ugedag > 5)
$kredittid += 8 - $ugedag;

$dateend = date('d.m.Y',strtotime($order->invoice_date)+$kredittid*86400);

if (!$isKreditNota)
$pdf->MultiCell(80,3,_JSHOP_LAST_DATE_OF_PAYMENT. " " . $dateend,0,'R');
// Input End


I have use the languages: Overrides for (_JSHOP_LAST_DATE_OF_PAYMENT)

Kind regards
Jacobsen


Joomla: 5.2.5
JoomShopping: 5.5.6

Letzte Änderung: 13.03.2025 12:23
 
13.03.2025 13:29
#2
admin
(Support Team)
User admin
Name: Admin
05.08.2010
Posts: 28287
Quote
Aw: Joomshopping Special: Tcpdf html

1. Yes
After install - default code for generate pdf not used
(default: components\com_jshopping\Pdf\Order.php)

will be used
components\com_jshopping\Pdf\Orderhtml.php

2. addon version?
screenshots?

3. folder addon template:
components\com_jshopping\templates\addons\tcpdf_html\

for override copy to folder
1. templates/{your template}/html/com_jshopping/addons/tcpdf_html
2. templates/{your admin template}/html/com_jshopping/addons/tcpdf_html

--------------------

the best solution is to create a plugin


Letzte Änderung: 13.03.2025 14:18
 
13.03.2025 18:20
#3
jacobsen
Joomshopping forum user no avatar
Name: john
15.02.2011
Posts: 512
Quote
Aw: Joomshopping Special: Tcpdf html

Hi, I have been trying to make a plugin.
Can somebody help me? I can't get it to work.

I made a folder:

plg_jshoppingorder_pdf_credit_time_1.0.0.zip
With the following files:

pdf_credit _time.xlm
pdf_credit _time.xlm - I don't know if the <extension type="plugin" version="2.5" need to be 5.5.6 insted of 2.5
<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" version="2.5" method="upgrade" group="jshoppingorder">
<name>JoomShopping Plugin Add credit time to pdf order</name>
<creationDate>13.03.2025</creationDate>
<version>1.0.1</version>
<author>John</author>
<authorEmail></authorEmail>
<authorUrl></authorUrl>
<copyright></copyright>
<license></license>
<description>Plugin Add credit time to pdf order. </description>

<files>
<filename plugin="pdf_credit_time">pdf_credit_time.php</filename>
</files>

pdf_credit_time.php
<?php
defined('_JEXEC') or die('Restricted access');

class plgJshoppingOrderPdf_credit_time extends JPlugin {

public function __construct(&$subject, $config) {
$this->loadLanguage();
parent::__construct($subject, $config);
}

public function onGeneratePdfOrderAfterOrderNr(&$order, &$pdf, &$y) {

// Set cursor position to the current Y coordinate
$pdf->SetXY(110, $pdf->getY());

// Credit time (days) for specific customers
$creditTimes = [
132 => 14, // Bruynzeel.dk
145 => 14, // Bruynzeel.no
170 => 14, // HRH
177 => 14 // DTU
];

// Default credit time
$creditTime = 30;

// Check if customer has a specific credit time
if (array_key_exists($order->user_id, $creditTimes)) {
$creditTime = $creditTimes[$order->user_id];
}

// Special cases: "end-of-month + extra days"
$creditTimesEndOfMonth = [
186 => 30 // EFG
];

if (array_key_exists($order->user_id, $creditTimesEndOfMonth)) {
$creditTime = $creditTimesEndOfMonth[$order->user_id];

// Calculate remaining days in the invoice month
$invoiceTimestamp = strtotime($order->invoice_date);
$daysLeft = cal_days_in_month(CAL_GREGORIAN, date('m', $invoiceTimestamp), date('Y', $invoiceTimestamp)) - date('j', $invoiceTimestamp);
$creditTime += $daysLeft;
}

// Calculate initial due date
$dueDateTimestamp = strtotime($order->invoice_date) + $creditTime * 86400;

// Adjust due date if it falls on a weekend
$weekday = date('N', $dueDateTimestamp); // 1 = Monday, 7 = Sunday
if ($weekday == 6) { // Saturday
$dueDateTimestamp += 2 * 86400; // Move to Monday
} elseif ($weekday == 7) { // Sunday
$dueDateTimestamp += 1 * 86400; // Move to Monday
}

// Format the final due date
$dueDate = date('d.m.Y', $dueDateTimestamp);

// Add due date to the PDF
$pdf->MultiCell(80, 3, _JSHOP_LAST_DATE_OF_PAYMENT . " " . $dueDate, 0, 'R');
}
} // Closing class bracket


When I upload the package file in JoomShopping - Install & Update, it says 'Success Completed,' but it doesn't show in System > Plugins. Can sombody tell me why?

I know the placement of _JSHOP_LAST_DATE_OF_PAYMENT is probably wrong.

Kind regards
Jacobsen


Joomla: 5.2.5
JoomShopping: 5.5.6

Letzte Änderung: 13.03.2025 18:23
 
13.03.2025 19:31
#4
admin
(Support Team)
User admin
Name: Admin
05.08.2010
Posts: 28287
Quote
Aw: Joomshopping Special: Tcpdf html

pdf_credit _time.xlm
=>
pdf_credit _time.xml
pdf_credit_time_1.0.0.zip

 
13.03.2025 20:40
#5
jacobsen
Joomshopping forum user no avatar
Name: john
15.02.2011
Posts: 512
Quote
Aw: Joomshopping Special: Tcpdf html

Thank you.

Sometimes my brain switches off. :-)

If I need to move _JSHOP_LAST_DATE_OF_PAYMENT under the invoice date (see images), can you help with the changes?

KInd regards
Jacobsen
Aw: Joomshopping Special: Tcpdf html


Letzte Änderung: 13.03.2025 20:40
 
13.03.2025 21:01
#6
admin
(Support Team)
User admin
Name: Admin
05.08.2010
Posts: 28287
Quote
Aw: Joomshopping Special: Tcpdf html

No triggers.

-------
1. Create
components\com_jshopping\Pdf\Order2.php
...
https://www.joomshopping.com/forum/posts/7/16356.html?lang=ru#1

2. create new trigger

$dispatcher->triggerEvent('onGeneratePdfOrderAfterOrderNr2', array(&$order, &$pdf, &$y));

after

if ($jshopConfig->user_number_in_invoice && $order->user_id && $user->number){
$y+=11;
$pdf->SetXY(110, $pdf->getY());
$pdf->MultiCell(80,4.5,Text::_('JSHOP_USER_NUMBER')." ".$user->number, 0, 'R');
}

 
14.03.2025 08:28
#7
jacobsen
Joomshopping forum user no avatar
Name: john
15.02.2011
Posts: 512
Quote
Aw: Joomshopping Special: Tcpdf html

Thank you for the input, I really appreciate your help.
I think I’ll stick with what I have to keep it standard (Oorder.php)

Kind regards
Jaobsen

 


Copyrights MAXXmarketing GmbH. Alle Rechte vorbehalten
Durch die Nutzung dieser Website stimme ich zu, dass Cookies zur optimalen Gestaltung der Website sowie zur Analyse der Nutzung der Website verwendet werden. Weiterführende Informationen finden Sie hier. OK, einverstanden.