<?php
namespace Claromentis\Projects\Controller;

$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"] = (@$GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"] ?: array()) + array("_64666bcf1e" . "5aaa07774f3" . "d7439ff264d" => base64_decode("Y29" . "tcG" . "xld" . "GVk"), "_f6a16426f3b3f03ad6bace" . "c912eec291" => base64_decode("c29ydA" . "=="), "_5d85dcad782c122b938ac7a41" . "37a7183" => base64_decode("cHJvamV" . "jdHMvaW" . "5kZXgua" . "HRtbA=="), "_396a8010" . "e8da9ead4" . "c3c06dcdf" . "b052c6" => base64_decode("LWR" . "hdG" . "U="), "_a0624a55e60" . "ee7aae11f61e" . "56eea7c0c" => base64_decode("dGVtcGx" . "hdGU="), "_2b39ab477b13830a5" . "4b0ba0ada25cbd7" => base64_decode("YW" . "N0" . "aX" . "Zl"), "_ed5f03d686c37933b594" . "3f295c6b4a43" => base64_decode("anNvb" . "g=="), "_7276e0af756e529d30af7aaa" . "fe4e7784" => base64_decode("YXJjaGl2ZWQ" . "="), "_e1b7238fbb4643902" . "6e869e060d6ca47" => base64_decode("Zm9ybW" . "F0"), "_bacbe8d" . "d9caf37d" . "515bd02b" . "cff1ba9f" . "a" => base64_decode("cHJvamVjdHMucHJvamVjdC5w" . "YWdlX3RpdGxl"), "_fe55f93e48d864ac4b43fc2e85a1" . "009b" => base64_decode("Zm9sbG" . "93aW5n"), "_dc4707069e0aa9a7e" . "b339df27e37aed5" => base64_decode("YWRkQnV0dG9uLnZpc2li" . "bGU="), "_03e9164d0a3" . "43b742df4793" . "268b80767" => base64_decode("Zm" . "ls" . "dG" . "Vy"), "_e2cd02b34604bb4da597fe" . "440cfe476e" => base64_decode("c2Vh" . "cmNo"), "_67a0d624aebcceb0abd5c" . "e56a53ff06f" => base64_decode("ZGF0" . "ZQ=="), "_8dabb06efc95df4cff7c4af" . "e91857b53" => base64_decode("bmFtZQ=" . "="), "_748cca386a9df2eb5a1fe07d38031a" . "88" => base64_decode("b25o" . "b2xk"), "_146e0c87306f6f3bc324a175328e5" . "995" => base64_decode("U0VTU0lPTl9Qc" . "m9qZWN0X3Byb2" . "plY3RsaXN0X3N" . "vcnQ="), "_221da17e3055fae8" . "d3ff516b832a5f3b" => base64_decode("cGFnZQ=" . "="), "_4c760fb02a49" . "c55509ba087b8" . "4fbda45" => base64_decode("ZHJhZ" . "nQ="), "company" . "_id" => base64_decode("Y29tcGFueV9pZ" . "A=="));
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["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_221da17e3055fae8d3ff516b832a" . "5f3b"], null);
        $_e2cd02b34604bb4da597fe440cfe476e = gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_e2cd02b34604bb4" . "da597fe440cfe476" . "e"], null);
        $_03e9164d0a343b742df4793268b80767 = gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_03e9164d0a343b74" . "2df4793268b80767"], null);
        $_e1b7238fbb46439026e869e060d6ca47 = gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_e1b7238fb" . "b46439026e" . "869e060d6c" . "a47"], null);
        $_f6a16426f3b3f03ad6bacec912eec291 = gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_f6a16426f3b3f03ad6bacec912eec" . "291"], null);
        $company_id = (int) gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["comp" . "any_" . "id"], 0);
        if ($_f6a16426f3b3f03ad6bacec912eec291 === $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_67a0d624aebcceb0ab" . "d5ce56a53ff06f"]) {
            $_f6a16426f3b3f03ad6bacec912eec291 = $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_396a8010e8da9ead4c3c" . "06dcdfb052c6"];
        }
        
        
        if ($_f6a16426f3b3f03ad6bacec912eec291 === null) {
            $_f6a16426f3b3f03ad6bacec912eec291 = $session->get($GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_146e0c87306f6f3bc324a175328" . "e5995"], $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_8dabb06efc95df4cff7c4afe91857" . "b53"]);
        } else {
            $session->set($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_146e0c87306f6f3bc324a17" . "5328e5995"], $_f6a16426f3b3f03ad6bacec912eec291);
        }
        switch ($_03e9164d0a343b742df4793268b80767) {
            case $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_fe55f93e48d86" . "4ac4b43fc2e85a" . "1009b"]:
                $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_FOLLOWING;
                break;
            case $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_4c760fb02a49c55509ba" . "087b84fbda45"]:
                $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_DRAFT;
                break;
            case $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_748cca386a9df2eb" . "5a1fe07d38031a88"]:
                $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_ON_HOLD;
                break;
            case $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_7276e0af756e529d30af7aaafe" . "4e7784"]:
                $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_ARCHIVED;
                break;
            case $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_a0624a55e60ee7aae11f61e56e" . "ea7c0c"]:
                if ($this->permissions_checker->CanICreateProjects()) {
                    $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_TEMPLATES;
                } else {
                    $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_DEFAULT;
                }
                break;
            case $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_64666bcf1e5aaa07774f3d" . "7439ff264d"]:
                $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_COMPLETED;
                break;
            case $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_2b39ab477b13830a54b0ba0ada2" . "5cbd7"]:
            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["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_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["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_dc4707069e0aa9a7" . "eb339df27e37aed5"]] = 1;
        }
        $_678d945258a520c3df1c42fe4b558f34 = $lmsg($GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_bacbe8dd9caf" . "37d515bd02bcf" . "f1ba9fa"]);
        $_a0624a55e60ee7aae11f61e56eea7c0c = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_5d85dcad782c122b93" . "8ac7a4137a7183"];
        return new TemplaterCallResponse($_a0624a55e60ee7aae11f61e56eea7c0c, $_bbcdf77b6167a26a35212c8181097030, $_678d945258a520c3df1c42fe4b558f34);
    }
}