Skip to content

Instantly share code, notes, and snippets.

@katgirl
Last active December 23, 2015 11:39
Show Gist options
  • Save katgirl/6629460 to your computer and use it in GitHub Desktop.
Save katgirl/6629460 to your computer and use it in GitHub Desktop.
Dateien für https://community.contao.org/de/newreply.php?p=287291 Neue Anforderung - Verkaufte Artikel zählen und QRCode generieren
<?php
/**
* PHP version 5
* @copyright Copyright (C) 2012-2013 Kirsten Roschanski
* @author Kirsten Roschanski <kat@kirsten-roschanski.de>
* @license http://opensource.org/licenses/lgpl-3.0.html
* @package IsotopeDeliveryNote
* @filesource https://github.com/katgirl/isotope-delivery_note
*/
$this->loadLanguageFile('countries');
$this->loadLanguageFile('tl_iso_config');
include(TL_ROOT . '/system/config/countries.php');
?>
<div style="font-size: 72.5%; font-family: Helvetica, sans-serif; float:left;">
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td colspan="2" align="center"><?php echo $this->logoImage; ?><br><br></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="60%"><span style="font-size: 65%;text-decoration: underline;"><?php
echo $this->config['company'] . " · " .
$this->config['firstname'] . " " .
$this->config['lastname'] . " · " .
$this->config['street_1'] . " · " .
$this->config['postal'] . " · " .
$this->config['city'];
?></span><br><?php
echo $this->arrShippingAddress['company'] ? $this->arrShippingAddress['company'] . "<br>" : "";
echo $this->arrShippingAddress['firstname'] . " ";
echo $this->arrShippingAddress['lastname'] . "<br>";
echo $this->arrShippingAddress['street_1'] ? $this->arrShippingAddress['street_1'] . "<br>" : "";
echo $this->arrShippingAddress['street_2'] ? $this->arrShippingAddress['street_2'] . "<br>" : "";
echo $this->arrShippingAddress['street_3'] ? $this->arrShippingAddress['street_3'] . "<br>" : "";
echo $this->arrShippingAddress['postal'] . " ";
echo $this->arrShippingAddress['city'] . "<br><br>";
echo $GLOBALS['TL_LANG']['CNT'][$this->arrShippingAddress['country']];
?><br><br><br><br><br><br
><span style="font-size: 100%;font-weight: bold;"><?php echo $this->deliveryNoteTitle; ?></span><br><br
><?php echo $GLOBALS['TL_LANG']['isoDeliveryNote']['customerID']; ?>: <?php echo $this->pid > 0 ? $this->pid : "-"; ?><br
><?php echo $this->orderDateLabel . ": " . $this->orderDate; ?><br
><?php echo $this->orderIdLabel . ": " . $this->orderId; ?><br
><?php echo $GLOBALS['TL_LANG']['isoDeliveryNote']['date']; ?>: <?php echo $this->orderDate; ?>
</td>
<td width="40%"><strong><?php
echo $this->config['company'] ? $this->config['company'] : "";
echo "</strong><br>";
echo $this->config['firstname'] . " " . $this->config['lastname']. "<br>";
echo $this->config['street_1'] ? $this->config['street_1'] . "<br>" : "";
echo $this->config['street_2'] ? $this->config['street_2'] . "<br>" : "";
echo $this->config['street_3'] ? $this->config['street_3'] . "<br>" : "";
echo $this->config['postal'] . " " . $this->config['city'] . "<br>";
echo $GLOBALS['TL_LANG']['CNT'][$this->config['country']] . "<br><br>";
echo $GLOBALS['TL_LANG']['tl_iso_config']['phone'][0] . ": " . $this->config['phone'] . "<br>";
echo $this->config['email'] . "<br>";
echo $_SERVER["SERVER_NAME"] . "<br><br>";
if(strlen($this->config['bank_name']) > 0):
echo "<br>";
echo $GLOBALS['TL_LANG']['tl_iso_config']['bank_name'][0] . "<br>";
echo $this->config['bank_name'] . "<br>";
echo $GLOBALS['TL_LANG']['tl_iso_config']['bank_id'][0] . ": " . $this->config['bank_id'] . "<br>";
echo $GLOBALS['TL_LANG']['tl_iso_config']['account_number'][0] . ": " . $this->config['account_number'] . "<br>";
echo $GLOBALS['TL_LANG']['tl_iso_config']['iban'][0] . ": " . $this->config['iban'] . "<br>";
echo $GLOBALS['TL_LANG']['tl_iso_config']['bic'][0] . ": " . $this->config['bic'];
endif; ?><br><br
><?php if(strlen($this->config['tax_number']) > 0): echo $GLOBALS['TL_LANG']['tl_iso_config']['tax_number'][0] . ": " . $this->config['tax_number']; endif; ?><br
><?php if(strlen($this->config['vat_no']) > 0): echo $GLOBALS['TL_LANG']['tl_iso_config']['vat_no'][0] . ": " . $this->config['vat_no']; endif; ?>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<table cellspacing="0" cellpadding="5" width="100%" style="margin-left:25px; margin-right:25px">
<tr>
<td width="15%"><?php echo $GLOBALS['TL_LANG']['isoInvoice']['sku']; ?></td>
<td width="10%"><?php echo $GLOBALS['TL_LANG']['isoInvoice']['quantity']; ?></td>
<td width="75%"><?php echo $GLOBALS['TL_LANG']['isoInvoice']['item']; ?></td>
</tr>
<?php
$countItems = count($this->items);
$count = 0;
foreach( $this->items as $item ):
// falls mehre Produkte vom gleichen Typ, dann bitte pro Zeile nur eines ausgeben.
// darum alles hiernach
for ($i = 1; $i <= $item['quantity']; $i++):
$count++;
$strQRCode = 'k10'.$this->orderDateTime.'-'.sprintf("%05u", $this->orderId).'-'.sprintf("%04u", $count);
$qrCodeURL = QRCodeGenerator::generate($strQRCode, QR_ECLEVEL_H, $intSize = 7, $intMargin = 0);
?>
<tr>
<td width="15%"><?php echo $item['raw']['sku']; ?></td>
<td width="10%">1</td>
<td width="35%">
<?php echo $item['name']; ?><br />
<?php if(is_array($item['product_options']) && count($item['product_options'])): ?>
<ul>
<?php foreach($item['product_options'] as $option): ?>
<li><strong><?php echo $option['label']; ?>:</strong> <?php echo $option['value']; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</td>
<td width="40%"><img src="<?php echo TL_ROOT . '/' . $qrCodeURL; ?>" alt=""><br><span><?php echo $strQRCode; ?></span></td>
</tr>
<?php endfor; endforeach;?>
</table>
</div>
<?php if (!defined('TL_ROOT')) die('You cannot access this file directly!');
/**
* PHP version 5
* @copyright Copyright (C) 2012-2013 Kirsten Roschanski
* @author Kirsten Roschanski <kat@kirsten-roschanski.de>
* @license http://opensource.org/licenses/lgpl-3.0.html
*/
/**
* Class IsotopeDeliveryNote
*
* @copyright Copyright (C) 2012-2013 Kirsten Roschanski
* @author Kirsten Roschanski <kat@kirsten-roschanski.de>
* @package IsotopeDeliveryNote
* @filesource https://github.com/katgirl/isotope-delivery_note
*/
class IsotopeDeliveryNote extends IsotopeOrder
{
/**
* Template
* @var string
*/
protected $strTemplate = 'iso_delivery_note';
/**
* New parameter for TemplateObject
*/
public function getGenerateCollection(&$objTemplate, $arrItems, IsotopeProductCollection $objProductCollection)
{
if ( ! preg_match("/iso_delivery_note/", $objTemplate->getName() ) )
{
return;
}
$objTemplate->deliveryNoteTitle = $GLOBALS['TL_LANG']['isoDeliveryNote']['iso_delivery_note_title'];
$objTemplate->orderIdLabel = $GLOBALS['TL_LANG']['isoDeliveryNote']['orderIdLabel'];
$objTemplate->orderId = $objProductCollection->order_id;
$objTemplate->orderDateLabel = $GLOBALS['TL_LANG']['isoDeliveryNote']['orderDateLabel'];
$objTemplate->orderDate = date($GLOBALS['TL_CONFIG']['dateFormat'], $objProductCollection->date);
$objTemplate->orderDateTime = date('dmYHi', $objProductCollection->date);
$objTemplate->arrBillingAddress = $objProductCollection->billing_address;
$objTemplate->arrShippingAddress = $objProductCollection->shipping_address ? $objProductCollection->shipping_address : $objProductCollection->billing_address;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment