diff --git a/app/Console/Commands/ChargeRenewalInvoices.php b/app/Console/Commands/ChargeRenewalInvoices.php index 1cc49942843e..870406a3af87 100644 --- a/app/Console/Commands/ChargeRenewalInvoices.php +++ b/app/Console/Commands/ChargeRenewalInvoices.php @@ -8,6 +8,7 @@ use App\Ninja\Mailers\ContactMailer as Mailer; use App\Ninja\Repositories\AccountRepository; use App\Services\PaymentService; use Illuminate\Console\Command; +use Carbon; /** * Class ChargeRenewalInvoices. @@ -83,6 +84,11 @@ class ChargeRenewalInvoices extends Command continue; } + if (Carbon::parse($company->plan_expires)->isFuture()) { + $this->info('Skipping invoice ' . $invoice->invoice_number . ' [plan not expired]'); + continue; + } + $this->info("Charging invoice {$invoice->invoice_number}"); if (! $this->paymentService->autoBillInvoice($invoice)) { $this->info('Failed to auto-bill, emailing invoice'); diff --git a/app/Console/Commands/CheckData.php b/app/Console/Commands/CheckData.php index de02d0d47094..5ed1f51de366 100644 --- a/app/Console/Commands/CheckData.php +++ b/app/Console/Commands/CheckData.php @@ -9,6 +9,8 @@ use Illuminate\Console\Command; use Mail; use Symfony\Component\Console\Input\InputOption; use Utils; +use App\Models\Contact; +use App\Models\Invitation; /* @@ -63,13 +65,15 @@ class CheckData extends Command $this->logMessage(date('Y-m-d') . ' Running CheckData...'); if (! $this->option('client_id')) { - $this->checkPaidToDate(); $this->checkBlankInvoiceHistory(); + $this->checkPaidToDate(); } $this->checkBalances(); + $this->checkContacts(); if (! $this->option('client_id')) { + $this->checkInvitations(); $this->checkFailedJobs(); $this->checkAccountData(); } @@ -94,6 +98,62 @@ class CheckData extends Command $this->log .= $str . "\n"; } + private function checkContacts() + { + $clients = DB::table('clients') + ->leftJoin('contacts', function($join) { + $join->on('contacts.client_id', '=', 'clients.id') + ->whereNull('contacts.deleted_at'); + }) + ->groupBy('clients.id', 'clients.user_id', 'clients.account_id') + ->havingRaw('count(contacts.id) = 0'); + + if ($this->option('client_id')) { + $clients->where('clients.id', '=', $this->option('client_id')); + } + + $clients = $clients->get(['clients.id', 'clients.user_id', 'clients.account_id']); + $this->logMessage(count($clients) . ' clients without any contacts'); + + if (count($clients) > 0) { + $this->isValid = false; + } + + if ($this->option('fix') == 'true') { + foreach ($clients as $client) { + $contact = new Contact(); + $contact->account_id = $client->account_id; + $contact->user_id = $client->user_id; + $contact->client_id = $client->id; + $contact->is_primary = true; + $contact->send_invoice = true; + $contact->contact_key = strtolower(str_random(RANDOM_KEY_LENGTH)); + $contact->public_id = Contact::whereAccountId($client->account_id)->withTrashed()->max('public_id') + 1; + $contact->save(); + } + } + + $clients = DB::table('clients') + ->leftJoin('contacts', function($join) { + $join->on('contacts.client_id', '=', 'clients.id') + ->where('contacts.is_primary', '=', true) + ->whereNull('contacts.deleted_at'); + }) + ->groupBy('clients.id') + ->havingRaw('count(contacts.id) != 1'); + + if ($this->option('client_id')) { + $clients->where('clients.id', '=', $this->option('client_id')); + } + + $clients = $clients->get(['clients.id', DB::raw('count(contacts.id)')]); + $this->logMessage(count($clients) . ' clients without a single primary contact'); + + if (count($clients) > 0) { + $this->isValid = false; + } + } + private function checkFailedJobs() { $count = DB::table('failed_jobs')->count(); @@ -120,6 +180,34 @@ class CheckData extends Command $this->logMessage($count . ' activities with blank invoice backup'); } + private function checkInvitations() + { + $invoices = DB::table('invoices') + ->leftJoin('invitations', 'invitations.invoice_id', '=', 'invoices.id') + ->groupBy('invoices.id', 'invoices.user_id', 'invoices.account_id', 'invoices.client_id') + ->havingRaw('count(invitations.id) = 0') + ->get(['invoices.id', 'invoices.user_id', 'invoices.account_id', 'invoices.client_id']); + + $this->logMessage(count($invoices) . ' invoices without any invitations'); + + if (count($invoices) > 0) { + $this->isValid = false; + } + + if ($this->option('fix') == 'true') { + foreach ($invoices as $invoice) { + $invitation = new Invitation(); + $invitation->account_id = $invoice->account_id; + $invitation->user_id = $invoice->user_id; + $invitation->invoice_id = $invoice->id; + $invitation->contact_id = Contact::whereClientId($invoice->client_id)->whereIsPrimary(true)->first()->id; + $invitation->invitation_key = strtolower(str_random(RANDOM_KEY_LENGTH)); + $invitation->public_id = Invitation::whereAccountId($invoice->account_id)->withTrashed()->max('public_id') + 1; + $invitation->save(); + } + } + } + private function checkAccountData() { $tables = [ @@ -159,6 +247,7 @@ class CheckData extends Command ], 'products' => [ ENTITY_USER, + ENTITY_TAX_RATE, ], 'vendors' => [ ENTITY_USER, @@ -173,14 +262,28 @@ class CheckData extends Command ENTITY_USER, ENTITY_CLIENT, ], + 'accounts' => [ + ENTITY_TAX_RATE, + ] ]; foreach ($tables as $table => $entityTypes) { foreach ($entityTypes as $entityType) { $tableName = Utils::pluralizeEntityType($entityType); + if ($entityType == ENTITY_TAX_RATE) { + $field = 'default_' . $entityType; + } else { + $field = $entityType; + } + if ($table == 'accounts') { + $accountId = 'id'; + } else { + $accountId = 'account_id'; + } + $records = DB::table($table) - ->join($tableName, "{$tableName}.id", '=', "{$table}.{$entityType}_id") - ->where("{$table}.account_id", '!=', DB::raw("{$tableName}.account_id")) + ->join($tableName, "{$tableName}.id", '=', "{$table}.{$field}_id") + ->where("{$table}.{$accountId}", '!=', DB::raw("{$tableName}.account_id")) ->get(["{$table}.id"]); if (count($records)) { diff --git a/app/Console/Commands/CreateLuisData.php b/app/Console/Commands/CreateLuisData.php new file mode 100644 index 000000000000..39a32bc74d54 --- /dev/null +++ b/app/Console/Commands/CreateLuisData.php @@ -0,0 +1,223 @@ +faker = Factory::create(); + } + + /** + * @return bool + */ + public function fire() + { + $this->fakerField = $this->argument('faker_field'); + + $intents = []; + $entityTypes = [ + ENTITY_INVOICE, + ENTITY_QUOTE, + ENTITY_CLIENT, + ENTITY_CREDIT, + ENTITY_EXPENSE, + ENTITY_PAYMENT, + ENTITY_PRODUCT, + ENTITY_RECURRING_INVOICE, + ENTITY_TASK, + ENTITY_VENDOR, + ]; + + foreach ($entityTypes as $entityType) { + $intents = array_merge($intents, $this->createIntents($entityType)); + } + + $intents = array_merge($intents, $this->getNavigateToIntents($entityType)); + + $this->info(json_encode($intents)); + } + + private function createIntents($entityType) + { + $intents = []; + + $intents = array_merge($intents, $this->getCreateEntityIntents($entityType)); + $intents = array_merge($intents, $this->getFindEntityIntents($entityType)); + $intents = array_merge($intents, $this->getListEntityIntents($entityType)); + + return $intents; + } + + private function getCreateEntityIntents($entityType) + { + $intents = []; + $phrases = [ + "create new {$entityType}", + "new {$entityType}", + "make a {$entityType}", + ]; + + foreach ($phrases as $phrase) { + $intents[] = $this->createIntent('CreateEntity', $phrase, [ + $entityType => 'EntityType', + ]); + if ($entityType != ENTITY_CLIENT) { + $client = $this->faker->{$this->fakerField}; + $phrase .= " for {$client}"; + $intents[] = $this->createIntent('CreateEntity', $phrase, [ + $entityType => 'EntityType', + $client => 'Name', + ]); + } + } + + return $intents; + } + + private function getFindEntityIntents($entityType) + { + $intents = []; + + if (in_array($entityType, [ENTITY_CLIENT, ENTITY_INVOICE, ENTITY_QUOTE])) { + $name = $entityType === ENTITY_CLIENT ? $this->faker->{$this->fakerField} : $this->faker->randomNumber(4); + $intents[] = $this->createIntent('FindEntity', "find {$entityType} {$name}", [ + $entityType => 'EntityType', + $name => 'Name', + ]); + if ($entityType === ENTITY_CLIENT) { + $name = $this->faker->{$this->fakerField}; + $intents[] = $this->createIntent('FindEntity', "find {$name}", [ + $name => 'Name', + ]); + } + } + + return $intents; + } + + private function getListEntityIntents($entityType) + { + $intents = []; + $entityTypePlural = Utils::pluralizeEntityType($entityType); + + $intents[] = $this->createIntent('ListEntity', "show me {$entityTypePlural}", [ + $entityTypePlural => 'EntityType', + ]); + $intents[] = $this->createIntent('ListEntity', "list {$entityTypePlural}", [ + $entityTypePlural => 'EntityType', + ]); + + $intents[] = $this->createIntent('ListEntity', "show me active {$entityTypePlural}", [ + $entityTypePlural => 'EntityType', + 'active' => 'Filter', + ]); + $intents[] = $this->createIntent('ListEntity', "list archived and deleted {$entityTypePlural}", [ + $entityTypePlural => 'EntityType', + 'archived' => 'Filter', + 'deleted' => 'Filter', + ]); + + if ($entityType != ENTITY_CLIENT) { + $client = $this->faker->{$this->fakerField}; + $intents[] = $this->createIntent('ListEntity', "list {$entityTypePlural} for {$client}", [ + $entityTypePlural => 'EntityType', + $client => 'Name', + ]); + $intents[] = $this->createIntent('ListEntity', "show me {$client}'s {$entityTypePlural}", [ + $entityTypePlural => 'EntityType', + $client . '\'s' => 'Name', + ]); + $intents[] = $this->createIntent('ListEntity', "show me {$client}'s active {$entityTypePlural}", [ + $entityTypePlural => 'EntityType', + $client . '\'s' => 'Name', + 'active' => 'Filter', + ]); + } + + return $intents; + } + + private function getNavigateToIntents($entityType) + { + $intents = []; + $locations = array_merge(Account::$basicSettings, Account::$advancedSettings); + + foreach ($locations as $location) { + $location = str_replace('_', ' ', $location); + $intents[] = $this->createIntent('NavigateTo', "go to {$location}", [ + $location => 'Location', + ]); + $intents[] = $this->createIntent('NavigateTo', "show me {$location}", [ + $location => 'Location', + ]); + } + + return $intents; + } + + private function createIntent($name, $text, $entities) + { + $intent = new stdClass(); + $intent->intent = $name; + $intent->text = $text; + $intent->entities = []; + + foreach ($entities as $value => $entity) { + $startPos = strpos($text, (string)$value); + if (! $startPos) { + dd("Failed to find {$value} in {$text}"); + } + $entityClass = new stdClass(); + $entityClass->entity = $entity; + $entityClass->startPos = $startPos; + $entityClass->endPos = $entityClass->startPos + strlen($value) - 1; + $intent->entities[] = $entityClass; + } + + return $intent; + } + + + /** + * @return array + */ + protected function getArguments() + { + return []; + } + + /** + * @return array + */ + protected function getOptions() + { + return []; + } +} diff --git a/app/Console/Commands/CreateTestData.php b/app/Console/Commands/CreateTestData.php index 1606e5eec5ec..ac046f3500c9 100644 --- a/app/Console/Commands/CreateTestData.php +++ b/app/Console/Commands/CreateTestData.php @@ -18,7 +18,6 @@ use Utils; */ class CreateTestData extends Command { - //protected $name = 'ninja:create-test-data'; /** * @var string */ @@ -126,6 +125,7 @@ class CreateTestData extends Command { for ($i = 0; $i < $this->count; $i++) { $data = [ + 'is_public' => true, 'client_id' => $client->id, 'invoice_date_sql' => date_create()->modify(rand(-100, 100) . ' days')->format('Y-m-d'), 'due_date_sql' => date_create()->modify(rand(-100, 100) . ' days')->format('Y-m-d'), diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 14b26d80f515..34938ea4c590 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -20,6 +20,7 @@ class Kernel extends ConsoleKernel 'App\Console\Commands\CheckData', 'App\Console\Commands\PruneData', 'App\Console\Commands\CreateTestData', + 'App\Console\Commands\CreateLuisData', 'App\Console\Commands\SendRenewalInvoices', 'App\Console\Commands\ChargeRenewalInvoices', 'App\Console\Commands\SendReminders', diff --git a/app/Constants.php b/app/Constants.php index 6fad1b3af634..732731686597 100644 --- a/app/Constants.php +++ b/app/Constants.php @@ -200,8 +200,11 @@ if (! defined('APP_NAME')) { define('TASK_STATUS_PAID', 4); define('EXPENSE_STATUS_LOGGED', 1); - define('EXPENSE_STATUS_INVOICED', 2); - define('EXPENSE_STATUS_PAID', 3); + define('EXPENSE_STATUS_PENDING', 2); + define('EXPENSE_STATUS_INVOICED', 3); + define('EXPENSE_STATUS_BILLED', 4); + define('EXPENSE_STATUS_PAID', 5); + define('EXPENSE_STATUS_UNPAID', 6); define('CUSTOM_DESIGN', 11); @@ -296,7 +299,7 @@ if (! defined('APP_NAME')) { define('NINJA_APP_URL', env('NINJA_APP_URL', 'https://app.invoiceninja.com')); define('NINJA_DOCS_URL', env('NINJA_DOCS_URL', 'http://docs.invoiceninja.com/en/latest')); define('NINJA_DATE', '2000-01-01'); - define('NINJA_VERSION', '3.2.1' . env('NINJA_VERSION_SUFFIX')); + define('NINJA_VERSION', '3.3.0' . env('NINJA_VERSION_SUFFIX')); define('SOCIAL_LINK_FACEBOOK', env('SOCIAL_LINK_FACEBOOK', 'https://www.facebook.com/invoiceninja')); define('SOCIAL_LINK_TWITTER', env('SOCIAL_LINK_TWITTER', 'https://twitter.com/invoiceninja')); @@ -306,6 +309,7 @@ if (! defined('APP_NAME')) { define('NINJA_CONTACT_URL', env('NINJA_CONTACT_URL', 'https://www.invoiceninja.com/contact/')); define('NINJA_FROM_EMAIL', env('NINJA_FROM_EMAIL', 'maildelivery@invoiceninja.com')); define('NINJA_IOS_APP_URL', 'https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=1220337560&mt=8'); + define('NINJA_ANDROID_APP_URL', 'https://play.google.com/store/apps/details?id=com.invoiceninja.invoiceninja'); define('RELEASES_URL', env('RELEASES_URL', 'https://trello.com/b/63BbiVVe/invoice-ninja')); define('ZAPIER_URL', env('ZAPIER_URL', 'https://zapier.com/zapbook/invoice-ninja')); define('OUTDATE_BROWSER_URL', env('OUTDATE_BROWSER_URL', 'http://browsehappy.com/')); @@ -317,6 +321,7 @@ if (! defined('APP_NAME')) { define('OFX_HOME_URL', env('OFX_HOME_URL', 'http://www.ofxhome.com/index.php/home/directory/all')); define('GOOGLE_ANALYITCS_URL', env('GOOGLE_ANALYITCS_URL', 'https://www.google-analytics.com/collect')); define('TRANSIFEX_URL', env('TRANSIFEX_URL', 'https://www.transifex.com/invoice-ninja/invoice-ninja')); + define('IP_LOOKUP_URL', env('IP_LOOKUP_URL', 'http://whatismyipaddress.com/ip/')); define('CHROME_PDF_HELP_URL', 'https://support.google.com/chrome/answer/6213030?hl=en'); define('FIREFOX_PDF_HELP_URL', 'https://support.mozilla.org/en-US/kb/view-pdf-files-firefox'); @@ -441,7 +446,7 @@ if (! defined('APP_NAME')) { define('CURRENCY_DECORATOR_NONE', 'none'); define('RESELLER_REVENUE_SHARE', 'A'); - define('RESELLER_LIMITED_USERS', 'B'); + define('RESELLER_ACCOUNT_COUNT', 'B'); define('AUTO_BILL_OFF', 1); define('AUTO_BILL_OPT_IN', 2); diff --git a/app/Events/InvoiceItemsWereCreated.php b/app/Events/InvoiceItemsWereCreated.php new file mode 100644 index 000000000000..45b010f56f6e --- /dev/null +++ b/app/Events/InvoiceItemsWereCreated.php @@ -0,0 +1,29 @@ +invoice = $invoice; + } +} diff --git a/app/Events/InvoiceItemsWereUpdated.php b/app/Events/InvoiceItemsWereUpdated.php new file mode 100644 index 000000000000..6a641e512386 --- /dev/null +++ b/app/Events/InvoiceItemsWereUpdated.php @@ -0,0 +1,29 @@ +invoice = $invoice; + } +} diff --git a/app/Events/InvoiceWasEmailed.php b/app/Events/InvoiceWasEmailed.php index 7083022512e5..db704915dd5b 100644 --- a/app/Events/InvoiceWasEmailed.php +++ b/app/Events/InvoiceWasEmailed.php @@ -17,13 +17,19 @@ class InvoiceWasEmailed extends Event */ public $invoice; + /** + * @var string + */ + public $notes; + /** * Create a new event instance. * * @param Invoice $invoice */ - public function __construct(Invoice $invoice) + public function __construct(Invoice $invoice, $notes) { $this->invoice = $invoice; + $this->notes = $notes; } } diff --git a/app/Events/QuoteItemsWereCreated.php b/app/Events/QuoteItemsWereCreated.php new file mode 100644 index 000000000000..6cee03a1580f --- /dev/null +++ b/app/Events/QuoteItemsWereCreated.php @@ -0,0 +1,24 @@ +quote = $quote; + } +} diff --git a/app/Events/QuoteItemsWereUpdated.php b/app/Events/QuoteItemsWereUpdated.php new file mode 100644 index 000000000000..1f7b88a3580a --- /dev/null +++ b/app/Events/QuoteItemsWereUpdated.php @@ -0,0 +1,24 @@ +quote = $quote; + } +} diff --git a/app/Events/QuoteWasEmailed.php b/app/Events/QuoteWasEmailed.php index e52714ddaa91..b5b2cc8cce99 100644 --- a/app/Events/QuoteWasEmailed.php +++ b/app/Events/QuoteWasEmailed.php @@ -12,13 +12,19 @@ class QuoteWasEmailed extends Event use SerializesModels; public $quote; + /** + * @var string + */ + public $notes; + /** * Create a new event instance. * * @param $quote */ - public function __construct($quote) + public function __construct($quote, $notes) { $this->quote = $quote; + $this->notes = $notes; } } diff --git a/app/Http/Controllers/AccountApiController.php b/app/Http/Controllers/AccountApiController.php index cc20a725c211..f73a7d2b7cff 100644 --- a/app/Http/Controllers/AccountApiController.php +++ b/app/Http/Controllers/AccountApiController.php @@ -78,7 +78,7 @@ class AccountApiController extends BaseAPIController $updatedAt = $request->updated_at ? date('Y-m-d H:i:s', $request->updated_at) : false; $transformer = new AccountTransformer(null, $request->serializer); - $account->load(array_merge($transformer->getDefaultIncludes(), ['projects.client'])); + $account->load(array_merge($transformer->getDefaultIncludes(), ['projects.client', 'products.default_tax_rate'])); $account = $this->createItem($account, $transformer, 'account'); return $this->response($account); diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index e7e04b15921d..15236634a71a 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -546,6 +546,7 @@ class AccountController extends BaseController $client->postal_code = '10000'; $client->work_phone = '(212) 555-0000'; $client->work_email = 'sample@example.com'; + $client->balance = 100; $invoice->invoice_number = '0000'; $invoice->invoice_date = Utils::fromSqlDate(date('Y-m-d')); @@ -892,6 +893,8 @@ class AccountController extends BaseController $account->custom_value2 = trim(Input::get('custom_value2')); $account->custom_client_label1 = trim(Input::get('custom_client_label1')); $account->custom_client_label2 = trim(Input::get('custom_client_label2')); + $account->custom_contact_label1 = trim(Input::get('custom_contact_label1')); + $account->custom_contact_label2 = trim(Input::get('custom_contact_label2')); $account->custom_invoice_label1 = trim(Input::get('custom_invoice_label1')); $account->custom_invoice_label2 = trim(Input::get('custom_invoice_label2')); $account->custom_invoice_taxes1 = Input::get('custom_invoice_taxes1') ? true : false; @@ -1016,13 +1019,9 @@ class AccountController extends BaseController /* Logo image file */ if ($uploaded = Input::file('logo')) { $path = Input::file('logo')->getRealPath(); - $disk = $account->getLogoDisk(); - if ($account->hasLogo() && ! Utils::isNinjaProd()) { - $disk->delete($account->logo); - } - $extension = strtolower($uploaded->getClientOriginalExtension()); + if (empty(Document::$types[$extension]) && ! empty(Document::$extraExtensions[$extension])) { $documentType = Document::$extraExtensions[$extension]; } else { @@ -1038,7 +1037,7 @@ class AccountController extends BaseController $size = filesize($filePath); if ($size / 1000 > MAX_DOCUMENT_SIZE) { - Session::flash('warning', trans('texts.logo_warning_too_large')); + Session::flash('error', trans('texts.logo_warning_too_large')); } else { if ($documentType != 'gif') { $account->logo = $account->account_key.'.'.$documentType; @@ -1055,24 +1054,25 @@ class AccountController extends BaseController $image->interlace(false); $imageStr = (string) $image->encode($documentType); $disk->put($account->logo, $imageStr); - $account->logo_size = strlen($imageStr); } else { - $stream = fopen($filePath, 'r'); - $disk->getDriver()->putStream($account->logo, $stream, ['mimetype' => $documentTypeData['mime']]); - fclose($stream); + if (Utils::isInterlaced($filePath)) { + $account->clearLogo(); + Session::flash('error', trans('texts.logo_warning_invalid')); + } else { + $stream = fopen($filePath, 'r'); + $disk->getDriver()->putStream($account->logo, $stream, ['mimetype' => $documentTypeData['mime']]); + fclose($stream); + } } } catch (Exception $exception) { - Session::flash('warning', trans('texts.logo_warning_invalid')); + $account->clearLogo(); + Session::flash('error', trans('texts.logo_warning_invalid')); } } else { if (extension_loaded('fileinfo')) { - $image = Image::make($path); - $image->resize(200, 120, function ($constraint) { - $constraint->aspectRatio(); - }); - $account->logo = $account->account_key.'.png'; + $image = Image::make($path); $image = Image::canvas($image->width(), $image->height(), '#FFFFFF')->insert($image); $imageStr = (string) $image->encode('png'); $disk->put($account->logo, $imageStr); @@ -1081,7 +1081,7 @@ class AccountController extends BaseController $account->logo_width = $image->width(); $account->logo_height = $image->height(); } else { - Session::flash('warning', trans('texts.logo_warning_fileinfo')); + Session::flash('error', trans('texts.logo_warning_fileinfo')); } } } diff --git a/app/Http/Controllers/AccountGatewayController.php b/app/Http/Controllers/AccountGatewayController.php index 44bbd40006ba..66b5fdc68b76 100644 --- a/app/Http/Controllers/AccountGatewayController.php +++ b/app/Http/Controllers/AccountGatewayController.php @@ -274,21 +274,21 @@ class AccountGatewayController extends BaseController } $plaidClientId = trim(Input::get('plaid_client_id')); - if ($plaidClientId = str_replace('*', '', $plaidClientId)) { + if (! $plaidClientId || $plaidClientId = str_replace('*', '', $plaidClientId)) { $config->plaidClientId = $plaidClientId; } elseif ($oldConfig && property_exists($oldConfig, 'plaidClientId')) { $config->plaidClientId = $oldConfig->plaidClientId; } $plaidSecret = trim(Input::get('plaid_secret')); - if ($plaidSecret = str_replace('*', '', $plaidSecret)) { + if (! $plaidSecret || $plaidSecret = str_replace('*', '', $plaidSecret)) { $config->plaidSecret = $plaidSecret; } elseif ($oldConfig && property_exists($oldConfig, 'plaidSecret')) { $config->plaidSecret = $oldConfig->plaidSecret; } $plaidPublicKey = trim(Input::get('plaid_public_key')); - if ($plaidPublicKey = str_replace('*', '', $plaidPublicKey)) { + if (! $plaidPublicKey || $plaidPublicKey = str_replace('*', '', $plaidPublicKey)) { $config->plaidPublicKey = $plaidPublicKey; } elseif ($oldConfig && property_exists($oldConfig, 'plaidPublicKey')) { $config->plaidPublicKey = $oldConfig->plaidPublicKey; diff --git a/app/Http/Controllers/AppController.php b/app/Http/Controllers/AppController.php index 13e96ae7443b..e269a7290fc5 100644 --- a/app/Http/Controllers/AppController.php +++ b/app/Http/Controllers/AppController.php @@ -83,10 +83,11 @@ class AppController extends BaseController $_ENV['APP_ENV'] = 'production'; $_ENV['APP_DEBUG'] = $app['debug']; - $_ENV['REQUIRE_HTTPS'] = $app['https']; + $_ENV['APP_LOCALE'] = 'en'; $_ENV['APP_URL'] = $app['url']; $_ENV['APP_KEY'] = $app['key']; $_ENV['APP_CIPHER'] = env('APP_CIPHER', 'AES-256-CBC'); + $_ENV['REQUIRE_HTTPS'] = $app['https']; $_ENV['DB_TYPE'] = $dbType; $_ENV['DB_HOST'] = $database['type']['host']; $_ENV['DB_DATABASE'] = $database['type']['database']; diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index efe471557917..0fb64d2d8ffd 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -118,7 +118,17 @@ class AuthController extends Controller public function getLoginWrapper() { if (! Utils::isNinja() && ! User::count()) { - return redirect()->to('invoice_now'); + return redirect()->to('/setup'); + } + + if (Utils::isNinja() && ! Utils::isTravis()) { + // make sure the user is on SITE_URL/login to ensure OAuth works + $requestURL = request()->url(); + $loginURL = SITE_URL . '/login'; + $subdomain = Utils::getSubdomain(request()->url()); + if ($requestURL != $loginURL && ! strstr($subdomain, 'webapp-')) { + return redirect()->to($loginURL); + } } return self::getLogin(); diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index 8a6beffcc81e..a9e4d9ae02b9 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -95,6 +95,9 @@ class ClientController extends BaseController if (Utils::hasFeature(FEATURE_QUOTES) && $user->can('create', ENTITY_QUOTE)) { $actionLinks[] = ['label' => trans('texts.new_quote'), 'url' => URL::to('/quotes/create/'.$client->public_id)]; } + if ($user->can('create', ENTITY_RECURRING_INVOICE)) { + $actionLinks[] = ['label' => trans('texts.new_recurring_invoice'), 'url' => URL::to('/recurring_invoices/create/'.$client->public_id)]; + } if (! empty($actionLinks)) { $actionLinks[] = \DropdownButton::DIVIDER; diff --git a/app/Http/Controllers/ClientPortalController.php b/app/Http/Controllers/ClientPortalController.php index 9800a1ed1651..b91794a199c1 100644 --- a/app/Http/Controllers/ClientPortalController.php +++ b/app/Http/Controllers/ClientPortalController.php @@ -651,7 +651,9 @@ class ClientPortalController extends BaseController $documents = $invoice->documents; foreach ($invoice->expenses as $expense) { - $documents = $documents->merge($expense->documents); + if ($expense->invoice_documents) { + $documents = $documents->merge($expense->documents); + } } $documents = $documents->sortBy('size'); @@ -740,7 +742,7 @@ class ClientPortalController extends BaseController $document = Document::scope($publicId, $invitation->account_id)->firstOrFail(); $authorized = false; - if ($document->expense && $document->expense->client_id == $invitation->invoice->client_id) { + if ($document->expense && $document->expense->invoice_documents && $document->expense->client_id == $invitation->invoice->client_id) { $authorized = true; } elseif ($document->invoice && $document->invoice->client_id == $invitation->invoice->client_id) { $authorized = true; diff --git a/app/Http/Controllers/ExpenseController.php b/app/Http/Controllers/ExpenseController.php index d0be38fc8491..39ef8de542fb 100644 --- a/app/Http/Controllers/ExpenseController.php +++ b/app/Http/Controllers/ExpenseController.php @@ -98,8 +98,6 @@ class ExpenseController extends BaseController { $expense = $request->entity(); - $expense->expense_date = Utils::fromSqlDate($expense->expense_date); - $actions = []; if ($expense->invoice) { $actions[] = ['url' => URL::to("invoices/{$expense->invoice->public_id}/edit"), 'label' => trans('texts.view_invoice')]; diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php index 9a8e54f59d17..bef47f2386a6 100644 --- a/app/Http/Controllers/ExportController.php +++ b/app/Http/Controllers/ExportController.php @@ -37,7 +37,7 @@ class ExportController extends BaseController // set the filename based on the entity types selected if ($request->include == 'all') { - $fileName = "invoice-ninja-{$date}"; + $fileName = "{$date}-invoiceninja"; } else { $fields = $request->all(); $fields = array_filter(array_map(function ($key) { @@ -47,7 +47,7 @@ class ExportController extends BaseController return null; } }, array_keys($fields), $fields)); - $fileName = 'invoice-ninja-' . implode('-', $fields) . "-{$date}"; + $fileName = $date. '-invoiceninja-' . implode('-', $fields); } if ($format === 'JSON') { diff --git a/app/Http/Controllers/ImportController.php b/app/Http/Controllers/ImportController.php index 49618a7abc72..30af4a6e02b4 100644 --- a/app/Http/Controllers/ImportController.php +++ b/app/Http/Controllers/ImportController.php @@ -34,16 +34,26 @@ class ImportController extends BaseController $fileName = $entityType; if ($request->hasFile($fileName)) { $file = $request->file($fileName); - $destinationPath = storage_path() . '/import'; + $destinationPath = env('FILE_IMPORT_PATH') ?: storage_path() . '/import'; $extension = $file->getClientOriginalExtension(); - if (! in_array($extension, ['csv', 'xls', 'xlsx', 'json'])) { - continue; + if ($source === IMPORT_CSV) { + if ($extension != 'csv') { + return redirect()->to('/settings/' . ACCOUNT_IMPORT_EXPORT)->withError(trans('texts.invalid_file')); + } + } elseif ($source === IMPORT_JSON) { + if ($extension != 'json') { + return redirect()->to('/settings/' . ACCOUNT_IMPORT_EXPORT)->withError(trans('texts.invalid_file')); + } + } else { + if (! in_array($extension, ['csv', 'xls', 'xlsx', 'json'])) { + return redirect()->to('/settings/' . ACCOUNT_IMPORT_EXPORT)->withError(trans('texts.invalid_file')); + } } $newFileName = sprintf('%s_%s_%s.%s', Auth::user()->account_id, $timestamp, $fileName, $extension); $file->move($destinationPath, $newFileName); - $files[$entityType] = $newFileName; + $files[$entityType] = $destinationPath . '/' . $newFileName; } } @@ -102,6 +112,7 @@ class ImportController extends BaseController $map = Input::get('map'); $headers = Input::get('headers'); $timestamp = Input::get('timestamp'); + if (config('queue.default') === 'sync') { $results = $this->importService->importCSV($map, $headers, $timestamp); $message = $this->importService->presentResults($results); diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index fea15293ab57..9fc99f4533ce 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -164,8 +164,9 @@ class InvoiceController extends BaseController foreach ($invoice->invitations as $invitation) { foreach ($client->contacts as $contact) { if ($invitation->contact_id == $contact->id) { + $hasPassword = $account->isClientPortalPasswordEnabled() && $contact->password; $contact->email_error = $invitation->email_error; - $contact->invitation_link = $invitation->getLink(); + $contact->invitation_link = $invitation->getLink('view', $hasPassword, $hasPassword); $contact->invitation_viewed = $invitation->viewed_date && $invitation->viewed_date != '0000-00-00 00:00:00' ? $invitation->viewed_date : false; $contact->invitation_openend = $invitation->opened_date && $invitation->opened_date != '0000-00-00 00:00:00' ? $invitation->opened_date : false; $contact->invitation_status = $contact->email_error ? false : $invitation->getStatus(); @@ -313,7 +314,7 @@ class InvoiceController extends BaseController 'recurringHelp' => $recurringHelp, 'recurringDueDateHelp' => $recurringDueDateHelp, 'invoiceLabels' => Auth::user()->account->getInvoiceLabels(), - 'tasks' => Session::get('tasks') ? json_encode(Session::get('tasks')) : null, + 'tasks' => Session::get('tasks') ? Session::get('tasks') : null, 'expenseCurrencyId' => Session::get('expenseCurrencyId') ?: null, 'expenses' => Session::get('expenses') ? Expense::scope(Session::get('expenses'))->with('documents', 'expense_category')->get() : [], ]; @@ -404,7 +405,8 @@ class InvoiceController extends BaseController if ($invoice->is_recurring) { $response = $this->emailRecurringInvoice($invoice); } else { - $this->dispatch(new SendInvoiceEmail($invoice, $reminder, $template)); + $userId = Auth::user()->id; + $this->dispatch(new SendInvoiceEmail($invoice, $userId, $reminder, $template)); $response = true; } @@ -436,7 +438,8 @@ class InvoiceController extends BaseController if ($invoice->isPaid()) { return true; } else { - $this->dispatch(new SendInvoiceEmail($invoice)); + $userId = Auth::user()->id; + $this->dispatch(new SendInvoiceEmail($invoice, $userId)); return true; } } diff --git a/app/Http/Controllers/OnlinePaymentController.php b/app/Http/Controllers/OnlinePaymentController.php index 399e73cdeb6a..163eaf30ca08 100644 --- a/app/Http/Controllers/OnlinePaymentController.php +++ b/app/Http/Controllers/OnlinePaymentController.php @@ -334,12 +334,14 @@ class OnlinePaymentController extends BaseController 'custom_value1' => Input::get('custom_client1'), 'custom_value2' => Input::get('custom_client2'), ]; + if (request()->currency_code) { + $data['currency_code'] = request()->currency_code; + } $client = $clientRepo->save($data, $client); } $data = [ 'client_id' => $client->id, - 'is_public' => true, 'is_recurring' => filter_var(Input::get('is_recurring'), FILTER_VALIDATE_BOOLEAN), 'frequency_id' => Input::get('frequency_id'), 'auto_bill_id' => Input::get('auto_bill_id'), diff --git a/app/Http/Controllers/ProjectApiController.php b/app/Http/Controllers/ProjectApiController.php new file mode 100644 index 000000000000..8f2708a9d2ee --- /dev/null +++ b/app/Http/Controllers/ProjectApiController.php @@ -0,0 +1,223 @@ +projectRepo = $projectRepo; + $this->projectService = $projectService; + } + + /** + * @SWG\Get( + * path="/projects", + * summary="List projects", + * operationId="listProjects", + * tags={"project"}, + * @SWG\Response( + * response=200, + * description="A list of projects", + * @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/Project")) + * ), + * @SWG\Response( + * response="default", + * description="an ""unexpected"" error" + * ) + * ) + */ + + public function index() + { + $projects = Project::scope() + ->withTrashed() + ->orderBy('created_at', 'desc'); + + return $this->listResponse($projects); + } + + + /** + * @SWG\Get( + * path="/projects/{project_id}", + * summary="Retrieve a project", + * operationId="getProject", + * tags={"project"}, + * @SWG\Parameter( + * in="path", + * name="project_id", + * type="integer", + * required=true + * ), + * @SWG\Response( + * response=200, + * description="A single project", + * @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Project")) + * ), + * @SWG\Response( + * response="default", + * description="an ""unexpected"" error" + * ) + * ) + */ + + public function show(ProjectRequest $request) + { + return $this->itemResponse($request->entity()); + } + + /** + * @SWG\Post( + * path="/projects", + * summary="Create a project", + * operationId="createProject", + * tags={"project"}, + * @SWG\Parameter( + * in="body", + * name="body", + * @SWG\Schema(ref="#/definitions/project") + * ), + * @SWG\Response( + * response=200, + * description="New project", + * @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/project")) + * ), + * @SWG\Response( + * response="default", + * description="an ""unexpected"" error" + * ) + * ) + */ + + public function store(CreateProjectRequest $request) + { + $project = $this->projectService->save($request->input()); + + return $this->itemResponse($project); + } + + + /** + * @SWG\Put( + * path="/projects/{project_id}", + * summary="Update a project", + * operationId="updateProject", + * tags={"project"}, + * @SWG\Parameter( + * in="path", + * name="project_id", + * type="integer", + * required=true + * ), + * @SWG\Parameter( + * in="body", + * name="project", + * @SWG\Schema(ref="#/definitions/project") + * ), + * @SWG\Response( + * response=200, + * description="Updated project", + * @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/project")) + * ), + * @SWG\Response( + * response="default", + * description="an ""unexpected"" error" + * ) + * ) + * + * @param mixed $publicId + */ + + public function update(UpdateProjectRequest $request, $publicId) + { + if ($request->action) { + return $this->handleAction($request); + } + + $data = $request->input(); + $data['public_id'] = $publicId; + $project = $this->projectService->save($request->input(), $request->entity()); + + return $this->itemResponse($project); + } + + + /** + * @SWG\Delete( + * path="/projects/{project_id}", + * summary="Delete a project", + * operationId="deleteProject", + * tags={"project"}, + * @SWG\Parameter( + * in="path", + * name="project_id", + * type="integer", + * required=true + * ), + * @SWG\Response( + * response=200, + * description="Deleted project", + * @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/project")) + * ), + * @SWG\Response( + * response="default", + * description="an ""unexpected"" error" + * ) + * ) + * + */ + + public function destroy(UpdateProjectRequest $request) + { + $project = $request->entity(); + + $this->projectRepo->delete($project); + + return $this->itemResponse($project); + } + + +} diff --git a/app/Http/Controllers/QuoteController.php b/app/Http/Controllers/QuoteController.php index c02e54672daa..0e154c5e0ec6 100644 --- a/app/Http/Controllers/QuoteController.php +++ b/app/Http/Controllers/QuoteController.php @@ -98,7 +98,7 @@ class QuoteController extends BaseController return [ 'entityType' => ENTITY_QUOTE, 'account' => $account, - 'products' => Product::scope()->orderBy('id')->get(['product_key', 'notes', 'cost', 'qty']), + 'products' => Product::scope()->with('default_tax_rate')->orderBy('product_key')->get(), 'taxRateOptions' => $account->present()->taxRateOptions, 'defaultTax' => $account->default_tax_rate, 'countries' => Cache::get('countries'), diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index 6e2f43a59306..354b6b00f286 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -27,7 +27,7 @@ class ReportController extends BaseController ->with(['clients.invoices.invoice_items', 'clients.contacts']) ->first(); $account = $account->hideFieldsForViz(); - $clients = $account->clients->toJson(); + $clients = $account->clients; } elseif (file_exists($fileName)) { $clients = file_get_contents($fileName); $message = trans('texts.sample_data'); @@ -129,11 +129,14 @@ class ReportController extends BaseController } $output = fopen('php://output', 'w') or Utils::fatalError(); - $reportType = trans("texts.{$reportType}s"); $date = date('Y-m-d'); + $columns = array_map(function($key, $val) { + return is_array($val) ? $key : $val; + }, array_keys($columns), $columns); + header('Content-Type:application/csv'); - header("Content-Disposition:attachment;filename={$date}_Ninja_{$reportType}.csv"); + header("Content-Disposition:attachment;filename={$date}-invoiceninja-{$reportType}-report.csv"); Utils::exportData($output, $data, Utils::trans($columns)); diff --git a/app/Http/Controllers/VendorController.php b/app/Http/Controllers/VendorController.php index e89c0028f738..828cb9f542ba 100644 --- a/app/Http/Controllers/VendorController.php +++ b/app/Http/Controllers/VendorController.php @@ -152,7 +152,6 @@ class VendorController extends BaseController 'data' => Input::old('data'), 'account' => Auth::user()->account, 'currencies' => Cache::get('currencies'), - 'countries' => Cache::get('countries'), ]; } diff --git a/app/Http/Middleware/StartupCheck.php b/app/Http/Middleware/StartupCheck.php index 806d19b70723..a1aabd9f7b0e 100644 --- a/app/Http/Middleware/StartupCheck.php +++ b/app/Http/Middleware/StartupCheck.php @@ -135,33 +135,20 @@ class StartupCheck $url = (Utils::isNinjaDev() ? SITE_URL : NINJA_APP_URL) . "/claim_license?license_key={$licenseKey}&product_id={$productId}&get_date=true"; $data = trim(CurlUtils::get($url)); - if ($productId == PRODUCT_INVOICE_DESIGNS) { - if ($data = json_decode($data)) { - foreach ($data as $item) { - $design = new InvoiceDesign(); - $design->id = $item->id; - $design->name = $item->name; - $design->pdfmake = $item->pdfmake; - $design->save(); - } + if ($data == RESULT_FAILURE) { + Session::flash('error', trans('texts.invalid_white_label_license')); + } elseif ($data) { + $company = Auth::user()->account->company; + $company->plan_term = PLAN_TERM_YEARLY; + $company->plan_paid = $data; + $date = max(date_create($data), date_create($company->plan_expires)); + $company->plan_expires = $date->modify('+1 year')->format('Y-m-d'); + $company->plan = PLAN_WHITE_LABEL; + $company->save(); - Cache::forget('invoiceDesigns'); - Session::flash('message', trans('texts.bought_designs')); - } - } elseif ($productId == PRODUCT_WHITE_LABEL) { - if ($data && $data != RESULT_FAILURE) { - $company = Auth::user()->account->company; - $company->plan_term = PLAN_TERM_YEARLY; - $company->plan_paid = $data; - $date = max(date_create($data), date_create($company->plan_expires)); - $company->plan_expires = $date->modify('+1 year')->format('Y-m-d'); - $company->plan = PLAN_WHITE_LABEL; - $company->save(); - - Session::flash('message', trans('texts.bought_white_label')); - } else { - Session::flash('error', trans('texts.invalid_white_label_license')); - } + Session::flash('message', trans('texts.bought_white_label')); + } else { + Session::flash('error', trans('texts.white_label_license_error')); } } } diff --git a/app/Http/ViewComposers/ClientPortalHeaderComposer.php b/app/Http/ViewComposers/ClientPortalHeaderComposer.php index a7a799150d59..f74e4903801f 100644 --- a/app/Http/ViewComposers/ClientPortalHeaderComposer.php +++ b/app/Http/ViewComposers/ClientPortalHeaderComposer.php @@ -2,8 +2,8 @@ namespace App\Http\ViewComposers; -use App\Models\Contact; use DB; +use App\Models\Contact; use Illuminate\View\View; /** @@ -37,6 +37,7 @@ class ClientPortalHeaderComposer } $client = $contact->client; + $account = $contact->account; $hasDocuments = DB::table('invoices') ->where('invoices.client_id', '=', $client->id) @@ -44,8 +45,18 @@ class ClientPortalHeaderComposer ->join('documents', 'documents.invoice_id', '=', 'invoices.id') ->count(); + $hasPaymentMethods = false; + if ($account->getTokenGatewayId() && ! $account->enable_client_portal_dashboard) { + $hasPaymentMethods = DB::table('payment_methods') + ->where('contacts.client_id', '=', $client->id) + ->whereNull('payment_methods.deleted_at') + ->join('contacts', 'contacts.id', '=', 'payment_methods.contact_id') + ->count(); + } + $view->with('hasQuotes', $client->publicQuotes->count()); $view->with('hasCredits', $client->creditsWithBalance->count()); $view->with('hasDocuments', $hasDocuments); + $view->with('hasPaymentMethods', $hasPaymentMethods); } } diff --git a/app/Http/routes.php b/app/Http/routes.php index 614954aa3d02..8506828fee72 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -319,6 +319,7 @@ Route::group(['middleware' => 'api', 'prefix' => 'api/v1'], function () { Route::post('email_invoice', 'InvoiceApiController@emailInvoice'); Route::get('user_accounts', 'AccountApiController@getUserAccounts'); Route::resource('products', 'ProductApiController'); + Route::resource('projects', 'ProjectApiController'); Route::resource('tax_rates', 'TaxRateApiController'); Route::resource('users', 'UserApiController'); Route::resource('expenses', 'ExpenseApiController'); diff --git a/app/Jobs/ImportData.php b/app/Jobs/ImportData.php index b4d16a6f01b2..31271c49e075 100644 --- a/app/Jobs/ImportData.php +++ b/app/Jobs/ImportData.php @@ -8,6 +8,7 @@ use Illuminate\Queue\SerializesModels; use Monolog\Logger; use App\Services\ImportService; use App\Ninja\Mailers\UserMailer; +use App\Models\User; use Auth; use App; @@ -39,7 +40,7 @@ class ImportData extends Job implements ShouldQueue * @param mixed $files * @param mixed $settings */ - public function __construct($user, $type, $settings) + public function __construct(User $user, $type, $settings) { $this->user = $user; $this->type = $type; diff --git a/app/Jobs/SendInvoiceEmail.php b/app/Jobs/SendInvoiceEmail.php index f37abac24e44..04168b609f8e 100644 --- a/app/Jobs/SendInvoiceEmail.php +++ b/app/Jobs/SendInvoiceEmail.php @@ -8,6 +8,8 @@ use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Monolog\Logger; +use Auth; +use App; /** * Class SendInvoiceEmail. @@ -31,6 +33,11 @@ class SendInvoiceEmail extends Job implements ShouldQueue */ protected $template; + /** + * @var int + */ + protected $userId; + /** * Create a new job instance. * @@ -39,9 +46,10 @@ class SendInvoiceEmail extends Job implements ShouldQueue * @param bool $reminder * @param mixed $pdfString */ - public function __construct(Invoice $invoice, $reminder = false, $template = false) + public function __construct(Invoice $invoice, $userId = false, $reminder = false, $template = false) { $this->invoice = $invoice; + $this->userId = $userId; $this->reminder = $reminder; $this->template = $template; } @@ -53,7 +61,16 @@ class SendInvoiceEmail extends Job implements ShouldQueue */ public function handle(ContactMailer $mailer) { + // send email as user + if (App::runningInConsole() && $this->userId) { + Auth::onceUsingId($this->userId); + } + $mailer->sendInvoice($this->invoice, $this->reminder, $this->template); + + if (App::runningInConsole() && $this->userId) { + Auth::logout(); + } } /* diff --git a/app/Jobs/SendNotificationEmail.php b/app/Jobs/SendNotificationEmail.php index bd8e893967dd..04fd4fd77c96 100644 --- a/app/Jobs/SendNotificationEmail.php +++ b/app/Jobs/SendNotificationEmail.php @@ -35,6 +35,11 @@ class SendNotificationEmail extends Job implements ShouldQueue */ protected $payment; + /** + * @var string + */ + protected $notes; + /** * Create a new job instance. @@ -46,12 +51,13 @@ class SendNotificationEmail extends Job implements ShouldQueue * @param mixed $type * @param mixed $payment */ - public function __construct($user, $invoice, $type, $payment) + public function __construct($user, $invoice, $type, $payment, $notes) { $this->user = $user; $this->invoice = $invoice; $this->type = $type; $this->payment = $payment; + $this->notes = $notes; } /** @@ -61,6 +67,6 @@ class SendNotificationEmail extends Job implements ShouldQueue */ public function handle(UserMailer $userMailer) { - $userMailer->sendNotification($this->user, $this->invoice, $this->type, $this->payment); + $userMailer->sendNotification($this->user, $this->invoice, $this->type, $this->payment, $this->notes); } } diff --git a/app/Libraries/HistoryUtils.php b/app/Libraries/HistoryUtils.php index 49a396474f4e..c886d68231f2 100644 --- a/app/Libraries/HistoryUtils.php +++ b/app/Libraries/HistoryUtils.php @@ -162,7 +162,7 @@ class HistoryUtils $icon = ''; if ($item->client_id) { $link = url('/clients/' . $item->client_id); - $name = $item->client_name; + $name = e($item->client_name); $buttonLink = url('/invoices/create/' . $item->client_id); $button = ' diff --git a/app/Libraries/Utils.php b/app/Libraries/Utils.php index 2dfb3366a67b..4d9cd1d70bdc 100644 --- a/app/Libraries/Utils.php +++ b/app/Libraries/Utils.php @@ -969,10 +969,11 @@ class Utils return $str; } - public static function getSubdomainPlaceholder() + public static function getSubdomain($url) { - $parts = parse_url(SITE_URL); + $parts = parse_url($url); $subdomain = ''; + if (isset($parts['host'])) { $host = explode('.', $parts['host']); if (count($host) > 2) { @@ -983,6 +984,11 @@ class Utils return $subdomain; } + public static function getSubdomainPlaceholder() + { + return static::getSubdomain(SITE_URL); + } + public static function getDomainPlaceholder() { $parts = parse_url(SITE_URL); @@ -1234,4 +1240,13 @@ class Utils { return strlen($string) > $length ? rtrim(substr($string, 0, $length)) . '...' : $string; } + + // http://stackoverflow.com/a/14238078/497368 + public static function isInterlaced($filename) + { + $handle = fopen($filename, 'r'); + $contents = fread($handle, 32); + fclose($handle); + return( ord($contents[28]) != 0 ); + } } diff --git a/app/Listeners/ActivityListener.php b/app/Listeners/ActivityListener.php index 59acdb457b98..d43ba83beaf0 100644 --- a/app/Listeners/ActivityListener.php +++ b/app/Listeners/ActivityListener.php @@ -392,7 +392,9 @@ class ActivityListener $event->payment, ACTIVITY_TYPE_CREATE_PAYMENT, $event->payment->amount * -1, - $event->payment->amount + $event->payment->amount, + false, + \App::runningInConsole() ? 'auto_billed' : '' ); } diff --git a/app/Listeners/HandleUserLoggedIn.php b/app/Listeners/HandleUserLoggedIn.php index 52eca07bd28c..6414ea62758f 100644 --- a/app/Listeners/HandleUserLoggedIn.php +++ b/app/Listeners/HandleUserLoggedIn.php @@ -56,8 +56,10 @@ class HandleUserLoggedIn $account->loadLocalizationSettings(); - if (strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') || strpos($_SERVER['HTTP_USER_AGENT'], 'iPad')) { + if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) { Session::flash('warning', trans('texts.iphone_app_message', ['link' => link_to(NINJA_IOS_APP_URL, trans('texts.iphone_app'))])); + } elseif (strstr($_SERVER['HTTP_USER_AGENT'], 'Android')) { + Session::flash('warning', trans('texts.iphone_app_message', ['link' => link_to(NINJA_ANDROID_APP_URL, trans('texts.android_app'))])); } // if they're using Stripe make sure they're using Stripe.js diff --git a/app/Listeners/NotificationListener.php b/app/Listeners/NotificationListener.php index ad94e5767a61..df6882d4e871 100644 --- a/app/Listeners/NotificationListener.php +++ b/app/Listeners/NotificationListener.php @@ -46,13 +46,13 @@ class NotificationListener * @param $type * @param null $payment */ - private function sendEmails($invoice, $type, $payment = null) + private function sendEmails($invoice, $type, $payment = null, $notes = false) { foreach ($invoice->account->users as $user) { if ($user->{"notify_{$type}"}) { - $this->userMailer->sendNotification($user, $invoice, $type, $payment); + dispatch(new SendNotificationEmail($user, $invoice, $type, $payment, $notes)); } } } @@ -62,7 +62,7 @@ class NotificationListener */ public function emailedInvoice(InvoiceWasEmailed $event) { - $this->sendEmails($event->invoice, 'sent'); + $this->sendEmails($event->invoice, 'sent', null, $event->notes); $this->pushService->sendNotification($event->invoice, 'sent'); } @@ -71,7 +71,7 @@ class NotificationListener */ public function emailedQuote(QuoteWasEmailed $event) { - $this->sendEmails($event->quote, 'sent'); + $this->sendEmails($event->quote, 'sent', null, $event->notes); $this->pushService->sendNotification($event->quote, 'sent'); } diff --git a/app/Listeners/SubscriptionListener.php b/app/Listeners/SubscriptionListener.php index e3e775911766..15fd543d5440 100644 --- a/app/Listeners/SubscriptionListener.php +++ b/app/Listeners/SubscriptionListener.php @@ -5,13 +5,13 @@ namespace App\Listeners; use App\Events\ClientWasCreated; use App\Events\CreditWasCreated; use App\Events\ExpenseWasCreated; -use App\Events\InvoiceWasCreated; +use App\Events\QuoteItemsWereCreated; +use App\Events\QuoteItemsWereUpdated; use App\Events\InvoiceWasDeleted; -use App\Events\InvoiceWasUpdated; use App\Events\PaymentWasCreated; -use App\Events\QuoteWasCreated; +use App\Events\InvoiceItemsWereCreated; +use App\Events\InvoiceItemsWereUpdated; use App\Events\QuoteWasDeleted; -use App\Events\QuoteWasUpdated; use App\Events\VendorWasCreated; use App\Models\EntityModel; use App\Ninja\Serializers\ArraySerializer; @@ -36,15 +36,6 @@ class SubscriptionListener $this->checkSubscriptions(EVENT_CREATE_CLIENT, $event->client, $transformer); } - /** - * @param QuoteWasCreated $event - */ - public function createdQuote(QuoteWasCreated $event) - { - $transformer = new InvoiceTransformer($event->quote->account); - $this->checkSubscriptions(EVENT_CREATE_QUOTE, $event->quote, $transformer, ENTITY_CLIENT); - } - /** * @param PaymentWasCreated $event */ @@ -54,15 +45,6 @@ class SubscriptionListener $this->checkSubscriptions(EVENT_CREATE_PAYMENT, $event->payment, $transformer, [ENTITY_CLIENT, ENTITY_INVOICE]); } - /** - * @param InvoiceWasCreated $event - */ - public function createdInvoice(InvoiceWasCreated $event) - { - $transformer = new InvoiceTransformer($event->invoice->account); - $this->checkSubscriptions(EVENT_CREATE_INVOICE, $event->invoice, $transformer, ENTITY_CLIENT); - } - /** * @param CreditWasCreated $event */ @@ -84,15 +66,42 @@ class SubscriptionListener { } + /** + * @param InvoiceWasCreated $event + */ + public function createdInvoice(InvoiceItemsWereCreated $event) + { + $transformer = new InvoiceTransformer($event->invoice->account); + $this->checkSubscriptions(EVENT_CREATE_INVOICE, $event->invoice, $transformer, ENTITY_CLIENT); + } + /** * @param InvoiceWasUpdated $event */ - public function updatedInvoice(InvoiceWasUpdated $event) + public function updatedInvoice(InvoiceItemsWereUpdated $event) { $transformer = new InvoiceTransformer($event->invoice->account); $this->checkSubscriptions(EVENT_UPDATE_INVOICE, $event->invoice, $transformer, ENTITY_CLIENT); } + /** + * @param QuoteWasCreated $event + */ + public function createdQuote(QuoteItemsWereCreated $event) + { + $transformer = new InvoiceTransformer($event->quote->account); + $this->checkSubscriptions(EVENT_CREATE_QUOTE, $event->quote, $transformer, ENTITY_CLIENT); + } + + /** + * @param QuoteWasUpdated $event + */ + public function updatedQuote(QuoteItemsWereUpdated $event) + { + $transformer = new InvoiceTransformer($event->quote->account); + $this->checkSubscriptions(EVENT_UPDATE_QUOTE, $event->quote, $transformer, ENTITY_CLIENT); + } + /** * @param InvoiceWasDeleted $event */ @@ -102,15 +111,6 @@ class SubscriptionListener $this->checkSubscriptions(EVENT_DELETE_INVOICE, $event->invoice, $transformer, ENTITY_CLIENT); } - /** - * @param QuoteWasUpdated $event - */ - public function updatedQuote(QuoteWasUpdated $event) - { - $transformer = new InvoiceTransformer($event->quote->account); - $this->checkSubscriptions(EVENT_UPDATE_QUOTE, $event->quote, $transformer, ENTITY_CLIENT); - } - /** * @param InvoiceWasDeleted $event */ diff --git a/app/Models/Account.php b/app/Models/Account.php index 0657ac3766d6..42e427a23936 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -7,13 +7,13 @@ use App\Events\UserSettingsChanged; use App\Models\Traits\GeneratesNumbers; use App\Models\Traits\PresentsInvoice; use App\Models\Traits\SendsEmails; +use App\Models\Traits\HasLogo; use Cache; use Carbon; use DateTime; use Eloquent; use Event; use Illuminate\Database\Eloquent\SoftDeletes; -use Illuminate\Support\Facades\Storage; use Laracasts\Presenter\PresentableTrait; use Session; use Utils; @@ -28,6 +28,7 @@ class Account extends Eloquent use PresentsInvoice; use GeneratesNumbers; use SendsEmails; + use HasLogo; /** * @var string @@ -161,6 +162,8 @@ class Account extends Eloquent 'payment_type_id', 'gateway_fee_enabled', 'reset_counter_date', + 'custom_contact_label1', + 'custom_contact_label2', 'domain_id', ]; @@ -370,6 +373,14 @@ class Account extends Eloquent return $this->belongsTo('App\Models\TaxRate'); } + /** + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function payment_type() + { + return $this->belongsTo('App\Models\PaymentType'); + } + /** * @return mixed */ @@ -826,101 +837,6 @@ class Account extends Eloquent return false; } - /** - * @return bool - */ - public function hasLogo() - { - return ! empty($this->logo); - } - - /** - * @return mixed - */ - public function getLogoDisk() - { - return Storage::disk(env('LOGO_FILESYSTEM', 'logos')); - } - - protected function calculateLogoDetails() - { - $disk = $this->getLogoDisk(); - - if ($disk->exists($this->account_key.'.png')) { - $this->logo = $this->account_key.'.png'; - } elseif ($disk->exists($this->account_key.'.jpg')) { - $this->logo = $this->account_key.'.jpg'; - } - - if (! empty($this->logo)) { - $image = imagecreatefromstring($disk->get($this->logo)); - $this->logo_width = imagesx($image); - $this->logo_height = imagesy($image); - $this->logo_size = $disk->size($this->logo); - } else { - $this->logo = null; - } - $this->save(); - } - - /** - * @return null - */ - public function getLogoRaw() - { - if (! $this->hasLogo()) { - return null; - } - - $disk = $this->getLogoDisk(); - - return $disk->get($this->logo); - } - - /** - * @param bool $cachebuster - * - * @return null|string - */ - public function getLogoURL($cachebuster = false) - { - if (! $this->hasLogo()) { - return null; - } - - $disk = $this->getLogoDisk(); - $adapter = $disk->getAdapter(); - - if ($adapter instanceof \League\Flysystem\Adapter\Local) { - // Stored locally - $logoUrl = url('/logo/' . $this->logo); - - if ($cachebuster) { - $logoUrl .= '?no_cache='.time(); - } - - return $logoUrl; - } - - return Document::getDirectFileUrl($this->logo, $this->getLogoDisk()); - } - - public function getLogoPath() - { - if (! $this->hasLogo()) { - return null; - } - - $disk = $this->getLogoDisk(); - $adapter = $disk->getAdapter(); - - if ($adapter instanceof \League\Flysystem\Adapter\Local) { - return $adapter->applyPathPrefix($this->logo); - } else { - return Document::getDirectFileUrl($this->logo, $this->getLogoDisk()); - } - } - /** * @return mixed */ @@ -948,30 +864,6 @@ class Account extends Eloquent return null; } - /** - * @return mixed|null - */ - public function getLogoWidth() - { - if (! $this->hasLogo()) { - return null; - } - - return $this->logo_width; - } - - /** - * @return mixed|null - */ - public function getLogoHeight() - { - if (! $this->hasLogo()) { - return null; - } - - return $this->logo_height; - } - /** * @param $entityType * @param null $clientId @@ -1338,26 +1230,6 @@ class Account extends Eloquent return Carbon::instance($date); } - /** - * @return float|null - */ - public function getLogoSize() - { - if (! $this->hasLogo()) { - return null; - } - - return round($this->logo_size / 1000); - } - - /** - * @return bool - */ - public function isLogoTooLarge() - { - return $this->getLogoSize() > MAX_LOGO_FILE_SIZE; - } - /** * @param $eventId * @@ -1776,6 +1648,11 @@ class Account extends Eloquent return $yearStart->format('Y-m-d'); } + + public function isClientPortalPasswordEnabled() + { + return $this->hasFeature(FEATURE_CLIENT_PORTAL_PASSWORD) && $this->enable_portal_password; + } } Account::updated(function ($account) { diff --git a/app/Models/Client.php b/app/Models/Client.php index 7f886fc96879..f264218e22de 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -294,7 +294,7 @@ class Client extends EntityModel } } - if (Utils::hasFeature(FEATURE_CLIENT_PORTAL_PASSWORD) && $this->account->enable_portal_password) { + if ($this->account->isClientPortalPasswordEnabled()) { if (! empty($data['password']) && $data['password'] != '-%unchanged%-') { $contact->password = bcrypt($data['password']); } elseif (empty($data['password'])) { diff --git a/app/Models/Contact.php b/app/Models/Contact.php index 087b1a356ac9..ef826e33792e 100644 --- a/app/Models/Contact.php +++ b/app/Models/Contact.php @@ -37,6 +37,8 @@ class Contact extends EntityModel implements AuthenticatableContract, CanResetPa 'email', 'phone', 'send_invoice', + 'custom_value1', + 'custom_value2', ]; /** diff --git a/app/Models/Expense.php b/app/Models/Expense.php index 109c461b5d8a..3004e2efa75e 100644 --- a/app/Models/Expense.php +++ b/app/Models/Expense.php @@ -47,6 +47,10 @@ class Expense extends EntityModel 'tax_name1', 'tax_rate2', 'tax_name2', + 'payment_date', + 'payment_type_id', + 'transaction_reference', + 'invoice_documents', ]; public static function getImportColumns() @@ -129,6 +133,14 @@ class Expense extends EntityModel return $this->hasMany('App\Models\Document')->orderBy('id'); } + /** + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function payment_type() + { + return $this->belongsTo('App\Models\PaymentType'); + } + /** * @return mixed */ @@ -175,6 +187,14 @@ class Expense extends EntityModel return $this->invoice_currency_id != $this->expense_currency_id || $this->exchange_rate != 1; } + /** + * @return bool + */ + public function isPaid() + { + return $this->payment_date || $this->payment_type_id; + } + /** * @return float */ @@ -221,19 +241,23 @@ class Expense extends EntityModel { $statuses = []; $statuses[EXPENSE_STATUS_LOGGED] = trans('texts.logged'); + $statuses[EXPENSE_STATUS_PENDING] = trans('texts.pending'); $statuses[EXPENSE_STATUS_INVOICED] = trans('texts.invoiced'); + $statuses[EXPENSE_STATUS_BILLED] = trans('texts.billed'); $statuses[EXPENSE_STATUS_PAID] = trans('texts.paid'); + $statuses[EXPENSE_STATUS_UNPAID] = trans('texts.unpaid'); + return $statuses; } - public static function calcStatusLabel($shouldBeInvoiced, $invoiceId, $balance) + public static function calcStatusLabel($shouldBeInvoiced, $invoiceId, $balance, $paymentDate) { if ($invoiceId) { if (floatval($balance) > 0) { $label = 'invoiced'; } else { - $label = 'paid'; + $label = 'billed'; } } elseif ($shouldBeInvoiced) { $label = 'pending'; @@ -241,7 +265,13 @@ class Expense extends EntityModel $label = 'logged'; } - return trans("texts.{$label}"); + $label = trans("texts.{$label}"); + + if ($paymentDate) { + $label = trans('texts.paid') . ' | ' . $label; + } + + return $label; } public static function calcStatusClass($shouldBeInvoiced, $invoiceId, $balance) @@ -270,7 +300,7 @@ class Expense extends EntityModel { $balance = $this->invoice ? $this->invoice->balance : 0; - return static::calcStatusLabel($this->should_be_invoiced, $this->invoice_id, $balance); + return static::calcStatusLabel($this->should_be_invoiced, $this->invoice_id, $balance, $this->payment_date); } } diff --git a/app/Models/Invitation.php b/app/Models/Invitation.php index 0e493bf204ea..7797eed651be 100644 --- a/app/Models/Invitation.php +++ b/app/Models/Invitation.php @@ -66,7 +66,7 @@ class Invitation extends EntityModel * * @return string */ - public function getLink($type = 'view', $forceOnsite = false) + public function getLink($type = 'view', $forceOnsite = false, $forcePlain = false) { if (! $this->account) { $this->load('account'); @@ -87,7 +87,7 @@ class Invitation extends EntityModel if ($iframe_url && ! $forceOnsite) { return "{$iframe_url}?{$this->invitation_key}"; - } elseif ($this->account->subdomain) { + } elseif ($this->account->subdomain && ! $forcePlain) { $url = Utils::replaceSubdomain($url, $account->subdomain); } } diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 36b40ede1d6d..edd6cce44d68 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -93,54 +93,23 @@ class Invoice extends EntityModel implements BalanceAffecting INVOICE_STATUS_PAID => 'success', ]; - /** - * @var string - */ - public static $fieldInvoiceNumber = 'invoice_number'; - /** - * @var string - */ - public static $fieldPONumber = 'po_number'; - /** - * @var string - */ - public static $fieldInvoiceDate = 'invoice_date'; - /** - * @var string - */ - public static $fieldDueDate = 'due_date'; - /** - * @var string - */ - public static $fieldAmount = 'amount'; - /** - * @var string - */ - public static $fieldPaid = 'paid'; - /** - * @var string - */ - public static $fieldNotes = 'notes'; - /** - * @var string - */ - public static $fieldTerms = 'terms'; - /** * @return array */ public static function getImportColumns() { return [ - Client::$fieldName, - self::$fieldInvoiceNumber, - self::$fieldPONumber, - self::$fieldInvoiceDate, - self::$fieldDueDate, - self::$fieldAmount, - self::$fieldPaid, - self::$fieldNotes, - self::$fieldTerms, + 'name', + 'invoice_number', + 'po_number', + 'invoice_date', + 'due_date', + 'amount', + 'paid', + 'notes', + 'terms', + 'product', + 'quantity', ]; } @@ -159,6 +128,8 @@ class Invoice extends EntityModel implements BalanceAffecting 'due date' => 'due_date', 'terms' => 'terms', 'notes' => 'notes', + 'product|item' => 'product', + 'quantity|qty' => 'quantity', ]; } @@ -930,6 +901,8 @@ class Invoice extends EntityModel implements BalanceAffecting 'last_name', 'email', 'phone', + 'custom_value1', + 'custom_value2', ]); } @@ -1439,6 +1412,22 @@ class Invoice extends EntityModel implements BalanceAffecting $taxes[$key]['paid'] += $paid; } + /** + * @return int + */ + public function countDocuments() + { + $count = count($this->documents); + + foreach ($this->expenses as $expense) { + if ($expense->invoice_documents) { + $count += count($expense->documents); + } + } + + return $count; + } + /** * @return bool */ @@ -1457,7 +1446,7 @@ class Invoice extends EntityModel implements BalanceAffecting public function hasExpenseDocuments() { foreach ($this->expenses as $expense) { - if (count($expense->documents)) { + if ($expense->invoice_documents && count($expense->documents)) { return true; } } diff --git a/app/Models/PaymentTerm.php b/app/Models/PaymentTerm.php index 899d239e29e4..c54e8c73f0ab 100644 --- a/app/Models/PaymentTerm.php +++ b/app/Models/PaymentTerm.php @@ -29,6 +29,11 @@ class PaymentTerm extends EntityModel return ENTITY_PAYMENT_TERM; } + public function getNumDays() + { + return $this->num_days == -1 ? 0 : $this->num_days; + } + public static function getSelectOptions() { $terms = Cache::get('paymentTerms'); @@ -37,6 +42,10 @@ class PaymentTerm extends EntityModel $terms->push($term); } + foreach ($terms as $term) { + $term->name = trans('texts.payment_terms_net') . ' ' . $term->getNumDays(); + } + return $terms->sortBy('num_days'); } } diff --git a/app/Models/Traits/HasLogo.php b/app/Models/Traits/HasLogo.php new file mode 100644 index 000000000000..6caf188ec009 --- /dev/null +++ b/app/Models/Traits/HasLogo.php @@ -0,0 +1,163 @@ +logo); + } + + /** + * @return mixed + */ + public function getLogoDisk() + { + return Storage::disk(env('LOGO_FILESYSTEM', 'logos')); + } + + protected function calculateLogoDetails() + { + $disk = $this->getLogoDisk(); + + if ($disk->exists($this->account_key.'.png')) { + $this->logo = $this->account_key.'.png'; + } elseif ($disk->exists($this->account_key.'.jpg')) { + $this->logo = $this->account_key.'.jpg'; + } + + if (! empty($this->logo)) { + $image = imagecreatefromstring($disk->get($this->logo)); + $this->logo_width = imagesx($image); + $this->logo_height = imagesy($image); + $this->logo_size = $disk->size($this->logo); + } else { + $this->logo = null; + } + $this->save(); + } + + /** + * @return null + */ + public function getLogoRaw() + { + if (! $this->hasLogo()) { + return null; + } + + $disk = $this->getLogoDisk(); + + if (! $disk->exists($this->logo)) { + return null; + } + + return $disk->get($this->logo); + } + + /** + * @param bool $cachebuster + * + * @return null|string + */ + public function getLogoURL($cachebuster = false) + { + if (! $this->hasLogo()) { + return null; + } + + $disk = $this->getLogoDisk(); + $adapter = $disk->getAdapter(); + + if ($adapter instanceof \League\Flysystem\Adapter\Local) { + // Stored locally + $logoUrl = url('/logo/' . $this->logo); + + if ($cachebuster) { + $logoUrl .= '?no_cache='.time(); + } + + return $logoUrl; + } + + return Document::getDirectFileUrl($this->logo, $this->getLogoDisk()); + } + + public function getLogoPath() + { + if (! $this->hasLogo()) { + return null; + } + + $disk = $this->getLogoDisk(); + $adapter = $disk->getAdapter(); + + if ($adapter instanceof \League\Flysystem\Adapter\Local) { + return $adapter->applyPathPrefix($this->logo); + } else { + return Document::getDirectFileUrl($this->logo, $this->getLogoDisk()); + } + } + + /** + * @return mixed|null + */ + public function getLogoWidth() + { + if (! $this->hasLogo()) { + return null; + } + + return $this->logo_width; + } + + /** + * @return mixed|null + */ + public function getLogoHeight() + { + if (! $this->hasLogo()) { + return null; + } + + return $this->logo_height; + } + + /** + * @return float|null + */ + public function getLogoSize() + { + if (! $this->hasLogo()) { + return null; + } + + return round($this->logo_size / 1000); + } + + /** + * @return bool + */ + public function isLogoTooLarge() + { + return $this->getLogoSize() > MAX_LOGO_FILE_SIZE; + } + + public function clearLogo() + { + $this->logo = ''; + $this->logo_width = 0; + $this->logo_height = 0; + $this->logo_size = 0; + } +} diff --git a/app/Models/Traits/PresentsInvoice.php b/app/Models/Traits/PresentsInvoice.php index 353506979ac2..073d2479c462 100644 --- a/app/Models/Traits/PresentsInvoice.php +++ b/app/Models/Traits/PresentsInvoice.php @@ -68,6 +68,12 @@ trait PresentsInvoice if ($this->custom_client_label2) { $fields[INVOICE_FIELDS_CLIENT][] = 'client.custom_value2'; } + if ($this->custom_contact_label1) { + $fields[INVOICE_FIELDS_CLIENT][] = 'contact.custom_value1'; + } + if ($this->custom_contact_label2) { + $fields[INVOICE_FIELDS_CLIENT][] = 'contact.custom_value2'; + } if ($this->custom_label1) { $fields['account_fields2'][] = 'account.custom_value1'; } @@ -86,8 +92,10 @@ trait PresentsInvoice 'invoice.po_number', 'invoice.invoice_date', 'invoice.due_date', + 'invoice.invoice_total', 'invoice.balance_due', 'invoice.partial_due', + 'invoice.outstanding', 'invoice.custom_text_value1', 'invoice.custom_text_value2', '.blank', @@ -108,6 +116,8 @@ trait PresentsInvoice 'client.phone', 'client.custom_value1', 'client.custom_value2', + 'contact.custom_value1', + 'contact.custom_value2', '.blank', ], INVOICE_FIELDS_ACCOUNT => [ @@ -227,6 +237,8 @@ trait PresentsInvoice 'credit_to', 'your_credit', 'work_phone', + 'invoice_total', + 'outstanding', ]; foreach ($fields as $field) { @@ -242,12 +254,14 @@ trait PresentsInvoice } foreach ([ + 'account.custom_value1' => 'custom_label1', + 'account.custom_value2' => 'custom_label2', 'invoice.custom_text_value1' => 'custom_invoice_text_label1', 'invoice.custom_text_value2' => 'custom_invoice_text_label2', 'client.custom_value1' => 'custom_client_label1', 'client.custom_value2' => 'custom_client_label2', - 'account.custom_value1' => 'custom_label1', - 'account.custom_value2' => 'custom_label2', + 'contact.custom_value1' => 'custom_contact_label1', + 'contact.custom_value2' => 'custom_contact_label2', ] as $field => $property) { $data[$field] = $this->$property ?: trans('texts.custom_field'); } diff --git a/app/Models/Traits/SendsEmails.php b/app/Models/Traits/SendsEmails.php index ecd7cd323e18..2e5ecc11e98b 100644 --- a/app/Models/Traits/SendsEmails.php +++ b/app/Models/Traits/SendsEmails.php @@ -69,7 +69,7 @@ trait SendsEmails $template .= "$message

"; } - return $template . '$footer'; + return $template . '$emailSignature'; } /** diff --git a/app/Ninja/Datatables/ActivityDatatable.php b/app/Ninja/Datatables/ActivityDatatable.php index 8c3785168af0..989d89bcf0fb 100644 --- a/app/Ninja/Datatables/ActivityDatatable.php +++ b/app/Ninja/Datatables/ActivityDatatable.php @@ -14,7 +14,19 @@ class ActivityDatatable extends EntityDatatable [ 'activities.id', function ($model) { - return Utils::timestampToDateTimeString(strtotime($model->created_at)); + $str = Utils::timestampToDateTimeString(strtotime($model->created_at)); + + if ($model->is_system && in_array($model->activity_type_id, [ + ACTIVITY_TYPE_VIEW_INVOICE, + ACTIVITY_TYPE_VIEW_QUOTE, + ACTIVITY_TYPE_CREATE_PAYMENT, + ACTIVITY_TYPE_APPROVE_QUOTE, + ])) { + $ipLookUpLink = IP_LOOKUP_URL . $model->ip; + $str .= sprintf('   ', $model->ip, $ipLookUpLink); + } + + return $str; }, ], [ diff --git a/app/Ninja/Datatables/ExpenseDatatable.php b/app/Ninja/Datatables/ExpenseDatatable.php index d29408ab31e8..30ccffab4fd5 100644 --- a/app/Ninja/Datatables/ExpenseDatatable.php +++ b/app/Ninja/Datatables/ExpenseDatatable.php @@ -90,7 +90,7 @@ class ExpenseDatatable extends EntityDatatable [ 'status', function ($model) { - return self::getStatusLabel($model->invoice_id, $model->should_be_invoiced, $model->balance); + return self::getStatusLabel($model->invoice_id, $model->should_be_invoiced, $model->balance, $model->payment_date); }, ], ]; @@ -129,9 +129,9 @@ class ExpenseDatatable extends EntityDatatable ]; } - private function getStatusLabel($invoiceId, $shouldBeInvoiced, $balance) + private function getStatusLabel($invoiceId, $shouldBeInvoiced, $balance, $paymentDate) { - $label = Expense::calcStatusLabel($shouldBeInvoiced, $invoiceId, $balance); + $label = Expense::calcStatusLabel($shouldBeInvoiced, $invoiceId, $balance, $paymentDate); $class = Expense::calcStatusClass($shouldBeInvoiced, $invoiceId, $balance); return "

$label

"; diff --git a/app/Ninja/Datatables/PaymentDatatable.php b/app/Ninja/Datatables/PaymentDatatable.php index b4593bd92426..e09e1f8db8f8 100644 --- a/app/Ninja/Datatables/PaymentDatatable.php +++ b/app/Ninja/Datatables/PaymentDatatable.php @@ -52,7 +52,7 @@ class PaymentDatatable extends EntityDatatable [ 'method', function ($model) { - return ($model->payment_type && ! $model->last4) ? $model->payment_type : ($model->account_gateway_id ? $model->gateway_name : ''); + return ($model->payment_type && ! $model->last4) ? trans('texts.payment_type_' . $model->payment_type) : ($model->account_gateway_id ? $model->gateway_name : ''); }, ], [ diff --git a/app/Ninja/Import/CSV/InvoiceTransformer.php b/app/Ninja/Import/CSV/InvoiceTransformer.php index 5cec4b6cc7e1..146f7a5846a6 100644 --- a/app/Ninja/Import/CSV/InvoiceTransformer.php +++ b/app/Ninja/Import/CSV/InvoiceTransformer.php @@ -37,10 +37,10 @@ class InvoiceTransformer extends BaseTransformer 'due_date_sql' => $this->getDate($data, 'due_date'), 'invoice_items' => [ [ - 'product_key' => '', + 'product_key' => $this->getString($data, 'product'), 'notes' => $this->getString($data, 'notes'), 'cost' => $this->getFloat($data, 'amount'), - 'qty' => 1, + 'qty' => $this->getFloat($data, 'quantity') ?: 1, ], ], ]; diff --git a/app/Ninja/Intents/BaseIntent.php b/app/Ninja/Intents/BaseIntent.php index f65407283431..9a07116df942 100644 --- a/app/Ninja/Intents/BaseIntent.php +++ b/app/Ninja/Intents/BaseIntent.php @@ -29,7 +29,7 @@ class BaseIntent $this->state = $state; $this->data = $data; - + // If they're viewing a client set it as the current state if (! $this->hasField('Filter', 'all')) { $url = url()->previous(); @@ -237,7 +237,6 @@ class BaseIntent foreach ($compositeEntity->children as $child) { if ($child->type == 'Field') { $field = $child->value; - ; } elseif ($child->type == 'Value') { $value = $child->value; } diff --git a/app/Ninja/Mailers/ContactMailer.php b/app/Ninja/Mailers/ContactMailer.php index e637ecf199b1..9c3b15d861fa 100644 --- a/app/Ninja/Mailers/ContactMailer.php +++ b/app/Ninja/Mailers/ContactMailer.php @@ -104,9 +104,9 @@ class ContactMailer extends Mailer if ($sent === true) { if ($invoice->isType(INVOICE_TYPE_QUOTE)) { - event(new QuoteWasEmailed($invoice)); + event(new QuoteWasEmailed($invoice, $reminder)); } else { - event(new InvoiceWasEmailed($invoice)); + event(new InvoiceWasEmailed($invoice, $reminder)); } } @@ -140,7 +140,7 @@ class ContactMailer extends Mailer $account = $invoice->account; $user = $invitation->user; - if ($invitation->user->trashed()) { + if ($user->trashed()) { $user = $account->users()->orderBy('id')->first(); } @@ -166,7 +166,7 @@ class ContactMailer extends Mailer $variables['autobill'] = $invoice->present()->autoBillEmailMessage(); } - if (empty($invitation->contact->password) && $account->hasFeature(FEATURE_CLIENT_PORTAL_PASSWORD) && $account->enable_portal_password && $account->send_portal_password) { + if (empty($invitation->contact->password) && $account->isClientPortalPasswordEnabled() && $account->send_portal_password) { // The contact needs a password $variables['password'] = $password = $this->generatePassword(); $invitation->contact->password = bcrypt($password); @@ -254,7 +254,7 @@ class ContactMailer extends Mailer $invitation = $payment->invitation; } else { $user = $payment->user; - $contact = $client->contacts[0]; + $contact = count($client->contacts) ? $client->contacts[0] : ''; $invitation = $payment->invoice->invitations[0]; } diff --git a/app/Ninja/Mailers/UserMailer.php b/app/Ninja/Mailers/UserMailer.php index 302e7d6b8ed2..e4698897195f 100644 --- a/app/Ninja/Mailers/UserMailer.php +++ b/app/Ninja/Mailers/UserMailer.php @@ -48,7 +48,8 @@ class UserMailer extends Mailer User $user, Invoice $invoice, $notificationType, - Payment $payment = null + Payment $payment = null, + $notes = false ) { if (! $user->email || $user->cannot('view', $invoice)) { return; @@ -81,6 +82,10 @@ class UserMailer extends Mailer 'client' => $client->getDisplayName(), ]); + if ($notes) { + $subject .= ' [' . trans('texts.notes_' . $notes) . ']'; + } + $this->sendTo($user->email, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data); } diff --git a/app/Ninja/Presenters/AccountPresenter.php b/app/Ninja/Presenters/AccountPresenter.php index 187e9f16f245..ee64c90a1acb 100644 --- a/app/Ninja/Presenters/AccountPresenter.php +++ b/app/Ninja/Presenters/AccountPresenter.php @@ -155,6 +155,8 @@ class AccountPresenter extends Presenter $fields = [ 'custom_client_label1' => 'custom_client1', 'custom_client_label2' => 'custom_client2', + 'custom_contact_label1' => 'custom_contact1', + 'custom_contact_label2' => 'custom_contact2', 'custom_invoice_text_label1' => 'custom_invoice1', 'custom_invoice_text_label2' => 'custom_invoice2', 'custom_invoice_item_label1' => 'custom_product1', diff --git a/app/Ninja/Presenters/ExpensePresenter.php b/app/Ninja/Presenters/ExpensePresenter.php index 9f8ac4c5506b..100a0de8cded 100644 --- a/app/Ninja/Presenters/ExpensePresenter.php +++ b/app/Ninja/Presenters/ExpensePresenter.php @@ -26,6 +26,14 @@ class ExpensePresenter extends EntityPresenter return Utils::fromSqlDate($this->entity->expense_date); } + /** + * @return \DateTime|string + */ + public function payment_date() + { + return Utils::fromSqlDate($this->entity->payment_date); + } + public function month() { return Carbon::parse($this->entity->payment_date)->format('Y m'); diff --git a/app/Ninja/Reports/AbstractReport.php b/app/Ninja/Reports/AbstractReport.php index 4b6ffa080c6e..e327c60b7170 100644 --- a/app/Ninja/Reports/AbstractReport.php +++ b/app/Ninja/Reports/AbstractReport.php @@ -80,4 +80,39 @@ class AbstractReport return $str; } + + // convert the date format to one supported by tablesorter + public function convertDateFormat() + { + $account = Auth::user()->account; + $format = $account->getMomentDateFormat(); + $format = strtolower($format); + $format = str_replace('do', '', $format); + + $orignalFormat = $format; + $format = preg_replace("/[^mdy]/", '', $format); + + $lastLetter = false; + $reportParts = []; + $phpParts = []; + + foreach (str_split($format) as $letter) { + if ($lastLetter && $letter == $lastLetter) { + continue; + } + $lastLetter = $letter; + if ($letter == 'm') { + $reportParts[] = 'mm'; + $phpParts[] = 'm'; + } elseif ($letter == 'd') { + $reportParts[] = 'dd'; + $phpParts[] = 'd'; + } elseif ($letter == 'y') { + $reportParts[] = 'yyyy'; + $phpParts[] = 'Y'; + } + } + + return join('', $reportParts); + } } diff --git a/app/Ninja/Repositories/AccountRepository.php b/app/Ninja/Repositories/AccountRepository.php index 9ff3d67beed4..f64cd05566f5 100644 --- a/app/Ninja/Repositories/AccountRepository.php +++ b/app/Ninja/Repositories/AccountRepository.php @@ -356,6 +356,9 @@ class AccountRepository $account->company_id = $company->id; $account->save(); + $emailSettings = new AccountEmailSettings(); + $account->account_email_settings()->save($emailSettings); + $random = strtolower(str_random(RANDOM_KEY_LENGTH)); $user = new User(); $user->registered = true; diff --git a/app/Ninja/Repositories/ActivityRepository.php b/app/Ninja/Repositories/ActivityRepository.php index e8538a988ed6..dc1d87993988 100644 --- a/app/Ninja/Repositories/ActivityRepository.php +++ b/app/Ninja/Repositories/ActivityRepository.php @@ -90,6 +90,8 @@ class ActivityRepository 'activities.balance', 'activities.adjustment', 'activities.notes', + 'activities.ip', + 'activities.is_system', 'users.first_name as user_first_name', 'users.last_name as user_last_name', 'users.email as user_email', diff --git a/app/Ninja/Repositories/ClientRepository.php b/app/Ninja/Repositories/ClientRepository.php index e30a458735cb..298f9b27bf52 100644 --- a/app/Ninja/Repositories/ClientRepository.php +++ b/app/Ninja/Repositories/ClientRepository.php @@ -60,6 +60,7 @@ class ClientRepository extends BaseRepository if ($filter) { $query->where(function ($query) use ($filter) { $query->where('clients.name', 'like', '%'.$filter.'%') + ->orWhere('clients.id_number', 'like', '%'.$filter.'%') ->orWhere('contacts.first_name', 'like', '%'.$filter.'%') ->orWhere('contacts.last_name', 'like', '%'.$filter.'%') ->orWhere('contacts.email', 'like', '%'.$filter.'%'); diff --git a/app/Ninja/Repositories/ExpenseRepository.php b/app/Ninja/Repositories/ExpenseRepository.php index 6a322e153d79..ba539eb254a7 100644 --- a/app/Ninja/Repositories/ExpenseRepository.php +++ b/app/Ninja/Repositories/ExpenseRepository.php @@ -81,6 +81,7 @@ class ExpenseRepository extends BaseRepository 'expenses.user_id', 'expenses.tax_rate1', 'expenses.tax_rate2', + 'expenses.payment_date', 'expense_categories.name as category', 'expense_categories.user_id as category_user_id', 'expense_categories.public_id as category_public_id', @@ -112,14 +113,24 @@ class ExpenseRepository extends BaseRepository } if (in_array(EXPENSE_STATUS_INVOICED, $statuses)) { $query->orWhere('expenses.invoice_id', '>', 0); - if (! in_array(EXPENSE_STATUS_PAID, $statuses)) { + if (! in_array(EXPENSE_STATUS_BILLED, $statuses)) { $query->where('invoices.balance', '>', 0); } } - if (in_array(EXPENSE_STATUS_PAID, $statuses)) { + if (in_array(EXPENSE_STATUS_BILLED, $statuses)) { $query->orWhere('invoices.balance', '=', 0) ->where('expenses.invoice_id', '>', 0); } + if (in_array(EXPENSE_STATUS_PAID, $statuses)) { + $query->orWhereNotNull('expenses.payment_date'); + } + if (in_array(EXPENSE_STATUS_UNPAID, $statuses)) { + $query->orWhereNull('expenses.payment_date'); + } + if (in_array(EXPENSE_STATUS_PENDING, $statuses)) { + $query->orWhere('expenses.should_be_invoiced', '=', 1) + ->whereNull('expenses.invoice_id'); + } }); } @@ -161,6 +172,9 @@ class ExpenseRepository extends BaseRepository if (isset($input['expense_date'])) { $expense->expense_date = Utils::toSqlDate($input['expense_date']); } + if (isset($input['payment_date'])) { + $expense->payment_date = Utils::toSqlDate($input['payment_date']); + } $expense->should_be_invoiced = isset($input['should_be_invoiced']) && floatval($input['should_be_invoiced']) || $expense->client_id ? true : false; diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index 8b2aea10b99c..0bf6cf2adbf9 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -2,10 +2,10 @@ namespace App\Ninja\Repositories; -use App\Events\InvoiceWasCreated; -use App\Events\InvoiceWasUpdated; -use App\Events\QuoteWasCreated; -use App\Events\QuoteWasUpdated; +use App\Events\QuoteItemsWereCreated; +use App\Events\QuoteItemsWereUpdated; +use App\Events\InvoiceItemsWereCreated; +use App\Events\InvoiceItemsWereUpdated; use App\Jobs\SendInvoiceEmail; use App\Models\Account; use App\Models\Client; @@ -693,11 +693,13 @@ class InvoiceRepository extends BaseRepository $invoice->invoice_items()->save($invoiceItem); } + $invoice->load('invoice_items'); + if (Auth::check()) { $invoice = $this->saveInvitations($invoice); } - //$this->dispachEvents($invoice); + $this->dispatchEvents($invoice); return $invoice; } @@ -708,6 +710,10 @@ class InvoiceRepository extends BaseRepository $client->load('contacts'); $sendInvoiceIds = []; + if (! count($client->contacts)) { + return $invoice; + } + foreach ($client->contacts as $contact) { if ($contact->send_invoice) { $sendInvoiceIds[] = $contact->id; @@ -740,19 +746,19 @@ class InvoiceRepository extends BaseRepository return $invoice; } - private function dispachEvents($invoice) + private function dispatchEvents($invoice) { if ($invoice->isType(INVOICE_TYPE_QUOTE)) { if ($invoice->wasRecentlyCreated) { - event(new QuoteWasCreated($invoice)); + event(new QuoteItemsWereCreated($invoice)); } else { - event(new QuoteWasUpdated($invoice)); + event(new QuoteItemsWereUpdated($invoice)); } } else { if ($invoice->wasRecentlyCreated) { - event(new InvoiceWasCreated($invoice)); + event(new InvoiceItemsWereCreated($invoice)); } else { - event(new InvoiceWasUpdated($invoice)); + event(new InvoiceItemsWereUpdated($invoice)); } } } @@ -1110,7 +1116,6 @@ class InvoiceRepository extends BaseRepository if ($item['invoice_item_type_id'] == INVOICE_ITEM_TYPE_PENDING_GATEWAY_FEE) { unset($data['invoice_items'][$key]); $this->save($data, $invoice); - $invoice->load('invoice_items'); break; } } @@ -1147,7 +1152,6 @@ class InvoiceRepository extends BaseRepository $data['invoice_items'][] = $item; $this->save($data, $invoice); - $invoice->load('invoice_items'); } public function findPhonetically($invoiceNumber) diff --git a/app/Ninja/Repositories/TaskRepository.php b/app/Ninja/Repositories/TaskRepository.php index e0dbc298ad24..5bf89158af54 100644 --- a/app/Ninja/Repositories/TaskRepository.php +++ b/app/Ninja/Repositories/TaskRepository.php @@ -7,6 +7,7 @@ use App\Models\Project; use App\Models\Task; use Auth; use Session; +use DB; class TaskRepository extends BaseRepository { @@ -17,7 +18,7 @@ class TaskRepository extends BaseRepository public function find($clientPublicId = null, $filter = null) { - $query = \DB::table('tasks') + $query = DB::table('tasks') ->leftJoin('clients', 'tasks.client_id', '=', 'clients.id') ->leftJoin('contacts', 'contacts.client_id', '=', 'clients.id') ->leftJoin('invoices', 'invoices.id', '=', 'tasks.invoice_id') @@ -30,7 +31,7 @@ class TaskRepository extends BaseRepository ->where('contacts.deleted_at', '=', null) ->select( 'tasks.public_id', - \DB::raw("COALESCE(NULLIF(clients.name,''), NULLIF(CONCAT(contacts.first_name, ' ', contacts.last_name),''), NULLIF(contacts.email,'')) client_name"), + DB::raw("COALESCE(NULLIF(clients.name,''), NULLIF(CONCAT(contacts.first_name, ' ', contacts.last_name),''), NULLIF(contacts.email,'')) client_name"), 'clients.public_id as client_public_id', 'clients.user_id as client_user_id', 'contacts.first_name', @@ -49,7 +50,7 @@ class TaskRepository extends BaseRepository 'tasks.time_log', 'tasks.time_log as duration', 'tasks.created_at', - 'tasks.created_at as date', + DB::raw("SUBSTRING(time_log, 3, 10) date"), 'tasks.user_id', 'projects.name as project', 'projects.public_id as project_public_id', diff --git a/app/Ninja/Transformers/AccountTransformer.php b/app/Ninja/Transformers/AccountTransformer.php index 7c11d68b834c..2effb3b97d40 100644 --- a/app/Ninja/Transformers/AccountTransformer.php +++ b/app/Ninja/Transformers/AccountTransformer.php @@ -213,7 +213,7 @@ class AccountTransformer extends EntityTransformer 'num_days_reminder3' => $account->num_days_reminder3, 'custom_invoice_text_label1' => $account->custom_invoice_text_label1, 'custom_invoice_text_label2' => $account->custom_invoice_text_label2, - 'default_tax_rate_id' => $account->default_tax_rate_id, + 'default_tax_rate_id' => $account->default_tax_rate_id ? $account->default_tax_rate->public_id : 0, 'recurring_hour' => $account->recurring_hour, 'invoice_number_pattern' => $account->invoice_number_pattern, 'quote_number_pattern' => $account->quote_number_pattern, @@ -266,6 +266,8 @@ class AccountTransformer extends EntityTransformer 'payment_type_id' => (int) $account->payment_type_id, 'gateway_fee_enabled' => (bool) $account->gateway_fee_enabled, 'reset_counter_date' => $account->reset_counter_date, + 'custom_contact_label1' => $account->custom_contact_label1, + 'custom_contact_label2' => $account->custom_contact_label2, ]; } } diff --git a/app/Ninja/Transformers/ContactTransformer.php b/app/Ninja/Transformers/ContactTransformer.php index 4e6ad4a633aa..8806e71845ef 100644 --- a/app/Ninja/Transformers/ContactTransformer.php +++ b/app/Ninja/Transformers/ContactTransformer.php @@ -26,6 +26,8 @@ class ContactTransformer extends EntityTransformer * @SWG\Property(property="phone", type="string", example="(212) 555-1212") * @SWG\Property(property="last_login", type="string", format="date-time", example="2016-01-01 12:10:00") * @SWG\Property(property="send_invoice", type="boolean", example=false) + * @SWG\Property(property="custom_value1", type="string", example="Value") + * @SWG\Property(property="custom_value2", type="string", example="Value") */ public function transform(Contact $contact) { @@ -40,6 +42,8 @@ class ContactTransformer extends EntityTransformer 'phone' => $contact->phone, 'last_login' => $contact->last_login, 'send_invoice' => (bool) $contact->send_invoice, + 'custom_value1' => $contact->custom_value1, + 'custom_value2' => $contact->custom_value2, ]); } } diff --git a/app/Ninja/Transformers/ProductTransformer.php b/app/Ninja/Transformers/ProductTransformer.php index 241e3e992f0d..ceba995c6223 100644 --- a/app/Ninja/Transformers/ProductTransformer.php +++ b/app/Ninja/Transformers/ProductTransformer.php @@ -27,7 +27,7 @@ class ProductTransformer extends EntityTransformer 'notes' => $product->notes, 'cost' => $product->cost, 'qty' => $product->qty, - 'default_tax_rate_id' => $product->default_tax_rate_id, + 'default_tax_rate_id' => $product->default_tax_rate_id ? $product->default_tax_rate->public_id : 0, 'updated_at' => $this->getTimestamp($product->updated_at), 'archived_at' => $this->getTimestamp($product->deleted_at), ]); diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 1a11e06b2071..518076901af9 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -28,7 +28,7 @@ class AppServiceProvider extends ServiceProvider $contents = $image; } - return 'data:image/jpeg;base64,' . base64_encode($contents); + return $contents ? 'data:image/jpeg;base64,' . base64_encode($contents) : ''; }); Form::macro('nav_link', function ($url, $text) { diff --git a/app/Providers/ComposerServiceProvider.php b/app/Providers/ComposerServiceProvider.php index 5d8e1bcc577b..ef2512c796f0 100644 --- a/app/Providers/ComposerServiceProvider.php +++ b/app/Providers/ComposerServiceProvider.php @@ -17,9 +17,12 @@ class ComposerServiceProvider extends ServiceProvider [ 'accounts.details', 'clients.edit', + 'vendors.edit', 'payments.edit', 'invoices.edit', + 'expenses.edit', 'accounts.localization', + 'payments.credit_card', ], 'App\Http\ViewComposers\TranslationComposer' ); diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index f50396865bf2..ab581e3f797c 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -32,12 +32,16 @@ class EventServiceProvider extends ServiceProvider // Invoices 'App\Events\InvoiceWasCreated' => [ 'App\Listeners\ActivityListener@createdInvoice', - 'App\Listeners\SubscriptionListener@createdInvoice', 'App\Listeners\InvoiceListener@createdInvoice', ], 'App\Events\InvoiceWasUpdated' => [ 'App\Listeners\ActivityListener@updatedInvoice', 'App\Listeners\InvoiceListener@updatedInvoice', + ], + 'App\Events\InvoiceItemsWereCreated' => [ + 'App\Listeners\SubscriptionListener@createdInvoice', + ], + 'App\Events\InvoiceItemsWereUpdated' => [ 'App\Listeners\SubscriptionListener@updatedInvoice', ], 'App\Events\InvoiceWasArchived' => [ @@ -66,10 +70,14 @@ class EventServiceProvider extends ServiceProvider // Quotes 'App\Events\QuoteWasCreated' => [ 'App\Listeners\ActivityListener@createdQuote', - 'App\Listeners\SubscriptionListener@createdQuote', ], 'App\Events\QuoteWasUpdated' => [ 'App\Listeners\ActivityListener@updatedQuote', + ], + 'App\Events\QuoteItemsWereCreated' => [ + 'App\Listeners\SubscriptionListener@createdQuote', + ], + 'App\Events\QuoteItemsWereUpdated' => [ 'App\Listeners\SubscriptionListener@updatedQuote', ], 'App\Events\QuoteWasArchived' => [ diff --git a/app/Services/ImportService.php b/app/Services/ImportService.php index f06241c95928..952b0865f5b2 100644 --- a/app/Services/ImportService.php +++ b/app/Services/ImportService.php @@ -24,6 +24,7 @@ use Auth; use Cache; use Excel; use Exception; +use File; use League\Fractal\Manager; use parsecsv; use Session; @@ -145,10 +146,9 @@ class ImportService * * @return array */ - public function importJSON($file, $includeData, $includeSettings) + public function importJSON($fileName, $includeData, $includeSettings) { $this->initMaps(); - $fileName = storage_path() . '/import/' . $file; $this->checkForFile($fileName); $file = file_get_contents($fileName); $json = json_decode($file, true); @@ -229,7 +229,7 @@ class ImportService } } - @unlink($fileName); + File::delete($fileName); return $this->results; } @@ -278,7 +278,7 @@ class ImportService * * @return array */ - private function execute($source, $entityType, $file) + private function execute($source, $entityType, $fileName) { $results = [ RESULT_SUCCESS => [], @@ -287,7 +287,6 @@ class ImportService // Convert the data $row_list = []; - $fileName = storage_path() . '/import/' . $file; $this->checkForFile($fileName); Excel::load($fileName, function ($reader) use ($source, $entityType, &$row_list, &$results) { @@ -321,7 +320,7 @@ class ImportService } } - @unlink($fileName); + File::delete($fileName); return $results; } @@ -590,7 +589,6 @@ class ImportService { require_once app_path().'/Includes/parsecsv.lib.php'; - $fileName = storage_path() . '/import/' . $fileName; $this->checkForFile($fileName); $csv = new parseCSV(); @@ -686,7 +684,8 @@ class ImportService ]; $source = IMPORT_CSV; - $fileName = sprintf('%s_%s_%s.csv', Auth::user()->account_id, $timestamp, $entityType); + $path = env('FILE_IMPORT_PATH') ?: storage_path() . '/import'; + $fileName = sprintf('%s/%s_%s_%s.csv', $path, Auth::user()->account_id, $timestamp, $entityType); $data = $this->getCsvData($fileName); $this->checkData($entityType, count($data)); $this->initMaps(); @@ -726,7 +725,7 @@ class ImportService } } - @unlink(storage_path() . '/import/' . $fileName); + File::delete($fileName); return $results; } @@ -868,7 +867,7 @@ class ImportService $this->maps['client'][$name] = $client->id; $this->maps['client_ids'][$client->public_id] = $client->id; } - if ($name = strtolower(trim($client->contacts[0]->email))) { + if (count($client->contacts) && $name = strtolower(trim($client->contacts[0]->email))) { $this->maps['client'][$name] = $client->id; $this->maps['client_ids'][$client->public_id] = $client->id; } diff --git a/app/Services/TemplateService.php b/app/Services/TemplateService.php index 1644ea95aced..5df95d2d24c6 100644 --- a/app/Services/TemplateService.php +++ b/app/Services/TemplateService.php @@ -28,6 +28,7 @@ class TemplateService $invitation = $data['invitation']; $invoice = $invitation->invoice; + $contact = $invitation->contact; $passwordHTML = isset($data['password']) ? '

'.trans('texts.password').': '.$data['password'].'

' : false; $documentsHTML = ''; @@ -46,12 +47,13 @@ class TemplateService $variables = [ '$footer' => $account->getEmailFooter(), + '$emailSignature' => $account->getEmailFooter(), '$client' => $client->getDisplayName(), '$account' => $account->getDisplayName(), '$dueDate' => $account->formatDate($invoice->due_date), '$invoiceDate' => $account->formatDate($invoice->invoice_date), - '$contact' => $invitation->contact->getDisplayName(), - '$firstName' => $invitation->contact->first_name, + '$contact' => $contact->getDisplayName(), + '$firstName' => $contact->first_name, '$amount' => $account->formatMoney($data['amount'], $client), '$invoice' => $invoice->invoice_number, '$quote' => $invoice->invoice_number, @@ -63,6 +65,8 @@ class TemplateService '$paymentButton' => Form::emailPaymentButton($invitation->getLink('payment')).'$password', '$customClient1' => $client->custom_value1, '$customClient2' => $client->custom_value2, + '$customContact1' => $contact->custom_value1, + '$customContact2' => $contact->custom_value2, '$customInvoice1' => $invoice->custom_text_value1, '$customInvoice2' => $invoice->custom_text_value2, '$documents' => $documentsHTML, diff --git a/composer.json b/composer.json index b0ae7b213193..c02f0decf4b5 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "ext-gmp": "*", "ext-gd": "*", "turbo124/laravel-push-notification": "2.*", - "omnipay/mollie": "dev-master#22956c1a62a9662afa5f5d119723b413770ac525", + "omnipay/mollie": "3.*", "omnipay/2checkout": "dev-master#e9c079c2dde0d7ba461903b3b7bd5caf6dee1248", "omnipay/gocardless": "dev-master", "omnipay/stripe": "dev-master", diff --git a/composer.lock b/composer.lock index e31cefa78a8d..caf760358ec2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "5c6d080c3a38d42e07ab70bf32760976", - "content-hash": "dcf4534113b5e62eb3f1fa6b453c82be", + "hash": "8fb907c3b74902fc105d5076234c4a80", + "content-hash": "1bc81460b475ce88809f30d99886ecfd", "packages": [ { "name": "agmscode/omnipay-agms", @@ -327,16 +327,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.24.9", + "version": "3.26.2", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "26212252dcd0f9b9b7b19702577d0b0b364888df" + "reference": "05df1887d7b8cea9fba9ad59e1513c3815e883ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/26212252dcd0f9b9b7b19702577d0b0b364888df", - "reference": "26212252dcd0f9b9b7b19702577d0b0b364888df", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/05df1887d7b8cea9fba9ad59e1513c3815e883ae", + "reference": "05df1887d7b8cea9fba9ad59e1513c3815e883ae", "shasum": "" }, "require": { @@ -403,7 +403,7 @@ "s3", "sdk" ], - "time": "2017-03-28 20:19:24" + "time": "2017-04-21 20:25:16" }, { "name": "barracudanetworks/archivestream-php", @@ -674,16 +674,16 @@ }, { "name": "braintree/braintree_php", - "version": "3.22.0", + "version": "3.23.0", "source": { "type": "git", "url": "https://github.com/braintree/braintree_php.git", - "reference": "402617b803779bed5ae899209afa75ef9950becc" + "reference": "0614d169e3ef8a9b16a90367f8a66bdd9f5a9df6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/braintree/braintree_php/zipball/402617b803779bed5ae899209afa75ef9950becc", - "reference": "402617b803779bed5ae899209afa75ef9950becc", + "url": "https://api.github.com/repos/braintree/braintree_php/zipball/0614d169e3ef8a9b16a90367f8a66bdd9f5a9df6", + "reference": "0614d169e3ef8a9b16a90367f8a66bdd9f5a9df6", "shasum": "" }, "require": { @@ -717,7 +717,7 @@ } ], "description": "Braintree PHP Client Library", - "time": "2017-02-16 19:59:04" + "time": "2017-04-13 20:06:18" }, { "name": "cardgate/omnipay-cardgate", @@ -922,12 +922,12 @@ "source": { "type": "git", "url": "https://github.com/codedge/laravel-selfupdater.git", - "reference": "b24b155fe0fcccf0ecfbc926a6c3043911418906" + "reference": "084a1dd447d9dcd532042dfc3296b195903c2530" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/codedge/laravel-selfupdater/zipball/b24b155fe0fcccf0ecfbc926a6c3043911418906", - "reference": "b24b155fe0fcccf0ecfbc926a6c3043911418906", + "url": "https://api.github.com/repos/codedge/laravel-selfupdater/zipball/084a1dd447d9dcd532042dfc3296b195903c2530", + "reference": "084a1dd447d9dcd532042dfc3296b195903c2530", "shasum": "" }, "require": { @@ -970,7 +970,7 @@ "self-update", "update" ], - "time": "2016-09-21 12:43:00" + "time": "2017-04-09 12:12:08" }, { "name": "collizo4sky/omnipay-wepay", @@ -2075,6 +2075,49 @@ ], "time": "2017-03-13 06:30:53" }, + { + "name": "firebase/php-jwt", + "version": "v4.0.0", + "source": { + "type": "git", + "url": "https://github.com/firebase/php-jwt.git", + "reference": "dccf163dc8ed7ed6a00afc06c51ee5186a428d35" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/firebase/php-jwt/zipball/dccf163dc8ed7ed6a00afc06c51ee5186a428d35", + "reference": "dccf163dc8ed7ed6a00afc06c51ee5186a428d35", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Firebase\\JWT\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Neuman Vong", + "email": "neuman+pear@twilio.com", + "role": "Developer" + }, + { + "name": "Anant Narayanan", + "email": "anant@php.net", + "role": "Developer" + } + ], + "description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.", + "homepage": "https://github.com/firebase/php-jwt", + "time": "2016-07-18 04:51:16" + }, { "name": "fotografde/omnipay-checkoutcom", "version": "2.0", @@ -2251,34 +2294,50 @@ }, { "name": "google/apiclient", - "version": "v1.1.8", + "version": "v2.1.3", "source": { "type": "git", "url": "https://github.com/google/google-api-php-client.git", - "reference": "85309a3520bb5f53368d43e35fd24f43c9556323" + "reference": "43996f09df274158fd04fce98e8a82effe5f3717" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/google/google-api-php-client/zipball/85309a3520bb5f53368d43e35fd24f43c9556323", - "reference": "85309a3520bb5f53368d43e35fd24f43c9556323", + "url": "https://api.github.com/repos/google/google-api-php-client/zipball/43996f09df274158fd04fce98e8a82effe5f3717", + "reference": "43996f09df274158fd04fce98e8a82effe5f3717", "shasum": "" }, "require": { - "php": ">=5.2.1" + "firebase/php-jwt": "~2.0|~3.0|~4.0", + "google/apiclient-services": "^0.11", + "google/auth": "^0.11", + "guzzlehttp/guzzle": "~5.2|~6.0", + "guzzlehttp/psr7": "^1.2", + "monolog/monolog": "^1.17", + "php": ">=5.4", + "phpseclib/phpseclib": "~0.3.10|~2.0" }, "require-dev": { - "phpunit/phpunit": "3.7.*", - "squizlabs/php_codesniffer": "~2.3" + "cache/filesystem-adapter": "^0.3.2", + "phpunit/phpunit": "~4", + "squizlabs/php_codesniffer": "~2.3", + "symfony/css-selector": "~2.1", + "symfony/dom-crawler": "~2.1" + }, + "suggest": { + "cache/filesystem-adapter": "For caching certs and tokens (using Google_Client::setCache)" }, "type": "library", "extra": { "branch-alias": { - "dev-v1-master": "1.1.x-dev" + "dev-master": "2.x-dev" } }, "autoload": { - "files": [ - "src/Google/autoload.php" + "psr-0": { + "Google_": "src/" + }, + "classmap": [ + "src/Google/Service/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -2290,7 +2349,92 @@ "keywords": [ "google" ], - "time": "2016-06-06 21:22:48" + "time": "2017-03-22 18:32:04" + }, + { + "name": "google/apiclient-services", + "version": "v0.11", + "source": { + "type": "git", + "url": "https://github.com/google/google-api-php-client-services.git", + "reference": "48c554aee06f2fd5700d7bdfa4fa6b82d184eb52" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/google/google-api-php-client-services/zipball/48c554aee06f2fd5700d7bdfa4fa6b82d184eb52", + "reference": "48c554aee06f2fd5700d7bdfa4fa6b82d184eb52", + "shasum": "" + }, + "require": { + "php": ">=5.4" + }, + "require-dev": { + "phpunit/phpunit": "~4.8" + }, + "type": "library", + "autoload": { + "psr-0": { + "Google_Service_": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "Client library for Google APIs", + "homepage": "http://developers.google.com/api-client-library/php", + "keywords": [ + "google" + ], + "time": "2017-03-13 17:40:44" + }, + { + "name": "google/auth", + "version": "v0.11.1", + "source": { + "type": "git", + "url": "https://github.com/google/google-auth-library-php.git", + "reference": "a240674b08a09949fd5597f7590b3ed83663a12d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/google/google-auth-library-php/zipball/a240674b08a09949fd5597f7590b3ed83663a12d", + "reference": "a240674b08a09949fd5597f7590b3ed83663a12d", + "shasum": "" + }, + "require": { + "firebase/php-jwt": "~2.0|~3.0|~4.0", + "guzzlehttp/guzzle": "~5.3|~6.0", + "guzzlehttp/psr7": "~1.2", + "php": ">=5.4", + "psr/cache": "^1.0", + "psr/http-message": "^1.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^1.11", + "phpunit/phpunit": "3.7.*" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ], + "psr-4": { + "Google\\Auth\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "Google Auth Library for PHP", + "homepage": "http://github.com/google/google-auth-library-php", + "keywords": [ + "Authentication", + "google", + "oauth2" + ], + "time": "2016-11-02 14:59:14" }, { "name": "guzzle/guzzle", @@ -2674,12 +2818,12 @@ "source": { "type": "git", "url": "https://github.com/Intervention/image.git", - "reference": "c9a162592dda7ae4ad3b49305da41e82155f9b9a" + "reference": "15a517f052ee15d373ffa145c9642d5fec7ddf5c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Intervention/image/zipball/c9a162592dda7ae4ad3b49305da41e82155f9b9a", - "reference": "c9a162592dda7ae4ad3b49305da41e82155f9b9a", + "url": "https://api.github.com/repos/Intervention/image/zipball/15a517f052ee15d373ffa145c9642d5fec7ddf5c", + "reference": "15a517f052ee15d373ffa145c9642d5fec7ddf5c", "shasum": "" }, "require": { @@ -2728,7 +2872,7 @@ "thumbnail", "watermark" ], - "time": "2017-02-23 16:15:05" + "time": "2017-04-23 18:45:36" }, { "name": "ircmaxell/password-compat", @@ -2902,16 +3046,16 @@ }, { "name": "jaybizzle/crawler-detect", - "version": "v1.2.37", + "version": "v1.2.40", "source": { "type": "git", "url": "https://github.com/JayBizzle/Crawler-Detect.git", - "reference": "850e5fc85506f9bee623fd29936ceb044d63ad2b" + "reference": "c5c0f049264edcf6499847c756dc36e51a072313" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/JayBizzle/Crawler-Detect/zipball/850e5fc85506f9bee623fd29936ceb044d63ad2b", - "reference": "850e5fc85506f9bee623fd29936ceb044d63ad2b", + "url": "https://api.github.com/repos/JayBizzle/Crawler-Detect/zipball/c5c0f049264edcf6499847c756dc36e51a072313", + "reference": "c5c0f049264edcf6499847c756dc36e51a072313", "shasum": "" }, "require": { @@ -2946,7 +3090,7 @@ "crawlerdetect", "php crawler detect" ], - "time": "2017-03-21 09:17:34" + "time": "2017-04-20 18:58:25" }, { "name": "jaybizzle/laravel-crawler-detect", @@ -3546,16 +3690,16 @@ }, { "name": "league/flysystem", - "version": "1.0.37", + "version": "1.0.38", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "78b5cc4feb61a882302df4fbaf63b7662e5e4ccd" + "reference": "4ba6e13f5116204b21c3afdf400ecf2b9eb1c482" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/78b5cc4feb61a882302df4fbaf63b7662e5e4ccd", - "reference": "78b5cc4feb61a882302df4fbaf63b7662e5e4ccd", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/4ba6e13f5116204b21c3afdf400ecf2b9eb1c482", + "reference": "4ba6e13f5116204b21c3afdf400ecf2b9eb1c482", "shasum": "" }, "require": { @@ -3577,12 +3721,12 @@ "league/flysystem-azure": "Allows you to use Windows Azure Blob storage", "league/flysystem-cached-adapter": "Flysystem adapter decorator for metadata caching", "league/flysystem-copy": "Allows you to use Copy.com storage", - "league/flysystem-dropbox": "Allows you to use Dropbox storage", "league/flysystem-eventable-filesystem": "Allows you to use EventableFilesystem", "league/flysystem-rackspace": "Allows you to use Rackspace Cloud Files", "league/flysystem-sftp": "Allows you to use SFTP server storage via phpseclib", "league/flysystem-webdav": "Allows you to use WebDAV storage", - "league/flysystem-ziparchive": "Allows you to use ZipArchive adapter" + "league/flysystem-ziparchive": "Allows you to use ZipArchive adapter", + "spatie/flysystem-dropbox": "Allows you to use Dropbox storage" }, "type": "library", "extra": { @@ -3625,7 +3769,7 @@ "sftp", "storage" ], - "time": "2017-03-22 15:43:14" + "time": "2017-04-22 18:59:19" }, { "name": "league/flysystem-aws-s3-v3", @@ -3953,16 +4097,16 @@ }, { "name": "maatwebsite/excel", - "version": "2.1.16", + "version": "2.1.17", "source": { "type": "git", "url": "https://github.com/Maatwebsite/Laravel-Excel.git", - "reference": "655def96b5e98d1fe0974d9c4e2ec5f2b591a322" + "reference": "14d5abf8e20563c80dd074fd7c8cf1c05bf51f1d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Maatwebsite/Laravel-Excel/zipball/655def96b5e98d1fe0974d9c4e2ec5f2b591a322", - "reference": "655def96b5e98d1fe0974d9c4e2ec5f2b591a322", + "url": "https://api.github.com/repos/Maatwebsite/Laravel-Excel/zipball/14d5abf8e20563c80dd074fd7c8cf1c05bf51f1d", + "reference": "14d5abf8e20563c80dd074fd7c8cf1c05bf51f1d", "shasum": "" }, "require": { @@ -4017,7 +4161,7 @@ "import", "laravel" ], - "time": "2017-03-28 10:47:04" + "time": "2017-04-04 18:28:12" }, { "name": "maximebf/debugbar", @@ -4561,16 +4705,16 @@ }, { "name": "nwidart/laravel-modules", - "version": "1.19.0", + "version": "1.20.0", "source": { "type": "git", "url": "https://github.com/nWidart/laravel-modules.git", - "reference": "694640a499452f1bff8f424b250260343d81acba" + "reference": "c259422a0c8303d552324ce13c5dbd672468676c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nWidart/laravel-modules/zipball/694640a499452f1bff8f424b250260343d81acba", - "reference": "694640a499452f1bff8f424b250260343d81acba", + "url": "https://api.github.com/repos/nWidart/laravel-modules/zipball/c259422a0c8303d552324ce13c5dbd672468676c", + "reference": "c259422a0c8303d552324ce13c5dbd672468676c", "shasum": "" }, "require": { @@ -4610,7 +4754,7 @@ "nwidart", "rad" ], - "time": "2017-03-16 10:56:06" + "time": "2017-04-19 13:47:31" }, { "name": "omnipay/2checkout", @@ -5486,16 +5630,16 @@ }, { "name": "omnipay/mollie", - "version": "dev-master", + "version": "v3.2.0", "source": { "type": "git", "url": "https://github.com/thephpleague/omnipay-mollie.git", - "reference": "22956c1a62a9662afa5f5d119723b413770ac525" + "reference": "8a81a9980a3de726e6badb2ca0edc3728bba6c95" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/omnipay-mollie/zipball/22956c1a62a9662afa5f5d119723b413770ac525", - "reference": "22956c1a62a9662afa5f5d119723b413770ac525", + "url": "https://api.github.com/repos/thephpleague/omnipay-mollie/zipball/8a81a9980a3de726e6badb2ca0edc3728bba6c95", + "reference": "8a81a9980a3de726e6badb2ca0edc3728bba6c95", "shasum": "" }, "require": { @@ -5539,7 +5683,7 @@ "pay", "payment" ], - "time": "2015-03-03 18:55:42" + "time": "2016-10-11 09:44:09" }, { "name": "omnipay/multisafepay", @@ -5715,16 +5859,16 @@ }, { "name": "omnipay/omnipay", - "version": "v2.3.1", + "version": "2.3.2", "source": { "type": "git", "url": "https://github.com/thephpleague/omnipay.git", - "reference": "ae75717ec00b93069768102af11b9dd909c78bd3" + "reference": "e9e6d95a2e7c3641ba31c985334d82e39dbd6078" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/omnipay/zipball/ae75717ec00b93069768102af11b9dd909c78bd3", - "reference": "ae75717ec00b93069768102af11b9dd909c78bd3", + "url": "https://api.github.com/repos/thephpleague/omnipay/zipball/e9e6d95a2e7c3641ba31c985334d82e39dbd6078", + "reference": "e9e6d95a2e7c3641ba31c985334d82e39dbd6078", "shasum": "" }, "require": { @@ -5740,7 +5884,7 @@ "omnipay/gocardless": "~2.0", "omnipay/manual": "~2.0", "omnipay/migs": "~2.0", - "omnipay/mollie": "~2.0", + "omnipay/mollie": "~3.0", "omnipay/multisafepay": "~2.0", "omnipay/netaxept": "~2.0", "omnipay/netbanx": "~2.0", @@ -5823,7 +5967,7 @@ "twocheckout", "worldpay" ], - "time": "2014-09-17 00:29:37" + "time": "2014-12-10 13:55:00" }, { "name": "omnipay/payfast", @@ -6119,16 +6263,16 @@ }, { "name": "omnipay/sagepay", - "version": "2.3.1", + "version": "2.4.0", "source": { "type": "git", "url": "https://github.com/thephpleague/omnipay-sagepay.git", - "reference": "ca992b28a0d7ec7dbf218852dab36ec309dee07e" + "reference": "4ca4847935bc31dbcdd627e92377b5c3cf709e9b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/omnipay-sagepay/zipball/ca992b28a0d7ec7dbf218852dab36ec309dee07e", - "reference": "ca992b28a0d7ec7dbf218852dab36ec309dee07e", + "url": "https://api.github.com/repos/thephpleague/omnipay-sagepay/zipball/4ca4847935bc31dbcdd627e92377b5c3cf709e9b", + "reference": "4ca4847935bc31dbcdd627e92377b5c3cf709e9b", "shasum": "" }, "require": { @@ -6174,7 +6318,7 @@ "sage pay", "sagepay" ], - "time": "2016-02-07 13:25:23" + "time": "2017-01-12 23:36:01" }, { "name": "omnipay/securepay", @@ -6568,6 +6712,98 @@ ], "time": "2015-05-01 07:00:55" }, + { + "name": "phpseclib/phpseclib", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phpseclib/phpseclib.git", + "reference": "ab8028c93c03cc8d9c824efa75dc94f1db2369bf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/ab8028c93c03cc8d9c824efa75dc94f1db2369bf", + "reference": "ab8028c93c03cc8d9c824efa75dc94f1db2369bf", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phing/phing": "~2.7", + "phpunit/phpunit": "~4.0", + "sami/sami": "~2.0", + "squizlabs/php_codesniffer": "~2.0" + }, + "suggest": { + "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.", + "ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.", + "ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.", + "ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations." + }, + "type": "library", + "autoload": { + "files": [ + "phpseclib/bootstrap.php" + ], + "psr-4": { + "phpseclib\\": "phpseclib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jim Wigginton", + "email": "terrafrost@php.net", + "role": "Lead Developer" + }, + { + "name": "Patrick Monnerat", + "email": "pm@datasphere.ch", + "role": "Developer" + }, + { + "name": "Andreas Fischer", + "email": "bantu@phpbb.com", + "role": "Developer" + }, + { + "name": "Hans-Jürgen Petrich", + "email": "petrich@tronic-media.com", + "role": "Developer" + }, + { + "name": "Graham Campbell", + "email": "graham@alt-three.com", + "role": "Developer" + } + ], + "description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.", + "homepage": "http://phpseclib.sourceforge.net", + "keywords": [ + "BigInteger", + "aes", + "asn.1", + "asn1", + "blowfish", + "crypto", + "cryptography", + "encryption", + "rsa", + "security", + "sftp", + "signature", + "signing", + "ssh", + "twofish", + "x.509", + "x509" + ], + "time": "2016-10-04 00:57:04" + }, { "name": "predis/predis", "version": "v1.1.1", @@ -6618,6 +6854,52 @@ ], "time": "2016-06-16 16:22:20" }, + { + "name": "psr/cache", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/cache.git", + "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", + "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for caching libraries", + "keywords": [ + "cache", + "psr", + "psr-6" + ], + "time": "2016-08-06 20:24:11" + }, { "name": "psr/container", "version": "1.0.0", @@ -7001,20 +7283,20 @@ }, { "name": "superbalist/flysystem-google-storage", - "version": "1.0.4", + "version": "1.0.3", "source": { "type": "git", "url": "https://github.com/Superbalist/flysystem-google-cloud-storage.git", - "reference": "8ae35803a102ed6ce58aa87bf7534d4396513765" + "reference": "441a8529680986a2d2063a268ee2918f51db1b79" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Superbalist/flysystem-google-cloud-storage/zipball/8ae35803a102ed6ce58aa87bf7534d4396513765", - "reference": "8ae35803a102ed6ce58aa87bf7534d4396513765", + "url": "https://api.github.com/repos/Superbalist/flysystem-google-cloud-storage/zipball/441a8529680986a2d2063a268ee2918f51db1b79", + "reference": "441a8529680986a2d2063a268ee2918f51db1b79", "shasum": "" }, "require": { - "google/apiclient": "~1.1", + "google/apiclient": "~1.1|^2.0.0@RC", "league/flysystem": "~1.0", "php": ">=5.4.0" }, @@ -7044,20 +7326,20 @@ } ], "description": "Flysystem adapter for Google Cloud Storage", - "time": "2016-05-19 14:33:03" + "time": "2016-04-12 14:56:22" }, { "name": "swiftmailer/swiftmailer", - "version": "v5.4.6", + "version": "v5.4.7", "source": { "type": "git", "url": "https://github.com/swiftmailer/swiftmailer.git", - "reference": "81fdccfaf8bdc5d5d7a1ef6bb3a61bbb1a6c4a3e" + "reference": "56db4ed32a6d5c9824c3ecc1d2e538f663f47eb4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/81fdccfaf8bdc5d5d7a1ef6bb3a61bbb1a6c4a3e", - "reference": "81fdccfaf8bdc5d5d7a1ef6bb3a61bbb1a6c4a3e", + "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/56db4ed32a6d5c9824c3ecc1d2e538f663f47eb4", + "reference": "56db4ed32a6d5c9824c3ecc1d2e538f663f47eb4", "shasum": "" }, "require": { @@ -7098,11 +7380,11 @@ "mail", "mailer" ], - "time": "2017-02-13 07:52:53" + "time": "2017-04-20 17:32:18" }, { "name": "symfony/class-loader", - "version": "v3.2.6", + "version": "v3.2.7", "source": { "type": "git", "url": "https://github.com/symfony/class-loader.git", @@ -7158,16 +7440,16 @@ }, { "name": "symfony/config", - "version": "v3.2.6", + "version": "v3.2.7", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "741d6d4cd1414d67d48eb71aba6072b46ba740c2" + "reference": "8444bde28e3c2a33e571e6f180c2d78bfdc4480d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/741d6d4cd1414d67d48eb71aba6072b46ba740c2", - "reference": "741d6d4cd1414d67d48eb71aba6072b46ba740c2", + "url": "https://api.github.com/repos/symfony/config/zipball/8444bde28e3c2a33e571e6f180c2d78bfdc4480d", + "reference": "8444bde28e3c2a33e571e6f180c2d78bfdc4480d", "shasum": "" }, "require": { @@ -7210,7 +7492,7 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2017-03-01 18:18:25" + "time": "2017-04-04 15:30:56" }, { "name": "symfony/console", @@ -7274,7 +7556,7 @@ }, { "name": "symfony/css-selector", - "version": "v3.2.6", + "version": "v3.2.7", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", @@ -7384,16 +7666,16 @@ }, { "name": "symfony/dependency-injection", - "version": "v3.2.6", + "version": "v3.2.7", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "74e0935e414ad33d5e82074212c0eedb4681a691" + "reference": "923bb014708b666e4092c9ba39993895c9c8fcd7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/74e0935e414ad33d5e82074212c0eedb4681a691", - "reference": "74e0935e414ad33d5e82074212c0eedb4681a691", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/923bb014708b666e4092c9ba39993895c9c8fcd7", + "reference": "923bb014708b666e4092c9ba39993895c9c8fcd7", "shasum": "" }, "require": { @@ -7443,20 +7725,20 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "https://symfony.com", - "time": "2017-03-05 00:06:55" + "time": "2017-04-04 07:26:27" }, { "name": "symfony/event-dispatcher", - "version": "v2.8.18", + "version": "v2.8.19", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "bb4ec47e8e109c1c1172145732d0aa468d967cd0" + "reference": "88b65f0ac25355090e524aba4ceb066025df8bd2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/bb4ec47e8e109c1c1172145732d0aa468d967cd0", - "reference": "bb4ec47e8e109c1c1172145732d0aa468d967cd0", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/88b65f0ac25355090e524aba4ceb066025df8bd2", + "reference": "88b65f0ac25355090e524aba4ceb066025df8bd2", "shasum": "" }, "require": { @@ -7503,20 +7785,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2017-02-21 08:33:48" + "time": "2017-04-03 20:37:06" }, { "name": "symfony/filesystem", - "version": "v3.2.6", + "version": "v3.2.7", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "bc0f17bed914df2cceb989972c3b996043c4da4a" + "reference": "64421e6479c4a8e60d790fb666bd520992861b66" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/bc0f17bed914df2cceb989972c3b996043c4da4a", - "reference": "bc0f17bed914df2cceb989972c3b996043c4da4a", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/64421e6479c4a8e60d790fb666bd520992861b66", + "reference": "64421e6479c4a8e60d790fb666bd520992861b66", "shasum": "" }, "require": { @@ -7552,7 +7834,7 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2017-03-06 19:30:27" + "time": "2017-03-26 15:47:15" }, { "name": "symfony/finder", @@ -7605,16 +7887,16 @@ }, { "name": "symfony/http-foundation", - "version": "v2.8.18", + "version": "v2.8.19", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "88af747e7af17d8d7d439ad4639dc3e23ddd3edd" + "reference": "0717efd2f2264dbd3d8e1bc69a0418c2fd6295d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/88af747e7af17d8d7d439ad4639dc3e23ddd3edd", - "reference": "88af747e7af17d8d7d439ad4639dc3e23ddd3edd", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/0717efd2f2264dbd3d8e1bc69a0418c2fd6295d2", + "reference": "0717efd2f2264dbd3d8e1bc69a0418c2fd6295d2", "shasum": "" }, "require": { @@ -7656,7 +7938,7 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2017-03-04 12:20:59" + "time": "2017-04-04 15:24:26" }, { "name": "symfony/http-kernel", @@ -7742,16 +8024,16 @@ }, { "name": "symfony/options-resolver", - "version": "v3.2.6", + "version": "v3.2.7", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "56e3d0a41313f8a54326851f10690d591e62a24c" + "reference": "6a19be85237fe8bbd4975f86942b4763bb0da6ca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/56e3d0a41313f8a54326851f10690d591e62a24c", - "reference": "56e3d0a41313f8a54326851f10690d591e62a24c", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/6a19be85237fe8bbd4975f86942b4763bb0da6ca", + "reference": "6a19be85237fe8bbd4975f86942b4763bb0da6ca", "shasum": "" }, "require": { @@ -7792,7 +8074,7 @@ "configuration", "options" ], - "time": "2017-02-21 09:12:04" + "time": "2017-03-21 21:44:32" }, { "name": "symfony/polyfill-mbstring", @@ -8328,16 +8610,16 @@ }, { "name": "symfony/yaml", - "version": "v3.2.6", + "version": "v3.2.7", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "093e416ad096355149e265ea2e4cc1f9ee40ab1a" + "reference": "62b4cdb99d52cb1ff253c465eb1532a80cebb621" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/093e416ad096355149e265ea2e4cc1f9ee40ab1a", - "reference": "093e416ad096355149e265ea2e4cc1f9ee40ab1a", + "url": "https://api.github.com/repos/symfony/yaml/zipball/62b4cdb99d52cb1ff253c465eb1532a80cebb621", + "reference": "62b4cdb99d52cb1ff253c465eb1532a80cebb621", "shasum": "" }, "require": { @@ -8379,7 +8661,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-03-07 16:47:02" + "time": "2017-03-20 09:45:15" }, { "name": "tijsverkoyen/css-to-inline-styles", @@ -8633,16 +8915,16 @@ }, { "name": "twig/twig", - "version": "v1.33.0", + "version": "v1.33.2", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "05cf49921b13f6f01d3cfdf9018cfa7a8086fd5a" + "reference": "dd6ca96227917e1e85b41c7c3cc6507b411e0927" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/05cf49921b13f6f01d3cfdf9018cfa7a8086fd5a", - "reference": "05cf49921b13f6f01d3cfdf9018cfa7a8086fd5a", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/dd6ca96227917e1e85b41c7c3cc6507b411e0927", + "reference": "dd6ca96227917e1e85b41c7c3cc6507b411e0927", "shasum": "" }, "require": { @@ -8691,7 +8973,7 @@ "keywords": [ "templating" ], - "time": "2017-03-22 15:40:09" + "time": "2017-04-20 17:39:48" }, { "name": "vink/omnipay-komoju", @@ -8966,16 +9248,16 @@ }, { "name": "wildbit/swiftmailer-postmark", - "version": "2.0.5", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/wildbit/swiftmailer-postmark.git", - "reference": "7b69441324b40517d4ef69703677853fb367ee4e" + "reference": "fb49114bc8033b125f9d19473dc0741385131d84" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wildbit/swiftmailer-postmark/zipball/7b69441324b40517d4ef69703677853fb367ee4e", - "reference": "7b69441324b40517d4ef69703677853fb367ee4e", + "url": "https://api.github.com/repos/wildbit/swiftmailer-postmark/zipball/fb49114bc8033b125f9d19473dc0741385131d84", + "reference": "fb49114bc8033b125f9d19473dc0741385131d84", "shasum": "" }, "require": { @@ -9005,7 +9287,7 @@ } ], "description": "A Swiftmailer Transport for Postmark.", - "time": "2016-09-13 20:43:41" + "time": "2017-04-18 14:24:10" }, { "name": "zendframework/zend-escaper", @@ -9575,16 +9857,16 @@ }, { "name": "codeception/c3", - "version": "2.0.10", + "version": "2.0.12", "source": { "type": "git", "url": "https://github.com/Codeception/c3.git", - "reference": "47842d23030638237fd3306657c5fe998273fc18" + "reference": "f08f20b0b6191f0c58be022c6f20d5b1cdc1004c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/c3/zipball/47842d23030638237fd3306657c5fe998273fc18", - "reference": "47842d23030638237fd3306657c5fe998273fc18", + "url": "https://api.github.com/repos/Codeception/c3/zipball/f08f20b0b6191f0c58be022c6f20d5b1cdc1004c", + "reference": "f08f20b0b6191f0c58be022c6f20d5b1cdc1004c", "shasum": "" }, "require": { @@ -9621,7 +9903,7 @@ "code coverage", "codecoverage" ], - "time": "2017-02-04 01:52:32" + "time": "2017-04-06 00:08:55" }, { "name": "codeception/codeception", @@ -10933,7 +11215,7 @@ }, { "name": "symfony/browser-kit", - "version": "v3.2.6", + "version": "v3.2.7", "source": { "type": "git", "url": "https://github.com/symfony/browser-kit.git", @@ -10990,7 +11272,7 @@ }, { "name": "symfony/dom-crawler", - "version": "v3.2.6", + "version": "v3.2.7", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", @@ -11098,7 +11380,6 @@ "aliases": [], "minimum-stability": "stable", "stability-flags": { - "omnipay/mollie": 20, "omnipay/2checkout": 20, "omnipay/gocardless": 20, "omnipay/stripe": 20, diff --git a/database/migrations/2017_04_16_101744_add_custom_contact_fields.php b/database/migrations/2017_04_16_101744_add_custom_contact_fields.php new file mode 100644 index 000000000000..45ae7b57a595 --- /dev/null +++ b/database/migrations/2017_04_16_101744_add_custom_contact_fields.php @@ -0,0 +1,145 @@ +string('custom_contact_label1')->nullable(); + $table->string('custom_contact_label2')->nullable(); + }); + + Schema::table('contacts', function ($table) { + $table->string('custom_value1')->nullable(); + $table->string('custom_value2')->nullable(); + }); + + Schema::table('payment_methods', function ($table) { + $table->unsignedInteger('account_gateway_token_id')->nullable()->change(); + $table->dropForeign('payment_methods_account_gateway_token_id_foreign'); + }); + + Schema::table('payment_methods', function ($table) { + $table->foreign('account_gateway_token_id')->references('id')->on('account_gateway_tokens')->onDelete('cascade'); + }); + + Schema::table('payments', function ($table) { + $table->dropForeign('payments_payment_method_id_foreign'); + }); + + Schema::table('payments', function ($table) { + $table->foreign('payment_method_id')->references('id')->on('payment_methods')->onDelete('cascade'); + }); + + Schema::table('expenses', function($table) { + $table->unsignedInteger('payment_type_id')->nullable(); + $table->date('payment_date')->nullable(); + $table->string('transaction_reference')->nullable(); + $table->foreign('payment_type_id')->references('id')->on('payment_types'); + $table->boolean('invoice_documents')->default(true); + }); + + // remove duplicate annual frequency + if (DB::table('frequencies')->count() == 9) { + DB::statement('update invoices set frequency_id = 8 where is_recurring = 1 and frequency_id = 9'); + DB::statement('update accounts set reset_counter_frequency_id = 8 where reset_counter_frequency_id = 9'); + DB::statement('update frequencies set name = "Annually" where id = 8'); + DB::statement('delete from frequencies where id = 9'); + } + + Schema::create('db_servers', function ($table) { + $table->increments('id'); + $table->string('name'); + }); + + Schema::create('lookup_companies', function ($table) { + $table->increments('id'); + $table->unsignedInteger('db_server_id'); + + $table->foreign('db_server_id')->references('id')->on('db_servers'); + }); + + Schema::create('lookup_accounts', function ($table) { + $table->increments('id'); + $table->unsignedInteger('lookup_company_id')->index(); + $table->string('account_key'); + + $table->foreign('lookup_company_id')->references('id')->on('lookup_companies')->onDelete('cascade'); + }); + + Schema::create('lookup_users', function ($table) { + $table->increments('id'); + $table->unsignedInteger('lookup_account_id')->index(); + $table->string('email'); + + $table->foreign('lookup_account_id')->references('id')->on('lookup_accounts')->onDelete('cascade'); + }); + + Schema::create('lookup_contacts', function ($table) { + $table->increments('id'); + $table->unsignedInteger('lookup_account_id')->index(); + $table->string('contact_key'); + + $table->foreign('lookup_account_id')->references('id')->on('lookup_accounts')->onDelete('cascade'); + }); + + Schema::create('lookup_invitations', function ($table) { + $table->increments('id'); + $table->unsignedInteger('lookup_account_id')->index(); + $table->string('invitation_key'); + $table->string('message_id'); + + $table->foreign('lookup_account_id')->references('id')->on('lookup_accounts')->onDelete('cascade'); + }); + + Schema::create('lookup_tokens', function ($table) { + $table->increments('id'); + $table->unsignedInteger('lookup_account_id')->index(); + $table->string('token'); + + $table->foreign('lookup_account_id')->references('id')->on('lookup_accounts')->onDelete('cascade'); + }); + + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function ($table) { + $table->dropColumn('custom_contact_label1'); + $table->dropColumn('custom_contact_label2'); + }); + + Schema::table('contacts', function ($table) { + $table->dropColumn('custom_value1'); + $table->dropColumn('custom_value2'); + }); + + Schema::table('expenses', function($table) { + $table->dropColumn('payment_type_id'); + $table->dropColumn('payment_date'); + $table->dropColumn('transaction_reference'); + $table->dropColumn('invoice_documents'); + }); + + Schema::dropIfExists('db_servers'); + Schema::dropIfExists('lookup_companies'); + Schema::dropIfExists('lookup_accounts'); + Schema::dropIfExists('lookup_users'); + Schema::dropIfExists('lookup_contacts'); + Schema::dropIfExists('lookup_invitations'); + Schema::dropIfExists('lookup_tokens'); + } +} diff --git a/database/seeds/CurrenciesSeeder.php b/database/seeds/CurrenciesSeeder.php index dec8b15f7e15..b6c87bdd3b52 100644 --- a/database/seeds/CurrenciesSeeder.php +++ b/database/seeds/CurrenciesSeeder.php @@ -72,6 +72,7 @@ class CurrenciesSeeder extends Seeder ['name' => 'Taiwan New Dollar', 'code' => 'TWD', 'symbol' => 'NT$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], ['name' => 'Dominican Peso', 'code' => 'DOP', 'symbol' => 'RD$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], ['name' => 'Chilean Peso', 'code' => 'CLP', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','], + ['name' => 'Icelandic Króna', 'code' => 'ISK', 'symbol' => 'kr', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ',', 'swap_currency_symbol' => true], ]; foreach ($currencies as $currency) { diff --git a/database/seeds/LanguageSeeder.php b/database/seeds/LanguageSeeder.php index b597d070b0e4..641445aa314b 100644 --- a/database/seeds/LanguageSeeder.php +++ b/database/seeds/LanguageSeeder.php @@ -31,6 +31,7 @@ class LanguageSeeder extends Seeder ['name' => 'Croatian', 'locale' => 'hr'], ['name' => 'Albanian', 'locale' => 'sq'], ['name' => 'Greek', 'locale' => 'el'], + ['name' => 'English - United Kingdom', 'locale' => 'en_UK'], ]; foreach ($languages as $language) { diff --git a/database/setup.sql b/database/setup.sql index ebe86b7c7fc7..9f042032fd5a 100644 --- a/database/setup.sql +++ b/database/setup.sql @@ -1,8 +1,8 @@ --- MySQL dump 10.13 Distrib 5.7.17, for Linux (x86_64) +-- MySQL dump 10.13 Distrib 5.7.18, for Linux (x86_64) -- -- Host: localhost Database: ninja -- ------------------------------------------------------ --- Server version 5.7.17-0ubuntu0.16.04.1 +-- Server version 5.7.18-0ubuntu0.16.04.1 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -353,6 +353,8 @@ CREATE TABLE `accounts` ( `payment_type_id` smallint(6) DEFAULT NULL, `gateway_fee_enabled` tinyint(1) NOT NULL DEFAULT '0', `reset_counter_date` date DEFAULT NULL, + `custom_contact_label1` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `custom_contact_label2` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `accounts_account_key_unique` (`account_key`), KEY `accounts_timezone_id_foreign` (`timezone_id`), @@ -711,6 +713,8 @@ CREATE TABLE `contacts` ( `remember_token` tinyint(1) DEFAULT NULL, `contact_key` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `bot_user_id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `custom_value1` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `custom_value2` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `contacts_account_id_public_id_unique` (`account_id`,`public_id`), UNIQUE KEY `contacts_contact_key_unique` (`contact_key`), @@ -831,7 +835,7 @@ CREATE TABLE `currencies` ( `code` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `swap_currency_symbol` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=60 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=64 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -840,7 +844,7 @@ CREATE TABLE `currencies` ( LOCK TABLES `currencies` WRITE; /*!40000 ALTER TABLE `currencies` DISABLE KEYS */; -INSERT INTO `currencies` VALUES (1,'US Dollar','$','2',',','.','USD',0),(2,'British Pound','£','2',',','.','GBP',0),(3,'Euro','€','2','.',',','EUR',0),(4,'South African Rand','R','2','.',',','ZAR',0),(5,'Danish Krone','kr','2','.',',','DKK',1),(6,'Israeli Shekel','NIS ','2',',','.','ILS',0),(7,'Swedish Krona','kr','2','.',',','SEK',1),(8,'Kenyan Shilling','KSh ','2',',','.','KES',0),(9,'Canadian Dollar','C$','2',',','.','CAD',0),(10,'Philippine Peso','P ','2',',','.','PHP',0),(11,'Indian Rupee','Rs. ','2',',','.','INR',0),(12,'Australian Dollar','$','2',',','.','AUD',0),(13,'Singapore Dollar','','2',',','.','SGD',0),(14,'Norske Kroner','kr','2','.',',','NOK',1),(15,'New Zealand Dollar','$','2',',','.','NZD',0),(16,'Vietnamese Dong','','0','.',',','VND',0),(17,'Swiss Franc','','2','\'','.','CHF',0),(18,'Guatemalan Quetzal','Q','2',',','.','GTQ',0),(19,'Malaysian Ringgit','RM','2',',','.','MYR',0),(20,'Brazilian Real','R$','2','.',',','BRL',0),(21,'Thai Baht','','2',',','.','THB',0),(22,'Nigerian Naira','','2',',','.','NGN',0),(23,'Argentine Peso','$','2','.',',','ARS',0),(24,'Bangladeshi Taka','Tk','2',',','.','BDT',0),(25,'United Arab Emirates Dirham','DH ','2',',','.','AED',0),(26,'Hong Kong Dollar','','2',',','.','HKD',0),(27,'Indonesian Rupiah','Rp','2',',','.','IDR',0),(28,'Mexican Peso','$','2',',','.','MXN',0),(29,'Egyptian Pound','E£','2',',','.','EGP',0),(30,'Colombian Peso','$','2','.',',','COP',0),(31,'West African Franc','CFA ','2',',','.','XOF',0),(32,'Chinese Renminbi','RMB ','2',',','.','CNY',0),(33,'Rwandan Franc','RF ','2',',','.','RWF',0),(34,'Tanzanian Shilling','TSh ','2',',','.','TZS',0),(35,'Netherlands Antillean Guilder','','2','.',',','ANG',0),(36,'Trinidad and Tobago Dollar','TT$','2',',','.','TTD',0),(37,'East Caribbean Dollar','EC$','2',',','.','XCD',0),(38,'Ghanaian Cedi','','2',',','.','GHS',0),(39,'Bulgarian Lev','','2',' ','.','BGN',0),(40,'Aruban Florin','Afl. ','2',' ','.','AWG',0),(41,'Turkish Lira','TL ','2','.',',','TRY',0),(42,'Romanian New Leu','','2',',','.','RON',0),(43,'Croatian Kuna','kn','2','.',',','HRK',0),(44,'Saudi Riyal','','2',',','.','SAR',0),(45,'Japanese Yen','¥','0',',','.','JPY',0),(46,'Maldivian Rufiyaa','','2',',','.','MVR',0),(47,'Costa Rican Colón','','2',',','.','CRC',0),(48,'Pakistani Rupee','Rs ','0',',','.','PKR',0),(49,'Polish Zloty','zł','2',' ',',','PLN',1),(50,'Sri Lankan Rupee','LKR','2',',','.','LKR',1),(51,'Czech Koruna','Kč','2',' ',',','CZK',1),(52,'Uruguayan Peso','$','2','.',',','UYU',0),(53,'Namibian Dollar','$','2',',','.','NAD',0),(54,'Tunisian Dinar','','2',',','.','TND',0),(55,'Russian Ruble','','2',',','.','RUB',0),(56,'Mozambican Metical','MT','2','.',',','MZN',1),(57,'Omani Rial','','2',',','.','OMR',0),(58,'Ukrainian Hryvnia','','2',',','.','UAH',0),(59,'Macanese Pataca','MOP$','2',',','.','MOP',0); +INSERT INTO `currencies` VALUES (1,'US Dollar','$','2',',','.','USD',0),(2,'British Pound','£','2',',','.','GBP',0),(3,'Euro','€','2','.',',','EUR',0),(4,'South African Rand','R','2','.',',','ZAR',0),(5,'Danish Krone','kr','2','.',',','DKK',1),(6,'Israeli Shekel','NIS ','2',',','.','ILS',0),(7,'Swedish Krona','kr','2','.',',','SEK',1),(8,'Kenyan Shilling','KSh ','2',',','.','KES',0),(9,'Canadian Dollar','C$','2',',','.','CAD',0),(10,'Philippine Peso','P ','2',',','.','PHP',0),(11,'Indian Rupee','Rs. ','2',',','.','INR',0),(12,'Australian Dollar','$','2',',','.','AUD',0),(13,'Singapore Dollar','','2',',','.','SGD',0),(14,'Norske Kroner','kr','2','.',',','NOK',1),(15,'New Zealand Dollar','$','2',',','.','NZD',0),(16,'Vietnamese Dong','','0','.',',','VND',0),(17,'Swiss Franc','','2','\'','.','CHF',0),(18,'Guatemalan Quetzal','Q','2',',','.','GTQ',0),(19,'Malaysian Ringgit','RM','2',',','.','MYR',0),(20,'Brazilian Real','R$','2','.',',','BRL',0),(21,'Thai Baht','','2',',','.','THB',0),(22,'Nigerian Naira','','2',',','.','NGN',0),(23,'Argentine Peso','$','2','.',',','ARS',0),(24,'Bangladeshi Taka','Tk','2',',','.','BDT',0),(25,'United Arab Emirates Dirham','DH ','2',',','.','AED',0),(26,'Hong Kong Dollar','','2',',','.','HKD',0),(27,'Indonesian Rupiah','Rp','2',',','.','IDR',0),(28,'Mexican Peso','$','2',',','.','MXN',0),(29,'Egyptian Pound','E£','2',',','.','EGP',0),(30,'Colombian Peso','$','2','.',',','COP',0),(31,'West African Franc','CFA ','2',',','.','XOF',0),(32,'Chinese Renminbi','RMB ','2',',','.','CNY',0),(33,'Rwandan Franc','RF ','2',',','.','RWF',0),(34,'Tanzanian Shilling','TSh ','2',',','.','TZS',0),(35,'Netherlands Antillean Guilder','','2','.',',','ANG',0),(36,'Trinidad and Tobago Dollar','TT$','2',',','.','TTD',0),(37,'East Caribbean Dollar','EC$','2',',','.','XCD',0),(38,'Ghanaian Cedi','','2',',','.','GHS',0),(39,'Bulgarian Lev','','2',' ','.','BGN',0),(40,'Aruban Florin','Afl. ','2',' ','.','AWG',0),(41,'Turkish Lira','TL ','2','.',',','TRY',0),(42,'Romanian New Leu','','2',',','.','RON',0),(43,'Croatian Kuna','kn','2','.',',','HRK',0),(44,'Saudi Riyal','','2',',','.','SAR',0),(45,'Japanese Yen','¥','0',',','.','JPY',0),(46,'Maldivian Rufiyaa','','2',',','.','MVR',0),(47,'Costa Rican Colón','','2',',','.','CRC',0),(48,'Pakistani Rupee','Rs ','0',',','.','PKR',0),(49,'Polish Zloty','zł','2',' ',',','PLN',1),(50,'Sri Lankan Rupee','LKR','2',',','.','LKR',1),(51,'Czech Koruna','Kč','2',' ',',','CZK',1),(52,'Uruguayan Peso','$','2','.',',','UYU',0),(53,'Namibian Dollar','$','2',',','.','NAD',0),(54,'Tunisian Dinar','','2',',','.','TND',0),(55,'Russian Ruble','','2',',','.','RUB',0),(56,'Mozambican Metical','MT','2','.',',','MZN',1),(57,'Omani Rial','','2',',','.','OMR',0),(58,'Ukrainian Hryvnia','','2',',','.','UAH',0),(59,'Macanese Pataca','MOP$','2',',','.','MOP',0),(60,'Taiwan New Dollar','NT$','2',',','.','TWD',0),(61,'Dominican Peso','RD$','2',',','.','DOP',0),(62,'Chilean Peso','$','2','.',',','CLP',0),(63,'Icelandic Króna','kr','2','.',',','ISK',1); /*!40000 ALTER TABLE `currencies` ENABLE KEYS */; UNLOCK TABLES; @@ -895,6 +899,29 @@ INSERT INTO `datetime_formats` VALUES (1,'d/M/Y g:i a','DD/MMM/YYYY h:mm:ss a'), /*!40000 ALTER TABLE `datetime_formats` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `db_servers` +-- + +DROP TABLE IF EXISTS `db_servers`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `db_servers` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `db_servers` +-- + +LOCK TABLES `db_servers` WRITE; +/*!40000 ALTER TABLE `db_servers` DISABLE KEYS */; +/*!40000 ALTER TABLE `db_servers` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `documents` -- @@ -1011,6 +1038,10 @@ CREATE TABLE `expenses` ( `tax_rate1` decimal(13,3) NOT NULL, `tax_name2` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `tax_rate2` decimal(13,3) NOT NULL, + `payment_type_id` int(10) unsigned DEFAULT NULL, + `payment_date` date DEFAULT NULL, + `transaction_reference` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `invoice_documents` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `expenses_account_id_public_id_unique` (`account_id`,`public_id`), KEY `expenses_user_id_foreign` (`user_id`), @@ -1019,10 +1050,12 @@ CREATE TABLE `expenses` ( KEY `expenses_expense_currency_id_index` (`expense_currency_id`), KEY `expenses_invoice_currency_id_foreign` (`invoice_currency_id`), KEY `expenses_expense_category_id_index` (`expense_category_id`), + KEY `expenses_payment_type_id_foreign` (`payment_type_id`), CONSTRAINT `expenses_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE, CONSTRAINT `expenses_expense_category_id_foreign` FOREIGN KEY (`expense_category_id`) REFERENCES `expense_categories` (`id`) ON DELETE CASCADE, CONSTRAINT `expenses_expense_currency_id_foreign` FOREIGN KEY (`expense_currency_id`) REFERENCES `currencies` (`id`), CONSTRAINT `expenses_invoice_currency_id_foreign` FOREIGN KEY (`invoice_currency_id`) REFERENCES `currencies` (`id`), + CONSTRAINT `expenses_payment_type_id_foreign` FOREIGN KEY (`payment_type_id`) REFERENCES `payment_types` (`id`), CONSTRAINT `expenses_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -1176,7 +1209,7 @@ CREATE TABLE `gateways` ( LOCK TABLES `gateways` WRITE; /*!40000 ALTER TABLE `gateways` DISABLE KEYS */; -INSERT INTO `gateways` VALUES (1,'2017-04-06 10:56:18','2017-04-06 10:56:18','Authorize.Net AIM','AuthorizeNet_AIM',1,1,4,0,NULL,0,0),(2,'2017-04-06 10:56:18','2017-04-06 10:56:18','Authorize.Net SIM','AuthorizeNet_SIM',1,2,10000,0,NULL,0,0),(3,'2017-04-06 10:56:18','2017-04-06 10:56:18','CardSave','CardSave',1,1,10000,0,NULL,0,0),(4,'2017-04-06 10:56:18','2017-04-06 10:56:18','Eway Rapid','Eway_RapidShared',1,1,10000,0,NULL,1,0),(5,'2017-04-06 10:56:18','2017-04-06 10:56:18','FirstData Connect','FirstData_Connect',1,1,10000,0,NULL,0,0),(6,'2017-04-06 10:56:18','2017-04-06 10:56:18','GoCardless','GoCardless',1,1,10000,0,NULL,1,0),(7,'2017-04-06 10:56:18','2017-04-06 10:56:18','Migs ThreeParty','Migs_ThreeParty',1,1,10000,0,NULL,0,0),(8,'2017-04-06 10:56:18','2017-04-06 10:56:18','Migs TwoParty','Migs_TwoParty',1,1,10000,0,NULL,0,0),(9,'2017-04-06 10:56:18','2017-04-06 10:56:18','Mollie','Mollie',1,1,7,0,NULL,1,0),(10,'2017-04-06 10:56:18','2017-04-06 10:56:18','MultiSafepay','MultiSafepay',1,1,10000,0,NULL,0,0),(11,'2017-04-06 10:56:18','2017-04-06 10:56:18','Netaxept','Netaxept',1,1,10000,0,NULL,0,0),(12,'2017-04-06 10:56:18','2017-04-06 10:56:18','NetBanx','NetBanx',1,1,10000,0,NULL,0,0),(13,'2017-04-06 10:56:18','2017-04-06 10:56:18','PayFast','PayFast',1,1,10000,0,NULL,1,0),(14,'2017-04-06 10:56:18','2017-04-06 10:56:18','Payflow Pro','Payflow_Pro',1,1,10000,0,NULL,0,0),(15,'2017-04-06 10:56:18','2017-04-06 10:56:18','PaymentExpress PxPay','PaymentExpress_PxPay',1,1,10000,0,NULL,0,0),(16,'2017-04-06 10:56:18','2017-04-06 10:56:18','PaymentExpress PxPost','PaymentExpress_PxPost',1,1,10000,0,NULL,0,0),(17,'2017-04-06 10:56:18','2017-04-06 10:56:18','PayPal Express','PayPal_Express',1,1,3,0,NULL,1,0),(18,'2017-04-06 10:56:18','2017-04-06 10:56:18','PayPal Pro','PayPal_Pro',1,1,10000,0,NULL,0,0),(19,'2017-04-06 10:56:18','2017-04-06 10:56:18','Pin','Pin',1,1,10000,0,NULL,0,0),(20,'2017-04-06 10:56:18','2017-04-06 10:56:18','SagePay Direct','SagePay_Direct',1,1,10000,0,NULL,0,0),(21,'2017-04-06 10:56:18','2017-04-06 10:56:18','SagePay Server','SagePay_Server',1,1,10000,0,NULL,0,0),(22,'2017-04-06 10:56:18','2017-04-06 10:56:18','SecurePay DirectPost','SecurePay_DirectPost',1,1,10000,0,NULL,0,0),(23,'2017-04-06 10:56:18','2017-04-06 10:56:18','Stripe','Stripe',1,1,1,0,NULL,0,0),(24,'2017-04-06 10:56:18','2017-04-06 10:56:18','TargetPay Direct eBanking','TargetPay_Directebanking',1,1,10000,0,NULL,0,0),(25,'2017-04-06 10:56:18','2017-04-06 10:56:18','TargetPay Ideal','TargetPay_Ideal',1,1,10000,0,NULL,0,0),(26,'2017-04-06 10:56:19','2017-04-06 10:56:19','TargetPay Mr Cash','TargetPay_Mrcash',1,1,10000,0,NULL,0,0),(27,'2017-04-06 10:56:19','2017-04-06 10:56:19','TwoCheckout','TwoCheckout',1,1,10000,0,NULL,1,0),(28,'2017-04-06 10:56:19','2017-04-06 10:56:19','WorldPay','WorldPay',1,1,10000,0,NULL,0,0),(29,'2017-04-06 10:56:19','2017-04-06 10:56:19','BeanStream','BeanStream',1,2,10000,0,NULL,0,0),(30,'2017-04-06 10:56:19','2017-04-06 10:56:19','Psigate','Psigate',1,2,10000,0,NULL,0,0),(31,'2017-04-06 10:56:19','2017-04-06 10:56:19','moolah','AuthorizeNet_AIM',1,1,10000,0,NULL,0,0),(32,'2017-04-06 10:56:19','2017-04-06 10:56:19','Alipay','Alipay_Express',1,1,10000,0,NULL,0,0),(33,'2017-04-06 10:56:19','2017-04-06 10:56:19','Buckaroo','Buckaroo_CreditCard',1,1,10000,0,NULL,0,0),(34,'2017-04-06 10:56:19','2017-04-06 10:56:19','Coinbase','Coinbase',1,1,10000,0,NULL,0,0),(35,'2017-04-06 10:56:19','2017-04-06 10:56:19','DataCash','DataCash',1,1,10000,0,NULL,0,0),(36,'2017-04-06 10:56:19','2017-04-06 10:56:19','Neteller','Neteller',1,2,10000,0,NULL,0,0),(37,'2017-04-06 10:56:19','2017-04-06 10:56:19','Pacnet','Pacnet',1,1,10000,0,NULL,0,0),(38,'2017-04-06 10:56:19','2017-04-06 10:56:19','PaymentSense','PaymentSense',1,2,10000,0,NULL,0,0),(39,'2017-04-06 10:56:19','2017-04-06 10:56:19','Realex','Realex_Remote',1,1,10000,0,NULL,0,0),(40,'2017-04-06 10:56:19','2017-04-06 10:56:19','Sisow','Sisow',1,1,10000,0,NULL,0,0),(41,'2017-04-06 10:56:19','2017-04-06 10:56:19','Skrill','Skrill',1,1,10000,0,NULL,1,0),(42,'2017-04-06 10:56:19','2017-04-06 10:56:19','BitPay','BitPay',1,1,6,0,NULL,1,0),(43,'2017-04-06 10:56:19','2017-04-06 10:56:19','Dwolla','Dwolla',1,1,5,0,NULL,1,0),(44,'2017-04-06 10:56:19','2017-04-06 10:56:19','AGMS','Agms',1,1,10000,0,NULL,0,0),(45,'2017-04-06 10:56:19','2017-04-06 10:56:19','Barclays','BarclaysEpdq\\Essential',1,1,10000,0,NULL,0,0),(46,'2017-04-06 10:56:19','2017-04-06 10:56:19','Cardgate','Cardgate',1,1,10000,0,NULL,0,0),(47,'2017-04-06 10:56:19','2017-04-06 10:56:19','Checkout.com','CheckoutCom',1,1,10000,0,NULL,0,0),(48,'2017-04-06 10:56:19','2017-04-06 10:56:19','Creditcall','Creditcall',1,1,10000,0,NULL,0,0),(49,'2017-04-06 10:56:19','2017-04-06 10:56:19','Cybersource','Cybersource',1,1,10000,0,NULL,0,0),(50,'2017-04-06 10:56:19','2017-04-06 10:56:19','ecoPayz','Ecopayz',1,1,10000,0,NULL,0,0),(51,'2017-04-06 10:56:19','2017-04-06 10:56:19','Fasapay','Fasapay',1,1,10000,0,NULL,0,0),(52,'2017-04-06 10:56:19','2017-04-06 10:56:19','Komoju','Komoju',1,1,10000,0,NULL,0,0),(53,'2017-04-06 10:56:19','2017-04-06 10:56:19','Multicards','Multicards',1,1,10000,0,NULL,0,0),(54,'2017-04-06 10:56:19','2017-04-06 10:56:19','Pagar.Me','Pagarme',1,2,10000,0,NULL,0,0),(55,'2017-04-06 10:56:19','2017-04-06 10:56:19','Paysafecard','Paysafecard',1,1,10000,0,NULL,0,0),(56,'2017-04-06 10:56:19','2017-04-06 10:56:19','Paytrace','Paytrace_CreditCard',1,1,10000,0,NULL,0,0),(57,'2017-04-06 10:56:19','2017-04-06 10:56:19','Secure Trading','SecureTrading',1,1,10000,0,NULL,0,0),(58,'2017-04-06 10:56:19','2017-04-06 10:56:19','SecPay','SecPay',1,1,10000,0,NULL,0,0),(59,'2017-04-06 10:56:19','2017-04-06 10:56:19','WeChat Express','WeChat_Express',1,2,10000,0,NULL,0,0),(60,'2017-04-06 10:56:19','2017-04-06 10:56:19','WePay','WePay',1,1,10000,0,NULL,0,0),(61,'2017-04-06 10:56:19','2017-04-06 10:56:19','Braintree','Braintree',1,1,2,0,NULL,0,0),(62,'2017-04-06 10:56:19','2017-04-06 10:56:19','Custom','Custom',1,1,8,0,NULL,1,0); +INSERT INTO `gateways` VALUES (1,'2017-04-30 10:36:46','2017-04-30 10:36:46','Authorize.Net AIM','AuthorizeNet_AIM',1,1,4,0,NULL,0,0),(2,'2017-04-30 10:36:46','2017-04-30 10:36:46','Authorize.Net SIM','AuthorizeNet_SIM',1,2,10000,0,NULL,0,0),(3,'2017-04-30 10:36:46','2017-04-30 10:36:46','CardSave','CardSave',1,1,10000,0,NULL,0,0),(4,'2017-04-30 10:36:46','2017-04-30 10:36:46','Eway Rapid','Eway_RapidShared',1,1,10000,0,NULL,1,0),(5,'2017-04-30 10:36:46','2017-04-30 10:36:46','FirstData Connect','FirstData_Connect',1,1,10000,0,NULL,0,0),(6,'2017-04-30 10:36:46','2017-04-30 10:36:46','GoCardless','GoCardless',1,1,10000,0,NULL,1,0),(7,'2017-04-30 10:36:46','2017-04-30 10:36:46','Migs ThreeParty','Migs_ThreeParty',1,1,10000,0,NULL,0,0),(8,'2017-04-30 10:36:46','2017-04-30 10:36:46','Migs TwoParty','Migs_TwoParty',1,1,10000,0,NULL,0,0),(9,'2017-04-30 10:36:46','2017-04-30 10:36:46','Mollie','Mollie',1,1,7,0,NULL,1,0),(10,'2017-04-30 10:36:46','2017-04-30 10:36:46','MultiSafepay','MultiSafepay',1,1,10000,0,NULL,0,0),(11,'2017-04-30 10:36:46','2017-04-30 10:36:46','Netaxept','Netaxept',1,1,10000,0,NULL,0,0),(12,'2017-04-30 10:36:46','2017-04-30 10:36:46','NetBanx','NetBanx',1,1,10000,0,NULL,0,0),(13,'2017-04-30 10:36:46','2017-04-30 10:36:46','PayFast','PayFast',1,1,10000,0,NULL,1,0),(14,'2017-04-30 10:36:46','2017-04-30 10:36:46','Payflow Pro','Payflow_Pro',1,1,10000,0,NULL,0,0),(15,'2017-04-30 10:36:46','2017-04-30 10:36:46','PaymentExpress PxPay','PaymentExpress_PxPay',1,1,10000,0,NULL,0,0),(16,'2017-04-30 10:36:46','2017-04-30 10:36:46','PaymentExpress PxPost','PaymentExpress_PxPost',1,1,10000,0,NULL,0,0),(17,'2017-04-30 10:36:46','2017-04-30 10:36:46','PayPal Express','PayPal_Express',1,1,3,0,NULL,1,0),(18,'2017-04-30 10:36:46','2017-04-30 10:36:46','PayPal Pro','PayPal_Pro',1,1,10000,0,NULL,0,0),(19,'2017-04-30 10:36:46','2017-04-30 10:36:46','Pin','Pin',1,1,10000,0,NULL,0,0),(20,'2017-04-30 10:36:46','2017-04-30 10:36:46','SagePay Direct','SagePay_Direct',1,1,10000,0,NULL,0,0),(21,'2017-04-30 10:36:46','2017-04-30 10:36:46','SagePay Server','SagePay_Server',1,1,10000,0,NULL,0,0),(22,'2017-04-30 10:36:46','2017-04-30 10:36:46','SecurePay DirectPost','SecurePay_DirectPost',1,1,10000,0,NULL,0,0),(23,'2017-04-30 10:36:47','2017-04-30 10:36:47','Stripe','Stripe',1,1,1,0,NULL,0,0),(24,'2017-04-30 10:36:47','2017-04-30 10:36:47','TargetPay Direct eBanking','TargetPay_Directebanking',1,1,10000,0,NULL,0,0),(25,'2017-04-30 10:36:47','2017-04-30 10:36:47','TargetPay Ideal','TargetPay_Ideal',1,1,10000,0,NULL,0,0),(26,'2017-04-30 10:36:47','2017-04-30 10:36:47','TargetPay Mr Cash','TargetPay_Mrcash',1,1,10000,0,NULL,0,0),(27,'2017-04-30 10:36:47','2017-04-30 10:36:47','TwoCheckout','TwoCheckout',1,1,10000,0,NULL,1,0),(28,'2017-04-30 10:36:47','2017-04-30 10:36:47','WorldPay','WorldPay',1,1,10000,0,NULL,0,0),(29,'2017-04-30 10:36:47','2017-04-30 10:36:47','BeanStream','BeanStream',1,2,10000,0,NULL,0,0),(30,'2017-04-30 10:36:47','2017-04-30 10:36:47','Psigate','Psigate',1,2,10000,0,NULL,0,0),(31,'2017-04-30 10:36:47','2017-04-30 10:36:47','moolah','AuthorizeNet_AIM',1,1,10000,0,NULL,0,0),(32,'2017-04-30 10:36:47','2017-04-30 10:36:47','Alipay','Alipay_Express',1,1,10000,0,NULL,0,0),(33,'2017-04-30 10:36:47','2017-04-30 10:36:47','Buckaroo','Buckaroo_CreditCard',1,1,10000,0,NULL,0,0),(34,'2017-04-30 10:36:47','2017-04-30 10:36:47','Coinbase','Coinbase',1,1,10000,0,NULL,0,0),(35,'2017-04-30 10:36:47','2017-04-30 10:36:47','DataCash','DataCash',1,1,10000,0,NULL,0,0),(36,'2017-04-30 10:36:47','2017-04-30 10:36:47','Neteller','Neteller',1,2,10000,0,NULL,0,0),(37,'2017-04-30 10:36:47','2017-04-30 10:36:47','Pacnet','Pacnet',1,1,10000,0,NULL,0,0),(38,'2017-04-30 10:36:47','2017-04-30 10:36:47','PaymentSense','PaymentSense',1,2,10000,0,NULL,0,0),(39,'2017-04-30 10:36:47','2017-04-30 10:36:47','Realex','Realex_Remote',1,1,10000,0,NULL,0,0),(40,'2017-04-30 10:36:47','2017-04-30 10:36:47','Sisow','Sisow',1,1,10000,0,NULL,0,0),(41,'2017-04-30 10:36:47','2017-04-30 10:36:47','Skrill','Skrill',1,1,10000,0,NULL,1,0),(42,'2017-04-30 10:36:47','2017-04-30 10:36:47','BitPay','BitPay',1,1,6,0,NULL,1,0),(43,'2017-04-30 10:36:47','2017-04-30 10:36:47','Dwolla','Dwolla',1,1,5,0,NULL,1,0),(44,'2017-04-30 10:36:47','2017-04-30 10:36:47','AGMS','Agms',1,1,10000,0,NULL,0,0),(45,'2017-04-30 10:36:47','2017-04-30 10:36:47','Barclays','BarclaysEpdq\\Essential',1,1,10000,0,NULL,0,0),(46,'2017-04-30 10:36:47','2017-04-30 10:36:47','Cardgate','Cardgate',1,1,10000,0,NULL,0,0),(47,'2017-04-30 10:36:47','2017-04-30 10:36:47','Checkout.com','CheckoutCom',1,1,10000,0,NULL,0,0),(48,'2017-04-30 10:36:47','2017-04-30 10:36:47','Creditcall','Creditcall',1,1,10000,0,NULL,0,0),(49,'2017-04-30 10:36:47','2017-04-30 10:36:47','Cybersource','Cybersource',1,1,10000,0,NULL,0,0),(50,'2017-04-30 10:36:47','2017-04-30 10:36:47','ecoPayz','Ecopayz',1,1,10000,0,NULL,0,0),(51,'2017-04-30 10:36:47','2017-04-30 10:36:47','Fasapay','Fasapay',1,1,10000,0,NULL,0,0),(52,'2017-04-30 10:36:47','2017-04-30 10:36:47','Komoju','Komoju',1,1,10000,0,NULL,0,0),(53,'2017-04-30 10:36:47','2017-04-30 10:36:47','Multicards','Multicards',1,1,10000,0,NULL,0,0),(54,'2017-04-30 10:36:47','2017-04-30 10:36:47','Pagar.Me','Pagarme',1,2,10000,0,NULL,0,0),(55,'2017-04-30 10:36:47','2017-04-30 10:36:47','Paysafecard','Paysafecard',1,1,10000,0,NULL,0,0),(56,'2017-04-30 10:36:47','2017-04-30 10:36:47','Paytrace','Paytrace_CreditCard',1,1,10000,0,NULL,0,0),(57,'2017-04-30 10:36:47','2017-04-30 10:36:47','Secure Trading','SecureTrading',1,1,10000,0,NULL,0,0),(58,'2017-04-30 10:36:47','2017-04-30 10:36:47','SecPay','SecPay',1,1,10000,0,NULL,0,0),(59,'2017-04-30 10:36:47','2017-04-30 10:36:47','WeChat Express','WeChat_Express',1,2,10000,0,NULL,0,0),(60,'2017-04-30 10:36:47','2017-04-30 10:36:47','WePay','WePay',1,1,10000,0,NULL,0,0),(61,'2017-04-30 10:36:47','2017-04-30 10:36:47','Braintree','Braintree',1,1,2,0,NULL,0,0),(62,'2017-04-30 10:36:47','2017-04-30 10:36:47','Custom','Custom',1,1,8,0,NULL,1,0); /*!40000 ALTER TABLE `gateways` ENABLE KEYS */; UNLOCK TABLES; @@ -1475,7 +1508,7 @@ CREATE TABLE `languages` ( `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `locale` varchar(255) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -1484,7 +1517,7 @@ CREATE TABLE `languages` ( LOCK TABLES `languages` WRITE; /*!40000 ALTER TABLE `languages` DISABLE KEYS */; -INSERT INTO `languages` VALUES (1,'English','en'),(2,'Italian','it'),(3,'German','de'),(4,'French','fr'),(5,'Brazilian Portuguese','pt_BR'),(6,'Dutch','nl'),(7,'Spanish','es'),(8,'Norwegian','nb_NO'),(9,'Danish','da'),(10,'Japanese','ja'),(11,'Swedish','sv'),(12,'Spanish - Spain','es_ES'),(13,'French - Canada','fr_CA'),(14,'Lithuanian','lt'),(15,'Polish','pl'),(16,'Czech','cs'),(17,'Croatian','hr'),(18,'Albanian','sq'),(19,'Greek','el'); +INSERT INTO `languages` VALUES (1,'English','en'),(2,'Italian','it'),(3,'German','de'),(4,'French','fr'),(5,'Brazilian Portuguese','pt_BR'),(6,'Dutch','nl'),(7,'Spanish','es'),(8,'Norwegian','nb_NO'),(9,'Danish','da'),(10,'Japanese','ja'),(11,'Swedish','sv'),(12,'Spanish - Spain','es_ES'),(13,'French - Canada','fr_CA'),(14,'Lithuanian','lt'),(15,'Polish','pl'),(16,'Czech','cs'),(17,'Croatian','hr'),(18,'Albanian','sq'),(19,'Greek','el'),(20,'English - United Kingdom','en_UK'); /*!40000 ALTER TABLE `languages` ENABLE KEYS */; UNLOCK TABLES; @@ -1524,6 +1557,162 @@ LOCK TABLES `licenses` WRITE; /*!40000 ALTER TABLE `licenses` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `lookup_accounts` +-- + +DROP TABLE IF EXISTS `lookup_accounts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `lookup_accounts` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `lookup_company_id` int(10) unsigned NOT NULL, + `account_key` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`), + KEY `lookup_accounts_lookup_company_id_index` (`lookup_company_id`), + CONSTRAINT `lookup_accounts_lookup_company_id_foreign` FOREIGN KEY (`lookup_company_id`) REFERENCES `lookup_companies` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `lookup_accounts` +-- + +LOCK TABLES `lookup_accounts` WRITE; +/*!40000 ALTER TABLE `lookup_accounts` DISABLE KEYS */; +/*!40000 ALTER TABLE `lookup_accounts` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `lookup_companies` +-- + +DROP TABLE IF EXISTS `lookup_companies`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `lookup_companies` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `db_server_id` int(10) unsigned NOT NULL, + PRIMARY KEY (`id`), + KEY `lookup_companies_db_server_id_foreign` (`db_server_id`), + CONSTRAINT `lookup_companies_db_server_id_foreign` FOREIGN KEY (`db_server_id`) REFERENCES `db_servers` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `lookup_companies` +-- + +LOCK TABLES `lookup_companies` WRITE; +/*!40000 ALTER TABLE `lookup_companies` DISABLE KEYS */; +/*!40000 ALTER TABLE `lookup_companies` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `lookup_contacts` +-- + +DROP TABLE IF EXISTS `lookup_contacts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `lookup_contacts` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `lookup_account_id` int(10) unsigned NOT NULL, + `contact_key` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`), + KEY `lookup_contacts_lookup_account_id_index` (`lookup_account_id`), + CONSTRAINT `lookup_contacts_lookup_account_id_foreign` FOREIGN KEY (`lookup_account_id`) REFERENCES `lookup_accounts` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `lookup_contacts` +-- + +LOCK TABLES `lookup_contacts` WRITE; +/*!40000 ALTER TABLE `lookup_contacts` DISABLE KEYS */; +/*!40000 ALTER TABLE `lookup_contacts` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `lookup_invitations` +-- + +DROP TABLE IF EXISTS `lookup_invitations`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `lookup_invitations` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `lookup_account_id` int(10) unsigned NOT NULL, + `invitation_key` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `message_id` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`), + KEY `lookup_invitations_lookup_account_id_index` (`lookup_account_id`), + CONSTRAINT `lookup_invitations_lookup_account_id_foreign` FOREIGN KEY (`lookup_account_id`) REFERENCES `lookup_accounts` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `lookup_invitations` +-- + +LOCK TABLES `lookup_invitations` WRITE; +/*!40000 ALTER TABLE `lookup_invitations` DISABLE KEYS */; +/*!40000 ALTER TABLE `lookup_invitations` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `lookup_tokens` +-- + +DROP TABLE IF EXISTS `lookup_tokens`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `lookup_tokens` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `lookup_account_id` int(10) unsigned NOT NULL, + `token` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`), + KEY `lookup_tokens_lookup_account_id_index` (`lookup_account_id`), + CONSTRAINT `lookup_tokens_lookup_account_id_foreign` FOREIGN KEY (`lookup_account_id`) REFERENCES `lookup_accounts` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `lookup_tokens` +-- + +LOCK TABLES `lookup_tokens` WRITE; +/*!40000 ALTER TABLE `lookup_tokens` DISABLE KEYS */; +/*!40000 ALTER TABLE `lookup_tokens` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `lookup_users` +-- + +DROP TABLE IF EXISTS `lookup_users`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `lookup_users` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `lookup_account_id` int(10) unsigned NOT NULL, + `email` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`), + KEY `lookup_users_lookup_account_id_index` (`lookup_account_id`), + CONSTRAINT `lookup_users_lookup_account_id_foreign` FOREIGN KEY (`lookup_account_id`) REFERENCES `lookup_accounts` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `lookup_users` +-- + +LOCK TABLES `lookup_users` WRITE; +/*!40000 ALTER TABLE `lookup_users` DISABLE KEYS */; +/*!40000 ALTER TABLE `lookup_users` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `migrations` -- @@ -1543,7 +1732,7 @@ CREATE TABLE `migrations` ( LOCK TABLES `migrations` WRITE; /*!40000 ALTER TABLE `migrations` DISABLE KEYS */; -INSERT INTO `migrations` VALUES ('2013_11_05_180133_confide_setup_users_table',1),('2013_11_28_195703_setup_countries_table',1),('2014_02_13_151500_add_cascase_drops',1),('2014_02_19_151817_add_support_for_invoice_designs',1),('2014_03_03_155556_add_phone_to_account',1),('2014_03_19_201454_add_language_support',1),('2014_03_20_200300_create_payment_libraries',1),('2014_03_23_051736_enable_forcing_jspdf',1),('2014_03_25_102200_add_sort_and_recommended_to_gateways',1),('2014_04_03_191105_add_pro_plan',1),('2014_04_17_100523_add_remember_token',1),('2014_04_17_145108_add_custom_fields',1),('2014_04_23_170909_add_products_settings',1),('2014_04_29_174315_add_advanced_settings',1),('2014_05_17_175626_add_quotes',1),('2014_06_17_131940_add_accepted_credit_cards_to_account_gateways',1),('2014_07_13_142654_one_click_install',1),('2014_07_17_205900_support_hiding_quantity',1),('2014_07_24_171214_add_zapier_support',1),('2014_10_01_141248_add_company_vat_number',1),('2014_10_05_141856_track_last_seen_message',1),('2014_10_06_103529_add_timesheets',1),('2014_10_06_195330_add_invoice_design_table',1),('2014_10_13_054100_add_invoice_number_settings',1),('2014_10_14_225227_add_danish_translation',1),('2014_10_22_174452_add_affiliate_price',1),('2014_10_30_184126_add_company_id_number',1),('2014_11_04_200406_allow_null_client_currency',1),('2014_12_03_154119_add_discount_type',1),('2015_02_12_102940_add_email_templates',1),('2015_02_17_131714_support_token_billing',1),('2015_02_27_081836_add_invoice_footer',1),('2015_03_03_140259_add_tokens',1),('2015_03_09_151011_add_ip_to_activity',1),('2015_03_15_174122_add_pdf_email_attachment_option',1),('2015_03_30_100000_create_password_resets_table',1),('2015_04_12_093447_add_sv_language',1),('2015_04_13_100333_add_notify_approved',1),('2015_04_16_122647_add_partial_amount_to_invoices',1),('2015_05_21_184104_add_font_size',1),('2015_05_27_121828_add_tasks',1),('2015_05_27_170808_add_custom_invoice_labels',1),('2015_06_09_134208_add_has_tasks_to_invoices',1),('2015_06_14_093410_enable_resuming_tasks',1),('2015_06_14_173025_multi_company_support',1),('2015_07_07_160257_support_locking_account',1),('2015_07_08_114333_simplify_tasks',1),('2015_07_19_081332_add_custom_design',1),('2015_07_27_183830_add_pdfmake_support',1),('2015_08_13_084041_add_formats_to_datetime_formats_table',1),('2015_09_04_080604_add_swap_postal_code',1),('2015_09_07_135935_add_account_domain',1),('2015_09_10_185135_add_reminder_emails',1),('2015_10_07_135651_add_social_login',1),('2015_10_21_075058_add_default_tax_rates',1),('2015_10_21_185724_add_invoice_number_pattern',1),('2015_10_27_180214_add_is_system_to_activities',1),('2015_10_29_133747_add_default_quote_terms',1),('2015_11_01_080417_encrypt_tokens',1),('2015_11_03_181318_improve_currency_localization',1),('2015_11_30_133206_add_email_designs',1),('2015_12_27_154513_add_reminder_settings',1),('2015_12_30_042035_add_client_view_css',1),('2016_01_04_175228_create_vendors_table',1),('2016_01_06_153144_add_invoice_font_support',1),('2016_01_17_155725_add_quote_to_invoice_option',1),('2016_01_18_195351_add_bank_accounts',1),('2016_01_24_112646_add_bank_subaccounts',1),('2016_01_27_173015_add_header_footer_option',1),('2016_02_01_135956_add_source_currency_to_expenses',1),('2016_02_25_152948_add_client_password',1),('2016_02_28_081424_add_custom_invoice_fields',1),('2016_03_14_066181_add_user_permissions',1),('2016_03_14_214710_add_support_three_decimal_taxes',1),('2016_03_22_168362_add_documents',1),('2016_03_23_215049_support_multiple_tax_rates',1),('2016_04_16_103943_enterprise_plan',1),('2016_04_18_174135_add_page_size',1),('2016_04_23_182223_payments_changes',1),('2016_05_16_102925_add_swap_currency_symbol_to_currency',1),('2016_05_18_085739_add_invoice_type_support',1),('2016_05_24_164847_wepay_ach',1),('2016_07_08_083802_support_new_pricing',1),('2016_07_13_083821_add_buy_now_buttons',1),('2016_08_10_184027_add_support_for_bots',1),('2016_09_05_150625_create_gateway_types',1),('2016_10_20_191150_add_expense_to_activities',1),('2016_11_03_113316_add_invoice_signature',1),('2016_11_03_161149_add_bluevine_fields',1),('2016_11_28_092904_add_task_projects',1),('2016_12_13_113955_add_pro_plan_discount',1),('2017_01_01_214241_add_inclusive_taxes',1),('2017_02_23_095934_add_custom_product_fields',1),('2017_03_16_085702_add_gateway_fee_location',1); +INSERT INTO `migrations` VALUES ('2013_11_05_180133_confide_setup_users_table',1),('2013_11_28_195703_setup_countries_table',1),('2014_02_13_151500_add_cascase_drops',1),('2014_02_19_151817_add_support_for_invoice_designs',1),('2014_03_03_155556_add_phone_to_account',1),('2014_03_19_201454_add_language_support',1),('2014_03_20_200300_create_payment_libraries',1),('2014_03_23_051736_enable_forcing_jspdf',1),('2014_03_25_102200_add_sort_and_recommended_to_gateways',1),('2014_04_03_191105_add_pro_plan',1),('2014_04_17_100523_add_remember_token',1),('2014_04_17_145108_add_custom_fields',1),('2014_04_23_170909_add_products_settings',1),('2014_04_29_174315_add_advanced_settings',1),('2014_05_17_175626_add_quotes',1),('2014_06_17_131940_add_accepted_credit_cards_to_account_gateways',1),('2014_07_13_142654_one_click_install',1),('2014_07_17_205900_support_hiding_quantity',1),('2014_07_24_171214_add_zapier_support',1),('2014_10_01_141248_add_company_vat_number',1),('2014_10_05_141856_track_last_seen_message',1),('2014_10_06_103529_add_timesheets',1),('2014_10_06_195330_add_invoice_design_table',1),('2014_10_13_054100_add_invoice_number_settings',1),('2014_10_14_225227_add_danish_translation',1),('2014_10_22_174452_add_affiliate_price',1),('2014_10_30_184126_add_company_id_number',1),('2014_11_04_200406_allow_null_client_currency',1),('2014_12_03_154119_add_discount_type',1),('2015_02_12_102940_add_email_templates',1),('2015_02_17_131714_support_token_billing',1),('2015_02_27_081836_add_invoice_footer',1),('2015_03_03_140259_add_tokens',1),('2015_03_09_151011_add_ip_to_activity',1),('2015_03_15_174122_add_pdf_email_attachment_option',1),('2015_03_30_100000_create_password_resets_table',1),('2015_04_12_093447_add_sv_language',1),('2015_04_13_100333_add_notify_approved',1),('2015_04_16_122647_add_partial_amount_to_invoices',1),('2015_05_21_184104_add_font_size',1),('2015_05_27_121828_add_tasks',1),('2015_05_27_170808_add_custom_invoice_labels',1),('2015_06_09_134208_add_has_tasks_to_invoices',1),('2015_06_14_093410_enable_resuming_tasks',1),('2015_06_14_173025_multi_company_support',1),('2015_07_07_160257_support_locking_account',1),('2015_07_08_114333_simplify_tasks',1),('2015_07_19_081332_add_custom_design',1),('2015_07_27_183830_add_pdfmake_support',1),('2015_08_13_084041_add_formats_to_datetime_formats_table',1),('2015_09_04_080604_add_swap_postal_code',1),('2015_09_07_135935_add_account_domain',1),('2015_09_10_185135_add_reminder_emails',1),('2015_10_07_135651_add_social_login',1),('2015_10_21_075058_add_default_tax_rates',1),('2015_10_21_185724_add_invoice_number_pattern',1),('2015_10_27_180214_add_is_system_to_activities',1),('2015_10_29_133747_add_default_quote_terms',1),('2015_11_01_080417_encrypt_tokens',1),('2015_11_03_181318_improve_currency_localization',1),('2015_11_30_133206_add_email_designs',1),('2015_12_27_154513_add_reminder_settings',1),('2015_12_30_042035_add_client_view_css',1),('2016_01_04_175228_create_vendors_table',1),('2016_01_06_153144_add_invoice_font_support',1),('2016_01_17_155725_add_quote_to_invoice_option',1),('2016_01_18_195351_add_bank_accounts',1),('2016_01_24_112646_add_bank_subaccounts',1),('2016_01_27_173015_add_header_footer_option',1),('2016_02_01_135956_add_source_currency_to_expenses',1),('2016_02_25_152948_add_client_password',1),('2016_02_28_081424_add_custom_invoice_fields',1),('2016_03_14_066181_add_user_permissions',1),('2016_03_14_214710_add_support_three_decimal_taxes',1),('2016_03_22_168362_add_documents',1),('2016_03_23_215049_support_multiple_tax_rates',1),('2016_04_16_103943_enterprise_plan',1),('2016_04_18_174135_add_page_size',1),('2016_04_23_182223_payments_changes',1),('2016_05_16_102925_add_swap_currency_symbol_to_currency',1),('2016_05_18_085739_add_invoice_type_support',1),('2016_05_24_164847_wepay_ach',1),('2016_07_08_083802_support_new_pricing',1),('2016_07_13_083821_add_buy_now_buttons',1),('2016_08_10_184027_add_support_for_bots',1),('2016_09_05_150625_create_gateway_types',1),('2016_10_20_191150_add_expense_to_activities',1),('2016_11_03_113316_add_invoice_signature',1),('2016_11_03_161149_add_bluevine_fields',1),('2016_11_28_092904_add_task_projects',1),('2016_12_13_113955_add_pro_plan_discount',1),('2017_01_01_214241_add_inclusive_taxes',1),('2017_02_23_095934_add_custom_product_fields',1),('2017_03_16_085702_add_gateway_fee_location',1),('2017_04_16_101744_add_custom_contact_fields',1); /*!40000 ALTER TABLE `migrations` ENABLE KEYS */; UNLOCK TABLES; @@ -1594,7 +1783,7 @@ CREATE TABLE `payment_libraries` ( LOCK TABLES `payment_libraries` WRITE; /*!40000 ALTER TABLE `payment_libraries` DISABLE KEYS */; -INSERT INTO `payment_libraries` VALUES (1,'2017-04-06 10:56:17','2017-04-06 10:56:17','Omnipay',1),(2,'2017-04-06 10:56:17','2017-04-06 10:56:17','PHP-Payments [Deprecated]',1); +INSERT INTO `payment_libraries` VALUES (1,'2017-04-30 10:36:45','2017-04-30 10:36:45','Omnipay',1),(2,'2017-04-30 10:36:45','2017-04-30 10:36:45','PHP-Payments [Deprecated]',1); /*!40000 ALTER TABLE `payment_libraries` ENABLE KEYS */; UNLOCK TABLES; @@ -1704,7 +1893,7 @@ CREATE TABLE `payment_terms` ( LOCK TABLES `payment_terms` WRITE; /*!40000 ALTER TABLE `payment_terms` DISABLE KEYS */; -INSERT INTO `payment_terms` VALUES (1,7,'Net 7','2017-04-06 10:56:17','2017-04-06 10:56:17',NULL,0,0,1),(2,10,'Net 10','2017-04-06 10:56:17','2017-04-06 10:56:17',NULL,0,0,2),(3,14,'Net 14','2017-04-06 10:56:17','2017-04-06 10:56:17',NULL,0,0,3),(4,15,'Net 15','2017-04-06 10:56:17','2017-04-06 10:56:17',NULL,0,0,4),(5,30,'Net 30','2017-04-06 10:56:17','2017-04-06 10:56:17',NULL,0,0,5),(6,60,'Net 60','2017-04-06 10:56:17','2017-04-06 10:56:17',NULL,0,0,6),(7,90,'Net 90','2017-04-06 10:56:17','2017-04-06 10:56:17',NULL,0,0,7),(8,-1,'Net 0','2017-04-06 10:56:22','2017-04-06 10:56:22',NULL,0,0,0); +INSERT INTO `payment_terms` VALUES (1,7,'Net 7','2017-04-30 10:36:45','2017-04-30 10:36:45',NULL,0,0,1),(2,10,'Net 10','2017-04-30 10:36:45','2017-04-30 10:36:45',NULL,0,0,2),(3,14,'Net 14','2017-04-30 10:36:45','2017-04-30 10:36:45',NULL,0,0,3),(4,15,'Net 15','2017-04-30 10:36:45','2017-04-30 10:36:45',NULL,0,0,4),(5,30,'Net 30','2017-04-30 10:36:45','2017-04-30 10:36:45',NULL,0,0,5),(6,60,'Net 60','2017-04-30 10:36:45','2017-04-30 10:36:45',NULL,0,0,6),(7,90,'Net 90','2017-04-30 10:36:45','2017-04-30 10:36:45',NULL,0,0,7),(8,-1,'Net 0','2017-04-30 10:36:48','2017-04-30 10:36:48',NULL,0,0,0); /*!40000 ALTER TABLE `payment_terms` ENABLE KEYS */; UNLOCK TABLES; @@ -2299,4 +2488,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2017-04-06 16:56:22 +-- Dump completed on 2017-04-30 16:36:49 diff --git a/docs/api.rst b/docs/api.rst index ea6b34b62d86..b4db0cb0e891 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -6,7 +6,9 @@ Invoice Ninja provides a REST based API, `click here `_ app, once the app is created you can import this `model file `_. + +You'll also need to set the following values in the .env file. + +.. code-block:: shell + + SPEECH_ENABLED=true + MSBOT_LUIS_APP_ID=... + MSBOT_LUIS_SUBSCRIPTION_KEY=... + Using a Proxy """"""""""""" diff --git a/docs/index.rst b/docs/index.rst index b5e5c910ce1e..c57ce6902d1d 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -46,7 +46,7 @@ Want to find out everything there is to know about how to use your Invoice Ninja install configure update - iphone_app + mobile_apps api developer_guide custom_modules diff --git a/docs/install.rst b/docs/install.rst index f5eb71e61b22..4af8b0ee81d8 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -29,7 +29,7 @@ Step 1: Download the code You can either download the zip file below or checkout the code from our GitHub repository. The zip includes all third party libraries whereas using GitHub requires you to use Composer to install the dependencies. -https://download.invoiceninja.com/ninja-v3.2.0.zip +https://download.invoiceninja.com/ninja-v3.2.1.zip .. Note:: All Pro and Enterprise features from our hosted app are included in both the zip file and the GitHub repository. We offer a $20 per year white-label license to remove our branding. diff --git a/docs/iphone_app.rst b/docs/mobile_apps.rst similarity index 50% rename from docs/iphone_app.rst rename to docs/mobile_apps.rst index 5cb6dcce34f0..f5d2269ed8c6 100644 --- a/docs/iphone_app.rst +++ b/docs/mobile_apps.rst @@ -1,14 +1,14 @@ -iPhone Application -================== +Mobile Applications +=================== -The Invoice Ninja iPhone application allows a user to connect to their self-hosted Invoice Ninja web application. +The Invoice Ninja iPhone and Android applications allows a user to connect to their self-hosted Invoice Ninja web application. -Connecting your iPhone to your self-hosted invoice ninja installation requires a couple of easy steps. +Connecting your to your self-hosted invoice ninja installation requires a couple of easy steps. -Web app configuration +Web App configuration """"""""""""""""""""" -Firstly you'll need to add an additional field to your .env file which is located in the root directory of your self-hosted Invoice Ninja installation. +First, you'll need to add an additional field to your .env file which is located in the root directory of your self-hosted Invoice Ninja installation. The additional field to add is API_SECRET, set this to your own defined alphanumeric string. @@ -17,10 +17,10 @@ The additional field to add is API_SECRET, set this to your own defined alphanum Save your .env file and now open Invoice Ninja on your iPhone. -iPhone configuration -"""""""""""""""""""" +Mobile App configuration +"""""""""""""""""""""""" -Once you have completed the in-app purchase to unlock the iPhone to connect to your own server, you'll be presented with two fields. +Once you have completed the in-app purchase to unlock the mobile app to connect to your own server, you'll be presented with two fields. The first is the Base URL of your self-hosted installation, ie http://ninja.yourapp.com @@ -30,7 +30,7 @@ The second field is the API_SECRET, enter in the API_SECRET you used in your .en Click SAVE. -You should be able to login now from your iPhone! +You should now be able to login! FAQ: @@ -40,9 +40,9 @@ Q: I get a HTTP 500 error. A: Most likely you have not entered your API_SECRET in your .env file -Q: I get a HTTP 403 error when i attempt to login with the iPhone. +Q: I get a HTTP 403 error when i attempt to login with the iPhone or Android device. -A: Most likely your API_SECRET on the iPhone does not match that on your self-hosted installation. +A: Most likely your API_SECRET on the iPhone/Android device does not match that on your self-hosted installation. Q: Do I need to create a token on the server? diff --git a/docs/update.rst b/docs/update.rst index bd2bc333a9ce..4ef3bbd96bf8 100644 --- a/docs/update.rst +++ b/docs/update.rst @@ -16,6 +16,11 @@ If the auto-update fails you can manually run the update with the following comm .. NOTE:: If you've downloaded the code from GitHub you also need to run ``composer install`` +Version 3.2 +""""""""""" + +An import folder has been adding to storage/, you may need to run ``sudo chown -R www-data:www-data storage`` + Version 2.6 """"""""""" diff --git a/public/built.js b/public/built.js index 0a55fe609b7e..8bff320ec6ea 100644 --- a/public/built.js +++ b/public/built.js @@ -1,27 +1,27 @@ -function generatePDF(t,e,n,i){if(t&&e){if(!n)return refreshTimer&&clearTimeout(refreshTimer),void(refreshTimer=setTimeout(function(){generatePDF(t,e,!0,i)},500));refreshTimer=null,t=calculateAmounts(t);var o=GetPdfMake(t,e,i);return i&&o.getDataUrl(i),o}}function copyObject(t){return!!t&&JSON.parse(JSON.stringify(t))}function processVariables(t){if(!t)return"";for(var e=["MONTH","QUARTER","YEAR"],n=0;n1?c=r.split("+")[1]:r.split("-").length>1&&(c=parseInt(r.split("-")[1])*-1),t=t.replace(r,getDatePart(i,c))}}return t}function getDatePart(t,e){return e=parseInt(e),e||(e=0),"MONTH"==t?getMonth(e):"QUARTER"==t?getQuarter(e):"YEAR"==t?getYear(e):void 0}function getMonth(t){var e=new Date,n=["January","February","March","April","May","June","July","August","September","October","November","December"],i=e.getMonth();return i=parseInt(i)+t,i%=12,i<0&&(i+=12),n[i]}function getYear(t){var e=new Date,n=e.getFullYear();return parseInt(n)+t}function getQuarter(t){var e=new Date,n=Math.floor((e.getMonth()+3)/3);return n+=t,n%=4,0==n&&(n=4),"Q"+n}function isStorageSupported(){try{return"localStorage"in window&&null!==window.localStorage}catch(t){return!1}}function isValidEmailAddress(t){var e=new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);return e.test(t)}function enableHoverClick(t,e,n){}function setAsLink(t,e){e?(t.css("text-decoration","underline"),t.css("cursor","pointer")):(t.css("text-decoration","none"),t.css("cursor","text"))}function setComboboxValue(t,e,n){t.find("input").val(e),t.find("input.form-control").val(n),e&&n?(t.find("select").combobox("setSelected"),t.find(".combobox-container").addClass("combobox-selected")):t.find(".combobox-container").removeClass("combobox-selected")}function convertDataURIToBinary(t){var e=t.indexOf(BASE64_MARKER)+BASE64_MARKER.length,n=t.substring(e);return base64DecToArr(n)}function getContactDisplayName(t){return t.first_name||t.last_name?$.trim((t.first_name||"")+" "+(t.last_name||"")):t.email}function getClientDisplayName(t){var e=!!t.contacts&&t.contacts[0];return t.name?t.name:e?getContactDisplayName(e):""}function populateInvoiceComboboxes(t,e){for(var n={},i={},o={},a=$("select#client"),s=0;s1?t+=", ":n64&&t<91?t-65:t>96&&t<123?t-71:t>47&&t<58?t+4:43===t?62:47===t?63:0}function base64DecToArr(t,e){for(var n,i,o=t.replace(/[^A-Za-z0-9\+\/]/g,""),a=o.length,s=e?Math.ceil((3*a+1>>2)/e)*e:3*a+1>>2,r=new Uint8Array(s),c=0,l=0,u=0;u>>(16>>>n&24)&255;c=0}return r}function uint6ToB64(t){return t<26?t+65:t<52?t+71:t<62?t-4:62===t?43:63===t?47:65}function base64EncArr(t){for(var e=2,n="",i=t.length,o=0,a=0;a0&&4*a/3%76===0&&(n+="\r\n"),o|=t[a]<<(16>>>e&24),2!==e&&t.length-a!==1||(n+=String.fromCharCode(uint6ToB64(o>>>18&63),uint6ToB64(o>>>12&63),uint6ToB64(o>>>6&63),uint6ToB64(63&o)),o=0);return n.substr(0,n.length-2+e)+(2===e?"":1===e?"=":"==")}function UTF8ArrToStr(t){for(var e,n="",i=t.length,o=0;o251&&e<254&&o+5247&&e<252&&o+4239&&e<248&&o+3223&&e<240&&o+2191&&e<224&&o+1>>6),e[s++]=128+(63&n)):n<65536?(e[s++]=224+(n>>>12),e[s++]=128+(n>>>6&63),e[s++]=128+(63&n)):n<2097152?(e[s++]=240+(n>>>18),e[s++]=128+(n>>>12&63),e[s++]=128+(n>>>6&63),e[s++]=128+(63&n)):n<67108864?(e[s++]=248+(n>>>24),e[s++]=128+(n>>>18&63),e[s++]=128+(n>>>12&63),e[s++]=128+(n>>>6&63),e[s++]=128+(63&n)):(e[s++]=252+n/1073741824,e[s++]=128+(n>>>24&63),e[s++]=128+(n>>>18&63),e[s++]=128+(n>>>12&63),e[s++]=128+(n>>>6&63),e[s++]=128+(63&n));return e}function hexToR(t){return parseInt(cutHex(t).substring(0,2),16)}function hexToG(t){return parseInt(cutHex(t).substring(2,4),16)}function hexToB(t){return parseInt(cutHex(t).substring(4,6),16)}function cutHex(t){return"#"==t.charAt(0)?t.substring(1,7):t}function setDocHexColor(t,e){var n=hexToR(e),i=hexToG(e),o=hexToB(e);return t.setTextColor(n,i,o)}function setDocHexFill(t,e){var n=hexToR(e),i=hexToG(e),o=hexToB(e);return t.setFillColor(n,i,o)}function setDocHexDraw(t,e){var n=hexToR(e),i=hexToG(e),o=hexToB(e);return t.setDrawColor(n,i,o)}function toggleDatePicker(t){$("#"+t).datepicker("show")}function roundToTwo(t,e){var n=+(Math.round(t+"e+2")+"e-2");return e?n.toFixed(2):n||0}function roundToFour(t,e){var n=+(Math.round(t+"e+4")+"e-4");return e?n.toFixed(4):n||0}function truncate(t,e){return t&&t.length>e?t.substr(0,e-1)+"...":t}function endsWith(t,e){return t.indexOf(e,t.length-e.length)!==-1}function secondsToTime(t){t=Math.round(t);var e=Math.floor(t/3600),n=t%3600,i=Math.floor(n/60),o=n%60,a=Math.ceil(o),s={h:e,m:i,s:a};return s}function twoDigits(t){return t<10?"0"+t:t}function toSnakeCase(t){return t?t.replace(/([A-Z])/g,function(t){return"_"+t.toLowerCase()}):""}function snakeToCamel(t){return t.replace(/_([a-z])/g,function(t){return t[1].toUpperCase()})}function getDescendantProp(t,e){for(var n=e.split(".");n.length&&(t=t[n.shift()]););return t}function doubleDollarSign(t){return t?t.replace?t.replace(/\$/g,"$$$"):t:""}function truncate(t,e){return t.length>e?t.substring(0,e)+"...":t}function actionListHandler(){$("tbody tr .tr-action").closest("tr").mouseover(function(){$(this).closest("tr").find(".tr-action").show(),$(this).closest("tr").find(".tr-status").hide()}).mouseout(function(){$dropdown=$(this).closest("tr").find(".tr-action"),$dropdown.hasClass("open")||($dropdown.hide(),$(this).closest("tr").find(".tr-status").show())})}function loadImages(t){$(t+" img").each(function(t,e){var n=$(e).attr("data-src");$(e).attr("src",n),$(e).attr("data-src",n)})}function prettyJson(t){return"string"!=typeof t&&(t=JSON.stringify(t,void 0,2)),t=t.replace(/&/g,"&").replace(//g,">"),t.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,function(t){var e="number";return/^"/.test(t)?e=/:$/.test(t)?"key":"string":/true|false/.test(t)?e="boolean":/null/.test(t)&&(e="null"),t=snakeToCamel(t),''+t+""})}function searchData(t,e,n){return function(i,o){var a;if(n){var s={keys:[e]},r=new Fuse(t,s);a=r.search(i)}else a=[],substrRegex=new RegExp(escapeRegExp(i),"i"),$.each(t,function(t,n){substrRegex.test(n[e])&&a.push(n)});o(a)}}function escapeRegExp(t){return t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}function firstJSONError(t){for(var e in t)if(t.hasOwnProperty(e)){var n=t[e];for(var i in n)if(n.hasOwnProperty(i))return n[i]}return!1}function pad(t,e,n){return n=n||"0",t+="",t.length>=e?t:new Array(e-t.length+1).join(n)+t}function GetPdfMake(t,e,n){function i(e,n){if("string"==typeof n){if(0===n.indexOf("$firstAndLast")){var i=n.split(":");return function(t,e){return 0===t||t===e.table.body.length?parseFloat(i[1]):0}}if(0===n.indexOf("$none"))return function(t,e){return 0};if(0===n.indexOf("$notFirstAndLastColumn")){var i=n.split(":");return function(t,e){return 0===t||t===e.table.widths.length?0:parseFloat(i[1])}}if(0===n.indexOf("$notFirst")){var i=n.split(":");return function(t,e){return 0===t?0:parseFloat(i[1])}}if(0===n.indexOf("$amount")){var i=n.split(":");return function(t,e){return parseFloat(i[1])}}if(0===n.indexOf("$primaryColor")){var i=n.split(":");return NINJA.primaryColor||i[1]}if(0===n.indexOf("$secondaryColor")){var i=n.split(":");return NINJA.secondaryColor||i[1]}}if(t.features.customize_invoice_design){if("header"===e)return function(e,i){return 1===e||"1"==t.account.all_pages_header?t.features.remove_created_by?NINJA.updatePageCount(JSON.parse(JSON.stringify(n)),e,i):n:""};if("footer"===e)return function(e,i){return e===i||"1"==t.account.all_pages_footer?t.features.remove_created_by?NINJA.updatePageCount(JSON.parse(JSON.stringify(n)),e,i):n:""}}return"text"===e&&(n=NINJA.parseMarkdownText(n,!0)),n}function o(t){window.ninjaFontVfs[t.folder]&&(folder="fonts/"+t.folder,pdfMake.fonts[t.name]={normal:folder+"/"+t.normal,italics:folder+"/"+t.italics,bold:folder+"/"+t.bold,bolditalics:folder+"/"+t.bolditalics})}e=NINJA.decodeJavascript(t,e);var a=JSON.parse(e,i);t.invoice_design_id;if(!t.features.remove_created_by&&!isEdge){var s="function"==typeof a.footer?a.footer():a.footer;if(s)if(s.hasOwnProperty("columns"))s.columns.push({image:logoImages.imageLogo1,alignment:"right",width:130,margin:[0,0,0,0]});else{for(var r,c=0;c0&&e-1 in t))}function i(t,e,n){if(ot.isFunction(e))return ot.grep(t,function(t,i){return!!e.call(t,i,t)!==n});if(e.nodeType)return ot.grep(t,function(t){return t===e!==n});if("string"==typeof e){if(dt.test(e))return ot.filter(e,t,n);e=ot.filter(e,t)}return ot.grep(t,function(t){return ot.inArray(t,e)>=0!==n})}function o(t,e){do t=t[e];while(t&&1!==t.nodeType);return t}function a(t){var e=yt[t]={};return ot.each(t.match(Mt)||[],function(t,n){e[n]=!0}),e}function s(){ft.addEventListener?(ft.removeEventListener("DOMContentLoaded",r,!1),t.removeEventListener("load",r,!1)):(ft.detachEvent("onreadystatechange",r),t.detachEvent("onload",r))}function r(){(ft.addEventListener||"load"===event.type||"complete"===ft.readyState)&&(s(),ot.ready())}function c(t,e,n){if(void 0===n&&1===t.nodeType){var i="data-"+e.replace(wt,"-$1").toLowerCase();if(n=t.getAttribute(i),"string"==typeof n){try{n="true"===n||"false"!==n&&("null"===n?null:+n+""===n?+n:Tt.test(n)?ot.parseJSON(n):n)}catch(o){}ot.data(t,e,n)}else n=void 0}return n}function l(t){var e;for(e in t)if(("data"!==e||!ot.isEmptyObject(t[e]))&&"toJSON"!==e)return!1;return!0}function u(t,e,n,i){if(ot.acceptData(t)){var o,a,s=ot.expando,r=t.nodeType,c=r?ot.cache:t,l=r?t[s]:t[s]&&s;if(l&&c[l]&&(i||c[l].data)||void 0!==n||"string"!=typeof e)return l||(l=r?t[s]=Y.pop()||ot.guid++:s),c[l]||(c[l]=r?{}:{toJSON:ot.noop}),"object"!=typeof e&&"function"!=typeof e||(i?c[l]=ot.extend(c[l],e):c[l].data=ot.extend(c[l].data,e)),a=c[l],i||(a.data||(a.data={}),a=a.data),void 0!==n&&(a[ot.camelCase(e)]=n),"string"==typeof e?(o=a[e],null==o&&(o=a[ot.camelCase(e)])):o=a,o}}function h(t,e,n){if(ot.acceptData(t)){var i,o,a=t.nodeType,s=a?ot.cache:t,r=a?t[ot.expando]:ot.expando;if(s[r]){if(e&&(i=n?s[r]:s[r].data)){ot.isArray(e)?e=e.concat(ot.map(e,ot.camelCase)):e in i?e=[e]:(e=ot.camelCase(e),e=e in i?[e]:e.split(" ")),o=e.length;for(;o--;)delete i[e[o]];if(n?!l(i):!ot.isEmptyObject(i))return}(n||(delete s[r].data,l(s[r])))&&(a?ot.cleanData([t],!0):nt.deleteExpando||s!=s.window?delete s[r]:s[r]=null)}}}function d(){return!0}function p(){return!1}function f(){try{return ft.activeElement}catch(t){}}function m(t){var e=Et.split("|"),n=t.createDocumentFragment();if(n.createElement)for(;e.length;)n.createElement(e.pop());return n}function g(t,e){var n,i,o=0,a=typeof t.getElementsByTagName!==_t?t.getElementsByTagName(e||"*"):typeof t.querySelectorAll!==_t?t.querySelectorAll(e||"*"):void 0;if(!a)for(a=[],n=t.childNodes||t;null!=(i=n[o]);o++)!e||ot.nodeName(i,e)?a.push(i):ot.merge(a,g(i,e));return void 0===e||e&&ot.nodeName(t,e)?ot.merge([t],a):a}function b(t){xt.test(t.type)&&(t.defaultChecked=t.checked)}function v(t,e){return ot.nodeName(t,"table")&&ot.nodeName(11!==e.nodeType?e:e.firstChild,"tr")?t.getElementsByTagName("tbody")[0]||t.appendChild(t.ownerDocument.createElement("tbody")):t}function M(t){return t.type=(null!==ot.find.attr(t,"type"))+"/"+t.type,t}function y(t){var e=Vt.exec(t.type);return e?t.type=e[1]:t.removeAttribute("type"),t}function A(t,e){for(var n,i=0;null!=(n=t[i]);i++)ot._data(n,"globalEval",!e||ot._data(e[i],"globalEval"))}function z(t,e){if(1===e.nodeType&&ot.hasData(t)){var n,i,o,a=ot._data(t),s=ot._data(e,a),r=a.events;if(r){delete s.handle,s.events={};for(n in r)for(i=0,o=r[n].length;i")).appendTo(e.documentElement),e=(Qt[0].contentWindow||Qt[0].contentDocument).document,e.write(),e.close(),n=T(t,e),Qt.detach()),Zt[t]=n),n}function C(t,e){return{get:function(){var n=t();if(null!=n)return n?void delete this.get:(this.get=e).apply(this,arguments)}}}function N(t,e){if(e in t)return e;for(var n=e.charAt(0).toUpperCase()+e.slice(1),i=e,o=de.length;o--;)if(e=de[o]+n,e in t)return e;return i}function O(t,e){for(var n,i,o,a=[],s=0,r=t.length;s=0&&n=0},isEmptyObject:function(t){var e;for(e in t)return!1;return!0},isPlainObject:function(t){var e;if(!t||"object"!==ot.type(t)||t.nodeType||ot.isWindow(t))return!1;try{if(t.constructor&&!et.call(t,"constructor")&&!et.call(t.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}if(nt.ownLast)for(e in t)return et.call(t,e);for(e in t);return void 0===e||et.call(t,e)},type:function(t){return null==t?t+"":"object"==typeof t||"function"==typeof t?Z[tt.call(t)]||"object":typeof t},globalEval:function(e){e&&ot.trim(e)&&(t.execScript||function(e){t.eval.call(t,e)})(e)},camelCase:function(t){return t.replace(st,"ms-").replace(rt,ct)},nodeName:function(t,e){return t.nodeName&&t.nodeName.toLowerCase()===e.toLowerCase()},each:function(t,e,i){var o,a=0,s=t.length,r=n(t);if(i){if(r)for(;az.cacheLength&&delete t[e.shift()],t[n+" "]=i}var e=[];return t}function i(t){return t[X]=!0,t}function o(t){var e=D.createElement("div");try{return!!t(e)}catch(n){return!1}finally{e.parentNode&&e.parentNode.removeChild(e), -e=null}}function a(t,e){for(var n=t.split("|"),i=t.length;i--;)z.attrHandle[n[i]]=e}function s(t,e){var n=e&&t,i=n&&1===t.nodeType&&1===e.nodeType&&(~e.sourceIndex||V)-(~t.sourceIndex||V);if(i)return i;if(n)for(;n=n.nextSibling;)if(n===e)return-1;return t?1:-1}function r(t){return function(e){var n=e.nodeName.toLowerCase();return"input"===n&&e.type===t}}function c(t){return function(e){var n=e.nodeName.toLowerCase();return("input"===n||"button"===n)&&e.type===t}}function l(t){return i(function(e){return e=+e,i(function(n,i){for(var o,a=t([],n.length,e),s=a.length;s--;)n[o=a[s]]&&(n[o]=!(i[o]=n[o]))})})}function u(t){return t&&"undefined"!=typeof t.getElementsByTagName&&t}function h(){}function d(t){for(var e=0,n=t.length,i="";e1?function(e,n,i){for(var o=t.length;o--;)if(!t[o](e,n,i))return!1;return!0}:t[0]}function m(t,n,i){for(var o=0,a=n.length;o-1&&(i[l]=!(s[l]=h))}}else M=g(M===s?M.splice(f,M.length):M),a?a(null,s,M,c):Q.apply(s,M)})}function v(t){for(var e,n,i,o=t.length,a=z.relative[t[0].type],s=a||z.relative[" "],r=a?1:0,c=p(function(t){return t===e},s,!0),l=p(function(t){return tt(e,t)>-1},s,!0),u=[function(t,n,i){var o=!a&&(i||n!==O)||((e=n).nodeType?c(t,n,i):l(t,n,i));return e=null,o}];r1&&f(u),r>1&&d(t.slice(0,r-1).concat({value:" "===t[r-2].type?"*":""})).replace(ct,"$1"),n,r0,a=t.length>0,s=function(i,s,r,c,l){var u,h,d,p=0,f="0",m=i&&[],b=[],v=O,M=i||a&&z.find.TAG("*",l),y=R+=null==v?1:Math.random()||.1,A=M.length;for(l&&(O=s!==D&&s);f!==A&&null!=(u=M[f]);f++){if(a&&u){for(h=0;d=t[h++];)if(d(u,s,r)){c.push(u);break}l&&(R=y)}o&&((u=!d&&u)&&p--,i&&m.push(u))}if(p+=f,o&&f!==p){for(h=0;d=n[h++];)d(m,b,s,r);if(i){if(p>0)for(;f--;)m[f]||b[f]||(b[f]=K.call(c));b=g(b)}Q.apply(c,b),l&&!i&&b.length>0&&p+n.length>1&&e.uniqueSort(c)}return l&&(R=y,O=v),m};return o?i(s):s}var y,A,z,_,T,w,C,N,O,S,x,L,D,k,q,W,E,B,I,X="sizzle"+1*new Date,P=t.document,R=0,F=0,H=n(),j=n(),U=n(),$=function(t,e){return t===e&&(x=!0),0},V=1<<31,Y={}.hasOwnProperty,J=[],K=J.pop,G=J.push,Q=J.push,Z=J.slice,tt=function(t,e){for(var n=0,i=t.length;n+~]|"+nt+")"+nt+"*"),ht=new RegExp("="+nt+"*([^\\]'\"]*?)"+nt+"*\\]","g"),dt=new RegExp(st),pt=new RegExp("^"+ot+"$"),ft={ID:new RegExp("^#("+it+")"),CLASS:new RegExp("^\\.("+it+")"),TAG:new RegExp("^("+it.replace("w","w*")+")"),ATTR:new RegExp("^"+at),PSEUDO:new RegExp("^"+st),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+nt+"*(even|odd|(([+-]|)(\\d*)n|)"+nt+"*(?:([+-]|)"+nt+"*(\\d+)|))"+nt+"*\\)|)","i"),bool:new RegExp("^(?:"+et+")$","i"),needsContext:new RegExp("^"+nt+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+nt+"*((?:-\\d)?\\d*)"+nt+"*\\)|)(?=[^-]|$)","i")},mt=/^(?:input|select|textarea|button)$/i,gt=/^h\d$/i,bt=/^[^{]+\{\s*\[native \w/,vt=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,Mt=/[+~]/,yt=/'|\\/g,At=new RegExp("\\\\([\\da-f]{1,6}"+nt+"?|("+nt+")|.)","ig"),zt=function(t,e,n){var i="0x"+e-65536;return i!==i||n?e:i<0?String.fromCharCode(i+65536):String.fromCharCode(i>>10|55296,1023&i|56320)},_t=function(){L()};try{Q.apply(J=Z.call(P.childNodes),P.childNodes),J[P.childNodes.length].nodeType}catch(Tt){Q={apply:J.length?function(t,e){G.apply(t,Z.call(e))}:function(t,e){for(var n=t.length,i=0;t[n++]=e[i++];);t.length=n-1}}}A=e.support={},T=e.isXML=function(t){var e=t&&(t.ownerDocument||t).documentElement;return!!e&&"HTML"!==e.nodeName},L=e.setDocument=function(t){var e,n,i=t?t.ownerDocument||t:P;return i!==D&&9===i.nodeType&&i.documentElement?(D=i,k=i.documentElement,n=i.defaultView,n&&n!==n.top&&(n.addEventListener?n.addEventListener("unload",_t,!1):n.attachEvent&&n.attachEvent("onunload",_t)),q=!T(i),A.attributes=o(function(t){return t.className="i",!t.getAttribute("className")}),A.getElementsByTagName=o(function(t){return t.appendChild(i.createComment("")),!t.getElementsByTagName("*").length}),A.getElementsByClassName=bt.test(i.getElementsByClassName),A.getById=o(function(t){return k.appendChild(t).id=X,!i.getElementsByName||!i.getElementsByName(X).length}),A.getById?(z.find.ID=function(t,e){if("undefined"!=typeof e.getElementById&&q){var n=e.getElementById(t);return n&&n.parentNode?[n]:[]}},z.filter.ID=function(t){var e=t.replace(At,zt);return function(t){return t.getAttribute("id")===e}}):(delete z.find.ID,z.filter.ID=function(t){var e=t.replace(At,zt);return function(t){var n="undefined"!=typeof t.getAttributeNode&&t.getAttributeNode("id");return n&&n.value===e}}),z.find.TAG=A.getElementsByTagName?function(t,e){return"undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t):A.qsa?e.querySelectorAll(t):void 0}:function(t,e){var n,i=[],o=0,a=e.getElementsByTagName(t);if("*"===t){for(;n=a[o++];)1===n.nodeType&&i.push(n);return i}return a},z.find.CLASS=A.getElementsByClassName&&function(t,e){if(q)return e.getElementsByClassName(t)},E=[],W=[],(A.qsa=bt.test(i.querySelectorAll))&&(o(function(t){k.appendChild(t).innerHTML="",t.querySelectorAll("[msallowcapture^='']").length&&W.push("[*^$]="+nt+"*(?:''|\"\")"),t.querySelectorAll("[selected]").length||W.push("\\["+nt+"*(?:value|"+et+")"),t.querySelectorAll("[id~="+X+"-]").length||W.push("~="),t.querySelectorAll(":checked").length||W.push(":checked"),t.querySelectorAll("a#"+X+"+*").length||W.push(".#.+[+~]")}),o(function(t){var e=i.createElement("input");e.setAttribute("type","hidden"),t.appendChild(e).setAttribute("name","D"),t.querySelectorAll("[name=d]").length&&W.push("name"+nt+"*[*^$|!~]?="),t.querySelectorAll(":enabled").length||W.push(":enabled",":disabled"),t.querySelectorAll("*,:x"),W.push(",.*:")})),(A.matchesSelector=bt.test(B=k.matches||k.webkitMatchesSelector||k.mozMatchesSelector||k.oMatchesSelector||k.msMatchesSelector))&&o(function(t){A.disconnectedMatch=B.call(t,"div"),B.call(t,"[s!='']:x"),E.push("!=",st)}),W=W.length&&new RegExp(W.join("|")),E=E.length&&new RegExp(E.join("|")),e=bt.test(k.compareDocumentPosition),I=e||bt.test(k.contains)?function(t,e){var n=9===t.nodeType?t.documentElement:t,i=e&&e.parentNode;return t===i||!(!i||1!==i.nodeType||!(n.contains?n.contains(i):t.compareDocumentPosition&&16&t.compareDocumentPosition(i)))}:function(t,e){if(e)for(;e=e.parentNode;)if(e===t)return!0;return!1},$=e?function(t,e){if(t===e)return x=!0,0;var n=!t.compareDocumentPosition-!e.compareDocumentPosition;return n?n:(n=(t.ownerDocument||t)===(e.ownerDocument||e)?t.compareDocumentPosition(e):1,1&n||!A.sortDetached&&e.compareDocumentPosition(t)===n?t===i||t.ownerDocument===P&&I(P,t)?-1:e===i||e.ownerDocument===P&&I(P,e)?1:S?tt(S,t)-tt(S,e):0:4&n?-1:1)}:function(t,e){if(t===e)return x=!0,0;var n,o=0,a=t.parentNode,r=e.parentNode,c=[t],l=[e];if(!a||!r)return t===i?-1:e===i?1:a?-1:r?1:S?tt(S,t)-tt(S,e):0;if(a===r)return s(t,e);for(n=t;n=n.parentNode;)c.unshift(n);for(n=e;n=n.parentNode;)l.unshift(n);for(;c[o]===l[o];)o++;return o?s(c[o],l[o]):c[o]===P?-1:l[o]===P?1:0},i):D},e.matches=function(t,n){return e(t,null,null,n)},e.matchesSelector=function(t,n){if((t.ownerDocument||t)!==D&&L(t),n=n.replace(ht,"='$1']"),A.matchesSelector&&q&&(!E||!E.test(n))&&(!W||!W.test(n)))try{var i=B.call(t,n);if(i||A.disconnectedMatch||t.document&&11!==t.document.nodeType)return i}catch(o){}return e(n,D,null,[t]).length>0},e.contains=function(t,e){return(t.ownerDocument||t)!==D&&L(t),I(t,e)},e.attr=function(t,e){(t.ownerDocument||t)!==D&&L(t);var n=z.attrHandle[e.toLowerCase()],i=n&&Y.call(z.attrHandle,e.toLowerCase())?n(t,e,!q):void 0;return void 0!==i?i:A.attributes||!q?t.getAttribute(e):(i=t.getAttributeNode(e))&&i.specified?i.value:null},e.error=function(t){throw new Error("Syntax error, unrecognized expression: "+t)},e.uniqueSort=function(t){var e,n=[],i=0,o=0;if(x=!A.detectDuplicates,S=!A.sortStable&&t.slice(0),t.sort($),x){for(;e=t[o++];)e===t[o]&&(i=n.push(o));for(;i--;)t.splice(n[i],1)}return S=null,t},_=e.getText=function(t){var e,n="",i=0,o=t.nodeType;if(o){if(1===o||9===o||11===o){if("string"==typeof t.textContent)return t.textContent;for(t=t.firstChild;t;t=t.nextSibling)n+=_(t)}else if(3===o||4===o)return t.nodeValue}else for(;e=t[i++];)n+=_(e);return n},z=e.selectors={cacheLength:50,createPseudo:i,match:ft,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(t){return t[1]=t[1].replace(At,zt),t[3]=(t[3]||t[4]||t[5]||"").replace(At,zt),"~="===t[2]&&(t[3]=" "+t[3]+" "),t.slice(0,4)},CHILD:function(t){return t[1]=t[1].toLowerCase(),"nth"===t[1].slice(0,3)?(t[3]||e.error(t[0]),t[4]=+(t[4]?t[5]+(t[6]||1):2*("even"===t[3]||"odd"===t[3])),t[5]=+(t[7]+t[8]||"odd"===t[3])):t[3]&&e.error(t[0]),t},PSEUDO:function(t){var e,n=!t[6]&&t[2];return ft.CHILD.test(t[0])?null:(t[3]?t[2]=t[4]||t[5]||"":n&&dt.test(n)&&(e=w(n,!0))&&(e=n.indexOf(")",n.length-e)-n.length)&&(t[0]=t[0].slice(0,e),t[2]=n.slice(0,e)),t.slice(0,3))}},filter:{TAG:function(t){var e=t.replace(At,zt).toLowerCase();return"*"===t?function(){return!0}:function(t){return t.nodeName&&t.nodeName.toLowerCase()===e}},CLASS:function(t){var e=H[t+" "];return e||(e=new RegExp("(^|"+nt+")"+t+"("+nt+"|$)"))&&H(t,function(t){return e.test("string"==typeof t.className&&t.className||"undefined"!=typeof t.getAttribute&&t.getAttribute("class")||"")})},ATTR:function(t,n,i){return function(o){var a=e.attr(o,t);return null==a?"!="===n:!n||(a+="","="===n?a===i:"!="===n?a!==i:"^="===n?i&&0===a.indexOf(i):"*="===n?i&&a.indexOf(i)>-1:"$="===n?i&&a.slice(-i.length)===i:"~="===n?(" "+a.replace(rt," ")+" ").indexOf(i)>-1:"|="===n&&(a===i||a.slice(0,i.length+1)===i+"-"))}},CHILD:function(t,e,n,i,o){var a="nth"!==t.slice(0,3),s="last"!==t.slice(-4),r="of-type"===e;return 1===i&&0===o?function(t){return!!t.parentNode}:function(e,n,c){var l,u,h,d,p,f,m=a!==s?"nextSibling":"previousSibling",g=e.parentNode,b=r&&e.nodeName.toLowerCase(),v=!c&&!r;if(g){if(a){for(;m;){for(h=e;h=h[m];)if(r?h.nodeName.toLowerCase()===b:1===h.nodeType)return!1;f=m="only"===t&&!f&&"nextSibling"}return!0}if(f=[s?g.firstChild:g.lastChild],s&&v){for(u=g[X]||(g[X]={}),l=u[t]||[],p=l[0]===R&&l[1],d=l[0]===R&&l[2],h=p&&g.childNodes[p];h=++p&&h&&h[m]||(d=p=0)||f.pop();)if(1===h.nodeType&&++d&&h===e){u[t]=[R,p,d];break}}else if(v&&(l=(e[X]||(e[X]={}))[t])&&l[0]===R)d=l[1];else for(;(h=++p&&h&&h[m]||(d=p=0)||f.pop())&&((r?h.nodeName.toLowerCase()!==b:1!==h.nodeType)||!++d||(v&&((h[X]||(h[X]={}))[t]=[R,d]),h!==e)););return d-=o,d===i||d%i===0&&d/i>=0}}},PSEUDO:function(t,n){var o,a=z.pseudos[t]||z.setFilters[t.toLowerCase()]||e.error("unsupported pseudo: "+t);return a[X]?a(n):a.length>1?(o=[t,t,"",n],z.setFilters.hasOwnProperty(t.toLowerCase())?i(function(t,e){for(var i,o=a(t,n),s=o.length;s--;)i=tt(t,o[s]),t[i]=!(e[i]=o[s])}):function(t){return a(t,0,o)}):a}},pseudos:{not:i(function(t){var e=[],n=[],o=C(t.replace(ct,"$1"));return o[X]?i(function(t,e,n,i){for(var a,s=o(t,null,i,[]),r=t.length;r--;)(a=s[r])&&(t[r]=!(e[r]=a))}):function(t,i,a){return e[0]=t,o(e,null,a,n),e[0]=null,!n.pop()}}),has:i(function(t){return function(n){return e(t,n).length>0}}),contains:i(function(t){return t=t.replace(At,zt),function(e){return(e.textContent||e.innerText||_(e)).indexOf(t)>-1}}),lang:i(function(t){return pt.test(t||"")||e.error("unsupported lang: "+t),t=t.replace(At,zt).toLowerCase(),function(e){var n;do if(n=q?e.lang:e.getAttribute("xml:lang")||e.getAttribute("lang"))return n=n.toLowerCase(),n===t||0===n.indexOf(t+"-");while((e=e.parentNode)&&1===e.nodeType);return!1}}),target:function(e){var n=t.location&&t.location.hash;return n&&n.slice(1)===e.id},root:function(t){return t===k},focus:function(t){return t===D.activeElement&&(!D.hasFocus||D.hasFocus())&&!!(t.type||t.href||~t.tabIndex)},enabled:function(t){return t.disabled===!1},disabled:function(t){return t.disabled===!0},checked:function(t){var e=t.nodeName.toLowerCase();return"input"===e&&!!t.checked||"option"===e&&!!t.selected},selected:function(t){return t.parentNode&&t.parentNode.selectedIndex,t.selected===!0},empty:function(t){for(t=t.firstChild;t;t=t.nextSibling)if(t.nodeType<6)return!1;return!0},parent:function(t){return!z.pseudos.empty(t)},header:function(t){return gt.test(t.nodeName)},input:function(t){return mt.test(t.nodeName)},button:function(t){var e=t.nodeName.toLowerCase();return"input"===e&&"button"===t.type||"button"===e},text:function(t){var e;return"input"===t.nodeName.toLowerCase()&&"text"===t.type&&(null==(e=t.getAttribute("type"))||"text"===e.toLowerCase())},first:l(function(){return[0]}),last:l(function(t,e){return[e-1]}),eq:l(function(t,e,n){return[n<0?n+e:n]}),even:l(function(t,e){for(var n=0;n=0;)t.push(i);return t}),gt:l(function(t,e,n){for(var i=n<0?n+e:n;++i2&&"ID"===(s=a[0]).type&&A.getById&&9===e.nodeType&&q&&z.relative[a[1].type]){if(e=(z.find.ID(s.matches[0].replace(At,zt),e)||[])[0],!e)return n;l&&(e=e.parentNode),t=t.slice(a.shift().value.length)}for(o=ft.needsContext.test(t)?0:a.length;o--&&(s=a[o],!z.relative[r=s.type]);)if((c=z.find[r])&&(i=c(s.matches[0].replace(At,zt),Mt.test(a[0].type)&&u(e.parentNode)||e))){if(a.splice(o,1),t=i.length&&d(a),!t)return Q.apply(n,i),n;break}}return(l||C(t,h))(i,e,!q,n,Mt.test(t)&&u(e.parentNode)||e),n},A.sortStable=X.split("").sort($).join("")===X,A.detectDuplicates=!!x,L(),A.sortDetached=o(function(t){return 1&t.compareDocumentPosition(D.createElement("div"))}),o(function(t){return t.innerHTML="","#"===t.firstChild.getAttribute("href")})||a("type|href|height|width",function(t,e,n){if(!n)return t.getAttribute(e,"type"===e.toLowerCase()?1:2)}),A.attributes&&o(function(t){return t.innerHTML="",t.firstChild.setAttribute("value",""),""===t.firstChild.getAttribute("value")})||a("value",function(t,e,n){if(!n&&"input"===t.nodeName.toLowerCase())return t.defaultValue}),o(function(t){return null==t.getAttribute("disabled")})||a(et,function(t,e,n){var i;if(!n)return t[e]===!0?e.toLowerCase():(i=t.getAttributeNode(e))&&i.specified?i.value:null}),e}(t);ot.find=lt,ot.expr=lt.selectors,ot.expr[":"]=ot.expr.pseudos,ot.unique=lt.uniqueSort,ot.text=lt.getText,ot.isXMLDoc=lt.isXML,ot.contains=lt.contains;var ut=ot.expr.match.needsContext,ht=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,dt=/^.[^:#\[\.,]*$/;ot.filter=function(t,e,n){var i=e[0];return n&&(t=":not("+t+")"),1===e.length&&1===i.nodeType?ot.find.matchesSelector(i,t)?[i]:[]:ot.find.matches(t,ot.grep(e,function(t){return 1===t.nodeType}))},ot.fn.extend({find:function(t){var e,n=[],i=this,o=i.length;if("string"!=typeof t)return this.pushStack(ot(t).filter(function(){for(e=0;e1?ot.unique(n):n),n.selector=this.selector?this.selector+" "+t:t,n},filter:function(t){return this.pushStack(i(this,t||[],!1))},not:function(t){return this.pushStack(i(this,t||[],!0))},is:function(t){return!!i(this,"string"==typeof t&&ut.test(t)?ot(t):t||[],!1).length}});var pt,ft=t.document,mt=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,gt=ot.fn.init=function(t,e){var n,i;if(!t)return this;if("string"==typeof t){if(n="<"===t.charAt(0)&&">"===t.charAt(t.length-1)&&t.length>=3?[null,t,null]:mt.exec(t),!n||!n[1]&&e)return!e||e.jquery?(e||pt).find(t):this.constructor(e).find(t);if(n[1]){if(e=e instanceof ot?e[0]:e,ot.merge(this,ot.parseHTML(n[1],e&&e.nodeType?e.ownerDocument||e:ft,!0)),ht.test(n[1])&&ot.isPlainObject(e))for(n in e)ot.isFunction(this[n])?this[n](e[n]):this.attr(n,e[n]);return this}if(i=ft.getElementById(n[2]),i&&i.parentNode){if(i.id!==n[2])return pt.find(t);this.length=1,this[0]=i}return this.context=ft,this.selector=t,this}return t.nodeType?(this.context=this[0]=t,this.length=1,this):ot.isFunction(t)?"undefined"!=typeof pt.ready?pt.ready(t):t(ot):(void 0!==t.selector&&(this.selector=t.selector,this.context=t.context),ot.makeArray(t,this))};gt.prototype=ot.fn,pt=ot(ft);var bt=/^(?:parents|prev(?:Until|All))/,vt={children:!0,contents:!0,next:!0,prev:!0};ot.extend({dir:function(t,e,n){for(var i=[],o=t[e];o&&9!==o.nodeType&&(void 0===n||1!==o.nodeType||!ot(o).is(n));)1===o.nodeType&&i.push(o),o=o[e];return i},sibling:function(t,e){for(var n=[];t;t=t.nextSibling)1===t.nodeType&&t!==e&&n.push(t);return n}}),ot.fn.extend({has:function(t){var e,n=ot(t,this),i=n.length;return this.filter(function(){for(e=0;e-1:1===n.nodeType&&ot.find.matchesSelector(n,t))){a.push(n);break}return this.pushStack(a.length>1?ot.unique(a):a)},index:function(t){return t?"string"==typeof t?ot.inArray(this[0],ot(t)):ot.inArray(t.jquery?t[0]:t,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(t,e){return this.pushStack(ot.unique(ot.merge(this.get(),ot(t,e))))},addBack:function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}}),ot.each({parent:function(t){var e=t.parentNode;return e&&11!==e.nodeType?e:null},parents:function(t){return ot.dir(t,"parentNode")},parentsUntil:function(t,e,n){return ot.dir(t,"parentNode",n)},next:function(t){return o(t,"nextSibling")},prev:function(t){return o(t,"previousSibling")},nextAll:function(t){return ot.dir(t,"nextSibling")},prevAll:function(t){return ot.dir(t,"previousSibling")},nextUntil:function(t,e,n){return ot.dir(t,"nextSibling",n)},prevUntil:function(t,e,n){return ot.dir(t,"previousSibling",n)},siblings:function(t){return ot.sibling((t.parentNode||{}).firstChild,t)},children:function(t){return ot.sibling(t.firstChild)},contents:function(t){return ot.nodeName(t,"iframe")?t.contentDocument||t.contentWindow.document:ot.merge([],t.childNodes)}},function(t,e){ot.fn[t]=function(n,i){var o=ot.map(this,e,n);return"Until"!==t.slice(-5)&&(i=n),i&&"string"==typeof i&&(o=ot.filter(i,o)),this.length>1&&(vt[t]||(o=ot.unique(o)),bt.test(t)&&(o=o.reverse())),this.pushStack(o)}});var Mt=/\S+/g,yt={};ot.Callbacks=function(t){t="string"==typeof t?yt[t]||a(t):ot.extend({},t);var e,n,i,o,s,r,c=[],l=!t.once&&[],u=function(a){for(n=t.memory&&a,i=!0,s=r||0,r=0,o=c.length,e=!0;c&&s-1;)c.splice(i,1),e&&(i<=o&&o--,i<=s&&s--)}),this},has:function(t){return t?ot.inArray(t,c)>-1:!(!c||!c.length)},empty:function(){return c=[],o=0,this},disable:function(){return c=l=n=void 0,this},disabled:function(){return!c},lock:function(){return l=void 0,n||h.disable(),this},locked:function(){return!l},fireWith:function(t,n){return!c||i&&!l||(n=n||[],n=[t,n.slice?n.slice():n],e?l.push(n):u(n)),this},fire:function(){return h.fireWith(this,arguments),this},fired:function(){return!!i}};return h},ot.extend({Deferred:function(t){var e=[["resolve","done",ot.Callbacks("once memory"),"resolved"],["reject","fail",ot.Callbacks("once memory"),"rejected"],["notify","progress",ot.Callbacks("memory")]],n="pending",i={state:function(){return n},always:function(){return o.done(arguments).fail(arguments),this},then:function(){var t=arguments;return ot.Deferred(function(n){ot.each(e,function(e,a){var s=ot.isFunction(t[e])&&t[e];o[a[1]](function(){var t=s&&s.apply(this,arguments);t&&ot.isFunction(t.promise)?t.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a[0]+"With"](this===i?n.promise():this,s?[t]:arguments)})}),t=null}).promise()},promise:function(t){return null!=t?ot.extend(t,i):i}},o={};return i.pipe=i.then,ot.each(e,function(t,a){var s=a[2],r=a[3];i[a[1]]=s.add,r&&s.add(function(){n=r},e[1^t][2].disable,e[2][2].lock),o[a[0]]=function(){return o[a[0]+"With"](this===o?i:this,arguments),this},o[a[0]+"With"]=s.fireWith}),i.promise(o),t&&t.call(o,o),o},when:function(t){var e,n,i,o=0,a=J.call(arguments),s=a.length,r=1!==s||t&&ot.isFunction(t.promise)?s:0,c=1===r?t:ot.Deferred(),l=function(t,n,i){return function(o){n[t]=this,i[t]=arguments.length>1?J.call(arguments):o,i===e?c.notifyWith(n,i):--r||c.resolveWith(n,i)}};if(s>1)for(e=new Array(s),n=new Array(s),i=new Array(s);o0||(At.resolveWith(ft,[ot]),ot.fn.triggerHandler&&(ot(ft).triggerHandler("ready"),ot(ft).off("ready")))}}}),ot.ready.promise=function(e){if(!At)if(At=ot.Deferred(),"complete"===ft.readyState)setTimeout(ot.ready);else if(ft.addEventListener)ft.addEventListener("DOMContentLoaded",r,!1),t.addEventListener("load",r,!1);else{ft.attachEvent("onreadystatechange",r),t.attachEvent("onload",r);var n=!1;try{n=null==t.frameElement&&ft.documentElement}catch(i){}n&&n.doScroll&&!function o(){if(!ot.isReady){try{n.doScroll("left")}catch(t){return setTimeout(o,50)}s(),ot.ready()}}()}return At.promise(e)};var zt,_t="undefined";for(zt in ot(nt))break;nt.ownLast="0"!==zt,nt.inlineBlockNeedsLayout=!1,ot(function(){var t,e,n,i;n=ft.getElementsByTagName("body")[0],n&&n.style&&(e=ft.createElement("div"),i=ft.createElement("div"),i.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",n.appendChild(i).appendChild(e),typeof e.style.zoom!==_t&&(e.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",nt.inlineBlockNeedsLayout=t=3===e.offsetWidth,t&&(n.style.zoom=1)),n.removeChild(i))}),function(){var t=ft.createElement("div");if(null==nt.deleteExpando){nt.deleteExpando=!0;try{delete t.test}catch(e){nt.deleteExpando=!1}}t=null}(),ot.acceptData=function(t){var e=ot.noData[(t.nodeName+" ").toLowerCase()],n=+t.nodeType||1;return(1===n||9===n)&&(!e||e!==!0&&t.getAttribute("classid")===e)};var Tt=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,wt=/([A-Z])/g;ot.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(t){return t=t.nodeType?ot.cache[t[ot.expando]]:t[ot.expando],!!t&&!l(t)},data:function(t,e,n){return u(t,e,n)},removeData:function(t,e){return h(t,e)},_data:function(t,e,n){return u(t,e,n,!0)},_removeData:function(t,e){return h(t,e,!0)}}),ot.fn.extend({data:function(t,e){var n,i,o,a=this[0],s=a&&a.attributes;if(void 0===t){if(this.length&&(o=ot.data(a),1===a.nodeType&&!ot._data(a,"parsedAttrs"))){for(n=s.length;n--;)s[n]&&(i=s[n].name,0===i.indexOf("data-")&&(i=ot.camelCase(i.slice(5)),c(a,i,o[i])));ot._data(a,"parsedAttrs",!0)}return o}return"object"==typeof t?this.each(function(){ot.data(this,t)}):arguments.length>1?this.each(function(){ot.data(this,t,e)}):a?c(a,t,ot.data(a,t)):void 0},removeData:function(t){return this.each(function(){ot.removeData(this,t)})}}),ot.extend({queue:function(t,e,n){var i;if(t)return e=(e||"fx")+"queue",i=ot._data(t,e),n&&(!i||ot.isArray(n)?i=ot._data(t,e,ot.makeArray(n)):i.push(n)),i||[]},dequeue:function(t,e){e=e||"fx";var n=ot.queue(t,e),i=n.length,o=n.shift(),a=ot._queueHooks(t,e),s=function(){ot.dequeue(t,e)};"inprogress"===o&&(o=n.shift(),i--),o&&("fx"===e&&n.unshift("inprogress"),delete a.stop,o.call(t,s,a)),!i&&a&&a.empty.fire()},_queueHooks:function(t,e){var n=e+"queueHooks";return ot._data(t,n)||ot._data(t,n,{empty:ot.Callbacks("once memory").add(function(){ot._removeData(t,e+"queue"),ot._removeData(t,n)})})}}),ot.fn.extend({queue:function(t,e){var n=2;return"string"!=typeof t&&(e=t,t="fx",n--),arguments.length
a",nt.leadingWhitespace=3===e.firstChild.nodeType,nt.tbody=!e.getElementsByTagName("tbody").length,nt.htmlSerialize=!!e.getElementsByTagName("link").length,nt.html5Clone="<:nav>"!==ft.createElement("nav").cloneNode(!0).outerHTML,t.type="checkbox",t.checked=!0,n.appendChild(t),nt.appendChecked=t.checked,e.innerHTML="",nt.noCloneChecked=!!e.cloneNode(!0).lastChild.defaultValue,n.appendChild(e),e.innerHTML="",nt.checkClone=e.cloneNode(!0).cloneNode(!0).lastChild.checked,nt.noCloneEvent=!0,e.attachEvent&&(e.attachEvent("onclick",function(){nt.noCloneEvent=!1}),e.cloneNode(!0).click()),null==nt.deleteExpando){nt.deleteExpando=!0;try{delete e.test}catch(i){nt.deleteExpando=!1}}}(),function(){var e,n,i=ft.createElement("div");for(e in{submit:!0,change:!0,focusin:!0})n="on"+e,(nt[e+"Bubbles"]=n in t)||(i.setAttribute(n,"t"),nt[e+"Bubbles"]=i.attributes[n].expando===!1);i=null}();var Lt=/^(?:input|select|textarea)$/i,Dt=/^key/,kt=/^(?:mouse|pointer|contextmenu)|click/,qt=/^(?:focusinfocus|focusoutblur)$/,Wt=/^([^.]*)(?:\.(.+)|)$/;ot.event={global:{},add:function(t,e,n,i,o){var a,s,r,c,l,u,h,d,p,f,m,g=ot._data(t);if(g){for(n.handler&&(c=n,n=c.handler,o=c.selector),n.guid||(n.guid=ot.guid++),(s=g.events)||(s=g.events={}),(u=g.handle)||(u=g.handle=function(t){return typeof ot===_t||t&&ot.event.triggered===t.type?void 0:ot.event.dispatch.apply(u.elem,arguments)},u.elem=t),e=(e||"").match(Mt)||[""],r=e.length;r--;)a=Wt.exec(e[r])||[],p=m=a[1],f=(a[2]||"").split(".").sort(),p&&(l=ot.event.special[p]||{},p=(o?l.delegateType:l.bindType)||p,l=ot.event.special[p]||{},h=ot.extend({type:p,origType:m,data:i,handler:n,guid:n.guid,selector:o,needsContext:o&&ot.expr.match.needsContext.test(o),namespace:f.join(".")},c),(d=s[p])||(d=s[p]=[],d.delegateCount=0,l.setup&&l.setup.call(t,i,f,u)!==!1||(t.addEventListener?t.addEventListener(p,u,!1):t.attachEvent&&t.attachEvent("on"+p,u))),l.add&&(l.add.call(t,h),h.handler.guid||(h.handler.guid=n.guid)),o?d.splice(d.delegateCount++,0,h):d.push(h),ot.event.global[p]=!0);t=null}},remove:function(t,e,n,i,o){var a,s,r,c,l,u,h,d,p,f,m,g=ot.hasData(t)&&ot._data(t);if(g&&(u=g.events)){for(e=(e||"").match(Mt)||[""],l=e.length;l--;)if(r=Wt.exec(e[l])||[],p=m=r[1],f=(r[2]||"").split(".").sort(),p){for(h=ot.event.special[p]||{},p=(i?h.delegateType:h.bindType)||p,d=u[p]||[],r=r[2]&&new RegExp("(^|\\.)"+f.join("\\.(?:.*\\.|)")+"(\\.|$)"),c=a=d.length;a--;)s=d[a],!o&&m!==s.origType||n&&n.guid!==s.guid||r&&!r.test(s.namespace)||i&&i!==s.selector&&("**"!==i||!s.selector)||(d.splice(a,1),s.selector&&d.delegateCount--,h.remove&&h.remove.call(t,s));c&&!d.length&&(h.teardown&&h.teardown.call(t,f,g.handle)!==!1||ot.removeEvent(t,p,g.handle),delete u[p])}else for(p in u)ot.event.remove(t,p+e[l],n,i,!0);ot.isEmptyObject(u)&&(delete g.handle,ot._removeData(t,"events"))}},trigger:function(e,n,i,o){var a,s,r,c,l,u,h,d=[i||ft],p=et.call(e,"type")?e.type:e,f=et.call(e,"namespace")?e.namespace.split("."):[];if(r=u=i=i||ft,3!==i.nodeType&&8!==i.nodeType&&!qt.test(p+ot.event.triggered)&&(p.indexOf(".")>=0&&(f=p.split("."),p=f.shift(),f.sort()),s=p.indexOf(":")<0&&"on"+p,e=e[ot.expando]?e:new ot.Event(p,"object"==typeof e&&e),e.isTrigger=o?2:3,e.namespace=f.join("."),e.namespace_re=e.namespace?new RegExp("(^|\\.)"+f.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,e.result=void 0,e.target||(e.target=i),n=null==n?[e]:ot.makeArray(n,[e]),l=ot.event.special[p]||{},o||!l.trigger||l.trigger.apply(i,n)!==!1)){if(!o&&!l.noBubble&&!ot.isWindow(i)){for(c=l.delegateType||p,qt.test(c+p)||(r=r.parentNode);r;r=r.parentNode)d.push(r),u=r;u===(i.ownerDocument||ft)&&d.push(u.defaultView||u.parentWindow||t); -}for(h=0;(r=d[h++])&&!e.isPropagationStopped();)e.type=h>1?c:l.bindType||p,a=(ot._data(r,"events")||{})[e.type]&&ot._data(r,"handle"),a&&a.apply(r,n),a=s&&r[s],a&&a.apply&&ot.acceptData(r)&&(e.result=a.apply(r,n),e.result===!1&&e.preventDefault());if(e.type=p,!o&&!e.isDefaultPrevented()&&(!l._default||l._default.apply(d.pop(),n)===!1)&&ot.acceptData(i)&&s&&i[p]&&!ot.isWindow(i)){u=i[s],u&&(i[s]=null),ot.event.triggered=p;try{i[p]()}catch(m){}ot.event.triggered=void 0,u&&(i[s]=u)}return e.result}},dispatch:function(t){t=ot.event.fix(t);var e,n,i,o,a,s=[],r=J.call(arguments),c=(ot._data(this,"events")||{})[t.type]||[],l=ot.event.special[t.type]||{};if(r[0]=t,t.delegateTarget=this,!l.preDispatch||l.preDispatch.call(this,t)!==!1){for(s=ot.event.handlers.call(this,t,c),e=0;(o=s[e++])&&!t.isPropagationStopped();)for(t.currentTarget=o.elem,a=0;(i=o.handlers[a++])&&!t.isImmediatePropagationStopped();)t.namespace_re&&!t.namespace_re.test(i.namespace)||(t.handleObj=i,t.data=i.data,n=((ot.event.special[i.origType]||{}).handle||i.handler).apply(o.elem,r),void 0!==n&&(t.result=n)===!1&&(t.preventDefault(),t.stopPropagation()));return l.postDispatch&&l.postDispatch.call(this,t),t.result}},handlers:function(t,e){var n,i,o,a,s=[],r=e.delegateCount,c=t.target;if(r&&c.nodeType&&(!t.button||"click"!==t.type))for(;c!=this;c=c.parentNode||this)if(1===c.nodeType&&(c.disabled!==!0||"click"!==t.type)){for(o=[],a=0;a=0:ot.find(n,this,null,[c]).length),o[n]&&o.push(i);o.length&&s.push({elem:c,handlers:o})}return r]","i"),Xt=/^\s+/,Pt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,Rt=/<([\w:]+)/,Ft=/\s*$/g,Jt={option:[1,""],legend:[1,"

","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],_default:nt.htmlSerialize?[0,"",""]:[1,"X
","
"]},Kt=m(ft),Gt=Kt.appendChild(ft.createElement("div"));Jt.optgroup=Jt.option,Jt.tbody=Jt.tfoot=Jt.colgroup=Jt.caption=Jt.thead,Jt.th=Jt.td,ot.extend({clone:function(t,e,n){var i,o,a,s,r,c=ot.contains(t.ownerDocument,t);if(nt.html5Clone||ot.isXMLDoc(t)||!It.test("<"+t.nodeName+">")?a=t.cloneNode(!0):(Gt.innerHTML=t.outerHTML,Gt.removeChild(a=Gt.firstChild)),!(nt.noCloneEvent&&nt.noCloneChecked||1!==t.nodeType&&11!==t.nodeType||ot.isXMLDoc(t)))for(i=g(a),r=g(t),s=0;null!=(o=r[s]);++s)i[s]&&_(o,i[s]);if(e)if(n)for(r=r||g(t),i=i||g(a),s=0;null!=(o=r[s]);s++)z(o,i[s]);else z(t,a);return i=g(a,"script"),i.length>0&&A(i,!c&&g(t,"script")),i=r=o=null,a},buildFragment:function(t,e,n,i){for(var o,a,s,r,c,l,u,h=t.length,d=m(e),p=[],f=0;f")+u[2],o=u[0];o--;)r=r.lastChild;if(!nt.leadingWhitespace&&Xt.test(a)&&p.push(e.createTextNode(Xt.exec(a)[0])),!nt.tbody)for(a="table"!==c||Ft.test(a)?""!==u[1]||Ft.test(a)?0:r:r.firstChild,o=a&&a.childNodes.length;o--;)ot.nodeName(l=a.childNodes[o],"tbody")&&!l.childNodes.length&&a.removeChild(l);for(ot.merge(p,r.childNodes),r.textContent="";r.firstChild;)r.removeChild(r.firstChild);r=d.lastChild}else p.push(e.createTextNode(a));for(r&&d.removeChild(r),nt.appendChecked||ot.grep(g(p,"input"),b),f=0;a=p[f++];)if((!i||ot.inArray(a,i)===-1)&&(s=ot.contains(a.ownerDocument,a),r=g(d.appendChild(a),"script"),s&&A(r),n))for(o=0;a=r[o++];)$t.test(a.type||"")&&n.push(a);return r=null,d},cleanData:function(t,e){for(var n,i,o,a,s=0,r=ot.expando,c=ot.cache,l=nt.deleteExpando,u=ot.event.special;null!=(n=t[s]);s++)if((e||ot.acceptData(n))&&(o=n[r],a=o&&c[o])){if(a.events)for(i in a.events)u[i]?ot.event.remove(n,i):ot.removeEvent(n,i,a.handle);c[o]&&(delete c[o],l?delete n[r]:typeof n.removeAttribute!==_t?n.removeAttribute(r):n[r]=null,Y.push(o))}}}),ot.fn.extend({text:function(t){return St(this,function(t){return void 0===t?ot.text(this):this.empty().append((this[0]&&this[0].ownerDocument||ft).createTextNode(t))},null,t,arguments.length)},append:function(){return this.domManip(arguments,function(t){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var e=v(this,t);e.appendChild(t)}})},prepend:function(){return this.domManip(arguments,function(t){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var e=v(this,t);e.insertBefore(t,e.firstChild)}})},before:function(){return this.domManip(arguments,function(t){this.parentNode&&this.parentNode.insertBefore(t,this)})},after:function(){return this.domManip(arguments,function(t){this.parentNode&&this.parentNode.insertBefore(t,this.nextSibling)})},remove:function(t,e){for(var n,i=t?ot.filter(t,this):this,o=0;null!=(n=i[o]);o++)e||1!==n.nodeType||ot.cleanData(g(n)),n.parentNode&&(e&&ot.contains(n.ownerDocument,n)&&A(g(n,"script")),n.parentNode.removeChild(n));return this},empty:function(){for(var t,e=0;null!=(t=this[e]);e++){for(1===t.nodeType&&ot.cleanData(g(t,!1));t.firstChild;)t.removeChild(t.firstChild);t.options&&ot.nodeName(t,"select")&&(t.options.length=0)}return this},clone:function(t,e){return t=null!=t&&t,e=null==e?t:e,this.map(function(){return ot.clone(this,t,e)})},html:function(t){return St(this,function(t){var e=this[0]||{},n=0,i=this.length;if(void 0===t)return 1===e.nodeType?e.innerHTML.replace(Bt,""):void 0;if("string"==typeof t&&!jt.test(t)&&(nt.htmlSerialize||!It.test(t))&&(nt.leadingWhitespace||!Xt.test(t))&&!Jt[(Rt.exec(t)||["",""])[1].toLowerCase()]){t=t.replace(Pt,"<$1>");try{for(;n1&&"string"==typeof d&&!nt.checkClone&&Ut.test(d))return this.each(function(n){var i=u.eq(n);p&&(t[0]=d.call(this,n,i.html())),i.domManip(t,e)});if(l&&(r=ot.buildFragment(t,this[0].ownerDocument,!1,this),n=r.firstChild,1===r.childNodes.length&&(r=n),n)){for(a=ot.map(g(r,"script"),M),o=a.length;c
t
",o=e.getElementsByTagName("td"),o[0].style.cssText="margin:0;border:0;padding:0;display:none",r=0===o[0].offsetHeight,r&&(o[0].style.display="",o[1].style.display="none",r=0===o[0].offsetHeight),n.removeChild(i))}var n,i,o,a,s,r,c;n=ft.createElement("div"),n.innerHTML="
a",o=n.getElementsByTagName("a")[0],i=o&&o.style,i&&(i.cssText="float:left;opacity:.5",nt.opacity="0.5"===i.opacity,nt.cssFloat=!!i.cssFloat,n.style.backgroundClip="content-box",n.cloneNode(!0).style.backgroundClip="",nt.clearCloneStyle="content-box"===n.style.backgroundClip,nt.boxSizing=""===i.boxSizing||""===i.MozBoxSizing||""===i.WebkitBoxSizing,ot.extend(nt,{reliableHiddenOffsets:function(){return null==r&&e(),r},boxSizingReliable:function(){return null==s&&e(),s},pixelPosition:function(){return null==a&&e(),a},reliableMarginRight:function(){return null==c&&e(),c}}))}(),ot.swap=function(t,e,n,i){var o,a,s={};for(a in e)s[a]=t.style[a],t.style[a]=e[a];o=n.apply(t,i||[]);for(a in e)t.style[a]=s[a];return o};var ae=/alpha\([^)]*\)/i,se=/opacity\s*=\s*([^)]*)/,re=/^(none|table(?!-c[ea]).+)/,ce=new RegExp("^("+Ct+")(.*)$","i"),le=new RegExp("^([+-])=("+Ct+")","i"),ue={position:"absolute",visibility:"hidden",display:"block"},he={letterSpacing:"0",fontWeight:"400"},de=["Webkit","O","Moz","ms"];ot.extend({cssHooks:{opacity:{get:function(t,e){if(e){var n=ee(t,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":nt.cssFloat?"cssFloat":"styleFloat"},style:function(t,e,n,i){if(t&&3!==t.nodeType&&8!==t.nodeType&&t.style){var o,a,s,r=ot.camelCase(e),c=t.style;if(e=ot.cssProps[r]||(ot.cssProps[r]=N(c,r)),s=ot.cssHooks[e]||ot.cssHooks[r],void 0===n)return s&&"get"in s&&void 0!==(o=s.get(t,!1,i))?o:c[e];if(a=typeof n,"string"===a&&(o=le.exec(n))&&(n=(o[1]+1)*o[2]+parseFloat(ot.css(t,e)),a="number"),null!=n&&n===n&&("number"!==a||ot.cssNumber[r]||(n+="px"),nt.clearCloneStyle||""!==n||0!==e.indexOf("background")||(c[e]="inherit"),!(s&&"set"in s&&void 0===(n=s.set(t,n,i)))))try{c[e]=n}catch(l){}}},css:function(t,e,n,i){var o,a,s,r=ot.camelCase(e);return e=ot.cssProps[r]||(ot.cssProps[r]=N(t.style,r)),s=ot.cssHooks[e]||ot.cssHooks[r],s&&"get"in s&&(a=s.get(t,!0,n)),void 0===a&&(a=ee(t,e,i)),"normal"===a&&e in he&&(a=he[e]),""===n||n?(o=parseFloat(a),n===!0||ot.isNumeric(o)?o||0:a):a}}),ot.each(["height","width"],function(t,e){ot.cssHooks[e]={get:function(t,n,i){if(n)return re.test(ot.css(t,"display"))&&0===t.offsetWidth?ot.swap(t,ue,function(){return L(t,e,i)}):L(t,e,i)},set:function(t,n,i){var o=i&&te(t);return S(t,n,i?x(t,e,i,nt.boxSizing&&"border-box"===ot.css(t,"boxSizing",!1,o),o):0)}}}),nt.opacity||(ot.cssHooks.opacity={get:function(t,e){return se.test((e&&t.currentStyle?t.currentStyle.filter:t.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":e?"1":""},set:function(t,e){var n=t.style,i=t.currentStyle,o=ot.isNumeric(e)?"alpha(opacity="+100*e+")":"",a=i&&i.filter||n.filter||"";n.zoom=1,(e>=1||""===e)&&""===ot.trim(a.replace(ae,""))&&n.removeAttribute&&(n.removeAttribute("filter"),""===e||i&&!i.filter)||(n.filter=ae.test(a)?a.replace(ae,o):a+" "+o)}}),ot.cssHooks.marginRight=C(nt.reliableMarginRight,function(t,e){if(e)return ot.swap(t,{display:"inline-block"},ee,[t,"marginRight"])}),ot.each({margin:"",padding:"",border:"Width"},function(t,e){ot.cssHooks[t+e]={expand:function(n){for(var i=0,o={},a="string"==typeof n?n.split(" "):[n];i<4;i++)o[t+Nt[i]+e]=a[i]||a[i-2]||a[0];return o}},ne.test(t)||(ot.cssHooks[t+e].set=S)}),ot.fn.extend({css:function(t,e){return St(this,function(t,e,n){var i,o,a={},s=0;if(ot.isArray(e)){for(i=te(t),o=e.length;s1)},show:function(){return O(this,!0)},hide:function(){return O(this)},toggle:function(t){return"boolean"==typeof t?t?this.show():this.hide():this.each(function(){Ot(this)?ot(this).show():ot(this).hide()})}}),ot.Tween=D,D.prototype={constructor:D,init:function(t,e,n,i,o,a){this.elem=t,this.prop=n,this.easing=o||"swing",this.options=e,this.start=this.now=this.cur(),this.end=i,this.unit=a||(ot.cssNumber[n]?"":"px")},cur:function(){var t=D.propHooks[this.prop];return t&&t.get?t.get(this):D.propHooks._default.get(this)},run:function(t){var e,n=D.propHooks[this.prop];return this.options.duration?this.pos=e=ot.easing[this.easing](t,this.options.duration*t,0,1,this.options.duration):this.pos=e=t,this.now=(this.end-this.start)*e+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):D.propHooks._default.set(this),this}},D.prototype.init.prototype=D.prototype,D.propHooks={_default:{get:function(t){var e;return null==t.elem[t.prop]||t.elem.style&&null!=t.elem.style[t.prop]?(e=ot.css(t.elem,t.prop,""),e&&"auto"!==e?e:0):t.elem[t.prop]},set:function(t){ot.fx.step[t.prop]?ot.fx.step[t.prop](t):t.elem.style&&(null!=t.elem.style[ot.cssProps[t.prop]]||ot.cssHooks[t.prop])?ot.style(t.elem,t.prop,t.now+t.unit):t.elem[t.prop]=t.now}}},D.propHooks.scrollTop=D.propHooks.scrollLeft={set:function(t){t.elem.nodeType&&t.elem.parentNode&&(t.elem[t.prop]=t.now)}},ot.easing={linear:function(t){return t},swing:function(t){return.5-Math.cos(t*Math.PI)/2}},ot.fx=D.prototype.init,ot.fx.step={};var pe,fe,me=/^(?:toggle|show|hide)$/,ge=new RegExp("^(?:([+-])=|)("+Ct+")([a-z%]*)$","i"),be=/queueHooks$/,ve=[E],Me={"*":[function(t,e){var n=this.createTween(t,e),i=n.cur(),o=ge.exec(e),a=o&&o[3]||(ot.cssNumber[t]?"":"px"),s=(ot.cssNumber[t]||"px"!==a&&+i)&&ge.exec(ot.css(n.elem,t)),r=1,c=20;if(s&&s[3]!==a){a=a||s[3],o=o||[],s=+i||1;do r=r||".5",s/=r,ot.style(n.elem,t,s+a);while(r!==(r=n.cur()/i)&&1!==r&&--c)}return o&&(s=n.start=+s||+i||0,n.unit=a,n.end=o[1]?s+(o[1]+1)*o[2]:+o[2]),n}]};ot.Animation=ot.extend(I,{tweener:function(t,e){ot.isFunction(t)?(e=t,t=["*"]):t=t.split(" ");for(var n,i=0,o=t.length;i
a",i=e.getElementsByTagName("a")[0],n=ft.createElement("select"),o=n.appendChild(ft.createElement("option")),t=e.getElementsByTagName("input")[0],i.style.cssText="top:1px",nt.getSetAttribute="t"!==e.className,nt.style=/top/.test(i.getAttribute("style")),nt.hrefNormalized="/a"===i.getAttribute("href"),nt.checkOn=!!t.value,nt.optSelected=o.selected,nt.enctype=!!ft.createElement("form").enctype,n.disabled=!0,nt.optDisabled=!o.disabled,t=ft.createElement("input"),t.setAttribute("value",""),nt.input=""===t.getAttribute("value"),t.value="t",t.setAttribute("type","radio"),nt.radioValue="t"===t.value}();var ye=/\r/g;ot.fn.extend({val:function(t){var e,n,i,o=this[0];{if(arguments.length)return i=ot.isFunction(t),this.each(function(n){var o;1===this.nodeType&&(o=i?t.call(this,n,ot(this).val()):t,null==o?o="":"number"==typeof o?o+="":ot.isArray(o)&&(o=ot.map(o,function(t){return null==t?"":t+""})),e=ot.valHooks[this.type]||ot.valHooks[this.nodeName.toLowerCase()],e&&"set"in e&&void 0!==e.set(this,o,"value")||(this.value=o))});if(o)return e=ot.valHooks[o.type]||ot.valHooks[o.nodeName.toLowerCase()],e&&"get"in e&&void 0!==(n=e.get(o,"value"))?n:(n=o.value,"string"==typeof n?n.replace(ye,""):null==n?"":n)}}}),ot.extend({valHooks:{option:{get:function(t){var e=ot.find.attr(t,"value");return null!=e?e:ot.trim(ot.text(t))}},select:{get:function(t){for(var e,n,i=t.options,o=t.selectedIndex,a="select-one"===t.type||o<0,s=a?null:[],r=a?o+1:i.length,c=o<0?r:a?o:0;c=0)try{i.selected=n=!0}catch(r){i.scrollHeight}else i.selected=!1;return n||(t.selectedIndex=-1),o}}}}),ot.each(["radio","checkbox"],function(){ot.valHooks[this]={set:function(t,e){if(ot.isArray(e))return t.checked=ot.inArray(ot(t).val(),e)>=0}},nt.checkOn||(ot.valHooks[this].get=function(t){return null===t.getAttribute("value")?"on":t.value})});var Ae,ze,_e=ot.expr.attrHandle,Te=/^(?:checked|selected)$/i,we=nt.getSetAttribute,Ce=nt.input;ot.fn.extend({attr:function(t,e){return St(this,ot.attr,t,e,arguments.length>1)},removeAttr:function(t){return this.each(function(){ot.removeAttr(this,t)})}}),ot.extend({attr:function(t,e,n){var i,o,a=t.nodeType;if(t&&3!==a&&8!==a&&2!==a)return typeof t.getAttribute===_t?ot.prop(t,e,n):(1===a&&ot.isXMLDoc(t)||(e=e.toLowerCase(),i=ot.attrHooks[e]||(ot.expr.match.bool.test(e)?ze:Ae)),void 0===n?i&&"get"in i&&null!==(o=i.get(t,e))?o:(o=ot.find.attr(t,e),null==o?void 0:o):null!==n?i&&"set"in i&&void 0!==(o=i.set(t,n,e))?o:(t.setAttribute(e,n+""),n):void ot.removeAttr(t,e))},removeAttr:function(t,e){var n,i,o=0,a=e&&e.match(Mt);if(a&&1===t.nodeType)for(;n=a[o++];)i=ot.propFix[n]||n,ot.expr.match.bool.test(n)?Ce&&we||!Te.test(n)?t[i]=!1:t[ot.camelCase("default-"+n)]=t[i]=!1:ot.attr(t,n,""),t.removeAttribute(we?n:i)},attrHooks:{type:{set:function(t,e){if(!nt.radioValue&&"radio"===e&&ot.nodeName(t,"input")){var n=t.value;return t.setAttribute("type",e),n&&(t.value=n),e}}}}}),ze={set:function(t,e,n){return e===!1?ot.removeAttr(t,n):Ce&&we||!Te.test(n)?t.setAttribute(!we&&ot.propFix[n]||n,n):t[ot.camelCase("default-"+n)]=t[n]=!0,n}},ot.each(ot.expr.match.bool.source.match(/\w+/g),function(t,e){var n=_e[e]||ot.find.attr;_e[e]=Ce&&we||!Te.test(e)?function(t,e,i){var o,a;return i||(a=_e[e],_e[e]=o,o=null!=n(t,e,i)?e.toLowerCase():null,_e[e]=a),o}:function(t,e,n){if(!n)return t[ot.camelCase("default-"+e)]?e.toLowerCase():null}}),Ce&&we||(ot.attrHooks.value={set:function(t,e,n){return ot.nodeName(t,"input")?void(t.defaultValue=e):Ae&&Ae.set(t,e,n)}}),we||(Ae={set:function(t,e,n){var i=t.getAttributeNode(n);if(i||t.setAttributeNode(i=t.ownerDocument.createAttribute(n)),i.value=e+="","value"===n||e===t.getAttribute(n))return e}},_e.id=_e.name=_e.coords=function(t,e,n){var i;if(!n)return(i=t.getAttributeNode(e))&&""!==i.value?i.value:null},ot.valHooks.button={get:function(t,e){var n=t.getAttributeNode(e);if(n&&n.specified)return n.value},set:Ae.set},ot.attrHooks.contenteditable={set:function(t,e,n){Ae.set(t,""!==e&&e,n)}},ot.each(["width","height"],function(t,e){ot.attrHooks[e]={set:function(t,n){if(""===n)return t.setAttribute(e,"auto"),n}}})),nt.style||(ot.attrHooks.style={get:function(t){return t.style.cssText||void 0},set:function(t,e){return t.style.cssText=e+""}});var Ne=/^(?:input|select|textarea|button|object)$/i,Oe=/^(?:a|area)$/i;ot.fn.extend({prop:function(t,e){return St(this,ot.prop,t,e,arguments.length>1)},removeProp:function(t){return t=ot.propFix[t]||t,this.each(function(){try{this[t]=void 0,delete this[t]}catch(e){}})}}),ot.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(t,e,n){var i,o,a,s=t.nodeType;if(t&&3!==s&&8!==s&&2!==s)return a=1!==s||!ot.isXMLDoc(t),a&&(e=ot.propFix[e]||e,o=ot.propHooks[e]),void 0!==n?o&&"set"in o&&void 0!==(i=o.set(t,n,e))?i:t[e]=n:o&&"get"in o&&null!==(i=o.get(t,e))?i:t[e]},propHooks:{tabIndex:{get:function(t){var e=ot.find.attr(t,"tabindex");return e?parseInt(e,10):Ne.test(t.nodeName)||Oe.test(t.nodeName)&&t.href?0:-1}}}}),nt.hrefNormalized||ot.each(["href","src"],function(t,e){ot.propHooks[e]={get:function(t){return t.getAttribute(e,4)}}}),nt.optSelected||(ot.propHooks.selected={get:function(t){var e=t.parentNode;return e&&(e.selectedIndex,e.parentNode&&e.parentNode.selectedIndex),null}}),ot.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){ot.propFix[this.toLowerCase()]=this}),nt.enctype||(ot.propFix.enctype="encoding");var Se=/[\t\r\n\f]/g;ot.fn.extend({addClass:function(t){var e,n,i,o,a,s,r=0,c=this.length,l="string"==typeof t&&t;if(ot.isFunction(t))return this.each(function(e){ot(this).addClass(t.call(this,e,this.className))});if(l)for(e=(t||"").match(Mt)||[];r=0;)i=i.replace(" "+o+" "," ");s=t?ot.trim(i):"",n.className!==s&&(n.className=s)}return this},toggleClass:function(t,e){var n=typeof t;return"boolean"==typeof e&&"string"===n?e?this.addClass(t):this.removeClass(t):ot.isFunction(t)?this.each(function(n){ot(this).toggleClass(t.call(this,n,this.className,e),e)}):this.each(function(){if("string"===n)for(var e,i=0,o=ot(this),a=t.match(Mt)||[];e=a[i++];)o.hasClass(e)?o.removeClass(e):o.addClass(e);else n!==_t&&"boolean"!==n||(this.className&&ot._data(this,"__className__",this.className),this.className=this.className||t===!1?"":ot._data(this,"__className__")||"")})},hasClass:function(t){for(var e=" "+t+" ",n=0,i=this.length;n=0)return!0;return!1}}),ot.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(t,e){ot.fn[e]=function(t,n){return arguments.length>0?this.on(e,null,t,n):this.trigger(e)}}),ot.fn.extend({hover:function(t,e){return this.mouseenter(t).mouseleave(e||t)},bind:function(t,e,n){return this.on(t,null,e,n)},unbind:function(t,e){return this.off(t,null,e)},delegate:function(t,e,n,i){return this.on(e,t,n,i)},undelegate:function(t,e,n){return 1===arguments.length?this.off(t,"**"):this.off(e,t||"**",n)}});var xe=ot.now(),Le=/\?/,De=/(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;ot.parseJSON=function(e){if(t.JSON&&t.JSON.parse)return t.JSON.parse(e+"");var n,i=null,o=ot.trim(e+"");return o&&!ot.trim(o.replace(De,function(t,e,o,a){return n&&e&&(i=0),0===i?t:(n=o||e,i+=!a-!o,"")}))?Function("return "+o)():ot.error("Invalid JSON: "+e)},ot.parseXML=function(e){var n,i;if(!e||"string"!=typeof e)return null;try{t.DOMParser?(i=new DOMParser,n=i.parseFromString(e,"text/xml")):(n=new ActiveXObject("Microsoft.XMLDOM"),n.async="false",n.loadXML(e))}catch(o){n=void 0}return n&&n.documentElement&&!n.getElementsByTagName("parsererror").length||ot.error("Invalid XML: "+e),n};var ke,qe,We=/#.*$/,Ee=/([?&])_=[^&]*/,Be=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Ie=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Xe=/^(?:GET|HEAD)$/,Pe=/^\/\//,Re=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,Fe={},He={},je="*/".concat("*");try{qe=location.href}catch(Ue){qe=ft.createElement("a"),qe.href="",qe=qe.href}ke=Re.exec(qe.toLowerCase())||[],ot.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:qe,type:"GET",isLocal:Ie.test(ke[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":je,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":ot.parseJSON,"text xml":ot.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(t,e){return e?R(R(t,ot.ajaxSettings),e):R(ot.ajaxSettings,t)},ajaxPrefilter:X(Fe),ajaxTransport:X(He),ajax:function(t,e){function n(t,e,n,i){var o,u,b,v,y,z=e;2!==M&&(M=2,r&&clearTimeout(r),l=void 0,s=i||"",A.readyState=t>0?4:0,o=t>=200&&t<300||304===t,n&&(v=F(h,A,n)),v=H(h,v,A,o),o?(h.ifModified&&(y=A.getResponseHeader("Last-Modified"),y&&(ot.lastModified[a]=y),y=A.getResponseHeader("etag"),y&&(ot.etag[a]=y)),204===t||"HEAD"===h.type?z="nocontent":304===t?z="notmodified":(z=v.state,u=v.data,b=v.error,o=!b)):(b=z,!t&&z||(z="error",t<0&&(t=0))),A.status=t,A.statusText=(e||z)+"",o?f.resolveWith(d,[u,z,A]):f.rejectWith(d,[A,z,b]),A.statusCode(g),g=void 0,c&&p.trigger(o?"ajaxSuccess":"ajaxError",[A,h,o?u:b]),m.fireWith(d,[A,z]),c&&(p.trigger("ajaxComplete",[A,h]),--ot.active||ot.event.trigger("ajaxStop")))}"object"==typeof t&&(e=t,t=void 0),e=e||{};var i,o,a,s,r,c,l,u,h=ot.ajaxSetup({},e),d=h.context||h,p=h.context&&(d.nodeType||d.jquery)?ot(d):ot.event,f=ot.Deferred(),m=ot.Callbacks("once memory"),g=h.statusCode||{},b={},v={},M=0,y="canceled",A={readyState:0,getResponseHeader:function(t){var e;if(2===M){if(!u)for(u={};e=Be.exec(s);)u[e[1].toLowerCase()]=e[2];e=u[t.toLowerCase()]}return null==e?null:e},getAllResponseHeaders:function(){return 2===M?s:null},setRequestHeader:function(t,e){var n=t.toLowerCase();return M||(t=v[n]=v[n]||t,b[t]=e),this},overrideMimeType:function(t){return M||(h.mimeType=t),this},statusCode:function(t){var e;if(t)if(M<2)for(e in t)g[e]=[g[e],t[e]];else A.always(t[A.status]);return this},abort:function(t){var e=t||y;return l&&l.abort(e),n(0,e),this}};if(f.promise(A).complete=m.add,A.success=A.done,A.error=A.fail,h.url=((t||h.url||qe)+"").replace(We,"").replace(Pe,ke[1]+"//"),h.type=e.method||e.type||h.method||h.type,h.dataTypes=ot.trim(h.dataType||"*").toLowerCase().match(Mt)||[""],null==h.crossDomain&&(i=Re.exec(h.url.toLowerCase()),h.crossDomain=!(!i||i[1]===ke[1]&&i[2]===ke[2]&&(i[3]||("http:"===i[1]?"80":"443"))===(ke[3]||("http:"===ke[1]?"80":"443")))),h.data&&h.processData&&"string"!=typeof h.data&&(h.data=ot.param(h.data,h.traditional)),P(Fe,h,e,A),2===M)return A;c=ot.event&&h.global,c&&0===ot.active++&&ot.event.trigger("ajaxStart"),h.type=h.type.toUpperCase(),h.hasContent=!Xe.test(h.type),a=h.url,h.hasContent||(h.data&&(a=h.url+=(Le.test(a)?"&":"?")+h.data,delete h.data),h.cache===!1&&(h.url=Ee.test(a)?a.replace(Ee,"$1_="+xe++):a+(Le.test(a)?"&":"?")+"_="+xe++)),h.ifModified&&(ot.lastModified[a]&&A.setRequestHeader("If-Modified-Since",ot.lastModified[a]),ot.etag[a]&&A.setRequestHeader("If-None-Match",ot.etag[a])),(h.data&&h.hasContent&&h.contentType!==!1||e.contentType)&&A.setRequestHeader("Content-Type",h.contentType),A.setRequestHeader("Accept",h.dataTypes[0]&&h.accepts[h.dataTypes[0]]?h.accepts[h.dataTypes[0]]+("*"!==h.dataTypes[0]?", "+je+"; q=0.01":""):h.accepts["*"]);for(o in h.headers)A.setRequestHeader(o,h.headers[o]);if(h.beforeSend&&(h.beforeSend.call(d,A,h)===!1||2===M))return A.abort();y="abort";for(o in{success:1,error:1,complete:1})A[o](h[o]);if(l=P(He,h,e,A)){A.readyState=1,c&&p.trigger("ajaxSend",[A,h]),h.async&&h.timeout>0&&(r=setTimeout(function(){A.abort("timeout")},h.timeout));try{M=1,l.send(b,n)}catch(z){if(!(M<2))throw z;n(-1,z)}}else n(-1,"No Transport");return A},getJSON:function(t,e,n){return ot.get(t,e,n,"json")},getScript:function(t,e){return ot.get(t,void 0,e,"script")}}),ot.each(["get","post"],function(t,e){ot[e]=function(t,n,i,o){return ot.isFunction(n)&&(o=o||i,i=n,n=void 0),ot.ajax({url:t,type:e,dataType:o,data:n,success:i})}}),ot._evalUrl=function(t){return ot.ajax({url:t,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},ot.fn.extend({wrapAll:function(t){if(ot.isFunction(t))return this.each(function(e){ot(this).wrapAll(t.call(this,e))});if(this[0]){var e=ot(t,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&e.insertBefore(this[0]),e.map(function(){for(var t=this;t.firstChild&&1===t.firstChild.nodeType;)t=t.firstChild;return t}).append(this)}return this},wrapInner:function(t){return ot.isFunction(t)?this.each(function(e){ot(this).wrapInner(t.call(this,e))}):this.each(function(){var e=ot(this),n=e.contents();n.length?n.wrapAll(t):e.append(t)})},wrap:function(t){var e=ot.isFunction(t);return this.each(function(n){ot(this).wrapAll(e?t.call(this,n):t)})},unwrap:function(){return this.parent().each(function(){ot.nodeName(this,"body")||ot(this).replaceWith(this.childNodes)}).end()}}),ot.expr.filters.hidden=function(t){return t.offsetWidth<=0&&t.offsetHeight<=0||!nt.reliableHiddenOffsets()&&"none"===(t.style&&t.style.display||ot.css(t,"display"))},ot.expr.filters.visible=function(t){return!ot.expr.filters.hidden(t)};var $e=/%20/g,Ve=/\[\]$/,Ye=/\r?\n/g,Je=/^(?:submit|button|image|reset|file)$/i,Ke=/^(?:input|select|textarea|keygen)/i;ot.param=function(t,e){var n,i=[],o=function(t,e){e=ot.isFunction(e)?e():null==e?"":e,i[i.length]=encodeURIComponent(t)+"="+encodeURIComponent(e)};if(void 0===e&&(e=ot.ajaxSettings&&ot.ajaxSettings.traditional),ot.isArray(t)||t.jquery&&!ot.isPlainObject(t))ot.each(t,function(){o(this.name,this.value)});else for(n in t)j(n,t[n],e,o);return i.join("&").replace($e,"+")},ot.fn.extend({serialize:function(){return ot.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var t=ot.prop(this,"elements");return t?ot.makeArray(t):this}).filter(function(){var t=this.type;return this.name&&!ot(this).is(":disabled")&&Ke.test(this.nodeName)&&!Je.test(t)&&(this.checked||!xt.test(t))}).map(function(t,e){var n=ot(this).val();return null==n?null:ot.isArray(n)?ot.map(n,function(t){return{name:e.name,value:t.replace(Ye,"\r\n")}}):{name:e.name,value:n.replace(Ye,"\r\n")}}).get()}}),ot.ajaxSettings.xhr=void 0!==t.ActiveXObject?function(){return!this.isLocal&&/^(get|post|head|put|delete|options)$/i.test(this.type)&&U()||$()}:U;var Ge=0,Qe={},Ze=ot.ajaxSettings.xhr();t.attachEvent&&t.attachEvent("onunload",function(){for(var t in Qe)Qe[t](void 0,!0)}),nt.cors=!!Ze&&"withCredentials"in Ze,Ze=nt.ajax=!!Ze,Ze&&ot.ajaxTransport(function(t){if(!t.crossDomain||nt.cors){var e;return{send:function(n,i){var o,a=t.xhr(),s=++Ge;if(a.open(t.type,t.url,t.async,t.username,t.password),t.xhrFields)for(o in t.xhrFields)a[o]=t.xhrFields[o];t.mimeType&&a.overrideMimeType&&a.overrideMimeType(t.mimeType),t.crossDomain||n["X-Requested-With"]||(n["X-Requested-With"]="XMLHttpRequest");for(o in n)void 0!==n[o]&&a.setRequestHeader(o,n[o]+"");a.send(t.hasContent&&t.data||null),e=function(n,o){var r,c,l;if(e&&(o||4===a.readyState))if(delete Qe[s],e=void 0,a.onreadystatechange=ot.noop,o)4!==a.readyState&&a.abort();else{l={},r=a.status,"string"==typeof a.responseText&&(l.text=a.responseText);try{c=a.statusText}catch(u){c=""}r||!t.isLocal||t.crossDomain?1223===r&&(r=204):r=l.text?200:404}l&&i(r,c,l,a.getAllResponseHeaders())},t.async?4===a.readyState?setTimeout(e):a.onreadystatechange=Qe[s]=e:e()},abort:function(){e&&e(void 0,!0)}}}}),ot.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(t){return ot.globalEval(t),t}}}),ot.ajaxPrefilter("script",function(t){void 0===t.cache&&(t.cache=!1),t.crossDomain&&(t.type="GET",t.global=!1)}),ot.ajaxTransport("script",function(t){if(t.crossDomain){var e,n=ft.head||ot("head")[0]||ft.documentElement;return{send:function(i,o){e=ft.createElement("script"),e.async=!0,t.scriptCharset&&(e.charset=t.scriptCharset),e.src=t.url,e.onload=e.onreadystatechange=function(t,n){(n||!e.readyState||/loaded|complete/.test(e.readyState))&&(e.onload=e.onreadystatechange=null,e.parentNode&&e.parentNode.removeChild(e),e=null,n||o(200,"success"))},n.insertBefore(e,n.firstChild)},abort:function(){e&&e.onload(void 0,!0)}}}});var tn=[],en=/(=)\?(?=&|$)|\?\?/;ot.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var t=tn.pop()||ot.expando+"_"+xe++;return this[t]=!0,t}}),ot.ajaxPrefilter("json jsonp",function(e,n,i){var o,a,s,r=e.jsonp!==!1&&(en.test(e.url)?"url":"string"==typeof e.data&&!(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&en.test(e.data)&&"data");if(r||"jsonp"===e.dataTypes[0])return o=e.jsonpCallback=ot.isFunction(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,r?e[r]=e[r].replace(en,"$1"+o):e.jsonp!==!1&&(e.url+=(Le.test(e.url)?"&":"?")+e.jsonp+"="+o),e.converters["script json"]=function(){return s||ot.error(o+" was not called"),s[0]},e.dataTypes[0]="json",a=t[o],t[o]=function(){s=arguments},i.always(function(){t[o]=a,e[o]&&(e.jsonpCallback=n.jsonpCallback,tn.push(o)),s&&ot.isFunction(a)&&a(s[0]),s=a=void 0}),"script"}),ot.parseHTML=function(t,e,n){if(!t||"string"!=typeof t)return null;"boolean"==typeof e&&(n=e,e=!1),e=e||ft;var i=ht.exec(t),o=!n&&[];return i?[e.createElement(i[1])]:(i=ot.buildFragment([t],e,o),o&&o.length&&ot(o).remove(),ot.merge([],i.childNodes))};var nn=ot.fn.load;ot.fn.load=function(t,e,n){if("string"!=typeof t&&nn)return nn.apply(this,arguments);var i,o,a,s=this,r=t.indexOf(" ");return r>=0&&(i=ot.trim(t.slice(r,t.length)),t=t.slice(0,r)),ot.isFunction(e)?(n=e,e=void 0):e&&"object"==typeof e&&(a="POST"),s.length>0&&ot.ajax({url:t,type:a,dataType:"html",data:e}).done(function(t){o=arguments,s.html(i?ot("
").append(ot.parseHTML(t)).find(i):t)}).complete(n&&function(t,e){s.each(n,o||[t.responseText,e,t])}),this},ot.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(t,e){ot.fn[e]=function(t){return this.on(e,t)}}),ot.expr.filters.animated=function(t){return ot.grep(ot.timers,function(e){return t===e.elem}).length};var on=t.document.documentElement;ot.offset={setOffset:function(t,e,n){var i,o,a,s,r,c,l,u=ot.css(t,"position"),h=ot(t),d={};"static"===u&&(t.style.position="relative"),r=h.offset(),a=ot.css(t,"top"),c=ot.css(t,"left"),l=("absolute"===u||"fixed"===u)&&ot.inArray("auto",[a,c])>-1,l?(i=h.position(),s=i.top,o=i.left):(s=parseFloat(a)||0,o=parseFloat(c)||0),ot.isFunction(e)&&(e=e.call(t,n,r)),null!=e.top&&(d.top=e.top-r.top+s),null!=e.left&&(d.left=e.left-r.left+o),"using"in e?e.using.call(t,d):h.css(d)}},ot.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){ot.offset.setOffset(this,t,e)});var e,n,i={top:0,left:0},o=this[0],a=o&&o.ownerDocument;if(a)return e=a.documentElement,ot.contains(e,o)?(typeof o.getBoundingClientRect!==_t&&(i=o.getBoundingClientRect()),n=V(a),{top:i.top+(n.pageYOffset||e.scrollTop)-(e.clientTop||0),left:i.left+(n.pageXOffset||e.scrollLeft)-(e.clientLeft||0)}):i},position:function(){if(this[0]){var t,e,n={top:0,left:0},i=this[0];return"fixed"===ot.css(i,"position")?e=i.getBoundingClientRect():(t=this.offsetParent(),e=this.offset(),ot.nodeName(t[0],"html")||(n=t.offset()),n.top+=ot.css(t[0],"borderTopWidth",!0),n.left+=ot.css(t[0],"borderLeftWidth",!0)),{top:e.top-n.top-ot.css(i,"marginTop",!0),left:e.left-n.left-ot.css(i,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var t=this.offsetParent||on;t&&!ot.nodeName(t,"html")&&"static"===ot.css(t,"position");)t=t.offsetParent;return t||on})}}),ot.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,e){var n=/Y/.test(e);ot.fn[t]=function(i){return St(this,function(t,i,o){var a=V(t);return void 0===o?a?e in a?a[e]:a.document.documentElement[i]:t[i]:void(a?a.scrollTo(n?ot(a).scrollLeft():o,n?o:ot(a).scrollTop()):t[i]=o)},t,i,arguments.length,null)}}),ot.each(["top","left"],function(t,e){ot.cssHooks[e]=C(nt.pixelPosition,function(t,n){if(n)return n=ee(t,e),ie.test(n)?ot(t).position()[e]+"px":n})}),ot.each({Height:"height",Width:"width"},function(t,e){ot.each({padding:"inner"+t,content:e,"":"outer"+t},function(n,i){ot.fn[i]=function(i,o){var a=arguments.length&&(n||"boolean"!=typeof i),s=n||(i===!0||o===!0?"margin":"border");return St(this,function(e,n,i){var o;return ot.isWindow(e)?e.document.documentElement["client"+t]:9===e.nodeType?(o=e.documentElement,Math.max(e.body["scroll"+t],o["scroll"+t],e.body["offset"+t],o["offset"+t],o["client"+t])):void 0===i?ot.css(e,n,s):ot.style(e,n,i,s)},e,a?i:void 0,a,null)}})}),ot.fn.size=function(){return this.length},ot.fn.andSelf=ot.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return ot});var an=t.jQuery,sn=t.$;return ot.noConflict=function(e){return t.$===ot&&(t.$=sn),e&&t.jQuery===ot&&(t.jQuery=an),ot},typeof e===_t&&(t.jQuery=t.$=ot),ot}),function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t(jQuery)}(function(t){function e(e,i){var o,a,s,r=e.nodeName.toLowerCase();return"area"===r?(o=e.parentNode,a=o.name,!(!e.href||!a||"map"!==o.nodeName.toLowerCase())&&(s=t("img[usemap='#"+a+"']")[0],!!s&&n(s))):(/input|select|textarea|button|object/.test(r)?!e.disabled:"a"===r?e.href||i:i)&&n(e)}function n(e){return t.expr.filters.visible(e)&&!t(e).parents().addBack().filter(function(){return"hidden"===t.css(this,"visibility")}).length}function i(t){for(var e,n;t.length&&t[0]!==document;){if(e=t.css("position"),("absolute"===e||"relative"===e||"fixed"===e)&&(n=parseInt(t.css("zIndex"),10),!isNaN(n)&&0!==n))return n;t=t.parent()}return 0}function o(){this._curInst=null,this._keyEvent=!1,this._disabledInputs=[],this._datepickerShowing=!1,this._inDialog=!1,this._mainDivId="ui-datepicker-div",this._inlineClass="ui-datepicker-inline",this._appendClass="ui-datepicker-append",this._triggerClass="ui-datepicker-trigger",this._dialogClass="ui-datepicker-dialog",this._disableClass="ui-datepicker-disabled",this._unselectableClass="ui-datepicker-unselectable",this._currentClass="ui-datepicker-current-day",this._dayOverClass="ui-datepicker-days-cell-over",this.regional=[],this.regional[""]={closeText:"Done",prevText:"Prev",nextText:"Next",currentText:"Today",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],weekHeader:"Wk",dateFormat:"mm/dd/yy",firstDay:0,isRTL:!1,showMonthAfterYear:!1,yearSuffix:""},this._defaults={showOn:"focus",showAnim:"fadeIn",showOptions:{},defaultDate:null,appendText:"",buttonText:"...",buttonImage:"",buttonImageOnly:!1,hideIfNoPrevNext:!1,navigationAsDateFormat:!1,gotoCurrent:!1,changeMonth:!1,changeYear:!1,yearRange:"c-10:c+10",showOtherMonths:!1,selectOtherMonths:!1,showWeek:!1,calculateWeek:this.iso8601Week,shortYearCutoff:"+10",minDate:null,maxDate:null,duration:"fast",beforeShowDay:null,beforeShow:null,onSelect:null,onChangeMonthYear:null,onClose:null,numberOfMonths:1,showCurrentAtPos:0,stepMonths:1,stepBigMonths:12,altField:"",altFormat:"",constrainInput:!0,showButtonPanel:!1,autoSize:!1,disabled:!1},t.extend(this._defaults,this.regional[""]),this.regional.en=t.extend(!0,{},this.regional[""]),this.regional["en-US"]=t.extend(!0,{},this.regional.en),this.dpDiv=a(t("
"))}function a(e){var n="button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";return e.delegate(n,"mouseout",function(){t(this).removeClass("ui-state-hover"),this.className.indexOf("ui-datepicker-prev")!==-1&&t(this).removeClass("ui-datepicker-prev-hover"),this.className.indexOf("ui-datepicker-next")!==-1&&t(this).removeClass("ui-datepicker-next-hover")}).delegate(n,"mouseover",s)}function s(){t.datepicker._isDisabledDatepicker(b.inline?b.dpDiv.parent()[0]:b.input[0])||(t(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"),t(this).addClass("ui-state-hover"),this.className.indexOf("ui-datepicker-prev")!==-1&&t(this).addClass("ui-datepicker-prev-hover"),this.className.indexOf("ui-datepicker-next")!==-1&&t(this).addClass("ui-datepicker-next-hover"))}function r(e,n){t.extend(e,n);for(var i in n)null==n[i]&&(e[i]=n[i]);return e}function c(t){return function(){var e=this.element.val();t.apply(this,arguments),this._refresh(),e!==this.element.val()&&this._trigger("change")}}t.ui=t.ui||{},t.extend(t.ui,{version:"1.11.2",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),t.fn.extend({scrollParent:function(e){var n=this.css("position"),i="absolute"===n,o=e?/(auto|scroll|hidden)/:/(auto|scroll)/,a=this.parents().filter(function(){var e=t(this);return(!i||"static"!==e.css("position"))&&o.test(e.css("overflow")+e.css("overflow-y")+e.css("overflow-x"))}).eq(0);return"fixed"!==n&&a.length?a:t(this[0].ownerDocument||document)},uniqueId:function(){var t=0;return function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++t)})}}(),removeUniqueId:function(){return this.each(function(){/^ui-id-\d+$/.test(this.id)&&t(this).removeAttr("id")})}}),t.extend(t.expr[":"],{data:t.expr.createPseudo?t.expr.createPseudo(function(e){return function(n){return!!t.data(n,e)}}):function(e,n,i){return!!t.data(e,i[3])},focusable:function(n){return e(n,!isNaN(t.attr(n,"tabindex")))},tabbable:function(n){var i=t.attr(n,"tabindex"),o=isNaN(i);return(o||i>=0)&&e(n,!o)}}),t("").outerWidth(1).jquery||t.each(["Width","Height"],function(e,n){function i(e,n,i,a){return t.each(o,function(){n-=parseFloat(t.css(e,"padding"+this))||0,i&&(n-=parseFloat(t.css(e,"border"+this+"Width"))||0),a&&(n-=parseFloat(t.css(e,"margin"+this))||0)}),n}var o="Width"===n?["Left","Right"]:["Top","Bottom"],a=n.toLowerCase(),s={innerWidth:t.fn.innerWidth,innerHeight:t.fn.innerHeight,outerWidth:t.fn.outerWidth,outerHeight:t.fn.outerHeight};t.fn["inner"+n]=function(e){return void 0===e?s["inner"+n].call(this):this.each(function(){t(this).css(a,i(this,e)+"px")})},t.fn["outer"+n]=function(e,o){return"number"!=typeof e?s["outer"+n].call(this,e):this.each(function(){t(this).css(a,i(this,e,!0,o)+"px")})}}),t.fn.addBack||(t.fn.addBack=function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}),t("").data("a-b","a").removeData("a-b").data("a-b")&&(t.fn.removeData=function(e){return function(n){return arguments.length?e.call(this,t.camelCase(n)):e.call(this)}}(t.fn.removeData)),t.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),t.fn.extend({focus:function(e){return function(n,i){return"number"==typeof n?this.each(function(){var e=this;setTimeout(function(){t(e).focus(),i&&i.call(e)},n)}):e.apply(this,arguments)}}(t.fn.focus),disableSelection:function(){var t="onselectstart"in document.createElement("div")?"selectstart":"mousedown";return function(){return this.bind(t+".ui-disableSelection",function(t){t.preventDefault()})}}(),enableSelection:function(){return this.unbind(".ui-disableSelection")},zIndex:function(e){if(void 0!==e)return this.css("zIndex",e);if(this.length)for(var n,i,o=t(this[0]);o.length&&o[0]!==document;){if(n=o.css("position"),("absolute"===n||"relative"===n||"fixed"===n)&&(i=parseInt(o.css("zIndex"),10),!isNaN(i)&&0!==i))return i;o=o.parent()}return 0}}),t.ui.plugin={add:function(e,n,i){var o,a=t.ui[e].prototype;for(o in i)a.plugins[o]=a.plugins[o]||[],a.plugins[o].push([n,i[o]])},call:function(t,e,n,i){var o,a=t.plugins[e];if(a&&(i||t.element[0].parentNode&&11!==t.element[0].parentNode.nodeType))for(o=0;o",options:{disabled:!1,create:null},_createWidget:function(e,n){n=t(n||this.defaultElement||this)[0],this.element=t(n),this.uuid=l++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=t(),this.hoverable=t(),this.focusable=t(),n!==this&&(t.data(n,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===n&&this.destroy()}}),this.document=t(n.style?n.ownerDocument:n.document||n),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this.options=t.widget.extend({},this.options,this._getCreateOptions(),e),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:t.noop,_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetFullName).removeData(t.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:t.noop,widget:function(){return this.element},option:function(e,n){var i,o,a,s=e;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof e)if(s={},i=e.split("."),e=i.shift(),i.length){for(o=s[e]=t.widget.extend({},this.options[e]),a=0;a=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}});!function(){function e(t,e,n){return[parseFloat(t[0])*(p.test(t[0])?e/100:1),parseFloat(t[1])*(p.test(t[1])?n/100:1)]}function n(e,n){return parseInt(t.css(e,n),10)||0}function i(e){var n=e[0];return 9===n.nodeType?{width:e.width(),height:e.height(),offset:{top:0,left:0}}:t.isWindow(n)?{width:e.width(),height:e.height(),offset:{top:e.scrollTop(),left:e.scrollLeft()}}:n.preventDefault?{width:0,height:0,offset:{top:n.pageY,left:n.pageX}}:{width:e.outerWidth(),height:e.outerHeight(),offset:e.offset()}}t.ui=t.ui||{};var o,a,s=Math.max,r=Math.abs,c=Math.round,l=/left|center|right/,u=/top|center|bottom/,h=/[\+\-]\d+(\.[\d]+)?%?/,d=/^\w+/,p=/%$/,f=t.fn.position;t.position={scrollbarWidth:function(){if(void 0!==o)return o;var e,n,i=t("
"),a=i.children()[0];return t("body").append(i),e=a.offsetWidth,i.css("overflow","scroll"),n=a.offsetWidth,e===n&&(n=i[0].clientWidth),i.remove(),o=e-n},getScrollInfo:function(e){var n=e.isWindow||e.isDocument?"":e.element.css("overflow-x"),i=e.isWindow||e.isDocument?"":e.element.css("overflow-y"),o="scroll"===n||"auto"===n&&e.width0?"right":"center",vertical:a<0?"top":i>0?"bottom":"middle"};ms(r(i),r(a))?c.important="horizontal":c.important="vertical",o.using.call(this,t,c)}),u.offset(t.extend(N,{using:l}))})},t.ui.position={fit:{left:function(t,e){var n,i=e.within,o=i.isWindow?i.scrollLeft:i.offset.left,a=i.width,r=t.left-e.collisionPosition.marginLeft,c=o-r,l=r+e.collisionWidth-a-o;e.collisionWidth>a?c>0&&l<=0?(n=t.left+c+e.collisionWidth-a-o,t.left+=c-n):l>0&&c<=0?t.left=o:c>l?t.left=o+a-e.collisionWidth:t.left=o:c>0?t.left+=c:l>0?t.left-=l:t.left=s(t.left-r,t.left)},top:function(t,e){var n,i=e.within,o=i.isWindow?i.scrollTop:i.offset.top,a=e.within.height,r=t.top-e.collisionPosition.marginTop,c=o-r,l=r+e.collisionHeight-a-o;e.collisionHeight>a?c>0&&l<=0?(n=t.top+c+e.collisionHeight-a-o,t.top+=c-n):l>0&&c<=0?t.top=o:c>l?t.top=o+a-e.collisionHeight:t.top=o:c>0?t.top+=c:l>0?t.top-=l:t.top=s(t.top-r,t.top)}},flip:{left:function(t,e){var n,i,o=e.within,a=o.offset.left+o.scrollLeft,s=o.width,c=o.isWindow?o.scrollLeft:o.offset.left,l=t.left-e.collisionPosition.marginLeft,u=l-c,h=l+e.collisionWidth-s-c,d="left"===e.my[0]?-e.elemWidth:"right"===e.my[0]?e.elemWidth:0,p="left"===e.at[0]?e.targetWidth:"right"===e.at[0]?-e.targetWidth:0,f=-2*e.offset[0];u<0?(n=t.left+d+p+f+e.collisionWidth-s-a,(n<0||n0&&(i=t.left-e.collisionPosition.marginLeft+d+p+f-c,(i>0||r(i)u&&(i<0||i0&&(n=t.top-e.collisionPosition.marginTop+p+f+m-c,t.top+p+f+m>h&&(n>0||r(n)10&&o<11,e.innerHTML="",n.removeChild(e)}()}();t.ui.position,t.widget("ui.accordion",{version:"1.11.2",options:{active:0,animate:{},collapsible:!1,event:"click",header:"> li > :first-child,> :not(li):even",heightStyle:"auto",icons:{activeHeader:"ui-icon-triangle-1-s",header:"ui-icon-triangle-1-e"},activate:null,beforeActivate:null},hideProps:{borderTopWidth:"hide",borderBottomWidth:"hide",paddingTop:"hide",paddingBottom:"hide",height:"hide"},showProps:{borderTopWidth:"show",borderBottomWidth:"show",paddingTop:"show",paddingBottom:"show",height:"show"},_create:function(){var e=this.options;this.prevShow=this.prevHide=t(),this.element.addClass("ui-accordion ui-widget ui-helper-reset").attr("role","tablist"),e.collapsible||e.active!==!1&&null!=e.active||(e.active=0),this._processPanels(),e.active<0&&(e.active+=this.headers.length),this._refresh()},_getCreateEventData:function(){return{header:this.active,panel:this.active.length?this.active.next():t()}},_createIcons:function(){var e=this.options.icons;e&&(t("").addClass("ui-accordion-header-icon ui-icon "+e.header).prependTo(this.headers),this.active.children(".ui-accordion-header-icon").removeClass(e.header).addClass(e.activeHeader),this.headers.addClass("ui-accordion-icons"))},_destroyIcons:function(){this.headers.removeClass("ui-accordion-icons").children(".ui-accordion-header-icon").remove()},_destroy:function(){var t;this.element.removeClass("ui-accordion ui-widget ui-helper-reset").removeAttr("role"),this.headers.removeClass("ui-accordion-header ui-accordion-header-active ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top").removeAttr("role").removeAttr("aria-expanded").removeAttr("aria-selected").removeAttr("aria-controls").removeAttr("tabIndex").removeUniqueId(),this._destroyIcons(),t=this.headers.next().removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled").css("display","").removeAttr("role").removeAttr("aria-hidden").removeAttr("aria-labelledby").removeUniqueId(),"content"!==this.options.heightStyle&&t.css("height","")},_setOption:function(t,e){return"active"===t?void this._activate(e):("event"===t&&(this.options.event&&this._off(this.headers,this.options.event),this._setupEvents(e)),this._super(t,e),"collapsible"!==t||e||this.options.active!==!1||this._activate(0),"icons"===t&&(this._destroyIcons(),e&&this._createIcons()),void("disabled"===t&&(this.element.toggleClass("ui-state-disabled",!!e).attr("aria-disabled",e),this.headers.add(this.headers.next()).toggleClass("ui-state-disabled",!!e))))},_keydown:function(e){if(!e.altKey&&!e.ctrlKey){var n=t.ui.keyCode,i=this.headers.length,o=this.headers.index(e.target),a=!1;switch(e.keyCode){case n.RIGHT:case n.DOWN:a=this.headers[(o+1)%i];break;case n.LEFT:case n.UP:a=this.headers[(o-1+i)%i];break;case n.SPACE:case n.ENTER:this._eventHandler(e);break;case n.HOME:a=this.headers[0];break;case n.END:a=this.headers[i-1]}a&&(t(e.target).attr("tabIndex",-1),t(a).attr("tabIndex",0),a.focus(),e.preventDefault())}},_panelKeyDown:function(e){e.keyCode===t.ui.keyCode.UP&&e.ctrlKey&&t(e.currentTarget).prev().focus()},refresh:function(){var e=this.options;this._processPanels(),e.active===!1&&e.collapsible===!0||!this.headers.length?(e.active=!1,this.active=t()):e.active===!1?this._activate(0):this.active.length&&!t.contains(this.element[0],this.active[0])?this.headers.length===this.headers.find(".ui-state-disabled").length?(e.active=!1,this.active=t()):this._activate(Math.max(0,e.active-1)):e.active=this.headers.index(this.active),this._destroyIcons(),this._refresh()},_processPanels:function(){var t=this.headers,e=this.panels;this.headers=this.element.find(this.options.header).addClass("ui-accordion-header ui-state-default ui-corner-all"),this.panels=this.headers.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom").filter(":not(.ui-accordion-content-active)").hide(),e&&(this._off(t.not(this.headers)),this._off(e.not(this.panels)))},_refresh:function(){var e,n=this.options,i=n.heightStyle,o=this.element.parent();this.active=this._findActive(n.active).addClass("ui-accordion-header-active ui-state-active ui-corner-top").removeClass("ui-corner-all"),this.active.next().addClass("ui-accordion-content-active").show(),this.headers.attr("role","tab").each(function(){var e=t(this),n=e.uniqueId().attr("id"),i=e.next(),o=i.uniqueId().attr("id");e.attr("aria-controls",o),i.attr("aria-labelledby",n)}).next().attr("role","tabpanel"),this.headers.not(this.active).attr({"aria-selected":"false","aria-expanded":"false",tabIndex:-1}).next().attr({"aria-hidden":"true"}).hide(),this.active.length?this.active.attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0}).next().attr({"aria-hidden":"false"}):this.headers.eq(0).attr("tabIndex",0),this._createIcons(),this._setupEvents(n.event),"fill"===i?(e=o.height(),this.element.siblings(":visible").each(function(){var n=t(this),i=n.css("position");"absolute"!==i&&"fixed"!==i&&(e-=n.outerHeight(!0))}),this.headers.each(function(){e-=t(this).outerHeight(!0)}),this.headers.next().each(function(){t(this).height(Math.max(0,e-t(this).innerHeight()+t(this).height()))}).css("overflow","auto")):"auto"===i&&(e=0,this.headers.next().each(function(){e=Math.max(e,t(this).css("height","").height())}).height(e))},_activate:function(e){var n=this._findActive(e)[0];n!==this.active[0]&&(n=n||this.active[0],this._eventHandler({target:n,currentTarget:n,preventDefault:t.noop}))},_findActive:function(e){return"number"==typeof e?this.headers.eq(e):t()},_setupEvents:function(e){var n={keydown:"_keydown"};e&&t.each(e.split(" "),function(t,e){n[e]="_eventHandler"}),this._off(this.headers.add(this.headers.next())),this._on(this.headers,n),this._on(this.headers.next(),{keydown:"_panelKeyDown"}),this._hoverable(this.headers),this._focusable(this.headers)},_eventHandler:function(e){var n=this.options,i=this.active,o=t(e.currentTarget),a=o[0]===i[0],s=a&&n.collapsible,r=s?t():o.next(),c=i.next(),l={oldHeader:i,oldPanel:c,newHeader:s?t():o,newPanel:r};e.preventDefault(),a&&!n.collapsible||this._trigger("beforeActivate",e,l)===!1||(n.active=!s&&this.headers.index(o),this.active=a?t():o,this._toggle(l),i.removeClass("ui-accordion-header-active ui-state-active"),n.icons&&i.children(".ui-accordion-header-icon").removeClass(n.icons.activeHeader).addClass(n.icons.header),a||(o.removeClass("ui-corner-all").addClass("ui-accordion-header-active ui-state-active ui-corner-top"),n.icons&&o.children(".ui-accordion-header-icon").removeClass(n.icons.header).addClass(n.icons.activeHeader),o.next().addClass("ui-accordion-content-active")))},_toggle:function(e){var n=e.newPanel,i=this.prevShow.length?this.prevShow:e.oldPanel;this.prevShow.add(this.prevHide).stop(!0,!0),this.prevShow=n,this.prevHide=i,this.options.animate?this._animate(n,i,e):(i.hide(),n.show(),this._toggleComplete(e)),i.attr({"aria-hidden":"true"}),i.prev().attr("aria-selected","false"),n.length&&i.length?i.prev().attr({tabIndex:-1,"aria-expanded":"false"}):n.length&&this.headers.filter(function(){return 0===t(this).attr("tabIndex")}).attr("tabIndex",-1),n.attr("aria-hidden","false").prev().attr({"aria-selected":"true",tabIndex:0,"aria-expanded":"true"})},_animate:function(t,e,n){var i,o,a,s=this,r=0,c=t.length&&(!e.length||t.index()",delay:300,options:{icons:{submenu:"ui-icon-carat-1-e"},items:"> *",menus:"ul",position:{my:"left-1 top",at:"right top"},role:"menu",blur:null,focus:null,select:null},_create:function(){this.activeMenu=this.element,this.mouseHandled=!1,this.element.uniqueId().addClass("ui-menu ui-widget ui-widget-content").toggleClass("ui-menu-icons",!!this.element.find(".ui-icon").length).attr({role:this.options.role,tabIndex:0}),this.options.disabled&&this.element.addClass("ui-state-disabled").attr("aria-disabled","true"),this._on({"mousedown .ui-menu-item":function(t){t.preventDefault()},"click .ui-menu-item":function(e){var n=t(e.target);!this.mouseHandled&&n.not(".ui-state-disabled").length&&(this.select(e),e.isPropagationStopped()||(this.mouseHandled=!0),n.has(".ui-menu").length?this.expand(e):!this.element.is(":focus")&&t(this.document[0].activeElement).closest(".ui-menu").length&&(this.element.trigger("focus",[!0]),this.active&&1===this.active.parents(".ui-menu").length&&clearTimeout(this.timer)))},"mouseenter .ui-menu-item":function(e){if(!this.previousFilter){var n=t(e.currentTarget);n.siblings(".ui-state-active").removeClass("ui-state-active"),this.focus(e,n)}},mouseleave:"collapseAll","mouseleave .ui-menu":"collapseAll",focus:function(t,e){var n=this.active||this.element.find(this.options.items).eq(0);e||this.focus(t,n)},blur:function(e){this._delay(function(){t.contains(this.element[0],this.document[0].activeElement)||this.collapseAll(e)})},keydown:"_keydown"}),this.refresh(),this._on(this.document,{click:function(t){this._closeOnDocumentClick(t)&&this.collapseAll(t),this.mouseHandled=!1}})},_destroy:function(){this.element.removeAttr("aria-activedescendant").find(".ui-menu").addBack().removeClass("ui-menu ui-widget ui-widget-content ui-menu-icons ui-front").removeAttr("role").removeAttr("tabIndex").removeAttr("aria-labelledby").removeAttr("aria-expanded").removeAttr("aria-hidden").removeAttr("aria-disabled").removeUniqueId().show(),this.element.find(".ui-menu-item").removeClass("ui-menu-item").removeAttr("role").removeAttr("aria-disabled").removeUniqueId().removeClass("ui-state-hover").removeAttr("tabIndex").removeAttr("role").removeAttr("aria-haspopup").children().each(function(){var e=t(this);e.data("ui-menu-submenu-carat")&&e.remove()}),this.element.find(".ui-menu-divider").removeClass("ui-menu-divider ui-widget-content")},_keydown:function(e){var n,i,o,a,s=!0;switch(e.keyCode){case t.ui.keyCode.PAGE_UP:this.previousPage(e);break;case t.ui.keyCode.PAGE_DOWN:this.nextPage(e);break;case t.ui.keyCode.HOME:this._move("first","first",e);break;case t.ui.keyCode.END:this._move("last","last",e);break;case t.ui.keyCode.UP:this.previous(e);break;case t.ui.keyCode.DOWN:this.next(e);break;case t.ui.keyCode.LEFT:this.collapse(e);break;case t.ui.keyCode.RIGHT:this.active&&!this.active.is(".ui-state-disabled")&&this.expand(e);break;case t.ui.keyCode.ENTER:case t.ui.keyCode.SPACE:this._activate(e);break;case t.ui.keyCode.ESCAPE:this.collapse(e);break;default:s=!1,i=this.previousFilter||"",o=String.fromCharCode(e.keyCode),a=!1,clearTimeout(this.filterTimer),o===i?a=!0:o=i+o,n=this._filterMenuItems(o),n=a&&n.index(this.active.next())!==-1?this.active.nextAll(".ui-menu-item"):n,n.length||(o=String.fromCharCode(e.keyCode),n=this._filterMenuItems(o)),n.length?(this.focus(e,n),this.previousFilter=o,this.filterTimer=this._delay(function(){delete this.previousFilter},1e3)):delete this.previousFilter}s&&e.preventDefault()},_activate:function(t){this.active.is(".ui-state-disabled")||(this.active.is("[aria-haspopup='true']")?this.expand(t):this.select(t))},refresh:function(){var e,n,i=this,o=this.options.icons.submenu,a=this.element.find(this.options.menus);this.element.toggleClass("ui-menu-icons",!!this.element.find(".ui-icon").length),a.filter(":not(.ui-menu)").addClass("ui-menu ui-widget ui-widget-content ui-front").hide().attr({role:this.options.role,"aria-hidden":"true","aria-expanded":"false"}).each(function(){var e=t(this),n=e.parent(),i=t("").addClass("ui-menu-icon ui-icon "+o).data("ui-menu-submenu-carat",!0);n.attr("aria-haspopup","true").prepend(i),e.attr("aria-labelledby",n.attr("id"))}),e=a.add(this.element),n=e.find(this.options.items),n.not(".ui-menu-item").each(function(){var e=t(this);i._isDivider(e)&&e.addClass("ui-widget-content ui-menu-divider")}),n.not(".ui-menu-item, .ui-menu-divider").addClass("ui-menu-item").uniqueId().attr({tabIndex:-1,role:this._itemRole()}),n.filter(".ui-state-disabled").attr("aria-disabled","true"),this.active&&!t.contains(this.element[0],this.active[0])&&this.blur()},_itemRole:function(){return{menu:"menuitem",listbox:"option"}[this.options.role]},_setOption:function(t,e){"icons"===t&&this.element.find(".ui-menu-icon").removeClass(this.options.icons.submenu).addClass(e.submenu),"disabled"===t&&this.element.toggleClass("ui-state-disabled",!!e).attr("aria-disabled",e),this._super(t,e)},focus:function(t,e){var n,i;this.blur(t,t&&"focus"===t.type),this._scrollIntoView(e),this.active=e.first(),i=this.active.addClass("ui-state-focus").removeClass("ui-state-active"),this.options.role&&this.element.attr("aria-activedescendant",i.attr("id")),this.active.parent().closest(".ui-menu-item").addClass("ui-state-active"),t&&"keydown"===t.type?this._close():this.timer=this._delay(function(){this._close()},this.delay),n=e.children(".ui-menu"),n.length&&t&&/^mouse/.test(t.type)&&this._startOpening(n),this.activeMenu=e.parent(),this._trigger("focus",t,{item:e})},_scrollIntoView:function(e){var n,i,o,a,s,r;this._hasScroll()&&(n=parseFloat(t.css(this.activeMenu[0],"borderTopWidth"))||0,i=parseFloat(t.css(this.activeMenu[0],"paddingTop"))||0,o=e.offset().top-this.activeMenu.offset().top-n-i,a=this.activeMenu.scrollTop(),s=this.activeMenu.height(),r=e.outerHeight(),o<0?this.activeMenu.scrollTop(a+o):o+r>s&&this.activeMenu.scrollTop(a+o-s+r))},blur:function(t,e){e||clearTimeout(this.timer),this.active&&(this.active.removeClass("ui-state-focus"),this.active=null,this._trigger("blur",t,{item:this.active}))},_startOpening:function(t){clearTimeout(this.timer),"true"===t.attr("aria-hidden")&&(this.timer=this._delay(function(){this._close(),this._open(t)},this.delay))},_open:function(e){var n=t.extend({of:this.active},this.options.position);clearTimeout(this.timer),this.element.find(".ui-menu").not(e.parents(".ui-menu")).hide().attr("aria-hidden","true"),e.show().removeAttr("aria-hidden").attr("aria-expanded","true").position(n)},collapseAll:function(e,n){clearTimeout(this.timer),this.timer=this._delay(function(){var i=n?this.element:t(e&&e.target).closest(this.element.find(".ui-menu"));i.length||(i=this.element),this._close(i),this.blur(e),this.activeMenu=i},this.delay)},_close:function(t){t||(t=this.active?this.active.parent():this.element),t.find(".ui-menu").hide().attr("aria-hidden","true").attr("aria-expanded","false").end().find(".ui-state-active").not(".ui-state-focus").removeClass("ui-state-active")},_closeOnDocumentClick:function(e){return!t(e.target).closest(".ui-menu").length},_isDivider:function(t){return!/[^\-\u2014\u2013\s]/.test(t.text())},collapse:function(t){var e=this.active&&this.active.parent().closest(".ui-menu-item",this.element);e&&e.length&&(this._close(),this.focus(t,e))},expand:function(t){var e=this.active&&this.active.children(".ui-menu ").find(this.options.items).first();e&&e.length&&(this._open(e.parent()),this._delay(function(){this.focus(t,e)}))},next:function(t){this._move("next","first",t)},previous:function(t){this._move("prev","last",t)},isFirstItem:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},isLastItem:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},_move:function(t,e,n){var i;this.active&&(i="first"===t||"last"===t?this.active["first"===t?"prevAll":"nextAll"](".ui-menu-item").eq(-1):this.active[t+"All"](".ui-menu-item").eq(0)),i&&i.length&&this.active||(i=this.activeMenu.find(this.options.items)[e]()),this.focus(n,i)},nextPage:function(e){var n,i,o;return this.active?void(this.isLastItem()||(this._hasScroll()?(i=this.active.offset().top,o=this.element.height(),this.active.nextAll(".ui-menu-item").each(function(){return n=t(this),n.offset().top-i-o<0}),this.focus(e,n)):this.focus(e,this.activeMenu.find(this.options.items)[this.active?"last":"first"]()))):void this.next(e)},previousPage:function(e){var n,i,o;return this.active?void(this.isFirstItem()||(this._hasScroll()?(i=this.active.offset().top,o=this.element.height(),this.active.prevAll(".ui-menu-item").each(function(){return n=t(this),n.offset().top-i+o>0}),this.focus(e,n)):this.focus(e,this.activeMenu.find(this.options.items).first()))):void this.next(e)},_hasScroll:function(){return this.element.outerHeight()",options:{appendTo:null,autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null,change:null,close:null,focus:null,open:null,response:null,search:null,select:null},requestIndex:0,pending:0,_create:function(){var e,n,i,o=this.element[0].nodeName.toLowerCase(),a="textarea"===o,s="input"===o;this.isMultiLine=!!a||!s&&this.element.prop("isContentEditable"),this.valueMethod=this.element[a||s?"val":"text"],this.isNewMenu=!0,this.element.addClass("ui-autocomplete-input").attr("autocomplete","off"),this._on(this.element,{keydown:function(o){if(this.element.prop("readOnly"))return e=!0,i=!0,void(n=!0);e=!1,i=!1,n=!1;var a=t.ui.keyCode;switch(o.keyCode){case a.PAGE_UP:e=!0,this._move("previousPage",o);break;case a.PAGE_DOWN:e=!0,this._move("nextPage",o);break;case a.UP:e=!0,this._keyEvent("previous",o);break;case a.DOWN:e=!0,this._keyEvent("next",o);break;case a.ENTER:this.menu.active&&(e=!0,o.preventDefault(),this.menu.select(o));break;case a.TAB:this.menu.active&&this.menu.select(o);break;case a.ESCAPE:this.menu.element.is(":visible")&&(this.isMultiLine||this._value(this.term),this.close(o),o.preventDefault());break;default:n=!0,this._searchTimeout(o)}},keypress:function(i){if(e)return e=!1,void(this.isMultiLine&&!this.menu.element.is(":visible")||i.preventDefault());if(!n){var o=t.ui.keyCode;switch(i.keyCode){case o.PAGE_UP:this._move("previousPage",i);break;case o.PAGE_DOWN:this._move("nextPage",i);break;case o.UP:this._keyEvent("previous",i);break;case o.DOWN:this._keyEvent("next",i)}}},input:function(t){return i?(i=!1,void t.preventDefault()):void this._searchTimeout(t)},focus:function(){this.selectedItem=null,this.previous=this._value()},blur:function(t){return this.cancelBlur?void delete this.cancelBlur:(clearTimeout(this.searching),this.close(t),void this._change(t))}}),this._initSource(),this.menu=t("
");var r=t("a",n),c=r[0],l=r[1],u=r[2],h=r[3];e.oApi._fnBindAction(c,{action:"first"},s),e.oApi._fnBindAction(l,{action:"previous"},s),e.oApi._fnBindAction(u,{action:"next"},s),e.oApi._fnBindAction(h,{action:"last"},s),e.aanFeatures.p||(n.id=e.sTableId+"_paginate",c.id=e.sTableId+"_first",l.id=e.sTableId+"_previous",u.id=e.sTableId+"_next",h.id=e.sTableId+"_last")},fnUpdate:function(e,n){if(e.aanFeatures.p){var i,o,a,s,r,c=e.oInstance.fnPagingInfo(),l=t.fn.dataTableExt.oPagination.iFullNumbersShowPages,u=Math.floor(l/2),h=Math.ceil(e.fnRecordsDisplay()/e._iDisplayLength),d=Math.ceil(e._iDisplayStart/e._iDisplayLength)+1,p="",f=(e.oClasses,e.aanFeatures.p);for(e._iDisplayLength===-1?(i=1,o=1,d=1):h=h-u?(i=h-l+1,o=h):(i=d-Math.ceil(l/2)+1,o=i+l-1),a=i;a<=o;a++)p+=d!==a?'
  • '+e.fnFormatNumber(a)+"
  • ":'
  • '+e.fnFormatNumber(a)+"
  • ";for(a=0,s=f.length;a",o[0];);return 4h.a.l(e,t[n])&&e.push(t[n]);return e},ya:function(t,e){t=t||[];for(var n=[],i=0,o=t.length;ii?n&&t.push(e):n||t.splice(i,1)},na:l,extend:r,ra:c,sa:l?c:r,A:s,Oa:function(t,e){if(!t)return t;var n,i={};for(n in t)t.hasOwnProperty(n)&&(i[n]=e(t[n],n,t));return i},Fa:function(t){for(;t.firstChild;)h.removeNode(t.firstChild)},ec:function(t){t=h.a.R(t);for(var e=n.createElement("div"),i=0,o=t.length;if?t.setAttribute("selected",e):t.selected=e},ta:function(e){return null===e||e===t?"":e.trim?e.trim():e.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")},oc:function(t,e){for(var n=[],i=(t||"").split(e),o=0,a=i.length;ot.length)&&t.substring(0,e.length)===e},Sb:function(t,e){if(t===e)return!0;if(11===t.nodeType)return!1;if(e.contains)return e.contains(3===t.nodeType?t.parentNode:t);if(e.compareDocumentPosition)return 16==(16&e.compareDocumentPosition(t));for(;t&&t!=e;)t=t.parentNode;return!!t},Ea:function(t){return h.a.Sb(t,t.ownerDocument.documentElement)},eb:function(t){return!!h.a.hb(t,h.a.Ea)},B:function(t){return t&&t.tagName&&t.tagName.toLowerCase()},q:function(t,e,n){var i=f&&p[e];if(!i&&o)o(t).bind(e,n);else if(i||"function"!=typeof t.addEventListener){if("undefined"==typeof t.attachEvent)throw Error("Browser doesn't support addEventListener or attachEvent");var a=function(e){n.call(t,e)},s="on"+e;t.attachEvent(s,a),h.a.u.ja(t,function(){t.detachEvent(s,a)})}else t.addEventListener(e,n,!1)},ha:function(t,i){if(!t||!t.nodeType)throw Error("element must be a DOM node when calling triggerEvent");var a;if("input"===h.a.B(t)&&t.type&&"click"==i.toLowerCase()?(a=t.type,a="checkbox"==a||"radio"==a):a=!1,o&&!a)o(t).trigger(i);else if("function"==typeof n.createEvent){if("function"!=typeof t.dispatchEvent)throw Error("The supplied element doesn't support dispatchEvent");a=n.createEvent(d[i]||"HTMLEvents"),a.initEvent(i,!0,!0,e,0,0,0,0,0,!1,!1,!1,!1,0,t),t.dispatchEvent(a)}else if(a&&t.click)t.click();else{if("undefined"==typeof t.fireEvent)throw Error("Browser doesn't support triggering events");t.fireEvent("on"+i)}},c:function(t){return h.v(t)?t():t},Sa:function(t){return h.v(t)?t.o():t},ua:function(t,e,n){if(e){var i=/\S+/g,o=t.className.match(i)||[];h.a.r(e.match(i),function(t){h.a.Y(o,t,n)}),t.className=o.join(" ")}},Xa:function(e,n){var i=h.a.c(n);null!==i&&i!==t||(i="");var o=h.e.firstChild(e);!o||3!=o.nodeType||h.e.nextSibling(o)?h.e.U(e,[e.ownerDocument.createTextNode(i)]):o.data=i,h.a.Vb(e)},Cb:function(t,e){if(t.name=e,7>=f)try{t.mergeAttributes(n.createElement(""),!1)}catch(i){}},Vb:function(t){9<=f&&(t=1==t.nodeType?t:t.parentNode,t.style&&(t.style.zoom=t.style.zoom))},Tb:function(t){if(f){var e=t.style.width;t.style.width=0,t.style.width=e}},ic:function(t,e){t=h.a.c(t),e=h.a.c(e);for(var n=[],i=t;i<=e;i++)n.push(i);return n},R:function(t){for(var e=[],n=0,i=t.length;n",""]||!a.indexOf("",""]||(!a.indexOf("",""]||[0,"",""],t="ignored
    "+a[1]+t+a[2]+"
    ","function"==typeof e.innerShiv?i.appendChild(e.innerShiv(t)):i.innerHTML=t;a[0]--;)i=i.lastChild;i=h.a.R(i.lastChild.childNodes)}return i},h.a.Va=function(e,n){if(h.a.Fa(e),n=h.a.c(n),null!==n&&n!==t)if("string"!=typeof n&&(n=n.toString()),o)o(e).html(n);else for(var i=h.a.Qa(n),a=0;a"},Hb:function(e,i){var o=n[e];if(o===t)throw Error("Couldn't find any memo with ID "+e+". Perhaps it's already been unmemoized.");try{return o.apply(null,i||[]),!0}finally{delete n[e]}},Ib:function(t,n){var i=[];e(t,i);for(var o=0,a=i.length;oa[0]?c+a[0]:a[0]),c);for(var c=1===l?c:Math.min(e+(a[1]||0),c),l=e+l-2,u=Math.max(c,l),d=[],p=[],f=2;ee;e++)t=t();return t})},h.toJSON=function(t,e,n){return t=h.Gb(t),h.a.Ya(t,e,n)},i.prototype={save:function(t,e){var n=h.a.l(this.keys,t);0<=n?this.ab[n]=e:(this.keys.push(t),this.ab.push(e))},get:function(e){return e=h.a.l(this.keys,e),0<=e?this.ab[e]:t}}}(),h.b("toJS",h.Gb),h.b("toJSON",h.toJSON),function(){h.i={p:function(e){switch(h.a.B(e)){case"option":return!0===e.__ko__hasDomDataOptionValue__?h.a.f.get(e,h.d.options.Pa):7>=h.a.oa?e.getAttributeNode("value")&&e.getAttributeNode("value").specified?e.value:e.text:e.value;case"select":return 0<=e.selectedIndex?h.i.p(e.options[e.selectedIndex]):t;default:return e.value}},X:function(e,n,i){switch(h.a.B(e)){case"option":switch(typeof n){case"string":h.a.f.set(e,h.d.options.Pa,t),"__ko__hasDomDataOptionValue__"in e&&delete e.__ko__hasDomDataOptionValue__,e.value=n;break;default:h.a.f.set(e,h.d.options.Pa,n),e.__ko__hasDomDataOptionValue__=!0,e.value="number"==typeof n?n:""}break;case"select":""!==n&&null!==n||(n=t);for(var o,a=-1,s=0,r=e.options.length;s=c){e&&s.push(n?{key:e,value:n.join("")}:{unknown:e}),e=n=c=0;continue}}else if(58===d){if(!n)continue}else if(47===d&&u&&1"===n.createComment("test").text,s=a?/^\x3c!--\s*ko(?:\s+([\s\S]+))?\s*--\x3e$/:/^\s*ko(?:\s+([\s\S]+))?\s*$/,r=a?/^\x3c!--\s*\/ko\s*--\x3e$/:/^\s*\/ko\s*$/,c={ul:!0,ol:!0};h.e={Q:{},childNodes:function(e){return t(e)?i(e):e.childNodes},da:function(e){if(t(e)){e=h.e.childNodes(e);for(var n=0,i=e.length;n=h.a.oa&&n in g?(n=g[n],o?e.removeAttribute(n):e[n]=i):o||e.setAttribute(n,i.toString()),"name"===n&&h.a.Cb(e,o?"":i.toString())})}},function(){h.d.checked={after:["value","attr"],init:function(e,n,i){function o(){return i.has("checkedValue")?h.a.c(i.get("checkedValue")):e.value}function a(){var t=e.checked,a=d?o():t;if(!h.ca.pa()&&(!c||t)){var s=h.k.t(n);l?u!==a?(t&&(h.a.Y(s,a,!0),h.a.Y(s,u,!1)),u=a):h.a.Y(s,a,t):h.g.va(s,i,"checked",a,!0)}}function s(){var t=h.a.c(n());e.checked=l?0<=h.a.l(t,o()):r?t:o()===t}var r="checkbox"==e.type,c="radio"==e.type;if(r||c){var l=r&&h.a.c(n())instanceof Array,u=l?o():t,d=c||l;c&&!e.name&&h.d.uniqueName.init(e,function(){return!0}),h.ba(a,null,{G:e}),h.a.q(e,"click",a),h.ba(s,null,{G:e})}}},h.g.W.checked=!0,h.d.checkedValue={update:function(t,e){t.value=h.a.c(e())}}}(),h.d.css={update:function(t,e){var n=h.a.c(e());"object"==typeof n?h.a.A(n,function(e,n){n=h.a.c(n),h.a.ua(t,e,n)}):(n=String(n||""),h.a.ua(t,t.__ko__cssValue,!1),t.__ko__cssValue=n,h.a.ua(t,n,!0))}},h.d.enable={update:function(t,e){var n=h.a.c(e());n&&t.disabled?t.removeAttribute("disabled"):n||t.disabled||(t.disabled=!0)}},h.d.disable={update:function(t,e){h.d.enable.update(t,function(){return!h.a.c(e())})}},h.d.event={init:function(t,e,n,i,o){var a=e()||{};h.a.A(a,function(a){"string"==typeof a&&h.a.q(t,a,function(t){var s,r=e()[a];if(r){try{var c=h.a.R(arguments);i=o.$data,c.unshift(i),s=r.apply(i,c)}finally{!0!==s&&(t.preventDefault?t.preventDefault():t.returnValue=!1)}!1===n.get(a+"Bubble")&&(t.cancelBubble=!0,t.stopPropagation&&t.stopPropagation())}})})}},h.d.foreach={vb:function(t){return function(){var e=t(),n=h.a.Sa(e);return n&&"number"!=typeof n.length?(h.a.c(e),{foreach:n.data,as:n.as,includeDestroyed:n.includeDestroyed,afterAdd:n.afterAdd,beforeRemove:n.beforeRemove,afterRender:n.afterRender,beforeMove:n.beforeMove,afterMove:n.afterMove,templateEngine:h.K.Ja}):{foreach:e,templateEngine:h.K.Ja}}},init:function(t,e){return h.d.template.init(t,h.d.foreach.vb(e))},update:function(t,e,n,i,o){return h.d.template.update(t,h.d.foreach.vb(e),n,i,o)}},h.g.aa.foreach=!1,h.e.Q.foreach=!0,h.d.hasfocus={init:function(t,e,n){function i(i){t.__ko_hasfocusUpdating=!0;var o=t.ownerDocument;if("activeElement"in o){var a;try{a=o.activeElement}catch(s){a=o.body}i=a===t}o=e(),h.g.va(o,n,"hasfocus",i,!0),t.__ko_hasfocusLastValue=i,t.__ko_hasfocusUpdating=!1}var o=i.bind(null,!0),a=i.bind(null,!1);h.a.q(t,"focus",o),h.a.q(t,"focusin",o),h.a.q(t,"blur",a),h.a.q(t,"focusout",a)},update:function(t,e){var n=!!h.a.c(e());t.__ko_hasfocusUpdating||t.__ko_hasfocusLastValue===n||(n?t.focus():t.blur(),h.k.t(h.a.ha,null,[t,n?"focusin":"focusout"]))}},h.g.W.hasfocus=!0,h.d.hasFocus=h.d.hasfocus,h.g.W.hasFocus=!0,h.d.html={init:function(){return{controlsDescendantBindings:!0}},update:function(t,e){h.a.Va(t,e())}},u("if"),u("ifnot",!1,!0),u("with",!0,!1,function(t,e){return t.createChildContext(e)});var b={};h.d.options={init:function(t){if("select"!==h.a.B(t))throw Error("options binding applies only to SELECT elements");for(;0","#comment",o)})},Mb:function(t,e){return h.w.Na(function(n,i){var o=n.nextSibling;o&&o.nodeName.toLowerCase()===e&&h.xa(o,t,i)})}}}(),h.b("__tr_ambtns",h.Za.Mb),function(){h.n={},h.n.j=function(t){this.j=t},h.n.j.prototype.text=function(){var t=h.a.B(this.j),t="script"===t?"text":"textarea"===t?"value":"innerHTML";if(0==arguments.length)return this.j[t];var e=arguments[0];"innerHTML"===t?h.a.Va(this.j,e):this.j[t]=e};var e=h.a.f.L()+"_";h.n.j.prototype.data=function(t){return 1===arguments.length?h.a.f.get(this.j,e+t):void h.a.f.set(this.j,e+t,arguments[1])};var n=h.a.f.L();h.n.Z=function(t){this.j=t},h.n.Z.prototype=new h.n.j,h.n.Z.prototype.text=function(){if(0==arguments.length){var e=h.a.f.get(this.j,n)||{};return e.$a===t&&e.Ba&&(e.$a=e.Ba.innerHTML),e.$a}h.a.f.set(this.j,n,{$a:arguments[0]})},h.n.j.prototype.nodes=function(){return 0==arguments.length?(h.a.f.get(this.j,n)||{}).Ba:void h.a.f.set(this.j,n,{Ba:arguments[0]})},h.b("templateSources",h.n),h.b("templateSources.domElement",h.n.j),h.b("templateSources.anonymousTemplate",h.n.Z)}(),function(){function e(t,e,n){var i;for(e=h.e.nextSibling(e);t&&(i=t)!==e;)t=h.e.nextSibling(i),n(i,t)}function n(t,n){if(t.length){var i=t[0],o=t[t.length-1],a=i.parentNode,s=h.J.instance,r=s.preprocessNode;if(r){if(e(i,o,function(t,e){var n=t.previousSibling,a=r.call(s,t);a&&(t===i&&(i=a[0]||e),t===o&&(o=a[a.length-1]||n))}),t.length=0,!i)return;i===o?t.push(i):(t.push(i,o),h.a.ea(t,a))}e(i,o,function(t){1!==t.nodeType&&8!==t.nodeType||h.fb(n,t)}),e(i,o,function(t){1!==t.nodeType&&8!==t.nodeType||h.w.Ib(t,[n])}),h.a.ea(t,a)}}function i(t){return t.nodeType?t:0h.a.oa?0:t.nodes)?t.nodes():null;return e?h.a.R(e.cloneNode(!0).childNodes):(t=t.text(),h.a.Qa(t))},h.K.Ja=new h.K,h.Wa(h.K.Ja),h.b("nativeTemplateEngine",h.K),function(){h.La=function(){var t=this.ac=function(){if(!o||!o.tmpl)return 0;try{if(0<=o.tmpl.tag.tmpl.open.toString().indexOf("__"))return 2}catch(t){}return 1}();this.renderTemplateSource=function(e,i,a){if(a=a||{},2>t)throw Error("Your version of jQuery.tmpl is too old. Please upgrade to jQuery.tmpl 1.0.0pre or later.");var s=e.data("precompiled");return s||(s=e.text()||"",s=o.template(null,"{{ko_with $item.koBindingContext}}"+s+"{{/ko_with}}"),e.data("precompiled",s)),e=[i.$data],i=o.extend({koBindingContext:i},a.templateOptions),i=o.tmpl(s,e,i),i.appendTo(n.createElement("div")),o.fragments={},i},this.createJavaScriptEvaluatorBlock=function(t){return"{{ko_code ((function() { return "+t+" })()) }}"},this.addTemplate=function(t,e){n.write("")},0=0&&(u&&(u.splice(m,1),t.processAllDeferredBindingUpdates&&t.processAllDeferredBindingUpdates()),p.splice(g,0,A)),l(v,n,null),t.processAllDeferredBindingUpdates&&t.processAllDeferredBindingUpdates(),T.afterMove&&T.afterMove.call(this,b,s,r)}y&&y.apply(this,arguments)},connectWith:!!T.connectClass&&"."+T.connectClass})),void 0!==T.isEnabled&&t.computed({read:function(){A.sortable(r(T.isEnabled)?"enable":"disable")},disposeWhenNodeIsRemoved:u})},0);return t.utils.domNodeDisposal.addDisposeCallback(u,function(){(A.data("ui-sortable")||A.data("sortable"))&&A.sortable("destroy"),clearTimeout(w)}),{controlsDescendantBindings:!0}},update:function(e,n,i,a,s){var r=p(n,"foreach");l(e,o,r.foreach),t.bindingHandlers.template.update(e,function(){return r},i,a,s)},connectClass:"ko_container",allowDrop:!0,afterMove:null,beforeMove:null,options:{}},t.bindingHandlers.draggable={init:function(n,i,o,a,c){var u=r(i())||{},h=u.options||{},d=t.utils.extend({},t.bindingHandlers.draggable.options),f=p(i,"data"),m=u.connectClass||t.bindingHandlers.draggable.connectClass,g=void 0!==u.isEnabled?u.isEnabled:t.bindingHandlers.draggable.isEnabled;return u="data"in u?u.data:u,l(n,s,u),t.utils.extend(d,h),d.connectToSortable=!!m&&"."+m,e(n).draggable(d),void 0!==g&&t.computed({read:function(){e(n).draggable(r(g)?"enable":"disable")},disposeWhenNodeIsRemoved:n}),t.bindingHandlers.template.init(n,function(){return f},o,a,c)},update:function(e,n,i,o,a){var s=p(n,"data");return t.bindingHandlers.template.update(e,function(){return s},i,o,a)},connectClass:t.bindingHandlers.sortable.connectClass,options:{helper:"clone"}}}),function(){var t=this,e=t._,n=Array.prototype,i=Object.prototype,o=Function.prototype,a=n.push,s=n.slice,r=n.concat,c=i.toString,l=i.hasOwnProperty,u=Array.isArray,h=Object.keys,d=o.bind,p=function(t){return t instanceof p?t:this instanceof p?void(this._wrapped=t):new p(t)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=p),exports._=p):t._=p,p.VERSION="1.7.0";var f=function(t,e,n){if(void 0===e)return t;switch(null==n?3:n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,i){return t.call(e,n,i)};case 3:return function(n,i,o){return t.call(e,n,i,o)};case 4:return function(n,i,o,a){return t.call(e,n,i,o,a)}}return function(){return t.apply(e,arguments)}};p.iteratee=function(t,e,n){return null==t?p.identity:p.isFunction(t)?f(t,e,n):p.isObject(t)?p.matches(t):p.property(t)},p.each=p.forEach=function(t,e,n){if(null==t)return t;e=f(e,n);var i,o=t.length;if(o===+o)for(i=0;i=0)},p.invoke=function(t,e){var n=s.call(arguments,2),i=p.isFunction(e);return p.map(t,function(t){return(i?e:t[e]).apply(t,n)})},p.pluck=function(t,e){return p.map(t,p.property(e))},p.where=function(t,e){return p.filter(t,p.matches(e))},p.findWhere=function(t,e){return p.find(t,p.matches(e))},p.max=function(t,e,n){var i,o,a=-(1/0),s=-(1/0);if(null==e&&null!=t){t=t.length===+t.length?t:p.values(t);for(var r=0,c=t.length;ra&&(a=i)}else e=p.iteratee(e,n),p.each(t,function(t,n,i){o=e(t,n,i),(o>s||o===-(1/0)&&a===-(1/0))&&(a=t,s=o)});return a},p.min=function(t,e,n){var i,o,a=1/0,s=1/0;if(null==e&&null!=t){t=t.length===+t.length?t:p.values(t);for(var r=0,c=t.length;ri||void 0===n)return 1;if(n>>1;n(t[r])=0;)if(t[i]===e)return i;return-1},p.range=function(t,e,n){arguments.length<=1&&(e=t||0,t=0),n=n||1;for(var i=Math.max(Math.ceil((e-t)/n),0),o=Array(i),a=0;ae?(clearTimeout(s),s=null,r=l,a=t.apply(i,o),s||(i=o=null)):s||n.trailing===!1||(s=setTimeout(c,u)),a}},p.debounce=function(t,e,n){var i,o,a,s,r,c=function(){var l=p.now()-s;l0?i=setTimeout(c,e-l):(i=null,n||(r=t.apply(a,o),i||(a=o=null)))};return function(){a=this,o=arguments,s=p.now();var l=n&&!i;return i||(i=setTimeout(c,e)),l&&(r=t.apply(a,o),a=o=null),r}},p.wrap=function(t,e){return p.partial(e,t)},p.negate=function(t){return function(){return!t.apply(this,arguments)}},p.compose=function(){var t=arguments,e=t.length-1;return function(){for(var n=e,i=t[e].apply(this,arguments);n--;)i=t[n].call(this,i);return i}},p.after=function(t,e){return function(){if(--t<1)return e.apply(this,arguments)}},p.before=function(t,e){var n;return function(){return--t>0?n=e.apply(this,arguments):e=null,n}},p.once=p.partial(p.before,2),p.keys=function(t){if(!p.isObject(t))return[];if(h)return h(t);var e=[];for(var n in t)p.has(t,n)&&e.push(n);return e},p.values=function(t){for(var e=p.keys(t),n=e.length,i=Array(n),o=0;o":">",'"':""","'":"'","`":"`"},A=p.invert(y),z=function(t){var e=function(e){return t[e]},n="(?:"+p.keys(t).join("|")+")",i=RegExp(n),o=RegExp(n,"g");return function(t){return t=null==t?"":""+t,i.test(t)?t.replace(o,e):t}};p.escape=z(y),p.unescape=z(A),p.result=function(t,e){if(null!=t){var n=t[e];return p.isFunction(n)?t[e]():n}};var _=0;p.uniqueId=function(t){var e=++_+"";return t?t+e:e},p.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var T=/(.)^/,w={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},C=/\\|'|\r|\n|\u2028|\u2029/g,N=function(t){return"\\"+w[t]};p.template=function(t,e,n){!e&&n&&(e=n),e=p.defaults({},e,p.templateSettings);var i=RegExp([(e.escape||T).source,(e.interpolate||T).source,(e.evaluate||T).source].join("|")+"|$","g"),o=0,a="__p+='";t.replace(i,function(e,n,i,s,r){return a+=t.slice(o,r).replace(C,N),o=r+e.length,n?a+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'":i?a+="'+\n((__t=("+i+"))==null?'':__t)+\n'":s&&(a+="';\n"+s+"\n__p+='"),e}),a+="';\n",e.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{var s=new Function(e.variable||"obj","_",a)}catch(r){throw r.source=a,r}var c=function(t){return s.call(this,t,p)},l=e.variable||"obj";return c.source="function("+l+"){\n"+a+"}",c},p.chain=function(t){var e=p(t);return e._chain=!0,e};var O=function(t){return this._chain?p(t).chain():t};p.mixin=function(t){p.each(p.functions(t),function(e){var n=p[e]=t[e];p.prototype[e]=function(){var t=[this._wrapped];return a.apply(t,arguments),O.call(this,n.apply(p,t))}})},p.mixin(p),p.each(["pop","push","reverse","shift","sort","splice","unshift"],function(t){var e=n[t];p.prototype[t]=function(){var n=this._wrapped;return e.apply(n,arguments),"shift"!==t&&"splice"!==t||0!==n.length||delete n[0],O.call(this,n)}}),p.each(["concat","join","slice"],function(t){var e=n[t];p.prototype[t]=function(){return O.call(this,e.apply(this._wrapped,arguments))}}),p.prototype.value=function(){return this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return p})}.call(this),function(t,e){function n(){return new Date(Date.UTC.apply(Date,arguments))}function i(){var t=new Date;return n(t.getFullYear(),t.getMonth(),t.getDate())}function o(t,e){return t.getUTCFullYear()===e.getUTCFullYear()&&t.getUTCMonth()===e.getUTCMonth()&&t.getUTCDate()===e.getUTCDate()}function a(t){return function(){return this[t].apply(this,arguments)}}function s(e,n){function i(t,e){return e.toLowerCase()}var o,a=t(e).data(),s={},r=new RegExp("^"+n.toLowerCase()+"([A-Z])");n=new RegExp("^"+n.toLowerCase());for(var c in a)n.test(c)&&(o=c.replace(r,i),s[o]=a[c]);return s}function r(e){var n={};if(m[e]||(e=e.split("-")[0],m[e])){var i=m[e];return t.each(f,function(t,e){e in i&&(n[e]=i[e])}),n}}var c=function(){var e={get:function(t){return this.slice(t)[0]},contains:function(t){for(var e=t&&t.valueOf(),n=0,i=this.length;no?(this.picker.addClass("datepicker-orient-right"),p=u.left+d-e):this.picker.addClass("datepicker-orient-left");var m,g,b=this.o.orientation.y;if("auto"===b&&(m=-s+f-n,g=s+a-(f+h+n),b=Math.max(m,g)===g?"top":"bottom"),this.picker.addClass("datepicker-orient-"+b),"top"===b?f+=h:f-=n+parseInt(this.picker.css("padding-top")),this.o.rtl){var v=o-(p+d);this.picker.css({top:f,right:v,zIndex:l})}else this.picker.css({top:f,left:p,zIndex:l});return this},_allow_update:!0,update:function(){if(!this._allow_update)return this;var e=this.dates.copy(),n=[],i=!1;return arguments.length?(t.each(arguments,t.proxy(function(t,e){e instanceof Date&&(e=this._local_to_utc(e)),n.push(e)},this)),i=!0):(n=this.isInput?this.element.val():this.element.data("date")||this.element.find("input").val(),n=n&&this.o.multidate?n.split(this.o.multidateSeparator):[n],delete this.element.data().date),n=t.map(n,t.proxy(function(t){return g.parseDate(t,this.o.format,this.o.language)},this)),n=t.grep(n,t.proxy(function(t){return tthis.o.endDate||!t},this),!0),this.dates.replace(n),this.dates.length?this.viewDate=new Date(this.dates.get(-1)):this.viewDatethis.o.endDate&&(this.viewDate=new Date(this.o.endDate)),i?this.setValue():n.length&&String(e)!==String(this.dates)&&this._trigger("changeDate"),!this.dates.length&&e.length&&this._trigger("clearDate"),this.fill(),this},fillDow:function(){var t=this.o.weekStart,e="";if(this.o.calendarWeeks){this.picker.find(".datepicker-days thead tr:first-child .datepicker-switch").attr("colspan",function(t,e){return parseInt(e)+1});var n=' ';e+=n}for(;t'+m[this.o.language].daysMin[t++%7]+"";e+="",this.picker.find(".datepicker-days thead").append(e)},fillMonths:function(){for(var t="",e=0;e<12;)t+=''+m[this.o.language].monthsShort[e++]+"";this.picker.find(".datepicker-months td").html(t)},setRange:function(e){e&&e.length?this.range=t.map(e,function(t){return t.valueOf()}):delete this.range,this.fill()},getClassNames:function(e){var n=[],i=this.viewDate.getUTCFullYear(),a=this.viewDate.getUTCMonth(),s=new Date;return e.getUTCFullYear()i||e.getUTCFullYear()===i&&e.getUTCMonth()>a)&&n.push("new"),this.focusDate&&e.valueOf()===this.focusDate.valueOf()&&n.push("focused"),this.o.todayHighlight&&e.getUTCFullYear()===s.getFullYear()&&e.getUTCMonth()===s.getMonth()&&e.getUTCDate()===s.getDate()&&n.push("today"),this.dates.contains(e)!==-1&&n.push("active"),(e.valueOf()this.o.endDate||t.inArray(e.getUTCDay(),this.o.daysOfWeekDisabled)!==-1)&&n.push("disabled"),this.o.datesDisabled.length>0&&t.grep(this.o.datesDisabled,function(t){return o(e,t)}).length>0&&n.push("disabled","disabled-date"),this.range&&(e>this.range[0]&&e"),this.o.calendarWeeks)){var y=new Date(+p+(this.o.weekStart-p.getUTCDay()-7)%7*864e5),A=new Date(Number(y)+(11-y.getUTCDay())%7*864e5),z=new Date(Number(z=n(A.getUTCFullYear(),0,1))+(11-z.getUTCDay())%7*864e5),_=(A-z)/864e5/7+1;M.push(''+_+"")}if(v=this.getClassNames(p),v.push("day"),this.o.beforeShowDay!==t.noop){var T=this.o.beforeShowDay(this._utc_to_local(p));T===e?T={}:"boolean"==typeof T?T={enabled:T}:"string"==typeof T&&(T={classes:T}),T.enabled===!1&&v.push("disabled"),T.classes&&(v=v.concat(T.classes.split(/\s+/))),T.tooltip&&(i=T.tooltip)}v=t.unique(v),M.push('"+p.getUTCDate()+""),i=null,p.getUTCDay()===this.o.weekEnd&&M.push(""),p.setUTCDate(p.getUTCDate()+1)}this.picker.find(".datepicker-days tbody").empty().append(M.join(""));var w=this.picker.find(".datepicker-months").find("th:eq(1)").text(a).end().find("span").removeClass("active");if(t.each(this.dates,function(t,e){e.getUTCFullYear()===a&&w.eq(e.getUTCMonth()).addClass("active")}),(al)&&w.addClass("disabled"),a===r&&w.slice(0,c).addClass("disabled"),a===l&&w.slice(u+1).addClass("disabled"),this.o.beforeShowMonth!==t.noop){var C=this;t.each(w,function(e,n){if(!t(n).hasClass("disabled")){var i=new Date(a,e,1),o=C.o.beforeShowMonth(i);o===!1&&t(n).addClass("disabled")}})}M="",a=10*parseInt(a/10,10);var N=this.picker.find(".datepicker-years").find("th:eq(1)").text(a+"-"+(a+9)).end().find("td");a-=1;for(var O,S=t.map(this.dates,function(t){return t.getUTCFullYear()}),x=-1;x<11;x++)O=["year"],x===-1?O.push("old"):10===x&&O.push("new"),t.inArray(a,S)!==-1&&O.push("active"),(al)&&O.push("disabled"),M+=''+a+"",a+=1;N.html(M)}},updateNavArrows:function(){if(this._allow_update){var t=new Date(this.viewDate),e=t.getUTCFullYear(),n=t.getUTCMonth();switch(this.viewMode){case 0:this.o.startDate!==-(1/0)&&e<=this.o.startDate.getUTCFullYear()&&n<=this.o.startDate.getUTCMonth()?this.picker.find(".prev").css({visibility:"hidden"}):this.picker.find(".prev").css({visibility:"visible"}),this.o.endDate!==1/0&&e>=this.o.endDate.getUTCFullYear()&&n>=this.o.endDate.getUTCMonth()?this.picker.find(".next").css({visibility:"hidden"}):this.picker.find(".next").css({visibility:"visible"});break;case 1:case 2:this.o.startDate!==-(1/0)&&e<=this.o.startDate.getUTCFullYear()?this.picker.find(".prev").css({visibility:"hidden"}):this.picker.find(".prev").css({visibility:"visible"}),this.o.endDate!==1/0&&e>=this.o.endDate.getUTCFullYear()?this.picker.find(".next").css({visibility:"hidden"}):this.picker.find(".next").css({visibility:"visible"})}}},click:function(e){e.preventDefault();var i,o,a,s=t(e.target).closest("span, td, th");if(1===s.length)switch(s[0].nodeName.toLowerCase()){case"th":switch(s[0].className){case"datepicker-switch":this.showMode(1);break;case"prev":case"next":var r=g.modes[this.viewMode].navStep*("prev"===s[0].className?-1:1);switch(this.viewMode){case 0:this.viewDate=this.moveMonth(this.viewDate,r),this._trigger("changeMonth",this.viewDate);break;case 1:case 2:this.viewDate=this.moveYear(this.viewDate,r),1===this.viewMode&&this._trigger("changeYear",this.viewDate)}this.fill();break;case"today":var c=new Date;c=n(c.getFullYear(),c.getMonth(),c.getDate(),0,0,0),this.showMode(-2);var l="linked"===this.o.todayBtn?null:"view";this._setDate(c,l);break;case"clear":this.clearDates()}break;case"span":s.hasClass("disabled")||(this.viewDate.setUTCDate(1),s.hasClass("month")?(a=1,o=s.parent().find("span").index(s),i=this.viewDate.getUTCFullYear(),this.viewDate.setUTCMonth(o),this._trigger("changeMonth",this.viewDate),1===this.o.minViewMode&&this._setDate(n(i,o,a))):(a=1,o=0,i=parseInt(s.text(),10)||0,this.viewDate.setUTCFullYear(i),this._trigger("changeYear",this.viewDate),2===this.o.minViewMode&&this._setDate(n(i,o,a))),this.showMode(-1),this.fill());break;case"td":s.hasClass("day")&&!s.hasClass("disabled")&&(a=parseInt(s.text(),10)||1,i=this.viewDate.getUTCFullYear(),o=this.viewDate.getUTCMonth(),s.hasClass("old")?0===o?(o=11,i-=1):o-=1:s.hasClass("new")&&(11===o?(o=0,i+=1):o+=1),this._setDate(n(i,o,a)))}this.picker.is(":visible")&&this._focused_from&&t(this._focused_from).focus(),delete this._focused_from},_toggle_multidate:function(t){var e=this.dates.contains(t);if(t||this.dates.clear(),e!==-1?(this.o.multidate===!0||this.o.multidate>1||this.o.toggleActive)&&this.dates.remove(e):this.o.multidate===!1?(this.dates.clear(),this.dates.push(t)):this.dates.push(t),"number"==typeof this.o.multidate)for(;this.dates.length>this.o.multidate;)this.dates.remove(0)},_setDate:function(t,e){e&&"date"!==e||this._toggle_multidate(t&&new Date(t)),e&&"view"!==e||(this.viewDate=t&&new Date(t)),this.fill(),this.setValue(),e&&"view"===e||this._trigger("changeDate");var n;this.isInput?n=this.element:this.component&&(n=this.element.find("input")),n&&n.change(),!this.o.autoclose||e&&"date"!==e||this.hide()},moveMonth:function(t,n){if(!t)return e;if(!n)return t;var i,o,a=new Date(t.valueOf()),s=a.getUTCDate(),r=a.getUTCMonth(),c=Math.abs(n);if(n=n>0?1:-1,1===c)o=n===-1?function(){return a.getUTCMonth()===r}:function(){return a.getUTCMonth()!==i},i=r+n,a.setUTCMonth(i),(i<0||i>11)&&(i=(i+12)%12);else{for(var l=0;l=this.o.startDate&&t<=this.o.endDate},keydown:function(t){if(!this.picker.is(":visible"))return void(27===t.keyCode&&this.show());var e,n,o,a=!1,s=this.focusDate||this.viewDate;switch(t.keyCode){case 27:this.focusDate?(this.focusDate=null,this.viewDate=this.dates.get(-1)||this.viewDate,this.fill()):this.hide(),t.preventDefault();break;case 37:case 39:if(!this.o.keyboardNavigation)break;e=37===t.keyCode?-1:1,t.ctrlKey?(n=this.moveYear(this.dates.get(-1)||i(),e),o=this.moveYear(s,e),this._trigger("changeYear",this.viewDate)):t.shiftKey?(n=this.moveMonth(this.dates.get(-1)||i(),e),o=this.moveMonth(s,e),this._trigger("changeMonth",this.viewDate)):(n=new Date(this.dates.get(-1)||i()),n.setUTCDate(n.getUTCDate()+e),o=new Date(s),o.setUTCDate(s.getUTCDate()+e)),this.dateWithinRange(o)&&(this.focusDate=this.viewDate=o,this.setValue(),this.fill(),t.preventDefault());break;case 38:case 40:if(!this.o.keyboardNavigation)break;e=38===t.keyCode?-1:1,t.ctrlKey?(n=this.moveYear(this.dates.get(-1)||i(),e),o=this.moveYear(s,e),this._trigger("changeYear",this.viewDate)):t.shiftKey?(n=this.moveMonth(this.dates.get(-1)||i(),e),o=this.moveMonth(s,e),this._trigger("changeMonth",this.viewDate)):(n=new Date(this.dates.get(-1)||i()),n.setUTCDate(n.getUTCDate()+7*e),o=new Date(s),o.setUTCDate(s.getUTCDate()+7*e)),this.dateWithinRange(o)&&(this.focusDate=this.viewDate=o,this.setValue(),this.fill(),t.preventDefault());break;case 32:break;case 13:s=this.focusDate||this.dates.get(-1)||this.viewDate,this.o.keyboardNavigation&&(this._toggle_multidate(s),a=!0),this.focusDate=null,this.viewDate=this.dates.get(-1)||this.viewDate,this.setValue(),this.fill(),this.picker.is(":visible")&&(t.preventDefault(),"function"==typeof t.stopPropagation?t.stopPropagation():t.cancelBubble=!0,this.o.autoclose&&this.hide());break;case 9:this.focusDate=null,this.viewDate=this.dates.get(-1)||this.viewDate,this.fill(),this.hide()}if(a){this.dates.length?this._trigger("changeDate"):this._trigger("clearDate");var r;this.isInput?r=this.element:this.component&&(r=this.element.find("input")),r&&r.change()}},showMode:function(t){t&&(this.viewMode=Math.max(this.o.minViewMode,Math.min(2,this.viewMode+t))),this.picker.children("div").hide().filter(".datepicker-"+g.modes[this.viewMode].clsName).css("display","block"),this.updateNavArrows()}};var u=function(e,n){this.element=t(e),this.inputs=t.map(n.inputs,function(t){return t.jquery?t[0]:t}),delete n.inputs,d.call(t(this.inputs),n).bind("changeDate",t.proxy(this.dateUpdated,this)),this.pickers=t.map(this.inputs,function(e){return t(e).data("datepicker")}),this.updateDates()};u.prototype={updateDates:function(){this.dates=t.map(this.pickers,function(t){return t.getUTCDate()}),this.updateRanges()},updateRanges:function(){var e=t.map(this.dates,function(t){return t.valueOf()});t.each(this.pickers,function(t,n){n.setRange(e)})},dateUpdated:function(e){if(!this.updating){this.updating=!0;var n=t(e.target).data("datepicker"),i=n.getUTCDate(),o=t.inArray(e.target,this.inputs),a=o-1,s=o+1,r=this.inputs.length;if(o!==-1){if(t.each(this.pickers,function(t,e){e.getUTCDate()||e.setUTCDate(i)}),i=0&&ithis.dates[s])for(;sthis.dates[s];)this.pickers[s++].setUTCDate(i);this.updateDates(),delete this.updating}}},remove:function(){t.map(this.pickers,function(t){t.remove()}),delete this.element.data().datepicker}};var h=t.fn.datepicker,d=function(n){var i=Array.apply(null,arguments);i.shift();var o;return this.each(function(){var a=t(this),c=a.data("datepicker"),h="object"==typeof n&&n;if(!c){var d=s(this,"date"),f=t.extend({},p,d,h),m=r(f.language),g=t.extend({},p,m,d,h);if(a.hasClass("input-daterange")||g.inputs){var b={inputs:g.inputs||a.find("input").toArray()};a.data("datepicker",c=new u(this,t.extend(g,b)))}else a.data("datepicker",c=new l(this,g))}if("string"==typeof n&&"function"==typeof c[n]&&(o=c[n].apply(c,i),o!==e))return!1}),o!==e?o:this};t.fn.datepicker=d;var p=t.fn.datepicker.defaults={autoclose:!1,beforeShowDay:t.noop,beforeShowMonth:t.noop,calendarWeeks:!1,clearBtn:!1,toggleActive:!1,daysOfWeekDisabled:[],datesDisabled:[],endDate:1/0,forceParse:!0,format:"mm/dd/yyyy",keyboardNavigation:!0,language:"en",minViewMode:0,multidate:!1,multidateSeparator:",",orientation:"auto",rtl:!1,startDate:-(1/0),startView:0,todayBtn:!1,todayHighlight:!1,weekStart:0,disableTouchKeyboard:!1,enableOnReadonly:!0,container:"body"},f=t.fn.datepicker.locale_opts=["format","rtl","weekStart"];t.fn.datepicker.Constructor=l;var m=t.fn.datepicker.dates={en:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sun"],daysMin:["Su","Mo","Tu","We","Th","Fr","Sa","Su"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],today:"Today",clear:"Clear"}},g={modes:[{clsName:"days",navFnc:"Month",navStep:1},{clsName:"months",navFnc:"FullYear",navStep:1},{clsName:"years",navFnc:"FullYear",navStep:10}],isLeapYear:function(t){return t%4===0&&t%100!==0||t%400===0},getDaysInMonth:function(t,e){return[31,g.isLeapYear(t)?29:28,31,30,31,30,31,31,30,31,30,31][e]},validParts:/dd?|DD?|mm?|MM?|yy(?:yy)?/g,nonpunctuation:/[^ -\/:-@\[\u3400-\u9fff-`{-~\t\n\r]+/g,parseFormat:function(t){var e=t.replace(this.validParts,"\0").split("\0"),n=t.match(this.validParts);if(!e||!e.length||!n||0===n.length)throw new Error("Invalid date format.");return{separators:e,parts:n}},parseDate:function(i,o,a){function s(){var t=this.slice(0,d[u].length),e=d[u].slice(0,t.length);return t.toLowerCase()===e.toLowerCase()}if(!i)return e;if(i instanceof Date)return i;"string"==typeof o&&(o=g.parseFormat(o));var r,c,u,h=/([\-+]\d+)([dmwy])/,d=i.match(/([\-+]\d+)([dmwy])/g);if(/^[\-+]\d+[dmwy]([\s,]+[\-+]\d+[dmwy])*$/.test(i)){for(i=new Date,u=0;u«»',contTemplate:'',footTemplate:''};g.template='
    '+g.headTemplate+""+g.footTemplate+'
    '+g.headTemplate+g.contTemplate+g.footTemplate+'
    '+g.headTemplate+g.contTemplate+g.footTemplate+"
    ",t.fn.datepicker.DPGlobal=g,t.fn.datepicker.noConflict=function(){return t.fn.datepicker=h,this},t.fn.datepicker.version="1.4.0",t(document).on("focus.datepicker.data-api click.datepicker.data-api",'[data-provide="datepicker"]',function(e){var n=t(this);n.data("datepicker")||(e.preventDefault(),d.call(n,"show"))}),t(function(){d.call(t('[data-provide="datepicker-inline"]'))})}(window.jQuery),!function(t){t.fn.datepicker.dates.de={days:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag","Sonntag"],daysShort:["Son","Mon","Die","Mit","Don","Fre","Sam","Son"],daysMin:["So","Mo","Di","Mi","Do","Fr","Sa","So"],months:["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],monthsShort:["Jan","Feb","Mär","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"],today:"Heute",clear:"Löschen",weekStart:1,format:"dd.mm.yyyy"}}(jQuery),!function(t){t.fn.datepicker.dates.da={days:["Søndag","Mandag","Tirsdag","Onsdag","Torsdag","Fredag","Lørdag","Søndag"],daysShort:["Søn","Man","Tir","Ons","Tor","Fre","Lør","Søn"],daysMin:["Sø","Ma","Ti","On","To","Fr","Lø","Sø"],months:["Januar","Februar","Marts","April","Maj","Juni","Juli","August","September","Oktober","November","December"],monthsShort:["Jan","Feb","Mar","Apr","Maj","Jun","Jul","Aug","Sep","Okt","Nov","Dec"],today:"I Dag",clear:"Nulstil"}}(jQuery),!function(t){t.fn.datepicker.dates["pt-BR"]={days:["Domingo","Segunda","Terça","Quarta","Quinta","Sexta","Sábado","Domingo"],daysShort:["Dom","Seg","Ter","Qua","Qui","Sex","Sáb","Dom"],daysMin:["Do","Se","Te","Qu","Qu","Se","Sa","Do"],months:["Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"],monthsShort:["Jan","Fev","Mar","Abr","Mai","Jun","Jul","Ago","Set","Out","Nov","Dez"],today:"Hoje",clear:"Limpar"}}(jQuery),!function(t){t.fn.datepicker.dates.nl={days:["zondag","maandag","dinsdag","woensdag","donderdag","vrijdag","zaterdag","zondag"],daysShort:["zo","ma","di","wo","do","vr","za","zo"],daysMin:["zo","ma","di","wo","do","vr","za","zo"],months:["januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december"],monthsShort:["jan","feb","mrt","apr","mei","jun","jul","aug","sep","okt","nov","dec"],today:"Vandaag",clear:"Wissen",weekStart:1,format:"dd-mm-yyyy"}}(jQuery),!function(t){t.fn.datepicker.dates.fr={days:["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi","dimanche"],daysShort:["dim.","lun.","mar.","mer.","jeu.","ven.","sam.","dim."],daysMin:["d","l","ma","me","j","v","s","d"],months:["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"],monthsShort:["janv.","févr.","mars","avril","mai","juin","juil.","août","sept.","oct.","nov.","déc."],today:"Aujourd'hui",clear:"Effacer",weekStart:1,format:"dd/mm/yyyy"}}(jQuery),!function(t){t.fn.datepicker.dates.it={days:["Domenica","Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato","Domenica"],daysShort:["Dom","Lun","Mar","Mer","Gio","Ven","Sab","Dom"],daysMin:["Do","Lu","Ma","Me","Gi","Ve","Sa","Do"],months:["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"],monthsShort:["Gen","Feb","Mar","Apr","Mag","Giu","Lug","Ago","Set","Ott","Nov","Dic"],today:"Oggi",clear:"Cancella",weekStart:1,format:"dd/mm/yyyy"}}(jQuery),!function(t){t.fn.datepicker.dates.lt={days:["Sekmadienis","Pirmadienis","Antradienis","Trečiadienis","Ketvirtadienis","Penktadienis","Šeštadienis","Sekmadienis"],daysShort:["S","Pr","A","T","K","Pn","Š","S"],daysMin:["Sk","Pr","An","Tr","Ke","Pn","Št","Sk"],months:["Sausis","Vasaris","Kovas","Balandis","Gegužė","Birželis","Liepa","Rugpjūtis","Rugsėjis","Spalis","Lapkritis","Gruodis"],monthsShort:["Sau","Vas","Kov","Bal","Geg","Bir","Lie","Rugp","Rugs","Spa","Lap","Gru"],today:"Šiandien",weekStart:1}}(jQuery),!function(t){t.fn.datepicker.dates.no={days:["Søndag","Mandag","Tirsdag","Onsdag","Torsdag","Fredag","Lørdag"],daysShort:["Søn","Man","Tir","Ons","Tor","Fre","Lør"],daysMin:["Sø","Ma","Ti","On","To","Fr","Lø"],months:["Januar","Februar","Mars","April","Mai","Juni","Juli","August","September","Oktober","November","Desember"],monthsShort:["Jan","Feb","Mar","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Des"],today:"I dag",clear:"Nullstill",weekStart:1,format:"dd.mm.yyyy"}}(jQuery),!function(t){t.fn.datepicker.dates.es={days:["Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado","Domingo"],daysShort:["Dom","Lun","Mar","Mié","Jue","Vie","Sáb","Dom"],daysMin:["Do","Lu","Ma","Mi","Ju","Vi","Sa","Do"],months:["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],monthsShort:["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],today:"Hoy",clear:"Borrar",weekStart:1,format:"dd/mm/yyyy"}}(jQuery),!function(t){t.fn.datepicker.dates.sv={days:["Söndag","Måndag","Tisdag","Onsdag","Torsdag","Fredag","Lördag","Söndag"],daysShort:["Sön","Mån","Tis","Ons","Tor","Fre","Lör","Sön"],daysMin:["Sö","Må","Ti","On","To","Fr","Lö","Sö"],months:["Januari","Februari","Mars","April","Maj","Juni","Juli","Augusti","September","Oktober","November","December"],monthsShort:["Jan","Feb","Mar","Apr","Maj","Jun","Jul","Aug","Sep","Okt","Nov","Dec"],today:"Idag",format:"yyyy-mm-dd",weekStart:1,clear:"Rensa"}}(jQuery),function(){var t,e,n,i,o,a,s,r,c=[].slice,l={}.hasOwnProperty,u=function(t,e){function n(){this.constructor=t}for(var i in e)l.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};s=function(){},e=function(){function t(){}return t.prototype.addEventListener=t.prototype.on,t.prototype.on=function(t,e){return this._callbacks=this._callbacks||{},this._callbacks[t]||(this._callbacks[t]=[]),this._callbacks[t].push(e),this},t.prototype.emit=function(){var t,e,n,i,o,a;if(i=arguments[0],t=2<=arguments.length?c.call(arguments,1):[],this._callbacks=this._callbacks||{},n=this._callbacks[i])for(o=0,a=n.length;o
    '),this.element.appendChild(e)),i=e.getElementsByTagName("span")[0],i&&(null!=i.textContent?i.textContent=this.options.dictFallbackMessage:null!=i.innerText&&(i.innerText=this.options.dictFallbackMessage)),this.element.appendChild(this.getFallbackForm())},resize:function(t){var e,n,i;return e={srcX:0,srcY:0,srcWidth:t.width,srcHeight:t.height},n=t.width/t.height,e.optWidth=this.options.thumbnailWidth,e.optHeight=this.options.thumbnailHeight,null==e.optWidth&&null==e.optHeight?(e.optWidth=e.srcWidth,e.optHeight=e.srcHeight):null==e.optWidth?e.optWidth=n*e.optHeight:null==e.optHeight&&(e.optHeight=1/n*e.optWidth),i=e.optWidth/e.optHeight,t.heighti?(e.srcHeight=t.height,e.srcWidth=e.srcHeight*i):(e.srcWidth=t.width,e.srcHeight=e.srcWidth/i),e.srcX=(t.width-e.srcWidth)/2,e.srcY=(t.height-e.srcHeight)/2,e},drop:function(t){return this.element.classList.remove("dz-drag-hover")},dragstart:s,dragend:function(t){return this.element.classList.remove("dz-drag-hover")},dragenter:function(t){return this.element.classList.add("dz-drag-hover")},dragover:function(t){return this.element.classList.add("dz-drag-hover")},dragleave:function(t){return this.element.classList.remove("dz-drag-hover")},paste:s,reset:function(){return this.element.classList.remove("dz-started")},addedfile:function(t){var e,i,o,a,s,r,c,l,u,h,d,p,f;if(this.element===this.previewsContainer&&this.element.classList.add("dz-started"),this.previewsContainer){for(t.previewElement=n.createElement(this.options.previewTemplate.trim()),t.previewTemplate=t.previewElement,this.previewsContainer.appendChild(t.previewElement),h=t.previewElement.querySelectorAll("[data-dz-name]"),a=0,c=h.length;a'+this.options.dictRemoveFile+""),t.previewElement.appendChild(t._removeLink)),i=function(e){return function(i){return i.preventDefault(),i.stopPropagation(),t.status===n.UPLOADING?n.confirm(e.options.dictCancelUploadConfirmation,function(){return e.removeFile(t)}):e.options.dictRemoveFileConfirmation?n.confirm(e.options.dictRemoveFileConfirmation,function(){return e.removeFile(t)}):e.removeFile(t)}}(this),p=t.previewElement.querySelectorAll("[data-dz-remove]"),f=[],r=0,u=p.length;r\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n Check\n \n \n \n \n \n
    \n
    \n \n Error\n \n \n \n \n \n \n \n
    \n'},i=function(){var t,e,n,i,o,a,s;for(i=arguments[0],n=2<=arguments.length?c.call(arguments,1):[],a=0,s=n.length;a'+this.options.dictDefaultMessage+"")),this.clickableElements.length&&(i=function(t){return function(){return t.hiddenFileInput&&t.hiddenFileInput.parentNode.removeChild(t.hiddenFileInput),t.hiddenFileInput=document.createElement("input"),t.hiddenFileInput.setAttribute("type","file"),(null==t.options.maxFiles||t.options.maxFiles>1)&&t.hiddenFileInput.setAttribute("multiple","multiple"),t.hiddenFileInput.className="dz-hidden-input",null!=t.options.acceptedFiles&&t.hiddenFileInput.setAttribute("accept",t.options.acceptedFiles),null!=t.options.capture&&t.hiddenFileInput.setAttribute("capture",t.options.capture),t.hiddenFileInput.style.visibility="hidden",t.hiddenFileInput.style.position="absolute",t.hiddenFileInput.style.top="0",t.hiddenFileInput.style.left="0",t.hiddenFileInput.style.height="0",t.hiddenFileInput.style.width="0",document.querySelector(t.options.hiddenInputContainer).appendChild(t.hiddenFileInput),t.hiddenFileInput.addEventListener("change",function(){var e,n,o,a;if(n=t.hiddenFileInput.files,n.length)for(o=0,a=n.length;o',this.options.dictFallbackText&&(i+="

    "+this.options.dictFallbackText+"

    "),i+='',e=n.createElement(i),"FORM"!==this.element.tagName?(o=n.createElement('
    '),o.appendChild(e)):(this.element.setAttribute("enctype","multipart/form-data"),this.element.setAttribute("method",this.options.method)),null!=o?o:e)},n.prototype.getExistingFallback=function(){var t,e,n,i,o,a;for(e=function(t){var e,n,i;for(n=0,i=t.length;n0){for(s=["TB","GB","MB","KB","b"],n=r=0,c=s.length;r=e){i=t/Math.pow(this.options.filesizeBase,4-n),o=a;break}i=Math.round(10*i)/10}return""+i+" "+o},n.prototype._updateMaxFilesReachedClass=function(){return null!=this.options.maxFiles&&this.getAcceptedFiles().length>=this.options.maxFiles?(this.getAcceptedFiles().length===this.options.maxFiles&&this.emit("maxfilesreached",this.files),this.element.classList.add("dz-max-files-reached")):this.element.classList.remove("dz-max-files-reached")},n.prototype.drop=function(t){var e,n;t.dataTransfer&&(this.emit("drop",t),e=t.dataTransfer.files,this.emit("addedfiles",e),e.length&&(n=t.dataTransfer.items,n&&n.length&&null!=n[0].webkitGetAsEntry?this._addFilesFromItems(n):this.handleFiles(e)))},n.prototype.paste=function(t){var e,n;if(null!=(null!=t&&null!=(n=t.clipboardData)?n.items:void 0))return this.emit("paste",t),e=t.clipboardData.items,e.length?this._addFilesFromItems(e):void 0},n.prototype.handleFiles=function(t){var e,n,i,o;for(o=[],n=0,i=t.length;n0){for(a=0,s=n.length;a1024*this.options.maxFilesize*1024?e(this.options.dictFileTooBig.replace("{{filesize}}",Math.round(t.size/1024/10.24)/100).replace("{{maxFilesize}}",this.options.maxFilesize)):n.isValidFile(t,this.options.acceptedFiles)?null!=this.options.maxFiles&&this.getAcceptedFiles().length>=this.options.maxFiles?(e(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}",this.options.maxFiles)),this.emit("maxfilesexceeded",t)):this.options.accept.call(this,t,e):e(this.options.dictInvalidFileType)},n.prototype.addFile=function(t){return t.upload={progress:0,total:t.size,bytesSent:0},this.files.push(t),t.status=n.ADDED,this.emit("addedfile",t),this._enqueueThumbnail(t),this.accept(t,function(e){return function(n){return n?(t.accepted=!1,e._errorProcessing([t],n)):(t.accepted=!0,e.options.autoQueue&&e.enqueueFile(t)),e._updateMaxFilesReachedClass()}}(this))},n.prototype.enqueueFiles=function(t){var e,n,i;for(n=0,i=t.length;n=e)&&(i=this.getQueuedFiles(),i.length>0)){if(this.options.uploadMultiple)return this.processFiles(i.slice(0,e-n));for(;t=B;u=0<=B?++L:--L)a.append(this._getParamName(u),t[u],this._renameFilename(t[u].name));return this.submitRequest(z,a,t)},n.prototype.submitRequest=function(t,e,n){return t.send(e)},n.prototype._finished=function(t,e,i){var o,a,s;for(a=0,s=t.length;au;)e=o[4*(c-1)+3],0===e?a=c:u=c,c=a+u>>1;return l=c/s,0===l?1:l},a=function(t,e,n,i,a,s,r,c,l,u){var h;return h=o(e),t.drawImage(e,n,i,a,s,r,c,l,u/h)},i=function(t,e){var n,i,o,a,s,r,c,l,u;if(o=!1,u=!0,i=t.document,l=i.documentElement,n=i.addEventListener?"addEventListener":"attachEvent",c=i.addEventListener?"removeEventListener":"detachEvent",r=i.addEventListener?"":"on",a=function(n){if("readystatechange"!==n.type||"complete"===i.readyState)return("load"===n.type?t:i)[c](r+n.type,a,!1),!o&&(o=!0)?e.call(t,n.type||n):void 0},s=function(){var t;try{l.doScroll("left")}catch(e){return t=e,void setTimeout(s,50)}return a("poll")},"complete"!==i.readyState){if(i.createEventObject&&l.doScroll){try{u=!t.frameElement}catch(h){}u&&s()}return i[n](r+"DOMContentLoaded",a,!1),i[n](r+"readystatechange",a,!1),t[n](r+"load",a,!1)}},t._autoDiscoverFunction=function(){if(t.autoDiscover)return t.discover()},i(window,t._autoDiscoverFunction)}.call(this),function(t,e){"function"==typeof define&&define.amd?define("typeahead.js",["jquery"],function(t){return e(t)}):"object"==typeof exports?module.exports=e(require("jquery")):e(jQuery)}(this,function(t){var e=function(){"use strict";return{isMsie:function(){return!!/(msie|trident)/i.test(navigator.userAgent)&&navigator.userAgent.match(/(msie |rv:)(\d+(.\d+)?)/i)[2]},isBlankString:function(t){return!t||/^\s*$/.test(t)},escapeRegExChars:function(t){return t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isArray:t.isArray,isFunction:t.isFunction,isObject:t.isPlainObject,isUndefined:function(t){return"undefined"==typeof t},isElement:function(t){return!(!t||1!==t.nodeType)},isJQuery:function(e){return e instanceof t},toStr:function(t){return e.isUndefined(t)||null===t?"":t+""},bind:t.proxy,each:function(e,n){function i(t,e){return n(e,t)}t.each(e,i)},map:t.map,filter:t.grep,every:function(e,n){var i=!0;return e?(t.each(e,function(t,o){if(!(i=n.call(null,o,t,e)))return!1}),!!i):i},some:function(e,n){var i=!1;return e?(t.each(e,function(t,o){if(i=n.call(null,o,t,e))return!1}),!!i):i},mixin:t.extend,identity:function(t){return t},clone:function(e){return t.extend(!0,{},e)},getIdGenerator:function(){var t=0;return function(){return t++}},templatify:function(e){function n(){return String(e)}return t.isFunction(e)?e:n},defer:function(t){setTimeout(t,0)},debounce:function(t,e,n){var i,o;return function(){var a,s,r=this,c=arguments;return a=function(){i=null,n||(o=t.apply(r,c))},s=n&&!i,clearTimeout(i),i=setTimeout(a,e),s&&(o=t.apply(r,c)),o}},throttle:function(t,e){var n,i,o,a,s,r;return s=0,r=function(){s=new Date,o=null,a=t.apply(n,i)},function(){var c=new Date,l=e-(c-s);return n=this,i=arguments,l<=0?(clearTimeout(o),o=null,s=c,a=t.apply(n,i)):o||(o=setTimeout(r,l)),a}},stringify:function(t){return e.isString(t)?t:JSON.stringify(t)},noop:function(){}}}(),n=function(){"use strict";function t(t){var s,r;return r=e.mixin({},a,t),s={css:o(),classes:r,html:n(r),selectors:i(r)},{css:s.css,html:s.html,classes:s.classes,selectors:s.selectors,mixin:function(t){e.mixin(t,s)}}}function n(t){return{wrapper:'',menu:'
    '}}function i(t){var n={};return e.each(t,function(t,e){n[e]="."+t}),n}function o(){var t={wrapper:{position:"relative",display:"inline-block"},hint:{position:"absolute",top:"0",left:"0",borderColor:"transparent",boxShadow:"none",opacity:"1"},input:{position:"relative",verticalAlign:"top",backgroundColor:"transparent"},inputWithNoHint:{position:"relative",verticalAlign:"top"},menu:{position:"absolute",top:"100%",left:"0",zIndex:"100",display:"none"},ltr:{left:"0",right:"auto"},rtl:{left:"auto",right:" 0"}};return e.isMsie()&&e.mixin(t.input,{backgroundImage:"url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)"}),t}var a={wrapper:"twitter-typeahead",input:"tt-input",hint:"tt-hint",menu:"tt-menu",dataset:"tt-dataset",suggestion:"tt-suggestion",selectable:"tt-selectable",empty:"tt-empty",open:"tt-open",cursor:"tt-cursor",highlight:"tt-highlight"};return t}(),i=function(){"use strict";function n(e){e&&e.el||t.error("EventBus initialized without el"),this.$el=t(e.el)}var i,o;return i="typeahead:",o={render:"rendered",cursorchange:"cursorchanged",select:"selected",autocomplete:"autocompleted"},e.mixin(n.prototype,{_trigger:function(e,n){var o;return o=t.Event(i+e),(n=n||[]).unshift(o),this.$el.trigger.apply(this.$el,n),o},before:function(t){var e,n;return e=[].slice.call(arguments,1),n=this._trigger("before"+t,e),n.isDefaultPrevented()},trigger:function(t){var e;this._trigger(t,[].slice.call(arguments,1)),(e=o[t])&&this._trigger(e,[].slice.call(arguments,1))}}),n}(),o=function(){"use strict";function t(t,e,n,i){var o;if(!n)return this;for(e=e.split(c),n=i?r(n,i):n,this._callbacks=this._callbacks||{};o=e.shift();)this._callbacks[o]=this._callbacks[o]||{sync:[],async:[]},this._callbacks[o][t].push(n);return this}function e(e,n,i){return t.call(this,"async",e,n,i)}function n(e,n,i){return t.call(this,"sync",e,n,i)}function i(t){var e;if(!this._callbacks)return this;for(t=t.split(c);e=t.shift();)delete this._callbacks[e];return this}function o(t){var e,n,i,o,s;if(!this._callbacks)return this;for(t=t.split(c),i=[].slice.call(arguments,1);(e=t.shift())&&(n=this._callbacks[e]);)o=a(n.sync,this,[e].concat(i)),s=a(n.async,this,[e].concat(i)),o()&&l(s);return this}function a(t,e,n){function i(){for(var i,o=0,a=t.length;!i&&o