<?php
namespace App\Permissions\Modules;

use App\Model\UserTypes;

class Orders extends BasePermissions{

    const ORDERS = "ORDERS_";
    const ORDERS_ADD = self::ORDERS."ADD";
    const ORDERS_EDIT = self::ORDERS."EDIT";
    const ORDERS_DELETE = self::ORDERS."DELETE";
    const ORDERS_VIEW = self::ORDERS."VIEW";
    const ORDERS_DETAIL_TABS = self::ORDERS."DETAIL_TABS";
    const ORDERS_DETAIL_TABS_NOTES = self::ORDERS."DETAIL_TABS_NOTES";
    const ORDERS_DETAIL_TABS_DETAIL = self::ORDERS."DETAIL_TABS_DETAIL";
    const ORDERS_DETAIL_TABS_PRESCRIPTION = self::ORDERS."DETAIL_TABS_PRESCRIPTION";

    public function permissions()
    {
        $permissions =  [
            [
                "text"=>"Order View",
                "id"=>self::ORDERS_VIEW,
                "state" => $this->selectNodes(self::ORDERS_VIEW)
            ],
            [
                "text"=>"Order Add",
                "id"=>self::ORDERS_ADD,
                "state" => $this->selectNodes(self::ORDERS_ADD)
            ],
            [
                "text"=>"Order Edit",
                "id"=>self::ORDERS_EDIT,
                "state" => $this->selectNodes(self::ORDERS_EDIT)
            ],
            [
                "text"=>"Order Delete",
                "id"=>self::ORDERS_DELETE,
                "state" => $this->selectNodes(self::ORDERS_DELETE)
            ],
            [
                "text"=> "Order Detail Tabs",
                "id"=>self::ORDERS_DETAIL_TABS,
                "children" =>[
                    [
                        "text"=>"Order Detail Tab",
                        "id"=>self::ORDERS_DETAIL_TABS_DETAIL,
                        "state" => $this->selectNodes(self::ORDERS_DETAIL_TABS_DETAIL)
                    ],
                    [
                        "text"=>"Notes Tab",
                        "id"=>self::ORDERS_DETAIL_TABS_NOTES,
                        "state" => $this->selectNodes(self::ORDERS_DETAIL_TABS_NOTES)
                    ],
                    [
                        "text"=>"Prescription Tab",
                        "id"=>self::ORDERS_DETAIL_TABS_PRESCRIPTION,
                        "state" => $this->selectNodes(self::ORDERS_DETAIL_TABS_PRESCRIPTION)
                    ]
                ]
            ]
        ];
        return ["text"=>"Order","id"=>self::ORDERS,"children"=>$permissions];
    }
    public function frontEndPermissions()
    {
        $orders_permissions =
        [
            [
                "text"=>"Order View",
                "ability" => $this->apiPermissionSelected(self::ORDERS_VIEW)
            ],
            [
                "text"=>"Order Add",
                "ability" => $this->apiPermissionSelected(self::ORDERS_ADD)
            ],
            [
                "text"=>"Order Edit",
                "ability" => $this->apiPermissionSelected(self::ORDERS_EDIT)
            ],
            [
                "text"=>"Order Delete",
                "ability" => $this->apiPermissionSelected(self::ORDERS_DELETE)
            ],
            [
                "text"=> "Order Detail Tabs",
                "children" =>[
                    [
                        "text"=>"Order Detail Tab",
                        "ability" => $this->apiPermissionSelected(self::ORDERS_DETAIL_TABS_DETAIL)
                    ],
                    [
                        "text"=>"Notes Tab",
                        "ability" => $this->apiPermissionSelected(self::ORDERS_DETAIL_TABS_NOTES)
                    ],
                    [
                        "text"=>"Prescription Tab",
                        "ability" => $this->apiPermissionSelected(self::ORDERS_DETAIL_TABS_PRESCRIPTION)
                    ]
                ]
            ]
        ];

        return ["text"=>"Orders Permissions","permissions"=>$orders_permissions];
    }
}
