mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Changes for mobile app
This commit is contained in:
parent
4de682994b
commit
fe1362eef4
@ -89,16 +89,17 @@ class AccountApiController extends BaseAPIController
|
||||
{
|
||||
// Create a new token only if one does not already exist
|
||||
$user = Auth::user();
|
||||
$account = $user->account;
|
||||
$this->accountRepo->createTokens($user, $request->token_name);
|
||||
|
||||
$users = $this->accountRepo->findUsers($user, 'account.account_tokens');
|
||||
$transformer = new UserAccountTransformer($user->account, $request->serializer, $request->token_name);
|
||||
$transformer = new UserAccountTransformer($account, $request->serializer, $request->token_name);
|
||||
$data = $this->createCollection($users, $transformer, 'user_account');
|
||||
|
||||
if (request()->include_static) {
|
||||
$data = [
|
||||
'accounts' => $data,
|
||||
'static' => Utils::getStaticData(),
|
||||
'static' => Utils::getStaticData($account->getLocale()),
|
||||
'version' => NINJA_VERSION,
|
||||
];
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ class BaseAPIController extends Controller
|
||||
$entity = $request->entity();
|
||||
$action = $request->action;
|
||||
|
||||
if (! in_array($action, ['archive', 'delete', 'restore', 'mark_sent'])) {
|
||||
if (! in_array($action, ['archive', 'delete', 'restore', 'mark_sent', 'markSent', 'emailInvoice', 'markPaid'])) {
|
||||
return $this->errorResponse("Action [$action] is not supported");
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ class ClientPortalController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
return View::make('invoices.view', $data);
|
||||
return View::make(request()->borderless ? 'invoices.view_borderless' : 'invoices.view', $data);
|
||||
}
|
||||
|
||||
private function getPaymentTypes($account, $client, $invitation)
|
||||
|
@ -501,7 +501,7 @@ class Utils
|
||||
}
|
||||
}
|
||||
|
||||
public static function getStaticData()
|
||||
public static function getStaticData($locale = false)
|
||||
{
|
||||
$data = [];
|
||||
|
||||
@ -510,6 +510,38 @@ class Utils
|
||||
$data[$name] = Cache::get($name);
|
||||
}
|
||||
|
||||
if ($locale) {
|
||||
$data['industries'] = Cache::get('industries')->each(function ($industry) {
|
||||
$industry->name = trans('texts.industry_'.$industry->name);
|
||||
})->sortBy(function ($industry) {
|
||||
return $industry->name;
|
||||
});
|
||||
|
||||
$data['countries'] = Cache::get('countries')->each(function ($country) {
|
||||
$country->name = trans('texts.country_'.$country->name);
|
||||
})->sortBy(function ($country) {
|
||||
return $country->name;
|
||||
});
|
||||
|
||||
$data['paymentTypes'] = Cache::get('paymentTypes')->each(function ($pType) {
|
||||
$pType->name = trans('texts.payment_type_'.$pType->name);
|
||||
})->sortBy(function ($pType) {
|
||||
return $pType->name;
|
||||
});
|
||||
|
||||
$data['languages'] = Cache::get('languages')->each(function ($lang) {
|
||||
$lang->name = trans('texts.lang_'.$lang->name);
|
||||
})->sortBy(function ($lang) {
|
||||
return $lang->name;
|
||||
});
|
||||
|
||||
$data['currencies'] = Cache::get('currencies')->each(function ($currency) {
|
||||
$currency->name = trans('texts.currency_' . Str::slug($currency->name, '_'));
|
||||
})->sortBy(function ($currency) {
|
||||
return $currency->name;
|
||||
});
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -1500,6 +1500,11 @@ class Account extends Eloquent
|
||||
return $this->getGatewayConfig($gatewayId);
|
||||
}
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->language_id && $this->language ? $this->language->locale : DEFAULT_LOCALE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
@ -7,10 +7,61 @@ use App\Models\User;
|
||||
|
||||
class UserAccountTransformer extends EntityTransformer
|
||||
{
|
||||
/**
|
||||
* @SWG\Property(property="account_key", type="string", example="123456")
|
||||
* @SWG\Property(property="name", type="string", example="John Doe")
|
||||
* @SWG\Property(property="token", type="string", example="Token")
|
||||
* @SWG\Property(property="default_url", type="string", example="http://www.example.com")
|
||||
* @SWG\Property(property="plan", type="string", example="Plan")
|
||||
* @SWG\Property(property="logo", type="string", example="Logo")
|
||||
* @SWG\Property(property="logo_url", type="string", example="http://www.example.com/logo.png")
|
||||
* @SWG\Property(property="currency_id", type="integer", example=1)
|
||||
* @SWG\Property(property="timezone_id", type="integer", example=1)
|
||||
* @SWG\Property(property="date_format_id", type="integer", example=1)
|
||||
* @SWG\Property(property="datetime_format_id", type="integer", example=1)
|
||||
* @SWG\Property(property="invoice_terms", type="string", example="Terms")
|
||||
* @SWG\Property(property="invoice_taxes", type="boolean", example=false)
|
||||
* @SWG\Property(property="invoice_item_taxes", type="boolean", example=false)
|
||||
* @SWG\Property(property="invoice_design_id", type="integer", example=1)
|
||||
* @SWG\Property(property="quote_design_id", type="integer", example=1)
|
||||
* @SWG\Property(property="language_id", type="integer", example=1)
|
||||
* @SWG\Property(property="country_id", type="integer", example=1)
|
||||
* @SWG\Property(property="invoice_footer", type="string", example="Footer")
|
||||
* @SWG\Property(property="invoice_labels", type="string", example="Labels")
|
||||
* @SWG\Property(property="show_item_taxes", type="boolean", example=false)
|
||||
* @SWG\Property(property="military_time", type="boolean", example=false)
|
||||
* @SWG\Property(property="tax_name1", type="string", example="VAT")
|
||||
* @SWG\Property(property="tax_name2", type="string", example="Upkeep")
|
||||
* @SWG\Property(property="tax_rate1", type="number", format="float", example="17.5")
|
||||
* @SWG\Property(property="tax_rate2", type="number", format="float", example="30.0")
|
||||
* @SWG\Property(property="quote_terms", type="string", example="Labels")
|
||||
* @SWG\Property(property="show_currency_code", type="boolean", example=false)
|
||||
* @SWG\Property(property="enable_second_tax_rate", type="boolean", example=false)
|
||||
* @SWG\Property(property="start_of_week", type="string", example="Monday")
|
||||
* @SWG\Property(property="financial_year_start", type="string", example="January")
|
||||
* @SWG\Property(property="enabled_modules", type="integer", example=1)
|
||||
* @SWG\Property(property="payment_terms", type="integer", example=1)
|
||||
* @SWG\Property(property="payment_type_id", type="integer", example=1)
|
||||
* @SWG\Property(property="task_rate", type="number", format="float", example="17.5")
|
||||
* @SWG\Property(property="inclusive_taxes", type="boolean", example=false)
|
||||
* @SWG\Property(property="convert_products", type="boolean", example=false)
|
||||
* @SWG\Property(property="custom_invoice_taxes1", type="string", example="Value")
|
||||
* @SWG\Property(property="custom_invoice_taxes2", type="string", example="Value")
|
||||
* @SWG\Property(property="custom_fields", type="string", example="Value")
|
||||
*/
|
||||
protected $defaultIncludes = [
|
||||
'user',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
'tax_rates',
|
||||
'expense_categories',
|
||||
'account_email_settings',
|
||||
];
|
||||
|
||||
protected $tokenName;
|
||||
|
||||
public function __construct(Account $account, $serializer, $tokenName)
|
||||
@ -27,6 +78,42 @@ class UserAccountTransformer extends EntityTransformer
|
||||
return $this->includeItem($user, $transformer, 'user');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
*
|
||||
* @return \League\Fractal\Resource\Collection
|
||||
*/
|
||||
public function includeAccountEmailSettings(User $user)
|
||||
{
|
||||
$transformer = new AccountEmailSettingsTransformer($this->account, $this->serializer);
|
||||
|
||||
return $this->includeItem($this->account->account_email_settings, $transformer, 'account_email_settings');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
*
|
||||
* @return \League\Fractal\Resource\Collection
|
||||
*/
|
||||
public function includeExpenseCategories(User $user)
|
||||
{
|
||||
$transformer = new ExpenseCategoryTransformer($this->account, $this->serializer);
|
||||
|
||||
return $this->includeCollection($this->account->expense_categories, $transformer, 'expense_categories');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
*
|
||||
* @return \League\Fractal\Resource\Collection
|
||||
*/
|
||||
public function includeTaxRates(User $user)
|
||||
{
|
||||
$transformer = new TaxRateTransformer($this->account, $this->serializer);
|
||||
|
||||
return $this->includeCollection($this->account->tax_rates, $transformer, 'tax_rates');
|
||||
}
|
||||
|
||||
public function transform(User $user)
|
||||
{
|
||||
$account = $user->account;
|
||||
@ -49,6 +136,7 @@ class UserAccountTransformer extends EntityTransformer
|
||||
'invoice_design_id' => (int) $account->invoice_design_id,
|
||||
'quote_design_id' => (int) $account->quote_design_id,
|
||||
'language_id' => (int) $account->language_id,
|
||||
'country_id' => (int) $account->country_id,
|
||||
'invoice_footer' => $account->invoice_footer ?: '',
|
||||
'invoice_labels' => $account->invoice_labels ?: '',
|
||||
'show_item_taxes' => (bool) $account->show_item_taxes,
|
||||
@ -66,7 +154,7 @@ class UserAccountTransformer extends EntityTransformer
|
||||
'payment_terms' => (int) $account->payment_terms,
|
||||
'payment_type_id' => (int) $account->payment_type_id,
|
||||
'task_rate' => (float) $account->task_rate,
|
||||
'inclusive_taxes' => (bool) $account->inclusiveu_taxes,
|
||||
'inclusive_taxes' => (bool) $account->inclusive_taxes,
|
||||
'convert_products' => (bool) $account->convert_products,
|
||||
'custom_invoice_taxes1' => (bool) $account->custom_invoice_taxes1,
|
||||
'custom_invoice_taxes2' => (bool) $account->custom_invoice_taxes1,
|
||||
|
@ -2848,6 +2848,7 @@ $LANG = array(
|
||||
'send_notifications_for' => 'Send Notifications For',
|
||||
'all_invoices' => 'All Invoices',
|
||||
'my_invoices' => 'My Invoices',
|
||||
'mobile_refresh_warning' => 'If you\'re using the mobile app you may need to do a full refresh.',
|
||||
|
||||
);
|
||||
|
||||
|
@ -271,6 +271,8 @@
|
||||
<div class="panel-body">
|
||||
<p><b>{{ trans('texts.purge_data_message') }}</b></p>
|
||||
<br/>
|
||||
<p>{{ trans('texts.mobile_refresh_warning') }}</p>
|
||||
<br/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -434,7 +434,7 @@
|
||||
sweetConfirm(function() {
|
||||
$('#action').val('purge');
|
||||
$('.mainForm').submit();
|
||||
}, "{{ trans('texts.purge_client_warning') . "\\n\\n" . trans('texts.no_undo') }}");
|
||||
}, "{{ trans('texts.purge_client_warning') . "\\n\\n" . trans('texts.mobile_refresh_warning') . "\\n\\n" . trans('texts.no_undo') }}");
|
||||
}
|
||||
|
||||
function showEmailHistory(email) {
|
||||
|
79
resources/views/invoices/view_borderless.blade.php
Normal file
79
resources/views/invoices/view_borderless.blade.php
Normal file
@ -0,0 +1,79 @@
|
||||
@extends('master')
|
||||
|
||||
@section('head')
|
||||
@parent
|
||||
|
||||
@include('money_script')
|
||||
|
||||
@foreach ($invoice->client->account->getFontFolders() as $font)
|
||||
<script src="{{ asset('js/vfs_fonts/'.$font.'.js') }}" type="text/javascript"></script>
|
||||
@endforeach
|
||||
|
||||
<script src="{{ asset('pdf.built.js') }}?no_cache={{ NINJA_VERSION }}" type="text/javascript"></script>
|
||||
|
||||
@stop
|
||||
|
||||
@section('body')
|
||||
<script type="text/javascript">
|
||||
|
||||
window.invoice = {!! $invoice !!};
|
||||
invoice.features = {
|
||||
customize_invoice_design:{{ $invoice->client->account->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN) ? 'true' : 'false' }},
|
||||
remove_created_by:{{ $invoice->client->account->hasFeature(FEATURE_REMOVE_CREATED_BY) ? 'true' : 'false' }},
|
||||
invoice_settings:{{ $invoice->client->account->hasFeature(FEATURE_INVOICE_SETTINGS) ? 'true' : 'false' }}
|
||||
};
|
||||
invoice.is_quote = {{ $invoice->isQuote() ? 'true' : 'false' }};
|
||||
invoice.contact = {!! $contact !!};
|
||||
|
||||
function getPDFString(cb) {
|
||||
return generatePDF(invoice, invoice.invoice_design.javascript, true, cb);
|
||||
}
|
||||
|
||||
if (window.hasOwnProperty('pjsc_meta')) {
|
||||
window['pjsc_meta'].remainingTasks++;
|
||||
}
|
||||
|
||||
function waitForSignature() {
|
||||
if (window.signatureAsPNG || ! invoice.invitations[0].signature_base64) {
|
||||
writePdfAsString();
|
||||
} else {
|
||||
window.setTimeout(waitForSignature, 100);
|
||||
}
|
||||
}
|
||||
|
||||
function writePdfAsString() {
|
||||
doc = getPDFString();
|
||||
doc.getDataUrl(function(pdfString) {
|
||||
document.write(pdfString);
|
||||
document.close();
|
||||
if (window.hasOwnProperty('pjsc_meta')) {
|
||||
window['pjsc_meta'].remainingTasks--;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(function() {
|
||||
@if (Input::has('phantomjs'))
|
||||
@if (Input::has('phantomjs_balances'))
|
||||
document.write(calculateAmounts(invoice).total_amount);
|
||||
document.close();
|
||||
if (window.hasOwnProperty('pjsc_meta')) {
|
||||
window['pjsc_meta'].remainingTasks--;
|
||||
}
|
||||
@else
|
||||
@if ($account->signature_on_pdf)
|
||||
refreshPDF();
|
||||
waitForSignature();
|
||||
@else
|
||||
writePdfAsString();
|
||||
@endif
|
||||
@endif
|
||||
@else
|
||||
refreshPDF();
|
||||
@endif
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@include('invoices.pdf', ['account' => $invoice->client->account])
|
||||
@stop
|
Loading…
x
Reference in New Issue
Block a user