Commit f767fcf6 authored by Dirk Wildt's avatar Dirk Wildt

0.0.6

parent 9ffbeee3
0.0.6
19-06-29
Feature
* #t3857: Relation cell <> product
* #t3818: Workflow Group
* #t3815: New field tx_tile_domain_model_cell.ticket
Affectd files:
......
......@@ -2,13 +2,13 @@
namespace Netzmacher\Tile\Controller;
use \Netzmacher\QuickShop\Domain\Repository\ProductRepository;
use \Netzmacher\Tile\Domain\Repository\AreaRepository;
use \Netzmacher\Tile\Domain\Repository\CategoryRepository;
use \Netzmacher\Tile\Domain\Repository\CellRepository;
use \Netzmacher\Tile\Domain\Repository\CssRepository;
use \Netzmacher\Tile\Domain\Repository\GroupRepository;
use \Netzmacher\Tile\Domain\Repository\PageRepository;
use \Netzmacher\Tile\Domain\Repository\ProductRepository;
use \Netzmacher\Tile\Domain\Repository\TicketRepository;
/* * *
......@@ -85,7 +85,7 @@ abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\Acti
/**
* ticketRepository
*
* @var \Netzmacher\QuickShop\Domain\Repository\ProductRepository
* @var \Netzmacher\Tile\Domain\Repository\ProductRepository
* @inject
*/
protected $productRepository = null;
......
......@@ -99,6 +99,38 @@ class AreaController extends AbstractController
return $sum;
}
/**
* _sumGroupProduct
*
* @param \Netzmacher\Tile\Domain\Model\Area $area
* @param string $relation
* @return void
* @version 0.0.6
* @since 0.0.6
* @internal #t3857
*/
private function _sumGroupProduct( \Netzmacher\Tile\Domain\Model\Area $area )
{
$products = [];
$sum = 0;
$rows = $this->_getCells( $area );
foreach( $rows as $row )
{
if( !$row[ 'tx_tile_product' ] )
{
continue;
}
$product = $row[ 'tx_tile_product' ];
if( in_array( $row[ 'tx_tile_product' ], $products ) )
{
continue;
}
$products[] = $product;
$sum++;
}
return $sum;
}
/**
* _sumRelation
*
......@@ -170,22 +202,26 @@ class AreaController extends AbstractController
*
* @param \Netzmacher\Tile\Domain\Model\Area $area
* @return void
* @version 0.0.2
* @version 0.0.6
* @since 0.0.1
* @internal #t3857
*/
public function deleteAction( \Netzmacher\Tile\Domain\Model\Area $area )
{
$groups = [];
$products = [];
$cells = $this->cellRepository->findBytx_tile_area( $area->getUid() );
foreach( $cells as $cell )
{
$groups[] = $cell->getTxTileGroup();
$products[] = $cell->getTxTileProduct();
$area->removeTxTileCell( $cell );
$this->cellRepository->remove( $cell );
}
$this->areaRepository->remove( $area );
$this->groupRepository->removeGroups( $groups );
$this->productRepository->removeProducts( $products );
$this->redirect( 'list', 'Module' );
}
......@@ -240,6 +276,7 @@ class AreaController extends AbstractController
{
$this->view->assign( 'sumCategory', $this->_sumRelation( $area, 'tx_tile_category' ) );
$this->view->assign( 'sumGroup', $this->_sumGroup( $area ) );
$this->view->assign( 'sumGroupProduct', $this->_sumGroupProduct( $area ) );
$this->view->assign( 'sumTicket', $this->_sumRelation( $area, 'tx_tile_ticket' ) );
$this->view->assign( 'sumTile', $this->_sumTile( $area ) );
$this->view->assign( 'area', $area );
......
......@@ -17,7 +17,7 @@ use Netzmacher\Tile\Utility\Module\SessionModuleUtility;
/**
* ShopController
* @internal #3823
* @internal #t3823
*/
class ShopController extends AbstractController
{
......@@ -117,8 +117,15 @@ class ShopController extends AbstractController
$clone = new \Netzmacher\Tile\Domain\Model\Area;
$properties = $area->_getProperties();
// uid, pid
unset( $properties[ 'uid' ] );
$properties[ 'pid' ] = $pid;
// image
// #t3849, 190702, dwildt: next line doesn't work
//$clone->setImage( $area->getImage() );
unset( $properties[ 'image' ] );
foreach( $properties as $key => $value )
{
......@@ -136,6 +143,56 @@ class ShopController extends AbstractController
return $uid;
}
/**
* _cloneCell
*
* @param int $pid
* @param int $cloneAreaUid
* @param array $properties
* @return void
* @version 0.0.6
* @since 0.0.6
* @internal #t3845
*/
private function _cloneCell( $pid, $cloneAreaUid, $properties )
{
$clone = new \Netzmacher\Tile\Domain\Model\Cell;
// uid, pid
unset( $properties[ 'uid' ] );
$properties[ 'pid' ] = $pid;
// Area
$clone->setTxTileArea( $this->areaRepository->findByUid( $cloneAreaUid ) );
unset( $properties[ 'tx_tile_area' ] );
// Category
$clone->setTxTileCategory( $properties[ 'tx_tile_category' ] );
unset( $properties[ 'tx_tile_category' ] );
// Ticket (must be before product!
$clone->setTxTileTicket( $properties[ 'tx_tile_ticket' ] );
unset( $properties[ 'tx_tile_ticket' ] );
// Group and Product
$groupClone = $this->_cloneCellGroup( $properties[ 'tx_tile_group' ], $pid );
if( $groupClone )
{
$clone = $this->_createProductByGroup( $clone, $groupClone, $pid );
$clone->setTxTileGroup( $groupClone );
}
unset( $properties[ 'tx_tile_group' ] );
unset( $properties[ 'tx_tile_product' ] );
// all other properties
foreach( $properties as $key => $value )
{
$clone->_setProperty( $key, $value );
}
$this->cellRepository->add( $clone );
}
/**
* _cloneCellGroup
*
......@@ -173,11 +230,59 @@ class ShopController extends AbstractController
$groupCloneUid = $groupClone->getUid();
$groups[ $groupOrigUid ] = $groupCloneUid;
//$this->addFlashMessage( __METHOD__ . ' (#' . __LINE__ . '): Group added with uid (#' . $groupCloneUid . ')', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::WARNING );
return $this->groupRepository->findByUid( $groupCloneUid );
}
/**
* _createProductByGroup
*
* @param \Netzmacher\Tile\Domain\Model\Cell $cell
* @param \Netzmacher\Tile\Domain\Model\Group $group
* @param int $pid
* @return \Netzmacher\Tile\Domain\Model\Cell
* @version 0.0.6
* @since 0.0.6
* @internal #t3857
*/
private function _createProductByGroup( \Netzmacher\Tile\Domain\Model\Cell $cell, \Netzmacher\Tile\Domain\Model\Group $group, $pid ): \Netzmacher\Tile\Domain\Model\Cell
{
static $products = []; // groupUid => cloneUid
if( empty( $group ) )
{
return $cell;
}
$groupUid = $group->getUid();
if( in_array( $groupUid, array_keys( $products ) ) )
{
$productUid = $products[ $groupUid ];
$product = $this->productRepository->findByUid( $productUid );
$cell->setTxTileProduct( $product );
return $cell;
}
$product = new \Netzmacher\Tile\Domain\Model\Product;
$product->_setProperty( 'pid', $pid );
$ticketUid = $cell->getTxTileTicket();
$ticket = $this->ticketRepository->findByUid( $ticketUid );
$product->setPrice( $ticket->getPrice() );
$product->setStockmanagement( true );
$product->setStockquantity( 1 );
$product->setTitle( $group->getTitle() );
$this->productRepository->add( $product );
$this->persistenceManager->persistAll();
$productUid = $product->getUid();
$products[ $groupUid ] = $productUid;
$cell->setTxTileProduct( $product );
return $cell;
}
/**
* _cloneCells
*
......@@ -191,49 +296,11 @@ class ShopController extends AbstractController
*/
private function _cloneCells( $area, $pid, $cloneAreaUid )
{
$rows = $this->cellRepository->getCellsByArea( $area );
foreach( $rows as $properties )
$aCells = $this->cellRepository->getCellsByArea( $area );
foreach( $aCells as $aCell )
{
$clone = new \Netzmacher\Tile\Domain\Model\Cell;
// uid, pid
unset( $properties[ 'uid' ] );
$properties[ 'pid' ] = $pid;
// Area
$clone->setTxTileArea( $this->areaRepository->findByUid( $cloneAreaUid ) );
unset( $properties[ 'tx_tile_area' ] );
// Category
$clone->setTxTileCategory( $properties[ 'tx_tile_category' ] );
unset( $properties[ 'tx_tile_category' ] );
// Group
$groupClone = $this->_cloneCellGroup( $properties[ 'tx_tile_group' ], $pid );
if( $groupClone )
{
$clone->setTxTileGroup( $groupClone );
}
unset( $properties[ 'tx_tile_group' ] );
// Ticket
$clone->setTxTileTicket( $properties[ 'tx_tile_ticket' ] );
unset( $properties[ 'tx_tile_ticket' ] );
// all other properties
foreach( $properties as $key => $value )
{
$clone->_setProperty( $key, $value );
}
// var_dump( __METHOD__, __LINE__, $clone->getTxTileCategory( ) );
// die();
$this->cellRepository->add( $clone );
// $this->addFlashMessage( __METHOD__ . ' (#' . __LINE__ . '): Cell with area uid: ' . $cloneAreaUid, '', \TYPO3\CMS\Core\Messaging\AbstractMessage::WARNING );
// $this->persistenceManager->persistAll();
// $uid = $clone->getUid();
$this->_cloneCell( $pid, $cloneAreaUid, $aCell );
}
}
/**
......
......@@ -344,12 +344,6 @@ class TicketController extends AbstractController
*/
private function _setTicketForCell( \Netzmacher\Tile\Domain\Model\Cell $cell )
{
// $newProduct = new \Netzmacher\QuickShop\Domain\Model\Product();
// $title = $cell->getTitle();
// $newProduct->setTitle( $title );
//// $newProduct->setType( 'page' );
// $this->productRepository->add( $newProduct );
$cell->setTxTileTicket( SessionModuleUtility::getFormCellTicket() );
$cell->setGroupcss( SessionModuleUtility::getFormCellMode() );
$this->cellRepository->update( $cell );
......
......@@ -63,7 +63,7 @@ class Area extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
/**
* type
*
* @var mixed
* @var string
*/
protected $type = '';
......
......@@ -56,11 +56,16 @@ class Cell extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* txTileGroup
*
* @var \Netzmacher\Tile\Domain\Model\Group
* @todo check lazy, check cascade remove
*/
protected $txTileGroup = null;
/**
* txTileProduct
*
* @var \Netzmacher\Tile\Domain\Model\Product
*/
protected $txTileProduct = null;
/**
* txTileTicket
*
......@@ -105,21 +110,25 @@ class Cell extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
$cssClass = null;
$devider = null;
if($cell->getX() == $range['minX']){
$cssClass = $cssClass . $devider . 'west' ;
if( $cell->getX() == $range[ 'minX' ] )
{
$cssClass = $cssClass . $devider . 'west';
$devider = ' ';
}
if($cell->getX() == $range['maxX']){
$cssClass = $cssClass . $devider . 'east' ;
if( $cell->getX() == $range[ 'maxX' ] )
{
$cssClass = $cssClass . $devider . 'east';
$devider = ' ';
}
if($cell->getY() == $range['minY']){
$cssClass = $cssClass . $devider . 'north' ;
if( $cell->getY() == $range[ 'minY' ] )
{
$cssClass = $cssClass . $devider . 'north';
$devider = ' ';
}
if($cell->getY() == $range['maxY']){
$cssClass = $cssClass . $devider . 'south' ;
if( $cell->getY() == $range[ 'maxY' ] )
{
$cssClass = $cssClass . $devider . 'south';
$devider = ' ';
}
......@@ -275,7 +284,6 @@ class Cell extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
/**
* Returns the txTileGroup
*
*
* @return \Netzmacher\Tile\Domain\Model\Group $txTileGroup
*/
public function getTxTileGroup()
......@@ -288,7 +296,7 @@ class Cell extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return void
*/
public function removeTxTileGroup( )
public function removeTxTileGroup()
{
$this->txTileGroup = null;
}
......@@ -304,6 +312,37 @@ class Cell extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
$this->txTileGroup = $txTileGroup;
}
/**
* Returns the txTileProduct
*
* @return \Netzmacher\Tile\Domain\Model\Product $txTileProduct
*/
public function getTxTileProduct()
{
return $this->txTileProduct;
}
/**
* Removes a Product
*
* @return void
*/
public function removeTxTileProduct()
{
$this->txTileProduct = null;
}
/**
* Sets the txTileProduct
*
* @param \Netzmacher\Tile\Domain\Model\Product $txTileProduct
* @return void
*/
public function setTxTileProduct( \Netzmacher\Tile\Domain\Model\Product $txTileProduct )
{
$this->txTileProduct = $txTileProduct;
}
/**
* Returns the txTileTicket
*
......
<?php
namespace Netzmacher\Tile\Domain\Model;
/* * *
*
* This file is part of the "Book a tile!" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2019 Dirk Wildt (Die Netzmacher) <http://wildt@die-netzmacher.de>, Die Netzmacher
*
* * */
/**
* Product
*/
class Product extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
const TABLE_NAME = 'tx_quickshop_products';
/**
* description
*
* @var string
*/
protected $description = '';
/**
* price
*
* @var float
*/
protected $price = '';
/**
* quantity_max
*
* @var integer
*/
protected $quantityMax = '';
/**
* short
*
* @var string
*/
protected $short = '';
/**
* sku
*
* @var string
*/
protected $sku = '';
/**
* stockmanagement
*
* @var boolean
*/
protected $stockmanagement = '';
/**
* stockquantity
*
* @var integer
*/
protected $stockquantity = '';
/**
* title
*
* @var string
* @validate NotEmpty
*/
protected $title = '';
/**
* type
*
* @var string
*/
protected $type = 'record';
/**
* Returns the description
*
* @return string $description
*/
public function getDescription()
{
return $this->description;
}
/**
* Sets the description
*
* @param string $description
* @return void
*/
public function setDescription( $description )
{
$this->description = $description;
}
/**
* Returns the price
*
* @return float $price
*/
public function getPrice() : float
{
return $this->price;
}
/**
* Sets the price
*
* @param float $price
* @return void
*/
public function setPrice( $price )
{
$this->price = $price;
}
/**
* Returns the quantityMax
*
* @return string $quantityMax
*/
public function getQuantityMax()
{
return $this->quantityMax;
}
/**
* Sets the quantityMax
*
* @param string $quantityMax
* @return void
*/
public function setQuantityMax( $quantityMax )
{
$this->quantityMax = $quantityMax;
}
/**
* Returns the short
*
* @return string $short
*/
public function getShort()
{
return $this->short;
}
/**
* Sets the short
*
* @param string $short
* @return void
*/
public function setShort( $short )
{
$this->short = $short;
}
/**
* Returns the sku
*
* @return string $sku
*/
public function getSku()
{
return $this->sku;
}
/**
* Sets the sku
*
* @param string $sku
* @return void
*/
public function setSku( $sku )
{
$this->sku = $sku;
}
/**
* Returns the stockmanagement
*
* @return boolean $stockmanagement
*/
public function getStockmanagement() : bool
{
return $this->stockmanagement;
}
/**
* Sets the stockmanagement
*
* @param boolean $stockmanagement
* @return void
*/
public function setStockmanagement( $stockmanagement )
{
$this->stockmanagement = $stockmanagement;
}
/**
* Returns the stockquantity
*
* @return integer $stockquantity
*/
public function getStockquantity() : int
{
return $this->stockquantity;
}
/**
* Sets the stockquantity
*
* @param integer $stockquantity
* @return void
*/
public function setStockquantity( $stockquantity )
{
$this->stockquantity = $stockquantity;
}
/**
* Returns the title
*
* @return string $title
*/
public function getTitle()
{
return $this->title;
}
/**
* Sets the title
*
* @param string $title
* @return void
*/
public function setTitle( $title )
{
$this->title = $title;
}
/**
* Returns the type
*
* @return string $type
*/
public function getType()
{
return $this->type;
}
/**
* Sets the type
*
* @param string $type
* @return void
*/
public function setType( $type )
{
$this->type = $type;
}
}
\ No newline at end of file
......@@ -43,26 +43,6 @@ class Ticket extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*/
protected $txTileCss = null;
// /**
// * __construct
// */
// public function __construct()
// {
//
// //Do not remove the next line: It would break the functionality
// $this->initStorageObjects();
// }
//
// /**
// * Initializes all ObjectStorage properties
// *
// * @return void
// */
// protected function initStorageObjects()
// {
// $this->txTileGroup = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
// }
/**
* Returns the price
*
......
<?php
namespace Netzmacher\Tile\Domain\Repository;
/* * *
*
* This file is part of the "Book a tile!" Extension for TYPO3 CMS.