Partner Producthchange WIP 2024-07-23

This commit is contained in:
Frank Schubert
2024-07-24 13:34:39 +02:00
parent ce671f2edd
commit a4f6b3b98c
8 changed files with 784 additions and 303 deletions

View File

@@ -371,18 +371,7 @@ class OrderController extends mfBaseController {
$users = [];
foreach($this->me->my_networks as $network) {
$network_ids[] = $network->id;
/*$tmp_users = $network->getAddressUsersByAddresstype("salespartner");
foreach($tmp_users as $user) {
if(!in_array($user->id, $users)) {
$users[] = $user->id;
}
}*/
}
/*
// get addresses from salespartner address' user ids
$addresses = AddressModel::search(["create_by" => $users]);
$this->layout()->set("addresses", $addresses);
*/
// get terminations in my networks
$terms = TerminationModel::search(["network_id" => $network_ids]);
$this->layout()->set("terminations", $terms);
@@ -437,6 +426,10 @@ class OrderController extends mfBaseController {
return $this->addAction();
}
protected function upgradesAction() {
}
protected function setwaitingAction() {
$order_id = $this->request->id;
@@ -471,12 +464,70 @@ class OrderController extends mfBaseController {
protected function addUpgrade() {
//$this->layout()->setTemplate("Order/Productchange");
Helper::renderVue($this, "OrderProductchange", $this->mod, ["CONTRACT_API_URL" => $this->getUrl("Contract", "api"),
Helper::renderVue($this, "OrderProductchange", "Neuer Produktwechsel", ["CONTRACT_API_URL" => $this->getUrl("Contract", "api"),
"ADDRESS_API_URL" => $this->getUrl("Address", "api"),
"CONTRACT_PRODUCTCHANGE_URL" => $this->getUrl("Contract", "productchange")]);
"ORDER_PRODUCTCHANGE_URL" => $this->getUrl("Order", "productchange")]);
}
protected function productchangeAction() {
$this->layout()->setTemplate("Order/ProductchangeForm");
$f = $this->request->f;
if(!$f) {
$f = "c"; // from Contract
}
$this->layout()->set("f", $f);
$id = $this->request->contract_id;
if (!$id) {
$id = $this->request->id;
}
if (!is_numeric($id) || !$id) {
$this->layout()->setFlash("Vertrag nicht gefunden", "error");
$this->redirect("Order", "addUpgrade");
}
$contract = new Contract($id);
if (!$contract->id) {
$this->layout()->setFlash("Vertrag nicht gefunden", "error");
$this->redirect("Order", "addUpgrade");
}
if($this->me->isAdmin()) {
$this->layout()->set("terminations", TerminationModel::getAll());
} else {
// check permissions
// check if correct network
$my_network_ids = [];
foreach($this->me->my_networks as $network) {
$my_network_ids[] = $network->id;
}
if($contract->termination_id) {
if(!in_array($contract->termination->network_id, $my_network_ids)) {
$this->layout()->setFlash("Keine Berechtigung", "error");
$this->redirect("Order", "addUpgrade", ["owner_id" => $contract->owner_id]);
}
}
$terms = TerminationModel::search(["network_id" => $my_network_ids]);
$this->layout()->set("terminations", $terms);
}
$this->layout()->set("contract", $contract);
if ($this->request->filter) {
$this->layout()->set("filter", $this->request->filter);
}
if ($this->request->s) {
$this->layout()->set("filter", $this->request->s);
}
}
protected function saveAction() {
$r = $this->request;
//var_dump($r->products);