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,16 +1,18 @@
@extends('layouts.app')
@extends('metronic::layouts.app')
@section('htmlheader_title')
{{ trans('message.home') }}
Order Service
@endsection
@section('main-content')
<div class="col-md-12">
<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">
<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>
@ -18,7 +20,7 @@
</ul>
</div>
<div class="col-md-9">
<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">
@ -37,9 +39,9 @@
<div class="panel-collapse">
<div class="panel-body">
<div class="col-md-12 margin-bottom-20">
<div class="col-12 margin-bottom-20">
<div class="col-md-6">
<div class="col-6">
<ul class="nav nav-tabs">
<li class="active">
<a href="#account_exist" data-toggle="tab">Existing Account</a>
@ -93,9 +95,9 @@
<div class="panel-collapse">
<div class="panel-body">
<div class="col-md-12 margin-bottom-20">
<div class="col-12 margin-bottom-20">
<div class="col-md-6">
<div class="col-6">
<ul class="nav nav-tabs">
<li class="active">
<a href="#account_exist" data-toggle="tab">Existing Account</a>
@ -152,8 +154,8 @@
<div class="panel-collapse">
<div class="panel-body">
<div class="col-md-12">
<div class="row col-md-6">
<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">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') }}">
@ -179,7 +181,7 @@
<div class="panel-collapse margin-bottom-20">
<div class="panel-body">
<div class="col-md-12">
<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>
@ -213,7 +215,7 @@
</div>
</div>
<div class="col-md-12" id="product_order">
<div class="col-12" id="product_order">
@if (old('product_id'))
@include('widgets.product_order',['o'=>$po])
@endif
@ -236,7 +238,7 @@
<div class="panel-collapse margin-bottom-20">
<div class="panel-body">
<div class="col-md-12">
<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>
@ -264,11 +266,13 @@
</div>
</div>
</div>
</div>
</div>
@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">
<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']);