Skip to content

Commit

Permalink
Ordered-Licenses module added
Browse files Browse the repository at this point in the history
  • Loading branch information
doishub committed Dec 4, 2020
1 parent 9d881ce commit 67b51ff
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 4 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ The following insert tags are available:

> \* = Id of collection / product
### Module:
With the module Ordered-Licenses the booked licenses can be displayed in the order confirmation.

> To determine the current order and its licenses, the GET parameter "uid" must be in the URL. This is the case on the order confirmation page, for example. It would look something like this: "complete.html?uid=550af3fe73763"
### Example content of the e-mail:

> Here are your ordered licenses 🎉\
Expand Down
7 changes: 5 additions & 2 deletions src/Resources/contao/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
));

// Register Model
$GLOBALS['TL_MODELS']['tl_license'] = '\\Oveleon\\IsotopeProductLicenses\\LicenseModel';
$GLOBALS['TL_MODELS']['tl_license_item'] = '\\Oveleon\\IsotopeProductLicenses\\LicenseItemModel';
$GLOBALS['TL_MODELS']['tl_license'] = 'Oveleon\IsotopeProductLicenses\LicenseModel';
$GLOBALS['TL_MODELS']['tl_license_item'] = 'Oveleon\IsotopeProductLicenses\LicenseItemModel';

// Front end modules
$GLOBALS['FE_MOD']['isotope']['orderLicenses'] = 'Oveleon\IsotopeProductLicenses\ModuleOrderLicenses';

// Register hooks
$GLOBALS['TL_HOOKS']['replaceInsertTags'][] = array('isotope_product_licenses.listener.insert_tags', 'onReplaceInsertTags');
8 changes: 8 additions & 0 deletions src/Resources/contao/dca/tl_module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
/*
* This file is part of Oveleon Isotope Product License.
*
* (c) https://www.oveleon.de/
*/
// Palette
$GLOBALS['TL_DCA']['tl_module']['palettes']['orderLicenses'] = '{title_legend},name,headline,type;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID';
10 changes: 9 additions & 1 deletion src/Resources/contao/languages/de/modules.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
<source>Product licences</source>
<target>Produkt-Lizenzen</target>
</trans-unit>
<trans-unit id="FMD.orderLicenses.0">
<source>Ordered-Licenses</source>
<target>Bestellte Lizenzen</target>
</trans-unit>
<trans-unit id="FMD.orderLicenses.1">
<source>Displays the ordered licenses in the order overview.</source>
<target>Gibt die Bestellten Lizenzen in der Bestellübersicht aus.</target>
</trans-unit>
</body>
</file>
</xliff>
</xliff>
8 changes: 7 additions & 1 deletion src/Resources/contao/languages/en/modules.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
<trans-unit id="MOD.iso_license.0">
<source>Product licences</source>
</trans-unit>
<trans-unit id="FMD.orderLicenses.0">
<source>Ordered-Licenses</source>
</trans-unit>
<trans-unit id="FMD.orderLicenses.1">
<source>Displays the ordered licenses in the order overview.</source>
</trans-unit>
</body>
</file>
</xliff>
</xliff>
56 changes: 56 additions & 0 deletions src/Resources/contao/modules/ModuleOrderLicenses.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/*
* This file is part of Oveleon Isotope Product License.
*
* (c) https://www.oveleon.de/
*/

namespace Oveleon\IsotopeProductLicenses;

use Contao\Input;
use Contao\Module;
use Isotope\Model\ProductCollection\Order;

class ModuleOrderLicenses extends Module
{
/**
* Template
* @var string
*/
protected $strTemplate = 'mod_orderLicenses';

/**
* Generate the content element
*/
protected function compile()
{
if (!Input::get('uid') || ($order = Order::findOneBy('uniqid', Input::get('uid'))) === null) {
return '';
}

$objLicenses = LicenseItemModel::findByOrder($order->id, ['order' => 'pid']);

if(null != $objLicenses)
{
$arrProducts = [];
$intCurrentProduct = 0;

while($objLicenses->next())
{
if($objLicenses->pid != $intCurrentProduct)
{
$intCurrentProduct = $objLicenses->pid;

$arrProducts[$intCurrentProduct] = [
'label' => $objLicenses->getRelated('pid')->title,
'licenses' => null
];
}

$arrProducts[$intCurrentProduct]['licenses'][] = $objLicenses->licence;
}
}

$this->Template->products = $arrProducts;
}
}
18 changes: 18 additions & 0 deletions src/Resources/contao/templates/mod_orderLicenses.html5
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php $this->extend('block_unsearchable'); ?>

<?php $this->block('content'); ?>

<?php if($this->products): ?>
<?php foreach ($this->products as $pid => $product):?>
<div class="product-item">
<div class="product-label"><?= $product['label'] ?></div>
<ul>
<?php foreach ($product['licenses'] as $license): ?>
<li class="license-item"><?= $license ?></li>
<?php endforeach; ?>
</ul>
</div>
<?php endforeach; ?>
<?php endif; ?>

<?php $this->endblock(); ?>

0 comments on commit 67b51ff

Please sign in to comment.