<?php

namespace App\Classes\ValueObjects\Constants;


use App\Classes\Modules\Orders\Processors\ConfirmsOrder;
use App\Classes\Modules\Orders\Processors\DeliverOrder;
use App\Classes\Modules\Orders\Processors\ShipOrder;
use App\Classes\Modules\Orders\Processors\WarehouseArrivalOrder;
use App\Classes\Modules\Orders\Processors\WarehousePackOrder;
use App\Classes\Modules\Orders\Processors\WarehouseReceivesOrder;
use App\Classes\Modules\Orders\Processors\WarehouseUnpackingOrder;

class OrderSteps
{

    public const COMPANY_PROCESSING_CATEGORY = 'processing';
    public const COMPANY_SHIPPING_CATEGORY = 'shipping';
    public const COMPANY_RECEIVING_CATEGORY = 'receiving';
    public const COMPANY_COMPLETE_CATEGORY = 'complete';
    public const COMPANY_CANCEL_CATEGORY = 'cancel';

    public const ORDER_PROCESSING_STEP = 'PS_PROCESSING';
    public const ORDER_SHIPPING_STEP = 'PS_SHIPPING';
    public const ORDER_DELIVERY_STEP = 'PS_DELIVERY';

    public const ORDER_MODULE_WAREHOUSE = 'WAREHOUSE';
    public const ORDER_WAREHOUSE_RECEIVING_STEP = 'MS_WAREHOUSE_RECEIVING';
    public const ORDER_WAREHOUSE_PACKING_STEP = 'MS_WAREHOUSE_PACKING';
    public const ORDER_WAREHOUSE_ARRIVAL_STEP = 'MS_WAREHOUSE_ARRIVAL';
    public const ORDER_WAREHOUSE_UNPACKING_STEP = 'MS_WAREHOUSE_UNPACKING';

    public const ORDER_MODULE_NO_WAREHOUSE = 'NO_WAREHOUSE';
    public const ORDER_NO_WAREHOUSE_PENDING_SUPPLIER = 'MS_NO_WAREHOUSE_PENDING_SUPPLIER';


    public const ORDER_PRIMARY_STEPS = [
        OrderSteps::ORDER_PROCESSING_STEP => [
            'initial_name' => 'processing order',
            'final_name' => 'order confirmed',
            'description' => 'Order created and pending confirmation',
            'sequence' => 0
        ]
    ];

    public const ORDER_PRIMARY_MODULAR_STEPS = [
        OrderSteps::ORDER_SHIPPING_STEP => [
            'initial_name' => 'shipping',
            'final_name' => 'shipped out',
            'description' => 'Order is Loaded to Container, waiting for Shipment',
            'sequence' => 1
        ],
        OrderSteps::ORDER_DELIVERY_STEP => [
            'initial_name' => 'delivery',
            'final_name' => 'Received',
            'description' => 'Order out for delivery soon',
            'sequence' => 2
        ],
    ];

    public const ORDER_MODULAR_STEPS = [
        OrderSteps::ORDER_MODULE_WAREHOUSE => [
            'china_warehouse' => [
                'previous' => OrderSteps::ORDER_PROCESSING_STEP,
                'next' => OrderSteps::ORDER_SHIPPING_STEP,
                'steps' => [
                    OrderSteps::ORDER_WAREHOUSE_RECEIVING_STEP => [
                        'initial_name' => 'pending supplier',
                        'final_name' => 'arrived at warehouse',
                        'description' => 'Waiting for supplier to deliver order to warehouse'
                    ],
                    OrderSteps::ORDER_WAREHOUSE_PACKING_STEP => [
                        'initial_name' => 'packing',
                        'final_name' => 'packed',
                        'description' => 'Packing order into shipping container'
                    ]
                ]
            ],
            'malaysia_warehouse' => [
                'previous' => OrderSteps::ORDER_SHIPPING_STEP,
                'next' => OrderSteps::ORDER_DELIVERY_STEP,
                'steps' => [
                    OrderSteps::ORDER_WAREHOUSE_ARRIVAL_STEP => [
                        'initial_name' => 'pending arrival',
                        'final_name' => 'arrived at warehouse',
                        'description' => 'Waiting for order\'s arrival & custom clearance'
                    ],
                    OrderSteps::ORDER_WAREHOUSE_UNPACKING_STEP => [
                        'initial_name' => 'unpacking',
                        'final_name' => 'unpacked',
                        'description' => 'Unpacking order from shipping container'
                    ]
                ]
            ]
        ],
        OrderSteps::ORDER_MODULE_NO_WAREHOUSE => [
            'pending_arrival' => [
                'previous' => OrderSteps::ORDER_PROCESSING_STEP,
                'next' => OrderSteps::ORDER_SHIPPING_STEP,
                'steps' => [
                    OrderSteps::ORDER_NO_WAREHOUSE_PENDING_SUPPLIER => [
                        'initial_name' => 'pending supplier',
                        'final_name' => 'supplier packed order',
                        'description' => 'Waiting for supplier to pack order for shipping'
                    ]
                ]
            ]

        ],
    ];

    public const COMPANY_ORDER_PROCESSING = [
        OrderSteps::ORDER_PROCESSING_STEP,
        OrderSteps::ORDER_NO_WAREHOUSE_PENDING_SUPPLIER,
        OrderSteps::ORDER_WAREHOUSE_RECEIVING_STEP
    ];

    public const COMPANY_ORDER_SHIPPING = [
        OrderSteps::ORDER_WAREHOUSE_PACKING_STEP,
        OrderSteps::ORDER_SHIPPING_STEP
    ];

    public const COMPANY_ORDER_RECEIVING = [
        OrderSteps::ORDER_WAREHOUSE_ARRIVAL_STEP,
        OrderSteps::ORDER_WAREHOUSE_UNPACKING_STEP,
        OrderSteps::ORDER_DELIVERY_STEP

    ];

    public const WAREHOUSE_RECEIVING_CATEGORY = 'receiving';
    public const WAREHOUSE_SHIPPING_CATEGORY = 'shipping';
    public const WAREHOUSE_COMPLETE_CATEGORY = 'complete';
    public const WAREHOUSE_CANCEL_CATEGORY = 'cancel';

    public const WAREHOUSE_ORDER_RECEIVING = [
        OrderSteps::ORDER_WAREHOUSE_RECEIVING_STEP
    ];

    public const WAREHOUSE_ORDER_SHIPPING = [
        OrderSteps::ORDER_WAREHOUSE_PACKING_STEP,
        OrderSteps::ORDER_SHIPPING_STEP,
    ];

    public const WAREHOUSE_ORDER_COMPLETE = [
        OrderSteps::ORDER_WAREHOUSE_ARRIVAL_STEP,
        OrderSteps::ORDER_WAREHOUSE_UNPACKING_STEP,
        OrderSteps::ORDER_DELIVERY_STEP
    ];

    public const STEP_PROCESSOR = [
        OrderSteps::ORDER_PROCESSING_STEP => ConfirmsOrder::class,
        OrderSteps::ORDER_WAREHOUSE_RECEIVING_STEP => WarehouseReceivesOrder::class,
        OrderSteps::ORDER_WAREHOUSE_PACKING_STEP => WarehousePackOrder::class,
        OrderSteps::ORDER_SHIPPING_STEP => ShipOrder::class,
        OrderSteps::ORDER_WAREHOUSE_ARRIVAL_STEP => WarehouseArrivalOrder::class,
        OrderSteps::ORDER_WAREHOUSE_UNPACKING_STEP => WarehouseUnpackingOrder::class,
        OrderSteps::ORDER_DELIVERY_STEP => DeliverOrder::class,
    ];

}