<?php

require_once __DIR__ . '/../src/Init.php';
use TPsoft\BugreportBackend\Models\Reports;

global $dbh;

$test_id = $argv[1];

if ($test_id == 1) { // cista query
	$query = sprintf('SELECT * FROM reports');
	$list = $dbh->getAll($query);
	print_r($list);
} else if ($test_id == 2) { // zistenie typu DB
	$type = $dbh->getDBtype();
	echo "DB type: '$type'\n";
} else if ($test_id == 3) { // ziskanie stlpcov tabulky
	$table_columns = $dbh->getTableColumns('reports');
	print_r($table_columns);
} else if ($test_id == 4) { // test modelu a ziskanie zoznamu
	$reports = new Reports();
	$ret = $reports->getList();
	print_r($ret);
} else if ($test_id == 5) { // test SELECT
	$reports = new Reports();
	$ret = $reports->report(52);
	print_r($ret);
} else if ($test_id == 6) { // test UPDATE
	$reports = new Reports();
	$ret = $reports->report(52, array('report_description' => 'zmenene o '.date('Y-m-d H:i:s')));
	print_r($ret);
} else if ($test_id == 7) { // test INSERT
	$reports = new Reports();
	$ret = $reports->report(null, array('report_title' => 'napis pre bug', 'report_description' => 'vytvorene o '.date('Y-m-d H:i:s')));
	print_r($ret);
} else if ($test_id == 8) { // test DELETE
	$reports = new Reports();
	$ret = $reports->report(55, null);
	print_r($ret);
} else if ($test_id == 9) { // test exists()
	$reports = new Reports();
	$ret = $reports->exist(52);
	var_dump($ret);
	$ret = $reports->exist(525);
	var_dump($ret);
} else if ($test_id == 10) { // test reportBy()
	$reports = new Reports();
	$ret = $reports->reportBy('report_title', 'test9');
	print_r($ret);
} else if ($test_id == 11) { // test reportSave()
	$reports = new Reports();
	$ret = $reports->reportSave(array('report_id' => 54, 'report_description' => 'zmenene o '.date('Y-m-d H:i:s')));
	print_r($ret);
} else if ($test_id == 12) { // test reportEmpty()
	$reports = new Reports();
	$ret = $reports->reportEmpty();
	print_r($ret);
} else if ($test_id == 13) { // test reportAttributes()
	$reports = new Reports();
	$ret = $reports->reportAttributes();
	print_r($ret);
} else if ($test_id == 14) { // test reportCount()
	$reports = new Reports();
	$ret = $reports->reportCount();
	print_r($ret);
} else if ($test_id == 15) { // test getList()
	$reports = new Reports();
	$ret = $reports->getList(array('report_status' => 3), true);
	print_r($ret);
} else if ($test_id == 16) { // test getListOrganize()
	$reports = new Reports();
	$ret = $reports->getListOrganize('report_id', array('report_status' => 3));
	print_r($ret);
} else if ($test_id == 17) { // test getListByID()
	$reports = new Reports();
	$ret = $reports->getListByID(array('report_status' => 3));
	print_r($ret);
} else if ($test_id == 18) { // test reportCombo()
	$reports = new Reports();
	$ret = $reports->reportCombo('report_id', 'report_title');
	print_r($ret);
} else {
	echo "Unknown test id (first argument): '$test_id'\n";
}
