1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-19 16:01:34 +02:00

Add bulk invoice button to products

This commit is contained in:
Hillel Coren 2017-11-03 10:19:03 +02:00
parent d5411e3f08
commit a5f4a369ab
17 changed files with 129 additions and 101 deletions

View File

@ -159,7 +159,16 @@ class ProductController extends BaseController
{
$action = Input::get('action');
$ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids');
$count = $this->productService->bulk($ids, $action);
if ($action == 'invoice') {
$products = Product::scope($ids)->get();
foreach ($products as $product) {
$data[] = $product->product_key;
}
return redirect("invoices/create")->with('selectedProducts', $data);
} else {
$count = $this->productService->bulk($ids, $action);
}
$message = Utils::pluralize($action.'d_product', $count);
Session::flash('message', $message);

View File

@ -16,7 +16,7 @@ class ActivityDatatable extends EntityDatatable
function ($model) {
$str = Utils::timestampToDateTimeString(strtotime($model->created_at));
if ($model->contact_id && $model->ip != '127.0.0.1') {
if ($model->contact_id && ! in_array($model->ip, ['127.0.0.1', '192.168.255.33'])) {
$ipLookUpLink = IP_LOOKUP_URL . $model->ip;
$str .= sprintf(' &nbsp; <i class="fa fa-globe" style="cursor:pointer" title="%s" onclick="openUrl(\'%s\', \'IP Lookup\')"></i>', $model->ip, $ipLookUpLink);
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -28,7 +28,7 @@ border-bottom: 1px solid #dfe0e1;
.redlink:hover { color:#c13b25; }
.buttons { margin: 25px 0; }
.buttons .btn { margin: 0 6px; }
.buttons .btn { margin: 0 4px; }
/*forms*/
.form-group {

View File

@ -179,41 +179,40 @@
</div>
</div>
<p/>&nbsp;<p/>
@if (Auth::user()->hasFeature(FEATURE_EXPENSES))
{!! Former::actions(
count(Cache::get('banks')) > 0 ?
<center class="buttons">
{!! count(Cache::get('banks')) > 0 ?
Button::normal(trans('texts.cancel'))
->withAttributes([
'data-bind' => 'visible: !importResults()',
])
->large()
->asLinkTo(URL::to('/settings/bank_accounts'))
->appendIcon(Icon::create('remove-circle')) : false,
Button::success(trans('texts.validate'))
->appendIcon(Icon::create('remove-circle')) : false !!}
{!! Button::success(trans('texts.validate'))
->withAttributes([
'data-bind' => 'css: {disabled: disableValidate}, visible: page() == "login"',
'onclick' => 'validate()'
])
->large()
->appendIcon(Icon::create('lock')),
Button::success(trans('texts.save'))
->appendIcon(Icon::create('lock')) !!}
{!! Button::success(trans('texts.save'))
->withAttributes([
'data-bind' => 'css: {disabled: disableSave}, visible: page() == "setup"',
'style' => 'display:none',
'onclick' => 'save()'
])
->large()
->appendIcon(Icon::create('floppy-disk')) ,
Button::success(trans('texts.import'))
->appendIcon(Icon::create('floppy-disk')) !!}
{!! Button::success(trans('texts.import'))
->withAttributes([
'data-bind' => 'css: {disabled: disableSaveExpenses}, visible: page() == "import"',
'style' => 'display:none',
'onclick' => 'saveExpenses()'
])
->large()
->appendIcon(Icon::create('floppy-disk'))) !!}
->appendIcon(Icon::create('floppy-disk')) !!}
</center>
@endif
{!! Former::close() !!}

View File

@ -305,25 +305,22 @@
</div>
</div>
<br/>
{!! Former::actions(
$account->getCustomDesign(CUSTOM_DESIGN1) ?
<center class="buttons">
{!! $account->getCustomDesign(CUSTOM_DESIGN1) ?
DropdownButton::primary(trans('texts.customize'))
->withContents($account->present()->customDesigns)
->large() :
Button::primary(trans('texts.customize'))
->appendIcon(Icon::create('edit'))
->asLinkTo(URL::to('/settings/customize_design') . '?design_id=' . CUSTOM_DESIGN1)
->large(),
Auth::user()->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN) ?
->large() !!}
{!! Auth::user()->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN) ?
Button::success(trans('texts.save'))
->submit()->large()
->appendIcon(Icon::create('floppy-disk'))
->withAttributes(['class' => 'save-button']) :
false
) !!}
<br/>
false !!}
</center>
{!! Former::close() !!}

View File

@ -55,10 +55,11 @@
</div>
{!! Former::actions(
Button::success(trans('texts.save'))
<center class="buttons">
{!! Button::success(trans('texts.save'))
->submit()->large()
->appendIcon(Icon::create('floppy-disk'))) !!}
->appendIcon(Icon::create('floppy-disk')) !!}
</center>
{!! Former::close() !!}

View File

@ -1,58 +1,58 @@
@extends('header')
@section('content')
@parent
@parent
{!! Former::open($url)->method($method)
->rules(['product_key' => 'required|max:255'])
->addClass('col-md-10 col-md-offset-1 warn-on-exit') !!}
{!! Former::open($url)
->method($method)
->rules(['product_key' => 'required|max:255'])
->addClass('col-md-10 col-md-offset-1 warn-on-exit') !!}
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{!! $title !!}</h3>
</div>
<div class="panel-body form-padding-right">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{!! $title !!}</h3>
</div>
<div class="panel-body form-padding-right">
@if ($product)
{{ Former::populate($product) }}
{{ Former::populateField('cost', Utils::roundSignificant($product->cost)) }}
@endif
@if ($product)
{{ Former::populate($product) }}
{{ Former::populateField('cost', Utils::roundSignificant($product->cost)) }}
@endif
{!! Former::text('product_key')->label('texts.product') !!}
{!! Former::textarea('notes')->rows(6) !!}
{!! Former::text('product_key')->label('texts.product') !!}
{!! Former::textarea('notes')->rows(6) !!}
@if ($account->hasFeature(FEATURE_INVOICE_SETTINGS))
@if ($account->custom_invoice_item_label1)
{!! Former::text('custom_value1')->label(e($account->custom_invoice_item_label1)) !!}
@endif
@if ($account->custom_invoice_item_label2)
{!! Former::text('custom_value2')->label(e($account->custom_invoice_item_label2)) !!}
@endif
@endif
@if ($account->hasFeature(FEATURE_INVOICE_SETTINGS))
@if ($account->custom_invoice_item_label1)
{!! Former::text('custom_value1')->label(e($account->custom_invoice_item_label1)) !!}
@endif
@if ($account->custom_invoice_item_label2)
{!! Former::text('custom_value2')->label(e($account->custom_invoice_item_label2)) !!}
@endif
@endif
{!! Former::text('cost') !!}
{!! Former::text('cost') !!}
@if ($account->invoice_item_taxes)
@include('partials.tax_rates')
@endif
@if ($account->invoice_item_taxes)
@include('partials.tax_rates')
@endif
</div>
</div>
</div>
</div>
<center class="buttons">
{!! Button::normal(trans('texts.cancel'))->large()->asLinkTo(HTMLUtils::previousUrl('/products'))->appendIcon(Icon::create('remove-circle')) !!}
{!! Button::success(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk')) !!}
</center>
{!! Former::actions(
Button::normal(trans('texts.cancel'))->large()->asLinkTo(HTMLUtils::previousUrl('/products'))->appendIcon(Icon::create('remove-circle')),
Button::success(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk'))
) !!}
{!! Former::close() !!}
{!! Former::close() !!}
<script type="text/javascript">
<script type="text/javascript">
$(function() {
$('#product_key').focus();
});
$(function() {
$('#product_key').focus();
});
</script>
</script>
@stop

View File

@ -39,10 +39,10 @@
</div>
</div>
{!! Former::actions(
Button::normal(trans('texts.cancel'))->large()->asLinkTo(URL::to('/settings/tax_rates'))->appendIcon(Icon::create('remove-circle')),
Button::success(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk'))
) !!}
<center class="buttons">
{!! Button::normal(trans('texts.cancel'))->large()->asLinkTo(URL::to('/settings/tax_rates'))->appendIcon(Icon::create('remove-circle')) !!}
{!! Button::success(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk')) !!}
</center>
{!! Former::close() !!}

View File

@ -1,6 +1,6 @@
@extends('header')
@section('content')
@section('content')
@parent
@include('accounts.nav', ['selected' => ACCOUNT_API_TOKENS])
@ -15,7 +15,7 @@
<div class="panel-body form-padding-right">
@if ($token)
{!! Former::populate($token) !!}
{!! Former::populate($token) !!}
@endif
{!! Former::text('name') !!}
@ -24,10 +24,10 @@
</div>
@if (Auth::user()->hasFeature(FEATURE_API))
{!! Former::actions(
Button::normal(trans('texts.cancel'))->asLinkTo(URL::to('/settings/api_tokens'))->appendIcon(Icon::create('remove-circle'))->large(),
Button::success(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk'))
) !!}
<center class="buttons">
{!! Button::normal(trans('texts.cancel'))->asLinkTo(URL::to('/settings/api_tokens'))->appendIcon(Icon::create('remove-circle'))->large() !!}
{!! Button::success(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk')) !!}
</center>
@else
<script>
$(function() {
@ -35,7 +35,7 @@
});
</script>
@endif
{!! Former::close() !!}
@ -43,4 +43,4 @@
@section('onReady')
$('#name').focus();
@stop
@stop

View File

@ -96,7 +96,7 @@
@include('accounts.partials.notifications')
@endif
<center>
<center class="buttons">
@if (Auth::user()->confirmed)
{!! Button::primary(trans('texts.change_password'))
->appendIcon(Icon::create('lock'))

View File

@ -503,8 +503,7 @@
</div>
</div>
<p>&nbsp;</p>
<div class="form-actions">
<center class="buttons">
<div style="display:none">
{!! Former::populateField('entityType', $entityType) !!}
@ -565,8 +564,7 @@
@endif
@endif
</div>
<p>&nbsp;</p>
</center>
@include('invoices.pdf', ['account' => Auth::user()->account, 'hide_pdf' => ! Auth::user()->account->live_preview])
@ -913,6 +911,7 @@
item.task_public_id(task.publicId);
}
model.invoice().has_tasks(true);
NINJA.formIsChanged = true;
@endif
@if (isset($expenses) && $expenses)
@ -937,8 +936,31 @@
}
model.invoice().invoice_items_without_tasks.push(blank);
model.invoice().has_expenses(true);
NINJA.formIsChanged = true;
@endif
@if ($selectedProducts = session('selectedProducts'))
// move the blank invoice line item to the end
var blank = model.invoice().invoice_items_without_tasks.pop();
var productMap = {};
for (var i=0; i<products.length; i++) {
var product = products[i];
productMap[product.product_key] = product;
}
var selectedProducts = {!! json_encode($selectedProducts) !!}
for (var i=0; i<selectedProducts.length; i++) {
var productKey = selectedProducts[i];
product = productMap[productKey];
if (product) {
var item = model.invoice().addItem();
item.loadData(product);
item.qty(1);
}
}
model.invoice().invoice_items_without_tasks.push(blank);
NINJA.formIsChanged = true;
@endif
@endif
// display blank instead of '0'

View File

@ -864,7 +864,7 @@ function ItemModel(data) {
owner: this
});
if (data) {
self.loadData = function(data) {
ko.mapping.fromJS(data, {}, this);
var precision = getPrecision(this.cost());
var cost = parseFloat(this.cost());
@ -876,6 +876,10 @@ function ItemModel(data) {
this.qty(roundSignificant(this.qty()));
}
if (data) {
self.loadData(data);
}
this.totals = ko.observable();
this.totals.rawTotal = ko.computed(function() {

View File

@ -8,14 +8,11 @@
</div>
<div class="pull-left">
@can('create', 'invoice')
@if ($entityType == ENTITY_TASK)
@if (in_array($entityType, [ENTITY_TASK, ENTITY_INVOICE, ENTITY_PRODUCT]))
@can('create', 'invoice')
{!! Button::primary(trans('texts.invoice'))->withAttributes(['class'=>'invoice', 'onclick' =>'submitForm_'.$entityType.'("invoice")'])->appendIcon(Icon::create('check')) !!}
@endif
@if ($entityType == ENTITY_EXPENSE)
{!! Button::primary(trans('texts.invoice'))->withAttributes(['class'=>'invoice', 'onclick' =>'submitForm_'.$entityType.'("invoice")'])->appendIcon(Icon::create('check')) !!}
@endif
@endcan
@endcan
@endif
{!! DropdownButton::normal(trans('texts.archive'))
->withContents($datatable->bulkActions())

View File

@ -171,7 +171,7 @@
@endif
<center>
<center class="buttons">
{!! DropdownButton::primary(trans('texts.export'))
->large()
->withAttributes(array('id' => 'export-button'))
@ -185,8 +185,7 @@
->submit()
->appendIcon(Icon::create('play'))
->large() !!}
</center><br/>
</center>
{!! Former::close() !!}

View File

@ -77,11 +77,11 @@
</div>
</div>
{!! Former::actions(
Button::normal(trans('texts.cancel'))->asLinkTo(URL::to('/settings/user_management'))->appendIcon(Icon::create('remove-circle'))->large(),
($user) ? Button::success(trans('texts.save'))->withAttributes(['onclick' => 'submitAction("save")'])->large()->appendIcon(Icon::create('floppy-disk')) : false,
(! $user || ! $user->confirmed) ? Button::info(trans($user ? 'texts.resend_invite' : 'texts.send_invite'))->withAttributes(['onclick' => 'submitAction("email")'])->large()->appendIcon(Icon::create('send')) : false
)!!}
<center class="buttons">
{!! Button::normal(trans('texts.cancel'))->asLinkTo(URL::to('/settings/user_management'))->appendIcon(Icon::create('remove-circle'))->large() !!}
{!! ($user) ? Button::success(trans('texts.save'))->withAttributes(['onclick' => 'submitAction("save")'])->large()->appendIcon(Icon::create('floppy-disk')) : false !!}
{!! (! $user || ! $user->confirmed) ? Button::info(trans($user ? 'texts.resend_invite' : 'texts.send_invite'))->withAttributes(['onclick' => 'submitAction("email")'])->large()->appendIcon(Icon::create('send')) : false !!}
</center>
{!! Former::close() !!}