Files
thetool/application/RimoWorkorder/RimoWorkorderController.php
2024-11-08 16:40:47 +01:00

43 lines
1.1 KiB
PHP

<?php
class RimoWorkorderController extends mfBaseController {
protected function init() {
$this->needlogin=true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me",$me);
}
protected function downloadAhaAction() {
$workorder_id = $this->request->id;
if(!$workorder_id || $workorder_id < 1) {
header("HTTP/1.1 400 Bad Request");
echo "Invalid workorder id.";
exit;
}
$workorder = new RimoWorkorder($workorder_id);
if(!$workorder->id) {
header("HTTP/1.1 404 Not Found");
echo "Workorder nicht gefunden.";
exit;
}
$return = $workorder->getAha();
if($return === false) {
header("HTTP/1.1 500 Not Found");
echo "Fehler beim Herunterladen des AHA-Reports aus Rimo.";
exit;
}
header("Content-type: text/pdf");
header('Content-disposition: attachment; filename="'.$workorder->rimo_name.'_AHA.pdf"');
echo $return;
exit;
}
}