Working on L5

This commit is contained in:
Hillel Coren 2015-04-06 14:46:02 +03:00
parent 8fc578ef39
commit 424eb15870
6 changed files with 32 additions and 109 deletions

View File

@ -101,23 +101,6 @@ class AccountGatewayController extends BaseController
$selectedCards = $accountGateway ? $accountGateway->accepted_credit_cards : 0;
$account = Auth::user()->account;
// $recommendedGateways = Gateway::remember(DEFAULT_QUERY_CACHE)
// ->where('recommended', '=', '1')
$recommendedGateways = Gateway::where('recommended', '=', '1')
->orderBy('sort_order')
->get();
$recommendedGatewayArray = array();
foreach ($recommendedGateways as $recommendedGateway) {
$arrayItem = array(
'value' => $recommendedGateway->id,
'other' => 'false',
'data-imageUrl' => asset($recommendedGateway->getLogoUrl()),
'data-siteUrl' => $recommendedGateway->site_url,
);
$recommendedGatewayArray[$recommendedGateway->name] = $arrayItem;
}
$creditCardsArray = unserialize(CREDIT_CARDS);
$creditCards = [];
foreach ($creditCardsArray as $card => $name) {
@ -128,14 +111,6 @@ class AccountGatewayController extends BaseController
}
}
$otherItem = array(
'value' => 1000000,
'other' => 'true',
'data-imageUrl' => '',
'data-siteUrl' => '',
);
$recommendedGatewayArray['Other Options'] = $otherItem;
$account->load('account_gateways');
$currentGateways = $account->account_gateways;
$gateways = Gateway::where('payment_library_id', '=', 1)->orderBy('name');
@ -172,7 +147,6 @@ class AccountGatewayController extends BaseController
'accountGateway' => $accountGateway,
'config' => false,
'gateways' => $gateways,
'recommendedGateways' => $recommendedGatewayArray,
'creditCardTypes' => $creditCards,
'tokenBillingOptions' => $tokenBillingOptions,
'showBreadcrumbs' => false,
@ -200,9 +174,7 @@ class AccountGatewayController extends BaseController
public function save($accountGatewayPublicId = false)
{
$rules = array();
$recommendedId = Input::get('recommendedGateway_id');
$gatewayId = ($recommendedId == 1000000 ? Input::get('gateway_id') : $recommendedId);
$gatewayId = Input::get('gateway_id');
if (!$gatewayId) {
Session::flash('error', trans('validation.required', ['attribute' => 'gateway']));

View File

@ -6,6 +6,12 @@ use DB;
use Datatable;
use Utils;
use URL;
use View;
use Input;
use Session;
use Redirect;
use App\Models\Product;
class ProductController extends BaseController
{

View File

@ -174,6 +174,7 @@ class ConstantsSeeder extends Seeder
DateFormat::create(array('format' => 'Y-M-d', 'picker_format' => 'yyyy-M-dd', 'label' => '2013-03-10'));
PaymentLibrary::create(['name' => 'Omnipay']);
PaymentLibrary::create(['name' => 'PHP-Payments [Deprecated]']);
/*
d, dd: Numeric date, no leading zero and leading zero, respectively. Eg, 5, 05.

View File

@ -22,26 +22,11 @@
@endif
@endif
<div class="two-column">
{!! Former::checkboxes('creditCardTypes[]')->label('Accepted Credit Cards')
->checkboxes($creditCardTypes)->class('creditcard-types')
!!}
</div>
<p/>&nbsp;<p/>
<div style="display:{{ $accountGateway ? 'none' : '' }}">
<div class="two-column" style="display:{{ $onlyPayPal ? 'none' : '' }}">
{!! Former::radios('recommendedGateway_id')->label('Recommended Gateway')
->radios($recommendedGateways)->class('recommended-gateway')
!!}
</div>
{!! Former::select('gateway_id')->label('Select Gateway')->addOption('', '')
->dataClass('gateway-dropdown')
->fromQuery($gateways, 'name', 'id')
->onchange('setFieldsShown()'); !!}
</div>
@foreach ($gateways as $gateway)
@ -64,7 +49,7 @@
<div class="form-group">
<label class="control-label col-lg-4 col-sm-4"></label>
<div class="col-lg-8 col-sm-8 help-block">
{{ $gateway->getHelp() }}
{!! $gateway->getHelp() !!}
</div>
</div>
@endif
@ -76,30 +61,25 @@
@endforeach
{!! Former::checkboxes('creditCardTypes[]')->label('Accepted Credit Cards')
->checkboxes($creditCardTypes)->class('creditcard-types')
!!}
<p/>&nbsp;<p/>
{!! Former::actions(
Button::success('Save')->submit()->large()->appendIcon(Icon::create('floppy-disk')),
$countGateways > 0 ? Button::lg_default_link('company/payments', 'Cancel')->append_with_icon('remove-circle') : false) !!}
Button::success(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk')),
$countGateways > 0 ? Button::normal(trans('texts.cancel'))->large()->asLinkTo('/company/payments')->appendIcon(Icon::create('remove-circle')) : false) !!}
{!! Former::close() !!}
<script type="text/javascript">
function setFieldsShown() {
var recommendedVal = $('input:radio[name=recommendedGateway_id]:checked').val();
var gatewayVal = $('#gateway_id').val();
var val = recommendedVal && recommendedVal != 1000000 ? recommendedVal : gatewayVal;
var val = $('#gateway_id').val();
$('.gateway-fields').hide();
$('#gateway_' + val + '_div').show();
$('#gateway_id').parent().parent().hide();
if(!$('input:radio[name=recommendedGateway_id][value!=1000000]:checked').val())
{
$('.recommended-gateway[value=1000000]').attr('checked', true);
$('#gateway_id').parent().parent().show();
}
}
function gatewayLink(url) {
@ -109,44 +89,6 @@
}
}
$(document).ready(function() {
$('.recommended-gateway').change(
function(){
var recVal = $(this).val();
if(recVal == 1000000)
{
$('#gateway_id').parent().parent().show();
}
else
{
$('#gateway_id').parent().parent().hide();
}
setFieldsShown();
}
);
$('.recommended-gateway[other != true]').each(function(){
var contents = $(this).parent().contents();
contents[contents.length - 1].nodeValue = '';
$(this).after('<img src="' +$(this).attr('data-imageUrl') + '" /><br />');
$(this).parent().children().last().after('<a href="#" onclick="gatewayLink(\'' + $(this).attr('data-siteUrl') + '\')" style="padding-left:26px">Create an account</a>');
});
// TODO: THIS IS JUST TO SHOW THE IMAGES, STYLE IS SET INLINE STYLE
$('.creditcard-types').each(function(){
var contents = $(this).parent().contents();
contents[contents.length - 1].nodeValue = '';
$(this).after('<img style="width: 60px; display: inline;" src="' +$(this).attr('data-imageUrl') + '" /><br />');
});
setFieldsShown();
$('.two-column .form-group .col-lg-8').removeClass('col-lg-8');
$('.two-column .form-group .col-sm-8').removeClass('col-sm-8');
});
</script>
@stop

View File

@ -62,9 +62,11 @@
{!! Former::legend('users') !!}
{!! Former::text('first_name') !!}
{!! Former::text('last_name') !!}
{!! Former::text('email') !!}
{!! Former::text('email') !!}
{!! Former::text('phone') !!}
{!! Former::actions(Button::primary(trans('texts.change_password'), ['onclick'=>'showChangePassword()']))->small() !!}
@if (Auth::user()->confirmed)
{!! Former::actions( Button::primary(trans('texts.change_password'))->small()->withAttributes(['onclick'=>'showChangePassword()'])) !!}
@endif
@endif
{!! Former::legend('localization') !!}

View File

@ -3,28 +3,28 @@
@section('content')
@parent
{{ Former::open($url)->method($method)
{!! Former::open($url)->method($method)
->rules(['product_key' => 'required|max:20'])
->addClass('col-md-8 col-md-offset-2 warn-on-exit') }}
->addClass('col-md-8 col-md-offset-2 warn-on-exit') !!}
{{ Former::legend($title) }}
{!! Former::legend($title) !!}
@if ($product)
{{ Former::populate($product) }}
{{ Former::populateField('cost', number_format($product->cost, 2, '.', '')) }}
@endif
{{ Former::text('product_key')->label('texts.product') }}
{{ Former::textarea('notes')->data_bind("value: wrapped_notes, valueUpdate: 'afterkeydown'") }}
{{ Former::text('cost') }}
{!! Former::text('product_key')->label('texts.product') !!}
{!! Former::textarea('notes')->data_bind("value: wrapped_notes, valueUpdate: 'afterkeydown'") !!}
{!! Former::text('cost') !!}
{{ Former::actions(
Button::lg_success_submit(trans('texts.save'))->append_with_icon('floppy-disk'),
Button::lg_default_link('company/products', trans('texts.cancel'))->append_with_icon('remove-circle')
) }}
{!! Former::actions(
Button::success(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk')),
Button::normal(trans('texts.cancel'))->large()->asLinkTo('/company/products')->appendIcon(Icon::create('remove-circle'))
) !!}
{{ Former::close() }}
{!! Former::close() !!}
<script type="text/javascript">