mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 03:44:35 -04:00
Working on Javascript front end
This commit is contained in:
parent
3829a874aa
commit
df5778c3c5
@ -49,7 +49,7 @@ class InvoiceController extends Controller
|
|||||||
return '<a href="/client/invoices/'. $invoice->hashed_id .'/edit" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a>';
|
return '<a href="/client/invoices/'. $invoice->hashed_id .'/edit" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a>';
|
||||||
})
|
})
|
||||||
->addColumn('checkbox', function ($invoice){
|
->addColumn('checkbox', function ($invoice){
|
||||||
return '<input type="checkbox" name="bulk" value="'. $invoice->hashed_id .'"/>';
|
return '<input type="checkbox" name="hashed_ids[]" value="'. $invoice->hashed_id .'"/>';
|
||||||
})
|
})
|
||||||
->rawColumns(['checkbox', 'action'])
|
->rawColumns(['checkbox', 'action'])
|
||||||
->make(true);
|
->make(true);
|
||||||
|
@ -14,6 +14,7 @@ namespace App\Models;
|
|||||||
use App\DataMapper\ClientSettings;
|
use App\DataMapper\ClientSettings;
|
||||||
use App\DataMapper\CompanySettings;
|
use App\DataMapper\CompanySettings;
|
||||||
use App\Filters\QueryFilters;
|
use App\Filters\QueryFilters;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
use App\Utils\Traits\UserSessionAttributes;
|
use App\Utils\Traits\UserSessionAttributes;
|
||||||
use Hashids\Hashids;
|
use Hashids\Hashids;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
@ -22,6 +23,7 @@ use Illuminate\Support\Facades\Log;
|
|||||||
|
|
||||||
class BaseModel extends Model
|
class BaseModel extends Model
|
||||||
{
|
{
|
||||||
|
use MakesHash;
|
||||||
use UserSessionAttributes;
|
use UserSessionAttributes;
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
|
||||||
@ -29,8 +31,18 @@ class BaseModel extends Model
|
|||||||
///const CREATED_AT = 'creation_date';
|
///const CREATED_AT = 'creation_date';
|
||||||
//const UPDATED_AT = 'last_update';
|
//const UPDATED_AT = 'last_update';
|
||||||
|
|
||||||
|
protected $appends = [
|
||||||
|
'hashed_id'
|
||||||
|
];
|
||||||
|
|
||||||
protected $dateFormat = 'Y-m-d H:i:s.u';
|
protected $dateFormat = 'Y-m-d H:i:s.u';
|
||||||
|
|
||||||
|
public function getHashedIdAttribute()
|
||||||
|
{
|
||||||
|
return $this->encodePrimaryKey($this->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function __call($method, $params)
|
public function __call($method, $params)
|
||||||
{
|
{
|
||||||
$entity = strtolower(class_basename($this));
|
$entity = strtolower(class_basename($this));
|
||||||
|
@ -37,22 +37,17 @@ class Client extends BaseModel
|
|||||||
|
|
||||||
protected $presenter = 'App\Models\Presenters\ClientPresenter';
|
protected $presenter = 'App\Models\Presenters\ClientPresenter';
|
||||||
|
|
||||||
protected $appends = [
|
|
||||||
];
|
protected $hidden = [
|
||||||
/*
|
|
||||||
protected $guarded = [
|
|
||||||
'id',
|
'id',
|
||||||
'updated_at',
|
'private_notes',
|
||||||
'created_at',
|
'user_id',
|
||||||
'deleted_at',
|
'company_id',
|
||||||
'contacts',
|
'backup',
|
||||||
'primary_contact',
|
'settings',
|
||||||
'q',
|
'last_login',
|
||||||
'company',
|
'private_notes'
|
||||||
'country',
|
|
||||||
'shipping_country'
|
|
||||||
];
|
];
|
||||||
*/
|
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name',
|
'name',
|
||||||
|
@ -60,7 +60,14 @@ class Company extends BaseModel
|
|||||||
'settings',
|
'settings',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $appends = [
|
protected $hidden = [
|
||||||
|
'id',
|
||||||
|
'settings',
|
||||||
|
'account_id',
|
||||||
|
'company_key',
|
||||||
|
'db',
|
||||||
|
'domain',
|
||||||
|
'ip',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
|
@ -14,7 +14,6 @@ namespace App\Models;
|
|||||||
use App\Models\Currency;
|
use App\Models\Currency;
|
||||||
use App\Models\Filterable;
|
use App\Models\Filterable;
|
||||||
use App\Utils\Traits\MakesDates;
|
use App\Utils\Traits\MakesDates;
|
||||||
use App\Utils\Traits\MakesHash;
|
|
||||||
use App\Utils\Traits\NumberFormatter;
|
use App\Utils\Traits\NumberFormatter;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
@ -22,7 +21,6 @@ use Illuminate\Support\Carbon;
|
|||||||
|
|
||||||
class Invoice extends BaseModel
|
class Invoice extends BaseModel
|
||||||
{
|
{
|
||||||
use MakesHash;
|
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
use Filterable;
|
use Filterable;
|
||||||
use NumberFormatter;
|
use NumberFormatter;
|
||||||
@ -30,11 +28,12 @@ class Invoice extends BaseModel
|
|||||||
|
|
||||||
protected $hidden = [
|
protected $hidden = [
|
||||||
'id',
|
'id',
|
||||||
'private_notes'
|
'private_notes',
|
||||||
];
|
'user_id',
|
||||||
|
'client_id',
|
||||||
protected $appends = [
|
'company_id',
|
||||||
'hashed_id'
|
'backup',
|
||||||
|
'settings',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
@ -89,11 +88,6 @@ class Invoice extends BaseModel
|
|||||||
const STATUS_UNPAID = -2;
|
const STATUS_UNPAID = -2;
|
||||||
const STATUS_REVERSED = -3;
|
const STATUS_REVERSED = -3;
|
||||||
|
|
||||||
public function getHashedIdAttribute()
|
|
||||||
{
|
|
||||||
return $this->encodePrimaryKey($this->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function company()
|
public function company()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Company::class);
|
return $this->belongsTo(Company::class);
|
||||||
|
@ -6,7 +6,7 @@ use Faker\Generator as Faker;
|
|||||||
|
|
||||||
$factory->define(App\Models\Invoice::class, function (Faker $faker) {
|
$factory->define(App\Models\Invoice::class, function (Faker $faker) {
|
||||||
return [
|
return [
|
||||||
'status_id' => App\Models\Invoice::STATUS_DRAFT,
|
'status_id' => App\Models\Invoice::STATUS_SENT,
|
||||||
'invoice_number' => $faker->text(256),
|
'invoice_number' => $faker->text(256),
|
||||||
'discount' => $faker->numberBetween(1,10),
|
'discount' => $faker->numberBetween(1,10),
|
||||||
'is_amount_discount' => $faker->boolean(),
|
'is_amount_discount' => $faker->boolean(),
|
||||||
|
@ -15,21 +15,22 @@
|
|||||||
|
|
||||||
<div class="pull-left">
|
<div class="pull-left">
|
||||||
|
|
||||||
<button class="btn btn-dark">{{ctrans('texts.download')}}</button>
|
{!! Former::dark_button(ctrans('texts.download'))->addClass('download_invoices') !!}
|
||||||
<button class="btn btn-success">{{ctrans('texts.pay_now')}}</button>
|
{!! Former::success_button(ctrans('texts.pay_now'))->addClass('pay_invoices') !!}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Filters / Buttons in here.-->
|
<!-- Filters / Buttons in here.-->
|
||||||
<div id="top_right_buttons" class="pull-right">
|
<div id="top_right_buttons" class="pull-right">
|
||||||
|
|
||||||
<input id="tableFilter_invoice" type="text" style="width:180px;background-color: white !important"
|
<input id="table_filter" type="text" style="width:180px;background-color: white !important"
|
||||||
class="form-control pull-left" placeholder="Filter" value=""/>
|
class="form-control pull-left" placeholder="Filter" value=""/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="animated fadeIn">
|
<div class="animated fadeIn">
|
||||||
<div class="col-md-12 card">
|
<div class="col-md-12 card">
|
||||||
|
|
||||||
{!! $html->table(['class' => 'table table-hover table-striped', 'id' => 'invoice-table'], true) !!}
|
{!! $html->table(['class' => 'table table-hover table-striped', 'id' => 'datatable'], true) !!}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -49,8 +50,12 @@
|
|||||||
|
|
||||||
@section('footer')
|
@section('footer')
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
var data;
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
$('#invoice-table').DataTable({
|
|
||||||
|
$('#datatable').DataTable({
|
||||||
processing: true,
|
processing: true,
|
||||||
serverSide: true,
|
serverSide: true,
|
||||||
searching: false,
|
searching: false,
|
||||||
@ -64,6 +69,11 @@ $(function() {
|
|||||||
zeroRecords: "{{ trans('texts.no_records_found') }}"
|
zeroRecords: "{{ trans('texts.no_records_found') }}"
|
||||||
},
|
},
|
||||||
ajax: '{!! route('client.invoices.index') !!}',
|
ajax: '{!! route('client.invoices.index') !!}',
|
||||||
|
drawCallback: function(settings){
|
||||||
|
|
||||||
|
data = this.api().ajax.json().data;
|
||||||
|
|
||||||
|
},
|
||||||
columns: [
|
columns: [
|
||||||
|
|
||||||
{data: 'checkbox', name: 'checkbox', title: '<input type="checkbox" class="select_all">', searchable: false, orderable: false},
|
{data: 'checkbox', name: 'checkbox', title: '<input type="checkbox" class="select_all">', searchable: false, orderable: false},
|
||||||
@ -78,24 +88,38 @@ $(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
</script defer>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
$('#tableFilter_invoice').on('keyup', function(){
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
$("#datatable").on('change', 'input[type=checkbox]', function() {
|
||||||
|
var selected = [];
|
||||||
|
$.each($("input[name='hashed_ids[]']:checked"), function(){
|
||||||
|
selected.push($(this).val());
|
||||||
|
});
|
||||||
|
alert("Selected hashed_ids: " + selected.join(", "));
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#table_filter').on('keyup', function(){
|
||||||
|
alert('filter');
|
||||||
|
});
|
||||||
|
|
||||||
$('.select_all').change(function() {
|
$('.select_all').change(function() {
|
||||||
$(this).closest('table').find(':checkbox:not(:disabled)').prop('checked', this.checked);
|
$(this).closest('table').find(':checkbox:not(:disabled)').prop('checked', this.checked);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('.pay_invoices').click(function() {
|
||||||
|
alert('pay');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.download_invoices').click(function() {
|
||||||
|
alert('download');
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user