Rejected or canceled reservations, comments
This commit is contained in:
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Phinx\Migration\AbstractMigration;
|
||||||
|
|
||||||
|
final class AddCommentsToReservations extends AbstractMigration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Change Method.
|
||||||
|
*
|
||||||
|
* Write your reversible migrations using this method.
|
||||||
|
*
|
||||||
|
* More information on writing migrations is available here:
|
||||||
|
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
|
||||||
|
*
|
||||||
|
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||||
|
* with the Table class.
|
||||||
|
*/
|
||||||
|
public function change(): void
|
||||||
|
{
|
||||||
|
$this->table('reservations')
|
||||||
|
->addColumn('comments', 'text')
|
||||||
|
->update();
|
||||||
|
}
|
||||||
|
}
|
@ -47,9 +47,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui top attached tabular menu" id="tabs">
|
<div class="ui top attached tabular menu" id="tabs">
|
||||||
<div class="yellow active item" data-tab="pending">Pendientes</div>
|
<div class="yellow active item link" data-tab="pending">Pendientes</div>
|
||||||
<div class="green item" data-tab="active">Activas</div>
|
<div class="green item link" data-tab="active">Activas</div>
|
||||||
<div class="red item" data-tab="rejected">Rechazadas</div>
|
<div class="red item link" data-tab="rejected">Rechazadas</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui bottom attached tab fitted segment active" data-tab="pending">
|
<div class="ui bottom attached tab fitted segment active" data-tab="pending">
|
||||||
<table class="ui yellow striped table" id="pending_reservations">
|
<table class="ui yellow striped table" id="pending_reservations">
|
||||||
@ -107,7 +107,7 @@
|
|||||||
@push('page_styles')
|
@push('page_styles')
|
||||||
<style>
|
<style>
|
||||||
.item.link {
|
.item.link {
|
||||||
cursor: pointer;
|
cursor: pointer !important;
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@ -294,9 +294,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
columnsData() {
|
columnsData() {
|
||||||
return this.reservations.map(reservation => {
|
return this.reservations.map(reservation => {
|
||||||
const date = new Date(Date.parse(reservation.date) + 24 * 60 * 60 * 1000)
|
const date = new Date(Date.parse(reservation.date) + 24 * 60 * 60 * 1000)
|
||||||
return {
|
return {
|
||||||
id: reservation.id,
|
id: reservation.id,
|
||||||
unidades: reservation.summary,
|
unidades: reservation.summary,
|
||||||
cliente: reservation.buyer.nombreCompleto,
|
cliente: reservation.buyer.nombreCompleto,
|
||||||
@ -412,7 +412,7 @@
|
|||||||
columnsData() {
|
columnsData() {
|
||||||
const data = super.columnsData();
|
const data = super.columnsData();
|
||||||
return data.map(row => {
|
return data.map(row => {
|
||||||
delete (row['valida'])
|
delete(row['valida'])
|
||||||
return row
|
return row
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -475,8 +475,8 @@
|
|||||||
columnsData() {
|
columnsData() {
|
||||||
const data = super.columnsData()
|
const data = super.columnsData()
|
||||||
return this.reservations.map((reservation, idx) => {
|
return this.reservations.map((reservation, idx) => {
|
||||||
data[idx]['estado'] = reservation.state.charAt(0).toUpperCase() + reservation.state.slice(1)
|
data[idx]['estado'] = this.mapState(reservation.current_state)
|
||||||
data[idx]['comentarios'] = reservation.comments?.join('<br />\n') ?? ''
|
data[idx]['comentarios'] = reservation.comments ?? ''
|
||||||
return data[idx]
|
return data[idx]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -484,6 +484,13 @@
|
|||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
watch() {}
|
watch() {}
|
||||||
|
|
||||||
|
mapState(state) {
|
||||||
|
return {
|
||||||
|
'canceled': 'Cancelado',
|
||||||
|
'rejected': 'Rechazado'
|
||||||
|
}[state.toLowerCase()]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const reservations = {
|
const reservations = {
|
||||||
@ -645,6 +652,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(() => {
|
$(document).ready(() => {
|
||||||
reservations.setup({
|
reservations.setup({
|
||||||
ids: {
|
ids: {
|
||||||
|
@ -117,6 +117,8 @@ class Reservation extends Common\Ideal\Model
|
|||||||
return $base >= $price;
|
return $base >= $price;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string $comments;
|
||||||
|
|
||||||
protected function jsonComplement(): array
|
protected function jsonComplement(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@ -131,7 +133,10 @@ class Reservation extends Common\Ideal\Model
|
|||||||
'base' => $this->base(),
|
'base' => $this->base(),
|
||||||
'price' => $this->price(),
|
'price' => $this->price(),
|
||||||
'valid' => $this->valid(),
|
'valid' => $this->valid(),
|
||||||
'summary' => $this->summary()
|
'summary' => $this->summary(),
|
||||||
|
'states' => $this->states() ?? [],
|
||||||
|
'current_state' => $this->currentState()?->type?->name ?? null,
|
||||||
|
'comments' => $this->comments ?? '',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,10 @@ class State extends Common\Ideal\Model
|
|||||||
return [
|
return [
|
||||||
'reservation_id' => $this->reservation->id,
|
'reservation_id' => $this->reservation->id,
|
||||||
'date' => $this->date->format('Y-m-d'),
|
'date' => $this->date->format('Y-m-d'),
|
||||||
'type' => $this->type
|
'type' => [
|
||||||
|
'id' => $this->type->value,
|
||||||
|
'name' => $this->type->name,
|
||||||
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,6 @@ enum Type: int
|
|||||||
}
|
}
|
||||||
public static function getTypes(): array
|
public static function getTypes(): array
|
||||||
{
|
{
|
||||||
return [self::ACTIVE->value, self::INACTIVE->value, self::REJECTED->value];
|
return [self::ACTIVE->value, self::INACTIVE->value, self::REJECTED->value, self::CANCELLED->value];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ namespace Incoviba\Repository\Venta;
|
|||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
use DateInterval;
|
use DateInterval;
|
||||||
use Incoviba\Common\Define;
|
use Incoviba\Common\Define;
|
||||||
|
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||||
use Incoviba\Exception\Model\InvalidState;
|
use Incoviba\Exception\Model\InvalidState;
|
||||||
use PDO;
|
use PDO;
|
||||||
use Incoviba\Common;
|
use Incoviba\Common;
|
||||||
@ -29,7 +30,7 @@ class Reservation extends Common\Ideal\Repository
|
|||||||
|
|
||||||
public function create(?array $data = null): Model\Venta\Reservation
|
public function create(?array $data = null): Model\Venta\Reservation
|
||||||
{
|
{
|
||||||
$map = (new Common\Implement\Repository\MapperParser())
|
$map = (new Common\Implement\Repository\MapperParser(['comments']))
|
||||||
->register('project_id', (new Common\Implement\Repository\Mapper())
|
->register('project_id', (new Common\Implement\Repository\Mapper())
|
||||||
->setProperty('project')
|
->setProperty('project')
|
||||||
->setFunction(function($data) {
|
->setFunction(function($data) {
|
||||||
@ -114,13 +115,16 @@ class Reservation extends Common\Ideal\Repository
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $project_id
|
* @param int $project_id
|
||||||
* @param int $state
|
* @param int|string $state
|
||||||
* @return array
|
* @return array
|
||||||
* @throws Common\Implement\Exception\EmptyResult
|
* @throws EmptyResult
|
||||||
* @throws InvalidState
|
* @throws InvalidState
|
||||||
*/
|
*/
|
||||||
public function fetchState(int $project_id, int $state): array
|
public function fetchState(int $project_id, int|string $state): array
|
||||||
{
|
{
|
||||||
|
if (is_string($state)) {
|
||||||
|
$state = Model\Venta\Reservation\State\Type::from($state)->value;
|
||||||
|
}
|
||||||
if (!in_array($state, Model\Venta\Reservation\State\Type::getTypes())) {
|
if (!in_array($state, Model\Venta\Reservation\State\Type::getTypes())) {
|
||||||
throw new InvalidState();
|
throw new InvalidState();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user