Added Order Form and File

This commit is contained in:
Frank Schubert
2021-07-30 18:24:51 +02:00
parent 1ae970564f
commit ec0abff225
18 changed files with 1078 additions and 101 deletions

View File

@@ -1,5 +1,37 @@
<?php
class OrderFile extends mfBaseModel {
private $file;
public function getProperty($name) {
if($this->$name == null) {
if(!$this->id) {
return null;
}
if($name == "creator") {
$this->creator = new User($this->create_by);
return $this->creator;
}
if($name == "editor") {
$this->editor = new User($this->edit_by);
return $this->editor;
}
$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;
}
}

View File

@@ -0,0 +1,36 @@
<?php
class OrderFileController 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 editAction() {
// internal redirect to File::editAction
}
protected function deleteAction() {
$id = $this->request->id;
$orderfile = new OrderFile($id);
if(!$orderfile->id || $orderfile->id != $id) {
$this->layout()->setFlash("Dokument nicht gefunden.", "error");
$this->redirect("Order");
}
$order_id = $orderfile->order_id;
$orderfile->file->delete();
$orderfile->delete();
$this->redirect("Order", "edit", ["id" => $order_id]);
}
}

View File

@@ -1,11 +1,10 @@
<?php
class OrderFileModel {
public $order_id;
public $file_id;
public $name;
public $description;
public $filename;
public $orig_filename;
public $subfolder;
public $create_by = null;
public $edit_by = null;
@@ -89,8 +88,8 @@ class OrderFileModel {
$where = self::getSqlFilter($filter);
$sql = "SELECT OrderFile.* FROM OrderFile
LEFT JOIN File ON (Order.file_id = File.id)
$where
LEFT JOIN File ON (OrderFile.file_id = File.id)
WHERE $where
ORDER BY order_id, name";
$res = $db->query($sql);