Commit f68b67a4 by Angel MAS

medio acordar con el vendedor

parent 3e82a44a
......@@ -16,6 +16,7 @@ use Onestartup\Shop\Model\DetailShop as Item;
use Onestartup\Shop\Payment\MP;
use Onestartup\Shop\Notifications\PaymentClient;
use Onestartup\Shop\Notifications\PaymentAcordarClient;
use Onestartup\Shop\Notifications\PaymentClientCard;
use PayPal\Rest\ApiContext;
......@@ -48,10 +49,10 @@ class CartController extends Controller
return view('shop-public::cart.show-cart')
->with('cart', $cart)
->with('total', $total);
}
}
public function add(Product $product)
{
public function add(Product $product)
{
if (\Session::has('sale')) {
$sale = Sale::find(\Session::get('sale')->id);
$sale->status = 0;
......@@ -72,11 +73,11 @@ class CartController extends Controller
\Session::put('cart', $cart);
return redirect()->route('cart.show');
}
}
public function remove(Product $product)
{
public function remove(Product $product)
{
$cart = \Session::get('cart');
if (!isset($cart[$product->slug])) {
......@@ -86,10 +87,10 @@ class CartController extends Controller
unset($cart[$product->slug]);
\Session::put('cart', $cart);
return redirect()->route('cart.show');
}
}
public function update(Product $product, $quantity)
{
public function update(Product $product, $quantity)
{
if (\Session::has('sale')) {
$sale = Sale::find(\Session::get('sale')->id);
$sale->status = 0;
......@@ -107,10 +108,10 @@ class CartController extends Controller
$cart[$product->slug]->quantity = $quantity;
\Session::put('cart', $cart);
return redirect()->route('cart.show');
}
}
public function trash()
{
public function trash()
{
if (\Session::has('sale')) {
$sale = Sale::find(\Session::get('sale')->id);
......@@ -123,13 +124,11 @@ class CartController extends Controller
\Session::forget('client');
return redirect()->route('cart.show');
}
}
public function shipping()
{
public function shipping()
{
/*\Session::forget('client');
\Session::forget('cart');
\Session::forget('sale');*/
$client = new Client();
$addres = new Addres();
......@@ -608,5 +607,40 @@ class CartController extends Controller
}
}
public function acordar(Request $request)
{
if (!\Session::has('client')) {
return redirect()->route('cart.shipping');
}
if (!\Session::has('sale')) {
return redirect()->route('cart.shipping');
}
$sale = Sale::find(\Session::get('sale')->id);
$client = $sale->client;
$items = $sale->items;
$addres = $client->shipping;
$detail = '';
$sale->status = 3;
$sale->transaction_id = null;
$sale->payment_type = 'Acordar con vendedor';
$sale->save();
\Session::forget('client');
\Session::forget('cart');
\Session::forget('sale');
$user = \App\User::first();
$user->notify(new PaymentAcordarClient('Acordar con el vendedor', $client));
return redirect()
->route('main.shop')
->with('acordar', 'acordar');
}
}
<?php
namespace Onestartup\Shop\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Onestartup\Shop\Model\ClientShop as Client;
class PaymentAcordarClient extends Notification
{
use Queueable;
protected $tipo;
protected $client;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($tipo, Client $client)
{
$this->tipo = $tipo;
$this->client = $client;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->greeting('¡Hola!')
->subject('Orden: Acordar con el vendedor '.env('APP_NAME'))
//->replyTo($this->interested->email, $this->interested->name)
->line('Un cliente elijió la opcion de acordar con el vendedor')
->line('Datos del cliente:')
->line('Nombre: '.$this->client->name.' '.$this->client->lastname)
->line('Telefono: '.$this->client->phone)
->line('Correo: '.$this->client->email);
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}
......@@ -86,6 +86,7 @@ Route::group(['middleware' => ['web']], function(){
Route::post('cart/payment', 'Onestartup\Shop\Controller\CartController@payment')->name('cart.payment');
Route::post('cart/paymentCash', 'Onestartup\Shop\Controller\CartController@paymentCash')->name('cart.paymentCash');
Route::post('cart/acordar', 'Onestartup\Shop\Controller\CartController@acordar')->name('cart.acordar');
Route::get('cart/update/{product_slug}/{quantity}', 'Onestartup\Shop\Controller\CartController@update')
->where('quantity', '[0-9]+')
......
......@@ -67,6 +67,10 @@ setlocale(LC_MONETARY, 'en_US');
@include('shop-public::forms.form-paypal')
<br>
<br>
@include('shop-public::forms.form-acordar')
<br>
</section>
......
<form action="{{route('cart.acordar')}}" method="POST">
{{ csrf_field() }}
<button type="submit">
Acordar con el vendedor: {{ money_format('%(#10n', ($total + $addres->shipping_price->cost)) }}
</button>
</form>
\ No newline at end of file
......@@ -64,6 +64,12 @@ $util = new Onestartup\Shop\Libs\Util();
</script>
@endif
@if(Session::has('acordar'))
<script type="text/javascript">
swal("Compra registrada", "Gracias! En breve nos comunicaremos contigo para cerrar la venta", "success")
</script>
@endif
@if(Session::has('url_ficha'))
<script>
......
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