Fixes for ordering

This commit is contained in:
Deon George 2021-07-09 11:39:27 +10:00
parent 24ff62094a
commit a9f81373fa
No known key found for this signature in database
GPG Key ID: 7670E8DC27415254
5 changed files with 255 additions and 251 deletions

View File

@ -40,9 +40,7 @@ class OrderController extends Controller
public function submit(Request $request)
{
Validator::make($request->all(),[
'product_id'=>'required|exists:ab_product,id',
])
Validator::make($request->all(),['product_id'=>'required|exists:ab_product,id'])
// Reseller
->sometimes('account_id','required|email',function($input) use ($request) {
return is_null($input->account_id) AND is_null($input->order_email_manual);
@ -63,15 +61,13 @@ class OrderController extends Controller
// Check we have the custom attributes for the product
$options = $po->orderValidation($request);
if ($request->input('order_email_manual'))
{
if ($request->input('order_email_manual')) {
$uo = User::firstOrNew(['email'=>$request->input('order_email_manual')]);
// If this is a new client
if (! $uo->exists)
{
if (! $uo->exists) {
// @todo Make this automatic
$uo->site_id = config('SITE')->id;
$uo->site_id = config('SITE')->site_id;
$uo->active = FALSE;
$uo->firstname = '';
$uo->lastname = '';
@ -83,12 +79,11 @@ class OrderController extends Controller
}
// If we have a new account.
if (is_null($request->input('account_id')))
{
if (is_null($request->input('account_id'))) {
$ao = new Account;
//$ao->id = Account::NextId();
// @todo Make this automatic
$ao->site_id = config('SITE')->id;
$ao->site_id = config('SITE')->site_id;
$ao->country_id = config('SITE')->country_id; // @todo This might be wrong
$ao->language_id = config('SITE')->language_id; // @todo This might be wrong
$ao->currency_id = config('SITE')->currency_id; // @todo This might be wrong
@ -102,15 +97,15 @@ class OrderController extends Controller
$so = new Service;
// @todo Make this automatic
$so->site_id = config('SITE')->id;
$so->site_id = config('SITE')->site_id;
$so->product_id = $request->input('product_id');
$so->order_status = 'ORDER-SUBMIT';
$so->orderby_id = Auth::id();
$so->model = get_class($options);
if ($options->order_info)
{
if ($options->order_info) {
$so->order_info = $options->order_info;
unset($options->order_info);
}

View File

@ -43,7 +43,7 @@ trait OrderServiceOptions
$o->forceFill(array_undot($x));
// @todo Make this automatic
$o->site_id = config('SITE')->id;
$o->site_id = config('SITE')->site_id;
return $o;
}

View File

@ -1,263 +1,267 @@
@extends('layouts.app')
@extends('metronic::layouts.app')
@section('htmlheader_title')
{{ trans('message.home') }}
Order Service
@endsection
@section('main-content')
<div class="col-md-12">
<h1>Order Service</h1>
<div class="main">
<div class="container">
<div class="col-12">
<h1>Order Service</h1>
<div class="order-page" id="order-page">
<div class="row">
<div class="col-md-3">
<ul class="tabbable faq-tabbable">
<li class="active">
<a href="#order_1" data-toggle="tab" aria-expanded="true">Order Service</a>
</li>
</ul>
</div>
<div class="order-page" id="order-page">
<div class="row">
<div class="col-3">
<ul class="tabbable faq-tabbable">
<li class="active">
<a href="#order_1" data-toggle="tab" aria-expanded="true">Order Service</a>
</li>
</ul>
</div>
<div class="col-md-9">
<div class="tab-content" style="padding:0; background: #fff;">
<div class="tab-pane active" id="order_1">
<div class="panel-group" id="accordion1">
<form role="form" method="POST" enctype="multipart/form-data">
{{ csrf_field() }}
<div class="col-9">
<div class="tab-content" style="padding:0; background: #fff;">
<div class="tab-pane active" id="order_1">
<div class="panel-group" id="accordion1">
<form role="form" method="POST" enctype="multipart/form-data">
{{ csrf_field() }}
<div id="accordion">
<!-- Reseller Choose Client -->
@if (Auth::user() AND Auth::user()->isReseller())
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
Account
</h4>
</div>
<div id="accordion">
<!-- Reseller Choose Client -->
@if (Auth::user() AND Auth::user()->isReseller())
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
Account
</h4>
</div>
<div class="panel-collapse">
<div class="panel-body">
<div class="col-md-12 margin-bottom-20">
<div class="panel-collapse">
<div class="panel-body">
<div class="col-12 margin-bottom-20">
<div class="col-md-6">
<ul class="nav nav-tabs">
<li class="active">
<a href="#account_exist" data-toggle="tab">Existing Account</a>
</li>
<li>
<a href="#client_new" data-toggle="tab">New Client</a>
</li>
</ul>
<div class="col-6">
<ul class="nav nav-tabs">
<li class="active">
<a href="#account_exist" data-toggle="tab">Existing Account</a>
</li>
<li>
<a href="#client_new" data-toggle="tab">New Client</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane row fade in active" id="account_exist">
<div class="control-group form-group col-sm-12 {{ $errors->has('account_id') ? 'has-error' : '' }}">
<label for="account_id">Client Account</label>
<select class="form-control" id="account_id" name="account_id">
<option value="">&nbsp;</option>
@foreach ($user->all_accounts()->sortBy('name') as $o)
<option value="{{ $o->id }}" @if($o->id == old('account_id')) selected @endif>{{ $o->name }}</option>
@endforeach
</select>
<span class="help-block">{{ $errors->first('account_id') }}</span>
<div class="tab-content">
<div class="tab-pane row fade in active" id="account_exist">
<div class="control-group form-group col-sm-12 {{ $errors->has('account_id') ? 'has-error' : '' }}">
<label for="account_id">Client Account</label>
<select class="form-control" id="account_id" name="account_id">
<option value="">&nbsp;</option>
@foreach ($user->all_accounts()->sortBy('name') as $o)
<option value="{{ $o->id }}" @if($o->id == old('account_id')) selected @endif>{{ $o->name }}</option>
@endforeach
</select>
<span class="help-block">{{ $errors->first('account_id') }}</span>
</div>
</div>
<div class="tab-pane row fade" id="client_new">
<div class="control-group form-group col-sm-12 {{ $errors->has('order_email_manual') ? 'has-error' : '' }}">
<label for="order_email_manual">New Client Email</label>
<input type="email" class="form-control" id="order_email_manual" name="order_email_manual" placeholder="New Client Email" value="{{ old('order_email_manual') }}">
<span class="help-block">{{ $errors->first('order_email_manual') }}</span>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane row fade" id="client_new">
<div class="row">
<div class="col-sm-2"><button class="btn btn-block btn-primary">Previous</button></div>
<div class="col-sm-2"><button class="btn btn-block btn-primary next">Next</button></div>
</div>
</div>
</div>
</div>
<!-- Non-Authed User -->
@elseif (Auth::user())
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
Account
</h4>
</div>
<div class="panel-collapse">
<div class="panel-body">
<div class="col-12 margin-bottom-20">
<div class="col-6">
<ul class="nav nav-tabs">
<li class="active">
<a href="#account_exist" data-toggle="tab">Existing Account</a>
</li>
<li>
<a href="#account_new" data-toggle="tab">New Account</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane row fade in active" id="account_exist">
<div class="control-group form-group col-sm-12 {{ $errors->has('account_id') ? 'has-error' : '' }}">
<label for="account_id">Existing Account</label>
<select class="form-control" id="account_id" name="account_id">
<option value="">&nbsp;</option>
@foreach ($user->accounts->sortBy('name') as $o)
<option value="{{ $o->id }}" @if($o->id == old('account_id')) selected @endif>{{ $o->name }}</option>
@endforeach
</select>
<span class="help-block">{{ $errors->first('account_id') }}</span>
</div>
</div>
<div class="tab-pane row fade" id="account_new">
<div class="control-group form-group col-sm-12 {{ $errors->has('account_name') ? 'has-error' : '' }}">
<label for="account_name">Account Name</label>
<input type="text" class="form-control" id="account_name" name="account_name" placeholder="New Account Name" value="{{ old('order_email_manual') }}" disabled>
<span class="help-block">{{ $errors->first('account_name') }}</span>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-2"><button class="btn btn-block btn-primary">Previous</button></div>
<div class="col-sm-2"><button class="btn btn-block btn-primary next">Next</button></div>
</div>
</div>
</div>
</div>
<!-- Non-Authed User -->
@else
@php
//dd($errors);
@endphp
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
Account
</h4>
</div>
<div class="panel-collapse">
<div class="panel-body">
<div class="col-12">
<div class="row col-6">
<div class="control-group form-group col-sm-12 {{ $errors->has('order_email_manual') ? 'has-error' : '' }}">
<label for="order_email_manual">New Client Email</label>
<input type="email" class="form-control" id="order_email_manual" name="order_email_manual" placeholder="New Client Email" value="{{ old('order_email_manual') }}">
<label for="order_email_manual">Email Address</label>
<input type="email" class="form-control" id="order_email_manual" name="order_email_manual" placeholder="Email Address" value="{{ old('order_email_manual') }}">
<span class="help-block">{{ $errors->first('order_email_manual') }}</span>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-2"><button class="btn btn-block btn-primary">Previous</button></div>
<div class="col-sm-2"><button class="btn btn-block btn-primary next">Next</button></div>
</div>
</div>
</div>
</div>
<!-- Non-Authed User -->
@elseif (Auth::user())
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
Account
</h4>
</div>
<div class="panel-collapse">
<div class="panel-body">
<div class="col-md-12 margin-bottom-20">
<div class="col-md-6">
<ul class="nav nav-tabs">
<li class="active">
<a href="#account_exist" data-toggle="tab">Existing Account</a>
</li>
<li>
<a href="#account_new" data-toggle="tab">New Account</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane row fade in active" id="account_exist">
<div class="control-group form-group col-sm-12 {{ $errors->has('account_id') ? 'has-error' : '' }}">
<label for="account_id">Existing Account</label>
<select class="form-control" id="account_id" name="account_id">
<option value="">&nbsp;</option>
@foreach ($user->accounts->sortBy('name') as $o)
<option value="{{ $o->id }}" @if($o->id == old('account_id')) selected @endif>{{ $o->name }}</option>
@endforeach
</select>
<span class="help-block">{{ $errors->first('account_id') }}</span>
</div>
</div>
<div class="tab-pane row fade" id="account_new">
<div class="control-group form-group col-sm-12 {{ $errors->has('account_name') ? 'has-error' : '' }}">
<label for="account_name">Account Name</label>
<input type="text" class="form-control" id="account_name" name="account_name" placeholder="New Account Name" value="{{ old('order_email_manual') }}" disabled>
<span class="help-block">{{ $errors->first('account_name') }}</span>
</div>
</div>
<div class="row">
<div class="col-sm-2"><button class="btn btn-block btn-primary">Previous</button></div>
<div class="col-sm-2"><button class="btn btn-block btn-primary next">Next</button></div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-2"><button class="btn btn-block btn-primary">Previous</button></div>
<div class="col-sm-2"><button class="btn btn-block btn-primary next">Next</button></div>
</div>
</div>
</div>
</div>
@endif
<!-- Non-Authed User -->
@else
@php
//dd($errors);
@endphp
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
Account
</h4>
</div>
<!-- Product -->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">Product</h4>
</div>
<div class="panel-collapse">
<div class="panel-body">
<div class="col-md-12">
<div class="row col-md-6">
<div class="control-group form-group col-sm-12 {{ $errors->has('order_email_manual') ? 'has-error' : '' }}">
<label for="order_email_manual">Email Address</label>
<input type="email" class="form-control" id="order_email_manual" name="order_email_manual" placeholder="Email Address" value="{{ old('order_email_manual') }}">
<span class="help-block">{{ $errors->first('order_email_manual') }}</span>
<div class="panel-collapse margin-bottom-20">
<div class="panel-body">
<div class="col-12">
<div class="control-group form-group col-sm-12 {{ $errors->has('product_options') ? 'has-error' : '' }}">
<span class="help-block">{{ $errors->first('product_options') }}</span>
</div>
<div class="control-group form-group col-sm-6 {{ $errors->has('product_id') ? 'has-error' : '' }}">
<label for="product_id">Product</label>
<select class="form-control" id="product_id" name="product_id">
<option value="">&nbsp;</option>
@php
$po = $selected = NULL;
@endphp
@foreach (\App\Models\Product::active()->get()->sortBy('name') as $o)
@php
if ($o->id == old('product_id'))
{
$selected = 'selected';
$po = $o;
} else {
$selected = NULL;
}
@endphp
<option value="{{ $o->id }}" {{ $selected }}>{{ $o->name }}</option>
@endforeach
</select>
<span class="help-block">{{ $errors->first('product_id') }}</span>
</div>
<div class="col-sm-6" id="product_info">
@if (old('product_id'))
@include('widgets.product_description',['o'=>$po])
@endif
</div>
</div>
</div>
<div class="row">
<div class="col-sm-2"><button class="btn btn-block btn-primary">Previous</button></div>
<div class="col-sm-2"><button class="btn btn-block btn-primary next">Next</button></div>
<div class="col-12" id="product_order">
@if (old('product_id'))
@include('widgets.product_order',['o'=>$po])
@endif
</div>
<div class="row">
<div class="col-sm-2"><button class="btn btn-block btn-primary">Previous</button></div>
<div class="col-sm-2"><button class="btn btn-block btn-primary next">Next</button></div>
</div>
</div>
</div>
</div>
<!-- Additional Notes -->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">Notes</h4>
</div>
<div class="panel-collapse margin-bottom-20">
<div class="panel-body">
<div class="col-12">
<div class="control-group form-group col-sm-12 {{ $errors->has('options.notes') ? 'has-error' : '' }}">
<label for="options.notes">Notes</label>
<textarea name="options[notes]" class="form-control" rows="4" placeholder="Enter any special instructions...">{{ old('options.notes') }}</textarea>
<span class="help-block">{{ $errors->first('options.notes') }}</span>
</div>
</div>
<div class="row">
<div class="col-sm-2"><button class="btn btn-block btn-primary">Previous</button></div>
<div class="col-sm-2 pull-right"><input type="submit" class="btn btn-block btn-primary" value="Submit Order"></div>
</div>
</div>
</div>
</div>
</div>
@endif
<!-- Product -->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">Product</h4>
</div>
<div class="panel-collapse margin-bottom-20">
<div class="panel-body">
<div class="col-md-12">
<div class="control-group form-group col-sm-12 {{ $errors->has('product_options') ? 'has-error' : '' }}">
<span class="help-block">{{ $errors->first('product_options') }}</span>
</div>
<div class="control-group form-group col-sm-6 {{ $errors->has('product_id') ? 'has-error' : '' }}">
<label for="product_id">Product</label>
<select class="form-control" id="product_id" name="product_id">
<option value="">&nbsp;</option>
@php
$po = $selected = NULL;
@endphp
@foreach (\App\Models\Product::active()->get()->sortBy('name') as $o)
@php
if ($o->id == old('product_id'))
{
$selected = 'selected';
$po = $o;
} else {
$selected = NULL;
}
@endphp
<option value="{{ $o->id }}" {{ $selected }}>{{ $o->name }}</option>
@endforeach
</select>
<span class="help-block">{{ $errors->first('product_id') }}</span>
</div>
<div class="col-sm-6" id="product_info">
@if (old('product_id'))
@include('widgets.product_description',['o'=>$po])
@endif
</div>
</div>
<div class="col-md-12" id="product_order">
@if (old('product_id'))
@include('widgets.product_order',['o'=>$po])
@endif
</div>
<div class="row">
<div class="col-sm-2"><button class="btn btn-block btn-primary">Previous</button></div>
<div class="col-sm-2"><button class="btn btn-block btn-primary next">Next</button></div>
</div>
</div>
</div>
</div>
<!-- Additional Notes -->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">Notes</h4>
</div>
<div class="panel-collapse margin-bottom-20">
<div class="panel-body">
<div class="col-md-12">
<div class="control-group form-group col-sm-12 {{ $errors->has('options.notes') ? 'has-error' : '' }}">
<label for="options.notes">Notes</label>
<textarea name="options[notes]" class="form-control" rows="4" placeholder="Enter any special instructions...">{{ old('options.notes') }}</textarea>
<span class="help-block">{{ $errors->first('options.notes') }}</span>
</div>
</div>
<div class="row">
<div class="col-sm-2"><button class="btn btn-block btn-primary">Previous</button></div>
<div class="col-sm-2 pull-right"><input type="submit" class="btn btn-block btn-primary" value="Submit Order"></div>
</div>
</div>
</div>
</div>
</form>
</div>
</form>
</div>
</div>
</div>
<div class="tab-pane" id="tab-2">
<div class="tab-pane" id="tab-2">
</div>
</div>
</div>
</div>
</div>
@ -267,8 +271,8 @@
@endsection
@section('page-scripts')
@js('/plugin/jqBootstrapValidation/jqBootstrapValidation.js','jq-validation','jquery')
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
@js('plugin/jqBootstrapValidation/jqBootstrapValidation.js','jq-validation','jquery')
@js('//code.jquery.com/ui/1.12.1/jquery-ui.js','jquery-ui-js','jqery')
<script>
$(function () { $("input,select,textarea").not("[type=submit]").jqBootstrapValidation(); } );

View File

@ -1,12 +1,16 @@
@extends('layouts.app')
@extends('metronic::layouts.app')
@section('htmlheader_title')
{{ trans('message.home') }}
Order Received
@endsection
@section('main-content')
<div class="col-md-12">
<h2>Order Service</h2>
<p>Your order has been received - #{{ $o->id }}. An email will be sent to you with as your order progresses.</p>
<div class="main">
<div class="container">
<div class="col-12">
<h2>Order Service</h2>
<p>Your order has been received - #{{ $o->id }}. An email will be sent to you with as your order progresses.</p>
</div>
</div>
</div>
@endsection

View File

@ -5,6 +5,7 @@ use App\Http\Controllers\{AdminController,
CheckoutController,
HomeController,
MediaController,
OrderController,
PaypalController,
SearchController,
WelcomeController};
@ -98,12 +99,12 @@ Route::group(['middleware'=>['theme:adminlte-be'],'prefix'=>'u'],function() {
// Frontend Routes (Non-Authed Users)
Route::group(['middleware'=>['theme:metronic-fe']],function() {
Route::get('/',[WelcomeController::class,'home']);
Route::get('order','OrderController@index');
Route::post('order','OrderController@submit');
Route::get('order',[OrderController::class,'index']);
Route::post('order',[OrderController::class,'submit']);
});
Route::get('product_order/{o}','OrderController@product_order');
Route::get('product_info/{o}','OrderController@product_info');
Route::get('product_order/{o}',[OrderController::class,'product_order']);
Route::get('product_info/{o}',[OrderController::class,'product_info']);
Route::redirect('home','u/home');
Route::get('search',[SearchController::class,'search']);