Order/Form: documents can be uploaded even if order is closed already
This commit is contained in:
@@ -239,7 +239,7 @@ class OrderController extends mfBaseController {
|
||||
&& $lop->product->attributes['termination_required']
|
||||
&& $lop->termination_id
|
||||
) {
|
||||
$has_term = true;
|
||||
$has_term = true; // is already in orders with terminations
|
||||
}
|
||||
}
|
||||
if(!$has_bras && !$has_voice && !$has_term) {
|
||||
@@ -1286,7 +1286,7 @@ class OrderController extends mfBaseController {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function saveVorortterminAction() {
|
||||
if(!$this->me->is(["Admin","salespartner"])) {
|
||||
$this->layout()->setFlash("Keine Berechtigung", "error");
|
||||
@@ -1478,5 +1478,76 @@ class OrderController extends mfBaseController {
|
||||
|
||||
$this->redirect("Order");
|
||||
}
|
||||
|
||||
protected function apiAction() {
|
||||
$do = $this->request->do;
|
||||
$data = [];
|
||||
|
||||
switch($do) {
|
||||
case "uploadDocument":
|
||||
$return = $this->uploadDocumentApi();
|
||||
break;
|
||||
default:
|
||||
$return = false;
|
||||
}
|
||||
|
||||
if(!is_array($return) || !count($return)) {
|
||||
$data = ["status" => "error"];
|
||||
$this->returnJson($data);
|
||||
}
|
||||
|
||||
if(mfResponse::isResponse($return)) {
|
||||
$this->returnJson($return);
|
||||
} else {
|
||||
$data['status'] = "OK";
|
||||
$data['result'] = $return;
|
||||
$this->returnJson($data);
|
||||
}
|
||||
}
|
||||
|
||||
private function uploadDocumentApi() {
|
||||
$order_id = $this->request->id;
|
||||
$filename = $this->request->file_name;
|
||||
$orig_filename = $this->request->orig_filename;
|
||||
$description = $this->request->file_description;
|
||||
|
||||
if(!$order_id || !is_numeric($order_id) || $order_id < 1) {
|
||||
return false;
|
||||
}
|
||||
$order = new Order($order_id);
|
||||
if(!$order->id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!$filename) {
|
||||
$this->log->error(__METHOD__.": No filename");
|
||||
return false;
|
||||
}
|
||||
|
||||
$file = mfUpload::handleFormUpload("file_contents");
|
||||
|
||||
if(!$file) {
|
||||
$this->log->error(__METHOD__.": Error uploading file");
|
||||
return false;
|
||||
} else {
|
||||
$of = [];
|
||||
$of['order_id'] = $order_id;
|
||||
$of['file_id'] = $file->id;
|
||||
$of['name'] = $filename;
|
||||
$of['description'] = $description;
|
||||
|
||||
$orderfile = OrderFileModel::create($of);
|
||||
if(!$orderfile->save()) {
|
||||
$file->delete();
|
||||
$this->log->error(__METHOD__.": Error saving OrderFile object: ".print_r($orderfile, true));
|
||||
} else {
|
||||
// send email based on file type
|
||||
$order->sendFileuploadEmail($orderfile);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return ["status" => "OK", "message" => "File uploaded successfully"];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user