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 class="ui top attached tabular menu" id="tabs">
|
||||
<div class="yellow active item" data-tab="pending">Pendientes</div>
|
||||
<div class="green item" data-tab="active">Activas</div>
|
||||
<div class="red item" data-tab="rejected">Rechazadas</div>
|
||||
<div class="yellow active item link" data-tab="pending">Pendientes</div>
|
||||
<div class="green item link" data-tab="active">Activas</div>
|
||||
<div class="red item link" data-tab="rejected">Rechazadas</div>
|
||||
</div>
|
||||
<div class="ui bottom attached tab fitted segment active" data-tab="pending">
|
||||
<table class="ui yellow striped table" id="pending_reservations">
|
||||
@ -107,7 +107,7 @@
|
||||
@push('page_styles')
|
||||
<style>
|
||||
.item.link {
|
||||
cursor: pointer;
|
||||
cursor: pointer !important;
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
@ -294,9 +294,9 @@
|
||||
}
|
||||
}
|
||||
columnsData() {
|
||||
return this.reservations.map(reservation => {
|
||||
return this.reservations.map(reservation => {
|
||||
const date = new Date(Date.parse(reservation.date) + 24 * 60 * 60 * 1000)
|
||||
return {
|
||||
return {
|
||||
id: reservation.id,
|
||||
unidades: reservation.summary,
|
||||
cliente: reservation.buyer.nombreCompleto,
|
||||
@ -412,7 +412,7 @@
|
||||
columnsData() {
|
||||
const data = super.columnsData();
|
||||
return data.map(row => {
|
||||
delete (row['valida'])
|
||||
delete(row['valida'])
|
||||
return row
|
||||
})
|
||||
}
|
||||
@ -475,8 +475,8 @@
|
||||
columnsData() {
|
||||
const data = super.columnsData()
|
||||
return this.reservations.map((reservation, idx) => {
|
||||
data[idx]['estado'] = reservation.state.charAt(0).toUpperCase() + reservation.state.slice(1)
|
||||
data[idx]['comentarios'] = reservation.comments?.join('<br />\n') ?? ''
|
||||
data[idx]['estado'] = this.mapState(reservation.current_state)
|
||||
data[idx]['comentarios'] = reservation.comments ?? ''
|
||||
return data[idx]
|
||||
})
|
||||
}
|
||||
@ -484,6 +484,13 @@
|
||||
return ''
|
||||
}
|
||||
watch() {}
|
||||
|
||||
mapState(state) {
|
||||
return {
|
||||
'canceled': 'Cancelado',
|
||||
'rejected': 'Rechazado'
|
||||
}[state.toLowerCase()]
|
||||
}
|
||||
}
|
||||
|
||||
const reservations = {
|
||||
@ -645,6 +652,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(() => {
|
||||
reservations.setup({
|
||||
ids: {
|
||||
|
@ -117,6 +117,8 @@ class Reservation extends Common\Ideal\Model
|
||||
return $base >= $price;
|
||||
}
|
||||
|
||||
public string $comments;
|
||||
|
||||
protected function jsonComplement(): array
|
||||
{
|
||||
return [
|
||||
@ -131,7 +133,10 @@ class Reservation extends Common\Ideal\Model
|
||||
'base' => $this->base(),
|
||||
'price' => $this->price(),
|
||||
'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 [
|
||||
'reservation_id' => $this->reservation->id,
|
||||
'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
|
||||
{
|
||||
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 DateInterval;
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Exception\Model\InvalidState;
|
||||
use PDO;
|
||||
use Incoviba\Common;
|
||||
@ -29,7 +30,7 @@ class Reservation extends Common\Ideal\Repository
|
||||
|
||||
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())
|
||||
->setProperty('project')
|
||||
->setFunction(function($data) {
|
||||
@ -114,13 +115,16 @@ class Reservation extends Common\Ideal\Repository
|
||||
|
||||
/**
|
||||
* @param int $project_id
|
||||
* @param int $state
|
||||
* @param int|string $state
|
||||
* @return array
|
||||
* @throws Common\Implement\Exception\EmptyResult
|
||||
* @throws EmptyResult
|
||||
* @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())) {
|
||||
throw new InvalidState();
|
||||
}
|
||||
|
Reference in New Issue
Block a user