<?php



Route::get('/', function() {
	return View::make('public');
});

/* Admin routes */
Route::get('login', 'AdminController@getLogin');
Route::post('login', 'AdminController@loginValidate');

Route::get('admin', 'AdminController@index');

Route::group(array('before' => 'auth', 'prefix' => 'admin'), function()
{
	/**
	 * Admin MVC
	 */
	Route::get('statuses/manager', ['as'=>'statusesManager', 'uses'=>'AdminController@getStatusesIndex']);
	Route::get('statuses/archive', ['as'=>'statusesArchive', 'uses'=>'ArchiveController@index']);

	Route::get('reports', ['as'=>'reports', 'uses'=>'ReportsController@getReportsIndex']);
	Route::post('reports', 'ReportsController@postReportsIndex');

	Route::post('reports/download', ['as'=>'download-report', 'uses'=>'ReportsController@downloadReport']);

	Route::get('settings', ['as'=>'settings', 'uses'=>'SettingsController@getIndex']);
	Route::post('settings', 'SettingsController@postIndex');



	/**
	 * Admin API
	 */
	Route::post('loginValidate', 'AdminController@loginValidate');

	Route::get('getColumns', 'AdminController@getColumns');
	Route::get('getStatuses', 'AdminController@getStatuses');
	Route::get('collectStatusesByColumns', 'AdminController@collectStatusesByColumns');
	Route::get('getApprovedStatuses/{num?}', 'AdminController@getApprovedStatuses');

	// Route::post('addColumn', 'AdminController@addColumn');
	Route::post('tab/create', 'AdminController@addColumn');
	Route::post('tab/{id}/settings', 'AdminController@postTabSettings');
	Route::post('tab/{id}/state', 'AdminController@postTabState');

	Route::post('approveStatus', 'AdminController@approveStatus');
	Route::post('cloneStatus/{id}', 'AdminController@cloneStatus');
	Route::post('setState/{statusId}', 'AdminController@setState');
	Route::post('sortStatuses', 'AdminController@sortStatuses');

	/**
	 * Arcihed Statuses
	 */
	Route::get('getArchived', 'ArchiveController@getStatuses');

	// Route::post('approveStatusesByColumn', 'AdminController@approveStatusesByColumn');

	Route::get('imageToBase64', 'AdminController@imageToBase64');
});

/* API routes */
Route::group(array('prefix' => 'api'), function()
{
Route::get('/statuses/{num?}', 'ApiController@getAllApprovedStatuses');

/**
 * XML Response
 */
Route::get('/status/{num}/{size}', 'ApiController@getNApprovedStatus')
		->where([
			'num'	=> '[0-9]+',
			'size'	=> '(?:4x3|16x9)'
		]);

Route::get('/status/{num}/{size}/image.png', 'ApiController@getNApprovedStatusImage')
		->where([
			'num'	=> '[0-9]+',
			'size'	=> '(?:4x3|16x9)'
		]);

Route::get('/', 'ApiController@getInitialStatuses');
Route::get('init/{num?}', 'ApiController@getInitialStatuses');
Route::get('next/{id}', 'ApiController@getNextStatus');
Route::get('crone/{response?}', 'BaseController@crone');
Route::get('{type?}', 'ApiController@index');
});

/*
Route::get('/api/unity', 'ApiController@unity');
Route::get('/api/getToplist', 'ApiController@getToplist');
*/

Route::get('/crone/{response?}', 'BaseController@crone');



