Commit ab9c859b by Francisco Salazar

cargar values en variables extra, mail, distancia de envio

parent aad411a8
...@@ -25,6 +25,7 @@ use Onestartup\Shop\Model\OrderTracking as Tracking; ...@@ -25,6 +25,7 @@ use Onestartup\Shop\Model\OrderTracking as Tracking;
use Onestartup\Shop\Model\ConfiguracionFactura as Config; use Onestartup\Shop\Model\ConfiguracionFactura as Config;
use Onestartup\Shop\Model\ProductTag as TagCatalog; use Onestartup\Shop\Model\ProductTag as TagCatalog;
use Onestartup\Shop\Libs\Util; use Onestartup\Shop\Libs\Util;
use App\CodigoPostal;
use Onestartup\Shop\Requests\RequestProduct; use Onestartup\Shop\Requests\RequestProduct;
use Onestartup\Shop\Requests\RequestProductInfo; use Onestartup\Shop\Requests\RequestProductInfo;
...@@ -324,6 +325,16 @@ class AdminProductController extends Controller ...@@ -324,6 +325,16 @@ class AdminProductController extends Controller
if ($client->shipping != null) { if ($client->shipping != null) {
$shipping = $client->shipping; $shipping = $client->shipping;
$shipping_price = $shipping->shipping_price; $shipping_price = $shipping->shipping_price;
$origin = CodigoPostal::where("postal_code", 67150)->first();
$destination = CodigoPostal::where("postal_code", $addres->cp)->first();
$total_cart = 0;
foreach($sale->products()->get() as $p){
$total_cart += $p->infoSale->sale_price * $p->pivot->quantity;
}
$distance = $this->envio($total_cart, $destination, $origin);
} }
...@@ -346,7 +357,7 @@ class AdminProductController extends Controller ...@@ -346,7 +357,7 @@ class AdminProductController extends Controller
if ($sale->status == 4) { if ($sale->status == 4) {
$estado = "Cancelado/Reembolsado"; $estado = "Cancelado/Reembolsado";
} }
return $distance;
return view('shop::clients.orden') return view('shop::clients.orden')
->with('sale', $sale) ->with('sale', $sale)
->with('client', $client) ->with('client', $client)
...@@ -354,7 +365,8 @@ class AdminProductController extends Controller ...@@ -354,7 +365,8 @@ class AdminProductController extends Controller
->with('estado', $estado) ->with('estado', $estado)
->with('promo', $promo) ->with('promo', $promo)
->with('shipping_price', $shipping_price) ->with('shipping_price', $shipping_price)
->with('variable', $variable) ->with('variable', $variable)
->with('distance', $distance)
->with('shipping', $shipping); ->with('shipping', $shipping);
} }
...@@ -705,4 +717,36 @@ class AdminProductController extends Controller ...@@ -705,4 +717,36 @@ class AdminProductController extends Controller
->with('message_success', 'Información actualizada'); ->with('message_success', 'Información actualizada');
} }
private function envio($total, $destination, $origin){
$distancia = 0;
if ($total > 5000){
if ($destination->state_code == "NLE" && ($destination->county_code == "6" || $destination->county_code == "39" || $destination->county_code == "26" || $destination->county_code == "46" || $destination->county_code == "21" || $destination->county_code == "48" || $destination->county_code == "19" || $destination->county_code == "31")) {
$distancia = 0;
}else{
$distancia = ceil($this->Distance($origin->latitude, $origin->longitude, $destination->latitude, $destination->longitude, "K"));
}
}else{
$distancia = ceil($this->Distance($origin->latitude, $origin->longitude, $destination->latitude, $destination->longitude, "K"));
}
return $distancia;
}
private function Distance($lat1, $lon1, $lat2, $lon2, $unit) {
$radius = 6378.137; // earth mean radius defined by WGS84
$dlon = $lon1 - $lon2;
$distance = acos( sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($dlon))) * $radius;
if ($unit == "K") {
return ($distance);
} else if ($unit == "M") {
return ($distance * 0.621371192);
} else if ($unit == "N") {
return ($distance * 0.539956803);
} else {
return 0;
}
}
} }
...@@ -173,9 +173,7 @@ public function shipping() ...@@ -173,9 +173,7 @@ public function shipping()
$cart = \Session::get('cart'); $cart = \Session::get('cart');
$total = $this->total(); $total = $this->total();
$shipping = Shipping::select( $shipping = Shipping::pluck('name', 'id');
\DB::raw("CONCAT(name,' $',cost) AS name"),'id')
->pluck('name', 'id');
return view('shop-public::cart.shipping') return view('shop-public::cart.shipping')
...@@ -186,7 +184,7 @@ public function shipping() ...@@ -186,7 +184,7 @@ public function shipping()
->with('shipping', $shipping); ->with('shipping', $shipping);
} }
public function storeClient(Client $request) public function storeClient(Request $request)
{ {
$client = new Client(); $client = new Client();
$addres = new Addres(); $addres = new Addres();
......
@php
$var=explode(",",$extra->values);
$value_array = [];
foreach($var as $result) {
$value_array[$result] = $result;
}
@endphp
<div class="form-group"> <div class="form-group">
{!! Form::label('variable', 'Variable') !!} {!! Form::label('variable', 'Variable') !!}
{!! Form::select('variable', $variables, null, ["class"=>"form-control", "required"=>"required", "placeholder"=>"Elija una variable"]) !!} {!! Form::select('variable', $variables, null, ["class"=>"form-control", "required"=>"required", "placeholder"=>"Elija una variable"]) !!}
...@@ -16,7 +23,7 @@ ...@@ -16,7 +23,7 @@
<div class="form-group" id="select-values" style="display: none;"> <div class="form-group" id="select-values" style="display: none;">
{!! Form::label('values', 'Valores del select: ', ['class'=>'control-label'])!!} {!! Form::label('values', 'Valores del select: ', ['class'=>'control-label'])!!}
{{ isset($extra->values) ? $extra->values : null }} {{ isset($extra->values) ? $extra->values : null }}
{!! Form::select('values[]', [], isset($extra->values) ? explode(",",$extra->values) : null, ["id"=>"values", "multiple"=>"multiple", "style"=>"width:100%;"]) !!} {!! Form::select('values[]', $value_array, isset($extra->values) ? explode(",",$extra->values) : null, ["id"=>"values", "multiple"=>"multiple", "style"=>"width:100%;"]) !!}
</div> </div>
<div class="form-group"> <div class="form-group">
......
...@@ -68,7 +68,6 @@ Envio: ...@@ -68,7 +68,6 @@ Envio:
@if($variable != null) @if($variable != null)
@component('mail::panel') @component('mail::panel')
Datos adicionales: Datos adicionales:
{{$variable->alias1 != null ? '- '.$variable->alias1.': ' : ''}} {{$additional->extra1 != null ? '*** '.$additional->extra1.' ***' : ''}} {{$variable->alias1 != null ? '- '.$variable->alias1.': ' : ''}} {{$additional->extra1 != null ? '*** '.$additional->extra1.' ***' : ''}}
{{$variable->alias2 != null ? '- '.$variable->alias2.': ' : ''}} {{$additional->extra2 != null ? '*** '.$additional->extra2.' ***' : ''}} {{$variable->alias2 != null ? '- '.$variable->alias2.': ' : ''}} {{$additional->extra2 != null ? '*** '.$additional->extra2.' ***' : ''}}
{{$variable->alias3 != null ? '- '.$variable->alias3.': ' : ''}} {{$additional->extra3 != null ? '*** '.$additional->extra3.' ***' : ''}} {{$variable->alias3 != null ? '- '.$variable->alias3.': ' : ''}} {{$additional->extra3 != null ? '*** '.$additional->extra3.' ***' : ''}}
......
...@@ -65,28 +65,25 @@ setlocale(LC_MONETARY, 'en_US'); ...@@ -65,28 +65,25 @@ setlocale(LC_MONETARY, 'en_US');
{!! Form::hidden('additional', true) !!} {!! Form::hidden('additional', true) !!}
<div class="form-group"> <div class="form-group">
{!! Form::label('extra1', 'Fecha de envío', ['class'=>'']) !!} {!! Form::label('extra1', 'Fecha de envío', ['class'=>'']) !!}
{!! Form::text('extra1', null, ['class'=>'form-control', 'required'=>'required']) !!} {!! Form::text('extra1', null, ['class'=>'form-control' ]) !!}
</div> </div>
<div> <div>
{!! Form::label('extra2', 'Hora de envío', ['class'=>'']) !!} {!! Form::label('extra2', 'Hora de envío', ['class'=>'']) !!}
{!! Form::text('extra2', null, ['class'=>'form-control', 'required'=>'required']) !!} {!! Form::text('extra2', null, ['class'=>'form-control']) !!}
</div> </div>
<div> <div>
{!! Form::label('extra3', 'Destinatario', ['class'=>'']) !!} {!! Form::label('extra3', 'Destinatario', ['class'=>'']) !!}
{!! Form::text('extra3', null, ['class'=>'form-control', 'required'=>'required']) !!} {!! Form::text('extra3', null, ['class'=>'form-control']) !!}
</div> </div>
<div> <div>
{!! Form::label('extra4', 'Dedicatoria', ['class'=>'']) !!} {!! Form::label('extra4', 'Dedicatoria', ['class'=>'']) !!}
{!! Form::text('extra4', null, ['class'=>'form-control', 'required'=>'required']) !!} {!! Form::text('extra4', null, ['class'=>'form-control']) !!}
</div> </div>
</section> </section>
{!! Form::submit('Enviar información', ['class'=>'']) !!} {!! Form::submit('Enviar información', ['class'=>'']) !!}
{!! Form::close() !!} {!! Form::close() !!}
@endsection @endsection
@section('scripts_extra') @section('scripts_extra')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment