Added Order Form
This commit is contained in:
383
Layout/default/Order/Form.php
Normal file
383
Layout/default/Order/Form.php
Normal file
@@ -0,0 +1,383 @@
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/header.php"); ?>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>">the-tool</a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Order")?>">Bestellungen</a></li>
|
||||
<li class="breadcrumb-item active"><?=($order->id) ? "bearbeiten" : "Neu" ?></li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Bestellungen</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="header-title mb-2"><?=($order->id) ? "Bestellung bearbeiten" : "Neue Bestellung"?></h4>
|
||||
|
||||
<form class="form-horizontal" method="post" action="<?=self::getUrl("Order", "save")?>">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<input type="hidden" name="id" value="<?=$order->id?>" />
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
|
||||
|
||||
|
||||
<div class="col-lg-12 mb-2">
|
||||
<h4>Vertragsinhaber</h4>
|
||||
<select class="form-control" name="owner_id" id="owner_id">
|
||||
<option></option>
|
||||
<option value="new">Neu...</option>
|
||||
<?php foreach($addresses as $address): ?>
|
||||
<option value="<?=$address->id?>"><?=$address->getCompanyOrName()?> (<?=$address->zip?> <?=$address->city?>, <?=$address->street?>)</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-12 hidden" id="owner-form">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="owner_company">Firmenname</label>
|
||||
<textarea class="form-control" name="owner_company" id="owner_company"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="owner_firstname">Vorname</label>
|
||||
<input type="text" class="form-control" name="owner_firstname" id="owner_firstname" value="" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="owner_lastname">Nachname</label>
|
||||
<input type="text" class="form-control" name="owner_lastname" id="owner_lastname" value="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="owner_street">Straße</label>
|
||||
<input type="text" class="form-control" name="owner_street" id="owner_street" value="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-3">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="owner_zip">Postleitzahl</label>
|
||||
<input type="text" class="form-control" name="owner_zip" id="owner_zip" value="" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-9">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="owner_city">Ort</label>
|
||||
<input type="text" class="form-control" name="owner_city" id="owner_city" value="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="owner_country">Land</label>
|
||||
<input type="text" class="form-control" name="owner_country" id="owner_country" value="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="owner_phone">Telefon</label>
|
||||
<input type="text" class="form-control" name="owner_phone" id="owner_phone" value="" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="owner_mobile">Mobil</label>
|
||||
<input type="text" class="form-control" name="owner_mobile" id="owner_mobile" value="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="owner_email">Emailadresse</label>
|
||||
<input type="text" class="form-control" name="owner_email" id="owner_email" value="" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="owner_fax">Fax</label>
|
||||
<input type="text" class="form-control" name="owner_fax" id="owner_fax" value="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
|
||||
<div class="form-group row">
|
||||
|
||||
<div class="col-lg-12 mb-2">
|
||||
<h4>Rechungsadresse</h4>
|
||||
<select class="form-control" name="billingaddress_id" id="billingaddress_id">
|
||||
<option></option>
|
||||
<option value="new">Neu...</option>
|
||||
<?php foreach($addresses as $address): ?>
|
||||
<option value="<?=$address->id?>"><?=$address->getCompanyOrName()?> (<?=$address->zip?> <?=$address->city?>, <?=$address->street?>)</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-12 hidden" id="billingaddress-form">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="owner_company">Firmenname</label>
|
||||
<textarea class="form-control" name="billing_company" id="billing_company"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="billing_firstname">Vorname</label>
|
||||
<input type="text" class="form-control" name="billing_firstname" id="billing_firstname" value="" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="billing_lastname">Nachname</label>
|
||||
<input type="text" class="form-control" name="billing_lastname" id="billing_lastname" value="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="billing_street">Straße</label>
|
||||
<input type="text" class="form-control" name="billing_street" id="billing_street" value="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-3">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="billing_zip">Postleitzahl</label>
|
||||
<input type="text" class="form-control" name="billing_zip" id="billing_zip" value="" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-9">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="billing_city">Ort</label>
|
||||
<input type="text" class="form-control" name="billing_city" id="billing_city" value="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="billing_country">Land</label>
|
||||
<input type="text" class="form-control" name="billing_country" id="billing_country" value="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="billing_phone">Telefon</label>
|
||||
<input type="text" class="form-control" name="billing_phone" id="billing_phone" value="" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="billing_mobile">Mobil</label>
|
||||
<input type="text" class="form-control" name="billing_mobile" id="billing_mobile" value="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="billing_email">Emailadresse</label>
|
||||
<input type="text" class="form-control" name="billing_email" id="billing_email" value="" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="billing_fax">Fax</label>
|
||||
<input type="text" class="form-control" name="billing_fax" id="billing_fax" value="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<h4 class="header-title">Verrechnung</h4>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="description">Rechnungsart</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control" name="billing_type">
|
||||
<option value="sepa">SEPA Bankeinzug</option>
|
||||
<option value="invoice">Rechnung</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="bank_account_bank">Kreitinstitut</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="bank_account_bank" id="bank_account_bank" value="" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="bank_account_owner">Kontoinhaber</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="bank_account_owner" id="bank_account_owner" value="" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="bank_account_iban">IBAN</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="bank_account_iban" id="bank_account_iban" value="" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="bank_account_bic">BIC</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="bank_account_bic" id="bank_account_bic" value="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h4 class="header-title">Einwilligungen</h4>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="form-group row">
|
||||
<div class="col-lg-2"></div>
|
||||
<div class="col-lg-10">
|
||||
<label class="form-check-label"><input type="checkbox" class="form-check-input" name="allow_contact" id="allow_contact" /> Informationen per Post/Email/Telefon</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col-lg-2"></div>
|
||||
<div class="col-lg-10">
|
||||
<label class="form-check-label"><input type="checkbox" class="form-check-input" name="allow_spin" id="allow_contact" /> Auskunft mit Service PIN</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
|
||||
<div class="col-lg-10">
|
||||
<textarea id="note" class="form-control" name="note" rows="5"><?=$order->note?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2"></label>
|
||||
<div class="col-lg-10">
|
||||
<button type="submit" class="btn btn-primary">Speichern</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
$("#productgroup_id").select2({
|
||||
allowClear: true,
|
||||
placeholder: ""
|
||||
});
|
||||
$("#producttech_id").select2({
|
||||
allowClear: true,
|
||||
placeholder: ""
|
||||
});
|
||||
$("#networks").select2({
|
||||
allowClear: true,
|
||||
placeholder: ""
|
||||
});
|
||||
|
||||
$('#owner_id').change(function() {
|
||||
var val = $('#owner_id').val();
|
||||
|
||||
if(val == "new") {
|
||||
$('#owner-form').show();
|
||||
} else {
|
||||
$('#owner-form').hide();
|
||||
}
|
||||
});
|
||||
|
||||
$('#billingaddress_id').change(function() {
|
||||
var val = $('#billingaddress_id').val();
|
||||
|
||||
if(val == "new") {
|
||||
$('#billingaddress-form').show();
|
||||
} else {
|
||||
$('#billingaddress-form').hide();
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/footer.php"); ?>
|
||||
70
Layout/default/Order/Index.php
Normal file
70
Layout/default/Order/Index.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/header.php"); ?>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>">the-tool</a></li>
|
||||
<li class="breadcrumb-item active">Bestellungen</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Bestellungen</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
<div class="float-left">
|
||||
<h4 class="header-title">Liste aller Bestellungen</h4>
|
||||
</div>
|
||||
<div class="float-right">
|
||||
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Order", "add")?>"><i class="fas fa-plus"></i> Neue Bestellung anlegen</a>
|
||||
</div>
|
||||
|
||||
<table class="table table-striped table-hover">
|
||||
<tr>
|
||||
<th>Kunde</th>
|
||||
<th>Adresse</th>
|
||||
<th>Anschlussadresse</th>
|
||||
<th>Kontakt</th>
|
||||
<th>Bestellt am</th>
|
||||
<th>Zuletzt bearbeitet</th>
|
||||
<th>Bearbeitet von</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach($orders as $order): ?>
|
||||
<tr>
|
||||
<td><?=nl2br($order->owner->getCompanyOrName())?></td>
|
||||
<td>
|
||||
<?=$order->owner->street?><br />
|
||||
<?=$order->owner->zip?> <?=$order->owner->city?>
|
||||
</td>
|
||||
<td>
|
||||
<?=$order->termination->building->street?><?=($order->termination->name) ? " ".$order->termination->name : ""?><br />
|
||||
<?=$order->termination->building->zip?> <?=$order->termination->building->city?>
|
||||
</td>
|
||||
<td><?=$order->contact->getCompanyOrName()?></td>
|
||||
<td class="text-monospace"><?=$order->create?></td>
|
||||
<td class="text-monospace"><?=$order->edit?></td>
|
||||
<td class="text-monospace"><?=$order->editor->name?></td>
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||
<a href="<?=self::getUrl("Order", "edit", ["id" => $order->id])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("Order", "delete", ["id" => $order->id])?>" onclick="if(!confirm('Bestellung wirklich löschen?')) return false;" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/footer.php"); ?>
|
||||
@@ -40,6 +40,15 @@
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="has-submenu">
|
||||
<a href="#">
|
||||
<i class="fas fa-hard-hat"></i>Verkauf <div class="arrow-down"></div>
|
||||
</a>
|
||||
<ul class="submenu">
|
||||
<li><a href="<?=self::getUrl("Order")?>">Bestellungen</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
<!-- End navigation menu -->
|
||||
|
||||
|
||||
5
application/AddressFile/AddressFile.php
Normal file
5
application/AddressFile/AddressFile.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
class AddressFile extends mfBaseModel {
|
||||
|
||||
}
|
||||
151
application/AddressFile/AddressFileModel.php
Normal file
151
application/AddressFile/AddressFileModel.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
class AddressFileModel {
|
||||
public $name;
|
||||
public $description;
|
||||
public $filename;
|
||||
public $orig_filename;
|
||||
public $subfolder;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
public $create = null;
|
||||
public $edit = null;
|
||||
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new AddressFile();
|
||||
|
||||
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("AddressFile", "*", "id=$id LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new AddressFile($data);
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("AddressFile", "*", "1=1 ORDER BY name, filename");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new AddressFile($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst() {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("AddressFile", "*", "$where ORDER BY name, filename");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new AddressFile($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function search($filter) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
//$res = $db->select("AddressFile", "*", "$where ORDER BY name, filename");
|
||||
|
||||
$sql = "SELECT AddressFile.* FROM AddressFile
|
||||
LEFT JOIN File ON (Address.file_id = File.id)
|
||||
$where
|
||||
ORDER BY address_id, name";
|
||||
|
||||
$res = $db->query($sql);
|
||||
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new AddressFile($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
private 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("address_id", $filter)) {
|
||||
$address_id = $filter['address_id'];
|
||||
if(is_numeric($address_id)) {
|
||||
$where .= " AND address_id=$address_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;
|
||||
}
|
||||
|
||||
}
|
||||
5
application/File/File.php
Normal file
5
application/File/File.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
class File extends mfBaseModel {
|
||||
|
||||
}
|
||||
16
application/File/FileController.php
Normal file
16
application/File/FileController.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
class FileController extends mfBaseController {
|
||||
|
||||
protected function init() {
|
||||
$this->needlogin=true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me",$me);
|
||||
|
||||
/*if(!$me->isAdmin()) {
|
||||
$this->redirect("Dashboard");
|
||||
}*/
|
||||
}
|
||||
}
|
||||
128
application/File/FileModel.php
Normal file
128
application/File/FileModel.php
Normal file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
class FileModel {
|
||||
public $name;
|
||||
public $description;
|
||||
public $filename;
|
||||
public $orig_filename;
|
||||
public $subfolder;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
public $create = null;
|
||||
public $edit = null;
|
||||
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new File();
|
||||
|
||||
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("File", "*", "id=$id LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new File($data);
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("File", "*", "1=1 ORDER BY name, filename");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new File($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst() {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("File", "*", "$where ORDER BY name, filename");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new File($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function search($filter) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("File", "*", "$where ORDER BY name, filename");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new File($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
private function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
//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 filename='$filename'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("subfolder", $filter)) {
|
||||
$subfolder = FronkDB::singleton()->escape($filter['subfolder']);
|
||||
if($subfolder) {
|
||||
$where .= " AND subfolder='$subfolder'";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
71
application/Order/Order.php
Normal file
71
application/Order/Order.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
class Order extends mfBaseModel {
|
||||
private $owner;
|
||||
private $billingaddress;
|
||||
private $creator;
|
||||
private $editor;
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "owner") {
|
||||
if($this->id) {
|
||||
$this->owner = new Address($this->owner_id);
|
||||
return $this->owner;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if($name == "contact") {
|
||||
if($this->id) {
|
||||
$this->contact = new Address($this->contact_id);
|
||||
return $this->contact;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if($name == "billingaddress") {
|
||||
if($this->id) {
|
||||
$this->billingaddress = new Address($this->billingaddress_id);
|
||||
return $this->billingaddress;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if($name == "creator") {
|
||||
if($this->id) {
|
||||
$this->creator = new User($this->create_by);
|
||||
return $this->creator;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if($name == "editor") {
|
||||
if($this->id) {
|
||||
$this->editor = new User($this->edit_by);
|
||||
return $this->editor;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
if($this->$name->id) {
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
}
|
||||
27
application/Order/OrderController.php
Normal file
27
application/Order/OrderController.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
class OrderController extends mfBaseController {
|
||||
|
||||
protected function init() {
|
||||
$this->needlogin=true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me",$me);
|
||||
|
||||
if(!$me->isAdmin()) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
protected function indexAction() {
|
||||
$this->layout()->setTemplate("Order/Index");
|
||||
$this->layout()->set("orders", OrderModel::getAll());
|
||||
|
||||
}
|
||||
|
||||
protected function addAction() {
|
||||
$this->layout()->setTemplate("Order/Form");
|
||||
$this->layout()->set("addresses", AddressModel::search(['parents_only' => 1]));
|
||||
}
|
||||
}
|
||||
135
application/Order/OrderModel.php
Normal file
135
application/Order/OrderModel.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
class OrderModel {
|
||||
public $owner_id;
|
||||
public $billingaddress_id;
|
||||
public $order_date;
|
||||
public $finish_date;
|
||||
public $billing_text;
|
||||
public $bank_account_bank;
|
||||
public $bank_account_owner;
|
||||
public $bank_account_iban;
|
||||
public $bank_account_bic;
|
||||
public $allow_contact;
|
||||
public $allow_spin;
|
||||
public $note;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
public $create = null;
|
||||
public $edit = null;
|
||||
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new Order();
|
||||
|
||||
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("Order", "*", "id=$id LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new Order($data);
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("Order", "*", "1=1 ORDER BY name, filename");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new Order($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst() {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("Order", "*", "$where ORDER BY name, filename");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new Order($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function search($filter) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("Order", "*", "$where ORDER BY id");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new Order($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
private function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
//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 filename='$filename'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("subfolder", $filter)) {
|
||||
$subfolder = FronkDB::singleton()->escape($filter['subfolder']);
|
||||
if($subfolder) {
|
||||
$where .= " AND subfolder='$subfolder'";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
5
application/OrderFile/OrderFile.php
Normal file
5
application/OrderFile/OrderFile.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
class OrderFile extends mfBaseModel {
|
||||
|
||||
}
|
||||
150
application/OrderFile/OrderFileModel.php
Normal file
150
application/OrderFile/OrderFileModel.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
class OrderFileModel {
|
||||
public $name;
|
||||
public $description;
|
||||
public $filename;
|
||||
public $orig_filename;
|
||||
public $subfolder;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
public $create = null;
|
||||
public $edit = null;
|
||||
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new OrderFile();
|
||||
|
||||
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("OrderFile", "*", "id=$id LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new OrderFile($data);
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("OrderFile", "*", "1=1 ORDER BY name, filename");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new OrderFile($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst() {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("OrderFile", "*", "$where ORDER BY name, filename");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new OrderFile($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 OrderFile.* FROM OrderFile
|
||||
LEFT JOIN File ON (Order.file_id = File.id)
|
||||
$where
|
||||
ORDER BY order_id, name";
|
||||
|
||||
$res = $db->query($sql);
|
||||
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new OrderFile($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
private 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("order_id", $filter)) {
|
||||
$order_id = $filter['order_id'];
|
||||
if(is_numeric($order_id)) {
|
||||
$where .= " AND order_id=$order_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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user