<?php
ini_set('max_execution_time', 0);
require 'vendor/autoload.php';
require_once 'vendor/fzaninotto/faker/src/autoload.php';
$faker = Faker\Factory::create('fr_FR');
use RedBeanPHP\Facade as R;
R::setup('mysql:host=localhost;dbname=gsb_cost_managment', 'root', 'pwsio');
R::exec('CREATE VIEW visitor AS SELECT * FROM gsb_human_ressources.employee WHERE employee.job_id=3');
$status = R::dispense('status');
$status->libelle = 'Créée';
R::store($status);
$status = R::dispense('status');
$status->libelle = 'Clôturée';
R::store($status);
$status = R::dispense('status');
$status->libelle = 'Validée';
R::store($status);
$status = R::dispense('status');
$status->libelle = 'Mise en paiement';
R::store($status);
$status = R::dispense('status');
$status->libelle = 'Remboursée';
R::store($status);
for ($i = 0; $i < 12960; $i++) {
$cost_sheet = R::dispense('costsheet');
$cost_sheet->month = $faker->month;
$cost_sheet->visitor = R::findOne('visitor', 'id=?', [$faker->numberBetween($min = 1, $max = 540)]);
$cost_sheet->status = R::findOne('status', 'id=?', [$faker->numberBetween($min = 1, $max = 5)]);
$cost_sheet->justification_number = $faker->randomDigitNotNull;
$cost_sheet->valid_amount = $faker->randomNumber($nbDigits = 3);