<?php

use Illuminate\Support\Facades\Route;
// use Spatie\LaravelAnalytics\LaravelAnalytics;
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

// Route::get('/', 'WelcomeController@index');

// Route::get('home', 'HomeController@index');

Route::controllers([
	'auth' => 'Auth\AuthController',
	'password' => 'Auth\PasswordController',
]);


Route::get('/', 'MainController@index');
Route::get('/sportslist', 'MainController@sports');
Route::get('/sports/{url}', 'MainController@templatesCat');
Route::get('/sports/{url}/{id}', 'MainController@templatesByCategory');
Route::get('/templatelist', 'MainController@fetchTemplates');
Route::get('/cartcount', 'MainController@countCart');
Route::get('/removeitem/{id}', 'MainController@removeCartItem');

Route::post('/custom/auth', 'CustomAuthController@authenticate');
Route::post('/custom/register', 'CustomAuthController@postRegister');


// Route::get('/cart', 'teamstore\TeamStoreController@cart');

Route::get('cart', ['as' => 'cart', 'uses' => 'teamstore\TeamStoreController@cart']);
Route::get('/checkout', 'teamstore\TeamStoreController@checkout');
Route::get('/mail', 'teamstore\TeamStoreController@mail');

Route::get('/designer/{templateid}', 'designer\DesignerController@index');

Route::get('/designer/preview/{designCode}', 'designer\DesignerController@getDesign');
Route::post('/designer/a/buy-form', 'designer\DesignerController@buyForm');

//edit routes//
Route::get('/designer/edit/{designCode}', 'designer\DesignerController@editDesign');
//end edit routes//

// CUSTOMIZER DISPLAY
Route::post('/designer/a/save-roster', 'designer\DesignerController@saveRoster');

//END CUSTOMIZER DISPLAY

Route::post('/designer/a/gradient-append', 'designer\DesignerController@gradientAppend');
Route::post('/designer/a/set-pattern', 'designer\DesignerController@setPattern');
Route::post('/designer/a/set-trim-pattern', 'designer\DesignerController@setTrimPattern');
Route::post('/designer/a/get-template-default-colors', 'designer\DesignerController@getTemplateDefaultColors');
Route::post('/designer/a/get-font-display', 'designer\DesignerController@getFontDisplay');
Route::post('/designer/a/get-cliparts', 'designer\DesignerController@getCliparts');
Route::post('/designer/a/clipart-properties', 'designer\DesignerController@clipartProperties');
Route::post('/designer/a/save-design', 'designer\DesignerController@saveDesign');
Route::post('/designer/edit/a/edit-gradient-append', 'designer\DesignerController@editGradientAppend');
Route::post('/designer/edit/a/edit-pattern-properties', 'designer\DesignerController@editPatternProperties');
Route::post('/designer/edit/a/edit-set-pattern', 'designer\DesignerController@editSetPattern');
Route::get('/designer/a/tab-clipart-content', 'designer\DesignerController@tabClipartContent');
Route::post('/designer/a/save-design-details', 'designer\DesignerController@saveDesignDetails');

// teamstore
Route::get('/teamstore', 'teamstore\TeamStoreController@login');  // old
Route::get('/teamstore', 'teamstore\TeamStoreController@storelist');  // old


// Route::group(['middleware' => 'teamstoresession'], function () {

Route::get('/teamstore/{storename}', 'teamstore\TeamStoreController@index');
Route::get('/teamstore/{storename}/product/{producurl}', 'teamstore\TeamStoreController@productDetails');
// Route::post('/teamstore/q/addnewrow', 'teamstore\TeamStoreController@addNewRow');
Route::post('/teamstore/q/add-to-cart', 'teamstore\TeamStoreController@addToCart');
Route::get('/teamstore/q/clearsession', 'teamstore\TeamStoreController@clearSession');
Route::post('/teamstore/q/add-voucher', 'teamstore\TeamStoreController@addVoucher');
Route::post('/teamstore/q/add-new-row', 'teamstore\TeamStoreController@addNewRow');
// });

Route::post('/teamstore/checkpassword', 'teamstore\TeamStoreController@checkTeamStorePassword');
// end teamstore

// user and store owner
Route::group(['middleware' => 'normaluser'], function () {

	Route::get('user', 'user\UserController@index');
	Route::get('user/address-book', 'user\UserController@addressBook');
	Route::get('user/address-book/create', 'user\UserController@createAddressBook');
	Route::post('user/address-book/save', 'user\UserController@saveAddressBook');
	Route::get('user/address-book/edit/{id}', 'user\UserController@editAddressBook');
	Route::post('user/address-book/update', 'user\UserController@updateAddressBook');
	Route::get('user/profile', 'user\UserController@profile');
	Route::get('user/profile/edit', 'user\UserController@editProfile');
	Route::post('user/profile/update', 'user\UserController@updateProfile');
	Route::get('user/profile/change-password', 'user\UserController@changePassword');
	Route::post('user/profile/update-password', 'user\UserController@updatePassword');
	Route::get('user/orders', 'user\UserController@orders');
	Route::get('user/orders/view/{ck}', 'user\UserController@orderDetails');
	Route::get('user/my-designs', 'user\UserController@myDesigns');
	Route::get('user/my-designs/view/{id}', 'user\UserController@viewDesign');
	Route::post('user/my-designs/update', 'user\UserController@updateDesignDetails');
	Route::get('user/store', 'user\UserController@store');
	Route::get('user/store-items', 'user\UserController@storeItems');
	Route::get('user/store-items/item/{url}', 'user\UserController@viewStoreItem');
	Route::post('user/store-items/update', 'user\UserController@storeItemUpdate');
	Route::get('user/store-settings', 'user\UserController@storeSetting');
	Route::post('user/store-settings/update', 'user\UserController@storeSettingUpdate');
	Route::get('user/email-verify', 'user\UserController@emailVerify');
	Route::post('user/post/resend-verification', 'user\UserController@resendVericationCode');
	Route::post('user/post/verify-code', 'user\UserController@verifyCode');
	Route::get('user/store-items/add-item', 'user\UserController@addStoreItem');
	Route::post('user/store-items/save-new-item', 'user\UserController@saveNewItem');
	Route::post('user/update-active-thumbnail', 'user\UserController@updateActiveThumbnail');
	Route::post('user/post/save-thumbnail-ordering', 'user\UserController@saveThumbnailOrdering');
	Route::post('user/post/save-item-ordering', 'user\UserController@saveItemOrdering');
	Route::post('user/post/show-store-order-details', 'user\UserController@showStoreOrderDetails');
	Route::post('user/post/delete-image-thumb', 'user\UserController@deleteImageThumb');
	Route::post('user/store-items/save-new-item-image', 'user\UserController@saveNewItemImage');
	Route::get('user/store-items/re-arrange', 'user\UserController@itemStoreReArrange');
	Route::post('user/store-items/delete', 'user\UserController@deleteStoreItem');

	Route::get('user/my-designs/sell-design/{designCode}', 'user\UserController@sellDesign');
	Route::post('user/my-designs/addstoreitem', 'user\UserController@saveNewStoreItem');

	Route::get('user/my-designs/buy-design/{designCode}', 'user\UserController@buyDesign');

	Route::get('user/store-orders', 'user\UserController@storeOrders');

	Route::get('user/announcement', 'user\UserController@announcementIndex');
	Route::post('user/announcement/updateSave', 'user\UserController@announcementUpdateSave');
	Route::post('user/announcement/status/update', 'user\UserController@announcementUpdateStatus');
});

Route::group(['middleware' => 'auth'], function () {
	// PAYPAL ROUTES
	Route::get('payPremium', ['as' => 'payPremium', 'uses' => 'paypal\PaypalController@payPremium']);
	Route::get('getCheckout', ['as' => 'getCheckout', 'uses' => 'paypal\PaypalController@getCheckout']);
	Route::get('getDone', ['as' => 'getDone', 'uses' => 'paypal\PaypalController@getDone']);
	Route::get('getCancel', ['as' => 'getCancel', 'uses' => 'paypal\PaypalController@getCancel']);
	Route::get('getDoneTest', ['as' => 'getDoneTest', 'uses' => 'paypal\PaypalController@getDoneTest']);
	// END PAYPAL ROUTES
});

Route::group(['middleware' => 'admin'], function () {
	Route::get('admin', function () {
		return view('sub_pages.index');
	});

	Route::get('admin/sports/', 'SportsController@displayAllSports');
	Route::get('admin/sports/add', 'SportsController@displayAddSportPage');
	Route::post('admin/sports/save', 'SportsController@saveNewSports');
	Route::get('admin/sports/edit/{sportsname}', 'SportsController@sportsDetails');
	Route::post('admin/sports/update', 'SportsController@updateSports');
	Route::get('admin/sports/sportsname', 'SportsController@selectSportsName');

	Route::get('admin/templates/', 'TemplatesController@displayTemplates');
	Route::post('admin/templates/id/{id}', 'TemplatesController@getTemplates');
	Route::get('admin/templates/add', 'TemplatesController@displayAddTemplatePage');
	Route::get('admin/templates/type', 'TemplatesController@getTemplateTypes');
	Route::get('admin/templates/getlastid', 'TemplatesController@getLastId');
	Route::post('admin/templates/save', 'TemplatesController@saveNewTemplates');
	Route::get('admin/templates/edit/{tempcode}', 'TemplatesController@displayEditTemplatePage');
	Route::post('admin/templates/update', 'TemplatesController@updateTemplate');
	Route::get('admin/templates/edit/{tempcode}/p-add', 'PrintPatternController@displayAddPrintTemplatePage');

	Route::get('admin/pattern/get', 'PatternsController@getPatterns');
	Route::post('admin/pattern/get/withvalue', 'PatternsController@getPatternsWithPostValue');

	Route::post('admin/print-template/save', 'PrintPatternController@savePrintPattern');
});


Route::get('cliparts/index', 'cliparts\ClipartsController@index');

// Route::get('analytics', function (){
// 	$analyticsData = LaravelAnalytics::getVisitorsAndPageViews(7);
// });

Route::group(array('middleware' => ['isAuthorized', 'cors'], 'prefix' => 'api'), function () {
	Route::post('login', 'ApiController@login');
	Route::post('insert', 'ApiController@insert');
	Route::get('tracking', 'ApiController@getTrackingStatus');
	Route::get('order-status', 'ApiController@getOrderStatus');
	Route::get('steps', 'ApiController@getSteps');
});
