diff --git a/CLI.Dockerfile b/CLI.Dockerfile index 87fcff6..5844682 100644 --- a/CLI.Dockerfile +++ b/CLI.Dockerfile @@ -1,19 +1,22 @@ -FROM php:8.2-cli +FROM php:8.4-cli ENV TZ "${TZ}" ENV APP_NAME "${APP_NAME}" -ENV API_URL "${API_URL}" -RUN apt-get update && apt-get install -y --no-install-recommends cron rsyslog nano && rm -r /var/lib/apt/lists/* +RUN apt-get update && apt-get install -y --no-install-recommends cron rsyslog nano beanstalkd \ + && rm -r /var/lib/apt/lists/* -RUN pecl install xdebug-3.2.2 \ +RUN pecl install xdebug-3.4.2 \ && docker-php-ext-enable xdebug \ - && echo "#/bin/bash\nprintenv >> /etc/environment\ncron -f -L 11" > /root/entrypoint && chmod a+x /root/entrypoint + && echo $TZ > /etc/timezone + +COPY --chmod=550 ./cli/start_command /root/start_command COPY ./php-errors.ini /usr/local/etc/php/conf.d/docker-php-errors.ini +COPY ./php-timezone.ini /usr/local/etc/php/conf.d/docker-php-timezone.ini WORKDIR /code/bin COPY --chmod=644 ./cli/crontab /var/spool/cron/crontabs/root -CMD [ "/root/entrypoint" ] +CMD [ "/root/start_command" ] diff --git a/Dockerfile b/Dockerfile index d728129..091b51d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,12 @@ -FROM php:8.2-fpm +FROM php:8.4-fpm ENV TZ=America/Santiago -RUN apt-get update && apt-get install -y --no-install-recommends libzip-dev libicu-dev git libpng-dev unzip tzdata \ +RUN apt-get update && apt-get install -y --no-install-recommends libzip-dev libicu-dev git \ + libpng-dev unzip tzdata libxml2-dev beanstalkd \ && rm -r /var/lib/apt/lists/* \ - && docker-php-ext-install pdo pdo_mysql zip intl gd bcmath \ - && pecl install xdebug-3.3.2 \ + && docker-php-ext-install pdo pdo_mysql zip intl gd bcmath dom \ + && pecl install xdebug-3.4.2 \ && docker-php-ext-enable xdebug \ && echo $TZ > /etc/timezone diff --git a/app/.env.sample b/app/.env.sample index 3b8c145..80b806e 100644 --- a/app/.env.sample +++ b/app/.env.sample @@ -2,17 +2,18 @@ APP_URL= -MYSQL_HOST=db - COOKIE_NAME= COOKIE_DOMAIN= COOKIE_PATH=/ MAX_LOGIN_HOURS=120 -REDIS_HOST=redis -REDIS_PORT=6379 +#REDIS_HOST=redis +#REDIS_PORT=6379 DB_HOST=db DB_DATABASE=incoviba DB_USER=incoviba DB_PASSWORD= + +TOKU_URL= +TOKU_TOKEN= diff --git a/app/.gitignore b/app/.gitignore index 2501489..a2eae68 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1 +1,2 @@ **/bin +**/public/tests diff --git a/app/.phpunit-watcher.yml b/app/.phpunit-watcher.yml index 8a8274c..744f6f4 100644 --- a/app/.phpunit-watcher.yml +++ b/app/.phpunit-watcher.yml @@ -10,5 +10,5 @@ notifications: failingTests: false hideManual: true phpunit: - arguments: '--log-events-text /logs/output.txt --stop-on-failure' + arguments: '--testsuite unit --log-events-text /logs/output.txt --stop-on-failure' timeout: 180 diff --git a/app/bin/console b/app/bin/console new file mode 100755 index 0000000..84821a2 --- /dev/null +++ b/app/bin/console @@ -0,0 +1,3 @@ +#!/usr/bin/bash + +php -d auto_prepend_file=test.bootstrap.php -a diff --git a/app/bin/integration_tests b/app/bin/integration_tests new file mode 100755 index 0000000..e113cb6 --- /dev/null +++ b/app/bin/integration_tests @@ -0,0 +1,3 @@ +#!/usr/bin/bash + +bin/phpunit --testsuite acceptance $@ \ No newline at end of file diff --git a/app/bin/performance_tests b/app/bin/performance_tests new file mode 100755 index 0000000..211dd53 --- /dev/null +++ b/app/bin/performance_tests @@ -0,0 +1,3 @@ +#!/usr/bin/bash + +bin/phpunit --testsuite performance $@ \ No newline at end of file diff --git a/app/bin/unit_tests b/app/bin/unit_tests new file mode 100755 index 0000000..40dc00b --- /dev/null +++ b/app/bin/unit_tests @@ -0,0 +1,3 @@ +#!/usr/bin/bash + +./bin/phpunit --testsuite unit $@ \ No newline at end of file diff --git a/app/common/Alias/View.php b/app/common/Alias/View.php index 80df0a9..6f761a3 100644 --- a/app/common/Alias/View.php +++ b/app/common/Alias/View.php @@ -1,9 +1,6 @@ logger = $logger; + } + public function getLogger(): LoggerInterface + { + return $this->logger; + } +} diff --git a/app/common/Ideal/Repository.php b/app/common/Ideal/Repository.php index 9a46692..1014be5 100644 --- a/app/common/Ideal/Repository.php +++ b/app/common/Ideal/Repository.php @@ -24,6 +24,11 @@ abstract class Repository implements Define\Repository return $this; } + public function getConnection(): Define\Connection + { + return $this->connection; + } + public function load(array $data_row): Define\Model { $model = $this->create($data_row); @@ -189,7 +194,7 @@ abstract class Repository implements Define\Repository try { $this->connection->execute($query, $values); } catch (PDOException $exception) { - throw new EmptyResult($query, $exception); + throw new EmptyResult($query, $exception, $data); } return $this->fetchById($this->getIndex($model)); } @@ -205,10 +210,10 @@ abstract class Repository implements Define\Repository try { $result = $this->connection->execute($query, $data)->fetch(PDO::FETCH_ASSOC); if ($result === false) { - throw new EmptyResult($query); + throw new EmptyResult($query, null, $data); } } catch (PDOException $exception) { - throw new EmptyResult($query, $exception); + throw new EmptyResult($query, $exception, $data); } return $this->load($result); } @@ -224,7 +229,7 @@ abstract class Repository implements Define\Repository try { $results = $this->connection->execute($query, $data)->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $exception) { - throw new EmptyResult($query, $exception); + throw new EmptyResult($query, $exception, $data); } return array_map([$this, 'load'], $results); } @@ -240,7 +245,7 @@ abstract class Repository implements Define\Repository try { $results = $this->connection->execute($query, $data)->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $exception) { - throw new EmptyResult($query, $exception); + throw new EmptyResult($query, $exception, $data); } return $results; } diff --git a/app/common/Ideal/Service/API.php b/app/common/Ideal/Service/API.php new file mode 100644 index 0000000..70da67a --- /dev/null +++ b/app/common/Ideal/Service/API.php @@ -0,0 +1,56 @@ +values)) . ')'; } diff --git a/app/common/Implement/Database/Query/Select.php b/app/common/Implement/Database/Query/Select.php index aa4874a..1ad75d3 100644 --- a/app/common/Implement/Database/Query/Select.php +++ b/app/common/Implement/Database/Query/Select.php @@ -64,10 +64,10 @@ class Select extends Ideal\Query implements Define\Query\Select public function having(array|string $conditions): Select { if (is_string($conditions)) { - return $this->addCondition($conditions); + return $this->addHaving($conditions); } foreach ($conditions as $condition) { - $this->addCondition($condition); + $this->addHaving($condition); } return $this; } diff --git a/app/common/Implement/Exception/EmptyResult.php b/app/common/Implement/Exception/EmptyResult.php index 421ba0b..df5fa2a 100644 --- a/app/common/Implement/Exception/EmptyResult.php +++ b/app/common/Implement/Exception/EmptyResult.php @@ -6,10 +6,15 @@ use Throwable; class EmptyResult extends Exception { - public function __construct(public string $query, ?Throwable $previous = null) + public function __construct(public string $query, ?Throwable $previous = null, protected ?array $data = null) { $message = "Empty results for {$query}"; $code = 700; parent::__construct($message, $code, $previous); } + + public function getData(): ?array + { + return $this->data; + } } diff --git a/app/common/Implement/Exception/HttpException.php b/app/common/Implement/Exception/HttpException.php new file mode 100644 index 0000000..e7cc640 --- /dev/null +++ b/app/common/Implement/Exception/HttpException.php @@ -0,0 +1,13 @@ +message, Throwable::class)) { + $exception = $record->message; + $message = $this->normalizeException($exception); + $context = $record->context; + $context['exception'] = $exception; + if ($exception->getPrevious()) { + $context['previous'] = $this->walkException($exception); + } + $new_record = new LogRecord( + $record->datetime, + $record->channel, + $record->level, + json_encode($message), + $context, + $record->extra + ); + $record = $new_record; + } + $normalized = $this->normalize($record, $this->maxNormalizeDepth); + return $normalized['message']; + } + + protected function walkException(Throwable $exception, int $depth = 0): array + { + $output = []; + $currentDepth = $depth; + while ($previous = $exception->getPrevious() and $currentDepth < $this->maxNormalizeDepth) { + $output []= $this->normalizeException($previous); + } + return $output; + } +} diff --git a/app/common/Implement/Log/MySQLHandler.php b/app/common/Implement/Log/Handler/MySQL.php similarity index 79% rename from app/common/Implement/Log/MySQLHandler.php rename to app/common/Implement/Log/Handler/MySQL.php index d7b03f0..adb6d66 100644 --- a/app/common/Implement/Log/MySQLHandler.php +++ b/app/common/Implement/Log/Handler/MySQL.php @@ -1,13 +1,13 @@ initialized) { + if (!$this->checkTableExists()) { + $this->createTable(); + } + $this->cleanup(); $this->initialized(); } - $this->cleanup(); $this->statement->execute([ 'channel' => $record->channel, 'level' => $record->level->getName(), @@ -35,6 +38,21 @@ class MySQLHandler extends AbstractProcessingHandler private function initialized(): void { $query = <<statement = $this->connection->getPDO()->prepare($query); + $this->initialized = true; + } + private function checkTableExists(): bool + { + $query = "SHOW TABLES LIKE 'monolog'"; + $result = $this->connection->query($query); + return $result->rowCount() > 0; + } + private function createTable(): void + { + $query = <<connection->getPDO()->exec($query); - $query = <<statement = $this->connection->getPDO()->prepare($query); - $this->initialized = true; } private function cleanup(): void { diff --git a/app/common/Implement/Log/PDOFormatter.php b/app/common/Implement/Log/PDOFormatter.php deleted file mode 100644 index 7233dce..0000000 --- a/app/common/Implement/Log/PDOFormatter.php +++ /dev/null @@ -1,19 +0,0 @@ -normalize($record); - return $normalized['message']; - } -} diff --git a/app/common/Implement/Log/Processor/ArrayBuilder.php b/app/common/Implement/Log/Processor/ArrayBuilder.php new file mode 100644 index 0000000..d323e4c --- /dev/null +++ b/app/common/Implement/Log/Processor/ArrayBuilder.php @@ -0,0 +1,139 @@ +setFormatter($this->container->get($formatter)); + } catch (NotFoundExceptionInterface | ContainerExceptionInterface $exception) { + $this->log($exception, ['handlerData' => $handlerData]); + continue; + } + } elseif ($handlerData['handler'] === Incoviba\Common\Implement\Log\Handler\MySQL::class) { + try { + $params = [ + $this->container->get(Incoviba\Common\Define\Connection::class) + ]; + $formatter = Incoviba\Common\Implement\Log\Formatter\PDO::class; + if (array_key_exists('formatter', $handlerData)) { + $formatter = $handlerData['formatter']; + } + $handler = new $handlerData['handler'](...$params) + ->setFormatter($this->container->get($formatter)); + } catch (NotFoundExceptionInterface | ContainerExceptionInterface $exception) { + $this->log($exception, ['handlerData' => $handlerData]); + continue; + } + } elseif ($handlerData['handler'] === Handler\RedisHandler::class) { + try { + $params = [ + $this->container->get(Predis\ClientInterface::class), + "logs:{$handlerData['name']}" + ]; + } catch (NotFoundExceptionInterface | ContainerExceptionInterface $exception) { + $this->log($exception, ['handlerData' => $handlerData]); + continue; + } + $handler = new $handlerData['handler'](...$params); + } + if (!isset($handler)) { + $this->log("Invalid handler", ['handlerData' => $handlerData]); + continue; + } + $params = [ + $handler, + ]; + if (is_array($handlerData['levels'])) { + foreach ($handlerData['levels'] as $level) { + $params []= $level; + } + } else { + $params []= $handlerData['levels']; + $params []= Level::Emergency; + } + $params []= false; + $handlers []= new Handler\FilterHandler(...$params); + } + return $handlers; + } + + protected function log(string|Throwable $message, array $context = []): void + { + try { + $dateTime = new DateTimeImmutable('now', new DateTimeZone($_ENV['TZ'] ?? 'America/Santiago')); + } catch (DateMalformedStringException | DateInvalidTimeZoneException $exception) { + $dateTime = new DateTimeImmutable(); + } + if (is_a($message, Throwable::class)) { + $exception = $message; + $message = $exception->getMessage(); + } + $context = json_encode($context, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + if ($context === false) { + $context = '[]'; + } + $extra = []; + $extra['from'] = __FILE__; + if (isset($exception)) { + $extra['file'] = $exception->getFile(); + $extra['line'] = $exception->getLine(); + $extra['trace'] = $exception->getTrace(); + } + $extra = json_encode($extra, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + $code = 0; + if (isset($exception)) { + $code = $exception->getCode(); + } + if ($extra === false) { + $extra = '[]'; + } + $output = "[{$dateTime->format('Y-m-d H:i:s P')}] [{$code}] {$message} {$context} {$extra}"; + $filename = '/logs/error.json'; + $fileContents = []; + if (file_exists($filename)) { + $fileContents = file_get_contents($filename); + $fileContents = json_decode($fileContents, true); + if ($fileContents === false) { + $fileContents = []; + } + } + $fileContents[$dateTime->getTimestamp()] = $output; + $fileContents = json_encode($fileContents, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + if ($fileContents === false) { + $fileContents = '[]'; + } + file_put_contents($filename, $fileContents); + } +} diff --git a/app/common/Implement/Log/UserProcessor.php b/app/common/Implement/Log/Processor/User.php similarity index 81% rename from app/common/Implement/Log/UserProcessor.php rename to app/common/Implement/Log/Processor/User.php index 4c41508..3ecbe74 100644 --- a/app/common/Implement/Log/UserProcessor.php +++ b/app/common/Implement/Log/Processor/User.php @@ -1,11 +1,11 @@ }t tag +; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t +; %T: time the log has been written (the request has finished) +; it can accept a strftime(3) format: +; %d/%b/%Y:%H:%M:%S %z (default) +; The strftime(3) format must be encapsulated in a %{}t tag +; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t +; %u: basic auth user if specified in Authorization header +; +; Default: "%R - %u %t \"%m %r\" %s" +;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{milli}d %{kilo}M %C%%" + +; A list of request_uri values which should be filtered from the access log. +; +; As a security precaution, this setting will be ignored if: +; - the request method is not GET or HEAD; or +; - there is a request body; or +; - there are query parameters; or +; - the response code is outwith the successful range of 200 to 299 +; +; Note: The paths are matched against the output of the access.format tag "%r". +; On common configurations, this may look more like SCRIPT_NAME than the +; expected pre-rewrite URI. +; +; Default Value: not set +;access.suppress_path[] = /ping +;access.suppress_path[] = /health_check.php + +; The log file for slow requests +; Default Value: not set +; Note: slowlog is mandatory if request_slowlog_timeout is set +;slowlog = log/$pool.log.slow + +; The timeout for serving a single request after which a PHP backtrace will be +; dumped to the 'slowlog' file. A value of '0s' means 'off'. +; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) +; Default Value: 0 +;request_slowlog_timeout = 0 + +; Depth of slow log stack trace. +; Default Value: 20 +;request_slowlog_trace_depth = 20 + +; The timeout for serving a single request after which the worker process will +; be killed. This option should be used when the 'max_execution_time' ini option +; does not stop script execution for some reason. A value of '0' means 'off'. +; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) +; Default Value: 0 +;request_terminate_timeout = 0 + +; The timeout set by 'request_terminate_timeout' ini option is not engaged after +; application calls 'fastcgi_finish_request' or when application has finished and +; shutdown functions are being called (registered via register_shutdown_function). +; This option will enable timeout limit to be applied unconditionally +; even in such cases. +; Default Value: no +;request_terminate_timeout_track_finished = no + +; Set open file descriptor rlimit. +; Default Value: system defined value +;rlimit_files = 1024 + +; Set max core size rlimit. +; Possible Values: 'unlimited' or an integer greater or equal to 0 +; Default Value: system defined value +;rlimit_core = 0 + +; Chroot to this directory at the start. This value must be defined as an +; absolute path. When this value is not set, chroot is not used. +; Note: you can prefix with '$prefix' to chroot to the pool prefix or one +; of its subdirectories. If the pool prefix is not set, the global prefix +; will be used instead. +; Note: chrooting is a great security feature and should be used whenever +; possible. However, all PHP paths will be relative to the chroot +; (error_log, sessions.save_path, ...). +; Default Value: not set +;chroot = + +; Chdir to this directory at the start. +; Note: relative path can be used. +; Default Value: current directory or / when chroot +;chdir = /var/www + +; Redirect worker stdout and stderr into main error log. If not set, stdout and +; stderr will be redirected to /dev/null according to FastCGI specs. +; Note: on highloaded environment, this can cause some delay in the page +; process time (several ms). +; Default Value: no +;catch_workers_output = yes +catch_workers_output = yes + +; Decorate worker output with prefix and suffix containing information about +; the child that writes to the log and if stdout or stderr is used as well as +; log level and time. This options is used only if catch_workers_output is yes. +; Settings to "no" will output data as written to the stdout or stderr. +; Default value: yes +;decorate_workers_output = no +decorate_workers_output = no + +; Clear environment in FPM workers +; Prevents arbitrary environment variables from reaching FPM worker processes +; by clearing the environment in workers before env vars specified in this +; pool configuration are added. +; Setting to "no" will make all environment variables available to PHP code +; via getenv(), $_ENV and $_SERVER. +; Default Value: yes +;clear_env = no +clear_env = no + +; Limits the extensions of the main script FPM will allow to parse. This can +; prevent configuration mistakes on the web server side. You should only limit +; FPM to .php extensions to prevent malicious users to use other extensions to +; execute php code. +; Note: set an empty value to allow all extensions. +; Default Value: .php +;security.limit_extensions = .php .php3 .php4 .php5 .php7 + +; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from +; the current environment. +; Default Value: clean env +;env[HOSTNAME] = $HOSTNAME +;env[PATH] = /usr/local/bin:/usr/bin:/bin +;env[TMP] = /tmp +;env[TMPDIR] = /tmp +;env[TEMP] = /tmp + +; Additional php.ini defines, specific to this pool of workers. These settings +; overwrite the values previously defined in the php.ini. The directives are the +; same as the PHP SAPI: +; php_value/php_flag - you can set classic ini defines which can +; be overwritten from PHP call 'ini_set'. +; php_admin_value/php_admin_flag - these directives won't be overwritten by +; PHP call 'ini_set' +; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no. + +; Defining 'extension' will load the corresponding shared extension from +; extension_dir. Defining 'disable_functions' or 'disable_classes' will not +; overwrite previously defined php.ini values, but will append the new value +; instead. + +; Note: path INI options can be relative and will be expanded with the prefix +; (pool, global or /usr/local) + +; Default Value: nothing is defined by default except the values in php.ini and +; specified at startup with the -d argument +;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com +;php_flag[display_errors] = off +;php_admin_value[error_log] = /var/log/fpm-php.www.log +;php_admin_flag[log_errors] = on +;php_admin_value[memory_limit] = 32M diff --git a/app/phpunit.xml b/app/phpunit.xml index aa76082..a4c8092 100644 --- a/app/phpunit.xml +++ b/app/phpunit.xml @@ -28,16 +28,15 @@ common - + - + diff --git a/app/public/index.php b/app/public/index.php index a7bedad..3d761f8 100644 --- a/app/public/index.php +++ b/app/public/index.php @@ -13,3 +13,12 @@ try { $app->getContainer()->get(Psr\Log\LoggerInterface::class)->notice($exception); header('Location: /construccion'); } +register_shutdown_function(function() { + $error = error_get_last(); + + $fatal_errors = [E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR]; + if ($error !== null and in_array($error['type'], $fatal_errors, true)) { + error_log(json_encode($error).PHP_EOL,3, '/logs/fatal.log'); + } + error_clear_last(); +}); diff --git a/app/resources/database/migrations/20141101080001_create_agente.php b/app/resources/database/migrations/20141101080001_create_agente.php index 2479113..ea39217 100644 --- a/app/resources/database/migrations/20141101080001_create_agente.php +++ b/app/resources/database/migrations/20141101080001_create_agente.php @@ -18,7 +18,7 @@ class CreateAgente extends Phinx\Migration\AbstractMigration ->addColumn('telefono', 'integer', ['length' => 11, 'default' => null, 'null' => true]) ->addColumn('correo', 'string', ['length' => 50, 'default' => null, 'null' => true]) ->addColumn('direccion', 'integer', ['length' => 11, 'default' => null, 'null' => true]) - ->addColumn('giro', 'mediumtext', ['default' => null, 'null' => true]) + ->addColumn('giro', 'text', ['default' => null, 'null' => true]) ->addColumn('abreviacion', 'string', ['length' => 20, 'default' => null, 'null' => true]) ->create(); $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); diff --git a/app/resources/database/migrations/20141101080007_create_cartolas.php b/app/resources/database/migrations/20141101080007_create_cartolas.php index 325be8f..146a22c 100644 --- a/app/resources/database/migrations/20141101080007_create_cartolas.php +++ b/app/resources/database/migrations/20141101080007_create_cartolas.php @@ -13,9 +13,9 @@ class CreateCartolas extends Phinx\Migration\AbstractMigration $this->table('cartolas') ->addColumn('cuenta_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) ->addColumn('fecha', 'date', ['null' => false]) - ->addColumn('cargos', 'bigint', ['length' => 20, 'default' => 0, 'null' => false, 'signed' => false]) - ->addColumn('abonos', 'bigint', ['length' => 20, 'default' => 0, 'null' => false, 'signed' => false]) - ->addColumn('saldo', 'bigint', ['length' => 20, 'default' => 0, 'null' => false]) + ->addColumn('cargos', 'biginteger', ['length' => 20, 'default' => 0, 'null' => false, 'signed' => false]) + ->addColumn('abonos', 'biginteger', ['length' => 20, 'default' => 0, 'null' => false, 'signed' => false]) + ->addColumn('saldo', 'biginteger', ['length' => 20, 'default' => 0, 'null' => false]) ->addForeignKey('cuenta_id', 'cuenta', 'id', ['delete' => 'cascade', 'update' => 'cascade']) ->create(); $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); diff --git a/app/resources/database/migrations/20141101080009_create_centros_costos.php b/app/resources/database/migrations/20141101080009_create_centros_costos.php index 0a302ac..875caa0 100644 --- a/app/resources/database/migrations/20141101080009_create_centros_costos.php +++ b/app/resources/database/migrations/20141101080009_create_centros_costos.php @@ -15,7 +15,7 @@ class CreateCentrosCostos extends Phinx\Migration\AbstractMigration ->addColumn('categoria_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) ->addColumn('tipo_cuenta_id', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) ->addColumn('cuenta_contable', 'string', ['length' => 100, 'null' => false]) - ->addColumn('descripcion', 'mediumtext', ['null' => false]) + ->addColumn('descripcion', 'text', ['null' => false, 'limit' => MysqlAdapter::TEXT_MEDIUM]) ->addForeignKey('tipo_centro_id', 'tipos_centros_costos', 'id', ['delete' => 'cascade', 'update' => 'cascade']) ->addForeignKey('categoria_id', 'categorias_centros_costos', 'id', ['delete' => 'cascade', 'update' => 'cascade']) ->create(); diff --git a/app/resources/database/migrations/20141101080011_create_cobro.php b/app/resources/database/migrations/20141101080011_create_cobro.php index f8acabd..59c51b4 100644 --- a/app/resources/database/migrations/20141101080011_create_cobro.php +++ b/app/resources/database/migrations/20141101080011_create_cobro.php @@ -19,7 +19,7 @@ class CreateCobro extends Phinx\Migration\AbstractMigration ->addColumn('iva', 'float', ['default' => 0]) ->addColumn('uf', 'float', ['default' => null, 'null' => true]) ->addColumn('identificador', 'string', ['length' => 50, 'default' => null, 'null' => true]) - ->addColumn('glosa', 'mediumtext', ['default' => null, 'null' => true]) + ->addColumn('glosa', 'text', ['default' => null, 'null' => true, 'limit' => MysqlAdapter::TEXT_MEDIUM]) ->create(); $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); } diff --git a/app/resources/database/migrations/20141101080024_create_escritura.php b/app/resources/database/migrations/20141101080024_create_escritura.php index 5959d1d..e7b1ede 100644 --- a/app/resources/database/migrations/20141101080024_create_escritura.php +++ b/app/resources/database/migrations/20141101080024_create_escritura.php @@ -11,7 +11,7 @@ class CreateEscritura extends Phinx\Migration\AbstractMigration $this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';"); $this->table('escritura') - ->addColumn('valor', 'bigint', ['length' => 20, 'null' => false]) + ->addColumn('valor', 'biginteger', ['length' => 20, 'null' => false]) ->addColumn('fecha', 'date', ['null' => false]) ->addColumn('uf', 'float', ['default' => null, 'null' => true]) ->addColumn('abonado', 'integer', ['length' => 11, 'default' => 0]) diff --git a/app/resources/database/migrations/20141101080029_create_estado_problema.php b/app/resources/database/migrations/20141101080029_create_estado_problema.php index 216c296..467f4c2 100644 --- a/app/resources/database/migrations/20141101080029_create_estado_problema.php +++ b/app/resources/database/migrations/20141101080029_create_estado_problema.php @@ -13,7 +13,7 @@ class CreateEstadoProblema extends Phinx\Migration\AbstractMigration $this->table('estado_problema') ->addColumn('problema', 'integer', ['length' => 11, 'default' => null, 'null' => true]) ->addColumn('fecha', 'date', ['default' => null, 'null' => true]) - ->addColumn('estado', 'enum', ['length' => 'ingreso','revision','correccion','ok', 'default' => null, 'null' => true]) + ->addColumn('estado', 'enum', ['values' => ['ingreso','revision','correccion','ok'], 'default' => null, 'null' => true]) ->create(); $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); } diff --git a/app/resources/database/migrations/20141101080040_create_inmobiliarias_nubox.php b/app/resources/database/migrations/20141101080040_create_inmobiliarias_nubox.php index e2ff626..be1ccfa 100644 --- a/app/resources/database/migrations/20141101080040_create_inmobiliarias_nubox.php +++ b/app/resources/database/migrations/20141101080040_create_inmobiliarias_nubox.php @@ -15,7 +15,7 @@ class CreateInmobiliariasNubox extends Phinx\Migration\AbstractMigration ->addColumn('alias', 'string', ['length' => 100, 'null' => false]) ->addColumn('usuario', 'string', ['length' => 100, 'null' => false]) ->addColumn('contraseña', 'string', ['length' => 100, 'null' => false]) - ->addForeignKey('inmobiliaria_rut', 'inmobiliaria', 'rut', ['delete' => 'cascade', 'update' => 'cascade']) + #->addForeignKey('inmobiliaria_rut', 'inmobiliaria', 'rut', ['delete' => 'cascade', 'update' => 'cascade']) ->create(); $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); } diff --git a/app/resources/database/migrations/20141101080044_create_movimientos.php b/app/resources/database/migrations/20141101080044_create_movimientos.php index 21ec94b..7c0e227 100644 --- a/app/resources/database/migrations/20141101080044_create_movimientos.php +++ b/app/resources/database/migrations/20141101080044_create_movimientos.php @@ -15,9 +15,9 @@ class CreateMovimientos extends Phinx\Migration\AbstractMigration ->addColumn('fecha', 'date', ['null' => false]) ->addColumn('glosa', 'text', ['null' => false]) ->addColumn('documento', 'string', ['length' => 50, 'null' => false]) - ->addColumn('cargo', 'bigint', ['length' => 20, 'default' => 0, 'null' => false, 'signed' => false]) - ->addColumn('abono', 'bigint', ['length' => 20, 'default' => 0, 'null' => false, 'signed' => false]) - ->addColumn('saldo', 'bigint', ['length' => 20, 'default' => 0, 'null' => false]) + ->addColumn('cargo', 'biginteger', ['length' => 20, 'default' => 0, 'null' => false, 'signed' => false]) + ->addColumn('abono', 'biginteger', ['length' => 20, 'default' => 0, 'null' => false, 'signed' => false]) + ->addColumn('saldo', 'biginteger', ['length' => 20, 'default' => 0, 'null' => false]) ->addForeignKey('cuenta_id', 'cuenta', 'id', ['delete' => 'cascade', 'update' => 'cascade']) ->create(); $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); diff --git a/app/resources/database/migrations/20141101080054_create_problema.php b/app/resources/database/migrations/20141101080054_create_problema.php index 387a3ca..4fe9637 100644 --- a/app/resources/database/migrations/20141101080054_create_problema.php +++ b/app/resources/database/migrations/20141101080054_create_problema.php @@ -12,7 +12,7 @@ class CreateProblema extends Phinx\Migration\AbstractMigration $this->table('problema') ->addColumn('venta', 'integer', ['length' => 11, 'default' => null, 'null' => true]) - ->addColumn('descripcion', 'mediumtext', ['default' => null, 'null' => true]) + ->addColumn('descripcion', 'text', ['default' => null, 'null' => true, 'limit' => MysqlAdapter::TEXT_MEDIUM]) ->create(); $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); } diff --git a/app/resources/database/migrations/20141101080104_create_proyecto.php b/app/resources/database/migrations/20141101080104_create_proyecto.php index c0c472b..6689281 100644 --- a/app/resources/database/migrations/20141101080104_create_proyecto.php +++ b/app/resources/database/migrations/20141101080104_create_proyecto.php @@ -12,7 +12,7 @@ class CreateProyecto extends Phinx\Migration\AbstractMigration $this->table('proyecto') ->addColumn('inmobiliaria', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) - ->addColumn('descripcion', 'mediumtext', ['null' => false]) + ->addColumn('descripcion', 'text', ['null' => false, 'limit' => MysqlAdapter::TEXT_MEDIUM]) ->addColumn('direccion', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) ->addColumn('superficie_terreno', 'float', ['default' => 0, 'null' => false, 'signed' => false]) ->addColumn('valor_terreno', 'float', ['default' => 0, 'null' => false, 'signed' => false]) diff --git a/app/resources/database/migrations/20141101080107_create_proyecto_tipo_unidad.php b/app/resources/database/migrations/20141101080107_create_proyecto_tipo_unidad.php index ee9700b..0f0fe1f 100644 --- a/app/resources/database/migrations/20141101080107_create_proyecto_tipo_unidad.php +++ b/app/resources/database/migrations/20141101080107_create_proyecto_tipo_unidad.php @@ -18,7 +18,7 @@ class CreateProyectoTipoUnidad extends Phinx\Migration\AbstractMigration ->addColumn('m2', 'float', ['default' => null, 'null' => true]) ->addColumn('logia', 'float', ['default' => 0]) ->addColumn('terraza', 'float', ['default' => 0]) - ->addColumn('descripcion', 'mediumtext', ['default' => null, 'null' => true]) + ->addColumn('descripcion', 'text', ['default' => null, 'null' => true, 'limit' => MysqlAdapter::TEXT_MEDIUM]) ->addForeignKey('proyecto', 'proyecto', 'id', ['delete' => 'cascade', 'update' => 'cascade']) ->create(); $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); diff --git a/app/resources/database/migrations/20141101080122_create_tipo_estado_pago.php b/app/resources/database/migrations/20141101080122_create_tipo_estado_pago.php index d7a65fa..2666b23 100644 --- a/app/resources/database/migrations/20141101080122_create_tipo_estado_pago.php +++ b/app/resources/database/migrations/20141101080122_create_tipo_estado_pago.php @@ -10,7 +10,8 @@ class CreateTipoEstadoPago extends Phinx\Migration\AbstractMigration $this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';"); $this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';"); - $this->table('tipo_estado_pago') + $this->table('tipo_estado_pago', ['id' => false, 'primary_key' => 'id']) + ->addColumn('id', 'integer', ['signed' => true]) ->addColumn('descripcion', 'string', ['length' => 20, 'default' => null, 'null' => true]) ->addColumn('active', 'integer', ['length' => 1, 'default' => 0]) ->create(); diff --git a/app/resources/database/migrations/20141101080146_create_venta.php b/app/resources/database/migrations/20141101080146_create_venta.php index eff21a5..30c46fe 100644 --- a/app/resources/database/migrations/20141101080146_create_venta.php +++ b/app/resources/database/migrations/20141101080146_create_venta.php @@ -33,7 +33,7 @@ class CreateVenta extends Phinx\Migration\AbstractMigration ->addColumn('resciliacion', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) ->addColumn('devolucion', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) ->addForeignKey('propiedad', 'propiedad', 'id', ['delete' => 'cascade', 'update' => 'cascade']) - ->addForeignKey('propietario', 'propietario', 'rut', ['delete' => 'cascade', 'update' => 'cascade']) + #->addForeignKey('propietario', 'propietario', 'rut', ['delete' => 'cascade', 'update' => 'cascade']) ->create(); $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); } diff --git a/app/resources/database/migrations/20141101080147_create_venta_abono_cuotas.php b/app/resources/database/migrations/20141101080147_create_venta_abono_cuotas.php deleted file mode 100644 index 8bc5a65..0000000 --- a/app/resources/database/migrations/20141101080147_create_venta_abono_cuotas.php +++ /dev/null @@ -1,22 +0,0 @@ -execute('SET unique_checks=0; SET foreign_key_checks=0;'); - $this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';"); - $this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';"); - - $this->table('venta_abono_cuotas') - ->addColumn('venta_id', 'integer', ['length' => 11, 'null' => false, 'signed' => false]) - ->addColumn('pago_id', 'integer', ['length' => 11, 'null' => false, 'signed' => false]) - ->addColumn('numero', 'integer', ['length' => 11, 'default' => 1, 'null' => false, 'signed' => false]) - ->addForeignKey('venta_id', 'venta', 'id', ['delete' => 'cascade', 'update' => 'cascade']) - ->addForeignKey('pago_id', 'pago', 'id', ['delete' => 'cascade', 'update' => 'cascade']) - ->create(); - $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); - } -} diff --git a/app/resources/database/migrations/20250215133405_create_broker.php b/app/resources/database/migrations/20250215133405_create_broker.php new file mode 100644 index 0000000..eb51a71 --- /dev/null +++ b/app/resources/database/migrations/20250215133405_create_broker.php @@ -0,0 +1,28 @@ +table('brokers', ['id' => false, 'primary_key' => ['rut']]) + ->addColumn('rut', 'integer', ['identity' => true, 'signed' => false, 'null' => false]) + ->addColumn('digit', 'string', ['length' => 1, 'null' => false]) + ->addColumn('name', 'string', ['length' => 255, 'null' => false]) + ->create(); + } +} diff --git a/app/resources/database/migrations/20250215133411_create_broker_contract.php b/app/resources/database/migrations/20250215133411_create_broker_contract.php new file mode 100644 index 0000000..22a3e25 --- /dev/null +++ b/app/resources/database/migrations/20250215133411_create_broker_contract.php @@ -0,0 +1,36 @@ +execute('SET unique_checks=0; SET foreign_key_checks=0;'); + $this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';"); + $this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';"); + + $this->table('broker_contracts') + ->addColumn('broker_rut', 'integer', ['signed' => false, 'null' => false]) + ->addColumn('project_id', 'integer', ['signed' => false, 'null' => false]) + ->addColumn('commission', 'decimal', ['precision' => 10, 'scale' => 2, 'null' => false]) + ->addForeignKey('broker_rut', 'brokers', 'rut', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('project_id', 'proyecto', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20250215133419_create_broker_data.php b/app/resources/database/migrations/20250215133419_create_broker_data.php new file mode 100644 index 0000000..62e0f97 --- /dev/null +++ b/app/resources/database/migrations/20250215133419_create_broker_data.php @@ -0,0 +1,36 @@ +execute('SET unique_checks=0; SET foreign_key_checks=0;'); + $this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';"); + $this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';"); + + $this->table('broker_data') + ->addColumn('broker_rut', 'integer', ['signed' => false, 'null' => false]) + ->addColumn('representative_id', 'integer', ['signed' => false, 'null' => true, 'default' => null]) + ->addColumn('legal_name', 'string', ['length' => 255, 'default' => null, 'null' => true]) + ->addForeignKey('broker_rut', 'brokers', ['rut'], ['delete' => 'CASCADE', 'update' => 'CASCADE']) + ->addForeignKey('representative_id', 'broker_contacts', ['id'], ['delete' => 'CASCADE', 'update' => 'CASCADE']) + ->create(); + + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20250215133429_create_promotion.php b/app/resources/database/migrations/20250215133429_create_promotion.php new file mode 100644 index 0000000..2e0eb47 --- /dev/null +++ b/app/resources/database/migrations/20250215133429_create_promotion.php @@ -0,0 +1,38 @@ +execute('SET unique_checks=0; SET foreign_key_checks=0;'); + $this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';"); + $this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';"); + + $this->table('promotions') + ->addColumn('price_id', 'integer', ['signed' => false, 'null' => false]) + ->addColumn('amount', 'decimal', ['precision' => 10, 'scale' => 2, 'null' => false]) + ->addColumn('start_date', 'date', ['null' => false]) + ->addColumn('end_date', 'date', ['null' => false]) + ->addColumn('valid_until', 'date', ['null' => false]) + ->addColumn('state', 'integer', ['length' => 1, 'null' => false, 'default' => 1]) + ->addForeignKey('price_id', 'prices', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20250215133437_create_reservation.php b/app/resources/database/migrations/20250215133437_create_reservation.php new file mode 100644 index 0000000..db9c32a --- /dev/null +++ b/app/resources/database/migrations/20250215133437_create_reservation.php @@ -0,0 +1,34 @@ +execute('SET unique_checks=0; SET foreign_key_checks=0;'); + $this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';"); + $this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';"); + + $this->table('reservation') + ->addColumn('buyer_rut', 'integer', ['signed' => false, 'null' => false]) + ->addColumn('date', 'date', ['null' => false]) + ->addForeignKey('buyer_rut', 'personas', 'rut', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20250215133451_create_broker_contract_state.php b/app/resources/database/migrations/20250215133451_create_broker_contract_state.php new file mode 100644 index 0000000..007b4d1 --- /dev/null +++ b/app/resources/database/migrations/20250215133451_create_broker_contract_state.php @@ -0,0 +1,35 @@ +execute('SET unique_checks=0; SET foreign_key_checks=0;'); + $this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';"); + $this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';"); + + $this->table('broker_contract_states') + ->addColumn('contract_id', 'integer', ['signed' => false, 'null' => false]) + ->addColumn('date', 'date', ['null' => false]) + ->addColumn('type', 'integer', ['length' => 1, 'null' => false, 'default' => 0]) + ->addForeignKey('contract_id', 'broker_contracts', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20250215135457_create_reservation_datas.php b/app/resources/database/migrations/20250215135457_create_reservation_datas.php new file mode 100644 index 0000000..ad85f98 --- /dev/null +++ b/app/resources/database/migrations/20250215135457_create_reservation_datas.php @@ -0,0 +1,35 @@ +execute('SET unique_checks=0; SET foreign_key_checks=0;'); + $this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';"); + $this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';"); + + $this->table('reservation_data') + ->addColumn('reservation_id', 'integer', ['signed' => false, 'null' => false]) + ->addColumn('type', 'integer', ['length' => 1, 'signed' => false, 'null' => false]) + ->addColumn('reference_id', 'integer', ['signed' => false, 'null' => false]) + ->addColumn('value', 'decimal', ['precision' => 10, 'scale' => 2, 'signed' => false, 'default' => 0.00, 'null' => true]) + ->create(); + + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20250215135822_create_reservation_states.php b/app/resources/database/migrations/20250215135822_create_reservation_states.php new file mode 100644 index 0000000..e617ef5 --- /dev/null +++ b/app/resources/database/migrations/20250215135822_create_reservation_states.php @@ -0,0 +1,35 @@ +execute('SET unique_checks=0; SET foreign_key_checks=0;'); + $this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';"); + $this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';"); + + $this->table('reservation_states') + ->addColumn('reservation_id', 'integer', ['signed' => false, 'null' => false]) + ->addColumn('date', 'date', ['null' => false]) + ->addColumn('type', 'integer', ['length' => 3, 'null' => false, 'default' => 0]) + ->addForeignKey('reservation_id', 'reservation', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20250307190931_create_broker_contacts.php b/app/resources/database/migrations/20250307190931_create_broker_contacts.php new file mode 100644 index 0000000..15aa701 --- /dev/null +++ b/app/resources/database/migrations/20250307190931_create_broker_contacts.php @@ -0,0 +1,38 @@ +execute('SET unique_checks=0; SET foreign_key_checks=0;'); + $this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';"); + $this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';"); + + $this->table('broker_contacts') + ->addColumn('rut', 'integer', ['signed' => false, 'null' => true]) + ->addColumn('digit', 'string', ['length' => 1, 'null' => true]) + ->addColumn('name', 'string', ['length' => 255, 'null' => true]) + ->addColumn('email', 'string', ['length' => 255, 'null' => true]) + ->addColumn('phone', 'string', ['length' => 255, 'null' => true]) + ->addColumn('address_id', 'integer', ['signed' => false, 'null' => true]) + ->addForeignKey('address_id', 'direccion', ['id'], ['delete' => 'CASCADE', 'update' => 'CASCADE']) + ->create(); + + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20250317193111_alter_promotions_remove_price.php b/app/resources/database/migrations/20250317193111_alter_promotions_remove_price.php new file mode 100644 index 0000000..9d6b264 --- /dev/null +++ b/app/resources/database/migrations/20250317193111_alter_promotions_remove_price.php @@ -0,0 +1,31 @@ +table('promotions')->hasColumn('price_id')) { + $this->table('promotions') + ->dropForeignKey('price_id') + ->removeColumn('price_id') + ->update(); + } + } + + public function down(): void {} +} diff --git a/app/resources/database/migrations/20250317193246_create_promotion_unit.php b/app/resources/database/migrations/20250317193246_create_promotion_unit.php new file mode 100644 index 0000000..dfc83bc --- /dev/null +++ b/app/resources/database/migrations/20250317193246_create_promotion_unit.php @@ -0,0 +1,30 @@ +table('promotion_units') + ->addColumn('promotion_id', 'integer', ['signed' => false, 'null' => false]) + ->addColumn('unit_id', 'integer', ['signed' => false, 'null' => false]) + ->addColumn('created_at', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP']) + ->addForeignKey('promotion_id', 'promotions', 'id', ['delete' => 'CASCADE', 'update' => 'CASCADE']) + ->addForeignKey('unit_id', 'unidad', 'id', ['delete' => 'CASCADE', 'update' => 'CASCADE']) + ->create(); + } +} diff --git a/app/resources/database/migrations/20250318204147_alter_promotions_null_dates.php b/app/resources/database/migrations/20250318204147_alter_promotions_null_dates.php new file mode 100644 index 0000000..83e0990 --- /dev/null +++ b/app/resources/database/migrations/20250318204147_alter_promotions_null_dates.php @@ -0,0 +1,28 @@ +table('promotions') + ->changeColumn('end_date', 'date', ['null' => true]) + ->changeColumn('valid_until', 'date', ['null' => true]) + ->update(); + } + public function down(): void {} +} diff --git a/app/resources/database/migrations/20250318205221_alter_promotions_add_description_and_type.php b/app/resources/database/migrations/20250318205221_alter_promotions_add_description_and_type.php new file mode 100644 index 0000000..d349bd8 --- /dev/null +++ b/app/resources/database/migrations/20250318205221_alter_promotions_add_description_and_type.php @@ -0,0 +1,27 @@ +table('promotions') + ->addColumn('description', 'string', ['limit' => 255, 'null' => false, 'after' => 'id']) + ->addColumn('type', 'integer', ['limit' => 1, 'null' => false, 'default' => 0, 'after' => 'description']) + ->update(); + } +} diff --git a/app/resources/database/migrations/20250318231051_create_promotion_projects.php b/app/resources/database/migrations/20250318231051_create_promotion_projects.php new file mode 100644 index 0000000..9a661a6 --- /dev/null +++ b/app/resources/database/migrations/20250318231051_create_promotion_projects.php @@ -0,0 +1,29 @@ +table('promotion_projects') + ->addColumn('promotion_id', 'integer', ['signed' => false, 'null' => false]) + ->addColumn('project_id', 'integer', ['signed' => false, 'null' => false]) + ->addForeignKey('promotion_id', 'promotions', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('project_id', 'proyecto', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + } +} diff --git a/app/resources/database/migrations/20250403175937_create_promotion_brokers.php b/app/resources/database/migrations/20250403175937_create_promotion_brokers.php new file mode 100644 index 0000000..bac0f0a --- /dev/null +++ b/app/resources/database/migrations/20250403175937_create_promotion_brokers.php @@ -0,0 +1,29 @@ +table('promotion_brokers') + ->addColumn('promotion_id', 'integer', ['signed' => false, 'null' => false]) + ->addColumn('broker_rut', 'integer', ['signed' => false, 'null' => false]) + ->addForeignKey('promotion_id', 'promotions', 'id', ['delete' => 'CASCADE', 'update' => 'CASCADE']) + ->addForeignKey('broker_rut', 'brokers', 'rut', ['delete' => 'CASCADE', 'update' => 'CASCADE']) + ->create(); + } +} diff --git a/app/resources/database/migrations/20250403175950_create_promotion_unit_lines.php b/app/resources/database/migrations/20250403175950_create_promotion_unit_lines.php new file mode 100644 index 0000000..f653c89 --- /dev/null +++ b/app/resources/database/migrations/20250403175950_create_promotion_unit_lines.php @@ -0,0 +1,29 @@ +table('promotion_unit_lines') + ->addColumn('promotion_id', 'integer', ['signed' => false, 'null' => false]) + ->addColumn('unit_line_id', 'integer', ['signed' => false, 'null' => false]) + ->addForeignKey('promotion_id', 'promotions', 'id', ['delete' => 'CASCADE', 'update' => 'CASCADE']) + ->addForeignKey('unit_line_id', 'proyecto_tipo_unidad', 'id', ['delete' => 'CASCADE', 'update' => 'CASCADE']) + ->create(); + } +} diff --git a/app/resources/database/migrations/20250403175954_create_promotion_unit_types.php b/app/resources/database/migrations/20250403175954_create_promotion_unit_types.php new file mode 100644 index 0000000..e9f3f4c --- /dev/null +++ b/app/resources/database/migrations/20250403175954_create_promotion_unit_types.php @@ -0,0 +1,31 @@ +table('promotion_unit_types') + ->addColumn('promotion_id', 'integer', ['signed' => false, 'null' => false]) + ->addColumn('project_id', 'integer', ['signed' => false, 'null' => false]) + ->addColumn('unit_type_id', 'integer', ['signed' => false, 'null' => false]) + ->addForeignKey('promotion_id', 'promotions', 'id', ['delete' => 'CASCADE', 'update' => 'CASCADE']) + ->addForeignKey('project_id', 'proyecto', 'id', ['delete' => 'CASCADE', 'update' => 'CASCADE']) + ->addForeignKey('unit_type_id', 'tipo_unidad', 'id', ['delete' => 'CASCADE', 'update' => 'CASCADE']) + ->create(); + } +} diff --git a/app/resources/database/migrations/20250506164824_create_toku_customers.php b/app/resources/database/migrations/20250506164824_create_toku_customers.php new file mode 100644 index 0000000..d51ad45 --- /dev/null +++ b/app/resources/database/migrations/20250506164824_create_toku_customers.php @@ -0,0 +1,29 @@ +table('toku_customers') + ->addColumn('rut', 'string', ['length' => 9]) + ->addColumn('toku_id', 'string', ['length' => 255]) + ->addTimestamps() + ->addIndex(['rut'], ['unique' => true]) + ->create(); + } +} diff --git a/app/resources/database/migrations/20250506212422_create_toku_subscriptions.php b/app/resources/database/migrations/20250506212422_create_toku_subscriptions.php new file mode 100644 index 0000000..03b6b63 --- /dev/null +++ b/app/resources/database/migrations/20250506212422_create_toku_subscriptions.php @@ -0,0 +1,29 @@ +table('toku_subscriptions') + ->addColumn('venta_id', 'integer', ['signed' => false]) + ->addColumn('toku_id', 'string', ['length' => 255]) + ->addTimestamps() + ->addIndex(['venta_id'], ['unique' => true]) + ->create(); + } +} diff --git a/app/resources/database/migrations/20250506213859_create_toku_invoices.php b/app/resources/database/migrations/20250506213859_create_toku_invoices.php new file mode 100644 index 0000000..aa1a143 --- /dev/null +++ b/app/resources/database/migrations/20250506213859_create_toku_invoices.php @@ -0,0 +1,29 @@ +table('toku_invoices') + ->addColumn('cuota_id', 'integer', ['signed' => false]) + ->addColumn('toku_id', 'string', ['length' => 255]) + ->addTimestamps() + ->addIndex(['cuota_id'], ['unique' => true]) + ->create(); + } +} diff --git a/app/resources/database/migrations/20250512175057_create_jobs.php b/app/resources/database/migrations/20250512175057_create_jobs.php new file mode 100644 index 0000000..275a4d2 --- /dev/null +++ b/app/resources/database/migrations/20250512175057_create_jobs.php @@ -0,0 +1,28 @@ +table('jobs') + ->addColumn('configuration', 'json') + ->addColumn('executed', 'boolean', ['default' => false]) + ->addTimestamps() + ->create(); + } +} diff --git a/app/resources/database/migrations/20250604015839_create_toku_webhooks.php b/app/resources/database/migrations/20250604015839_create_toku_webhooks.php new file mode 100644 index 0000000..bec7088 --- /dev/null +++ b/app/resources/database/migrations/20250604015839_create_toku_webhooks.php @@ -0,0 +1,29 @@ +table('toku_webhooks') + ->addColumn('secret', 'string', ['length' => 255]) + ->addColumn('events', 'json') + ->addColumn('enabled', 'boolean', ['default' => true]) + ->addTimestamps() + ->create(); + } +} diff --git a/app/resources/database/migrations/20250701192525_create_toku_accounts.php b/app/resources/database/migrations/20250701192525_create_toku_accounts.php new file mode 100644 index 0000000..dbfce11 --- /dev/null +++ b/app/resources/database/migrations/20250701192525_create_toku_accounts.php @@ -0,0 +1,36 @@ +execute('SET unique_checks=0; SET foreign_key_checks=0;'); + + $this->table('toku_accounts') + ->addColumn('sociedad_rut', 'integer', ['limit' => 8, 'signed' => false, 'null' => false]) + ->addColumn('toku_id', 'string', ['length' => 255, 'null' => false]) + ->addColumn('account_key', 'string', ['length' => 255, 'null' => false]) + ->addColumn('enabled', 'boolean', ['default' => true]) + ->addTimestamps() + #->addForeignKey('sociedad_rut', 'inmobiliaria', 'rut', ['delete' => 'CASCADE', 'update' => 'CASCADE']) + ->addIndex(['toku_id'], ['unique' => true]) + ->create(); + + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/seeds/Comuna.php b/app/resources/database/seeds/Comuna.php new file mode 100644 index 0000000..034fb40 --- /dev/null +++ b/app/resources/database/seeds/Comuna.php @@ -0,0 +1,52 @@ +execute('SET unique_checks=0; SET foreign_key_checks=0;'); + + $table = $this->table('comuna'); + $table->truncate(); + + $filename = implode(DIRECTORY_SEPARATOR, [getcwd(), 'resources', 'database', 'seeds', 'comuna.csv']); + $dataRows = explode(PHP_EOL, trim(file_get_contents($filename))); + $data = array_map(fn($row) => explode(';', $row), $dataRows); + $columns = array_shift($data); + $columns = array_map(function($column) { + if (str_contains($column, 'id')) { + return 'id'; + } + if (str_contains($column, 'provincia')) { + return 'provincia'; + } + return $column; + }, $columns); + $data = array_map(function ($row) use ($columns) { + return array_combine($columns, $row); + }, $data); + + $table->insert($data)->save(); + + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/seeds/Provincia.php b/app/resources/database/seeds/Provincia.php new file mode 100644 index 0000000..da3a9b2 --- /dev/null +++ b/app/resources/database/seeds/Provincia.php @@ -0,0 +1,52 @@ +execute('SET unique_checks=0; SET foreign_key_checks=0;'); + + $table = $this->table('provincia'); + $table->truncate(); + + $filename = implode(DIRECTORY_SEPARATOR, [getcwd(), 'resources', 'database', 'seeds', 'provincia.csv']); + $dataRows = explode(PHP_EOL, trim(file_get_contents($filename))); + $data = array_map(fn($row) => explode(';', $row), $dataRows); + $columns = array_shift($data); + $columns = array_map(function($column) { + if (str_contains($column, 'id')) { + return 'id'; + } + if (str_contains($column, 'region')) { + return 'region'; + } + return $column; + }, $columns); + $data = array_map(function ($row) use ($columns) { + return array_combine($columns, $row); + }, $data); + + $table->insert($data)->save(); + + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/seeds/Region.php b/app/resources/database/seeds/Region.php new file mode 100644 index 0000000..f5c8681 --- /dev/null +++ b/app/resources/database/seeds/Region.php @@ -0,0 +1,45 @@ +execute('SET unique_checks=0; SET foreign_key_checks=0;'); + + $table = $this->table('region'); + $table->truncate(); + + $filename = implode(DIRECTORY_SEPARATOR, [getcwd(), 'resources', 'database', 'seeds', 'region.csv']); + $dataRows = explode(PHP_EOL, trim(file_get_contents($filename))); + $data = array_map(fn($row) => explode(';', $row), $dataRows); + $columns = array_shift($data); + $columns = array_map(function($column) { + if (str_contains($column, 'id')) { + return 'id'; + } + if (str_contains($column, 'numeracion')) { + return 'numeracion'; + } + return $column; + }, $columns); + $data = array_map(function ($row) use ($columns) { + return array_combine($columns, $row); + }, $data); + + $table->insert($data)->save(); + + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/seeds/TipoEstadoPago.php b/app/resources/database/seeds/TipoEstadoPago.php new file mode 100644 index 0000000..a9f27cf --- /dev/null +++ b/app/resources/database/seeds/TipoEstadoPago.php @@ -0,0 +1,36 @@ +execute('SET unique_checks=0; SET foreign_key_checks=0;'); + + $table = $this->table('tipo_estado_pago'); + $table->truncate(); + + $data = [ + ['id' => -3, 'descripcion' => 'anulado'], + ['id' => -2, 'descripcion' => 'reemplazado'], + ['id' => -1, 'descripcion' => 'devuelto'], + ['id' => 0, 'descripcion' => 'no pagado', 'active' => 1], + ['id' => 1, 'descripcion' => 'depositado', 'active' => 1], + ['id' => 2, 'descripcion' => 'abonado', 'active' => 1], + ]; + $table->insert($data)->saveData(); + + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/seeds/TipoPago.php b/app/resources/database/seeds/TipoPago.php new file mode 100644 index 0000000..648937c --- /dev/null +++ b/app/resources/database/seeds/TipoPago.php @@ -0,0 +1,52 @@ +table('tipo_pago'); + $data = [ + [ + 'descripcion' => 'cheque', + ], + [ + 'descripcion' => 'carta de resguardo', + ], + [ + 'descripcion' => 'vale vista' + ], + [ + 'descripcion' => 'deposito', + ], + [ + 'descripcion' => 'efectivo', + ], + [ + 'descripcion' => 'tarjeta de credito', + ], + [ + 'descripcion' => 'transferencia electronica', + ], + [ + 'descripcion' => 'virtual', + ] + ]; + + $table->truncate(); + $table + ->insert($data) + ->saveData(); + } +} diff --git a/app/resources/database/seeds/TipoSociedad.php b/app/resources/database/seeds/TipoSociedad.php new file mode 100644 index 0000000..e0c4e52 --- /dev/null +++ b/app/resources/database/seeds/TipoSociedad.php @@ -0,0 +1,43 @@ +execute('SET unique_checks=0; SET foreign_key_checks=0;'); + + $table = $this->table('tipo_sociedad'); + $table->truncate(); + + $data = [ + [ + 'descripcion' => 'Limitada', + 'abreviacion' => 'Ltda', + ], + [ + 'descripcion' => 'Sociedad Anónima', + 'abreviacion' => 'SA', + ], + [ + 'descripcion' => 'Sociedad por Acciones', + 'abreviacion' => 'SpA', + ] + ]; + + $table->insert($data)->saveData(); + + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/seeds/TipoUnidad.php b/app/resources/database/seeds/TipoUnidad.php new file mode 100644 index 0000000..9d58fbe --- /dev/null +++ b/app/resources/database/seeds/TipoUnidad.php @@ -0,0 +1,43 @@ +execute('SET unique_checks=0; SET foreign_key_checks=0;'); + + $table = $this->table('tipo_unidad'); + $table->truncate(); + + $data = [ + [ + 'descripcion' => 'departamento', + 'orden' => 0, + ], + [ + 'descripcion' => 'estacionamiento', + 'orden' => 1, + ], + [ + 'descripcion' => 'bodega', + 'orden' => 2, + ] + ]; + + $table->insert($data)->saveData(); + + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/seeds/comuna.csv b/app/resources/database/seeds/comuna.csv new file mode 100644 index 0000000..206a0b3 --- /dev/null +++ b/app/resources/database/seeds/comuna.csv @@ -0,0 +1,347 @@ +id;descripcion;provincia +1101;Iquique;11 +1107;Alto Hospicio;11 +1401;Pozo Almonte;14 +1402;Camiña;14 +1403;Colchane;14 +1404;Huara;14 +1405;Pica;14 +2101;Antofagasta;21 +2102;Mejillones;21 +2103;Sierra Gorda;21 +2104;Taltal;21 +2201;Calama;22 +2202;Ollagüe;22 +2203;San Pedro de Atacama;22 +2301;Tocopilla;23 +2302;María Elena;23 +3101;Copiapó;31 +3102;Caldera;31 +3103;Tierra Amarilla;31 +3201;Chañaral;32 +3202;Diego de Almagro;32 +3301;Vallenar;33 +3302;Alto del Carmen;33 +3303;Freirina;33 +3304;Huasco;33 +4101;La Serena;41 +4102;Coquimbo;41 +4103;Andacollo;41 +4104;La Higuera;41 +4105;Paiguano;41 +4106;Vicuña;41 +4201;Illapel;42 +4202;Canela;42 +4203;Los Vilos;42 +4204;Salamanca;42 +4301;Ovalle;43 +4302;Combarbalá;43 +4303;Monte Patria;43 +4304;Punitaqui;43 +4305;Río Hurtado;43 +5101;Valparaíso;51 +5102;Casablanca;51 +5103;Concón;51 +5104;Juan Fernández;51 +5105;Puchuncaví;51 +5107;Quintero;51 +5109;Viña del Mar;51 +5201;Isla de Pascua;52 +5301;Los Andes;53 +5302;Calle Larga;53 +5303;Rinconada;53 +5304;San Esteban;53 +5401;La Ligua;54 +5402;Cabildo;54 +5403;Papudo;54 +5404;Petorca;54 +5405;Zapallar;54 +5501;Quillota;55 +5502;Calera;55 +5503;Hijuelas;55 +5504;La Cruz;55 +5506;Nogales;55 +5601;San Antonio;56 +5602;Algarrobo;56 +5603;Cartagena;56 +5604;El Quisco;56 +5605;El Tabo;56 +5606;Santo Domingo;56 +5701;San Felipe;57 +5702;Catemu;57 +5703;Llaillay;57 +5704;Panquehue;57 +5705;Putaendo;57 +5706;Santa María;57 +5801;Quilpué;58 +5802;Limache;58 +5803;Olmué;58 +5804;Villa Alemana;58 +6101;Rancagua;61 +6102;Codegua;61 +6103;Coinco;61 +6104;Coltauco;61 +6105;Doñihue;61 +6106;Graneros;61 +6107;Las Cabras;61 +6108;Machalí;61 +6109;Malloa;61 +6110;Mostazal;61 +6111;Olivar;61 +6112;Peumo;61 +6113;Pichidegua;61 +6114;Quinta de Tilcoco;61 +6115;Rengo;61 +6116;Requínoa;61 +6117;San Vicente;61 +6201;Pichilemu;62 +6202;La Estrella;62 +6203;Litueche;62 +6204;Marchihue;62 +6205;Navidad;62 +6206;Paredones;62 +6301;San Fernando;63 +6302;Chépica;63 +6303;Chimbarongo;63 +6304;Lolol;63 +6305;Nancagua;63 +6306;Palmilla;63 +6307;Peralillo;63 +6308;Placilla;63 +6309;Pumanque;63 +6310;Santa Cruz;63 +7101;Talca;71 +7102;Constitución;71 +7103;Curepto;71 +7104;Empedrado;71 +7105;Maule;71 +7106;Pelarco;71 +7107;Pencahue;71 +7108;Río Claro;71 +7109;San Clemente;71 +7110;San Rafael;71 +7201;Cauquenes;72 +7202;Chanco;72 +7203;Pelluhue;72 +7301;Curicó;73 +7302;Hualañé;73 +7303;Licantén;73 +7304;Molina;73 +7305;Rauco;73 +7306;Romeral;73 +7307;Sagrada Familia;73 +7308;Teno;73 +7309;Vichuquén;73 +7401;Linares;74 +7402;Colbún;74 +7403;Longaví;74 +7404;Parral;74 +7405;Retiro;74 +7406;San Javier;74 +7407;Villa Alegre;74 +7408;Yerbas Buenas;74 +8101;Concepción;81 +8102;Coronel;81 +8103;Chiguayante;81 +8104;Florida;81 +8105;Hualqui;81 +8106;Lota;81 +8107;Penco;81 +8108;San Pedro de la Paz;81 +8109;Santa Juana;81 +8110;Talcahuano;81 +8111;Tomé;81 +8112;Hualpén;81 +8201;Lebu;82 +8202;Arauco;82 +8203;Cañete;82 +8204;Contulmo;82 +8205;Curanilahue;82 +8206;Los Álamos;82 +8207;Tirúa;82 +8301;Los Ángeles;83 +8302;Antuco;83 +8303;Cabrero;83 +8304;Laja;83 +8305;Mulchén;83 +8306;Nacimiento;83 +8307;Negrete;83 +8308;Quilaco;83 +8309;Quilleco;83 +8310;San Rosendo;83 +8311;Santa Bárbara;83 +8312;Tucapel;83 +8313;Yumbel;83 +8314;Alto Biobío;83 +8401;Chillán;84 +8402;Bulnes;84 +8403;Cobquecura;84 +8404;Coelemu;84 +8405;Coihueco;84 +8406;Chillán Viejo;84 +8407;El Carmen;84 +8408;Ninhue;84 +8409;Ñiquén;84 +8410;Pemuco;84 +8411;Pinto;84 +8412;Portezuelo;84 +8413;Quillón;84 +8414;Quirihue;84 +8415;Ránquil;84 +8416;San Carlos;84 +8417;San Fabián;84 +8418;San Ignacio;84 +8419;San Nicolás;84 +8420;Treguaco;84 +8421;Yungay;84 +9101;Temuco;91 +9102;Carahue;91 +9103;Cunco;91 +9104;Curarrehue;91 +9105;Freire;91 +9106;Galvarino;91 +9107;Gorbea;91 +9108;Lautaro;91 +9109;Loncoche;91 +9110;Melipeuco;91 +9111;Nueva Imperial;91 +9112;Padre las Casas;91 +9113;Perquenco;91 +9114;Pitrufquén;91 +9115;Pucón;91 +9116;Saavedra;91 +9117;Teodoro Schmidt;91 +9118;Toltén;91 +9119;Vilcún;91 +9120;Villarrica;91 +9121;Cholchol;91 +9201;Angol;92 +9202;Collipulli;92 +9203;Curacautín;92 +9204;Ercilla;92 +9205;Lonquimay;92 +9206;Los Sauces;92 +9207;Lumaco;92 +9208;Purén;92 +9209;Renaico;92 +9210;Traiguén;92 +9211;Victoria;92 +10101;Puerto Montt;101 +10102;Calbuco;101 +10103;Cochamó;101 +10104;Fresia;101 +10105;Frutillar;101 +10106;Los Muermos;101 +10107;Llanquihue;101 +10108;Maullín;101 +10109;Puerto Varas;101 +10201;Castro;102 +10202;Ancud;102 +10203;Chonchi;102 +10204;Curaco de Vélez;102 +10205;Dalcahue;102 +10206;Puqueldón;102 +10207;Queilén;102 +10208;Quellón;102 +10209;Quemchi;102 +10210;Quinchao;102 +10301;Osorno;103 +10302;Puerto Octay;103 +10303;Purranque;103 +10304;Puyehue;103 +10305;Río Negro;103 +10306;San Juan de la Costa;103 +10307;San Pablo;103 +10401;Chaitén;104 +10402;Futaleufú;104 +10403;Hualaihué;104 +10404;Palena;104 +11101;Coihaique;111 +11102;Lago Verde;111 +11201;Aisén;112 +11202;Cisnes;112 +11203;Guaitecas;112 +11301;Cochrane;113 +11302;O’Higgins;113 +11303;Tortel;113 +11401;Chile Chico;114 +11402;Río Ibáñez;114 +12101;Punta Arenas;121 +12102;Laguna Blanca;121 +12103;Río Verde;121 +12104;San Gregorio;121 +12201;Cabo de Hornos (Ex Navarino);122 +12202;Antártica;122 +12301;Porvenir;123 +12302;Primavera;123 +12303;Timaukel;123 +12401;Natales;124 +12402;Torres del Paine;124 +13101;Santiago;131 +13102;Cerrillos;131 +13103;Cerro Navia;131 +13104;Conchalí;131 +13105;El Bosque;131 +13106;Estación Central;131 +13107;Huechuraba;131 +13108;Independencia;131 +13109;La Cisterna;131 +13110;La Florida;131 +13111;La Granja;131 +13112;La Pintana;131 +13113;La Reina;131 +13114;Las Condes;131 +13115;Lo Barnechea;131 +13116;Lo Espejo;131 +13117;Lo Prado;131 +13118;Macul;131 +13119;Maipú;131 +13120;Ñuñoa;131 +13121;Pedro Aguirre Cerda;131 +13122;Peñalolén;131 +13123;Providencia;131 +13124;Pudahuel;131 +13125;Quilicura;131 +13126;Quinta Normal;131 +13127;Recoleta;131 +13128;Renca;131 +13129;San Joaquín;131 +13130;San Miguel;131 +13131;San Ramón;131 +13132;Vitacura;131 +13201;Puente Alto;132 +13202;Pirque;132 +13203;San José de Maipo;132 +13301;Colina;133 +13302;Lampa;133 +13303;Tiltil;133 +13401;San Bernardo;134 +13402;Buin;134 +13403;Calera de Tango;134 +13404;Paine;134 +13501;Melipilla;135 +13502;Alhué;135 +13503;Curacaví;135 +13504;María Pinto;135 +13505;San Pedro;135 +13601;Talagante;136 +13602;El Monte;136 +13603;Isla de Maipo;136 +13604;Padre Hurtado;136 +13605;Peñaflor;136 +14101;Valdivia;141 +14102;Corral;141 +14103;Lanco;141 +14104;Los Lagos;141 +14105;Máfil;141 +14106;Mariquina;141 +14107;Paillaco;141 +14108;Panguipulli;141 +14201;La Unión;142 +14202;Futrono;142 +14203;Lago Ranco;142 +14204;Río Bueno;142 +15101;Arica;151 +15102;Camarones;151 +15201;Putre;152 +15202;General Lagos;152 diff --git a/app/resources/database/seeds/provincia.csv b/app/resources/database/seeds/provincia.csv new file mode 100644 index 0000000..0f5abbe --- /dev/null +++ b/app/resources/database/seeds/provincia.csv @@ -0,0 +1,55 @@ +id;descripcion;region +11;Iquique;1 +14;Tamarugal;1 +21;Antofagasta;2 +22;El Loa;2 +23;Tocopilla;2 +31;Copiap;3 +32;Chañaral;3 +33;Huasco;3 +41;Elqui;4 +42;Choapa;4 +43;Limari;4 +51;Valparaíso;5 +52;Isla de Pascua;5 +53;Los Andes;5 +54;Petorca;5 +55;Quillota;5 +56;San Antonio;5 +57;San Felipe;5 +58;Marga Marga;5 +61;Cachapoal;6 +62;Cardenal Caro;6 +63;Colchagua;6 +71;Talca;7 +72;Cauquenes;7 +73;Curico;7 +74;Linares;7 +81;Concepci;8 +82;Arauco;8 +83;Bío- Bío;8 +84;Ñuble;8 +91;Cautín;9 +92;Malleco;9 +101;Llanquihue;10 +102;Chiloe;10 +103;Osorno;10 +104;Palena;10 +111;Coihaique;11 +112;Aisén;11 +113;Capitan Prat;11 +114;General Carrera;11 +121;Magallanes;12 +122;Antártica Chilena;12 +123;Tierra del Fuego;12 +124;Ultima Esperanza;12 +131;Santiago;13 +132;Cordillera;13 +133;Chacabuco;13 +134;Maipo;13 +135;Melipilla;13 +136;Talagante;13 +141;Valdivia;14 +142;Ranco;14 +151;Arica;15 +152;Parinacota;15 diff --git a/app/resources/database/seeds/region.csv b/app/resources/database/seeds/region.csv new file mode 100644 index 0000000..a6d8425 --- /dev/null +++ b/app/resources/database/seeds/region.csv @@ -0,0 +1,16 @@ +id;descripcion;numeral;numeracion +1;Región de Tarapacá;I;1 +2;Región de Antofagasta;II;2 +3;Región de Atacama;III;3 +4;Región de Coquimbo;IV;4 +5;Región de Valparaíso;V;5 +6;Región del Libertador Gral. Bernardo O’Higgins;VI;6 +7;Región del Maule;VII;7 +8;Región del Biobío;VIII;8 +9;Región de la Araucanía;IX;9 +10;Región de Los Lagos;X;10 +11;Región Aisén del Gral. Carlos Ibáñez del Campo;XI;11 +12;Región de Magallanes y de la Antártica Chilena;XII;12 +13;Región Metropolitana de Santiago;RM;13 +14;Región de Los Ríos;XIV;14 +15;Región de Arica y Parinacota;XV;15 diff --git a/app/resources/routes/03_proyectos.php b/app/resources/routes/03_proyectos.php index 332e7e7..1cc23c0 100644 --- a/app/resources/routes/03_proyectos.php +++ b/app/resources/routes/03_proyectos.php @@ -2,6 +2,16 @@ use Incoviba\Controller\Proyectos; $app->group('/proyectos', function($app) { + $folder = implode(DIRECTORY_SEPARATOR, [__DIR__, 'proyectos']); + if (file_exists($folder)) { + $files = new FilesystemIterator($folder); + foreach ($files as $file) { + if ($file->isDir()) { + continue; + } + include_once $file->getRealPath(); + } + } $app->get('/unidades[/]', [Proyectos::class, 'unidades']); $app->get('[/]', Proyectos::class); })->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class)); diff --git a/app/resources/routes/04_ventas.php b/app/resources/routes/04_ventas.php index 3834184..270c83b 100644 --- a/app/resources/routes/04_ventas.php +++ b/app/resources/routes/04_ventas.php @@ -23,6 +23,7 @@ $app->group('/venta/{venta_id:[0-9]+}', function($app) { $app->get('[/]', [Ventas::class, 'propiedad']); }); $app->group('/pie', function($app) { + $app->get('/add[/]', [Ventas\Pies::class, 'add']); $app->group('/cuotas', function($app) { $app->get('[/]', [Ventas::class, 'cuotas']); }); diff --git a/app/resources/routes/05_contabilidad.php b/app/resources/routes/05_contabilidad.php index 08de783..14ac085 100644 --- a/app/resources/routes/05_contabilidad.php +++ b/app/resources/routes/05_contabilidad.php @@ -7,4 +7,4 @@ $app->group('/contabilidad', function($app) { } include_once $file->getRealPath(); } -}); +})->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class)); diff --git a/app/resources/routes/96_admin.php b/app/resources/routes/96_admin.php index 4a79cb3..19ee387 100644 --- a/app/resources/routes/96_admin.php +++ b/app/resources/routes/96_admin.php @@ -7,4 +7,4 @@ $app->group('/admin', function($app) { } include_once $file->getRealPath(); } -}); +})->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class)); diff --git a/app/resources/routes/api/admin/users.php b/app/resources/routes/api/admin/users.php index b05b43d..4160b5c 100644 --- a/app/resources/routes/api/admin/users.php +++ b/app/resources/routes/api/admin/users.php @@ -2,5 +2,9 @@ use Incoviba\Controller\API\Admin\Users; $app->group('/users', function($app) { - $app->post('/add[/]', Users::class . ':add'); + $app->post('/add[/]', [Users::class, 'add']); +}); +$app->group('/user/{user_id}', function($app) { + $app->post('/edit[/]', [Users::class, 'edit']); + $app->delete('[/]', [Users::class, 'delete']); }); diff --git a/app/resources/routes/api/external.php b/app/resources/routes/api/external.php new file mode 100644 index 0000000..e9b7ae9 --- /dev/null +++ b/app/resources/routes/api/external.php @@ -0,0 +1,16 @@ +group('/external', function($app) { + $files = new FilesystemIterator(implode(DIRECTORY_SEPARATOR, [__DIR__, 'external'])); + foreach ($files as $file) { + if ($file->isDir()) { + continue; + } + include_once $file->getRealPath(); + } + $app->group('/services', function($app) { + $app->get('/check[/]', [External::class, 'check']); + $app->get('/update[/]', [External::class, 'update']); + }); +}); diff --git a/app/resources/routes/api/external/toku.php b/app/resources/routes/api/external/toku.php new file mode 100644 index 0000000..6a93cc8 --- /dev/null +++ b/app/resources/routes/api/external/toku.php @@ -0,0 +1,11 @@ +group('/toku', function($app) { + $app->post('/cuotas/{venta_id}[/]', [Toku::class, 'cuotas']); + $app->post('/success[/]', [Toku::class, 'success']); + $app->get('/test[/]', [Toku::class, 'test']); + $app->delete('/reset[/]', [Toku::class, 'reset']); + $app->post('/enqueue[/]', [Toku::class, 'enqueue']); + $app->post('/update[/{type}[/]]', [Toku::class, 'update']); +}); diff --git a/app/resources/routes/api/proyectos.php b/app/resources/routes/api/proyectos.php index 0dd2495..15d0445 100644 --- a/app/resources/routes/api/proyectos.php +++ b/app/resources/routes/api/proyectos.php @@ -3,6 +3,13 @@ use Incoviba\Controller\API\Proyectos; $app->group('/proyectos', function($app) { $app->get('/escriturando[/]', [Proyectos::class, 'escriturando']); + $files = new FilesystemIterator(implode(DIRECTORY_SEPARATOR, [__DIR__, 'proyectos'])); + foreach ($files as $file) { + if ($file->isDir()) { + continue; + } + include_once $file->getRealPath(); + } $app->get('[/]', [Proyectos::class, 'list']); }); $app->group('/proyecto/{proyecto_id}', function($app) { @@ -14,10 +21,13 @@ $app->group('/proyecto/{proyecto_id}', function($app) { $app->get('/vendible[/]', [Proyectos::class, 'superficies']); }); $app->group('/unidades', function($app) { + $app->post('/precios[/]', [Proyectos\Unidades::class, 'precios']); + $app->post('/estados[/]', [Proyectos\Unidades::class, 'estados']); $app->get('/disponibles[/]', [Proyectos::class, 'disponibles']); $app->get('[/]', [Proyectos::class, 'unidades']); }); $app->group('/terreno', function($app) { $app->post('/edit[/]', [Proyectos::class, 'terreno']); }); + $app->get('/brokers', [Proyectos::class, 'brokers']); }); diff --git a/app/resources/routes/api/proyectos/brokers.php b/app/resources/routes/api/proyectos/brokers.php new file mode 100644 index 0000000..9df5d0f --- /dev/null +++ b/app/resources/routes/api/proyectos/brokers.php @@ -0,0 +1,30 @@ +group('/brokers', function($app) { + $app->group('/contracts', function($app) { + $app->post('/add[/]', [Contracts::class, 'add']); + $app->get('[/]', Contracts::class); + }); + $app->group('/contract/{contract_id}', function($app) { + $app->post('/edit[/]', [Contracts::class, 'edit']); + $app->post('/inactive[/]', [Contracts::class, 'inactive']); + $app->delete('[/]', [Contracts::class, 'delete']); + $app->get('[/]', [Contracts::class, 'get']); + }); + $app->post('/add[/]', [Brokers::class, 'add']); + $app->post('/edit[/]', [Brokers::class, 'edit']); + $app->get('[/]', Brokers::class); +}); +$app->group('/broker/{broker_rut}', function($app) { + $app->group('/contracts', function($app) { + $app->post('/add[/]', [Contracts::class, 'add']); + $app->get('[/]', [Contracts::class, 'getByBroker']); + }); + $app->group('/contract/{contract_id}', function($app) { + $app->post('/promotions[/]', [Contracts::class, 'promotions']); + }); + $app->delete('[/]', [Brokers::class, 'delete']); + $app->get('[/]', [Brokers::class, 'get']); +}); diff --git a/app/resources/routes/api/queue.php b/app/resources/routes/api/queue.php new file mode 100644 index 0000000..43a94d1 --- /dev/null +++ b/app/resources/routes/api/queue.php @@ -0,0 +1,10 @@ +group('/queue', function($app) { + #$app->get('/jobs[/]', [Queues::class, 'jobs']); + $app->group('/run', function($app) { + #$app->get('/{job_id:[0-9]+}[/]', [Queues::class, 'run']); + $app->get('[/]', Queues::class); + }); +}); diff --git a/app/resources/routes/api/ventas.php b/app/resources/routes/api/ventas.php index 02833f8..cb32bc0 100644 --- a/app/resources/routes/api/ventas.php +++ b/app/resources/routes/api/ventas.php @@ -21,6 +21,7 @@ $app->group('/ventas', function($app) { }); $app->group('/by', function($app) { $app->get('/unidad/{unidad_id}', [Ventas::class, 'unidad']); + $app->post('/unidades[/]', [Ventas::class, 'byUnidades']); }); $app->post('/get[/]', [Ventas::class, 'getMany']); $app->post('[/]', [Ventas::class, 'proyecto']); @@ -55,6 +56,9 @@ $app->group('/venta/{venta_id}', function($app) { $app->group('/propietario', function($app) { $app->put('/edit[/]', [Ventas::class, 'propietario']); }); + $app->group('/pie', function($app) { + $app->post('/add[/]', [Ventas\Pies::class, 'add']); + }); $app->post('[/]', [Ventas::class, 'edit']); $app->get('[/]', [Ventas::class, 'get']); }); diff --git a/app/resources/routes/api/ventas/promotions.php b/app/resources/routes/api/ventas/promotions.php new file mode 100644 index 0000000..5cb3c8e --- /dev/null +++ b/app/resources/routes/api/ventas/promotions.php @@ -0,0 +1,28 @@ +group('/promotions', function($app) { + $app->post('/add[/]', [Promotions::class, 'add']); + $app->post('/edit[/]', [Promotions::class, 'edit']); +}); +$app->group('/promotion/{promotion_id}', function($app) { + $app->delete('/remove[/]', [Promotions::class, 'remove']); + $app->group('/connections', function($app) { + $app->post('/add[/]', [Promotions::class, 'addConnections']); + $app->group('/project/{project_id}', function($app) { + $app->delete('[/]', [Promotions::class, 'removeProject']); + $app->group('/unit-type/{unit_type_id}', function($app) { + $app->delete('[/]', [Promotions::class, 'removeUnitType']); + }); + }); + $app->group('/broker/{broker_rut}', function($app) { + $app->delete('[/]', [Promotions::class, 'removeBroker']); + }); + $app->group('/unit-line/{unit_line_id}', function($app) { + $app->delete('[/]', [Promotions::class, 'removeUnitLine']); + }); + $app->group('/unit/{unit_id}', function($app) { + $app->delete('[/]', [Promotions::class, 'removeUnit']); + }); + }); +}); diff --git a/app/resources/routes/api/ventas/reservations.php b/app/resources/routes/api/ventas/reservations.php new file mode 100644 index 0000000..7e2e194 --- /dev/null +++ b/app/resources/routes/api/ventas/reservations.php @@ -0,0 +1,12 @@ +group('/reservations', function($app) { + $app->post('/add[/]', [Reservations::class, 'add']); + $app->get('[/]', Reservations::class); +}); +$app->group('/reservation/{reservation_id}', function($app) { + $app->post('/edit[/]', [Reservations::class, 'edit']); + $app->delete('[/]', [Reservations::class, 'delete']); + $app->get('[/]', [Reservations::class, 'get']); +}); diff --git a/app/resources/routes/proyectos/brokers.php b/app/resources/routes/proyectos/brokers.php new file mode 100644 index 0000000..448135f --- /dev/null +++ b/app/resources/routes/proyectos/brokers.php @@ -0,0 +1,12 @@ +group('/brokers', function($app) { + $app->get('[/]', Brokers::class); +}); +$app->group('/broker/{broker_rut}', function($app) { + $app->group('/contract/{contract_id}', function($app) { + $app->get('[/]', [Brokers\Contracts::class, 'show']); + }); + $app->get('[/]', [Brokers::class, 'show']); +}); diff --git a/app/resources/routes/ventas/promotions.php b/app/resources/routes/ventas/promotions.php new file mode 100644 index 0000000..bad3850 --- /dev/null +++ b/app/resources/routes/ventas/promotions.php @@ -0,0 +1,9 @@ +group('/promotions', function($app) { + $app->get('[/]', Promotions::class); +}); +$app->group('/promotion/{promotion_id}', function($app) { + $app->get('[/]', [Promotions::class, 'show']); +}); diff --git a/app/resources/views/admin/users.blade.php b/app/resources/views/admin/users.blade.php index cf98844..d0339bf 100644 --- a/app/resources/views/admin/users.blade.php +++ b/app/resources/views/admin/users.blade.php @@ -14,15 +14,15 @@ - + @foreach($users as $user) - + {{ $user->name }} - - @@ -50,6 +50,10 @@ +
+ + +
@@ -62,6 +66,45 @@
+ @endsection @include('layout.body.scripts.cryptojs') @@ -74,12 +117,20 @@ return [passphrase, encrypted.toString()].join('') } $(document).ready(function () { - $('#create-user-modal').modal({ + const $createUserModal = $('#create-user-modal') + $createUserModal.modal({ onApprove: function() { + const form = document.querySelector('#create-user-modal form') + const password = form.querySelector('[name="password"]').value + const password_confirmation = form.querySelector('[name="password_confirmation"]').value + if (password !== password_confirmation) { + alert('Las contraseñas no coinciden') + return + } const url = '{{$urls->api}}/admin/users/add' const method = 'post' - const body = new FormData(document.querySelector('#create-user-modal form')) - body.set('password', encryptPassword(body.get('password'))) + const body = new FormData(form) + body.set('password', encryptPassword(password)) fetchAPI(url, {method, body}).then(response => { if (!response) { return; @@ -92,8 +143,64 @@ }) } }) - $('#create-user-button').on('click', function () { - $('#create-user-modal').modal('show') + const $editUserModal = $('#edit-user-modal') + $editUserModal.modal({ + onApprove: function() { + const form = document.querySelector('#edit-user-modal form') + const user_id = form.querySelector('[name="id"]').value + const old_password = form.querySelector('[name="old_password"]').value + const password = form.querySelector('[name="password"]').value + const password_confirmation = form.querySelector('[name="password_confirmation"]').value + if (password !== password_confirmation) { + alert('Las nuevas contraseñas no coinciden') + return + } + const url = `{{$urls->api}}/admin/user/${user_id}/edit` + const method = 'post' + const body = new FormData(form) + body.set('old_password', encryptPassword(old_password)) + body.set('password', encryptPassword(password)) + if (form.querySelector('[name="force"]').checked) { + body.set('force', 'true') + } + fetchAPI(url, {method, body}).then(response => { + if (!response) { + return; + } + response.json().then(result => { + if (result.success) { + location.reload() + } + }) + }) + } + }) + document.getElementById('create-user-modal').addEventListener('submit', event => { + $createUserModal.modal('show') + }) + document.querySelectorAll('.button.edit').forEach(button => { + button.addEventListener('click', clickEvent => { + const user_id = clickEvent.currentTarget.dataset.user + $editUserModal.find('input[name="id"]').val(user_id) + $editUserModal.modal('show') + }) + }) + document.querySelectorAll('.button.remove').forEach(button => { + button.addEventListener('click', clickEvent => { + const user_id = clickEvent.currentTarget.dataset.user + const url = `{{$urls->api}}/admin/user/${user_id}` + const method = 'delete' + fetchAPI(url, {method}).then(response => { + if (!response) { + return; + } + response.json().then(result => { + if (result.success) { + location.reload() + } + }) + }) + }) }) }); diff --git a/app/resources/views/contabilidad/movimientos/scripts/movimientos_table.blade.php b/app/resources/views/contabilidad/movimientos/scripts/movimientos_table.blade.php index 48fedb8..18c23c6 100644 --- a/app/resources/views/contabilidad/movimientos/scripts/movimientos_table.blade.php +++ b/app/resources/views/contabilidad/movimientos/scripts/movimientos_table.blade.php @@ -96,26 +96,7 @@ columnDefs, order, language: Object.assign(dtD.language, { - searchBuilder: { - add: 'Filtrar', - condition: 'Comparador', - clearAll: 'Resetear', - delete: 'Eliminar', - deleteTitle: 'Eliminar Titulo', - data: 'Columna', - left: 'Izquierda', - leftTitle: 'Titulo Izquierdo', - logicAnd: 'Y', - logicOr: 'O', - right: 'Derecha', - rightTitle: 'Titulo Derecho', - title: { - 0: 'Filtros', - _: 'Filtros (%d)' - }, - value: 'Opciones', - valueJoiner: 'y' - } + searchBuilder }), layout: { top1: { diff --git a/app/resources/views/home.blade.php b/app/resources/views/home.blade.php index 24d7e79..33d01c4 100644 --- a/app/resources/views/home.blade.php +++ b/app/resources/views/home.blade.php @@ -20,7 +20,7 @@ @endsection @push('page_scripts') - - diff --git a/app/resources/views/layout/body/scripts/datatables.blade.php b/app/resources/views/layout/body/scripts/datatables.blade.php index 36ba125..1849417 100644 --- a/app/resources/views/layout/body/scripts/datatables.blade.php +++ b/app/resources/views/layout/body/scripts/datatables.blade.php @@ -1,4 +1,4 @@ @push('page_scripts') - + @endpush diff --git a/app/resources/views/layout/body/scripts/datatables/searchbuilder.blade.php b/app/resources/views/layout/body/scripts/datatables/searchbuilder.blade.php index abd45e6..1e1b686 100644 --- a/app/resources/views/layout/body/scripts/datatables/searchbuilder.blade.php +++ b/app/resources/views/layout/body/scripts/datatables/searchbuilder.blade.php @@ -2,4 +2,26 @@ + @endpush diff --git a/app/resources/views/layout/body/scripts/number_format.blade.php b/app/resources/views/layout/body/scripts/number_format.blade.php new file mode 100644 index 0000000..f3b2cb4 --- /dev/null +++ b/app/resources/views/layout/body/scripts/number_format.blade.php @@ -0,0 +1,45 @@ +@push('page_scripts') + +@endpush \ No newline at end of file diff --git a/app/resources/views/layout/body/scripts/number_input.blade.php b/app/resources/views/layout/body/scripts/number_input.blade.php new file mode 100644 index 0000000..589478c --- /dev/null +++ b/app/resources/views/layout/body/scripts/number_input.blade.php @@ -0,0 +1,76 @@ +@push('page_scripts') + +@endpush diff --git a/app/resources/views/layout/body/scripts/rut.blade.php b/app/resources/views/layout/body/scripts/rut.blade.php index 832d810..a6b86c1 100644 --- a/app/resources/views/layout/body/scripts/rut.blade.php +++ b/app/resources/views/layout/body/scripts/rut.blade.php @@ -28,7 +28,7 @@ if (!(typeof digito === 'string' || digito instanceof String)) { digito = digito.toString() } - return Rut.digitoVerificador(rut) === digito + return Rut.digitoVerificador(rut).toString().toUpperCase() === digito.toUpperCase() } } diff --git a/app/resources/views/layout/body/scripts/stats.blade.php b/app/resources/views/layout/body/scripts/stats.blade.php new file mode 100644 index 0000000..6b777bf --- /dev/null +++ b/app/resources/views/layout/body/scripts/stats.blade.php @@ -0,0 +1,6 @@ +@prepend('page_scripts') + + +@endprepend diff --git a/app/resources/views/layout/head.blade.php b/app/resources/views/layout/head.blade.php index 98233b9..9d6c07f 100644 --- a/app/resources/views/layout/head.blade.php +++ b/app/resources/views/layout/head.blade.php @@ -1,9 +1,9 @@ @hasSection('page_title') - Incoviba - @yield('page_title') + Incoviba - @yield('page_title') @else - Incoviba + Incoviba @endif @include('layout.head.styles') diff --git a/app/resources/views/login/form.blade.php b/app/resources/views/login/form.blade.php index 42445c1..65f2fdd 100644 --- a/app/resources/views/login/form.blade.php +++ b/app/resources/views/login/form.blade.php @@ -19,7 +19,7 @@ @include('layout.body.scripts.cryptojs') @push('page_scripts') - +@endpush diff --git a/app/resources/views/proyectos/brokers/add_modal.blade.php b/app/resources/views/proyectos/brokers/add_modal.blade.php new file mode 100644 index 0000000..3c7e7d5 --- /dev/null +++ b/app/resources/views/proyectos/brokers/add_modal.blade.php @@ -0,0 +1,115 @@ + + +@include('layout.body.scripts.rut') + +@push('page_scripts') + +@endpush diff --git a/app/resources/views/proyectos/brokers/base.blade.php b/app/resources/views/proyectos/brokers/base.blade.php new file mode 100644 index 0000000..ef52115 --- /dev/null +++ b/app/resources/views/proyectos/brokers/base.blade.php @@ -0,0 +1,22 @@ +@extends('layout.base') + +@section('page_title') + @hasSection('brokers_title') + Operadores - @yield('brokers_title') + @else + Operadores + @endif +@endsection + +@section('page_content') +
+

+ @hasSection('brokers_header') + Operador - @yield('brokers_header') + @else + Operadores + @endif +

+ @yield('brokers_content') +
+@endsection diff --git a/app/resources/views/proyectos/brokers/contracts/show.blade.php b/app/resources/views/proyectos/brokers/contracts/show.blade.php new file mode 100644 index 0000000..a393e46 --- /dev/null +++ b/app/resources/views/proyectos/brokers/contracts/show.blade.php @@ -0,0 +1,489 @@ +@extends('proyectos.brokers.base') + +@section('brokers_title') + {{ $contract->broker->name }} - {{ $contract->project->descripcion }} +@endsection + +@section('brokers_header') + {{ $contract->broker->name }} - {{ $contract->project->descripcion }} +@endsection + +@include('layout.body.scripts.stats') + +@prepend('page_scripts') + +@endprepend + +@section('brokers_content') +
+
{{ $format->percent($contract->commission ?? 0, 2, true) }}
+
+ Comisión desde {{ $contract->current()?->date?->format('d/m/Y') }} +
+
+
+
+
+
+ Promociones Aplicadas +
+
+ @if (count($contract->promotions()) === 0) + - Ninguna + @else +
+ @foreach ($contract->promotions() as $promotion) +
+ {{ $promotion->description }} {{ $format->percent($promotion->amount, 2, true) }} {{ ucwords($promotion->type->name()) }} +
+ @endforeach +
+ @endif +
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+ @include('proyectos.brokers.contracts.show.tipo') +
+
+ @include('proyectos.brokers.contracts.show.linea') +
+
+ @include('proyectos.brokers.contracts.show.unidades') +
+
+@endsection + +@include('layout.body.scripts.datatables') +@include('layout.body.scripts.datatables.searchbuilder') +@include('layout.body.scripts.datatables.buttons') + +@push('page_scripts') + +@endpush diff --git a/app/resources/views/proyectos/brokers/contracts/show/linea.blade.php b/app/resources/views/proyectos/brokers/contracts/show/linea.blade.php new file mode 100644 index 0000000..3536b89 --- /dev/null +++ b/app/resources/views/proyectos/brokers/contracts/show/linea.blade.php @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + +
TipoLíneaOrientaciónCantidadPrecio BaseComisiónPrecio OperadorPromociones
+ +@push('page_scripts') + +@endpush diff --git a/app/resources/views/proyectos/brokers/contracts/show/tipo.blade.php b/app/resources/views/proyectos/brokers/contracts/show/tipo.blade.php new file mode 100644 index 0000000..c126d5b --- /dev/null +++ b/app/resources/views/proyectos/brokers/contracts/show/tipo.blade.php @@ -0,0 +1,71 @@ + + + + + + + + + + + + +
TipoCantidadPrecio BaseComisiónPrecio OperadorPromociones
+ +@push('page_scripts') + +@endpush diff --git a/app/resources/views/proyectos/brokers/contracts/show/unidades.blade.php b/app/resources/views/proyectos/brokers/contracts/show/unidades.blade.php new file mode 100644 index 0000000..cd62a14 --- /dev/null +++ b/app/resources/views/proyectos/brokers/contracts/show/unidades.blade.php @@ -0,0 +1,254 @@ + + + + + + + + + + + + + + + + + + + + + + + +
EstadoTipoTipo OrderUnidadUnidad OrdenTipologíaPisoOrientaciónm² Interiorm² Terrazam² Vendiblesm² TotalPrecio BaseComisiónPrecio OperadorUF/m²Promociones
+ +@push('page_scripts') + +@endpush diff --git a/app/resources/views/proyectos/brokers/edit_modal.blade.php b/app/resources/views/proyectos/brokers/edit_modal.blade.php new file mode 100644 index 0000000..a1ff35b --- /dev/null +++ b/app/resources/views/proyectos/brokers/edit_modal.blade.php @@ -0,0 +1,113 @@ + + +@push('page_scripts') + +@endpush diff --git a/app/resources/views/proyectos/brokers/proyectos.blade.php b/app/resources/views/proyectos/brokers/proyectos.blade.php new file mode 100644 index 0000000..2b5cb69 --- /dev/null +++ b/app/resources/views/proyectos/brokers/proyectos.blade.php @@ -0,0 +1,52 @@ +
+ + +
+ + + + + + + + @foreach($projects as $project) + + + + @endforeach + +
Proyecto
+ +@push('page_scripts') + +@endpush diff --git a/app/resources/views/proyectos/brokers/show.blade.php b/app/resources/views/proyectos/brokers/show.blade.php new file mode 100644 index 0000000..e9c5348 --- /dev/null +++ b/app/resources/views/proyectos/brokers/show.blade.php @@ -0,0 +1,170 @@ +@extends('proyectos.brokers.base') + +@section('brokers_title') + {{ $broker->name }} +@endsection + +@section('brokers_header') + {{ $broker->name }} +@endsection + +@section('brokers_content') +
+ RUT: {{ $broker->rutFull() }}
+ Razón Social: {{ $broker->data()?->legalName }} +
+ @if ($broker->data()?->representative->name !== null) +
+
+
+ Contacto +
+
+ Nombre: {{ $broker->data()?->representative?->name }}
+ Email: {{ $broker->data()?->representative?->email }}
+ Teléfono: {{ $broker->data()?->representative?->phone }}
+ Dirección: {{ $broker->data()?->representative?->address }} +
+
+
+ @endif + + + + + + + + + + + @foreach($broker->contracts() as $contract) + + + + + + + @endforeach + +
ProyectoComisiónFecha Inicio + +
+ + {{ $contract->project->descripcion }} + + + {{ $format->percent($contract->commission, 2, true) }}{{ $contract->current()->date->format('d-m-Y') }} + +
+ + @include('proyectos.brokers.show.add_modal') +@endsection + +@include('layout.body.scripts.datatables') + +@push('page_scripts') + +@endpush diff --git a/app/resources/views/proyectos/brokers/show/add_modal.blade.php b/app/resources/views/proyectos/brokers/show/add_modal.blade.php new file mode 100644 index 0000000..7b6bfd7 --- /dev/null +++ b/app/resources/views/proyectos/brokers/show/add_modal.blade.php @@ -0,0 +1,96 @@ + + +@push('page_scripts') + +@endpush diff --git a/app/resources/views/proyectos/list.blade.php b/app/resources/views/proyectos/list.blade.php index c01ac85..c67853f 100644 --- a/app/resources/views/proyectos/list.blade.php +++ b/app/resources/views/proyectos/list.blade.php @@ -35,7 +35,7 @@ @endsection @push('page_scripts') - +@endpush diff --git a/app/resources/views/ventas/pies/bonos/edit.blade.php b/app/resources/views/ventas/pies/bonos/edit.blade.php index ab9c216..879e0d9 100644 --- a/app/resources/views/ventas/pies/bonos/edit.blade.php +++ b/app/resources/views/ventas/pies/bonos/edit.blade.php @@ -33,6 +33,8 @@ @endsection +@include('layout.body.scripts.number_input') + @push('page_scripts') +@endpush diff --git a/app/resources/views/ventas/promotions/add_modal.blade.php b/app/resources/views/ventas/promotions/add_modal.blade.php new file mode 100644 index 0000000..6a71ba0 --- /dev/null +++ b/app/resources/views/ventas/promotions/add_modal.blade.php @@ -0,0 +1,100 @@ +