Compare commits
10 Commits
6ab24c8961
...
0cd357b6cb
Author | SHA1 | Date | |
---|---|---|---|
0cd357b6cb | |||
fa15da1ee2 | |||
59825259b6 | |||
ef30ae67d2 | |||
38383f5295 | |||
43cd955061 | |||
1a7b10ce3c | |||
d9d5a15376 | |||
b7fc538e78 | |||
be33305cf1 |
@ -1,2 +0,0 @@
|
||||
ADMINER_DESIGN=dracula
|
||||
ADMINER_PLUGINS=dump-json
|
5
.db.env
@ -1,5 +0,0 @@
|
||||
MYSQL_DATABASE=incoviba
|
||||
MYSQL_PASSWORD=5GQYFvRjVw2A4KcD
|
||||
MYSQL_ROOT_PASSWORD=password
|
||||
MYSQL_USER=incoviba
|
||||
MYSQL_PORT=3307
|
@ -1,3 +1,3 @@
|
||||
COMPOSE_PROFILES=
|
||||
BASE_URL=
|
||||
MYSQL_HOST=
|
||||
COMPOSE_PROFILES=app,db
|
||||
APP_PATH=./app
|
||||
APP_PORT=8080
|
||||
|
@ -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 \
|
||||
RUN apt-get update && apt-get install -y 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
|
||||
@ -8,6 +8,8 @@ RUN docker-php-ext-install pdo pdo_mysql zip intl gd bcmath
|
||||
RUN pecl install xdebug-3.1.3 \
|
||||
&& docker-php-ext-enable xdebug
|
||||
|
||||
COPY ./php-errors.ini /usr/local/etc/php/conf.d/docker-php-errors.ini
|
||||
|
||||
COPY --from=composer /usr/bin/composer /usr/bin/composer
|
||||
|
||||
WORKDIR /code
|
||||
|
@ -1,9 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>View</title>
|
||||
</head>
|
||||
<body>
|
||||
View test
|
||||
</body>
|
||||
</html>
|
@ -1,12 +0,0 @@
|
||||
<?php
|
||||
use App\Helper\Format as F;
|
||||
class Format
|
||||
{
|
||||
public static function __callstatic($name, $params)
|
||||
{
|
||||
if (method_exists(F, $name)) {
|
||||
return F::$name($params);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
9
app/common/Alias/View.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Alias;
|
||||
|
||||
use Illuminate\Events\Dispatcher;
|
||||
use Slim\Views\Blade;
|
||||
|
||||
class View extends Blade
|
||||
{
|
||||
}
|
14
app/common/Define/Connection.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Define;
|
||||
|
||||
use PDO;
|
||||
use PDOStatement;
|
||||
|
||||
interface Connection
|
||||
{
|
||||
public function connect(): Connection;
|
||||
public function query(string $query): PDOStatement;
|
||||
public function prepare(string $query): PDOStatement;
|
||||
public function execute(string $query, ?array $data = null): PDOStatement;
|
||||
public function getPDO(): PDO;
|
||||
}
|
8
app/common/Define/Database.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Define;
|
||||
|
||||
interface Database
|
||||
{
|
||||
public function getDSN(): string;
|
||||
public function needsUser(): bool;
|
||||
}
|
8
app/common/Define/Model.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Define;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
interface Model extends JsonSerializable
|
||||
{
|
||||
}
|
9
app/common/Define/Money/Provider.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Define\Money;
|
||||
|
||||
use DateTimeInterface;
|
||||
|
||||
interface Provider
|
||||
{
|
||||
public function get(string $money_symbol, DateTimeInterface $dateTime): float;
|
||||
}
|
11
app/common/Define/Repository.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Define;
|
||||
|
||||
interface Repository
|
||||
{
|
||||
public function create(?array $data = null): Model;
|
||||
public function save(Model $model): Model;
|
||||
public function load(array $data_row): Model;
|
||||
public function edit(Model $model, array $new_data): Model;
|
||||
public function remove(Model $model): void;
|
||||
}
|
9
app/common/Define/Repository/Factory.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Define\Repository;
|
||||
|
||||
interface Factory
|
||||
{
|
||||
public function setCallable(callable $callable): Factory;
|
||||
public function setArgs(array $args): Factory;
|
||||
public function run(): mixed;
|
||||
}
|
15
app/common/Define/Repository/Mapper.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Define\Repository;
|
||||
|
||||
interface Mapper
|
||||
{
|
||||
public function setProperty(string $property): Mapper;
|
||||
public function setFunction(callable $function): Mapper;
|
||||
public function setFactory(Factory $factory): Mapper;
|
||||
public function setDefault(mixed $value): Mapper;
|
||||
|
||||
public function hasProperty(): bool;
|
||||
public function hasFunction(): bool;
|
||||
public function hasFactory(): bool;
|
||||
public function hasDefault(): bool;
|
||||
}
|
10
app/common/Define/Repository/MapperParser.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Define\Repository;
|
||||
|
||||
interface MapperParser
|
||||
{
|
||||
public function register(string $column, ?Mapper $mapper = null): MapperParser;
|
||||
public function getColumns(): array;
|
||||
public function hasMapper(string $column): bool;
|
||||
public function getMapper(string $column): Mapper;
|
||||
}
|
32
app/common/Ideal/Model.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Ideal;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
|
||||
abstract class Model implements Define\Model
|
||||
{
|
||||
public int $id;
|
||||
|
||||
protected array $factories;
|
||||
|
||||
public function addFactory(string $property, Define\Repository\Factory $factory): Model
|
||||
{
|
||||
$this->factories[$property] = $factory;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function runFactory(string $property): mixed
|
||||
{
|
||||
if (isset($this->factories[$property])) {
|
||||
return $this->factories[$property]->run();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return [
|
||||
'id' => $this->id
|
||||
];
|
||||
}
|
||||
}
|
149
app/common/Ideal/Repository.php
Normal file
@ -0,0 +1,149 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Ideal;
|
||||
|
||||
use PDO;
|
||||
use ReflectionProperty;
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
|
||||
abstract class Repository implements Define\Repository
|
||||
{
|
||||
public function __construct(protected Define\Connection $connection) {}
|
||||
|
||||
protected string $table;
|
||||
public function getTable(): string
|
||||
{
|
||||
return $this->table;
|
||||
}
|
||||
public function setTable(string $table): Repository
|
||||
{
|
||||
$this->table = $table;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function load(array $data_row): Define\Model
|
||||
{
|
||||
$model = $this->create($data_row);
|
||||
$model->{$this->getKey()} = $data_row[$this->getKey()];
|
||||
return $model;
|
||||
}
|
||||
|
||||
public function remove(Define\Model $model): void
|
||||
{
|
||||
$query = "DELETE FROM `{$this->getTable()}` WHERE `{$this->getKey()}` = ?";
|
||||
$this->connection->execute($query, [$model->getId()]);
|
||||
}
|
||||
|
||||
public function fetchById(int $id): Define\Model
|
||||
{
|
||||
$query = "SELECT * FROM `{$this->getTable()}` WHERE `{$this->getKey()}` = ?";
|
||||
return $this->fetchOne($query, [$id]);
|
||||
}
|
||||
public function fetchAll(): array
|
||||
{
|
||||
$query = "SELECT * FROM `{$this->getTable()}`";
|
||||
return $this->fetchMany($query);
|
||||
}
|
||||
|
||||
protected function getKey(): string
|
||||
{
|
||||
return 'id';
|
||||
}
|
||||
protected function parseData(Define\Model $model, ?array $data, Implement\Repository\MapperParser $data_map): Define\Model
|
||||
{
|
||||
if ($data === null) {
|
||||
return $model;
|
||||
}
|
||||
foreach ($data_map->getColumns() as $column) {
|
||||
if (!$data_map->hasMapper($column)) {
|
||||
$this->parsePlainColumn($model, $column, $data);
|
||||
continue;
|
||||
}
|
||||
|
||||
$settings = $data_map->getMapper($column);
|
||||
if ($settings->parse($model, $column, $data)) {
|
||||
continue;
|
||||
}
|
||||
$property = $column;
|
||||
if ($settings->hasProperty()) {
|
||||
$property = $settings->property;
|
||||
}
|
||||
$this->setDefault($model, $property);
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
protected function parsePlainColumn(Define\Model &$model, string $column, ?array $data): void
|
||||
{
|
||||
$property = $column;
|
||||
if (isset($data[$column])) {
|
||||
$model->{$property} = $data[$column];
|
||||
return;
|
||||
}
|
||||
$this->setDefault($model, $property);
|
||||
}
|
||||
protected function setDefault(Define\Model &$model, string $property): void
|
||||
{
|
||||
$prop = new ReflectionProperty($model, $property);
|
||||
$type = $prop->getType()->getName();
|
||||
$value = match ($type) {
|
||||
'int' => 0,
|
||||
'float' => 0.0,
|
||||
'string' => '',
|
||||
default => null,
|
||||
};
|
||||
$model->{$property} = $value;
|
||||
}
|
||||
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)";
|
||||
$this->connection->execute($query, $values);
|
||||
return $this->connection->getPDO()->lastInsertId();
|
||||
}
|
||||
protected function update(Define\Model $model, array $columns, array $data): Define\Model
|
||||
{
|
||||
$changes = [];
|
||||
$values = [];
|
||||
foreach ($columns as $column) {
|
||||
if (isset($data[$column])) {
|
||||
$changes []= $column;
|
||||
$values []= $data[$column];
|
||||
}
|
||||
}
|
||||
|
||||
if (count($changes) === 0) {
|
||||
return $model;
|
||||
}
|
||||
$columns_string = implode(', ', array_map(function($property) {return "`{$property}` = ?";}, $changes));
|
||||
$query = "UPDATE `{$this->getTable()}` SET {$columns_string} WHERE `{$this->getKey()}` = ?";
|
||||
$values []= $model->{$this->getKey()};
|
||||
$this->connection->execute($query, $values);
|
||||
return $this->fetchById($model->{$this->getKey()});
|
||||
}
|
||||
protected function fetchOne(string $query, ?array $data = null): Define\Model
|
||||
{
|
||||
$result = $this->connection->execute($query, $data)->fetch(PDO::FETCH_ASSOC);
|
||||
if ($result === false) {
|
||||
throw new EmptyResult($query);
|
||||
}
|
||||
return $this->load($result);
|
||||
}
|
||||
protected function fetchMany(string $query, ?array $data = null): array
|
||||
{
|
||||
$results = $this->connection->execute($query, $data)->fetchAll(PDO::FETCH_ASSOC);
|
||||
if ($results === false) {
|
||||
throw new EmptyResult($query);
|
||||
}
|
||||
return array_map([$this, 'load'], $results);
|
||||
}
|
||||
protected function fetchAsArray(string $query, ?array $data = null): array
|
||||
{
|
||||
$results = $this->connection->execute($query, $data)->fetchAll(PDO::FETCH_ASSOC);
|
||||
if ($results === false) {
|
||||
throw new EmptyResult($query);
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
}
|
61
app/common/Implement/Connection.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement;
|
||||
|
||||
use PDO;
|
||||
use PDOStatement;
|
||||
use PDOException;
|
||||
use Incoviba\Common\Define;
|
||||
|
||||
class Connection implements Define\Connection
|
||||
{
|
||||
public function __construct(protected Define\Database $database) {}
|
||||
|
||||
protected PDO $connection;
|
||||
public function connect(): Define\Connection
|
||||
{
|
||||
if (!isset($this->connection)) {
|
||||
if ($this->database->needsUser()) {
|
||||
$this->connection = new PDO($this->database->getDSN(), $this->database->user, $this->database->password);
|
||||
} else {
|
||||
$this->connection = new PDO($this->database->getDSN());
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function getPDO(): PDO
|
||||
{
|
||||
$this->connect();
|
||||
return $this->connection;
|
||||
}
|
||||
|
||||
public function query(string $query): PDOStatement
|
||||
{
|
||||
$this->connect();
|
||||
$statement = $this->connection->query($query);
|
||||
if ($statement === false) {
|
||||
throw new PDOException("Query failed: '{$query}'");
|
||||
}
|
||||
return $statement;
|
||||
}
|
||||
public function prepare(string $query): PDOStatement
|
||||
{
|
||||
$this->connect();
|
||||
$statement = $this->connection->prepare($query);
|
||||
if ($statement === false) {
|
||||
throw new PDOException("Query failed: '{$query}'");
|
||||
}
|
||||
return $statement;
|
||||
}
|
||||
public function execute(string $query, ?array $data = null): PDOStatement
|
||||
{
|
||||
if ($data === null) {
|
||||
return $this->query($query);
|
||||
}
|
||||
$statement = $this->prepare($query);
|
||||
$status = $statement->execute($data);
|
||||
if ($status === false) {
|
||||
throw new PDOException("Query could not be executed: '{$query}'");
|
||||
}
|
||||
return $statement;
|
||||
}
|
||||
}
|
24
app/common/Implement/Database/MySQL.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Database;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
|
||||
class MySQL implements Define\Database
|
||||
{
|
||||
public function __construct(public string $host, public string $name, public string $user, public string $password) {}
|
||||
|
||||
public int $port = 3306;
|
||||
|
||||
public function getDSN(): string
|
||||
{
|
||||
$dsn = "mysql:host={$this->host};dbname={$this->name}";
|
||||
if ($this->port !== 3306) {
|
||||
$dsn .= ";port={$this->port}";
|
||||
}
|
||||
return $dsn;
|
||||
}
|
||||
public function needsUser(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
15
app/common/Implement/Exception/EmptyResponse.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Exception;
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
class EmptyResponse extends Exception
|
||||
{
|
||||
public function __construct(string $uri = "", ?Throwable $previous = null)
|
||||
{
|
||||
$message = "Empty Response from {$uri}";
|
||||
$code = 800;
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
15
app/common/Implement/Exception/EmptyResult.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Exception;
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
class EmptyResult extends Exception
|
||||
{
|
||||
public function __construct(string $query, ?Throwable $previous = null)
|
||||
{
|
||||
$message = "Empty results for {$query}";
|
||||
$code = 700;
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
27
app/common/Implement/Repository/Factory.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Repository;
|
||||
|
||||
use Closure;
|
||||
use Incoviba\Common\Define;
|
||||
|
||||
class Factory implements Define\Repository\Factory
|
||||
{
|
||||
public Closure $callable;
|
||||
public array $args;
|
||||
|
||||
public function setCallable(callable $callable): Define\Repository\Factory
|
||||
{
|
||||
$this->callable = $callable(...);
|
||||
return $this;
|
||||
}
|
||||
public function setArgs(array $args): Define\Repository\Factory
|
||||
{
|
||||
$this->args = $args;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function run(): mixed
|
||||
{
|
||||
return call_user_func_array($this->callable, $this->args);
|
||||
}
|
||||
}
|
76
app/common/Implement/Repository/Mapper.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Repository;
|
||||
|
||||
use Closure;
|
||||
use Incoviba\Common\Define;
|
||||
|
||||
class Mapper implements Define\Repository\Mapper
|
||||
{
|
||||
public string $property;
|
||||
public Closure $function;
|
||||
public Define\Repository\Factory $factory;
|
||||
public mixed $default;
|
||||
|
||||
public function setProperty(string $property): Define\Repository\Mapper
|
||||
{
|
||||
$this->property = $property;
|
||||
return $this;
|
||||
}
|
||||
public function setFunction(callable $function): Define\Repository\Mapper
|
||||
{
|
||||
$this->function = $function(...);
|
||||
return $this;
|
||||
}
|
||||
public function setFactory(Define\Repository\Factory $factory): Define\Repository\Mapper
|
||||
{
|
||||
$this->factory = $factory;
|
||||
return $this;
|
||||
}
|
||||
public function setDefault(mixed $value): Define\Repository\Mapper
|
||||
{
|
||||
$this->default = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function hasProperty(): bool
|
||||
{
|
||||
return isset($this->property);
|
||||
}
|
||||
public function hasFunction(): bool
|
||||
{
|
||||
return isset($this->function);
|
||||
}
|
||||
public function hasFactory(): bool
|
||||
{
|
||||
return isset($this->factory);
|
||||
}
|
||||
public function hasDefault(): bool
|
||||
{
|
||||
return isset($this->default);
|
||||
}
|
||||
|
||||
public function parse(Define\Model &$model, string $column, ?array $data): bool
|
||||
{
|
||||
$property = $column;
|
||||
if ($this->hasProperty()) {
|
||||
$property = $this->property;
|
||||
}
|
||||
if (isset($data[$column])) {
|
||||
if ($this->hasFactory()) {
|
||||
$model->addFactory($property, $this->factory);
|
||||
return true;
|
||||
}
|
||||
$value = $data[$column];
|
||||
if ($this->hasFunction()) {
|
||||
$value = ($this->function)($data);
|
||||
}
|
||||
$model->{$property} = $value;
|
||||
return true;
|
||||
}
|
||||
if ($this->hasDefault()) {
|
||||
$model->{$property} = $this->default;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
18
app/common/Implement/Repository/Mapper/Boolean.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Repository\Mapper;
|
||||
|
||||
use Incoviba\Common\Implement\Repository\Mapper;
|
||||
|
||||
class Boolean extends Mapper
|
||||
{
|
||||
public function __construct(string $column, ?string $property = null, bool $default = false)
|
||||
{
|
||||
$this->setFunction(function($data) use ($column) {
|
||||
return $data[$column] !== 0;
|
||||
});
|
||||
$this->setDefault($default);
|
||||
if ($property !== null) {
|
||||
$this->setProperty($property);
|
||||
}
|
||||
}
|
||||
}
|
18
app/common/Implement/Repository/Mapper/DateTime.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Repository\Mapper;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Incoviba\Common\Implement\Repository\Mapper;
|
||||
|
||||
class DateTime extends Mapper
|
||||
{
|
||||
public function __construct(string $column, ?string $property = null)
|
||||
{
|
||||
$this->setFunction(function($data) use ($column) {
|
||||
return new DateTimeImmutable($data[$column]);
|
||||
});
|
||||
if ($property !== null) {
|
||||
$this->setProperty($property);
|
||||
}
|
||||
}
|
||||
}
|
41
app/common/Implement/Repository/MapperParser.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Repository;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Define\Repository\Mapper;
|
||||
|
||||
class MapperParser implements Define\Repository\MapperParser
|
||||
{
|
||||
public function __construct(?array $columns = null)
|
||||
{
|
||||
if ($columns !== null) {
|
||||
foreach ($columns as $column) {
|
||||
$this->register($column);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected array $maps;
|
||||
|
||||
public function register(string $column, ?Mapper $mapper = null): Define\Repository\MapperParser
|
||||
{
|
||||
if ($mapper !== null) {
|
||||
$this->maps[$column] = $mapper;
|
||||
return $this;
|
||||
}
|
||||
$this->maps[$column] = [];
|
||||
return $this;
|
||||
}
|
||||
public function getColumns(): array
|
||||
{
|
||||
return array_keys($this->maps);
|
||||
}
|
||||
public function hasMapper(string $column): bool
|
||||
{
|
||||
return is_a($this->maps[$column], Define\Repository\Mapper::class);
|
||||
}
|
||||
public function getMapper(string $column): Mapper
|
||||
{
|
||||
return $this->maps[$column];
|
||||
}
|
||||
}
|
32
app/composer.json
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "incoviba/web",
|
||||
"type": "project",
|
||||
"require": {
|
||||
"berrnd/slim-blade-view": "^1.0",
|
||||
"guzzlehttp/guzzle": "^7.8",
|
||||
"monolog/monolog": "^3.4",
|
||||
"nyholm/psr7": "^1.8",
|
||||
"nyholm/psr7-server": "^1.0",
|
||||
"php-di/php-di": "^7.0",
|
||||
"php-di/slim-bridge": "^3.4",
|
||||
"slim/slim": "^4.11"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^10.2"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Aldarien",
|
||||
"email": "aldarien85@gmail.com"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Incoviba\\Common\\": "common/",
|
||||
"Incoviba\\": "src/"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
15
app/public/index.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
$app = require_once implode(DIRECTORY_SEPARATOR, [
|
||||
dirname(__FILE__, 2),
|
||||
'setup',
|
||||
'app.php'
|
||||
]);
|
||||
try {
|
||||
$app->run();
|
||||
} catch (Error $error) {
|
||||
$app->getContainer()->get(Psr\Log\LoggerInterface::class)->error($error);
|
||||
header('Location: /construccion');
|
||||
} catch (Exception $exception) {
|
||||
$app->getContainer()->get(Psr\Log\LoggerInterface::class)->notice($exception);
|
||||
header('Location: /construccion');
|
||||
}
|
2
app/public/robots.txt
Normal file
@ -0,0 +1,2 @@
|
||||
User-agent: *
|
||||
Disallow: /
|
13
app/resources/routes/01_api.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
$app->group('/api', function($app) {
|
||||
$folder = implode(DIRECTORY_SEPARATOR, [__DIR__, 'api']);
|
||||
if (file_exists($folder)) {
|
||||
$files = new FilesystemIterator($folder);
|
||||
foreach ($files as $file) {
|
||||
if ($file->isDir()) {
|
||||
continue;
|
||||
}
|
||||
include_once $file->getRealPath();
|
||||
}
|
||||
}
|
||||
});
|
6
app/resources/routes/03_proyectos.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Proyectos;
|
||||
|
||||
$app->group('/proyectos', function($app) {
|
||||
$app->get('[/]', Proyectos::class);
|
||||
});
|
35
app/resources/routes/04_ventas.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Ventas;
|
||||
|
||||
$app->group('/ventas', function($app) {
|
||||
$files = new FilesystemIterator(implode(DIRECTORY_SEPARATOR, [__DIR__, 'ventas']));
|
||||
foreach ($files as $file) {
|
||||
if ($file->isDir()) {
|
||||
continue;
|
||||
}
|
||||
include_once $file->getRealPath();
|
||||
}
|
||||
$app->group('/add', function($app) {
|
||||
$app->post('[/]', [Ventas::class, 'doAdd']);
|
||||
$app->get('[/]', [Ventas::class, 'add']);
|
||||
});
|
||||
$app->get('[/]', Ventas::class);
|
||||
});
|
||||
$app->group('/venta/{proyecto_nombre:[A-za-zÑñ\+\ %0-9]+}/{unidad_descripcion:[0-9]+}', function($app) {
|
||||
$app->get('[/]', [Ventas::class, 'showUnidad']);
|
||||
});
|
||||
$app->group('/venta/{venta_id:[0-9]+}', function($app) {
|
||||
$app->group('/propietario', function($app) {
|
||||
$app->get('[/]', [Ventas::class, 'propietario']);
|
||||
});
|
||||
$app->group('/propiedad', function($app) {
|
||||
$app->get('[/]', [Ventas::class, 'propiedad']);
|
||||
});
|
||||
$app->group('/pie', function($app) {
|
||||
$app->group('/cuotas', function($app) {
|
||||
$app->get('[/]', [Ventas::class, 'cuotas']);
|
||||
});
|
||||
});
|
||||
$app->get('/edit[/]', [Ventas::class, 'edit']);
|
||||
$app->get('[/]', [Ventas::class, 'show']);
|
||||
});
|
8
app/resources/routes/98_login.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
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']);
|
5
app/resources/routes/99_base.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Base;
|
||||
|
||||
$app->get('/construccion', [Base::class, 'construccion'])->setName('construccion');
|
||||
$app->get('[/]', Base::class);
|
11
app/resources/routes/api/direcciones.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Direcciones;
|
||||
|
||||
$app->group('/direcciones', function($app) {
|
||||
$app->group('/region/{region_id:[0-9]+}', function($app) {
|
||||
$app->get('/comunas[/]', [Direcciones::class, 'comunas']);
|
||||
});
|
||||
$app->group('/comunas', function($app) {
|
||||
$app->post('/find[/]', [Direcciones::class, 'findComunas']);
|
||||
});
|
||||
});
|
6
app/resources/routes/api/provincias.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Provincias;
|
||||
|
||||
$app->group('/provincia/{provincia_id}', function($app) {
|
||||
$app->get('/comunas', [Provincias::class, 'comunas']);
|
||||
});
|
9
app/resources/routes/api/proyectos.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Proyectos;
|
||||
|
||||
$app->group('/proyectos', function($app) {
|
||||
$app->get('[/]', [Proyectos::class, 'list']);
|
||||
});
|
||||
$app->group('/proyecto/{proyecto_id}', function($app) {
|
||||
$app->get('/unidades[/]', [Proyectos::class, 'unidades']);
|
||||
});
|
7
app/resources/routes/api/regiones.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Regiones;
|
||||
|
||||
//$app->group('/regiones', function($app) {});
|
||||
$app->group('/region/{region_id}', function($app) {
|
||||
$app->get('/provincias[/]', [Regiones::class, 'provincias']);
|
||||
});
|
20
app/resources/routes/api/ventas.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Ventas;
|
||||
|
||||
$app->group('/ventas', function($app) {
|
||||
$folder = implode(DIRECTORY_SEPARATOR, [__DIR__, 'ventas']);
|
||||
if (file_exists($folder)) {
|
||||
$files = new FilesystemIterator($folder);
|
||||
foreach ($files as $file) {
|
||||
if ($file->isDir()) {
|
||||
continue;
|
||||
}
|
||||
include_once $file->getRealPath();
|
||||
}
|
||||
}
|
||||
$app->post('[/]', [Ventas::class, 'proyecto']);
|
||||
});
|
||||
$app->group('/venta/{venta_id}', function($app) {
|
||||
$app->get('/comentarios', [Ventas::class, 'comentarios']);
|
||||
$app->get('[/]', [Ventas::class, 'get']);
|
||||
});
|
6
app/resources/routes/api/ventas/cierres.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Ventas\Cierres;
|
||||
|
||||
$app->group('/cierres', function($app) {
|
||||
$app->post('[/]', [Cierres::class, 'proyecto']);
|
||||
});
|
12
app/resources/routes/api/ventas/pagos.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Ventas\Pagos;
|
||||
|
||||
$app->group('/pagos', function($app) {
|
||||
$app->get('/pendientes', [Pagos::class, 'para_pendientes']);
|
||||
$app->get('/abonar', [Pagos::class, 'para_abonar']);
|
||||
$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']);
|
||||
});
|
11
app/resources/routes/api/ventas/precios.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Ventas\Precios;
|
||||
|
||||
$app->group('/precios', function($app) {
|
||||
$app->post('[/]', [Precios::class, 'proyecto']);
|
||||
});
|
||||
$app->group('/precio', function($app) {
|
||||
$app->group('/unidad/{unidad_id}', function($app) {
|
||||
$app->get('[/]', [Precios::class, 'unidad']);
|
||||
});
|
||||
});
|
6
app/resources/routes/api/ventas/propietarios.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Ventas\Propietarios;
|
||||
|
||||
$app->group('/propietario/{propietario_rut}', function($app) {
|
||||
$app->get('[/]', [Propietarios::class, 'get']);
|
||||
});
|
9
app/resources/routes/ventas/cierres.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Ventas\Cierres;
|
||||
|
||||
$app->group('/cierres', function($app) {
|
||||
$app->get('[/]', Cierres::class);
|
||||
});
|
||||
$app->group('/cierre/{cierre_id}', function($app) {
|
||||
$app->get('[/]', [Cierres::class, 'show']);
|
||||
});
|
12
app/resources/routes/ventas/cuotas.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Ventas\Cuotas;
|
||||
|
||||
$app->group('/cuotas', function($app) {
|
||||
$app->get('/pendientes[/]', [Cuotas::class, 'pendientes']);
|
||||
$app->get('/abonar[/]', [Cuotas::class, 'depositadas']);
|
||||
});
|
||||
$app->group('/cuota', function($app) {
|
||||
$app->post('/depositar[/]', [Cuotas::class, 'depositar']);
|
||||
$app->post('/abonar[/]', [Cuotas::class, 'abonar']);
|
||||
$app->post('/devolver[/]', [Cuotas::class, 'devolver']);
|
||||
});
|
6
app/resources/routes/ventas/pagos.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Ventas\Pagos;
|
||||
|
||||
$app->group('/pagos', function($app) {
|
||||
$app->get('/pendientes', [Pagos::class, 'pendientes']);
|
||||
});
|
13
app/resources/routes/ventas/pies.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Ventas\Pies;
|
||||
use Incoviba\Controller\Ventas\Cuotas;
|
||||
|
||||
$app->group('/pie/{pie_id}', function($app) {
|
||||
$app->group('/cuotas', function($app) {
|
||||
$app->group('/add', function($app) {
|
||||
$app->get('[/]', [Cuotas::class, 'add']);
|
||||
$app->post('[/]', [Cuotas::class, 'doAdd']);
|
||||
});
|
||||
$app->get('[/]', [Pies::class, 'cuotas']);
|
||||
});
|
||||
});
|
6
app/resources/routes/ventas/precios.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Ventas\Precios;
|
||||
|
||||
$app->group('/precios', function($app) {
|
||||
$app->get('[/]', Precios::class);
|
||||
});
|
6
app/resources/routes/ventas/propietarios.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Ventas\Propietarios;
|
||||
|
||||
$app->group('/propietario/{propietario_rut:[0-9]+}', function($app) {
|
||||
$app->get('[/]', [Propietarios::class, 'show']);
|
||||
});
|
14
app/resources/views/construccion.blade.php
Normal file
@ -0,0 +1,14 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_title')
|
||||
Construcción
|
||||
@endsection
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<div class="ui warning message">
|
||||
<i class="hammer icon"></i>
|
||||
Esta parte del sitio está en construcción.
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
7
app/resources/views/guest.blade.php
Normal file
@ -0,0 +1,7 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
Bienvenid@ a Incoviba
|
||||
</div>
|
||||
@endsection
|
26
app/resources/views/home.blade.php
Normal file
@ -0,0 +1,26 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h4 class="ui header">Bienvenid@ {{$user->name}}</h4>
|
||||
<div class="ui basic fitted segment">
|
||||
@if ($cuotas_hoy > 0)
|
||||
Existe{{$cuotas_hoy > 1 ? 'n' : ''}} {{$cuotas_hoy}} deposito{{$cuotas_hoy > 1 ? 's' : ''}} para hoy.
|
||||
<br />
|
||||
@endif
|
||||
@if ($cuotas_pendientes > 0)
|
||||
<a href="{{$urls->base}}/ventas/cuotas/pendientes">
|
||||
Existe{{$cuotas_pendientes > 1 ? 'n' : ''}} {{$cuotas_pendientes}} cuota{{$cuotas_pendientes > 1 ? 's' : ''}} pendiente{{$cuotas_pendientes > 1 ? 's' : ''}}. <i class="right arrow icon"></i>
|
||||
</a>
|
||||
@endif
|
||||
</div>
|
||||
<div class="ui two column grid">
|
||||
<div class="column">
|
||||
@include('home.cuotas_por_vencer')
|
||||
</div>
|
||||
<div class="column">
|
||||
@include('home.cierres_vigentes')
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
24
app/resources/views/home/cierres_vigentes.blade.php
Normal file
@ -0,0 +1,24 @@
|
||||
<h4 class="ui dividing header">Cierres Vigentes</h4>
|
||||
<div class="ui divided list">
|
||||
@foreach($cierres_vigentes as $proyecto => $estados)
|
||||
<div class="item">
|
||||
<div class="ui feed">
|
||||
<div class="date">
|
||||
<strong>{{$proyecto}}</strong> [{{$estados['total']}}]
|
||||
</div>
|
||||
<div class="event">
|
||||
<div class="content">Promesados</div>
|
||||
<div class="meta">{{$estados['promesados']}}</div>
|
||||
</div>
|
||||
<div class="event">
|
||||
<div class="content">Pendientes</div>
|
||||
<div class="meta">{{$estados['pendientes']}}</div>
|
||||
</div>
|
||||
<div class="event">
|
||||
<div class="content">Rechazados</div>
|
||||
<div class="meta">{{$estados['rechazados']}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
22
app/resources/views/home/cuotas_por_vencer.blade.php
Normal file
@ -0,0 +1,22 @@
|
||||
<h4 class="ui dividing header">Cuotas Por Vencer</h4>
|
||||
<div class="ui divided list">
|
||||
@foreach ($cuotas_por_vencer as $date => $proyectos)
|
||||
<div class="item">
|
||||
<div class="ui feed">
|
||||
<div class="date">
|
||||
<strong>{{$format->localDate($date, "EEE. dd 'de' MMMM 'de' yyyy", true)}}</strong>
|
||||
</div>
|
||||
@foreach ($proyectos as $proyecto => $cuotas)
|
||||
<div class="event">
|
||||
<div class="content">
|
||||
<span class="ui small text">
|
||||
{{$proyecto}}
|
||||
</span>
|
||||
</div>
|
||||
<div class="meta">{{$cuotas}}</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
5
app/resources/views/layout/base.blade.php
Normal file
@ -0,0 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
@include('layout.head')
|
||||
@include('layout.body')
|
||||
</html>
|
5
app/resources/views/layout/body.blade.php
Normal file
@ -0,0 +1,5 @@
|
||||
<body>
|
||||
@include('layout.body.header')
|
||||
@yield('page_content')
|
||||
@include('layout.body.footer')
|
||||
</body>
|
4
app/resources/views/layout/body/footer.blade.php
Normal file
@ -0,0 +1,4 @@
|
||||
<footer>
|
||||
|
||||
</footer>
|
||||
@include('layout.body.scripts')
|
7
app/resources/views/layout/body/header.blade.php
Normal file
@ -0,0 +1,7 @@
|
||||
<header class="ui container">
|
||||
<a class="ui medium image" href="{{$urls->base}}">
|
||||
<img src="{{$urls->images}}/logo_cabezal.png" alt="logo" />
|
||||
</a>
|
||||
@include('layout.body.header.menu')
|
||||
</header>
|
||||
<br />
|
17
app/resources/views/layout/body/header/menu.blade.php
Normal file
@ -0,0 +1,17 @@
|
||||
<nav class="ui borderless menu">
|
||||
<a class="item" href="{{$urls->base}}"><img src="{{$urls->images}}/Isotipo 64.png" alt="brand" /></a>
|
||||
@if ($login->isIn())
|
||||
@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.operadores')--}}
|
||||
{{--@include('layout.body.header.menu.herramientas')--}}
|
||||
<div class="right aligned menu">
|
||||
@include('layout.body.header.menu.user')
|
||||
@include('layout.body.header.menu.search')
|
||||
</div>
|
||||
@else
|
||||
@include('layout.body.header.menu.guest')
|
||||
@endif
|
||||
</nav>
|
@ -0,0 +1,8 @@
|
||||
<div class="ui simple dropdown item">
|
||||
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>
|
||||
</div>
|
@ -0,0 +1 @@
|
||||
<a class="item" href="{{$urls->base}}/login">Ingresar</a>
|
@ -0,0 +1,7 @@
|
||||
<div class="ui simple dropdown item">
|
||||
Herramientas
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="menu">
|
||||
<a class="item" href="{{$money_url}}">Valores Monetarios</a>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1 @@
|
||||
<a class="item" href="{{$urls->base}}/inmobiliarias">Inmobiliarias</a>
|
@ -0,0 +1,9 @@
|
||||
<div class="ui simple dropdown item">
|
||||
Operadores
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="menu">
|
||||
<a class="item" href="{{$urls->base}}/operadores/listado">Listado</a>
|
||||
<a class="item" href="{{$urls->base}}/operadores/ventas">Ventas</a>
|
||||
<a class="item" href="{{$urls->base}}/operadores/informe">Informe</a>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,8 @@
|
||||
<div class="ui simple dropdown item">
|
||||
Proyectos
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="menu">
|
||||
<a class="item" href="{{$urls->base}}/proyectos">Listado</a>
|
||||
<a class="item" href="{{$urls->base}}/proyectos/unidades">Unidades</a>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1 @@
|
||||
<a class="item" href="{{$urls->base}}/search"><i class="large search icon"></i></a>
|
31
app/resources/views/layout/body/header/menu/user.blade.php
Normal file
@ -0,0 +1,31 @@
|
||||
<div class="ui simple dropdown item">
|
||||
{{$user->name}}
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="menu">
|
||||
<a class="item" href="{{$urls->base}}/user/password/change">Cambiar Clave</a>
|
||||
@if ($user->isAdmin())
|
||||
<a class="item" href="{{$urls->base}}/admin">Administración</a>
|
||||
@endif
|
||||
<div class="item" onclick="logout()">Salir</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
function logout() {
|
||||
return fetch('{{$urls->base}}/logout').then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
if (data.logout === true) {
|
||||
@if(isset($redirect_uri))
|
||||
window.location = '{{$redirect_uri}}'
|
||||
@else
|
||||
window.location = '{{$urls->base}}'
|
||||
@endif
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
@endpush
|
41
app/resources/views/layout/body/header/menu/ventas.blade.php
Normal file
@ -0,0 +1,41 @@
|
||||
<div class="ui simple dropdown item">
|
||||
Ventas
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="menu">
|
||||
<div class="item">
|
||||
Listados
|
||||
<i class="dropdown icon"></i>
|
||||
<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>
|
||||
<div class="item">
|
||||
Cuotas
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="menu">
|
||||
<a class="item" href="{{$urls->base}}/ventas/cuotas/pendientes">Pendientes</a>
|
||||
<a class="item" href="{{$urls->base}}/ventas/cuotas/abonar">Abonar</a>
|
||||
</div>
|
||||
</div>
|
||||
{{--<a class="item" href="{{$urls->base}}/ventas/pagos/pendientes">Pagos Pendientes</a>--}}
|
||||
{{--<a class="item" href="{{$urls->base}}/ventas/consolidado">Consolidado Ventas</a>--}}
|
||||
</div>
|
||||
</div>
|
||||
{{--<div class="item">
|
||||
Informes
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="menu">
|
||||
<a class="item" href="{{$urls->base}}/informes/ventas">Ventas</a>
|
||||
<a class="item" href="{{$urls->base}}/informes/escrituras">Escrituras</a>
|
||||
<a class="item" href="{{$urls->base}}/informes/entregas/gantt">Gantt de Entregas</a>
|
||||
<a class="item" href="{{$urls->base}}/informes/resciliaciones">Resciliaciones</a>
|
||||
</div>
|
||||
</div>--}}
|
||||
{{--<a class="item" href="{{$urls->base}}/ventas/precios/importar">Importar Precios</a>--}}
|
||||
{{--<a class="item" href="{{$urls->base}}/ventas/cierres/evaluar">Evaluar Cierre</a>--}}
|
||||
<a class="item" href="{{$urls->base}}/ventas/add">
|
||||
Nueva Venta
|
||||
<i class="plus icon"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
22
app/resources/views/layout/body/scripts.blade.php
Normal file
@ -0,0 +1,22 @@
|
||||
<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 type="text/javascript">
|
||||
const calendar_date_options = {
|
||||
type: 'date',
|
||||
firstDayOfWeek: 1,
|
||||
today: true,
|
||||
monthFirst: false,
|
||||
text: {
|
||||
days: ['Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'Sa'],
|
||||
months: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
|
||||
monthsShort: ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'],
|
||||
today: 'Hoy'
|
||||
},
|
||||
formatter: {
|
||||
date: 'DD-MM-YYYY'
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@stack('page_scripts')
|
@ -0,0 +1,3 @@
|
||||
@push('page_scripts')
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
@endpush
|
@ -0,0 +1,4 @@
|
||||
@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>
|
||||
@endpush
|
1
app/resources/views/layout/body/scripts/dayjs.blade.php
Normal file
@ -0,0 +1 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/dayjs@1/dayjs.min.js"></script>
|
10
app/resources/views/layout/head.blade.php
Normal file
@ -0,0 +1,10 @@
|
||||
<head>
|
||||
<meta charset="utf8" />
|
||||
@hasSection('page_title')
|
||||
<title>Incoviba - @yield('page_title')</title>
|
||||
@else
|
||||
<title>Incoviba</title>
|
||||
@endif
|
||||
<link rel="icon" href="{{$urls->images}}/Isotipo 16.png" />
|
||||
@include('layout.head.styles')
|
||||
</head>
|
3
app/resources/views/layout/head/styles.blade.php
Normal file
@ -0,0 +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" />
|
||||
|
||||
@stack('page_styles')
|
@ -0,0 +1,3 @@
|
||||
@push('page_styles')
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.5/css/dataTables.semanticui.min.css" />
|
||||
@endpush
|
60
app/resources/views/login/form.blade.php
Normal file
@ -0,0 +1,60 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<div class="ui form" id="login_form">
|
||||
<div class="six wide field">
|
||||
<label for="name">Nombre</label>
|
||||
<input type="text" id="name" name="name" />
|
||||
</div>
|
||||
<div class="six wide field">
|
||||
<label for="password">Clave</label>
|
||||
<input type="password" id="password" name="password" />
|
||||
</div>
|
||||
<button class="ui button" id="enter">Ingresar</button>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
function sendLogin(name, password) {
|
||||
const data = new FormData()
|
||||
data.append('name', name)
|
||||
data.append('password', password)
|
||||
return fetch('{{$urls->base}}/login', {
|
||||
method: 'post',
|
||||
headers: {
|
||||
Accept: 'json'
|
||||
},
|
||||
body: data
|
||||
}).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
if (data.login === true) {
|
||||
@if(isset($redirect_uri))
|
||||
window.location = '{{$redirect_uri}}'
|
||||
@else
|
||||
window.location = '{{$urls->base}}'
|
||||
@endif
|
||||
}
|
||||
})
|
||||
}
|
||||
$(document).ready(() => {
|
||||
$('#login_form').find('input').keypress(event => {
|
||||
if (event.which !== 13) {
|
||||
return
|
||||
}
|
||||
$('#enter').click()
|
||||
})
|
||||
$('#enter').click(event => {
|
||||
const form = $('#login_form')
|
||||
const name = form.find('#name').val()
|
||||
const password = form.find('#password').val()
|
||||
sendLogin(name, password)
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
14
app/resources/views/not_found.blade.php
Normal file
@ -0,0 +1,14 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_title')
|
||||
404 - No Encontrado
|
||||
@endsection
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<div class="ui message">
|
||||
<i class="exclamation triangle icon"></i>
|
||||
No se ha encontrado la página solicitada
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
809
app/resources/views/ventas/add.blade.php
Normal file
@ -0,0 +1,809 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h2 class="ui header">Nueva Venta</h2>
|
||||
<form class="ui form" id="add_form" action="{{$urls->base}}/ventas/add" method="post">
|
||||
<label for="fecha_venta">Fecha de Venta</label>
|
||||
<div class="inline field">
|
||||
<div class="ui calendar" id="fecha_venta_calendar">
|
||||
<div class="ui icon input">
|
||||
<input type="text" name="fecha_venta" id="fecha_venta" />
|
||||
<i class="calendar icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h4 class="ui dividing header">PROPIETARIO</h4>
|
||||
<div class="inline fields">
|
||||
<div class="field">
|
||||
<div class="ui checkbox">
|
||||
<input type="checkbox" id="persona_propietario" name="natural_uno" checked="checked" />
|
||||
<label>Personal Natural</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui checkbox">
|
||||
<input type="checkbox" id="cantidad_propietario" name="natural_multiple" />
|
||||
<label>Multiples Propietarios</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<span id="propietario"></span>
|
||||
<h4 class="ui dividing header">PROPIEDAD</h4>
|
||||
<label for="proyecto">Proyecto</label>
|
||||
<div class="four wide field">
|
||||
<div class="ui fluid search selection dropdown" id="proyecto">
|
||||
<input type="hidden" name="proyecto" />
|
||||
<div class="default text">Proyecto</div>
|
||||
<div class="menu">
|
||||
@foreach($proyectos as $proyecto)
|
||||
<div class="item" data-value="{{$proyecto->id}}">{{$proyecto->descripcion}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="ui button" type="button" id="agregar_departamento">
|
||||
<i class="plus icon"></i>
|
||||
<i class="building icon"></i>
|
||||
{{--Departamento--}}
|
||||
</button>
|
||||
<button class="ui button" type="button" id="agregar_estacionamiento">
|
||||
<i class="plus icon"></i>
|
||||
<i class="car icon"></i>
|
||||
{{--Estacionamiento--}}
|
||||
</button>
|
||||
<button class="ui button" type="button" id="agregar_bodega">
|
||||
<i class="plus icon"></i>
|
||||
<i class="warehouse icon"></i>
|
||||
{{--Bodega--}}
|
||||
</button>
|
||||
<div id="unidades" class="ui ordered list"></div>
|
||||
<h4 class="ui dividing header">FORMA DE PAGO</h4>
|
||||
<label for="valor">Valor</label>
|
||||
<div class="inline field">
|
||||
<div class="ui right labeled input">
|
||||
<input type="text" name="valor" id="valor" />
|
||||
<div class="ui label">UF</div>
|
||||
</div>
|
||||
</div>
|
||||
<label for="has_pie">Pie</label>
|
||||
<div class="inline fields">
|
||||
<div class="ui checkbox">
|
||||
<input type="checkbox" name="has_pie" id="has_pie" />
|
||||
<label></label>
|
||||
</div>
|
||||
<span id="pie">
|
||||
<div class="inline fields">
|
||||
<div class="inline field">
|
||||
<div class="ui right labeled input">
|
||||
<input type="text" name="pie" />
|
||||
<div class="ui label">UF</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="four wide inline field">
|
||||
<label for="cuotas">Cuotas</label>
|
||||
<input type="text" name="cuotas" id="cuotas" />
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
<label for="has_subsidio">Subsidio</label>
|
||||
<div class="inline fields">
|
||||
<div class="ui checkbox">
|
||||
<input type="checkbox" name="has_subsidio" id="has_subsidio" />
|
||||
<label></label>
|
||||
</div>
|
||||
<span id="subsidio">
|
||||
<div class="inline fields">
|
||||
<div class="inline field">
|
||||
<div class="ui right labeled input">
|
||||
<input type="text" name="subsidio" />
|
||||
<div class="ui label">UF</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="inline field">
|
||||
<label for="ahorro">Ahorro</label>
|
||||
<div class="ui right labeled input">
|
||||
<input type="text" name="ahorro" id="ahorro" />
|
||||
<div class="ui label">UF</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
<label for="has_credito">Crédito</label>
|
||||
<div class="inline fields">
|
||||
<div class="ui checkbox">
|
||||
<input type="checkbox" name="has_credito" id="has_credito" />
|
||||
<label></label>
|
||||
</div>
|
||||
<span id="credito">
|
||||
<div class="ui right labeled input">
|
||||
<input type="text" name="credito" />
|
||||
<div class="ui label">UF</div>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
<h4 class="ui dividing header">OTRAS CONDICIONES</h4>
|
||||
<label for="has_bono_pie">Bono Pie</label>
|
||||
<div class="inline fields">
|
||||
<div class="ui checkbox">
|
||||
<input type="checkbox" name="has_bono_pie" id="has_bono_pie" />
|
||||
<label></label>
|
||||
</div>
|
||||
<span id="bono_pie">
|
||||
<div class="ui right labeled input">
|
||||
<input type="text" name="bono_pie" />
|
||||
<div class="ui label">UF</div>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<button class="ui button" type="submit">Agregar</button>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
const regiones = [
|
||||
@foreach ($regiones as $region)
|
||||
'<div class="item" data-value="{{$region->id}}">{{$region->descripcion}}</div>',
|
||||
@endforeach
|
||||
]
|
||||
|
||||
class Rut {
|
||||
ids
|
||||
patterns
|
||||
valid
|
||||
|
||||
constructor({id, alert_id, valid}) {
|
||||
this.ids = {
|
||||
input: id,
|
||||
alert: alert_id
|
||||
}
|
||||
this.patterns = {
|
||||
like: /^(\d{0,2})\.?(\d{3})\.?(\d{3})-?(\d|k)$/gi,
|
||||
suspicious: /^(\d)\1?\.?(\1{3})\.?(\1{3})-?(\d|k)?$/gi
|
||||
}
|
||||
this.valid = valid
|
||||
|
||||
$(this.ids.alert).hide()
|
||||
$(this.ids.input).change(event => {
|
||||
this.verify(event)
|
||||
})
|
||||
}
|
||||
is() {
|
||||
return {
|
||||
like: rut => this.patterns.like.test(rut),
|
||||
suspicious: rut => this.patterns.suspicious.test(rut)
|
||||
}
|
||||
}
|
||||
clean() {
|
||||
return {
|
||||
rut: rut => rut.includes('-') ? rut.split('-').join('') : rut
|
||||
}
|
||||
}
|
||||
get() {
|
||||
return {
|
||||
digits: rut => this.clean().rut(rut).slice(0, -1),
|
||||
verifier: rut => this.clean().rut(rut).slice(-1)
|
||||
}
|
||||
}
|
||||
calculate() {
|
||||
return {
|
||||
verifier: digits => {
|
||||
let sum = 0
|
||||
let mul = 2
|
||||
|
||||
let i = digits.length
|
||||
while (i--) {
|
||||
sum = sum + parseInt(digits.charAt(i)) * mul
|
||||
if (mul % 7 === 0) {
|
||||
mul = 2
|
||||
} else {
|
||||
mul++
|
||||
}
|
||||
}
|
||||
|
||||
const res = sum % 11
|
||||
|
||||
if (res === 0) {
|
||||
return '0'
|
||||
} else if (res === 1) {
|
||||
return 'k'
|
||||
}
|
||||
|
||||
return `${11 - res}`
|
||||
}
|
||||
}
|
||||
}
|
||||
validate(rut, not_suspicious = true) {
|
||||
if (!this.is().like(rut) || (not_suspicious && this.is().suspicious(rut))) {
|
||||
return false
|
||||
}
|
||||
return this.get().verifier(rut).toLowerCase() === this.calculate().verifier(this.get().digits(rut))
|
||||
}
|
||||
verify(event) {
|
||||
const input = $(event.currentTarget)
|
||||
const val = input.val()
|
||||
let new_val = this.clean().rut(val)
|
||||
if (new_val.length < 3) {
|
||||
return
|
||||
}
|
||||
new_val = [this.get().digits(new_val), this.get().verifier(new_val)].join('-')
|
||||
input.val(new_val)
|
||||
if (!this.validate(new_val)) {
|
||||
this.alert().invalid()
|
||||
return
|
||||
}
|
||||
this.alert().valid()
|
||||
this.valid(new_val)
|
||||
}
|
||||
alert() {
|
||||
return {
|
||||
valid: () => {
|
||||
$(this.ids.alert).hide()
|
||||
},
|
||||
invalid: () => {
|
||||
$(this.ids.alert).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
class Comuna {
|
||||
id
|
||||
data
|
||||
|
||||
constructor(id) {
|
||||
this.id = id
|
||||
this.data = {
|
||||
region: 0,
|
||||
provincias: []
|
||||
}
|
||||
|
||||
$(this.id).dropdown()
|
||||
}
|
||||
|
||||
get() {
|
||||
return {
|
||||
provincias: () => {
|
||||
const uri = '{{$urls->api}}/region/' + this.data.region + '/provincias'
|
||||
return fetch(uri).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
this.data.provincias = data.provincias
|
||||
const promises = []
|
||||
this.data.provincias.forEach(provincia => {
|
||||
promises.push(this.get().comunas(provincia.id))
|
||||
})
|
||||
Promise.all(promises).then(() => {
|
||||
this.draw().comunas()
|
||||
})
|
||||
})
|
||||
},
|
||||
comunas: provincia_id => {
|
||||
const uri = '{{$urls->api}}/provincia/' + provincia_id + '/comunas'
|
||||
return fetch(uri).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
const i = this.data.provincias.findIndex(provincia => provincia.id === data.provincia_id)
|
||||
this.data.provincias[i].comunas = data.comunas
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
draw() {
|
||||
return {
|
||||
comunas: () => {
|
||||
const dropdown = $(this.id)
|
||||
const menu = dropdown.find('.menu')
|
||||
menu.html('')
|
||||
this.data.provincias.forEach(provincia => {
|
||||
menu.append(
|
||||
$('<div></div>').addClass('header').html(provincia.descripcion)
|
||||
)
|
||||
menu.append(
|
||||
$('<div></div>').addClass('divider')
|
||||
)
|
||||
provincia.comunas.forEach(comuna => {
|
||||
menu.append(
|
||||
$('<div></div>').addClass('item').attr('data-value', comuna.id).html(comuna.descripcion)
|
||||
)
|
||||
})
|
||||
})
|
||||
dropdown.dropdown('refresh')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
class Region {
|
||||
id
|
||||
comuna
|
||||
|
||||
constructor({id, comuna}) {
|
||||
this.id = id
|
||||
this.comuna = comuna
|
||||
|
||||
const dd = $(this.id)
|
||||
dd.dropdown({
|
||||
fireOnInit: true,
|
||||
onChange: value => {
|
||||
this.comuna.data.region = value
|
||||
this.comuna.get().provincias()
|
||||
}
|
||||
})
|
||||
dd.dropdown('set selected', 13)
|
||||
}
|
||||
}
|
||||
class PersonaNatural {
|
||||
valid
|
||||
constructor({valid}) {
|
||||
this.valid = valid
|
||||
}
|
||||
draw() {
|
||||
const lines = [
|
||||
'<label for="rut">RUT</label>',
|
||||
'<div class="inline field">',
|
||||
'<input type="text" id="rut" name="rut" />',
|
||||
'<span class="ui error message" id="alert_rut">',
|
||||
'<i class="exclamation triangle icon"></i>',
|
||||
'RUT Inválido',
|
||||
'</span>',
|
||||
'</div>',
|
||||
'<label for="nombres">Nombre</label>',
|
||||
'<div class="inline fields">',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="nombres" id="nombres" />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="apellido_paterno" />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="apellido_materno" />',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<label for="calle">Dirección</label>',
|
||||
'<div class="inline fields">',
|
||||
'<div class="eight wide field">',
|
||||
'<input type="text" name="calle" id="calle" size="16" />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="numero" size="5" />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="extra" />',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<div class="inline fields">',
|
||||
'<div class="two wide field"></div>',
|
||||
'<div class="four wide field">',
|
||||
'<div class="ui fluid search selection dropdown" id="comuna">',
|
||||
'<input type="hidden" name="comuna" />',
|
||||
'<div class="default text">Comuna</div>',
|
||||
'<div class="menu"></div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<div class="six wide field">',
|
||||
'<div class="ui fluid search selection dropdown" id="region">',
|
||||
'<input type="hidden" name="region" />',
|
||||
'<div class="default text">Región</div>',
|
||||
'<div class="menu">',
|
||||
...regiones,
|
||||
'</div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'</div>'
|
||||
]
|
||||
return lines.join("\n")
|
||||
}
|
||||
activate() {
|
||||
new Rut({id: '#rut', alert_id: '#alert_rut', valid: this.valid})
|
||||
const comuna = new Comuna('#comuna')
|
||||
new Region({id: '#region', comuna})
|
||||
}
|
||||
}
|
||||
class PersonaTributaria {
|
||||
persona
|
||||
constructor({valid}) {
|
||||
this.persona = new PersonaNatural({valid})
|
||||
}
|
||||
draw() {
|
||||
const lines = [
|
||||
'<label for="rut">RUT Sociedad</label>',
|
||||
'<div class="inline field">',
|
||||
'<input type="text" id="rut_sociedad" name="rut_sociedad" />',
|
||||
'<span class="ui error message" id="alert_rut_sociedad">',
|
||||
'<i class="exclamation triangle icon"></i>',
|
||||
'RUT Inválido',
|
||||
'</span>',
|
||||
'</div>',
|
||||
'<label for="razon_social">Razón Social</label>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="razon_social" id="razon_social" />',
|
||||
'</div>',
|
||||
'<label for="calle_comercial">Dirección Comercial</label>',
|
||||
'<div class="inline fields">',
|
||||
'<div class="eight wide field">',
|
||||
'<input type="text" name="calle_comercial" id="calle_comercial" size="16" />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="numero_comercial" size="5" />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="extra_comercial" />',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<div class="inline fields">',
|
||||
'<div class="two wide field"></div>',
|
||||
'<div class="four wide field">',
|
||||
'<div class="ui fluid search selection dropdown" id="comuna_sociedad">',
|
||||
'<input type="hidden" name="comuna_sociedad" />',
|
||||
'<div class="default text">Comuna</div>',
|
||||
'<div class="menu"></div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<div class="six wide field">',
|
||||
'<div class="ui fluid search selection dropdown" id="region_sociedad">',
|
||||
'<input type="hidden" name="region_sociedad" />',
|
||||
'<div class="default text">Región</div>',
|
||||
'<div class="menu">',
|
||||
...regiones,
|
||||
'</div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<div>Representante Legal</div>',
|
||||
]
|
||||
return [lines.join("\n"), this.persona.draw()].join("\n")
|
||||
}
|
||||
activate() {
|
||||
new Rut({id: '#rut_sociedad', alert_id: '#alert_rut_sociedad'})
|
||||
const comuna = new Comuna('#comuna_sociedad')
|
||||
new Region({id: '#region_sociedad', comuna})
|
||||
this.persona.activate()
|
||||
}
|
||||
}
|
||||
class MultiplesPersonas {
|
||||
persona
|
||||
constructor({valid}) {
|
||||
this.persona = new PersonaNatural({valid})
|
||||
}
|
||||
|
||||
draw() {
|
||||
let lines = [
|
||||
this.persona.draw(),
|
||||
'<label for="rut">RUT Otro</label>',
|
||||
'<div class="inline field">',
|
||||
'<input type="text" id="rut_otro" name="rut_otro" />',
|
||||
'<span class="ui error message" id="alert_rut_otro">',
|
||||
'<i class="exclamation triangle icon"></i>',
|
||||
'RUT Inválido',
|
||||
'</span>',
|
||||
'</div>',
|
||||
'<label for="nombres_otro">Nombre Otro</label>',
|
||||
'<div class="inline fields">',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="nombres_otro" id="nombres_otro" />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="apellido_paterno_otro" />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="apellido_materno_otro" />',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<label for="calle_otro">Dirección Otro</label>',
|
||||
'<div class="inline fields">',
|
||||
'<div class="eight wide field">',
|
||||
'<input type="text" name="calle_otro" id="calle_otro" size="16" />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="numero_otro" size="5" />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="extra_otro" />',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<div class="inline fields">',
|
||||
'<div class="two wide field"></div>',
|
||||
'<div class="four wide field">',
|
||||
'<div class="ui fluid search selection dropdown" id="comuna_otro">',
|
||||
'<input type="hidden" name="comuna_otro" />',
|
||||
'<div class="default text">Comuna</div>',
|
||||
'<div class="menu"></div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<div class="six wide field">',
|
||||
'<div class="ui fluid search selection dropdown" id="region_otro">',
|
||||
'<input type="hidden" name="region_otro" />',
|
||||
'<div class="default text">Región</div>',
|
||||
'<div class="menu">',
|
||||
...regiones,
|
||||
'</div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'</div>'
|
||||
]
|
||||
return lines.join("\n")
|
||||
}
|
||||
activate() {
|
||||
this.persona.activate()
|
||||
new Rut({id: '#rut_otro', alert_id: '#alert_rut_otro'})
|
||||
const comuna = new Comuna('#comuna_otro')
|
||||
new Region({id: '#region_otro', comuna})
|
||||
}
|
||||
}
|
||||
class Propietario {
|
||||
ids
|
||||
|
||||
constructor({id, id_tipo, id_cantidad}) {
|
||||
this.ids = {
|
||||
span: id,
|
||||
tipo: id_tipo,
|
||||
cantidad: id_cantidad
|
||||
}
|
||||
|
||||
document.getElementById(this.ids.tipo).onchange = event => {
|
||||
const cantidad = document.getElementById(this.ids.cantidad)
|
||||
cantidad.disabled = !event.currentTarget.checked;
|
||||
this.draw()
|
||||
}
|
||||
document.getElementById(this.ids.cantidad).onchange = event => {
|
||||
this.draw()
|
||||
}
|
||||
document.getElementById(this.ids.cantidad).disabled = !document.getElementById(this.ids.tipo).checked
|
||||
|
||||
this.draw()
|
||||
|
||||
$(this.ids.span).find('#rut')
|
||||
}
|
||||
get tipo() {
|
||||
return document.getElementById(this.ids.tipo).checked ? (document.getElementById(this.ids.cantidad).checked ? 2 : 0) : 1
|
||||
}
|
||||
get() {
|
||||
return {
|
||||
propietario: tipo => {
|
||||
const map = {
|
||||
0: new PersonaNatural({valid: rut => this.fetch().propietario(rut)}),
|
||||
1: new PersonaTributaria({valid: () => {}}),
|
||||
2: new MultiplesPersonas({valid: () => {}})
|
||||
}
|
||||
return map[tipo]
|
||||
}
|
||||
}
|
||||
}
|
||||
fetch() {
|
||||
return {
|
||||
propietario: rut => {
|
||||
const uri = '{{$urls->api}}/ventas/propietario/' + rut.split('-')[0]
|
||||
return fetch(uri).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
if (data.propietario !== null) {
|
||||
const parent = $(this.ids.span)
|
||||
parent.find("[name='nombres']").val(data.propietario.nombres)
|
||||
parent.find("[name='apellido_paterno']").val(data.propietario.apellidos.paterno)
|
||||
parent.find("[name='apellido_materno']").val(data.propietario.apellidos.materno)
|
||||
parent.find("[name='calle']").val(data.propietario.direccion.calle)
|
||||
parent.find("[name='numero']").val(data.propietario.direccion.numero)
|
||||
parent.find("[name='extra']").val(data.propietario.direccion.extra)
|
||||
parent.find('#region').dropdown('set selected', data.propietario.direccion.comuna.provincia.region.id)
|
||||
parent.find('#comuna').dropdown('set selected', data.propietario.direccion.comuna.id)
|
||||
|
||||
if (data.propietario.representante !== '') {
|
||||
document.getElementById(this.ids.tipo).trigger('check')
|
||||
} else {
|
||||
if (data.propietario.otro) {
|
||||
document.getElementById(this.ids.cantidad).trigger('check')
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
draw() {
|
||||
const propietario = this.get().propietario(this.tipo)
|
||||
$(this.ids.span).html(propietario.draw())
|
||||
propietario.activate()
|
||||
}
|
||||
}
|
||||
|
||||
class Proyecto {
|
||||
ids
|
||||
data
|
||||
unidades
|
||||
added
|
||||
|
||||
constructor({unidades_id, proyecto_id}) {
|
||||
this.ids = {
|
||||
proyecto: proyecto_id,
|
||||
unidades: unidades_id,
|
||||
buttons: []
|
||||
}
|
||||
this.data = {id: 0}
|
||||
this.unidades = []
|
||||
this.added = []
|
||||
|
||||
$(this.ids.proyecto).dropdown({
|
||||
fireOnInit: true,
|
||||
onChange: (value, text, $choice) => {
|
||||
this.data.id = value
|
||||
this.ids.buttons.forEach(button => {
|
||||
$(button).prop('disabled', true)
|
||||
})
|
||||
this.reset()
|
||||
this.fetch().unidades().then(() => {
|
||||
this.ids.buttons.forEach(button => {
|
||||
$(button).prop('disabled', false)
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
const buttons = [
|
||||
'departamento',
|
||||
'estacionamiento',
|
||||
'bodega'
|
||||
]
|
||||
buttons.forEach(name => {
|
||||
const id = '#agregar_' + name
|
||||
this.ids.buttons.push(id)
|
||||
$(id).click(event => {
|
||||
this.add(name)
|
||||
})
|
||||
})
|
||||
}
|
||||
fetch() {
|
||||
return {
|
||||
unidades: () => {
|
||||
const uri = '{{$urls->api}}/proyecto/' + this.data.id + '/unidades'
|
||||
return fetch(uri).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
if (data.total === 0) {
|
||||
return
|
||||
}
|
||||
this.unidades = data.unidades
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
add(tipo) {
|
||||
const number = Math.floor(Math.random() * 1000)
|
||||
const unidad = new Unidad({number})
|
||||
this.added.push(unidad)
|
||||
$(this.ids.unidades).append(
|
||||
$('<div></div>').addClass('item').attr('data-number', number).append(
|
||||
$('<div></div>').addClass('content').append(tipo.charAt(0).toUpperCase() + tipo.slice(1) + ' ').append(
|
||||
unidad.draw(this.unidades[tipo])
|
||||
).append(
|
||||
$('<button></button>').addClass('ui icon button').attr('type', 'button').attr('data-number', number).append(
|
||||
$('<i></i>').addClass('remove icon')
|
||||
).click(event => {
|
||||
const number = $(event.currentTarget).attr('data-number')
|
||||
this.remove(number)
|
||||
})
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
remove(number) {
|
||||
number = parseInt(number)
|
||||
const index = this.added.findIndex(unidad => unidad.number === number)
|
||||
if (index === -1) {
|
||||
return
|
||||
}
|
||||
$(this.ids.unidades).find("div.item[data-number='" + number + "']").remove()
|
||||
this.added.splice(index, 1)
|
||||
}
|
||||
reset() {
|
||||
this.added = []
|
||||
$(this.ids.unidades).html('')
|
||||
}
|
||||
}
|
||||
class Unidad{
|
||||
number
|
||||
constructor({number}) {
|
||||
this.number = number
|
||||
}
|
||||
|
||||
draw(unidades) {
|
||||
const dropdown = $('<div></div>').addClass('ui search selection dropdown')
|
||||
const tipo = unidades[0].proyecto_tipo_unidad.tipo_unidad.descripcion
|
||||
dropdown.append(
|
||||
$('<input />').attr('type', 'hidden').attr('name', 'unidad' + this.number)
|
||||
).append(
|
||||
$('<div></div>').addClass('default text').html(tipo.charAt(0).toUpperCase() + tipo.slice(1))
|
||||
).append(
|
||||
$('<i></i>').addClass('dropdown icon')
|
||||
)
|
||||
const menu = $('<div></div>').addClass('menu')
|
||||
unidades.forEach(unidad => {
|
||||
menu.append(
|
||||
$('<div></div>').addClass('item').attr('data-value', unidad.id).html(unidad.descripcion)
|
||||
)
|
||||
})
|
||||
dropdown.append(menu)
|
||||
dropdown.dropdown()
|
||||
return dropdown
|
||||
}
|
||||
}
|
||||
|
||||
class Payment {
|
||||
ids
|
||||
|
||||
constructor({id, checkbox_id}) {
|
||||
this.ids = {
|
||||
base: id,
|
||||
checkbox: checkbox_id
|
||||
}
|
||||
|
||||
document.getElementById(this.ids.checkbox).onchange = event => {
|
||||
this.toggle()
|
||||
}
|
||||
this.toggle()
|
||||
}
|
||||
|
||||
get status() {
|
||||
return document.getElementById(this.ids.checkbox).checked
|
||||
}
|
||||
toggle() {
|
||||
if (this.status) {
|
||||
$(this.ids.base).show()
|
||||
return
|
||||
}
|
||||
$(this.ids.base).hide()
|
||||
}
|
||||
}
|
||||
|
||||
function showErrors(errors) {
|
||||
console.debug(errors)
|
||||
}
|
||||
|
||||
$(document).ready(() => {
|
||||
$('#fecha_venta_calendar').calendar(calendar_date_options)
|
||||
new Propietario({id: '#propietario', id_tipo: 'persona_propietario', id_cantidad: 'cantidad_propietario'})
|
||||
new Proyecto({unidades_id: '#unidades', proyecto_id: '#proyecto'})
|
||||
|
||||
const payments = [
|
||||
'pie',
|
||||
'subsidio',
|
||||
'credito',
|
||||
'bono_pie'
|
||||
]
|
||||
payments.forEach(payment => {
|
||||
new Payment({
|
||||
id: '#' + payment,
|
||||
checkbox_id: 'has_' + payment
|
||||
})
|
||||
})
|
||||
|
||||
$('#add_form').submit(event => {
|
||||
event.preventDefault()
|
||||
const data = new FormData(event.currentTarget)
|
||||
const uri = $(event.currentTarget).attr('action')
|
||||
fetch(uri, {method: 'post', body: data}).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
if (data.status) {
|
||||
window.location = '{{$urls->base}}'
|
||||
return true
|
||||
}
|
||||
showErrors(data.errors)
|
||||
})
|
||||
return false
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
293
app/resources/views/ventas/cierres/list.blade.php
Normal file
@ -0,0 +1,293 @@
|
||||
@extends('layout.base')
|
||||
|
||||
|
||||
@section('page_title')
|
||||
Cierres - Listado
|
||||
@endsection
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h2 class="ui header">Listado de Cierres</h2>
|
||||
<h4 class="ui dividing header">Proyectos</h4>
|
||||
<div class="ui compact fluid styled accordion" id="cierres_accordion"></div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('layout.head.styles.datatables')
|
||||
@include('layout.body.scripts.datatables')
|
||||
|
||||
@push('page_styles')
|
||||
<style>
|
||||
.proyecto, .estado-cierres {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
class Cierre {
|
||||
id
|
||||
proyecto_id
|
||||
estado = {
|
||||
id: 0,
|
||||
descripcion: '',
|
||||
titulo: ''
|
||||
}
|
||||
departamento
|
||||
tipologia
|
||||
vendible
|
||||
fecha
|
||||
valor
|
||||
|
||||
unitario() {
|
||||
return this.valor / this.vendible
|
||||
}
|
||||
|
||||
draw(formatter) {
|
||||
const date = new Date(this.fecha)
|
||||
const dateFormatter = new Intl.DateTimeFormat('es-CL')
|
||||
const estado = this.estado.titulo.charAt(0).toUpperCase() + this.estado.titulo.slice(1)
|
||||
return $('<tr></tr>').addClass('cierre ' + this.estado.descripcion)
|
||||
.attr('data-proyecto', this.proyecto_id).attr('data-estado', this.estado.id).append(
|
||||
$('<td></td>').attr('data-order', this.departamento).append(
|
||||
$('<a></a>').attr('href', '{{$urls->base}}/ventas/cierre/' + this.id).html(this.departamento + ' (' + this.tipologia + ')')
|
||||
)
|
||||
).append(
|
||||
$('<td></td>').attr('data-order', this.fecha).html(dateFormatter.format(date))
|
||||
).append(
|
||||
$('<td></td>').html(formatter.format(this.valor) + ' UF (' + formatter.format(this.unitario()) + ' UF/m²)')
|
||||
).append(
|
||||
$('<td></td>').html(estado)
|
||||
)
|
||||
}
|
||||
}
|
||||
class Estado {
|
||||
id
|
||||
proyecto_id
|
||||
title
|
||||
descripcion
|
||||
cierres = []
|
||||
total = 0
|
||||
|
||||
proporcion() {
|
||||
return this.cierres.length / this.total * 100
|
||||
}
|
||||
add(data) {
|
||||
let cierre = this.cierres.find(cierre => cierre.id === data.id)
|
||||
if (typeof cierre !== 'undefined') {
|
||||
return
|
||||
}
|
||||
cierre = new Cierre()
|
||||
cierre.id = data.id
|
||||
cierre.proyecto_id = this.proyecto_id
|
||||
cierre.departamento = ''
|
||||
cierre.tipologia = ''
|
||||
cierre.vendible = 0
|
||||
const departamento = data.unidades.filter(unidad => unidad.proyecto_tipo_unidad.tipo_unidad.descripcion === 'departamento')[0]
|
||||
if (typeof departamento !== 'undefined') {
|
||||
cierre.departamento = departamento.descripcion
|
||||
cierre.tipologia = departamento.proyecto_tipo_unidad.abreviacion
|
||||
cierre.vendible = departamento.proyecto_tipo_unidad.vendible
|
||||
}
|
||||
cierre.fecha = data.date_time
|
||||
cierre.valor = data.precio
|
||||
cierre.estado.id = this.id
|
||||
cierre.estado.descripcion = this.descripcion
|
||||
cierre.estado.titulo = data.estado_cierre.tipo_estado_cierre.descripcion
|
||||
this.cierres.push(cierre)
|
||||
}
|
||||
draw(parent, formatter) {
|
||||
const tbody = $('<tbody></tbody>')
|
||||
this.cierres.forEach(cierre => {
|
||||
tbody.append(cierre.draw(formatter))
|
||||
})
|
||||
const table = $('<table></table>').addClass('ui striped table').append(
|
||||
$('<thead></thead>').append(
|
||||
$('<tr></tr>').append(
|
||||
$('<th></th>').html('Departamento')
|
||||
).append(
|
||||
$('<th></th>').html('Fecha')
|
||||
).append(
|
||||
$('<th></th>').html('Valor')
|
||||
).append(
|
||||
$('<th></th>').html('Estado')
|
||||
)
|
||||
)
|
||||
).append(tbody)
|
||||
parent.append(
|
||||
$('<div></div>').addClass('title ' + this.descripcion).append(
|
||||
$('<span></span>').addClass('ui text ' + this.descripcion.replace('positive', 'success')).html(this.title).append(
|
||||
$('<i></i>').addClass('right caret icon')
|
||||
).append(' [' + this.cierres.length + '] ' + formatter.format(this.proporcion()) + '%')
|
||||
)
|
||||
).append(
|
||||
$('<div></div>').addClass('content').append(table)
|
||||
)
|
||||
new DataTable(table, {
|
||||
order: [[1, 'desc'], [0, 'asc']]
|
||||
})
|
||||
}
|
||||
}
|
||||
class Proyecto {
|
||||
id
|
||||
descripcion
|
||||
total = 0
|
||||
estados
|
||||
|
||||
constructor({id, descripcion}) {
|
||||
this.id = id
|
||||
this.descripcion = descripcion
|
||||
this.estados = {
|
||||
aprobado: new Estado(),
|
||||
promesado: new Estado(),
|
||||
rechazado: new Estado()
|
||||
}
|
||||
this.estados.aprobado.id = 1
|
||||
this.estados.aprobado.proyecto_id = this.id
|
||||
this.estados.aprobado.title = 'Aprobado'
|
||||
this.estados.aprobado.descripcion = 'warning'
|
||||
|
||||
this.estados.promesado.id = 2
|
||||
this.estados.promesado.proyecto_id = this.id
|
||||
this.estados.promesado.title = 'Promesado'
|
||||
this.estados.promesado.descripcion = 'positive'
|
||||
|
||||
this.estados.rechazado.id = 3
|
||||
this.estados.rechazado.proyecto_id = this.id
|
||||
this.estados.rechazado.title = 'Abandonado/Rechazado'
|
||||
this.estados.rechazado.descripcion = 'error'
|
||||
}
|
||||
|
||||
add(data) {
|
||||
if (data.proyecto.id !== this.id) {
|
||||
return
|
||||
}
|
||||
this.total ++
|
||||
if (['revisado', 'aprobado'].includes(data.estado_cierre.tipo_estado_cierre.descripcion)) {
|
||||
return this.estados.aprobado.add(data)
|
||||
}
|
||||
if (['vendido', 'promesado'].includes(data.estado_cierre.tipo_estado_cierre.descripcion)) {
|
||||
return this.estados.promesado.add(data)
|
||||
}
|
||||
this.estados.rechazado.add(data)
|
||||
}
|
||||
draw(parent, formatter) {
|
||||
const accordion = $('<div></div>').addClass('compact accordion')
|
||||
Object.keys(this.estados).forEach(key => {
|
||||
this.estados[key].total = this.total
|
||||
this.estados[key].draw(accordion, formatter)
|
||||
})
|
||||
parent.append(
|
||||
$('<div></div>').addClass('title').html(this.descripcion).append(
|
||||
$('<i></i>').addClass('dropdown icon')
|
||||
).append(' [' + this.total + ']')
|
||||
).append(
|
||||
$('<div></div>').addClass('content').append(accordion)
|
||||
)
|
||||
}
|
||||
}
|
||||
const cierres = {
|
||||
ids: {
|
||||
accordion: '',
|
||||
},
|
||||
data: {
|
||||
proyectos: []
|
||||
},
|
||||
get: function() {
|
||||
return {
|
||||
proyectos: () => {
|
||||
this.data.proyectos = []
|
||||
|
||||
this.draw().loading()
|
||||
|
||||
return fetch('{{$urls->api}}/proyectos').then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
const promises = []
|
||||
if (data.total > 0) {
|
||||
data.proyectos.forEach(proyecto => {
|
||||
promises.push(this.get().cierres(proyecto.id))
|
||||
})
|
||||
return promises
|
||||
}
|
||||
}).then(promises => {
|
||||
Promise.all(promises).then(() => {
|
||||
this.data.proyectos.sort((a, b) => {
|
||||
return a.descripcion.localeCompare(b.descripcion)
|
||||
})
|
||||
this.draw().proyectos()
|
||||
})
|
||||
})
|
||||
},
|
||||
cierres: proyecto_id => {
|
||||
return fetch('{{$urls->api}}/ventas/cierres',
|
||||
{method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({proyecto_id})}).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
if (data.total > 0) {
|
||||
data.cierres.forEach(cierre => {
|
||||
this.add().cierre(cierre)
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
},
|
||||
add: function() {
|
||||
return {
|
||||
cierre: data => {
|
||||
let proyecto = this.data.proyectos.find(proyecto => proyecto.id === data.proyecto.id)
|
||||
if (this.data.proyectos.length === 0 || typeof proyecto === 'undefined') {
|
||||
proyecto = new Proyecto({
|
||||
id: data.proyecto.id,
|
||||
descripcion: data.proyecto.descripcion
|
||||
})
|
||||
this.data.proyectos.push(proyecto)
|
||||
}
|
||||
proyecto.add(data)
|
||||
}
|
||||
}
|
||||
},
|
||||
draw: function() {
|
||||
return {
|
||||
proyectos: () => {
|
||||
const accordion = $(this.ids.accordion)
|
||||
accordion.html('')
|
||||
const formatter = new Intl.NumberFormat('es-CL', {minimumFractionDigits: 2, maximumFractionDigits: 2})
|
||||
this.data.proyectos.forEach(proyecto => {
|
||||
proyecto.draw(accordion, formatter)
|
||||
})
|
||||
},
|
||||
loading: () => {
|
||||
const accordion = $(this.ids.accordion)
|
||||
accordion.append(
|
||||
$('<div></div>').addClass('ui basic segment').append(
|
||||
$('<div></div>').addClass('ui active dimmer').append(
|
||||
$('<div></div>').addClass('ui loader')
|
||||
)
|
||||
).append(
|
||||
$('<div></div>').addClass('ui fluid placeholder').append(
|
||||
$('<div></div>').addClass('image')
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
setup: function() {
|
||||
$(this.ids.accordion).accordion()
|
||||
this.get().proyectos()
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(() => {
|
||||
cierres.ids.accordion = '#cierres_accordion'
|
||||
cierres.setup()
|
||||
})
|
||||
</script>
|
||||
@endpush
|
141
app/resources/views/ventas/cierres/show.blade.php
Normal file
@ -0,0 +1,141 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_title')
|
||||
Cierre - Detalle
|
||||
@endsection
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<div class="ui segment">
|
||||
<h2 class="ui blue header">Cierre {{$cierre->principal()->descripcion}} - {{$cierre->proyecto->descripcion}}</h2>
|
||||
<div class="ui basic segments">
|
||||
<div class="ui grid segment">
|
||||
<div class="two wide column">
|
||||
Fecha
|
||||
</div>
|
||||
<div class="two wide column">
|
||||
{{$cierre->dateTime->format('d-m-Y')}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui inverted grey segment">PROPIETARIO</div>
|
||||
<div class="ui grid segment">
|
||||
<div class="row">
|
||||
<div class="two wide column">
|
||||
{{$cierre->propietario->rut()}}
|
||||
</div>
|
||||
<div class="six wide column">
|
||||
{{$cierre->propietario->nombreCompleto()}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="column"></div>
|
||||
<div class="fifteen wide column">
|
||||
{{$cierre->propietario->datos->direccion}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui inverted grey segment">PROPIEDAD</div>
|
||||
<div class="ui segment">
|
||||
<table class="ui very basic table">
|
||||
<tbody>
|
||||
@foreach ($cierre->unidades as $unidad)
|
||||
<tr>
|
||||
<td>{{ucwords($unidad->proyectoTipoUnidad->tipoUnidad->descripcion)}}</td>
|
||||
<td>{{$unidad->descripcion}}</td>
|
||||
<td>{{$unidad->proyectoTipoUnidad->nombre}}</td>
|
||||
<td>{{$unidad->proyectoTipoUnidad->abreviacion}}</td>
|
||||
<td>{{number_format($unidad->proyectoTipoUnidad->vendible(), 2, ',', '.')}} m²</td>
|
||||
<td>{{number_format($unidad->currentPrecio->valor, 2, ',', '.')}} UF</td>
|
||||
<td>{{number_format($unidad->currentPrecio->valor / $unidad->proyectoTipoUnidad->vendible(), 2, ',', '.')}} UF/m²</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="ui inverted grey segment">OFERTA</div>
|
||||
<div class="ui grid segment">
|
||||
<div class="two wide column">
|
||||
Precio
|
||||
</div>
|
||||
<div class="two wide column">
|
||||
{{number_format($cierre->precio, 2, ',', '.')}} UF
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui grid segment">
|
||||
<strong class="two wide column">
|
||||
Neto
|
||||
</strong>
|
||||
<strong class="two wide column">
|
||||
{{number_format($cierre->neto(), 2, ',', '.')}} UF
|
||||
</strong>
|
||||
<strong class="two wide column">
|
||||
{{number_format($cierre->neto() / $cierre->principal()->vendible, 2, ',', '.')}} UF/m²
|
||||
</strong>
|
||||
<div class="column">
|
||||
@if ($cierre->neto() / $cierre->principal()->vendible > $cierre->principal()->precio / $cierre->principal()->vendible)
|
||||
<i class="green check icon"></i>
|
||||
@else
|
||||
<i class="red remove icon"></i>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@foreach($cierre->valoresCierre as $valorCierre)
|
||||
<div class="ui grid segment">
|
||||
<div class="two wide column">{{ucwords($valorCierre->tipoValorCierre->descripcion)}}</div>
|
||||
<div class="two wide column">{{number_format($valorCierre->valor, 2, ',', '.')}} UF</div>
|
||||
<div class="two wide column">{{number_format($valorCierre->valor / $cierre->precio * 100, 2, ',', '.')}}%</div>
|
||||
</div>
|
||||
@endforeach
|
||||
<div class="ui inverted grey segment">DIFERENCIA</div>
|
||||
<div class="ui grid segment">
|
||||
<div class="two wide column">Neto</div>
|
||||
<div class="two wide column">
|
||||
{{number_format($cierre->neto() - $cierre->principal()->precio, 2, ',', '.')}} UF
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui inverted grey segment">ESTADO</div>
|
||||
<div class="ui segment">
|
||||
<div class="ui grid message {{['aprobado' => 'success', 'abandonado' => 'warning', 'promesado' => 'success'][$cierre->current->tipoEstadoCierre->descripcion]}}">
|
||||
<div class="two wide column">
|
||||
{{ucwords($cierre->current->tipoEstadoCierre->descripcion)}}
|
||||
</div>
|
||||
<div class="four wide column">
|
||||
{{$cierre->current->fecha->format('d-m-Y')}}
|
||||
</div>
|
||||
<div class="right aligned ten wide column">
|
||||
@if ($cierre->current->tipoEstadoCierre->descripcion === 'aprobado')
|
||||
<button class="ui icon basic button" data-content="Promesar" id="promesar" data-id="{{$cierre->id}}">
|
||||
<i class="check icon"></i>
|
||||
</button>
|
||||
<button class="ui icon basic button" data-content="Abandonar" id="abandonar" data-id="{{$cierre->id}}">
|
||||
<i class="remove icon"></i>
|
||||
</button>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
function action(action, cierre_id) {
|
||||
const url = '{{$urls->base}}/api/cierre/' + cierre_id + '/' + action
|
||||
console.debug(url)
|
||||
}
|
||||
$(document).ready(() => {
|
||||
$('#promesar').popup().click(event => {
|
||||
const button = $(event.currentTarget)
|
||||
const id = button.data('id')
|
||||
action('promesar', id)
|
||||
})
|
||||
$('#abandonar').popup().click(event => {
|
||||
const button = $(event.currentTarget)
|
||||
const id = button.data('id')
|
||||
action('abandonar', id)
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
145
app/resources/views/ventas/cuotas/abonar.blade.php
Normal file
@ -0,0 +1,145 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h3 class="ui header">Abonar Cuotas</h3>
|
||||
<div class="ui grid">
|
||||
<div class="two wide column">Total</div>
|
||||
<div class="column">{{count($cuotas_depositadas)}}</div>
|
||||
<div class="two wide column">{{$format->pesos(array_reduce($cuotas_depositadas, function($sum, $cuota) {return $sum + $cuota['Valor'];}, 0))}}</div>
|
||||
</div>
|
||||
<table class="ui striped table" id="cuotas">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="two wide column">Proyecto</th>
|
||||
<th class="column">Departamento</th>
|
||||
<th>Departamento Sort</th>
|
||||
<th class="two wide column">Propietario</th>
|
||||
<th class="column">Valor Cuota</th>
|
||||
<th class="column">Fecha Cuota</th>
|
||||
<th>Fecha ISO</th>
|
||||
<th class="column">Fecha Depositada</th>
|
||||
<th class="two wide column">Fecha Abono / Devolución</th>
|
||||
<th class="column">Acción</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($cuotas_depositadas as $cuota)
|
||||
<tr>
|
||||
<td>{{$cuota['Proyecto']}}</td>
|
||||
<td>
|
||||
<a href="{{$urls->base}}/venta/{{$cuota['venta_id']}}">{{$cuota['Departamento']}}</a>
|
||||
</td>
|
||||
<td>{{str_pad($cuota['Departamento'], 4, 0, STR_PAD_LEFT)}}</td>
|
||||
<td>{{$cuota['Propietario']}}</td>
|
||||
<td>{{$format->pesos($cuota['Valor'])}}</td>
|
||||
<td>{{$cuota['Fecha Cheque']}}</td>
|
||||
<td>{{$cuota['Fecha ISO']}}</td>
|
||||
<td>{{$cuota['Fecha Depositada']}}</td>
|
||||
<td>
|
||||
<div class="ui calendar" data-cuota="{{$cuota['id']}}">
|
||||
<div class="ui icon input">
|
||||
<input type="text" name="fecha_abono{{$cuota['id']}}" />
|
||||
<i class="calendar icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="ui vertical buttons">
|
||||
<button class="ui green icon button abonar" title="Abonar">
|
||||
<i class="check icon"></i>
|
||||
</button>
|
||||
<button class="ui red icon button devolver" title="Devolver">
|
||||
<i class="remove icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('layout.head.styles.datatables')
|
||||
@include('layout.body.scripts.datatables')
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
$(document).ready(() => {
|
||||
const cuotas_tables = new DataTable('#cuotas', {
|
||||
language: {
|
||||
info: 'Mostrando página _PAGE_ de _PAGES_',
|
||||
infoEmpty: 'No hay cuotas depositadas por abonar',
|
||||
infoFiltered: '(filtrado de _MAX_ cuotas)',
|
||||
lengthMenu: 'Mostrando de a _MENU_ cuotas',
|
||||
zeroRecords: 'No se encotró cuotas con ese criterio',
|
||||
search: 'Buscar: '
|
||||
},
|
||||
columnDefs: [
|
||||
{
|
||||
target: 6,
|
||||
visible: false,
|
||||
searchable: false
|
||||
},
|
||||
{
|
||||
target: 2,
|
||||
visible: false,
|
||||
searchable: false
|
||||
}
|
||||
],
|
||||
order: [
|
||||
[6, 'desc'],
|
||||
[0, 'asc'],
|
||||
[2, 'asc']
|
||||
]
|
||||
})
|
||||
$('.ui.calendar').calendar({
|
||||
type: 'date',
|
||||
formatter: {
|
||||
date: 'DD-MM-YYYY'
|
||||
}
|
||||
})
|
||||
$('.abonar.button').click(event => {
|
||||
const button = $(event.currentTarget)
|
||||
const cuota_id = button.data('cuota')
|
||||
const calendar = $(".ui.calendar[data-cuota='" + cuota_id + "']").calendar('get date')
|
||||
const fecha = [calendar.getFullYear(), calendar.getMonth()+1, calendar.getDate()].join('-')
|
||||
fetch('{{$urls->api}}/ventas/cuota/abonar', {
|
||||
method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({cuota_id, fecha})
|
||||
}).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
if (data.depositada) {
|
||||
const button = $(".depositar.button[data-cuota='" + data.cuota_id + "']")
|
||||
const cell = button.parent()
|
||||
const row = cell.parent()
|
||||
cuotas_tables.row(row).remove().draw()
|
||||
}
|
||||
})
|
||||
})
|
||||
$('.devolver.button').click(event => {
|
||||
const button = $(event.currentTarget)
|
||||
const cuota_id = button.data('cuota')
|
||||
const calendar = $(".ui.calendar[data-cuota='" + cuota_id + "']").calendar('get date')
|
||||
const fecha = [calendar.getFullYear(), calendar.getMonth()+1, calendar.getDate()].join('-')
|
||||
fetch('{{$urls->api}}/ventas/cuota/devolver', {
|
||||
method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({cuota_id, fecha})
|
||||
}).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
if (data.depositada) {
|
||||
const button = $(".depositar.button[data-cuota='" + data.cuota_id + "']")
|
||||
const cell = button.parent()
|
||||
const row = cell.parent()
|
||||
cuotas_tables.row(row).remove().draw()
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
125
app/resources/views/ventas/cuotas/pendientes.blade.php
Normal file
@ -0,0 +1,125 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h3 class="ui header">Cuotas Pendientes</h3>
|
||||
<div class="ui grid">
|
||||
<div class="two wide column">Total</div>
|
||||
<div class="column">{{count($cuotas_pendientes)}}</div>
|
||||
<div class="two wide column">{{$format->pesos(array_reduce($cuotas_pendientes, function($sum, $cuota) {return $sum + $cuota['Valor'];}, 0))}}</div>
|
||||
</div>
|
||||
<table class="ui striped table" id="cuotas">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="two wide column">Proyecto</th>
|
||||
<th class="column">Departamento</th>
|
||||
<th>Departamento Sort</th>
|
||||
<th class="two wide column">Propietario</th>
|
||||
<th class="column">Cuota</th>
|
||||
<th class="column">Banco</th>
|
||||
<th class="column">Valor</th>
|
||||
<th class="column">Día</th>
|
||||
<th class="two wide column">Fecha Cheque (Días)</th>
|
||||
<th>Fecha ISO</th>
|
||||
<th class="two wide column">Fecha Deposito</th>
|
||||
<th class="column">Depositar</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($cuotas_pendientes as $cuota)
|
||||
<tr>
|
||||
<td>{{$cuota['Proyecto']}}</td>
|
||||
<td>
|
||||
<a href="{{$urls->base}}/venta/{{$cuota['venta_id']}}">
|
||||
{{$cuota['Departamento']}}
|
||||
</a>
|
||||
</td>
|
||||
<td>{{str_pad($cuota['Departamento'], 4, '0', STR_PAD_LEFT)}}</td>
|
||||
<td>{{$cuota['Propietario']}}</td>
|
||||
<td>{{$cuota['Numero']}}</td>
|
||||
<td>{{$cuota['Banco']}}</td>
|
||||
<td>{{$format->pesos($cuota['Valor'])}}</td>
|
||||
<td>{{$cuota['Dia']}}</td>
|
||||
<td>{{$cuota['Fecha Cheque']}} ({{$cuota['Vencida']}})</td>
|
||||
<td>{{$cuota['Fecha ISO']}}</td>
|
||||
<td>
|
||||
<div class="ui calendar" data-cuota="{{$cuota['id']}}">
|
||||
<div class="ui icon input">
|
||||
<input type="text" name="fecha_deposito{{$cuota['id']}}" />
|
||||
<i class="calendar icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<button class="ui icon button depositar" data-cuota="{{$cuota['id']}}">
|
||||
<i class="dollar icon"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('layout.head.styles.datatables')
|
||||
@include('layout.body.scripts.datatables')
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
$(document).ready(() => {
|
||||
const cuotas_tables = new DataTable('#cuotas', {
|
||||
language: {
|
||||
info: 'Mostrando página _PAGE_ de _PAGES_',
|
||||
infoEmpty: 'No hay cuotas pendientes',
|
||||
infoFiltered: '(filtrado de _MAX_ cuotas)',
|
||||
lengthMenu: 'Mostrando de a _MENU_ cuotas',
|
||||
zeroRecords: 'No se encotró cuotas con ese criterio',
|
||||
search: 'Buscar: '
|
||||
},
|
||||
columnDefs: [
|
||||
{
|
||||
target: 9,
|
||||
visible: false
|
||||
},
|
||||
{
|
||||
target: 2,
|
||||
visible: false,
|
||||
searchable: false
|
||||
}
|
||||
],
|
||||
order: [
|
||||
[9, 'desc'],
|
||||
[0, 'asc'],
|
||||
[2, 'asc']
|
||||
]
|
||||
})
|
||||
$('.ui.calendar').calendar({
|
||||
type: 'date',
|
||||
formatter: {
|
||||
date: 'DD-MM-YYYY'
|
||||
}
|
||||
})
|
||||
$('.depositar.button').click(event => {
|
||||
const button = $(event.currentTarget)
|
||||
const cuota_id = button.data('cuota')
|
||||
const calendar = $(".ui.calendar[data-cuota='" + cuota_id + "']").calendar('get date')
|
||||
const fecha = [calendar.getFullYear(), calendar.getMonth()+1, calendar.getDate()].join('-')
|
||||
fetch('{{$urls->api}}/ventas/cuota/depositar', {
|
||||
method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({cuota_id, fecha})
|
||||
}).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
if (data.depositada) {
|
||||
const button = $(".depositar.button[data-cuota='" + data.cuota_id + "']")
|
||||
const cell = button.parent()
|
||||
const row = cell.parent()
|
||||
cuotas_tables.row(row).remove().draw()
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
94
app/resources/views/ventas/edit.blade.php
Normal file
@ -0,0 +1,94 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h2 class="ui header">Editar Venta</h2>
|
||||
<form class="ui form" id="edit_form">
|
||||
<div class="inline field">
|
||||
<label for="valor">Valor</label>
|
||||
<div class="ui right labeled input">
|
||||
<input type="text" id="valor" name="valor" value="{{$venta->valor}}" />
|
||||
<div class="ui label">UF</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="inline field">
|
||||
<label for="fecha">Fecha Promesa</label>
|
||||
<div class="ui calendar" id="fecha_calendar">
|
||||
<div class="ui icon input">
|
||||
<input type="text" name="fecha" id="fecha" />
|
||||
<i class="calendar icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="ui button">
|
||||
Guardar
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
function getMonthsList() {
|
||||
const formatter = new Intl.DateTimeFormat('es-CL', {month: 'long'})
|
||||
const months = []
|
||||
let m = ''
|
||||
for (let i = 0; i < 12; i ++) {
|
||||
m = formatter.format((new Date()).setMonth(i))
|
||||
months.push(m.charAt(0).toUpperCase() + m.slice(1))
|
||||
}
|
||||
return months
|
||||
}
|
||||
function redirect() {
|
||||
const uri = '{{$urls->base}}/venta/{{$venta->id}}'
|
||||
window.location = uri
|
||||
}
|
||||
function editVenta() {
|
||||
const original = {
|
||||
valor: {{$venta->valor}},
|
||||
fecha: new Date('{{$venta->fecha->format('Y-m-d')}}T00:00:00')
|
||||
}
|
||||
const collator = new Intl.Collator('es-CL')
|
||||
const data = {}
|
||||
Object.keys(original).forEach(name => {
|
||||
let val = $("[name='" + name + "']").val()
|
||||
if (name === 'fecha') {
|
||||
val = $('#fecha_calendar').calendar('get date')
|
||||
if (val.getTime() !== original[name].getTime()) {
|
||||
data[name] = [val.getFullYear(), (''+(val.getMonth()+1)).padStart(2, '0'), (''+val.getDate()).padStart(2, '0')].join('-')
|
||||
}
|
||||
return
|
||||
}
|
||||
if (collator.compare(val, original[name]) !== 0) {
|
||||
data[name] = val
|
||||
}
|
||||
})
|
||||
if (Object.keys(data).length === 0) {
|
||||
redirect()
|
||||
return
|
||||
}
|
||||
const uri = '{{$urls->api}}/venta/{{$venta->id}}'
|
||||
return fetch(uri,
|
||||
{method: 'put', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(data)}
|
||||
).then(response => {
|
||||
if (response.ok) {
|
||||
redirect()
|
||||
}
|
||||
})
|
||||
}
|
||||
$(document).ready(() => {
|
||||
$('#fecha_calendar').calendar({
|
||||
type: 'date',
|
||||
initialDate: '{{$venta->fecha->format('Y-m-d')}}',
|
||||
text: {
|
||||
months: getMonthsList()
|
||||
}
|
||||
})
|
||||
$('#edit_form').submit(event => {
|
||||
event.preventDefault()
|
||||
editVenta()
|
||||
return false
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
302
app/resources/views/ventas/list.blade.php
Normal file
@ -0,0 +1,302 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_title')
|
||||
Ventas
|
||||
@endsection
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h2 class="ui header">Listado de Ventas</h2>
|
||||
<h4 class="ui dividing header">
|
||||
<div class="ui two column grid">
|
||||
<div id="list_title" class="column">Proyectos</div>
|
||||
<div class="right aligned column">
|
||||
<div class="ui tiny icon buttons">
|
||||
<button class="ui button" id="up_button">
|
||||
<i class="up arrow icon"></i>
|
||||
</button>
|
||||
<button class="ui button" id="refresh_button">
|
||||
<i class="refresh icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</h4>
|
||||
<div class="ui link selection list" id="proyectos"></div>
|
||||
<table class="ui table" id="data"></table>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('layout.head.styles.datatables')
|
||||
@include('layout.body.scripts.datatables')
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
class Venta {
|
||||
id
|
||||
propiedad
|
||||
propietario
|
||||
valor
|
||||
fecha
|
||||
estado
|
||||
|
||||
constructor({id, propiedad, propietario, valor, fecha, estado}) {
|
||||
this.id = id
|
||||
this.propiedad = propiedad
|
||||
this.propietario = propietario
|
||||
this.valor = valor
|
||||
this.fecha = fecha
|
||||
this.estado = estado
|
||||
}
|
||||
|
||||
draw(formatter, dateFormatter) {
|
||||
const tipo = this.estado.tipo_estado_venta.descripcion
|
||||
const date = new Date(this.fecha)
|
||||
return $('<tr></tr>').append(
|
||||
$('<td></td>').attr('data-order', this.propiedad.departamentos[0].descripcion).append(
|
||||
$('<a></a>').attr('href', '{{$urls->base}}/venta/' + this.id).html(this.propiedad.summary)
|
||||
)
|
||||
).append(
|
||||
$('<td></td>').append(
|
||||
$('<a></a>').attr('href', '{{$urls->base}}/search?tipo=propietario&query=' + encodeURIComponent(this.propietario.nombre_completo)).html(this.propietario.nombre_completo)
|
||||
)
|
||||
).append(
|
||||
$('<td></td>').html(formatter.format(this.valor) + ' UF')
|
||||
).append(
|
||||
$('<td></td>').html(this.propiedad.departamentos[0].proyecto_tipo_unidad.abreviacion + ' (' + formatter.format(this.propiedad.departamentos[0].proyecto_tipo_unidad.vendible) + ' m²)')
|
||||
).append(
|
||||
$('<td></td>').html(formatter.format(this.valor / this.propiedad.departamentos[0].proyecto_tipo_unidad.vendible) + ' UF/m²')
|
||||
).append(
|
||||
$('<td></td>').attr('data-order', this.fecha).html(dateFormatter.format(date))
|
||||
).append(
|
||||
$('<td></td>').html(tipo.charAt(0).toUpperCase() + tipo.slice(1))
|
||||
)
|
||||
}
|
||||
}
|
||||
const ventas = {
|
||||
ids: {
|
||||
title: '',
|
||||
proyectos: '',
|
||||
table: '',
|
||||
buttons: {
|
||||
up: '',
|
||||
refresh: ''
|
||||
}
|
||||
},
|
||||
data: {
|
||||
id: 0,
|
||||
proyecto: '',
|
||||
proyectos: JSON.parse('{!! json_encode($proyectos) !!}'),
|
||||
venta_ids: [],
|
||||
ventas: []
|
||||
},
|
||||
loading: {
|
||||
ventas: false
|
||||
},
|
||||
formatters: {
|
||||
number: new Intl.NumberFormat('es-CL', {minimumFractionDigits: 2, maximumFractionDigits: 2}),
|
||||
date: new Intl.DateTimeFormat('es-CL')
|
||||
},
|
||||
table: null,
|
||||
get: function() {
|
||||
return {
|
||||
ventas: proyecto_id => {
|
||||
this.data.venta_ids = []
|
||||
this.data.ventas = []
|
||||
return fetch('{{$urls->api}}/ventas',
|
||||
{method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({proyecto_id})}
|
||||
).then(response => {
|
||||
this.loading.precios = false
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
if (data.total > 0) {
|
||||
this.data.id = data.proyecto.id
|
||||
this.data.proyecto = data.proyecto.descripcion
|
||||
this.data.venta_ids = data.ventas
|
||||
const promises = []
|
||||
data.ventas.forEach(venta_id => {
|
||||
const promise = this.get().venta(venta_id)
|
||||
/*promise.then(() => {
|
||||
this.draw().ventas(true)
|
||||
})*/
|
||||
promises.push(promise)
|
||||
})
|
||||
Promise.all(promises).then(() => {
|
||||
this.draw().ventas()
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
venta: venta_id => {
|
||||
return fetch('{{$urls->api}}/venta/' + venta_id).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
if (typeof data.venta === 'undefined') {
|
||||
console.error(venta_id, data.error)
|
||||
return
|
||||
}
|
||||
this.add().venta(data.venta)
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
add: function() {
|
||||
return {
|
||||
venta: data => {
|
||||
const venta = new Venta({
|
||||
id: data.id,
|
||||
propiedad: data.propiedad,
|
||||
propietario: data.propietario,
|
||||
valor: data.valor,
|
||||
fecha: data.fecha,
|
||||
estado: data.current_estado
|
||||
})
|
||||
this.data.ventas.push(venta)
|
||||
}
|
||||
}
|
||||
},
|
||||
draw: function() {
|
||||
return {
|
||||
proyectos: () => {
|
||||
const title = $(this.ids.title)
|
||||
const parent = $(this.ids.proyectos)
|
||||
const table = $(this.ids.table)
|
||||
|
||||
table.hide()
|
||||
parent.html('')
|
||||
this.loading.ventas = false
|
||||
if (this.table !== null) {
|
||||
this.table.destroy()
|
||||
this.table = null
|
||||
}
|
||||
|
||||
title.html('Proyectos')
|
||||
|
||||
this.data.proyectos.forEach(proyecto => {
|
||||
parent.append(
|
||||
$('<div></div>').addClass('item proyecto').attr('data-proyecto', proyecto.id).html(proyecto.descripcion).css('cursor', 'pointer')
|
||||
)
|
||||
})
|
||||
|
||||
parent.show()
|
||||
parent.find('.item.proyecto').click(this.actions().get)
|
||||
},
|
||||
ventas: (loading = false) => {
|
||||
const title = $(this.ids.title)
|
||||
const parent = $(this.ids.proyectos)
|
||||
const table = $(this.ids.table)
|
||||
|
||||
parent.hide()
|
||||
table.html('')
|
||||
this.loading.ventas = false
|
||||
if (this.table !== null) {
|
||||
this.table.destroy()
|
||||
this.table = null
|
||||
}
|
||||
|
||||
title.html('Ventas de ' + this.data.proyecto + ' [' + this.data.ventas.length + ']')
|
||||
if (loading) {
|
||||
title.append(
|
||||
$('<span></span>').addClass('ui active inline loader')
|
||||
)
|
||||
}
|
||||
|
||||
const tbody = $('<tbody></tbody>')
|
||||
this.data.ventas.forEach(venta => {
|
||||
tbody.append(venta.draw(this.formatters.number, this.formatters.date))
|
||||
})
|
||||
table.append(this.draw().header()).append(tbody)
|
||||
table.show()
|
||||
|
||||
this.table = new DataTable(table, {
|
||||
order: [[0, 'asc']],
|
||||
})
|
||||
},
|
||||
table: () => {
|
||||
const parent = $(this.ids.proyectos)
|
||||
const table = $(this.ids.table)
|
||||
if (table.length > 0) {
|
||||
return
|
||||
}
|
||||
console.debug(parent.parent())
|
||||
},
|
||||
header: () => {
|
||||
return $('<thead></thead>').append(
|
||||
$('<tr></tr>').append(
|
||||
$('<th></th>').html('Departamento')
|
||||
).append(
|
||||
$('<th></th>').html('Propietario')
|
||||
).append(
|
||||
$('<th></th>').html('Valor [UF]')
|
||||
).append(
|
||||
$('<th></th>').html('Tipologia')
|
||||
).append(
|
||||
$('<th></th>').html('UF/m²')
|
||||
).append(
|
||||
$('<th></th>').html('Fecha Venta')
|
||||
).append(
|
||||
$('<th></th>').html('Estado')
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
actions: function() {
|
||||
return {
|
||||
up: event => {
|
||||
this.draw().proyectos()
|
||||
},
|
||||
refresh: event => {
|
||||
const list = $(this.ids.proyectos)
|
||||
if (list.is(':hidden')) {
|
||||
const table = $(this.ids.table)
|
||||
table.hide()
|
||||
if (this.table !== null) {
|
||||
this.table.destroy()
|
||||
this.table = null
|
||||
}
|
||||
this.get().ventas(this.data.id)
|
||||
} else {
|
||||
this.draw().proyectos()
|
||||
}
|
||||
},
|
||||
get: event => {
|
||||
if (this.loading.ventas) {
|
||||
return false
|
||||
}
|
||||
const element = $(event.currentTarget)
|
||||
$(this.ids.proyectos + ' .item.proyecto').css('cursor', 'wait')
|
||||
this.loading.ventas = true
|
||||
const proyecto_id = element.data('proyecto')
|
||||
this.get().ventas(proyecto_id)
|
||||
}
|
||||
}
|
||||
},
|
||||
setup: function({title, proyectos_id, table_id, up_button, refresh_button}) {
|
||||
this.ids.title = title
|
||||
this.ids.proyectos = proyectos_id
|
||||
this.ids.table = table_id
|
||||
this.ids.buttons.up = up_button
|
||||
this.ids.buttons.refresh = refresh_button
|
||||
|
||||
$(this.ids.buttons.up).click(this.actions().up)
|
||||
$(this.ids.buttons.refresh).click(this.actions().refresh)
|
||||
|
||||
this.draw().proyectos()
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
ventas.setup({
|
||||
title: '#list_title',
|
||||
proyectos_id: '#proyectos',
|
||||
table_id: '#data',
|
||||
up_button: '#up_button',
|
||||
refresh_button: '#refresh_button'
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
257
app/resources/views/ventas/pagos/pendientes.blade.php
Normal file
@ -0,0 +1,257 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_title')
|
||||
Pagos Pendientes
|
||||
@endsection
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h2 class="ui header">Pagos Pendientes</h2>
|
||||
<div class="ui basic segment" id="pendientes"></div>
|
||||
<h2 class="ui header">Para Abonar<span id="total_abonar"></span></h2>
|
||||
<div class="ui basic segment" id="abonar"></div>
|
||||
<h2 class="ui header">Pagos Devueltos<span id="total_devueltos"></span></h2>
|
||||
<div class="ui basic segment" id="devueltos"></div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('layout.body.scripts.chartjs')
|
||||
@include('layout.head.styles.datatables')
|
||||
@include('layout.body.scripts.datatables')
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
const historicos = {
|
||||
id: '',
|
||||
data: {
|
||||
total: {
|
||||
pendientes: 0,
|
||||
depositados: 0
|
||||
},
|
||||
graph: {}
|
||||
},
|
||||
get: function() {
|
||||
return {
|
||||
pagos: () => {
|
||||
const uri = '{{$urls->api}}/ventas/pagos/pendientes'
|
||||
fetch(uri).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
this.data.total.pendientes = data.pagos.historicos
|
||||
this.data.total.depositados = data.abonos.historicos
|
||||
this.data.graph = data
|
||||
|
||||
this.draw().all()
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
draw: function() {
|
||||
return {
|
||||
all: () => {
|
||||
const parent = $(this.id)
|
||||
parent.append(this.draw().table())
|
||||
this.draw().graph(parent)
|
||||
},
|
||||
table: () => {
|
||||
return $('<table></table>').append(
|
||||
$('<tr></tr>').append(
|
||||
$('<td></td>').attr('rowspan', 2).html('Históricos')
|
||||
).append(
|
||||
$('<td></td>').html('Pendientes')
|
||||
).append(
|
||||
$('<td></td>').append(
|
||||
$('<a></a>').attr('href', '{{$urls->base}}/ventas/cuotas/pendientes').html(this.data.total.pendientes)
|
||||
)
|
||||
)
|
||||
).append(
|
||||
$('<tr></tr>').append(
|
||||
$('<td></td>').html('Depositadas')
|
||||
).append(
|
||||
$('<td></td>').append(
|
||||
$('<a></a>').attr('href', '{{$urls->base}}/ventas/cuotas/abonar').html(this.data.total.depositados)
|
||||
)
|
||||
)
|
||||
)
|
||||
},
|
||||
graph: parent => {
|
||||
const canvas = $('<canvas></canvas>').attr('id', 'pagos_historicos')
|
||||
parent.append(canvas)
|
||||
const chart = new Chart(canvas, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: this.data.graph.fechas,
|
||||
datasets: [
|
||||
{
|
||||
label: 'Pagos',
|
||||
data: this.data.graph.pagos.data,
|
||||
backgroundColor: this.data.graph.pagos.backgroundColor
|
||||
},
|
||||
{
|
||||
label: 'Abonos',
|
||||
data: this.data.graph.abonos.data,
|
||||
backgroundColor: this.data.graph.abonos.backgroundColor
|
||||
}
|
||||
]
|
||||
},
|
||||
options: {
|
||||
legend: {
|
||||
display: false
|
||||
},
|
||||
scales: {
|
||||
x: [
|
||||
{
|
||||
stacked: true
|
||||
}
|
||||
],
|
||||
y: [
|
||||
{
|
||||
stacked: true
|
||||
}
|
||||
]
|
||||
},
|
||||
plugins: {
|
||||
chartJSPluginBarchartBackground: {
|
||||
color: 'rgb(100, 100, 100)'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
setup: function(id) {
|
||||
this.id = id
|
||||
this.get().pagos()
|
||||
}
|
||||
}
|
||||
const depositados = {
|
||||
ids: {
|
||||
data: '',
|
||||
total: ''
|
||||
},
|
||||
data: [],
|
||||
total: 0,
|
||||
get: function() {
|
||||
return {
|
||||
pendientes: () => {
|
||||
const uri = '{{$urls->api}}/ventas/pagos/abonar'
|
||||
fetch(uri).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
this.data = data.pagos
|
||||
this.total = data.total
|
||||
this.draw().all()
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
draw: function() {
|
||||
return {
|
||||
all: () => {
|
||||
this.draw().total()
|
||||
this.draw().table($(this.ids.data))
|
||||
},
|
||||
total: () => {
|
||||
$(this.ids.total).html(' [' + this.total + ']')
|
||||
},
|
||||
table: parent => {
|
||||
const header_row = $('<tr></tr>')
|
||||
['Proyecto', 'Departamento', 'Propietario', 'Tipo', 'Fecha Deposito', 'Valor'].forEach(title => {
|
||||
header_row.append(
|
||||
$('<th></th>').html(title)
|
||||
)
|
||||
})
|
||||
const tbody = $('<tbody></tbody>')
|
||||
this.data.forEach(pago => {
|
||||
tbody.append(
|
||||
$('<tr></tr>').append(
|
||||
$('<td></td>').html(pago.proyecto)
|
||||
).append(
|
||||
$('<td></td>').html(pago.departamento)
|
||||
).append(
|
||||
$('<td></td>').html(pago.propietario)
|
||||
).append(
|
||||
$('<td></td>').html(pago.tipo)
|
||||
).append(
|
||||
$('<td></td>').html(pago.fecha)
|
||||
).append(
|
||||
$('<td></td>').html(pago.valor)
|
||||
)
|
||||
)
|
||||
})
|
||||
const table = $('<table></table>').attr('id', 'pendientes_table').append(
|
||||
$('<thead></thead>').append(header_row)
|
||||
).append(tbody)
|
||||
parent.append(table)
|
||||
const dt = new DataTable('#pendientes_table', {
|
||||
language: {
|
||||
info: 'Mostrando página _PAGE_ de _PAGES_',
|
||||
infoEmpty: 'No hay cuotas depositadas por abonar',
|
||||
infoFiltered: '(filtrado de _MAX_ cuotas)',
|
||||
lengthMenu: 'Mostrando de a _MENU_ cuotas',
|
||||
zeroRecords: 'No se encotró cuotas con ese criterio',
|
||||
search: 'Buscar: '
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
setup: function(id, total_id) {
|
||||
this.ids.data = id
|
||||
this.ids.total = total_id
|
||||
this.get().pendientes()
|
||||
}
|
||||
}
|
||||
const devueltos = {
|
||||
ids: {
|
||||
data: '',
|
||||
total: ''
|
||||
},
|
||||
data: [],
|
||||
total: 0,
|
||||
get: function() {
|
||||
return {
|
||||
devueltos: () => {
|
||||
const uri = '{{$urls->api}}/ventas/pagos/rebotes'
|
||||
fetch(uri).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
this.data = data.pagos
|
||||
this.total = data.total
|
||||
this.draw().all()
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
draw: function() {
|
||||
return {
|
||||
all: () => {
|
||||
this.draw().total()
|
||||
this.draw().table($(this.ids.data))
|
||||
},
|
||||
total: () => {
|
||||
$(this.ids.total).html(' [' + this.total + ']')
|
||||
},
|
||||
table: parent => {}
|
||||
}
|
||||
},
|
||||
setup: function(id, total_id) {
|
||||
this.ids.data = id
|
||||
this.ids.total = total_id
|
||||
this.get().devueltos()
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
historicos.setup('#pendientes')
|
||||
depositados.setup('#abonar', '#total_abonar')
|
||||
devueltos.setup('#devueltos', '#total_devueltos')
|
||||
})
|
||||
</script>
|
||||
@endpush
|
79
app/resources/views/ventas/pies/cuotas.blade.php
Normal file
@ -0,0 +1,79 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<div class="ui two column grid">
|
||||
<h1 class="four wide column header">
|
||||
<div class="content">
|
||||
<div class="ui dividing sub header">{{$venta->proyecto()->descripcion}}</div>
|
||||
{{$venta->propiedad()->summary()}}
|
||||
</div>
|
||||
</h1>
|
||||
</div>
|
||||
<h2>Cuotas - Pie</h2>
|
||||
<table class="ui table" id="cuotas">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Fecha</th>
|
||||
<th>Fecha ISO</th>
|
||||
<th>Banco</th>
|
||||
<th>Identificador</th>
|
||||
<th>Valor</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($venta->formaPago()->pie->cuotas() as $cuota)
|
||||
<tr>
|
||||
<td>{{$cuota->numero}}</td>
|
||||
<td>
|
||||
{{$cuota->pago->fecha->format('d-m-Y')}}
|
||||
</td>
|
||||
<td>
|
||||
{{$cuota->pago->fecha->format('Y-m-d')}}
|
||||
</td>
|
||||
<td>
|
||||
{{$cuota->pago->banco->nombre}}
|
||||
</td>
|
||||
<td>
|
||||
{{$cuota->pago->identificador}}
|
||||
</td>
|
||||
<td>
|
||||
{{$format->pesos($cuota->pago->valor)}}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('layout.body.scripts.datatables')
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
$(document).ready(() => {
|
||||
new DataTable('#cuotas', {
|
||||
language: {
|
||||
info: 'Mostrando página _PAGE_ de _PAGES_',
|
||||
infoEmpty: 'No hay cuotas ingresadas',
|
||||
infoFiltered: '(filtrado de _MAX_ cuotas)',
|
||||
lengthMenu: 'Mostrando de a _MENU_ cuotas',
|
||||
zeroRecords: 'No se encotró cuotas con ese criterio',
|
||||
search: 'Buscar: '
|
||||
},
|
||||
columnDefs: [
|
||||
{
|
||||
target: 2,
|
||||
visible: false,
|
||||
searchable: false
|
||||
}
|
||||
],
|
||||
order: [
|
||||
[0, 'asc'],
|
||||
[2, 'asc']
|
||||
]
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
142
app/resources/views/ventas/pies/cuotas/add.blade.php
Normal file
@ -0,0 +1,142 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<div class="ui two column grid">
|
||||
<h1 class="four wide column header">
|
||||
<div class="content">
|
||||
<div class="ui dividing sub header">{{$venta->proyecto()->descripcion}}</div>
|
||||
{{$venta->propiedad()->summary()}}
|
||||
</div>
|
||||
</h1>
|
||||
</div>
|
||||
<h2>Agregar Cuotas - Pie</h2>
|
||||
<form class="ui form" id="add_form" action="{{$urls->base}}/ventas/pie/{{$pie->id}}/cuotas/add" method="post">
|
||||
<table class="ui table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Fecha</th>
|
||||
<th>Banco</th>
|
||||
<th>Identificador</th>
|
||||
<th>Valor</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="cuotas">
|
||||
@for ($i = count($pie->cuotas()); $i < $pie->cuotas - count($pie->cuotas()); $i ++)
|
||||
<tr>
|
||||
<td>{{$i + 1}}</td>
|
||||
<td>
|
||||
<div class="inline field">
|
||||
<div class="ui calendar fecha" data-index="{{$i}}">
|
||||
<div class="ui icon input">
|
||||
<input type="text" name="fecha{{$i}}" />
|
||||
<i class="calendar icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
<button class="ui mini compact basic icon button copy fecha" type="button" data-index="{{$i}}">
|
||||
<i class="down arrow icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="ui search selection dropdown banco" data-index="{{$i}}">
|
||||
<input type="hidden" name="banco{{$i}}" />
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Banco</div>
|
||||
<div class="menu">
|
||||
@foreach ($bancos as $banco)
|
||||
@if ($banco->nombre === '')
|
||||
@continue
|
||||
@endif
|
||||
<div class="item" data-value="{{$banco->id}}">{{$banco->nombre}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
<button class="ui mini compact basic icon button copy banco" type="button" data-index="{{$i}}">
|
||||
<i class="down arrow icon"></i>
|
||||
</button>
|
||||
</td>
|
||||
<td>
|
||||
<div class="ui input">
|
||||
<input type="text" name="identificador{{$i}}" />
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="inline field">
|
||||
<div class="ui left labeled input">
|
||||
<div class="ui label">$</div>
|
||||
<input type="text" name="valor{{$i}}" />
|
||||
</div>
|
||||
<button class="ui mini compact basic icon button copy valor" type="button" data-index="{{$i}}">
|
||||
<i class="down arrow icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endfor
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="5">
|
||||
<button class="ui button" type="submit">
|
||||
Agregar
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('layout.body.scripts.dayjs')
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
function setDate(index, calendar, date = new Date()) {
|
||||
const d = dayjs(date)
|
||||
$(calendar).calendar('set date', new Date(d.add(index, 'M').valueOf()))
|
||||
}
|
||||
function formatValor(valor) {
|
||||
if (valor.length < 3) {
|
||||
return valor
|
||||
}
|
||||
let new_valor = parseInt(valor.split('.').join(''))
|
||||
const formatter = new Intl.NumberFormat('es-CL', {style: 'decimal', maximumFractionDigits: 0})
|
||||
return formatter.format(new_valor)
|
||||
}
|
||||
$(document).ready(() => {
|
||||
$('.fecha.calendar').calendar(calendar_date_options).each(setDate)
|
||||
$('.copy.fecha').click(event => {
|
||||
const index = $(event.currentTarget).data('index')
|
||||
const calendar = $(".fecha.calendar[data-index='" + index + "']")
|
||||
const fecha = calendar.calendar('get date')
|
||||
for (let i = index + 1; i < {{$pie->cuotas - count($pie->cuotas())}}; i ++) {
|
||||
setDate(i - index, $(".fecha.calendar[data-index='" + i + "']"), fecha)
|
||||
}
|
||||
})
|
||||
$('.banco.ui.dropdown').dropdown()
|
||||
$('.copy.banco').click(event => {
|
||||
const index = $(event.currentTarget).data('index')
|
||||
const banco = $(".banco.dropdown[data-index='" + index + "']").dropdown('get value')
|
||||
for (let i = index + 1; i < {{$pie->cuotas - count($pie->cuotas())}}; i ++) {
|
||||
$(".banco.dropdown[data-index='" + i + "']").dropdown('set selected', banco)
|
||||
}
|
||||
})
|
||||
$("input[name^='valor']").each((index, input) => {
|
||||
$(input).change(event => {
|
||||
const valor = $(event.currentTarget).val()
|
||||
$(event.currentTarget).val(formatValor(valor))
|
||||
})
|
||||
})
|
||||
$('.copy.valor').click(event => {
|
||||
const index = $(event.currentTarget).data('index')
|
||||
const valor = $("[name='valor" + index + "']").val()
|
||||
for (let i = index + 1; i < {{$pie->cuotas - count($pie->cuotas())}}; i ++) {
|
||||
$("[name='valor" + i + "']").val(valor)
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
676
app/resources/views/ventas/precios/list.blade.php
Normal file
@ -0,0 +1,676 @@
|
||||
@extends('layout.base')
|
||||
|
||||
|
||||
@section('page_title')
|
||||
Precios - Listado
|
||||
@endsection
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h2 class="ui header">Listado de Precios</h2>
|
||||
<div id="list">
|
||||
<h4 class="ui dividing header">
|
||||
<div class="ui two column grid">
|
||||
<div id="list_title" class="column"></div>
|
||||
<div class="right aligned column">
|
||||
<div class="ui tiny icon buttons">
|
||||
<button class="ui button" id="up_button">
|
||||
<i class="up arrow icon"></i>
|
||||
</button>
|
||||
<button class="ui button" id="refresh_button">
|
||||
<i class="refresh icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
<button class="ui tiny green icon button" id="add_button">
|
||||
<i class="plus icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</h4>
|
||||
<div class="ui link selection list" id="proyectos"></div>
|
||||
<table class="ui table" id="list_data"></table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui modal" id="list_modal">
|
||||
<div class="header">
|
||||
Actualizar <span id="modal_title"></span>
|
||||
<button class="ui right floated icon button"><i class="close icon"></i></button>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="ui form">
|
||||
<input type="hidden" name="type" value="" />
|
||||
<input type="hidden" name="id" value="" />
|
||||
<div class="inline field">
|
||||
<label for="fecha">Fecha</label>
|
||||
<div class="ui calendar" id="fecha">
|
||||
<div class="ui input left icon">
|
||||
<i class="calendar icon"></i>
|
||||
<input type="text" placeholder="Fecha" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="inline field">
|
||||
<label for="valor">Valor</label>
|
||||
<div class="ui right labeled input">
|
||||
<input type="text" id="valor" name="valor" />
|
||||
<div class="ui basic label">UF</div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="ui button" id="send">
|
||||
Actualizar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('page_styles')
|
||||
<style>
|
||||
.show-unidades, .linea {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
class Unidad {
|
||||
data = {
|
||||
id: 0,
|
||||
nombre: '',
|
||||
fecha: '',
|
||||
precio: 0,
|
||||
superficie: 0,
|
||||
tipo: '',
|
||||
linea: 0
|
||||
}
|
||||
|
||||
constructor({id, nombre, fecha, precio, superficie, tipo, linea}) {
|
||||
this.data.id = id
|
||||
this.data.nombre = nombre
|
||||
this.data.fecha = fecha
|
||||
this.data.precio = precio
|
||||
this.data.superficie = superficie
|
||||
this.data.tipo = tipo
|
||||
this.data.linea = linea
|
||||
}
|
||||
|
||||
unitario() {
|
||||
return this.data.precio / this.data.superficie
|
||||
}
|
||||
draw(formatter) {
|
||||
const date = new Date(this.data.fecha)
|
||||
const dateFormatter = new Intl.DateTimeFormat('es-CL')
|
||||
return $('<tr></tr>').addClass('unidad').attr('data-linea', this.data.linea).append(
|
||||
$('<td></td>').html(this.data.nombre)
|
||||
).append(
|
||||
$('<td></td>')
|
||||
).append(
|
||||
$('<td></td>').html(dateFormatter.format(date))
|
||||
).append(
|
||||
$('<td></td>').html(formatter.format(this.data.precio) + ' UF')
|
||||
).append(
|
||||
$('<td></td>').html(formatter.format(this.unitario()) + ' UF/m²')
|
||||
).append(
|
||||
$('<td></td>').append(
|
||||
$('<button></button>').addClass('ui tiny green icon button add_unidad')
|
||||
.attr('data-id', this.data.id)
|
||||
.attr('data-tipo', this.data.tipo)
|
||||
.attr('data-unidad', this.data.nombre).append(
|
||||
$('<i></i>').addClass('plus icon')
|
||||
).click(precios.actions().add().unidad)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
class Linea {
|
||||
data = {
|
||||
id: 0,
|
||||
nombre: '',
|
||||
orientacion: '',
|
||||
superficie: 0,
|
||||
unidades: [],
|
||||
}
|
||||
|
||||
constructor({id, nombre, orientacion, superficie}) {
|
||||
this.data.id = id
|
||||
this.data.nombre = nombre
|
||||
this.data.orientacion = orientacion
|
||||
this.data.superficie = superficie
|
||||
}
|
||||
|
||||
precio() {
|
||||
let sum = 0
|
||||
this.data.unidades.forEach(unidad => {
|
||||
sum += unidad.data.precio
|
||||
})
|
||||
return sum / this.data.unidades.length
|
||||
}
|
||||
unitario() {
|
||||
return this.precio() / this.data.superficie
|
||||
}
|
||||
add(data) {
|
||||
if (this.data.id !== data.unidad.subtipo) {
|
||||
return
|
||||
}
|
||||
let unidad = this.data.unidades.find(unidad => unidad.data.id === data.unidad.id)
|
||||
if (typeof unidad !== 'undefined') {
|
||||
return
|
||||
}
|
||||
const tipo = data.unidad.proyecto_tipo_unidad.tipo_unidad.descripcion
|
||||
unidad = new Unidad({
|
||||
id: data.unidad.id,
|
||||
nombre: data.unidad.descripcion,
|
||||
fecha: data.estado_precio.fecha,
|
||||
precio: data.valor,
|
||||
superficie: this.data.superficie,
|
||||
tipo: tipo.charAt(0).toUpperCase() + tipo.slice(1),
|
||||
linea: this.data.id
|
||||
})
|
||||
this.data.unidades.push(unidad)
|
||||
}
|
||||
draw(formatter) {
|
||||
const row1 = $('<tr></tr>').attr('data-id', this.data.id).attr('data-status', 'closed').append(
|
||||
$('<td></td>').addClass('linea').append($('<strong></strong>').html(this.data.nombre)).append(
|
||||
$('<i></i>').addClass('right caret icon')
|
||||
)
|
||||
).append(
|
||||
$('<td></td>').addClass('linea').append($('<strong></strong>').html(this.data.orientacion))
|
||||
).append(
|
||||
$('<td></td>').addClass('linea')
|
||||
).append(
|
||||
$('<td></td>').addClass('linea').append($('<strong></strong>').html(formatter.format(this.precio()) + ' UF'))
|
||||
).append(
|
||||
$('<td></td>').addClass('linea').append($('<strong></strong>').html(formatter.format(this.unitario()) + ' UF/m²'))
|
||||
).append(
|
||||
$('<td></td>').append(
|
||||
$('<button></button>').addClass('ui tiny green icon button add_linea').attr('data-id', this.data.id).append(
|
||||
$('<i></i>').addClass('plus icon')
|
||||
).click(precios.actions().add().linea)
|
||||
)
|
||||
)
|
||||
const output = [
|
||||
row1
|
||||
]
|
||||
this.data.unidades.forEach(unidad => {
|
||||
output.push(unidad.draw(formatter))
|
||||
})
|
||||
return output
|
||||
}
|
||||
}
|
||||
class Tipologia {
|
||||
data = {
|
||||
id: 0,
|
||||
tipo: '',
|
||||
nombre: '',
|
||||
descripcion: '',
|
||||
lineas: [],
|
||||
superficie: 0,
|
||||
}
|
||||
constructor({id, tipo, nombre, descripcion, superficie}) {
|
||||
this.data.id = id
|
||||
this.data.tipo = tipo
|
||||
this.data.nombre = nombre
|
||||
this.data.descripcion = descripcion
|
||||
this.data.superficie = superficie
|
||||
}
|
||||
count() {
|
||||
return this.data.lineas.reduce((sum, linea) => {
|
||||
return sum + linea.data.unidades.length
|
||||
}, 0)
|
||||
}
|
||||
precio() {
|
||||
let sum = 0
|
||||
this.data.lineas.forEach(linea => {
|
||||
sum += linea.precio()
|
||||
})
|
||||
return sum / this.data.lineas.length
|
||||
}
|
||||
unitario() {
|
||||
return this.precio() / this.data.superficie
|
||||
}
|
||||
add(data) {
|
||||
if (this.data.id !== data.unidad.proyecto_tipo_unidad.id) {
|
||||
return
|
||||
}
|
||||
let linea = this.data.lineas.find(linea => linea.data.id === data.unidad.subtipo)
|
||||
if (this.data.lineas.length === 0 || typeof linea === 'undefined') {
|
||||
linea = new Linea({
|
||||
id: data.unidad.subtipo,
|
||||
nombre: 'Linea ' + data.unidad.subtipo,
|
||||
orientacion: data.unidad.orientacion,
|
||||
superficie: data.unidad.proyecto_tipo_unidad.vendible
|
||||
})
|
||||
this.data.lineas.push(linea)
|
||||
}
|
||||
linea.add(data)
|
||||
}
|
||||
draw(formatter) {
|
||||
const output = []
|
||||
const row1 = $('<tr></tr>').attr('data-status', 'closed').attr('data-id', this.data.id)
|
||||
row1.append(
|
||||
$('<td></td>').addClass('show-unidades').html(this.data.tipo).append(
|
||||
$('<i></i>').addClass('right caret icon')
|
||||
)
|
||||
).append(
|
||||
$('<td></td>').addClass('show-unidades').html(this.data.nombre)
|
||||
).append(
|
||||
$('<td></td>').addClass('show-unidades').html(this.data.descripcion)
|
||||
).append(
|
||||
$('<td></td>').addClass('show-unidades').html(this.data.lineas.map(linea => linea.data.id).sort((a, b) => parseInt(a) - parseInt(b)).join(' - '))
|
||||
).append(
|
||||
$('<td></td>').addClass('show-unidades').html(formatter.format(this.data.superficie) + ' m²')
|
||||
).append(
|
||||
$('<td></td>').addClass('show-unidades').html(this.count())
|
||||
).append(
|
||||
$('<td></td>').addClass('show-unidades').html(formatter.format(this.precio()) + ' UF')
|
||||
).append(
|
||||
$('<td></td>').addClass('show-unidades').html(formatter.format(this.unitario()) + ' UF/m²')
|
||||
).append(
|
||||
$('<td></td>').append(
|
||||
$('<button></button>').addClass('ui tiny green icon button add_tipologia').attr('data-id', this.data.id).attr('data-tipologia', this.data.nombre).append(
|
||||
$('<i></i>').addClass('plus icon')
|
||||
).click(precios.actions().add().tipologia)
|
||||
)
|
||||
)
|
||||
const row2 = $('<tr></tr>').addClass('unidades').attr('data-tipo', this.data.id)
|
||||
const tbody = $('<tbody></tbody>')
|
||||
this.data.lineas.forEach(linea => {
|
||||
linea.draw(formatter).forEach(row => {
|
||||
tbody.append(row)
|
||||
})
|
||||
})
|
||||
const table = $('<table></table>').addClass('ui striped table')
|
||||
table.append(
|
||||
$('<thead></thead>').append(
|
||||
$('<tr></tr>').append(
|
||||
$('<th></th>').html('Unidad')
|
||||
).append(
|
||||
$('<th></th>').html('Orientación')
|
||||
).append(
|
||||
$('<th></th>').html('Desde')
|
||||
).append(
|
||||
$('<th></th>').html('Precio')
|
||||
).append(
|
||||
$('<th></th>').html('UF/m²')
|
||||
).append(
|
||||
$('<th></th>')
|
||||
)
|
||||
)
|
||||
).append(tbody)
|
||||
row2.append(
|
||||
$('<td></td>')
|
||||
).append(
|
||||
$('<td></td>').attr('colspan', 8).append(table)
|
||||
)
|
||||
output.push(row1)
|
||||
output.push(row2)
|
||||
return output
|
||||
}
|
||||
}
|
||||
const precios = {
|
||||
ids: {
|
||||
list: '',
|
||||
proyectos: '',
|
||||
buttons: {
|
||||
add: '',
|
||||
up: '',
|
||||
refresh: ''
|
||||
}
|
||||
},
|
||||
data: {
|
||||
id: 0,
|
||||
proyecto: '',
|
||||
proyectos: JSON.parse('{!! json_encode($proyectos) !!}'),
|
||||
precios: []
|
||||
},
|
||||
table: null,
|
||||
loading: {
|
||||
precios: false
|
||||
},
|
||||
get: function() {
|
||||
return {
|
||||
proyectos: () => {
|
||||
this.data.proyectos = []
|
||||
this.data.id = 0
|
||||
this.data.proyecto = ''
|
||||
|
||||
$(this.ids.buttons.add).hide()
|
||||
|
||||
return fetch('{{$urls->api}}/proyectos').then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
if (data.total > 0) {
|
||||
data.proyectos.forEach(proyecto => {
|
||||
this.data.proyectos.push({
|
||||
id: proyecto.id,
|
||||
descripcion: proyecto.descripcion
|
||||
})
|
||||
})
|
||||
this.draw().proyectos()
|
||||
}
|
||||
})
|
||||
},
|
||||
precios: proyecto_id => {
|
||||
this.data.precios = []
|
||||
return fetch('{{$urls->api}}/ventas/precios',
|
||||
{method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({proyecto_id})}
|
||||
).then(response => {
|
||||
$('.item.proyecto').css('cursor', 'default')
|
||||
this.loading.precios = false
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
if (data.total > 0) {
|
||||
this.data.id = data.precios[0].unidad.proyecto_tipo_unidad.proyecto.id
|
||||
this.data.proyecto = data.precios[0].unidad.proyecto_tipo_unidad.proyecto.descripcion
|
||||
data.precios.forEach(precio => {
|
||||
this.add().precio(precio)
|
||||
})
|
||||
this.draw().precios()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
add: function() {
|
||||
return {
|
||||
precio: data => {
|
||||
let tipologia = this.data.precios.find(tipologia => tipologia.data.id === data.unidad.proyecto_tipo_unidad.id)
|
||||
if (this.data.precios.length === 0 || typeof tipologia === 'undefined') {
|
||||
const tipo = data.unidad.proyecto_tipo_unidad.tipo_unidad.descripcion
|
||||
tipologia = new Tipologia({
|
||||
id: data.unidad.proyecto_tipo_unidad.id,
|
||||
tipo: tipo.charAt(0).toUpperCase() + tipo.slice(1),
|
||||
nombre: data.unidad.proyecto_tipo_unidad.nombre,
|
||||
descripcion: data.unidad.proyecto_tipo_unidad.abreviacion,
|
||||
superficie: data.unidad.proyecto_tipo_unidad.vendible
|
||||
})
|
||||
this.data.precios.push(tipologia)
|
||||
}
|
||||
tipologia.add(data)
|
||||
}
|
||||
}
|
||||
},
|
||||
draw: function() {
|
||||
return {
|
||||
proyectos: () => {
|
||||
const parent = $(this.ids.list)
|
||||
const header = parent.find('#list_title')
|
||||
const list = parent.find('.list')
|
||||
const table = parent.find('table.table')
|
||||
|
||||
$(this.ids.buttons.add).hide()
|
||||
$(this.ids.buttons.add).attr('data-id', '')
|
||||
$(this.ids.buttons.add).attr('data-proyecto', '')
|
||||
|
||||
header.html('Proyectos')
|
||||
table.hide()
|
||||
list.html('')
|
||||
|
||||
this.data.proyectos.forEach(proyecto => {
|
||||
list.append(
|
||||
$('<div></div>').addClass('item proyecto').attr('data-proyecto', proyecto.id).html(proyecto.descripcion).css('cursor', 'pointer')
|
||||
)
|
||||
})
|
||||
list.show()
|
||||
$('.item.proyecto').click(event => {
|
||||
if (this.loading.precios) {
|
||||
return false
|
||||
}
|
||||
const element = $(event.currentTarget)
|
||||
$('.item.proyecto').css('cursor', 'wait')
|
||||
this.loading.precios = true
|
||||
const proyecto_id = element.data('proyecto')
|
||||
this.get().precios(proyecto_id)
|
||||
})
|
||||
},
|
||||
precios: () => {
|
||||
const parent = $(this.ids.list)
|
||||
const header = parent.find('#list_title')
|
||||
const list = parent.find('.list')
|
||||
const table = parent.find('table.table')
|
||||
|
||||
$(this.ids.buttons.add).attr('data-id', this.data.id)
|
||||
$(this.ids.buttons.add).attr('data-proyecto', this.data.proyecto)
|
||||
$(this.ids.buttons.add).show()
|
||||
|
||||
header.html('Precios de ' + this.data.proyecto)
|
||||
list.hide()
|
||||
table.html('')
|
||||
|
||||
table.append(this.draw().header())
|
||||
const tbody = $('<tbody></tbody>')
|
||||
const formatter = new Intl.NumberFormat('es-CL', {minimumFractionDigits: 2, maximumFractionDigits: 2})
|
||||
this.data.precios.forEach(tipologia => {
|
||||
tipologia.draw(formatter).forEach(row => {
|
||||
tbody.append(row)
|
||||
})
|
||||
})
|
||||
table.append(tbody)
|
||||
table.show()
|
||||
|
||||
$('.show-unidades').click(this.actions().toggle().tipologia)
|
||||
$('.unidades').hide()
|
||||
$('.linea').click(this.actions().toggle().linea)
|
||||
$('.unidad').hide()
|
||||
},
|
||||
header: () => {
|
||||
return $('<thead></thead>').append(
|
||||
$('<tr></tr>').append(
|
||||
$('<th></th>').html('Tipo')
|
||||
).append(
|
||||
$('<th></th>').html('Nombre')
|
||||
).append(
|
||||
$('<th></th>').html('Tipología')
|
||||
).append(
|
||||
$('<th></th>').html('Líneas')
|
||||
).append(
|
||||
$('<th></th>').html('m² Vendibles')
|
||||
).append(
|
||||
$('<th></th>').html('#')
|
||||
).append(
|
||||
$('<th></th>').html('Precio Promedio')
|
||||
).append(
|
||||
$('<th></th>').html('UF/m²')
|
||||
).append(
|
||||
$('<th></th>')
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
actions: function() {
|
||||
return {
|
||||
toggle: () => {
|
||||
return {
|
||||
tipologia: event => {
|
||||
const th = $(event.currentTarget)
|
||||
const row = th.parent()
|
||||
const id = row.data('id')
|
||||
const status = row.attr('data-status')
|
||||
const unidades = $(".unidades[data-tipo='" + id + "']")
|
||||
if (status === 'closed') {
|
||||
unidades.show()
|
||||
row.attr('data-status', 'open')
|
||||
row.find('.caret.icon').removeClass('right').addClass('down')
|
||||
return
|
||||
}
|
||||
unidades.find('.linea').data('status', 'closed')
|
||||
unidades.find('.unidad').hide()
|
||||
unidades.hide()
|
||||
row.attr('data-status', 'closed')
|
||||
row.find('.caret.icon').removeClass('down').addClass('right')
|
||||
},
|
||||
linea: event => {
|
||||
const th = $(event.currentTarget)
|
||||
const row = th.parent()
|
||||
const id = row.data('id')
|
||||
const status = row.attr('data-status')
|
||||
const unidades = $(".unidad[data-linea='" + id + "']")
|
||||
if (status === 'closed') {
|
||||
unidades.show()
|
||||
row.attr('data-status', 'open')
|
||||
row.find('.caret.icon').removeClass('right').addClass('down')
|
||||
return
|
||||
}
|
||||
unidades.hide()
|
||||
row.attr('data-status', 'closed')
|
||||
row.find('.caret.icon').removeClass('down').addClass('right')
|
||||
}
|
||||
}
|
||||
},
|
||||
up: event => {
|
||||
this.draw().proyectos()
|
||||
},
|
||||
refresh: event => {
|
||||
const list = $(this.ids.proyectos)
|
||||
if (list.is(':hidden')) {
|
||||
this.get().precios(this.data.id)
|
||||
} else {
|
||||
this.draw().proyectos()
|
||||
}
|
||||
},
|
||||
add: () => {
|
||||
return {
|
||||
list: event => {
|
||||
const button = $(event.currentTarget)
|
||||
const id = button.data('id')
|
||||
const proyecto = button.data('proyecto')
|
||||
list_modal.data.title = 'Precios del Proyecto ' + proyecto
|
||||
list_modal.data.type = 'proyecto'
|
||||
list_modal.data.id = id
|
||||
list_modal.actions().open()
|
||||
},
|
||||
tipologia: event => {
|
||||
const button = $(event.currentTarget)
|
||||
const id = button.data('id')
|
||||
const tipologia = button.data('tipologia')
|
||||
list_modal.data.title = 'Precios de Tipología ' + tipologia
|
||||
list_modal.data.type = 'tipologia'
|
||||
list_modal.data.id = id
|
||||
list_modal.actions().open()
|
||||
},
|
||||
linea: event => {
|
||||
const button = $(event.currentTarget)
|
||||
const id = button.data('id')
|
||||
list_modal.data.title = 'Precios de la Línea ' + id
|
||||
list_modal.data.type = 'linea'
|
||||
list_modal.data.id = id
|
||||
list_modal.actions().open()
|
||||
},
|
||||
unidad: event => {
|
||||
const button = $(event.currentTarget)
|
||||
const id = button.data('id')
|
||||
const tipo = button.data('tipo')
|
||||
const unidad = button.data('unidad')
|
||||
list_modal.data.title = 'Precio de ' + tipo + ' ' + unidad
|
||||
list_modal.data.type = 'unidad'
|
||||
list_modal.data.id = id
|
||||
list_modal.actions().open()
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
setup: function() {
|
||||
$(this.ids.buttons.up).click(this.actions().up)
|
||||
$(this.ids.buttons.refresh).click(this.actions().refresh)
|
||||
$(this.ids.buttons.add).click(this.actions().add().list)
|
||||
|
||||
this.draw().proyectos()
|
||||
}
|
||||
}
|
||||
|
||||
const list_modal = {
|
||||
ids: {
|
||||
modal: '',
|
||||
title: '',
|
||||
fields: {
|
||||
type: '',
|
||||
id: '',
|
||||
calendar: '',
|
||||
valor: ''
|
||||
},
|
||||
button: ''
|
||||
},
|
||||
data: {
|
||||
title: '',
|
||||
type: '',
|
||||
id: 0
|
||||
},
|
||||
actions: function() {
|
||||
return {
|
||||
reset: () => {
|
||||
this.data.title = ''
|
||||
this.data.type = ''
|
||||
this.data.id = 0
|
||||
|
||||
$(this.ids.fields.calendar).calendar('refresh')
|
||||
$(this.ids.fields.valor).val('')
|
||||
},
|
||||
open: event => {
|
||||
this.draw()
|
||||
$(this.ids.modal).modal('show')
|
||||
},
|
||||
close: event => {
|
||||
$(this.ids.modal).modal('hide')
|
||||
this.actions().reset()
|
||||
},
|
||||
send: event => {
|
||||
const data = {
|
||||
type: $(this.ids.fields.type).val(),
|
||||
id: $(this.ids.fields.id).val(),
|
||||
fecha: $(this.ids.fields.calendar).calendar('get date'),
|
||||
valor: $(this.ids.fields.valor).val()
|
||||
}
|
||||
return fetch('{{$urls->api}}/precios/update',
|
||||
{method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(data)}
|
||||
).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
precios.get().precios(precios.data.proyecto)
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
draw: function() {
|
||||
$(this.ids.title).html(this.data.title)
|
||||
$(this.ids.modal).find("input[name='type']").val(this.data.type)
|
||||
$(this.ids.modal).find("input[name='id']").val(this.data.id)
|
||||
},
|
||||
setup: function() {
|
||||
$(this.ids.modal).modal('hide')
|
||||
$(this.ids.modal).find('.icon.button').find('.close.icon').parent().click(this.actions().close)
|
||||
|
||||
$(this.ids.fields.calendar).calendar({
|
||||
type: 'date'
|
||||
})
|
||||
$(this.ids.button).click(this.actions().send)
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(() => {
|
||||
precios.ids.list = '#list'
|
||||
precios.ids.proyectos = '#proyectos'
|
||||
precios.ids.buttons.up = '#up_button'
|
||||
precios.ids.buttons.refresh = '#refresh_button'
|
||||
precios.ids.buttons.add = '#add_button'
|
||||
precios.setup()
|
||||
|
||||
list_modal.ids.modal = '#list_modal'
|
||||
list_modal.ids.title = '#modal_title'
|
||||
list_modal.ids.fields.type = "input[name='type']"
|
||||
list_modal.ids.fields.id = "input[name='id']"
|
||||
list_modal.ids.fields.calendar = '#fecha'
|
||||
list_modal.ids.fields.valor = '#valor'
|
||||
list_modal.ids.button = '#send'
|
||||
list_modal.setup()
|
||||
})
|
||||
</script>
|
||||
@endpush
|
104
app/resources/views/ventas/propiedades/edit.blade.php
Normal file
@ -0,0 +1,104 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h2>Editar Propiedad - {{$proyecto->descripcion}} {{$propiedad->summary()}}</h2>
|
||||
<table class="ui table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Tipo</th>
|
||||
<th>Unidad</th>
|
||||
<th class="right aligned">
|
||||
<button class="ui small green circular icon button" id="add_unidad">
|
||||
<i class="plus icon"></i>
|
||||
</button>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($propiedad->unidades as $unidad)
|
||||
<tr>
|
||||
<td>{{ucwords($unidad->proyectoTipoUnidad->tipoUnidad->descripcion)}}</td>
|
||||
<td>{{$unidad->descripcion}}</td>
|
||||
<td class="right aligned">
|
||||
<button class="ui small red circular icon button remove_unidad" data-id="{{$unidad->id}}">
|
||||
<i class="remove icon"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="ui modal" id="add_modal">
|
||||
<div class="content">
|
||||
<h3 class="header">Agregar</h3>
|
||||
<div class="ui form" id="add_form">
|
||||
<div class="field">
|
||||
<label for="tipo">Tipo</label>
|
||||
<select id="tipo" name="tipo" class="ui search selection dropdown">
|
||||
@foreach ($tiposUnidades as $tipoUnidad)
|
||||
<option value="{{$tipoUnidad->id}}">{{ucwords($tipoUnidad->descripcion)}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="unidad">Unidad</label>
|
||||
<select id="unidad" name="unidad" class="ui search selection dropdown" size="4"></select>
|
||||
</div>
|
||||
<button class="ui button">Agregar</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
const unidades = {
|
||||
@foreach($tiposUnidades as $tipoUnidad)
|
||||
{{$tipoUnidad->id}}: [
|
||||
@foreach($unidades as $unidad)
|
||||
@if ($unidad->proyectoTipoUnidad->tipoUnidad->id === $tipoUnidad->id)
|
||||
{
|
||||
value: {{$unidad->id}},
|
||||
text: '{{$unidad->descripcion}}',
|
||||
name: '{{$unidad->descripcion}}'
|
||||
},
|
||||
@endif
|
||||
@endforeach
|
||||
],
|
||||
@endforeach
|
||||
}
|
||||
function changeTipoUnidad(tipo_unidad_id) {
|
||||
$('#unidad').dropdown('change values', unidades[tipo_unidad_id].sort((a, b) => a.text.padStart(4, '0').localeCompare(b.text.padStart(4, '0'))))
|
||||
}
|
||||
function addUnidad() {
|
||||
$('#add_modal').modal('show')
|
||||
}
|
||||
function removeUnidad(unidad_id) {
|
||||
console.debug(unidad_id)
|
||||
}
|
||||
$(document).ready(() => {
|
||||
$('#add_unidad').click(event => {
|
||||
addUnidad()
|
||||
})
|
||||
$('.remove_unidad').click(event => {
|
||||
const unidad_id = $(event.currentTarget).data('id')
|
||||
removeUnidad(unidad_id)
|
||||
})
|
||||
$('#add_modal').modal()
|
||||
const tipo = $('#tipo')
|
||||
tipo.dropdown()
|
||||
tipo.change(event => {
|
||||
changeTipoUnidad(tipo.val())
|
||||
})
|
||||
$('#unidad').dropdown()
|
||||
changeTipoUnidad(tipo.val())
|
||||
$('#add_form').submit(event => {
|
||||
event.preventDefault()
|
||||
tipo.model('hide')
|
||||
return false
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
226
app/resources/views/ventas/propietarios/edit.blade.php
Normal file
@ -0,0 +1,226 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_title')
|
||||
Editar Propietario
|
||||
@endsection
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h2 class="ui header">Editar Propietario</h2>
|
||||
<form class="ui form" id="edit_form">
|
||||
<input type="hidden" name="venta_id" value="{{$venta_id}}" />
|
||||
<div class="field">
|
||||
<label for="rut">RUT</label>
|
||||
{{$propietario->rut()}}
|
||||
</div>
|
||||
<div class="fields">
|
||||
<div class="field">
|
||||
<label for="nombres">Nombre</label>
|
||||
<input type="text" name="nombres" id="nombres" value="{{trim($propietario->nombres)}}" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="apellido_paterno">Apellido Paterno</label>
|
||||
<input type="text" id="apellido_paterno" name="apellido_paterno" value="{{$propietario->apellidos['paterno']}}" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="apellido_materno">Apellido Materno</label>
|
||||
<input type="text" id="apellido_materno" name="apellido_materno" value="{{$propietario->apellidos['materno']}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="fields">
|
||||
<div class="field">
|
||||
<label for="calle">Dirección</label>
|
||||
<input type="text" name="calle" id="calle" value="{{$propietario->datos->direccion->calle}}" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="numero">Número</label>
|
||||
<input type="number" id="numero" size="6" name="numero" value="{{$propietario->datos->direccion->numero}}" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="extra">Información Adicional*</label>
|
||||
<input type="text" id="extra" name="extra" value="{{$propietario->datos->direccion->extra}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="fields">
|
||||
<div class="field">
|
||||
<label for="region">Región</label>
|
||||
<select id="region" name="region" class="ui search selection dropdown">
|
||||
@foreach($regiones as $region)
|
||||
<option value="{{$region->id}}"{{($propietario->datos->direccion->comuna->provincia->region->id === $region->id) ? ' selected="selected"' : ''}}>{{$region->numeral}} {{$region->descripcion}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="comunas">Comuna</label>
|
||||
<select class="ui search selection dropdown" name="comuna" id="comunas"></select>
|
||||
</div>
|
||||
</div>
|
||||
<button class="ui button" id="guardar_button">Guardar</button>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
function drawComunas({parent, comunas}) {
|
||||
parent.html('')
|
||||
comunas.forEach(comuna => {
|
||||
const option = $('<option></option>')
|
||||
option.attr('value', comuna.id).html(comuna.descripcion)
|
||||
if (comuna.id === {{$propietario->datos->direccion->comuna->id}}) {
|
||||
option.prop('selected', true)
|
||||
}
|
||||
parent.append(option)
|
||||
})
|
||||
parent.show()
|
||||
parent.dropdown()
|
||||
}
|
||||
function findComunas(direccion) {
|
||||
const original_id = $("[name='comuna']").val()
|
||||
const uri = '{{$urls->api}}/direcciones/comunas/find'
|
||||
const data = {direccion}
|
||||
return fetch(uri,
|
||||
{method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(data)}
|
||||
).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
if (data.total === 0) {
|
||||
return
|
||||
}
|
||||
const comuna_id = data.comunas[0].id
|
||||
if (comuna_id === original_id) {
|
||||
return
|
||||
}
|
||||
const parent = $('#comunas')
|
||||
parent.dropdown('set selected', comuna_id)
|
||||
})
|
||||
}
|
||||
function getComunas(region_id) {
|
||||
const parent = $('#comunas')
|
||||
parent.hide()
|
||||
const uri = '{{$urls->api}}/direcciones/region/' + region_id + '/comunas'
|
||||
return fetch(uri).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
if (data.total === 0) {
|
||||
return
|
||||
}
|
||||
drawComunas({parent, comunas: data.comunas})
|
||||
})
|
||||
}
|
||||
function redirect() {
|
||||
window.location = '{{$urls->base}}/venta/{{$venta_id}}'
|
||||
}
|
||||
function changeDireccion() {
|
||||
const names = [
|
||||
'calle',
|
||||
'numero',
|
||||
'extra'
|
||||
]
|
||||
const originals = [
|
||||
'{{trim($propietario->datos->direccion->calle)}}',
|
||||
'{{trim($propietario->datos->direccion->numero)}}',
|
||||
'{{trim($propietario->datos->direccion->extra)}}'
|
||||
]
|
||||
const values = []
|
||||
names.forEach(name => {
|
||||
const val = $("[name='" + name + "']").val()
|
||||
values.push(val)
|
||||
})
|
||||
const collator = new Intl.Collator('es')
|
||||
if (collator.compare(originals.join(' '), values.join(' ')) !== 0) {
|
||||
findComunas(values.join(' ').trim())
|
||||
}
|
||||
}
|
||||
function watchChangeDireccion() {
|
||||
const watched = [
|
||||
'calle',
|
||||
'numero',
|
||||
'extra'
|
||||
]
|
||||
watched.forEach(name => {
|
||||
$("[name='" + name + "']").change(event => {
|
||||
changeDireccion()
|
||||
})
|
||||
})
|
||||
}
|
||||
function editPropietario() {
|
||||
const uri = '{{$urls->api}}/ventas/propietario/{{$propietario->rut}}'
|
||||
const names = [
|
||||
'nombres',
|
||||
'apellido_paterno',
|
||||
'apellido_materno'
|
||||
]
|
||||
const values = [
|
||||
'{{trim($propietario->nombres)}}',
|
||||
'{{trim($propietario->apellidos['paterno'])}}',
|
||||
'{{trim($propietario->apellidos['materno'])}}'
|
||||
]
|
||||
const direccion_names = [
|
||||
'calle',
|
||||
'numero',
|
||||
'extra',
|
||||
'comuna'
|
||||
]
|
||||
const direccion_values = [
|
||||
'{{trim($propietario->datos->direccion->calle)}}',
|
||||
'{{$propietario->datos->direccion->numero}}',
|
||||
'{{trim($propietario->datos->direccion->extra)}}',
|
||||
'{{$propietario->datos->direccion->comuna->id}}'
|
||||
]
|
||||
const data = {}
|
||||
const collator = new Intl.Collator('es')
|
||||
names.forEach((name, index) => {
|
||||
const val = $("[name='" + name + "']").val()
|
||||
if (collator.compare(val, values[index]) !== 0) {
|
||||
console.debug(name, val, values[index], collator.compare(val, values[index]))
|
||||
data[name] = val
|
||||
}
|
||||
})
|
||||
direccion_names.forEach((name, index) => {
|
||||
const val = $("[name='" + name + "']").val()
|
||||
if (collator.compare(val, direccion_values[index]) !== 0) {
|
||||
if (typeof data['direccion'] === 'undefined') {
|
||||
data['direccion'] = {}
|
||||
}
|
||||
console.debug(name, val, direccion_values[index])
|
||||
data['direccion'][name] = val
|
||||
}
|
||||
})
|
||||
if (Object.keys(data).length === 0) {
|
||||
redirect()
|
||||
return
|
||||
}
|
||||
return fetch(uri,
|
||||
{method: 'put', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(data)}
|
||||
).then(response => {
|
||||
if (response.ok) {
|
||||
redirect()
|
||||
}
|
||||
})
|
||||
}
|
||||
$(document).ready(() => {
|
||||
const regiones = $("select[name='region']")
|
||||
regiones.dropdown()
|
||||
regiones.change(event => {
|
||||
const region_id = $(event.currentTarget).val()
|
||||
getComunas(region_id)
|
||||
})
|
||||
$('#comunas').hide()
|
||||
getComunas({{$propietario->datos->direccion->comuna->provincia->region->id}})
|
||||
$('#edit_form').submit(event => {
|
||||
event.preventDefault()
|
||||
editPropietario({{$propietario->rut}})
|
||||
return false
|
||||
})
|
||||
$('#guardar_button').click(event => {
|
||||
editPropietario({{$propietario->rut}})
|
||||
})
|
||||
watchChangeDireccion()
|
||||
})
|
||||
</script>
|
||||
@endpush
|
7
app/resources/views/ventas/propietarios/show.blade.php
Normal file
@ -0,0 +1,7 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
{{$propietario->nombreCompleto()}}
|
||||
</div>
|
||||
@endsection
|
40
app/resources/views/ventas/show.blade.php
Normal file
@ -0,0 +1,40 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_title')
|
||||
Venta {{$venta->proyecto()->descripcion}} {{$venta->propiedad()->summary()}}
|
||||
@endsection
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<div class="ui two column grid">
|
||||
<h1 class="four wide column header">
|
||||
<div class="content">
|
||||
<div class="ui dividing sub header">{{$venta->proyecto()->descripcion}}</div>
|
||||
{{$venta->propiedad()->summary()}}
|
||||
</div>
|
||||
</h1>
|
||||
<div class="right floated column">
|
||||
@include('ventas.show.propietario')
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<div class="ui fitted basic mini segment">
|
||||
@if ($venta->currentEstado()->tipoEstadoVenta->activa)
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/desistir">
|
||||
Desistir <i class="minus icon"></i>
|
||||
</a>
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/ceder">
|
||||
Ceder <i clasS="right chevron icon"></i>
|
||||
</a>
|
||||
@endif
|
||||
</div>
|
||||
<div class="ui segments">
|
||||
@include('ventas.show.propiedad')
|
||||
@include('ventas.show.detalle')
|
||||
@include('ventas.show.forma_pago', ['formaPago' => $venta->formaPago()])
|
||||
@include('ventas.show.escritura')
|
||||
@include('ventas.show.entrega')
|
||||
@include('ventas.show.comentarios')
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
88
app/resources/views/ventas/show/comentarios.blade.php
Normal file
@ -0,0 +1,88 @@
|
||||
<div class="ui inverted grey two column grid segment">
|
||||
<div class="column">
|
||||
COMENTARIOS
|
||||
</div>
|
||||
<div class="right aligned column">
|
||||
<a href="javascript: addComment()" style="color: inherit;">
|
||||
<i class="plus icon"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui segment">
|
||||
<table class="ui very basic table">
|
||||
<tbody id="comentarios"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
class Comentario
|
||||
{
|
||||
fecha
|
||||
texto
|
||||
|
||||
constructor({fecha, texto})
|
||||
{
|
||||
this.fecha = new Date(fecha + 'T00:00:00')
|
||||
this.texto = texto
|
||||
}
|
||||
draw(dateFormatter)
|
||||
{
|
||||
return $('<tr></tr>').append(
|
||||
$('<td></td>').html(dateFormatter.format(this.fecha))
|
||||
).append(
|
||||
$('<td></td>').html(this.texto)
|
||||
).append(
|
||||
$('<td></td>').addClass('right aligned').append(
|
||||
$('<a></a>').attr('href', 'javascript: removeComment();').append(
|
||||
$('<i></i>').addClass('minus icon')
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
const comentarios = {
|
||||
comentarios: [],
|
||||
id: '',
|
||||
fetch: function() {
|
||||
return {
|
||||
comentarios: () => {
|
||||
const uri = '{{$urls->api}}/venta/{{$venta->id}}/comentarios'
|
||||
return fetch(uri).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
if (data.total === 0) {
|
||||
return
|
||||
}
|
||||
data.comentarios.forEach(settings => {
|
||||
this.comentarios.push(new Comentario(settings))
|
||||
})
|
||||
this.draw().comentarios()
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
draw: function() {
|
||||
return {
|
||||
comentarios: () => {
|
||||
const body = $(this.id)
|
||||
const dateFormatter = new Intl.DateTimeFormat('es-CL', {dateStyle: 'medium'})
|
||||
body.html('')
|
||||
this.comentarios.forEach(comentario => {
|
||||
body.append(comentario.draw(dateFormatter))
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
setup: function(id) {
|
||||
this.id = id
|
||||
this.fetch().comentarios()
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
comentarios.setup('#comentarios')
|
||||
})
|
||||
</script>
|
||||
@endpush
|
38
app/resources/views/ventas/show/detalle.blade.php
Normal file
@ -0,0 +1,38 @@
|
||||
<div class="ui inverted grey two column grid segment">
|
||||
<div class="column">
|
||||
VENTA
|
||||
</div>
|
||||
<div class="right aligned column">
|
||||
<a style="color: inherit;" href="{{$urls->base}}/venta/{{$venta->id}}/edit">
|
||||
<i class="edit icon"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui segment">
|
||||
<table class="ui very basic fluid table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Valor Promesa</th>
|
||||
<th>Valor Util</th>
|
||||
<th>UF/m²</th>
|
||||
<th>Comisión</th>
|
||||
<th>
|
||||
Fecha Promesa <br/>
|
||||
Fecha Ingreso
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{{$format->ufs($venta->valor)}}</td>
|
||||
<td>{{$format->ufs($venta->util())}}</td>
|
||||
<td>{{$format->number($venta->util() / $venta->propiedad()->vendible(), 2)}} UF/m²</td>
|
||||
<td>0,00 UF (0,00%)</td>
|
||||
<td>
|
||||
{{$venta->fecha->format('d-m-Y')}}<br/>
|
||||
{{$venta->fechaIngreso->format('d-m-Y')}}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
11
app/resources/views/ventas/show/entrega.blade.php
Normal file
@ -0,0 +1,11 @@
|
||||
<div class="ui inverted grey segment">
|
||||
ENTREGA
|
||||
</div>
|
||||
<div class="ui segment">
|
||||
@if ($venta->entrega() !== null)
|
||||
@else
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/entregar">
|
||||
No <i class="right chevron icon"></i>
|
||||
</a>
|
||||
@endif
|
||||
</div>
|
22
app/resources/views/ventas/show/escritura.blade.php
Normal file
@ -0,0 +1,22 @@
|
||||
<div class="ui inverted grey segment">
|
||||
ESCRITURA
|
||||
</div>
|
||||
@if ($venta->formaPago()->escritura !== null)
|
||||
<div class="ui segment">
|
||||
Escriturado {{$venta->formaPago()->escritura->fecha->format('d-m-Y')}}
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/escritura/informe">
|
||||
Informe
|
||||
<i class="right chevron icon"></i>
|
||||
</a>
|
||||
<br />
|
||||
<a href="{{$urls->base}}/venta{{$venta->id}}/escritura/firmar">
|
||||
Firmar
|
||||
</a>
|
||||
</div>
|
||||
@else
|
||||
<div class="ui segment">
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/escriturar">
|
||||
Escriturar
|
||||
</a>
|
||||
</div>
|
||||
@endif
|