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

feat: Bestellung durchführen

Übergeordneter 1237f475
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -27,10 +27,12 @@ function ($orderId, $step) {
}
$OrderProcess->setAttribute('step', $Current->getName());
$html = $OrderProcess->create();
$current = $OrderProcess->getCurrentStep()->getName();
return array(
'html' => $OrderProcess->create(),
'step' => $Current->getName()
'html' => $html,
'step' => $current
);
},
array('orderId', 'step')
......
......@@ -21,17 +21,16 @@ function ($orderId, $current) {
'orderId' => (int)$orderId
));
$Next = $OrderProcess->getNextStep();
$result = $OrderProcess->create();
$next = false;
if (!$Next) {
$Next = $OrderProcess->getFirstStep();
if ($OrderProcess->getNextStep()) {
$next = $OrderProcess->getNextStep()->getName();
}
$OrderProcess->setAttribute('step', $Next->getName());
return array(
'html' => $OrderProcess->create(),
'step' => $current
'html' => $result,
'step' => $next
);
},
array('orderId', 'current')
......
......@@ -299,7 +299,7 @@ define('package/quiqqer/order/bin/frontend/controls/OrderProcess', [
if (typeof showFromRight === 'undefined') {
showFromRight = true;
}
console.warn(result);
this.setAttribute('current', result.step);
// render container
......
......@@ -5,10 +5,15 @@
<table name="orders">
<field type="BIGINT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY">id</field>
<field type="BIGINT(10) NULL DEFAULT NULL">order_process_id</field>
<field type="BIGINT(10) NULL DEFAULT NULL">parent_order</field> <!-- Für aufgesplittete Bestellungen -->
<field type="INT NULL DEFAULT NULL">invoice_id</field> <!-- nur setzen wenn invoice gebucht ist -->
<field type="INT NULL DEFAULT NULL">temporary_invoice_id
</field> <!-- nur setzen wenn invoice gebucht ist -->
<!-- Für aufgesplittete Bestellungen -->
<field type="BIGINT(10) NULL DEFAULT NULL">parent_order</field>
<!-- nur setzen wenn invoice gebucht ist -->
<field type="INT NULL DEFAULT NULL">invoice_id</field>
<!-- nur setzen wenn invoice gebucht ist -->
<field type="INT NULL DEFAULT NULL">temporary_invoice_id</field>
<field type="INT NOT NULL">status</field>
<field type="INT NOT NULL">customerId</field>
......
......@@ -39,6 +39,11 @@ abstract class AbstractOrder
*/
protected $id;
/**
* @var int
*/
protected $status;
/**
* invoice ID
*
......
......@@ -36,4 +36,4 @@
</div>
</section>
{/if}}
\ No newline at end of file
{/if}
\ No newline at end of file
......@@ -97,6 +97,18 @@ public function save()
$Order = $Orders->getOrderInProcess($this->getAttribute('orderId'));
$Payment = $Order->getPayment();
if (!$Payment) {
return;
}
if (!isset($_REQUEST['current']) || $_REQUEST['current'] !== 'checkout') {
return;
}
if (!isset($_REQUEST['payableToOrder'])) {
return;
}
$Order->setData('orderedWithCosts', 1);
$Order->setData('orderedWithCostsPayment', $Payment->getId());
$Order->save();
......
......@@ -39,9 +39,11 @@ public function create($PermissionUser = null)
$table = $Orders->table();
QUI::getDataBase()->insert($table, array(
'c_user' => $User->getId(),
'c_date' => date('Y-m-d H:i:s'),
'hash' => Uuid::uuid1()->toString()
'c_user' => $User->getId(),
'c_date' => date('Y-m-d H:i:s'),
'hash' => Uuid::uuid1()->toString(),
'status' => AbstractOrder::STATUS_CREATED,
'customerId' => 0
));
$orderId = QUI::getDataBase()->getPDO()->lastInsertId();
......
......@@ -15,6 +15,11 @@
*/
class OrderInProcess extends AbstractOrder
{
/**
* @var null|integer
*/
protected $orderId = null;
/**
* Order constructor.
*
......@@ -22,9 +27,17 @@ class OrderInProcess extends AbstractOrder
*/
public function __construct($orderId)
{
parent::__construct(
Handler::getInstance()->getOrderProcessData($orderId)
);
$data = Handler::getInstance()->getOrderProcessData($orderId);
parent::__construct($data);
$this->orderId = (int)$data['order_id'];
try {
Handler::getInstance()->get($this->orderId);
} catch (QUI\ERP\Order\Exception $Exception) {
$this->orderId = null;
}
}
/**
......@@ -113,6 +126,7 @@ public function isPosted()
* Create the order
*
* @param null|QUI\Interfaces\Users\User $PermissionUser
* @return Order
* @throws QUI\Permissions\Exception
*/
public function createOrder($PermissionUser = null)
......@@ -124,6 +138,10 @@ public function createOrder($PermissionUser = null)
);
}
if ($this->orderId) {
return Handler::getInstance()->get($this->orderId);
}
$SystemUser = QUI::getUsers()->getSystemUser();
$this->save($SystemUser);
......@@ -137,6 +155,8 @@ public function createOrder($PermissionUser = null)
array('id' => $this->getId())
);
$this->orderId = $Order->getId();
// copy the data to the order
$data = $this->getDataForSaving();
$data['order_process_id'] = $this->getId();
......@@ -146,6 +166,8 @@ public function createOrder($PermissionUser = null)
$data,
array('id' => $Order->getId())
);
return $Order;
}
/**
......@@ -192,6 +214,13 @@ protected function getDataForSaving()
QUI\System\Log::writeException($Exception);
}
// status
$status = self::STATUS_CREATED;
if ($this->status) {
$status = $this->status;
}
//payment
$paymentId = null;
$paymentMethod = null;
......@@ -212,6 +241,7 @@ protected function getDataForSaving()
'articles' => $this->Articles->toJSON(),
'comments' => $this->Comments->toJSON(),
'data' => json_encode($this->data),
'status' => $status,
'payment_id' => $paymentId,
'payment_method' => $paymentMethod,
......
......@@ -106,13 +106,15 @@ protected function send()
// is one is invalid, go to them
foreach ($steps as $name => $Step) {
/* @var $Step AbstractOrderingStep */
if ($Step->getName() === 'checkout'
|| $Step->getName() === 'finish'
) {
if ($Step->getName() === 'checkout' || $Step->getName() === 'finish') {
continue;
}
$Step->validate();
try {
$Step->validate();
} catch (Exception $Exception) {
$this->setAttribute('current', $Step->getName());
}
}
QUI::getEvents()->fireEvent('orderStart', [$this]);
......@@ -142,6 +144,9 @@ protected function send()
// all runs fine
$Order->createOrder();
$Order->delete();
$this->setAttribute('current', 'finish');
$this->setAttribute('step', 'finish');
}
/**
......@@ -149,16 +154,34 @@ protected function send()
*/
public function getBody()
{
$template = dirname(__FILE__).'/Controls/OrderProcess.html';
$Engine = QUI::getTemplateManager()->getEngine();
if (isset($_REQUEST['payableToOrder'])) {
try {
$this->send();
$Engine->assign(array(
'listWidth' => floor(100 / count($this->getSteps())),
'this' => $this,
'error' => false,
'next' => false,
'previous' => false,
'payableToOrder' => false,
'steps' => $this->getSteps(),
'CurrentStep' => $this->getCurrentStep(),
'Site' => $this->getSite(),
'Order' => $this->getOrder()
));
return $Engine->fetch($template);
} catch (QUI\Exception $Exception) {
if (DEBUG_MODE) {
QUI\System\Log::writeException($Exception);
}
}
}
$template = dirname(__FILE__).'/Controls/OrderProcess.html';
$Engine = QUI::getTemplateManager()->getEngine();
// processing step
if ($this->ProcessingProvider !== null) {
$ProcessingStep = new Controls\ProcessingProviderStep();
......@@ -206,7 +229,6 @@ public function getBody()
$payableToOrder = false;
if ($Current->showNext() === false) {
$next = false;
}
......@@ -228,6 +250,8 @@ public function getBody()
$error = $Exception->getMessage();
}
$this->setAttribute('step', $Current->getName());
$Engine->assign(array(
'listWidth' => floor(100 / count($this->getSteps())),
'this' => $this,
......@@ -288,7 +312,7 @@ public function getNextStep($StartStep = null)
$PaymentType = $Payment->getPaymentType();
// checkout gateway
if ($PaymentType->isGateway()) {
if ($Payment && $PaymentType && $PaymentType->isGateway()) {
return $this->getStepByName('checkout');
}
}
......@@ -428,7 +452,7 @@ public function getSite()
$sites = $Project->getSitesIds(array(
'where' => array(
'type' => 'quiqqer/order:types/orderingProcess',
'type' => 'quiqqer / order:types / orderingProcess',
'active' => 1
),
'limit' => 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