Started Contract Index
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
<?php
|
||||
$pagination_baseurl = $this->getUrl($Mod,"Index");
|
||||
$pagination_baseurl_params = ["filter" => $filter];
|
||||
$pagination_entity_name = "Verträge";
|
||||
?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
|
||||
<!-- start page title -->
|
||||
@@ -28,6 +33,9 @@
|
||||
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Contract", "add")?>"><i class="fas fa-plus"></i> Neuen Vertrag anlegen</a>
|
||||
</div>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
||||
|
||||
<table class="table table-striped table-hover">
|
||||
<tr>
|
||||
<th>Inhaber</th>
|
||||
@@ -42,26 +50,44 @@
|
||||
</tr>
|
||||
<?php foreach($contracts as $contract): ?>
|
||||
<tr>
|
||||
<td><?=$contract->owner->getCompanyOrName()?></td>
|
||||
<td><a href="<?=self::getUrl("Address", "Edit", ["id" => $contract->owner_id])?>" target="_blank"><?=$contract->owner->getCompanyOrName()?></a></td>
|
||||
<td><?=$contract->product->name?></td>
|
||||
<td>
|
||||
<?php if($contract->termination_id): ?>
|
||||
<?=$contract->termination->building->street?><br />
|
||||
<?=$contract->termination->building->zip?> <?=$contract->termination->building->city?>
|
||||
<?=$contract->termination->building->zip?> <?=$contract->termination->building->city?><br />
|
||||
<a href="<?=self::getUrl("Building", "Index",["filter" => ['code' => $contract->termination->building->code]])?>#building=<?=$contract->termination->building_id?>" target="_blank">
|
||||
<span class="text-monospace text-pink"><?=$contract->termination->code?></span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><?=$contract->price?></td>
|
||||
<td><?=$contract->price_setup?></td>
|
||||
<td><?=(12 / $contract->billing_period)?>x Jährlich</td>
|
||||
<td>
|
||||
<?php if($contract->billing_period == 1): ?>
|
||||
monatlich
|
||||
<?php elseif($contract->billing_period == 24): ?>
|
||||
biennal
|
||||
<?php elseif($contract->billing_period == 36): ?>
|
||||
triennal
|
||||
<?php else: ?>
|
||||
<?=(12 / $contract->billing_period)?>x Jährlich
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><?=date('d.m.Y H:i', $contract->create)?> (<?=$contract->creator->name?>)</td>
|
||||
<td><?=date('d.m.Y H:i', $contract->edit)?> (<?=$contract->editor->name?>)</td>
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||
<a href="<?=self::getUrl("Contract", "edit", ["id" => $contract->id])?>"><i class="far fa-edit" title="Vertrag bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("Order", "edit", ["id" => $contract->product->order_id])?>"><i class="far fa-file-signature" title="Bestellung anzeigen"></i></a>
|
||||
<a href="<?=self::getUrl("Contract", "cancel", ["id" => $contract->id])?>" class="text-danger" title="Vertrag kündigen"><i class="fas fa-trash"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -23,6 +23,12 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="row justify-content-center " >
|
||||
<div class="hidden mb-4 col-6 alert alert-warning text-center" id="contract-readonly-notice">
|
||||
Diese Bestellung kann nicht mehr bearbeitet werden, da sie bereits abgeschlossen und in Verrechnung ist.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
@@ -34,8 +40,6 @@
|
||||
|
||||
<input type="hidden" name="id" value="<?=$order->id?>" />
|
||||
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
|
||||
@@ -624,27 +628,22 @@
|
||||
<?php else: ?>
|
||||
|
||||
<?php if(is_array($order->files) && count($order->files)): ?>
|
||||
<table class="table table-striped table-hover">
|
||||
<table id="files-table" class="table table-striped table-hover">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Beschreibung</th>
|
||||
<th>Dateiname</th>
|
||||
<th>Original Dateiname</th>
|
||||
<th>Hochgeladen</th>
|
||||
<th>Zuletzt bearbeitet</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach($order->files as $file): ?>
|
||||
<tr>
|
||||
<td><a href="<?=self::getUrl("File", "Download", ['id' => $file->file->id])?>"><?=$file->name?></a></td>
|
||||
<td><?=nl2br($file->description)?></td>
|
||||
<td><?=nl2br(htmlentities($file->description))?></td>
|
||||
<td><?=$file->file->filename?></td>
|
||||
<td><?=$file->file->orig_filename?></td>
|
||||
<td class="text-monospace"><?=date("d.m.Y", $file->create)?> (<?=$file->creator->name?>)</td>
|
||||
<td class="text-monospace"><?=date("d.m.Y", $file->edit)?> (<?=$file->editor->name?>)</td>
|
||||
<td>
|
||||
<a href="<?=self::getUrl("OrderFile", "edit", ["id" => $file->id])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("OrderFile", "delete", ["id" => $file->id])?>" onclick="if(!confirm('Dokument wirklich löschen?')) return false;" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>
|
||||
<a class="delete-button" href="<?=self::getUrl("OrderFile", "delete", ["id" => $file->id])?>" onclick="if(!confirm('Dokument wirklich löschen?')) return false;" title="Löschen"><i class="fas fa-trash text-danger"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -660,13 +659,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="file_filename">Download Dateiname</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="file_filename" id="file_filename" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="file_description">Beschreibung</label>
|
||||
<div class="col-lg-10">
|
||||
@@ -1183,6 +1175,17 @@
|
||||
<?php if(!$order->finish_date): ?>
|
||||
$('#finish_date_field').hide();
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if($order->finish_date && is_array($order->contracts) && count($order->contracts)): ?>
|
||||
$("input").prop("disabled", true);
|
||||
$("input[type=text]").prop("readonly", true);
|
||||
$("select").prop("disabled", true);
|
||||
$("textarea").prop("disabled", true);
|
||||
$("button").prop("disabled", true);
|
||||
//$("#files-table a.edit-button").removeAttr("href");
|
||||
$("#files-table a.delete-button").removeAttr("href").removeAttr("onclick");
|
||||
$("#contract-readonly-notice").show();
|
||||
<?php endif; ?>
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,94 @@
|
||||
<?php
|
||||
|
||||
class Contract extends mfBaseModel {
|
||||
private $owner;
|
||||
private $creator;
|
||||
private $product;
|
||||
private $termination;
|
||||
private $sla;
|
||||
private $editor;
|
||||
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if(!$this->id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if($name == "owner") {
|
||||
$this->owner = mfValuecache::singleton()->get("mfObjectmodel-Address-".$this->owner_id);
|
||||
if($this->owner === null) {
|
||||
$this->owner = new Address($this->owner_id);
|
||||
if($this->owner->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-Address-".$this->owner_id, $this->owner);
|
||||
}
|
||||
}
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
if($name == "billingaddress") {
|
||||
$this->billingaddress = mfValuecache::singleton()->get("mfObjectmodel-Address-".$this->billingaddress_id);
|
||||
if($this->billingaddress === null) {
|
||||
$this->billingaddress = new Address($this->billingaddress_id);
|
||||
if($this->billingaddress->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-Address-".$this->billingaddress_id, $this->billingaddress);
|
||||
}
|
||||
}
|
||||
return $this->billingaddress;
|
||||
}
|
||||
|
||||
if($name == "product") {
|
||||
$this->product = mfValuecache::singleton()->get("mfObjectmodel-OrderProduct-".$this->orderproduct_id);
|
||||
if($this->product === null) {
|
||||
$this->product = new OrderProduct($this->orderproduct_id);
|
||||
if($this->product->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-OrderProduct-".$this->orderproduct_id, $this->product);
|
||||
}
|
||||
}
|
||||
return $this->product;
|
||||
}
|
||||
|
||||
if($name == "creator") {
|
||||
$this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
|
||||
if($this->creator === null) {
|
||||
$this->creator = new User($this->create_by);
|
||||
if($this->creator->id) {
|
||||
mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator);
|
||||
}
|
||||
}
|
||||
return $this->creator;
|
||||
}
|
||||
|
||||
if($name == "editor") {
|
||||
$this->editor = mfValuecache::singleton()->get("Worker-id-".$this->edit_by);
|
||||
if($this->editor === null) {
|
||||
$this->editor = new User($this->edit_by);
|
||||
if($this->editor->id) {
|
||||
mfValuecache::singleton()->set("Worker-id-".$this->edit_by, $this->editor);
|
||||
}
|
||||
}
|
||||
return $this->editor;
|
||||
}
|
||||
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
|
||||
if(!$this->$name) {
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
}
|
||||
|
||||
if($this->$name->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -41,6 +41,7 @@ class ContractController extends mfBaseController {
|
||||
$contracts = ContractModel::search($filter, $pagination);
|
||||
|
||||
$this->layout()->set("contracts", $contracts);
|
||||
$this->layout()->set("pagination", $pagination);
|
||||
}
|
||||
|
||||
private function getPreparedFilter($filter) {
|
||||
|
||||
@@ -60,11 +60,21 @@ class ContractModel {
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst() {
|
||||
public static function getFirst($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("Contract", "*", "$where ORDER BY owner_id,product_id,`create` LIMIT 1");
|
||||
$sql = "SELECT Contract.* FROM Contract
|
||||
LEFT JOIN Address ON (Contract.owner_id = Address.id)
|
||||
LEFT JOIN OrderProduct ON (Contract.orderproduct_id = OrderProduct.id)
|
||||
LEFT JOIN `Order` ON (OrderProduct.order_id = `Order`.id)
|
||||
LEFT JOIN Product ON (Contract.product_id = Product.id)
|
||||
WHERE $where
|
||||
GROUP BY Contract.id
|
||||
ORDER BY Contract.owner_id,Contract.product_id,Contract.`create`
|
||||
LIMIT 1";
|
||||
//var_dump($sql);exit;
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new Contract($data);
|
||||
@@ -81,11 +91,13 @@ class ContractModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) FROM Contract
|
||||
LEFT JOIN Address ON (Contract.address_id = Address.id)
|
||||
$sql = "SELECT COUNT(*) as cnt FROM Contract
|
||||
LEFT JOIN Address ON (Contract.owner_id = Address.id)
|
||||
LEFT JOIN OrderProduct ON (Contract.orderproduct_id = OrderProduct.id)
|
||||
LEFT JOIN `Order` ON (OrderProduct.order_id = `Order`.id)
|
||||
LEFT JOIN Product ON (Contract.product_id = Product.id)
|
||||
WHERE $where
|
||||
GROUP BY Contract.id
|
||||
ORDER BY owner_id,product_id,`create`";
|
||||
GROUP BY Contract.id";
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
@@ -102,10 +114,13 @@ class ContractModel {
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT Contract.* FROM Contract
|
||||
LEFT JOIN Address ON (Contract.address_id = Address.id)
|
||||
LEFT JOIN Address ON (Contract.owner_id = Address.id)
|
||||
LEFT JOIN OrderProduct ON (Contract.orderproduct_id = OrderProduct.id)
|
||||
LEFT JOIN `Order` ON (OrderProduct.order_id = `Order`.id)
|
||||
LEFT JOIN Product ON (Contract.product_id = Product.id)
|
||||
WHERE $where
|
||||
GROUP BY Contract.id
|
||||
ORDER BY owner_id,product_id,`create`";
|
||||
ORDER BY Contract.owner_id,Contract.product_id,Contract.`create`";
|
||||
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
@@ -147,6 +162,13 @@ class ContractModel {
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@@ -4,6 +4,7 @@ class Order extends mfBaseModel {
|
||||
private $owner;
|
||||
private $billingaddress;
|
||||
private $products;
|
||||
private $contracts;
|
||||
private $terminations;
|
||||
private $journals;
|
||||
private $files;
|
||||
@@ -195,6 +196,16 @@ class Order extends mfBaseModel {
|
||||
return $this->products;
|
||||
}
|
||||
|
||||
if($name == "contracts") {
|
||||
foreach($this->getProperty("products") as $product) {
|
||||
//var_dump($product);
|
||||
if($product->contract && $product->contract->id) {
|
||||
$this->contracts[] = $product->contract;
|
||||
}
|
||||
}
|
||||
return $this->contracts;
|
||||
}
|
||||
|
||||
if($name == "terminations") {
|
||||
$this->terminations = $this->getTerminations();
|
||||
return $this->terminations;
|
||||
|
||||
@@ -366,6 +366,18 @@ class OrderController extends mfBaseController {
|
||||
$this->layout()->setFlash("Bestellung nicht gefunden", "error");
|
||||
$this->redirect("Order");
|
||||
}
|
||||
// refuse to save if there is a contract already
|
||||
|
||||
if($order->finish_date && is_array($order->contracts) && count($order->contracts)) {
|
||||
$this->layout()->setFlash("Bestellung kann nicht mehr bearbeitet werden, da sie bereits abgeschlossen und in Verrechnung ist.", "error");
|
||||
$this->redirect("Order", "edit", ['id' => $order->id]);
|
||||
}
|
||||
/*foreach($order->products as $p) {
|
||||
if($p->contract && $p->contract->id) {
|
||||
$this->layout()->setFlash("Bestellung kann nicht mehr bearbeitet werden, da sie bereits abgeschlossen und in Verrechnung ist.", "error");
|
||||
$this->redirect("Order", "edit", ['id' => $order->id]);
|
||||
}
|
||||
}*/
|
||||
} else {
|
||||
$id = false;
|
||||
$mode = "add";
|
||||
@@ -827,7 +839,7 @@ class OrderController extends mfBaseController {
|
||||
$of['order_id'] = $new_id;
|
||||
$of['file_id'] = $file_id;
|
||||
$of['name'] = $file->name;
|
||||
$of['description'] = $file->description;
|
||||
$of['description'] = $r->file_description;
|
||||
|
||||
$orderfile = OrderFileModel::create($of);
|
||||
if(!$orderfile->save()) {
|
||||
|
||||
@@ -5,6 +5,7 @@ class OrderProduct extends mfBaseModel {
|
||||
private $product;
|
||||
private $termination;
|
||||
private $cpeprovisioning;
|
||||
private $contract;
|
||||
private $editor;
|
||||
private $creator;
|
||||
|
||||
@@ -35,11 +36,19 @@ class OrderProduct extends mfBaseModel {
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if(!$this->id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if($name == "cpeprovisioning") {
|
||||
$this->cpeprovisioning = CpeprovisioningModel::getFirst(["orderproduct_id" => $this->id]);
|
||||
return $this->cpeprovisioning;
|
||||
}
|
||||
|
||||
if($name == "contract") {
|
||||
$this->contract = ContractModel::getFirst(['orderproduct_id' => $this->id]);
|
||||
return $this->contract;
|
||||
}
|
||||
|
||||
if($name == "creator") {
|
||||
$this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
|
||||
|
||||
Reference in New Issue
Block a user