<?php
namespace Claromentis\Projects\Controller;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"] ?: array()) + array("_fe55f93e48d864ac4b43fc2e85a" . "1009b" => base64_decode("Zm9sbG93aW" . "5n"), "_7276e0af756" . "e529d30af7aa" . "afe4e7784" => base64_decode("YXJj" . "aGl2" . "ZWQ="), "_e2cd02b34604bb4d" . "a597fe440cfe476e" => base64_decode("c2Vhc" . "mNo"), "_f6a16426f3b3f03ad" . "6bacec912eec291" => base64_decode("c29ydA" . "=="), "_8dabb06efc95" . "df4cff7c4afe9" . "1857b53" => base64_decode("bmFt" . "ZQ=="), "_146e0c87306f6f3bc3" . "24a175328e5995" => base64_decode("U0VTU0lPTl9Qcm9q" . "ZWN0X3Byb2plY3Rs" . "aXN0X3NvcnQ="), "_03e9164d0" . "a343b742df" . "4793268b80" . "767" => base64_decode("Zmlsd" . "GVy"), "_2b39ab477b13830a54b0ba0ada25" . "cbd7" => base64_decode("YWN" . "0aX" . "Zl"), "_e1b7238fbb46" . "439026e869e06" . "0d6ca47" => base64_decode("Zm9y" . "bWF0"), "_4c760fb02" . "a49c55509b" . "a087b84fbd" . "a45" => base64_decode("ZH" . "Jh" . "Zn" . "Q="), "_221da17e3055fae8d3ff516" . "b832a5f3b" => base64_decode("cGFnZQ" . "=="), "_dc4707069e0aa9a7eb33" . "9df27e37aed5" => base64_decode("YWRkQnV0" . "dG9uLnZp" . "c2libGU="), "_67a0d624aebcceb0abd5ce56a53ff06" . "f" => base64_decode("ZGF0ZQ=" . "="), "com" . "pan" . "y_i" . "d" => base64_decode("Y29tcGFue" . "V9pZA=="), "_ed5f03d686c37933b59" . "43f295c6b4a43" => base64_decode("anNvbg" . "=="), "_748cca386a" . "9df2eb5a1fe" . "07d38031a88" => base64_decode("b25" . "ob2" . "xk"), "_bacbe8dd9caf37d515b" . "d02bcff1ba9fa" => base64_decode("cHJvamVjdH" . "MucHJvamVj" . "dC5wYWdlX3" . "RpdGxl"), "_396a8010e8da9ead4c3c06dcdfb" . "052c6" => base64_decode("LWRhd" . "GU="), "_5d85dcad782c122b938ac7a413" . "7a7183" => base64_decode("cHJvamVjdHMvaW" . "5kZXguaHRtbA=="), "_a0624a55e60ee7aae11" . "f61e56eea7c0c" => base64_decode("dGV" . "tcG" . "xhd" . "GU="));
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["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_221da17e3055fae8d3ff516" . "b832a5f3b"], null);
        $_e2cd02b34604bb4da597fe440cfe476e = gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_e2cd02b3460" . "4bb4da597fe4" . "40cfe476e"], null);
        $_03e9164d0a343b742df4793268b80767 = gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_03e9164d0a343b742df47" . "93268b80767"], null);
        $_e1b7238fbb46439026e869e060d6ca47 = gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_e1b7238" . "fbb46439" . "026e869e" . "060d6ca4" . "7"], null);
        $_f6a16426f3b3f03ad6bacec912eec291 = gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_f6a16426f3b3f03ad6bace" . "c912eec291"], null);
        $company_id = (int) gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["company_i" . "d"], 0);
        if ($_f6a16426f3b3f03ad6bacec912eec291 === $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_67a0d624a" . "ebcceb0abd" . "5ce56a53ff" . "06f"]) {
            $_f6a16426f3b3f03ad6bacec912eec291 = $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_396a8010e8da9ead4c3c" . "06dcdfb052c6"];
        }
        
        
        if ($_f6a16426f3b3f03ad6bacec912eec291 === null) {
            $_f6a16426f3b3f03ad6bacec912eec291 = $session->get($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_146e0c87306f6f3bc324a1" . "75328e5995"], $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_8dabb06efc95df4cff7c" . "4afe91857b53"]);
        } else {
            $session->set($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_146e0c87306f" . "6f3bc324a1753" . "28e5995"], $_f6a16426f3b3f03ad6bacec912eec291);
        }
        switch ($_03e9164d0a343b742df4793268b80767) {
            case $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_fe55f93e48d864ac4b4" . "3fc2e85a1009b"]:
                $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_FOLLOWING;
                break;
            case $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_4c760fb02a49c55509b" . "a087b84fbda45"]:
                $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_DRAFT;
                break;
            case $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_748cca386a9df2eb5a1fe07d" . "38031a88"]:
                $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_ON_HOLD;
                break;
            case $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_7276e0af756" . "e529d30af7aa" . "afe4e7784"]:
                $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_ARCHIVED;
                break;
            case $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_a0624a55e60ee7aa" . "e11f61e56eea7c0c"]:
                if ($this->permissions_checker->CanICreateProjects()) {
                    $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_TEMPLATES;
                } else {
                    $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_DEFAULT;
                }
                break;
            case $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_2b39ab477b13830a54b0ba" . "0ada25cbd7"]:
            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["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_ed5f03d686c37933b5943f29" . "5c6b4a43"]) {
            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"]["_dc4707069e0aa9a7eb339df27e" . "37aed5"]] = 1;
        }
        $_678d945258a520c3df1c42fe4b558f34 = $lmsg($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_bacbe8dd9caf37d515b" . "d02bcff1ba9fa"]);
        $_a0624a55e60ee7aae11f61e56eea7c0c = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_5d85dcad782c122b938ac7a4137" . "a7183"];
        return new TemplaterCallResponse($_a0624a55e60ee7aae11f61e56eea7c0c, $_bbcdf77b6167a26a35212c8181097030, $_678d945258a520c3df1c42fe4b558f34);
    }
}