enabled deleting orders
This commit is contained in:
@@ -46,6 +46,15 @@ class Order extends mfBaseModel {
|
||||
return $terminations;
|
||||
}
|
||||
|
||||
public function deletePositions() {
|
||||
if(!is_array($this->getProperty("products")) || !count($this->getProperty("products"))) {
|
||||
return true;
|
||||
}
|
||||
foreach($this->getProperty("products") as $position) {
|
||||
$position->delete();
|
||||
}
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
|
||||
@@ -247,7 +247,11 @@ class OrderController extends mfBaseController {
|
||||
if(is_numeric($r->billingaddress_id)) {
|
||||
$order_data['billingaddress_id'] = $r->billingaddress_id;
|
||||
}
|
||||
$order_data['billing_type'] = $r->billing_type;
|
||||
if($r->billing_type == "sepa") {
|
||||
$order_data['billing_type'] = "sepa";
|
||||
} else {
|
||||
$order_data['billing_type'] = "invoice";
|
||||
}
|
||||
$order_data['bank_account_bank'] = $r->bank_account_bank;
|
||||
$order_data['bank_account_owner'] = $r->bank_account_owner;
|
||||
$order_data['bank_account_iban'] = $r->bank_account_iban;
|
||||
@@ -411,5 +415,25 @@ class OrderController extends mfBaseController {
|
||||
|
||||
}
|
||||
|
||||
public function deleteAction() {
|
||||
if(!$this->me->is(["Admin"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
|
||||
$id = $this->request->id;
|
||||
|
||||
$order = new Order($id);
|
||||
if(!$order->id || $order->id != $id) {
|
||||
$this->layout()->setFlash("Bestellung nicht gefunden.", "error");
|
||||
$this->redirect("Order");
|
||||
}
|
||||
|
||||
$order->deletePositions();
|
||||
|
||||
// check if Product is unused
|
||||
$order->delete();
|
||||
$this->redirect("Order");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -7,7 +7,7 @@ class OrderModel {
|
||||
public $finish_date;
|
||||
public $finish_after;
|
||||
public $finish_after_comment;
|
||||
public $billing_text;
|
||||
public $billing_type;
|
||||
public $bank_account_bank;
|
||||
public $bank_account_owner;
|
||||
public $bank_account_iban;
|
||||
|
||||
Reference in New Issue
Block a user