| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php /** @noinspection PhpUnhandledExceptionInspection */
- namespace App;
- /**
- * @var string $type_string
- */
- use App\Enums\DocumentTypes;
- use RuntimeException;
- $core = Core::getInstance();
- $user = $core->getUser();
- $user->requireAdmin();
- switch($type_string) {
- case "invoices":
- $title = __("Invoices");
- $type = DocumentTypes::INVOICE;
- $singular = __("%s invoice");
- $plural = __("%s invoices");
- break;
- case "goods-in":
- $title = __("Goods-In");
- $type = DocumentTypes::GOODS_IN;
- $singular = __("%s goods-in documents");
- $plural = __("%s goods-in documents");
- break;
- case "arus":
- $title = __("ARUs");
- $type = DocumentTypes::ADVANCE_REPLACEMENT_UNIT;
- $singular = __("%s ARU");
- $plural = __("%s ARUs");
- break;
- default:
- throw new RuntimeException(__("Invalid type string."));
- }
- $core->addBreadcrumb("/$type_string", $title);
- $type_name = DocumentTypes::enumToText($type);
- $nvp = [
- "type" => $type,
- "dts_deleted" => null
- ];
- $count = Document::count($nvp);
- $pagination = new Pagination($count);
- $pagination->setTerms($singular, $plural);
- $documents = Document::query($nvp, [
- "sort" => "id",
- "order" => "desc",
- "offset" => $pagination->getOffset(),
- "limit" => $pagination->getPageSize()
- ]);
- $core->addScript("/js/new-document-modal.js");
- View::include("header");
- View::include("documents", compact("title", "type", "documents", "pagination", "type_name"));
- View::include("modals/new_document");
- View::include("footer");
|