1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/app/routes.php

284 lines
9.3 KiB
PHP
Raw Normal View History

2013-11-26 13:45:07 +01: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 16:26:27 +01:00
//apc_clear_cache();
2014-01-30 23:29:09 +01:00
//Cache::flush();
2014-01-09 16:26:27 +01:00
2013-12-05 21:25:20 +01:00
//dd(DB::getQueryLog());
2013-12-04 17:20:14 +01:00
//dd(Client::getPrivateId(1));
2013-12-10 18:18:35 +01:00
//dd(new DateTime());
2013-12-15 13:55:50 +01:00
//Event::fire('user.signup');
2014-01-04 23:51:16 +01:00
//dd(App::environment());
2014-01-05 08:25:15 +01:00
//dd(gethostname());
2014-01-05 17:44:49 +01:00
//Log::error('test');
2014-01-16 22:12:46 +01:00
/*
2014-01-09 11:39:20 +01: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-01-16 22:12:46 +01:00
*/
2014-01-13 20:22:43 +01:00
2014-01-09 20:00:08 +01:00
/*
2013-12-10 23:10:43 +01:00
Route::get('/send_emails', function() {
Artisan::call('ninja:send-invoices');
});
2014-01-09 20:00:08 +01:00
*/
2014-02-19 21:36:09 +01:00
Route::get('/', 'HomeController@showWelcome');
2014-01-08 21:09:47 +01:00
Route::get('/rocksteady', 'HomeController@showWelcome');
2014-03-05 21:19:12 +01:00
Route::get('/about', 'HomeController@showAboutUs');
2014-03-11 18:37:54 +01:00
Route::get('/terms', 'HomeController@showTerms');
2014-03-05 21:19:12 +01:00
Route::get('/contact', 'HomeController@showContactUs');
Route::post('/contact', 'HomeController@doContactUs');
2014-01-08 21:09:47 +01:00
2014-01-02 14:21:15 +01:00
Route::get('log_error', 'HomeController@logError');
2013-11-26 13:45:07 +01:00
Route::post('get_started', 'AccountController@getStarted');
2014-02-02 19:14:56 +01:00
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');
2013-11-26 13:45:07 +01:00
2013-12-04 17:20:14 +01:00
Route::post('signup/validate', 'AccountController@checkEmail');
Route::post('signup/submit', 'AccountController@submitSignup');
2013-11-26 13:45:07 +01:00
2013-12-07 19:45:00 +01:00
// Confide routes
Route::get('login', 'UserController@login');
Route::post('login', 'UserController@do_login');
2014-01-09 20:00:08 +01:00
Route::get('user/confirm/{code}', 'UserController@confirm');
2013-12-07 19:45:00 +01:00
Route::get('forgot_password', 'UserController@forgot_password');
Route::post('forgot_password', 'UserController@do_forgot_password');
2014-01-09 20:00:08 +01:00
Route::get('user/reset/{token}', 'UserController@reset_password');
Route::post('user/reset', 'UserController@do_reset_password');
2013-12-07 19:45:00 +01:00
Route::get('logout', 'UserController@logout');
2013-12-03 18:32:33 +01:00
Route::group(array('before' => 'auth'), function()
2013-11-26 13:45:07 +01:00
{
2014-02-16 21:32:25 +01:00
Route::get('dashboard', 'DashboardController@index');
2014-02-18 22:56:18 +01:00
Route::get('view_archive/{entity_type}/{visible}', 'AccountController@setTrashVisible');
2013-12-26 01:36:34 +01:00
Route::get('account/getSearchData', array('as' => 'getSearchData', 'uses' => 'AccountController@getSearchData'));
2014-02-18 16:07:22 +01:00
Route::get('company/{section?}', 'AccountController@showSection');
Route::post('company/{section?}', 'AccountController@doSection');
2013-12-05 16:23:24 +01:00
Route::post('user/setTheme', 'UserController@setTheme');
2014-03-18 19:55:50 +01:00
Route::post('remove_logo', 'AccountController@removeLogo');
2013-12-05 16:23:24 +01:00
2013-11-26 13:45:07 +01:00
Route::resource('clients', 'ClientController');
Route::get('api/clients', array('as'=>'api.clients', 'uses'=>'ClientController@getDatatable'));
2013-12-01 21:58:25 +01:00
Route::get('api/activities/{client_id?}', array('as'=>'api.activities', 'uses'=>'ActivityController@getDatatable'));
2013-12-01 08:33:17 +01:00
Route::post('clients/bulk', 'ClientController@bulk');
2013-11-26 13:45:07 +01:00
2013-12-11 12:11:59 +01:00
Route::get('recurring_invoices', 'InvoiceController@recurringIndex');
Route::get('api/recurring_invoices/{client_id?}', array('as'=>'api.recurring_invoices', 'uses'=>'InvoiceController@getRecurringDatatable'));
2013-11-26 13:45:07 +01:00
Route::resource('invoices', 'InvoiceController');
2013-11-29 13:09:21 +01:00
Route::get('api/invoices/{client_id?}', array('as'=>'api.invoices', 'uses'=>'InvoiceController@getDatatable'));
2013-12-09 10:38:49 +01:00
Route::get('invoices/create/{client_id?}', 'InvoiceController@create');
2013-12-01 08:33:17 +01:00
Route::post('invoices/bulk', 'InvoiceController@bulk');
2013-11-26 13:45:07 +01:00
2013-12-05 21:25:20 +01:00
Route::get('payments/{id}/edit', function() { return View::make('header'); });
2013-12-04 17:20:14 +01:00
Route::resource('payments', 'PaymentController');
2014-01-02 14:21:15 +01:00
Route::get('payments/create/{client_id?}/{invoice_id?}', 'PaymentController@create');
2013-11-29 13:09:21 +01:00
Route::get('api/payments/{client_id?}', array('as'=>'api.payments', 'uses'=>'PaymentController@getDatatable'));
2013-12-01 08:33:17 +01:00
Route::post('payments/bulk', 'PaymentController@bulk');
2013-12-05 21:25:20 +01:00
Route::get('credits/{id}/edit', function() { return View::make('header'); });
2013-12-04 17:20:14 +01:00
Route::resource('credits', 'CreditController');
2014-01-02 14:21:15 +01:00
Route::get('credits/create/{client_id?}/{invoice_id?}', 'CreditController@create');
2013-12-01 21:58:25 +01:00
Route::get('api/credits/{client_id?}', array('as'=>'api.credits', 'uses'=>'CreditController@getDatatable'));
2013-12-15 13:55:50 +01:00
Route::post('credits/bulk', 'CreditController@bulk');
2013-12-05 21:25:20 +01:00
2013-12-16 22:27:32 +01:00
Route::get('reports', 'ReportController@report');
Route::post('reports', 'ReportController@report');
2013-11-26 13:45:07 +01:00
});
2013-11-29 13:09:21 +01:00
HTML::macro('nav_link', function($url, $text, $url2 = '', $extra = '') {
2013-11-26 13:45:07 +01:00
$class = ( Request::is($url) || Request::is($url.'/*') || Request::is($url2) ) ? ' class="active"' : '';
2013-11-29 13:09:21 +01:00
return '<li'.$class.'><a href="'.URL::to($url).'" '.$extra.'>'.$text.'</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>';
2013-11-26 13:45:07 +01:00
});
HTML::macro('menu_link', function($type) {
$types = $type.'s';
$Type = ucfirst($type);
$Types = ucfirst($types);
2013-12-10 23:10:43 +01:00
$class = ( Request::is($types) || Request::is('*'.$type.'*')) ? ' active' : '';
$str= '<li class="dropdown '.$class.'">
2013-11-26 13:45:07 +01:00
<a href="'.URL::to($types).'" class="dropdown-toggle">'.$Types.'</a>
<ul class="dropdown-menu" id="menu1">
2013-12-11 12:11:59 +01:00
<li><a href="'.URL::to($types.'/create').'">New '.$Type.'</a></li>';
//<li><a href="'.URL::to($types).'">View '.$Types.'</a></li>';
/*
2013-12-10 23:10:43 +01:00
if ($Type == 'Invoice') {
2013-12-11 12:11:59 +01:00
$str .= '<li><a href="'.URL::to('recurring_invoices').'">Recurring Invoices</a></li>';
2013-12-10 23:10:43 +01:00
}
2013-12-11 12:11:59 +01:00
*/
return $str . '</ul>
2013-11-26 13:45:07 +01:00
</li>';
});
HTML::macro('image_data', function($imagePath) {
return 'data:image/jpeg;base64,' . base64_encode(file_get_contents($imagePath));
});
2014-02-17 00:09:34 +01:00
HTML::macro('breadcrumbs', function() {
$str = '<ol class="breadcrumb">';
2014-02-20 15:42:09 +01:00
// Get the breadcrumbs by exploding the current path.
2014-03-18 21:43:12 +01:00
$basePath = Utils::basePath();
$path = $_SERVER['REQUEST_URI'];
if ($basePath != '/')
{
$path = str_replace($basePath, '', $path);
}
$crumbs = explode('/', $path);
2014-02-20 15:42:09 +01:00
foreach ($crumbs as $key => $val)
{
if (is_numeric($val))
{
unset($crumbs[$key]);
}
}
2014-03-18 21:43:12 +01:00
2014-02-25 12:52:40 +01:00
$crumbs = array_values($crumbs);
2014-02-17 00:09:34 +01:00
for ($i=0; $i<count($crumbs); $i++) {
$crumb = trim($crumbs[$i]);
if (!$crumb) continue;
2014-02-18 16:07:22 +01:00
if ($crumb == 'company') return '';
2014-02-17 00:09:34 +01:00
$name = ucwords($crumb);
if ($i==count($crumbs)-1)
{
$str .= "<li class='active'>$name</li>";
}
else
{
$str .= '<li>'.link_to($crumb, $name).'</li>';
}
}
return $str . '</ol>';
});
2014-01-07 16:52:47 +01:00
define('CONTACT_EMAIL', 'contact@invoiceninja.com');
2013-11-29 13:09:21 +01:00
2014-01-08 00:59:06 +01:00
define('ENV_DEVELOPMENT', 'local');
define('ENV_STAGING', 'staging');
2014-01-08 21:09:47 +01:00
define('ENV_PRODUCTION', 'fortrabbit');
2014-01-08 00:59:06 +01: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');
define('PERSON_CONTACT', 'contact');
define('PERSON_USER', 'user');
define('ACCOUNT_DETAILS', 'details');
2014-02-18 16:07:22 +01:00
define('ACCOUNT_NOTIFICATIONS', 'notifications');
define('ACCOUNT_IMPORT_EXPORT', 'import_export');
define('ACCOUNT_PAYMENTS', 'payments');
2014-01-08 00:59:06 +01:00
define('ACCOUNT_MAP', 'import_map');
define('ACCOUNT_EXPORT', 'export');
define('DEFAULT_INVOICE_NUMBER', '0001');
define('RECENTLY_VIEWED_LIMIT', 8);
define('LOGGED_ERROR_LIMIT', 100);
2014-01-13 20:22:43 +01:00
define('RANDOM_KEY_LENGTH', 32);
2014-02-20 15:31:46 +01:00
define('MAX_NUM_CLIENTS', 1000);
2013-12-01 21:58:25 +01:00
2013-12-07 19:45:00 +01:00
define('INVOICE_STATUS_DRAFT', 1);
define('INVOICE_STATUS_SENT', 2);
define('INVOICE_STATUS_VIEWED', 3);
define('INVOICE_STATUS_PARTIAL', 4);
2013-12-09 10:38:49 +01:00
define('INVOICE_STATUS_PAID', 5);
2014-01-16 22:12:46 +01:00
define('PAYMENT_TYPE_CREDIT', 1);
2013-12-09 10:38:49 +01: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 13:55:50 +01:00
define('FREQUENCY_ANNUALLY', 7);
define('SESSION_TIMEZONE', 'timezone');
2013-12-29 18:40:11 +01:00
define('SESSION_CURRENCY', 'currency');
2013-12-15 13:55:50 +01:00
define('SESSION_DATE_FORMAT', 'dateFormat');
2013-12-25 22:34:42 +01:00
define('SESSION_DATE_PICKER_FORMAT', 'datePickerFormat');
2013-12-15 13:55:50 +01:00
define('SESSION_DATETIME_FORMAT', 'datetimeFormat');
define('DEFAULT_TIMEZONE', 'US/Eastern');
2013-12-29 18:40:11 +01:00
define('DEFAULT_CURRENCY', 1); // US Dollar
2013-12-25 22:34:42 +01:00
define('DEFAULT_DATE_FORMAT', 'M j, Y');
2014-01-01 00:50:13 +01:00
define('DEFAULT_DATE_PICKER_FORMAT', 'M d, yyyy');
2013-12-15 13:55:50 +01:00
define('DEFAULT_DATETIME_FORMAT', 'F j, Y, g:i a');
2014-01-01 16:23:32 +01:00
define('DEFAULT_QUERY_CACHE', 120);
define('GATEWAY_PAYPAL_EXPRESS', 17);
2014-01-01 16:23:32 +01:00
2014-02-03 11:34:58 +01:00
if (Auth::check() && !Session::has(SESSION_TIMEZONE))
{
2014-01-01 16:23:32 +01:00
Event::fire('user.refresh');
2014-01-14 12:52:56 +01:00
}
Validator::extend('positive', function($attribute, $value, $parameters)
{
return Utils::parseFloat($value) > 0;
2014-01-16 22:12:46 +01:00
});
Validator::extend('has_credit', function($attribute, $value, $parameters)
{
$publicClientId = $parameters[0];
$amount = $parameters[1];
$client = Client::scope($publicClientId)->firstOrFail();
$credit = $client->getTotalCredit();
return $credit >= $amount;
2014-01-14 12:52:56 +01:00
});