invoiceninja/app/routes.php

409 lines
15 KiB
PHP
Raw Normal View History

2013-11-26 14:45:07 +02:00
<?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.
|
*/
2014-01-09 15:26:27 +00:00
//apc_clear_cache();
2014-01-31 00:29:09 +02:00
//Cache::flush();
2014-01-09 15:26:27 +00:00
2013-12-05 22:25:20 +02:00
//dd(DB::getQueryLog());
2013-12-04 18:20:14 +02:00
//dd(Client::getPrivateId(1));
2013-12-10 19:18:35 +02:00
//dd(new DateTime());
2013-12-15 14:55:50 +02:00
//Event::fire('user.signup');
2014-01-05 00:51:16 +02:00
//dd(App::environment());
2014-01-05 09:25:15 +02:00
//dd(gethostname());
2014-01-05 16:44:49 +00:00
//Log::error('test');
2014-09-28 13:37:54 +03:00
Route::get('install', 'AccountController@install');
Route::get('update', 'AccountController@update');
Route::get('reset', 'AccountController@reset');
2014-07-27 23:31:41 +03:00
2014-07-15 23:36:40 +03:00
Route::get('/', 'HomeController@showIndex');
Route::get('/rocksteady', 'HomeController@showIndex');
Route::get('/about', 'HomeController@showAboutUs');
Route::get('/terms', 'HomeController@showTerms');
Route::get('/contact', 'HomeController@showContactUs');
Route::get('/plans', 'HomeController@showPlans');
Route::post('/contact_submit', 'HomeController@doContactUs');
Route::get('/faq', 'HomeController@showFaq');
Route::get('/features', 'HomeController@showFeatures');
Route::get('/testimonials', 'HomeController@showTestimonials');
2014-10-06 00:00:42 +03:00
Route::get('/compare-online-invoicing{sites?}', 'HomeController@showCompare');
2014-07-15 23:36:40 +03:00
Route::get('log_error', 'HomeController@logError');
Route::get('invoice_now', 'HomeController@invoiceNow');
Route::post('get_started', 'AccountController@getStarted');
Route::get('view/{invitation_key}', 'InvoiceController@view');
Route::get('payment/{invitation_key}', 'PaymentController@show_payment');
Route::post('payment/{invitation_key}', 'PaymentController@do_payment');
Route::get('complete', 'PaymentController@offsite_payment');
Route::get('license', 'PaymentController@show_license_payment');
Route::post('license', 'PaymentController@do_license_payment');
Route::get('claim_license', 'PaymentController@claim_license');
Route::post('signup/validate', 'AccountController@checkEmail');
Route::post('signup/submit', 'AccountController@submitSignup');
2013-12-07 20:45:00 +02:00
// Confide routes
Route::get('login', 'UserController@login');
Route::post('login', 'UserController@do_login');
2014-01-09 19:00:08 +00:00
Route::get('user/confirm/{code}', 'UserController@confirm');
2013-12-07 20:45:00 +02:00
Route::get('forgot_password', 'UserController@forgot_password');
Route::post('forgot_password', 'UserController@do_forgot_password');
2014-07-23 18:02:56 +03:00
Route::get('user/reset/{token?}', 'UserController@reset_password');
2014-01-09 19:00:08 +00:00
Route::post('user/reset', 'UserController@do_reset_password');
2013-12-07 20:45:00 +02:00
Route::get('logout', 'UserController@logout');
2014-10-06 00:00:42 +03:00
if (Utils::isNinja()) {
Route::get('/news_feed/{user_type}/{version}/', 'HomeController@newsFeed');
}
2013-12-07 20:45:00 +02:00
2013-12-03 19:32:33 +02:00
Route::group(array('before' => 'auth'), function()
2013-11-26 14:45:07 +02:00
{
Route::get('dashboard', 'DashboardController@index');
2014-02-18 23:56:18 +02:00
Route::get('view_archive/{entity_type}/{visible}', 'AccountController@setTrashVisible');
2014-10-06 00:00:42 +03:00
Route::get('hide_message', 'HomeController@hideMessage');
2014-03-23 11:30:48 +02:00
Route::get('force_inline_pdf', 'UserController@forcePDFJS');
2014-07-23 18:02:56 +03:00
Route::get('api/users', array('as'=>'api.users', 'uses'=>'UserController@getDatatable'));
Route::resource('users', 'UserController');
Route::post('users/delete', 'UserController@delete');
2014-04-23 23:30:54 +03:00
2014-04-24 00:48:09 +03:00
Route::get('api/products', array('as'=>'api.products', 'uses'=>'ProductController@getDatatable'));
Route::resource('products', 'ProductController');
Route::get('products/{product_id}/archive', 'ProductController@archive');
2014-10-05 12:35:51 +03:00
Route::get('company/advanced_settings/data_visualizations', 'ReportController@d3');
2014-05-08 22:19:33 +03:00
Route::get('company/advanced_settings/chart_builder', 'ReportController@report');
Route::post('company/advanced_settings/chart_builder', 'ReportController@report');
2014-09-14 15:26:51 +03:00
Route::post('company/cancel_account', 'AccountController@cancelAccount');
2013-12-25 19:36:34 -05:00
Route::get('account/getSearchData', array('as' => 'getSearchData', 'uses' => 'AccountController@getSearchData'));
2014-05-08 22:19:33 +03:00
Route::get('company/{section?}/{sub_section?}', 'AccountController@showSection');
Route::post('company/{section?}/{sub_section?}', 'AccountController@doSection');
2013-12-05 17:23:24 +02:00
Route::post('user/setTheme', 'UserController@setTheme');
2014-03-18 20:55:50 +02:00
Route::post('remove_logo', 'AccountController@removeLogo');
2014-04-10 22:29:01 +03:00
Route::post('account/go_pro', 'AccountController@enableProPlan');
2014-04-23 23:30:54 +03:00
2013-11-26 14:45:07 +02:00
Route::resource('clients', 'ClientController');
Route::get('api/clients', array('as'=>'api.clients', 'uses'=>'ClientController@getDatatable'));
2013-12-01 22:58:25 +02:00
Route::get('api/activities/{client_id?}', array('as'=>'api.activities', 'uses'=>'ActivityController@getDatatable'));
2013-12-01 09:33:17 +02:00
Route::post('clients/bulk', 'ClientController@bulk');
2013-11-26 14:45:07 +02:00
2013-12-11 13:11:59 +02:00
Route::get('recurring_invoices', 'InvoiceController@recurringIndex');
Route::get('api/recurring_invoices/{client_id?}', array('as'=>'api.recurring_invoices', 'uses'=>'InvoiceController@getRecurringDatatable'));
2014-05-17 22:29:57 +03:00
Route::resource('invoices', 'InvoiceController');
Route::get('api/invoices/{client_id?}', array('as'=>'api.invoices', 'uses'=>'InvoiceController@getDatatable'));
Route::get('invoices/create/{client_id?}', 'InvoiceController@create');
2014-05-21 00:40:09 +03:00
Route::get('invoices/{public_id}/clone', 'InvoiceController@cloneInvoice');
2014-05-17 22:29:57 +03:00
Route::post('invoices/bulk', 'InvoiceController@bulk');
2014-05-21 00:40:09 +03:00
Route::get('quotes/create/{client_id?}', 'QuoteController@create');
Route::get('quotes/{public_id}/clone', 'InvoiceController@cloneInvoice');
Route::get('quotes/{public_id}/edit', 'InvoiceController@edit');
Route::put('quotes/{public_id}', 'InvoiceController@update');
Route::get('quotes/{public_id}', 'InvoiceController@edit');
Route::post('quotes', 'InvoiceController@store');
Route::get('quotes', 'QuoteController@index');
Route::get('api/quotes/{client_id?}', array('as'=>'api.quotes', 'uses'=>'QuoteController@getDatatable'));
Route::post('quotes/bulk', 'QuoteController@bulk');
2013-11-26 14:45:07 +02:00
2013-12-05 22:25:20 +02:00
Route::get('payments/{id}/edit', function() { return View::make('header'); });
2013-12-04 18:20:14 +02:00
Route::resource('payments', 'PaymentController');
2014-01-02 15:21:15 +02:00
Route::get('payments/create/{client_id?}/{invoice_id?}', 'PaymentController@create');
2013-11-29 14:09:21 +02:00
Route::get('api/payments/{client_id?}', array('as'=>'api.payments', 'uses'=>'PaymentController@getDatatable'));
2013-12-01 09:33:17 +02:00
Route::post('payments/bulk', 'PaymentController@bulk');
2013-12-05 22:25:20 +02:00
Route::get('credits/{id}/edit', function() { return View::make('header'); });
2013-12-04 18:20:14 +02:00
Route::resource('credits', 'CreditController');
2014-01-02 15:21:15 +02:00
Route::get('credits/create/{client_id?}/{invoice_id?}', 'CreditController@create');
2013-12-01 22:58:25 +02:00
Route::get('api/credits/{client_id?}', array('as'=>'api.credits', 'uses'=>'CreditController@getDatatable'));
2014-05-08 22:19:33 +03:00
Route::post('credits/bulk', 'CreditController@bulk');
2013-11-26 14:45:07 +02:00
});
2014-07-27 23:31:41 +03:00
// Route group for API
2014-05-13 22:20:54 +03:00
Route::group(array('prefix' => 'api/v1', 'before' => 'auth.basic'), function()
{
2014-07-27 23:31:41 +03:00
Route::resource('ping', 'ClientApiController@ping');
Route::resource('clients', 'ClientApiController');
Route::resource('invoices', 'InvoiceApiController');
Route::resource('quotes', 'QuoteApiController');
Route::resource('payments', 'PaymentApiController');
Route::post('api/hooks', 'IntegrationController@subscribe');
});
2013-11-26 14:45:07 +02:00
2014-08-26 10:37:47 +02:00
define('CONTACT_EMAIL', Config::get('mail.from.address'));
define('CONTACT_NAME', Config::get('mail.from.name'));
define('SITE_URL', Config::get('app.url'));
2014-04-27 08:58:39 +03:00
2014-01-07 23:59:06 +00:00
define('ENV_DEVELOPMENT', 'local');
define('ENV_STAGING', 'staging');
2014-01-08 20:09:47 +00:00
define('ENV_PRODUCTION', 'fortrabbit');
2014-01-07 23:59:06 +00:00
define('RECENTLY_VIEWED', 'RECENTLY_VIEWED');
define('ENTITY_CLIENT', 'client');
define('ENTITY_INVOICE', 'invoice');
define('ENTITY_RECURRING_INVOICE', 'recurring_invoice');
define('ENTITY_PAYMENT', 'payment');
define('ENTITY_CREDIT', 'credit');
2014-05-17 22:29:57 +03:00
define('ENTITY_QUOTE', 'quote');
2014-01-07 23:59:06 +00:00
define('PERSON_CONTACT', 'contact');
define('PERSON_USER', 'user');
define('ACCOUNT_DETAILS', 'details');
2014-02-18 17:07:22 +02:00
define('ACCOUNT_NOTIFICATIONS', 'notifications');
define('ACCOUNT_IMPORT_EXPORT', 'import_export');
define('ACCOUNT_PAYMENTS', 'payments');
2014-01-07 23:59:06 +00:00
define('ACCOUNT_MAP', 'import_map');
define('ACCOUNT_EXPORT', 'export');
2014-04-23 23:30:54 +03:00
define('ACCOUNT_PRODUCTS', 'products');
2014-05-08 22:19:33 +03:00
define('ACCOUNT_ADVANCED_SETTINGS', 'advanced_settings');
define('ACCOUNT_CUSTOM_FIELDS', 'custom_fields');
define('ACCOUNT_INVOICE_DESIGN', 'invoice_design');
define('ACCOUNT_CHART_BUILDER', 'chart_builder');
2014-07-23 18:02:56 +03:00
define('ACCOUNT_USER_MANAGEMENT', 'user_management');
2014-10-05 12:35:51 +03:00
define('ACCOUNT_DATA_VISUALIZATIONS', 'data_visualizations');
2014-01-07 23:59:06 +00:00
define('DEFAULT_INVOICE_NUMBER', '0001');
define('RECENTLY_VIEWED_LIMIT', 8);
define('LOGGED_ERROR_LIMIT', 100);
2014-01-13 19:22:43 +00:00
define('RANDOM_KEY_LENGTH', 32);
2014-05-04 16:07:45 +03:00
define('MAX_NUM_CLIENTS', 500);
2014-07-23 18:02:56 +03:00
define('MAX_NUM_CLIENTS_PRO', 20000);
define('MAX_NUM_USERS', 5);
2013-12-01 22:58:25 +02:00
2013-12-07 20:45:00 +02:00
define('INVOICE_STATUS_DRAFT', 1);
define('INVOICE_STATUS_SENT', 2);
define('INVOICE_STATUS_VIEWED', 3);
define('INVOICE_STATUS_PARTIAL', 4);
2013-12-09 11:38:49 +02:00
define('INVOICE_STATUS_PAID', 5);
2014-01-16 21:12:46 +00:00
define('PAYMENT_TYPE_CREDIT', 1);
2013-12-09 11:38:49 +02:00
define('FREQUENCY_WEEKLY', 1);
define('FREQUENCY_TWO_WEEKS', 2);
define('FREQUENCY_FOUR_WEEKS', 3);
define('FREQUENCY_MONTHLY', 4);
define('FREQUENCY_THREE_MONTHS', 5);
define('FREQUENCY_SIX_MONTHS', 6);
2013-12-15 14:55:50 +02:00
define('FREQUENCY_ANNUALLY', 7);
define('SESSION_TIMEZONE', 'timezone');
2013-12-29 19:40:11 +02:00
define('SESSION_CURRENCY', 'currency');
2013-12-15 14:55:50 +02:00
define('SESSION_DATE_FORMAT', 'dateFormat');
2013-12-25 16:34:42 -05:00
define('SESSION_DATE_PICKER_FORMAT', 'datePickerFormat');
2013-12-15 14:55:50 +02:00
define('SESSION_DATETIME_FORMAT', 'datetimeFormat');
2014-03-19 18:17:26 +02:00
define('SESSION_COUNTER', 'sessionCounter');
2014-04-02 16:10:00 +03:00
define('SESSION_LOCALE', 'sessionLocale');
2013-12-15 14:55:50 +02:00
define('DEFAULT_TIMEZONE', 'US/Eastern');
2013-12-29 19:40:11 +02:00
define('DEFAULT_CURRENCY', 1); // US Dollar
2013-12-25 16:34:42 -05:00
define('DEFAULT_DATE_FORMAT', 'M j, Y');
2014-01-01 01:50:13 +02:00
define('DEFAULT_DATE_PICKER_FORMAT', 'M d, yyyy');
2013-12-15 14:55:50 +02:00
define('DEFAULT_DATETIME_FORMAT', 'F j, Y, g:i a');
2014-03-19 20:54:27 +02:00
define('DEFAULT_QUERY_CACHE', 120); // minutes
define('DEFAULT_LOCALE', 'en');
2014-01-01 17:23:32 +02:00
2014-04-12 21:55:40 +03:00
define('RESULT_SUCCESS', 'success');
define('RESULT_FAILURE', 'failure');
define('PAYMENT_LIBRARY_OMNIPAY', 1);
define('PAYMENT_LIBRARY_PHP_PAYMENTS', 2);
2014-01-01 17:23:32 +02:00
2014-04-25 18:37:08 +03:00
define('GATEWAY_AUTHORIZE_NET', 1);
2014-04-13 16:34:58 +03:00
define('GATEWAY_PAYPAL_EXPRESS', 17);
define('GATEWAY_BEANSTREAM', 29);
2014-04-13 16:34:58 +03:00
define('GATEWAY_PSIGATE', 30);
define('GATEWAY_MOOLAH', 31);
2014-04-13 16:34:58 +03:00
2014-07-27 23:31:41 +03:00
define('EVENT_CREATE_CLIENT', 1);
define('EVENT_CREATE_INVOICE', 2);
define('EVENT_CREATE_QUOTE', 3);
define('EVENT_CREATE_PAYMENT', 4);
2014-04-13 16:34:58 +03:00
define('REQUESTED_PRO_PLAN', 'REQUESTED_PRO_PLAN');
define('NINJA_ACCOUNT_KEY', 'zg4ylmzDkdkPOT8yoKQw9LTWaoZJx79h');
2014-04-25 18:37:08 +03:00
define('NINJA_GATEWAY_ID', GATEWAY_AUTHORIZE_NET);
2014-04-25 16:04:57 +03:00
define('NINJA_GATEWAY_CONFIG', '{"apiLoginId":"626vWcD5","transactionKey":"4bn26TgL9r4Br4qJ","testMode":"","developerMode":""}');
2014-04-27 08:58:39 +03:00
define('NINJA_URL', 'https://www.invoiceninja.com');
2014-10-06 00:00:42 +03:00
define('NINJA_VERSION', '1.4.0');
define('RELEASES_URL', 'https://github.com/hillelcoren/invoice-ninja/releases/');
2014-04-13 16:34:58 +03:00
2014-07-15 23:36:40 +03:00
define('PRO_PLAN_PRICE', 50);
define('LICENSE_PRICE', 30.00);
2014-04-13 16:34:58 +03:00
2014-10-06 00:00:42 +03:00
define('USER_TYPE_SELF_HOST', 'SELF_HOST');
define('USER_TYPE_CLOUD_HOST', 'CLOUD_HOST');
define('NEW_VERSION_AVAILABLE', 'NEW_VERSION_AVAILABLE');
2014-04-13 16:34:58 +03:00
/*
define('GATEWAY_AMAZON', 30);
define('GATEWAY_BLUEPAY', 31);
define('GATEWAY_BRAINTREE', 32);
define('GATEWAY_GOOGLE', 33);
define('GATEWAY_QUICKBOOKS', 35);
2014-04-13 16:34:58 +03:00
*/
2014-01-01 17:23:32 +02:00
/**
* TEST VALUES FOR THE CREDIT CARDS
* NUMBER IS FOR THE BINARY COUNT FOR WHICH IMAGES TO DISPLAY
* card IS FOR CARD IMAGE AND text IS FOR CARD NAME (TO ADD TO alt FOR IMAGE)
**/
$creditCards = [
1 => ['card' => 'images/credit_cards/Test-Visa-Icon.png', 'text' => 'Visa'],
2 => ['card' => 'images/credit_cards/Test-MasterCard-Icon.png', 'text' => 'Master Card'],
4 => ['card' => 'images/credit_cards/Test-AmericanExpress-Icon.png', 'text' => 'American Express'],
8 => ['card' => 'images/credit_cards/Test-Diners-Icon.png', 'text' => 'Diners'],
16 => ['card' => 'images/credit_cards/Test-Discover-Icon.png', 'text' => 'Discover']
];
define('CREDIT_CARDS', serialize($creditCards));
2014-04-18 11:57:31 +03:00
HTML::macro('nav_link', function($url, $text, $url2 = '', $extra = '') {
$class = ( Request::is($url) || Request::is($url.'/*') || Request::is($url2) ) ? ' class="active"' : '';
$title = ucwords(trans("texts.$text")) . Utils::getProLabel($text);
return '<li'.$class.'><a href="'.URL::to($url).'" '.$extra.'>'.$title.'</a></li>';
});
HTML::macro('tab_link', function($url, $text, $active = false) {
$class = $active ? ' class="active"' : '';
return '<li'.$class.'><a href="'.URL::to($url).'" data-toggle="tab">'.$text.'</a></li>';
});
HTML::macro('menu_link', function($type) {
$types = $type.'s';
$Type = ucfirst($type);
$Types = ucfirst($types);
2014-05-08 22:19:33 +03:00
$class = ( Request::is($types) || Request::is('*'.$type.'*')) && !Request::is('*advanced_settings*') ? ' active' : '';
2014-04-18 11:57:31 +03:00
return '<li class="dropdown '.$class.'">
<a href="'.URL::to($types).'" class="dropdown-toggle">'.trans("texts.$types").'</a>
<ul class="dropdown-menu" id="menu1">
<li><a href="'.URL::to($types.'/create').'">'.trans("texts.new_$type").'</a></li>
</ul>
</li>';
});
HTML::macro('image_data', function($imagePath) {
2014-06-29 20:23:10 +03:00
return 'data:image/jpeg;base64,' . base64_encode(file_get_contents(public_path().'/'.$imagePath));
2014-04-18 11:57:31 +03:00
});
HTML::macro('breadcrumbs', function() {
$str = '<ol class="breadcrumb">';
// Get the breadcrumbs by exploding the current path.
$basePath = Utils::basePath();
$parts = explode('?', $_SERVER['REQUEST_URI']);
$path = $parts[0];
if ($basePath != '/')
{
$path = str_replace($basePath, '', $path);
}
$crumbs = explode('/', $path);
foreach ($crumbs as $key => $val)
{
if (is_numeric($val))
{
unset($crumbs[$key]);
}
}
$crumbs = array_values($crumbs);
for ($i=0; $i<count($crumbs); $i++) {
$crumb = trim($crumbs[$i]);
if (!$crumb) continue;
if ($crumb == 'company') return '';
$name = trans("texts.$crumb");
if ($i==count($crumbs)-1)
{
$str .= "<li class='active'>$name</li>";
}
else
{
$str .= '<li>'.link_to($crumb, $name).'</li>';
}
}
return $str . '</ol>';
});
function uctrans($text)
{
return ucwords(trans($text));
}
2014-02-03 12:34:58 +02:00
if (Auth::check() && !Session::has(SESSION_TIMEZONE))
{
2014-01-01 17:23:32 +02:00
Event::fire('user.refresh');
2014-01-14 11:52:56 +00:00
}
Validator::extend('positive', function($attribute, $value, $parameters)
{
return Utils::parseFloat($value) > 0;
2014-01-16 21:12:46 +00:00
});
Validator::extend('has_credit', function($attribute, $value, $parameters)
{
$publicClientId = $parameters[0];
$amount = $parameters[1];
$client = Client::scope($publicClientId)->firstOrFail();
$credit = $client->getTotalCredit();
2014-04-18 11:57:31 +03:00
return $credit >= $amount;
2014-03-19 20:54:27 +02:00
});
/*
Event::listen('illuminate.query', function($query, $bindings, $time, $name)
{
$data = compact('bindings', 'time', 'name');
// Format binding data for sql insertion
foreach ($bindings as $i => $binding)
{
if ($binding instanceof \DateTime)
{
$bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
}
else if (is_string($binding))
{
$bindings[$i] = "'$binding'";
}
}
// Insert bindings into query
$query = str_replace(array('%', '?'), array('%%', '%s'), $query);
$query = vsprintf($query, $bindings);
Log::info($query, $data);
});
2014-03-23 11:30:48 +02:00
*/
/*
if (Auth::check() && Auth::user()->id === 1)
{
Auth::loginUsingId(1);
}
2014-04-28 01:07:45 +03:00
*/
2014-07-27 23:31:41 +03:00