Compare commits
158 Commits
b4742a501e
...
2.2.0
Author | SHA1 | Date | |
---|---|---|---|
6ddc48ec60 | |||
8caa80459e | |||
98953cce42 | |||
c7dd309185 | |||
48bfe5d8ab | |||
d9b5bc6507 | |||
21d1ef653f | |||
e8d43e43ff | |||
fc9788a1cd | |||
02dcc950f4 | |||
370b6714bc | |||
dc7a9f9e7a | |||
cfe18c1909 | |||
5156858205 | |||
415ba31270 | |||
c784d1bee9 | |||
a1ade5c2c7 | |||
879b612493 | |||
b4cdd2d5f7 | |||
51cabee824 | |||
d2e51e76f8 | |||
1621d6fe30 | |||
0e32512adc | |||
338f290539 | |||
2aad7e1152 | |||
e542615128 | |||
1c7797b1b1 | |||
ba0d4073d7 | |||
faac3874a8 | |||
ade107ab3c | |||
c192cf1883 | |||
4fb75b11c4 | |||
ccbb71d875 | |||
7f25b4b5e1 | |||
f0b26a251b | |||
ea068d95d0 | |||
1ccc9ab3d4 | |||
5cd19bcdce | |||
712c70b34d | |||
35ab7e7e8b | |||
4b39f93f30 | |||
d3f188684a | |||
82647a171d | |||
e44ab30665 | |||
19333bc338 | |||
4738dae7c8 | |||
a370ffff43 | |||
88f9e539f7 | |||
671b26f038 | |||
e133bd36cf | |||
251dbbe0f0 | |||
e1eb2c4c56 | |||
1078f4c188 | |||
38962cb9cf | |||
3cd699d2e2 | |||
d8b8787be9 | |||
ad3285efd9 | |||
62edca5335 | |||
ac6c5b7d3d | |||
5b5a0ed1f5 | |||
9d7857621e | |||
029cd095cb | |||
c1792907c0 | |||
fa11f5b240 | |||
f55e4dbd5f | |||
ca83472012 | |||
01af47fba1 | |||
e1462657fc | |||
72f63c5e6c | |||
1f076bc2f1 | |||
ad003c7dcf | |||
aef1ccd4a0 | |||
3684bc2e21 | |||
d1d3705a7b | |||
ecdb67a9ab | |||
4c86ce2a8a | |||
5c6bd91425 | |||
18d7e449f7 | |||
bfdaf0e7f2 | |||
ce0510687a | |||
3eb4ce4d21 | |||
674aba801e | |||
c4f486d3fa | |||
dc840a7bff | |||
316cc51387 | |||
68e59770fd | |||
a66b549a8c | |||
74b3bb42ea | |||
72a2ffe924 | |||
6393a1fced | |||
d225011ae9 | |||
bc2333bc95 | |||
675b3843ea | |||
0829d338a9 | |||
20b2bdc6c6 | |||
8492d1df2b | |||
afbadd520b | |||
ac52305002 | |||
d7d17a3051 | |||
80a6bf1535 | |||
93431e41b3 | |||
d99f2a6214 | |||
30277e6355 | |||
06d5327934 | |||
6f772a56b8 | |||
abe82e4689 | |||
379a33a4da | |||
1ba53c9e12 | |||
94906eea8c | |||
8b9b02825a | |||
8f2f90aca2 | |||
d699f9bf62 | |||
e38fdd20ee | |||
f362054ea7 | |||
f597d552be | |||
43977d1bd9 | |||
9aa4e0ae1d | |||
377cf51b44 | |||
57579a52f1 | |||
af9c6c51d4 | |||
0eaa09bea0 | |||
04478afa2f | |||
f2efb41977 | |||
d0a85b2149 | |||
68821fb0d3 | |||
f957d29779 | |||
dc7a39e193 | |||
17f93dcd34 | |||
9991b7c6a3 | |||
91bdef5cc5 | |||
244d304e04 | |||
2600bd409e | |||
0761be6613 | |||
e347aaabe9 | |||
fe3055708f | |||
62153dd1ef | |||
39048e12b3 | |||
094209823a | |||
bcdca32075 | |||
fada4f80a2 | |||
a28c51d94c | |||
df679b2a1a | |||
ec4b16b2af | |||
3c983fc6c9 | |||
7945579e80 | |||
ab1647eed3 | |||
ec7d8e69ab | |||
3cadaca746 | |||
2726bc5074 | |||
b66ef435c6 | |||
a82db6e1da | |||
e1ef31dccd | |||
bf03e85975 | |||
9ab0515954 | |||
331ee1e584 | |||
24c17debf3 | |||
552fd0aa06 | |||
60faf293d4 |
@ -1,3 +1,6 @@
|
||||
COMPOSE_PROFILES=app,db
|
||||
COMPOSE_PATH_SEPARATOR=:
|
||||
COMPOSE_FILE=./docker-compose.yml:./adminer-compose.yml
|
||||
COMPOSE_PROFILES=app,db,cli,cache
|
||||
APP_PATH=./app
|
||||
CLI_PATH=./cli
|
||||
APP_PORT=8080
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -8,3 +8,5 @@
|
||||
**/cache/
|
||||
**/modules/
|
||||
**/.idea/
|
||||
**/upload?/
|
||||
**/informe?/
|
||||
|
1
.key.env.sample
Normal file
1
.key.env.sample
Normal file
@ -0,0 +1 @@
|
||||
API_KEY=
|
19
CLI.Dockerfile
Normal file
19
CLI.Dockerfile
Normal file
@ -0,0 +1,19 @@
|
||||
FROM php:8.2-cli
|
||||
|
||||
ENV TZ "${TZ}"
|
||||
ENV APP_NAME "${APP_NAME}"
|
||||
ENV API_URL "${API_URL}"
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends cron rsyslog nano && rm -r /var/lib/apt/lists/*
|
||||
|
||||
RUN pecl install xdebug-3.2.2 \
|
||||
&& docker-php-ext-enable xdebug \
|
||||
&& echo "#/bin/bash\nprintenv >> /etc/environment\ncron -f -L 11" > /root/entrypoint && chmod a+x /root/entrypoint
|
||||
|
||||
COPY ./php-errors.ini /usr/local/etc/php/conf.d/docker-php-errors.ini
|
||||
|
||||
WORKDIR /code/bin
|
||||
|
||||
COPY --chmod=644 ./cli/crontab /var/spool/cron/crontabs/root
|
||||
|
||||
CMD [ "/root/entrypoint" ]
|
@ -1,6 +1,6 @@
|
||||
FROM php:8.1-fpm
|
||||
|
||||
RUN apt-get update && apt-get install -y libzip-dev libicu-dev git libpng-dev unzip tzdata \
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends libzip-dev libicu-dev git libpng-dev unzip tzdata \
|
||||
&& rm -r /var/lib/apt/lists/*
|
||||
|
||||
RUN docker-php-ext-install pdo pdo_mysql zip intl gd bcmath
|
||||
|
1
app/.adminer.env.sample
Normal file
1
app/.adminer.env.sample
Normal file
@ -0,0 +1 @@
|
||||
ADMINER_DESIGN=dracula
|
@ -1,4 +1,4 @@
|
||||
MYSQL_DATABASE=
|
||||
MYSQL_PASSWORD=
|
||||
MYSQL_ROOT_PASSWORD=
|
||||
MYSQL_DATABASE=
|
||||
MYSQL_USER=
|
||||
MYSQL_PASSWORD=
|
11
app/.env.sample
Normal file
11
app/.env.sample
Normal file
@ -0,0 +1,11 @@
|
||||
APP_URL=
|
||||
|
||||
MYSQL_HOST=db
|
||||
|
||||
COOKIE_NAME=
|
||||
COOKIE_DOMAIN=
|
||||
COOKIE_PATH=/
|
||||
MAX_LOGIN_HOURS=120
|
||||
|
||||
REDIS_HOST=redis
|
||||
REDIS_PORT=6379
|
10
app/common/Define/Cartola/Banco.php
Normal file
10
app/common/Define/Cartola/Banco.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Define\Cartola;
|
||||
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
|
||||
interface Banco
|
||||
{
|
||||
public function process(UploadedFileInterface $file): array;
|
||||
|
||||
}
|
@ -11,4 +11,5 @@ interface Connection
|
||||
public function prepare(string $query): PDOStatement;
|
||||
public function execute(string $query, ?array $data = null): PDOStatement;
|
||||
public function getPDO(): PDO;
|
||||
public function getQueryBuilder(): Query\Builder;
|
||||
}
|
||||
|
10
app/common/Define/Contabilidad/Exporter.php
Normal file
10
app/common/Define/Contabilidad/Exporter.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Define\Contabilidad;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Model;
|
||||
|
||||
interface Exporter
|
||||
{
|
||||
public function export(Model\Inmobiliaria $inmobiliaria, Model\Banco $banco, DateTimeInterface $mes, array $movimientos): string;
|
||||
}
|
10
app/common/Define/Informe.php
Normal file
10
app/common/Define/Informe.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Define;
|
||||
|
||||
interface Informe
|
||||
{
|
||||
public function setTitle(string $title): Informe;
|
||||
public function setFilename(string $filename): Informe;
|
||||
public function addData(array $rows): Informe;
|
||||
public function build(): void;
|
||||
}
|
@ -5,4 +5,5 @@ use JsonSerializable;
|
||||
|
||||
interface Model extends JsonSerializable
|
||||
{
|
||||
public function addFactory(string $property, Repository\Factory $factory): Model;
|
||||
}
|
||||
|
15
app/common/Define/Query.php
Normal file
15
app/common/Define/Query.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Define;
|
||||
|
||||
interface Query
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function build(): string;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string;
|
||||
}
|
33
app/common/Define/Query/Builder.php
Normal file
33
app/common/Define/Query/Builder.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Define\Query;
|
||||
|
||||
interface Builder
|
||||
{
|
||||
/**
|
||||
* @param string $table_name
|
||||
* @return Create
|
||||
*/
|
||||
public function create(string $table_name): Create;
|
||||
|
||||
/**
|
||||
* @param string|array $columns
|
||||
* @return Select
|
||||
*/
|
||||
public function select(string|array $columns = '*'): Select;
|
||||
|
||||
/**
|
||||
* @return Insert
|
||||
*/
|
||||
public function insert(): Insert;
|
||||
|
||||
/**
|
||||
* @param string $table
|
||||
* @return Update
|
||||
*/
|
||||
public function update(string $table): Update;
|
||||
|
||||
/**
|
||||
* @return Delete
|
||||
*/
|
||||
public function delete(): Delete;
|
||||
}
|
31
app/common/Define/Query/Create.php
Normal file
31
app/common/Define/Query/Create.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Define\Query;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
|
||||
interface Create extends Define\Query
|
||||
{
|
||||
/**
|
||||
* @param string $name
|
||||
* @return Create
|
||||
*/
|
||||
public function table(string $name): Create;
|
||||
|
||||
/**
|
||||
* @param string|Create\CreateDefinition|array $create_definitions
|
||||
* @return Create
|
||||
*/
|
||||
public function definitions(string|Create\CreateDefinition|array $create_definitions): Create;
|
||||
|
||||
/**
|
||||
* @param string|array $table_options
|
||||
* @return Create
|
||||
*/
|
||||
public function options(string|array $table_options): Create;
|
||||
|
||||
/**
|
||||
* @param string|array $partition_options
|
||||
* @return Create
|
||||
*/
|
||||
public function partition(string|array $partition_options): Create;
|
||||
}
|
59
app/common/Define/Query/Create/CreateDefinition.php
Normal file
59
app/common/Define/Query/Create/CreateDefinition.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Define\Query\Create;
|
||||
|
||||
interface CreateDefinition
|
||||
{
|
||||
const RESTRICT = 0;
|
||||
const CASCADE = 1;
|
||||
const SET_NULL = 2;
|
||||
const NO_ACTION = 3;
|
||||
const SET_DEFAULT = 4;
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return CreateDefinition
|
||||
*/
|
||||
public function name(string $name): CreateDefinition;
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param int|null $size
|
||||
* @return CreateDefinition
|
||||
*/
|
||||
public function type(string $type, ?int $size = null): CreateDefinition;
|
||||
|
||||
/**
|
||||
* @return CreateDefinition
|
||||
*/
|
||||
public function primary(): CreateDefinition;
|
||||
|
||||
/**
|
||||
* @return CreateDefinition
|
||||
*/
|
||||
public function autoIncrement(): CreateDefinition;
|
||||
|
||||
/**
|
||||
* @return CreateDefinition
|
||||
*/
|
||||
public function unsigned(): CreateDefinition;
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @return CreateDefinition
|
||||
*/
|
||||
public function default(mixed $value): CreateDefinition;
|
||||
|
||||
/**
|
||||
* @param string $reference_table
|
||||
* @param string $reference_column
|
||||
* @param int $on_delete
|
||||
* @param int $on_update
|
||||
* @return CreateDefinition
|
||||
*/
|
||||
public function foreign(string $reference_table, string $reference_column = 'id', int $on_delete = CreateDefinition::CASCADE, int $on_update = CreateDefinition::CASCADE): CreateDefinition;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string;
|
||||
}
|
12
app/common/Define/Query/Delete.php
Normal file
12
app/common/Define/Query/Delete.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Define\Query;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
|
||||
interface Delete extends Define\Query
|
||||
{
|
||||
public function from(string $table): Delete;
|
||||
public function where(string|array $conditions): Delete;
|
||||
public function order(string|array $sorting): Delete;
|
||||
public function limit(int $limit): Delete;
|
||||
}
|
32
app/common/Define/Query/Insert.php
Normal file
32
app/common/Define/Query/Insert.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Define\Query;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
|
||||
interface Insert extends Define\Query
|
||||
{
|
||||
/**
|
||||
* @param string $table
|
||||
* @param array|null $columns
|
||||
* @return Insert
|
||||
*/
|
||||
public function into(string $table, ?array $columns = null): Insert;
|
||||
|
||||
/**
|
||||
* @param array $columns
|
||||
* @return Insert
|
||||
*/
|
||||
public function columns(array $columns): Insert;
|
||||
|
||||
/**
|
||||
* @param array $values
|
||||
* @return Insert
|
||||
*/
|
||||
public function values(array $values): Insert;
|
||||
|
||||
/**
|
||||
* @param Select $select
|
||||
* @return Insert
|
||||
*/
|
||||
public function select(Select $select): Insert;
|
||||
}
|
62
app/common/Define/Query/Select.php
Normal file
62
app/common/Define/Query/Select.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Define\Query;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
|
||||
interface Select extends Define\Query
|
||||
{
|
||||
/**
|
||||
* @param string|array $expressions
|
||||
* @return Select
|
||||
*/
|
||||
public function columns(string|array $expressions): Select;
|
||||
|
||||
/**
|
||||
* @param string $table
|
||||
* @return Select
|
||||
*/
|
||||
public function from(string $table): Select;
|
||||
|
||||
/**
|
||||
* @param string|array $joins
|
||||
* @return Select
|
||||
*/
|
||||
public function joined(string|array $joins): Select;
|
||||
|
||||
/**
|
||||
* @param string|array $conditions
|
||||
* @return Select
|
||||
*/
|
||||
public function where(string|array $conditions): Select;
|
||||
|
||||
/**
|
||||
* @param string|array $grouping
|
||||
* @return Select
|
||||
*/
|
||||
public function group(string|array $grouping): Select;
|
||||
|
||||
/**
|
||||
* @param string|array $conditions
|
||||
* @return Select
|
||||
*/
|
||||
public function having(string|array $conditions): Select;
|
||||
|
||||
/**
|
||||
* @param string|array $sorting
|
||||
* @return Select
|
||||
*/
|
||||
public function order(string|array $sorting): Select;
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
* @param int|null $offset
|
||||
* @return Select
|
||||
*/
|
||||
public function limit(int $limit, ?int $offset = null): Select;
|
||||
|
||||
/**
|
||||
* @param int $offset
|
||||
* @return Select
|
||||
*/
|
||||
public function offset(int $offset): Select;
|
||||
}
|
13
app/common/Define/Query/Update.php
Normal file
13
app/common/Define/Query/Update.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Define\Query;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
|
||||
interface Update extends Define\Query
|
||||
{
|
||||
public function table(string $table): Update;
|
||||
public function set(string|array $column_pairs): Update;
|
||||
public function where(string|array $conditions): Update;
|
||||
public function order(string|array $ordering): Update;
|
||||
public function limit(int $limit): Update;
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Define\Repository;
|
||||
|
||||
use Incoviba\Common\Define\Model;
|
||||
|
||||
interface Mapper
|
||||
{
|
||||
public function setProperty(string $property): Mapper;
|
||||
@ -12,4 +14,6 @@ interface Mapper
|
||||
public function hasFunction(): bool;
|
||||
public function hasFactory(): bool;
|
||||
public function hasDefault(): bool;
|
||||
|
||||
public function parse(Model &$model, string $column, ?array $data): bool;
|
||||
}
|
||||
|
34
app/common/Ideal/Cartola/Banco.php
Normal file
34
app/common/Ideal/Cartola/Banco.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Ideal\Cartola;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal\Service;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
|
||||
abstract class Banco extends Service implements Define\Cartola\Banco
|
||||
{
|
||||
public function process(UploadedFileInterface $file): array
|
||||
{
|
||||
$data = $this->parseFile($file);
|
||||
$temp = [];
|
||||
$columns = $this->columnMap();
|
||||
foreach ($data as $row) {
|
||||
$r = [];
|
||||
foreach ($columns as $old => $new) {
|
||||
if (!isset($row[$old])) {
|
||||
continue;
|
||||
}
|
||||
$r[$new] = $row[$old];
|
||||
}
|
||||
$temp []= $r;
|
||||
}
|
||||
return $temp;
|
||||
}
|
||||
public function processMovimientosDiarios(array $movimientos): array
|
||||
{
|
||||
return $movimientos;
|
||||
}
|
||||
|
||||
abstract protected function columnMap(): array;
|
||||
abstract protected function parseFile(UploadedFileInterface $uploadedFile): array;
|
||||
}
|
9
app/common/Ideal/Controller.php
Normal file
9
app/common/Ideal/Controller.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Ideal;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
public function __construct(protected LoggerInterface $logger) {}
|
||||
}
|
12
app/common/Ideal/Query.php
Normal file
12
app/common/Ideal/Query.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Ideal;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
|
||||
abstract class Query implements Define\Query
|
||||
{
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->build();
|
||||
}
|
||||
}
|
@ -31,18 +31,28 @@ abstract class Repository implements Define\Repository
|
||||
|
||||
public function remove(Define\Model $model): void
|
||||
{
|
||||
$query = "DELETE FROM `{$this->getTable()}` WHERE `{$this->getKey()}` = ?";
|
||||
$this->connection->execute($query, [$model->getId()]);
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->delete()->from($this->getTable())
|
||||
->where("{$this->getKey()} = ?");
|
||||
$this->connection->execute($query, [$model->id]);
|
||||
}
|
||||
|
||||
public function fetchById(int $id): Define\Model
|
||||
{
|
||||
$query = "SELECT * FROM `{$this->getTable()}` WHERE `{$this->getKey()}` = ?";
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->select()
|
||||
->from($this->getTable())
|
||||
->where("{$this->getKey()} = ?");
|
||||
return $this->fetchOne($query, [$id]);
|
||||
}
|
||||
public function fetchAll(): array
|
||||
public function fetchAll(null|string|array $ordering = null): array
|
||||
{
|
||||
$query = "SELECT * FROM `{$this->getTable()}`";
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->select()
|
||||
->from($this->getTable());
|
||||
if ($ordering !== null) {
|
||||
$query->order($ordering);
|
||||
}
|
||||
return $this->fetchMany($query);
|
||||
}
|
||||
|
||||
@ -96,9 +106,11 @@ abstract class Repository implements Define\Repository
|
||||
}
|
||||
protected function saveNew(array $columns, array $values): int
|
||||
{
|
||||
$columns_string = implode(', ', array_map(function($column) {return "`{$column}`";}, $columns));
|
||||
$columns_questions = implode(', ', array_fill(0, count($columns), '?'));
|
||||
$query = "INSERT INTO `{$this->getTable()}` ({$columns_string}) VALUES ($columns_questions)";
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->insert()
|
||||
->into($this->getTable())
|
||||
->columns($columns)
|
||||
->values(array_fill(0, count($columns), '?'));
|
||||
$this->connection->execute($query, $values);
|
||||
return $this->connection->getPDO()->lastInsertId();
|
||||
}
|
||||
@ -107,7 +119,7 @@ abstract class Repository implements Define\Repository
|
||||
$changes = [];
|
||||
$values = [];
|
||||
foreach ($columns as $column) {
|
||||
if (isset($data[$column])) {
|
||||
if (in_array($column, array_keys($data))) {
|
||||
$changes []= $column;
|
||||
$values []= $data[$column];
|
||||
}
|
||||
@ -117,7 +129,10 @@ abstract class Repository implements Define\Repository
|
||||
return $model;
|
||||
}
|
||||
$columns_string = implode(', ', array_map(function($property) {return "`{$property}` = ?";}, $changes));
|
||||
$query = "UPDATE `{$this->getTable()}` SET {$columns_string} WHERE `{$this->getKey()}` = ?";
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->update($this->getTable())
|
||||
->set($columns_string)
|
||||
->where("{$this->getKey()} = ?");
|
||||
$values []= $model->{$this->getKey()};
|
||||
$this->connection->execute($query, $values);
|
||||
return $this->fetchById($model->{$this->getKey()});
|
||||
|
9
app/common/Ideal/Service.php
Normal file
9
app/common/Ideal/Service.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Ideal;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
abstract class Service
|
||||
{
|
||||
public function __construct(protected LoggerInterface $logger) {}
|
||||
}
|
@ -8,7 +8,7 @@ use Incoviba\Common\Define;
|
||||
|
||||
class Connection implements Define\Connection
|
||||
{
|
||||
public function __construct(protected Define\Database $database) {}
|
||||
public function __construct(protected Define\Database $database, protected Database\Query\Builder $queryBuilder) {}
|
||||
|
||||
protected PDO $connection;
|
||||
public function connect(): Define\Connection
|
||||
@ -27,6 +27,10 @@ class Connection implements Define\Connection
|
||||
$this->connect();
|
||||
return $this->connection;
|
||||
}
|
||||
public function getQueryBuilder(): Database\Query\Builder
|
||||
{
|
||||
return $this->queryBuilder;
|
||||
}
|
||||
|
||||
public function query(string $query): PDOStatement
|
||||
{
|
||||
|
29
app/common/Implement/Database/Query/Builder.php
Normal file
29
app/common/Implement/Database/Query/Builder.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Database\Query;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
|
||||
class Builder implements Define\Query\Builder
|
||||
{
|
||||
public function create(string $table_name): Create
|
||||
{
|
||||
return (new Create())->table($table_name);
|
||||
}
|
||||
|
||||
public function select(array|string $columns = '*'): Select
|
||||
{
|
||||
return (new Select())->columns($columns);
|
||||
}
|
||||
public function insert(): Insert
|
||||
{
|
||||
return new Insert();
|
||||
}
|
||||
public function update(string $table): Update
|
||||
{
|
||||
return (new Update())->table($table);
|
||||
}
|
||||
public function delete(): Delete
|
||||
{
|
||||
return new Delete();
|
||||
}
|
||||
}
|
102
app/common/Implement/Database/Query/Create.php
Normal file
102
app/common/Implement/Database/Query/Create.php
Normal file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Database\Query;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
class Create extends Ideal\Query implements Define\Query\Create
|
||||
{
|
||||
protected string $name;
|
||||
protected array $definitions;
|
||||
protected array $options;
|
||||
protected array $partitions;
|
||||
|
||||
public function table(string $name): Define\Query\Create
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
public function definitions(Define\Query\Create\CreateDefinition|array|string $create_definitions): Define\Query\Create
|
||||
{
|
||||
if (is_array($create_definitions)) {
|
||||
foreach ($create_definitions as $definition) {
|
||||
$this->addDefinition($definition);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
return $this->addDefinition($create_definitions);
|
||||
}
|
||||
public function options(array|string $table_options): Define\Query\Create
|
||||
{
|
||||
if (is_string($table_options)) {
|
||||
return $this->addOption($table_options);
|
||||
}
|
||||
foreach ($table_options as $option) {
|
||||
$this->addOption($option);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function partition(array|string $partition_options): Define\Query\Create
|
||||
{
|
||||
if (is_string($partition_options)) {
|
||||
return $this->addPartition($partition_options);
|
||||
}
|
||||
foreach ($partition_options as $option) {
|
||||
$this->addPartition($option);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function build(): string
|
||||
{
|
||||
$query = [
|
||||
"CREATE TABLE {$this->name}",
|
||||
$this->getDefinitions(),
|
||||
$this->getOptions(),
|
||||
$this->getPartitions()
|
||||
];
|
||||
return implode('', $query);
|
||||
}
|
||||
|
||||
protected function addDefinition(string $definition): Create
|
||||
{
|
||||
if (!isset($this->definitions)) {
|
||||
$this->definitions = [];
|
||||
}
|
||||
$this->definitions []= $definition;
|
||||
return $this;
|
||||
}
|
||||
protected function addOption(string $option): Create
|
||||
{
|
||||
if (!isset($this->options)) {
|
||||
$this->options = [];
|
||||
}
|
||||
$this->options []= $option;
|
||||
return $this;
|
||||
}
|
||||
protected function addPartition(string $partition): Create
|
||||
{
|
||||
if (!isset($this->partitions)) {
|
||||
$this->partitions = [];
|
||||
}
|
||||
$this->partitions []= $partition;
|
||||
return $this;
|
||||
}
|
||||
protected function getDefinitions(): string
|
||||
{
|
||||
return ' (' . implode(', ', $this->definitions) . ')';
|
||||
}
|
||||
protected function getOptions(): string
|
||||
{
|
||||
if (!isset($this->options) or count($this->options) <= 0) {
|
||||
return '';
|
||||
}
|
||||
return ' ' . implode(' ', $this->options);
|
||||
}
|
||||
protected function getPartitions(): string
|
||||
{
|
||||
if (!isset($this->partitions) or count($this->partitions) <= 0) {
|
||||
return '';
|
||||
}
|
||||
return ' PARTITION BY (' . implode(', ', $this->partitions) . ')';
|
||||
}
|
||||
}
|
104
app/common/Implement/Database/Query/Create/Definition.php
Normal file
104
app/common/Implement/Database/Query/Create/Definition.php
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
namespace ProVM\Implement\Data\Query\Create;
|
||||
|
||||
use ProVM\Define\Query\Create\CreateDefinition;
|
||||
|
||||
class Definition implements CreateDefinition
|
||||
{
|
||||
protected string $name;
|
||||
protected string $type;
|
||||
protected int $size;
|
||||
protected bool $primary;
|
||||
protected bool $auto_increment;
|
||||
protected bool $unsigned;
|
||||
protected mixed $default;
|
||||
protected string $foreign_table;
|
||||
protected string $foreign_key;
|
||||
protected int $foreign_delete;
|
||||
protected int $foreign_update;
|
||||
|
||||
public function name(string $name): CreateDefinition
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
public function type(string $type, ?int $size = null): CreateDefinition
|
||||
{
|
||||
$this->type = $type;
|
||||
if ($size !== null) {
|
||||
$this->size = $size;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function primary(): CreateDefinition
|
||||
{
|
||||
$this->primary = true;
|
||||
return $this;
|
||||
}
|
||||
public function autoIncrement(): CreateDefinition
|
||||
{
|
||||
$this->auto_increment = true;
|
||||
return $this;
|
||||
}
|
||||
public function unsigned(): CreateDefinition
|
||||
{
|
||||
$this->unsigned = true;
|
||||
return $this;
|
||||
}
|
||||
public function default(mixed $value): CreateDefinition
|
||||
{
|
||||
$this->default = $value;
|
||||
return $this;
|
||||
}
|
||||
public function foreign(string $reference_table, string $reference_column = 'id', int $on_delete = CreateDefinition::CASCADE, int $on_update = CreateDefinition::CASCADE): CreateDefinition
|
||||
{
|
||||
$this->foreign_table = $reference_table;
|
||||
$this->foreign_key = $reference_column;
|
||||
$this->foreign_delete = $on_delete;
|
||||
$this->foreign_update = $on_update;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
$type = $this->type ?? 'int';
|
||||
if (isset($this->size)) {
|
||||
$type = "{$type}({$this->size})";
|
||||
} elseif (in_array($type, ['varchar'])) {
|
||||
$type = "{$type}(255)";
|
||||
}
|
||||
$output = [
|
||||
"`{$this->name}`",
|
||||
$type
|
||||
];
|
||||
if (isset($this->unsigned)) {
|
||||
$output []= 'UNSIGNED';
|
||||
}
|
||||
if (isset($this->default)) {
|
||||
$default = $this->default;
|
||||
if (in_array($this->type, ['varchar', 'text', 'char'])) {
|
||||
$default = "'{$default}'";
|
||||
}
|
||||
$output []= "DEFAULT {$default}";
|
||||
}
|
||||
if (isset($this->auto_increment)) {
|
||||
$output []= 'AUTO_INCREMENT';
|
||||
}
|
||||
if (isset($this->primary)) {
|
||||
$output []= 'PRIMARY KEY';
|
||||
}
|
||||
if (isset($this->foreign_table)) {
|
||||
$output []= "REFERENCES `{$this->foreign_table}` (`{$this->foreign_key}`)";
|
||||
$on = [
|
||||
'RESTRICT',
|
||||
'CASCADE',
|
||||
'SET_NULL',
|
||||
'NO_ACTION',
|
||||
'SET_DEFAULT'
|
||||
];
|
||||
$output []= "ON DELETE {$on[$this->foreign_delete]}";
|
||||
$output []= "ON UPDATE {$on[$this->foreign_update]}";
|
||||
}
|
||||
return implode(' ', $output);
|
||||
}
|
||||
}
|
89
app/common/Implement/Database/Query/Delete.php
Normal file
89
app/common/Implement/Database/Query/Delete.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Database\Query;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
class Delete extends Ideal\Query implements Define\Query\Delete
|
||||
{
|
||||
protected string $table;
|
||||
protected array $conditions;
|
||||
protected array $sorts;
|
||||
protected int $limit;
|
||||
|
||||
public function from(string $table): Delete
|
||||
{
|
||||
$this->table = $table;
|
||||
return $this;
|
||||
}
|
||||
public function where(array|string $conditions): Delete
|
||||
{
|
||||
if (is_string($conditions)) {
|
||||
return $this->addCondition($conditions);
|
||||
}
|
||||
foreach ($conditions as $condition) {
|
||||
$this->addCondition($condition);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function order(array|string $sorting): Delete
|
||||
{
|
||||
if (is_string($sorting)) {
|
||||
return $this->addOrder($sorting);
|
||||
}
|
||||
foreach ($sorting as $order) {
|
||||
$this->addOrder($order);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function limit(int $limit): Delete
|
||||
{
|
||||
$this->limit = $limit;
|
||||
return $this;
|
||||
}
|
||||
public function build(): string
|
||||
{
|
||||
$query = [
|
||||
"DELETE FROM {$this->table}",
|
||||
$this->getConditions(),
|
||||
$this->getSorting(),
|
||||
$this->getLimit()
|
||||
];
|
||||
return implode('', $query);
|
||||
}
|
||||
|
||||
protected function addCondition(string $condition): Delete
|
||||
{
|
||||
if (!isset($this->conditions)) {
|
||||
$this->conditions = [];
|
||||
}
|
||||
$this->conditions []= $condition;
|
||||
return $this;
|
||||
}
|
||||
protected function getConditions(): string
|
||||
{
|
||||
return ' WHERE ' . implode(' AND ', $this->conditions);
|
||||
}
|
||||
protected function addOrder(string $order): Delete
|
||||
{
|
||||
if (!isset($this->sorts)) {
|
||||
$this->sorts = [];
|
||||
}
|
||||
$this->sorts []= $order;
|
||||
return $this;
|
||||
}
|
||||
protected function getSorting(): string
|
||||
{
|
||||
if (!isset($this->sorts) or count($this->sorts) === 0) {
|
||||
return '';
|
||||
}
|
||||
return ' ORDER BY ' . implode(', ', $this->sorts);
|
||||
}
|
||||
protected function getLimit(): string
|
||||
{
|
||||
if (!isset($this->limit) or $this->limit <= 0) {
|
||||
return '';
|
||||
}
|
||||
return " LIMIT {$this->limit}";
|
||||
}
|
||||
}
|
87
app/common/Implement/Database/Query/Insert.php
Normal file
87
app/common/Implement/Database/Query/Insert.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Database\Query;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
class Insert extends Ideal\Query implements Define\Query\Insert
|
||||
{
|
||||
protected string $table;
|
||||
protected array $columns;
|
||||
protected array $values;
|
||||
protected Define\Query\Select $select;
|
||||
|
||||
public function into(string $table, ?array $columns = null): Insert
|
||||
{
|
||||
$this->table = $table;
|
||||
if ($columns !== null) {
|
||||
return $this->columns($columns);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function columns(array $columns): Insert
|
||||
{
|
||||
foreach ($columns as $column) {
|
||||
$this->addColumn($column);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function values(array $values): Insert
|
||||
{
|
||||
foreach ($values as $value) {
|
||||
$this->addValue($value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function select(Define\Query\Select $select): Insert
|
||||
{
|
||||
$this->select = $select;
|
||||
return $this;
|
||||
}
|
||||
public function build(): string
|
||||
{
|
||||
$query = [
|
||||
"INSERT INTO {$this->table}"
|
||||
];
|
||||
if (isset($this->select)) {
|
||||
$query []= " {$this->select}";
|
||||
return implode('', $query);
|
||||
}
|
||||
$query []= $this->getColumns();
|
||||
$query []= $this->getValues();
|
||||
return implode('', $query);
|
||||
}
|
||||
|
||||
protected function addColumn(string $column): Insert
|
||||
{
|
||||
if (!isset($this->columns)) {
|
||||
$this->columns = [];
|
||||
}
|
||||
$this->columns []= $column;
|
||||
return $this;
|
||||
}
|
||||
protected function addValue(mixed $value): Insert
|
||||
{
|
||||
if (!isset($this->values)) {
|
||||
$this->values = [];
|
||||
}
|
||||
$this->values []= $value;
|
||||
return $this;
|
||||
}
|
||||
protected function getColumns(): string
|
||||
{
|
||||
return ' (' . implode(', ', array_map(function(string $column) {return "`{$column}`";}, $this->columns)) . ')';
|
||||
}
|
||||
protected function getValues(): string
|
||||
{
|
||||
return ' VALUES (' . implode(', ', array_map(function($value) {
|
||||
if ($value === '?') {
|
||||
return $value;
|
||||
}
|
||||
if ($value === (int) $value) {
|
||||
return $value;
|
||||
}
|
||||
return "'{$value}'";
|
||||
}, $this->values)) . ')';
|
||||
}
|
||||
}
|
215
app/common/Implement/Database/Query/Select.php
Normal file
215
app/common/Implement/Database/Query/Select.php
Normal file
@ -0,0 +1,215 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Database\Query;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
class Select extends Ideal\Query implements Define\Query\Select
|
||||
{
|
||||
protected array $columns;
|
||||
protected string $table;
|
||||
protected array $joins;
|
||||
protected array $conditions;
|
||||
protected array $groups;
|
||||
protected array $haves;
|
||||
protected array $orders;
|
||||
protected int $limit;
|
||||
protected int $offset;
|
||||
|
||||
public function columns(array|string $expressions): Select
|
||||
{
|
||||
if (is_string($expressions)) {
|
||||
return $this->addColumn($expressions);
|
||||
}
|
||||
foreach ($expressions as $expression) {
|
||||
$this->addColumn($expression);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function from(string $table): Select
|
||||
{
|
||||
$this->table = $table;
|
||||
return $this;
|
||||
}
|
||||
public function joined(array|string $joins): Select
|
||||
{
|
||||
if (is_string($joins)) {
|
||||
return $this->addJoin($joins);
|
||||
}
|
||||
foreach ($joins as $join) {
|
||||
$this->addJoin($join);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function where(array|string $conditions): Select
|
||||
{
|
||||
if (is_string($conditions)) {
|
||||
return $this->addCondition($conditions);
|
||||
}
|
||||
foreach ($conditions as $condition) {
|
||||
$this->addCondition($condition);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function group(array|string $grouping): Select
|
||||
{
|
||||
if (is_string($grouping)) {
|
||||
return $this->addGroup($grouping);
|
||||
}
|
||||
foreach ($grouping as $group) {
|
||||
$this->addGroup($group);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function having(array|string $conditions): Select
|
||||
{
|
||||
if (is_string($conditions)) {
|
||||
return $this->addCondition($conditions);
|
||||
}
|
||||
foreach ($conditions as $condition) {
|
||||
$this->addCondition($condition);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function order(array|string $sorting): Select
|
||||
{
|
||||
if (is_string($sorting)) {
|
||||
return $this->addOrder($sorting);
|
||||
}
|
||||
foreach ($sorting as $order) {
|
||||
$this->addOrder($order);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function limit(int $limit, ?int $offset = null): Select
|
||||
{
|
||||
$this->limit = $limit;
|
||||
if ($offset !== null) {
|
||||
return $this->offset($offset);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function offset(int $offset): Select
|
||||
{
|
||||
$this->offset = $offset;
|
||||
return $this;
|
||||
}
|
||||
public function build(): string
|
||||
{
|
||||
$query = [
|
||||
"SELECT {$this->getColumns()} FROM {$this->table}",
|
||||
$this->getJoins(),
|
||||
$this->getConditions(),
|
||||
$this->getGroups(),
|
||||
$this->getHaving(),
|
||||
$this->getOrder(),
|
||||
$this->getLimit()
|
||||
];
|
||||
return implode('', $query);
|
||||
}
|
||||
|
||||
protected function addColumn(string $expression): Select
|
||||
{
|
||||
if (!isset($this->columns)) {
|
||||
$this->columns = [];
|
||||
}
|
||||
$this->columns []= $expression;
|
||||
return $this;
|
||||
}
|
||||
protected function addJoin(string $join): Select
|
||||
{
|
||||
if (!isset($this->joins)) {
|
||||
$this->joins = [];
|
||||
}
|
||||
$this->joins []= $join;
|
||||
return $this;
|
||||
}
|
||||
protected function addCondition(string $condition): Select
|
||||
{
|
||||
if (!isset($this->coditions)) {
|
||||
$this->conditions = [];
|
||||
}
|
||||
$this->conditions []= $condition;
|
||||
return $this;
|
||||
}
|
||||
protected function addGroup(string $group): Select
|
||||
{
|
||||
if (!isset($this->groups)) {
|
||||
$this->groups = [];
|
||||
}
|
||||
$this->groups []= $group;
|
||||
return $this;
|
||||
}
|
||||
protected function addHaving(string $having): Select
|
||||
{
|
||||
if (!isset($this->haves)) {
|
||||
$this->haves = [];
|
||||
}
|
||||
$this->haves []= $having;
|
||||
return $this;
|
||||
}
|
||||
protected function addOrder(string $order): Select
|
||||
{
|
||||
if (!isset($this->orders)) {
|
||||
$this->orders = [];
|
||||
}
|
||||
$this->orders []= $order;
|
||||
return $this;
|
||||
}
|
||||
protected function getColumns(): string
|
||||
{
|
||||
if (!isset($this->columns) or count($this->columns) === 0) {
|
||||
return '*';
|
||||
}
|
||||
return implode(', ', $this->columns);
|
||||
}
|
||||
protected function getJoins(): string
|
||||
{
|
||||
if (!isset($this->joins) or count($this->joins) === 0) {
|
||||
return '';
|
||||
}
|
||||
return ' ' . implode(' ', $this->joins);
|
||||
}
|
||||
protected function getConditions(): string
|
||||
{
|
||||
if (!isset($this->conditions) or count($this->conditions) === 0) {
|
||||
return '';
|
||||
}
|
||||
return ' WHERE ' . implode(' AND ', $this->conditions);
|
||||
}
|
||||
protected function getGroups(): string
|
||||
{
|
||||
if (!isset($this->groups) or count($this->groups) === 0) {
|
||||
return '';
|
||||
}
|
||||
return ' GROUP BY ' . implode(', ', $this->groups);
|
||||
}
|
||||
protected function getHaving(): string
|
||||
{
|
||||
if (!isset($this->haves) or count($this->haves) === 0) {
|
||||
return '';
|
||||
}
|
||||
return ' HAVING ' . implode(' AND ', $this->haves);
|
||||
}
|
||||
protected function getOrder(): string
|
||||
{
|
||||
if (!isset($this->orders) or count($this->orders) === 0) {
|
||||
return '';
|
||||
}
|
||||
return ' ORDER BY ' . implode(', ', $this->orders);
|
||||
}
|
||||
protected function getLimit(): string
|
||||
{
|
||||
if (!isset($this->limit) or $this->limit <= 0) {
|
||||
return '';
|
||||
}
|
||||
return " LIMIT {$this->limit}{$this->getOffset()}";
|
||||
}
|
||||
protected function getOffset(): string
|
||||
{
|
||||
if (!isset($this->offset) or $this->offset <= 0) {
|
||||
return '';
|
||||
}
|
||||
return " OFFSET {$this->offset}";
|
||||
}
|
||||
}
|
113
app/common/Implement/Database/Query/Update.php
Normal file
113
app/common/Implement/Database/Query/Update.php
Normal file
@ -0,0 +1,113 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Database\Query;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
class Update extends Ideal\Query implements Define\Query\Update
|
||||
{
|
||||
protected string $table;
|
||||
protected array $setPairs;
|
||||
protected array $conditions;
|
||||
protected array $orders;
|
||||
protected int $limit;
|
||||
|
||||
public function table(string $table): Define\Query\Update
|
||||
{
|
||||
$this->table = $table;
|
||||
return $this;
|
||||
}
|
||||
public function set(array|string $column_pairs): Define\Query\Update
|
||||
{
|
||||
if (is_string($column_pairs)) {
|
||||
return $this->addSet($column_pairs);
|
||||
}
|
||||
foreach ($column_pairs as $pair) {
|
||||
$this->addSet($pair);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function where(array|string $conditions): Define\Query\Update
|
||||
{
|
||||
if (is_string($conditions)) {
|
||||
return $this->addCondition($conditions);
|
||||
}
|
||||
foreach ($conditions as $condition) {
|
||||
$this->addCondition($condition);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function order(array|string $ordering): Define\Query\Update
|
||||
{
|
||||
if (is_string($ordering)) {
|
||||
return $this->addOrder($ordering);
|
||||
}
|
||||
foreach ($ordering as $order) {
|
||||
$this->addOrder($order);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function limit(int $limit): Define\Query\Update
|
||||
{
|
||||
$this->limit = $limit;
|
||||
return $this;
|
||||
}
|
||||
public function build(): string
|
||||
{
|
||||
$query = [
|
||||
"UPDATE {$this->table}",
|
||||
$this->getSet(),
|
||||
$this->getConditions(),
|
||||
$this->getOrder(),
|
||||
$this->getLimit()
|
||||
];
|
||||
return implode('', $query);
|
||||
}
|
||||
|
||||
protected function addSet(string $pair): Update
|
||||
{
|
||||
if (!isset($this->setPairs)) {
|
||||
$this->setPairs = [];
|
||||
}
|
||||
$this->setPairs []= $pair;
|
||||
return $this;
|
||||
}
|
||||
protected function addCondition(string $condition): Update
|
||||
{
|
||||
if (!isset($this->conditions)) {
|
||||
$this->conditions = [];
|
||||
}
|
||||
$this->conditions []= $condition;
|
||||
return $this;
|
||||
}
|
||||
protected function addOrder(string $order): Update
|
||||
{
|
||||
if (!isset($this->orders)) {
|
||||
$this->orders = [];
|
||||
}
|
||||
$this->orders []= $order;
|
||||
return $this;
|
||||
}
|
||||
protected function getSet(): string
|
||||
{
|
||||
return ' SET ' . implode(', ', $this->setPairs);
|
||||
}
|
||||
protected function getConditions(): string
|
||||
{
|
||||
return ' WHERE ' . implode(' AND ', $this->conditions);
|
||||
}
|
||||
protected function getOrder(): string
|
||||
{
|
||||
if (!isset($this->orders) or count($this->orders) === 0) {
|
||||
return '';
|
||||
}
|
||||
return ' ORDER BY ' . implode(', ', $this->orders);
|
||||
}
|
||||
protected function getLimit(): string
|
||||
{
|
||||
if (!isset($this->limit) or $this->limit <= 0) {
|
||||
return '';
|
||||
}
|
||||
return " LIMIT {$this->limit}";
|
||||
}
|
||||
}
|
@ -55,14 +55,18 @@ class Mapper implements Define\Repository\Mapper
|
||||
if ($this->hasProperty()) {
|
||||
$property = $this->property;
|
||||
}
|
||||
if (isset($data[$column])) {
|
||||
if (in_array($column, array_keys($data))) {
|
||||
if ($this->hasFactory()) {
|
||||
$model->addFactory($property, $this->factory);
|
||||
return true;
|
||||
}
|
||||
$value = $data[$column];
|
||||
if ($this->hasFunction()) {
|
||||
$value = ($this->function)($data);
|
||||
if ($value !== null) {
|
||||
$value = ($this->function)($data);
|
||||
} elseif ($this->hasDefault()) {
|
||||
$value = $this->default;
|
||||
}
|
||||
}
|
||||
$model->{$property} = $value;
|
||||
return true;
|
||||
|
@ -9,7 +9,7 @@ class DateTime extends Mapper
|
||||
public function __construct(string $column, ?string $property = null)
|
||||
{
|
||||
$this->setFunction(function($data) use ($column) {
|
||||
return new DateTimeImmutable($data[$column]);
|
||||
return new DateTimeImmutable($data[$column] ?? '');
|
||||
});
|
||||
if ($property !== null) {
|
||||
$this->setProperty($property);
|
||||
|
@ -9,10 +9,12 @@
|
||||
"nyholm/psr7-server": "^1.0",
|
||||
"php-di/php-di": "^7.0",
|
||||
"php-di/slim-bridge": "^3.4",
|
||||
"phpoffice/phpspreadsheet": "^1.29",
|
||||
"predis/predis": "^2.2",
|
||||
"slim/slim": "^4.11"
|
||||
},
|
||||
"require-dev": {
|
||||
"kint-php/kint": "^5.1",
|
||||
"phpunit/phpunit": "^10.2"
|
||||
},
|
||||
"authors": [
|
||||
|
0
app/public/informes/.gitkeep
Normal file
0
app/public/informes/.gitkeep
Normal file
@ -10,4 +10,4 @@ $app->group('/api', function($app) {
|
||||
include_once $file->getRealPath();
|
||||
}
|
||||
}
|
||||
});
|
||||
})->add($app->getContainer()->get(Incoviba\Middleware\API::class));
|
||||
|
@ -3,4 +3,4 @@ use Incoviba\Controller\Inmobiliarias;
|
||||
|
||||
$app->group('/inmobiliarias', function($app) {
|
||||
$app->get('[/]', Inmobiliarias::class);
|
||||
});
|
||||
})->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class));
|
||||
|
@ -4,7 +4,7 @@ use Incoviba\Controller\Proyectos;
|
||||
$app->group('/proyectos', function($app) {
|
||||
$app->get('/unidades[/]', [Proyectos::class, 'unidades']);
|
||||
$app->get('[/]', Proyectos::class);
|
||||
});
|
||||
})->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class));
|
||||
$app->group('/proyecto/{proyecto_id}', function($app) {
|
||||
$app->get('[/]', [Proyectos::class, 'show']);
|
||||
});
|
||||
})->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class));
|
||||
|
@ -11,10 +11,10 @@ $app->group('/ventas', function($app) {
|
||||
}
|
||||
$app->get('/add[/]', [Ventas::class, 'add']);
|
||||
$app->get('[/]', Ventas::class);
|
||||
});
|
||||
})->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class));
|
||||
$app->group('/venta/{proyecto_nombre:[A-za-zÑñ\+\ %0-9]+}/{unidad_descripcion:[0-9]+}', function($app) {
|
||||
$app->get('[/]', [Ventas::class, 'showUnidad']);
|
||||
});
|
||||
})->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class));
|
||||
$app->group('/venta/{venta_id:[0-9]+}', function($app) {
|
||||
$app->group('/propietario', function($app) {
|
||||
$app->get('[/]', [Ventas::class, 'propietario']);
|
||||
@ -26,7 +26,17 @@ $app->group('/venta/{venta_id:[0-9]+}', function($app) {
|
||||
$app->group('/cuotas', function($app) {
|
||||
$app->get('[/]', [Ventas::class, 'cuotas']);
|
||||
});
|
||||
$app->get('[/]', [Ventas::class, 'pie']);
|
||||
});
|
||||
$app->group('/escritura', function($app) {
|
||||
$app->get('/add[/]', [Ventas\Escrituras::class, 'add']);
|
||||
});
|
||||
$app->group('/credito', function($app) {
|
||||
$app->get('[/]', [Ventas\Creditos::class, 'show']);
|
||||
});
|
||||
$app->get('/escriturar[/]', [Ventas::class, 'escriturar']);
|
||||
$app->get('/desistir[/]', [Ventas::class, 'desistir']);
|
||||
$app->get('/desistida[/]', [Ventas::class, 'desistida']);
|
||||
$app->get('/edit[/]', [Ventas::class, 'edit']);
|
||||
$app->get('[/]', [Ventas::class, 'show']);
|
||||
});
|
||||
})->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class));
|
||||
|
10
app/resources/routes/05_contabilidad.php
Normal file
10
app/resources/routes/05_contabilidad.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
$app->group('/contabilidad', function($app) {
|
||||
$files = new FilesystemIterator(implode(DIRECTORY_SEPARATOR, [__DIR__, 'contabilidad']));
|
||||
foreach ($files as $file) {
|
||||
if ($file->isDir()) {
|
||||
continue;
|
||||
}
|
||||
include_once $file->getRealPath();
|
||||
}
|
||||
});
|
@ -4,4 +4,4 @@ use Incoviba\Controller\Search;
|
||||
$app->group('/search', function($app) {
|
||||
$app->get('[/{query}[/{tipo}[/]]]', Search::class);
|
||||
$app->post('[/]', Search::class);
|
||||
});
|
||||
})->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class));
|
||||
|
@ -4,5 +4,5 @@ use Incoviba\Controller\Login;
|
||||
$app->group('/login', function($app) {
|
||||
$app->post('[/]', [Login::class, 'login']);
|
||||
$app->get('[/]', [Login::class, 'form']);
|
||||
});
|
||||
$app->get('/logout', [Login::class, 'logout']);
|
||||
})->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class));
|
||||
$app->get('/logout', [Login::class, 'logout'])->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class));
|
||||
|
@ -2,4 +2,4 @@
|
||||
use Incoviba\Controller\Base;
|
||||
|
||||
$app->get('/construccion', [Base::class, 'construccion'])->setName('construccion');
|
||||
$app->get('[/]', Base::class);
|
||||
$app->get('[/]', Base::class)->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class));
|
||||
|
10
app/resources/routes/api/contabilidad.php
Normal file
10
app/resources/routes/api/contabilidad.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
$app->group('/contabilidad', function($app) {
|
||||
$files = new FilesystemIterator(implode(DIRECTORY_SEPARATOR, [__DIR__, 'contabilidad']));
|
||||
foreach ($files as $file) {
|
||||
if ($file->isDir()) {
|
||||
continue;
|
||||
}
|
||||
include_once $file->getRealPath();
|
||||
}
|
||||
});
|
13
app/resources/routes/api/contabilidad/cartolas.php
Normal file
13
app/resources/routes/api/contabilidad/cartolas.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Contabilidad\Cartolas;
|
||||
|
||||
$app->group('/cartolas', function($app) {
|
||||
$app->post('/procesar[/]', [Cartolas::class, 'procesar']);
|
||||
});
|
||||
$app->group('/cartola', function($app) {
|
||||
$app->group('/diaria', function($app) {
|
||||
$app->post('/ayer[/]', [Cartolas::class, 'ayer']);
|
||||
$app->post('/procesar[/]', [Cartolas::class, 'diaria']);
|
||||
});
|
||||
$app->post('/exportar[/]', [Cartolas::class, 'exportar']);
|
||||
});
|
10
app/resources/routes/api/contabilidad/centros_costos.php
Normal file
10
app/resources/routes/api/contabilidad/centros_costos.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\CentrosCostos;
|
||||
|
||||
$app->group('/centros_costos', function($app) {
|
||||
$app->post('/add[/]', [CentrosCostos::class, 'add']);
|
||||
});
|
||||
$app->group('/centro_costo/{centro_costo_id}', function($app) {
|
||||
$app->post('/edit[/]', [CentrosCostos::class, 'edit']);
|
||||
$app->delete('[/]', [CentrosCostos::class, 'remove']);
|
||||
});
|
7
app/resources/routes/api/contabilidad/daps.php
Normal file
7
app/resources/routes/api/contabilidad/daps.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Contabilidad\Depositos;
|
||||
|
||||
$app->group('/depositos', function($app) {
|
||||
$app->post('/add[/]', [Depositos::class, 'add']);
|
||||
$app->get('/inmobiliaria/{inmobiliaria_rut}[/]', [Depositos::class, 'inmobiliaria']);
|
||||
});
|
6
app/resources/routes/api/contabilidad/movimientos.php
Normal file
6
app/resources/routes/api/contabilidad/movimientos.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Contabilidad\Movimientos;
|
||||
|
||||
$app->group('/movimiento/{movimiento_id}', function($app) {
|
||||
$app->post('/detalles', [Movimientos::class, 'detalles']);
|
||||
});
|
11
app/resources/routes/api/contabilidad/nubox.php
Normal file
11
app/resources/routes/api/contabilidad/nubox.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Nubox;
|
||||
|
||||
$app->group('/nubox/{inmobiliaria_rut}', function($app) {
|
||||
$app->get('/token[/]', [Nubox::class, 'token']);
|
||||
$app->get('/sistemas[/]', [Nubox::class, 'sistemas']);
|
||||
$app->group('/libro', function($app) {
|
||||
$app->post('/mayor[/]', [Nubox::class, 'libroMayor']);
|
||||
$app->post('/diario[/]', [Nubox::class, 'libroDiario']);
|
||||
});
|
||||
});
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Direcciones;
|
||||
use Incoviba\Controller\API\Direcciones;
|
||||
|
||||
$app->group('/direcciones', function($app) {
|
||||
$app->group('/region/{region_id:[0-9]+}', function($app) {
|
||||
|
10
app/resources/routes/api/inmobiliarias.php
Normal file
10
app/resources/routes/api/inmobiliarias.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Inmobiliarias;
|
||||
|
||||
$app->group('/inmobiliarias', function($app) {
|
||||
$app->get('[/]', Inmobiliarias::class);
|
||||
});
|
||||
$app->group('/inmobiliaria/{inmobiliaria_rut}', function($app) {
|
||||
$app->get('/cuentas[/]', [Inmobiliarias::class, 'cuentas']);
|
||||
$app->get('/proyectos[/]', [Inmobiliarias::class, 'proyectos']);
|
||||
});
|
8
app/resources/routes/api/money.php
Normal file
8
app/resources/routes/api/money.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Money;
|
||||
|
||||
$app->group('/money', function($app) {
|
||||
$app->post('/ipc[/]', [Money::class, 'ipc']);
|
||||
$app->post('/uf[/]', [Money::class, 'uf']);
|
||||
$app->post('[/]', [Money::class, 'get']);
|
||||
});
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Provincias;
|
||||
use Incoviba\Controller\API\Provincias;
|
||||
|
||||
$app->group('/provincia/{provincia_id}', function($app) {
|
||||
$app->get('/comunas', [Provincias::class, 'comunas']);
|
||||
|
@ -17,4 +17,7 @@ $app->group('/proyecto/{proyecto_id}', function($app) {
|
||||
$app->get('/disponibles[/]', [Proyectos::class, 'disponibles']);
|
||||
$app->get('[/]', [Proyectos::class, 'unidades']);
|
||||
});
|
||||
$app->group('/terreno', function($app) {
|
||||
$app->post('/edit[/]', [Proyectos::class, 'terreno']);
|
||||
});
|
||||
});
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Regiones;
|
||||
|
||||
use Incoviba\Controller\API\Regiones;
|
||||
|
||||
//$app->group('/regiones', function($app) {});
|
||||
$app->group('/region/{region_id}', function($app) {
|
||||
|
@ -1,4 +1,12 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Search;
|
||||
use Incoviba\Controller\API\Search;
|
||||
|
||||
$app->post('/search', [Search::class, 'query']);
|
||||
$app->group('/search', function($app) {
|
||||
$app->group('/ventas', function($app) {
|
||||
$app->post('/unidades', [Search::class, 'unidades']);
|
||||
$app->get('/unidad/{unidad_id}', [Search::class, 'unidad']);
|
||||
$app->post('[/]', [Search::class, 'ventas']);
|
||||
});
|
||||
$app->get('/venta/{venta_id}', [Search::class, 'venta']);
|
||||
$app->post('[/]', [Search::class, 'query']);
|
||||
});
|
||||
|
@ -19,9 +19,26 @@ $app->group('/ventas', function($app) {
|
||||
$app->group('/escrituras', function($app) {
|
||||
$app->post('/estados[/]', [Ventas::class, 'escrituras']);
|
||||
});
|
||||
$app->group('/by', function($app) {
|
||||
$app->get('/unidad/{unidad_id}', [Ventas::class, 'unidad']);
|
||||
});
|
||||
$app->post('/get[/]', [Ventas::class, 'getMany']);
|
||||
$app->post('[/]', [Ventas::class, 'proyecto']);
|
||||
});
|
||||
$app->group('/venta/{venta_id}', function($app) {
|
||||
$app->get('/comentarios', [Ventas::class, 'comentarios']);
|
||||
$app->get('/unidades[/]', [Ventas::class, 'unidades']);
|
||||
$app->get('/comentarios[/]', [Ventas::class, 'comentarios']);
|
||||
$app->group('/escritura', function($app) {
|
||||
$app->post('/add[/]', [Ventas\Escrituras::class, 'add']);
|
||||
});
|
||||
$app->group('/credito', function($app) {
|
||||
$app->post('[/]', [Ventas\Creditos::class, 'edit']);
|
||||
});
|
||||
$app->post('/escriturar[/]', [Ventas::class, 'escriturar']);
|
||||
$app->group('/desistir', function($app) {
|
||||
$app->get('/eliminar[/]', [Ventas::class, 'insistir']);
|
||||
$app->post('[/]', [Ventas::class, 'desistir']);
|
||||
});
|
||||
$app->post('[/]', [Ventas::class, 'edit']);
|
||||
$app->get('[/]', [Ventas::class, 'get']);
|
||||
});
|
||||
|
6
app/resources/routes/api/ventas/escrituras.php
Normal file
6
app/resources/routes/api/ventas/escrituras.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Ventas\Escrituras;
|
||||
|
||||
$app->group('/escritura/{venta_id}', function($app) {
|
||||
$app->post('/edit[/]', [Escrituras::class, 'edit']);
|
||||
});
|
6
app/resources/routes/api/ventas/facturacion.php
Normal file
6
app/resources/routes/api/ventas/facturacion.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Ventas\Facturacion;
|
||||
|
||||
$app->group('/facturacion', function($app) {
|
||||
$app->get('/proyecto/{proyecto_id}[/]', [Facturacion::class, 'proyecto']);
|
||||
});
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Ventas\Pagos;
|
||||
use Incoviba\Controller\API\Ventas\Pagos;
|
||||
|
||||
$app->group('/pagos', function($app) {
|
||||
$app->get('/pendientes', [Pagos::class, 'para_pendientes']);
|
||||
@ -7,6 +7,9 @@ $app->group('/pagos', function($app) {
|
||||
$app->get('/rebotes', [Pagos::class, 'rebotes']);
|
||||
});
|
||||
$app->group('/pago/{pago_id:[0-9]+}', function($app) {
|
||||
$app->put('/depositar[/]', [Pagos::class, 'depositar']);
|
||||
$app->put('/abonar[/]', [Pagos::class, 'abonar']);
|
||||
$app->post('/depositar[/]', [Pagos::class, 'depositar']);
|
||||
$app->post('/abonar[/]', [Pagos::class, 'abonar']);
|
||||
$app->post('/devolver[/]', [Pagos::class, 'devolver']);
|
||||
$app->get('/anular[/]', [Pagos::class, 'anular']);
|
||||
$app->post('[/]', [Pagos::class, 'edit']);
|
||||
});
|
||||
|
6
app/resources/routes/api/ventas/pies.php
Normal file
6
app/resources/routes/api/ventas/pies.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Ventas\Pies;
|
||||
|
||||
$app->group('/pie/{pie_id}', function($app) {
|
||||
$app->post('/edit[/]', [Pies::class, 'edit']);
|
||||
});
|
10
app/resources/routes/api/ventas/propiedades.php
Normal file
10
app/resources/routes/api/ventas/propiedades.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
$app->group('/propiedades', function($app) {
|
||||
$files = new FilesystemIterator(implode(DIRECTORY_SEPARATOR, [__DIR__, 'propiedades']));
|
||||
foreach ($files as $file) {
|
||||
if ($file->isDir()) {
|
||||
continue;
|
||||
}
|
||||
include_once $file->getRealPath();
|
||||
}
|
||||
});
|
10
app/resources/routes/api/ventas/propiedades/unidades.php
Normal file
10
app/resources/routes/api/ventas/propiedades/unidades.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Ventas\PropiedadesUnidades;
|
||||
|
||||
$app->group('/unidades', function($app) {
|
||||
$app->post('/add[/]', [PropiedadesUnidades::class, 'add']);
|
||||
});
|
||||
$app->group('/unidad/{pu_id}', function($app) {
|
||||
$app->post('/edit[/]', [PropiedadesUnidades::class, 'edit']);
|
||||
$app->delete('[/]', [PropiedadesUnidades::class, 'remove']);
|
||||
});
|
@ -4,3 +4,9 @@ use Incoviba\Controller\API\Ventas\Unidades;
|
||||
$app->group('/unidades', function($app) {
|
||||
$app->post('/disponibles', [Unidades::class, 'disponibles']);
|
||||
});
|
||||
$app->group('/unidad/{unidad_id}', function($app) {
|
||||
$app->group('/prorrateo', function($app) {
|
||||
$app->post('[/]', [Unidades::class, 'prorrateo']);
|
||||
});
|
||||
$app->get('[/]', [Unidades::class, 'get']);
|
||||
});
|
||||
|
6
app/resources/routes/contabilidad/cartolas.php
Normal file
6
app/resources/routes/contabilidad/cartolas.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Contabilidad;
|
||||
|
||||
$app->group('/cartolas', function($app) {
|
||||
$app->get('/diaria[/]', [Contabilidad::class, 'diaria']);
|
||||
});
|
7
app/resources/routes/contabilidad/centros_costos.php
Normal file
7
app/resources/routes/contabilidad/centros_costos.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
use Incoviba\Controller\CentrosCostos;
|
||||
|
||||
$app->group('/centros_costos', function($app) {
|
||||
$app->get('/asignar[/]', [CentrosCostos::class, 'asignar']);
|
||||
$app->get('[/]', CentrosCostos::class);
|
||||
});
|
6
app/resources/routes/contabilidad/daps.php
Normal file
6
app/resources/routes/contabilidad/daps.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Contabilidad;
|
||||
|
||||
$app->group('/depositos', function($app) {
|
||||
$app->get('[/]', [Contabilidad::class, 'depositos']);
|
||||
});
|
10
app/resources/routes/contabilidad/informes.php
Normal file
10
app/resources/routes/contabilidad/informes.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
$app->group('/informes', function($app) {
|
||||
$files = new FilesystemIterator(implode(DIRECTORY_SEPARATOR, [__DIR__, 'informes']));
|
||||
foreach ($files as $file) {
|
||||
if ($file->isDir()) {
|
||||
continue;
|
||||
}
|
||||
include_once $file->getRealPath();
|
||||
}
|
||||
});
|
6
app/resources/routes/contabilidad/informes/tesoreria.php
Normal file
6
app/resources/routes/contabilidad/informes/tesoreria.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Contabilidad;
|
||||
|
||||
$app->group('/tesoreria', function($app) {
|
||||
$app->get('[/[{fecha}[/]]]', [Contabilidad::class, 'tesoreria']);
|
||||
});
|
6
app/resources/routes/contabilidad/informes/xlsx.php
Normal file
6
app/resources/routes/contabilidad/informes/xlsx.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Contabilidad\Informes;
|
||||
|
||||
$app->group('/xlsx', function($app) {
|
||||
$app->get('/tesoreria/{fecha}[/]', [Informes::class, 'tesoreria']);
|
||||
});
|
7
app/resources/routes/ventas/escrituras.php
Normal file
7
app/resources/routes/ventas/escrituras.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Ventas\Escrituras;
|
||||
|
||||
$app->group('/escritura/{venta_id}', function($app) {
|
||||
$app->get('/informe[/]', [Escrituras::class, 'informe']);
|
||||
$app->get('[/]', [Escrituras::class, 'show']);
|
||||
});
|
9
app/resources/routes/ventas/facturacion.php
Normal file
9
app/resources/routes/ventas/facturacion.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Ventas\Facturacion;
|
||||
|
||||
$app->group('/facturacion', function($app) {
|
||||
$app->get('[/]', Facturacion::class);
|
||||
});
|
||||
$app->group('/factura/{venta_id}', function($app) {
|
||||
$app->get('[/]', [Facturacion::class, 'show']);
|
||||
});
|
823
app/resources/views/contabilidad/cartolas/diaria.blade.php
Normal file
823
app/resources/views/contabilidad/cartolas/diaria.blade.php
Normal file
@ -0,0 +1,823 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h1 class="ui header">
|
||||
Cartola Diaria
|
||||
</h1>
|
||||
<div class="ui grid">
|
||||
<div class="right aligned sixteen wide column">
|
||||
<button class="ui green icon button" id="add_button">
|
||||
Agregar
|
||||
<i class="plus icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<form class="ui form" id="cartola_form">
|
||||
<input type="hidden" id="fields" name="fields" value="0" />
|
||||
</form>
|
||||
<div class="ui two columns grid">
|
||||
<div class="column">
|
||||
<button class="ui icon button" id="process_button">
|
||||
<i class="file excel icon"></i>
|
||||
Procesar
|
||||
</button>
|
||||
</div>
|
||||
<div class="right aligned column">
|
||||
<div class="ui inline active loader" id="loader"></div>
|
||||
</div>
|
||||
</div>
|
||||
<table class="ui table" id="diferencia">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Sociedad</th>
|
||||
<th>Banco - Cuenta</th>
|
||||
<th>Hoy</th>
|
||||
<th>Último Saldo</th>
|
||||
<th>Saldo Actual</th>
|
||||
<th>Diferencia</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="ui fluid container">
|
||||
<table class="ui table" id="tabla_movimientos">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Sociedad</th>
|
||||
<th>Banco - Cuenta</th>
|
||||
<th>Fecha</th>
|
||||
<th>Glosa</th>
|
||||
<th class="right aligned">Cargo</th>
|
||||
<th class="right aligned">Abono</th>
|
||||
<th class="right aligned">Saldo</th>
|
||||
<th>Centro de Costo</th>
|
||||
<th>Detalle</th>
|
||||
<th>Orden</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="movimientos"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="ui modal" id="manual_modal">
|
||||
<div class="content">
|
||||
<div class="header">
|
||||
Movimientos |
|
||||
<span id="modal_inmobiliaria"></span> |
|
||||
<span id="modal_cuenta"></span> |
|
||||
<span id="modal_fecha"></span>
|
||||
</div>
|
||||
<div class="ui one column grid">
|
||||
<div class="right aligned column">
|
||||
<button class="ui green icon button" id="add_manual">
|
||||
<i class="plus icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<form class="ui form" id="modal_form">
|
||||
<input type="hidden" name="movimientos" value="[1]" />
|
||||
<div id="modal_movimientos">
|
||||
<div class="fields" data-movimiento="1">
|
||||
<div class="field">
|
||||
<label>Glosa</label>
|
||||
<input type="text" name="glosa1" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Cargo</label>
|
||||
<div class="ui left labeled input">
|
||||
<div class="ui basic label">$</div>
|
||||
<input type="text" name="cargo1" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Abono</label>
|
||||
<div class="ui left labeled input">
|
||||
<div class="ui basic label">$</div>
|
||||
<input type="text" name="abono1" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Saldo</label>
|
||||
<div class="ui left labeled input">
|
||||
<div class="ui basic label">$</div>
|
||||
<input type="text" name="saldo1" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field"></div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="actions">
|
||||
<button class="ui approve button">
|
||||
Procesar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('layout.head.styles.datatables')
|
||||
@include('layout.body.scripts.datatables')
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
class Cartola {
|
||||
idx
|
||||
inmobiliaria = {
|
||||
rut: 0,
|
||||
razon: ''
|
||||
}
|
||||
cuenta = {
|
||||
id: 0,
|
||||
descripcion: ''
|
||||
}
|
||||
fecha = ''
|
||||
bancos = []
|
||||
movimientos = []
|
||||
saldo = 0
|
||||
ayer = 0
|
||||
|
||||
constructor(idx) {
|
||||
this.idx = idx
|
||||
}
|
||||
|
||||
get() {
|
||||
return {
|
||||
bancos: () => {
|
||||
const url = '{{$urls->api}}/inmobiliaria/' + this.inmobiliaria.rut + '/cuentas'
|
||||
diaria.loader().show()
|
||||
return fetchAPI(url).then(response => {
|
||||
diaria.loader().hide()
|
||||
if (!response) {
|
||||
this.bancos = []
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (json.cuentas.length === 0) {
|
||||
this.bancos = []
|
||||
return
|
||||
}
|
||||
this.bancos = json.cuentas.map(cuenta => {
|
||||
return {
|
||||
value: cuenta.id,
|
||||
text: cuenta.banco.nombre + ' - ' + cuenta.cuenta,
|
||||
name: cuenta.banco.nombre + ' - ' + cuenta.cuenta
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
ayer: (fecha) => {
|
||||
const url = '{{$urls->api}}/contabilidad/cartola/diaria/ayer'
|
||||
const body = new FormData()
|
||||
body.set('cuenta_id', this.cuenta.id)
|
||||
body.set('fecha', fecha.toISOString())
|
||||
return fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (json.cartola.length === 0) {
|
||||
return
|
||||
}
|
||||
this.ayer = json.cartola.saldo
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
update() {
|
||||
return {
|
||||
centro: (idx, centro_id) => {
|
||||
const id = this.movimientos[idx].id
|
||||
const url = '{{$urls->api}}/contabilidad/movimiento/' + id + '/detalles'
|
||||
const body = new FormData()
|
||||
body.set('centro_id', centro_id)
|
||||
return fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
response.json().then(json => {
|
||||
if (!json.status) {
|
||||
return
|
||||
}
|
||||
const dropdown = $(".dropdown[data-idx='" + idx + "']")
|
||||
dropdown.dropdown('set selected', json.centro.id, true)
|
||||
})
|
||||
})
|
||||
},
|
||||
detalle: (idx, detalle) => {
|
||||
const id = this.movimientos[idx].id
|
||||
const url = '{{$urls->api}}/contabilidad/movimiento/' + id + '/detalles'
|
||||
const body = new FormData()
|
||||
body.set('detalle', detalle)
|
||||
return fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
response.json().then(json => {
|
||||
if (!json.status) {
|
||||
return
|
||||
}
|
||||
const input = $("input[data-idx='" + idx + "']")
|
||||
input.val(json.detalle)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
draw() {
|
||||
return {
|
||||
form: ($form, inmobiliarias, first = false) => {
|
||||
const $fields = $('<div></div>').addClass('fields cartola').attr('data-cartola', this.idx)
|
||||
const $inmobiliarias_menu = $('<div></div>').addClass('menu')
|
||||
inmobiliarias.forEach(inmobiliaria => {
|
||||
$inmobiliarias_menu.append(
|
||||
$('<div></div>').addClass('item').attr('data-value', inmobiliaria.rut).html(inmobiliaria.razon)
|
||||
)
|
||||
})
|
||||
const $inmobiliarias_dropdown = $('<div></div>').addClass('ui search selection dropdown').attr('id', 'inmobiliaria' + this.idx).append(
|
||||
$('<input />').attr('type', 'hidden')//.attr('name', 'inmobiliaria_rut' + this.idx)
|
||||
).append(
|
||||
$('<i></i>').addClass('dropdown icon')
|
||||
).append(
|
||||
$('<div></div>').addClass('default text').html('Inmobiliaria')
|
||||
).append($inmobiliarias_menu)
|
||||
$fields.append(
|
||||
$('<div></div>').addClass('six wide field').append(
|
||||
$('<label></label>').attr('for', 'inmobiliaria' + this.idx).html('Sociedad')
|
||||
).append($inmobiliarias_dropdown)
|
||||
)
|
||||
const $cuentas_dropdown = $('<div></div>').addClass('ui search selection dropdown').attr('id', 'cuenta' + this.idx).append(
|
||||
$('<input />').attr('type', 'hidden').attr('name', 'cuenta_id' + this.idx)
|
||||
).append(
|
||||
$('<i></i>').addClass('dropdown icon')
|
||||
).append(
|
||||
$('<div></div>').addClass('default text').html('Banco - Cuenta')
|
||||
).append(
|
||||
$('<div></div>').addClass('menu')
|
||||
)
|
||||
$fields.append(
|
||||
$('<div></div>').addClass('four wide field').append(
|
||||
$('<label></label>').html('Banco - Cuenta')
|
||||
).append($cuentas_dropdown)
|
||||
)
|
||||
const $fecha_calendar = $('<div></div>').addClass('ui calendar').attr('id', 'fecha' + this.idx).append(
|
||||
$('<div></div>').addClass('ui left icon input').append(
|
||||
$('<i></i>').addClass('calendar icon')
|
||||
).append(
|
||||
$('<input />').attr('type', 'text')
|
||||
)
|
||||
)
|
||||
$fields.append(
|
||||
$('<div></div>').addClass('three wide field').append(
|
||||
$('<label></label>').attr('for', 'fecha' + this.idx).html('Fecha')
|
||||
).append($fecha_calendar)
|
||||
)
|
||||
$fields.append(
|
||||
$('<div></div>').addClass('field').append(
|
||||
$('<label></label>').html('Cartola')
|
||||
).append(
|
||||
$('<input />').addClass('ui invisible file input').attr('type', 'file').attr('name', 'file' + this.idx).attr('id', 'file' + this.idx)
|
||||
).append(
|
||||
$('<label></label>').addClass('ui icon button').attr('for', 'file' + this.idx).append(
|
||||
$('<i></i>').addClass('file icon')
|
||||
).append('Cargar')
|
||||
)
|
||||
)
|
||||
const $manual_checkbox = $('<div></div>').addClass('ui invisible checkbox').append(
|
||||
$('<input />').attr('type', 'checkbox').attr('name', 'manual' + this.idx).attr('id', 'manual' + this.idx)
|
||||
).append(
|
||||
$('<label></label>').addClass('image').attr('for', 'manual' + this.idx).append(
|
||||
$('<i></i>').addClass('large orange keyboard icon')
|
||||
)
|
||||
)
|
||||
|
||||
$fields.append($('<div></div>').addClass('field').append(
|
||||
$('<label></label>').html('Manual')
|
||||
).append($manual_checkbox))
|
||||
if (!first) {
|
||||
$fields.append(
|
||||
$('<div></div>').addClass('field').append(
|
||||
$('<label></label>').html('Eliminar')
|
||||
).append(
|
||||
$('<button></button>').addClass('ui red icon button').attr('data-cartola', this.idx).append(
|
||||
$('<i></i>').addClass('remove icon')
|
||||
).click(event => {
|
||||
const idx = $(event.currentTarget).data('cartola')
|
||||
diaria.cartolas().remove(idx)
|
||||
})
|
||||
)
|
||||
)
|
||||
}
|
||||
$form.append($fields)
|
||||
|
||||
const cdo = JSON.parse(JSON.stringify(calendar_date_options))
|
||||
cdo['initialDate'] = new Date()
|
||||
cdo['maxDate'] = cdo['initialDate']
|
||||
cdo['onChange'] = (date, text, mode) => {
|
||||
this.fecha = date
|
||||
}
|
||||
this.fecha = cdo['initialDate']
|
||||
|
||||
$inmobiliarias_dropdown.dropdown({
|
||||
fireOnInit: true,
|
||||
onChange: (value, text, $choice) => {
|
||||
this.inmobiliaria.rut = value
|
||||
this.inmobiliaria.razon = text
|
||||
this.get().bancos(value).then(() => {
|
||||
$cuentas_dropdown.dropdown('change values', this.bancos)
|
||||
})
|
||||
},
|
||||
})
|
||||
$cuentas_dropdown.dropdown({
|
||||
fireOnInit: true,
|
||||
onChange: (value, text, $choice) => {
|
||||
this.cuenta.id = value
|
||||
this.cuenta.descripcion = text
|
||||
}
|
||||
})
|
||||
$fecha_calendar.calendar(cdo)
|
||||
$manual_checkbox.change(event => {
|
||||
const $element = $(event.currentTarget)
|
||||
const status = $element.checkbox('is checked')
|
||||
const $field = $element.parent().parent()
|
||||
const $file = $field.find('#file' + this.idx).parent()
|
||||
if (status) {
|
||||
$file.find('input').attr('type', 'hidden')
|
||||
$file.hide()
|
||||
|
||||
manual.data.inmobiliaria = $inmobiliarias_dropdown.dropdown('get text')
|
||||
manual.data.cuenta = $cuentas_dropdown.dropdown('get text')
|
||||
const fecha = $fecha_calendar.calendar('get date')
|
||||
manual.data.fecha = [fecha.getDate(), (fecha.getMonth()+1).toString().padStart(2, '0'), fecha.getFullYear()].join('-')
|
||||
manual.data.field = this.idx
|
||||
manual.$modal.modal('show')
|
||||
return
|
||||
}
|
||||
$file.find('input').attr('type', 'file')
|
||||
$file.show()
|
||||
})
|
||||
},
|
||||
diferencia: ($tbody, dateFormatter, numberFormatter) => {
|
||||
$tbody.append(
|
||||
$('<tr></tr>').append(
|
||||
$('<td></td>').html(this.inmobiliaria.razon)
|
||||
).append(
|
||||
$('<td></td>').html(this.cuenta.descripcion)
|
||||
).append(
|
||||
$('<td></td>').html(dateFormatter.format(this.fecha))
|
||||
).append(
|
||||
$('<td></td>').html(numberFormatter.format(this.ayer))
|
||||
).append(
|
||||
$('<td></td>').html(numberFormatter.format(this.saldo))
|
||||
).append(
|
||||
$('<td></td>').html(numberFormatter.format(this.saldo - this.ayer))
|
||||
)
|
||||
)
|
||||
},
|
||||
cartola: ($tbody, dateFormatter, numberFormatter) => {
|
||||
this.movimientos.forEach((row, idx) => {
|
||||
$tbody.append(
|
||||
$('<tr></tr>').append(
|
||||
'<td>' + this.inmobiliaria.razon + '</td>' + "\n"
|
||||
+ '<td>' + this.cuenta.descripcion + '</td>' + "\n"
|
||||
+ '<td>' + dateFormatter.format(row.fecha) + '</td>' + "\n"
|
||||
+ '<td>' + row.glosa + '</td>' + "\n"
|
||||
+ '<td class="right aligned">' + (row.cargo === 0 ? '' : numberFormatter.format(row.cargo)) + '</td>' + "\n"
|
||||
+ '<td class="right aligned">' + (row.abono === 0 ? '' : numberFormatter.format(row.abono)) + '</td>' + "\n"
|
||||
+ '<td class="right aligned">' + (row.saldo === 0 ? '' : numberFormatter.format(row.saldo)) + '</td>' + "\n"
|
||||
).append(
|
||||
$('<td></td>').append(
|
||||
this.draw().centroCosto(idx)
|
||||
)
|
||||
).append(
|
||||
$('<td></td>').append(
|
||||
this.draw().detalle(idx)
|
||||
)
|
||||
).append(
|
||||
$('<td></td>').html(idx + 1)
|
||||
)
|
||||
)
|
||||
})
|
||||
},
|
||||
centroCosto: idx => {
|
||||
const centros = JSON.parse('{!! json_encode($centrosCostos) !!}')
|
||||
const menu = $('<div></div>').addClass('menu')
|
||||
centros.forEach(centro => {
|
||||
menu.append(
|
||||
'<div class="item" data-value="' + centro.id + '">'
|
||||
+ centro.id + ' - ' + centro.descripcion
|
||||
+ '</div>'
|
||||
)
|
||||
})
|
||||
const dropdown = $('<div></div>').addClass('ui search selection dropdown').attr('data-idx', idx).html(
|
||||
'<input type="hidden" name="centro" />' + "\n" +
|
||||
'<i class="dropdown icon"></i>' + "\n" +
|
||||
'<div class="default text">Centro de Costo</div>' + "\n"
|
||||
).append(menu)
|
||||
dropdown.dropdown({
|
||||
onChange: (value, text, $element) => {
|
||||
const idx = $element.parent().parent().data('idx')
|
||||
this.update().centro(idx, value)
|
||||
}
|
||||
})
|
||||
|
||||
if (this.movimientos[idx].centro !== '') {
|
||||
const cid = centros.findIndex(centro => centro.descripcion === this.movimientos[idx].centro)
|
||||
dropdown.dropdown('set selected', centros[cid].id, true)
|
||||
}
|
||||
return dropdown
|
||||
},
|
||||
detalle: idx => {
|
||||
const detalle = document.createElement('input')
|
||||
detalle.type = 'text'
|
||||
detalle.name = 'detalle' + idx
|
||||
detalle.placeholder = 'Detalle'
|
||||
detalle.setAttribute('data-idx', idx)
|
||||
const input = document.createElement('div')
|
||||
input.className = 'ui input'
|
||||
input.appendChild(detalle)
|
||||
if (this.movimientos[idx].detalle !== '') {
|
||||
detalle.value = this.movimientos[idx].detalle
|
||||
}
|
||||
detalle.addEventListener('blur', event => {
|
||||
const idx = event.currentTarget.dataset['idx']
|
||||
this.update().detalle(idx, event.currentTarget.value)
|
||||
})
|
||||
return $(input)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@php
|
||||
$columns = [
|
||||
'sociedad',
|
||||
'cuenta',
|
||||
'fecha',
|
||||
'glosa',
|
||||
'cargo',
|
||||
'abono',
|
||||
'saldo',
|
||||
'centro',
|
||||
'detalle',
|
||||
'orden'
|
||||
];
|
||||
@endphp
|
||||
const diaria = {
|
||||
ids: {},
|
||||
data: {
|
||||
inmobiliarias: JSON.parse('{!! json_encode($inmobiliarias) !!}'),
|
||||
cartolasIdx: [],
|
||||
cartolas: [],
|
||||
},
|
||||
dataTableConfig: {
|
||||
order: [[{{array_search('orden', $columns)}}, 'asc']],
|
||||
columnDefs: [
|
||||
{
|
||||
targets: [{{implode(',', array_keys(array_filter($columns, function($column) {return in_array($column, ['fecha', 'cargo', 'abono', 'saldo']);})))}}],
|
||||
width: '{{round((1/(count($columns) + 3 - 1)) * 100,2)}}%'
|
||||
},
|
||||
{
|
||||
targets: [{{implode(',', array_keys(array_filter($columns, function($column) {return in_array($column, ['sociedad', 'cuenta', 'glosa', 'centro', 'detalle']);})))}}],
|
||||
width: '{{round((1/(count($columns) + 3 - 1)) * 2 * 100, 2)}}%'
|
||||
},
|
||||
{
|
||||
targets: [{{array_search('orden', $columns)}}],
|
||||
visible: false
|
||||
}
|
||||
],
|
||||
},
|
||||
loaderStatus: true,
|
||||
loader() {
|
||||
return {
|
||||
show: () => {
|
||||
if (!this.loaderStatus) {
|
||||
$(this.ids.loader).show()
|
||||
this.loaderStatus = true
|
||||
}
|
||||
},
|
||||
hide: () => {
|
||||
if (this.loaderStatus) {
|
||||
$(this.ids.loader).hide()
|
||||
this.loaderStatus = false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
cartolas() {
|
||||
return {
|
||||
add: () => {
|
||||
let first = false
|
||||
if (this.data.cartolas.length === 0) {
|
||||
first = true
|
||||
}
|
||||
const idx = this.data.cartolas.reduce((prev, cartola) => Math.max(prev, cartola.idx), 0) + 1
|
||||
const cartola = new Cartola(idx)
|
||||
this.data.cartolas.push(cartola)
|
||||
this.data.cartolasIdx.push(idx)
|
||||
const form = $(this.ids.form)
|
||||
cartola.draw().form(form, this.data.inmobiliarias, first)
|
||||
$(this.ids.fields).attr('value', JSON.stringify(this.data.cartolasIdx))
|
||||
},
|
||||
remove: idx => {
|
||||
if (this.data.cartolas.length === 1) {
|
||||
return
|
||||
}
|
||||
const i = this.data.cartolasIdx.findIndex(value => value === idx)
|
||||
const cartolaIdx = this.data.cartolas.findIndex(cartola => cartola.idx === idx)
|
||||
$("div.cartola[data-cartola='" + idx + "']").remove()
|
||||
this.data.cartolasIdx.splice(i,1)
|
||||
this.data.cartolas.splice(cartolaIdx,1)
|
||||
$(this.ids.fields).attr('value', JSON.stringify(this.data.cartolasIdx))
|
||||
}
|
||||
}
|
||||
},
|
||||
draw() {
|
||||
return {
|
||||
empty: () => {
|
||||
Object.values(this.ids.table).forEach(id => $(id).find('tbody').html(''))
|
||||
},
|
||||
diferencia: () => {
|
||||
const $table = $(this.ids.table.diferencia)
|
||||
const $tbody = $table.find('tbody')
|
||||
$tbody.html('')
|
||||
const dateFormatter = new Intl.DateTimeFormat('es-CL', {
|
||||
year: 'numeric',
|
||||
month: 'numeric',
|
||||
day: 'numeric'
|
||||
})
|
||||
const numberFormatter = new Intl.NumberFormat('es-CL', {minimumFractionDigits: 0, maximumFractionDigits: 0})
|
||||
this.data.cartolas.forEach(cartola => {
|
||||
cartola.draw().diferencia($tbody, dateFormatter, numberFormatter)
|
||||
})
|
||||
},
|
||||
cartola: () => {
|
||||
const $table = $(this.ids.table.base)
|
||||
$table.DataTable().clear()
|
||||
$table.DataTable().destroy()
|
||||
const $tbody = $(this.ids.table.body)
|
||||
$tbody.html('')
|
||||
const dateFormatter = new Intl.DateTimeFormat('es-CL', {
|
||||
year: 'numeric',
|
||||
month: 'numeric',
|
||||
day: 'numeric'
|
||||
})
|
||||
const numberFormatter = new Intl.NumberFormat('es-CL', {minimumFractionDigits: 0, maximumFractionDigits: 0})
|
||||
this.data.cartolas.forEach(cartola => {
|
||||
cartola.draw().cartola($tbody, dateFormatter, numberFormatter)
|
||||
})
|
||||
$table.DataTable(this.dataTableConfig)
|
||||
},
|
||||
}
|
||||
},
|
||||
parse() {
|
||||
return {
|
||||
cartola: event => {
|
||||
const body = new FormData($(this.ids.form)[0])
|
||||
this.data.cartolas.forEach(cartola => {
|
||||
body.set('fecha' + cartola.idx, [cartola.fecha.getFullYear(), cartola.fecha.getMonth()+1, cartola.fecha.getDate()].join('-'))
|
||||
})
|
||||
const url = '{{$urls->api}}/contabilidad/cartola/diaria/procesar'
|
||||
diaria.loader().show()
|
||||
fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
diaria.loader().hide()
|
||||
this.draw().empty()
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (json.cartolas.length === 0) {
|
||||
return
|
||||
}
|
||||
Object.entries(json.cartolas).forEach(entry => {
|
||||
const cartolaIdx = this.data.cartolas.findIndex(cartola => cartola.idx === parseInt(entry[0]))
|
||||
this.data.cartolas[cartolaIdx].movimientos = []
|
||||
entry[1].movimientos.forEach((row, idx) => {
|
||||
const fecha = new Date(row.fecha)
|
||||
fecha.setDate(fecha.getDate() + 1)
|
||||
this.data.cartolas[cartolaIdx].movimientos[idx] = {
|
||||
id: row.id,
|
||||
fecha: fecha,
|
||||
glosa: row.glosa,
|
||||
documento: row.documento,
|
||||
cargo: row.cargo,
|
||||
abono: row.abono,
|
||||
saldo: row.saldo,
|
||||
centro: row.detalles?.centro_costo.descripcion ?? '',
|
||||
detalle: row.detalles?.detalle ?? ''
|
||||
}
|
||||
})
|
||||
const ayer = new Date(this.data.cartolas[cartolaIdx].fecha.getTime())
|
||||
ayer.setDate(this.data.cartolas[cartolaIdx].fecha.getDate() - 1)
|
||||
this.data.cartolas[cartolaIdx].saldo = entry[1].cartola.saldo
|
||||
this.data.cartolas[cartolaIdx].get().ayer(ayer)
|
||||
})
|
||||
this.draw().diferencia()
|
||||
this.draw().cartola()
|
||||
})
|
||||
})
|
||||
return false
|
||||
}
|
||||
}
|
||||
},
|
||||
setup(ids) {
|
||||
this.ids = ids
|
||||
|
||||
this.loader().hide()
|
||||
|
||||
$(this.ids.form).submit(event => {
|
||||
event.preventDefault()
|
||||
return false
|
||||
})
|
||||
$(this.ids.buttons.add).click(event => {
|
||||
this.cartolas().add()
|
||||
})
|
||||
$(this.ids.buttons.process).click(this.parse().cartola)
|
||||
$(this.ids.table.base).DataTable(this.dataTableConfig)
|
||||
|
||||
this.cartolas().add()
|
||||
}
|
||||
}
|
||||
const manual = {
|
||||
ids: {},
|
||||
$modal: null,
|
||||
data: {
|
||||
inmobiliaria: '',
|
||||
cuenta: '',
|
||||
fecha: '',
|
||||
field: 0,
|
||||
movimientos: [
|
||||
{idx: 1}
|
||||
]
|
||||
},
|
||||
get movimientosIdx() {
|
||||
const $movimientosIdx = $(this.ids.form).find("[name='movimientos']")
|
||||
return JSON.parse($movimientosIdx.val())
|
||||
},
|
||||
set movimientosIdx(list) {
|
||||
const $movimientosIdx = $(this.ids.form).find("[name='movimientos']")
|
||||
$movimientosIdx.val(JSON.stringify(list))
|
||||
},
|
||||
update() {
|
||||
return {
|
||||
file: movimientos => {
|
||||
const $file = $("[name='file" + this.data.field + "']")
|
||||
$file.val(JSON.stringify(movimientos))
|
||||
}
|
||||
}
|
||||
},
|
||||
parse() {
|
||||
return {
|
||||
movimientos: () => {
|
||||
const $fields = $(this.ids.movimientos).find('.fields')
|
||||
const movimientos = []
|
||||
$fields.each((i, fields) => {
|
||||
const idx = $(fields).data('movimiento')
|
||||
const inputs = [
|
||||
'glosa',
|
||||
'cargo',
|
||||
'abono',
|
||||
'saldo'
|
||||
]
|
||||
const data = {}
|
||||
inputs.forEach(name => {
|
||||
data[name] = $(fields).find("[name='"+name+idx+"']").val()
|
||||
if (name !== 'glosa') {
|
||||
data[name] = parseInt(data[name]) || 0
|
||||
}
|
||||
})
|
||||
|
||||
movimientos.push(data)
|
||||
})
|
||||
this.update().file(movimientos)
|
||||
}
|
||||
}
|
||||
},
|
||||
movimiento() {
|
||||
return {
|
||||
add: () => {
|
||||
const idx = this.data.movimientos.reduce((prev, movimiento) => Math.max(prev, movimiento.idx), 0) + 1
|
||||
const movimiento = {
|
||||
idx
|
||||
}
|
||||
this.data.movimientos.push(movimiento)
|
||||
const movimientosidx = this.movimientosIdx
|
||||
movimientosidx.push(idx)
|
||||
this.movimientosIdx = movimientosidx
|
||||
this.draw().movimiento(idx)
|
||||
},
|
||||
remove: idx => {
|
||||
const movimientosIdx = this.movimientosIdx
|
||||
const i = movimientosIdx.findIndex(n => n === idx)
|
||||
movimientosIdx.splice(i, 1)
|
||||
const movimientoIdx = this.data.movimientos.findIndex(movimiento => movimiento.idx === idx)
|
||||
this.data.movimientos.splice(movimientoIdx, 1)
|
||||
$(this.ids.movimientos).find("[data-idx='"+idx+"']").parent().parent().remove()
|
||||
this.movimientosIdx = movimientosIdx
|
||||
}
|
||||
}
|
||||
},
|
||||
draw() {
|
||||
return {
|
||||
movimiento: idx => {
|
||||
$(this.ids.movimientos).append(
|
||||
$('<div></div>').addClass('fields').attr('data-movimiento', idx).append(
|
||||
'<div class="field">' + "\n"
|
||||
+ '<label>Glosa</label>' + "\n"
|
||||
+ '<input type="text" name="glosa' + idx + '" />' + "\n"
|
||||
+ '</div>' + "\n" +
|
||||
'<div class="field">' + "\n"
|
||||
+ '<label>Cargo</label>' + "\n"
|
||||
+ '<div class="ui left labeled input">' + "\n"
|
||||
+ '<div class="ui basic label">$</div>' + "\n"
|
||||
+ '<input type="text" name="cargo' + idx + '" />' + "\n"
|
||||
+ '</div>' + "\n"
|
||||
+ '</div>' + "\n" +
|
||||
'<div class="field">' + "\n"
|
||||
+ '<label>Abono</label>' + "\n"
|
||||
+ '<div class="ui left labeled input">' + "\n"
|
||||
+ '<div class="ui basic label">$</div>' + "\n"
|
||||
+ '<input type="text" name="abono' + idx + '" />' + "\n"
|
||||
+ '</div>' + "\n"
|
||||
+ '</div>' + "\n" +
|
||||
'<div class="field">' + "\n"
|
||||
+ '<label>Saldo</label>' + "\n"
|
||||
+ '<div class="ui left labeled input">' + "\n"
|
||||
+ '<div class="ui basic label">$</div>' + "\n"
|
||||
+ '<input type="text" name="saldo' + idx + '" />' + "\n"
|
||||
+ '</div>' + "\n"
|
||||
+ '</div>'
|
||||
).append(
|
||||
$('<div></div>').addClass('field').append(
|
||||
$('<label></label>').html('Eliminar')
|
||||
).append(
|
||||
$('<button></button>').addClass('ui red icon button').attr('type', 'button').attr('data-idx', idx).append(
|
||||
$('<i></i>').addClass('remove icon')
|
||||
).click(event => {
|
||||
const idx = $(event.currentTarget).data('idx')
|
||||
manual.movimiento().remove(idx)
|
||||
})
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
setup(ids) {
|
||||
this.ids = ids
|
||||
|
||||
$(this.ids.modal).modal({
|
||||
onShow: () => {
|
||||
$(this.ids.inmobiliaria).html(this.data.inmobiliaria)
|
||||
$(this.ids.cuenta).html(this.data.cuenta)
|
||||
$(this.ids.fecha).html(this.data.fecha)
|
||||
this.movimientos = []
|
||||
$(this.ids.form).trigger('reset')
|
||||
},
|
||||
onApprove: $element => {
|
||||
this.parse().movimientos()
|
||||
},
|
||||
onHide: $element => {
|
||||
this.parse().movimientos()
|
||||
}
|
||||
})
|
||||
this.$modal = $(this.ids.modal)
|
||||
$(this.ids.button).click(event => {
|
||||
this.movimiento().add()
|
||||
})
|
||||
$(this.ids.form).submit(event => {
|
||||
event.preventDefault()
|
||||
this.$modal.modal('hide')
|
||||
return false
|
||||
})
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
diaria.setup({
|
||||
table: {
|
||||
base: '#tabla_movimientos',
|
||||
body: '#movimientos',
|
||||
diferencia: '#diferencia'
|
||||
},
|
||||
form: '#cartola_form',
|
||||
fields: '#fields',
|
||||
buttons: {
|
||||
add: '#add_button',
|
||||
process: '#process_button'
|
||||
},
|
||||
loader: '#loader'
|
||||
})
|
||||
manual.setup({
|
||||
modal: '#manual_modal',
|
||||
button: '#add_manual',
|
||||
inmobiliaria: '#modal_inmobiliaria',
|
||||
cuenta: '#modal_cuenta',
|
||||
fecha: '#modal_fecha',
|
||||
form: '#modal_form',
|
||||
movimientos: '#modal_movimientos'
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
330
app/resources/views/contabilidad/centros_costos.blade.php
Normal file
330
app/resources/views/contabilidad/centros_costos.blade.php
Normal file
@ -0,0 +1,330 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h1 class="ui header">
|
||||
Centros de Costos
|
||||
</h1>
|
||||
{{--<div class="ui top attached right aligned basic segment">
|
||||
<button class="ui tiny green icon button" id="add_button">
|
||||
Agregar
|
||||
<i class="plus icon"></i>
|
||||
</button>
|
||||
</div>--}}
|
||||
<table class="ui table" id="centros_costos">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Tipo de Centro</th>
|
||||
<th>Categoría</th>
|
||||
<th>Tipo de Cuenta</th>
|
||||
<th>Cuenta Contable</th>
|
||||
<th>Centro de Costo</th>
|
||||
<th>Descripción</th>
|
||||
{{--<th>
|
||||
</th>--}}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($centrosCostos as $centroCosto)
|
||||
<tr data-id="{{$centroCosto->id}}">
|
||||
<td data-id="{{$centroCosto->tipoCentro->id}}">{{$centroCosto->tipoCentro->descripcion}}</td>
|
||||
<td data-id="{{$centroCosto->categoria->id}}">{{$centroCosto->categoria->descripcion}}</td>
|
||||
<td data-id="{{$centroCosto->tipoCuenta?->id}}">{{$centroCosto->tipoCuenta?->descripcion}}</td>
|
||||
<td>{{$centroCosto->cuentaContable}}</td>
|
||||
<td>{{$centroCosto->id}}</td>
|
||||
<td>{{$centroCosto->descripcion}}</td>
|
||||
{{--<td>
|
||||
<div class="ui mini buttons">
|
||||
<button class="ui icon button edit_button" data-id="{{$centroCosto->id}}">
|
||||
<i class="edit icon"></i>
|
||||
</button>
|
||||
<button class="ui red icon button remove_button" data-id="{{$centroCosto->id}}">
|
||||
<i class="remove icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</td>--}}
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="ui modal" id="modal_add">
|
||||
<div class="content">
|
||||
<form class="ui form" id="add_form">
|
||||
<div class="fields">
|
||||
<div class="three wide field">
|
||||
<label for="tipo_centro">Tipo de Centro</label>
|
||||
<div class="ui selection search dropdown" id="tipo_centro">
|
||||
<input type="hidden" name="tipo_centro_id" />
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Tipo</div>
|
||||
<div class="menu">
|
||||
@foreach ($tiposCentros as $tipoCentro)
|
||||
<div class="item" data-value="{{$tipoCentro->id}}">{{$tipoCentro->descripcion}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="three wide field">
|
||||
<label for="tipo_cuenta">Tipo de Cuenta</label>
|
||||
<div class="ui selection search dropdown" id="tipo_cuenta">
|
||||
<input type="hidden" name="tipo_cuenta_id" />
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Tipo de Cuenta</div>
|
||||
<div class="menu">
|
||||
<div class="item" data-value="">---</div>
|
||||
@foreach ($tiposCuentas as $tipoCuenta)
|
||||
<div class="item" data-value="{{$tipoCuenta->id}}">{{$tipoCuenta->descripcion}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="five wide field">
|
||||
<label for="categoria">Categoría</label>
|
||||
<div class="ui selection search dropdown" id="categoria">
|
||||
<input type="hidden" name="categoria_id" />
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Categoría</div>
|
||||
<div class="menu">
|
||||
@foreach ($categorias as $categoria)
|
||||
<div class="item" data-value="{{$categoria->id}}">{{$categoria->descripcion}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="three wide field">
|
||||
<label for="cuenta_contable">Cuenta Contable</label>
|
||||
<input type="text" name="cuenta_contable" id="cuenta_contable" />
|
||||
</div>
|
||||
<div class="two wide field">
|
||||
<label for="identificador">Centro de Costo</label>
|
||||
<input type="number" name="id" id="identificador" maxlength="3" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="descripcion">Descripción</label>
|
||||
<textarea id="descripcion" name="descripcion" class="ui textarea" rows="1" cols="10"></textarea>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="ui positive icon button">
|
||||
<i class="plus icon"></i>
|
||||
Agregar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui modal" id="modal_edit">
|
||||
<div class="header">
|
||||
Centro de Costo <span id="id"></span>
|
||||
</div>
|
||||
<div class="content">
|
||||
<form class="ui form" id="edit_form">
|
||||
<input type="hidden" name="id" id="identificador" />
|
||||
<div class="fields">
|
||||
<div class="three wide field">
|
||||
<label for="tipo_centro">Tipo de Centro</label>
|
||||
<div class="ui selection search dropdown" id="tipo_centro">
|
||||
<input type="hidden" name="tipo_centro_id" />
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Tipo</div>
|
||||
<div class="menu">
|
||||
@foreach ($tiposCentros as $tipoCentro)
|
||||
<div class="item" data-value="{{$tipoCentro->id}}">{{$tipoCentro->descripcion}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="three wide field">
|
||||
<label for="tipo_cuenta">Tipo de Cuenta</label>
|
||||
<div class="ui selection search dropdown" id="tipo_cuenta">
|
||||
<input type="hidden" name="tipo_cuenta_id" />
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Tipo de Cuenta</div>
|
||||
<div class="menu">
|
||||
<div class="item" data-value="">---</div>
|
||||
@foreach ($tiposCuentas as $tipoCuenta)
|
||||
<div class="item" data-value="{{$tipoCuenta->id}}">{{$tipoCuenta->descripcion}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="five wide field">
|
||||
<label for="categoria">Categoría</label>
|
||||
<div class="ui selection search dropdown" id="categoria">
|
||||
<input type="hidden" name="categoria_id" />
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Categoría</div>
|
||||
<div class="menu">
|
||||
@foreach ($categorias as $categoria)
|
||||
<div class="item" data-value="{{$categoria->id}}">{{$categoria->descripcion}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="three wide field">
|
||||
<label for="cuenta_contable">Cuenta Contable</label>
|
||||
<input type="text" name="cuenta_contable" id="cuenta_contable" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="descripcion">Descripción</label>
|
||||
<textarea id="descripcion" name="descripcion" class="ui textarea" rows="1" cols="10"></textarea>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="ui positive icon button">
|
||||
<i class="plus icon"></i>
|
||||
Editar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('layout.head.styles.datatables')
|
||||
@include('layout.body.scripts.datatables')
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
const centros = {
|
||||
ids: {
|
||||
table: '',
|
||||
modals: {
|
||||
add: '',
|
||||
edit: ''
|
||||
},
|
||||
buttons: {
|
||||
add: '',
|
||||
edit: '',
|
||||
remove: ''
|
||||
},
|
||||
forms: {
|
||||
add: '',
|
||||
edit: ''
|
||||
}
|
||||
},
|
||||
setup: function({ids}) {
|
||||
this.ids = ids
|
||||
|
||||
Object.keys(this.ids.modals).forEach(name => {
|
||||
$(this.ids.modals[name]).modal({
|
||||
onApprove: ($element) => {
|
||||
this.actions()[name]()
|
||||
},
|
||||
onHidden: (modal) => {
|
||||
document.getElementById(this.ids.forms[name]).reset()
|
||||
}
|
||||
})
|
||||
$(this.ids.modals[name]).find('.dropdown').each((idx, item) => {
|
||||
$(item).dropdown()
|
||||
})
|
||||
})
|
||||
Object.keys(this.ids.buttons).forEach(name => {
|
||||
if (name === 'remove') {
|
||||
return
|
||||
}
|
||||
$(this.ids.buttons[name]).click(event => {
|
||||
if (name === 'edit') {
|
||||
const id = $(event.currentTarget).data('id')
|
||||
const row = $("tr[data-id='" + id + "']")
|
||||
const data = {
|
||||
id,
|
||||
tipo_centro_id: row.find(':nth-child(1)').data('id'),
|
||||
categoria_id: row.find(':nth-child(2)').data('id'),
|
||||
tipo_cuenta_id: row.find(':nth-child(3)').data('id'),
|
||||
cuenta_contable: row.find(':nth-child(4)').html(),
|
||||
descripcion: row.find(':nth-child(6)').html()
|
||||
}
|
||||
$(this.ids.modals[name]).find('#id').html(id)
|
||||
const form = $('#' + this.ids.forms[name])
|
||||
form.find("[name='id']").val(data.id)
|
||||
form.find('#tipo_centro').dropdown('set selected', data.tipo_centro_id)
|
||||
form.find('#categoria').dropdown('set selected', data.categoria_id)
|
||||
form.find('#tipo_cuenta').dropdown('set selected', data.tipo_cuenta_id)
|
||||
form.find('#cuenta_contable').val(data.cuenta_contable)
|
||||
form.find('#descripcion').val(data.descripcion)
|
||||
}
|
||||
$(this.ids.modals[name]).modal('show')
|
||||
})
|
||||
})
|
||||
$(this.ids.buttons.remove).click(event => {
|
||||
const id = $(event.currentTarget).data('id')
|
||||
this.actions().remove(id)
|
||||
})
|
||||
$(this.ids.table).dataTable({
|
||||
order: [
|
||||
[0, 'desc'],
|
||||
[2, 'asc'],
|
||||
[1, 'asc'],
|
||||
[4, 'asc']
|
||||
]
|
||||
})
|
||||
},
|
||||
actions: function() {
|
||||
return {
|
||||
add: () => {
|
||||
const body = new FormData(document.getElementById(this.ids.forms.add))
|
||||
const url = '{{$urls->api}}/contabilidad/centros_costos/add'
|
||||
fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
response.json().then(json => {
|
||||
if (json.added) {
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
edit: () => {
|
||||
const body = new FormData(document.getElementById(this.ids.forms.edit))
|
||||
const url = '{{$urls->api}}/contabilidad/centro_costo/' + body.get('id') + '/edit'
|
||||
fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
response.json().then(json => {
|
||||
if (json.edited) {
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
remove: id => {
|
||||
const url = '{{$urls->api}}/contabilidad/centro_costo/' + id
|
||||
fetchAPI(url, {method: 'delete'}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
response.json().then(json => {
|
||||
if (json.removed) {
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
centros.setup({ids: {
|
||||
table: '#centros_costos',
|
||||
modals: {
|
||||
add: '#modal_add',
|
||||
edit: '#modal_edit'
|
||||
},
|
||||
buttons: {
|
||||
add: '#add_button',
|
||||
edit: '.edit_button',
|
||||
remove: '.remove_button'
|
||||
},
|
||||
forms: {
|
||||
add: 'add_form',
|
||||
edit: 'edit_form'
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
@ -0,0 +1,399 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h1 class="ui header">Asignar Centros de Costos</h1>
|
||||
<form class="ui form" id="asignar_form">
|
||||
<div class="ui grid">
|
||||
<div class="fourteen wide column">
|
||||
<div class="fields">
|
||||
<div class="five wide field">
|
||||
<label>Inmobiliaria</label>
|
||||
<div class="ui selection search dropdown" id="inmobiliaria">
|
||||
<input type="hidden" name="inmobiliaria"/>
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Inmobiliaria</div>
|
||||
<div class="menu">
|
||||
@foreach ($inmobiliarias as $inmobiliaria)
|
||||
<div class="item" data-value="{{$inmobiliaria->rut}}">{{$inmobiliaria->razon}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="two wide field">
|
||||
<label>Banco</label>
|
||||
<div class="ui selection search dropdown" id="banco">
|
||||
<input type="hidden" name="banco"/>
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Banco</div>
|
||||
<div class="menu"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Mes</label>
|
||||
<div class="ui calendar" id="mes">
|
||||
<div class="ui icon input">
|
||||
<i class="calendar icon"></i>
|
||||
<input type="text" name="mes"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="file">Cartola</label>
|
||||
<input type="file" name="file" id="file" class="ui invisible file input" />
|
||||
<label for="file" class="ui icon button">
|
||||
<i class="file icon"></i>
|
||||
Cargar
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="two wide middle aligned column">
|
||||
<button class="ui icon button">
|
||||
Procesar
|
||||
<i class="sync icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="ui two columns grid">
|
||||
<div class="column">
|
||||
<button class="ui icon button" id="export_button">
|
||||
<i class="file excel icon"></i>
|
||||
Exportar
|
||||
</button>
|
||||
</div>
|
||||
<div class="right aligned column">
|
||||
<div class="ui inline active loader" id="loader"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui fluid container">
|
||||
<table class="ui table" id="tabla_movimientos">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Fecha</th>
|
||||
<th>Glosa</th>
|
||||
<th>Documento</th>
|
||||
<th class="right aligned">Cargo</th>
|
||||
<th class="right aligned">Abono</th>
|
||||
<th>Centro de Costo</th>
|
||||
<th>Detalle</th>
|
||||
<th>Orden</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="movimientos"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('layout.head.styles.datatables')
|
||||
@include('layout.body.scripts.datatables')
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
const cartola = {
|
||||
ids: {
|
||||
table: {
|
||||
base: '',
|
||||
body: ''
|
||||
},
|
||||
form: {
|
||||
base: '',
|
||||
inmobiliaria: '',
|
||||
banco: '',
|
||||
mes: '',
|
||||
},
|
||||
button: '',
|
||||
loader: '',
|
||||
},
|
||||
data: {
|
||||
inmobiliaria: {
|
||||
rut: 0,
|
||||
razon: ''
|
||||
},
|
||||
banco: {
|
||||
id: 0,
|
||||
nombre: ''
|
||||
},
|
||||
mes: '',
|
||||
movimientos: [],
|
||||
centrosCostos: {
|
||||
ingresos: JSON.parse('{!! json_encode(array_values(array_map(function(\Incoviba\Model\CentroCosto $centroCosto) {
|
||||
return [
|
||||
'id' => $centroCosto->id,
|
||||
'descripcion' => $centroCosto->descripcion
|
||||
];
|
||||
}, array_filter($centrosCostos, function(\Incoviba\Model\CentroCosto $centroCosto) {
|
||||
return $centroCosto->tipoCentro->descripcion === 'Ingreso';
|
||||
})))) !!}'),
|
||||
egresos: JSON.parse('{!! json_encode(array_values(array_map(function(\Incoviba\Model\CentroCosto $centroCosto) {
|
||||
return [
|
||||
'id' => $centroCosto->id,
|
||||
'descripcion' => $centroCosto->descripcion
|
||||
];
|
||||
}, array_filter($centrosCostos, function(\Incoviba\Model\CentroCosto $centroCosto) {
|
||||
return $centroCosto->tipoCentro->descripcion === 'Egreso';
|
||||
})))) !!}'),
|
||||
}
|
||||
},
|
||||
dataTableConfig: {
|
||||
pageLength: 100,
|
||||
order: [[7, 'asc']],
|
||||
columnDefs: [
|
||||
{
|
||||
targets: [0, 2, 3, 4],
|
||||
width: '10%'
|
||||
},
|
||||
{
|
||||
targets: [1],
|
||||
width: '20%'
|
||||
},
|
||||
{
|
||||
targets: [7],
|
||||
visible: false
|
||||
}
|
||||
],
|
||||
},
|
||||
get() {
|
||||
return {
|
||||
bancos: inmobiliaria_rut => {
|
||||
const url = '{{$urls->api}}/inmobiliaria/' + inmobiliaria_rut + '/cuentas'
|
||||
$(this.ids.loader).show()
|
||||
return fetchAPI(url).then(response => {
|
||||
$(this.ids.loader).hide()
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (json.cuentas.length === 0) {
|
||||
return
|
||||
}
|
||||
$(this.ids.form.banco).dropdown('change values', json.cuentas.map(cuenta => {
|
||||
return {value: cuenta.banco.id, text: cuenta.banco.nombre, name: cuenta.banco.nombre}
|
||||
})).dropdown('refresh')
|
||||
})
|
||||
})
|
||||
},
|
||||
firstDate: inmobiliaria_rut => {
|
||||
const url = '{{$urls->api}}/inmobiliaria/' + inmobiliaria_rut + '/proyectos'
|
||||
$(this.ids.loader).show()
|
||||
return fetchAPI(url).then(response => {
|
||||
$(this.ids.loader).hide()
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (json.proyectos.length === 0) {
|
||||
return
|
||||
}
|
||||
const min = json.proyectos.reduce((min, proyecto) => {
|
||||
const date = new Date(proyecto.current_estado.fecha.date)
|
||||
if (min > date.getTime()) {
|
||||
return date.getTime()
|
||||
}
|
||||
return min
|
||||
}, (new Date()).getTime())
|
||||
$(this.ids.form.mes).calendar('set minDate', new Date(min))
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
parse() {
|
||||
return {
|
||||
cartola: event => {
|
||||
event.preventDefault()
|
||||
const body = new FormData(document.getElementById('asignar_form'))
|
||||
body.set('mes', $('#mes').calendar('get date').toISOString())
|
||||
const url = '{{$urls->api}}/contabilidad/cartolas/procesar'
|
||||
$(this.ids.loader).show()
|
||||
fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
$(this.ids.loader).hide()
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (json.movimientos.length === 0) {
|
||||
return
|
||||
}
|
||||
this.data.movimientos = []
|
||||
json.movimientos.forEach((row, idx) => {
|
||||
const fecha = new Date(row.fecha)
|
||||
fecha.setDate(fecha.getDate() + 1)
|
||||
this.data.movimientos[idx] = {
|
||||
fecha: fecha,
|
||||
glosa: row.glosa,
|
||||
documento: row.documento,
|
||||
cargo: row.cargo,
|
||||
abono: row.abono,
|
||||
}
|
||||
})
|
||||
this.draw().cartola()
|
||||
})
|
||||
})
|
||||
return false
|
||||
}
|
||||
}
|
||||
},
|
||||
export() {
|
||||
return {
|
||||
cartola: event => {
|
||||
const url = '{{$urls->api}}/contabilidad/cartola/exportar'
|
||||
const body = new FormData()
|
||||
body.set('inmobiliaria', $(this.ids.form.inmobiliaria).dropdown('get value'))
|
||||
body.set('banco', $(this.ids.form.banco).dropdown('get value'))
|
||||
body.set('mes', $(this.ids.form.mes).calendar('get date').toISOString())
|
||||
const movimientos = this.data.movimientos.map((movimiento, idx) => {
|
||||
const temp = structuredClone(movimiento)
|
||||
temp.fecha = movimiento.fecha.toISOString()
|
||||
let centro = $(".centro[data-index='" + (idx+1) + "']").dropdown('get value')
|
||||
if (centro.length === 0) {
|
||||
centro = ''
|
||||
}
|
||||
temp.centro_costo = centro
|
||||
let detalle = $("[name='detalle" + (idx+1) + "']").val()
|
||||
if (typeof detalle === 'undefined') {
|
||||
detalle = ''
|
||||
}
|
||||
temp.detalle = detalle
|
||||
return temp
|
||||
})
|
||||
body.set('movimientos', JSON.stringify(movimientos))
|
||||
$(this.ids.loader).show()
|
||||
fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
$(this.ids.loader).hide()
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
response.json().then(json => {
|
||||
if (json.filename === '') {
|
||||
return
|
||||
}
|
||||
const anchor = document.createElement('a')
|
||||
anchor.href = ['/uploads/', json.filename].join('/')
|
||||
anchor.download = 'Cartola ' + this.data.banco.nombre + ' - ' + this.data.inmobiliaria.razon + ' - ' + this.data.mes + '.xlsx'
|
||||
document.body.appendChild(anchor)
|
||||
anchor.click()
|
||||
anchor.remove()
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
draw() {
|
||||
return {
|
||||
cartola: () => {
|
||||
const table = $(this.ids.table.base)
|
||||
table.DataTable().clear()
|
||||
table.DataTable().destroy()
|
||||
const tbody = $(this.ids.table.body)
|
||||
tbody.html('')
|
||||
const dateFormatter = new Intl.DateTimeFormat('es-CL', {
|
||||
year: 'numeric',
|
||||
month: 'numeric',
|
||||
day: 'numeric'
|
||||
})
|
||||
const numberFormatter = new Intl.NumberFormat('es-CL', {minimumFractionDigits: 0, maximumFractionDigits: 0})
|
||||
this.data.movimientos.forEach((row, idx) => {
|
||||
tbody.append(
|
||||
$('<tr></tr>').append(
|
||||
$('<td></td>').html(dateFormatter.format(row.fecha))
|
||||
).append(
|
||||
$('<td></td>').html(row.glosa)
|
||||
).append(
|
||||
$('<td></td>').html(row.documento)
|
||||
).append(
|
||||
$('<td></td>').addClass('right aligned').html(row.cargo === 0 ? '' : numberFormatter.format(row.cargo))
|
||||
).append(
|
||||
$('<td></td>').addClass('right aligned').html(row.abono === 0 ? '' : numberFormatter.format(row.abono))
|
||||
).append(
|
||||
$('<td></td>').append(this.draw().centrosDropdown(idx + 1, row.cargo === 0))
|
||||
).append(
|
||||
$('<td></td>').append(
|
||||
$('<div></div>').addClass('ui fluid input').append(
|
||||
$('<input />').attr('type', 'text').attr('name', 'detalle' + (idx + 1))
|
||||
)
|
||||
)
|
||||
).append(
|
||||
$('<td></td>').html(idx + 1)
|
||||
)
|
||||
)
|
||||
})
|
||||
table.DataTable(this.dataTableConfig)
|
||||
},
|
||||
centrosDropdown: (idx, ingreso=true) => {
|
||||
const menu = $('<div></div>').addClass('menu')
|
||||
let centros = this.data.centrosCostos.ingresos
|
||||
if (!ingreso) {
|
||||
centros = this.data.centrosCostos.egresos
|
||||
}
|
||||
centros.forEach(centro => {
|
||||
menu.append(
|
||||
$('<div></div>').addClass('item').attr('data-value', centro.id).html(centro.id + ' - ' + centro.descripcion)
|
||||
)
|
||||
})
|
||||
return $('<div></div>').addClass('ui selection search dropdown centro').attr('data-index', idx).css('width', '80%').append(
|
||||
$('<input />').attr('type', 'hidden').attr('name', 'centro' + idx)
|
||||
).append(
|
||||
$('<i></i>').addClass('dropdown icon')
|
||||
).append(
|
||||
$('<div></div>').addClass('default text').html('Centro de Costos')
|
||||
).append(menu).dropdown()
|
||||
}
|
||||
}
|
||||
},
|
||||
setup({ids}) {
|
||||
this.ids = ids
|
||||
$(this.ids.form.inmobiliaria).dropdown({
|
||||
fireOnInit: true,
|
||||
onChange: (value, text, $choice) => {
|
||||
this.data.inmobiliaria.rut = value
|
||||
this.data.inmobiliaria.razon = text
|
||||
this.get().bancos(value)
|
||||
this.get().firstDate(value)
|
||||
},
|
||||
})
|
||||
$(this.ids.form.banco).dropdown({
|
||||
fireOnInit: true,
|
||||
onChange: (value, text, $choice) => {
|
||||
this.data.banco.id = value
|
||||
this.data.banco.nombre = text
|
||||
}
|
||||
})
|
||||
$(this.ids.loader).hide()
|
||||
|
||||
calendar_date_options['type'] = 'month'
|
||||
const lastMonth = new Date()
|
||||
lastMonth.setDate(0)
|
||||
calendar_date_options['maxDate'] = lastMonth
|
||||
calendar_date_options['onChange'] = (date, text, mode) => {
|
||||
this.data.mes = text
|
||||
}
|
||||
$(this.ids.form.mes).calendar(calendar_date_options)
|
||||
$(this.ids.form.base).submit(this.parse().cartola)
|
||||
$(this.ids.table.base).DataTable(this.dataTableConfig)
|
||||
|
||||
$(this.ids.button).click(this.export().cartola)
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
cartola.setup({
|
||||
ids: {
|
||||
table: {
|
||||
base: '#tabla_movimientos',
|
||||
body: '#movimientos'
|
||||
},
|
||||
form: {
|
||||
base: '#asignar_form',
|
||||
inmobiliaria: '#inmobiliaria',
|
||||
banco: '#banco',
|
||||
mes: '#mes',
|
||||
},
|
||||
button: '#export_button',
|
||||
loader: '#loader'
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
263
app/resources/views/contabilidad/depositos.blade.php
Normal file
263
app/resources/views/contabilidad/depositos.blade.php
Normal file
@ -0,0 +1,263 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h1 class="ui header">Depósitos a Plazo</h1>
|
||||
</div>
|
||||
<div class="ui stackable grid">
|
||||
<div class="two wide column"></div>
|
||||
<div class="twelve wide column">
|
||||
<table class="ui table" id="depositos">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Inmobiliaria</th>
|
||||
<th>Banco</th>
|
||||
<th>N° Depósito</th>
|
||||
<th>Capital</th>
|
||||
<th>Inicio</th>
|
||||
<th>Plazo</th>
|
||||
<th>Vencimiento</th>
|
||||
<th>Vencimiento ISO</th>
|
||||
<th>Monto al Vencimiento</th>
|
||||
<th>Tasa</th>
|
||||
<th>
|
||||
<button class="ui green icon button" id="add_button">
|
||||
<i class="plus icon"></i>
|
||||
</button>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($activos as $deposito)
|
||||
<tr>
|
||||
<td>{{$deposito->cuenta->inmobiliaria->razon}}</td>
|
||||
<td>{{$deposito->cuenta->banco->nombre}}</td>
|
||||
<td>{{$deposito->id}}</td>
|
||||
<td>{{$format->pesos($deposito->capital)}}</td>
|
||||
<td>{{$deposito->inicio->format('d-m-Y')}}</td>
|
||||
<td>{{$deposito->plazo()}}</td>
|
||||
<td>{{$deposito->termino->format('d-m-Y')}}</td>
|
||||
<td>{{$deposito->termino->format('Y-m-d')}}</td>
|
||||
<td>{{$format->pesos($deposito->futuro)}}</td>
|
||||
<td>{{$format->percent($deposito->tasa() * 100, 4)}}</td>
|
||||
<td>
|
||||
<button class="ui red icon button remove_button" data-deposito="{{$deposito->id}}">
|
||||
<i class="remove icon"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@foreach ($vencidos as $deposito)
|
||||
<tr class="yellow">
|
||||
<td>{{$deposito->cuenta->inmobiliaria->razon}}</td>
|
||||
<td>{{$deposito->cuenta->banco->nombre}}</td>
|
||||
<td>{{$deposito->id}}</td>
|
||||
<td>{{$format->pesos($deposito->capital)}}</td>
|
||||
<td>{{$deposito->inicio->format('d-m-Y')}}</td>
|
||||
<td>{{$deposito->plazo()}}</td>
|
||||
<td>{{$deposito->termino->format('d-m-Y')}}</td>
|
||||
<td>{{$deposito->termino->format('Y-m-d')}}</td>
|
||||
<td>{{$format->pesos($deposito->futuro)}}</td>
|
||||
<td>{{$format->percent($deposito->tasa() * 100, 4)}}</td>
|
||||
<td>
|
||||
<button class="ui red icon button remove_button" data-deposito="{{$deposito->id}}">
|
||||
<i class="remove icon"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui modal" id="add_modal">
|
||||
<div class="content">
|
||||
<form class="ui form" id="add_form">
|
||||
<div class="two fields">
|
||||
<div class="field">
|
||||
<label for="inmobiliaria">Inmobiliaria</label>
|
||||
<div class="ui search selection dropdown" id="inmobiliaria">
|
||||
<input type="hidden" name="inmobiliaria_rut" />
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Inmobiliaria</div>
|
||||
<div class="menu">
|
||||
@foreach ($inmobiliarias as $inmobiliaria)
|
||||
<div class="item" data-value="{{$inmobiliaria->rut}}">{{$inmobiliaria->razon}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="banco">Banco</label>
|
||||
<div class="ui search selection dropdown" id="banco">
|
||||
<input type="hidden" name="banco_id" />
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Banco</div>
|
||||
<div class="menu"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="three wide field">
|
||||
<label for="identificador">N° Depósito</label>
|
||||
<input type="text" id="identificador" name="id" />
|
||||
</div>
|
||||
<div class="three fields">
|
||||
<div class="field">
|
||||
<label for="capital">Capital</label>
|
||||
<input type="number" id="capital" name="capital" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="futuro">Monto al Vencimiento</label>
|
||||
<input type="number" id="futuro" name="futuro" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="two fields">
|
||||
<div class="field">
|
||||
<label for="inicio">Inicio</label>
|
||||
<div class="ui calendar" id="inicio">
|
||||
<div class="ui left icon input">
|
||||
<i class="calendar icon"></i>
|
||||
<input type="text" name="inicio" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="termino">Vencimiento</label>
|
||||
<div class="ui calendar" id="termino">
|
||||
<div class="ui left icon input">
|
||||
<i class="calendar icon"></i>
|
||||
<input type="text" name="termino" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="ui approve button">Agregar</button>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('layout.head.styles.datatables')
|
||||
@include('layout.body.scripts.datatables')
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
const depositos = {
|
||||
ids: {},
|
||||
data: {
|
||||
inmobiliaria: {
|
||||
rut: 0,
|
||||
razon: ''
|
||||
},
|
||||
banco: {
|
||||
id: 0,
|
||||
nombre: ''
|
||||
}
|
||||
},
|
||||
get() {
|
||||
return {
|
||||
bancos: inmobiliaria_rut => {
|
||||
const url = '{{$urls->api}}/inmobiliaria/' + inmobiliaria_rut + '/cuentas'
|
||||
return fetchAPI(url).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (json.cuentas.length === 0) {
|
||||
return
|
||||
}
|
||||
$(this.ids.forms.add.bancos).dropdown('change values', json.cuentas.map(cuenta => {
|
||||
return {value: cuenta.banco.id, text: cuenta.banco.nombre, name: cuenta.banco.nombre}
|
||||
})).dropdown('refresh')
|
||||
})
|
||||
})
|
||||
},
|
||||
}
|
||||
},
|
||||
add() {
|
||||
return {
|
||||
deposito: form => {
|
||||
const url = '{{$urls->api}}/contabilidad/depositos/add'
|
||||
const body = new FormData(form)
|
||||
const inicio = $(this.ids.forms.add.inicio).calendar('get date')
|
||||
const termino = $(this.ids.forms.add.termino).calendar('get date')
|
||||
body.set('inicio', [inicio.getFullYear(), inicio.getMonth()+1, inicio.getDate()].join('-'))
|
||||
body.set('termino', [termino.getFullYear(), termino.getMonth()+1, termino.getDate()].join('-'))
|
||||
|
||||
return fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (json.status) {
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
setup(ids) {
|
||||
this.ids = ids
|
||||
|
||||
$(this.ids.buttons.add).click(event => {
|
||||
$(this.ids.modals.add).modal('show')
|
||||
})
|
||||
$(this.ids.modals.add).modal({
|
||||
onApprove: $element => {
|
||||
$(this.ids.forms.add.base).submit()
|
||||
}
|
||||
})
|
||||
$(this.ids.forms.add.base).submit(event => {
|
||||
event.preventDefault()
|
||||
this.add().deposito(event.currentTarget)
|
||||
return false
|
||||
})
|
||||
$(this.ids.forms.add.inmobiliarias).dropdown({
|
||||
fireOnInit: true,
|
||||
onChange: (value, text, $choice) => {
|
||||
this.data.inmobiliaria.rut = value
|
||||
this.data.inmobiliaria.razon = text
|
||||
this.get().bancos(value)
|
||||
}
|
||||
})
|
||||
$(this.ids.forms.add.banco).dropdown({
|
||||
fireOnInit: true,
|
||||
onChange: (value, text, $choice) => {
|
||||
this.data.banco.id = value
|
||||
this.data.banco.nombre = text
|
||||
}
|
||||
})
|
||||
$(this.ids.forms.add.inicio).calendar(calendar_date_options)
|
||||
$(this.ids.forms.add.termino).calendar(calendar_date_options)
|
||||
|
||||
$(this.ids.table).dataTable({
|
||||
columnDefs: [{target: 7, visible: false, searchable: false}],
|
||||
order: [[7, 'desc'], [0, 'asc']]
|
||||
})
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
depositos.setup({
|
||||
table: '#depositos',
|
||||
buttons: {
|
||||
add: '#add_button'
|
||||
},
|
||||
modals: {
|
||||
add: '#add_modal'
|
||||
},
|
||||
forms: {
|
||||
add: {
|
||||
base: '#add_form',
|
||||
inmobiliarias: '#inmobiliaria',
|
||||
bancos: '#banco',
|
||||
inicio: '#inicio',
|
||||
termino: '#termino'
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
156
app/resources/views/contabilidad/informes/tesoreria.blade.php
Normal file
156
app/resources/views/contabilidad/informes/tesoreria.blade.php
Normal file
@ -0,0 +1,156 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h1 class="ui centered header">Informe de Tesorería</h1>
|
||||
<h4 class="ui centered sub header">{{$fecha->format('d M Y')}}</h4>
|
||||
<div class="ui grid">
|
||||
<div class="three wide column">
|
||||
<a href="/contabilidad/informes/xlsx/tesoreria/{{$fecha->format('Y-m-d')}}" target="_blank" style="color: inherit;">
|
||||
<div class="ui inverted green center aligned segment">
|
||||
Descargar en Excel <i class="file excel icon"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui grid">
|
||||
<div class="four wide column">
|
||||
<table class="ui collapsing simple table">
|
||||
<tr>
|
||||
<td>Informe anterior</td>
|
||||
<td>{{$anterior->format('d/m/Y')}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Informe actual</td>
|
||||
<td>{{$fecha->format('d/m/Y')}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="column"></div>
|
||||
<div class="four wide column">
|
||||
<table class="ui collapsing simple table">
|
||||
<tr>
|
||||
<td>Valor UF</td>
|
||||
<td class="right aligned">{{$format->pesos($UF->get($fecha), 2)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Valor Dólar</td>
|
||||
<td class="right aligned">{{$format->pesos($USD->get($fecha), 2)}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<table class="ui striped table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>EMPRESA</th>
|
||||
<th>Banco</th>
|
||||
<th>Cuenta</th>
|
||||
<th class="right aligned">Saldo Anterior</th>
|
||||
<th class="right aligned">Saldo Actual</th>
|
||||
<th class="right aligned">Diferencia</th>
|
||||
<th class="right aligned">FFMM</th>
|
||||
<th class="right aligned">DAP</th>
|
||||
<th class="right aligned">Saldo Empresa</th>
|
||||
<th class="right aligned">Total Cuentas</th>
|
||||
<th class="right aligned">Total FFMM</th>
|
||||
<th class="right aligned">Total DAP</th>
|
||||
<th class="right aligned">Caja Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($informes['inmobiliarias'] as $inmobiliaria_rut => $informe)
|
||||
@foreach ($informe->cuentas as $i => $cuenta)
|
||||
<tr>
|
||||
@if ($i === 0)
|
||||
<td rowspan="{{count($informe->cuentas)}}">{{$informe->inmobiliaria->razon}}</td>
|
||||
@endif
|
||||
<td>{{$cuenta->banco}}</td>
|
||||
<td>{{$cuenta->numero}}</td>
|
||||
<td class="right aligned">{{$format->pesos($cuenta->anterior)}}</td>
|
||||
<td class="right aligned">{{$format->pesos($cuenta->actual)}}</td>
|
||||
<td class="right aligned">{{$format->pesos($cuenta->diferencia())}}</td>
|
||||
<td class="right aligned">{{$format->pesos($cuenta->ffmm)}}</td>
|
||||
<td class="right aligned">{{$format->pesos($cuenta->deposito)}}</td>
|
||||
<td class="right aligned">{{$format->pesos($cuenta->saldo())}}</td>
|
||||
@if ($i === 0)
|
||||
<td class="right aligned" rowspan="{{count($informe->cuentas)}}">{{$format->pesos($informe->total())}}</td>
|
||||
<td class="right aligned" rowspan="{{count($informe->cuentas)}}">{{$format->pesos($informe->ffmm())}}</td>
|
||||
<td class="right aligned" rowspan="{{count($informe->cuentas)}}">{{$format->pesos($informe->deposito())}}</td>
|
||||
<td class="right aligned" rowspan="{{count($informe->cuentas)}}">{{$format->pesos($informe->caja())}}</td>
|
||||
@endif
|
||||
</tr>
|
||||
@endforeach
|
||||
@endforeach
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="bold">
|
||||
<th colspan="3">TOTAL</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->anterior)}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->actual)}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->diferencia())}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->ffmm)}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->deposito)}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->saldo())}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->cuentas())}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->ffmms())}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->depositos())}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->caja())}}</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<table class="ui table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>EMPRESA</th>
|
||||
<th class="right aligned">INGRESOS</th>
|
||||
<th class="right aligned">EGRESOS</th>
|
||||
<th>FECHA</th>
|
||||
<th>BANCO</th>
|
||||
<th>DESCRIPCIÓN</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($informes['movimientos'] as $tipo => $movimientos)
|
||||
@if ($tipo === 'capital dap')
|
||||
@if (count($movimientos['ingresos']) === 0 and count($movimientos['egresos']) === 0)
|
||||
@continue
|
||||
@endif
|
||||
<tr class="grey">
|
||||
<td colspan="6">{{strtoupper($tipo)}}</td>
|
||||
</tr>
|
||||
@foreach ($movimientos as $ms)
|
||||
@foreach ($ms as $movimiento)
|
||||
<tr>
|
||||
<td >{{$movimiento->cuenta->inmobiliaria->razon}}</td>
|
||||
<td class="right aligned">{{$format->pesos($movimiento->abono)}}</td>
|
||||
<td class="right aligned">{{$format->pesos($movimiento->cargo)}}</td>
|
||||
<td>{{$movimiento->fecha->format('d/m/Y')}}</td>
|
||||
<td>{{$movimiento->cuenta->banco->nombre}}</td>
|
||||
<td>{{$movimiento->glosa}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@endforeach
|
||||
@continue
|
||||
@endif
|
||||
@if (count($movimientos) === 0)
|
||||
@continue
|
||||
@endif
|
||||
<tr class="grey">
|
||||
<td colspan="6">{{strtoupper($tipo)}}</td>
|
||||
</tr>
|
||||
@foreach ($movimientos as $movimiento)
|
||||
<tr>
|
||||
<td >{{$movimiento->cuenta->inmobiliaria->razon}}</td>
|
||||
<td class="right aligned">{{$format->pesos($movimiento->abono)}}</td>
|
||||
<td class="red right aligned">{{$format->pesos($movimiento->cargo)}}</td>
|
||||
<td>{{$movimiento->fecha->format('d/m/Y')}}</td>
|
||||
<td>{{$movimiento->cuenta->banco->nombre}}</td>
|
||||
<td>{{$movimiento->glosa}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
@endsection
|
@ -28,7 +28,7 @@
|
||||
return {
|
||||
hoy: () => {
|
||||
const span = $('#cuotas_hoy')
|
||||
return fetch('{{$urls->api}}/ventas/cuotas/hoy').then(response => {
|
||||
return fetchAPI('{{$urls->api}}/ventas/cuotas/hoy').then(response => {
|
||||
span.html('')
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
@ -48,7 +48,7 @@
|
||||
},
|
||||
pendiente: () => {
|
||||
const span = $('#cuotas_pendientes')
|
||||
return fetch('{{$urls->api}}/ventas/cuotas/pendiente').then(response => {
|
||||
return fetchAPI('{{$urls->api}}/ventas/cuotas/pendiente').then(response => {
|
||||
span.html('')
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
|
@ -13,7 +13,7 @@
|
||||
proyectos: () => {
|
||||
this.draw().loading()
|
||||
const url = '{{$urls->api}}/proyectos/escriturando'
|
||||
return fetch(url).then(response => {
|
||||
return fetchAPI(url).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
@ -38,7 +38,7 @@
|
||||
},
|
||||
unidades: proyecto_id => {
|
||||
const url = '{{$urls->api}}/ventas/unidades/disponibles'
|
||||
return fetch(url, {method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({proyecto_id})}).then(response => {
|
||||
return fetchAPI(url, {method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({proyecto_id})}).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
@ -49,7 +49,7 @@
|
||||
},
|
||||
promesas: proyecto_id => {
|
||||
const url = '{{$urls->api}}/ventas/estados/firmar'
|
||||
return fetch(url, {method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({proyecto_id})}).then(response => {
|
||||
return fetchAPI(url, {method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({proyecto_id})}).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
@ -60,7 +60,7 @@
|
||||
},
|
||||
escrituras: proyecto_id => {
|
||||
const url = '{{$urls->api}}/ventas/escrituras/estados';
|
||||
return fetch(url, {method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({proyecto_id})}).then(response => {
|
||||
return fetchAPI(url, {method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({proyecto_id})}).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
list.append(
|
||||
$('<div><div>').addClass('ui inline active loader')
|
||||
)
|
||||
fetch('{{$urls->api}}/ventas/cierres/vigentes').then(response => {
|
||||
fetchAPI('{{$urls->api}}/ventas/cierres/vigentes').then(response => {
|
||||
list.html('')
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
|
@ -10,7 +10,7 @@
|
||||
list.append(
|
||||
$('<div><div>').addClass('ui inline active loader')
|
||||
)
|
||||
return fetch('{{$urls->api}}/ventas/cuotas/vencer').then(response => {
|
||||
return fetchAPI('{{$urls->api}}/ventas/cuotas/vencer').then(response => {
|
||||
list.html('')
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
|
@ -4,7 +4,7 @@
|
||||
@include('layout.body.header.menu.ventas')
|
||||
@include('layout.body.header.menu.proyectos')
|
||||
@include('layout.body.header.menu.inmobiliarias')
|
||||
{{--@include('layout.body.header.menu.contabilidad')--}}
|
||||
@include('layout.body.header.menu.contabilidad')
|
||||
{{--@include('layout.body.header.menu.operadores')--}}
|
||||
{{--@include('layout.body.header.menu.herramientas')--}}
|
||||
<div class="right aligned menu">
|
||||
|
@ -2,7 +2,21 @@
|
||||
Contabilidad
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="menu">
|
||||
<a class="item" href="{{$urls->base}}/contabilidad/pagos/mes">Pagos Mes</a>
|
||||
<a class="item" href="{{$urls->base}}/contabilidad/resumen">Resumen</a>
|
||||
<div class="item">
|
||||
<i class="dropdown icon"></i>
|
||||
Informes
|
||||
<div class="menu">
|
||||
<a class="item" href="{{$urls->base}}/contabilidad/informes/tesoreria/{{$hoy->sub(new DateInterval('P1D'))->format('Y-m-d')}}">Tesorería</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<i class="dropdown icon"></i>
|
||||
<a class="text" href="{{$urls->base}}/contabilidad/centros_costos">Centros de Costos</a>
|
||||
<div class="menu">
|
||||
<a class="item" href="{{$urls->base}}/contabilidad/centros_costos/asignar">Asignar en Cartola</a>
|
||||
</div>
|
||||
</div>
|
||||
<a class="item" href="{{$urls->base}}/contabilidad/cartolas/diaria">Cartola Diaria</a>
|
||||
<a class="item" href="{{$urls->base}}/contabilidad/depositos">Depósitos a Plazo</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -8,7 +8,7 @@
|
||||
<div class="menu">
|
||||
<a class="item" href="{{$urls->base}}/ventas/precios">Precios</a>
|
||||
<a class="item" href="{{$urls->base}}/ventas/cierres">Cierres</a>
|
||||
<a class="item" href="{{$urls->base}}/ventas">Ventas</a>
|
||||
<a class="item" href="{{$urls->base}}/ventas/">Ventas</a>
|
||||
<div class="item">
|
||||
Cuotas
|
||||
<i class="dropdown icon"></i>
|
||||
|
@ -1,7 +1,26 @@
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js" integrity="sha512-3gJwYpMe3QewGELv8k/BX9vcqhryRdzRMxVfq6ngyWXwo03GFEzjsUm8Q7RZcHPHksttq7/GFoxjCVUjkjvPdw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.9.2/semantic.min.js" integrity="sha512-5cguXwRllb+6bcc2pogwIeQmQPXEzn2ddsqAexIBhh7FO1z5Hkek1J9mrK2+rmZCTU6b6pERxI7acnp1MpAg4Q==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.9.3/semantic.min.js" integrity="sha512-gnoBksrDbaMnlE0rhhkcx3iwzvgBGz6mOEj4/Y5ZY09n55dYddx6+WYc72A55qEesV8VX2iMomteIwobeGK1BQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
function fetchAPI(url, options=null) {
|
||||
if (options === null) {
|
||||
options = {}
|
||||
}
|
||||
if (!Object.hasOwn(options, 'headers')) {
|
||||
options['headers'] = {}
|
||||
}
|
||||
if (!Object.hasOwn(options['headers'], 'Authorization')) {
|
||||
options['headers']['Authorization'] = 'Bearer {{md5($API_KEY)}}'
|
||||
}
|
||||
return fetch(url, options).then(response => {
|
||||
if (response.ok) {
|
||||
return response
|
||||
}
|
||||
throw new Error(JSON.stringify({code: response.status, message: response.statusText, url}))
|
||||
}).catch(error => {
|
||||
console.error(error)
|
||||
})
|
||||
}
|
||||
const calendar_date_options = {
|
||||
type: 'date',
|
||||
firstDayOfWeek: 1,
|
||||
|
@ -1,4 +1,5 @@
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript" src="https://cdn.datatables.net/1.13.5/js/jquery.dataTables.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdn.datatables.net/1.13.5/js/dataTables.semanticui.min.js"></script>
|
||||
{{--<script type="text/javascript" src="https://cdn.datatables.net/2.0.1/js/jquery.dataTables.min.js"></script>--}}
|
||||
<script type="text/javascript" src="https://cdn.datatables.net/2.0.1/js/dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/2.0.1/js/dataTables.semanticui.min.js"></script>
|
||||
@endpush
|
||||
|
@ -0,0 +1,9 @@
|
||||
@push('page_scripts')
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.9/pdfmake.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/3.0.0/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/3.0.0/js/buttons.semanticui.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/3.0.0/js/buttons.colVis.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/3.0.0/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/3.0.0/js/buttons.print.min.js"></script>
|
||||
@endpush
|
@ -1,3 +1,3 @@
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.9.2/semantic.min.css" integrity="sha512-n//BDM4vMPvyca4bJjZPDh7hlqsQ7hqbP9RH18GF2hTXBY5amBwM2501M0GPiwCU/v9Tor2m13GOTFjk00tkQA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.9.3/semantic.min.css" integrity="sha512-3quBdRGJyLy79hzhDDcBzANW+mVqPctrGCfIPosHQtMKb3rKsCxfyslzwlz2wj1dT8A7UX+sEvDjaUv+WExQrA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
|
||||
@stack('page_styles')
|
||||
|
@ -1,3 +1,3 @@
|
||||
@push('page_styles')
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.5/css/dataTables.semanticui.min.css" />
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/2.0.1/css/dataTables.semanticui.min.css" />
|
||||
@endpush
|
||||
|
@ -0,0 +1,3 @@
|
||||
@push('page_styles')
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/3.0.0/css/buttons.semanticui.min.css" />
|
||||
@endpush
|
@ -8,7 +8,7 @@
|
||||
<input type="text" id="name" name="name" />
|
||||
</div>
|
||||
<div class="six wide field">
|
||||
<label for="password">Clave</label>
|
||||
<label for="password">Contraseña</label>
|
||||
<input type="password" id="password" name="password" />
|
||||
</div>
|
||||
<button class="ui button" id="enter">Ingresar</button>
|
||||
@ -34,11 +34,11 @@
|
||||
}
|
||||
}).then(data => {
|
||||
if (data.login === true) {
|
||||
@if(isset($redirect_uri))
|
||||
window.location = '{{$redirect_uri}}'
|
||||
@else
|
||||
window.location = '{{$urls->base}}'
|
||||
@endif
|
||||
@if(isset($redirect_uri))
|
||||
window.location = '{{$redirect_uri}}'
|
||||
@else
|
||||
window.location = '{{$urls->base}}'
|
||||
@endif
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -51,7 +51,7 @@
|
||||
get() {
|
||||
return {
|
||||
start: () => {
|
||||
return fetch('{{$urls->api}}/proyecto/' + this.id + '/inicio').then(response => {
|
||||
return fetchAPI('{{$urls->api}}/proyecto/' + this.id + '/inicio').then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
@ -60,7 +60,7 @@
|
||||
})
|
||||
},
|
||||
current: () => {
|
||||
return fetch('{{$urls->api}}/proyecto/' + this.id + '/estado').then(response => {
|
||||
return fetchAPI('{{$urls->api}}/proyecto/' + this.id + '/estado').then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
@ -69,7 +69,7 @@
|
||||
})
|
||||
},
|
||||
recepcion: () => {
|
||||
return fetch('{{$urls->api}}/proyecto/' + this.id + '/recepcion').then(response => {
|
||||
return fetchAPI('{{$urls->api}}/proyecto/' + this.id + '/recepcion').then(response => {
|
||||
if (response.ok) {
|
||||
if (response.status === 204) {
|
||||
return null
|
||||
|
@ -42,6 +42,26 @@
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Terreno</td>
|
||||
<td>
|
||||
<table class="ui very basic striped table">
|
||||
<tr>
|
||||
<td>
|
||||
{{$format->number($proyecto->terreno->superficie, 2)}}m²
|
||||
</td>
|
||||
<td>
|
||||
{{$format->pesos($proyecto->terreno->valor)}} ({{$proyecto->terreno->fecha?->format('d-m-Y')}})
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{$urls->base}}/proyecto/{{$proyecto->id}}/terreno">
|
||||
<i class="edit icon"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Superficies</td>
|
||||
<td>
|
||||
@ -134,7 +154,7 @@
|
||||
return {
|
||||
superficies: () => {
|
||||
const url = '{{$urls->api}}/proyecto/{{$proyecto->id}}/superficies/vendible'
|
||||
return fetch(url).then(response => {
|
||||
return fetchAPI(url).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
@ -197,7 +217,7 @@
|
||||
data: {},
|
||||
get: function() {
|
||||
const url = '{{$urls->api}}/proyecto/{{$proyecto->id}}/unidades'
|
||||
return fetch(url).then(response => {
|
||||
return fetchAPI(url).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
@ -273,7 +293,7 @@
|
||||
return {
|
||||
ventas: () => {
|
||||
const url = '{{$urls->api}}/ventas'
|
||||
return fetch(url, {method: 'post', headers: {'Content-Type': 'application/json'},
|
||||
return fetchAPI(url, {method: 'post', headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({proyecto_id: '{{$proyecto->id}}'})}).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
@ -294,7 +314,7 @@
|
||||
},
|
||||
stock: () => {
|
||||
const url = '{{$urls->api}}/proyecto/{{$proyecto->id}}/unidades/disponibles'
|
||||
return fetch(url).then(response => {
|
||||
return fetchAPI(url).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
@ -315,7 +335,7 @@
|
||||
},
|
||||
venta: venta_id => {
|
||||
const url = '{{$urls->api}}/venta/' + venta_id
|
||||
return fetch(url).then(response => {
|
||||
return fetchAPI(url).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
@ -325,7 +345,7 @@
|
||||
},
|
||||
precio: unidad_id => {
|
||||
const url = '{{$urls->api}}/ventas/precio/unidad/' + unidad_id
|
||||
return fetch(url).then(response => {
|
||||
return fetchAPI(url).then(response => {
|
||||
if (response.ok) {
|
||||
if (response.status === 204) {
|
||||
return null
|
||||
|
5
app/resources/views/proyectos/terreno/edit.blade.php
Normal file
5
app/resources/views/proyectos/terreno/edit.blade.php
Normal file
@ -0,0 +1,5 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@push('page_content')
|
||||
|
||||
@endpush
|
@ -203,7 +203,7 @@
|
||||
return {
|
||||
tipos: proyecto_id => {
|
||||
const url = '{{$urls->api}}/proyecto/' + proyecto_id + '/unidades/tipos'
|
||||
return fetch(url).then(response => {
|
||||
return fetchAPI(url).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
@ -224,6 +224,7 @@
|
||||
const proyecto_id = element.data('proyecto')
|
||||
this.get().tipos(proyecto_id)
|
||||
})
|
||||
$('#data').hide()
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user