<?php
namespace Claromentis\Projects\Controller;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"] ?: array()) + array("company" . "_id" => base64_decode("Y29tcGFu" . "eV9pZA=="), "_e2cd02b34604bb4da597fe440cfe4" . "76e" => base64_decode("c2" . "Vh" . "cm" . "No"), "_bacbe8dd" . "9caf37d51" . "5bd02bcff" . "1ba9fa" => base64_decode("cHJvamVjdHMucHJvamVjdC" . "5wYWdlX3RpdGxl"), "_2b39ab477b1383" . "0a54b0ba0ada25c" . "bd7" => base64_decode("YWN0" . "aXZl"), "_396a8010e8da9ead4c3c06dcd" . "fb052c6" => base64_decode("LWRhdGU" . "="), "_dc4707069e0aa9a7e" . "b339df27e37aed5" => base64_decode("YWRkQnV0dG9uLnZp" . "c2libGU="), "_7276e0af756e529d30af7aaafe4e" . "7784" => base64_decode("YXJjaG" . "l2ZWQ="), "_f6a16426f3b" . "3f03ad6bacec" . "912eec291" => base64_decode("c29" . "ydA" . "=="), "_748cca386a9df2eb" . "5a1fe07d38031a88" => base64_decode("b25ob2x" . "k"), "_5d85dcad782c12" . "2b938ac7a4137a7" . "183" => base64_decode("cHJvamVjdHMvaW5kZXg" . "uaHRtbA=="), "_a0624a55e60ee7aae11f61e56ee" . "a7c0c" => base64_decode("dGVtcGxhd" . "GU="), "_e1b7238fbb464390" . "26e869e060d6ca47" => base64_decode("Zm9yb" . "WF0"), "_ed5f03d686c" . "37933b5943f2" . "95c6b4a43" => base64_decode("an" . "Nv" . "bg" . "=="), "_fe55f93e48d864ac4b4" . "3fc2e85a1009b" => base64_decode("Zm9sbG93a" . "W5n"), "_03e9164d0a3" . "43b742df4793" . "268b80767" => base64_decode("ZmlsdG" . "Vy"), "_221da17e3055fae8d3ff516b832a" . "5f3b" => base64_decode("cG" . "Fn" . "ZQ" . "=="), "_4c760fb" . "02a49c55" . "509ba087" . "b84fbda4" . "5" => base64_decode("ZHJhZ" . "nQ="), "_146e0c87306f6f3bc324a175328e59" . "95" => base64_decode("U0VTU0lPTl9Qcm9qZWN0X3By" . "b2plY3RsaXN0X3NvcnQ="), "_67a0d624aebcceb0abd5ce56a53ff0" . "6f" => base64_decode("ZG" . "F0" . "ZQ" . "=="), "_8dabb06efc95df4cff7c4af" . "e91857b53" => base64_decode("bmF" . "tZQ" . "=="));
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["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_221da17e3055fa" . "e8d3ff516b832a5" . "f3b"], null);
        $_e2cd02b34604bb4da597fe440cfe476e = gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_e2cd02b34604bb4da59" . "7fe440cfe476e"], null);
        $_03e9164d0a343b742df4793268b80767 = gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_03e9164d0a343b742df4793268b8" . "0767"], null);
        $_e1b7238fbb46439026e869e060d6ca47 = gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_e1b7238fbb46439026e869e060d6c" . "a47"], null);
        $_f6a16426f3b3f03ad6bacec912eec291 = gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_f6a16426f3b3f03" . "ad6bacec912eec29" . "1"], null);
        $company_id = (int) gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["company_i" . "d"], 0);
        if ($_f6a16426f3b3f03ad6bacec912eec291 === $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_67a0d624aebcceb0abd5c" . "e56a53ff06f"]) {
            $_f6a16426f3b3f03ad6bacec912eec291 = $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_396a8010e8da9ead4c3c06d" . "cdfb052c6"];
        }
        
        
        if ($_f6a16426f3b3f03ad6bacec912eec291 === null) {
            $_f6a16426f3b3f03ad6bacec912eec291 = $session->get($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_146e0c873" . "06f6f3bc32" . "4a175328e5" . "995"], $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_8dabb06efc95d" . "f4cff7c4afe918" . "57b53"]);
        } else {
            $session->set($GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_146e0c87306" . "f6f3bc324a17" . "5328e5995"], $_f6a16426f3b3f03ad6bacec912eec291);
        }
        switch ($_03e9164d0a343b742df4793268b80767) {
            case $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_fe55f93e48d864ac4b43fc2e85a10" . "09b"]:
                $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_FOLLOWING;
                break;
            case $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_4c760fb02a49c55" . "509ba087b84fbda4" . "5"]:
                $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_DRAFT;
                break;
            case $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_748cca386a9df2eb5a1fe07d380" . "31a88"]:
                $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_ON_HOLD;
                break;
            case $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_7276e0af756e529d30af7aaafe" . "4e7784"]:
                $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_ARCHIVED;
                break;
            case $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_a0624a55e60ee7aae11f61e56eea7c" . "0c"]:
                if ($this->permissions_checker->CanICreateProjects()) {
                    $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_TEMPLATES;
                } else {
                    $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_DEFAULT;
                }
                break;
            case $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_2b39ab477b13830a54b0ba0ad" . "a25cbd7"]:
            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["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_ed5f03d" . "686c3793" . "3b5943f2" . "95c6b4a4" . "3"]) {
            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["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_dc4707069e0aa9a7eb339df2" . "7e37aed5"]] = 1;
        }
        $_678d945258a520c3df1c42fe4b558f34 = $lmsg($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_bacbe8dd9caf37d515bd02b" . "cff1ba9fa"]);
        $_a0624a55e60ee7aae11f61e56eea7c0c = $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_5d85dcad782c1" . "22b938ac7a4137" . "a7183"];
        return new TemplaterCallResponse($_a0624a55e60ee7aae11f61e56eea7c0c, $_bbcdf77b6167a26a35212c8181097030, $_678d945258a520c3df1c42fe4b558f34);
    }
}