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");