<?php
namespace Claromentis\Projects\Controller;

$GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"] = (@$GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"] ?: array()) + array("_4c760fb02a49c55509ba087b8" . "4fbda45" => base64_decode("ZHJhZnQ" . "="), "_bacbe8dd9" . "caf37d515b" . "d02bcff1ba" . "9fa" => base64_decode("cHJvamVjdHMucHJvam" . "VjdC5wYWdlX3RpdGxl"), "_8dabb06efc95df4cff7c4afe91857b" . "53" => base64_decode("bmFtZ" . "Q=="), "_f6a16426f3b3f03ad6bacec912ee" . "c291" => base64_decode("c29" . "ydA" . "=="), "_748cca386a9df2eb5a1" . "fe07d38031a88" => base64_decode("b25" . "ob2" . "xk"), "_dc4707069e0aa9a7eb" . "339df27e37aed5" => base64_decode("YWRkQnV0dG9uLnZpc2lib" . "GU="), "company_i" . "d" => base64_decode("Y29tcGFueV9" . "pZA=="), "_e1b7238fbb46439026e869e060d6ca" . "47" => base64_decode("Zm9ybWF" . "0"), "_67a0d624aebcceb0abd" . "5ce56a53ff06f" => base64_decode("ZG" . "F0" . "ZQ" . "=="), "_fe55f93e48d864ac4b43fc2e8" . "5a1009b" => base64_decode("Zm9sbG9" . "3aW5n"), "_5d85dcad78" . "2c122b938ac" . "7a4137a7183" => base64_decode("cHJvamVjd" . "HMvaW5kZX" . "guaHRtbA=" . "="), "_03e9164d0a34" . "3b742df479326" . "8b80767" => base64_decode("ZmlsdGV" . "y"), "_a0624a55e60ee7aae11f6" . "1e56eea7c0c" => base64_decode("dGVtcGxhd" . "GU="), "_2b39ab477b13830a54b0ba0ada25" . "cbd7" => base64_decode("YW" . "N0" . "aX" . "Zl"), "_e2cd02b34604bb4da597fe440" . "cfe476e" => base64_decode("c2Vh" . "cmNo"), "_396a8010e8da" . "9ead4c3c06dcd" . "fb052c6" => base64_decode("LWRhdG" . "U="), "_ed5f03d686c3" . "7933b5943f295" . "c6b4a43" => base64_decode("anNvbg=" . "="), "_64666bcf1e5aaa07774f3d7439f" . "f264d" => base64_decode("Y29tc" . "GxldG" . "Vk"), "_221da17e3055fae8d3" . "ff516b832a5f3b" => base64_decode("cGFnZQ" . "=="), "_7276e0a" . "f756e529" . "d30af7aa" . "afe4e778" . "4" => base64_decode("YXJj" . "aGl2" . "ZWQ="), "_146e0c87306f6f3b" . "c324a175328e5995" => base64_decode("U0VTU0lPTl9Qcm9qZWN0X3Byb" . "2plY3RsaXN0X3NvcnQ="));
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["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_221da17e3055fae8d3ff516b832a5" . "f3b"], null);
        $_e2cd02b34604bb4da597fe440cfe476e = gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_e2cd02b34604bb4da597fe440cfe" . "476e"], null);
        $_03e9164d0a343b742df4793268b80767 = gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_03e9164d0a343b742df4793268b8076" . "7"], null);
        $_e1b7238fbb46439026e869e060d6ca47 = gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_e1b7238fbb46439026" . "e869e060d6ca47"], null);
        $_f6a16426f3b3f03ad6bacec912eec291 = gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_f6a16426f3b3f03ad6bace" . "c912eec291"], null);
        $company_id = (int) gpc::get($_b791059c94b285cdf1c90ca6f3a8f2a6, $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["com" . "pan" . "y_i" . "d"], 0);
        if ($_f6a16426f3b3f03ad6bacec912eec291 === $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_67a0d624aebcceb0" . "abd5ce56a53ff06f"]) {
            $_f6a16426f3b3f03ad6bacec912eec291 = $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_396a8010e8da9ead4c3c06d" . "cdfb052c6"];
        }
        
        
        if ($_f6a16426f3b3f03ad6bacec912eec291 === null) {
            $_f6a16426f3b3f03ad6bacec912eec291 = $session->get($GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_146e0c87306f6f3bc324a17532" . "8e5995"], $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_8dabb06e" . "fc95df4cf" . "f7c4afe91" . "857b53"]);
        } else {
            $session->set($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_146e0c87306f6f3bc324a1" . "75328e5995"], $_f6a16426f3b3f03ad6bacec912eec291);
        }
        switch ($_03e9164d0a343b742df4793268b80767) {
            case $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_fe55f93e48d864ac" . "4b43fc2e85a1009b"]:
                $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_FOLLOWING;
                break;
            case $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_4c760fb02a49c" . "55509ba087b84f" . "bda45"]:
                $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_DRAFT;
                break;
            case $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_748cca386a9df2eb5a1fe07" . "d38031a88"]:
                $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_ON_HOLD;
                break;
            case $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_7276e0af756e529d30af7aaafe4e" . "7784"]:
                $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_ARCHIVED;
                break;
            case $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_a0624a55e60ee7aae1" . "1f61e56eea7c0c"]:
                if ($this->permissions_checker->CanICreateProjects()) {
                    $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_TEMPLATES;
                } else {
                    $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_DEFAULT;
                }
                break;
            case $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_64666bcf1e5aaa0777" . "4f3d7439ff264d"]:
                $_03e9164d0a343b742df4793268b80767 = ProjectListFilter::FILTER_COMPLETED;
                break;
            case $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_2b39ab477b13830a54b0ba0ada25c" . "bd7"]:
            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["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_ed5f03d686c" . "37933b5943f2" . "95c6b4a43"]) {
            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["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_dc4707069e0aa9a7eb339df27e" . "37aed5"]] = 1;
        }
        $_678d945258a520c3df1c42fe4b558f34 = $lmsg($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_bacbe8dd9caf37d" . "515bd02bcff1ba9f" . "a"]);
        $_a0624a55e60ee7aae11f61e56eea7c0c = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_5d85dcad782c122b" . "938ac7a4137a7183"];
        return new TemplaterCallResponse($_a0624a55e60ee7aae11f61e56eea7c0c, $_bbcdf77b6167a26a35212c8181097030, $_678d945258a520c3df1c42fe4b558f34);
    }
}