refs #443 Revenue create page new customer and category modal transform.
This commit is contained in:
parent
e83eade56a
commit
41f54e64f6
@ -513,10 +513,10 @@ class Invoices extends Controller
|
||||
*/
|
||||
public function export()
|
||||
{
|
||||
\Excel::create('invoices', function($excel) {
|
||||
\Excel::create('invoices', function ($excel) {
|
||||
$invoices = Invoice::with(['items', 'histories', 'payments', 'totals'])->filter(request()->input())->get();
|
||||
|
||||
$excel->sheet('invoices', function($sheet) use ($invoices) {
|
||||
$excel->sheet('invoices', function ($sheet) use ($invoices) {
|
||||
$sheet->fromModel($invoices->makeHidden([
|
||||
'company_id', 'parent_id', 'created_at', 'updated_at', 'deleted_at', 'attachment', 'discount', 'items', 'histories', 'payments', 'totals', 'media'
|
||||
]));
|
||||
|
61
app/Http/Controllers/Modals/Categories.php
Normal file
61
app/Http/Controllers/Modals/Categories.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Modals;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Setting\Category as Request;
|
||||
use App\Models\Setting\Category;
|
||||
|
||||
class Categories extends Controller
|
||||
{
|
||||
/**
|
||||
* Instantiate a new controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-settings-categories')->only(['create', 'store', 'duplicate', 'import']);
|
||||
$this->middleware('permission:read-settings-categories')->only(['index', 'show', 'edit', 'export']);
|
||||
$this->middleware('permission:update-settings-categories')->only(['update', 'enable', 'disable']);
|
||||
$this->middleware('permission:delete-settings-categories')->only('destroy');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$html = view('modals.categories.create')->render();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'error' => false,
|
||||
'message' => 'null',
|
||||
'html' => $html,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$category = Category::create($request->all());
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.categories', 1)]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'error' => false,
|
||||
'data' => $category,
|
||||
'message' => $message,
|
||||
'html' => 'null',
|
||||
]);
|
||||
}
|
||||
}
|
74
app/Http/Controllers/Modals/Customers.php
Normal file
74
app/Http/Controllers/Modals/Customers.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Modals;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Income\Customer as Request;
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\Income\Customer;
|
||||
use App\Models\Income\Invoice;
|
||||
use App\Models\Income\Revenue;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Utilities\Import;
|
||||
use App\Utilities\ImportFile;
|
||||
use Date;
|
||||
use Illuminate\Http\Request as FRequest;
|
||||
use Illuminate\Pagination\Paginator;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class Customers extends Controller
|
||||
{
|
||||
/**
|
||||
* Instantiate a new controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-incomes-customers')->only(['create', 'store', 'duplicate', 'import']);
|
||||
$this->middleware('permission:read-incomes-customers')->only(['index', 'show', 'edit', 'export']);
|
||||
$this->middleware('permission:update-incomes-customers')->only(['update', 'enable', 'disable']);
|
||||
$this->middleware('permission:delete-incomes-customers')->only('destroy');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$currencies = Currency::enabled()->pluck('name', 'code');
|
||||
|
||||
$html = view('modals.customers.create', compact('currencies'))->render();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'error' => false,
|
||||
'message' => 'null',
|
||||
'html' => $html,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$customer = Customer::create($request->all());
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.customers', 1)]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'error' => false,
|
||||
'data' => $customer,
|
||||
'message' => $message,
|
||||
'html' => 'null',
|
||||
]);
|
||||
}
|
||||
}
|
82
app/Http/Controllers/Modals/Vendors.php
Normal file
82
app/Http/Controllers/Modals/Vendors.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Modals;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Expense\Vendor as Request;
|
||||
use App\Models\Expense\Bill;
|
||||
use App\Models\Expense\Payment;
|
||||
use App\Models\Expense\Vendor;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Traits\Uploads;
|
||||
use App\Utilities\Import;
|
||||
use App\Utilities\ImportFile;
|
||||
use Date;
|
||||
use Illuminate\Pagination\Paginator;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class Vendors extends Controller
|
||||
{
|
||||
use Uploads;
|
||||
|
||||
/**
|
||||
* Instantiate a new controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-expenses-vendors')->only(['create', 'store', 'duplicate', 'import']);
|
||||
$this->middleware('permission:read-expenses-vendors')->only(['index', 'show', 'edit', 'export']);
|
||||
$this->middleware('permission:update-expenses-vendors')->only(['update', 'enable', 'disable']);
|
||||
$this->middleware('permission:delete-expenses-vendors')->only('destroy');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$currencies = Currency::enabled()->pluck('name', 'code');
|
||||
|
||||
$html = view('modals.vendors.create', compact('currencies'))->render();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'error' => false,
|
||||
'message' => 'null',
|
||||
'html' => $html,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$vendor = Vendor::create($request->all());
|
||||
|
||||
// Upload logo
|
||||
if ($request->file('logo')) {
|
||||
$media = $this->getMedia($request->file('logo'), 'vendors');
|
||||
|
||||
$vendor->attachMedia($media, 'logo');
|
||||
}
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.vendors', 1)]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'error' => false,
|
||||
'data' => $vendor,
|
||||
'message' => $message,
|
||||
'html' => 'null',
|
||||
]);
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@
|
||||
|
||||
{{ Form::textGroup('amount', trans('general.amount'), 'money', ['required' => 'required', 'autofocus' => 'autofocus']) }}
|
||||
|
||||
@stack('account_id_input_start')
|
||||
<div class="form-group col-md-6 form-small">
|
||||
{!! Form::label('account_id', trans_choice('general.accounts', 1), ['class' => 'control-label']) !!}
|
||||
<div class="input-group">
|
||||
@ -25,31 +26,36 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@stack('account_id_input_end')
|
||||
|
||||
@stack('customer_id_input_start')
|
||||
<div class="form-group col-md-6">
|
||||
{!! Form::label('customer_id', trans_choice('general.customers', 1), ['class' => 'control-label']) !!}
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon"><i class="fa fa-user"></i></div>
|
||||
{!! Form::select('customer_id', $customers, null, array_merge(['class' => 'form-control', 'placeholder' => trans('general.form.select.field', ['field' => trans_choice('general.customers', 1)])])) !!}
|
||||
<span class="input-group-btn">
|
||||
<button type="button" onclick="createCustomer();" class="btn btn-default btn-icon"><i class="fa fa-plus"></i></button>
|
||||
<button type="button" id="button-customer" class="btn btn-default btn-icon"><i class="fa fa-plus"></i></button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@stack('customer_id_input_end')
|
||||
|
||||
{{ Form::textareaGroup('description', trans('general.description')) }}
|
||||
|
||||
@stack('category_id_input_start')
|
||||
<div class="form-group col-md-6 required {{ $errors->has('category_id') ? 'has-error' : ''}}">
|
||||
{!! Form::label('category_id', trans_choice('general.categories', 1), ['class' => 'control-label']) !!}
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon"><i class="fa fa-folder-open-o"></i></div>
|
||||
{!! Form::select('category_id', $categories, null, array_merge(['class' => 'form-control', 'placeholder' => trans('general.form.select.field', ['field' => trans_choice('general.categories', 1)])])) !!}
|
||||
<div class="input-group-btn">
|
||||
<button type="button" onclick="createCategory();" class="btn btn-default btn-icon"><i class="fa fa-plus"></i></button>
|
||||
<button type="button" id="button-category" class="btn btn-default btn-icon"><i class="fa fa-plus"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
{!! $errors->first('category_id', '<p class="help-block">:message</p>') !!}
|
||||
</div>
|
||||
@stack('category_id_input_end')
|
||||
|
||||
{{ Form::recurring('create') }}
|
||||
|
||||
@ -166,198 +172,31 @@
|
||||
});
|
||||
});
|
||||
|
||||
function createCustomer() {
|
||||
$(document).on('click', '#button-customer', function (e) {
|
||||
$('#modal-create-customer').remove();
|
||||
|
||||
modal = '<div class="modal fade" id="modal-create-customer" style="display: none;">';
|
||||
modal += ' <div class="modal-dialog modal-lg">';
|
||||
modal += ' <div class="modal-content">';
|
||||
modal += ' <div class="modal-header">';
|
||||
modal += ' <h4 class="modal-title">{{ trans('general.title.new', ['type' => trans_choice('general.customers', 1)]) }}</h4>';
|
||||
modal += ' </div>';
|
||||
modal += ' <div class="modal-body">';
|
||||
modal += ' {!! Form::open(['id' => 'form-create-customer', 'role' => 'form']) !!}';
|
||||
modal += ' <div class="row">';
|
||||
modal += ' <div class="form-group col-md-6 required">';
|
||||
modal += ' <label for="name" class="control-label">{{ trans('general.name') }}</label>';
|
||||
modal += ' <div class="input-group">';
|
||||
modal += ' <div class="input-group-addon"><i class="fa fa-id-card-o"></i></div>';
|
||||
modal += ' <input class="form-control" placeholder="{{ trans('general.name') }}" required="required" name="name" type="text" id="name">';
|
||||
modal += ' </div>';
|
||||
modal += ' </div>';
|
||||
modal += ' <div class="form-group col-md-6">';
|
||||
modal += ' <label for="email" class="control-label">{{ trans('general.email') }}</label>';
|
||||
modal += ' <div class="input-group">';
|
||||
modal += ' <div class="input-group-addon"><i class="fa fa-envelope"></i></div>';
|
||||
modal += ' <input class="form-control" placeholder="{{ trans('general.email') }}" name="email" type="text" id="email">';
|
||||
modal += ' </div>';
|
||||
modal += ' </div>';
|
||||
modal += ' <div class="form-group col-md-6">';
|
||||
modal += ' <label for="tax_number" class="control-label">{{ trans('general.tax_number') }}</label>';
|
||||
modal += ' <div class="input-group">';
|
||||
modal += ' <div class="input-group-addon"><i class="fa fa-percent"></i></div>';
|
||||
modal += ' <input class="form-control" placeholder="{{ trans('general.tax_number') }}" name="tax_number" type="text" id="tax_number">';
|
||||
modal += ' </div>';
|
||||
modal += ' </div>';
|
||||
modal += ' <div class="form-group col-md-6 required">';
|
||||
modal += ' <label for="email" class="control-label">{{ trans_choice('general.currencies', 1) }}</label>';
|
||||
modal += ' <div class="input-group">';
|
||||
modal += ' <div class="input-group-addon"><i class="fa fa-exchange"></i></div>';
|
||||
modal += ' <select class="form-control" required="required" id="customer_currency_code" name="currency_code">';
|
||||
modal += ' <option value="">{{ trans('general.form.select.field', ['field' => trans_choice('general.currencies', 1)]) }}</option>';
|
||||
@foreach($currencies as $currency_code => $currency_name)
|
||||
modal += ' <option value="{{ $currency_code }}" {{ (setting('general.default_currency') == $currency_code) ? 'selected' : '' }}>{{ $currency_name }}</option>';
|
||||
@endforeach
|
||||
modal += ' </select>';
|
||||
modal += ' </div>';
|
||||
modal += ' </div>';
|
||||
modal += ' <div class="form-group col-md-12">';
|
||||
modal += ' <label for="address" class="control-label">{{ trans('general.address') }}</label>';
|
||||
modal += ' <textarea class="form-control" placeholder="{{ trans('general.address') }}" rows="3" name="address" cols="50" id="address"></textarea>';
|
||||
modal += ' </div>';
|
||||
modal += ' {!! Form::hidden('enabled', '1', []) !!}';
|
||||
modal += ' </div>';
|
||||
modal += ' {!! Form::close() !!}';
|
||||
modal += ' </div>';
|
||||
modal += ' <div class="modal-footer">';
|
||||
modal += ' <div class="pull-left">';
|
||||
modal += ' {!! Form::button('<span class="fa fa-save"></span> ' . trans('general.save'), ['type' => 'button', 'id' =>'button-create-customer', 'class' => 'btn btn-success']) !!}';
|
||||
modal += ' <button type="button" class="btn btn-default" data-dismiss="modal"><span class="fa fa-times-circle"></span> {{ trans('general.cancel') }}</button>';
|
||||
modal += ' </div>';
|
||||
modal += ' </div>';
|
||||
modal += ' </div>';
|
||||
modal += ' </div>';
|
||||
modal += '</div>';
|
||||
|
||||
$('body').append(modal);
|
||||
|
||||
$("#modal-create-customer #customer_currency_code").select2({
|
||||
placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.currencies', 1)]) }}"
|
||||
});
|
||||
|
||||
$('#modal-create-customer').modal('show');
|
||||
}
|
||||
|
||||
$(document).on('click', '#button-create-customer', function (e) {
|
||||
$('#modal-create-customer .modal-header').before('<span id="span-loading" style="position: absolute; height: 100%; width: 100%; z-index: 99; background: #6da252; opacity: 0.4;"><i class="fa fa-spinner fa-spin" style="font-size: 16em !important;margin-left: 35%;margin-top: 8%;"></i></span>');
|
||||
|
||||
$.ajax({
|
||||
url: '{{ url("incomes/customers/customer") }}',
|
||||
type: 'POST',
|
||||
url: '{{ url("modals/customers/create") }}',
|
||||
type: 'GET',
|
||||
dataType: 'JSON',
|
||||
data: $("#form-create-customer").serialize(),
|
||||
beforeSend: function () {
|
||||
$(".form-group").removeClass("has-error");
|
||||
$(".help-block").remove();
|
||||
},
|
||||
success: function(data) {
|
||||
$('#span-loading').remove();
|
||||
|
||||
$('#modal-create-customer').modal('hide');
|
||||
|
||||
$("#customer_id").append('<option value="' + data.id + '" selected="selected">' + data.name + '</option>');
|
||||
$("#customer_id").select2('refresh');
|
||||
},
|
||||
error: function(error, textStatus, errorThrown) {
|
||||
$('#span-loading').remove();
|
||||
|
||||
if (error.responseJSON.name) {
|
||||
$("#modal-create-customer input[name='name']").parent().parent().addClass('has-error');
|
||||
$("#modal-create-customer input[name='name']").parent().after('<p class="help-block">' + error.responseJSON.name + '</p>');
|
||||
}
|
||||
|
||||
if (error.responseJSON.email) {
|
||||
$("#modal-create-customer input[name='email']").parent().parent().addClass('has-error');
|
||||
$("#modal-create-customer input[name='email']").parent().after('<p class="help-block">' + error.responseJSON.email + '</p>');
|
||||
}
|
||||
|
||||
if (error.responseJSON.currency_code) {
|
||||
$("#modal-create-customer select[name='currency_code']").parent().parent().addClass('has-error');
|
||||
$("#modal-create-customer select[name='currency_code']").parent().after('<p class="help-block">' + error.responseJSON.currency_code + '</p>');
|
||||
success: function(json) {
|
||||
if (json['success']) {
|
||||
$('body').append(json['html']);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function createCategory() {
|
||||
$(document).on('click', '#button-category', function (e) {
|
||||
$('#modal-create-category').remove();
|
||||
|
||||
modal = '<div class="modal fade" id="modal-create-category" style="display: none;">';
|
||||
modal += ' <div class="modal-dialog modal-lg">';
|
||||
modal += ' <div class="modal-content">';
|
||||
modal += ' <div class="modal-header">';
|
||||
modal += ' <h4 class="modal-title">{{ trans('general.title.new', ['type' => trans_choice('general.categories', 1)]) }}</h4>';
|
||||
modal += ' </div>';
|
||||
modal += ' <div class="modal-body">';
|
||||
modal += ' {!! Form::open(['id' => 'form-create-category', 'role' => 'form']) !!}';
|
||||
modal += ' <div class="row">';
|
||||
modal += ' <div class="form-group col-md-6 required">';
|
||||
modal += ' <label for="name" class="control-label">{{ trans('general.name') }}</label>';
|
||||
modal += ' <div class="input-group">';
|
||||
modal += ' <div class="input-group-addon"><i class="fa fa-id-card-o"></i></div>';
|
||||
modal += ' <input class="form-control" placeholder="{{ trans('general.name') }}" required="required" name="name" type="text" id="name">';
|
||||
modal += ' </div>';
|
||||
modal += ' </div>';
|
||||
modal += ' <div class="form-group col-md-6 required">';
|
||||
modal += ' <label for="color" class="control-label">{{ trans('general.color') }}</label>';
|
||||
modal += ' <div id="category-color-picker" class="input-group colorpicker-component">';
|
||||
modal += ' <div class="input-group-addon"><i></i></div>';
|
||||
modal += ' <input class="form-control" value="#00a65a" placeholder="{{ trans('general.color') }}" required="required" name="color" type="text" id="color">';
|
||||
modal += ' </div>';
|
||||
modal += ' </div>';
|
||||
modal += ' {!! Form::hidden('type', 'income', []) !!}';
|
||||
modal += ' {!! Form::hidden('enabled', '1', []) !!}';
|
||||
modal += ' </div>';
|
||||
modal += ' {!! Form::close() !!}';
|
||||
modal += ' </div>';
|
||||
modal += ' <div class="modal-footer">';
|
||||
modal += ' <div class="pull-left">';
|
||||
modal += ' {!! Form::button('<span class="fa fa-save"></span> ' . trans('general.save'), ['type' => 'button', 'id' =>'button-create-category', 'class' => 'btn btn-success']) !!}';
|
||||
modal += ' <button type="button" class="btn btn-default" data-dismiss="modal"><span class="fa fa-times-circle"></span> {{ trans('general.cancel') }}</button>';
|
||||
modal += ' </div>';
|
||||
modal += ' </div>';
|
||||
modal += ' </div>';
|
||||
modal += ' </div>';
|
||||
modal += '</div>';
|
||||
|
||||
$('body').append(modal);
|
||||
|
||||
$('#category-color-picker').colorpicker();
|
||||
|
||||
$('#modal-create-category').modal('show');
|
||||
}
|
||||
|
||||
$(document).on('click', '#button-create-category', function (e) {
|
||||
$('#modal-create-category .modal-header').before('<span id="span-loading" style="position: absolute; height: 100%; width: 100%; z-index: 99; background: #6da252; opacity: 0.4;"><i class="fa fa-spinner fa-spin" style="font-size: 10em !important;margin-left: 35%;margin-top: 8%;"></i></span>');
|
||||
|
||||
$.ajax({
|
||||
url: '{{ url("settings/categories/category") }}',
|
||||
type: 'POST',
|
||||
url: '{{ url("modals/categories/create") }}',
|
||||
type: 'GET',
|
||||
dataType: 'JSON',
|
||||
data: $("#form-create-category").serialize(),
|
||||
beforeSend: function () {
|
||||
$(".form-group").removeClass("has-error");
|
||||
$(".help-block").remove();
|
||||
},
|
||||
success: function(data) {
|
||||
$('#span-loading').remove();
|
||||
|
||||
$('#modal-create-category').modal('hide');
|
||||
|
||||
$("#category_id").append('<option value="' + data.id + '" selected="selected">' + data.name + '</option>');
|
||||
$("#category_id").select2('refresh');
|
||||
},
|
||||
error: function(error, textStatus, errorThrown) {
|
||||
$('#span-loading').remove();
|
||||
|
||||
if (error.responseJSON.name) {
|
||||
$("#modal-create-category input[name='name']").parent().parent().addClass('has-error');
|
||||
$("#modal-create-category input[name='name']").parent().after('<p class="help-block">' + error.responseJSON.name + '</p>');
|
||||
}
|
||||
|
||||
if (error.responseJSON.color) {
|
||||
$("#modal-create-category input[name='color']").parent().parent().addClass('has-error');
|
||||
$("#modal-create-category input[name='color']").parent().after('<p class="help-block">' + error.responseJSON.color + '</p>');
|
||||
success: function(json) {
|
||||
if (json['success']) {
|
||||
$('body').append(json['html']);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
{{ Form::textGroup('amount', trans('general.amount'), 'money', ['required' => 'required', 'autofocus' => 'autofocus']) }}
|
||||
|
||||
@stack('account_id_input_start')
|
||||
<div class="form-group col-md-6 form-small">
|
||||
{!! Form::label('account_id', trans_choice('general.accounts', 1), ['class' => 'control-label']) !!}
|
||||
<div class="input-group">
|
||||
@ -42,6 +43,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@stack('account_id_input_end')
|
||||
|
||||
{{ Form::selectGroup('customer_id', trans_choice('general.customers', 1), 'user', $customers, null, []) }}
|
||||
|
||||
|
82
resources/views/modals/categories/create.blade.php
Normal file
82
resources/views/modals/categories/create.blade.php
Normal file
@ -0,0 +1,82 @@
|
||||
<div class="modal fade" id="modal-create-category" style="display: none;">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">{{ trans('general.title.new', ['type' => trans_choice('general.categories', 1)]) }}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
{!! Form::open(['id' => 'form-create-category', 'role' => 'form']) !!}
|
||||
<div class="row">
|
||||
{{ Form::textGroup('name', trans('general.name'), 'id-card-o') }}
|
||||
|
||||
@stack('color_input_start')
|
||||
<div class="form-group col-md-6 required {{ $errors->has('color') ? 'has-error' : ''}}">
|
||||
{!! Form::label('color', trans('general.color'), ['class' => 'control-label']) !!}
|
||||
<div id="category-color-picker" class="input-group colorpicker-component">
|
||||
<div class="input-group-addon"><i></i></div>
|
||||
{!! Form::text('color', '#00a65a', ['id' => 'color', 'class' => 'form-control', 'required' => 'required']) !!}
|
||||
</div>
|
||||
{!! $errors->first('color', '<p class="help-block">:message</p>') !!}
|
||||
</div>
|
||||
@stack('color_input_end')
|
||||
|
||||
{!! Form::hidden('type', 'income', []) !!}
|
||||
{!! Form::hidden('enabled', '1', []) !!}
|
||||
</div>
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="pull-left">
|
||||
{!! Form::button('<span class="fa fa-save"></span> ' . trans('general.save'), ['type' => 'button', 'id' =>'button-create-category', 'class' => 'btn btn-success']) !!}
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal"><span class="fa fa-times-circle"></span> {{ trans('general.cancel') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$('#modal-create-category').modal('show');
|
||||
|
||||
$('#category-color-picker').colorpicker();
|
||||
});
|
||||
|
||||
$(document).on('click', '#button-create-category', function (e) {
|
||||
$('#modal-create-category .modal-header').before('<span id="span-loading" style="position: absolute; height: 100%; width: 100%; z-index: 99; background: #6da252; opacity: 0.4;"><i class="fa fa-spinner fa-spin" style="font-size: 10em !important;margin-left: 35%;margin-top: 8%;"></i></span>');
|
||||
|
||||
$.ajax({
|
||||
url: '{{ url("modals/categories") }}',
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
data: $("#form-create-category").serialize(),
|
||||
beforeSend: function () {
|
||||
$(".form-group").removeClass("has-error");
|
||||
$(".help-block").remove();
|
||||
},
|
||||
success: function(json) {
|
||||
var data = json['data'];
|
||||
|
||||
$('#span-loading').remove();
|
||||
|
||||
$('#modal-create-category').modal('hide');
|
||||
|
||||
$("#category_id").append('<option value="' + data.id + '" selected="selected">' + data.name + '</option>');
|
||||
$("#category_id").select2('refresh');
|
||||
},
|
||||
error: function(error, textStatus, errorThrown) {
|
||||
$('#span-loading').remove();
|
||||
|
||||
if (error.responseJSON.name) {
|
||||
$("#modal-create-category input[name='name']").parent().parent().addClass('has-error');
|
||||
$("#modal-create-category input[name='name']").parent().after('<p class="help-block">' + error.responseJSON.name + '</p>');
|
||||
}
|
||||
|
||||
if (error.responseJSON.color) {
|
||||
$("#modal-create-category input[name='color']").parent().parent().addClass('has-error');
|
||||
$("#modal-create-category input[name='color']").parent().after('<p class="help-block">' + error.responseJSON.color + '</p>');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
85
resources/views/modals/customers/create.blade.php
Normal file
85
resources/views/modals/customers/create.blade.php
Normal file
@ -0,0 +1,85 @@
|
||||
<div class="modal fade" id="modal-create-customer" style="display: none;">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">{{ trans('general.title.new', ['type' => trans_choice('general.customers', 1)]) }}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
{!! Form::open(['id' => 'form-create-customer', 'role' => 'form']) !!}
|
||||
<div class="row">
|
||||
{{ Form::textGroup('name', trans('general.name'), 'id-card-o') }}
|
||||
|
||||
{{ Form::textGroup('email', trans('general.email'), 'envelope', []) }}
|
||||
|
||||
{{ Form::textGroup('tax_number', trans('general.tax_number'), 'percent', []) }}
|
||||
|
||||
{{ Form::selectGroup('currency_code', trans_choice('general.currencies', 1), 'exchange', $currencies, setting('general.default_currency')) }}
|
||||
|
||||
{{ Form::textareaGroup('address', trans('general.address')) }}
|
||||
|
||||
{!! Form::hidden('enabled', '1', []) !!}
|
||||
</div>
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="pull-left">
|
||||
{!! Form::button('<span class="fa fa-save"></span> ' . trans('general.save'), ['type' => 'button', 'id' =>'button-create-customer', 'class' => 'btn btn-success']) !!}
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal"><span class="fa fa-times-circle"></span> {{ trans('general.cancel') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$('#modal-create-customer').modal('show');
|
||||
|
||||
$("#modal-create-customer #currency_code").select2({
|
||||
placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.currencies', 1)]) }}"
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '#button-create-customer', function (e) {
|
||||
$('#modal-create-customer .modal-header').before('<span id="span-loading" style="position: absolute; height: 100%; width: 100%; z-index: 99; background: #6da252; opacity: 0.4;"><i class="fa fa-spinner fa-spin" style="font-size: 16em !important;margin-left: 35%;margin-top: 8%;"></i></span>');
|
||||
|
||||
$.ajax({
|
||||
url: '{{ url("modals/customers") }}',
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
data: $("#form-create-customer").serialize(),
|
||||
beforeSend: function () {
|
||||
$(".form-group").removeClass("has-error");
|
||||
$(".help-block").remove();
|
||||
},
|
||||
success: function(json) {
|
||||
var data = json['data'];
|
||||
|
||||
$('#span-loading').remove();
|
||||
|
||||
$('#modal-create-customer').modal('hide');
|
||||
|
||||
$("#customer_id").append('<option value="' + data.id + '" selected="selected">' + data.name + '</option>');
|
||||
$("#customer_id").select2('refresh');
|
||||
},
|
||||
error: function(error, textStatus, errorThrown) {
|
||||
$('#span-loading').remove();
|
||||
|
||||
if (error.responseJSON.name) {
|
||||
$("#modal-create-customer input[name='name']").parent().parent().addClass('has-error');
|
||||
$("#modal-create-customer input[name='name']").parent().after('<p class="help-block">' + error.responseJSON.name + '</p>');
|
||||
}
|
||||
|
||||
if (error.responseJSON.email) {
|
||||
$("#modal-create-customer input[name='email']").parent().parent().addClass('has-error');
|
||||
$("#modal-create-customer input[name='email']").parent().after('<p class="help-block">' + error.responseJSON.email + '</p>');
|
||||
}
|
||||
|
||||
if (error.responseJSON.currency_code) {
|
||||
$("#modal-create-customer select[name='currency_code']").parent().parent().addClass('has-error');
|
||||
$("#modal-create-customer select[name='currency_code']").parent().after('<p class="help-block">' + error.responseJSON.currency_code + '</p>');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
@ -161,6 +161,12 @@ Route::group(['middleware' => 'language'], function () {
|
||||
Route::resource('updates', 'Install\Updates');
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'modals'], function () {
|
||||
Route::resource('categories', 'Modals\Categories');
|
||||
Route::resource('customers', 'Modals\Customers');
|
||||
Route::resource('vendors', 'Modals\Vendors');
|
||||
});
|
||||
|
||||
/* @deprecated */
|
||||
Route::post('items/items/totalItem', 'Common\Items@totalItem');
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user