Contract WIP

This commit is contained in:
Frank Schubert
2023-02-23 13:06:04 +01:00
parent 0c5f463ec1
commit aa373b5f4e
10 changed files with 624 additions and 154 deletions

View File

@@ -27,163 +27,187 @@
</div>
</div>
<div class="card">
<div class="card-body">
<h3 class="text-center mb-3"><?=$address->getCompanyOrName()?><?=($address->customer_number) ? " [".$address->customer_number."]" : ""?></h3>
<div class="row">
<div class="col-8">
<table class="table table-sm table-striped view-table">
<tr>
<th>Kundennummer</th>
<td><?=$address->customer_number?></td>
</tr><tr>
<th>Firmenname</th>
<td><?=nl2br($address->company)?></td>
</tr><tr>
<th>Vorname</th>
<td><?=$address->firstname?></td>
</tr><tr>
<th>Nachname</th>
<td><?=$address->lastname?></td>
</tr><tr>
<th>Straße</th>
<td><?=$address->street?></td>
</tr><tr>
<th>PLZ / Ort</th>
<td><?=$address->zip?> <?=$address->city?></td>
</tr><tr>
<th>Land</th>
<td><?=$address->country?></td>
</tr><tr>
<th>Telefon</th>
<td><?=$address->phone?></td>
</tr><tr>
<th>Mobil</th>
<td><?=$address->mobile?></td>
</tr><tr>
<th>Fax</th>
<td><?=$address->fax?></td>
</tr><tr>
<th>Email</th>
<td><?=$address->email?></td>
</tr><tr>
<th></th>
<td></td>
</tr><tr>
<th>Service PIN</th>
<td><?=$address->spin?></td>
</tr><tr>
<th>Einwilligungen</th>
<td>
<p><i class="mr-1 fas <?=($address->allow_contact) ? "fa-check text-success" : "fa-xmark-large text-danger"?>"></i> Informationen per Post/Email/Telefon</p>
<p><i class="mr-1 fas <?=($address->allow_spin) ? "fa-check text-success" : "fa-xmark-large text-danger"?>"></i>Auskunft mit Service PIN</p>
</td>
</tr><tr>
<th>Rollen</th>
<td>
<?php if(is_array($address->types) && count($address->types)): ?>
<?php foreach(TT_ROLES as $role): ?>
<ul>
<?php if(array_key_exists($role, $address->types)): ?>
<li><?=__($role)?></li>
<div class="card border-top-primary">
<div class="card-body">
<h3 class="text-center mb-3"><?=$address->getCompanyOrName()?><?=($address->customer_number) ? " [".$address->customer_number."]" : ""?></h3>
<table class="table table-sm table-striped view-table">
<tr>
<th>Kundennummer</th>
<td><?=$address->customer_number?></td>
</tr><tr>
<th>Firmenname</th>
<td><?=nl2br($address->company)?></td>
</tr><tr>
<th>Vorname</th>
<td><?=$address->firstname?></td>
</tr><tr>
<th>Nachname</th>
<td><?=$address->lastname?></td>
</tr><tr>
<th>Straße</th>
<td><?=$address->street?></td>
</tr><tr>
<th>PLZ / Ort</th>
<td><?=$address->zip?> <?=$address->city?></td>
</tr><tr>
<th>Land</th>
<td><?=$address->country?></td>
</tr><tr>
<th>Telefon</th>
<td><?=$address->phone?></td>
</tr><tr>
<th>Mobil</th>
<td><?=$address->mobile?></td>
</tr><tr>
<th>Fax</th>
<td><?=$address->fax?></td>
</tr><tr>
<th>Email</th>
<td><?=$address->email?></td>
</tr><tr>
<th></th>
<td></td>
</tr><tr>
<th>Service PIN</th>
<td><?=$address->spin?></td>
</tr><tr>
<th>Einwilligungen</th>
<td>
<p><i class="mr-1 fas <?=($address->allow_contact) ? "fa-check text-success" : "fa-xmark-large text-danger"?>"></i> Informationen per Post/Email/Telefon</p>
<p><i class="mr-1 fas <?=($address->allow_spin) ? "fa-check text-success" : "fa-xmark-large text-danger"?>"></i>Auskunft mit Service PIN</p>
</td>
</tr><tr>
<th>Rollen</th>
<td>
<?php if(is_array($address->types) && count($address->types)): ?>
<?php foreach(TT_ROLES as $role): ?>
<ul>
<?php if(array_key_exists($role, $address->types)): ?>
<li><?=__($role)?></li>
<?php endif; ?>
</ul>
<?php endforeach; ?>
<?php endif; ?>
</ul>
<?php endforeach; ?>
<?php endif; ?>
</td>
</tr><tr>
<td colspan="2"><h4>Verrechnungsdaten</h4></td>
</tr><tr>
<th>UID</th>
<td><?=$address->uid?></td>
</tr><tr>
<th>Verrechnungsart</th>
<td><?=($address->billing_type == "sepa") ? "SEPA Bankeinzug" : "Rechnung"?></td>
</tr><tr>
<th>Rechnungsversand</th>
<td><?=($address->billing_delivery == "paper") ? "POST" : "Email"?></td>
</tr><tr>
<th>Kreditinstitut</th>
<td><?=$address->bank_account_bank?></td>
</tr><tr>
<th>Kontoinhaber</th>
<td><?=$address->bank_account_owner?></td>
</tr><tr>
<th>IBAN</th>
<td><?=$address->bank_account_iban?></td>
</tr><tr>
<th>BIC</th>
<td><?=$address->bank_account_bic?></td>
</tr><tr>
<td colspan="2"><h4>Zusatzdaten</h4></td>
</tr><tr>
<th>RTR Code</th>
<td><?=$address->attributes['rtrcode']->value?></td>
</tr>
</table>
<h4>Verknüpfungen</h4>
<?php if(is_array($address->links) && count($address->links)): ?>
<div class="card">
<div class="card-body" id="link-container">
<table class="table table-striped table-sm table-bordered">
<tr>
<th>Typ</th>
<th>Firma</th>
<th>Name</th>
<th>Telefon</th>
<th>Mobil</th>
<th>Email</th>
<th></th>
</tr>
<?php foreach(TT_ADDRESS_LINK_TYPES as $type): ?>
<?php if(array_key_exists($type, $address->links)): ?>
<?php foreach($address->links[$type] as $link): ?>
<tr>
<td class="font-weight-bold"><?=__($type)?></td>
<td><a href="<?=self::getUrl("Address", "view", ["id" => $link->address_id])?>"><?=$link->address->company?></a></td>
<td><a href="<?=self::getUrl("Address", "view", ["id" => $link->address_id])?>"><?=$link->address->getFullName()?></a></td>
<td><?=$link->address->phone?></td>
<td><?=$link->address->mobile?></td>
<td><?=$link->address->email?></td>
<td>
<a class="mr-2" href="<?=self::getUrl("Address", "view", ["id" => $link->address_id])?>"><i class="far fa-eyes" title="Anzeigen"></i></a>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
<?php endforeach; ?>
</td>
</tr><tr>
<td colspan="2"><h4>Verrechnungsdaten</h4></td>
</tr><tr>
<th>UID</th>
<td><?=$address->uid?></td>
</tr><tr>
<th>Verrechnungsart</th>
<td><?=($address->billing_type == "sepa") ? "SEPA Bankeinzug" : "Rechnung"?></td>
</tr><tr>
<th>Rechnungsversand</th>
<td><?=($address->billing_delivery == "paper") ? "POST" : "Email"?></td>
</tr><tr>
<th>Kreditinstitut</th>
<td><?=$address->bank_account_bank?></td>
</tr><tr>
<th>Kontoinhaber</th>
<td><?=$address->bank_account_owner?></td>
</tr><tr>
<th>IBAN</th>
<td><?=$address->bank_account_iban?></td>
</tr><tr>
<th>BIC</th>
<td><?=$address->bank_account_bic?></td>
</tr><tr>
<td colspan="2"><h4>Zusatzdaten</h4></td>
</tr><tr>
<th>RTR Code</th>
<td><?=$address->attributes['rtrcode']->value?></td>
</tr>
</table>
<h4>Verknüpfungen</h4>
<?php if(is_array($address->links) && count($address->links)): ?>
<div class="card border-top-warning">
<div class="card-body" id="link-container">
<table class="table table-striped table-sm table-bordered">
<tr>
<th>Typ</th>
<th>Firma</th>
<th>Name</th>
<th>Telefon</th>
<th>Mobil</th>
<th>Email</th>
<th></th>
</tr>
<?php foreach(TT_ADDRESS_LINK_TYPES as $type): ?>
<?php if(array_key_exists($type, $address->links)): ?>
<?php foreach($address->links[$type] as $link): ?>
<tr>
<td class="font-weight-bold"><?=__($type)?></td>
<td><a href="<?=self::getUrl("Address", "view", ["id" => $link->address_id])?>"><?=$link->address->company?></a></td>
<td><a href="<?=self::getUrl("Address", "view", ["id" => $link->address_id])?>"><?=$link->address->getFullName()?></a></td>
<td><?=$link->address->phone?></td>
<td><?=$link->address->mobile?></td>
<td><?=$link->address->email?></td>
<td>
<a class="mr-2" href="<?=self::getUrl("Address", "view", ["id" => $link->address_id])?>"><i class="far fa-eyes" title="Anzeigen"></i></a>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
<?php endforeach; ?>
</table>
</div>
</div>
<?php endif; ?>
<?php if(is_array($address->linked_as) && count($address->linked_as)): ?>
<h4>Verknüpft als</h4>
<div class="card">
<div class="card-body" id="link-container">
<table class="table-sm table-striped">
<?php foreach(TT_ADDRESS_LINK_TYPES as $type): ?>
<?php if(array_key_exists($type, $address->linked_as)): ?>
<?php foreach($address->linked_as[$type] as $link): ?>
<tr>
<td><strong><?=__($type)?></strong> für:</td>
<td><a href="<?=self::getUrl("Address", "view", ['id' => $link->origin_address_id])?>"><?=$link->origin->getCompanyOrName()?><?=($link->origin->customer_number) ? " [".$link->origin->customer_number."]" : ""?></a></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
<?php endforeach; ?>
</table>
</div>
</div>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<?php if(is_array($address->linked_as) && count($address->linked_as)): ?>
<h4>Verknüpft als</h4>
<div class="card">
<div class="card-body" id="link-container">
<table class="table-sm table-striped">
<?php foreach(TT_ADDRESS_LINK_TYPES as $type): ?>
<?php if(array_key_exists($type, $address->linked_as)): ?>
<?php foreach($address->linked_as[$type] as $link): ?>
<tr>
<td><strong><?=__($type)?></strong> für:</td>
<td><a href="<?=self::getUrl("Address", "view", ['id' => $link->origin_address_id])?>"><?=$link->origin->getCompanyOrName()?><?=($link->origin->customer_number) ? " [".$link->origin->customer_number."]" : ""?></a></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
<?php endforeach; ?>
</table>
</div>
</div>
<?php endif; ?>
</div>
<div class="col-4">
<div class="card border-top-success">
<div class="card-header">
Aktive Produkte (Contracts)
</div>
<?php if(is_array($address->contracts) && count($address->contracts)): ?>
<ul class="list-group list-group-flush">
<?php foreach($address->contracts as $contract): ?>
<li class="list-group-item"><a href="<?=self::getUrl("Contract", "View", ["id" => $contract->id])?>"><?=$contract->product_name?> [<?=$contract->matchcode?>]</a> (<?=($contract->finish_date) ? "Fertigstellung: ".date('d.m.Y', $contract->finish_date) : ""?>)</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
</div>
</div>
<?php if(is_array($address->contracts) && count($address->contracts)): ?>
<div class="card">
<?php if(is_array($address->active_contracts) && count($address->active_contracts)): ?>
<div class="card border-top-success">
<div class="card-header">
Verträge
</div>
<div class="card-body">
<h4>Verträge</h4>
<table class="table table-striped table-sm table-bordered table-hover">
<tr>
@@ -194,9 +218,8 @@
<th>Bestelldatum</th>
<th>Fertigstellung</th>
<th>Kündigung</th>
<th></th>
</tr>
<?php foreach($address->contracts as $contract): ?>
<?php foreach($address->active_contracts as $contract): ?>
<tr>
<td class="contract <?=($contract->isCancelled()) ? "canceled" : ""?>">
<a href="<?=self::getUrl("Contract", "View", ["id" => $contract->id])?>">
@@ -213,9 +236,7 @@
<td class="contract <?=($contract->isCancelled()) ? "canceled" : ""?>"><?=($contract->order_date) ? date('d.m.Y', $contract->order_date) : ""?></td>
<td class="contract <?=($contract->isCancelled()) ? "canceled" : ""?>"><?=($contract->finish_date) ? date('d.m.Y', $contract->finish_date) : ""?></td>
<td class="contract <?=($contract->isCancelled()) ? "canceled" : ""?>"><?=($contract->cancel_date) ? date('d.m.Y', $contract->cancel_date) : ""?></td>
<td>
<a href="<?=self::getUrl("Contract", "deleteLink", ["link_id" => $contract->id])?>" onclick="if(!confirm('Verknüpfung wirklich entfernen?')) return false;" class="text-danger" title="Verknüpfung entfernen"><i class="fas fa-xmark-large"></i></a>
</td>
</tr>
<?php endforeach; ?>
</table>

View File

@@ -27,7 +27,7 @@
</div>
</div>
<div class="card">
<div class="card border-top-success">
<div class="card-body">
<?php if(!$contract->finish_date || $contract->finish_date > date('U')): ?>
<h2 class="text-center mb-3 text-secondary">In Herstellung</h2>
@@ -215,8 +215,50 @@
</div>
</div>
<?php if(is_array($contract->journals) && count($contract->journals)): ?>
<div class="card border-top-warning">
<div class="card-header">
<h5>Journaleinträge</h5>
</div>
<div class="card-body">
<div class="row justify-content-center">
<div class="col-8">
<table class="table table-striped table-sm">
<?php foreach($contract->journals as $j): ?>
<tr>
<td style="white-space: nowrap" class="text-monospace"><?=date("d.m.Y H:i", $j->create)?> (<?=$j->creator?>)</td>
<td style="width: 100%">
<?php if($j->type == "text"):?>
<?=self::strtrim(str_replace(["\n", "\r", "\t"]," ", $j->text), 128)?>
<?php elseif($j->type == "phone"): ?>
<i class="fas fa-phone text-white bg-warning p-1"></i> <?=self::strtrim(str_replace(["\n", "\r", "\t"]," ", $j->text), 128)?>
<?php elseif($j->type == "file"): ?>
<?php if($j->text): ?>
<?=self::strtrim(str_replace(["\n", "\r", "\t"]," ", $j->text), 128)?><br />
<?php endif; ?>
<a class="text-monospace" href="<?=self::getUrl("File", "download", ["id" => $j->contractfile->file_id])?>"> <i class="fas fa-download"></i> <?=$j->contractfile->name?></a>
<?php elseif($j->type == "created_from"): ?>
<?php if($j->value == "manual"): ?>
<em>Vertrag manuell angelegt.</em>
<?php endif; ?>
<?php endif; ?>
</td>
<td style="white-space: nowrap">
<a href="<?=self::getUrl("Contractjournal", "edit", ["journal_id" => $j->id])?>" title="Journaleintrag bearbeiten"><i class="fas fa-edit"></i></a>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
</div>
</div>
</div>
<?php endif; ?>
<?php if((is_array($contract->linkFrom) && count($contract->linkFrom)) || (is_array($contract->linkTo) && count($contract->linkTo))): ?>
<div class="card">
<div class="card border-top-success">
<div class="card-body">
<h4>Verknüpfte Verträge <small><a href="<?=self::getUrl("Contract", "add", ["origin_contract_id" => $contract->id])?>"><i class="fas fa-plus"></i>Neuen Contract anlegen</a></small></h4>

View File

@@ -10,6 +10,7 @@ class Address extends mfBaseModel {
private $attributes;
private $permissions;
private $contracts;
private $active_contracts;
private $phoneparts;
@@ -190,6 +191,13 @@ class Address extends mfBaseModel {
return $this->contracts;
}
if($name == "active_contracts") {
$owning = ContractModel::searchActive(['owner_id' => $this->id]);
$billing = ContractModel::searchActive(['billingaddress_id' => $this->id]);
$this->contracts = array_merge($owning, $billing);
return $this->contracts;
}
/*
if($name == "links_to") {
$links = AddressLinkModel::search(['address_id' => $this->id]);

View File

@@ -11,6 +11,7 @@ class Contract extends mfBaseModel {
private $contractConfigItems;
private $configgroups;
private $isCancelled;
private $journals;
private $links;
private $linkFrom;
private $linkTo;
@@ -188,6 +189,11 @@ class Contract extends mfBaseModel {
return $this->contractConfigItems;
}
if($name == "journals") {
$this->journals = array_reverse(ContractjournalModel::search(["contract_id" => $this->id]));
return $this->journals;
}
if($name == "links") {
$this->links = ContractLinkModel::includesContractId($this->id, ["type" => $link]);
//var_dump($this->links);exit;

View File

@@ -116,6 +116,42 @@ class ContractModel {
return 0;
}
public static function searchActive($filter, $limit = false) {
//var_dump($filter);exit;
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$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
AND (cancel_date IS NULL OR cancel_date > UNIX_TIMESTAMP())
GROUP BY Contract.id
ORDER BY Contract.owner_id,Contract.`create`";
if(is_array($limit) && count($limit)) {
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
} elseif(is_numeric($count)) {
$sql .= " LIMIT ".$limit['count'];
}
}
mfLoghandler::singleton()->debug($sql);
$res = $db->query($sql);
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[$data->id] = new Contract($data);
}
}
return $items;
}
public static function search($filter, $limit = false) {
//var_dump($filter);exit;
$items = [];

View File

@@ -0,0 +1,5 @@
<?php
class ContractFile extends mfBaseModel {
}

View File

@@ -0,0 +1,149 @@
<?php
class ContractFileModel {
public $contract_id;
public $file_id;
public $name;
public $description;
public $create_by = null;
public $edit_by = null;
public $create = null;
public $edit = null;
public static function create(Array $data) {
$model = new ContractFile();
foreach($data as $field => $value) {
if(property_exists(get_called_class(), $field)) {
$model ->$field = $value;
}
}
$me = new User();
$me->loadMe();
if($model->create_by === null) {
$model->create_by = $me->id;
}
if($model->edit_by === null) {
$model->edit_by = $me->id;
}
return $model;
}
public static function getOne($id) {
if(!is_numeric($id) || !$id) {
throw new Exception("Invalid number", 400);
}
$item = [];
$db = FronkDB::singleton();
$res = $db->select("ContractFile", "*", "id=$id LIMIT 1");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new ContractFile($data);
}
return $item;
}
public static function getAll() {
$items = [];
$db = FronkDB::singleton();
$res = $db->select("ContractFile", "*", "1=1 ORDER BY contract_id, `create`");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new ContractFile($data);
}
}
return $items;
}
public static function getFirst() {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("ContractFile", "*", "$where ORDER BY contract_id, `create`");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new ContractFile($data);
if($item->id) {
return $item;
} else {
return null;
}
}
return null;
}
public static function search($filter) {
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$sql = "SELECT ContractFile.* FROM ContractFile
LEFT JOIN File ON (ContractFile.file_id = File.id)
WHERE $where
ORDER BY contract_id, `create`";
$res = $db->query($sql);
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new ContractFile($data);
}
}
return $items;
}
private static function getSqlFilter($filter) {
$where = "1=1 ";
if(array_key_exists("file_id", $filter)) {
$file_id = $filter['file_id'];
if(is_numeric($file_id)) {
$where .= " AND file_id=$file_id";
}
}
if(array_key_exists("contract_id", $filter)) {
$contract_id = $filter['contract_id'];
if(is_numeric($contract_id)) {
$where .= " AND contract_id=$contract_id";
}
}
//var_dump($filter);exit;
if(array_key_exists("name", $filter)) {
$name = FronkDB::singleton()->escape($filter['name']);
if($name) {
$where .= " AND name='$name'";
}
}
if(array_key_exists("filename", $filter)) {
$filename = FronkDB::singleton()->escape($filter['filename']);
if($filename) {
$where .= " AND File.filename='$filename'";
}
}
if(array_key_exists("subfolder", $filter)) {
$subfolder = FronkDB::singleton()->escape($filter['subfolder']);
if($subfolder) {
$where .= " AND File.subfolder='$subfolder'";
}
}
//var_dump($filter, $where);exit;
return $where;
}
}

View File

@@ -0,0 +1,59 @@
<?php
class Contractjournal extends mfBaseModel {
private $contract;
private $contractfile;
private $creator;
private $editor;
public function getProperty($name) {
if($this->$name == null) {
if($name == "contractfile") {
if(!is_numeric($this->value)) return null;
$this->contractfile = new ContractFile($this->value);
return $this->contractfile;
}
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;
}
}

View File

@@ -0,0 +1,128 @@
<?php
class ContractjournalModel {
public $contract_id;
public $type;
public $value;
public $text;
public $create_by = null;
public $edit_by = null;
public $create = null;
public $edit = null;
public static function create(Array $data) {
$model = new Contractjournal();
foreach($data as $field => $value) {
if(property_exists(get_called_class(), $field)) {
$model ->$field = $value;
}
}
$me = new User();
$me->loadMe();
if($model->create_by === null) {
$model->create_by = $me->id;
}
if($model->edit_by === null) {
$model->edit_by = $me->id;
}
return $model;
}
public static function getAll() {
$items = [];
$db = FronkDB::singleton();
$res = $db->select("Contractjournal", "*", "1=1 ORDER BY contract_id,`create`");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new Contractjournal($data);
}
}
return $items;
}
public static function getFirst($filter = false) {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("Contractjournal", "*", "$where ORDER BY contract_id,`create`");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Contractjournal($data);
if($item->id) {
return $item;
} else {
return null;
}
}
return null;
}
public static function search($filter) {
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
/*
$sql = "SELECT Contractjournal.* FROM Contractjournal
LEFT JOIN File ON (Contractjournal.file_id = File.id)
WHERE $where
ORDER BY order_id, name";
$res = $db->query($sql);
*/
$res = $db->select("Contractjournal", "*", $where);
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new Contractjournal($data);
}
}
return $items;
}
private static function getSqlFilter($filter) {
$where = "1=1 ";
if(array_key_exists("contract_id", $filter)) {
$contract_id = $filter['contract_id'];
if(is_numeric($contract_id)) {
$where .= " AND contract_id=$contract_id";
}
}
if(array_key_exists("order_id", $filter)) {
$order_id = $filter['order_id'];
if(is_numeric($order_id)) {
$where .= " AND order_id=$order_id";
}
}
if(array_key_exists("type", $filter)) {
$type = FronkDB::singleton()->escape($filter['type']);
if($type) {
$where .= " AND type='$type'";
}
}
if(array_key_exists("value", $filter)) {
$value = FronkDB::singleton()->escape($filter['value']);
if($value) {
$where .= " AND value='$value'";
}
}
//var_dump($filter, $where);exit;
return $where;
}
}

View File

@@ -71,6 +71,22 @@ h1, h2, h3, h4, h5, h6 {
border-color: #f0f0f0;
box-shadow: 3px 3px 2px #a0a0a0;
}
.card.border-top-primary {
border-top: 2px solid #007bff;
}
.card.border-top-danger {
border-top: 2px solid #f1556c;
}
.card.border-top-success {
border-top: 2px solid #25b343;
}
.card.border-top-warning {
border-top: 2px solid #f7b84b;
}
/*
.card-header.underline-danger {
border-bottom: 2px solid #f1556c;
}*/
#topnav {
box-shadow: 2px 2px 1px #a0a0a0;