<?php

namespace Database\Seeders;

use App\Models\EmployeeStatus;
use Illuminate\Database\Seeder;

class EmployeeTableSeeder extends Seeder
{


    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $feeds = [
            [
                'id'          => 1,
                'name'        => 'calf',
                'sex'         => '',
                'description' => '',
                'created_at'  => now(),
                'updated_at'  => now(),
            ],
            [
                'id'          => 2,
                'name'        => 'heifer',
                'sex'         => '',
                'description' => '',
                'created_at'  => now(),
                'updated_at'  => now(),
            ],
            [
                'id'          => 3,
                'name'        => 'adult',
                'sex'         => 'male',
                'description' => '',
                'created_at'  => now(),
                'updated_at'  => now(),
            ],
            [
                'id'          => 4,
                'name'        => 'open_unbred',
                'sex'         => 'female',
                'description' => '',
                'created_at'  => now(),
                'updated_at'  => now(),
            ],
            [
                'id'          => 5,
                'name'        => 'open_bred',
                'sex'         => 'female',
                'description' => '',
                'created_at'  => now(),
                'updated_at'  => now(),
            ],
            [
                'id'          => 6,
                'name'        => 'pregnant',
                'sex'         => 'female',
                'description' => '',
                'created_at'  => now(),
                'updated_at'  => now(),
            ],
            [
                'id'          => 7,
                'name'        => 'milking',
                'sex'         => 'female',
                'description' => '',
                'created_at'  => now(),
                'updated_at'  => now(),
            ],
            [
                'id'          => 8,
                'name'        => 'dry',
                'sex'         => 'female',
                'description' => '',
                'created_at'  => now(),
                'updated_at'  => now(),
            ],
        ];
        EmployeeStatus::insert($feeds);
        // $employee1 = Employee::create([
        //     'organization_id' => 1,
        //     'herd_id' => 1,
        //     'lot_id' =>  1,
        //     'breed_id' =>  1,
        //     'tag_id' =>  2,
        //     'sire_id' =>  1,
        //     'dam' =>  'TG99999',
        //     'employee_name' => 'Rupali',
        //     'birth_date' => '12/12/2020',
        //     'birth_weight' => '25',
        //     'current_weight' => '40',
        //     'teeth' => '2',
        //     'sex' => 'female',
        //     'status' => 'heifer',
        //     'source' => 'organizationbred',
        //     'breeding_status' => 'none',
        //     'reproduction_status' => 'none',
        //     'inseminated_by' => 4,
        //     'created_by' => 1
        // ]);

        // $employee2 = Employee::create([
        //     'organization_id' => 1,
        //     'herd_id' => 1,
        //     'lot_id' =>  2,
        //     'breed_id' =>  1,
        //     'tag_id' =>  2,
        //     'sire_id' =>  1,
        //     'dam' =>  'TG99999',
        //     'employee_name' => 'Shefali',
        //     'birth_date' => '12/05/2021',
        //     'birth_weight' => '32',
        //     'current_weight' => '14',
        //     'teeth' => '4',
        //     'sex' => 'female',
        //     'status' => 'heifer',
        //     'source' => 'organizationbred',
        //     'breeding_status' => 'none',
        //     'reproduction_status' => 'none',
        //     'inseminated_by' => 4,
        //     'created_by' => 1
        // ]);

        // for($i = 1; $i <= 2000; $i++) {

        //     $tid = Tag::max('uid');
        //     if(!empty($tid)){
        //         $uid = '0'.Tag::max('uid') + 1;
        //     }else{
        //         $uid = '050000000000001';
        //     }

        //     $last_four_digit = substr($uid, -4);
        //     $d = new DNS2D();
        //     $image = base64_decode($d->getBarcodePNG($uid,'QRCODE',3.0,3.0));

        //     $barcode = 'tag_barcode/'.$uid.'.png';
        //     Storage::disk('public')->put($barcode,$image);

        //     $tag = new Tag();
        //     $tag->uid = $uid;
        //     $tag->barcode = $barcode;
        //     $tag->qr_code = $last_four_digit;
        //     $tag->created_by = 1;
        //     $tag->save();
        // }

        // $user1 = User::where('id',1)->first();

        // //Create Roles
        // $roleSuperAdmin = Role::where('id',1)->first();

        //   //Permission List as array
        //   $permissions = [


        //     //Daily Action Permission
        //     [
        //         'group_name' => 'Daily Action',
        //         'permissions' => [
        //             'breeding_action.list',
        //             'vaccine_action.list',
        //             'deworming_action.list',
        //             'treatment_action.list',
        //         ]
        //     ],

        //     //Alert Action Permission
        //     [
        //         'group_name' => 'Alert Action',
        //         'permissions' => [
        //             'alert_action.list',
        //         ]
        //     ],

        //     //General Report Permission
        //     [
        //         'group_name' => 'General Report',
        //         'permissions' => [
        //             'general_report.list',
        //         ]
        //     ],

        //     //Custom Report Permission
        //     [
        //         'group_name' => 'Custom Report',
        //         'permissions' => [
        //             'custom_vaccine_report.list',
        //             'custom_deworm_report.list',
        //             'custom_sire_report.list',
        //         ]
        //     ],

        //     //Statistics Report Permission
        //     [
        //         'group_name' => 'Statistics Report',
        //         'permissions' => [
        //             'statistics_report.list',
        //         ]
        //     ],

        // ];

        // //Create and Assign Permissions

        // for($i=0; $i < count($permissions); $i++){
        //     $permissionGroup = $permissions[$i]['group_name'];

        //     for($j=0; $j < count($permissions[$i]['permissions']); $j++){
        //         $permission = Permission::create(['name' => $permissions[$i]['permissions'][$j],'group_name' => $permissionGroup]);
        //         $roleSuperAdmin->givePermissionTo($permission);
        //         $permission->assignRole($roleSuperAdmin);
        //     }
        // }

        // $user1->assignRole($roleSuperAdmin);

    // }

    }
}
