<?php

namespace App\Database\Seeds;

use CodeIgniter\Database\Seeder;

class DummySeeder extends Seeder
{
  public function run()
  {
    $now = date('Y-m-d H:i:s');

    // users
    // Password: 'password' for all users (bcrypt hash)
    $passwordHash = password_hash('123', PASSWORD_BCRYPT);
    $data = [
      ['id' => 1, 'role_id' => 1, 'username' => 'lisfse', 'password' => $passwordHash],
      ['id' => 2, 'role_id' => 1, 'username' => 'tes', 'password' => $passwordHash]
    ];
    $this->db->table('users')->insertBatch($data);

    // patvisit
    $data = [
      ['InternalPVID' => 1, "PVID" => "XLAB0001", "InternalPID" => 1, "EpisodeID" => 1, "CreateDate" => "$now"],
      ['InternalPVID' => 2, "PVID" => "XLAB0002", "InternalPID" => 1, "EpisodeID" => 1, "CreateDate" => "$now"],
    ];
    $this->db->table('patvisit')->insertBatch($data);

    // patvisitadt
    $data = [
      ['InternalPVID' => 1, "ADTCode" => "X01", "LocationID" => 1, "AttDoc" => null, "CreateDate" => "$now"],
      ['InternalPVID' => 1, "ADTCode" => "X02", "LocationID" => null, "AttDoc" => 1, "CreateDate" => "$now"],
      ['InternalPVID' => 1, "ADTCode" => "X01", "LocationID" => 2, "AttDoc" => null, "CreateDate" => "$now"],
      ['InternalPVID' => 1, "ADTCode" => "X02", "LocationID" => null, "AttDoc" => 2, "CreateDate" => "$now"],
      ['InternalPVID' => 2, "ADTCode" => "X01", "LocationID" => 1, "AttDoc" => null, "CreateDate" => "$now"],
      ['InternalPVID' => 2, "ADTCode" => "X02", "LocationID" => null, "AttDoc" => 1, "CreateDate" => "$now"],
      ['InternalPVID' => 2, "ADTCode" => "X01", "LocationID" => 2, "AttDoc" => null, "CreateDate" => "$now"],
      ['InternalPVID' => 2, "ADTCode" => "X02", "LocationID" => null, "AttDoc" => 2, "CreateDate" => "$now"],
    ];
    $this->db->table('patvisitadt')->insertBatch($data);
  }
}