Commit 2a81ab3e authored by Dirk Wildt's avatar Dirk Wildt

8.17.0

parent 20615d31
......@@ -7,8 +7,17 @@ TODO
19-01-21
Features
* #i0288: E-mail template: unused option will removed automatically
Affected file:
* Classes/Lib/Powermail/Powermail.php
---------
New files
---------
* Classes/Utility/Template/CleanupTemplateUtility.php
* Resources/Private/Templates/E-Mail/caddy.html
--------------
Affected files
--------------
* Classes/Lib/Powermail
* Attachments.php
* Powermail.php
* #i0286: new service options: insurance, recycle fee.
---------
New files
......
......@@ -31,7 +31,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
* Class for extending the Caddy classes
*
* @package TYPO3
* @subpackage org
* @subpackage caddy
* @author Dirk Wildt <http://wildt.at.die-netzmacher.de>
* @version 8.15.0
* @since 8.7.0
......
......@@ -2,6 +2,9 @@
namespace Netzmacher\Caddy\Lib\Powermail;
use Netzmacher\Caddy\Utility\Template\CleanupTemplateUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/* * *************************************************************
* Copyright notice
*
......@@ -31,7 +34,7 @@ namespace Netzmacher\Caddy\Lib\Powermail;
* @author Dirk Wildt <http://wildt.at.die-netzmacher.de>
* @package TYPO3
* @subpackage tx_caddy
* @version 8.7.0
* @version 8.17.0
* @since 2.0.0
*/
class Attachments extends \Netzmacher\Caddy\AbstractPlugin
......@@ -448,10 +451,10 @@ class Attachments extends \Netzmacher\Caddy\AbstractPlugin
$this->caddy = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( \Netzmacher\Caddy\Lib\Caddy\Caddy::class );
$this->dynamicMarkers = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( \Netzmacher\Caddy\Lib\Dynamicmarkers::class );
// #i0191, 180109, #i0184, 171201, dwildt, ~
// #i0191, 180109, #i0184, 171201, dwildt, ~
switch( true )
{
// #i0195, 180118, dwildt, ~
// #i0195, 180118, dwildt, ~
case($this->zz_getTYPO3Version() <= 7006000):
require_once( \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath( 't3_tcpdf' ) . 'class.tx_t3_tcpdf.php' );
break;
......@@ -500,6 +503,13 @@ class Attachments extends \Netzmacher\Caddy\AbstractPlugin
$absFileName = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName( $file );
$tmplFile = file_get_contents( $absFileName );
// :TODO: get pid of current plugin
$pid = $GLOBALS[ "TSFE" ]->id;
$CleanupTemplateUtility = GeneralUtility::makeInstance( CleanupTemplateUtility::class );
$tmplFile = $CleanupTemplateUtility->RemoveUnusedSubparts( $tmplFile, $pid );
// var_dump(__METHOD__, __LINE__, $tmplFile);
// die();
$this->tmpl = array();
$this->tmpl[ 'all' ] = $this->MarkerBasedTemplateService->getSubpart( $tmplFile, $markerAll );
$this->tmpl[ 'item' ] = $this->MarkerBasedTemplateService->getSubpart( $this->tmpl[ 'all' ], $markerItem );
......@@ -513,7 +523,8 @@ class Attachments extends \Netzmacher\Caddy\AbstractPlugin
* @param $string $case : deliveryorder || invoice || revocation || terms
* @return void
* @access private
* @version 2.0.0
* @internal #i0288
* @version 8.17.0
* @since 2.0.0
*/
private function initTemplateTable( $case )
......@@ -1143,7 +1154,6 @@ class Attachments extends \Netzmacher\Caddy\AbstractPlugin
require_once( $path2lib . 'FPDI-1.5.4/fpdi.php' );
$this->tcpdf = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( 'FPDI' );
// //$this->tcpdf = new FPDI( );
// $path2lib = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath( 't3_tcpdf' ) . 'Resources/Private/PHP/';
// require_once( $path2lib . 'tcpdf/tcpdf.php' );
// $this->tcpdf = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( 'TCPDF' );
......@@ -1435,7 +1445,6 @@ class Attachments extends \Netzmacher\Caddy\AbstractPlugin
$keepmargins = true;
$this->tcpdf->SetMargins( $left, $top, $right, $keepmargins );
//$this->zz_debugToConsole( 'dev only.', __METHOD__, __LINE__ );
// Write HTML cell
$this->tcpdf->writeHtmlCell( $w, $h, $cursor[ 'x' ], $cursor[ 'y' ], $htmlContent, $border, $ln, $fill, $reseth, $align, $autopadding );
//$this->zz_debugToConsole( 'dev only.', __METHOD__, __LINE__ );
......@@ -2152,4 +2161,4 @@ class Attachments extends \Netzmacher\Caddy\AbstractPlugin
return $version;
}
}
\ No newline at end of file
}
......@@ -2,6 +2,9 @@
namespace Netzmacher\Caddy\Lib\Powermail;
use Netzmacher\Caddy\Utility\Template\CleanupTemplateUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/* * *************************************************************
* Copyright notice
*
......@@ -581,7 +584,7 @@ class Powermail extends \Netzmacher\Caddy\AbstractPlugin
}
/**
* caddyEmailSubparts( ) : Remove unused subparts
* caddyEmailSubparts( ): Remove unused subparts
*
* @param string $tmpl
* @return string $tmpl
......@@ -592,178 +595,11 @@ class Powermail extends \Netzmacher\Caddy\AbstractPlugin
*/
private function caddyEmailSubparts( $tmpl )
{
// :TODO: get pid of current plugin
$pid = $GLOBALS[ "TSFE" ]->id;
$sesArray = $GLOBALS[ 'TSFE' ]->fe_user->getKey( 'ses', $this->extKey . '_' . $pid );
$tmpl = $this->caddyEmailSubpartsRemoveInsurance( $sesArray, $tmpl );
$tmpl = $this->caddyEmailSubpartsRemovePayment( $sesArray, $tmpl );
$tmpl = $this->caddyEmailSubpartsRemoveRecyclingfee( $sesArray, $tmpl );
$tmpl = $this->caddyEmailSubpartsRemoveShipping( $sesArray, $tmpl );
$tmpl = $this->caddyEmailSubpartsRemoveSpecials( $sesArray, $tmpl );
$tmpl = $this->caddyEmailSubpartsRemoveTaxNormal( $sesArray, $tmpl );
$tmpl = $this->caddyEmailSubpartsRemoveTaxReduced( $sesArray, $tmpl );
return $tmpl;
}
/**
* caddyEmailSubpartsRemove( ) : Removes a subpart, if net is empty
*
* @param array $optionType :
* @param array $sesArray
* @param string $tmpl
* @return string $tmpl
* @access private
* @internal #i0288
* @version 8.17.0
* @since 8.17.0
*/
private function caddyEmailSubpartsRemove( $optionType, $sesArray, $tmpl )
{
$value = $sesArray[ 'options' ][ $optionType ][ 'sum' ][ 'net' ];
if( !empty( $value ) )
{
return $tmpl;
}
$subpart = '###OPTIONS' . strtoupper( $optionType ) . '###';
$tmpl = $this->MarkerBasedTemplateService->substituteSubpart( $tmpl, $subpart, null );
return $tmpl;
}
/**
* caddyEmailSubpartsRemoveInsurance( ) : Removes a subpart, if net is empty
*
* @param array $sesArray
* @param string $tmpl
* @return string $tmpl
* @access private
* @internal #i0288
* @version 8.17.0
* @since 8.17.0
*/
private function caddyEmailSubpartsRemoveInsurance( $sesArray, $tmpl )
{
$tmpl = $this->caddyEmailSubpartsRemove( 'insurance', $sesArray, $tmpl );
return $tmpl;
}
/**
* caddyEmailSubpartsRemovePayment( ) : Removes a subpart, if net is empty
*
* @param array $sesArray
* @param string $tmpl
* @return string $tmpl
* @access private
* @internal #i0288
* @version 8.17.0
* @since 8.17.0
*/
private function caddyEmailSubpartsRemovePayment( $sesArray, $tmpl )
{
$tmpl = $this->caddyEmailSubpartsRemove( 'payment', $sesArray, $tmpl );
return $tmpl;
}
/**
* caddyEmailSubpartsRemoveRecyclingfee( ) : Removes a subpart, if net is empty
*
* @param array $sesArray
* @param string $tmpl
* @return string $tmpl
* @access private
* @internal #i0288
* @version 8.17.0
* @since 8.17.0
*/
private function caddyEmailSubpartsRemoveRecyclingfee( $sesArray, $tmpl )
{
$tmpl = $this->caddyEmailSubpartsRemove( 'recyclingfee', $sesArray, $tmpl );
return $tmpl;
}
/**
* caddyEmailSubpartsRemoveShipping( ) : Removes a subpart, if net is empty
*
* @param array $sesArray
* @param string $tmpl
* @return string $tmpl
* @access private
* @internal #i0288
* @version 8.17.0
* @since 8.17.0
*/
private function caddyEmailSubpartsRemoveShipping( $sesArray, $tmpl )
{
$tmpl = $this->caddyEmailSubpartsRemove( 'shipping', $sesArray, $tmpl );
return $tmpl;
}
$CleanupTemplateUtility = GeneralUtility::makeInstance( CleanupTemplateUtility::class );
$tmpl = $CleanupTemplateUtility->RemoveUnusedSubparts( $tmpl, $pid );
/**
* caddyEmailSubpartsRemoveTaxNormal( ) : Removes a subpart, if net is empty
*
* @param array $sesArray
* @param string $tmpl
* @return string $tmpl
* @access private
* @internal #i0288
* @version 8.17.0
* @since 8.17.0
*/
private function caddyEmailSubpartsRemoveTaxNormal( $sesArray, $tmpl )
{
$value = $sesArray[ 'sumsumtaxnormal' ];
if( !empty( $value ) )
{
return $tmpl;
}
$subpart = '###TAXNORMAL###';
$tmpl = $this->MarkerBasedTemplateService->substituteSubpart( $tmpl, $subpart, null );
return $tmpl;
}
/**
* caddyEmailSubpartsRemoveTaxReduced( ) : Removes a subpart, if net is empty
*
* @param array $sesArray
* @param string $tmpl
* @return string $tmpl
* @access private
* @internal #i0288
* @version 8.17.0
* @since 8.17.0
*/
private function caddyEmailSubpartsRemoveTaxReduced( $sesArray, $tmpl )
{
$value = $sesArray[ 'sumsumtaxreduced' ];
if( !empty( $value ) )
{
return $tmpl;
}
$subpart = '###TAXREDUCED###';
$tmpl = $this->MarkerBasedTemplateService->substituteSubpart( $tmpl, $subpart, null );
return $tmpl;
}
/**
* caddyEmailSubpartsRemoveSpecials( ) : Removes a subpart, if net is empty
*
* @param array $sesArray
* @param string $tmpl
* @return string $tmpl
* @access private
* @internal #i0288
* @version 8.17.0
* @since 8.17.0
*/
private function caddyEmailSubpartsRemoveSpecials( $sesArray, $tmpl )
{
$tmpl = $this->caddyEmailSubpartsRemove( 'specials', $sesArray, $tmpl );
return $tmpl;
}
......
<?php
namespace Netzmacher\Caddy\Utility\Template;
/* * *************************************************************
* Copyright notice
*
* (c) 2019 - Dirk Wildt <http://wildt.at.die-netzmacher.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
* ************************************************************* */
/**
* Class for extending the Caddy classes
*
* @package TYPO3
* @subpackage caddy
* @author Dirk Wildt <http://wildt.at.die-netzmacher.de>
* @internal #i0288
* @version 8.17.0
* @since 8.17.0
*/
class CleanupTemplateUtility extends \Netzmacher\Caddy\AbstractPlugin
{
public $extKey = 'caddy';
private $sessionArray = [];
/**
* caddyEmailSubparts( ) : Remove unused subparts
*
* @param string $tmpl
* @param integer $pid
* @return string $tmpl
* @access public
* @version 8.17.0
* @since 8.17.0
*/
public function RemoveUnusedSubparts( $tmpl, $pid = null )
{
$this->_initSessionArray( $pid );
$tmpl = $this->_removeInsurance( $tmpl );
$tmpl = $this->_removePayment( $tmpl );
$tmpl = $this->_removeRecyclingfee( $tmpl );
$tmpl = $this->_removeShipping( $tmpl );
$tmpl = $this->_removeSpecials( $tmpl );
$tmpl = $this->_removeTaxNormal( $tmpl );
$tmpl = $this->_removeTaxReduced( $tmpl );
// var_dump( __METHOD__, __LINE__, $tmpl );
// die();
return $tmpl;
}
/**
* _initSessionArray( ) : Remove unused subparts
*
* @param string $tmpl
* @param integer $pid
* @return string $tmpl
* @access private
* @version 8.17.0
* @since 8.17.0
*/
public function _initSessionArray( $pid )
{
if( empty( $pid ) )
{
$pid = $GLOBALS[ "TSFE" ]->id;
}
$this->sessionArray = $GLOBALS[ 'TSFE' ]->fe_user->getKey( 'ses', $this->extKey . '_' . $pid );
}
/**
* _remove( ): Removes a subpart, if sum net is empty
*
* @param array $optionType :
* @param string $tmpl
* @return string $tmpl
* @access private
* @version 8.17.0
* @since 8.17.0
*/
private function _remove( $optionType, $tmpl )
{
$value = $this->sessionArray[ 'options' ][ $optionType ][ 'sum' ][ 'net' ];
if( !empty( $value ) )
{
return $tmpl;
}
$subpart = '###OPTIONS' . strtoupper( $optionType ) . '###';
$tmpl = $this->MarkerBasedTemplateService->substituteSubpart( $tmpl, $subpart, null );
return $tmpl;
}
/**
* _removeInsurance( ) : Removes a subpart, if sum net is empty
*
* @param string $tmpl
* @return string $tmpl
* @access private
* @version 8.17.0
* @since 8.17.0
*/
private function _removeInsurance( $tmpl )
{
$tmpl = $this->_remove( 'insurance', $tmpl );
return $tmpl;
}
/**
* _removePayment( ) : Removes a subpart, if sum net is empty
*
* @param string $tmpl
* @return string $tmpl
* @access private
* @version 8.17.0
* @since 8.17.0
*/
private function _removePayment( $tmpl )
{
$tmpl = $this->_remove( 'payment', $tmpl );
return $tmpl;
}
/**
* _removeRecyclingfee( ) : Removes a subpart, if sum net is empty
*
* @param string $tmpl
* @return string $tmpl
* @access private
* @version 8.17.0
* @since 8.17.0
*/
private function _removeRecyclingfee( $tmpl )
{
$tmpl = $this->_remove( 'recyclingfee', $tmpl );
return $tmpl;
}
/**
* _removeShipping( ) : Removes a subpart, if sum net is empty
*
* @param string $tmpl
* @return string $tmpl
* @access private
* @version 8.17.0
* @since 8.17.0
*/
private function _removeShipping( $tmpl )
{
$tmpl = $this->_remove( 'shipping', $tmpl );
return $tmpl;
}
/**
* _removeTaxNormal( ) : Removes a subpart, if sum net is empty
*
* @param string $tmpl
* @return string $tmpl
* @access private
* @version 8.17.0
* @since 8.17.0
*/
private function _removeTaxNormal( $tmpl )
{
$value = $this->sessionArray[ 'sumsumtaxnormal' ];
if( !empty( $value ) )
{
return $tmpl;
}
$subpart = '###TAXNORMAL###';
$tmpl = $this->MarkerBasedTemplateService->substituteSubpart( $tmpl, $subpart, null );
return $tmpl;
}
/**
* _removeTaxReduced( ) : Removes a subpart, if sum net is empty
*
* @param string $tmpl
* @return string $tmpl
* @access private
* @version 8.17.0
* @since 8.17.0
*/
private function _removeTaxReduced( $tmpl )
{
$value = $this->sessionArray[ 'sumsumtaxreduced' ];
if( !empty( $value ) )
{
return $tmpl;
}
$subpart = '###TAXREDUCED###';
$tmpl = $this->MarkerBasedTemplateService->substituteSubpart( $tmpl, $subpart, null );
return $tmpl;
}
/**
* _removeSpecials( ) : Removes a subpart, if sum net is empty
*
* @param string $tmpl
* @return string $tmpl
* @access private
* @version 8.17.0
* @since 8.17.0
*/
private function _removeSpecials( $tmpl )
{
$tmpl = $this->_remove( 'specials', $tmpl );
return $tmpl;
}
}
plugin.caddy {
# cat=caddy - options - insurance/enable/201; type=boolean; label= Enabled:Disable it, if there isn't any transport insurance fee
options.insurance.1.enabled = 1
# cat=caddy - options - insurance/enable/201; type=boolean; label= Enabled:Enable it, if you like to use a transport insurance fee
options.insurance.1.enabled = 0
# cat=caddy - options - insurance/enable/203; type=options[normal,reduced]; label= Tax rate:Tax rate for extra costs for the transport insurance fee
options.insurance.1.taxrate = normal
......
plugin.caddy {
# cat=caddy - options - recyclingfee/enable/201; type=boolean; label= Enabled:Disable it, if there isn't any recycling fee
options.recyclingfee.1.enabled = 1
# cat=caddy - options - recyclingfee/enable/201; type=boolean; label= Enabled:Enable it, if you like to use a recycling fee
options.recyclingfee.1.enabled = 0
# cat=caddy - options - recyclingfee/enable/203; type=options[normal,reduced]; label= Tax rate:Tax rate for extra costs for the recycling fee
options.recyclingfee.1.taxrate = normal
......
.. ==================================================
.. ==================================================
.. FOR YOUR INFORMATION
.. --------------------------------------------------
.. -*- coding: utf-8 -*- with BOM.
......
.. ==================================================
.. ==================================================
.. FOR YOUR INFORMATION
.. --------------------------------------------------
.. -*- coding: utf-8 -*- with BOM.
......
......@@ -11,6 +11,15 @@
Calculating
===========
Samples
-------
Please refer to:
* :ref:`Administrators > Setup > Caddy > Options <administrators_setup_caddy_options>`
Table of Contents
-----------------
......@@ -18,8 +27,8 @@ Table of Contents
:maxdepth: 3
:titlesonly:
10_Default/Index
20_BasedOnPrice/Index
30_BasedOnQuantity/Index
40_BasedOnEach/Index
50_BasedOnWeight/Index
\ No newline at end of file
Default/Index
BasedOnPrice/Index
BasedOnQuantity/Index
BasedOnEach/Index
BasedOnWeight/Index
\ No newline at end of file
......@@ -34,8 +34,9 @@ Content
Calculating/Index
Epayment/Index
Labelling/Index
Options/Index
Newsletter/Index
Powermail/Index
Privacy/Index
Templating/Index
Variants/Index
Variants/Index
\ No newline at end of file
.. ==================================================
.. FOR YOUR INFORMATION
.. --------------------------------------------------
.. -*- coding: utf-8 -*- with BOM.
.. include:: ../../../../Includes.txt
.. _administrators_setup_caddy_options:
Options
=======
Table of Contents
-----------------
.. toctree::
:maxdepth: 3
:titlesonly:
Insurance/Index
Payment/Index
Recyclingfee/Index
Shipping/Index
Specials/Index
\ No newline at end of file
.. ==================================================
.. FOR YOUR INFORMATION
.. --------------------------------------------------
.. -*- coding: utf-8 -*- with BOM.
.. include:: ../../../../../Includes.txt
.. _administrators_setup_caddy_options_insurance:
Insurance
=========
Setup
-----
Enable or disable it with the Constant Editor.
* Constant Editor > [CADDY - OPTIONS - INSURANCE]
Configuration
-------------
.. code:: php
plugin.tx_caddy_pi1.api.options {
// preset, options
recyclingfee =
recyclingfee {
preset = {$plugin.caddy.options.recyclingfee.1.enabled}
// 1: transport insurance
options =
options {
1 {
enabled = {$plugin.caddy.options.recyclingfee.1.enabled}
title = TEXT
title {
data = LLL:EXT:caddy/Resources/Private/Language/Plugins/pi1/locallang.xlf:feeperitem
}
extra = each
extra {
1 {
extra = 0.15
}
}
tax = {$plugin.caddy.options.recyclingfee.1.taxrate}
}
}
}
}
Details about Calculating
-------------------------
* :ref:`Administrators > Setup > Caddy > Calculating <administrators_setup_caddy-calculating>`
\ No newline at end of file
.. ==================================================
.. FOR YOUR INFORMATION