WIP Mass Productchange
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
class Admin_MassProductchange {
|
||||
private $request;
|
||||
private $db;
|
||||
private $log;
|
||||
private $flash = [];
|
||||
|
||||
|
||||
public function __construct($request = false) {
|
||||
$this->request = $request;
|
||||
$this->db = FronkDB::singleton();
|
||||
$this->log = mfLoghandler::singleton();
|
||||
|
||||
}
|
||||
|
||||
public function runRequest() {
|
||||
$action = $this->request->do;
|
||||
if(!$action) {
|
||||
return $this->indexAction();
|
||||
} else {
|
||||
$method = $action."Action";
|
||||
if(method_exists($this, $method)) {
|
||||
return $this->$method();
|
||||
} else {
|
||||
throw new Exception("Method not found", "404");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function indexAction() {
|
||||
|
||||
return [
|
||||
"template" => "Admin/MassProductchange/Index",
|
||||
"redirect" => "",
|
||||
"templateVars" => []
|
||||
];
|
||||
}
|
||||
|
||||
public function createAction() {
|
||||
$this->log->debug("Create action called");
|
||||
$this->log->debug($this->request->getPost());
|
||||
|
||||
$old_product_id = $this->request->getPost("old_product_id");
|
||||
$new_product_id = $this->request->getPost("new_product_id");
|
||||
|
||||
if(!$old_product_id || !$new_product_id) {
|
||||
$this->flash[] = "Beide Produkte werden benötigt.";
|
||||
return [
|
||||
"template" => "Admin/MassProductchange/Index",
|
||||
"redirect" => "",
|
||||
"templateVars" => []
|
||||
];
|
||||
}
|
||||
|
||||
$contracts = ContractModel::searchActive(["product_id" => $old_product_id]);
|
||||
|
||||
|
||||
|
||||
if($this->request->preview) {
|
||||
return [
|
||||
"template" => "Admin/MassProductchange/Index",
|
||||
"redirect" => "",
|
||||
"templateVars" => ["contracts" => $contracts]
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
"template" => "Admin/MassProductchange/Index",
|
||||
"redirect" => "",
|
||||
"templateVars" => []
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user