<?php

namespace App\Console;

use App\Classes\Jobs\FetchContainersStatusUpdateFromVTPortalJob;
use App\Classes\Jobs\FetchDeliveryListFromVTPortalJob;
use App\Classes\Jobs\FetchLoadedContainersFromVTPortalJob;
use App\Classes\Jobs\FetchPackingListFromVTPortalJob;
use App\Classes\Jobs\FetchWarehouseReceiveListFromVTPortalJob;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {

        $schedule->command('command:curlVTCommand')
            ->cron('0 8 * * *')
            ->withoutOverlapping()
            ->appendOutputTo (storage_path().'/logs/curlvt.log');

        $schedule->command('command:curlYdOrderListCommand')
            ->cron('0 9-18/3 * * *')
            ->withoutOverlapping()
            ->appendOutputTo (storage_path().'/logs/curlyd.log');

        $schedule->command('fix-packinglist')
            ->cron('30 9-18/3 * * *')
            ->withoutOverlapping()
            ->appendOutputTo (storage_path().'/logs/fix_packinglist.log');

        // $schedule->command('command:curlYdOrderListCommand')
        //     ->cron('0 9 * * *')
        //     ->withoutOverlapping()
        //     ->appendOutputTo (storage_path().'/logs/departure_email.log');

        $schedule->command('fix-duplicate-container-reference')
            ->cron('0 1 * * *')
            ->withoutOverlapping()
            ->appendOutputTo (storage_path().'/logs/fix_duplicate_container_reference.log');

        $schedule->command('invoice:generate')
            ->hourly()
            ->withoutOverlapping()
            ->appendOutputTo (storage_path().'/logs/auto_generate_invoice.log');

        $schedule->command('billplz-failed-callback:fix')
            ->hourly()
            ->withoutOverlapping()
            ->appendOutputTo (storage_path().'/logs/fix_failed_callback_from_billplz.log');
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }
}
