You are on page 1of 13

1/8/2020 Admin sucursal puede importar facturas y conceptos.

conceptos. Usuario final puede ver sus facturas pendientes (3f1d8573) · Commits · Guillermo Agudelo / transito-frontend · GitLab

Please ensure your account's recovery settings are up to date.

Commit 3f1d8573 authored 4 weeks ago by Guillermo Agudelo

Admin sucursal puede importar facturas y conceptos. Usuario final puede ver
sus facturas pendientes

parent d10782f6 master

No related merge requests found

Showing 16 changed files  with 492 additions and 121 deletions

  app/Http/Controllers/API/InvoiceDetailController.php 0 → 100644
1 + <?php
2 +
3 + namespace App\Http\Controllers\API;
4 +
5 + use App\Http\Controllers\Controller;
6 + use App\InvoiceDetail;
7 + use Illuminate\Http\Request;
8 +
9 + class InvoiceDetailController extends Controller
10 +{
11 + public function byInvoiceId(Request $request, $invoiceId)
12 + {
13 + $concepts = InvoiceDetail::whereGetInstances('idInvoice', '=', $invoiceId);
14 +
15 + return response()->json(['status' => 'success', 'data' => compact('concepts')]);
16 + }
17 +}

  app/Http/Controllers/Admin/InvoiceController.php

... ... @@ -5,6 +5,8 @@ namespace App\Http\Controllers\Admin;


5 5 use App\Http\Controllers\Controller;
6 6 use App\Imports\InvoiceDetailImport;
7 7 use App\Imports\InvoiceImport;
8 + use App\Invoice;
9 + use App\InvoiceDetail;
8 10 use App\Service;
9 11 use Illuminate\Http\Request;
10 12 use Maatwebsite\Excel\Facades\Excel;
... ... @@ -13,8 +15,40 @@ class InvoiceController extends Controller
13 15 {
14 16 public function index()
15 17 {
18 + $activeInvoices = Invoice::whereGetInstances([
19 + ['state', '=', \InvoiceState::ACTIVO],
20 + ['idBranch', '=', \State::get('branch.id')]
21 + ]);
22 +
23 + $activeInvoicesCount = count($activeInvoices);
24 +
25 + $activeInvoicesIds = $activeInvoices->map(fn($ai) => $ai->id())->toArray();
26 +
27 + $activeInvoices = $activeInvoices->toArray();
28 +
29 + $activeInvoicesConcepts = count($activeInvoices) == 0 ? [] :
InvoiceDetail::whereGetInstances('idInvoice', 'in', $activeInvoicesIds);
30 +
31 + // Eliminar del $activeInvoices las facturas que si tienen conceptos
32 + $currentInvoiceId = null;
33 + foreach ($activeInvoicesConcepts as $concept) {
34 + if ($concept->field('idInvoice') == $currentInvoiceId) continue;
35 + $currentInvoiceId = $concept->field('idInvoice');

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/3f1d8573cb9f650ab21df4018895cd23f9a96352 1/13
1/8/2020 Admin sucursal puede importar facturas y conceptos. Usuario final puede ver sus facturas pendientes (3f1d8573) · Commits · Guillermo Agudelo / transito-frontend · GitLab

36 + foreach ($activeInvoices as $index => $invoice) {


37 + if ($invoice->id() == $concept->field('idInvoice')) {
38 + array_splice($activeInvoices, $index, 1);
39 + break;
40 + }
41 + }
42 + }
43 +
44 + $activeInvoicesWithoutConceptsCount = count($activeInvoices);
45 +
16 46 $services = Service::whereGetInstances('idBranch', '=', \State::get('branch.id'));
17 - return view('admin.invoices.index', compact('services'));
47 + return view('admin.invoices.index', compact(
48 + 'services',
49 + 'activeInvoicesCount',
50 + 'activeInvoicesWithoutConceptsCount',
51 + ));
18 52 }
19 53
20 54
... ... @@ -28,7 +62,7 @@ class InvoiceController extends Controller
28 62 $import = new InvoiceImport($request->get('idService'));
29 63 Excel::import($import, request()->file('invoicesFile'));
30 64
31 - feedback('success', 'Se importaron *'.$import->getRowCount().'* facturas');
65 + feedback('success', 'Se importaron '.$import->getRowCount().' facturas');
32 66
33 67 return redirect()->route('admin.invoices.index');
34 68 }
... ... @@ -44,7 +78,39 @@ class InvoiceController extends Controller
44 78 $import = new InvoiceDetailImport($request->get('idService'));
45 79 Excel::import($import, request()->file('detailsFile'));
46 80
47 - feedback('success', 'Se importaron *'.$import->getRowCount().'* conceptos');
81 + feedback('success', 'Se importaron '.$import->getRowCount().' conceptos');
82 +
83 + return redirect()->route('admin.invoices.index');
84 + }
85 +
86 +
87 + public function deactivate()
88 + {
89 + // Desactivar facturas
90 + $batch = Invoice::batch();
91 + $invoices = Invoice::whereGetInstances([
92 + ['state', '=', \InvoiceState::ACTIVO],
93 + ['idBranch', '=', \State::get('branch.id')]
94 + ]);
95 + foreach ($invoices as $invoice) {
96 + $batch->update($invoice->getDocumentReference(), [
97 + ['path' => 'state', 'value' => \InvoiceState::INACTIVO]
98 + ]);
99 + }
100 + $batch->commit();
101 +
102 + //Desactivar conceptos
103 + $batch = InvoiceDetail::batch();
104 + $invoicesIds = $invoices->map(fn($i) => $i->id())->toArray();
105 + $concepts = count($invoicesIds) == 0 ? [] : InvoiceDetail::whereGetInstances('idInvoice', 'in',
$invoicesIds);
106 + foreach ($concepts as $concept) {
107 + $batch->update($concept->getDocumentReference(), [
108 + ['path' => 'state', 'value' => \InvoiceState::INACTIVO]
109 + ]);
110 + }
111 + $batch->commit();
112 +
113 + feedback('success', 'Se desactivaron '.count($invoices).' facturas');
48 114
49 115 return redirect()->route('admin.invoices.index');
50 116 }
... ...

  app/Http/Controllers/AuthController.php

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/3f1d8573cb9f650ab21df4018895cd23f9a96352 2/13
1/8/2020 Admin sucursal puede importar facturas y conceptos. Usuario final puede ver sus facturas pendientes (3f1d8573) · Commits · Guillermo Agudelo / transito-frontend · GitLab

... ... @@ -48,19 +48,23 @@ class AuthController extends Controller


48 48 break;
49 49 }
50 50
51 - Client::create([
52 - 'createAt' => date_create(),
53 - 'creteBy' => null,
54 - 'state' => 'Activo',
55 - 'identification' => null,
56 - 'location' => [
57 - 'address' => '',
58 - 'city' => '',
59 - 'lat' => 0,
60 - 'lng' => 0
61 - ],
62 - 'uid' => $signInResults->data()['localId']
63 - ]);
51 + $client = Client::first('uid', '=', $signInResults->data()['localId']);
52 +
53 + if (!$client) {
54 + Client::create([
55 + 'createAt' => date_create(),
56 + 'creteBy' => null,
57 + 'state' => 'Activo',
58 + 'identification' => null,
59 + 'location' => [
60 + 'address' => '',
61 + 'city' => '',
62 + 'lat' => 0,
63 + 'lng' => 0
64 + ],
65 + 'uid' => $signInResults->data()['localId']
66 + ]);
67 + }
64 68
65 69 $this->createState($signInResults);
66 70 }
... ...

  app/Http/Controllers/Portal/PaymentController.php 0 → 100644

1 + <?php
2 +
3 + namespace App\Http\Controllers\Portal;
4 +
5 + use App\Company;
6 + use App\Http\Controllers\Controller;
7 + use App\Invoice;
8 + use App\Service;
9 + use Illuminate\Http\Request;
10 +
11 + class PaymentController extends Controller
12 +{
13 + public function index()
14 + {
15 + $invoices = Invoice::whereGetInstances([
16 + ['state', '=', \InvoiceState::ACTIVO],
17 + ['idClient', '=', \State::get('client.id')]
18 + ]);
19 +
20 + $servicesIds = $invoices->map(fn($i) => $i->field('idService'))->toArray();
21 + $companiesIds = $invoices->map(fn($i) => $i->field('idCompany'))->toArray();
22 +
23 + $services = Service::whereIdIn($servicesIds);
24 + $companies = Company::whereIdIn($companiesIds);
25 +
26 + return view('portal.payments.index', compact(
27 + 'invoices',
28 + 'services',
29 + 'companies'
30 + ));
31 + }
32 +}

  app/Imports/InvoiceDetailImport.php

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/3f1d8573cb9f650ab21df4018895cd23f9a96352 3/13
1/8/2020 Admin sucursal puede importar facturas y conceptos. Usuario final puede ver sus facturas pendientes (3f1d8573) · Commits · Guillermo Agudelo / transito-frontend · GitLab

... ... @@ -2,6 +2,7 @@


2 2
3 3 namespace App\Imports;
4 4
5 + use App\Invoice;
5 6 use App\InvoiceDetail;
6 7 use Illuminate\Support\Collection;
7 8 use Maatwebsite\Excel\Concerns\ToCollection;
... ... @@ -23,28 +24,30 @@ class InvoiceDetailImport implements ToCollection, WithHeadingRow, WithChunkRead
23 24 {
24 25 $batch = InvoiceDetail::batch();
25 26 $invoicesIds = $collection->map(fn($r) => (string)$r['numero_factura'])->unique()->toArray();
26 - $clients = Client::whereGetInstances('identification', 'in', $clientsIds);
27 + $invoices = Invoice::whereGetInstances([
28 + ['companyIdInvoice', 'in', $invoicesIds],
29 + ['idBranch', '=', \State::get('branch.id')],
30 + ['state', '=', \InvoiceState::ACTIVO]
31 + ]);
32 +
33 + if (count($invoices) == 0) throw new \Exception('No hay facturas activas para estos conceptos');
34 +
27 35 foreach ($collection as $row) {
28 36 ++$this->rows;
29 - $client = $clients->first(function ($client) use ($row) {
30 - return $client->field('identification') == $row['numero_identificacion'];
37 + $invoice = $invoices->first(function($invoice) use($row) {
38 + return $invoice->field('companyIdInvoice') == $row['numero_factura'];
31 39 });
32 - $batch->create(InvoiceDetail::newDocument(), [
33 - 'companyAddress' => $row['direccion'],
34 - 'companyIdClient' => $row['numero_identificacion'],
35 - 'companyIdInvoice' => $row['numero_factura'],
36 - 'companyName' => $row['nombre'],
37 - 'companyPhone' => $row['telefono'],
38 - 'month' => $row['mes'],
39 - 'year' => $row['ano'],
40 - 'valor' => $row['valor'],
40 + $batch->create(InvoiceDetail::newDocumentReference(), [
41 + 'concept' => $row['concepto'],
42 + 'createAt' => date_create(),
43 + 'creteBy' => \State::get('user.id'),
41 44 'idBranch' => \State::get('branch.id'),
45 + 'idClient' => $invoice->field('idClient'),
42 46 'idCompany' => \State::get('company.id'),
43 - 'idClient' => $client ? $client->id() : null,
47 + 'idInvoice' => $invoice->id(),
44 48 'idService' => $this->serviceId,
45 49 'state' => 'Activo',
46 - 'createAt' => date_create(),
47 - 'creteBy' => \State::get('user.id'),
50 + 'valor' => $row['valor'],
48 51 ]);
49 52 }
50 53 $batch->commit();
... ...

  app/Imports/InvoiceImport.php
... ... @@ -23,19 +23,19 @@ class InvoiceImport implements ToCollection, WithHeadingRow, WithChunkReading, W
23 23 public function collection(Collection $collection)
24 24 {
25 25 $batch = Invoice::batch();
26 - $clientsIds = $collection->map(fn($r) => (string)$r['numero_identificacion'])->toArray();
27 - $clients = Client::whereGetInstances('identification', 'in', $clientsIds);
26 + $clientsIdentifications = $collection->map(fn($r) => (string)$r['numero_identificacion'])-
>toArray();
27 + $clients = Client::whereGetInstances('identification', 'in', $clientsIdentifications);
28 28 foreach ($collection as $row) {
29 29 ++$this->rows;
30 30 $client = $clients->first(function ($client) use ($row) {
31 31 return $client->field('identification') == $row['numero_identificacion'];
32 32 });
33 - $batch->create(Invoice::newDocument(), [
33 + $batch->create(Invoice::newDocumentReference(), [
34 34 'companyAddress' => $row['direccion'],

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/3f1d8573cb9f650ab21df4018895cd23f9a96352 4/13
1/8/2020 Admin sucursal puede importar facturas y conceptos. Usuario final puede ver sus facturas pendientes (3f1d8573) · Commits · Guillermo Agudelo / transito-frontend · GitLab

35 - 'companyIdClient' => $row['numero_identificacion'],


36 - 'companyIdInvoice' => $row['numero_factura'],
35 + 'companyIdClient' => (string)$row['numero_identificacion'],
36 + 'companyIdInvoice' => (string)$row['numero_factura'],
37 37 'companyName' => $row['nombre'],
38 - 'companyPhone' => $row['telefono'],
38 + 'companyPhone' => (string)$row['telefono'],
39 39 'month' => $row['mes'],
40 40 'year' => $row['ano'],
41 41 'valor' => $row['valor'],
... ...

  app/Providers/BladeServiceProvider.php

... ... @@ -52,11 +52,17 @@ class BladeServiceProvider extends ServiceProvider


52 52 });
53 53
54 54 setlocale(LC_ALL, 'es_CO.UTF-8');
55 +
55 56 \Blade::directive('datetime', function ($expression) {
56 57 return "<?php echo strftime('%e de %B %I:%M %p',
strtotime(\Carbon\Carbon::make($expression))); ?>";
57 58 });
59 +
58 60 \Blade::directive('date', function ($expression) {
59 61 return "<?php echo strftime('%e de %B', strtotime(\Carbon\Carbon::make($expression))); ?>";
60 62 });
63 +
64 + \Blade::directive('money', function($value) {
65 + return "<?php echo '$' . number_format((int)$value); ?>";
66 + });
61 67 }
62 68 }

  app/Support/Globals.php
... ... @@ -31,6 +31,14 @@ abstract class Roles
31 31 const OPERATOR = '2OPERATOR';
32 32 }
33 33
34 + abstract class InvoiceState
35 +{
36 + const ACTIVO = 'Activo';
37 + const PAGADO = 'Pagado';
38 + const INACTIVO = 'Inactivo';
39 +}
40 +
41 +
34 42
35 43 if (!defined('MUNICIPIOS')) {
36 44 define('MUNICIPIOS', [
... ...

  app/Support/LarafireModel.php

... ... @@ -74,11 +74,23 @@ class LarafireModel implements JsonSerializable


74 74 return $instance;
75 75 }
76 76
77 - public static function where($field, $operation, $value)
77 + public static function where($fieldOrConditions, $operation = null, $value = null)
78 78 {
79 79 $instance = self::getNewInstance();
80 80
81 - return $instance->collection->where($field, $operation, $value);
81 + if (is_string($fieldOrConditions)) {
82 + return $instance->collection->where($fieldOrConditions, $operation, $value);
83 + }
84 +
85 + if (is_array($fieldOrConditions)) {
86 + $instanceCollection = $instance->collection();
87 + foreach ($fieldOrConditions as $condition) {
88 + $instanceCollection = $instanceCollection->where($condition[0], $condition[1],
$condition[2]);
89 + }
90 + return $instanceCollection;
https://gitlab.com/guille.agudelo/transito-frontend/-/commit/3f1d8573cb9f650ab21df4018895cd23f9a96352 5/13
1/8/2020 Admin sucursal puede importar facturas y conceptos. Usuario final puede ver sus facturas pendientes (3f1d8573) · Commits · Guillermo Agudelo / transito-frontend · GitLab

91 + }
92 +
93 + throw new InvalidArgumentException('First parameter must be a string or an array');
82 94 }
83 95
84 96 // public static function whereGetInstances($field, $operation, $value)
... ... @@ -120,6 +132,11 @@ class LarafireModel implements JsonSerializable
120 132 }, $ids));
121 133 }
122 134
135 + public static function whereSize($field, $operation, $value)
136 + {
137 + return static::where($field, $operation, $value)->documents()->size();
138 + }
139 +
123 140 public static function first($field, $operation, $value)
124 141 {
125 142 $instance = self::getNewInstance();
... ... @@ -181,21 +198,21 @@ class LarafireModel implements JsonSerializable
181 198 }
182 199
183 200
184 - public static function newDocument()
201 + public static function batch()
185 202 {
186 203 $instance = self::getNewInstance();
187 - return $instance->collection->newDocument();
204 + return $instance->firestore->database()->batch();
188 205 }
189 206
190 - public static function batch()
207 +
208 + public static function newDocumentReference()
191 209 {
192 210 $instance = self::getNewInstance();
193 - return $instance->firestore->database()->batch();
211 + return $instance->collection->newDocument();
194 212 }
195 213
196 214
197 215
198 -
199 216 // INSTANCE METHODS
200 217
201 218 private function checkFirebaseObjectSet()
... ... @@ -221,6 +238,11 @@ class LarafireModel implements JsonSerializable
221 238 return $this->firebaseObject;
222 239 }
223 240
241 + public function getDocumentReference()
242 + {
243 + return $this->collection->document($this->id());
244 + }
245 +
224 246 public function get()
225 247 {
226 248 $this->checkFirebaseObjectIsQuery();
... ...

  notas.txt
1 1 . reasignar turno a otro tramite ¿?
2 2 . ambiente modo sucursal cuando usuario final escoja sucursal (muestre) ¿?
3 3 . latitud y longitud en crud admin->sucursal
4 + . que la importacion de facturas y conceptos se haga en una transaction
5 + . que muestre ayuda sobre los .csv en admin.invoices
6 + . portal: que no permite crear mas de un turno para hoy ni agendar mas de uno para el mismo dia
4 7
5 8 notas edwin
6 9 .que las entidades tengan logo ¿entidades o sucursales?
... ... @@ -20,10 +23,14 @@ largo
20 23 .pagina de perfil
21 24 .poner politicas de privacidad en "registrarse"
22 25
26 + preguntas

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/3f1d8573cb9f650ab21df4018895cd23f9a96352 6/13
1/8/2020 Admin sucursal puede importar facturas y conceptos. Usuario final puede ver sus facturas pendientes (3f1d8573) · Commits · Guillermo Agudelo / transito-frontend · GitLab

27 + . desactivar facturas debe ser segun trámite?


28 +
29 +
23 30 hecho
24 - .loguear a persona cuando cree cuenta
25 - .superadmin puede editar y crear todo
26 - .fix vista mobile
31 + . importar facturas y conceptos
32 + . que se puedan ver las facturas activas y sin conceptos asociados en admin.invoices
33 + . portal: cliente puede consultar facturas
27 34
28 35
29 36
... ...

  resources/views/admin/invoices/index.blade.php
... ... @@ -2,10 +2,41 @@
2 2 @section('content')
3 3 <div class="container" id="invoices">
4 4
5 + <div class="d-flex justify-content-between align-items-start">
6 + <div>
7 + @if ($activeInvoicesCount > 0)
8 + <h4 class="text-success">Hay {{ $activeInvoicesCount }} facturas en estado
'Activo'</h4>
9 + @if ($activeInvoicesWithoutConceptsCount > 0)
10 + <h4 class="text-warning">
11 + Hay {{ $activeInvoicesWithoutConceptsCount }} facturas activas sin conceptos
asociados
12 + </h4>
13 + @endif
14 + @else
15 + <h4>No hay facturas activas en el momento</h4>
16 + @endif
17 + </div>
18 + @if ($activeInvoicesCount > 0)
19 + <div>
20 + <button class="btn btn-outline-danger btn-sm" @click="deactivate">
21 + Desactivar Facturas
22 + </button>
23 + <form action="{{route('admin.invoices.deactivate')}}" method="post" id="deactivate-
form">
24 + @csrf @method('put')
25 + </form>
26 + </div>
27 + @endif
28 + </div>
29 +
30 + <hr>
5 31
6 32 <!-- CARGUE MASIVO DE FACTURAS -->
7 - <div class="border rounded p-3">
8 - <h2>Cargue masivo de Facturas</h2>
33 + <div class="border rounded p-3 mt-4">
34 + <h2>
35 + Cargue masivo de Facturas
36 + <a href="#" class="text-decoration-none">
37 + <!-- <small><i class="far fa&#45;question&#45;circle fa&#45;xs text&#45;dark"></i>
</small> -->
38 + </a>
39 + </h2>
9 40 <form action="{{route('admin.invoices.upload-invoices')}}"
10 41 method="post"
11 42 enctype="multipart/form-data">
... ... @@ -74,7 +105,12 @@
74 105
75 106 <!-- CARGUE MASIVO DE CONCEPTOS -->
76 107 <div class="border rounded p-3 mt-5">
77 - <h2>Cargue masivo de Conceptos</h2>
108 + <h2>
109 + Cargue masivo de Conceptos
110 + <a href="#" class="text-decoration-none">
111 + <!-- <small><i class="far fa&#45;question&#45;circle fa&#45;xs text&#45;dark"></i>
</small> -->

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/3f1d8573cb9f650ab21df4018895cd23f9a96352 7/13
1/8/2020 Admin sucursal puede importar facturas y conceptos. Usuario final puede ver sus facturas pendientes (3f1d8573) · Commits · Guillermo Agudelo / transito-frontend · GitLab

112 + </a>
113 + </h2>
78 114 <form action="{{route('admin.invoices.upload-details')}}"
79 115 method="post"
80 116 enctype="multipart/form-data">
... ... @@ -191,6 +227,11 @@
191 227 complete: handleParsedRows
192 228 })
193 229 },
230 + deactivate() {
231 + if (confirm("Esta orden pondrá todas las facturas activas en estado 'Inactivo'. ¿Desea
continuar?")) {
232 + $('#deactivate-form').submit()
233 + }
234 + }
194 235 }
195 236 })
196 237 </script>
... ...

  resources/views/layouts/navbars/sidebar.blade.php
... ... @@ -190,7 +190,7 @@
190 190 </a>
191 191 </li>
192 192 <li class="nav-item">
193 - <a class="nav-link" href="#">
193 + <a class="nav-link" href="{{ route('portal.payments.index') }}">
194 194 <i class="fa fa-wallet text-warning"></i>Pagos en línea
195 195 </a>
196 196 </li>
... ...

  resources/views/portal/dashboard.blade.php
... ... @@ -15,7 +15,7 @@
15 15 <i class="fa fa-concierge-bell text-success"></i>
16 16 Crear y Administrar Turnos
17 17 </a>
18 - <a href="#" class="btn btn-outline-primary btn-xl mb-3">
18 + <a href="{{ route('portal.payments.index') }}" class="btn btn-outline-primary btn-xl mb-3">
19 19 <i class="fa fa-wallet text-orange"></i>
20 20 Pagar en Línea
21 21 </a>
... ...

  resources/views/portal/payments/index.blade.php 0 → 100644
1 + @extends('layouts.app', ['title' => 'Pagos en Línea'])
2 +
3 + @section('content')
4 + @include('layouts.headers.cards')
5 +
6 + <div class="container-fluid" id="payments">
7 +
8 + <h2>Facturas pendientes</h2>
9 +
10 + <div class="w-100" style="overflow-x: scroll">
11 + <table class="table table-hover">
12 + <thead>
13 + <th>Trámite</th>
14 + <th>#Factura</th>
15 + <th>Nombre</th>
16 + <th>Periodo</th>
17 + <th class="text-center">Valor</th>
18 + <th>Entidad</th>
19 + <th class="text-center">Acciones</th>
20 + </thead>
21 + <tbody>
22 + @forelse($invoices as $invoice)
23 + <tr>
24 + <td>{{$invoice->foreign($services, 'idService')->field('name')}}</td>
25 + <td>{{$invoice->field('companyIdInvoice')}}</td>
26 + <td>{{$invoice->field('companyName')}}</td>
27 + <td>{{$invoice->field('month')}}/{{$invoice->field('year')}}</td>
28 + <td class="text-right">@money($invoice->field('valor'))</td>
https://gitlab.com/guille.agudelo/transito-frontend/-/commit/3f1d8573cb9f650ab21df4018895cd23f9a96352 8/13
1/8/2020 Admin sucursal puede importar facturas y conceptos. Usuario final puede ver sus facturas pendientes (3f1d8573) · Commits · Guillermo Agudelo / transito-frontend · GitLab

29 + <td>{{$invoice->foreign($companies, 'idCompany')->field('name')}}</td>
30 + <td class="text-center">
31 + <a href="#"
32 + class="btn btn-sm"
33 + title="Ver detalles de factura"
34 + @click.prevent="details('{{$invoice->id()}}',
35 + '{{$invoice->field('companyIdInvoice')}}',
36 + '{{$invoice->field('valor')}}')">
37 + <i class="fa fa-file-invoice"></i> Detalles
38 + </a>
39 +
40 + <a href="#"
41 + class="btn btn-primary btn-sm"
42 + title="Pagar Factura"
43 + @click.prevent="pay('{{$invoice->id()}}')">
44 + <i class="fa fa-credit-card"></i> Pagar
45 + </a>
46 +
47 + {{-- <form action="#" --}}
48 + {{-- method="post" --}}
49 + {{-- class="d-none" --}}
50 + {{-- id="cancel-form-{{$queue->id()}}"> --}}
51 + {{-- @csrf --}}
52 + {{-- @method('put') --}}
53 + {{-- </form> --}}
54 + </td>
55 + </tr>
56 + @empty
57 + <tr>
58 + <td colspan="4">No hay facturas pendientes en el momento</td>
59 + </tr>
60 + @endforelse
61 + </tbody>
62 + </table>
63 + </div>
64 +
65 + <div class="modal fade" id="detailsModal" tabindex="-1" role="dialog" aria-
labelledby="detailsModalLabel" aria-hidden="true">
66 + <div class="modal-dialog" role="document">
67 + <div class="modal-content">
68 + <div class="modal-header">
69 + <h5 class="modal-title" id="detailsModalLabel">
70 + Detalles de Factura: # @{{invoiceNumber}}
71 + </h5>
72 + <button type="button" class="close" data-dismiss="modal" aria-label="Close">
73 + <span aria-hidden="true">&times;</span>
74 + </button>
75 + </div>
76 + <div class="modal-body">
77 + <table class="table table-hover">
78 + <thead>
79 + <th class="text-center">Concepto</th>
80 + <th class="text-center">Valor</th>
81 + </thead>
82 + <tbody>
83 + <tr v-for="concept in concepts">
84 + <td>@{{concept.concept}}</td>
85 + <td class="text-right">@{{concept.valor | money}}</td>
86 + </tr>
87 + </tbody>
88 + <tfoot>
89 + <tr>
90 + <th>Total</th>
91 + <th class="text-right">@{{value | money}}</th>
92 + </tr>
93 + </tfoot>
94 + </table>
95 + </div>
96 + <div class="modal-footer">
97 + <button type="button" class="btn btn-secondary" data-
dismiss="modal">Cerrar</button>
98 + <button type="button" class="btn btn-primary">
99 + <i class="fa fa-credit-card"></i> Pagar
100 + </button>
101 + </div>

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/3f1d8573cb9f650ab21df4018895cd23f9a96352 9/13
1/8/2020 Admin sucursal puede importar facturas y conceptos. Usuario final puede ver sus facturas pendientes (3f1d8573) · Commits · Guillermo Agudelo / transito-frontend · GitLab

102 + </div>
103 + </div>
104 + </div>
105 + </div>
106 + @endsection
107 +
108 + @push('js')
109 +
110 + <script>
111 + new Vue({
112 + el: '#payments',
113 + data() {
114 + return {
115 + invoiceNumber: null,
116 + value: null,
117 + concepts: [],
118 + }
119 + },
120 + methods: {
121 + pay(invoiceId) {
122 + console.log('paying')
123 + },
124 + details(invoiceId, invoiceNumber, value) {
125 + Progress.start()
126 + axios.get('/api/invoice-details/by-invoice-id/'+invoiceId)
127 + .then(res => {
128 + if (res.data.status == 'success') {
129 + this.invoiceNumber = invoiceNumber
130 + this.value = value
131 + this.concepts = res.data.data.concepts
132 + $('#detailsModal').modal('show')
133 + }
134 + }).catch(err => {
135 + console.log(err)
136 + }).then(() => Progress.done())
137 + }
138 + },
139 + filters: {
140 + money(value) {
141 + return '$' + new Intl.NumberFormat().format(value)
142 + }
143 + }
144 + })
145 + </script>
146 + @endpush

  resources/views/portal/queue/index.blade.php
... ... @@ -158,76 +158,81 @@
158 158
159 159 <div class="mt-5">
160 160 <h2>Mis Turnos</h2>
161 - <table class="table table-responsive table-hover">
162 - <thead>
163 - <th>Orden</th>
164 - <th>Estado</th>
165 - <th>Fecha</th>
166 - <th>Trámite</th>
167 - <th>Sucursal</th>
168 - <th :class="{'d-none': fieldsHidden}">Dirección</th>
169 - <th :class="{'d-none': fieldsHidden}">Teléfono</th>
170 - <th :class="{'d-none': fieldsHidden}">Entidad</th>
171 - <th>
172 - <a href="#"
173 - @click.prevent="fieldsHidden = !fieldsHidden"
174 - title="Ver/Ocultar campos extras">
175 - <i class="fa fa-angle-double-right" v-if="fieldsHidden"></i>
176 - <i class="fa fa-angle-double-left" v-else></i>
177 - </a>
178 - </th>
179 - <th>Acciones</th>
180 - </thead>
181 - <tbody>
182 - @forelse($queues as $queue)

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/3f1d8573cb9f650ab21df4018895cd23f9a96352 10/13
1/8/2020 Admin sucursal puede importar facturas y conceptos. Usuario final puede ver sus facturas pendientes (3f1d8573) · Commits · Guillermo Agudelo / transito-frontend · GitLab

183 - <tr class="@if($queue->field('state') == \TurnState::CANCELADO) text-danger


@endif">
184 - <td>{{ $queue->field('order') ?? '-' }}</td>
185 - <td>{{ $queue->field('state') }}</td>
186 - <td>
187 - @if($queue->field('date'))
188 - @datetime($queue->field('date'))
189 - @else
190 - -
191 - @endif
192 - </td>
193 - <td>{{ \App\Service::find($queue->field('idService'))->field('name') }}</td>
194 - <td>
195 - {{ $branches->first(function($b) use($queue) {
196 - return $b->id() == $queue->field('idBranch');
197 - })->field('name') }}
198 - </td>
199 - <td :class="{'d-none': fieldsHidden}">{{ $queue->foreign($branches,
'idBranch')->field('location.address') }}</td>
200 - <td :class="{'d-none': fieldsHidden}">{{ $queue->foreign($branches,
'idBranch')->field('phone') }}</td>
201 - <td :class="{'d-none': fieldsHidden}">
202 - {{ $companies->first(function($c) use($queue) {
203 - return $c->id() == $queue->field('idCompany');
204 - })->field('name') }}
205 - </td>
206 - <td></td>
207 - <td class="text-center">
208 - <a href="#"
209 - class="text-danger @if($queue->field('state') == \TurnState::CANCELADO)
d-none @endif"
210 - title="Cancelar Turno"
211 - @click.prevent="cancel('{{$queue->id()}}')">
212 - <i class="fa fa-trash"></i>
213 - </a>
161 + <div class="w-100" style="overflow-x: scroll">
162 + <table class="table table-hover">
163 + <thead>
164 + <th>Orden</th>
165 + <th>Estado</th>
166 + <th>Fecha</th>
167 + <th>Trámite</th>
168 + <th>Sucursal</th>
169 + <th :class="{'d-none': fieldsHidden}">Dirección</th>
170 + <th :class="{'d-none': fieldsHidden}">Teléfono</th>
171 + <th :class="{'d-none': fieldsHidden}">Entidad</th>
172 + <th>
173 + <a href="#"
174 + @click.prevent="fieldsHidden = !fieldsHidden"
175 + title="Ver/Ocultar campos extras">
176 + <i class="fa fa-angle-double-right" v-if="fieldsHidden"></i>
177 + <i class="fa fa-angle-double-left" v-else></i>
178 + </a>
179 + </th>
180 + <th class="text-center">Acciones</th>
181 + </thead>
182 + <tbody>
183 + @forelse($queues as $queue)
184 + <tr class="@if($queue->field('state') == \TurnState::CANCELADO) text-danger
@endif">
185 + <td>{{ $queue->field('order') ?? '-' }}</td>
186 + <td>{{ $queue->field('state') }}</td>
187 + <td>
188 + @if($queue->field('date'))
189 + @datetime($queue->field('date'))
190 + @else
191 + -
192 + @endif
193 + </td>
194 + <td>{{ \App\Service::find($queue->field('idService'))->field('name') }}
</td>
195 + <td>
196 + {{ $branches->first(function($b) use($queue) {
197 + return $b->id() == $queue->field('idBranch');
198 + })->field('name') }}

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/3f1d8573cb9f650ab21df4018895cd23f9a96352 11/13
1/8/2020 Admin sucursal puede importar facturas y conceptos. Usuario final puede ver sus facturas pendientes (3f1d8573) · Commits · Guillermo Agudelo / transito-frontend · GitLab

199 + </td>
200 + <td :class="{'d-none': fieldsHidden}">{{ $queue->foreign($branches,
'idBranch')->field('location.address') }}</td>
201 + <td :class="{'d-none': fieldsHidden}">{{ $queue->foreign($branches,
'idBranch')->field('phone') }}</td>
202 + <td :class="{'d-none': fieldsHidden}">
203 + {{ $companies->first(function($c) use($queue) {
204 + return $c->id() == $queue->field('idCompany');
205 + })->field('name') }}
206 + </td>
207 + <td></td>
208 + <td class="text-center">
209 + @if($queue->field('state') != \TurnState::CANCELADO &&
210 + $queue->field('state') != \TurnState::TERMINADO)
211 + <a href="#"
212 + class="text-danger"
213 + title="Cancelar Turno"
214 + @click.prevent="cancel('{{$queue->id()}}')">
215 + <i class="fa fa-trash"></i>
216 + </a>
214 217
215 - <form action="{{route('queue.cancel', $queue->id())}}"
216 - method="post"
217 - class="d-none"
218 - id="cancel-form-{{$queue->id()}}">
219 - @csrf
220 - @method('put')
221 - </form>
222 - </td>
223 - </tr>
224 - @empty
225 - <tr>
226 - <td colspan="4"><p>No hay turnos creados todavía</p></td>
227 - </tr>
228 - @endforelse
229 - </tbody>
230 - </table>
218 + <form action="{{route('queue.cancel', $queue->id())}}"
219 + method="post"
220 + class="d-none"
221 + id="cancel-form-{{$queue->id()}}">
222 + @csrf
223 + @method('put')
224 + </form>
225 + @endif
226 + </td>
227 + </tr>
228 + @empty
229 + <tr>
230 + <td colspan="4"><p>No hay turnos creados todavía</p></td>
231 + </tr>
232 + @endforelse
233 + </tbody>
234 + </table>
235 + </div>
231 236 </div>
232 237
233 238 <div class="text-center mt-6">
... ...

  routes/web.php
... ... @@ -99,6 +99,7 @@ Route::group([
99 99 Route::get('', 'InvoiceController@index')->name('index');
100 100 Route::post('upload-invoices', 'InvoiceController@uploadInvoices')->name('upload-invoices');
101 101 Route::post('upload-details', 'InvoiceController@uploadDetails')->name('upload-details');
102 + Route::put('deactivate', 'InvoiceController@deactivate')->name('deactivate');
102 103 });
103 104 });
104 105
... ... @@ -120,6 +121,13 @@ Route::group([
120 121 ], function() {
121 122 Route::get('', 'QueueController@index')->name('index');
122 123 });
124 +

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/3f1d8573cb9f650ab21df4018895cd23f9a96352 12/13
1/8/2020 Admin sucursal puede importar facturas y conceptos. Usuario final puede ver sus facturas pendientes (3f1d8573) · Commits · Guillermo Agudelo / transito-frontend · GitLab

125 + Route::group([
126 + 'prefix' => 'payments',
127 + 'as' => 'payments.',
128 + ], function() {
129 + Route::get('', 'PaymentController@index')->name('index');
130 + });
123 131 });
124 132
125 133
... ... @@ -180,5 +188,11 @@ Route::group([
180 188 Route::get('{id}/services','BranchController@services');
181 189 Route::get('{id}','BranchController@find');
182 190 });
191 +
192 + Route::group([
193 + 'prefix' => 'invoice-details',
194 + ], function() {
195 + Route::get('by-invoice-id/{invoiceId}','InvoiceDetailController@byInvoiceId');
196 + });
183 197 });
184 198

Write a comment or drag your files here…

Markdown and quick actions are supported

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/3f1d8573cb9f650ab21df4018895cd23f9a96352 13/13

You might also like