Partner productchange done
This commit is contained in:
@@ -189,7 +189,7 @@
|
||||
<hr />
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="order_date">Bestelldatum</label>
|
||||
<label class="col-lg-2 col-form-label" for="order_date">Bestelldatum *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="order_date" id="order_date" value="<?=($contract->order_date) ? date("d.m.Y",$contract->order_date) : ""?>">
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
<?php
|
||||
$f = false;
|
||||
$hide_credit = false;
|
||||
$hide_credit = true;
|
||||
|
||||
if($me->is("Admin")) {
|
||||
$hide_credit = false;
|
||||
}
|
||||
|
||||
?>
|
||||
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
|
||||
|
||||
|
||||
@@ -199,8 +199,8 @@
|
||||
<td>
|
||||
<input type="radio" class="form-check link-keep pointer"
|
||||
id="link-<?=$link->id?>-action-keep"
|
||||
name="links[<?=$link->id?>][action]"
|
||||
value="keep" <?=($linkcontract->cancel_date && $linkcontract->cancel_date < date('U')) ? "" : "checked='checked'"?>
|
||||
name="links[<?=$link->id?>][action]" value="keep"
|
||||
<?=($linkcontract->cancel_date && $linkcontract->cancel_date < date('U')) ? "" : "checked='checked'"?>
|
||||
onchange="linkActionChange(<?=$link->id?>)" />
|
||||
<?php if($link->type == "credit"): ?>
|
||||
(Gutschrift wird neu erstellt)
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
<?php
|
||||
$f = "o";
|
||||
$hide_credit = true;
|
||||
|
||||
if($me->is("Admin")) {
|
||||
$hide_credit = false;
|
||||
}
|
||||
?>
|
||||
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
|
||||
|
||||
|
||||
@@ -241,6 +241,17 @@ class Contract extends mfBaseModel {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function countActiveLinks($with_credit = false) {
|
||||
$links = $this->getProperty("links");
|
||||
|
||||
if(is_array($links) && count($links)) {
|
||||
return count($links);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public function generateMatchcode() {
|
||||
$owner_address = $this->getProperty("owner")->street . ", " . $this->getProperty("owner")->zip . " " . $this->getProperty("owner")->city;
|
||||
|
||||
|
||||
@@ -429,6 +429,21 @@ class ContractController extends mfBaseController
|
||||
$contract_data['termination_id'] = null;
|
||||
}
|
||||
|
||||
//var_dump($r->links);
|
||||
// lookup credit contract and if it's missing in $r->links
|
||||
if(!$this->me->is("Admin")) {
|
||||
$credit_link = ContractLinkModel::includesContractId($contract->id, ["type" => "credit"]);
|
||||
if($credit_link) {
|
||||
if(is_array($r->links) && !array_key_exists($credit_link->id, $r->links)) {
|
||||
$r->links[$credit_link->id] = [];
|
||||
}
|
||||
$r->links[$credit_link->id]["action"] = "keep";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($r->links);exit;
|
||||
|
||||
|
||||
$new_contract->update($contract_data);
|
||||
$new_contract_id = $new_contract->save();
|
||||
@@ -455,6 +470,8 @@ class ContractController extends mfBaseController
|
||||
]);
|
||||
$journal->save();
|
||||
|
||||
|
||||
|
||||
if (is_array($r->links) && count($r->links)) {
|
||||
foreach ($r->links as $link_id => $link_data) {
|
||||
$action = $link_data["action"];
|
||||
@@ -597,7 +614,7 @@ class ContractController extends mfBaseController
|
||||
|
||||
$this->layout()->setFlash("Produktwechsel erfolgreich erstellt", "success");
|
||||
if($f == "o") {
|
||||
$this->redirect("Order");
|
||||
$this->redirect("Order","Upgrades");
|
||||
} else {
|
||||
$this->redirect("Contract", "view", ["contract_id" => $new_contract_id]);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ class ContractLinkModel {
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) as cnt FROM ContractLink
|
||||
LEFT JOIN Contract ON (ContractLink.contract_id = Contract.id)
|
||||
LEFT JOIN Address AS Owner ON (Contract.owner_id = Owner.id)
|
||||
LEFT JOIN Address ON (Contract.owner_id = Address.id)
|
||||
LEFT JOIN Worker ON (ContractLink.create_by = Worker.id)
|
||||
LEFT JOIN OrderProduct ON (Contract.orderproduct_id = OrderProduct.id)
|
||||
LEFT JOIN `Order` ON (OrderProduct.order_id = `Order`.id)
|
||||
@@ -123,7 +123,7 @@ class ContractLinkModel {
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT ContractLink.* FROM ContractLink
|
||||
LEFT JOIN Contract ON (ContractLink.contract_id = Contract.id)
|
||||
LEFT JOIN Address AS Owner ON (Contract.owner_id = Owner.id)
|
||||
LEFT JOIN Address ON (Contract.owner_id = Address.id)
|
||||
LEFT JOIN Worker ON (ContractLink.create_by = Worker.id)
|
||||
LEFT JOIN OrderProduct ON (Contract.orderproduct_id = OrderProduct.id)
|
||||
LEFT JOIN `Order` ON (OrderProduct.order_id = `Order`.id)
|
||||
@@ -230,6 +230,84 @@ class ContractLinkModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("owner_id", $filter)) {
|
||||
$owner_id = $filter['owner_id'];
|
||||
if(is_numeric($owner_id)) {
|
||||
$where .= " AND Contract.owner_id=$owner_id";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("billingaddress_id", $filter)) {
|
||||
$billingaddress_id = $filter['billingaddress_id'];
|
||||
if(is_numeric($billingaddress_id)) {
|
||||
$where .= " AND Contract.billingaddress_id=$billingaddress_id";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("product_id", $filter)) {
|
||||
$product_id = $filter['product_id'];
|
||||
if(is_numeric($product_id)) {
|
||||
$where .= " AND Contract.product_id=$product_id";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("orderproduct_id", $filter)) {
|
||||
$orderproduct_id = $filter['orderproduct_id'];
|
||||
if(is_numeric($orderproduct_id)) {
|
||||
$where .= " AND Contract.orderproduct_id=$orderproduct_id";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("product_name", $filter)) {
|
||||
$product_name = $db->escape($filter['product_name']);
|
||||
if($product_name) {
|
||||
$where .= " AND (Contract.`product_name` like '%$product_name%' OR Product.name like '%$product_name%')";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(array_key_exists("matchcode", $filter)) {
|
||||
$matchcode = $db->escape($filter['matchcode']);
|
||||
if($matchcode) {
|
||||
$where .= " AND Contract.`matchcode` like '%$matchcode%'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("rtr_code", $filter)) {
|
||||
$rtr_code = $filter['rtr_code'];
|
||||
if(is_numeric($rtr_code)) {
|
||||
$where .= " AND Contract.rtr_code=$rtr_code";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("customer_number", $filter)) {
|
||||
$customer_number = $filter['customer_number'];
|
||||
if(is_numeric($customer_number)) {
|
||||
$where .= " AND Address.customer_number=$customer_number";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("owner", $filter)) {
|
||||
$owner = FronkDB::singleton()->escape($filter["owner"]);
|
||||
if($owner) {
|
||||
$where .= " AND (Address.customer_number like '$owner' OR Address.company like '%$owner%' OR (CONCAT(Address.firstname, ' ', Address.lastname) like '%$owner%' OR CONCAT(Address.lastname, ' ', Address.firstname) like '%$owner%' ))";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("imported_from", $filter)) {
|
||||
$imported_from = FronkDB::singleton()->escape($filter["imported_from"]);
|
||||
if($imported_from) {
|
||||
$where .= " AND Contract.imported_from like '$imported_from'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("imported_data", $filter)) {
|
||||
$imported_data = FronkDB::singleton()->escape($filter["imported_data"]);
|
||||
if($imported_data) {
|
||||
$where .= " AND Contract.imported_data like '$imported_data'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("price<", $filter)) {
|
||||
$price = $filter['price<'];
|
||||
if(is_numeric($price)) {
|
||||
@@ -256,6 +334,13 @@ class ContractLinkModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("billing_period", $filter)) {
|
||||
$billing_period = $filter['billing_period'];
|
||||
if(is_numeric($billing_period)) {
|
||||
$where .= " AND Contract.billing_period=$billing_period";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("finish_date", $filter)) {
|
||||
$finish_date = $filter['finish_date'];
|
||||
if(is_numeric($finish_date)) {
|
||||
@@ -270,13 +355,6 @@ class ContractLinkModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("finish_date_null_or_gte", $filter)) {
|
||||
$finish_date = $filter['finish_date_null_or_gte'];
|
||||
if(is_numeric($finish_date)) {
|
||||
$where .= " AND (Contract.finish_date IS NULL OR Contract.finish_date >= $finish_date)";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("finish_date<", $filter)) {
|
||||
$finish_date = $filter['finish_date<'];
|
||||
if(is_numeric($finish_date)) {
|
||||
@@ -284,10 +362,17 @@ class ContractLinkModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("finish_date_null_or_gte", $filter)) {
|
||||
$cancel_date = $filter['finish_date_null_or_gte'];
|
||||
if(is_numeric($cancel_date)) {
|
||||
$where .= " AND (Contract.finish_date IS NULL OR Contract.finish_date >= $cancel_date)";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("finish_date_null_or_lte", $filter)) {
|
||||
$finish_date = $filter['finish_date_null_or_lte'];
|
||||
if(is_numeric($finish_date)) {
|
||||
$where .= " AND (Contract.finish_date IS NULL OR Contract.finish_date <= $finish_date)";
|
||||
$cancel_date = $filter['finish_date_null_or_lte'];
|
||||
if(is_numeric($cancel_date)) {
|
||||
$where .= " AND (Contract.finish_date IS NULL OR Contract.finish_date <= $cancel_date)";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -479,13 +479,14 @@ class OrderController extends mfBaseController {
|
||||
$pagination['start'] = intval($this->request->s);
|
||||
}
|
||||
|
||||
$upgrade_search = [
|
||||
"type" => "upgrade",
|
||||
"contract_creator_address_id" => $this->me->address_id,
|
||||
"finish_date_null_or_gte" => date("U"),
|
||||
"price>=" => 0
|
||||
];
|
||||
unset($filter["finish_date"]);
|
||||
|
||||
$upgrade_search = $filter;
|
||||
|
||||
$upgrade_search["type"] = "upgrade";
|
||||
$upgrade_search["contract_creator_address_id"] = $this->me->address_id;
|
||||
$upgrade_search["finish_date_null_or_gte"] = date("U");
|
||||
$upgrade_search["price>="] = 0;
|
||||
|
||||
$pagination["maxItems"] = ContractLinkModel::countWithContracts($upgrade_search);
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ class OrderModel {
|
||||
if(array_key_exists("owner", $filter)) {
|
||||
$owner = FronkDB::singleton()->escape($filter['owner']);
|
||||
if($owner) {
|
||||
$where .= " AND (Address.company like '%$owner%' OR Address.firstname like '%$owner%' OR Address.lastname like '%$owner%' OR Address.customer_number like '%$owner%')";
|
||||
$where .= " AND (Address.customer_number like '$owner' OR Address.company like '%$owner%' OR Address.firstname like '%$owner%' OR Address.lastname like '%$owner%' OR Address.customer_number like '%$owner%')";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user