<?php
namespace Claromentis\Projects\Controller;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"] = (@$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"] ?: array()) + array("_e2cd02b3" . "4604bb4da" . "597fe440c" . "fe476e" => base64_decode("c2Vhcm" . "No"), "_03e9164d0a343b742df4793268b807" . "67" => base64_decode("Zml" . "sdG" . "Vy"), "_4c760fb02a49c55509ba087b8" . "4fbda45" => base64_decode("ZHJhZn" . "Q="), "_5d85dcad782c12" . "2b938ac7a4137a7" . "183" => base64_decode("cHJvamVjdHMvaW5kZXg" . "uaHRtbA=="), "_f6a16426f3b3f03ad6bacec9" . "12eec291" => base64_decode("c29yd" . "A=="), "_ed5f03d686c37933b5943" . "f295c6b4a43" => base64_decode("anNv" . "bg=="), "_fe55f93e48d" . "864ac4b43fc2" . "e85a1009b" => base64_decode("Zm9sbG" . "93aW5n"), "company_i" . "d" => base64_decode("Y29tcGFueV9pZ" . "A=="), "_748cca386a9df2eb5a1fe07d" . "38031a88" => base64_decode("b25ob2" . "xk"), "_146e0c87306f6f3b" . "c324a175328e5995" => base64_decode("U0VTU0lPTl9Qcm9qZWN0X3Byb2plY3RsaX" . "N0X3NvcnQ="), "_7276e0af756e529d30af7aaafe4e7" . "784" => base64_decode("YXJjaGl2ZW" . "Q="), "_8dabb06efc95df4cff7c4afe918" . "57b53" => base64_decode("bm" . "Ft" . "ZQ" . "=="), "_396a8010e8da9ead4c3c06dcdfb" . "052c6" => base64_decode("LWR" . "hdG" . "U="), "_67a0d62" . "4aebcceb" . "0abd5ce5" . "6a53ff06" . "f" => base64_decode("ZGF0" . "ZQ=="), "_dc4707069e0aa9a7eb339df27e" . "37aed5" => base64_decode("YWRkQnV" . "0dG9uLn" . "Zpc2lib" . "GU="), "_2b39ab477b13" . "830a54b0ba0ad" . "a25cbd7" => base64_decode("YWN" . "0aX" . "Zl"), "_e1b7238fbb46439026e869e060d6" . "ca47" => base64_decode("Zm9ybWF" . "0"), "_64666bc" . "f1e5aaa0" . "7774f3d7" . "439ff264" . "d" => base64_decode("Y29tc" . "GxldG" . "Vk"), "_a0624a55e60ee7" . "aae11f61e56eea7" . "c0c" => base64_decode("dGVtcGxhdGU" . "="), "_221da17e3055f" . "ae8d3ff516b832" . "a5f3b" => base64_decode("cGF" . "nZQ" . "=="), "_bacbe8dd9caf37d515b" . "d02bcff1ba9fa" => base64_decode("cHJvamVjdHMucHJvamVjdC5wY" . "WdlX3RpdGxl"));
use Claromentis\Core\Http\gpc;
use Claromentis\Core\Http\JsonPrettyResponse;
use Claromentis\Core\Http\TemplaterCallResponse;
use Claromentis\Core\Localization\Lmsg;
use Claromentis\Projects\PermissionsChecker;
use Claromentis\Projects\PermissionsMap;
use Claromentis\Projects\ProjectListFilter;
use Claromentis\Projects\Repository\CompanyRepository;
use Claromentis\Projects\Repository\ProjectRepository;
use Claromentis\Projects\View\ProjectListView;
use Claromentis\Projects\View\ProjectView;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Component\HttpFoundation\Session\Session;




class ProjectsListController
{
    
    
    protected $permissions_checker;
    
    
    protected $page_size;
    
    
    
    
    
    
    public function __construct(PermissionsChecker $permissions_checker, int $page_size)
    {
        $this->permissions_checker = $permissions_checker;
        $this->page_size = $page_size;
    }
    public function ShowList(Session $session, ServerRequestInterface $_b791059c94b285cdf1c90ca6f3a8f2a6, CompanyRepository $company_repository, ProjectRepository $project_repository, ProjectView $project_view, Lmsg $lmsg)
    {
        $_221da17e3055fae8d3ff516b832a5f3b = gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_221da17e3055fae8d3ff5" . "16b832a5f3b"], null);
        $_e2cd02b34604bb4da597fe440cfe476e = gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_e2cd02b34604bb4da597fe440cfe" . "476e"], null);
        $_03e9164d0a343b742df4793268b80767 = gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_03e9164d0a343b742d" . "f4793268b80767"], null);
        $_e1b7238fbb46439026e869e060d6ca47 = gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_e1b7238fbb46439026e869e0" . "60d6ca47"], null);
        $_f6a16426f3b3f03ad6bacec912eec291 = gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_f6a16426f3b3f03ad6" . "bacec912eec291"], null);
        $company_id = (int) gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["comp" . "any_" . "id"], 0);
        if ($_f6a16426f3b3f03ad6bacec912eec291 === $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_67a0d624aebcceb0abd5ce56a53f" . "f06f"]) {
            $_f6a16426f3b3f03ad6bacec912eec291 = $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_396a8010e8da9ead4c3c06dcdfb052" . "c6"];
        }
        
        
        if ($_f6a16426f3b3f03ad6bacec912eec291 === null) {
            $_f6a16426f3b3f03ad6bacec912eec291 = $session->get($GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_146e0c87306f6f3bc324a175328e59" . "95"], $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_8dabb06efc95df4cff7c4afe" . "91857b53"]);
        } else {
            $session->set($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_146e0c87306f6f3bc324a175" . "328e5995"], $_f6a16426f3b3f03ad6bacec912eec291);
        }
        switch ($_03e9164d0a343b742df4793268b80767) {
            case $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_fe55f93e48d864ac4b43fc2e" . "85a1009b"]:
                $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_FOLLOWING;
                break;
            case $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_4c760fb02a49c55509ba08" . "7b84fbda45"]:
                $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_DRAFT;
                break;
            case $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_748cca386a9" . "df2eb5a1fe07" . "d38031a88"]:
                $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_ON_HOLD;
                break;
            case $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_7276e0af756e529d30af7a" . "aafe4e7784"]:
                $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_ARCHIVED;
                break;
            case $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_a0624a55e60ee7aa" . "e11f61e56eea7c0c"]:
                if ($this->permissions_checker->CanICreateProjects()) {
                    $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_TEMPLATES;
                } else {
                    $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_DEFAULT;
                }
                break;
            case $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_64666bcf1e5aaa07774f" . "3d7439ff264d"]:
                $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_COMPLETED;
                break;
            case $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_2b39ab477b13830a54b0ba0" . "ada25cbd7"]:
            default:
                $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_DEFAULT;
                break;
        }
        $_6daeec015ee6c52ced92781b59ff89b5 = new ProjectListFilter();
        $_6daeec015ee6c52ced92781b59ff89b5->SetResultSize($this->page_size);
        if ($_221da17e3055fae8d3ff516b832a5f3b !== null) {
            $_6daeec015ee6c52ced92781b59ff89b5->SetPage($_221da17e3055fae8d3ff516b832a5f3b);
        }
        if ($_03e9164d0a343b742df4793268b80767 !== null) {
            $_6daeec015ee6c52ced92781b59ff89b5->SetFilter($_03e9164d0a343b742df4793268b80767);
        }
        $_6daeec015ee6c52ced92781b59ff89b5->SetSort($_f6a16426f3b3f03ad6bacec912eec291);
        $_6daeec015ee6c52ced92781b59ff89b5->SetSearch($_e2cd02b34604bb4da597fe440cfe476e);
        if ($company_id !== 0) {
            $_6daeec015ee6c52ced92781b59ff89b5->SetCompanyId($company_id);
        }
        $project_repository->SetListFilter($_6daeec015ee6c52ced92781b59ff89b5);
        $_68680c984182bf7876b2bb0ab77ebe01 = $project_repository->GetProjects(true);
        $view = new ProjectListView($project_repository, $company_repository, $project_view);
        if ($_e1b7238fbb46439026e869e060d6ca47 === $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_ed5f03d686c37933b59" . "43f295c6b4a43"]) {
            return new JsonPrettyResponse($view->GetProjectListJsonView($_68680c984182bf7876b2bb0ab77ebe01));
        }
        $_bbcdf77b6167a26a35212c8181097030 = array();
        $view->SetArgsArray($_bbcdf77b6167a26a35212c8181097030);
        $view->ShowProjectList($_68680c984182bf7876b2bb0ab77ebe01);
        if ($this->permissions_checker->CanI(0, PermissionsMap::CREATE_PROJECT)) {
            $_bbcdf77b6167a26a35212c8181097030[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_dc4707069e0a" . "a9a7eb339df27" . "e37aed5"]] = 1;
        }
        $_678d945258a520c3df1c42fe4b558f34 = $lmsg($GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_bacbe8dd9caf37d515bd02b" . "cff1ba9fa"]);
        $_a0624a55e60ee7aae11f61e56eea7c0c = $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_5d85dcad782c122b938ac7a4137" . "a7183"];
        return new TemplaterCallResponse($_a0624a55e60ee7aae11f61e56eea7c0c, $_bbcdf77b6167a26a35212c8181097030, $_678d945258a520c3df1c42fe4b558f34);
    }
}