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

View File

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

View File

@ -1,16 +1,18 @@
@extends('layouts.app') @extends('metronic::layouts.app')
@section('htmlheader_title') @section('htmlheader_title')
{{ trans('message.home') }} Order Service
@endsection @endsection
@section('main-content') @section('main-content')
<div class="col-md-12"> <div class="main">
<div class="container">
<div class="col-12">
<h1>Order Service</h1> <h1>Order Service</h1>
<div class="order-page" id="order-page"> <div class="order-page" id="order-page">
<div class="row"> <div class="row">
<div class="col-md-3"> <div class="col-3">
<ul class="tabbable faq-tabbable"> <ul class="tabbable faq-tabbable">
<li class="active"> <li class="active">
<a href="#order_1" data-toggle="tab" aria-expanded="true">Order Service</a> <a href="#order_1" data-toggle="tab" aria-expanded="true">Order Service</a>
@ -18,7 +20,7 @@
</ul> </ul>
</div> </div>
<div class="col-md-9"> <div class="col-9">
<div class="tab-content" style="padding:0; background: #fff;"> <div class="tab-content" style="padding:0; background: #fff;">
<div class="tab-pane active" id="order_1"> <div class="tab-pane active" id="order_1">
<div class="panel-group" id="accordion1"> <div class="panel-group" id="accordion1">
@ -37,9 +39,9 @@
<div class="panel-collapse"> <div class="panel-collapse">
<div class="panel-body"> <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"> <ul class="nav nav-tabs">
<li class="active"> <li class="active">
<a href="#account_exist" data-toggle="tab">Existing Account</a> <a href="#account_exist" data-toggle="tab">Existing Account</a>
@ -93,9 +95,9 @@
<div class="panel-collapse"> <div class="panel-collapse">
<div class="panel-body"> <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"> <ul class="nav nav-tabs">
<li class="active"> <li class="active">
<a href="#account_exist" data-toggle="tab">Existing Account</a> <a href="#account_exist" data-toggle="tab">Existing Account</a>
@ -152,8 +154,8 @@
<div class="panel-collapse"> <div class="panel-collapse">
<div class="panel-body"> <div class="panel-body">
<div class="col-md-12"> <div class="col-12">
<div class="row col-md-6"> <div class="row col-6">
<div class="control-group form-group col-sm-12 {{ $errors->has('order_email_manual') ? 'has-error' : '' }}"> <div class="control-group form-group col-sm-12 {{ $errors->has('order_email_manual') ? 'has-error' : '' }}">
<label for="order_email_manual">Email Address</label> <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') }}"> <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-collapse margin-bottom-20">
<div class="panel-body"> <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' : '' }}"> <div class="control-group form-group col-sm-12 {{ $errors->has('product_options') ? 'has-error' : '' }}">
<span class="help-block">{{ $errors->first('product_options') }}</span> <span class="help-block">{{ $errors->first('product_options') }}</span>
</div> </div>
@ -213,7 +215,7 @@
</div> </div>
</div> </div>
<div class="col-md-12" id="product_order"> <div class="col-12" id="product_order">
@if (old('product_id')) @if (old('product_id'))
@include('widgets.product_order',['o'=>$po]) @include('widgets.product_order',['o'=>$po])
@endif @endif
@ -236,7 +238,7 @@
<div class="panel-collapse margin-bottom-20"> <div class="panel-collapse margin-bottom-20">
<div class="panel-body"> <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' : '' }}"> <div class="control-group form-group col-sm-12 {{ $errors->has('options.notes') ? 'has-error' : '' }}">
<label for="options.notes">Notes</label> <label for="options.notes">Notes</label>
<textarea name="options[notes]" class="form-control" rows="4" placeholder="Enter any special instructions...">{{ old('options.notes') }}</textarea> <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> </div>
</div>
</div>
@endsection @endsection
@section('page-scripts') @section('page-scripts')
@js('/plugin/jqBootstrapValidation/jqBootstrapValidation.js','jq-validation','jquery') @js('plugin/jqBootstrapValidation/jqBootstrapValidation.js','jq-validation','jquery')
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script> @js('//code.jquery.com/ui/1.12.1/jquery-ui.js','jquery-ui-js','jqery')
<script> <script>
$(function () { $("input,select,textarea").not("[type=submit]").jqBootstrapValidation(); } ); $(function () { $("input,select,textarea").not("[type=submit]").jqBootstrapValidation(); } );

View File

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

View File

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