<?php

/*
  |--------------------------------------------------------------------------
  | 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 Closure to execute when that URI is requested.
  |
 */


// Session Routes
Route::get('login', array('as' => 'login', 'uses' => 'SessionController@create'));
Route::get('logout', array('as' => 'logout', 'uses' => 'SessionController@destroy'));
Route::resource('sessions', 'SessionController', array('only' => array('create', 'store', 'destroy')));

// User Routes
//Route::get('register', 'UserController@create');
Route::get('users/{id}/activate/{code}', 'UserController@activate')->where('id', '[0-9]+');
Route::get('resend', array('as' => 'resendActivationForm', function() {
	return View::make('users.resend');
}));
Route::post('resend', 'UserController@resend');
Route::get('forgot', array('as' => 'forgotPasswordForm', function() {
	return View::make('users.forgot');
}));
Route::post('forgot', 'UserController@forgot');
Route::post('users/{id}/change', 'UserController@change');
Route::get('users/{id}/reset/{code}', 'UserController@reset')->where('id', '[0-9]+');
Route::get('users/{id}/suspend', array('as' => 'suspendUserForm', function($id) {
	return View::make('users.suspend')->with('id', $id);
}));
Route::post('users/{id}/suspend', 'UserController@suspend')->where('id', '[0-9]+');
Route::get('users/{id}/unsuspend', 'UserController@unsuspend')->where('id', '[0-9]+');
Route::get('users/{id}/ban', 'UserController@ban')->where('id', '[0-9]+');
Route::get('users/{id}/unban', 'UserController@unban')->where('id', '[0-9]+');
Route::post('users/addmoney', 'UserController@addMoney');
Route::resource('users', 'UserController');

//Заявки
Route::get('lead', 'LeadController@index');
Route::post('lead/{id}', 'LeadController@getLead')->where('id', '[0-9]+');
Route::post('lead/sendtocrm', 'LeadController@sendToCRM');
Route::post('lead/delete', 'LeadController@delete');

//CRM
Route::get('crm', 'CrmController@index');
Route::get('crm/needsize', 'CrmController@needSize');
Route::post('crm/partner/{id}', 'CrmController@getPartner')->where('id', '[0-9]+');
Route::post('crm/partner/update', 'CrmController@updatePartner');
Route::any('crm/search', 'CrmController@search');
Route::get('crm/searchpage', 'CrmController@searchPage');
Route::any('crm/globalsearch', 'CrmController@globalSearch');
//Route::post('crm/getrefrence', 'CrmController@getRefrence');
Route::post('crm/getrefrencestat', 'CrmController@getRefrenceStat');
Route::get('crm/getrefrencestat', function()
{
	return Redirect::to('/');
});
Route::post('crm/holdrefrence', 'CrmController@holdRefrence');
Route::post('crm/{id}/comments', 'CrmController@getPartnerComments')->where('partnerId', '[0-9]+');
Route::post('crm/getworkpartner', 'CrmController@getWorkPartner');

//работа с клиентом
Route::get('partner/{id}', 'PartnerController@index')->where('partnerId', '[0-9]+');
Route::post('partner/{id}/infosource', 'PartnerController@getSource')->where('id', '[0-9]+');
Route::post('partner/trashphone', 'PartnerController@trashPhone');
Route::post('partner/repeated', 'PartnerController@repeated');
Route::post('partner/holdover', 'PartnerController@holdOver');
Route::post('partner/busy', 'PartnerController@busy');
Route::post('partner/reject', 'PartnerController@reject');
Route::post('partner/setdatetime', 'PartnerController@setDateTime');
Route::post('partner/agree', 'PartnerController@agree');
Route::post('partner/{partnerId}/toproduction', 'PartnerController@toProduction')->where('partnerId', '[0-9]+'); // ДОДЕЛАТЬ
Route::post('partner/paymentrecive', 'PartnerController@paymentRecive');
Route::post('partner/paymentconfirm', 'PartnerController@paymentConfirm');
Route::post('partner/registrationok', 'PartnerController@registrationOk');
Route::post('partner/todelivering', 'PartnerController@toDelivering');
Route::post('partner/sended', 'PartnerController@sended');
Route::post('partner/recived', 'PartnerController@recived');
Route::post('partner/clientRecived', 'PartnerController@clientRecived');
Route::post('partner/uploadfile', 'PartnerController@uploadFile');
Route::post('partner/deletefile', 'PartnerController@deleteFile');
Route::post('partner/sendchecked', 'PartnerController@sendChecked');
Route::post('partner/deliverychecked', 'PartnerController@deliveryChecked');
Route::post('partner/update', 'PartnerController@update');
Route::post('partner/production', 'PartnerController@production');
Route::get('partner/{id}/productsjson', 'PartnerController@productsJSON')->where('partnerId', '[0-9]+');
Route::post('partner/clarificationaddress', 'PartnerController@clarificationAddress');
Route::post('partner/cdekcalculate', 'PartnerController@cdekcalculate');
Route::post('partner/checkcdek', 'PartnerController@checkCdek');
Route::post('partner/deletecdek', 'PartnerController@deleteCdek');
Route::post('partner/checkpatternssuccess', 'PartnerController@checkPatternsSuccess');
Route::post('partner/checkpatternsfail', 'PartnerController@checkPatternsFail');

//Отправка
Route::get('shipments', 'ShipmentsController@index');
Route::get('shipments/create', 'ShipmentsController@create');
Route::post('shipments/store', 'ShipmentsController@store');
Route::post('shipments/setnogoods', 'ShipmentsController@setNoGoods');
Route::post('shipments/sethasgoods', 'ShipmentsController@setHasGoods');
Route::post('shipments/cdekpacked', 'ShipmentsController@cdekPacked');
Route::post('shipments/shoplogistics/actfeence', 'ShipmentsController@shoplogisticsActFence');
Route::post('shipments/shoplogistics/zabor', 'ShipmentsController@shoplogisticsAddZabor');
Route::post('shipments/shoplogistics/transfered', 'ShipmentsController@shoplogisticsTransfered');
Route::post('shipments/shoplogistics/send', 'ShipmentsController@shoplogisticsSend');
Route::get('shipments/shoplogistics/{id}/act_fence', 'ShipmentsController@downloadShoplogisticsActFence')->where('shipmentId', '[0-9]+');
Route::post('shipments/cdek/actfeence', 'ShipmentsController@cdekActFence');
Route::post('shipments/cdek/zabor', 'ShipmentsController@cdekAddZabor');
Route::post('shipments/cdek/transfered', 'ShipmentsController@cdekTransfered');
Route::post('shipments/cdek/send', 'ShipmentsController@cdekSend');
Route::get('shipments/sdek/{id}/act_fence', 'ShipmentsController@downloadCdekActFence')->where('shipmentId', '[0-9]+');
Route::get('shipments/sdek/{id}/orderprint', 'ShipmentsController@downloadCdekOrderPrint')->where('partnerId', '[0-9]+');
Route::get('shipments/post/export', 'ShipmentsController@downloadPostExport');
Route::get('shipments/post/import', 'ShipmentsController@uploadPostExport');

//загрузка акта сверки сдек
Route::get('cdek/upload', 'CdekUploadController@index');
Route::post('cdek/upload/uploadfile', 'CdekUploadController@uploadFile');

//Производство
Route::get('production', 'ProductionController@index');
Route::get('production/{id}/print', 'ProductionController@productionPrint')->where('partnerId', '[0-9]+');
Route::get('production/{id}/printsuccess', 'ProductionController@productionPrintSuccess')->where('partnerId', '[0-9]+');
Route::post('production/sizing', 'ProductionController@sizing');
Route::post('production/process', 'ProductionController@process');
Route::post('production/success', 'ProductionController@success');
Route::post('production/nostorage', 'ProductionController@noStorage');
Route::post('production/packed', 'ProductionController@packed');
//Упаковка
Route::get('production/packing', 'ProductionController@packing');
Route::get('production/stat', 'ProductionController@stat');


//Статистика
Route::get('stat/crm', 'StatController@crm');
Route::get('stat/leadstotal', 'StatController@leadstotal');
Route::get('stat/infosources', 'StatController@infosources');
Route::get('stat/leads', 'StatController@leads');
Route::get('stat/reject', 'StatController@reject');
Route::get('stat/reject/detail', 'StatController@rejectDetail');
Route::get('stat/shipments', 'StatController@shipments');
Route::get('stat/products', 'StatController@products');
Route::get('stat/production', 'StatController@production');
Route::get('stat/franchisees', 'StatController@franchisees');
Route::get('stat/daily', 'StatController@daily');
Route::get('stat/daily/money', 'StatController@dailymoney');
Route::get('stat/daily/pay', 'StatController@dailypay');


//Экспорт для realroi
Route::get('realroi/export', 'RealroiController@export');

//Франчайзи
Route::get('franchisees', 'FranchiseesController@index');


//Route::get('crm/project/{id}', 'CrmController@index')->where('projectId', '[0-9]+');


//Route::post('crm/lead/addcomment', 'CrmController@addComment');
//Route::post('crm/lead/take', 'CrmController@take');
//Route::post('crm/lead/setstatus', 'CrmController@setStatus');
//
//Route::any('crm/stat/search', 'CrmStatController@search');


//API
Route::any('api', 'ApiController@api');
Route::any('papi', 'ApiController@papi');

//Проекты, сайты, продукты, новости, отказы, промоутеры
Route::resource('projects', 'ProjectsController', array('except' => array('show')));
  //сайты
Route::resource('projects/{projectId}/sites', 'SitesController', array('except' => array('show')));
  //продукты
Route::resource('projects/{projectId}/products', 'ProductsController', array('except' => array('show')));
Route::get('projects/{projectId}/products/storage_quant_{productId}_{productTypeId}/{type}', 'ProductsController@updateQuant');
Route::get('projects/{projectId}/products/export', 'ProductsController@export')->where('partnerId', '[0-9]+');
  //новости, маркетинг, обучение
Route::resource('projects/{projectId}/project_news', 'ProjectNewsController');
Route::get('projects/9/marketing/part/{projectNewsType}/view', 'ProjectNewsController@setViewedAll');
Route::get('projects/9/training/part/{projectNewsType}/view', 'ProjectNewsController@setViewedAll');
Route::get('projects/9/project_news/{projectNewsType}/view', 'ProjectNewsController@setViewedAll');
Route::get('projects/{projectId}/marketing', 'ProjectNewsController@getMenuMarketing')->where('id', '[0-9]+');
Route::get('projects/9/marketing/part/{id}', 'ProjectNewsController@getPartMarketing')->where('id', '[0-9]+');
Route::get('projects/{projectId}/training', 'ProjectNewsController@getMenuTraining')->where('id', '[0-9]+');
Route::get('projects/9/training/part/{id}', 'ProjectNewsController@getPartTraining')->where('id', '[0-9]+');
  //отказы
Route::resource('projects/{projectId}/rejects', 'RejectsController', array('except' => array('show')));
  //промоутеры
Route::resource('promoters', 'PromotersController', array('except' => array('show')));
  // источники информации
Route::post('projects/9/info_sources/getComments', 'InfoSourcesController@getComments');
Route::resource('projects/{projectId}/info_sources', 'InfoSourcesController', array('except' => array('show')));

//Route::get('project/{id}', 'StatController@show')->where('id', '[0-9]+');

// Group Routes
//Route::resource('groups', 'GroupController');

Route::get('/', array('as' => 'home', 'uses' => 'HomeController@index'));

App::missing(function($exception) {
	return 'Page not found';
	//App::abort(404, 'Page not found');
	//return Response::view('errors.missing', array(), 404);
});




