Commit 95653012 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Test UI (Kasar)

parent 7abfbb27
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -509,7 +509,7 @@ return array(
                [
                    'controller' => 'Public',
                    'action' => ['test'],
                    'roles' => ['Administrateur'],
                    'roles' => ['user'],
                ],
                [
                    'controller' => 'Console',
+331 −27
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Oscar\Controller;

use Laminas\View\Model\JsonModel;
use Oscar\Entity\Activity;
use Oscar\Entity\ActivityPerson;
use Oscar\Entity\ActivityRepository;
@@ -108,8 +109,7 @@ class PublicController extends AbstractOscarController implements UseTimesheetSe
            if ($method == 'GET') {
                $datas = $timesheetService->getDayLengthPerson($this->getCurrentPerson());
                return $this->ajaxResponse($datas);
            }
            elseif ($method == 'POST') {
            } elseif ($method == 'POST') {
                $schedule = $this->params()->fromPost('days');
                try {
                    $this->getUserParametersService()->performChangeSchedule(
@@ -208,8 +208,9 @@ class PublicController extends AbstractOscarController implements UseTimesheetSe
     */
    public function testAction()
    {
        echo unknwo_function();
        die("DEV ONLY");
        $response = new ViewModel();
        $this->layout()->setTemplate('layout/kusanagi');
        return $response;
    }

    /**
@@ -229,6 +230,12 @@ class PublicController extends AbstractOscarController implements UseTimesheetSe
        $periodsRejected = [];
        $documentsWait = [];

        $action = $this->params()->fromQuery('a');
        if ($action == 'menu') {
            $response = new JsonModel($this->getUserMenu());
            return $response;
        }


        if ($person) {
            try {
@@ -264,8 +271,7 @@ class PublicController extends AbstractOscarController implements UseTimesheetSe
                // Accès globale
                if ($this->getOscarUserContextService()->hasPrivileges(Privileges::ACTIVITY_REQUEST_MANAGE)) {
                    $requests = $serviceDemandeActivite->getAllRequestActivityUnDraft();
                }
                elseif (count(
                } elseif (count(
                        $organizations = $this->getOscarUserContextService()->getOrganizationsWithPrivilege(
                            Privileges::ACTIVITY_REQUEST_MANAGE
                        )
@@ -334,12 +340,310 @@ class PublicController extends AbstractOscarController implements UseTimesheetSe
            return [
                'contenu' => "super doc"
            ];
        }
        else {
        } else {
            return [
                'contenu' => 'foo'
            ];
        }
        return [];
    }

    private function getUserMenu()
    {

        $desc = [];

        $menu = [];

        $personnalAccess = [];
        $personnalAccess[] = [
            'type' => 'separator',
            'icon' => 'person',
            'text' => 'Mon activités',
        ];
        $personnalAccess[] = [
            'label' => _('Mes projets'),
            'url' => $this->url()->fromRoute('project/mine')
        ];

        // Signature
        if ($this->getOscarUserContextService()->hasSignaturePersonalAccess()) {

            $personnalAccess[] = [
                'label' => _('Mes visa de document'),
                'url' => $this->url()->fromRoute('unicaen-signature/my-documents')
            ];
            $personnalAccess[] = [
                'label' => _('Circuits de signature'),
                'url' => $this->url()->fromRoute('contractdocument/documents-observed')
            ];
        }

        // Demande d'activité
        if ($this->getOscarUserContextService()->hasPrivileges(Privileges::ACTIVITY_REQUEST) ||
            $this->getOscarUserContextService()->hasPrivilegeInOrganizations(Privileges::ACTIVITY_REQUEST)
        ) {
            $personnalAccess[] = [
                'label' => _("Mes demandes d'activité"),
                'url' => $this->url()->fromRoute('requestactivity')
            ];
        }

        // Responsable de structure
        if ($this->getOscarUserContextService()->hasPrivilegeInOrganizations(Privileges::ACTIVITY_CREATE)) {
            $personnalAccess[] = [
                'icon' => 'icon-cube',
                'label' => _("Nouvelle activité"),
                'url' => $this->url()->fromRoute('contract/new')
            ];
        }
        if ($this->getOscarUserContextService()->hasPrivilegeInOrganizations(Privileges::PROJECT_CREATE)) {
            $personnalAccess[] = [
                'icon' => 'icon-cubes',
                'label' => _("Nouveau projet"),
                'url' => $this->url()->fromRoute('project/new')
            ];
        }

        $personnalAccess[] = ['type' => 'separator', 'text' => 'Divers', 'icon' => 'bookmark'];
        $personnalAccess[] = [
            'label' => _("Documents pratiques"),
            'url' => $this->url()->fromRoute('administrativedocument')
        ];

        //////////////////////// - MENU "Activité"
        $menuActivities = [];
        if ($this->getOscarUserContextService()->hasPrivileges(Privileges::PROJECT_INDEX)) {
            $menuActivities[] = [
                'type' => 'separator',
                'icon' => 'library_books',
                'text' => 'Projets',
            ];
            $menuActivities[] = [
//                'icon' => 'icon-cube',
                'label' => _('Liste des projets'),
                'url' => $this->url()->fromRoute('contract/advancedsearch') . '?=projectview=on'
            ];
            if ($this->getOscarUserContextService()->hasPrivileges(Privileges::PROJECT_CREATE)) {
                $menuActivities[] = [
//                    'icon' => 'icon-cube',
                    'label' => _('Créer un projet'),
                    'url' => $this->url()->fromRoute('project/new')
                ];
            }
        }

        if ($this->getOscarUserContextService()->hasPrivileges(Privileges::ACTIVITY_INDEX)) {
            $menuActivities[] = [
                'type' => 'separator',
                'icon' => 'assignment',
                'text' => _('Activités'),
            ];
            $menuActivities[] = [
//                'icon' => 'icon-cube',
                'label' => _('Liste des activités'),
                'url' => $this->url()->fromRoute('contract/advancedsearch')
            ];
        }
        if ($this->getOscarUserContextService()->hasPrivileges(Privileges::ACTIVITY_DOCUMENT_SHOW)) {
            $menuActivities[] = [
//                'icon' => 'icon-file-pdf',
                'label' => _('Documents téléversés'),
                'url' => $this->url()->fromRoute('contractdocument')
            ];
        }
        if ($this->getOscarUserContextService()->hasPrivileges(Privileges::ACTIVITY_EDIT)) {
            $menuActivities[] = [
                // 'icon' => 'icon-file-pdf',
                'label' => _('Nouvelle activité'),
                'url' => $this->url()->fromRoute('contract/new')
            ];
            $menuActivities[] = [
                // 'icon' => 'icon-file-pdf',
                'label' => _('Bientôt terminés'),
                'url' => $this->url()->fromRoute('contract/almostdone')
            ];
            $menuActivities[] = [
                // 'icon' => 'icon-file-pdf',
                'label' => _('Débutant prochainement'),
                'url' => $this->url()->fromRoute('contract/almoststart')
            ];
        }

        if ($this->getOscarUserContextService()->hasPrivileges(Privileges::ACTIVITY_PAYMENT_SHOW)) {
            $menuActivities[] = [
                'type' => 'separator',
                'icon' => 'payments',
                'text' => _('Versements'),
            ];
            $menuActivities[] = [
                // 'icon' => 'icon-file-pdf',
                'label' => _('Versements'),
                'url' => $this->url()->fromRoute('payment/income')
            ];

            $menuActivities[] = [
                // 'icon' => 'icon-file-pdf',
                'label' => _('Versements en retards'),
                'url' => $this->url()->fromRoute('payment/late')
            ];

            $menuActivities[] = [
                // 'icon' => 'icon-file-pdf',
                'label' => _('Écarts de paiement'),
                'url' => $this->url()->fromRoute('payment/difference')
            ];

            $menuActivities[] = [
                // 'icon' => 'icon-file-pdf',
                'label' => _('Tous les paiement'),
                'url' => $this->url()->fromRoute('payment')
            ];

        }

        if ($this->getOscarUserContextService()->hasPrivileges(Privileges::ACTIVITY_MILESTONE_SHOW)) {
            $menuActivities[] = [
                'type' => 'separator',
                'icon' => 'event',
                'text' => _('Jalons'),
            ];
            $menuActivities[] = [
                // 'icon' => 'icon-file-pdf',
                'label' => _('Tous les jalons'),
                'url' => $this->url()->fromRoute('milestones')
            ];
        }


        ///////////// ADMINISTRATION
        $menuAdministration = [];

        $menu[] = [
            'icon' => 'home',
            'label' => _("Accueil"),
            'items' => $personnalAccess
        ];

        $menu[] = [
            'icon' => 'assignment',
            'label' => _("Activités"),
            'items' => $menuActivities
        ];

        ///////////////////////////// ADMIN
        if ($this->getOscarUserContextService()->hasPrivileges(Privileges::MAINTENANCE_MENU_ADMIN)) {
            $menuAdministration = [];
            if ($this->getOscarUserContextService()->hasPrivileges(Privileges::ORGANIZATION_INDEX)) {
                $menuAdministration[] = [
                    'icon' => 'apartment',
                    'text' => _('Organisations')
                ];

                $menuAdministration[] = [
                    'label' => _('Liste des organisations'),
                    'url' => $this->url()->fromRoute('organization')
                ];
                if ($this->getOscarUserContextService()->hasPrivileges(Privileges::ORGANIZATION_EDIT)) {
                    $menuAdministration[] = [
                        'label' => _('Nouvelle organisation'),
                        'url' => $this->url()->fromRoute('organization/new')
                    ];
                }
            }

            if ($this->getOscarUserContextService()->hasPrivileges(Privileges::PERSON_INDEX)) {
                $menuAdministration[] = [
                    'icon' => 'apartment',
                    'text' => _('Personnes')
                ];

                $menuAdministration[] = [
                    'label' => _('Liste des personnes'),
                    'url' => $this->url()->fromRoute('person')
                ];
                if ($this->getOscarUserContextService()->hasPrivileges(Privileges::PERSON_EDIT)) {
                    $menuAdministration[] = [
                        'label' => _('Nouvelle organisation'),
                        'url' => $this->url()->fromRoute('person/new')
                    ];
                }
            }

            if ($this->getOscarUserContextService()->hasPrivileges(Privileges::ACTIVITY_TIMESHEET_VIEW)) {
                $menuAdministration[] = [
                    'icon' => 'event',
                    'text' => _('Feuille de temps')
                ];

                $menuAdministration[] = [
                    'label' => _('Liste des déclarants'),
                    'url' => $this->url()->fromRoute('person/declarers')
                ];
                $menuAdministration[] = [
                    'label' => _('Retards importants'),
                    'url' => $this->url()->fromRoute('timesheet/highdelay')
                ];

            }

            $menuAdministration[] = [
                'icon' => 'cog',
                'text' => _('Maintenance')
            ];

            $menuAdministration[] = [
                'label' => _('Processus PCRU'),
                'url' => $this->url()->fromRoute('contract/pcru-list')
            ];

            if ($this->getOscarUserContextService()->hasPrivileges(Privileges::ACTIVITY_INDEX)) {
                $menuAdministration[] = [
                    'label' => _('Activités sans projets'),
                    'url' => $this->url()->fromRoute('contract/advancedsearch') . '?criteria[]=pp%3Bnull%3Bnull'
                ];
            }

            if ($this->getOscarUserContextService()->hasPrivileges(Privileges::PROJECT_INDEX)) {
                $menuAdministration[] = [
                    'label' => _('Projets sans activités'),
                    'url' => $this->url()->fromRoute('project/empty')
                ];
            }

            $menuAdministration[] = [
                'icon' => 'cog',
                'text' => _('Configuration')
            ];

            $menuAdministration[] = [
                'label' => _('Configuration et maintenance'),
                'url' => $this->url()->fromRoute('administration/accueil')
            ];



            $menu[] = [
                'icon' => 'settings',
                'label' => _("Administration"),
                'items' => $menuAdministration
            ];
        }


        $menu[] = [
            'icon' => 'security',
            'label' => _("Usurpation"),
            'items' => []
        ];

        $menu[] = [
            'icon' => 'badge',
            'label' => _("Identité"),
            'items' => []
        ];


        return $menu;
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -11,9 +11,9 @@ namespace Oscar;
class OscarVersion
{
    const MAJOR = 2;
    const MINOR = 14;
    const MINOR = 15;
    const PATCH = 0;
    const NAME = "Starling";
    const NAME = "Kusanagi";

    public static function getBuild(){
        return sprintf('v%s.%s.%s "%s"', self::MAJOR, self::MINOR, self::PATCH, self::NAME);
+11 −0
Original line number Diff line number Diff line
@@ -675,6 +675,12 @@ class OscarUserContext implements UseOscarConfigurationService, UseLoggerService
        return $organizations;
    }

    public function isBoss()
    {
        return $this->connected() && $this->hasRolePrincipalInAnyOrganisations();
    }


    protected function getOrganizationsIdRecursive(Organization $organization, &$idsReturn = [], $id = false): array
    {
        if (!in_array($organization->getId(), $idsReturn)) {
@@ -1762,4 +1768,9 @@ class OscarUserContext implements UseOscarConfigurationService, UseLoggerService
    {
        return $this->getBaseRoleId();
    }

    private function connected()
    {
        return $this->getCurrentPerson() !== null;
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ class Grant extends AbstractHtmlElement implements UseOscarUserContextService
    }

    public function isBoss(){
        return $this->connected() && $this->getOscarUserContextService()->hasRolePrincipalInAnyOrganisations();
        return $this->getOscarUserContextService()->isBoss();
    }

    /**
Loading