Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
onestartup-shop
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Angel Martin
onestartup-shop
Commits
077f60f2
Commit
077f60f2
authored
Jun 11, 2018
by
Angel MAS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
formulario de facturación
parent
d6bb8da5
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
343 additions
and
5 deletions
+343
-5
CartController.php
src/controllers/CartController.php
+105
-2
2018_06_11_211816_create_billings_table.php
src/migrations/2018_06_11_211816_create_billings_table.php
+46
-0
Billing.php
src/models/Billing.php
+29
-0
SaleShop.php
src/models/SaleShop.php
+6
-0
routes.php
src/routes.php
+4
-0
orden.blade.php
src/views/clients/orden.blade.php
+26
-3
order.blade.php
src/views/mail/resumen/order.blade.php
+5
-0
facturacion.blade.php
src/views/public/cart/facturacion.blade.php
+72
-0
fields-facturacion.blade.php
src/views/public/forms/fields-facturacion.blade.php
+42
-0
layout.blade.php
src/views/public/layout.blade.php
+8
-0
No files found.
src/controllers/CartController.php
View file @
077f60f2
...
...
@@ -14,6 +14,7 @@ use Onestartup\Shop\Model\ShippingAddres as Addres;
use
Onestartup\Shop\Model\SaleShop
as
Sale
;
use
Onestartup\Shop\Model\DetailShop
as
Item
;
use
Onestartup\Shop\Model\DiscountCoupon
as
Coupon
;
use
Onestartup\Shop\Model\Billing
;
use
Onestartup\Shop\Payment\MP
;
use
Onestartup\Shop\Notifications\PaymentClient
;
...
...
@@ -859,8 +860,62 @@ public function shipping()
}
public
function
search
(
Request
$request
)
{
public
function
getDiscount2
(
$sale
)
{
$client
=
$sale
->
client
;
$addres
=
$client
->
shipping
;
$cost_shipping
=
$addres
->
shipping_price
->
cost
;
$coupon
=
Coupon
::
where
(
'code'
,
$sale
->
coupon
)
->
first
();
$descuento
=
0
;
$total
=
0
;
$total_without
=
0
;
$data
=
[];
foreach
(
$sale
->
products
as
$product
)
{
$aux
=
$product
->
pivot
->
quantity
*
$product
->
infoSale
->
sale_price
;
$total
+=
$aux
;
$total_without
+=
$aux
;
}
if
(
$coupon
!=
null
)
{
if
(
$total
>=
$coupon
->
min_sale
)
{
if
(
$coupon
->
type
==
'Efectivo'
)
{
$descuento
=
$coupon
->
value
;
}
if
(
$coupon
->
type
==
'Porcentaje'
)
{
$descuento
=
(
$coupon
->
value
/
100
)
*
$total
;
}
}
}
$data
=
[
'amount'
=>
money_format
(
'%(#10n'
,
$descuento
),
'amount_unformated'
=>
$descuento
,
'total'
=>
money_format
(
'%(#10n'
,
((
$total
+
$cost_shipping
)
-
$descuento
)),
'total_unformated'
=>
(
$total
+
$cost_shipping
)
-
$descuento
,
'shipping'
=>
money_format
(
'%(#10n'
,
$cost_shipping
),
'shipping_unformated'
=>
$cost_shipping
,
'total_without'
=>
money_format
(
'%(#10n'
,
$total_without
),
'total_without_unformated'
=>
$total_without
];
return
$data
;
}
public
function
search
(
Request
$request
)
{
$error
=
[
'error'
=>
'Sin resultados, ingrese otros campos para la búsqueda.'
];
if
(
$request
->
has
(
'text'
))
{
...
...
@@ -870,6 +925,54 @@ public function shipping()
}
return
$error
;
}
public
function
facturacion
(
$order_id
)
{
$id_decript
=
\Crypt
::
decryptString
(
$order_id
);
$order
=
Sale
::
find
(
$id_decript
);
$data
=
null
;
$client
=
$order
->
client
;
$products
=
$order
->
products
;
$addres
=
$client
->
shipping
;
$billing
=
new
Billing
();
if
(
$order
->
billing
()
->
count
()
>
0
)
{
$billing
=
$order
->
billing
;;
}
$data
=
$this
->
getDiscount2
(
$order
);
return
view
(
'shop-public::cart.facturacion'
)
->
with
(
'order'
,
$order
)
->
with
(
'order_id'
,
$order_id
)
->
with
(
'billing'
,
$billing
)
->
with
(
'client'
,
$client
)
->
with
(
'data'
,
$data
)
->
with
(
'products'
,
$products
)
->
with
(
'total'
,
0
)
->
with
(
'addres'
,
$addres
);
}
public
function
facturacionStore
(
Request
$request
,
$order_id
)
{
$id_decript
=
\Crypt
::
decryptString
(
$order_id
);
$order
=
Sale
::
find
(
$id_decript
);
$billing
=
null
;
if
(
$order
->
billing
()
->
count
()
<=
0
)
{
$billing
=
new
Billing
(
$request
->
all
());
$order
->
billing
()
->
save
(
$billing
);
}
return
redirect
()
->
route
(
'root'
)
->
with
(
'billing'
,
'billing'
);
}
}
src/migrations/2018_06_11_211816_create_billings_table.php
0 → 100644
View file @
077f60f2
<?php
use
Illuminate\Support\Facades\Schema
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Database\Migrations\Migration
;
class
CreateBillingsTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'billings'
,
function
(
Blueprint
$table
)
{
$table
->
increments
(
'id'
);
$table
->
string
(
'razon'
);
$table
->
string
(
'rfc'
);
$table
->
string
(
'correo'
);
$table
->
string
(
'cp'
);
$table
->
string
(
'calle'
);
$table
->
string
(
'numero'
);
$table
->
string
(
'colonia'
);
$table
->
string
(
'ciudad'
);
$table
->
string
(
'estado'
);
$table
->
tinyInteger
(
'status'
)
->
default
(
0
);
$table
->
integer
(
'sale_id'
)
->
unsigned
();
$table
->
foreign
(
'sale_id'
)
->
references
(
'id'
)
->
on
(
'sale_shops'
);
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'billings'
);
}
}
src/models/Billing.php
0 → 100644
View file @
077f60f2
<?php
namespace
Onestartup\Shop\Model
;
use
Illuminate\Database\Eloquent\Model
;
class
Billing
extends
Model
{
protected
$table
=
'billings'
;
protected
$fillable
=
[
'razon'
,
'rfc'
,
'correo'
,
'cp'
,
'calle'
,
'numero'
,
'colonia'
,
'ciudad'
,
'estado'
,
'sale_id'
];
public
function
sale
()
{
return
$this
->
belongsTo
(
'Onestartup\Shop\Model\SaleShop'
,
'sale_id'
);
}
}
src/models/SaleShop.php
View file @
077f60f2
...
...
@@ -34,4 +34,10 @@ class SaleShop extends Model
'product_id'
)
->
withPivot
(
'quantity'
);
}
public
function
billing
()
{
return
$this
->
hasOne
(
'Onestartup\Shop\Model\Billing'
,
'sale_id'
);
}
}
src/routes.php
View file @
077f60f2
...
...
@@ -111,4 +111,8 @@ Route::group(['middleware' => ['web']], function(){
Route
::
get
(
'get/coupon'
,
'Onestartup\Shop\Controller\CartController@discount'
)
->
name
(
'cart.discount'
);
Route
::
get
(
'/search'
,
'Onestartup\Shop\Controller\CartController@search'
)
->
name
(
'api.search'
);
Route
::
get
(
'/cart/facturacion/{order_id}'
,
'Onestartup\Shop\Controller\CartController@facturacion'
)
->
name
(
'cart.facturacion'
);
Route
::
put
(
'/cart/facturacion/{order_id}'
,
'Onestartup\Shop\Controller\CartController@facturacionStore'
)
->
name
(
'facturacion.store'
);
});
src/views/clients/orden.blade.php
View file @
077f60f2
...
...
@@ -22,7 +22,7 @@ setlocale(LC_MONETARY, 'en_US');
</
li
>
<
li
class
="
nav
-
item
">
<a class="
nav
-
link
block
" href="" data-toggle="
tab
" data-target="
#tab-3">
<
h6
>
Envio
</
h6
>
<
h6
>
Envio
y
factura
</
h6
>
</
a
>
</
li
>
</
ul
>
...
...
@@ -183,7 +183,7 @@ setlocale(LC_MONETARY, 'en_US');
<div class="
box
">
<div class="
box
-
body
">
<div class="
row
">
<div class="
col
-
md
-
8
offset
-
2
">
<div class="
col
-
md
-
6
">
Direccion de entrega:<br>
<b>
{
{$shipping->calle}
}
, #
{
{$shipping->numero}
}
, col.
{
{$shipping->colonia}
}
</b><br>
...
...
@@ -196,8 +196,31 @@ setlocale(LC_MONETARY, 'en_US');
<
span
class
="
label
warning
">
{
{$sale->shipping_status}
}
</span>
</div>
<div class="
col
-
md
-
6
">
@if(
$sale->billing
()->count() > 0)
<h4>Datos de facturación</h4>
Dirección: <br>
Calle
{
{$sale->billing->calle}
}
numero
{
{$sale->billing->numero}
}
, Col.
{
{$sale->billing->colonia}
}
<br>
{
{$sale->billing->ciudad}
}
,
{
{$sale->billing->estado}
}
. C.P.
{
{$sale->billing->cp}
}
<br>
Razón social: <b>
{
{$sale->billing->razon}
}
</b><br>
R.F.C. <b>
{
{$sale->billing->rfc}
}
</b><br>
Correo electrónico:<b>
{
{$sale->billing->correo}
}
</b>
<br><br>
<h6>Liga de formulario de facturación</h6>
<a target="
blank
" href="
{{
route
(
'cart.facturacion'
,
\Crypt
::
encryptString
(
$sale
->
id
))}}
">
Visitar link
</a>
@else
<br><br>
<h6>Liga de formulario de facturación</h6>
<a target="
blank
" href="
{{
route
(
'cart.facturacion'
,
\Crypt
::
encryptString
(
$sale
->
id
))}}
">
Visitar link
</a>
@endif
</div>
</div>
</div>
...
...
src/views/mail/resumen/order.blade.php
View file @
077f60f2
...
...
@@ -44,6 +44,11 @@ Datos de envio:
-
***
{{
$shipping
->
ciudad
}},
{{
$shipping
->
estado
}},
C
.
P
.
{{
$shipping
->
cp
}}
***
-
Referencias
:
***
{{
$shipping
->
referencias
}}
***
-
Requiere
factura
:
***
{{
$shipping
->
facturacion
}}
***
@
if
(
$shipping
->
facturacion
==
'Si'
)
[
Rellenar
formulario
de
facturación
]({{
route
(
'cart.facturacion'
,
\Crypt
::
encryptString
(
$order
->
id
))}})
@
endif
@
endcomponent
Gracias
por
tu
compra
,
<
br
>
...
...
src/views/public/cart/facturacion.blade.php
0 → 100644
View file @
077f60f2
@
extends
(
'shop-public::layout'
)
@
section
(
'pageTitle'
,
'Finalizar compra'
)
@
section
(
'content'
)
@
php
setlocale
(
LC_MONETARY
,
'en_US'
);
@
endphp
<
section
>
<
h4
>
Detalle
de
la
orden
</
h4
>
<
table
class
="
table
" style="
width
:
60
%
;
">
<thead>
<tr>
<th>Producto</th>
<th>Precio</th>
<th>Cantidad</th>
<th>Subtotal</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach(
$products
as
$product
)
<tr align="
center
">
<td>
{
{$product->name}
}
</td>
<td>{{money_format('%(#10n',
$product->infoSale
->sale_price)}}</td>
<td>
{
{$product->pivot->quantity}
}
</td>
<td>
{{money_format('%(#10n', (
$product->infoSale
->sale_price *
$product->pivot
->quantity))}}
</td>
</tr>
@endforeach
@if(
$order->coupon
!= null)
<tr align="
center
">
<td>Descuento:
{
{$order->coupon}
}
</td>
<td> -
{
{$data['amount']}
}
</td>
<td>1</td>
<td> -
{
{$data['amount']}
}
</td>
</tr>
@endif
<tr align="
center
">
<td> Envio </td>
<td>
{
{$data['shipping']}
}
</td>
<td> 1 </td>
<td>
{
{$data['shipping']}
}
</td>
</tr>
</tbody>
<tr>
<td colspan="
3
" align="
right
">
Total + Envio:
</td>
<td align="
center
">
{
{$data['total']}
}
</td>
</tr>
</table>
</section>
<h4>Formulario de pago</h4>
<section>
{!! Form::model(
$billing
,['route'=> ['facturacion.store',
$order_id
],"
method
"=>"
PUT
"]) !!}
@include('shop-public::forms.fields-facturacion')
{!! Form::submit('Enviar información', ['class'=>'btn btn-primary']) !!}
{!! Form::close() !!}
</section>
@endsection
src/views/public/forms/fields-facturacion.blade.php
0 → 100644
View file @
077f60f2
<div
class=
"form-group"
>
{!! Form::label('razon', 'Nombre o razón social', ['class'=>'form-control']) !!}
{!! Form::text('razon', null, ['class'=>'form-control','required'=>'required']) !!}
</div>
<div
class=
"form-group"
>
{!! Form::label('rfc', 'RFC', ['class'=>'form-control']) !!}
{!! Form::text('rfc', null, ['class'=>'form-control','required'=>'required']) !!}
</div>
<div
class=
"form-group"
>
{!! Form::label('correo', 'Correo electrónico', ['class'=>'form-control']) !!}
{!! Form::text('correo', null, ['class'=>'form-control','required'=>'required']) !!}
</div>
<div
class=
"form-group"
>
{!! Form::label('calle', 'Calle', ['class'=>'form-control']) !!}
{!! Form::text('calle', null, ['class'=>'form-control','required'=>'required']) !!}
</div>
<div
class=
"form-group"
>
{!! Form::label('numero', 'Numero', ['class'=>'form-control']) !!}
{!! Form::text('numero', null, ['class'=>'form-control','required'=>'required']) !!}
</div>
<div
class=
"form-group"
>
{!! Form::label('colonia', 'Colonia', ['class'=>'form-control']) !!}
{!! Form::text('colonia', null, ['class'=>'form-control','required'=>'required']) !!}
</div>
<div
class=
"form-group"
>
{!! Form::label('estado', 'Estado', ['class'=>'form-control']) !!}
{!! Form::text('estado', null, ['class'=>'form-control','required'=>'required']) !!}
</div>
<div
class=
"form-group"
>
{!! Form::label('ciudad', 'Ciudad o delegación', ['class'=>'form-control']) !!}
{!! Form::text('ciudad', null, ['class'=>'form-control','required'=>'required']) !!}
</div>
<div
class=
"form-group"
>
{!! Form::label('cp', 'Codigo postal', ['class'=>'form-control']) !!}
{!! Form::text('cp', null, ['class'=>'form-control','required'=>'required']) !!}
</div>
src/views/public/layout.blade.php
View file @
077f60f2
...
...
@@ -86,6 +86,14 @@ $util = new Onestartup\Shop\Libs\Util();
</script>
@endif
@if(Session::has('billing'))
<script
type=
"text/javascript"
>
swal
(
"Petición exitosa"
,
"Enviaremos la factura a tu correo electrónico"
,
"success"
)
</script>
@endif
@if(Session::has('url_ficha'))
<script>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment