diff --git a/Gruntfile.js b/Gruntfile.js index 7b687181b2..9fec5aee6c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -31,8 +31,7 @@ module.exports = function(grunt) { 'public/vendor/spectrum/spectrum.js', 'public/js/bootstrap-combobox.js', 'public/vendor/jspdf/dist/jspdf.min.js', - //'public/js/jspdf.source.js', - //'public/js/jspdf.plugin.split_text_to_size.js', + 'public/vendor/lightbox2/js/lightbox.min.js', 'public/js/script.js', ], dest: 'public/built.js', @@ -58,6 +57,7 @@ module.exports = function(grunt) { 'public/vendor/spectrum/spectrum.css', 'public/css/bootstrap-combobox.css', 'public/css/typeahead.js-bootstrap.css', + 'public/vendor/lightbox2/css/lightbox.css', 'public/css/style.css', ], dest: 'public/built.css', diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index 550b60aa1a..37b3b45fee 100755 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -272,7 +272,7 @@ class AccountController extends \BaseController { $invoice = new stdClass(); $client = new stdClass(); $invoiceItem = new stdClass(); - + $client->name = 'Sample Client'; $client->address1 = ''; $client->city = ''; @@ -280,10 +280,10 @@ class AccountController extends \BaseController { $client->postal_code = ''; $client->work_phone = ''; $client->work_email = ''; - + $invoice->invoice_number = Auth::user()->account->getNextInvoiceNumber(); $invoice->invoice_date = date_create()->format('Y-m-d'); - $invoice->account = Auth::user()->account; + $invoice->account = json_decode(Auth::user()->account->toJson()); $invoice->amount = $invoice->balance = 100; $invoiceItem->cost = 100; @@ -295,7 +295,7 @@ class AccountController extends \BaseController { $invoice->invoice_items = [$invoiceItem]; $data['invoice'] = $invoice; - $data['invoiceDesigns'] = InvoiceDesign::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(); + $data['invoiceDesigns'] = InvoiceDesign::remember(DEFAULT_QUERY_CACHE, 'invoice_designs_cache')->where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get(); } return View::make("accounts.{$subSection}", $data); diff --git a/app/controllers/InvoiceController.php b/app/controllers/InvoiceController.php index 197db91f41..fda9f643b8 100755 --- a/app/controllers/InvoiceController.php +++ b/app/controllers/InvoiceController.php @@ -243,7 +243,7 @@ class InvoiceController extends \BaseController { 'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'paymentTerms' => PaymentTerm::remember(DEFAULT_QUERY_CACHE)->orderBy('num_days')->get(['name', 'num_days']), 'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), - 'invoiceDesigns' => InvoiceDesign::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), + 'invoiceDesigns' => InvoiceDesign::remember(DEFAULT_QUERY_CACHE, 'invoice_designs_cache')->where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get(), 'frequencies' => array( 1 => 'Weekly', 2 => 'Two weeks', diff --git a/app/controllers/PaymentController.php b/app/controllers/PaymentController.php index 1bf0f3c15a..1e0e9f734c 100755 --- a/app/controllers/PaymentController.php +++ b/app/controllers/PaymentController.php @@ -19,16 +19,16 @@ class PaymentController extends \BaseController $this->contactMailer = $contactMailer; } - public function index() - { + public function index() + { return View::make('list', array( 'entityType'=>ENTITY_PAYMENT, 'title' => trans('texts.payments'), 'columns'=>Utils::trans(['checkbox', 'invoice', 'client', 'transaction_reference', 'method', 'payment_amount', 'payment_date', 'action']) )); - } + } - public function getDatatable($clientPublicId = null) + public function getDatatable($clientPublicId = null) { $payments = $this->paymentRepo->find($clientPublicId, Input::get('sSearch')); $table = Datatable::query($payments); @@ -47,7 +47,7 @@ class PaymentController extends \BaseController ->addColumn('payment_type', function($model) { return $model->payment_type ? $model->payment_type : ($model->account_gateway_id ? 'Online payment' : ''); }); return $table->addColumn('amount', function($model) { return Utils::formatMoney($model->amount, $model->currency_id); }) - ->addColumn('payment_date', function($model) { return Utils::dateToString($model->payment_date); }) + ->addColumn('payment_date', function($model) { return Utils::dateToString($model->payment_date); }) ->addColumn('dropdown', function($model) { return ''; }) - ->make(); + ->make(); } @@ -132,13 +132,13 @@ class PaymentController extends \BaseController return $gateway; } - private function getLicensePaymentDetails($input) + private function getLicensePaymentDetails($input, $affiliate) { $data = self::convertInputForOmnipay($input); $card = new CreditCard($data); return [ - 'amount' => LICENSE_PRICE, + 'amount' => $affiliate->price, 'card' => $card, 'currency' => 'USD', 'returnUrl' => URL::to('license_complete'), @@ -172,7 +172,7 @@ class PaymentController extends \BaseController private function getPaymentDetails($invoice, $input = null) { $key = $invoice->invoice_number . '_details'; - $gateway = $invoice->client->account->account_gateways[0]->gateway; + $gateway = $invoice->client->account->account_gateways[0]->gateway; $paymentLibrary = $gateway->paymentlibrary; if ($input && $paymentLibrary->id == PAYMENT_LIBRARY_OMNIPAY) @@ -181,9 +181,9 @@ class PaymentController extends \BaseController Session::put($key, $data); } - else if ($input && $paymentLibrary->id == PAYMENT_LIBRARY_PHP_PAYMENTS) + else if ($input && $paymentLibrary->id == PAYMENT_LIBRARY_PHP_PAYMENTS) { - $input = Input::all(); + $input = Input::all(); $data = [ 'first_name' => $input['first_name'], 'last_name' => $input['last_name'], @@ -200,29 +200,29 @@ class PaymentController extends \BaseController 'ship_to_city' => $input['city'], 'ship_to_state' => $input['state'], 'ship_to_postal_code' => $input['postal_code'], - 'currency_code' => $invoice->client->currency->code, + 'currency_code' => $invoice->client->currency->code, ]; - - switch($gateway->id) - { - case GATEWAY_BEANSTREAM: - $data['phone'] = $input['phone']; - $data['email'] = $input['email']; - $data['country'] = $input['country']; - $data['ship_to_country'] = $input['country']; - break; - case GATEWAY_BRAINTREE: - $data['ship_to_state'] = 'Ohio'; //$input['state']; - break; - } - - if(strlen($data['cc_exp']) == 5) - { - $data['cc_exp'] = '0'.$data['cc_exp']; - } + + switch($gateway->id) + { + case GATEWAY_BEANSTREAM: + $data['phone'] = $input['phone']; + $data['email'] = $input['email']; + $data['country'] = $input['country']; + $data['ship_to_country'] = $input['country']; + break; + case GATEWAY_BRAINTREE: + $data['ship_to_state'] = 'Ohio'; //$input['state']; + break; + } + + if(strlen($data['cc_exp']) == 5) + { + $data['cc_exp'] = '0'.$data['cc_exp']; + } Session::put($key, $data); - return $data; + return $data; } else if (Session::get($key)) { @@ -233,22 +233,22 @@ class PaymentController extends \BaseController $data = []; } - if($paymentLibrary->id == PAYMENT_LIBRARY_OMNIPAY) - { - $card = new CreditCard($data); - - return [ - 'amount' => $invoice->amount, - 'card' => $card, - 'currency' => $invoice->client->currency->code, - 'returnUrl' => URL::to('complete'), - 'cancelUrl' => URL::to('/') - ]; - } - else - { - return $data; - } + if($paymentLibrary->id == PAYMENT_LIBRARY_OMNIPAY) + { + $card = new CreditCard($data); + + return [ + 'amount' => $invoice->amount, + 'card' => $card, + 'currency' => $invoice->client->currency->code, + 'returnUrl' => URL::to('complete'), + 'cancelUrl' => URL::to('/') + ]; + } + else + { + return $data; + } } public function show_payment($invitationKey) @@ -306,16 +306,18 @@ class PaymentController extends \BaseController { if ($affiliate = Affiliate::where('affiliate_key', '=', Input::get('affiliate_key'))->first()) { - Session::set('affiliate_id', $affiliate->id); + Session::set('affiliate_id', $affiliate->id); } } + Session::set('product_id', Input::get('product_id', PRODUCT_ONE_CLICK_INSTALL)); + if (!Session::get('affiliate_id')) { return Utils::fatalError(); } - if (Input::has('test_mode')) + if (Utils::isNinjaDev() && Input::has('test_mode')) { Session::set('test_mode', Input::get('test_mode')); } @@ -334,7 +336,7 @@ class PaymentController extends \BaseController 'showBreadcrumbs' => false, 'hideHeader' => true, 'url' => 'license', - 'amount' => LICENSE_PRICE, + 'amount' => $affiliate->price, 'client' => false, 'contact' => false, 'paymentLibrary' => $paymentLibrary, @@ -380,6 +382,8 @@ class PaymentController extends \BaseController try { + $affiliate = Affiliate::find(Session::get('affiliate_id')); + if ($testMode) { $ref = 'TEST_MODE'; @@ -387,7 +391,7 @@ class PaymentController extends \BaseController else { $gateway = self::createGateway($accountGateway); - $details = self::getLicensePaymentDetails(Input::all()); + $details = self::getLicensePaymentDetails(Input::all(), $affiliate); $response = $gateway->purchase($details)->send(); $ref = $response->getTransactionReference(); @@ -415,10 +419,9 @@ class PaymentController extends \BaseController $license->transaction_reference = $ref; $license->license_key = $licenseKey; $license->affiliate_id = Session::get('affiliate_id'); + $license->product_id = Session::get('product_id'); $license->save(); - $affiliate = Affiliate::find(Session::get('affiliate_id')); - $data = [ 'message' => $affiliate->payment_subtitle, 'license' => $licenseKey, @@ -426,11 +429,16 @@ class PaymentController extends \BaseController ]; $name = "{$license->first_name} {$license->last_name}"; - $this->contactMailer->sendLicensePaymentConfirmation($name, $license->email, LICENSE_PRICE, $license->license_key); + $this->contactMailer->sendLicensePaymentConfirmation($name, $license->email, $affiliate->price, $license->license_key, $license->product_id); - return View::make('public.license', $data); - - //return Redirect::away(Session::get('return_url') . "?license_key={$license->license_key}"); + if (Session::has('return_url')) + { + return Redirect::away(Session::get('return_url') . "?license_key={$license->license_key}&product_id=" . Session::get('product_id')); + } + else + { + return View::make('public.license', $data); + } } catch (\Exception $e) { @@ -443,8 +451,13 @@ class PaymentController extends \BaseController public function claim_license() { - $license = License::where('license_key', '=', Input::get('license_key')) - ->where('is_claimed', '=', false)->first(); + $licenseKey = Input::get('license_key'); + $productId = Input::get('product_id', PRODUCT_ONE_CLICK_INSTALL); + + $license = License::where('license_key', '=', $licenseKey) + ->where('is_claimed', '=', false) + ->where('product_id', '=', $productId) + ->first(); if ($license) { @@ -454,7 +467,7 @@ class PaymentController extends \BaseController $license->save(); } - return 'valid'; + return $productId == PRODUCT_ONE_CLICK_INSTALL ? 'valid' : $_ENV['INVOICE_DESIGNS']; } else { @@ -503,84 +516,84 @@ class PaymentController extends \BaseController $client->postal_code = trim(Input::get('postal_code')); $client->save(); } - + try { - if($paymentLibrary->id == PAYMENT_LIBRARY_OMNIPAY) - { - $gateway = self::createGateway($accountGateway); - $details = self::getPaymentDetails($invoice, Input::all()); - $response = $gateway->purchase($details)->send(); - $ref = $response->getTransactionReference(); - - if (!$ref) - { - Session::flash('error', $response->getMessage()); - return Redirect::to('payment/' . $invitationKey) - ->withInput(); - } + if($paymentLibrary->id == PAYMENT_LIBRARY_OMNIPAY) + { + $gateway = self::createGateway($accountGateway); + $details = self::getPaymentDetails($invoice, Input::all()); + $response = $gateway->purchase($details)->send(); + $ref = $response->getTransactionReference(); + + if (!$ref) + { + Session::flash('error', $response->getMessage()); + return Redirect::to('payment/' . $invitationKey) + ->withInput(); + } - if ($response->isSuccessful()) - { - $payment = self::createPayment($invitation, $ref); - - Session::flash('message', trans('texts.applied_payment')); - return Redirect::to('view/' . $payment->invitation->invitation_key); - } - else if ($response->isRedirect()) - { - $invitation->transaction_reference = $ref; - $invitation->save(); - - $response->redirect(); - } - else - { - Session::flash('error', $response->getMessage()); - return Utils::fatalError('Sorry, there was an error processing your payment. Please try again later.

', $response->getMessage()); - } + if ($response->isSuccessful()) + { + $payment = self::createPayment($invitation, $ref); + + Session::flash('message', trans('texts.applied_payment')); + return Redirect::to('view/' . $payment->invitation->invitation_key); + } + else if ($response->isRedirect()) + { + $invitation->transaction_reference = $ref; + $invitation->save(); + + $response->redirect(); + } + else + { + Session::flash('error', $response->getMessage()); + return Utils::fatalError('Sorry, there was an error processing your payment. Please try again later.

', $response->getMessage()); + } } - else if ($paymentLibrary->id == PAYMENT_LIBRARY_PHP_PAYMENTS) - { - $gateway = $accountGateway->gateway; - $provider = $gateway->provider; - $p = new PHP_Payments(array('mode' => 'test')); - - $config = Payment_Utility::load('config', 'drivers/'.$provider); - - switch($gateway->id) - { - case GATEWAY_BEANSTREAM: - $config['delay_charge'] = FALSE; - $config['bill_outstanding'] = TRUE; - break; - case GATEWAY_AMAZON: - $config['return_url'] = URL::to('complete'); - $config['abandon_url'] = URL::to('/'); - $config['immediate_return'] = 0; - $config['process_immediate'] = 1; - $config['ipn_url'] = URL::to('ipn'); - $config['collect_shipping_address'] = false; - break; - } - - $details = self::getPaymentDetails($invoice, Input::all()); - - $response = $p->oneoff_payment($provider, $details, $config); + else if ($paymentLibrary->id == PAYMENT_LIBRARY_PHP_PAYMENTS) + { + $gateway = $accountGateway->gateway; + $provider = $gateway->provider; + $p = new PHP_Payments(array('mode' => 'test')); + + $config = Payment_Utility::load('config', 'drivers/'.$provider); + + switch($gateway->id) + { + case GATEWAY_BEANSTREAM: + $config['delay_charge'] = FALSE; + $config['bill_outstanding'] = TRUE; + break; + case GATEWAY_AMAZON: + $config['return_url'] = URL::to('complete'); + $config['abandon_url'] = URL::to('/'); + $config['immediate_return'] = 0; + $config['process_immediate'] = 1; + $config['ipn_url'] = URL::to('ipn'); + $config['collect_shipping_address'] = false; + break; + } + + $details = self::getPaymentDetails($invoice, Input::all()); + + $response = $p->oneoff_payment($provider, $details, $config); - if (strtolower($response->status) == 'success') - { - $payment = self::createPayment($invitation, $response->response_message); - - Session::flash('message', trans('texts.applied_payment')); - return Redirect::to('view/' . $payment->invitation->invitation_key); - } - else - { - Session::flash('error', $response->response_message); - return Utils::fatalError('Sorry, there was an error processing your payment. Please try again later.

', $response->response_message); - } - } + if (strtolower($response->status) == 'success') + { + $payment = self::createPayment($invitation, $response->response_message); + + Session::flash('message', trans('texts.applied_payment')); + return Redirect::to('view/' . $payment->invitation->invitation_key); + } + else + { + Session::flash('error', $response->response_message); + return Utils::fatalError('Sorry, there was an error processing your payment. Please try again later.

', $response->response_message); + } + } } catch (\Exception $e) { @@ -715,4 +728,4 @@ class PaymentController extends \BaseController return Redirect::to('payments'); } -} +} \ No newline at end of file diff --git a/app/controllers/QuoteController.php b/app/controllers/QuoteController.php index 683cc0bf00..497e7cc74a 100644 --- a/app/controllers/QuoteController.php +++ b/app/controllers/QuoteController.php @@ -95,7 +95,7 @@ class QuoteController extends \BaseController { 'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'paymentTerms' => PaymentTerm::remember(DEFAULT_QUERY_CACHE)->orderBy('num_days')->get(['name', 'num_days']), 'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), - 'invoiceDesigns' => InvoiceDesign::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), + 'invoiceDesigns' => InvoiceDesign::remember(DEFAULT_QUERY_CACHE, 'invoice_designs_cache')->where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get(), 'invoiceLabels' => Auth::user()->account->getInvoiceLabels() ]; } diff --git a/app/database/migrations/2014_10_22_174452_add_affiliate_price.php b/app/database/migrations/2014_10_22_174452_add_affiliate_price.php new file mode 100644 index 0000000000..305ad1f421 --- /dev/null +++ b/app/database/migrations/2014_10_22_174452_add_affiliate_price.php @@ -0,0 +1,44 @@ +decimal('price', 7, 2)->nullable(); + }); + + Schema::table('licenses', function($table) + { + $table->unsignedInteger('product_id')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('affiliates', function($table) + { + $table->dropColumn('price'); + }); + + Schema::table('licenses', function($table) + { + $table->dropColumn('product_id'); + }); + } + +} diff --git a/app/filters.php b/app/filters.php index 9c252974fa..dd667f9600 100755 --- a/app/filters.php +++ b/app/filters.php @@ -77,6 +77,34 @@ App::before(function($request) $locale = Session::get(SESSION_LOCALE, DEFAULT_LOCALE); App::setLocale($locale); } + + $claimingLicense = Utils::startsWith($_SERVER['REQUEST_URI'], '/claim_license'); + if (!$claimingLicense && Input::has('license_key') && Input::has('product_id')) + { + $licenseKey = Input::get('license_key'); + $productId = Input::get('product_id'); + + if ($productId == PRODUCT_INVOICE_DESIGNS) + { + //$data = file_get_contents("http://ninja.dev/claim_license?license_key={$licenseKey}&product_id={$productId}"); + $data = file_get_contents(NINJA_URL . "/claim_license?license_key={$licenseKey}&product_id={$productId}"); + + if ($data = json_decode($data)) + { + foreach ($data as $item) + { + $design = new InvoiceDesign(); + $design->id = $item->id; + $design->name = $item->name; + $design->javascript = $item->javascript; + $design->save(); + } + + Cache::forget('invoice_designs_cache'); + Session::flash('message', trans('texts.bought_designs')); + } + } + } }); diff --git a/app/lang/en/texts.php b/app/lang/en/texts.php index 876457dc22..28228cf0fe 100644 --- a/app/lang/en/texts.php +++ b/app/lang/en/texts.php @@ -449,4 +449,14 @@ return array( 'gateway_help_23' => 'Note: use your secret API key, not your publishable API key.', 'gateway_help_27' => ':link to sign up for TwoCheckout.', + 'more_designs' => 'More designs', + 'more_designs_title' => 'Additional Invoice Designs', + 'more_designs_cloud_header' => 'Go Pro for more invoice designs', + 'more_designs_cloud_text' => '', + 'more_designs_self_host_header' => 'Get 6 more invoice designs for just $20', + 'more_designs_self_host_text' => '', + 'buy' => 'Buy', + 'bought_designs' => 'Successfully added additional invoice designs', + + ); \ No newline at end of file diff --git a/app/models/User.php b/app/models/User.php index 60e7500c9d..d46b7160c5 100755 --- a/app/models/User.php +++ b/app/models/User.php @@ -85,6 +85,11 @@ class User extends ConfideUser implements UserInterface, RemindableInterface return $this->account->id == Utils::getDemoAccountId(); } + public function maxInvoiceDesignId() + { + return $this->isPro() ? 10 : COUNT_FREE_DESIGNS; + } + public function getDisplayName() { if ($this->getFullName()) diff --git a/app/ninja/mailers/ContactMailer.php b/app/ninja/mailers/ContactMailer.php index 271edef7ad..fd9da56aa4 100755 --- a/app/ninja/mailers/ContactMailer.php +++ b/app/ninja/mailers/ContactMailer.php @@ -37,7 +37,7 @@ class ContactMailer extends Mailer { 'contactName' => $invitation->contact->getDisplayName(), 'invoiceAmount' => Utils::formatMoney($invoice->amount, $invoice->client->currency_id), 'emailFooter' => $invoice->account->email_footer, - 'showNinjaFooter' => !$invoice->account->isPro() || !Utils::isNinjaProd() + 'showNinjaFooter' => !$invoice->account->isPro() ]; $fromEmail = $invitation->user->email; @@ -67,25 +67,31 @@ class ContactMailer extends Mailer { 'clientName' => $payment->client->getDisplayName(), 'emailFooter' => $payment->account->email_footer, 'paymentAmount' => Utils::formatMoney($payment->amount, $payment->client->currency_id), - 'showNinjaFooter' => !$payment->account->isPro() || !Utils::isNinjaProd() + 'showNinjaFooter' => !$payment->account->isPro() ]; $user = $payment->invitation->user; $this->sendTo($payment->contact->email, $user->email, $user->getDisplayName(), $subject, $view, $data); } - public function sendLicensePaymentConfirmation($name, $email, $amount, $license) + public function sendLicensePaymentConfirmation($name, $email, $amount, $license, $productId) { $view = 'payment_confirmation'; $subject = trans('texts.payment_subject'); + if ($productId == PRODUCT_ONE_CLICK_INSTALL) { + $message = "Softaculous install license: $license"; + } else if ($productId == PRODUCT_INVOICE_DESIGNS) { + $message = "Invoice designs license: $license"; + } + $data = [ 'accountName' => trans('texts.email_from'), 'clientName' => $name, 'emailFooter' => false, 'paymentAmount' => Utils::formatMoney($amount, 1), 'showNinjaFooter' => false, - 'emailMessage' => "Your license: $license", + 'emailMessage' => $message, ]; $this->sendTo($email, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data); diff --git a/app/routes.php b/app/routes.php index f41f95a687..5cab648897 100755 --- a/app/routes.php +++ b/app/routes.php @@ -13,7 +13,7 @@ */ //apc_clear_cache(); -//Cache::flush(); +Cache::flush(); //dd(DB::getQueryLog()); //dd(Client::getPrivateId(1)); @@ -248,8 +248,11 @@ define('NINJA_URL', 'https://www.invoiceninja.com'); define('NINJA_VERSION', '1.4.0'); define('RELEASES_URL', 'https://github.com/hillelcoren/invoice-ninja/releases/'); +define('COUNT_FREE_DESIGNS', 4); define('PRO_PLAN_PRICE', 50); -define('LICENSE_PRICE', 30.00); +define('PRODUCT_ONE_CLICK_INSTALL', 1); +define('PRODUCT_INVOICE_DESIGNS', 2); +define('DESIGNS_AFFILIATE_KEY', 'T3RS74'); define('USER_TYPE_SELF_HOST', 'SELF_HOST'); define('USER_TYPE_CLOUD_HOST', 'CLOUD_HOST'); diff --git a/app/views/accounts/invoice_design.blade.php b/app/views/accounts/invoice_design.blade.php index b004dd7865..de76b6db24 100644 --- a/app/views/accounts/invoice_design.blade.php +++ b/app/views/accounts/invoice_design.blade.php @@ -17,7 +17,13 @@ function getDesignJavascript() { var id = $('#invoice_design_id').val(); - return invoiceDesigns[id-1].javascript; + if (id == '-1') { + showMoreDesigns(); + $('#invoice_design_id').val(1); + return invoiceDesigns[0].javascript; + } else { + return invoiceDesigns[id-1].javascript; + } } function getPDFString() { @@ -64,8 +70,15 @@ {{ Former::populateField('hide_paid_to_date', intval($account->hide_paid_to_date)) }} {{ Former::legend('invoice_design') }} - {{ Former::select('invoice_design_id')->style('display:inline;width:120px') - ->fromQuery($invoiceDesigns, 'name', 'id') }} + + + @if (InvoiceDesign::count() == COUNT_FREE_DESIGNS) + {{ Former::select('invoice_design_id')->style('display:inline;width:120px')->fromQuery($invoiceDesigns, 'name', 'id')->addOption(trans('texts.more_designs') . '...', '-1') }} + @else + {{ Former::select('invoice_design_id')->style('display:inline;width:120px')->fromQuery($invoiceDesigns, 'name', 'id') }} + @endif + + {{ Former::text('primary_color') }} {{ Former::text('secondary_color') }} diff --git a/app/views/invoices/edit.blade.php b/app/views/invoices/edit.blade.php index fea5a414b4..fa51355c6c 100755 --- a/app/views/invoices/edit.blade.php +++ b/app/views/invoices/edit.blade.php @@ -265,11 +265,12 @@ + @if (InvoiceDesign::count() == COUNT_FREE_DESIGNS) + {{ Former::select('invoice_design_id')->style('display:inline;width:150px')->raw()->fromQuery($invoiceDesigns, 'name', 'id')->data_bind("value: invoice_design_id")->addOption(trans('texts.more_designs') . '...', '-1') }} + @else + {{ Former::select('invoice_design_id')->style('display:inline;width:150px')->raw()->fromQuery($invoiceDesigns, 'name', 'id')->data_bind("value: invoice_design_id") }} + @endif - {{ Former::select('invoice_design_id')->style('display:inline;width:120px')->raw() - ->fromQuery($invoiceDesigns, 'name', 'id')->data_bind("value: invoice_design_id") }} - - {{ Button::primary(trans('texts.download_pdf'), array('onclick' => 'onDownloadClick()'))->append_with_icon('download-alt'); }} @if (!$invoice || (!$invoice->trashed() && !$invoice->client->trashed())) @@ -646,6 +647,7 @@ function getPDFString() { var invoice = createInvoiceModel(); var design = getDesignJavascript(); + if (!design) return; var doc = generatePDF(invoice, design); if (!doc) return; return doc.output('datauristring'); @@ -653,13 +655,21 @@ function getDesignJavascript() { var id = $('#invoice_design_id').val(); - return invoiceDesigns[id-1].javascript; + if (id == '-1') { + showMoreDesigns(); + $('#invoice_design_id').val(1); + return invoiceDesigns[0].javascript; + } else { + return invoiceDesigns[id-1].javascript; + } } function onDownloadClick() { trackUrl('/download_pdf'); var invoice = createInvoiceModel(); - var doc = generatePDF(invoice, true); + var design = getDesignJavascript(); + if (!design) return; + var doc = generatePDF(invoice, design, true); doc.save('Invoice-' + $('#invoice_number').val() + '.pdf'); } diff --git a/app/views/invoices/pdf.blade.php b/app/views/invoices/pdf.blade.php index d5f8635828..4ab59ba3a3 100644 --- a/app/views/invoices/pdf.blade.php +++ b/app/views/invoices/pdf.blade.php @@ -1,6 +1,54 @@ +

+ + + \ No newline at end of file diff --git a/bower.json b/bower.json index 281fc64a96..b5b19c0677 100644 --- a/bower.json +++ b/bower.json @@ -17,7 +17,8 @@ "typeahead.js": "~0.9.3", "accounting": "~0.*", "spectrum": "~1.3.4", - "d3": "~3.4.11" + "d3": "~3.4.11", + "lightbox2": "~2.7.1" }, "resolutions": { "jquery": "~1.11" diff --git a/public/built.css b/public/built.css index e081951a12..7660eed314 100644 --- a/public/built.css +++ b/public/built.css @@ -1773,6 +1773,217 @@ See http://bgrins.github.io/spectrum/themes/ for instructions. border-radius: 6px; line-height: 1.33; } +/* Preload images */ +body:after { + content: url(images/lightbox/close.png) url(images/lightbox/loading.gif) url(images/lightbox/prev.png) url(images/lightbox/next.png); + display: none; +} + +.lightboxOverlay { + position: absolute; + top: 0; + left: 0; + z-index: 9999; + background-color: black; + filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80); + opacity: 0.8; + display: none; +} + +.lightbox { + position: absolute; + left: 0; + width: 100%; + z-index: 10000; + text-align: center; + line-height: 0; + font-weight: normal; +} + +.lightbox .lb-image { + display: block; + height: auto; + max-width: inherit; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + -ms-border-radius: 3px; + -o-border-radius: 3px; + border-radius: 3px; +} + +.lightbox a img { + border: none; +} + +.lb-outerContainer { + position: relative; + background-color: white; + *zoom: 1; + width: 250px; + height: 250px; + margin: 0 auto; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + -ms-border-radius: 4px; + -o-border-radius: 4px; + border-radius: 4px; +} + +.lb-outerContainer:after { + content: ""; + display: table; + clear: both; +} + +.lb-container { + padding: 4px; +} + +.lb-loader { + position: absolute; + top: 43%; + left: 0; + height: 25%; + width: 100%; + text-align: center; + line-height: 0; +} + +.lb-cancel { + display: block; + width: 32px; + height: 32px; + margin: 0 auto; + background: url(images/lightbox/loading.gif) no-repeat; +} + +.lb-nav { + position: absolute; + top: 0; + left: 0; + height: 100%; + width: 100%; + z-index: 10; +} + +.lb-container > .nav { + left: 0; +} + +.lb-nav a { + outline: none; + background-image: url('data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='); +} + +.lb-prev, .lb-next { + height: 100%; + cursor: pointer; + display: block; +} + +.lb-nav a.lb-prev { + width: 34%; + left: 0; + float: left; + background: url(images/lightbox/prev.png) left 48% no-repeat; + filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0); + opacity: 0; + -webkit-transition: opacity 0.6s; + -moz-transition: opacity 0.6s; + -o-transition: opacity 0.6s; + transition: opacity 0.6s; +} + +.lb-nav a.lb-prev:hover { + filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100); + opacity: 1; +} + +.lb-nav a.lb-next { + width: 64%; + right: 0; + float: right; + background: url(images/lightbox/next.png) right 48% no-repeat; + filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0); + opacity: 0; + -webkit-transition: opacity 0.6s; + -moz-transition: opacity 0.6s; + -o-transition: opacity 0.6s; + transition: opacity 0.6s; +} + +.lb-nav a.lb-next:hover { + filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100); + opacity: 1; +} + +.lb-dataContainer { + margin: 0 auto; + padding-top: 5px; + *zoom: 1; + width: 100%; + -moz-border-radius-bottomleft: 4px; + -webkit-border-bottom-left-radius: 4px; + border-bottom-left-radius: 4px; + -moz-border-radius-bottomright: 4px; + -webkit-border-bottom-right-radius: 4px; + border-bottom-right-radius: 4px; +} + +.lb-dataContainer:after { + content: ""; + display: table; + clear: both; +} + +.lb-data { + padding: 0 4px; + color: #ccc; +} + +.lb-data .lb-details { + width: 85%; + float: left; + text-align: left; + line-height: 1.1em; +} + +.lb-data .lb-caption { + font-size: 13px; + font-weight: bold; + line-height: 1em; +} + +.lb-data .lb-number { + display: block; + clear: left; + padding-bottom: 1em; + font-size: 12px; + color: #999999; +} + +.lb-data .lb-close { + display: block; + float: right; + width: 30px; + height: 30px; + background: url(images/lightbox/close.png) top right no-repeat; + text-align: right; + outline: none; + filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=70); + opacity: 0.7; + -webkit-transition: opacity 0.2s; + -moz-transition: opacity 0.2s; + -o-transition: opacity 0.2s; + transition: opacity 0.2s; +} + +.lb-data .lb-close:hover { + cursor: pointer; + filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100); + opacity: 1; +} + body { background: #f8f8f8 !important; font-family: 'Roboto', sans-serif; } @@ -2482,6 +2693,10 @@ box-shadow: 0px 0px 15px 0px rgba(0, 5, 5, 0.2); .plans-table a .cta h2 span {background: #1e84a5;} +#designThumbs img { + border: 1px solid #CCCCCC; +} + @media screen and (min-width: 992px) { .hide-desktop {display: none;} } diff --git a/public/built.js b/public/built.js index 3267f24ab6..057cb33087 100644 --- a/public/built.js +++ b/public/built.js @@ -45923,6 +45923,16 @@ MIT license. for(l(0,(-1*e*c).toFixed(2),"Td"),s=0,o=a.length;s!==o;)a[s][0]&&this.RenderTextFragment(a[s][0],a[s][1]),s++;this.y+=c*r}return l("ET","Q"),this.y+=f}},a.prototype.setBlockBoundary=function(){return this.renderParagraph()},a.prototype.setBlockStyle=function(t){return this.paragraph.blockstyle=t},a.prototype.addText=function(t,e){return this.paragraph.text.push(t),this.paragraph.style.push(e)},r={helvetica:"helvetica","sans-serif":"helvetica",serif:"times",times:"times","times new roman":"times",monospace:"courier",courier:"courier"},s={100:"normal",200:"normal",300:"normal",400:"normal",500:"bold",600:"bold",700:"bold",800:"bold",900:"bold",normal:"normal",bold:"bold",bolder:"bold",lighter:"normal"},n={normal:"normal",italic:"italic",oblique:"italic"},l={normal:1},t.fromHTML=function(t,e,r,n,s,o){"use strict";return this.margins_doc=o||{top:0,bottom:0},n||(n={}),n.elementHandlers||(n.elementHandlers={}),p(this,t,e||4,r||4,n,s)}}(r.API),function(t){"use strict";var e,r,n;t.addJS=function(t){return n=t,this.internal.events.subscribe("postPutResources",function(){e=this.internal.newObject(),this.internal.write("<< /Names [(EmbeddedJS) "+(e+1)+" 0 R] >>","endobj"),r=this.internal.newObject(),this.internal.write("<< /S /JavaScript /JS (",n,") >>","endobj")}),this.internal.events.subscribe("putCatalog",function(){void 0!==e&&void 0!==r&&this.internal.write("/Names <>")}),this}}(r.API),function(t){"use strict";var e=function(){return"function"!=typeof PNG||"function"!=typeof a},r=function(e){return e!==t.image_compression.NONE&&n()},n=function(){var t="function"==typeof o;if(!t)throw new Error("requires deflate.js for compression");return t},s=function(e,r,n,s){var a=5,l=d;switch(s){case t.image_compression.FAST:a=3,l=f;break;case t.image_compression.MEDIUM:a=6,l=h;break;case t.image_compression.SLOW:a=9,l=p}e=c(e,r,n,l);var w=new Uint8Array(i(a)),m=u(e),y=new o(a),v=y.append(e),g=y.flush(),b=w.length+v.length+g.length,q=new Uint8Array(b+4);return q.set(w),q.set(v,w.length),q.set(g,w.length+v.length),q[b++]=m>>>24&255,q[b++]=m>>>16&255,q[b++]=m>>>8&255,q[b++]=255&m,t.arrayBufferToBinaryString(q)},i=function(t,e){var r=8,n=Math.LOG2E*Math.log(32768)-8,s=n<<4|r,o=s<<8,i=Math.min(3,(e-1&255)>>1);return o|=i<<6,o|=0,o+=31-o%31,[s,255&o&255]},u=function(t,e){for(var r,n=1,s=65535&n,o=n>>>16&65535,i=t.length,a=0;i>0;){r=i>e?e:i,i-=r;do s+=t[a++],o+=s;while(--r);s%=65521,o%=65521}return(o<<16|s)>>>0},c=function(t,e,r,n){for(var s,o,i,a=t.length/e,u=new Uint8Array(t.length+a),c=m(),l=0;a>l;l++){if(i=l*e,s=t.subarray(i,i+e),n)u.set(n(s,r,o),i+l);else{for(var f=0,d=c.length,h=[];d>f;f++)h[f]=c[f](s,r,o);var p=y(h.concat());u.set(h[p],i+l)}o=s}return u},l=function(t){var e=Array.apply([],t);return e.unshift(0),e},f=function(t,e){var r,n=[],s=0,o=t.length;for(n[0]=1;o>s;s++)r=t[s-e]||0,n[s+1]=t[s]-r+256&255;return n},d=function(t,e,r){var n,s=[],o=0,i=t.length;for(s[0]=2;i>o;o++)n=r&&r[o]||0,s[o+1]=t[o]-n+256&255;return s},h=function(t,e,r){var n,s,o=[],i=0,a=t.length;for(o[0]=3;a>i;i++)n=t[i-e]||0,s=r&&r[i]||0,o[i+1]=t[i]+256-(n+s>>>1)&255;return o},p=function(t,e,r){var n,s,o,i,a=[],u=0,c=t.length;for(a[0]=4;c>u;u++)n=t[u-e]||0,s=r&&r[u]||0,o=r&&r[u-e]||0,i=w(n,s,o),a[u+1]=t[u]-i+256&255;return a},w=function(t,e,r){var n=t+e-r,s=Math.abs(n-t),o=Math.abs(n-e),i=Math.abs(n-r);return o>=s&&i>=s?t:i>=o?e:r},m=function(){return[l,f,d,h,p]},y=function(t){for(var e,r,n,s=0,o=t.length;o>s;)e=v(t[s].slice(1)),(r>e||!r)&&(r=e,n=s),s++;return n},v=function(t){for(var e=0,r=t.length,n=0;r>e;)n+=Math.abs(t[e++]);return n};t.processPNG=function(t,n,o,i){var a,u,c,l,f,d,h=this.color_spaces.DEVICE_RGB,p=this.decode.FLATE_DECODE,w=8;if(this.isArrayBuffer(t)&&(t=new Uint8Array(t)),this.isArrayBufferView(t)){if(e())throw new Error("PNG support requires png.js and zlib.js");if(a=new PNG(t),t=a.imgData,w=a.bits,h=a.colorSpace,l=a.colors,-1!==[4,6].indexOf(a.colorType)){if(8===a.bits)for(var m,y,v=window["Uint"+a.pixelBitlength+"Array"],g=new v(a.decodePixels().buffer),b=g.length,q=new Uint8Array(b*a.colors),x=new Uint8Array(b),k=a.pixelBitlength-a.bits,_=0,A=0;b>_;_++){for(m=g[_],y=0;k>y;)q[A++]=m>>>y&255,y+=a.bits;x[_]=m>>>y&255}if(16===a.bits){for(var m,g=new Uint32Array(a.decodePixels().buffer),b=g.length,q=new Uint8Array(b*(32/a.pixelBitlength)*a.colors),x=new Uint8Array(b*(32/a.pixelBitlength)),C=a.colors>1,_=0,A=0,S=0;b>_;)m=g[_++],q[A++]=m>>>0&255,C&&(q[A++]=m>>>16&255,m=g[_++],q[A++]=m>>>0&255),x[S++]=m>>>16&255;w=8}r(i)?(t=s(q,a.width*a.colors,a.colors,i),d=s(x,a.width,1,i)):(t=q,d=x,p=null)}if(3===a.colorType&&(h=this.color_spaces.INDEXED,f=a.palette,a.transparency.indexed)){for(var E=a.transparency.indexed,z=0,_=0,b=E.length;b>_;++_)z+=E[_];if(z/=255,z===b-1&&-1!==E.indexOf(0))c=[E.indexOf(0)];else if(z!==b){for(var g=a.decodePixels(),x=new Uint8Array(g.length),_=0,b=g.length;b>_;_++)x[_]=E[g[_]];d=s(x,a.width,1)}}return u=p===this.decode.FLATE_DECODE?"/Predictor 15 /Colors "+l+" /BitsPerComponent "+w+" /Columns "+a.width:"/Colors "+l+" /BitsPerComponent "+w+" /Columns "+a.width,(this.isArrayBuffer(t)||this.isArrayBufferView(t))&&(t=this.arrayBufferToBinaryString(t)),(d&&this.isArrayBuffer(d)||this.isArrayBufferView(d))&&(d=this.arrayBufferToBinaryString(d)),this.createImageInfo(t,a.width,a.height,h,w,p,n,o,u,c,f,d)}throw new Error("Unsupported PNG image data, try using JPEG instead.")}}(r.API),function(t){"use strict";t.addSVG=function(t,e,r,n,s){function o(t,e){var r=e.createElement("style");r.type="text/css",r.styleSheet?r.styleSheet.cssText=t:r.appendChild(e.createTextNode(t)),e.getElementsByTagName("head")[0].appendChild(r)}function i(t){var e="childframe",r=t.createElement("iframe");return o(".jsPDF_sillysvg_iframe {display:none;position:absolute;}",t),r.name=e,r.setAttribute("width",0),r.setAttribute("height",0),r.setAttribute("frameborder","0"),r.setAttribute("scrolling","no"),r.setAttribute("seamless","seamless"),r.setAttribute("class","jsPDF_sillysvg_iframe"),t.body.appendChild(r),r}function a(t,e){var r=(e.contentWindow||e.contentDocument).document;return r.write(t),r.close(),r.getElementsByTagName("svg")[0]}function u(t){for(var e=parseFloat(t[1]),r=parseFloat(t[2]),n=[],s=3,o=t.length;o>s;)"c"===t[s]?(n.push([parseFloat(t[s+1]),parseFloat(t[s+2]),parseFloat(t[s+3]),parseFloat(t[s+4]),parseFloat(t[s+5]),parseFloat(t[s+6])]),s+=7):"l"===t[s]?(n.push([parseFloat(t[s+1]),parseFloat(t[s+2])]),s+=3):s+=1;return[e,r,n]}var c;if(e===c||e===c)throw new Error("addSVG needs values for 'x' and 'y'");var l=i(document),f=a(t,l),d=[1,1],h=parseFloat(f.getAttribute("width")),p=parseFloat(f.getAttribute("height"));h&&p&&(n&&s?d=[n/h,s/p]:n?d=[n/h,n/h]:s&&(d=[s/p,s/p]));var w,m,y,v,g=f.childNodes;for(w=0,m=g.length;m>w;w++)y=g[w],y.tagName&&"PATH"===y.tagName.toUpperCase()&&(v=u(y.getAttribute("d").split(" ")),v[0]=v[0]*d[0]+e,v[1]=v[1]*d[1]+r,this.lines.call(this,v[2],v[0],v[1],d));return this}}(r.API),function(t){"use strict";var e=t.getCharWidthsArray=function(t,e){e||(e={});var r,n,s,o=e.widths?e.widths:this.internal.getFont().metadata.Unicode.widths,i=o.fof?o.fof:1,a=e.kerning?e.kerning:this.internal.getFont().metadata.Unicode.kerning,u=a.fof?a.fof:1,c=0,l=o[0]||i,f=[];for(r=0,n=t.length;n>r;r++)s=t.charCodeAt(r),f.push((o[s]||l)/i+(a[s]&&a[s][c]||0)/u),c=s;return f},r=function(t){for(var e=t.length,r=0;e;)e--,r+=t[e];return r},n=t.getStringUnitWidth=function(t,n){return r(e.call(this,t,n))},s=function(t,e,r,n){for(var s=[],o=0,i=t.length,a=0;o!==i&&a+e[o]n&&(s.push(t.slice(u,o)),a=0,u=o),a+=e[o],o++;return u!==o&&s.push(t.slice(u,o)),s},o=function(t,o,i){i||(i={});var a,u,c,l,f,d,h=[],p=[h],w=i.textIndent||0,m=0,y=0,v=t.split(" "),g=e(" ",i)[0];if(d=-1===i.lineIndent?v[0].length+2:i.lineIndent||0){var b=Array(d).join(" "),q=[];v.map(function(t){t=t.split(/\s*\n/),t.length>1?q=q.concat(t.map(function(t,e){return(e&&t.length?"\n":"")+t})):q.push(t[0])}),v=q,d=n(b,i)}for(c=0,l=v.length;l>c;c++){var x=0;if(a=v[c],d&&"\n"==a[0]&&(a=a.substr(1),x=1),u=e(a,i),y=r(u),w+m+y>o||x){if(y>o){for(f=s(a,u,o-(w+m),o),h.push(f.shift()),h=[f.pop()];f.length;)p.push([f.shift()]);y=r(u.slice(a.length-h[0].length))}else h=[a];p.push(h),w=y+d,m=g}else h.push(a),w+=m+y,m=g}if(d)var k=function(t,e){return(e?b:"")+t.join(" ")};else var k=function(t){return t.join(" ")};return p.map(k)};t.splitTextToSize=function(t,e,r){r||(r={});var n,s=r.fontSize||this.internal.getFontSize(),i=function(t){var e={0:1},r={};if(t.widths&&t.kerning)return{widths:t.widths,kerning:t.kerning};var n=this.internal.getFont(t.fontName,t.fontStyle),s="Unicode";return n.metadata[s]?{widths:n.metadata[s].widths||e,kerning:n.metadata[s].kerning||r}:{widths:e,kerning:r}}.call(this,r);n=Array.isArray(t)?t:t.split(/\r?\n/);var a=1*this.internal.scaleFactor*e/s;i.textIndent=r.textIndent?1*r.textIndent*this.internal.scaleFactor/s:0,i.lineIndent=r.lineIndent;var u,c,l=[];for(u=0,c=n.length;c>u;u++)l=l.concat(o(n[u],a,i));return l}}(r.API),function(t){"use strict";var e=function(t){for(var e="0123456789abcdef",r="klmnopqrstuvwxyz",n={},s=0;su;u++)s+=String.fromCharCode(o[u]);r.push(s)}else if("Blob"===e(t)||"File"===e(t)){if(!i)throw new a("NOT_READABLE_ERR");var l=new i;r.push(l.readAsBinaryString(t))}else t instanceof n?"base64"===t.encoding&&w?r.push(w(t.data)):"URI"===t.encoding?r.push(decodeURIComponent(t.data)):"raw"===t.encoding&&r.push(t.data):("string"!=typeof t&&(t+=""),r.push(unescape(encodeURIComponent(t))))},s.getBlob=function(t){return arguments.length||(t=null),new n(this.data.join(""),t,"raw")},s.toString=function(){return"[object BlobBuilder]"},o.slice=function(t,e,r){var s=arguments.length;return 3>s&&(r=null),new n(this.data.slice(t,s>1?e:this.data.length),r,this.encoding)},o.toString=function(){return"[object Blob]"},r}(t);return function(t,r){var n=r?r.type||"":"",s=new e;if(t)for(var o=0,i=t.length;i>o;o++)s.append(t[o]);return s.getBlob(n)}}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content||this);else self.URL=webkitURL;var s=s||"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob&&navigator.msSaveOrOpenBlob.bind(navigator)||function(t){"use strict";if("undefined"==typeof navigator||!/MSIE [1-9]\./.test(navigator.userAgent)){var e=t.document,r=function(){return t.URL||t.webkitURL||t},n=t.URL||t.webkitURL||t,s=e.createElementNS("http://www.w3.org/1999/xhtml","a"),o=!t.externalHost&&"download"in s,i=t.webkitRequestFileSystem,a=t.requestFileSystem||i||t.mozRequestFileSystem,u=function(e){(t.setImmediate||t.setTimeout)(function(){throw e},0)},c="application/octet-stream",l=0,f=[],d=function(){for(var t=f.length;t--;){var e=f[t];"string"==typeof e?n.revokeObjectURL(e):e.remove()}f.length=0},h=function(t,e,r){e=[].concat(e);for(var n=e.length;n--;){var s=t["on"+e[n]];if("function"==typeof s)try{s.call(t,r||t)}catch(o){u(o)}}},p=function(n,u){var d,p,w,m=this,y=n.type,v=!1,g=function(){var t=r().createObjectURL(n);return f.push(t),t},b=function(){h(m,"writestart progress write writeend".split(" "))},q=function(){(v||!d)&&(d=g(n)),p?p.location.href=d:window.open(d,"_blank"),m.readyState=m.DONE,b()},x=function(t){return function(){return m.readyState!==m.DONE?t.apply(this,arguments):void 0}},k={create:!0,exclusive:!1};if(m.readyState=m.INIT,u||(u="download"),o){d=g(n),e=t.document,s=e.createElementNS("http://www.w3.org/1999/xhtml","a"),s.href=d,s.download=u;var _=e.createEvent("MouseEvents");return _.initMouseEvent("click",!0,!1,t,0,0,0,0,0,!1,!1,!1,!1,0,null),s.dispatchEvent(_),m.readyState=m.DONE,b(),void 0}return t.chrome&&y&&y!==c&&(w=n.slice||n.webkitSlice,n=w.call(n,0,n.size,c),v=!0),i&&"download"!==u&&(u+=".download"),(y===c||i)&&(p=t),a?(l+=n.size,a(t.TEMPORARY,l,x(function(t){t.root.getDirectory("saved",k,x(function(t){var e=function(){t.getFile(u,k,x(function(t){t.createWriter(x(function(e){e.onwriteend=function(e){p.location.href=t.toURL(),f.push(t),m.readyState=m.DONE,h(m,"writeend",e)},e.onerror=function(){var t=e.error;t.code!==t.ABORT_ERR&&q()},"writestart progress write abort".split(" ").forEach(function(t){e["on"+t]=m["on"+t]}),e.write(n),m.abort=function(){e.abort(),m.readyState=m.DONE},m.readyState=m.WRITING}),q)}),q)};t.getFile(u,{create:!1},x(function(t){t.remove(),e()}),x(function(t){t.code===t.NOT_FOUND_ERR?e():q()}))}),q)}),q),void 0):(q(),void 0)},w=p.prototype,m=function(t,e){return new p(t,e)};return w.abort=function(){var t=this;t.readyState=t.DONE,h(t,"abort")},w.readyState=w.INIT=0,w.WRITING=1,w.DONE=2,w.error=w.onwritestart=w.onprogress=w.onwrite=w.onabort=w.onerror=w.onwriteend=null,t.addEventListener("unload",d,!1),m.unload=function(){d(),t.removeEventListener("unload",d,!1)},m}}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content);"undefined"!=typeof module&&null!==module?module.exports=s:"undefined"!=typeof define&&null!==define&&null!=define.amd&&define([],function(){return s}),void function(t,e){"object"==typeof module?module.exports=e():t.adler32cs=e()}(r,function(){var t="function"==typeof ArrayBuffer&&"function"==typeof Uint8Array,e=null,r=function(){if(!t)return function(){return!1};try{var r=require("buffer");"function"==typeof r.Buffer&&(e=r.Buffer)}catch(n){}return function(t){return t instanceof ArrayBuffer||null!==e&&t instanceof e}}(),n=function(){return null!==e?function(t){return new e(t,"utf8").toString("binary")}:function(t){return unescape(encodeURIComponent(t))}}(),s=65521,o=function(t,e){for(var r=65535&t,n=t>>>16,o=0,i=e.length;i>o;o++)r=(r+(255&e.charCodeAt(o)))%s,n=(n+r)%s;return(n<<16|r)>>>0},i=function(t,e){for(var r=65535&t,n=t>>>16,o=0,i=e.length;i>o;o++)r=(r+e[o])%s,n=(n+r)%s;return(n<<16|r)>>>0},a={},u=a.Adler32=function(){var e=function(t){if(!(this instanceof e))throw new TypeError("Constructor cannot called be as a function.");if(!isFinite(t=null==t?1:+t))throw new Error("First arguments needs to be a finite number.");this.checksum=t>>>0},s=e.prototype={};return s.constructor=e,e.from=function(t){return t.prototype=s,t}(function(t){if(!(this instanceof e))throw new TypeError("Constructor cannot called be as a function.");if(null==t)throw new Error("First argument needs to be a string.");this.checksum=o(1,t.toString())}),e.fromUtf8=function(t){return t.prototype=s,t}(function(t){if(!(this instanceof e))throw new TypeError("Constructor cannot called be as a function.");if(null==t)throw new Error("First argument needs to be a string.");var r=n(t.toString());this.checksum=o(1,r)}),t&&(e.fromBuffer=function(t){return t.prototype=s,t}(function(t){if(!(this instanceof e))throw new TypeError("Constructor cannot called be as a function.");if(!r(t))throw new Error("First argument needs to be ArrayBuffer."); var n=new Uint8Array(t);return this.checksum=i(1,n)})),s.update=function(t){if(null==t)throw new Error("First argument needs to be a string.");return t=t.toString(),this.checksum=o(this.checksum,t)},s.updateUtf8=function(t){if(null==t)throw new Error("First argument needs to be a string.");var e=n(t.toString());return this.checksum=o(this.checksum,e)},t&&(s.updateBuffer=function(t){if(!r(t))throw new Error("First argument needs to be ArrayBuffer.");var e=new Uint8Array(t);return this.checksum=i(this.checksum,e)}),s.clone=function(){return new u(this.checksum)},e}();return a.from=function(t){if(null==t)throw new Error("First argument needs to be a string.");return o(1,t.toString())},a.fromUtf8=function(t){if(null==t)throw new Error("First argument needs to be a string.");var e=n(t.toString());return o(1,e)},t&&(a.fromBuffer=function(t){if(!r(t))throw new Error("First argument need to be ArrayBuffer.");var e=new Uint8Array(t);return i(1,e)}),a});var o=function(){function t(){function t(t){var e,r,s,o,a,u,c=n.dyn_tree,l=n.stat_desc.static_tree,f=n.stat_desc.extra_bits,h=n.stat_desc.extra_base,p=n.stat_desc.max_length,w=0;for(o=0;i>=o;o++)t.bl_count[o]=0;for(c[2*t.heap[t.heap_max]+1]=0,e=t.heap_max+1;d>e;e++)r=t.heap[e],o=c[2*c[2*r+1]+1]+1,o>p&&(o=p,w++),c[2*r+1]=o,r>n.max_code||(t.bl_count[o]++,a=0,r>=h&&(a=f[r-h]),u=c[2*r],t.opt_len+=u*(o+a),l&&(t.static_len+=u*(l[2*r+1]+a)));if(0!==w){do{for(o=p-1;0===t.bl_count[o];)o--;t.bl_count[o]--,t.bl_count[o+1]+=2,t.bl_count[p]--,w-=2}while(w>0);for(o=p;0!==o;o--)for(r=t.bl_count[o];0!==r;)s=t.heap[--e],s>n.max_code||(c[2*s+1]!=o&&(t.opt_len+=(o-c[2*s+1])*c[2*s],c[2*s+1]=o),r--)}}function e(t,e){var r=0;do r|=1&t,t>>>=1,r<<=1;while(--e>0);return r>>>1}function r(t,r,n){var s,o,a,u=[],c=0;for(s=1;i>=s;s++)u[s]=c=c+n[s-1]<<1;for(o=0;r>=o;o++)a=t[2*o+1],0!==a&&(t[2*o]=e(u[a]++,a))}var n=this;n.build_tree=function(e){var s,o,i,a=n.dyn_tree,u=n.stat_desc.static_tree,c=n.stat_desc.elems,l=-1;for(e.heap_len=0,e.heap_max=d,s=0;c>s;s++)0!==a[2*s]?(e.heap[++e.heap_len]=l=s,e.depth[s]=0):a[2*s+1]=0;for(;e.heap_len<2;)i=e.heap[++e.heap_len]=2>l?++l:0,a[2*i]=1,e.depth[i]=0,e.opt_len--,u&&(e.static_len-=u[2*i+1]);for(n.max_code=l,s=Math.floor(e.heap_len/2);s>=1;s--)e.pqdownheap(a,s);i=c;do s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],e.pqdownheap(a,1),o=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=o,a[2*i]=a[2*s]+a[2*o],e.depth[i]=Math.max(e.depth[s],e.depth[o])+1,a[2*s+1]=a[2*o+1]=i,e.heap[1]=i++,e.pqdownheap(a,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],t(e),r(a,n.max_code,e.bl_count)}}function e(t,e,r,n,s){var o=this;o.static_tree=t,o.extra_bits=e,o.extra_base=r,o.elems=n,o.max_length=s}function r(t,e,r,n,s){var o=this;o.good_length=t,o.max_lazy=e,o.nice_length=r,o.max_chain=n,o.func=s}function n(t,e,r,n){var s=t[2*e],o=t[2*r];return o>s||s==o&&n[e]<=n[r]}function s(){function r(){var t;for(Be=2*Ce,Te[Oe-1]=0,t=0;Oe-1>t;t++)Te[t]=0;Ve=j[Xe].max_lazy,Ke=j[Xe].good_length,Qe=j[Xe].nice_length,We=j[Xe].max_chain,Me=0,Fe=0,Ge=0,je=Je=Z-1,Ne=0,Pe=0}function s(){var t;for(t=0;f>t;t++)$e[2*t]=0;for(t=0;a>t;t++)Ze[2*t]=0;for(t=0;u>t;t++)tr[2*t]=0;$e[2*h]=1,er.opt_len=er.static_len=0,ar=cr=0}function o(){rr.dyn_tree=$e,rr.stat_desc=e.static_l_desc,nr.dyn_tree=Ze,nr.stat_desc=e.static_d_desc,sr.dyn_tree=tr,sr.stat_desc=e.static_bl_desc,fr=0,dr=0,lr=8,s()}function i(t,e){var r,n,s=-1,o=t[1],i=0,a=7,u=4;for(0===o&&(a=138,u=3),t[2*(e+1)+1]=65535,r=0;e>=r;r++)n=o,o=t[2*(r+1)+1],++ii?tr[2*n]+=i:0!==n?(n!=s&&tr[2*n]++,tr[2*w]++):10>=i?tr[2*m]++:tr[2*y]++,i=0,s=n,0===o?(a=138,u=3):n==o?(a=6,u=3):(a=7,u=4))}function c(){var e;for(i($e,rr.max_code),i(Ze,nr.max_code),sr.build_tree(er),e=u-1;e>=3&&0===tr[2*t.bl_order[e]+1];e--);return er.opt_len+=3*(e+1)+5+5+4,e}function d(t){er.pending_buf[er.pending++]=t}function p(t){d(255&t),d(t>>>8&255)}function P(t){d(t>>8&255),d(255&t&255)}function re(t,e){var r,n=e;dr>v-n?(r=t,fr|=r<>>v-dr,dr+=n-v):(fr|=t<=r;r++)if(n=o,o=t[2*(r+1)+1],!(++ii){do ne(n,tr);while(0!==--i)}else 0!==n?(n!=s&&(ne(n,tr),i--),ne(w,tr),re(i-3,2)):10>=i?(ne(m,tr),re(i-3,3)):(ne(y,tr),re(i-11,7));i=0,s=n,0===o?(a=138,u=3):n==o?(a=6,u=3):(a=7,u=4)}}function oe(e,r,n){var s;for(re(e-257,5),re(r-1,5),re(n-4,4),s=0;n>s;s++)re(tr[2*t.bl_order[s]+1],3);se($e,e-1),se(Ze,r-1)}function ie(){16==dr?(p(fr),fr=0,dr=0):dr>=8&&(d(255&fr),fr>>>=8,dr-=8)}function ae(){re(Q<<1,3),ne(h,e.static_ltree),ie(),9>1+lr+10-dr&&(re(Q<<1,3),ne(h,e.static_ltree),ie()),lr=7}function ue(e,r){var n,s,o;if(er.pending_buf[ur+2*ar]=e>>>8&255,er.pending_buf[ur+2*ar+1]=255&e,er.pending_buf[or+ar]=255&r,ar++,0===e?$e[2*r]++:(cr++,e--,$e[2*(t._length_code[r]+l+1)]++,Ze[2*t.d_code(e)]++),0===(8191&ar)&&Xe>2){for(n=8*ar,s=Me-Fe,o=0;a>o;o++)n+=Ze[2*o]*(5+t.extra_dbits[o]);if(n>>>=3,cra);ne(h,e),lr=e[2*h+1]}function le(){dr>8?p(fr):dr>0&&d(255&fr),fr=0,dr=0}function fe(t,e,r){le(),lr=8,r&&(p(e),p(~e)),er.pending_buf.set(ze.subarray(t,t+e),er.pending),er.pending+=e}function de(t,e,r){re((K<<1)+(r?1:0),3),fe(t,e,!0)}function he(t,r,n){var o,i,a=0;Xe>0?(rr.build_tree(er),nr.build_tree(er),a=c(),o=er.opt_len+3+7>>>3,i=er.static_len+3+7>>>3,o>=i&&(o=i)):o=i=r+5,o>=r+4&&-1!=t?de(t,r,n):i==o?(re((Q<<1)+(n?1:0),3),ce(e.static_ltree,e.static_dtree)):(re(($<<1)+(n?1:0),3),oe(rr.max_code+1,nr.max_code+1,a+1),ce($e,Ze)),s(),n&&le()}function pe(t){he(Fe>=0?Fe:-1,Me-Fe,t),Fe=Me,qe.flush_pending()}function we(){var t,e,r,n;do{if(n=Be-Ge-Me,0===n&&0===Me&&0===Ge)n=Ce;else if(-1==n)n--;else if(Me>=Ce+Ce-ee){ze.set(ze.subarray(Ce,Ce+Ce),0),He-=Ce,Me-=Ce,Fe-=Ce,t=Oe,r=t;do e=65535&Te[--r],Te[r]=e>=Ce?e-Ce:0;while(0!==--t);t=Ce,r=t;do e=65535&Ie[--r],Ie[r]=e>=Ce?e-Ce:0;while(0!==--t);n+=Ce}if(0===qe.avail_in)return;t=qe.read_buf(ze,Me+Ge,n),Ge+=t,Ge>=Z&&(Pe=255&ze[Me],Pe=(Pe<Ge&&0!==qe.avail_in)}function me(t){var e,r=65535;for(r>ke-5&&(r=ke-5);;){if(1>=Ge){if(we(),0===Ge&&t==k)return N;if(0===Ge)break}if(Me+=Ge,Ge=0,e=Fe+r,(0===Me||Me>=e)&&(Ge=Me-e,Me=e,pe(!1),0===qe.avail_out))return N;if(Me-Fe>=Ce-ee&&(pe(!1),0===qe.avail_out))return N}return pe(t==C),0===qe.avail_out?t==C?H:N:t==C?G:M}function ye(t){var e,r,n=We,s=Me,o=Je,i=Me>Ce-ee?Me-(Ce-ee):0,a=Qe,u=Ee,c=Me+te,l=ze[s+o-1],f=ze[s+o];Je>=Ke&&(n>>=2),a>Ge&&(a=Ge);do if(e=t,ze[e+o]==f&&ze[e+o-1]==l&&ze[e]==ze[s]&&ze[++e]==ze[s+1]){s+=2,e++;do;while(ze[++s]==ze[++e]&&ze[++s]==ze[++e]&&ze[++s]==ze[++e]&&ze[++s]==ze[++e]&&ze[++s]==ze[++e]&&ze[++s]==ze[++e]&&ze[++s]==ze[++e]&&ze[++s]==ze[++e]&&c>s);if(r=te-(c-s),s=c-te,r>o){if(He=t,o=r,r>=a)break;l=ze[s+o-1],f=ze[s+o]}}while((t=65535&Ie[t&u])>i&&0!==--n);return Ge>=o?o:Ge}function ve(t){for(var e,r=0;;){if(ee>Ge){if(we(),ee>Ge&&t==k)return N;if(0===Ge)break}if(Ge>=Z&&(Pe=(Pe<=(Me-r&65535)&&Ye!=q&&(je=ye(r)),je>=Z)if(e=ue(Me-He,je-Z),Ge-=je,Ve>=je&&Ge>=Z){je--;do Me++,Pe=(Pe<Ge){if(we(),ee>Ge&&t==k)return N;if(0===Ge)break}if(Ge>=Z&&(Pe=(Pe<Je&&Ce-ee>=(Me-n&65535)&&(Ye!=q&&(je=ye(n)),5>=je&&(Ye==b||je==Z&&Me-He>4096)&&(je=Z-1)),Je>=Z&&Je>=je){r=Me+Ge-Z,e=ue(Me-1-Le,Je-Z),Ge-=Je-1,Je-=2;do++Me<=r&&(Pe=(Pe<s||s>O||n!=Y||9>r||r>15||0>e||e>9||0>o||o>q?B:(t.dstate=er,Se=r,Ce=1<e||e>9||0>r||r>q?B:(j[Xe].func!=j[e].func&&0!==t.total_in&&(n=t.deflate(_)),Xe!=e&&(Xe=e,Ve=j[Xe].max_lazy,Ke=j[Xe].good_length,Qe=j[Xe].nice_length,We=j[Xe].max_chain),Ye=r,n)},er.deflateSetDictionary=function(t,e,r){var n,s=r,o=0;if(!e||xe!=W)return B;if(Z>s)return S;for(s>Ce-ee&&(s=Ce-ee,o=r-s),ze.set(e.subarray(o,o+s),0),Me=s,Fe=s,Pe=255&ze[0],Pe=(Pe<=n;n++)Pe=(Pe<C||0>e)return B;if(!t.next_out||!t.next_in&&0!==t.avail_in||xe==X&&e!=C)return t.msg=L[z-B],B;if(0===t.avail_out)return t.msg=L[z-T],T;if(qe=t,o=Ae,Ae=e,xe==W&&(n=Y+(Se-8<<4)<<8,s=(Xe-1&255)>>1,s>3&&(s=3),n|=s<<6,0!==Me&&(n|=J),n+=31-n%31,xe=V,P(n)),0!==er.pending){if(qe.flush_pending(),0===qe.avail_out)return Ae=-1,S}else if(0===qe.avail_in&&o>=e&&e!=C)return qe.msg=L[z-T],T;if(xe==X&&0!==qe.avail_in)return t.msg=L[z-T],T;if(0!==qe.avail_in||0!==Ge||e!=k&&xe!=X){switch(i=-1,j[Xe].func){case D:i=me(e);break;case U:i=ve(e);break;case F:i=ge(e)}if((i==H||i==G)&&(xe=X),i==N||i==H)return 0===qe.avail_out&&(Ae=-1),S;if(i==M){if(e==_)ae();else if(de(0,0,!1),e==A)for(r=0;Oe>r;r++)Te[r]=0;if(qe.flush_pending(),0===qe.avail_out)return Ae=-1,S}}return e!=C?S:E}}function o(){var t=this;t.next_in_index=0,t.next_out_index=0,t.avail_in=0,t.total_in=0,t.avail_out=0,t.total_out=0}var i=15,a=30,u=19,c=29,l=256,f=l+1+c,d=2*f+1,h=256,p=7,w=16,m=17,y=18,v=16,g=-1,b=1,q=2,x=0,k=0,_=1,A=3,C=4,S=0,E=1,z=2,B=-2,I=-3,T=-5,P=[0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,0,0,16,17,18,18,19,19,20,20,20,20,21,21,21,21,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29];t._length_code=[0,1,2,3,4,5,6,7,8,8,9,9,10,10,11,11,12,12,12,12,13,13,13,13,14,14,14,14,15,15,15,15,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28],t.base_length=[0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224,0],t.base_dist=[0,1,2,3,4,6,8,12,16,24,32,48,64,96,128,192,256,384,512,768,1024,1536,2048,3072,4096,6144,8192,12288,16384,24576],t.d_code=function(t){return 256>t?P[t]:P[256+(t>>>7)]},t.extra_lbits=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],t.extra_dbits=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],t.extra_blbits=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],t.bl_order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],e.static_ltree=[12,8,140,8,76,8,204,8,44,8,172,8,108,8,236,8,28,8,156,8,92,8,220,8,60,8,188,8,124,8,252,8,2,8,130,8,66,8,194,8,34,8,162,8,98,8,226,8,18,8,146,8,82,8,210,8,50,8,178,8,114,8,242,8,10,8,138,8,74,8,202,8,42,8,170,8,106,8,234,8,26,8,154,8,90,8,218,8,58,8,186,8,122,8,250,8,6,8,134,8,70,8,198,8,38,8,166,8,102,8,230,8,22,8,150,8,86,8,214,8,54,8,182,8,118,8,246,8,14,8,142,8,78,8,206,8,46,8,174,8,110,8,238,8,30,8,158,8,94,8,222,8,62,8,190,8,126,8,254,8,1,8,129,8,65,8,193,8,33,8,161,8,97,8,225,8,17,8,145,8,81,8,209,8,49,8,177,8,113,8,241,8,9,8,137,8,73,8,201,8,41,8,169,8,105,8,233,8,25,8,153,8,89,8,217,8,57,8,185,8,121,8,249,8,5,8,133,8,69,8,197,8,37,8,165,8,101,8,229,8,21,8,149,8,85,8,213,8,53,8,181,8,117,8,245,8,13,8,141,8,77,8,205,8,45,8,173,8,109,8,237,8,29,8,157,8,93,8,221,8,61,8,189,8,125,8,253,8,19,9,275,9,147,9,403,9,83,9,339,9,211,9,467,9,51,9,307,9,179,9,435,9,115,9,371,9,243,9,499,9,11,9,267,9,139,9,395,9,75,9,331,9,203,9,459,9,43,9,299,9,171,9,427,9,107,9,363,9,235,9,491,9,27,9,283,9,155,9,411,9,91,9,347,9,219,9,475,9,59,9,315,9,187,9,443,9,123,9,379,9,251,9,507,9,7,9,263,9,135,9,391,9,71,9,327,9,199,9,455,9,39,9,295,9,167,9,423,9,103,9,359,9,231,9,487,9,23,9,279,9,151,9,407,9,87,9,343,9,215,9,471,9,55,9,311,9,183,9,439,9,119,9,375,9,247,9,503,9,15,9,271,9,143,9,399,9,79,9,335,9,207,9,463,9,47,9,303,9,175,9,431,9,111,9,367,9,239,9,495,9,31,9,287,9,159,9,415,9,95,9,351,9,223,9,479,9,63,9,319,9,191,9,447,9,127,9,383,9,255,9,511,9,0,7,64,7,32,7,96,7,16,7,80,7,48,7,112,7,8,7,72,7,40,7,104,7,24,7,88,7,56,7,120,7,4,7,68,7,36,7,100,7,20,7,84,7,52,7,116,7,3,8,131,8,67,8,195,8,35,8,163,8,99,8,227,8],e.static_dtree=[0,5,16,5,8,5,24,5,4,5,20,5,12,5,28,5,2,5,18,5,10,5,26,5,6,5,22,5,14,5,30,5,1,5,17,5,9,5,25,5,5,5,21,5,13,5,29,5,3,5,19,5,11,5,27,5,7,5,23,5],e.static_l_desc=new e(e.static_ltree,t.extra_lbits,l+1,f,i),e.static_d_desc=new e(e.static_dtree,t.extra_dbits,0,a,i),e.static_bl_desc=new e(null,t.extra_blbits,0,u,p);var O=9,R=8,D=0,U=1,F=2,j=[new r(0,0,0,0,D),new r(4,4,8,4,U),new r(4,5,16,8,U),new r(4,6,32,32,U),new r(4,4,16,16,F),new r(8,16,32,32,F),new r(8,16,128,128,F),new r(8,32,128,256,F),new r(32,128,258,1024,F),new r(32,258,258,4096,F)],L=["need dictionary","stream end","","","stream error","data error","","buffer error","",""],N=0,M=1,H=2,G=3,J=32,W=42,V=113,X=666,Y=8,K=0,Q=1,$=2,Z=3,te=258,ee=te+Z+1;return o.prototype={deflateInit:function(t,e){var r=this;return r.dstate=new s,e||(e=i),r.dstate.deflateInit(r,t,e)},deflate:function(t){var e=this;return e.dstate?e.dstate.deflate(e,t):B},deflateEnd:function(){var t=this;if(!t.dstate)return B;var e=t.dstate.deflateEnd();return t.dstate=null,e},deflateParams:function(t,e){var r=this;return r.dstate?r.dstate.deflateParams(r,t,e):B},deflateSetDictionary:function(t,e){var r=this;return r.dstate?r.dstate.deflateSetDictionary(r,t,e):B},read_buf:function(t,e,r){var n=this,s=n.avail_in;return s>r&&(s=r),0===s?0:(n.avail_in-=s,t.set(n.next_in.subarray(n.next_in_index,n.next_in_index+s),e),n.next_in_index+=s,n.total_in+=s,s)},flush_pending:function(){var t=this,e=t.dstate.pending;e>t.avail_out&&(e=t.avail_out),0!==e&&(t.next_out.set(t.dstate.pending_buf.subarray(t.dstate.pending_out,t.dstate.pending_out+e),t.next_out_index),t.next_out_index+=e,t.dstate.pending_out+=e,t.total_out+=e,t.avail_out-=e,t.dstate.pending-=e,0===t.dstate.pending&&(t.dstate.pending_out=0))}},function(t){var e=this,r=new o,n=512,s=k,i=new Uint8Array(n);"undefined"==typeof t&&(t=g),r.deflateInit(t),r.next_out=i,e.append=function(t,e){var o,a,u=[],c=0,l=0,f=0;if(t.length){r.next_in_index=0,r.next_in=t,r.avail_in=t.length;do{if(r.next_out_index=0,r.avail_out=n,o=r.deflate(s),o!=S)throw"deflating: "+r.msg;r.next_out_index&&(r.next_out_index==n?u.push(new Uint8Array(i)):u.push(new Uint8Array(i.subarray(0,r.next_out_index)))),f+=r.next_out_index,e&&r.next_in_index>0&&r.next_in_index!=c&&(e(r.next_in_index),c=r.next_in_index)}while(r.avail_in>0||0===r.avail_out);return a=new Uint8Array(f),u.forEach(function(t){a.set(t,l),l+=t.length}),a}},e.flush=function(){var t,e,s=[],o=0,a=0;do{if(r.next_out_index=0,r.avail_out=n,t=r.deflate(C),t!=E&&t!=S)throw"deflating: "+r.msg;n-r.avail_out>0&&s.push(new Uint8Array(i.subarray(0,r.next_out_index))),a+=r.next_out_index}while(r.avail_in>0||0===r.avail_out);return r.deflateEnd(),e=new Uint8Array(a),s.forEach(function(t){e.set(t,o),o+=t.length}),e}}}(this);!function(t){var e;e=function(){function e(t){var e,r,n,s,o,i,a,u,c,l,f,d,h,p,w;for(this.data=t,this.pos=8,this.palette=[],this.imgData=[],this.transparency={},this.animation=null,this.text={},i=null;;){switch(e=this.readUInt32(),l=function(){var t,e;for(e=[],a=t=0;4>t;a=++t)e.push(String.fromCharCode(this.data[this.pos++]));return e}.call(this).join("")){case"IHDR":this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++];break;case"acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case"PLTE":this.palette=this.read(e);break;case"fcTL":i&&this.animation.frames.push(i),this.pos+=4,i={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()},o=this.readUInt16(),s=this.readUInt16()||100,i.delay=1e3*o/s,i.disposeOp=this.data[this.pos++],i.blendOp=this.data[this.pos++],i.data=[];break;case"IDAT":case"fdAT":for("fdAT"===l&&(this.pos+=4,e-=4),t=(null!=i?i.data:void 0)||this.imgData,a=h=0;e>=0?e>h:h>e;a=e>=0?++h:--h)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(n=this.palette.length/3,this.transparency.indexed=this.read(e),this.transparency.indexed.length>n)throw new Error("More transparent colors than palette size");if(f=n-this.transparency.indexed.length,f>0)for(a=p=0;f>=0?f>p:p>f;a=f>=0?++p:--p)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;case"tEXt":d=this.read(e),u=d.indexOf(0),c=String.fromCharCode.apply(String,d.slice(0,u)),this.text[c]=String.fromCharCode.apply(String,d.slice(u+1));break;case"IEND":return i&&this.animation.frames.push(i),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(w=this.colorType)||6===w,r=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*r,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),this.imgData=new Uint8Array(this.imgData),void 0;default:this.pos+=e}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}var r,n,s,o,i,u,c,l;e.load=function(t,r,n){var s;return"function"==typeof r&&(n=r),s=new XMLHttpRequest,s.open("GET",t,!0),s.responseType="arraybuffer",s.onload=function(){var t,o;return t=new Uint8Array(s.response||s.mozResponseArrayBuffer),o=new e(t),"function"==typeof(null!=r?r.getContext:void 0)&&o.render(r),"function"==typeof n?n(o):void 0},s.send(null)},o=0,s=1,i=2,n=0,r=1,e.prototype.read=function(t){var e,r,n;for(n=[],e=r=0;t>=0?t>r:r>t;e=t>=0?++r:--r)n.push(this.data[this.pos++]);return n},e.prototype.readUInt32=function(){var t,e,r,n;return t=this.data[this.pos++]<<24,e=this.data[this.pos++]<<16,r=this.data[this.pos++]<<8,n=this.data[this.pos++],t|e|r|n},e.prototype.readUInt16=function(){var t,e;return t=this.data[this.pos++]<<8,e=this.data[this.pos++],t|e},e.prototype.decodePixels=function(t){var e,r,n,s,o,i,u,c,l,f,d,h,p,w,m,y,v,g,b,q,x,k,_;if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);for(t=new a(t),t=t.getBytes(),h=this.pixelBitlength/8,y=h*this.width,p=new Uint8Array(y*this.height),i=t.length,m=0,w=0,r=0;i>w;){switch(t[w++]){case 0:for(s=b=0;y>b;s=b+=1)p[r++]=t[w++];break;case 1:for(s=q=0;y>q;s=q+=1)e=t[w++],o=h>s?0:p[r-h],p[r++]=(e+o)%256;break;case 2:for(s=x=0;y>x;s=x+=1)e=t[w++],n=(s-s%h)/h,v=m&&p[(m-1)*y+n*h+s%h],p[r++]=(v+e)%256;break;case 3:for(s=k=0;y>k;s=k+=1)e=t[w++],n=(s-s%h)/h,o=h>s?0:p[r-h],v=m&&p[(m-1)*y+n*h+s%h],p[r++]=(e+Math.floor((o+v)/2))%256;break;case 4:for(s=_=0;y>_;s=_+=1)e=t[w++],n=(s-s%h)/h,o=h>s?0:p[r-h],0===m?v=g=0:(v=p[(m-1)*y+n*h+s%h],g=n&&p[(m-1)*y+(n-1)*h+s%h]),u=o+v-g,c=Math.abs(u-o),f=Math.abs(u-v),d=Math.abs(u-g),l=f>=c&&d>=c?o:d>=f?v:g,p[r++]=(e+l)%256;break;default:throw new Error("Invalid filter algorithm: "+t[w-1])}m++}return p},e.prototype.decodePalette=function(){var t,e,r,n,s,o,i,a,u,c;for(n=this.palette,i=this.transparency.indexed||[],o=new Uint8Array((i.length||0)+n.length),s=0,r=n.length,t=0,e=a=0,u=n.length;u>a;e=a+=3)o[s++]=n[e],o[s++]=n[e+1],o[s++]=n[e+2],o[s++]=null!=(c=i[t++])?c:255;return o},e.prototype.copyToImageData=function(t,e){var r,n,s,o,i,a,u,c,l,f,d;if(n=this.colors,l=null,r=this.hasAlphaChannel,this.palette.length&&(l=null!=(d=this._decodedPalette)?d:this._decodedPalette=this.decodePalette(),n=4,r=!0),s=t.data||t,c=s.length,i=l||e,o=a=0,1===n)for(;c>o;)u=l?4*e[o/4]:a,f=i[u++],s[o++]=f,s[o++]=f,s[o++]=f,s[o++]=r?i[u++]:255,a=u;else for(;c>o;)u=l?4*e[o/4]:a,s[o++]=i[u++],s[o++]=i[u++],s[o++]=i[u++],s[o++]=r?i[u++]:255,a=u},e.prototype.decode=function(){var t;return t=new Uint8Array(this.width*this.height*4),this.copyToImageData(t,this.decodePixels()),t};try{c=t.document.createElement("canvas"),l=c.getContext("2d")}catch(f){return-1}return u=function(t){var e;return l.width=t.width,l.height=t.height,l.clearRect(0,0,t.width,t.height),l.putImageData(t,0,0),e=new Image,e.src=c.toDataURL(),e},e.prototype.decodeFrames=function(t){var e,r,n,s,o,i,a,c;if(this.animation){for(a=this.animation.frames,c=[],r=o=0,i=a.length;i>o;r=++o)e=a[r],n=t.createImageData(e.width,e.height),s=this.decodePixels(new Uint8Array(e.data)),this.copyToImageData(n,s),e.imageData=n,c.push(e.image=u(n));return c}},e.prototype.renderFrame=function(t,e){var r,o,a;return o=this.animation.frames,r=o[e],a=o[e-1],0===e&&t.clearRect(0,0,this.width,this.height),(null!=a?a.disposeOp:void 0)===s?t.clearRect(a.xOffset,a.yOffset,a.width,a.height):(null!=a?a.disposeOp:void 0)===i&&t.putImageData(a.imageData,a.xOffset,a.yOffset),r.blendOp===n&&t.clearRect(r.xOffset,r.yOffset,r.width,r.height),t.drawImage(r.image,r.xOffset,r.yOffset)},e.prototype.animate=function(t){var e,r,n,s,o,i,a=this;return r=0,i=this.animation,s=i.numFrames,n=i.frames,o=i.numPlays,(e=function(){var i,u;return i=r++%s,u=n[i],a.renderFrame(t,i),s>1&&o>r/s?a.animation._timeout=setTimeout(e,u.delay):void 0})()},e.prototype.stopAnimation=function(){var t;return clearTimeout(null!=(t=this.animation)?t._timeout:void 0)},e.prototype.render=function(t){var e,r;return t._png&&t._png.stopAnimation(),t._png=this,t.width=this.width,t.height=this.height,e=t.getContext("2d"),this.animation?(this.decodeFrames(e),this.animate(e)):(r=e.createImageData(this.width,this.height),this.copyToImageData(r,this.decodePixels()),e.putImageData(r,0,0))},e}(),t.PNG=e}("undefined"!=typeof window&&window||this);var i=function(){function t(){this.pos=0,this.bufferLength=0,this.eof=!1,this.buffer=null}return t.prototype={ensureBuffer:function(t){var e=this.buffer,r=e?e.byteLength:0;if(r>t)return e;for(var n=512;t>n;)n<<=1;for(var s=new Uint8Array(n),o=0;r>o;++o)s[o]=e[o];return this.buffer=s},getByte:function(){for(var t=this.pos;this.bufferLength<=t;){if(this.eof)return null;this.readBlock()}return this.buffer[this.pos++]},getBytes:function(t){var e=this.pos;if(t){this.ensureBuffer(e+t);for(var r=e+t;!this.eof&&this.bufferLengthn&&(r=n)}else{for(;!this.eof;)this.readBlock();var r=this.bufferLength}return this.pos=r,this.buffer.subarray(e,r)},lookChar:function(){for(var t=this.pos;this.bufferLength<=t;){if(this.eof)return null;this.readBlock()}return String.fromCharCode(this.buffer[this.pos])},getChar:function(){for(var t=this.pos;this.bufferLength<=t;){if(this.eof)return null;this.readBlock()}return String.fromCharCode(this.buffer[this.pos++])},makeSubStream:function(t,e,r){for(var n=t+e;this.bufferLength<=n&&!this.eof;)this.readBlock();return new Stream(this.buffer,t,e,r)},skip:function(t){t||(t=1),this.pos+=t},reset:function(){this.pos=0}},t}(),a=function(){function t(t){throw new Error(t)}function e(e){var r=0,n=e[r++],s=e[r++];(-1==n||-1==s)&&t("Invalid header in flate stream"),8!=(15&n)&&t("Unknown compression method in flate stream"),((n<<8)+s)%31!=0&&t("Bad FCHECK in flate stream"),32&s&&t("FDICT bit set in flate stream"),this.bytes=e,this.bytesPos=r,this.codeSize=0,this.codeBuf=0,i.call(this)}if("undefined"==typeof Uint32Array)return void 0;var r=new Uint32Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),n=new Uint32Array([3,4,5,6,7,8,9,10,65547,65549,65551,65553,131091,131095,131099,131103,196643,196651,196659,196667,262211,262227,262243,262259,327811,327843,327875,327907,258,258,258]),s=new Uint32Array([1,2,3,4,65541,65543,131081,131085,196625,196633,262177,262193,327745,327777,393345,393409,459009,459137,524801,525057,590849,591361,657409,658433,724993,727041,794625,798721,868353,876545]),o=[new Uint32Array([459008,524368,524304,524568,459024,524400,524336,590016,459016,524384,524320,589984,524288,524416,524352,590048,459012,524376,524312,589968,459028,524408,524344,590032,459020,524392,524328,59e4,524296,524424,524360,590064,459010,524372,524308,524572,459026,524404,524340,590024,459018,524388,524324,589992,524292,524420,524356,590056,459014,524380,524316,589976,459030,524412,524348,590040,459022,524396,524332,590008,524300,524428,524364,590072,459009,524370,524306,524570,459025,524402,524338,590020,459017,524386,524322,589988,524290,524418,524354,590052,459013,524378,524314,589972,459029,524410,524346,590036,459021,524394,524330,590004,524298,524426,524362,590068,459011,524374,524310,524574,459027,524406,524342,590028,459019,524390,524326,589996,524294,524422,524358,590060,459015,524382,524318,589980,459031,524414,524350,590044,459023,524398,524334,590012,524302,524430,524366,590076,459008,524369,524305,524569,459024,524401,524337,590018,459016,524385,524321,589986,524289,524417,524353,590050,459012,524377,524313,589970,459028,524409,524345,590034,459020,524393,524329,590002,524297,524425,524361,590066,459010,524373,524309,524573,459026,524405,524341,590026,459018,524389,524325,589994,524293,524421,524357,590058,459014,524381,524317,589978,459030,524413,524349,590042,459022,524397,524333,590010,524301,524429,524365,590074,459009,524371,524307,524571,459025,524403,524339,590022,459017,524387,524323,589990,524291,524419,524355,590054,459013,524379,524315,589974,459029,524411,524347,590038,459021,524395,524331,590006,524299,524427,524363,590070,459011,524375,524311,524575,459027,524407,524343,590030,459019,524391,524327,589998,524295,524423,524359,590062,459015,524383,524319,589982,459031,524415,524351,590046,459023,524399,524335,590014,524303,524431,524367,590078,459008,524368,524304,524568,459024,524400,524336,590017,459016,524384,524320,589985,524288,524416,524352,590049,459012,524376,524312,589969,459028,524408,524344,590033,459020,524392,524328,590001,524296,524424,524360,590065,459010,524372,524308,524572,459026,524404,524340,590025,459018,524388,524324,589993,524292,524420,524356,590057,459014,524380,524316,589977,459030,524412,524348,590041,459022,524396,524332,590009,524300,524428,524364,590073,459009,524370,524306,524570,459025,524402,524338,590021,459017,524386,524322,589989,524290,524418,524354,590053,459013,524378,524314,589973,459029,524410,524346,590037,459021,524394,524330,590005,524298,524426,524362,590069,459011,524374,524310,524574,459027,524406,524342,590029,459019,524390,524326,589997,524294,524422,524358,590061,459015,524382,524318,589981,459031,524414,524350,590045,459023,524398,524334,590013,524302,524430,524366,590077,459008,524369,524305,524569,459024,524401,524337,590019,459016,524385,524321,589987,524289,524417,524353,590051,459012,524377,524313,589971,459028,524409,524345,590035,459020,524393,524329,590003,524297,524425,524361,590067,459010,524373,524309,524573,459026,524405,524341,590027,459018,524389,524325,589995,524293,524421,524357,590059,459014,524381,524317,589979,459030,524413,524349,590043,459022,524397,524333,590011,524301,524429,524365,590075,459009,524371,524307,524571,459025,524403,524339,590023,459017,524387,524323,589991,524291,524419,524355,590055,459013,524379,524315,589975,459029,524411,524347,590039,459021,524395,524331,590007,524299,524427,524363,590071,459011,524375,524311,524575,459027,524407,524343,590031,459019,524391,524327,589999,524295,524423,524359,590063,459015,524383,524319,589983,459031,524415,524351,590047,459023,524399,524335,590015,524303,524431,524367,590079]),9],a=[new Uint32Array([327680,327696,327688,327704,327684,327700,327692,327708,327682,327698,327690,327706,327686,327702,327694,0,327681,327697,327689,327705,327685,327701,327693,327709,327683,327699,327691,327707,327687,327703,327695,0]),5];return e.prototype=Object.create(i.prototype),e.prototype.getBits=function(e){for(var r,n=this.codeSize,s=this.codeBuf,o=this.bytes,i=this.bytesPos;e>n;)"undefined"==typeof(r=o[i++])&&t("Bad encoding in flate stream"),s|=r<>e,this.codeSize=n-=e,this.bytesPos=i,r},e.prototype.getCode=function(e){for(var r=e[0],n=e[1],s=this.codeSize,o=this.codeBuf,i=this.bytes,a=this.bytesPos;n>s;){var u;"undefined"==typeof(u=i[a++])&&t("Bad encoding in flate stream"),o|=u<>16,f=65535&c;return(0==s||l>s||0==l)&&t("Bad encoding in flate stream"),this.codeBuf=o>>l,this.codeSize=s-l,this.bytesPos=a,f},e.prototype.generateHuffmanTable=function(t){for(var e=t.length,r=0,n=0;e>n;++n)t[n]>r&&(r=t[n]);for(var s=1<=i;++i,a<<=1,u<<=1)for(var c=0;e>c;++c)if(t[c]==i){for(var l=0,f=a,n=0;i>n;++n)l=l<<1|1&f,f>>=1;for(var n=l;s>n;n+=u)o[n]=i<<16|c;++a}return[o,r]},e.prototype.readBlock=function(){function e(t,e,r,n,s){for(var o=t.getBits(r)+n;o-->0;)e[k++]=s}var i=this.getBits(3);if(1&i&&(this.eof=!0),i>>=1,0==i){var u,c=this.bytes,l=this.bytesPos; "undefined"==typeof(u=c[l++])&&t("Bad block header in flate stream");var f=u;"undefined"==typeof(u=c[l++])&&t("Bad block header in flate stream"),f|=u<<8,"undefined"==typeof(u=c[l++])&&t("Bad block header in flate stream");var d=u;"undefined"==typeof(u=c[l++])&&t("Bad block header in flate stream"),d|=u<<8,d!=(65535&~f)&&t("Bad uncompressed block length in flate stream"),this.codeBuf=0,this.codeSize=0;var h=this.bufferLength,p=this.ensureBuffer(h+f),w=h+f;this.bufferLength=w;for(var m=h;w>m;++m){if("undefined"==typeof(u=c[l++])){this.eof=!0;break}p[m]=u}return this.bytesPos=l,void 0}var y,v;if(1==i)y=o,v=a;else if(2==i){for(var g=this.getBits(5)+257,b=this.getBits(5)+1,q=this.getBits(4)+4,x=Array(r.length),k=0;q>k;)x[r[k++]]=this.getBits(3);for(var _=this.generateHuffmanTable(x),A=0,k=0,C=g+b,S=new Array(C);C>k;){var E=this.getCode(_);16==E?e(this,S,2,3,A):17==E?e(this,S,3,3,A=0):18==E?e(this,S,7,11,A=0):S[k++]=A=E}y=this.generateHuffmanTable(S.slice(0,g)),v=this.generateHuffmanTable(S.slice(g,C))}else t("Unknown block type in flate stream");for(var p=this.buffer,z=p?p.length:0,B=this.bufferLength;;){var I=this.getCode(y);if(256>I)B+1>=z&&(p=this.ensureBuffer(B+1),z=p.length),p[B++]=I;else{if(256==I)return this.bufferLength=B,void 0;I-=257,I=n[I];var T=I>>16;T>0&&(T=this.getBits(T));var A=(65535&I)+T;I=this.getCode(v),I=s[I],T=I>>16,T>0&&(T=this.getBits(T));var P=(65535&I)+T;B+A>=z&&(p=this.ensureBuffer(B+A),z=p.length);for(var O=0;A>O;++O,++B)p[B]=p[B-P]}}},e}();!function(t){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";"undefined"==typeof t.btoa&&(t.btoa=function(t){var r,n,s,o,i,a,u,c,l=0,f=0,d="",h=[];if(!t)return t;do r=t.charCodeAt(l++),n=t.charCodeAt(l++),s=t.charCodeAt(l++),c=r<<16|n<<8|s,o=c>>18&63,i=c>>12&63,a=c>>6&63,u=63&c,h[f++]=e.charAt(o)+e.charAt(i)+e.charAt(a)+e.charAt(u);while(l>16&255,n=c>>8&255,s=255&c,h[f++]=64==a?String.fromCharCode(r):64==u?String.fromCharCode(r,n):String.fromCharCode(r,n,s);while(l>>0,n=new Array(r),s=arguments.length>1?arguments[1]:void 0,o=0;r>o;o++)o in e&&(n[o]=t.call(s,e[o],o,e));return n}),Array.prototype.forEach||(Array.prototype.forEach=function(t,e){"use strict";if(void 0===this||null===this||"function"!=typeof t)throw new TypeError;for(var r=Object(this),n=r.length>>>0,s=0;n>s;s++)s in r&&t.call(e,r[s],s,r)}),Object.keys||(Object.keys=function(){"use strict";var t=Object.prototype.hasOwnProperty,e=!{toString:null}.propertyIsEnumerable("toString"),r=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],n=r.length;return function(s){if("object"!=typeof s&&("function"!=typeof s||null===s))throw new TypeError;var o,i,a=[];for(o in s)t.call(s,o)&&a.push(o);if(e)for(i=0;n>i;i++)t.call(s,r[i])&&a.push(r[i]);return a}}()),String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),String.prototype.trimLeft||(String.prototype.trimLeft=function(){return this.replace(/^\s+/g,"")}),String.prototype.trimRight||(String.prototype.trimRight=function(){return this.replace(/\s+$/g,"")})}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this)}({},function(){return this}()); +/** + * Lightbox v2.7.1 + * by Lokesh Dhakar - http://lokeshdhakar.com/projects/lightbox2/ + * + * @license http://creativecommons.org/licenses/by/2.5/ + * - Free for use in both personal and commercial projects + * - Attribution requires leaving author name, author link, and the license info intact + */ +(function(){var a=jQuery,b=function(){function a(){this.fadeDuration=500,this.fitImagesInViewport=!0,this.resizeDuration=700,this.positionFromTop=50,this.showImageNumberLabel=!0,this.alwaysShowNavOnTouchDevices=!1,this.wrapAround=!1}return a.prototype.albumLabel=function(a,b){return"Image "+a+" of "+b},a}(),c=function(){function b(a){this.options=a,this.album=[],this.currentImageIndex=void 0,this.init()}return b.prototype.init=function(){this.enable(),this.build()},b.prototype.enable=function(){var b=this;a("body").on("click","a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]",function(c){return b.start(a(c.currentTarget)),!1})},b.prototype.build=function(){var b=this;a("
").appendTo(a("body")),this.$lightbox=a("#lightbox"),this.$overlay=a("#lightboxOverlay"),this.$outerContainer=this.$lightbox.find(".lb-outerContainer"),this.$container=this.$lightbox.find(".lb-container"),this.containerTopPadding=parseInt(this.$container.css("padding-top"),10),this.containerRightPadding=parseInt(this.$container.css("padding-right"),10),this.containerBottomPadding=parseInt(this.$container.css("padding-bottom"),10),this.containerLeftPadding=parseInt(this.$container.css("padding-left"),10),this.$overlay.hide().on("click",function(){return b.end(),!1}),this.$lightbox.hide().on("click",function(c){return"lightbox"===a(c.target).attr("id")&&b.end(),!1}),this.$outerContainer.on("click",function(c){return"lightbox"===a(c.target).attr("id")&&b.end(),!1}),this.$lightbox.find(".lb-prev").on("click",function(){return b.changeImage(0===b.currentImageIndex?b.album.length-1:b.currentImageIndex-1),!1}),this.$lightbox.find(".lb-next").on("click",function(){return b.changeImage(b.currentImageIndex===b.album.length-1?0:b.currentImageIndex+1),!1}),this.$lightbox.find(".lb-loader, .lb-close").on("click",function(){return b.end(),!1})},b.prototype.start=function(b){function c(a){d.album.push({link:a.attr("href"),title:a.attr("data-title")||a.attr("title")})}var d=this,e=a(window);e.on("resize",a.proxy(this.sizeOverlay,this)),a("select, object, embed").css({visibility:"hidden"}),this.sizeOverlay(),this.album=[];var f,g=0,h=b.attr("data-lightbox");if(h){f=a(b.prop("tagName")+'[data-lightbox="'+h+'"]');for(var i=0;ij||e.height>i)&&(e.width/j>e.height/i?(h=j,g=parseInt(e.height/(e.width/h),10),d.width(h),d.height(g)):(g=i,h=parseInt(e.width/(e.height/g),10),d.width(h),d.height(g)))),c.sizeContainer(d.width(),d.height())},e.src=this.album[b].link,this.currentImageIndex=b},b.prototype.sizeOverlay=function(){this.$overlay.width(a(window).width()).height(a(document).height())},b.prototype.sizeContainer=function(a,b){function c(){d.$lightbox.find(".lb-dataContainer").width(g),d.$lightbox.find(".lb-prevLink").height(h),d.$lightbox.find(".lb-nextLink").height(h),d.showImage()}var d=this,e=this.$outerContainer.outerWidth(),f=this.$outerContainer.outerHeight(),g=a+this.containerLeftPadding+this.containerRightPadding,h=b+this.containerTopPadding+this.containerBottomPadding;e!==g||f!==h?this.$outerContainer.animate({width:g,height:h},this.options.resizeDuration,"swing",function(){c()}):c()},b.prototype.showImage=function(){this.$lightbox.find(".lb-loader").hide(),this.$lightbox.find(".lb-image").fadeIn("slow"),this.updateNav(),this.updateDetails(),this.preloadNeighboringImages(),this.enableKeyboardNav()},b.prototype.updateNav=function(){var a=!1;try{document.createEvent("TouchEvent"),a=this.options.alwaysShowNavOnTouchDevices?!0:!1}catch(b){}this.$lightbox.find(".lb-nav").show(),this.album.length>1&&(this.options.wrapAround?(a&&this.$lightbox.find(".lb-prev, .lb-next").css("opacity","1"),this.$lightbox.find(".lb-prev, .lb-next").show()):(this.currentImageIndex>0&&(this.$lightbox.find(".lb-prev").show(),a&&this.$lightbox.find(".lb-prev").css("opacity","1")),this.currentImageIndex1&&this.options.showImageNumberLabel?this.$lightbox.find(".lb-number").text(this.options.albumLabel(this.currentImageIndex+1,this.album.length)).fadeIn("fast"):this.$lightbox.find(".lb-number").hide(),this.$outerContainer.removeClass("animating"),this.$lightbox.find(".lb-dataContainer").fadeIn(this.options.resizeDuration,function(){return b.sizeOverlay()})},b.prototype.preloadNeighboringImages=function(){if(this.album.length>this.currentImageIndex+1){var a=new Image;a.src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){var b=new Image;b.src=this.album[this.currentImageIndex-1].link}},b.prototype.enableKeyboardNav=function(){a(document).on("keyup.keyboard",a.proxy(this.keyboardAction,this))},b.prototype.disableKeyboardNav=function(){a(document).off(".keyboard")},b.prototype.keyboardAction=function(a){var b=27,c=37,d=39,e=a.keyCode,f=String.fromCharCode(e).toLowerCase();e===b||f.match(/x|o|c/)?this.end():"p"===f||e===c?0!==this.currentImageIndex?this.changeImage(this.currentImageIndex-1):this.options.wrapAround&&this.album.length>1&&this.changeImage(this.album.length-1):("n"===f||e===d)&&(this.currentImageIndex!==this.album.length-1?this.changeImage(this.currentImageIndex+1):this.options.wrapAround&&this.album.length>1&&this.changeImage(0))},b.prototype.end=function(){this.disableKeyboardNav(),a(window).off("resize",this.sizeOverlay),this.$lightbox.fadeOut(this.options.fadeDuration),this.$overlay.fadeOut(this.options.fadeDuration),a("select, object, embed").css({visibility:"visible"})},b}();a(function(){{var a=new b;new c(a)}})}).call(this); +//# sourceMappingURL=lightbox.min.map // http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0; var isFirefox = typeof InstallTrigger !== 'undefined'; // Firefox 1.0+ @@ -46883,7 +46893,6 @@ function getInvoiceTaxRate(invoice) { return tax; } -/* function displayInvoiceHeader(doc, invoice, layout) { var costX = layout.unitCostRight - (doc.getStringUnitWidth(invoiceLabels.unit_cost) * doc.internal.getFontSize()); @@ -46891,6 +46900,15 @@ function displayInvoiceHeader(doc, invoice, layout) { var taxX = layout.taxRight - (doc.getStringUnitWidth(invoiceLabels.tax) * doc.internal.getFontSize()); var totalX = layout.lineTotalRight - (doc.getStringUnitWidth(invoiceLabels.line_total) * doc.internal.getFontSize()); + if (invoice.invoice_design_id == 6 || invoice.invoice_design_id == 8 || invoice.invoice_design_id == 10) { + invoiceLabels.item = invoiceLabels.item.toUpperCase(); + invoiceLabels.description = invoiceLabels.description.toUpperCase(); + invoiceLabels.unit_cost = invoiceLabels.unit_cost.toUpperCase(); + invoiceLabels.quantity = invoiceLabels.quantity.toUpperCase(); + invoiceLabels.line_total = invoiceLabels.total.toUpperCase(); + invoiceLabels.tax = invoiceLabels.tax.toUpperCase(); + } + doc.text(layout.marginLeft, layout.tableTop, invoiceLabels.item); doc.text(layout.descriptionLeft, layout.tableTop, invoiceLabels.description); doc.text(costX, layout.tableTop, invoiceLabels.unit_cost); @@ -46903,258 +46921,7 @@ function displayInvoiceHeader(doc, invoice, layout) { { doc.text(taxX, layout.tableTop, invoiceLabels.tax); } -} -function displayInvoiceItems(doc, invoice, layout) { - doc.setFontType("normal"); - - var line = 1; - var total = 0; - var shownItem = false; - var currencyId = invoice && invoice.client ? invoice.client.currency_id : 1; - var tableTop = layout.tableTop; - var hideQuantity = invoice.account.hide_quantity == '1'; - - doc.setFontSize(8); - for (var i=0; i 770) { - line = 0; - tableTop = layout.accountTop + layout.tablePadding; - y = tableTop; - top = y - layout.tablePadding; - newTop = top + (numLines * layout.tableRowHeight); - doc.addPage(); - } - - var left = layout.marginLeft - layout.tablePadding; - var width = layout.marginRight + layout.tablePadding; - - var cost = formatMoney(item.cost, currencyId, true); - var qty = NINJA.parseFloat(item.qty) ? NINJA.parseFloat(item.qty) + '' : ''; - var notes = item.notes; - var productKey = item.product_key; - var tax = 0; - if (item.tax && parseFloat(item.tax.rate)) { - tax = parseFloat(item.tax.rate); - } else if (item.tax_rate && parseFloat(item.tax_rate)) { - tax = parseFloat(item.tax_rate); - } - - // show at most one blank line - if (shownItem && (!cost || cost == '0.00') && !notes && !productKey) { - continue; - } - shownItem = true; - - // process date variables - notes = processVariables(notes); - productKey = processVariables(productKey); - - var lineTotal = NINJA.parseFloat(item.cost) * NINJA.parseFloat(item.qty); - if (tax) { - lineTotal += lineTotal * tax / 100; - } - if (lineTotal) { - total += lineTotal; - } - lineTotal = formatMoney(lineTotal, currencyId); - - var costX = layout.unitCostRight - (doc.getStringUnitWidth(cost) * doc.internal.getFontSize()); - var qtyX = layout.qtyRight - (doc.getStringUnitWidth(qty) * doc.internal.getFontSize()); - var taxX = layout.taxRight - (doc.getStringUnitWidth(tax+'%') * doc.internal.getFontSize()); - var totalX = layout.lineTotalRight - (doc.getStringUnitWidth(lineTotal) * doc.internal.getFontSize()); - - line += numLines; - - if (invoice.invoice_design_id == 1) { - if (i%2 == 0) { - doc.setDrawColor(255,255,255); - doc.setFillColor(246,246,246); - doc.rect(left, top, width-left, newTop-top, 'FD'); - - doc.setLineWidth(0.3); - doc.setDrawColor(200,200,200); - doc.line(left, top, width, top); - doc.line(left, newTop, width, newTop); - } - } else if (invoice.invoice_design_id == 2) { - if (i%2 == 0) { - left = 0; - width = 1000; - - doc.setDrawColor(255,255,255); - doc.setFillColor(235,235,235); - doc.rect(left, top, width-left, newTop-top, 'FD'); - - } - } else if (invoice.invoice_design_id == 5) { - if (i%2 == 0) { - doc.setDrawColor(255,255,255); - doc.setFillColor(247,247,247); - doc.rect(left, top, width-left+17, newTop-top, 'FD'); - doc.setLineWidth(0.3); - doc.setDrawColor(255,255,255); - } else { - doc.setDrawColor(255,255,255); - doc.setFillColor(232,232,232); - doc.rect(left, top, width-left+17, newTop-top, 'FD'); - - doc.setLineWidth(0.3); - doc.setDrawColor(255,255,255); - } - } else { - doc.setLineWidth(0.3); - doc.setDrawColor(150,150,150); - doc.line(left, newTop, width, newTop); - } - - y += 4; - - if (invoice.invoice_design_id == 1) { - SetPdfColor('LightBlue', doc, 'primary'); - } else if (invoice.invoice_design_id == 2) { - SetPdfColor('SomeGreen', doc, 'primary'); - } else if (invoice.invoice_design_id == 3) { - doc.setFontType('bold'); - } else if (invoice.invoice_design_id == 4) { - SetPdfColor('Black', doc); - } else if (invoice.invoice_design_id == 5) { - SetPdfColor('Black', doc); - } - - var splitTitle = doc.splitTextToSize(productKey, 60); - doc.text(layout.marginLeft, y+2, splitTitle); - - if (invoice.invoice_design_id == 5) { - doc.setDrawColor(255, 255, 255); - doc.setLineWidth(1); - doc.line(layout.descriptionLeft-8, y-16,layout.descriptionLeft-8, y+55); - - doc.setDrawColor(255, 255, 255); - doc.setLineWidth(1); - doc.line(costX-30, y-16,costX-30, y+55); - - doc.setDrawColor(255, 255, 255); - doc.setLineWidth(1); - doc.line(qtyX-45, y-16,qtyX-45, y+55); - - if (invoice.has_taxes) { - doc.setDrawColor(255, 255, 255); - doc.setLineWidth(1); - doc.line(taxX-15, y-16,taxX-15, y+55); - } - - doc.setDrawColor(255, 255, 255); - doc.setLineWidth(1); - doc.line(totalX-27, y-16,totalX-27, y+55); - } - - SetPdfColor('Black', doc); - doc.setFontType('normal'); - - doc.text(layout.descriptionLeft, y+2, notes); - doc.text(costX, y+2, cost); - if (!hideQuantity) { - doc.text(qtyX, y+2, qty); - } - doc.text(totalX, y+2, lineTotal); - - if (tax) { - doc.text(taxX, y+2, tax+'%'); - } - } - - y = tableTop + (line * layout.tableRowHeight) + (3 * layout.tablePadding); - var cutoff = 700; - if (invoice.terms) { - cutoff -= 50; - } - if (invoice.public_notes) { - cutoff -= 50; - } - - if (y > cutoff) { - doc.addPage(); - return layout.marginLeft; - } - - return y; -} -*/ - -function displayInvoiceHeader(doc, invoice, layout) { - - var costX = layout.unitCostRight - (doc.getStringUnitWidth(invoiceLabels.unit_cost) * doc.internal.getFontSize()); - var qtyX = layout.qtyRight - (doc.getStringUnitWidth(invoiceLabels.quantity) * doc.internal.getFontSize()); - var taxX = layout.taxRight - (doc.getStringUnitWidth(invoiceLabels.tax) * doc.internal.getFontSize()); - var totalX = layout.lineTotalRight - (doc.getStringUnitWidth(invoiceLabels.line_total) * doc.internal.getFontSize()); - - if(invoice.invoice_design_id == 6) { - doc.setFontType('normal'); - doc.text(layout.marginLeft, layout.tableTop, invoiceLabels.item.toUpperCase()); - doc.text(layout.descriptionLeft, layout.tableTop, invoiceLabels.description.toUpperCase()); - doc.text(costX, layout.tableTop, ' UNIT'); - if (invoice.account.hide_quantity != '1') { - doc.text(qtyX, layout.tableTop, invoiceLabels.quantity.toUpperCase()); - } - doc.text(totalX, layout.tableTop, ' TOTAL'); - - if (invoice.has_taxes) - { - doc.text(taxX, layout.tableTop, invoiceLabels.tax.toUpperCase()); - } - } else if(invoice.invoice_design_id == 8) { - doc.setFontType('bold'); - doc.text(layout.marginLeft, layout.tableTop, invoiceLabels.item.toUpperCase()); - doc.text(layout.descriptionLeft, layout.tableTop, invoiceLabels.description.toUpperCase()); - doc.text(costX, layout.tableTop, ' UNIT'); - if (invoice.account.hide_quantity != '1') { - doc.text(qtyX, layout.tableTop, invoiceLabels.quantity.toUpperCase()); - } - doc.text(totalX, layout.tableTop, ' TOTAL'); - - if (invoice.has_taxes) - { - doc.text(taxX, layout.tableTop, invoiceLabels.tax.toUpperCase()); - } - } else if(invoice.invoice_design_id == 10) { - doc.setFontType('bold'); - doc.setTextColor(63,60,60); - doc.text(layout.marginLeft, layout.tableTop, invoiceLabels.item.toUpperCase()); - doc.text(layout.descriptionLeft, layout.tableTop, invoiceLabels.description.toUpperCase()); - doc.text(costX, layout.tableTop, invoiceLabels.unit_cost.toUpperCase()); - if (invoice.account.hide_quantity != '1') { - doc.text(qtyX, layout.tableTop, invoiceLabels.quantity.toUpperCase()); - } - doc.text(totalX, layout.tableTop, invoiceLabels.line_total.toUpperCase()); - - if (invoice.has_taxes) - { - doc.text(taxX, layout.tableTop, invoiceLabels.tax.toUpperCase()); - } - } else { - doc.text(layout.marginLeft, layout.tableTop, invoiceLabels.item); - doc.text(layout.descriptionLeft, layout.tableTop, invoiceLabels.description); - doc.text(costX, layout.tableTop, invoiceLabels.unit_cost); - if (invoice.account.hide_quantity != '1') { - doc.text(qtyX, layout.tableTop, invoiceLabels.quantity); - } - doc.text(totalX, layout.tableTop, invoiceLabels.line_total); - - if (invoice.has_taxes) - { - doc.text(taxX, layout.tableTop, invoiceLabels.tax); - } - } - } function displayInvoiceItems(doc, invoice, layout) { @@ -47335,9 +47102,11 @@ function displayInvoiceItems(doc, invoice, layout) { doc.line(costX-30, y-16,costX-30, y+55); doc.line(qtyX-45, y-16,qtyX-45, y+55); - - doc.line(taxX-15, y-16,taxX-15, y+55); - + + if (invoice.has_taxes) { + doc.line(taxX-15, y-16,taxX-15, y+55); + } + doc.line(totalX-27, y-16,totalX-27, y+55); } @@ -47352,9 +47121,11 @@ function displayInvoiceItems(doc, invoice, layout) { doc.line(costX-30, y-60,costX-30, y+20); doc.line(qtyX-45, y-60,qtyX-45, y+20); - - doc.line(taxX-15, y-60,taxX-15, y+20); - + + if (invoice.has_taxes) { + doc.line(taxX-10, y-60,taxX-10, y+20); + } + doc.line(totalX-27, y-60,totalX-27, y+120); doc.line(totalX+35, y-60,totalX+35, y+120); diff --git a/public/css/style.css b/public/css/style.css index 0244c4c219..7b93f0ec51 100755 --- a/public/css/style.css +++ b/public/css/style.css @@ -707,6 +707,10 @@ box-shadow: 0px 0px 15px 0px rgba(0, 5, 5, 0.2); .plans-table a .cta h2 span {background: #1e84a5;} +#designThumbs img { + border: 1px solid #CCCCCC; +} + @media screen and (min-width: 992px) { .hide-desktop {display: none;} } diff --git a/public/images/designs/business.png b/public/images/designs/business.png new file mode 100644 index 0000000000..f9939580c4 Binary files /dev/null and b/public/images/designs/business.png differ diff --git a/public/images/designs/business_thumb.png b/public/images/designs/business_thumb.png new file mode 100644 index 0000000000..cf20f752af Binary files /dev/null and b/public/images/designs/business_thumb.png differ diff --git a/public/images/designs/creative.png b/public/images/designs/creative.png new file mode 100644 index 0000000000..60ca228b75 Binary files /dev/null and b/public/images/designs/creative.png differ diff --git a/public/images/designs/creative_thumb.png b/public/images/designs/creative_thumb.png new file mode 100644 index 0000000000..6853331c1e Binary files /dev/null and b/public/images/designs/creative_thumb.png differ diff --git a/public/images/designs/elegant.png b/public/images/designs/elegant.png new file mode 100644 index 0000000000..0001346f5d Binary files /dev/null and b/public/images/designs/elegant.png differ diff --git a/public/images/designs/elegant_thumb.png b/public/images/designs/elegant_thumb.png new file mode 100644 index 0000000000..92feeb0651 Binary files /dev/null and b/public/images/designs/elegant_thumb.png differ diff --git a/public/images/designs/hipster.png b/public/images/designs/hipster.png new file mode 100644 index 0000000000..65bbb2b95f Binary files /dev/null and b/public/images/designs/hipster.png differ diff --git a/public/images/designs/hipster_thumb.png b/public/images/designs/hipster_thumb.png new file mode 100644 index 0000000000..0569807400 Binary files /dev/null and b/public/images/designs/hipster_thumb.png differ diff --git a/public/images/designs/photo.png b/public/images/designs/photo.png new file mode 100644 index 0000000000..be3357e780 Binary files /dev/null and b/public/images/designs/photo.png differ diff --git a/public/images/designs/photo_thumb.png b/public/images/designs/photo_thumb.png new file mode 100644 index 0000000000..518521b170 Binary files /dev/null and b/public/images/designs/photo_thumb.png differ diff --git a/public/images/designs/playful.png b/public/images/designs/playful.png new file mode 100644 index 0000000000..2483dfaeb0 Binary files /dev/null and b/public/images/designs/playful.png differ diff --git a/public/images/designs/playful_thumb.png b/public/images/designs/playful_thumb.png new file mode 100644 index 0000000000..71be4e3753 Binary files /dev/null and b/public/images/designs/playful_thumb.png differ diff --git a/public/images/lightbox/close.png b/public/images/lightbox/close.png new file mode 100644 index 0000000000..20baa1db5f Binary files /dev/null and b/public/images/lightbox/close.png differ diff --git a/public/images/lightbox/loading.gif b/public/images/lightbox/loading.gif new file mode 100644 index 0000000000..5087c2a644 Binary files /dev/null and b/public/images/lightbox/loading.gif differ diff --git a/public/images/lightbox/next.png b/public/images/lightbox/next.png new file mode 100644 index 0000000000..08365ac84d Binary files /dev/null and b/public/images/lightbox/next.png differ diff --git a/public/images/lightbox/prev.png b/public/images/lightbox/prev.png new file mode 100644 index 0000000000..329fa98602 Binary files /dev/null and b/public/images/lightbox/prev.png differ diff --git a/public/js/script.js b/public/js/script.js index 81383690a7..a1fa8b8ccc 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -958,7 +958,6 @@ function getInvoiceTaxRate(invoice) { return tax; } -/* function displayInvoiceHeader(doc, invoice, layout) { var costX = layout.unitCostRight - (doc.getStringUnitWidth(invoiceLabels.unit_cost) * doc.internal.getFontSize()); @@ -966,6 +965,15 @@ function displayInvoiceHeader(doc, invoice, layout) { var taxX = layout.taxRight - (doc.getStringUnitWidth(invoiceLabels.tax) * doc.internal.getFontSize()); var totalX = layout.lineTotalRight - (doc.getStringUnitWidth(invoiceLabels.line_total) * doc.internal.getFontSize()); + if (invoice.invoice_design_id == 6 || invoice.invoice_design_id == 8 || invoice.invoice_design_id == 10) { + invoiceLabels.item = invoiceLabels.item.toUpperCase(); + invoiceLabels.description = invoiceLabels.description.toUpperCase(); + invoiceLabels.unit_cost = invoiceLabels.unit_cost.toUpperCase(); + invoiceLabels.quantity = invoiceLabels.quantity.toUpperCase(); + invoiceLabels.line_total = invoiceLabels.total.toUpperCase(); + invoiceLabels.tax = invoiceLabels.tax.toUpperCase(); + } + doc.text(layout.marginLeft, layout.tableTop, invoiceLabels.item); doc.text(layout.descriptionLeft, layout.tableTop, invoiceLabels.description); doc.text(costX, layout.tableTop, invoiceLabels.unit_cost); @@ -978,258 +986,7 @@ function displayInvoiceHeader(doc, invoice, layout) { { doc.text(taxX, layout.tableTop, invoiceLabels.tax); } -} -function displayInvoiceItems(doc, invoice, layout) { - doc.setFontType("normal"); - - var line = 1; - var total = 0; - var shownItem = false; - var currencyId = invoice && invoice.client ? invoice.client.currency_id : 1; - var tableTop = layout.tableTop; - var hideQuantity = invoice.account.hide_quantity == '1'; - - doc.setFontSize(8); - for (var i=0; i 770) { - line = 0; - tableTop = layout.accountTop + layout.tablePadding; - y = tableTop; - top = y - layout.tablePadding; - newTop = top + (numLines * layout.tableRowHeight); - doc.addPage(); - } - - var left = layout.marginLeft - layout.tablePadding; - var width = layout.marginRight + layout.tablePadding; - - var cost = formatMoney(item.cost, currencyId, true); - var qty = NINJA.parseFloat(item.qty) ? NINJA.parseFloat(item.qty) + '' : ''; - var notes = item.notes; - var productKey = item.product_key; - var tax = 0; - if (item.tax && parseFloat(item.tax.rate)) { - tax = parseFloat(item.tax.rate); - } else if (item.tax_rate && parseFloat(item.tax_rate)) { - tax = parseFloat(item.tax_rate); - } - - // show at most one blank line - if (shownItem && (!cost || cost == '0.00') && !notes && !productKey) { - continue; - } - shownItem = true; - - // process date variables - notes = processVariables(notes); - productKey = processVariables(productKey); - - var lineTotal = NINJA.parseFloat(item.cost) * NINJA.parseFloat(item.qty); - if (tax) { - lineTotal += lineTotal * tax / 100; - } - if (lineTotal) { - total += lineTotal; - } - lineTotal = formatMoney(lineTotal, currencyId); - - var costX = layout.unitCostRight - (doc.getStringUnitWidth(cost) * doc.internal.getFontSize()); - var qtyX = layout.qtyRight - (doc.getStringUnitWidth(qty) * doc.internal.getFontSize()); - var taxX = layout.taxRight - (doc.getStringUnitWidth(tax+'%') * doc.internal.getFontSize()); - var totalX = layout.lineTotalRight - (doc.getStringUnitWidth(lineTotal) * doc.internal.getFontSize()); - - line += numLines; - - if (invoice.invoice_design_id == 1) { - if (i%2 == 0) { - doc.setDrawColor(255,255,255); - doc.setFillColor(246,246,246); - doc.rect(left, top, width-left, newTop-top, 'FD'); - - doc.setLineWidth(0.3); - doc.setDrawColor(200,200,200); - doc.line(left, top, width, top); - doc.line(left, newTop, width, newTop); - } - } else if (invoice.invoice_design_id == 2) { - if (i%2 == 0) { - left = 0; - width = 1000; - - doc.setDrawColor(255,255,255); - doc.setFillColor(235,235,235); - doc.rect(left, top, width-left, newTop-top, 'FD'); - - } - } else if (invoice.invoice_design_id == 5) { - if (i%2 == 0) { - doc.setDrawColor(255,255,255); - doc.setFillColor(247,247,247); - doc.rect(left, top, width-left+17, newTop-top, 'FD'); - doc.setLineWidth(0.3); - doc.setDrawColor(255,255,255); - } else { - doc.setDrawColor(255,255,255); - doc.setFillColor(232,232,232); - doc.rect(left, top, width-left+17, newTop-top, 'FD'); - - doc.setLineWidth(0.3); - doc.setDrawColor(255,255,255); - } - } else { - doc.setLineWidth(0.3); - doc.setDrawColor(150,150,150); - doc.line(left, newTop, width, newTop); - } - - y += 4; - - if (invoice.invoice_design_id == 1) { - SetPdfColor('LightBlue', doc, 'primary'); - } else if (invoice.invoice_design_id == 2) { - SetPdfColor('SomeGreen', doc, 'primary'); - } else if (invoice.invoice_design_id == 3) { - doc.setFontType('bold'); - } else if (invoice.invoice_design_id == 4) { - SetPdfColor('Black', doc); - } else if (invoice.invoice_design_id == 5) { - SetPdfColor('Black', doc); - } - - var splitTitle = doc.splitTextToSize(productKey, 60); - doc.text(layout.marginLeft, y+2, splitTitle); - - if (invoice.invoice_design_id == 5) { - doc.setDrawColor(255, 255, 255); - doc.setLineWidth(1); - doc.line(layout.descriptionLeft-8, y-16,layout.descriptionLeft-8, y+55); - - doc.setDrawColor(255, 255, 255); - doc.setLineWidth(1); - doc.line(costX-30, y-16,costX-30, y+55); - - doc.setDrawColor(255, 255, 255); - doc.setLineWidth(1); - doc.line(qtyX-45, y-16,qtyX-45, y+55); - - if (invoice.has_taxes) { - doc.setDrawColor(255, 255, 255); - doc.setLineWidth(1); - doc.line(taxX-15, y-16,taxX-15, y+55); - } - - doc.setDrawColor(255, 255, 255); - doc.setLineWidth(1); - doc.line(totalX-27, y-16,totalX-27, y+55); - } - - SetPdfColor('Black', doc); - doc.setFontType('normal'); - - doc.text(layout.descriptionLeft, y+2, notes); - doc.text(costX, y+2, cost); - if (!hideQuantity) { - doc.text(qtyX, y+2, qty); - } - doc.text(totalX, y+2, lineTotal); - - if (tax) { - doc.text(taxX, y+2, tax+'%'); - } - } - - y = tableTop + (line * layout.tableRowHeight) + (3 * layout.tablePadding); - var cutoff = 700; - if (invoice.terms) { - cutoff -= 50; - } - if (invoice.public_notes) { - cutoff -= 50; - } - - if (y > cutoff) { - doc.addPage(); - return layout.marginLeft; - } - - return y; -} -*/ - -function displayInvoiceHeader(doc, invoice, layout) { - - var costX = layout.unitCostRight - (doc.getStringUnitWidth(invoiceLabels.unit_cost) * doc.internal.getFontSize()); - var qtyX = layout.qtyRight - (doc.getStringUnitWidth(invoiceLabels.quantity) * doc.internal.getFontSize()); - var taxX = layout.taxRight - (doc.getStringUnitWidth(invoiceLabels.tax) * doc.internal.getFontSize()); - var totalX = layout.lineTotalRight - (doc.getStringUnitWidth(invoiceLabels.line_total) * doc.internal.getFontSize()); - - if(invoice.invoice_design_id == 6) { - doc.setFontType('normal'); - doc.text(layout.marginLeft, layout.tableTop, invoiceLabels.item.toUpperCase()); - doc.text(layout.descriptionLeft, layout.tableTop, invoiceLabels.description.toUpperCase()); - doc.text(costX, layout.tableTop, ' UNIT'); - if (invoice.account.hide_quantity != '1') { - doc.text(qtyX, layout.tableTop, invoiceLabels.quantity.toUpperCase()); - } - doc.text(totalX, layout.tableTop, ' TOTAL'); - - if (invoice.has_taxes) - { - doc.text(taxX, layout.tableTop, invoiceLabels.tax.toUpperCase()); - } - } else if(invoice.invoice_design_id == 8) { - doc.setFontType('bold'); - doc.text(layout.marginLeft, layout.tableTop, invoiceLabels.item.toUpperCase()); - doc.text(layout.descriptionLeft, layout.tableTop, invoiceLabels.description.toUpperCase()); - doc.text(costX, layout.tableTop, ' UNIT'); - if (invoice.account.hide_quantity != '1') { - doc.text(qtyX, layout.tableTop, invoiceLabels.quantity.toUpperCase()); - } - doc.text(totalX, layout.tableTop, ' TOTAL'); - - if (invoice.has_taxes) - { - doc.text(taxX, layout.tableTop, invoiceLabels.tax.toUpperCase()); - } - } else if(invoice.invoice_design_id == 10) { - doc.setFontType('bold'); - doc.setTextColor(63,60,60); - doc.text(layout.marginLeft, layout.tableTop, invoiceLabels.item.toUpperCase()); - doc.text(layout.descriptionLeft, layout.tableTop, invoiceLabels.description.toUpperCase()); - doc.text(costX, layout.tableTop, invoiceLabels.unit_cost.toUpperCase()); - if (invoice.account.hide_quantity != '1') { - doc.text(qtyX, layout.tableTop, invoiceLabels.quantity.toUpperCase()); - } - doc.text(totalX, layout.tableTop, invoiceLabels.line_total.toUpperCase()); - - if (invoice.has_taxes) - { - doc.text(taxX, layout.tableTop, invoiceLabels.tax.toUpperCase()); - } - } else { - doc.text(layout.marginLeft, layout.tableTop, invoiceLabels.item); - doc.text(layout.descriptionLeft, layout.tableTop, invoiceLabels.description); - doc.text(costX, layout.tableTop, invoiceLabels.unit_cost); - if (invoice.account.hide_quantity != '1') { - doc.text(qtyX, layout.tableTop, invoiceLabels.quantity); - } - doc.text(totalX, layout.tableTop, invoiceLabels.line_total); - - if (invoice.has_taxes) - { - doc.text(taxX, layout.tableTop, invoiceLabels.tax); - } - } - } function displayInvoiceItems(doc, invoice, layout) { @@ -1410,9 +1167,11 @@ function displayInvoiceItems(doc, invoice, layout) { doc.line(costX-30, y-16,costX-30, y+55); doc.line(qtyX-45, y-16,qtyX-45, y+55); - - doc.line(taxX-15, y-16,taxX-15, y+55); - + + if (invoice.has_taxes) { + doc.line(taxX-15, y-16,taxX-15, y+55); + } + doc.line(totalX-27, y-16,totalX-27, y+55); } @@ -1427,9 +1186,11 @@ function displayInvoiceItems(doc, invoice, layout) { doc.line(costX-30, y-60,costX-30, y+20); doc.line(qtyX-45, y-60,qtyX-45, y+20); - - doc.line(taxX-15, y-60,taxX-15, y+20); - + + if (invoice.has_taxes) { + doc.line(taxX-10, y-60,taxX-10, y+20); + } + doc.line(totalX-27, y-60,totalX-27, y+120); doc.line(totalX+35, y-60,totalX+35, y+120);