Skip to content
Code-Schnipsel Gruppen Projekte
Commit d33364c3 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

refactor: basket -> order process

Übergeordneter f82ffc4c
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -60,7 +60,7 @@ public function __construct($basketId, $User = false)
$this->List = new ProductList();
$this->List->duplicate = true;
$data = QUI\ERP\Order\Handler::getInstance()->getBasketData($basketId);
$data = QUI\ERP\Order\Handler::getInstance()->getBasketData($basketId, $User);
$this->id = $basketId;
$this->User = $User;
......@@ -105,6 +105,14 @@ public function clear()
$this->List->clear();
}
/**
* @return int
*/
public function count()
{
return $this->List->count();
}
/**
* Import the products to the basket
*
......
......@@ -26,9 +26,16 @@
</thead>
<tbody>
{assign var=pos value=1}
{foreach $articles as $Article}
{foreach $products as $product}
<tr>
<td>{$pos}</td>
<td>
<div class="articles-article-title">{$product.title}</div>
<div class="articles-article-description">{$product.description}</div>
</td>
<td>{$product.quantity}</td>
<td>{$product.price}</td>
<td>{$product.sum}</td>
</tr>
{assign var=pos value=$pos+1}
{/foreach}
......@@ -39,4 +46,4 @@
{locale group="quiqqer/order" var="message.basket.is.empty"}
</div>
{/if}
</section>
\ No newline at end of file
</section>
......@@ -30,17 +30,16 @@ class Basket extends AbstractOrderingStep
*/
public function __construct($attributes = array())
{
// @todo
// $orderId = $this->getAttribute('orderId');
//
// if ($orderId) {
// $this->Basket = new QUI\ERP\Order\Basket\Basket($orderId);
// } else {
// $this->Basket = new QUI\ERP\Order\Basket\Basket();
// }
parent::__construct($attributes);
if ($this->getAttribute('Basket')) {
$this->Basket = $this->getAttribute('Basket');
} else {
$this->Basket = new QUI\ERP\Order\Basket\Basket(
$this->getAttribute('basketId')
);
}
$this->addCSSFile(dirname(__FILE__).'/Basket.css');
}
......@@ -96,6 +95,7 @@ public function showNext()
/**
* @return string
*
* @throws QUI\Exception
*/
public function getBody()
......@@ -104,14 +104,13 @@ public function getBody()
return '';
}
$Engine = QUI::getTemplateManager()->getEngine();
$Articles = $this->Basket->getArticles()->toUniqueList();
$Articles->hideHeader();
$Engine = QUI::getTemplateManager()->getEngine();
$Products = $this->Basket->getProducts()->getView();
$Engine->assign(array(
'articles' => $Articles->toArray(),
'count' => $Articles->count()
'Products' => $Products,
'products' => $Products->getProducts(),
'count' => $Products->count()
));
return $Engine->fetch(dirname(__FILE__).'/Basket.html');
......
......@@ -22,7 +22,12 @@ class OrderProcess extends QUI\Control
/**
* @var QUI\ERP\Order\OrderInProcess
*/
protected $Order = null;
protected $Order;
/**
* @var Basket\Basket
*/
protected $Basket = null;
/**
* @var null|AbstractOrderProcessProvider
......@@ -44,6 +49,7 @@ public static function getUrl()
* @param array $attributes
*
* @throws Exception
* @throws Basket\Exception
*/
public function __construct($attributes = array())
{
......@@ -57,6 +63,40 @@ public function __construct($attributes = array())
$this->addCSSFile(dirname(__FILE__).'/Controls/OrderProcess.css');
// current basket
$basketId = $this->getAttribute('basketId');
if ($basketId) {
try {
$this->Basket = new Basket\Basket($basketId);
} catch (QUI\ERP\Order\Basket\Exception $Exception) {
}
}
if ($this->Basket === null) {
$this->Basket = Handler::getInstance()->getBasketFromUser(
QUI::getUserBySession()
);
}
// insert basket products into the articles
$Order = $this->getOrder();
$Products = $this->Basket->getProducts();
$products = $Products->getProducts();
$Order->clearArticles();
foreach ($products as $Product) {
try {
/* @var QUI\ERP\Order\Basket\Product $Product */
$Order->addArticle($Product->toArticle());
} catch (QUI\Users\Exception $Exception) {
}
}
// current step
$steps = $this->getSteps();
$step = $this->getAttribute('step');
......@@ -75,7 +115,6 @@ public function __construct($attributes = array())
$this->setAttribute('step', $step);
}
if (!$step || !isset($steps[$step])) {
reset($steps);
$this->setAttribute('step', key($steps));
......@@ -87,6 +126,7 @@ public function __construct($attributes = array())
* Must the previous step be saved?
*
* @throws Exception
* @throws Basket\Exception
*/
protected function checkSubmission()
{
......@@ -334,6 +374,7 @@ public function getBody()
* @return AbstractOrderingStep
*
* @throws Exception
* @throws Basket\Exception
*/
public function getCurrentStep()
{
......@@ -349,6 +390,7 @@ public function getCurrentStep()
* @return AbstractOrderingStep
*
* @throws Exception
* @throws Basket\Exception
*/
public function getFirstStep()
{
......@@ -362,6 +404,7 @@ public function getFirstStep()
* @return bool|AbstractOrderingStep
*
* @throws Exception
* @throws Basket\Exception
*/
public function getNextStep($StartStep = null)
{
......@@ -400,6 +443,7 @@ public function getNextStep($StartStep = null)
* @return bool|AbstractOrderingStep
*
* @throws Exception
* @throws Basket\Exception
*/
public function getPreviousStep($StartStep = null)
{
......@@ -435,6 +479,7 @@ public function getPreviousStep($StartStep = null)
* @return bool|AbstractOrderingStep
*
* @throws Exception
* @throws Basket\Exception
*/
protected function getStepByName($name)
{
......@@ -453,6 +498,7 @@ protected function getStepByName($name)
* @return string
*
* @throws Exception
* @throws Basket\Exception
*/
protected function getCurrentStepName()
{
......@@ -473,6 +519,7 @@ protected function getCurrentStepName()
* @return bool|string
*
* @throws Exception
* @throws Basket\Exception
*/
protected function getNextStepName($StartStep = null)
{
......@@ -492,6 +539,7 @@ protected function getNextStepName($StartStep = null)
* @return bool|string
*
* @throws Exception
* @throws Basket\Exception
*/
protected function getPreviousStepName($StartStep = null)
{
......@@ -573,12 +621,21 @@ public function getOrder()
return $this->Order;
}
/**
* @return Basket\Basket
*/
public function getBasket()
{
return $this->Basket;
}
/**
* Return all steps
*
* @return array
*
* @throws Exception
* @throws Basket\Exception
*/
protected function getSteps()
{
......@@ -586,8 +643,8 @@ protected function getSteps()
$providers = QUI\ERP\Order\Handler::getInstance()->getOrderProcessProvider();
$Basket = new Controls\Basket(array(
'orderId' => $this->getOrder()->getId(),
'Order' => $this->getOrder(),
'basketId' => $this->Basket->getId(),
'Basket' => $this->Basket,
'priority' => 1
));
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren