diff --git a/resources/js/app.js b/resources/js/app.js new file mode 100644 index 0000000..9f41c7f --- /dev/null +++ b/resources/js/app.js @@ -0,0 +1,30 @@ +require('./bootstrap'); + +var autocomplete = require('jquery-ui/ui/widgets/autocomplete'); + +$(document).ready(function() { + $('form:first').find('*').filter(':input:visible:first').focus(); + + $('.dropdown-submenu>a').on("click", function(e) { + $(this).next('ul').toggle(); + e.stopPropagation(); + e.preventDefault(); + }); +}); + +require('./jquery.filterTable'); +require('./binaryIndexOf'); + +require('jquery.rut'); + +String.prototype.ucwords = function() { + str = this.toLowerCase(); + return str.replace(/(^([a-zA-Z\p{M}]))|([ -][a-zA-Z\p{M}])/g, + function(s) { + return s.toUpperCase(); + }); +}; + +require('./chart'); + +window.zxcvbn = require('zxcvbn'); diff --git a/resources/js/binaryIndexOf.js b/resources/js/binaryIndexOf.js new file mode 100644 index 0000000..7059895 --- /dev/null +++ b/resources/js/binaryIndexOf.js @@ -0,0 +1,28 @@ +function binaryIndexOf(searchElement) { + 'use strict'; + + var minIndex = 0; + var maxIndex = this.length - 1; + var currentIndex; + var currentElement; + var resultIndex; + + while (minIndex <= maxIndex) { + resultIndex = currentIndex = (minIndex + maxIndex) / 2 | 0; + currentElement = this[currentIndex]; + + if (currentElement < searchElement) { + minIndex = currentIndex + 1; + } + else if (currentElement > searchElement) { + maxIndex = currentIndex - 1; + } + else { + return currentIndex; + } + } + + return ~maxIndex; +} + +Array.prototype.binaryIndexOf = binaryIndexOf; \ No newline at end of file diff --git a/resources/js/bootstrap.js b/resources/js/bootstrap.js new file mode 100644 index 0000000..50f981b --- /dev/null +++ b/resources/js/bootstrap.js @@ -0,0 +1,11 @@ + +/** + * We'll load jQuery and the Bootstrap jQuery plugin which provides support + * for JavaScript based Bootstrap features such as modals and tabs. This + * code may be modified to fit the specific needs of your application. + */ + +window.$ = window.jQuery = require('jquery'); + +require('bootstrap'); +require('bootstrap-3-typeahead'); diff --git a/resources/js/chart.js b/resources/js/chart.js new file mode 100644 index 0000000..a66f23f --- /dev/null +++ b/resources/js/chart.js @@ -0,0 +1,2 @@ +window.Chart = require('chart.js'); +require('chartjs-plugin-barchart-background'); \ No newline at end of file diff --git a/resources/js/jquery.filterTable.js b/resources/js/jquery.filterTable.js new file mode 100644 index 0000000..f38ae7f --- /dev/null +++ b/resources/js/jquery.filterTable.js @@ -0,0 +1,68 @@ +(function($) { + $.fn.filterTable = function(options) + { + var input = this; + + var excludeFilter = function(row, col, headers, excludes) { + var exclude = false; + var cols = $(headers.get(row)).find('th'); + + if (excludes.indexOf($(cols.get(col)).html().toUpperCase()) > -1) { + exclude = true; + } + + return exclude; + } + + this.keyup(function(e) { + var settings = $.extend({ + "table": "filteredTable", + "excludes": [], + "height": 1 + }, options); + var id_table = settings.table; + var excludes = settings.excludes; + var height = settings.height; + + for (i = 0; i < excludes.length; i ++) { + excludes[i] = excludes[i].toUpperCase(); + } + + var filter = input.val().toUpperCase(); + var table = $('#' + id_table); + var rows = table.find('tbody tr'); + var headers = table.find('thead tr'); + + if (filter == '') { + rows.css('display', ''); + return; + } + + for (i = 0; i < rows.length; i += height) { + var cols; + var found = false; + for (n = 0; n < height; n ++) { + cols = $(rows.get(i + n)).find('td'); + $.each(cols, function(j, e) { + if (excludeFilter(n, j, headers, excludes)) { + return; + } + if ($(this).html().toUpperCase().indexOf(filter) > -1) { + found = true; + } + }); + } + if (found) { + for (n = 0; n < height; n ++) { + $(rows.get(i + n)).css('display', ''); + } + } else { + for (n = 0; n < height; n ++) { + $(rows.get(i + n)).css('display', 'none'); + } + } + } + }); + return this; + } +}(jQuery)); \ No newline at end of file diff --git a/resources/less/Controller/Admin.php b/resources/less/Controller/Admin.php new file mode 100644 index 0000000..137057c --- /dev/null +++ b/resources/less/Controller/Admin.php @@ -0,0 +1,233 @@ +list(); + } + public static function listNamespaces() + { + $base = [ + 'Common', + 'Inmobiliaria', + 'Proyecto', + 'Venta' + ]; + $nss = [ + 'Incoviba' => [ + 'old' => $base, + 'new' => $base + ] + ]; + + echo json_encode(['namespaces' => self::collapseMultiArray($nss)]); + } + protected static function collapseMultiArray($array, $level = '') + { + $output = []; + foreach ($array as $key => $subarray) { + if (is_array($subarray)) { + $output = array_merge($output, self::collapseMultiArray($subarray, $level . '\\' . $key)); + } else { + $output []= $level . '\\' . $subarray; + } + } + + return $output; + } + public static function createModel() + { + $db = post('database'); + $ns = post('namespace'); + $table = post('table'); + + $modeler = new DBToModel($db); + echo $modeler->create($ns, $table); + } + public static function list_roles() + { + $roles = \Model::factory(\Incoviba\common\Role::class)->findMany(); + echo view('admin.roles.list', compact('roles')); + } + public static function add_role() + { + echo view('admin.roles.add'); + } + public static function do_add_role() + { + $role = \Model::factory(\Incoviba\common\Role::class)->where('description', post('description'))->findOne(); + if ($role === false) { + $role = \Model::factory(\Incoviba\common\Role::class)->create(['description' => post('description')]); + $role->save(); + } + header('Location: ' . nUrl('admin', 'add_role')); + } + public static function role() + { + $role = \Model::factory(\Incoviba\common\Role::class)->findOne(get('role')); + $actions = model(Action::class)->orderByAsc('description')->findMany(); + $permissions = []; + foreach ($actions as $action) { + $permissions []= (object) ['description' => $action->description, 'status' => false, 'inherited' => false]; + } + array_walk($permissions, function(&$el, $i, $role) { + if ($role->checkAccess($el->description)) { + $el->status = true; + if ($role->isInherited($el->description)) { + $el->inherited = true; + } + } + }, $role); + echo view('admin.roles.show', compact('role', 'permissions')); + } + public static function add_role_permissions() + { + $role = \Model::factory(\Incoviba\common\Role::class)->findOne(get('role')); + $locations = \Model::factory(\Incoviba\common\Location::class)->findMany(); + $actions = model(\Incoviba\common\Action::class)->findMany(); + echo view('admin.roles.add_permissions', compact('role', 'locations', 'actions')); + } + public static function do_add_role_permissions() + { + $role = \Model::factory(\Incoviba\common\Role::class)->findOne(get('role')); + $actions = model(\Incoviba\common\Action::class)->findMany(); + foreach ($actions as $action) { + $p = \Model::factory(\Incoviba\common\Permission::class)->where('type', 2)->where('ext_id', $role->id)->where('action_id', $action->id)->findOne(); + if (array_search($action->id, post('allowed'))) { + if (!$p) { + $data = [ + 'type' => 2, + 'ext_id' => $role->id, + 'action_id' => $action->id + ]; + $p = model(\Incoviba\common\Permission::class)->create($data); + } + $p->status = 1; + } else { + if ($p !== false) { + $p->status = 0; + } + } + if ($p !== false) { + $p->save(); + } + } + header('Location: ' . nUrl('admin', 'role', ['role' => $role->id])); + } + public static function list_users() + { + $users = \Model::factory(\Incoviba\common\User::class)->orderByAsc('name')->findMany(); + echo view('admin.users.list', compact('users')); + } + public static function add_user() + { + echo view('admin.users.add'); + } + public static function do_add_user() + { + $user = \Model::factory(\Incoviba\common\User::class)->where('name', post('name'))->findOne(); + if ($user === false) { + $user = \Model::factory(\Incoviba\common\User::class)->create(); + $user->name = post('name'); + $user->password(post('password')); + + $user->save(); + } + header('Location: ' . url('', ['p' => 'admin', 'a' => 'add_user'])); + } + public static function user() + { + $user = \Model::factory(\Incoviba\common\User::class)->findOne(get('user')); + echo view('admin.users.show', compact('user')); + } + public static function add_user_role() + { + if (get('user') !== false) { + $user = \Model::factory(\Incoviba\common\User::class)->findOne(get('user')); + $roles = \Model::factory(\Incoviba\common\Role::class)->findMany(); + return view('admin.users.add_role', compact('user', 'roles')); + } elseif (get('role') !== false) { + $role = \Model::factory(\Incoviba\common\Role::class)->findOne(get('role')); + $users = \Model::factory(\Incoviba\common\User::class)->findMany(); + return view('admin.roles.add_users', compact('users', 'role')); + } + } + public static function do_add_user_role() + { + if (get('user') !== false) { + $user = \Model::factory(\Incoviba\common\User::class)->findOne(get('user')); + foreach (post('role') as $r_id) { + $role = \Model::factory(\Incoviba\common\Role::class)->findOne($r_id); + + $usrRl = \Model::factory(\Incoviba\common\UserRole::class)->where('user', $user->id)->where('role', $role->id)->findOne(); + if ($usrRl === false) { + $usrRl = \Model::factory(\Incoviba\common\UserRole::class)->create(['user' => $user->id, 'role' => $role->id]); + $usrRl->save(); + } + } + header('Location: ' . url('', ['p' => 'admin', 'a' => 'user', 'user' => $user->id])); + } elseif (get('role') !== false) { + $role = \Model::factory(\Incoviba\common\Role::class)->findOne(get('role')); + foreach (post('users') as $u_id) { + $user = \Model::factory(\Incoviba\common\User::class)->findOne($u_id); + + $usrRl = \Model::factory(\Incoviba\common\UserRole::class)->where('user', $user->id)->where('role', $role->id)->findOne(); + if ($usrRl === false) { + $usrRl = \Model::factory(\Incoviba\common\UserRole::class)->create(['user' => $user->id, 'role' => $role->id]); + $usrRl->save(); + } + } + header('Location: ' . url('', ['p' => 'admin', 'a' => 'role', 'role' => $role->id])); + } + } + public static function remove_user_role() + { + $q = "DELETE FROM user_roles WHERE user = ? AND role = ?"; + $st = \ORM::getDb()->prepare($q); + $st->execute([get('user'), get('role')]); + header('Location: ' . nUrl('admin')); + } + public static function delete_user() + { + $q = "DELETE FROM user_roles WHERE user = ?"; + $st = \ORM::getDb()->prepare($q); + $st->execute([get('user')]); + $q = "DELETE FROM logins WHERE user = ?"; + $st = \ORM::getDb()->prepare($q); + $st->execute([get('user')]); + $q = "DELETE FROM permissions WHERE type = 1 AND ext_id = ?"; + $st = \ORM::getDb()->prepare($q); + $st->execute([get('user')]); + $user = \model(\Incoviba\common\User::class)->findOne(get('user')); + $user->delete(); + header('Location: ' . nUrl('admin', 'list_users')); + } + public static function reset_user() + { + $user = model(\Incoviba\common\User::class)->findOne(get('user')); + $user->password('123456'); + $user->save(); + header('Location: ' . nUrl('admin', 'user', ['user' => $user->id])); + } +} +?> diff --git a/resources/less/Controller/Ajax.php b/resources/less/Controller/Ajax.php new file mode 100644 index 0000000..912c979 --- /dev/null +++ b/resources/less/Controller/Ajax.php @@ -0,0 +1,215 @@ +whereNotEqual('nombre', '')->order_by_asc('nombre')->findMany(); + foreach ($bancos as &$banco) { + $banco = $banco->as_array('nombre')['nombre']; + } + return json_encode($bancos); + } + protected static function buscarBanco() + { + $q = get('q'); + if ($q == null) { + $q = get('query'); + if ($q == null) { + return ''; + } + } + $bancos = \Model::factory(\Incoviba\old\Common\Banco::class)->whereLike('nombre', '%' . $q . '%')->order_by_asc('nombre')->findMany(); + foreach ($bancos as &$banco) { + $banco = $banco->as_array('nombre')['nombre']; + } + return json_encode($bancos); + } + public static function comunas() + { + $id = post('region'); + $comunas = \Model::factory(\Incoviba\old\Common\Comuna::class) + ->select('comuna.*') + ->join('provincia', ['provincia.id', '=', 'comuna.provincia']) + ->where('provincia.region', $id) + ->order_by_asc('comuna.descripcion') + ->findMany(); + + foreach ($comunas as &$comuna) { + $comuna = $comuna->as_array('id', 'descripcion'); + } + return json_encode($comunas); + } + public static function propietario() + { + $id = post('rut'); + $propietario = \Model::factory(\Incoviba\old\Venta\Propietario::class)->where('rut', $id)->findOne(); + if ($propietario) { + $propietario = $propietario->as_array(); + return json_encode($propietario); + } + return null; + } + public static function direccion() + { + $id = post('direccion'); + $direccion = \Model::factory(\Incoviba\old\Common\Direccion::class)->findOne($id); + $comuna = $direccion->comuna(); + $provincia = $comuna->provincia(); + $region = $provincia->region(); + $direccion = $direccion->as_array(); + $direccion['comuna'] = $comuna->as_array(); + $direccion['comuna']['provincia'] = $provincia->as_array(); + $direccion['comuna']['provincia']['region'] = $region->as_array(); + return json_encode($direccion); + } + public static function tipo_unidades() + { + $id = post('proyecto'); + $proyecto = \Model::factory(\Incoviba\old\Proyecto\Proyecto::class)->findOne($id); + $tipos = $proyecto->tipoUnidades(); + foreach ($tipos as &$tipo) { + $tipo = $tipo->as_array(); + } + return json_encode($tipos); + } + public static function unidades() + { + $id_proyecto = post('proyecto'); + $id_tipo = post('tipo'); + + $proyecto = model(\Incoviba\old\Proyecto\Proyecto::class)->findOne($id_proyecto); + $unidades = $proyecto->unidadesDisponibles($id_tipo); + foreach ($unidades as &$unidad) { + $tipologia = $unidad->tipologia(); + $unidad = $unidad->as_array(); + $unidad['tipologia'] = $tipologia->as_array(); + if ($tipologia->tipologia()) { + $unidad['tipologia']['tipologia'] = (array) $tipologia->tipologia(); + continue; + } + $unidad['tipologia']['tipologia'] = ['descripcion' => $tipologia->abreviacion]; + } + return json_encode($unidades); + } + public static function unidades_precios() + { + $proyecto = model(\Incoviba\old\Proyecto\Proyecto::class)->findOne(post('proyecto')); + $unidades = $proyecto->unidades(); + usort($unidades, function($a, $b) { + $t = $a->tipo - $b->tipo; + if ($t == 0) { + return (int) $a->descripcion - (int) $b->descripcion; + } + return $t; + }); + $output = []; + foreach ($unidades as $u) { + $info = [ + 'id' => $u->id, + 'abreviacion' => $u->abreviacion, + 'descripcion' => $u->descripcion, + 'valor' => '--' + ]; + if ($u->precio()) { + $info['valor'] = format('ufs', $u->precio()->valor, null, true); + } + $output []= $info; + } + return json_encode($output); + } + public static function operadores() + { + $id_proyecto = post('proyecto'); + $proyecto = \Model::factory(\Incoviba\old\Proyecto\Proyecto::class)->findOne($id_proyecto); + $operadores = $proyecto->operadores(); + foreach ($operadores as &$operador) { + $operador = [ + 'id' => $operador->id, + 'abreviacion' => $operador->abreviacion + ]; + } + return json_encode($operadores); + } + public static function promociones() + { + $id = post('proyecto'); + $proyecto = \Model::factory(\Incoviba\old\Proyecto\Proyecto::class)->findOne($id); + $promociones = $proyecto->promociones(); + foreach ($promociones as &$promocion) { + $promocion = $promocion->as_array(); + } + return json_encode($promociones); + } + public static function nombres() + { + $nss = model(Propietario::class)->select('nombres')->orderByAsc('nombres')->findMany(); + $nombres = []; + foreach ($nss as $n) { + $ns = explode(' ', $n->nombres); + foreach ($ns as $nombre) { + $nombres []= $nombre; + } + } + $nombres = array_values(array_unique($nombres)); + return json_encode($nombres); + } + public static function apellidos() + { + $aps = model(Propietario::class)->select('apellido_paterno')->orderByAsc('apellido_paterno')->findMany(); + $apellidos = []; + foreach ($aps as $ap) { + $apellidos []= $ap->apellido_paterno; + } + $aps = model(Propietario::class)->select('apellido_materno')->orderByAsc('apellido_materno')->findMany(); + foreach ($aps as $ap) { + $apellidos []= $ap->apellido_paterno; + } + $apellidos = array_values(array_unique($apellidos)); + sort($apellidos); + return json_encode($apellidos); + } + public static function calles() + { + $results = model(Direccion::class)->select('calle')->orderByAsc('calle')->findMany(); + $calles = []; + foreach ($results as $result) { + $calles []= $result->calle; + } + $calles = array_values(array_unique($calles)); + return json_encode($calles); + } + public static function inmobiliarias() + { + $q = post('rut'); + $inmobiliaria = model(Inmobiliaria::class)->findOne($q); + return json_encode($inmobiliaria->as_array()); + } +} +?> diff --git a/resources/less/Controller/Auth.php b/resources/less/Controller/Auth.php new file mode 100644 index 0000000..c7ca497 --- /dev/null +++ b/resources/less/Controller/Auth.php @@ -0,0 +1,56 @@ + 'auth', 'a' => 'login'])); + } + } + public static function logout() + { + sAuth::logout(); + header('Location: .'); + } + public static function check_pass() + { + if (\password_verify(post('password'), sAuth::User()->password)) { + return 'OK'; + } + return 'KO'; + } + public static function change_pass() + { + return view('auth.change_pass'); + } + public static function do_change_pass() + { + if (\password_verify(post('old'), sAuth::User()->password)) { + if (post('new') == post('new2')) { + $user = sAuth::User(); + $user->password(post('new')); + $user->save(); + header('Location: .'); + die(); + } + } + header('Location: ' . url('', ['p' => 'auth', 'a' => 'change_pass'])); + } +} +?> diff --git a/resources/less/Controller/Bonos.php b/resources/less/Controller/Bonos.php new file mode 100644 index 0000000..837c3f0 --- /dev/null +++ b/resources/less/Controller/Bonos.php @@ -0,0 +1,57 @@ +findOne($id_venta); + return view('ventas.bonos.add', compact('venta')); + } + public static function do_add() + { + $id_venta = get('venta'); + $venta = model(Venta::class)->findOne($id_venta); + if ($venta->bono_pie != 0) { + header('Location: ' . nUrl('ventas', 'show', ['venta' => $venta->id])); + return; + } + $uf = uf($venta->fecha()); + $valor = post('valor'); + $data = [ + 'fecha' => $venta->fecha, + 'valor' => $valor * $uf->uf->value, + 'tipo' => 8, + 'uf' => $uf->uf->value + ]; + $pago = model(Pago::class)->create($data); + $pago->save(); + $data = [ + 'valor' => $valor, + 'pago' => $pago->id + ]; + $bono = model(BonoPie::class)->create($data); + $bono->save(); + $venta->bono_pie = $bono->id; + $venta->save(); + header('Location: ' . nUrl('ventas', 'show', ['venta' => $venta->id])); + } + public static function edit() + { + $id_venta = get('venta'); + $venta = model(Venta::class)->findOne($id_venta); + return view('ventas.bonos.edit', compact('venta')); + } + public static function do_edit() + { + d(post()); + } +} diff --git a/resources/less/Controller/Buscar.php b/resources/less/Controller/Buscar.php new file mode 100644 index 0000000..ef62a9e --- /dev/null +++ b/resources/less/Controller/Buscar.php @@ -0,0 +1,340 @@ + $results]); + } + protected static function getResults() + { + $q = get('q'); + if ($q == null) { + $q = get('query'); + } + $t = get('t'); + if ($t == null) { + $t = get('tipo'); + } + $t = urldecode($t); + if ($t == null) { + $t = 'cualquiera'; + } + + $results = null; + if ($q != null) { + $q = urldecode($q); + $results = self::buscar($q, $t); + } + return $results; + } + public static function buscar($query, $tipo) + { + $method = 'buscar' . str_replace(' ', '', ucwords($tipo)); + if (is_callable(['self', $method])) { + $results = self::$method(self::prepareQuery($query)); + $results = self::removeDuplicates($results); + $results = self::sort($results); + return $results; + } + return []; + } + protected static function prepareQuery($query) + { + $query = str_replace('"', '"', $query); + $data = explode(' ', $query); + $regex = "~(?=\\S)[^'\"\\s]*(?:'[^']*'[^'\"\\s]*|\"[^\"]*\"[^'\"\\s]*)*~"; + preg_match_all($regex, $query, $data); + $data = $data[0]; + foreach ($data as &$l) { + $l = str_replace('"', '', str_replace("'", '', $l)); + } + if (is_array($data) and count($data) == 1) { + $data = $data[0]; + } + return $data; + } + protected static function removeDuplicates($results) + { + $output = []; + foreach ($results as $result) { + if (array_search($result, $output) === false) { + $output []= $result; + } + } + return $output; + } + protected static function sort($results) + { + usort($results, function($a, $b) { + $py = strcmp($a->proyecto()->descripcion, $b->proyecto()->descripcion); + if ($py == 0) { + if (!method_exists($a, 'unidad') and !method_exists($b, 'unidad')) { + return $a->descripcion - $b->descripcion; + } + if (!method_exists($a, 'unidad')) { + return $a->descripcion - $b->unidad()->descripcion; + } + if (!method_exists($b, 'unidad')) { + return $a->unidad()->descripcion - $b->descripcion; + } + + $u = $a->unidad()->descripcion - $b->unidad()->descripcion; + if ($u == 0) { + return strcmp($a->propietario()->apellido_paterno, $b->propietario()->apellido_paterno); + } + return $u; + } + return $py; + }); + return $results; + } + protected static function buscarCualquiera($query) + { + $results = []; + foreach (self::$tipos as $tipo) { + if ($tipo == 'cualquiera') { + continue; + } + $method = 'buscar' . str_replace(' ', '', ucwords($tipo)); + + if (is_callable(['self', $method])) { + $results = array_merge($results, self::$method($query)); + } + } + return $results; + } + protected static function buscarDepartamento($query) + { + if (is_array($query)) { + $results = []; + foreach ($query as $segment) { + $results = array_merge($results, self::buscarDepartamento($segment)); + } + } else { + $results = \Model::factory(Venta::class) + ->select('venta.*') + ->join('propiedad', ['propiedad.id', '=', 'venta.propiedad']) + ->join('unidad', ['unidad.id', '=', 'propiedad.unidad_principal']) + ->whereLike('unidad.descripcion', '%' . $query . '%') + ->findMany(); + } + return $results; + } + protected static function buscarEstacionamiento($query) + { + if (is_array($query)) { + $results = []; + foreach ($query as $segment) { + $results = array_merge($results, self::buscarEstacionamiento($segment)); + } + } else { + $results = \Model::factory(Venta::class) + ->select('venta.*') + ->join('propiedad', ['propiedad.id', '=', 'venta.propiedad']) + ->join('unidad', "`propiedad`.`estacionamientos` LIKE `unidad`.`id` OR `propiedad`.`estacionamientos` LIKE CONCAT('%;', `unidad`.`id`) OR `propiedad`.`estacionamientos` LIKE CONCAT(`unidad`.`id`, ';%') OR `propiedad`.`estacionamientos` LIKE CONCAT('%;', `unidad`.`id`, ';%')") + ->where('unidad.descripcion', $query) + ->findMany(); + } + return $results; + } + protected static function buscarBodega($query) + { + if (is_array($query)) { + $results = []; + foreach ($query as $segment) { + $results = array_merge($results, self::buscarBodega($segment)); + } + } else { + $results = \Model::factory(Venta::class) + ->select('venta.*') + ->join('propiedad', ['propiedad.id', '=', 'venta.propiedad']) + ->join('unidad', "`propiedad`.`bodegas` LIKE `unidad`.`id` OR `propiedad`.`bodegas` LIKE CONCAT('%;', `unidad`.`id`) OR `propiedad`.`bodegas` LIKE CONCAT(`unidad`.`id`, ';%') OR `propiedad`.`bodegas` LIKE CONCAT('%;', `unidad`.`id`, ';%')") + ->where('unidad.descripcion', $query) + ->findMany(); + } + return $results; + } + protected static function buscarPropietario($query) + { + if (is_array($query)) { + $results = []; + foreach ($query as $segment) { + $results = array_merge($results, self::buscarPropietario($segment)); + } + } else { + $results = self::buscarPropietarioNombres($query); + $results = array_merge($results, self::buscarPropietarioApellido($query)); + $results = array_merge($results, self::buscarPropietarioNombreCompleto($query)); + } + return $results; + } + protected static function buscarPropietarioNombres($query) + { + $results = \Model::factory(Venta::class) + ->select('venta.*') + ->join('propietario', ['propietario.rut', '=', 'venta.propietario']) + ->whereLike('propietario.nombres', '%' . $query . '%') + ->findMany(); + return $results; + } + protected static function buscarPropietarioApellido($query) + { + $results = \Model::factory(Venta::class) + ->select('venta.*') + ->join('propietario', ['propietario.rut', '=', 'venta.propietario']) + ->whereAnyIs([ + ['propietario.apellido_paterno' => '%' . $query . '%'], + ['propietario.apellido_materno' => '%' . $query . '%'] + ], 'LIKE') + ->findMany(); + return $results; + } + protected static function buscarPropietarioNombreCompleto($query) + { + $results = \Model::factory(Venta::class) + ->select('venta.*') + ->join('propietario', ['propietario.rut', '=', 'venta.propietario']) + ->whereRaw("CONCAT_WS(' ', propietario.nombres, propietario.apellido_paterno, propietario.apellido_materno) LIKE '%" . $query . "%'") + ->findMany(); + return $results; + } + protected static function buscarPrecioVenta($query) + { + if (is_array($query)) { + $results = []; + foreach ($query as $segment) { + $results = array_merge($results, self::buscarPrecioVenta($segment)); + } + } else { + $query = str_replace([',', '.'], ['.', ''], $query); + $results = \Model::factory(Venta::class)->where('valor_uf', $query)->findMany(); + } + return $results; + } + protected static function buscarProyecto($query) + { + if (is_array($query)) { + $results = []; + foreach ($query as $segment) { + $results = array_merge($results, self::buscarProyecto($segment)); + } + } else { + $results = model(Venta::class) + ->select('venta.*') + ->join('propiedad', ['propiedad.id', '=', 'venta.propiedad']) + ->join('unidad', ['unidad.id', '=', 'propiedad.unidad_principal']) + ->join('proyecto', ['proyecto.id', '=', 'unidad.proyecto']) + ->whereLike('proyecto.descripcion', '%' . $query . '%') + ->findMany(); + } + return $results; + } + protected static function buscarPago($query) + { + if (is_array($query)) { + $results = []; + foreach ($query as $segment) { + $results = array_merge($results, self::buscarPrecioVenta($segment)); + } + } else { + $query = str_replace(',', '.', str_replace('.', '', $query)); + $query2 = (float) $query; + if ($query != $query2) { + return []; + } + if (!is_float($query2)) { + return []; + } + $query = $query2; + $results = self::buscarValorCuota($query); + $results = array_merge($results, self::buscarReajuste($query)); + $results = array_merge($results, self::buscarEscritura($query)); + $results = array_merge($results, self::buscarSubsidio($query)); + $results = array_merge($results, self::buscarCredito($query)); + } + return $results; + } + protected static function buscarValorCuota($query) + { + $results = \Model::factory(Venta::class) + ->select('venta.*') + ->join('cuota', ['cuota.pie', '=', 'venta.pie']) + ->join('pago', ['pago.id', '=', 'cuota.pago']) + ->whereRaw("`pago`.`valor` = " . $query . " OR `pago`.`valor` / `pago`.`uf` = " . $query) + ->findMany(); + return $results; + } + protected static function buscarReajuste($query) + { + $results = \Model::factory(Venta::class) + ->select('venta.*') + ->join('pie', ['pie.id', '=', 'venta.pie']) + ->join('pago', ['pago.id', '=', 'pie.reajuste']) + ->whereRaw("`pago`.`valor` = " . $query . " OR `pago`.`valor` / `pago`.`uf` = " . $query) + ->findMany(); + return $results; + } + protected static function buscarEscritura($query) + { + $results = \Model::factory(Venta::class) + ->select('venta.*') + ->join('escritura', ['escritura.id', '=', 'venta.escritura']) + ->join('pago', ['pago.id', '=', 'escritura.pago']) + ->whereRaw("`pago`.`valor` = " . $query . " OR `pago`.`valor` / `pago`.`uf` = " . $query) + ->findMany(); + return $results; + } + protected static function buscarSubsidio($query) + { + $results = \Model::factory(Venta::class) + ->select('venta.*') + ->join('subsidio', ['subsidio.id', '=', 'venta.subsidio']) + ->join('pago', ['pago.id', '=', 'subsidio.pago']) + ->whereRaw("`pago`.`valor` = " . $query . " OR `pago`.`valor` / `pago`.`uf` = " . $query) + ->findMany(); + return $results; + } + protected static function buscarCredito($query) + { + $results = \Model::factory(Venta::class) + ->select('venta.*') + ->join('credito', ['credito.id', '=', 'venta.credito']) + ->join('pago', ['pago.id', '=', 'credito.pago']) + ->whereRaw("`pago`.`valor` = " . $query . " OR `pago`.`valor` / `pago`.`uf` = " . $query) + ->findMany(); + return $results; + } + protected static function buscarUnidad($query) + { + if (is_array($query)) { + $results = []; + foreach ($query as $segment) { + $results = array_merge($results, self::buscarUnidad($segment)); + } + } else { + $results = model(Unidad::class)->where('descripcion', $query)->findMany(); + foreach ($results as $i => $u) { + if ($u->venta()) { + unset($results[$i]); + } + } + } + return $results; + } +} +?> diff --git a/resources/less/Controller/Cierres.php b/resources/less/Controller/Cierres.php new file mode 100644 index 0000000..077a5ce --- /dev/null +++ b/resources/less/Controller/Cierres.php @@ -0,0 +1,428 @@ +select('proyecto.*') + ->join('estado_proyecto', ['estado.proyecto', '=', 'proyecto.id'], 'estado') + ->join('tipo_estado_proyecto', ['tipo.id', '=', 'estado.estado'], 'tipo') + ->join('etapa_proyecto', ['etapa.id', '=', 'tipo.etapa'], 'etapa') + ->whereGte('etapa.orden', 3) + ->orderByAsc('proyecto.descripcion') + ->groupBy('proyecto.id') + ->findMany(); + $regiones = model(Region::class)->order_by_asc('numeracion')->findMany(); + return view('ventas.cierres.add', compact('proyectos', 'regiones')); + } + public static function agregar() + { + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $id_proyecto = post('proyecto'); + $proyecto = model(Proyecto::class)->findOne($id_proyecto); + $id_agente = post('agente'); + $agente = model(Agente::class)->findOne($id_agente); + + $direccion = model(Direccion::class) + ->where('calle', post('calle')) + ->where('numero', post('numero')) + ->where('extra', post('extra')) + ->where('comuna', post('comuna')) + ->findOne(); + if (!$direccion) { + $data = [ + 'calle' => post('calle'), + 'numero' => post('numero'), + 'extra' => post('extra'), + 'comuna' => post('comuna') + ]; + $direccion = model(Direccion::class)->create($data); + $direccion->save(); + } + + list($rut, $dv) = explode('-', str_replace('.', '', post('rut'))); + $propietario = model(Propietario::class)->findOne($rut); + if (!$propietario) { + $data = [ + 'rut' => $rut, + 'dv' => $dv, + 'nombres' => trim(post('nombres')), + 'apellido_paterno' => post('paterno'), + 'apellido_materno' => post('materno'), + 'sexo' => post('sexo'), + 'estado_civil' => post('estado_civil'), + 'profesion' => post('profesion'), + 'direccion' => $direccion->id, + 'telefono' => post('codigo_telefono') . post('telefono'), + 'email' => post('email') . '@' . post('email_domain'), + 'representante' => 0, + 'otro' => 0 + ]; + $propietario = model(Propietario::class)->create($data); + $propietario->save(); + } + + $unis = json_decode(post('unidades')); + $id_principal = array_shift($unis); + $unidad = model(Unidad::class)->findOne(post('unidad' . $id_principal)); + $u = model(U::class)->findOne($unidad->id); + if (!$u) { + $unidad->save(); + } + $data = [ + 'unidad_id' => $unidad->id + ]; + $reserva = model(Reserva::class)->create($data); + $reserva->save(); + foreach ($unis as $id_unidad) { + $unidad = model(Unidad::class)->findOne(post('unidad' . $id_unidad)); + $data = [ + 'reserva_id' => $reserva->id, + 'unidad_id' => $unidad->id + ]; + $ur = model(UnidadReserva::class)->create($data); + $ur->save(); + } + + $data = [ + 'proyecto_id' => $proyecto->id, + 'agente_id' => $agente->id, + 'propietario_rut' => $propietario->rut, + 'reserva_id' => $reserva->id, + 'fecha' => $f->format('Y-m-d'), + 'valor' => correctNumber(post('valor')), + 'pie' => correctNumber(post('pie')), + 'credito' => correctNumber(post('credito')), + 'estado' => 1 + ]; + $cierre = model(Cierre::class)->create($data); + $cierre->save(); + header('Location: ' . url('', ['p' => 'cierres', 'a' => 'list'])); + } + public static function list() + { + $proyectos = Cierre::proyectos(); + + return view('ventas.cierres.list', compact('proyectos')); + } + public static function show() + { + $id = get('cierre'); + $cierre = model(Cierre::class)->findOne($id); + + return view('ventas.cierres.show', compact('cierre')); + } + public static function guardar() + { + $proyecto = \model(Proyecto::class)->findOne(post('proyecto')); + $fecha = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $unidad = \model(Unidad::class)->findOne(post('departamento')); + $relacionado = (post('relacionado') === true) ? true : false; + $subrelacionado = (post('subrelacionado') === true) ? true : false; + $precio = (float) post('precio') ?: 0; + $input = [ + 'proyecto' => $proyecto, + 'fecha' => $fecha, + 'departamento' => $unidad, + 'precio' => $precio, + 'relacionado' => $relacionado, + 'subrelacionado' => $subrelacionado, + 'unidades' => [], + 'pie' => (float) post('pie') + ]; + $ebs = 0; + if (post('unidades') != '') { + $unidades = json_decode(html_entity_decode(post('unidades')), true); + foreach ($unidades as $un) { + $u = \model(Unidad::class)->findOne($un); + $input['unidades'] []= $u; + if ($u->precio($fecha) !== false) { + $ebs += $u->precio($fecha)->valor; + } + } + } + $promo = 0; + if (post('promocion') != null) { + $promo = (float) post('promocion'); + $input['promocion'] = $promo; + } + $bono = 0; + if (post('bono') != null) { + $bono = (float) post('bono'); + $input['bono'] = $bono; + } + $operador = 0; + if (post('operador') != null) { + $operador = ($precio - $bono - $promo) * (float) post('operador') / 100; + $input['operador'] = $operador; + } + + $cierre = Cierre::find($proyecto, $unidad, $precio)->findOne(); + if ($cierre === false) { + $cierre = model(Cierre::class)->create(); + $cierre->guardar((object) $input); + } + $output = ['status' => 'ok', 'cierre' => $cierre->asArray()]; + return json_encode($output); + } + public static function aprobar() + { + $fecha = Carbon::today(config('app.timezone')); + $cierre = model(Cierre::class)->findOne(post('cierre')); + if ($cierre->estado()->tipo()->descripcion == "revisado" or $cierre->estado()->tipo()->descripcion == "rechazado") { + $cierre->aprobar($fecha); + return json_encode(['estado' => 'aprobado']); + } + return json_encode(['estado' => 'no vigente']); + } + public static function rechazar() + { + $fecha = Carbon::today(config('app.timezone')); + $cierre = model(Cierre::class)->findOne(post('cierre')); + if ($cierre->estado()->tipo()->vigente == 1) { + $cierre->rechazar($fecha); + return json_encode(['estado' => 'rechazado']); + } + return json_encode(['estado' => 'no vigente']); + } + public static function abandonar() + { + $id = get('cierre'); + $cierre = model(Cierre::class)->findOne($id); + $tipo = model(TipoEstadoCierre::class)->where('descripcion', 'abandonado')->findOne(); + $today = Carbon::today(config('app.timezone')); + $data = [ + 'cierre' => $cierre->id, + 'tipo' => $tipo->id, + 'fecha' => $today->format('Y-m-d') + ]; + $estado = model(EstadoCierre::class)->create($data); + $estado->save(); + header('Location: ' . url('', ['p' => 'cierres', 'a' => 'list'])); + } + public static function promesar() + { + $id = get('cierre'); + $cierre = model(Cierre::class)->findOne($id); + $tipo = model(TipoEstadoCierre::class)->where('descripcion', 'promesado')->findOne(); + $today = Carbon::today(config('app.timezone')); + $data = [ + 'cierre' => $cierre->id, + 'tipo' => $tipo->id, + 'fecha' => $today->format('Y-m-d') + ]; + $estado = model(EstadoCierre::class)->create($data); + $estado->save(); + header('Location: ' . url('', ['p' => 'cierres', 'a' => 'show', 'cierre' => $cierre->id])); + } + public static function borrador() + { + $id = get('cierre'); + $cierre = model(Cierre::class)->findOne($id); + + $borrador = new Borrador($cierre); + d($borrador->show()); + $borrador->create(); + } + public static function evalue() + { + $proyectos = \model(Proyecto::class)->orderByAsc('descripcion')->findMany(); + return view('ventas.cierres.evaluar', compact('proyectos')); + } + public static function evaluar() + { + $proyecto = \model(Proyecto::class)->findOne(post('proyecto')); + $fecha = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $unidad = \model(Unidad::class)->findOne(post('departamento')); + $relacionado = (post('relacionado') === 'true') ? true : false; + $subrelacionado = (post('subrelacionado') === 'true') ? true : false; + $precio = (float) post('precio') ?: 0; + $neto = $precio; + $ebs = 0; + if (post('unidades') != '') { + $unidades = json_decode(html_entity_decode(post('unidades')), true); + foreach ($unidades as $un) { + $u = \model(Unidad::class)->findOne($un); + if ($u->precio($fecha) !== false) { + $ebs += $u->precio($fecha)->valor; + } + } + } + $promocion = 0; + if (post('promocion') != null) { + $promocion = (float) post('promocion'); + } + $bono = 0; + if (post('bono') != null) { + $bono = (float) post('bono'); + } + $operador = 0; + if (post('operador') != null) { + $operador = ($precio - $bono - $promocion) * (float) post('operador') / 100; + } + $rel = 0; + if ($relacionado) { + $rel = ($unidad->precio($fecha)->valor) * 6 / 100; + } + if ($subrelacionado) { + $rel = ($unidad->precio($fecha)->valor) * 3 / 100; + } + $neto = $precio - $bono - $promocion - $operador - $ebs; + + $output = [ + 'unidad' => [ + 'tipo' => [ + 'nombre' => $unidad->tipologia()->nombre, + 'tipologia' => $unidad->tipologia()->tipologia()->descripcion + ], + 'superficie' => format('m2', $unidad->m2()) . ' m²' + ], + 'oferta' => [ + 'bruto' => format('ufs', $precio, null, true), + 'neto' => format('ufs', $neto, null, true), + 'uf_m2' => format('ufs', $neto / $unidad->m2('vendible'), null, true) . '/m²', + 'fecha' => format('shortDate', $unidad->precio($fecha)->inicio()->fecha()) + ], + 'lista' => [ + 'precio' => format('ufs', $unidad->precio($fecha)->valor, null, true), + 'uf_m2' => format('ufs', $unidad->precio($fecha)->valor / $unidad->m2('vendible'), null, true) . '/m²' + ], + 'precios' => [ + 'bruto' => format('ufs', $precio, null, true), + 'neto' => format('ufs', $neto, null, true), + 'departamento' => format('ufs', $unidad->precio($fecha)->valor, null, true), + 'relacionado' => format('ufs', $unidad->precio($fecha)->valor - $rel, null, true), + 'fecha' => format('shortDate', $unidad->precio($fecha)->inicio()->fecha()) + ], + 'uf_m2' => [ + 'neto' => format('ufs', $neto / $unidad->m2('vendible'), null, true) . '/m²', + 'departamento' => format('ufs', $unidad->precio($fecha)->valor / $unidad->m2('vendible'), null, true) . '/m²', + 'relacionado' => format('ufs', ($unidad->precio($fecha)->valor - $rel) / $unidad->m2('vendible'), null, true) . '/²' + ], + 'evaluacion' => Cierre::evaluar($neto, $unidad, $fecha, $rel), + 'estado' => ['id' => 0, 'descripcion' => 'no existe'] + ]; + if ($rel > 0) { + $output ['relacionado'] = [ + 'precio' => format('ufs', $unidad->precio($fecha)->valor - $rel, null, true), + 'uf_m2' => format('ufs', ($unidad->precio($fecha)->valor - $rel) / $unidad->m2('vendible'), null, true) . '/²' + ]; + } + $estado = Cierre::find($proyecto, $unidad, $precio)->findOne(); + if ($estado) { + $output['estado'] = [ + 'id' => $estado->estado()->tipo()->id, + 'cierre' => $estado->id, + 'descripcion' => $estado->estado()->tipo()->descripcion, + 'fecha' => format('shortDate', $estado->estado()->fecha) + ]; + } + + return json_encode($output); + } + public static function edit() + { + $cierre = model(Cierre::class)->findOne(get('cierre')); + $proyectos = model(Proyecto::class)->findMany(); + $regiones = model(Region::class)->findMany(); + $valores = model(TipoValorCierre::class)->findMany(); + return view('ventas.cierres.edit', compact('cierre', 'proyectos', 'regiones', 'valores')); + } + public static function do_edit() + { + $cierre = model(Cierre::class)->findOne(get('cierre')); + + $data = [ + 'calle' => post('calle'), + 'numero' => post('numero'), + 'extra' => post('extra'), + 'comuna' => post('comuna') + ]; + $direccion = (new Factory(Direccion::class))->where($data)->find(); + if (!$direccion) { + $direccion = model(Direccion::class)->create($data); + $direccion->save(); + } + if (post('rut') != '') { + $data = [ + 'rut' => explode('-', str_replace('.', '', post('rut')))[0], + ]; + $propietario = (new Factory(Propietario::class))->where($data)->find(); + if (!$propietario) { + $data = array_merge($data, [ + 'nombres' => post('nombres'), + 'apellido_paterno' => post('paterno'), + 'apellido_materno' => post('materno'), + 'dv' => (post('rut')) ? explode('-', str_replace('.', '', post('rut')))[1] : '', + 'sexo' => post('sexo'), + 'estado_civil' => post('estado_civil'), + 'profesion' => post('profesion'), + 'telefono' => post('codigo_telefono') . post('telefono'), + 'email' => post('email') . '@' . post('email_domain'), + 'direccion' => $direccion->id + ]); + $propietario = model(Propietario::class)->create($data); + $propietario->save(); + } + } + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $data = [ + 'proyecto' => post('proyecto'), + 'precio' => post('precio'), + 'fecha' => $f->format('Y-m-d'), + 'relacionado' => (post('relacionado')) ? 1 : 0, + 'propietario' => (isset($propietario) and $propietario) ? $propietario->rut : 0 + ]; + foreach ($data as $field => $value) { + if ($value != $cierre->$field) { + $cierre->$field = $value; + } + } + $cierre->save(); + + $valores = model(TipoValorCierre::class)->findMany(); + foreach ($valores as $valor) { + if (post($valor->descripcion) == '') { + continue; + } + if ($cierre->valor($valor->descripcion)) { + if ($cierre->valor($valor->descripcion)->valor != post($valor->descripcion)) { + $v = $cierre->valor($valor->descripcion); + $v->valor = post($valor->descripcion); + $v->save(); + } + continue; + } + $data = [ + 'tipo' => $valor->descripcion, + 'valor' => post($valor->descripcion) + ]; + $cierre->addValor($data); + } + header('Location: ' . nUrl('cierres', 'show', ['cierre' => $cierre->id])); + } +} +?> diff --git a/resources/less/Controller/Comentarios.php b/resources/less/Controller/Comentarios.php new file mode 100644 index 0000000..494fcc6 --- /dev/null +++ b/resources/less/Controller/Comentarios.php @@ -0,0 +1,39 @@ +findOne(get('venta')); + echo view('ventas.comentarios.add', compact('venta')); + } + public static function agregar() + { + $venta = \Model::factory(\Incoviba\old\Venta\Venta::class)->findOne(get('venta')); + if ($venta === false) { + throw new Exception('Venta no existe.'); + } + $data = [ + 'venta' => $venta->id, + 'fecha' => \Carbon\Carbon::now(config('app.timezone'))->format('Y-m-d H:i:s'), + 'texto' => post('comentario') + ]; + $comentario = \Model::factory(\Incoviba\old\Venta\Comentario::class)->create($data); + $comentario->save(); + header('Location: ' . nUrl('ventas', 'show', ['venta' => $venta->id])); + } + public static function delete() + { + $comentario = \Model::factory(\Incoviba\old\Venta\Comentario::class)->findOne(get('comentario')); + $venta = $comentario->venta(); + $comentario->estado = 0; + $comentario->save(); + header('Location: ' . nUrl('ventas', 'show', ['venta' => $venta->id])); + } +} +?> diff --git a/resources/less/Controller/Contabilidad.php b/resources/less/Controller/Contabilidad.php new file mode 100644 index 0000000..be9fceb --- /dev/null +++ b/resources/less/Controller/Contabilidad.php @@ -0,0 +1,102 @@ +orderByAsc('descripcion')->findMany(); + foreach ($proyectos as &$proyecto) { + $arr = $proyecto->asArray(); + $arr['direccion'] = $proyecto->direccion()->asArray(); + $arr['direccion']['comuna'] = $proyecto->direccion()->comuna()->asArray(); + $arr['inmobiliaria'] = $proyecto->inmobiliaria()->asArray(); + $proyecto = $arr; + } + return json_encode(compact('proyectos')); + } + public static function get_fechas() { + $id_proyecto = get('proyecto'); + $proyecto = model(Proyecto::class)->findOne($id_proyecto); + $cuotas = []; + foreach ($proyecto->ventas() as $venta) { + $cs = $venta->pie()->cuotas(); + $cuotas = array_merge($cs, array_filter($cs, function($item) { + $tipo = $item->pago()->estado()->tipo(); + return ($tipo == 'depositado' or $tipo == 'abonado'); + })); + } + $fechas = array_map(function($item) { + return [ + 'timestamp' => $item->pago()->estado()->fecha()->timestamp, + 'short' => $item->pago()->estado()->fecha()->format('Y-m-d'), + 'long' => $item->pago()->estado()->fecha()->format('d / m / Y') + ]; + }, $cuotas); + usort($fechas, function($a, $b) { + return $b['timestamp'] - $a['timestamp']; + }); + return json_encode(compact('fechas')); + } + public static function get_pagos_fechas() { + $id_proyecto = get('proyecto'); + $fecha = Carbon::parse(get('fecha')); + $proyecto = model(Proyecto::class)->findOne($id_proyecto); + $pagos = []; + foreach ($proyecto->ventas() as $venta) { + foreach ($venta->pie()->cuotas() as $cuota) { + if ($cuota->pago()->estado()->fecha() == $fecha) { + $pagos []= [ + 'Departamento' => $venta->propiedad()->unidad()->descripcion, + 'Valor' => [ + 'UF' => $cuota->pago()->valor('ufs'), + 'Pesos' => $cuota->pago()->valor() + ], + 'Numero' => $cuota->numero(), + 'Total' => $venta->pie()->cuotas + ]; + break; + } + } + } + return json_encode(compact('pagos')); + } + public static function pagos_fecha() { + $fecha = Carbon::now(); + return view('contabilidad.pagos', compact('fecha')); + } + public static function show_pagos() { + $id_proyecto = get('proyecto'); + $fecha = Carbon::parse(get('fecha')); + $proyecto = model(Proyecto::class)->findOne($id_proyecto); + $pagos = []; + !d($fecha); + foreach ($proyecto->ventas() as $venta) { + foreach ($venta->pie()->cuotas() as $cuota) { + !d($cuota, $cuota->pago()->estado()->fecha()); + if ($cuota->pago()->estado()->fecha() == $fecha) { + $pagos []= (object) [ + 'Departamento' => $venta->propiedad()->unidad()->descripcion, + 'Valor' => (object) [ + 'UF' => $cuota->pago()->valor('ufs'), + 'Pesos' => $cuota->pago()->valor() + ], + 'Numero' => $cuota->numero(), + 'Total' => $venta->pie()->cuotas + ]; + break; + } + } + } + return view('contabilidad.pago', compact('proyecto', 'fecha', 'pagos')); + } +} diff --git a/resources/less/Controller/Creditos.php b/resources/less/Controller/Creditos.php new file mode 100644 index 0000000..60a72da --- /dev/null +++ b/resources/less/Controller/Creditos.php @@ -0,0 +1,207 @@ +findOne($id); + return view('ventas.creditos.add', compact('venta')); + } + public static function agregado() + { + $id = get('venta'); + if ($id == null) { + header('Location: .'); + } + $venta = \Model::factory(Venta::class)->findOne($id); + + $banco = \Model::factory(Banco::class)->where('nombre', post('banco'))->findOne(); + $f = Carbon::createFromDate(post('y'), post('m'), post('d'), config('app.timezone')); + $uf = uf($f); + + $pago = \Model::factory(Pago::class)->create(); + $pago->banco = $banco->id; + $pago->fecha = $f->format('Y-m-d'); + $pago->uf = $uf->uf->value; + $pago->valor = post('valor') * $pago->uf; + $pago->tipo = 2; + + $credito = \Model::factory(Credito::class)->create(); + $credito->banco = $pago->banco; + $credito->valor = $pago->valor; + $credito->fecha = $pago->fecha; + $credito->uf = $pago->uf; + + $pago->new(); + + $credito->pago = $pago->id; + $credito->save(); + + $venta->credito = $credito->id; + $venta->save(); + header('Location: ' . url('', ['p' => 'ventas', 'a' => 'show', 'venta' => $venta->id])); + } + public static function pagar() + { + $id = get('venta'); + $venta = \Model::factory(Venta::class)->findOne($id); + return view('ventas.creditos.pagar', compact('venta')); + } + public static function pagando() + { + $id = get('venta'); + $venta = \Model::factory(Venta::class)->findOne($id); + $valor = str_replace(',', '.', str_replace('.', '', post('valor'))); + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + + $pago = $venta->credito()->pago(); + if ($pago->valor != $valor) { + $pago->valor = $valor; + } + + $estado = \Model::factory(EstadoPago::class)->create(); + $estado->pago = $pago->id; + $estado->fecha = $f->format('Y-m-d'); + $estado->estado = 1; + $estado->save(); + + if ($pago->is_dirty('valor')) { + $pago->save(); + } + header('Location: ' . url('', ['p' => 'ventas', 'a' => 'show', 'venta' => $venta->id])); + } + public static function abonar() + { + $id = get('venta'); + $venta = \Model::factory(Venta::class)->findOne($id); + return view('ventas.creditos.abonar', compact('venta')); + } + public static function abonando() + { + $id = get('venta'); + $venta = \Model::factory(Venta::class)->findOne($id); + $valor = str_replace(',', '.', str_replace('.', '', post('valor'))); + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + + $pago = $venta->credito()->pago(); + if ($pago->valor != $valor) { + $pago->valor = $valor; + } + + $estado = \Model::factory(EstadoPago::class)->create(); + $estado->pago = $pago->id; + $estado->fecha = $f->format('Y-m-d'); + $estado->estado = 2; + + $estado->save(); + + if ($pago->is_dirty('valor')) { + $pago->save(); + } + header('Location: ' . url('', ['p' => 'ventas', 'a' => 'show', 'venta' => $venta->id])); + } + public static function show() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + + return view('ventas.creditos.show', compact('venta')); + } + public static function edit() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + + return view('ventas.creditos.edit', compact('venta')); + } + public static function editado() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + + $pago = $venta->credito()->pago(); + + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $uf = uf($f); + $banco = model(Banco::class)->where('nombre', post('banco'))->findOne(); + $valor = correctNumber(post('valor')) * $uf->uf->value; + + $fields = ['valor', 'uf', 'fecha', 'banco']; + $data = ['valor' => $valor, 'uf' => $uf->uf->value, 'fecha' => $f->format('Y-m-d'), 'banco' => $banco->id]; + + $change = false; + foreach ($fields as $field) { + if ($pago->$field != $data[$field]) { + $change = true; + $pago->$field = $data[$field]; + if ($field == 'fecha') { + $eps = $pago->estados(); + foreach ($eps as $ep) { + if ($ep->estado == 0) { + $ep->fecha = $data[$field]; + $ep->save(); + break; + } + } + } + } + } + + if ($change) { + $pago->save(); + } + header('Location: ' . url('', ['p' => 'ventas', 'a' => 'show', 'venta' => $venta->id])); + } + public static function remove() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + + $pago = $venta->credito()->pago(); + $f = Carbon::today(config('app.timezone')); + + $data = [ + 'pago' => $pago->id, + 'estado' => -3, + 'fecha' => $f->format('Y-m-d') + ]; + $estado = model(EstadoPago::class)->create($data); + $estado->save(); + $venta->credito = 0; + $venta->save(); + header('Location: ' . url('', ['p' => 'ventas', 'a' => 'show', 'venta' => $venta->id])); + } + public static function pendientes() + { + $creditos = model(Credito::class) + ->select('credito.*') + ->join('venta', ['venta.credito', '=', 'credito.id']) + ->join('pago', ['pago.id', '=', 'credito.pago']) + ->rawJoin('JOIN (SELECT ep.* FROM (SELECT pago, MAX(id) AS id FROM estado_pago GROUP BY pago) e0 JOIN estado_pago ep ON ep.id = e0.id)', ['estado_pago.pago', '=', 'pago.id'], 'estado_pago') + ->whereLt('estado_pago.estado', 2) + ->where('venta.estado', 1) + ->orderByAsc('estado_pago.fecha') + ->findMany(); + return view('ventas.creditos.pendientes', compact('creditos')); + } +} +?> diff --git a/resources/less/Controller/Cuotas.php b/resources/less/Controller/Cuotas.php new file mode 100644 index 0000000..4d457ba --- /dev/null +++ b/resources/less/Controller/Cuotas.php @@ -0,0 +1,230 @@ +findOne($id); + + return view('ventas.pies.cuotas.show', compact('cuota')); + } + public static function edit() + { + $id = get('cuota'); + $cuota = \Model::factory(Cuota::class)->findOne($id); + return view('ventas.pies.cuotas.edit', compact('cuota')); + } + public static function editar() + { + $id = get('cuota'); + $cuota = \Model::factory(Cuota::class)->findOne($id); + + $cuota->numero = post('numero'); + $cuota->{'valor_$'} = post('valor'); + $banco = \Model::factory(\Incoviba\old\Common\Banco::class)->where('nombre', post('banco'))->findOne(); + if ($banco) { + $cuota->banco = $banco->id; + } else { + $cuota->banco = 0; + } + $f = \Carbon\Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $cuota->fecha = $f->format('Y-m-d'); + $pago = $cuota->pago(); + $pago->valor = post('valor'); + $pago->banco = $banco->id; + $pago->identificador = post('identificador'); + $pago->fecha = $f->format('Y-m-d'); + $uf = uf($f); + if ($uf->total > 0) { + $pago->uf = $uf->uf->value; + } else { + $pago->uf = 0; + } + + $pago->save(); + $cuota->save(); + header('Location: ' . url('', ['p' => 'pies', 'a' => 'resumen', 'pie' => $cuota->pie()->id])); + } + public static function edited() + { + $id = get('cuota'); + $cuota = \Model::factory(Cuota::class)->findOne($id); + $pago = $cuota->pago(); + foreach ($_POST as $key => $value) { + $pago->$key = $value; + } + $pago->save(); + } + public static function pendientes() + { + $f = \Carbon\Carbon::today(config('app.timezone')); + $cuotas = \Model::factory(Cuota::class) + ->select('cuota.*') + ->join('pago', ['pago.id', '=', 'cuota.pago']) + ->join('venta', ['venta.pie', '=', 'cuota.pie']) + ->raw_join('JOIN (SELECT e1.* FROM (SELECT pago, MAX(id) AS id FROM estado_pago GROUP BY pago) e0 JOIN estado_pago e1 ON e1.id = e0.id)', ['ep.pago', '=', 'pago.id'], 'ep') + ->where('ep.estado', 0) + ->where('venta.estado', 1) + ->whereLte('pago.fecha', $f->format('Y-m-d')) + ->order_by_asc('pago.fecha') + ->findMany(); + $sum = 0; + if (count($cuotas) > 0) { + $sum = array_reduce($cuotas, function($carry, $item) { + $carry += $item->pago()->valor; + return $carry; + }); + } + setlocale(LC_TIME, 'es'); + return view('ventas.pies.cuotas.pendientes', compact('cuotas', 'sum')); + } + public static function depositar() + { + $id = post('cuota'); + $cuota = \Model::factory(Cuota::class)->findOne($id); + if ($cuota->pago()->estado()->estado == 1) { + return 'ok'; + } + $estado = \Model::factory(EstadoPago::class)->create(); + $estado->pago = $cuota->pago()->id; + $estado->estado = 1; + $f = Carbon::parse(post('fecha'), config('app.timezone')); + $estado->fecha = $f->format('Y-m-d'); + $estado->save(); + return 'ok'; + } + public static function remove() + { + $id = get('cuota'); + $cuota = \Model::factory(Cuota::class)->findOne($id); + + $estado = \Model::factory(EstadoPago::class)->create(); + $estado->pago = $cuota->pago()->id; + $estado->estado = -3; + $f = Carbon::today(config('app.timezone')); + $estado->fecha = $f->format('Y-m-d'); + $estado->save(); + header('Location: ' . url('', ['p' => 'pies', 'a' => 'resumen', 'pie' => $cuota->pie()->id])); + } + public static function para_abonar() + { + $cuotas = \Model::factory(Cuota::class) + ->select('cuota.*') + ->join('pago', ['pago.id', '=', 'cuota.pago']) + ->join('venta', ['venta.pie', '=', 'cuota.pie']) + ->raw_join('JOIN (SELECT e1.* FROM (SELECT pago, MAX(id) AS id FROM estado_pago GROUP BY pago) e0 JOIN estado_pago e1 ON e1.id = e0.id)', ['ep.pago', '=', 'pago.id'], 'ep') + ->where('ep.estado', 1) + ->where('venta.estado', 1) + ->order_by_asc('ep.fecha') + ->findMany(); + $ini = get('start'); + if ($ini == null) { + $ini = 0; + } + $n = get('step'); + if ($n == 0) { + $n = 30; + } + $total = count($cuotas); + $cuotas = array_slice($cuotas, $ini, $n); + $pages = ceil($total / $n); + $current = ($ini + $n) / $n; + return view('ventas.pies.cuotas.abonar', compact('cuotas', 'total', 'pages', 'current')); + } + public static function abonar() + { + $id = post('cuota'); + $cuota = \Model::factory(Cuota::class)->findOne($id); + if ($cuota->pago()->estado()->estado == 2) { + return 'ok'; + } + $estado = \Model::factory(EstadoPago::class)->create(); + $estado->pago = $cuota->pago()->id; + $estado->estado = 2; + $f = Carbon::parse(post('fecha'), config('app.timezone')); + $estado->fecha = $f->format('Y-m-d'); + $estado->save(); + return 'ok'; + } + public static function rebotar() + { + $id = post('cuota'); + $cuota = \Model::factory(Cuota::class)->findOne($id); + if ($cuota->pago()->estado()->estado == -1) { + return 'ok'; + } + $estado = \Model::factory(EstadoPago::class)->create(); + $estado->pago = $cuota->pago()->id; + $estado->estado = -1; + $f = Carbon::parse(post('fecha'), config('app.timezone')); + $estado->fecha = $f->format('Y-m-d'); + $estado->save(); + return 'ok'; + } + public static function add() + { + $id = get('pie'); + $pie = \Model::factory(Pie::class)->findOne($id); + return view('ventas.pies.cuotas.add', compact('pie')); + } + public static function agregar() + { + $id = get('pie'); + $pie = \Model::factory(Pie::class)->findOne($id); + + $cant = $pie->cuotas - count($pie->cuotas()); + for ($i = 0; $i < $cant; $i ++) { + if (trim(post('valor' . $i)) == '') { + continue; + } + $banco = \Model::factory(Banco::class)->where('nombre', post('banco' . $i))->findOne(); + $f = Carbon::createFromDate(post('year' . $i), post('month' . $i), post('day' . $i), config('app.timezone')); + $uf = uf($f); + $valor = correctNumber(post('valor' . $i)); + + $pago = \Model::factory(Pago::class)->create(); + $pago->banco = $banco->id; + $pago->fecha = $f->format('Y-m-d'); + if ($uf and $uf->total > 0) { + $pago->uf = $uf->uf->value; + } else { + $pago->uf = 0; + } + $pago->tipo = 1; + $pago->valor = $valor; + $pago->identificador = post('identificador' . $i); + + $cuota = \Model::factory(Cuota::class)->create(); + $cuota->pie = $pie->id; + $cuota->fecha = $pago->fecha; + $cuota->{'valor_$'} = $pago->valor; + $cuota->estado = 0; + $cuota->banco = $pago->banco; + $cuota->uf = $pago->uf; + $cuota->numero = post('numero' . $i); + + $pago->new(); + + $cuota->pago = $pago->id; + $cuota->save(); + header('Location: ' . url('', ['p' => 'ventas', 'a' => 'show', 'venta' => $pie->venta()->id])); + } + } +} +?> diff --git a/resources/less/Controller/Devoluciones.php b/resources/less/Controller/Devoluciones.php new file mode 100644 index 0000000..8d9c41c --- /dev/null +++ b/resources/less/Controller/Devoluciones.php @@ -0,0 +1,19 @@ +findOne($id); + + return view('print.devolucion', compact('venta')); + } +} +?> diff --git a/resources/less/Controller/Escrituras.php b/resources/less/Controller/Escrituras.php new file mode 100644 index 0000000..f2cb056 --- /dev/null +++ b/resources/less/Controller/Escrituras.php @@ -0,0 +1,212 @@ +findOne($id); + return view('ventas.escrituras.add', compact('venta')); + } + public static function agregar() + { + $id = get('venta'); + $venta = \Model::factory(Venta::class)->findOne($id); + + $f = Carbon::createFromDate(post('escritura_year'), post('escritura_month'), post('escritura_day'), config('app.timezone')); + $venta->escriturado = $f->format('Y-m-d'); + + if (post('valor_reajuste')) { + $reajuste = \Model::factory(Pago::class)->create(); + $reajuste->valor = correctNumber(post('valor_reajuste')); + $fp = Carbon::createFromDate(post('reajuste_year'), post('reajuste_month'), post('reajuste_day'), config('app.timezone')); + $reajuste->fecha = $fp->format('Y-m-d'); + $reajuste->uf = (float) uf($fp)->uf->value; + $reajuste->newPagado(); + + $pie = $venta->pie(); + $pie->reajuste = $reajuste->id; + $pie->save(); + } + if (post('escritura_valor') or post('escritura_valor_uf')) { + $pago = \Model::factory(Pago::class)->create(); + $fp = Carbon::createFromDate(post('pago_escritura_year'), post('pago_escritura_month'), post('pago_escritura_day'), config('app.timezone')); + $pago->fecha = $fp->format('Y-m-d'); + $pago->uf = (float) uf($fp)->uf->value; + if (post('escritura_valor')) { + $pago->valor = correctNumber(post('escritura_valor')); + $pago->newPagado(); + } else { + $pago->valor = correctNumber(post('escritura_valor_uf')) * $pago->uf; + $pago->new(); + } + + $escritura = \Model::factory(Escritura::class)->create(); + $escritura->pago = $pago->id; + $escritura->valor = $pago->valor('uf'); + $escritura->fecha = $pago->fecha; + $escritura->save(); + + $venta->escritura = $escritura->id; + } + if (post('subsidio_ahorrado') or post('subsidio_valor')) { + $total = post('subsidio_ahorrado') + post('subsidio_valor'); + $subsidio = \Model::factory(Subsidio::class)->create(); + $pago = \Model::factory(Pago::class)->create(); + $pago->fecha = $f->format('Y-m-d'); + $pago->uf = (float) uf($f)->uf->value; + $pago->valor = correctNumber(post('subsidio_ahorrado')) * $pago->uf; + $pago->new(); + $subsidio->pago = $pago->id; + $pago = \Model::factory(Pago::class)->create(); + $pago->fecha = $f->format('Y-m-d'); + $pago->uf = (float) uf($f)->uf->value; + $pago->valor = correctNumber(post('subsidio_valor')) * $pago->uf; + $pago->new(); + $subsidio->subsidio = $pago->id; + $subsidio->save(); + + $venta->subsidio = $subsidio->id; + } + if (post('credito_valor')) { + $pago = \Model::factory(Pago::class)->create(); + $pago->fecha = $f->format('Y-m-d'); + $pago->uf = (float) uf($f)->uf->value; + $valor = post('credito_valor'); + if (strpos($valor, ',') !== false) { + $valor = correctNumber($valor); + } + $pago->valor = $valor * $pago->uf; + $banco = \Model::factory(Banco::class)->where('nombre', post('credito_banco'))->findOne(); + $pago->banco = $banco->id; + $pago->new(); + + $credito = \Model::factory(Credito::class)->create(); + $credito->pago = $pago->id; + $credito->save(); + + $venta->credito = $credito->id; + } elseif (post('credito_banco')) { + $pago = $venta->credito()->pago(); + $banco = \Model::factory(Banco::class)->where('nombre', post('credito_banco'))->findOne(); + $pago->banco = $banco->id; + $pago->save(); + } + + $tipo = \Model::factory(TipoEstadoVenta::class)->where('descripcion', 'escriturando')->findOne(); + $data = [ + 'venta' => $venta->id, + 'estado' => $tipo->id, + 'fecha' => $venta->escriturado + ]; + $estado = \Model::factory(EstadoVenta::class)->create($data); + $estado->save(); + $venta->save(); + header('Location: ' . url('', ['p' => 'ventas', 'a' => 'show', 'venta' => $venta->id])); + } + public static function edit() + { + $id = get('venta'); + $venta = \Model::factory(Venta::class)->findOne($id); + echo view('ventas.escrituras.edit', compact('venta')); + } + public static function editar() + { + $id = get('venta'); + $venta = \Model::factory(Venta::class)->findOne($id); + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $uf = uf($f); + + $valor = correctNumber(post('valor')); + if ($valor == '') { + $valor_uf = correctNumber(post('valor_uf')); + $valor = $valor_uf * $uf->uf->value; + } + $pago = $venta->escritura()->pago(); + if ($pago->valor != $valor) { + $pago->valor = $valor; + } + if ($pago->fecha != $f->format('Y-m-d')) { + $pago->fecha = $f->format('Y-m-d'); + $pago->uf = $uf->uf->value; + } + + $pago->save(); + header('Location: ' . url('', ['p' => 'ventas', 'a' => 'show', 'venta' => $venta->id])); + } + public static function informe() + { + $id = get('venta'); + $venta = \Model::factory(Venta::class)->findOne($id); + return view('ventas.escrituras.informe', compact('venta')); + } + public static function pagar() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + + return view('ventas.escrituras.pagar', compact('venta')); + } + public static function pagado() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + + $data = [ + 'pago' => $venta->escritura()->pago()->id, + 'fecha' => $f->format('Y-m-d'), + 'estado' => 1 + ]; + $estado = model(EstadoPago::class)->create($data); + $estado->save(); + header('Location: ' . url('', ['p' => 'ventas', 'a' => 'show', 'venta' => $venta->id])); + } + public static function abonar() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + + return view('ventas.escrituras.abonar', compact('venta')); + } + public static function abonado() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + + $data = [ + 'pago' => $venta->escritura()->pago()->id, + 'fecha' => $f->format('Y-m-d'), + 'estado' => 2 + ]; + $estado = model(EstadoPago::class)->create($data); + $estado->save(); + header('Location: ' . url('', ['p' => 'ventas', 'a' => 'show', 'venta' => $venta->id])); + } +} +?> diff --git a/resources/less/Controller/FormaPago.php b/resources/less/Controller/FormaPago.php new file mode 100644 index 0000000..6ccc7b3 --- /dev/null +++ b/resources/less/Controller/FormaPago.php @@ -0,0 +1,98 @@ +findOne($id); + + return view('ventas.forma_pago.edit', compact('venta')); + } + public static function editar() + { + d(post()); + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + + $valor = correctNumber(post('valor_pie')); + $cuotas = post('cuotas_pie'); + if ($venta->pie != 0) { + $pie = $venta->pie(); + $changed = false; + if ($pie->valor != $valor) { + $pie->valor = $valor; + $changed = true; + } + if ($pie->cuotas != $cuotas) { + $pie->cuotas = $cuotas; + $changed = true; + } + if ($changed) { + d($pie); + } + + $valor = correctNumber(post('valor_reajuste')); + $f = Carbon::createFromDate(post('year_reajuste'), post('month_reajuste'), post('day_reajuste'), config('app.timezone')); + $uf = uf($f); + $reajuste = $pie->reajuste(); + $changed = false; + if ($reajuste->valor != $valor) { + $reajuste->valor = $valor; + $changed = true; + } + if ($reajuste->fecha != $f->format('Y-m-d')) { + $reajuste->fecha = $f->format('Y-m-d'); + $reajuste->uf = $uf->uf->value; + $changed = true; + } + if ($changed) { + d($reajuste); + } + } elseif ($valor != '') { + $f = Carbon::parse($venta->fecha, config('app.timezone')); + $uf = uf($f); + $data = [ + 'valor' => $valor, + 'cuotas' => $cuotas, + 'uf' => $uf->uf->value, + 'fecha' => $f->format('Y-m-d') + ]; + $pie = model(Pie::class)->create($data); + d($pie); + } + + $valor = correctNumber(post('valor_escritura')); + $f = Carbon::createFromDate(post('year_escritura'), post('month_escritura'), post('day_escritura'), config('app.timezone')); + if ($venta->escritura != 0) { + $escritura = $venta->escritura(); + d($escritura); + } elseif ($valor != '') { + $data = [ + 'valor' => $valor, + 'fecha' => $f->format('Y-m-d'), + 'uf' => $uf->uf->value, + 'tipo' => 7 + ]; + $pago = model(Pago::class)->create($data); + $pago->newPagado(); + $data['pago'] = $pago->id; + unset($data['tipo']); + $escritura = model(Escritura::class)->create($data); + $escritura->save(); + $venta->escritura = $escritura->id; + $venta->save(); + } + } +} +?> diff --git a/resources/less/Controller/Informes.php b/resources/less/Controller/Informes.php new file mode 100644 index 0000000..965a88b --- /dev/null +++ b/resources/less/Controller/Informes.php @@ -0,0 +1,951 @@ +find_one($id_proyecto); + $ini = \Carbon\Carbon::parse($proyecto->estado()->fecha, config('app.timezone')); + #$informe = new Informador('Carta Gantt Proyecto - ' . $proyecto->descripcion); + $name = 'Carta Gantt Proyecto - ' . $proyecto->descripcion; + $hoy = Carbon::now(config('app.timezone')); + $filename = str_replace('ñ', 'n', $name . ' - ' . $hoy->format('Y-m-d') . '.xls'); + $informe = new PHPExcel($name, $filename); + + $columnas = ['Departamento', 'Propietario', 'Entrega', 'Estado']; + $today = \Carbon\Carbon::today(config('app.timezone')); + $end = $today->copy()->addDays(30); + $dif = $end->diffInDays($ini); + for ($i = 0; $i <= $dif; $i ++) { + $f = $ini->copy()->addDays($i); + if ($f->isWeekend()) { + continue; + } + $columnas []= $f->format('Y-m-d'); + } + $informe->addColumns($columnas); + + $data = []; + foreach ($proyecto->entregas() as $venta) { + $info = []; + $info []= $venta->unidad()->descripcion; + $info []= $venta->propietario()->findOne()->nombreCompleto(); + $fe = Carbon::parse($venta->entrega()->find_one()->fecha, config('app.timezone')); + $info []= $fe->format('Y-m-d'); + $info []= ''; + + for ($i = 0; $i <= $dif; $i ++) { + $f = $ini->copy()->addDays($i); + if ($f->isWeekend()) { + continue; + } + if ($f >= $fe and $f <= $fe->copy()->addDays(14)) { + $info []= 'X'; + } else { + $info []= ''; + } + } + + $data []= $info; + } + $informe->addDatas($data); + + return $informe->informe(); + } else { + $proyectos = model(Proyecto::class)->order_by_asc('descripcion')->find_many(); + return view('informes.gantt_entregas', compact('proyectos')); + } + } + public static function escrituras() + { + if (get('proyecto')) { + set_time_limit(60); + $id_proyecto = get('proyecto'); + $proyecto = model(Proyecto::class)->find_one($id_proyecto); + + #$informe = new Informador('Escrituras - ' . $proyecto->descripcion); + $name = 'Escrituras'; + $hoy = Carbon::now(config('app.timezone')); + $filename = str_replace('ñ', 'n', $name . ' - ' . $proyecto->descripcion . ' - ' . $hoy->format('Y-m-d') . '.xls'); + $informe = new PHPExcel($name, $filename); + + $columnas = [ + 'Departamento', + 'Estacionamientos', + 'Bodegas', + 'Propietario', + (object) ['name' => 'Promesa', 'style' => 'number'], + ['name' => 'Bono Pie', 'style' => 'amount'], + ['name' => 'Pie Pagado', 'style' => 'amount'], + ['name' => 'Reajuste', 'style' => 'amount'], + ['name' => 'Abono Contado', 'style' => 'amount'], + ['name' => 'Subsidio', 'style' => 'amount'], + 'Estado Subsidio', + ['name' => 'Credito', 'style' => 'amount'], + 'Banco', + 'Estado Credito', + ['name' => 'Saldo', 'style' => 'amount'], + ['name' => 'Escritura', 'style' => 'amount'], + ['name' => 'Entrega', 'style' => 'date'] + ]; + $informe->addColumns($columnas); + + //$ventas = $proyecto->escrituras(); + $ventas = $proyecto->ventas(); + + $data = []; + foreach ($ventas as $venta) { + $info = []; + $info['Departamento'] = $venta->unidad()->descripcion; + $ests = []; + foreach ($venta->propiedad()->estacionamientos() as $e) { + $ests []= $e->descripcion; + } + $bods = []; + foreach ($venta->propiedad()->bodegas() as $b) { + $bods []= $b->descripcion; + } + $info['Estacionamientos'] = implode(' - ', $ests); + $info['Bodegas'] = implode(' - ', $bods); + $info['Propietario'] = $venta->propietario()->nombreCompleto(); + $info['Promesa'] = $venta->valor_uf; + $saldo = $venta->valor_uf; + $info['Bono Pie'] = ''; + if ($venta->bono_pie != 0) { + $info['Bono Pie'] = $venta->bonoPie()->pago()->valor('ufs'); + $saldo -= $venta->bonoPie()->pago()->valor('ufs'); + } + $info['Pie'] = ''; + $info['Reajuste'] = ''; + if ($venta->pie != 0) { + $info['Pie'] = $venta->pie()->valorPagado(); + $saldo -= $venta->pie()->valorPagado(); + if ($venta->pie()->reajuste != 0) { + $info['Reajuste'] = $venta->pie()->reajuste()->valor('ufs'); + $saldo -= $venta->pie()->reajuste()->valor('ufs'); + } + } + $info['Abono Contado'] = ''; + if ($venta->escritura != 0) { + $info['Abono Contado'] = $venta->escritura()->pago()->valor('ufs'); + $saldo -= $venta->escritura()->pago()->valor('ufs'); + } + $info['Subsidio'] = ''; + $info['Estado Subsidio'] = ''; + if ($venta->subsidio != 0) { + $info['Subsidio'] = $venta->subsidio()->total('ufs'); + $info['Estado Subsidio'] = implode(' - ', [ + $venta->subsidio()->subsidio()->estado()->tipo()->descripcion, + $venta->subsidio()->pago()->estado()->tipo()->descripcion + ]); + $saldo -= $venta->subsidio()->total('ufs'); + } + $info['Credito'] = ''; + $info['Banco'] = ''; + $info['Estado Credito'] = ''; + if ($venta->credito != 0) { + $info['Credito'] = $venta->credito()->pago()->valor('ufs'); + $saldo -= $venta->credito()->pago()->valor('ufs'); + if ($venta->credito()->pago()->banco != 0) { + $info['Banco'] = $venta->credito()->pago()->banco()->nombre; + } + $info['Estado Credito'] = $venta->credito()->pago()->estado()->tipo()->descripcion; + } + $info['Saldo'] = -$saldo; + $info['Escritura'] = ''; + if ($venta->escriturado != 0) { + $info['Escritura'] = $venta->escriturado; + } + $info['Entrega'] = ''; + if ($venta->entregado != 0) { + $info['Entrega'] = $venta->entregado; + } + + $data []= $info; + } + $informe->addData($data); + + return $informe->informe(); + } else { + $proyectos = model(Proyecto::class)->order_by_asc('descripcion')->find_many(); + return view('informes.escrituras', compact('proyectos')); + } + } + public static function consolidacion() + { + $id_proyecto = get('proyecto'); + $proyecto = model(Proyecto::class)->findOne($id_proyecto); + + $ventas = $proyecto->ventas(); + set_time_limit(count($ventas)); + + $f = Carbon::today(config('app.timezone')); + setlocale(LC_TIME, 'es'); + + $data = [ + [$proyecto->descripcion], + [strftime('%d de %B de %Y', $f->timestamp)], + [''], + [''] + ]; + $columns = [ + ['name' => 'Fecha', 'style' => 'date'], + 'Glosa', + ['name' => 'Debe', 'style' => 'number'], + ['name' => 'Haber', 'style' => 'number'], + ['name' => 'Saldo', 'style' => 'number'], + 'Comentario' + ]; + $bold_rows = []; + + foreach ($ventas as $venta) { + $data []= ['Departamento ' . $venta->unidad()->descripcion . ' (' . format('ufs', $venta->valor_uf) . ' UF)']; + $data []= $columns; + $bold_rows []= count($data) - 1; + $ufs = 0; + $debe = 0; + $haber = 0; + $sum = 0; + if ($venta->pie != 0) { + $cuotas = $venta->pie()->cuotas(); + foreach ($cuotas as $cuota) { + $sum += $cuota->pago()->valor(); + $ufs += $cuota->pago()->valor('ufs'); + $haber += $cuota->pago()->valor(); + $info = [ + $cuota->pago()->estado()->fecha, + 'Pie - Cuota ' . $cuota->numero() . ' - ' . $venta->pie()->cuotas . ' (' . format('ufs', $cuota->pago()->valor('ufs')) . ' UF)', + '', + $cuota->pago()->valor(), + $sum + ]; + if ($cuota->pago()->estado()->estado < 2) { + $info []= 'No ha sido abonada.'; + } + $data []= $info; + } + if ($venta->pie()->reajuste != 0) { + $sum += $venta->pie()->reajuste()->valor(); + $ufs += $venta->pie()->reajuste()->valor('ufs'); + $haber += $venta->pie()->reajuste()->valor(); + $info = [ + $venta->pie()->reajuste()->estado()->fecha, + 'Reajuste (' . format('ufs', $venta->pie()->reajuste()->valor('ufs')) . ' UF)', + '', + $venta->pie()->reajuste()->valor(), + $sum + ]; + if ($venta->pie()->reajuste()->estado()->estado < 2) { + $info []= 'No ha sido abonado.'; + } + $data []= $info; + } + } + if ($venta->escritura != 0) { + $sum += $venta->escritura()->pago()->valor(); + $ufs += $venta->escritura()->pago()->valor('ufs'); + $haber += $venta->escritura()->pago()->valor(); + $info = [ + $venta->escritura()->pago()->estado()->fecha, + 'Abono Escritura (' . format('ufs', $venta->escritura()->pago()->valor('ufs')) . ' UF)', + '', + $venta->escritura()->pago()->valor(), + $sum + ]; + if ($venta->escritura()->pago()->estado()->estado < 2) { + $info []= 'No ha sido abonado.'; + } + $data []= $info; + } + if ($venta->credito != 0) { + $sum += $venta->credito()->pago()->valor(); + $ufs += $venta->credito()->pago()->valor('ufs'); + $haber += $venta->credito()->pago()->valor(); + $info = [ + $venta->credito()->pago()->estado()->fecha, + 'Crédito (' . format('ufs', $venta->credito()->pago()->valor('ufs')) . ' UF)', + '', + $venta->credito()->pago()->valor(), + $sum + ]; + if ($venta->credito()->pago()->estado()->estado < 2) { + $info []= 'No ha sido pagado.'; + } + $data []= $info; + } + if ($venta->bono_pie != 0) { + try { + $sum -= $venta->bonoPie()->pago()->valor(); + $debe += $venta->bonoPie()->pago()->valor(); + $info = [ + $venta->bonoPie()->pago()->estado()->fecha, + 'Bono Pie (' . format('ufs', $venta->bonoPie()->pago()->valor('ufs')) . ' UF)'. + $venta->bonoPie()->pago()->valor(), + '', + $sum + ]; + $data []= $info; + $sum += $venta->bonoPie()->pago()->valor(); + $haber += $venta->bonoPie()->pago()->valor(); + $info = [ + $venta->bonoPie()->pago()->estado()->fecha, + 'Bono Pie (' . format('ufs', $venta->bonoPie()->pago()->valor('ufs')) . ' UF)'. + '', + $venta->bonoPie()->pago()->valor(), + $sum + ]; + $data []= $info; + } catch (\Exception $e) { + + } + } + $info = [ + '', + 'TOTAL (' . format('ufs', $ufs) . ' UF)', + $debe, + $haber, + $sum + ]; + $data []= $info; + $bold_rows []= count($data) - 1; + + $data []= ['']; + } + /** + * Departamento # + * Fecha |Glosa |Debe |Haber |Saldo + * |Pie - Cuota 1 - n (# UF) |- |$# | + * |Reajuste (# UF) |- |$# | + * |Abono Escritura (# UF) |- |$# | + * |Crédito (# UF) |- |$# | + * |Bono Pie (# UF) |$# |- | + * |Bono Pie (# UF) |- |$# | + * |Devolución (# UF) |$# |- | + * - |TOTAL (# UF) | | | + */ + + array_walk($data, function(&$e, $i) use ($columns) { + if (count($e) < count($columns)) { + $n = count($columns) - count($e); + for ($j = 0; $j < $n; $j ++) { + $e []= ''; + } + } + }); + + #$informe = new Informador('Consolidación - ' . $proyecto->descripcion); + $name = 'Consolidación'; + $hoy = Carbon::now(config('app.timezone')); + $filename = str_replace('ñ', 'n', $name . ' - ' . $proyecto->descripcion . ' - ' . $hoy->format('Y-m-d') . '.xls'); + $informe = new PHPExcel($name, $filename); + $informe->addColumns($columns); + $informe->addData($data); + + return $informe->informe(); + } + public static function creditos_pendientes() + { + function creditos() { + $creditos = model(Credito::class) + ->select('credito.*') + ->join('venta', ['venta.credito', '=', 'credito.id']) + ->join('pago', ['pago.id', '=', 'credito.pago']) + ->rawJoin('JOIN (SELECT ep.* FROM (SELECT pago, MAX(id) AS id FROM estado_pago GROUP BY pago) e0 JOIN estado_pago ep ON ep.id = e0.id)', ['estado_pago.pago', '=', 'pago.id'], 'estado_pago') + ->whereLt('estado_pago.estado', 2) + ->where('venta.estado', 1) + ->orderByAsc('estado_pago.fecha') + ->findMany(); + foreach ($creditos as $credito) { + yield $credito; + } + } + $informe = new Informador('Créditos Pendientes'); + + $columnas = ['Proyecto', 'Departamento', 'Valor', 'Fecha Escritura', 'Estado']; + $informe->addColumns($columnas); + + $row = 0; + foreach (creditos() as $credito) { + $informe->addData($row, $credito->venta()->proyecto()->descripcion, 'Proyecto'); + $informe->addData($row, $credito->venta()->unidad()->descripcion, 'Departamento'); + $informe->addData($row, $credito->pago()->valor('ufs'), 'Valor'); + $informe->addData($row, (($credito->venta()->escriturado) ? $credito->venta()->escriturado : $credito->pago()->estado()->fecha), 'Fecha Escritura'); + $informe->addData($row, ucwords($credito->pago()->estado()->tipo()->descripcion), 'Estado'); + + $row ++; + } + + $date = [ + 'numberFormat' => ['short-date'] + ]; + $ufs = [ + 'numberFormat' => ['thousands'] + ]; + $formats = ['Valor' => $ufs, 'Fecha Escritura' => $date]; + $informe->addFormats($formats); + + return $informe->informe(); + } + public static function ventas() + { + if (get('proyecto')) { + $id = get('proyecto'); + $proyecto = model(Proyecto::class)->findOne($id); + $ventas = $proyecto->ventas(); + + /*usort($ventas, function($a, $b) { + return $a->fecha()->timestamp - $b->fecha()->timestamp; + });*/ + + $procasa = model(Agente::class)->findOne(1); + $pa = model(ProyectoAgente::class)->where('agente', $procasa->id)->where('proyecto', $proyecto->id)->findOne(); + if ($pa) { + $comision = $pa->comision / 100; + } else { + $comision = 0.03; + } + + #$informe = new Informador('Ventas - ' . $proyecto->descripcion); + $name = 'Informe de Ventas'; + $hoy = Carbon::now(config('app.timezone')); + $filename = str_replace('ñ', 'n', $name . ' - ' . $proyecto->descripcion . ' - ' . $hoy->format('Y-m-d') . '.xlsx'); + //$informe = new PHPExcel($name, $filename); + + $columnas = [ + 'Propietario', + ['name' => 'Departamento', 'style' => 'number'], + ['name' => 'Estacionamientos', 'style' => 'number'], + ['name' => 'Bodegas', 'style' => 'number'], + 'Fecha Venta', + ['name' => 'Mes', 'style' => 'mes'], + 'Tipo', + ['name' => 'm² Ponderados', 'style' => 'amount'], + ['name' => 'Valor Promesa', 'style' => 'amount'], + ['name' => 'Pie', 'style' => 'amount'], + ['name' => 'Pie Pagado', 'style' => 'amount'], + ['name' => '% Pie Pagado', 'style' => 'percent'], + ['name' => 'Bono Pie', 'style' => 'amount'], + 'Operador', + ['name' => 'Valor Operador', 'style' => 'amount'], + ['name' => 'Premios', 'style' => 'amount'], + ['name' => 'Subsidio', 'style' => 'amount'], + ['name' => 'Ahorro', 'style' => 'amount'], + ['name' => 'Credito', 'style' => 'amount'], + 'Banco', + ['name' => 'Valor Ests & Bods', 'style' => 'amount'], + ['name' => 'Valor Neto', 'style' => 'amount'], + ['name' => 'UF/m²*', 'style' => 'amount'], + ['name' => 'Comision', 'style' => 'amount'], + ['name' => 'Venta s/Comision', 'style' => 'amount'] + ]; + //$informe->addColumns($columnas); + + $data = []; + foreach ($ventas as $venta) { + $info = []; + $info['Propietario'] = mb_strtoupper($venta->propietario()->nombreCompleto()); + $info['Departamento'] = trim(array_reduce($venta->propiedad()->departamentos(), function($carry, $item) { + return implode(' - ', [$carry, $item->descripcion]); + }), ' -'); + //$ests = []; + $es = $venta->propiedad()->estacionamientos(); + /*if (count($es) > 0) { + foreach ($es as $e) { + $ests []= $e->descripcion; + } + } + $info['Estacionamientos'] = implode(', ', $ests);*/ + $info['Estacionamientos'] = implode(', ', array_map(function($item) { + return $item->descripcion; + }, $es)); + //$bods = []; + $bs = $venta->propiedad()->bodegas(); + /*if (count($bs) > 0) { + foreach ($bs as $b) { + $bods []= $b->descripcion; + } + } + $info['Bodegas'] = implode(', ', $bods);*/ + $info['Bodegas'] = implode(', ', array_map(function($item) { + return $item->descripcion; + }, $bs)); + $info['Fecha Venta'] = $venta->fecha()->format('Y-m-d'); + $info['Mes'] = $venta->fecha()->format('M-y'); + $info['Tipo'] = $venta->unidad()->abreviacion; + $info['m² Ponderados'] = $venta->unidad()->m2('vendible'); + $info['Valor Promesa'] = $venta->valor_uf; + $info['Pie'] = $venta->pie()->valor; + $info['Pie Pagado'] = 0; + $info['% Pie Pagado'] = 0; + if ($venta->pie()) { + $info['Pie Pagado'] = $venta->pie()->valorPagado('uf'); + $info['% Pie Pagado'] = $venta->pie()->valorPagado('uf') / $venta->valor_uf; + } + + $info['Bono Pie'] = ($venta->bono_pie == 0 or $venta->bonoPie() === false) ? '' : $venta->bonoPie()->pago()->valor('ufs'); + $info['Operador'] = ($venta->agente and $venta->agente()->agente()->tipo == 19) ? $venta->agente()->agente()->descripcion : ''; + $info['Valor Operador'] = $venta->valorComision(); + //$promos = 0; + $ps = $venta->promociones(); + /*if (count($ps) > 0) { + foreach ($ps as $promo) { + $promos += $promo->valor; + } + } + $info['Premios'] = $promos;*/ + $info['Premios'] = array_reduce($ps, function($sum, $item) { + return $sum + $item->valor; + }); + $info['Subsidio'] = 0; + $info['Ahorro'] = 0; + if ($venta->subsidio != 0) { + $info['Subsidio'] = $venta->subsidio()->subsidio()->valor('ufs'); + $info['Ahorro'] = $venta->subsidio()->pago()->valor('ufs'); + } + $info['Credito'] = 0; + $info['Banco'] = ''; + if ($venta->credito != 0) { + $info['Credito'] = $venta->credito()->pago()->valor('ufs'); + if ($venta->credito()->pago()->banco != 0) { + $info['Banco'] = $venta->credito()->pago()->banco()->nombre; + } + } + $info['Valor Ests & Bods'] = $venta->valorEstacionamientosYBodegas(); + $info['Valor Neto'] = $venta->valorFinal(); + $info['UF/m²*'] = $venta->uf_m2(); + $info['Comision'] = $venta->valorFinal() * $comision; + $info['Venta s/Comision'] = $venta->valorFinal() - $info['Comision']; + + $data []= $info; + } + /*$informe->addData($data); + + $totals = [ + 'Propietario' => 'TOTAL', + 'Departamento' => 'count', + 'Estacionamientos' => 'count', + 'Bodegas' => 'count', + 'm² Ponderados' => 'sum', + 'Valor Promesa' => 'sum', + 'Bono Pie' => 'sum', + 'Subsidio' => 'sum', + 'Ahorro' => 'sum', + 'Credito' => 'sum', + 'Valor Operador' => 'sum', + 'Premios' => 'sum', + 'Valor Ests & Bods' => 'sum', + 'Valor Neto' => 'sum', + 'Comision' => 'sum' + ]; + $informe->addTotals($totals); + + return $informe->informe();*/ + + $body = [ + "Proyecto" => $proyecto->descripcion, + "Compañía" => $proyecto->inmobiliaria()->abreviacion, + "data" => $data + ]; + $client = new Client(['base_uri' => 'localhost:8011']); + $response = $client->post('/ventas', ['json' => $body]); + + header("Content-Type: application/octet-stream; charset=utf-8"); + header('Content-Transfer-Encoding: binary'); + header('Content-Disposition: attachment; filename="' . $filename . '"'); + header('Cache-Control: max-age=0'); + return $response->getBody(); + //file_put_contents('php://output', $output); + + } else { + $proyectos = model(Proyecto::class)->order_by_asc('descripcion')->find_many(); + return view('informes.ventas', compact('proyectos')); + } + } + public static function resumen_contabilidad() + { + if (get('proyecto')) { + $id = get('proyecto'); + $proyecto = model(Proyecto::class)->findOne($id); + $fecha = get('fecha'); + $mes = null; + if ($fecha != null) { + $mes = Carbon::parse($fecha)->addMonths(1)->subDays(1); + } + + $ventas = $proyecto->ventas(); + + usort($ventas, function($a, $b) { + return $a->fecha()->timestamp - $b->fecha()->timestamp; + }); + + $name = 'Resumen Contabilidad'; + $hoy = Carbon::now(config('app.timezone')); + $filename = str_replace('ñ', 'n', $name . ' - ' . $proyecto->descripcion . ' - hasta ' . $fecha->format('Y-m-d') . '.xls'); + $name .= ' - Hasta ' . $fecha->format('d-m-Y'); + $informe = new PHPExcel($name, $filename); + + $columnas = [ + 'Propietario', + ['name' => 'Departamento', 'style' => 'general_number'], + ['name' => 'Estacionamientos', 'style' => 'number'], + ['name' => 'Bodegas', 'style' => 'number'], + 'Fecha Venta', + ['name' => 'Mes', 'style' => 'mes'], + 'Tipo', + ['name' => 'm² Ponderados', 'style' => 'amount'], + ['name' => 'Valor Promesa', 'style' => 'amount'], + ['name' => 'Pie [UF]', 'style' => 'amount'], + ['name' => 'Pie [$]', 'style' => 'amount'], + ['name' => 'Abono Escritura', 'style' => 'amount'], + ['name' => 'Crédito', 'style' => 'amount'], + ['name' => 'Cuotas', 'style' => 'number'], + ['name' => 'Cuotas Pagadas', 'style' => 'number'], + ['name' => 'Pie Pagado [UF]', 'style' => 'amount'], + ['name' => 'Pie Pagado [$]', 'style' => 'amount'] + ]; + $informe->addColumns($columnas); + + $data = []; + foreach ($ventas as $venta) { + $info = []; + $info['Propietario'] = mb_strtoupper($venta->propietario()->nombreCompleto()); + $info['Departamento'] = $venta->unidad()->descripcion; + $ests = []; + if ($venta->propiedad()->estacionamientos != '') { + $es = $venta->propiedad()->estacionamientos(); + foreach ($es as $e) { + $ests []= $e->descripcion; + } + } + $info['Estacionamientos'] = implode(', ', $ests); + $bods = []; + if ($venta->propiedad()->bodegas != '') { + $bs = $venta->propiedad()->bodegas(); + foreach ($bs as $b) { + $bods []= $b->descripcion; + } + } + $info['Bodegas'] = implode(', ', $bods); + $info['Fecha Venta'] = $venta->fecha()->format('d.m.Y'); + $info['Mes'] = $venta->fecha()->format('M-y'); + $info['Tipo'] = $venta->unidad()->abreviacion; + $info['m² Ponderados'] = $venta->unidad()->m2('vendible'); + $info['Valor Promesa'] = $venta->valor_uf; + $info['Pie [UF]'] = 0; + $info['Pie [$]'] = 0; + $info['Abono Escritura'] = 0; + $info['Crédito'] = 0; + $info['Cuotas'] = 0; + $info['Cuotas Pagadas'] = 0; + $info['Pie Pagado [UF]'] = 0; + $info['Pie Pagado [$]'] = 0; + if ($venta->pie()) { + $info['Pie [UF]'] = $venta->pie()->valor; + $info['Pie [$]'] = $venta->pie()->valorPesos(); + $info['Abono Escritura'] = ($venta->escritura != 0) ? $venta->escritura()->valor('ufs') : ($venta->valor_uf - $venta->pie()->valor - (($venta->credito != 0) ? $venta->credito()->pago()->valor('ufs') : 0)); + $info['Crédito'] = ($venta->credito != 0) ? $venta->credito()->pago()->valor('ufs') : 0; + $info['Cuotas'] = $venta->pie()->cuotas; + $info['Cuotas Pagadas'] = count($venta->pie()->pagadas($mes)); + $info['Pie Pagado [UF]'] = $venta->pie()->valorPagado('uf', $mes); + $info['Pie Pagado [$]'] = $venta->pie()->valorPagado('pesos', $mes); + } + + $data []= $info; + } + $informe->addData($data); + + $totals = [ + 'Departamento' => 'count', + 'Estacionamientos' => 'count', + 'Bodegas' => 'count', + 'm² Ponderados' => 'sum', + 'Valor Promesa' => 'sum', + 'Pie' => 'sum', + 'Pie Pagado' => 'sum' + ]; + $informe->addTotals($totals); + + return $informe->informe(); + } else { + $proyectos = model(Proyecto::class)->order_by_asc('descripcion')->find_many(); + return view('informes.resumen_contabilidad', compact('proyectos')); + } + } + public static function contabilidad() + { + if (get('proyecto')) { + $id = get('proyecto'); + $fecha = get('fecha'); + $mes = null; + if ($fecha != null) { + $mes = Carbon::parse($fecha); + } + $proyecto = model(Proyecto::class)->findOne($id); + $q = "SELECT pago.*, venta.id AS vid, venta.tipo AS ctipo, venta.pie AS pie + FROM ( + SELECT pago.id, banco.nombre AS banco, pago.fecha, pago.valor, pago.uf, ep.estado, ep.fecha AS efecha + FROM pago JOIN banco ON banco.id = pago.banco JOIN (( + SELECT pago, MAX(id) AS id FROM estado_pago GROUP BY pago) e0 JOIN estado_pago ep ON ep.id = e0.id) ON ep.pago = pago.id + WHERE ep.estado > 0 "; + if ($mes != null) { + $q .= "AND (pago.fecha BETWEEN '" . $mes->format('Y-m-01') . "' AND '" . $mes->format('Y-m-t') . "' + OR ep.fecha BETWEEN '" . $mes->format('Y-m-01') . "' AND '" . $mes->format('Y-m-t') . "')"; + } + $q .= ") pago JOIN (SELECT venta.* + FROM (( + SELECT venta.id, venta.pie, venta.propiedad, credito.pago, 'credito' AS tipo + FROM venta JOIN credito ON credito.id = venta.credito) + UNION ALL ( + SELECT venta.id, venta.pie, venta.propiedad, escritura.pago, 'escritura' AS tipo + FROM venta JOIN escritura ON escritura.id = venta.escritura) + UNION ALL ( + SELECT venta.id, venta.pie, venta.propiedad, cuota.pago, 'cuota' AS tipo + FROM venta JOIN cuota ON cuota.pie = venta.pie)) venta + JOIN propiedad ON propiedad.id = venta.propiedad + JOIN unidad ON unidad.id = propiedad.unidad_principal + WHERE unidad.proyecto = ?) venta + ON venta.pago = pago.id"; + $st = \ORM::getDB()->prepare($q); + $st->execute([$id]); + if ($st->rowCount() > 0) { + $R = $st->fetchAll(\PDO::FETCH_OBJ); + + //$informe = new Informador('Contabilidad - ' . (($mes != null) ? $mes->format('Y-m') . ' - ' : '') . $proyecto->descripcion); + $name = 'Contabilidad'; + $hoy = Carbon::now(config('app.timezone')); + $filename = str_replace('ñ', 'n', 'Contabilidad - ' . (($mes != null) ? $mes->format('Y-m') . ' - ' : '') . $proyecto->descripcion . ' - ' . $hoy->format('Y-m-d') . '.xls'); + + $informe = new PHPExcel($name, $filename); + + $columnas = ['Proyecto', 'Fecha', 'Banco', 'Departamento', 'RUT', 'Propietario', 'Glosa', 'Glosa2', (object) ['name' => 'Valor', 'style' => 'integer'], (object) ['name' => 'Valor UF', 'style' => 'currency']]; + $informe->addColumns($columnas); + $data = []; + foreach ($R as $r) { + $info = []; + $info['Proyecto'] = $proyecto->descripcion; + $f1 = \Carbon\Carbon::parse($r->fecha, config('app.timezone')); + $f2 = \Carbon\Carbon::parse($r->efecha, config('app.timezone')); + $info['Fecha'] = ($f1->max($f2))->format('Y-m-d'); + $info['Banco'] = $r->banco; + $venta = model(Venta::class)->findOne($r->vid); + $info['Departamento'] = $venta->unidad()->descripcion; + $info['RUT'] = $venta->propietario()->rut(); + $info['Propietario'] = $venta->propietario()->nombreCompleto(); + $info['Glosa'] = ucwords($r->ctipo); + $info['Glosa2'] = ''; + if ($r->ctipo == 'cuota') { + $cuota = model(Cuota::class)->where('pago', $r->id)->findOne(); + + $info['Glosa'] = 'Pie - ' . format('ufs', $cuota->pie()->valor('ufs'), null, true); + + $info['Glosa2'] = $cuota->numero() . ' - ' . $cuota->pie()->cuotas; + } + $info['Valor'] = $r->valor; + $info['Valor UF'] = '0'; + if ($r->uf > 0) { + $info['Valor UF'] = $r->valor / $r->uf; + } + $data []= $info; + } + + $informe->addData($data); + + return $informe->informe(); + } + } else { + setlocale(LC_TIME, 'es_ES'); + $proyectos = model(Proyecto::class)->order_by_asc('descripcion')->find_many(); + return view('informes.contabilidad', compact('proyectos')); + } + } + public static function para_comision() + { + $proyectos = model(Proyecto::class)->orderByAsc('descripcion')->findMany(); + return view('informes.para_comision', compact('proyectos')); + } + public static function comisiones() + { + $id = post('proyecto'); + $proyecto = model(Proyecto::class)->findOne($id); + $unidades = explode('-', str_replace([';', '.', ':', ' ', PHP_EOL, '|', '+', ','], '-', post('unidades'))); + $ventas = model(Venta::class) + ->select('venta.*') + ->join('propiedad', ['propiedad.id', '=', 'venta.propiedad']) + ->join('unidad', ['unidad.id', '=', 'propiedad.unidad_principal']) + ->where('unidad.proyecto', $proyecto->id) + ->where('venta.estado', 1) + ->whereIn('unidad.descripcion', $unidades) + ->orderByExpr('FIELD(unidad.descripcion, ' . implode(', ', $unidades) . ')') + ->findMany(); + $ids = []; + $totales = (object) ['precio' => 0, 'neto' => 0, 'comision' => 0]; + foreach ($ventas as $venta) { + $ids []= $venta->id; + $totales->precio += $venta->valor_uf; + $totales->neto += $venta->valorCorredora(); + $totales->comision += $venta->valorCorredora() * 1.5 / 100; + } + return view('informes.comisiones', compact('ventas', 'proyecto', 'totales', 'ids')); + } + public static function comisiones_xlsx() + { + $id_ventas = explode(',', get('ventas')); + $ventas = model(Venta::class) + ->whereIn('id', $id_ventas) + ->orderByExpr('FIELD(id, ' . implode(', ', $id_ventas) . ')') + ->findMany(); + + $informe = new Informador('Comisiones - ' . $ventas[0]->proyecto()->descripcion); + $columnas = ['Departamento', 'Estacionamientos', 'Bodegas', 'Propietario', 'Precio', '% Com', 'Com UF']; + $informe->addColumns($columnas); + $data = []; + foreach ($ventas as $venta) { + $info = []; + $info['Departamento'] = $venta->unidad()->descripcion; + $info['Estacionamientos'] = implode(' - ', $venta->propiedad()->estacionamientos('array')); + $info['Bodegas'] = implode(' - ', $venta->propiedad()->bodegas('array')); + $info['Propietario'] = $venta->propietario()->nombreCompleto(); + $info['Precio'] = "'" . format('ufs', $venta->valorCorredora()); + $info['% Com'] = '1,5 %'; + $info['Com UF'] = "'" . format('ufs', $venta->valorCorredora() * 1.5 / 100); + $data []= $info; + } + + $informe->addDatas($data); + + return $informe->informe(); + } + public static function cuotas() + { + $id_venta = get('venta'); + $venta = model(Venta::class)->findOne($id_venta); + + $name = 'Cuotas - ' . $venta->unidad()->descripcion; + $hoy = Carbon::now(config('app.timezone')); + $filename = str_replace('ñ', 'n', $name . ' - ' . $venta->proyecto()->descripcion . ' - ' . $hoy->format('Y-m-d') . '.xls'); + $informe = new PHPExcel($name, $filename); + $columnas = [ + ['name' => 'Cuota', 'style' => 'number'], + ['name' => 'Fecha Cuota', 'style' => 'date'], + 'Banco', + 'Identificador', + ['name' => 'Valor $', 'style' => 'number'], + ['name' => 'Valor UF', 'style' => 'currency'], + ['name' => 'Fecha Pago', 'style' => 'date'] + ]; + $informe->addColumns($columnas); + $data = []; + foreach ($venta->pie()->cuotas() as $cuota) { + $info = []; + $info['Cuota'] = $cuota->numero(); + $info['Fecha Cuota'] = $cuota->pago()->fecha()->format('Y-m-d'); + $info['Banco'] = $cuota->pago()->banco()->descripcion; + $info['Identificador'] = $cuota->pago()->identificador; + $info['Valor $'] = $cuota->pago()->valor(); + $info['Valor UF'] = $cuota->pago()->valor('ufs'); + $info['Fecha Pago'] = $cuota->pago()->estado()->fecha()->format('Y-m-d'); + $data []= $info; + } + $informe->addData($data); + + return $informe->informe(); + } + public static function resciliaciones() + { + if (get('proyecto')) { + $id = get('proyecto'); + $proyecto = model(Proyecto::class)->findOne($id); + $ventas = $proyecto->resciliaciones(); + + usort($ventas, function($a, $b) { + return $a->fecha()->timestamp - $b->fecha()->timestamp; + }); + + $name = 'Resciliaciones'; + $hoy = Carbon::now(config('app.timezone')); + $filename = str_replace('ñ', 'n', $name . ' - ' . $proyecto->descripcion . ' - ' . $hoy->format('Y-m-d') . '.xls'); + $informe = new PHPExcel($name, $filename); + + $columnas = [ + 'Propietario', + ['name' => 'Departamento', 'style' => 'number'], + ['name' => 'Estacionamientos', 'style' => 'number'], + ['name' => 'Bodegas', 'style' => 'number'], + 'Fecha Venta', + 'Fecha Resciliación', + ['name' => 'Mes', 'style' => 'mes'], + 'Tipo', + ['name' => 'm² Ponderados', 'style' => 'amount'], + ['name' => 'Valor Promesa', 'style' => 'amount'], + ]; + $informe->addColumns($columnas); + + $data = []; + foreach ($ventas as $venta) { + $info = []; + $info['Propietario'] = mb_strtoupper($venta->propietario()->nombreCompleto()); + $info['Departamento'] = $venta->unidad()->descripcion; + $ests = []; + if ($venta->propiedad()->estacionamientos != '') { + $es = $venta->propiedad()->estacionamientos(); + foreach ($es as $e) { + $ests []= $e->descripcion; + } + } + $info['Estacionamientos'] = implode(', ', $ests); + $bods = []; + if ($venta->propiedad()->bodegas != '') { + $bs = $venta->propiedad()->bodegas(); + foreach ($bs as $b) { + $bods []= $b->descripcion; + } + } + $info['Bodegas'] = implode(', ', $bods); + $info['Fecha Venta'] = $venta->fecha()->format('d.m.Y'); + $info['Fecha Resciliación'] = $venta->estado()->fecha()->format('d.m.Y'); + $info['Mes'] = $venta->estado()->fecha()->format('M-y'); + $info['Tipo'] = $venta->unidad()->abreviacion; + $info['m² Ponderados'] = $venta->unidad()->m2('vendible'); + $info['Valor Promesa'] = $venta->valor_uf; + + $data []= $info; + } + $informe->addData($data); + + $totals = [ + 'Departamento' => 'count', + 'Estacionamientos' => 'count', + 'Bodegas' => 'count', + 'm² Ponderados' => 'sum', + 'Valor Promesa' => 'sum' + ]; + $informe->addTotals($totals); + + return $informe->informe(); + } else { + $proyectos = model(Proyecto::class)->order_by_asc('descripcion')->find_many(); + return view('informes.resciliaciones', compact('proyectos')); + } + } +} diff --git a/resources/less/Controller/Informes.php.save b/resources/less/Controller/Informes.php.save new file mode 100644 index 0000000..efd5035 --- /dev/null +++ b/resources/less/Controller/Informes.php.save @@ -0,0 +1,901 @@ +find_one($id_proyecto); + $ini = \Carbon\Carbon::parse($proyecto->estado()->fecha, config('app.timezone')); + #$informe = new Informador('Carta Gantt Proyecto - ' . $proyecto->descripcion); + $name = 'Carta Gantt Proyecto - ' . $proyecto->descripcion; + $hoy = Carbon::now(config('app.timezone')); + $filename = str_replace('ñ', 'n', $name . ' - ' . $hoy->format('Y-m-d') . '.xls'); + $informe = new PHPExcel($name, $filename); + + $columnas = ['Departamento', 'Propietario', 'Entrega', 'Estado']; + $today = \Carbon\Carbon::today(config('app.timezone')); + $end = $today->copy()->addDays(30); + $dif = $end->diffInDays($ini); + for ($i = 0; $i <= $dif; $i ++) { + $f = $ini->copy()->addDays($i); + if ($f->isWeekend()) { + continue; + } + $columnas []= $f->format('Y-m-d'); + } + $informe->addColumns($columnas); + + $data = []; + foreach ($proyecto->entregas() as $venta) { + $info = []; + $info []= $venta->unidad()->descripcion; + $info []= $venta->propietario()->findOne()->nombreCompleto(); + $fe = Carbon::parse($venta->entrega()->find_one()->fecha, config('app.timezone')); + $info []= $fe->format('Y-m-d'); + $info []= ''; + + for ($i = 0; $i <= $dif; $i ++) { + $f = $ini->copy()->addDays($i); + if ($f->isWeekend()) { + continue; + } + if ($f >= $fe and $f <= $fe->copy()->addDays(14)) { + $info []= 'X'; + } else { + $info []= ''; + } + } + + $data []= $info; + } + $informe->addDatas($data); + + return $informe->informe(); + } else { + $proyectos = model(Proyecto::class)->order_by_asc('descripcion')->find_many(); + return view('informes.gantt_entregas', compact('proyectos')); + } + } + public static function escrituras() + { + if (get('proyecto')) { + set_time_limit(60); + $id_proyecto = get('proyecto'); + $proyecto = model(Proyecto::class)->find_one($id_proyecto); + + #$informe = new Informador('Escrituras - ' . $proyecto->descripcion); + $name = 'Escrituras'; + $hoy = Carbon::now(config('app.timezone')); + $filename = str_replace('ñ', 'n', $name . ' - ' . $proyecto->descripcion . ' - ' . $hoy->format('Y-m-d') . '.xls'); + $informe = new PHPExcel($name, $filename); + + $columnas = [ + 'Departamento', + 'Estacionamientos', + 'Bodegas', + 'Propietario', + (object) ['name' => 'Promesa', 'style' => 'number'], + ['name' => 'Bono Pie', 'style' => 'amount'], + ['name' => 'Pie Pagado', 'style' => 'amount'], + ['name' => 'Reajuste', 'style' => 'amount'], + ['name' => 'Abono Contado', 'style' => 'amount'], + ['name' => 'Subsidio', 'style' => 'amount'], + 'Estado Subsidio', + ['name' => 'Credito', 'style' => 'amount'], + 'Banco', + 'Estado Credito', + ['name' => 'Saldo', 'style' => 'amount'], + ['name' => 'Escritura', 'style' => 'amount'], + ['name' => 'Entrega', 'style' => 'date'] + ]; + $informe->addColumns($columnas); + + //$ventas = $proyecto->escrituras(); + $ventas = $proyecto->ventas(); + + $data = []; + foreach ($ventas as $venta) { + $info = []; + $info['Departamento'] = $venta->unidad()->descripcion; + $ests = []; + foreach ($venta->propiedad()->estacionamientos() as $e) { + $ests []= $e->descripcion; + } + $bods = []; + foreach ($venta->propiedad()->bodegas() as $b) { + $bods []= $b->descripcion; + } + $info['Estacionamientos'] = implode(' - ', $ests); + $info['Bodegas'] = implode(' - ', $bods); + $info['Propietario'] = $venta->propietario()->nombreCompleto(); + $info['Promesa'] = $venta->valor_uf; + $saldo = $venta->valor_uf; + $info['Bono Pie'] = ''; + if ($venta->bono_pie != 0) { + $info['Bono Pie'] = $venta->bonoPie()->pago()->valor('ufs'); + $saldo -= $venta->bonoPie()->pago()->valor('ufs'); + } + $info['Pie'] = ''; + $info['Reajuste'] = ''; + if ($venta->pie != 0) { + $info['Pie'] = $venta->pie()->valorPagado(); + $saldo -= $venta->pie()->valorPagado(); + if ($venta->pie()->reajuste != 0) { + $info['Reajuste'] = $venta->pie()->reajuste()->valor('ufs'); + $saldo -= $venta->pie()->reajuste()->valor('ufs'); + } + } + $info['Abono Contado'] = ''; + if ($venta->escritura != 0) { + $info['Abono Contado'] = $venta->escritura()->pago()->valor('ufs'); + $saldo -= $venta->escritura()->pago()->valor('ufs'); + } + $info['Subsidio'] = ''; + $info['Estado Subsidio'] = ''; + if ($venta->subsidio != 0) { + $info['Subsidio'] = $venta->subsidio()->total('ufs'); + $info['Estado Subsidio'] = implode(' - ', [ + $venta->subsidio()->subsidio()->estado()->tipo()->descripcion, + $venta->subsidio()->pago()->estado()->tipo()->descripcion + ]); + $saldo -= $venta->subsidio()->total('ufs'); + } + $info['Credito'] = ''; + $info['Banco'] = ''; + $info['Estado Credito'] = ''; + if ($venta->credito != 0) { + $info['Credito'] = $venta->credito()->pago()->valor('ufs'); + $saldo -= $venta->credito()->pago()->valor('ufs'); + if ($venta->credito()->pago()->banco != 0) { + $info['Banco'] = $venta->credito()->pago()->banco()->nombre; + } + $info['Estado Credito'] = $venta->credito()->pago()->estado()->tipo()->descripcion; + } + $info['Saldo'] = -$saldo; + $info['Escritura'] = ''; + if ($venta->escriturado != 0) { + $info['Escritura'] = $venta->escriturado; + } + $info['Entrega'] = ''; + if ($venta->entregado != 0) { + $info['Entrega'] = $venta->entregado; + } + + $data []= $info; + } + $informe->addData($data); + + return $informe->informe(); + } else { + $proyectos = model(Proyecto::class)->order_by_asc('descripcion')->find_many(); + return view('informes.escrituras', compact('proyectos')); + } + } + public static function consolidacion() + { + $id_proyecto = get('proyecto'); + $proyecto = model(Proyecto::class)->findOne($id_proyecto); + + $ventas = $proyecto->ventas(); + set_time_limit(count($ventas)); + + $f = Carbon::today(config('app.timezone')); + setlocale(LC_TIME, 'es'); + + $data = [ + [$proyecto->descripcion], + [strftime('%d de %B de %Y', $f->timestamp)], + [''], + [''] + ]; + $columns = [ + ['name' => 'Fecha', 'style' => 'date'], + 'Glosa', + ['name' => 'Debe', 'style' => 'number'], + ['name' => 'Haber', 'style' => 'number'], + ['name' => 'Saldo', 'style' => 'number'], + 'Comentario' + ]; + $bold_rows = []; + + foreach ($ventas as $venta) { + $data []= ['Departamento ' . $venta->unidad()->descripcion . ' (' . format('ufs', $venta->valor_uf) . ' UF)']; + $data []= $columns; + $bold_rows []= count($data) - 1; + $ufs = 0; + $debe = 0; + $haber = 0; + $sum = 0; + if ($venta->pie != 0) { + $cuotas = $venta->pie()->cuotas(); + foreach ($cuotas as $cuota) { + $sum += $cuota->pago()->valor(); + $ufs += $cuota->pago()->valor('ufs'); + $haber += $cuota->pago()->valor(); + $info = [ + $cuota->pago()->estado()->fecha, + 'Pie - Cuota ' . $cuota->numero() . ' - ' . $venta->pie()->cuotas . ' (' . format('ufs', $cuota->pago()->valor('ufs')) . ' UF)', + '', + $cuota->pago()->valor(), + $sum + ]; + if ($cuota->pago()->estado()->estado < 2) { + $info []= 'No ha sido abonada.'; + } + $data []= $info; + } + if ($venta->pie()->reajuste != 0) { + $sum += $venta->pie()->reajuste()->valor(); + $ufs += $venta->pie()->reajuste()->valor('ufs'); + $haber += $venta->pie()->reajuste()->valor(); + $info = [ + $venta->pie()->reajuste()->estado()->fecha, + 'Reajuste (' . format('ufs', $venta->pie()->reajuste()->valor('ufs')) . ' UF)', + '', + $venta->pie()->reajuste()->valor(), + $sum + ]; + if ($venta->pie()->reajuste()->estado()->estado < 2) { + $info []= 'No ha sido abonado.'; + } + $data []= $info; + } + } + if ($venta->escritura != 0) { + $sum += $venta->escritura()->pago()->valor(); + $ufs += $venta->escritura()->pago()->valor('ufs'); + $haber += $venta->escritura()->pago()->valor(); + $info = [ + $venta->escritura()->pago()->estado()->fecha, + 'Abono Escritura (' . format('ufs', $venta->escritura()->pago()->valor('ufs')) . ' UF)', + '', + $venta->escritura()->pago()->valor(), + $sum + ]; + if ($venta->escritura()->pago()->estado()->estado < 2) { + $info []= 'No ha sido abonado.'; + } + $data []= $info; + } + if ($venta->credito != 0) { + $sum += $venta->credito()->pago()->valor(); + $ufs += $venta->credito()->pago()->valor('ufs'); + $haber += $venta->credito()->pago()->valor(); + $info = [ + $venta->credito()->pago()->estado()->fecha, + 'Crédito (' . format('ufs', $venta->credito()->pago()->valor('ufs')) . ' UF)', + '', + $venta->credito()->pago()->valor(), + $sum + ]; + if ($venta->credito()->pago()->estado()->estado < 2) { + $info []= 'No ha sido pagado.'; + } + $data []= $info; + } + if ($venta->bono_pie != 0) { + try { + $sum -= $venta->bonoPie()->pago()->valor(); + $debe += $venta->bonoPie()->pago()->valor(); + $info = [ + $venta->bonoPie()->pago()->estado()->fecha, + 'Bono Pie (' . format('ufs', $venta->bonoPie()->pago()->valor('ufs')) . ' UF)'. + $venta->bonoPie()->pago()->valor(), + '', + $sum + ]; + $data []= $info; + $sum += $venta->bonoPie()->pago()->valor(); + $haber += $venta->bonoPie()->pago()->valor(); + $info = [ + $venta->bonoPie()->pago()->estado()->fecha, + 'Bono Pie (' . format('ufs', $venta->bonoPie()->pago()->valor('ufs')) . ' UF)'. + '', + $venta->bonoPie()->pago()->valor(), + $sum + ]; + $data []= $info; + } catch (\Exception $e) { + + } + } + $info = [ + '', + 'TOTAL (' . format('ufs', $ufs) . ' UF)', + $debe, + $haber, + $sum + ]; + $data []= $info; + $bold_rows []= count($data) - 1; + + $data []= ['']; + } + /** + * Departamento # + * Fecha |Glosa |Debe |Haber |Saldo + * |Pie - Cuota 1 - n (# UF) |- |$# | + * |Reajuste (# UF) |- |$# | + * |Abono Escritura (# UF) |- |$# | + * |Crédito (# UF) |- |$# | + * |Bono Pie (# UF) |$# |- | + * |Bono Pie (# UF) |- |$# | + * |Devolución (# UF) |$# |- | + * - |TOTAL (# UF) | | | + */ + + array_walk($data, function(&$e, $i) use ($columns) { + if (count($e) < count($columns)) { + $n = count($columns) - count($e); + for ($j = 0; $j < $n; $j ++) { + $e []= ''; + } + } + }); + + #$informe = new Informador('Consolidación - ' . $proyecto->descripcion); + $name = 'Consolidación'; + $hoy = Carbon::now(config('app.timezone')); + $filename = str_replace('ñ', 'n', $name . ' - ' . $proyecto->descripcion . ' - ' . $hoy->format('Y-m-d') . '.xls'); + $informe = new PHPExcel($name, $filename); + $informe->addColumns($columns); + $informe->addData($data); + + return $informe->informe(); + } + public static function creditos_pendientes() + { + function creditos() { + $creditos = model(Credito::class) + ->select('credito.*') + ->join('venta', ['venta.credito', '=', 'credito.id']) + ->join('pago', ['pago.id', '=', 'credito.pago']) + ->rawJoin('JOIN (SELECT ep.* FROM (SELECT pago, MAX(id) AS id FROM estado_pago GROUP BY pago) e0 JOIN estado_pago ep ON ep.id = e0.id)', ['estado_pago.pago', '=', 'pago.id'], 'estado_pago') + ->whereLt('estado_pago.estado', 2) + ->where('venta.estado', 1) + ->orderByAsc('estado_pago.fecha') + ->findMany(); + foreach ($creditos as $credito) { + yield $credito; + } + } + $informe = new Informador('Créditos Pendientes'); + + $columnas = ['Proyecto', 'Departamento', 'Valor', 'Fecha Escritura', 'Estado']; + $informe->addColumns($columnas); + + $row = 0; + foreach (creditos() as $credito) { + $informe->addData($row, $credito->venta()->proyecto()->descripcion, 'Proyecto'); + $informe->addData($row, $credito->venta()->unidad()->descripcion, 'Departamento'); + $informe->addData($row, $credito->pago()->valor('ufs'), 'Valor'); + $informe->addData($row, (($credito->venta()->escriturado) ? $credito->venta()->escriturado : $credito->pago()->estado()->fecha), 'Fecha Escritura'); + $informe->addData($row, ucwords($credito->pago()->estado()->tipo()->descripcion), 'Estado'); + + $row ++; + } + + $date = [ + 'numberFormat' => ['short-date'] + ]; + $ufs = [ + 'numberFormat' => ['thousands'] + ]; + $formats = ['Valor' => $ufs, 'Fecha Escritura' => $date]; + $informe->addFormats($formats); + + return $informe->informe(); + } + public static function ventas() + { + if (get('proyecto')) { + $id = get('proyecto'); + $proyecto = model(Proyecto::class)->findOne($id); + $ventas = $proyecto->ventas(); + + usort($ventas, function($a, $b) { + return $a->fecha()->timestamp - $b->fecha()->timestamp; + }); + + $procasa = model(Agente::class)->findOne(1); + $pa = model(ProyectoAgente::class)->where('agente', $procasa->id)->where('proyecto', $proyecto->id)->findOne(); + if ($pa) { + $comision = $pa->comision / 100; + } else { + $comision = 0.03; + } + + #$informe = new Informador('Ventas - ' . $proyecto->descripcion); + $name = 'Ventas'; + $hoy = Carbon::now(config('app.timezone')); + $filename = str_replace('ñ', 'n', $name . ' - ' . $proyecto->descripcion . ' - ' . $hoy->format('Y-m-d') . '.xls'); + $informe = new PHPExcel($name, $filename); + + $columnas = [ + 'Propietario', + ['name' => 'Departamento', 'style' => 'number'], + ['name' => 'Estacionamientos', 'style' => 'number'], + ['name' => 'Bodegas', 'style' => 'number'], + 'Fecha Venta', + ['name' => 'Mes', 'style' => 'mes'], + 'Tipo', + ['name' => 'm² Ponderados', 'style' => 'amount'], + ['name' => 'Valor Promesa', 'style' => 'amount'], + ['name' => 'Bono Pie', 'style' => 'amount'], + 'Operador', + ['name' => 'Valor Operador', 'style' => 'amount'], + ['name' => 'Premios', 'style' => 'amount'], + ['name' => 'Subsidio', 'style' => 'amount'], + ['name' => 'Ahorro', 'style' => 'amount'], + ['name' => 'Credito', 'style' => 'amount'], + 'Banco', + ['name' => 'Valor Ests & Bods', 'style' => 'amount'], + ['name' => 'Valor Neto', 'style' => 'amount'], + ['name' => 'UF/m²*', 'style' => 'amount'], + ['name' => 'Comision', 'style' => 'amount'], + ['name' => 'Venta s/Comision', 'style' => 'amount'] + ]; + $informe->addColumns($columnas); + + $data = []; + foreach ($ventas as $venta) { + $info = []; + $info['Propietario'] = mb_strtoupper($venta->propietario()->nombreCompleto()); + $info['Departamento'] = $venta->unidad()->descripcion; + $ests = []; + if ($venta->propiedad()->estacionamientos != '') { + $es = $venta->propiedad()->estacionamientos(); + foreach ($es as $e) { + $ests []= $e->descripcion; + } + } + $info['Estacionamientos'] = implode(', ', $ests); + $bods = []; + if ($venta->propiedad()->bodegas != '') { + $bs = $venta->propiedad()->bodegas(); + foreach ($bs as $b) { + $bods []= $b->descripcion; + } + } + $info['Bodegas'] = implode(', ', $bods); + $info['Fecha Venta'] = $venta->fecha()->format('d.m.Y'); + $info['Mes'] = $venta->fecha()->format('M-y'); + $info['Tipo'] = $venta->unidad()->abreviacion; + $info['m² Ponderados'] = $venta->unidad()->m2('vendible'); + $info['Valor Promesa'] = $venta->valor_uf; + $info['Bono Pie'] = ($venta->bono_pie == 0 or $venta->bonoPie() === false) ? '' : $venta->bonoPie()->pago()->valor('ufs'); + $info['Operador'] = ($venta->agente and $venta->agente()->agente()->tipo == 19) ? $venta->agente()->agente()->descripcion : ''; + $info['Valor Operador'] = $venta->valorComision(); + $promos = 0; + $ps = $venta->promociones(); + if (count($ps) > 0) { + foreach ($ps as $promo) { + $promos += $promo->valor; + } + } + $info['Premios'] = $promos; + $info['Subsidio'] = 0; + $info['Ahorro'] = 0; + if ($venta->subsidio != 0) { + $info['Subsidio'] = $venta->subsidio()->subsidio()->valor('ufs'); + $info['Ahorro'] = $venta->subsidio()->pago()->valor('ufs'); + } + $info['Credito'] = 0; + $info['Banco'] = ''; + if ($venta->credito != 0) { + $info['Credito'] = $venta->credito()->pago()->valor('ufs'); + if ($venta->credito()->pago()->banco != 0) { + $info['Banco'] = $venta->credito()->pago()->banco()->nombre; + } + } + $info['Valor Ests & Bods'] = $venta->valorEstacionamientosYBodegas(); + $info['Valor Neto'] = $venta->valorFinal(); + $info['UF/m²*'] = $venta->uf_m2(); + $info['Comision'] = $venta->valorFinal() * $comision; + $info['Venta s/Comision'] = $venta->valorFinal() - $info['Comision']; + + $data []= $info; + } + $informe->addData($data); + + $totals = [ + 'Propietario' => 'TOTAL', + 'Departamento' => 'count', + 'Estacionamientos' => 'count', + 'Bodegas' => 'count', + 'm² Ponderados' => 'sum', + 'Valor Promesa' => 'sum', + 'Bono Pie' => 'sum', + 'Subsidio' => 'sum', + 'Ahorro' => 'sum', + 'Credito' => 'sum', + 'Valor Operador' => 'sum', + 'Premios' => 'sum', + 'Valor Ests & Bods' => 'sum', + 'Valor Neto' => 'sum', + 'Comision' => 'sum' + ]; + $informe->addTotals($totals); + + return $informe->informe(); + } else { + $proyectos = model(Proyecto::class)->order_by_asc('descripcion')->find_many(); + return view('informes.ventas', compact('proyectos')); + } + } + public static function resumen_contabilidad() + { + if (get('proyecto')) { + $id = get('proyecto'); + $proyecto = model(Proyecto::class)->findOne($id); + $ventas = $proyecto->ventas(); + + usort($ventas, function($a, $b) { + return $a->fecha()->timestamp - $b->fecha()->timestamp; + }); + + $name = 'Ventas'; + $hoy = Carbon::now(config('app.timezone')); + $filename = str_replace('ñ', 'n', $name . ' - ' . $proyecto->descripcion . ' - ' . $hoy->format('Y-m-d') . '.xls'); + $informe = new PHPExcel($name, $filename); + + $columnas = [ + 'Propietario', + ['name' => 'Departamento', 'style' => 'general_number'], + ['name' => 'Estacionamientos', 'style' => 'number'], + ['name' => 'Bodegas', 'style' => 'number'], + 'Fecha Venta', + ['name' => 'Mes', 'style' => 'mes'], + 'Tipo', + ['name' => 'm² Ponderados', 'style' => 'amount'], + ['name' => 'Valor Promesa', 'style' => 'amount'], + ['name' => 'Pie [UF]', 'style' => 'amount'], + ['name' => 'Pie [$]', 'style' => 'amount'], + ['name' => 'Abono Escritura', 'style' => 'amount'], + ['name' => 'Crédito', 'style' => 'amount'], + ['name' => 'Cuotas', 'style' => 'number'], + ['name' => 'Cuotas Pagadas', 'style' => 'number'], + ['name' => 'Pie Pagado [UF]', 'style' => 'amount'], + ['name' => 'Pie Pagado [$]', 'style' => 'amount'] + ]; + $informe->addColumns($columnas); + + $data = []; + foreach ($ventas as $venta) { + $info = []; + $info['Propietario'] = mb_strtoupper($venta->propietario()->nombreCompleto()); + $info['Departamento'] = $venta->unidad()->descripcion; + $ests = []; + if ($venta->propiedad()->estacionamientos != '') { + $es = $venta->propiedad()->estacionamientos(); + foreach ($es as $e) { + $ests []= $e->descripcion; + } + } + $info['Estacionamientos'] = implode(', ', $ests); + $bods = []; + if ($venta->propiedad()->bodegas != '') { + $bs = $venta->propiedad()->bodegas(); + foreach ($bs as $b) { + $bods []= $b->descripcion; + } + } + $info['Bodegas'] = implode(', ', $bods); + $info['Fecha Venta'] = $venta->fecha()->format('d.m.Y'); + $info['Mes'] = $venta->fecha()->format('M-y'); + $info['Tipo'] = $venta->unidad()->abreviacion; + $info['m² Ponderados'] = $venta->unidad()->m2('vendible'); + $info['Valor Promesa'] = $venta->valor_uf; + $info['Pie [UF]'] = 0; + $info['Pie [$]'] = 0; + if ($venta->pie()) { + $info['Pie [UF]'] = $venta->pie()->valor; + $info['Pie [$]'] = $venta->pie()->valorPesos(); + } + $info['Abono Escritura'] = ($venta->escritura != 0) ? $venta->escritura()->valor('ufs') : ($venta->valor_uf - $venta->pie()->valor - (($venta->credito != 0) ? $venta->credito()->pago()->valor('ufs') : 0)); + $info['Crédito'] = ($venta->credito != 0) ? $venta->credito()->pago()->valor('ufs') : 0; + + $info['Cuotas'] = $venta->pie()->cuotas; + $info['Cuotas Pagadas'] = count($venta->pie()->pagadas()); + $info['Pie Pagado [UF]'] = $venta->pie()->valorPagado('uf'); + $info['Pie Pagado [$]'] = $venta->pie()->valorPagado('pesos'); + + $data []= $info; + } + $informe->addData($data); + + $totals = [ + 'Departamento' => 'count', + 'Estacionamientos' => 'count', + 'Bodegas' => 'count', + 'm² Ponderados' => 'sum', + 'Valor Promesa' => 'sum', + 'Pie' => 'sum', + 'Pie Pagado' => 'sum' + ]; + $informe->addTotals($totals); + + return $informe->informe(); + } else { + $proyectos = model(Proyecto::class)->order_by_asc('descripcion')->find_many(); + return view('informes.resumen_contabilidad', compact('proyectos')); + } + } + public static function contabilidad() + { + if (get('proyecto')) { + $id = get('proyecto'); + $fecha = get('fecha'); + $mes = null; + if ($fecha != null) { + $mes = Carbon::parse($fecha); + } + $proyecto = model(Proyecto::class)->findOne($id); + $q = "SELECT pago.*, venta.id AS vid, venta.tipo AS ctipo, venta.pie AS pie + FROM ( + SELECT pago.id, banco.nombre AS banco, pago.fecha, pago.valor, pago.uf, ep.estado, ep.fecha AS efecha + FROM pago JOIN banco ON banco.id = pago.banco JOIN (( + SELECT pago, MAX(id) AS id FROM estado_pago GROUP BY pago) e0 JOIN estado_pago ep ON ep.id = e0.id) ON ep.pago = pago.id + WHERE ep.estado > 0 "; + if ($mes != null) { + $q .= "AND (pago.fecha BETWEEN '" . $mes->format('Y-m-01') . "' AND '" . $mes->format('Y-m-t') . "' + OR ep.fecha BETWEEN '" . $mes->format('Y-m-01') . "' AND '" . $mes->format('Y-m-t') . "')"; + } + $q .= ") pago JOIN (SELECT venta.* + FROM (( + SELECT venta.id, venta.pie, venta.propiedad, credito.pago, 'credito' AS tipo + FROM venta JOIN credito ON credito.id = venta.credito) + UNION ALL ( + SELECT venta.id, venta.pie, venta.propiedad, escritura.pago, 'escritura' AS tipo + FROM venta JOIN escritura ON escritura.id = venta.escritura) + UNION ALL ( + SELECT venta.id, venta.pie, venta.propiedad, cuota.pago, 'cuota' AS tipo + FROM venta JOIN cuota ON cuota.pie = venta.pie)) venta + JOIN propiedad ON propiedad.id = venta.propiedad + JOIN unidad ON unidad.id = propiedad.unidad_principal + WHERE unidad.proyecto = ?) venta + ON venta.pago = pago.id"; + $st = \ORM::getDB()->prepare($q); + $st->execute([$id]); + if ($st->rowCount() > 0) { + $R = $st->fetchAll(\PDO::FETCH_OBJ); + + #$informe = new Informador('Contabilidad - ' . (($mes != null) ? $mes->format('Y-m') . ' - ' : '') . $proyecto->descripcion); + $name = 'Contabilidad'; + $hoy = Carbon::now(config('app.timezone')); + $filename = str_replace('ñ', 'n', 'Contabilidad - ' . (($mes != null) ? $mes->format('Y-m') . ' - ' : '') . $proyecto->descripcion . ' - ' . $hoy->format('Y-m-d') . '.xls'); + + $informe = new PHPExcel($name, $filename); + + $columnas = ['Proyecto', 'Fecha', 'Banco', 'Departamento', 'RUT', 'Propietario', 'Glosa', 'Glosa2', (object) ['name' => 'Valor', 'style' => 'integer'], (object) ['name' => 'Valor UF', 'style' => 'currency']]; + $informe->addColumns($columnas); + $data = []; + foreach ($R as $r) { + $info = []; + $info['Proyecto'] = $proyecto->descripcion; + $f1 = \Carbon\Carbon::parse($r->fecha, config('app.timezone')); + $f2 = \Carbon\Carbon::parse($r->efecha, config('app.timezone')); + $info['Fecha'] = ($f1->max($f2))->format('Y-m-d'); + $info['Banco'] = $r->banco; + $venta = model(Venta::class)->findOne($r->vid); + $info['Departamento'] = $venta->unidad()->descripcion; + $info['RUT'] = $venta->propietario()->rut(); + $info['Propietario'] = $venta->propietario()->nombreCompleto(); + $info['Glosa'] = ucwords($r->ctipo); + $info['Glosa2'] = ''; + if ($r->ctipo == 'cuota') { + $cuota = model(Cuota::class)->where('pago', $r->id)->findOne(); + + $info['Glosa'] = 'Pie - ' . format('ufs', $cuota->pie()->valor('ufs'), null, true); + + $info['Glosa2'] = $cuota->numero() . ' - ' . $cuota->pie()->cuotas; + } + $info['Valor'] = $r->valor; + $info['Valor UF'] = '0'; + if ($r->uf > 0) { + $info['Valor UF'] = $r->valor / $r->uf; + } + $data []= $info; + } + + $informe->addData($data); + + return $informe->informe(); + } + } else { + setlocale(LC_TIME, 'es'); + $proyectos = model(Proyecto::class)->order_by_asc('descripcion')->find_many(); + return view('informes.contabilidad', compact('proyectos')); + } + } + public static function para_comision() + { + $proyectos = model(Proyecto::class)->orderByAsc('descripcion')->findMany(); + return view('informes.para_comision', compact('proyectos')); + } + public static function comisiones() + { + $id = post('proyecto'); + $proyecto = model(Proyecto::class)->findOne($id); + $unidades = explode('-', str_replace([';', '.', ':', ' ', PHP_EOL, '|', '+', ','], '-', post('unidades'))); + $ventas = model(Venta::class) + ->select('venta.*') + ->join('propiedad', ['propiedad.id', '=', 'venta.propiedad']) + ->join('unidad', ['unidad.id', '=', 'propiedad.unidad_principal']) + ->where('unidad.proyecto', $proyecto->id) + ->where('venta.estado', 1) + ->whereIn('unidad.descripcion', $unidades) + ->orderByExpr('FIELD(unidad.descripcion, ' . implode(', ', $unidades) . ')') + ->findMany(); + $ids = []; + $totales = (object) ['precio' => 0, 'neto' => 0, 'comision' => 0]; + foreach ($ventas as $venta) { + $ids []= $venta->id; + $totales->precio += $venta->valor_uf; + $totales->neto += $venta->valorCorredora(); + $totales->comision += $venta->valorCorredora() * 1.5 / 100; + } + return view('informes.comisiones', compact('ventas', 'proyecto', 'totales', 'ids')); + } + public static function comisiones_xlsx() + { + $id_ventas = explode(',', get('ventas')); + $ventas = model(Venta::class) + ->whereIn('id', $id_ventas) + ->orderByExpr('FIELD(id, ' . implode(', ', $id_ventas) . ')') + ->findMany(); + + $informe = new Informador('Comisiones - ' . $ventas[0]->proyecto()->descripcion); + $columnas = ['Departamento', 'Estacionamientos', 'Bodegas', 'Propietario', 'Precio', '% Com', 'Com UF']; + $informe->addColumns($columnas); + $data = []; + foreach ($ventas as $venta) { + $info = []; + $info['Departamento'] = $venta->unidad()->descripcion; + $info['Estacionamientos'] = implode(' - ', $venta->propiedad()->estacionamientos('array')); + $info['Bodegas'] = implode(' - ', $venta->propiedad()->bodegas('array')); + $info['Propietario'] = $venta->propietario()->nombreCompleto(); + $info['Precio'] = "'" . format('ufs', $venta->valorCorredora()); + $info['% Com'] = '1,5 %'; + $info['Com UF'] = "'" . format('ufs', $venta->valorCorredora() * 1.5 / 100); + $data []= $info; + } + + $informe->addDatas($data); + + return $informe->informe(); + } + public static function cuotas() + { + $id_venta = get('venta'); + $venta = model(Venta::class)->findOne($id_venta); + + $name = 'Cuotas - ' . $venta->unidad()->descripcion; + $hoy = Carbon::now(config('app.timezone')); + $filename = str_replace('ñ', 'n', $name . ' - ' . $venta->proyecto()->descripcion . ' - ' . $hoy->format('Y-m-d') . '.xls'); + $informe = new PHPExcel($name, $filename); + $columnas = [ + ['name' => 'Cuota', 'style' => 'number'], + ['name' => 'Fecha Cuota', 'style' => 'date'], + 'Banco', + 'Identificador', + ['name' => 'Valor $', 'style' => 'number'], + ['name' => 'Valor UF', 'style' => 'currency'], + ['name' => 'Fecha Pago', 'style' => 'date'] + ]; + $informe->addColumns($columnas); + $data = []; + foreach ($venta->pie()->cuotas() as $cuota) { + $info = []; + $info['Cuota'] = $cuota->numero(); + $info['Fecha Cuota'] = $cuota->pago()->fecha()->format('Y-m-d'); + $info['Banco'] = $cuota->pago()->banco()->descripcion; + $info['Identificador'] = $cuota->pago()->identificador; + $info['Valor $'] = $cuota->pago()->valor(); + $info['Valor UF'] = $cuota->pago()->valor('ufs'); + $info['Fecha Pago'] = $cuota->pago()->estado()->fecha()->format('Y-m-d'); + $data []= $info; + } + $informe->addData($data); + + return $informe->informe(); + } + public static function resciliaciones() + { + if (get('proyecto')) { + $id = get('proyecto'); + $proyecto = model(Proyecto::class)->findOne($id); + $ventas = $proyecto->resciliaciones(); + + usort($ventas, function($a, $b) { + return $a->fecha()->timestamp - $b->fecha()->timestamp; + }); + + $name = 'Resciliaciones'; + $hoy = Carbon::now(config('app.timezone')); + $filename = str_replace('ñ', 'n', $name . ' - ' . $proyecto->descripcion . ' - ' . $hoy->format('Y-m-d') . '.xls'); + $informe = new PHPExcel($name, $filename); + + $columnas = [ + 'Propietario', + ['name' => 'Departamento', 'style' => 'number'], + ['name' => 'Estacionamientos', 'style' => 'number'], + ['name' => 'Bodegas', 'style' => 'number'], + 'Fecha Venta', + 'Fecha Resciliación', + ['name' => 'Mes', 'style' => 'mes'], + 'Tipo', + ['name' => 'm² Ponderados', 'style' => 'amount'], + ['name' => 'Valor Promesa', 'style' => 'amount'], + ]; + $informe->addColumns($columnas); + + $data = []; + foreach ($ventas as $venta) { + $info = []; + $info['Propietario'] = mb_strtoupper($venta->propietario()->nombreCompleto()); + $info['Departamento'] = $venta->unidad()->descripcion; + $ests = []; + if ($venta->propiedad()->estacionamientos != '') { + $es = $venta->propiedad()->estacionamientos(); + foreach ($es as $e) { + $ests []= $e->descripcion; + } + } + $info['Estacionamientos'] = implode(', ', $ests); + $bods = []; + if ($venta->propiedad()->bodegas != '') { + $bs = $venta->propiedad()->bodegas(); + foreach ($bs as $b) { + $bods []= $b->descripcion; + } + } + $info['Bodegas'] = implode(', ', $bods); + $info['Fecha Venta'] = $venta->fecha()->format('d.m.Y'); + $info['Fecha Resciliación'] = $venta->estado()->fecha()->format('d.m.Y'); + $info['Mes'] = $venta->estado()->fecha()->format('M-y'); + $info['Tipo'] = $venta->unidad()->abreviacion; + $info['m² Ponderados'] = $venta->unidad()->m2('vendible'); + $info['Valor Promesa'] = $venta->valor_uf; + + $data []= $info; + } + $informe->addData($data); + + $totals = [ + 'Departamento' => 'count', + 'Estacionamientos' => 'count', + 'Bodegas' => 'count', + 'm² Ponderados' => 'sum', + 'Valor Promesa' => 'sum' + ]; + $informe->addTotals($totals); + + return $informe->informe(); + } else { + $proyectos = model(Proyecto::class)->order_by_asc('descripcion')->find_many(); + return view('informes.resciliaciones', compact('proyectos')); + } + } +} diff --git a/resources/less/Controller/Inmobiliarias.php b/resources/less/Controller/Inmobiliarias.php new file mode 100644 index 0000000..f0b8910 --- /dev/null +++ b/resources/less/Controller/Inmobiliarias.php @@ -0,0 +1,74 @@ +orderByAsc('abreviacion')->findMany(); + return view('inmobiliarias.list', compact('inmobiliarias')); + } + public static function show() + { + $rut = get('rut'); + $inmobiliaria = model(Inmobiliaria::class)->findOne($rut); + return view('inmobiliarias.show', compact('inmobiliaria')); + } + public static function add() + { + $sociedades = model(TipoSociedad::class)->findMany(); + return view('inmobiliarias.add', compact('sociedades')); + } + public static function agregar() + { + list($rut, $dv) = explode('-', str_replace('.', '', post('rut'))); + + $inmobiliaria = model(Inmobiliaria::class)->findOne($rut); + if ($inmobiliaria) { + header('Location: ' . url('', ['p' => 'inmobiliarias', 'a' => 'show', 'rut' => $inmobiliaria->rut])); + die(); + } + + $inmobiliaria = model(Inmobiliaria::class)->create(); + $inmobiliaria->rut = $rut; + $inmobiliaria->dv = $dv; + $inmobiliaria->razon = post('razon'); + $inmobiliaria->abreviacion = post('abrev'); + $inmobiliaria->sociedad = post('sociedad'); + + $inmobiliaria->save(); + header('Location: ' . url('', ['p' => 'inmobiliarias', 'a' => 'show', 'rut' => $inmobiliaria->rut])); + } + public static function edit() + { + $sociedades = model(TipoSociedad::class)->findMany(); + $rut = get('rut'); + $inmobiliaria = model(Inmobiliaria::class)->findOne($rut); + $bancos = model(Banco::class)->findMany(); + usort($bancos, function($a, $b) { + return strcmp($a->nombre, $b->nombre); + }); + return view('inmobiliarias.edit', compact('inmobiliaria', 'bancos', 'sociedades')); + } + public static function do_edit() + { + $rut = get('rut'); + $inmobiliaria = model(Inmobiliaria::class)->findOne($rut); + foreach (post() as $field => $value) { + if ($value != '' and $inmobiliaria->{$field} != $value) { + $inmobiliaria->{$field} = $value; + } + } + + $inmobiliaria->save(); + header('Location: ' . nUrl('inmobiliarias', 'show', ['rut' => $inmobiliaria->rut])); + } +} +?> diff --git a/resources/less/Controller/Operadores.php b/resources/less/Controller/Operadores.php new file mode 100644 index 0000000..765ba2a --- /dev/null +++ b/resources/less/Controller/Operadores.php @@ -0,0 +1,47 @@ +findOne(get('proyecto')); + $operadores = model(Agente::class) + ->select('agente.*') + ->join('agente_tipo', ['agente_tipo.agente', '=', 'agente.id']) + ->join('tipo_agente', ['tipo_agente.id', '=', 'agente_tipo.tipo']) + ->where('tipo_agente.descripcion', 'operador') + ->orderByAsc('agente.abreviacion') + ->findMany(); + $vigentes = array_map(function($item) { + return $item->agente()->agente(); + }, $proyecto->operadoresVigentes()); + echo view('proyectos.operadores.add', compact('proyecto', 'operadores', 'vigentes')); + } + public static function add() + { + $proyecto = model(Proyecto::class)->findOne(get('proyecto')); + $fecha = Carbon::today(config('app.timezone')); + foreach (post('operadores') as $op) { + $operador = model(Agente::class)->findOne($op); + $at = $operador->tipos(19); + $data = [ + 'proyecto' => $proyecto->id, + 'agente' => $at->id, + 'fecha' => $fecha->format('Y-m-d'), + 'comision' => 2 + ]; + $pa = model(ProyectoAgente::class)->create($data); + $pa->new(); + } + header('Location: ' . nUrl('proyectos', 'show', ['proyecto' => $proyecto->id])); + } +} diff --git a/resources/less/Controller/Other.php b/resources/less/Controller/Other.php new file mode 100644 index 0000000..eb90f31 --- /dev/null +++ b/resources/less/Controller/Other.php @@ -0,0 +1,71 @@ +create(); + $unidad = \Model::factory(Unidad::class)->where('descripcion', $info[0])->where('proyecto', post('proyecto'))->find_one(); + if (!$unidad->venta()->find_one()) { + echo 'x'; + continue; + } + $venta = $unidad->venta()->find_one(); + $entrega->fecha = \Carbon\Carbon::parse($info[1])->format('Y-m-d'); + if ($venta->entrega == '0') { + $entrega->save(); + $venta->entrega = $entrega->id; + $venta->save(); + echo '.'; + } else { + echo 'x'; + } + } + } else { + $proyectos = \Model::factory(Proyecto::class)->order_by_asc('descripcion')->find_many(); + return view('other.entregar_multiple', compact('proyectos')); + } + } + public static function capacidades() + { + $capacidades = []; + $controllers = glob(config('locations.app') . '/Controller/*.php'); + foreach ($controllers as $controller) { + if (basename($controller) == 'Admin.php' or basename($controller) == 'Other.php') { + continue; + } + $class = Stringy::create($controller)->replace(config('locations.app'), '/App')->replace('.php', '')->replace('/', '\\')->__toString(); + $ref = new \ReflectionClass($class); + $static = $ref->getMethods(\ReflectionMethod::IS_STATIC && \ReflectionMethod::IS_PUBLIC); + foreach ($static as $method) { + if ($method->name == 'setDefault' or $method->name == 'index') { + continue; + } + $capacidades []= $method; + } + } + return view('other.capacidades', compact('capacidades')); + } +} +?> \ No newline at end of file diff --git a/resources/less/Controller/Pagares.php b/resources/less/Controller/Pagares.php new file mode 100644 index 0000000..f05b24e --- /dev/null +++ b/resources/less/Controller/Pagares.php @@ -0,0 +1,271 @@ +findOne(get('pagare')); + return view('proyectos.pagares.show', compact('pagare')); + } + public static function add() + { + $proyecto = model(Proyecto::class)->findOne(get('proyecto')); + return view('proyectos.pagares.add', compact('proyecto')); + } + public static function do_add() + { + $proyecto = model(Proyecto::class)->findOne(get('proyecto')); + $data = post(); + + $data['id'] = $data['numero']; + unset($data['numero']); + $data['proyecto'] = $proyecto->id; + $moneda = model(TipoMonedaPagare::class)->where('descripcion', $data['moneda'])->findOne(); + $data['moneda'] = $moneda->id; + + $fecha = ['year', 'month', 'day']; + $fecha_arr = array_filter($data, function($item) use ($fecha) { + return (array_search($item, $fecha) !== false); + }, \ARRAY_FILTER_USE_KEY); + uksort($fecha_arr, function($a, $b) use ($fecha) { + return array_search($a, $fecha) - array_search($b, $fecha); + }); + foreach ($fecha as $f) { + unset($data[$f]); + } + array_walk($fecha_arr, function(&$item) { + if (strlen($item) < 4) { + $item = str_pad($item, 2, '0', \STR_PAD_LEFT); + } + }); + $data['fecha'] = implode('-', $fecha_arr); + + foreach ($fecha as &$key) { + $key .= '_banco'; + } + $fecha_arr = array_filter($data, function($item) use ($fecha) { + return (array_search($item, $fecha) !== false); + }, \ARRAY_FILTER_USE_KEY); + uksort($fecha_arr, function($a, $b) use ($fecha) { + return array_search($a, $fecha) - array_search($b, $fecha); + }); + foreach ($fecha as $f) { + unset($data[$f]); + } + array_walk($fecha_arr, function(&$item) { + if (strlen($item) < 4) { + $item = str_pad($item, 2, '0', \STR_PAD_LEFT); + } + }); + $data['fecha_banco'] = implode('-', $fecha_arr); + + $data['abonado'] = (int) $data['abonado']; + if ($data['abonado'] == 0) { + $data['fecha'] = '0000-00-00'; + } + + $pagare = model(Pagare::class)->create($data); + $pagare->save(); + header('Location: ' . nUrl('pagares', 'show', ['pagare' => $pagare->id])); + } + public static function edit() + { + $pagare = model(Pagare::class)->findOne(get('pagare')); + return view('proyectos.pagares.edit', compact('pagare')); + } + public static function do_edit() + { + $pagare = model(Pagare::class)->findOne(get('pagare')); + + $data = post(); + if ($pagare->id != $data['numero']) { + foreach ($pagare->renovaciones() as $renovacion) { + $renovacion->pagare = $data['numero']; + $renovacion->save(); + } + $pagare->id = $data['numero']; + $changed = true; + } + unset($data['numero']); + $moneda = model(TipoMonedaPagare::class)->where('descripcion', $data['moneda'])->findOne(); + $data['moneda'] = $moneda->id; + $fecha = ['year', 'month', 'day']; + $fecha_arr = array_filter($data, function($item) use ($fecha) { + return (array_search($item, $fecha) !== false); + }, \ARRAY_FILTER_USE_KEY); + uksort($fecha_arr, function($a, $b) use ($fecha) { + return array_search($a, $fecha) - array_search($b, $fecha); + }); + foreach ($fecha as $f) { + unset($data[$f]); + } + array_walk($fecha_arr, function(&$item) { + if (strlen($item) < 4) { + $item = str_pad($item, 2, '0', \STR_PAD_LEFT); + } + }); + $data['fecha'] = implode('-', $fecha_arr); + + foreach ($fecha as &$key) { + $key .= '_banco'; + } + $fecha_arr = array_filter($data, function($item) use ($fecha) { + return (array_search($item, $fecha) !== false); + }, \ARRAY_FILTER_USE_KEY); + uksort($fecha_arr, function($a, $b) use ($fecha) { + return array_search($a, $fecha) - array_search($b, $fecha); + }); + foreach ($fecha as $f) { + unset($data[$f]); + } + array_walk($fecha_arr, function(&$item) { + if (strlen($item) < 4) { + $item = str_pad($item, 2, '0', \STR_PAD_LEFT); + } + }); + $data['fecha_banco'] = implode('-', $fecha_arr); + + $data['abonado'] = (int) $data['abonado']; + if ($data['abonado'] == 0) { + $data['fecha'] = '0000-00-00'; + } + + $changed = false; + foreach ($data as $k => $v) { + if ($pagare->$k != $v) { + $pagare->$k = $v; + $changed = true; + if (strpos($k, 'fecha') !== false) { + $pagare->uf = 0; + } + } + } + + if ($changed) { + $pagare->save(); + } + header('Location: ' . nUrl('pagares', 'show', ['pagare' => $pagare->id])); + } + public static function edit_renovacion() + { + $renovacion = model(RenovacionPagare::class)->findOne(get('renovacion')); + return view('proyectos.pagares.edit_renovacion', compact('renovacion')); + } + public static function do_edit_renovacion() + { + $renovacion = model(RenovacionPagare::class)->findOne(get('renovacion')); + + $data = post(); + $fecha = ['year', 'month', 'day']; + $fecha_arr = array_filter($data, function($item) use ($fecha) { + return (array_search($item, $fecha) !== false); + }, \ARRAY_FILTER_USE_KEY); + uksort($fecha_arr, function($a, $b) use ($fecha) { + return array_search($a, $fecha) - array_search($b, $fecha); + }); + foreach ($fecha as $f) { + unset($data[$f]); + } + array_walk($fecha_arr, function(&$item) { + if (strlen($item) < 4) { + $item = str_pad($item, 2, '0', \STR_PAD_LEFT); + } + }); + $data['fecha'] = implode('-', $fecha_arr); + + foreach ($fecha as &$key) { + $key .= '_banco'; + } + $fecha_arr = array_filter($data, function($item) use ($fecha) { + return (array_search($item, $fecha) !== false); + }, \ARRAY_FILTER_USE_KEY); + uksort($fecha_arr, function($a, $b) use ($fecha) { + return array_search($a, $fecha) - array_search($b, $fecha); + }); + foreach ($fecha as $f) { + unset($data[$f]); + } + array_walk($fecha_arr, function(&$item) { + if (strlen($item) < 4) { + $item = str_pad($item, 2, '0', \STR_PAD_LEFT); + } + }); + $data['fecha_banco'] = implode('-', $fecha_arr); + + $changed = false; + foreach ($data as $k => $v) { + if ($renovacion->$k != $v) { + $renovacion->$k = $v; + $changed = true; + if (strpos($k, 'fecha') !== false) { + $renovacion->uf = 0; + } + } + } + if ($changed) { + $renovacion->save(); + } + header('Location: ' . nUrl('pagares', 'show', ['pagare' => $renovacion->pagare])); + } + public static function add_renovacion() + { + $pagare = model(Pagare::class)->findOne(get('pagare')); + return view('proyectos.pagares.add_renovacion', compact('pagare')); + } + public static function do_add_renovacion() + { + $pagare = model(Pagare::class)->findOne(get('pagare')); + $data = post(); + + $data['pagare'] = $pagare->id; + $fecha = ['year', 'month', 'day']; + $fecha_arr = array_filter($data, function($item) use ($fecha) { + return (array_search($item, $fecha) !== false); + }, \ARRAY_FILTER_USE_KEY); + uksort($fecha_arr, function($a, $b) use ($fecha) { + return array_search($a, $fecha) - array_search($b, $fecha); + }); + foreach ($fecha as $f) { + unset($data[$f]); + } + array_walk($fecha_arr, function(&$item) { + if (strlen($item) < 4) { + $item = str_pad($item, 2, '0', \STR_PAD_LEFT); + } + }); + $data['fecha'] = implode('-', $fecha_arr); + + foreach ($fecha as &$key) { + $key .= '_banco'; + } + $fecha_arr = array_filter($data, function($item) use ($fecha) { + return (array_search($item, $fecha) !== false); + }, \ARRAY_FILTER_USE_KEY); + uksort($fecha_arr, function($a, $b) use ($fecha) { + return array_search($a, $fecha) - array_search($b, $fecha); + }); + foreach ($fecha as $f) { + unset($data[$f]); + } + array_walk($fecha_arr, function(&$item) { + if (strlen($item) < 4) { + $item = str_pad($item, 2, '0', \STR_PAD_LEFT); + } + }); + $data['fecha_banco'] = implode('-', $fecha_arr); + + $renovacion = model(RenovacionPagare::class)->create($data); + $renovacion->save(); + + header('Location: ' . nUrl('pagares', 'show', ['pagare' => $renovacion->pagare])); + } +} diff --git a/resources/less/Controller/Pagos.php b/resources/less/Controller/Pagos.php new file mode 100644 index 0000000..f279b9e --- /dev/null +++ b/resources/less/Controller/Pagos.php @@ -0,0 +1,358 @@ +findOne($id); + $tipos = model(TipoPago::class)->orderByAsc('descripcion')->findMany(); + $estados = model(TipoEstadoPago::class)->orderByAsc('descripcion')->findMany(); + + return view('ventas.pagos.edit', compact('pago', 'asociado', 'id_asociado', 'tipos', 'estados')); + } + public static function editar() + { + $id = get('pago'); + $pago = model(Pago::class)->findOne($id); + + $fp = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $tipo = model(TipoPago::class)->findOne(post('tipo')); + $valor = correctNumber(post('valor')); + $banco = model(Banco::class)->where('nombre', post('banco'))->findOne(); + + $fe = Carbon::createFromDate(post('yearestado'), post('monthestado'), post('dayestado'), config('app.timezone')); + $estado = model(TipoEstadoPago::class)->findOne(post('estado')); + $uf = uf($fe); + + $est = $pago->estado(); + if ($est->fecha != $fe->format('Y-m-d')) { + $est->fecha = $fe->format('Y-m-d'); + $pago->uf = $uf->uf->value; + } + if ($est->estado != $estado->id) { + $est->estado = $estado->id; + } + + if ($pago->fecha != $fp->format('Y-m-d')) { + $pago->fecha = $fp->format('Y-m-d'); + } + if ($pago->tipo != $tipo->id) { + $pago->tipo = $tipo->id; + } + if ($pago->valor != $valor) { + $pago->valor = $valor; + } + if ($pago->identificador != post('identificador')) { + $pago->identificador = post('identificador'); + } + if ($pago->pagador != post('pagador')) { + $pago->pagador = post('pagador'); + } + if ($pago->banco != $banco->id) { + $pago->banco = $banco->id; + } + + $est->save(); + $pago->save(); + header('Location: ' . url('', ['p' => get('asociado') . 's', 'a' => 'show', get('asociado') => get(get('asociado'))])); + } + public static function pendientes() + { + $ventas = model(Venta::class) + ->select('venta.*') + ->rawJoin('JOIN (SELECT e1.* FROM estado_venta e1 JOIN (SELECT venta, MAX(id) AS id FROM estado_venta GROUP BY venta) e0 ON e0.id = e1.id)', ['ev.venta', '=', 'venta.id'], 'ev') + ->join('tipo_estado_venta', ['te.id', '=', 'ev.estado'], 'te') + ->join('propiedad', ['propiedad.id', '=', 'venta.propiedad']) + ->join('unidad', ['unidad.id', '=', 'propiedad.unidad_principal']) + ->join('proyecto', ['proyecto.id', '=', 'unidad.proyecto']) + ->where('te.activa', 1) + ->orderByAsc('proyecto.descripcion') + ->orderByExpr('LPAD(unidad.descripcion, 4, "0")') + ->findMany(); + $n = 30; + $mod = floor(count($ventas) / $n); + $i_rest = count($ventas) - count($ventas) % $mod + 1; + $rest = count($ventas) - $i_rest; + $lots = (object) ['size' => $mod, 'N' => $n, 'rest' => (object) [ + 'size' => $rest, + 'start' => $i_rest + ] + ]; + return view('ventas.pagos.pendientes', compact('ventas', 'lots')); + } + public static function para_pendientes() + { + $timezone = config('app.timezone'); + $today = Carbon::today($timezone); + $days = []; + $fechas = []; + for ($i = $today->copy()->subDays(15); $i <= $today->copy()->addDays(15); $i = $i->copy()->addDay()) { + $days []= $i->format('Y-m-d'); + $fechas []= $i->format('d-m-Y'); + } + $pagos_pendientes = model(Pago::class) + ->select('estado_pago.fecha') + ->selectExpr('COUNT(pago.id)', 'cantidad') + ->join('cuota', ['cuota.pago', '=', 'pago.id']) + ->join('venta', ['venta.pie', '=', 'cuota.pie']) + ->filter('filterEstado') + ->where('estado_pago.estado', 0) + ->where('venta.estado', 1) + ->whereGte('estado_pago.fecha', $today->copy()->subDays(15)->format('Y-m-d')) + ->whereLte('estado_pago.fecha', $today->copy()->addDays(15)->format('Y-m-d')) + ->orderByAsc('estado_pago.fecha') + ->groupBy('estado_pago.fecha') + ->findMany(); + $valores = array_fill(0, count($days), 0); + $anteriores = model(Pago::class) + ->join('cuota', ['cuota.pago', '=', 'pago.id']) + ->join('venta', ['venta.pie', '=', 'cuota.pie']) + ->filter('filterEstado') + ->where('estado_pago.estado', 0) + ->where('venta.estado', 1) + ->whereLt('estado_pago.fecha', $today->copy()->subDays(15)->format('Y-m-d')) + ->count(); + foreach ($pagos_pendientes as $pago) { + $valores[array_search($pago->fecha()->format('Y-m-d'), $days)] = $pago->cantidad; + } + $acum = []; + $sum = 0; + foreach ($valores as $valor) { + $sum += $valor; + $acum []= $sum; + } + $t = array_search($today->format('Y-m-d'), $days); + $color = array_merge( + array_fill(0, $t, 'red'), + ['blue'], + array_fill(0, count($days) - $t, 'green') + ); + $pagos = ['data' => $acum, 'historico' => $anteriores, 'backgroundColor' => $color]; + $abonos_pendientes = model(Pago::class) + ->select('estado_pago.fecha') + ->selectExpr('COUNT(pago.id)', 'cantidad') + ->filter('filterEstado') + ->where('estado_pago.estado', 1) + ->whereGte('estado_pago.fecha', $today->copy()->subDays(15)->format('Y-m-d')) + ->whereLt('estado_pago.fecha', $today->copy()->format('Y-m-d')) + ->orderByAsc('estado_pago.fecha') + ->groupBy('estado_pago.fecha') + ->findMany(); + $anteriores = model(Pago::class) + ->join('cuota', ['cuota.pago', '=', 'pago.id']) + ->join('venta', ['venta.pie', '=', 'cuota.pie']) + ->filter('filterEstado') + ->where('estado_pago.estado', 1) + ->where('venta.estado', 1) + ->whereLt('estado_pago.fecha', $today->copy()->subDays(15)->format('Y-m-d')) + ->count(); + $valores = array_fill(0, count($days), 0); + foreach ($abonos_pendientes as $pago) { + $valores[array_search($pago->fecha()->format('Y-m-d'), $days)] = $pago->cantidad; + } + $acum = []; + $sum = 0; + foreach ($valores as $valor) { + $sum += $valor; + $acum []= $sum; + } + $color = array_fill(0, count($pagos), 'rgb(200, 0, 0)'); + $abonos = ['data' => $acum, 'historico' => $anteriores, 'backgroundColor' => $color]; + $output = ['count' => count($days), 'fechas' => $fechas, 'pagos' => $pagos, 'abonos' => $abonos]; + echo json_encode($output); + } + public static function para_abonar() + { + $ids = json_decode(post('ids')); + //$id = get('id'); + function checkPago(&$pagos, $tipo, $pago) { + if (!$pago) { + return; + } + if (!$pago->estado()) { + $pagos []= [ + 'tipo' => $tipo, + 'pago' => $pago->asArray(), + 'estado' => -1 + ]; + return; + } + if ($pago->estado()->tipo()->descripcion == 'depositado') { + $pagos []= [ + 'tipo' => $tipo, + 'pago' => $pago->asArray(), + 'fecha' => format('shortDate', $pago->estado()->fecha), + 'valor' => format('pesos', $pago->valor, true), + 'estado' => 1 + ]; + } + } + $output = []; + foreach ($ids as $id) { + $venta = model(Venta::class)->findOne($id); + if ($venta->estado()->tipo()->activa == 0) { + $output []= ['status' => -1, 'venta' => $venta->id]; + continue; + } + $pagos = []; + if ($venta->pie()) { + foreach ($venta->pie()->cuotas() as $cuota) { + checkPago($pagos, 'Pie', $cuota->pago()); + } + if ($venta->pie()->reajuste()) { + checkPago($pagos, 'Reajuste', $venta->pie()->reajuste()); + } + } + if ($venta->credito()) { + checkPago($pagos, 'Credito', $venta->credito()->pago()); + } + if ($venta->escritura()) { + checkPago($pagos, 'Abono Escritura', $venta->escritura()->pago()); + } + if ($venta->subsidio()) { + checkPago($pagos, 'Subsidio', $venta->subsidio()->subsidio()); + checkPago($pagos, 'Ahorro', $venta->subsidio()->pago()); + } + if (count($pagos) <= 0) { + $output []= ['status' => -1, 'venta' => $venta->id]; + continue; + } + $output []= [ + 'status' => 1, + 'proyecto' => $venta->proyecto()->descripcion, + 'venta' => $venta->id, + 'propietario' => $venta->propietario()->nombreCompleto(), + 'departamento' => $venta->unidad()->descripcion, + 'pagos' => $pagos + ]; + } + return json_encode($output); + } + public static function rebotes() + { + $ids = json_decode(post('ids')); + $response = []; + foreach ($ids as $id) { + //$id = get('id'); + $venta = model(Venta::class)->findOne($id); + $rebotes = $venta->pagos(-1); + if (count($rebotes) < 1) { + $response []= ['status' => -1, 'venta' => $venta->id]; + continue; + } + usort($rebotes, function($a, $b) { + return $b->estado()->fecha()->diffInDays($a->estado()->fecha(), false); + }); + + $output = []; + $textos = []; + foreach ($rebotes as $rebote) { + $fuente = $rebote->fuente()[0]; + $text = '' . ucwords(str_replace('_', ' ', $fuente->tipo)) . ''; + $info = ['tipo' => ucwords(str_replace('_', ' ', $fuente->tipo))]; + switch ($fuente->tipo) { + case('cuota'): + $text .= '' . $fuente->obj->pie()->venta()->proyecto()->descripcion + . '' . $fuente->obj->pie()->venta()->unidad()->descripcion . '' + . $fuente->obj->pie()->venta()->propietario()->nombreCompleto() + . '' . format('shortDate', $rebote->estado()->fecha) . ''; + $info['proyecto'] = $fuente->obj->pie()->venta()->proyecto()->descripcion; + $info['venta'] = $fuente->obj->pie()->venta()->id; + $info['departamento'] = $fuente->obj->pie()->venta()->unidad()->descripcion; + $info['propietario'] = $fuente->obj->pie()->venta()->propietario()->nombreCompleto(); + $info['fecha'] = format('shortDate', $rebote->estado()->fecha); + break; + } + $text .= '' . format('pesos', $rebote->valor('pesos'), true) . ''; + $info['valor'] = format('pesos', $rebote->valor('pesos'), true); + $output []= array_merge(['id' => $rebote->id], $info); + $textos []= ['id' => $rebote->id, 'text' => $text]; + } + $response []= ['status' => 1, 'venta' => $venta->id, 'textos' => $textos, 'rebotes' => $output]; + } + + return json_encode($response); + } + public static function show() + { + $id = get('pago'); + $asociado = get('asociado'); + $id_asociado = get($asociado); + + $pago = model(Pago::class)->findOne($id); + + return view('ventas.pagos.show', compact('pago', 'asociado', 'id_asociado')); + } + public static function pagar() + { + $id = get('pago'); + $pago = model(Pago::class)->findOne($id); + $asociado = get('asociado'); + $id_asociado = get($asociado); + + return view('ventas.pagos.pagar', compact('pago', 'asociado', 'id_asociado')); + } + public static function pagando() + { + $id = get('pago'); + $pago = model(Pago::class)->findOne($id); + $asociado = get('asociado'); + $id_asociado = get($asociado); + + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $data = [ + 'fecha' => $f->format('Y-m-d'), + 'pago' => $pago->id, + 'estado' => 1 + ]; + $estado = model(EstadoPago::class)->create($data); + + $estado->save(); + header('Location: ' . url('', ['p' => $asociado . 's', 'a' => 'show', $asociado => $id_asociado])); + } + public static function abonar() + { + $id = get('pago'); + $pago = model(Pago::class)->findOne($id); + $asociado = get('asociado'); + $id_asociado = get($asociado); + + return view('ventas.pagos.abonar', compact('pago', 'asociado', 'id_asociado')); + } + public static function abonando() + { + $id = get('pago'); + $pago = model(Pago::class)->findOne($id); + $asociado = get('asociado'); + $id_asociado = get($asociado); + + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $data = [ + 'fecha' => $f->format('Y-m-d'), + 'pago' => $pago->id, + 'estado' => 2 + ]; + $estado = model(EstadoPago::class)->create($data); + + $estado->save(); + header('Location: ' . url('', ['p' => $asociado . 's', 'a' => 'show', $asociado => $id_asociado])); + } +} +?> diff --git a/resources/less/Controller/Pies.php b/resources/less/Controller/Pies.php new file mode 100644 index 0000000..38c2fcb --- /dev/null +++ b/resources/less/Controller/Pies.php @@ -0,0 +1,104 @@ +findOne($proyecto); + $ventas = $proyecto->ventas(); + self::sort($ventas); + return view('ventas.list', compact('proyecto', 'ventas')); + } + public static function listProyectos() + { + $proyectos = \Model::factory(Proyecto::class) + ->select('proyecto.*') + ->join('estado_proyecto', ['estado.proyecto', '=', 'proyecto.id'], 'estado') + ->join('tipo_estado_proyecto', ['tipo.id', '=', 'estado.estado'], 'tipo') + ->join('etapa_proyecto', ['etapa.id', '=', 'tipo.etapa'], 'etapa') + ->whereGte('etapa.orden', 4) + ->groupBy('proyecto.id') + ->findMany(); + echo view('ventas.proyectos', compact('proyectos')); + } + public static function resumen() + { + $id = get('pie'); + $pie = \Model::factory(\Incoviba\old\Venta\Pie::class)->findOne($id); + $venta = $pie->venta(); + return view('ventas.pies.resumen', compact('venta')); + } + public static function reajustar() + { + $id = get('venta'); + $venta = \Model::factory(Venta::class)->findOne($id); + return view('ventas.pies.reajustar', compact('venta')); + } + public static function reajuste() + { + $id = get('venta'); + $venta = \Model::factory(Venta::class)->findOne($id); + + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $pago = \Model::factory(Pago::class)->create(); + $pago->fecha = $f->format('Y-m-d'); + $pago->uf = (float) uf($f)->uf->value; + $pago->valor = str_replace('.', '', post('valor')); + + $pago->new(); + + $pie = $venta->pie(); + $pie->reajuste = $pago->id; + $pie->save(); + header('Location: ' . url('', ['p' => 'ventas', 'a' => 'show', 'venta' => $venta->id])); + } + public static function edit() + { + $id = get('venta'); + $venta = \Model::factory(Venta::class)->findOne($id); + return view('ventas.pies.edit', compact('venta')); + } + public static function editar() + { + $id = get('venta'); + $venta = \Model::factory(Venta::class)->findOne($id); + $pie = $venta->pie(); + $valor = correctNumber(post('valor')); + if ($pie->valor != $valor) { + $pie->valor = $valor; + } + if ($pie->cuotas != post('cuotas')) { + $pie->cuotas = post('cuotas'); + } + + $pie->save(); + header('Location: ' . url('', ['p' => 'ventas', 'a' => 'show', 'venta' => $venta->id])); + } + public static function asociar() + { + $id = get('pie'); + $pie = \Model::factory(Pie::class)->findOne($id); + $pie->asociado = post('asociado'); + + $pie->save(); + header('Location: ' . url('', ['p' => 'ventas', 'a' => 'show', 'venta' => $pie->venta()->id])); + } +} +?> diff --git a/resources/less/Controller/Postventas.php b/resources/less/Controller/Postventas.php new file mode 100644 index 0000000..7b38cb6 --- /dev/null +++ b/resources/less/Controller/Postventas.php @@ -0,0 +1,69 @@ +findOne($id); + + return view('ventas.postventas.add', compact('venta')); + } + public static function agregar() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $observaciones = json_decode(post('observaciones')); + $postventa = model(Postventa::class)->create(); + $postventa->venta_id = $venta->id; + $postventa->save(); + + $estado = model(EstadoPostventa::class)->create(); + $estado->postventa_id = $postventa->id; + $estado->tipo_estado_postventa_id = 1; + $estado->fecha = $f->format('Y-m-d'); + $estado->save(); + + foreach ($observaciones as $o) { + $observacion = model(Observacion::class)->create(); + $observacion->texto = post('observacion' . $o); + + $observacion->save(); + + $estado = model(EstadoObservacion::class)->create(); + $estado->observacion_id = $observacion->id; + $estado->tipo_estado_observacion_id = 1; + $estado->fecha = $f->format('Y-m-d'); + $estado->save(); + + $po = model(PostventaObservacion::class)->create(); + $po->postventa_id = $postventa->id; + $po->observacion_id = $observacion->id; + $po->save(); + } + header('Location: ' . url('', ['p' => 'ventas', 'a' => 'show', 'venta' => $venta->id])); + } + public static function show() + { + $id = get('postventa'); + $postventa = model(Postventa::class)->findOne($id); + $venta = model(Venta::class)->findOne($postventa->venta_id); + + return view('ventas.postventas.show', compact('postventa', 'venta')); + } +} +?> diff --git a/resources/less/Controller/Precios.php b/resources/less/Controller/Precios.php new file mode 100644 index 0000000..6975b73 --- /dev/null +++ b/resources/less/Controller/Precios.php @@ -0,0 +1,166 @@ +orderByAsc('descripcion')->findMany(); + return view('ventas.precios.proyectos', compact('proyectos')); + } + public static function list() + { + $proyecto = \model(Proyecto::class)->findOne(get('proyecto')); + return view('ventas.precios.list', compact('proyecto')); + } + public static function import() + { + $proyectos = \model(Proyecto::class)->orderByAsc('descripcion')->findMany(); + return view('ventas.precios.import', compact('proyectos')); + } + public static function importar() + { + $proyecto = \model(Proyecto::class)->findOne(post('proyecto')); + $fecha = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $file = explode(PHP_EOL, trim(file_get_contents($_FILES['archivo']['tmp_name']))); + $columnas = explode(';', array_shift($file)); + $tr = model(TipoEstadoPrecio::class)->where('descripcion', 'reemplazado')->findOne()->id; + $tv = model(TipoEstadoPrecio::class)->where('descripcion', 'vigente')->findOne()->id; + foreach ($file as $line) { + if (trim($line) == '') { + continue; + } + $info = explode(';', $line); + $tipo = \model(TipoUnidad::class)->where('descripcion', $info[0])->findOne(); + $unidad = \model(Unidad::class)->where('tipo', $tipo->id)->where('descripcion', $info[1])->where('proyecto', $proyecto->id)->findOne(); + + self::reemplazar($unidad->id, $info[2], $fecha, $tr, $tv); + } + header('Location: ' . nUrl('precios', 'list', ['proyecto' => $proyecto->id])); + } + public static function add() + { + $proyecto = \model(Proyecto::class)->findOne(get('proyecto')); + return view('ventas.precios.add', compact('proyecto')); + } + public static function agregar() + { + $proyecto = get('proyecto'); + $fecha = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $precios = []; + foreach (post() as $name => $valor) { + if ($valor == '' or strpos($name, 'precio') === false) { + continue; + } + list($tipo, $id) = explode(':', $name); + $tipo = trim(str_replace('precio', '', $tipo), '_'); + $id = explode('-', $id); + switch (count($id)) { + case 1: + $precios []= ['tipo' => 'pt', 'id' => $id[0], 'valor' => $valor]; + break; + case 2: + $exists = false; + foreach ($precios as $precio) { + if ($precio['tipo'] == 'pt' and $precio['id'] == $id[0]) { + $exists = true; + break; + } + } + if (!$exists) { + $precios []= ['tipo' => 'subtipo', 'id' => $id[1], 'pt' => $id[0], 'valor' => $valor]; + } + break; + case 3: + $exists = false; + foreach ($precios as $precio) { + if ($precio['tipo'] == 'pt' and $precio['id'] == $id[0]) { + $exists = true; + break; + } + if ($precio['tipo'] == 'subtipo' and 'id' == $id[1] and 'pt' == $id[0]) { + $exists = true; + break; + } + } + if (!$exists) { + $precios []= ['tipo' => 'unidad', 'id' => $id[2], 'valor' => $valor]; + } + break; + } + } + foreach ($precios as $precio) { + $precio = (object) $precio; + switch ($precio->tipo) { + case 'pt': + $pt = model(ProyectoTipoUnidad::class)->findOne($precio->id); + $pt->setPrecios($fecha, $precio->valor); + break; + case 'subtipo': + $pt = model(ProyectoTipoUnidad::class)->findOne($precio->pt); + $pt->setPreciosSubtipo($precios->id, $fecha, $precio->valor); + break; + case 'unidad': + $unidad = model(Unidad::class)->findOne($precio->id); + $unidad->setPrecio($fecha, $precio->valor); + break; + } + } + header('Location: ' . nUrl('precios', 'list', ['proyecto' => $proyecto])); + } + protected static function reemplazar(int $unidad_id, float $valor, \DateTime $fecha, int $tr = 0, int $tv = 0) + { + if ($tr == 0) { + $tr = model(TipoEstadoPrecio::class)->where('descripcion', 'reemplazado')->findOne()->id; + } + if ($tv == 0) { + $tv = model(TipoEstadoPrecio::class)->where('descripcion', 'vigente')->findOne()->id; + } + $olds = \model(Precio::class)->where('unidad', $unidad_id)->findMany(); + if ($olds !== false) { + foreach ($olds as $old) { + if (!$old->vigente()) { + continue; + } + $data = [ + 'precio' => $old->id, + 'fecha' => $fecha->format('Y-m-d'), + 'estado' => $tr + ]; + $estado = \model(EstadoPrecio::class)->create($data); + $estado->save(); + } + } + $data = [ + 'unidad' => $unidad_id, + 'valor' => $valor + ]; + $precio = (new Factory(Precio::class))->where($data)->find(); + if (!$precio) { + $precio = \model(Precio::class)->create($data); + $precio->save(); + } + $data = [ + 'precio' => $precio->id, + 'fecha' => $fecha->format('Y-m-d'), + 'estado' => $tv + ]; + $estado = \model(EstadoPrecio::class)->create($data); + $estado->save(); + } +} diff --git a/resources/less/Controller/Propietarios.php b/resources/less/Controller/Propietarios.php new file mode 100644 index 0000000..5d38ee7 --- /dev/null +++ b/resources/less/Controller/Propietarios.php @@ -0,0 +1,129 @@ +findOne($id); + $propietario = $venta->propietario(); + $regiones = model(Region::class)->orderByAsc('numeracion')->findMany(); + + return view('ventas.propietarios.edit', compact('venta', 'propietario', 'regiones')); + } + public static function editar() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + + $info = post(); + list($info['rut'], $info['dv']) = explode('-', str_replace('.', '', $info['rut'])); + $propietario = model(Propietario::class)->findOne($info['rut']); + if (!$propietario) { + $propietario = model(Propietario::class)->create(); + } + if ($propietario->direccion != 0) { + $direccion = $propietario->direccion(); + } else { + $direccion = model(Direccion::class) + ->where('calle', post('calle')) + ->where('numero', post('numero')) + ->where('extra', post('extra')) + ->where('comuna', post('comuna')) + ->findOne(); + if (!$direccion) { + $data = [ + 'calle' => post('calle'), + 'numero' => post('numero'), + 'extra' => post('extra'), + 'comuna' => post('comuna') + ]; + $direccion = model(Direccion::class)->create($data); + } + } + + if (isset($info['empresa'])) { + $info['apellido_paterno'] = ''; + $info['apellido_materno'] = ''; + } + + if ($propietario->representante != 0) { + list($info['rep_rut'], $info['rep_dv']) = explode('-', str_replace('.', '', $info['rep_rut'])); + $representante = $propietario->representante(); + } elseif (isset($info['rep_rut'])) { + list($info['rep_rut'], $info['rep_dv']) = explode('-', str_replace('.', '', $info['rep_rut'])); + $representante= model(Propietario::class)->findOne($info['rep_rut']); + if (!$representante) { + $representante= model(Propietario::class)->create(); + } + } + + $fields = ['rut', 'dv', 'nombres', 'apellido_paterno', 'apellido_materno']; + $change = false; + foreach ($fields as $key) { + if ($propietario->$key != $info[$key]) { + $propietario->$key = $info[$key]; + $change = true; + } + } + if ($direccion->isNew()) { + $direccion->save(); + } + if ($propietario->direccion != $direccion->id) { + $propietario->direccion = $direccion->id; + $change = true; + } + if ($change) { + d($propietario); + $propietario->save(); + } + + if (isset($info['rep_rut'])) { + $change = false; + if ($representante->rut != $info['rep_rut']) { + $representante->rut = $info['rep_rut']; + $representante->dv = $info['rep_dv']; + $change = true; + } + if ($representante->nombres != $info['rep_nombres']) { + $representante->nombres = $info['rep_nombres']; + $change = true; + } + if ($representante->apellido_paterno != $info['rep_apaterno']) { + $representante->apellido_paterno = $info['rep_apaterno']; + $change = true; + } + if ($representante->apellido_materno != $info['rep_amaterno']) { + $representante->apellido_materno = $info['rep_amaterno']; + $change = true; + } + if ($representante->direccion != $direccion->id) { + $representante->direccion = $direccion->id; + $change = true; + } + if ($change) { + $representante->save(); + } + if ($propietario->representante != $representante->rut) { + $propietario->representante = $representante->rut; + $propietario->save(); + } + } + + if ($venta->propietario != $propietario->rut) { + $venta->propietario = $propietario->rut; + $venta->save(); + } + header('Location: ' . url('', ['p' => 'ventas', 'a' => 'show', 'venta' => $venta->id])); + } +} +?> diff --git a/resources/less/Controller/ProyectoTipoUnidades.php b/resources/less/Controller/ProyectoTipoUnidades.php new file mode 100644 index 0000000..32c0c1d --- /dev/null +++ b/resources/less/Controller/ProyectoTipoUnidades.php @@ -0,0 +1,77 @@ +findOne($id); + $tipos = model(TipoUnidad::class)->findMany(); + + return view('proyectos.tipo_unidades.edit', compact('tipo', 'tipos')); + } + public static function editar() + { + $id = get('tipo_unidad'); + $tipo = model(ProyectoTipoUnidad::class)->findOne($id); + + $changed = false; + foreach (post() as $field => $value) { + if ($tipo->{$field} != $value) { + $tipo->{$field} = $value; + $changed = true; + } + } + if ($changed) { + $tipo->save(); + } + header('Location: ' . nUrl('proyectos', 'list_unidades', ['proyecto' => $tipo->proyecto()->id])); + } + public static function add_unidad() + { + $id = get('tipo_unidad'); + $tipo = model(ProyectoTipoUnidad::class)->findOne($id); + if ($tipo->tipo()->descripcion == 'departamento') { + return view('proyectos.unidades.add', compact('tipo')); + } + return view('proyectos.unidades.add2', compact('tipo')); + } + public static function assign() + { + $id = get('proyecto'); + $proyecto = model(Proyecto::class)->findOne($id); + $tipos = model(ProyectoTipoUnidad::class)->where('proyecto', $proyecto->id)->findMany(); + $libres = model(Unidad::class)->where('proyecto', $proyecto->id)->where('pt', 0)->findMany(); + + return view('proyectos.unidades.assign', compact('proyecto', 'tipos', 'libres')); + } + public static function asignar() + { + $id = get('proyecto'); + $proyecto = model(Proyecto::class)->findOne($id); + + $libres = model(Unidad::class)->where('proyecto', $proyecto->id)->where('pt', 0)->findMany(); + foreach ($libres as $unidad) { + $unidad->pt = post('tipo' . $unidad->id); + $unidad->save(); + } + header('Location: ' . nUrl('proyectos', 'list_unidades', ['proyecto' => $proyecto->id])); + } +} diff --git a/resources/less/Controller/Proyectos.php b/resources/less/Controller/Proyectos.php new file mode 100644 index 0000000..f6a4e45 --- /dev/null +++ b/resources/less/Controller/Proyectos.php @@ -0,0 +1,327 @@ +where('inmobiliaria', $id_inmobiliaria); + } else { + $proyectos = model(Proyecto::class); + } + $proyectos = $proyectos->order_by_asc('descripcion')->findMany(); + return view('proyectos.list', compact('proyectos')); + } + public static function show() + { + $id_proyecto = get('proyecto'); + if ($id_proyecto == null) { + header('Location: ' . url('', ['p' => 'proyectos', 'a' => 'list'])); + } + $proyecto = model(Proyecto::class)->findOne($id_proyecto); + $estados = model(TipoEstadoProyecto::class)->findMany(); + foreach ($estados as &$estado) { + $estado = $estado->asArray()['orden'] + 1; + } + $colors = []; + + $ventas_pt = (object) ['fields' => [], 'data' => [], 'totales' => [], 'vendidas' => []]; + $ventas = $proyecto->ventas('fecha'); + $months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + if (count($ventas) > 0) { + $inicio = $ventas[0]->fecha()->format('Y'); + $fin = $ventas[count($ventas) - 1]->fecha()->format('Y'); + $end = $ventas[count($ventas) - 1]->fecha()->format('M'); + for ($y = $inicio; $y <= $fin; $y ++) { + foreach ($months as $month) { + $ventas_pt->fields []= $y . ' ' . $month; + if ($y == $fin and $month == $end) { + break; + } + } + } + } + + foreach ($proyecto->tipologias() as $tipo) { + if (!isset($ventas_pt->data[$tipo->tipologia->descripcion])) { + $ventas_pt->data[$tipo->tipologia->descripcion] = []; + $ventas_pt->data[$tipo->tipologia->descripcion] = array_fill(0, count($ventas_pt->fields), 0); + $ventas_pt->totales[$tipo->tipologia->descripcion] = 0; + $ventas_pt->vendidas[$tipo->tipologia->descripcion] = 0; + } + foreach ($tipo->tipos as $pt) { + foreach ($pt->ventas('fecha') as $venta) { + $ventas_pt->data[$tipo->tipologia->descripcion][array_search($venta->fecha()->format('Y M'), $ventas_pt->fields)] ++; + $ventas_pt->vendidas[$tipo->tipologia->descripcion] ++; + } + $ventas_pt->totales[$tipo->tipologia->descripcion] += count($pt->unidades()); + } + } + foreach ($ventas_pt->data as $tipo => $data) { + $acum = 0; + foreach ($data as $i => $cantidad) { + $acum += $cantidad; + $ventas_pt->data[$tipo][$i] = round($acum / $ventas_pt->totales[$tipo] * 100, 2); + } + } + $meses = ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic']; + array_walk($ventas_pt->fields, function(&$item) use ($meses, $months) { + $item = str_replace($months, $meses, $item); + }); + + for ($i = 0; $i < 10; $i ++) { + $colors[$i] = 'rgb(' . mt_rand(0, 255) . ', ' . mt_rand(0, 255) . ', ' . mt_rand(0, 255) . ')'; + } + return view('proyectos.show', compact('proyecto', 'estados', 'colors', 'ventas_pt')); + } + public static function historial() + { + $proyecto = model(Proyecto::class)->findOne(get('proyecto')); + return view('proyectos.historia', compact('proyecto')); + } + public static function advance() + { + $id_proyecto = get('proyecto'); + $proyecto = model(Proyecto::class)->findOne($id_proyecto); + $estados = model(TipoEstadoProyecto::class)->whereGt('orden', $proyecto->estado()->tipo()->orden)->orderByAsc('orden')->findMany(); + + return view('proyectos.advance', compact('proyecto', 'estados')); + } + public static function avanzar() + { + $id_proyecto = get('proyecto'); + $proyecto = model(Proyecto::class)->findOne($id_proyecto); + $id_tipo = post('estado'); + $tipo = model(TipoEstadoProyecto::class)->findOne($id_tipo); + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + + $tipos = model(TipoEstadoProyecto::class) + ->whereGt('orden', $proyecto->estado()->tipo()->orden) + ->whereLte('orden', $tipo->orden) + ->orderByAsc('orden') + ->findMany(); + + foreach ($tipos as $t) { + $estado = model(EstadoProyecto::class)->create(); + $estado->proyecto = $proyecto->id; + $estado->estado = $t->id; + $estado->fecha = $f->format('Y-m-d'); + $estado->save(); + } + header('Location: ' . url('', ['p' => 'proyectos', 'a' => 'show', 'proyecto' => $proyecto->id])); + } + public static function avance() + { + $id = get('proyecto'); + $proyecto = model(Proyecto::class)->findOne($id); + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $av = post('avance') / 100; + $ep = (double) post('estado_pago'); + $avance = model(AvanceConstruccion::class) + ->where('proyecto', $proyecto->id) + ->where('fecha', $f->format('Y-m-d')) + ->findOne(); + if (!$avance) { + $data = [ + 'proyecto' => $proyecto->id, + 'fecha' => $f->format('Y-m-d'), + 'numero' => post('numero'), + 'avance' => $av, + 'estado_pago' => $ep + ]; + $avance = model(AvanceConstruccion::class)->create($data); + } + $avance->save(); + header('Location: ' . url('', ['p' => 'proyectos', 'a' => 'historial', 'proyecto' => $proyecto->id])); + } + public static function add() + { + $rut = get('inmobiliaria'); + + $inmobiliarias = model(Inmobiliaria::class)->orderByAsc('abreviacion')->findMany(); + $regiones = model(Region::class)->orderByAsc('numeracion')->findMany(); + + return view('proyectos.add', compact('inmobiliarias', 'rut', 'regiones')); + } + public static function agregar() + { + $proyecto = model(Proyecto::class)->where('descripcion', post('descripcion'))->where('inmobiliaria', post('inmobiliaria'))->find_one(); + if ($proyecto) { + header('Location: ' . url('', ['p' => 'proyectos', 'a' => 'show', 'proyecto' => $proyecto->id])); + die(); + } + $proyecto = model(Proyecto::class)->create(); + $proyecto->descripcion = post('descripcion'); + $proyecto->inmobiliaria = post('inmobiliaria'); + + $direccion = model(Direccion::class) + ->where('calle', post('calle')) + ->where('numero', post('numero')) + ->where('extra', post('extra')) + ->where('comuna', post('comuna')) + ->findOne(); + if (!$direccion) { + $direccion = model(Direccion::class)->create(); + $direccion->calle = post('calle'); + $direccion->numero = post('numero'); + $direccion->extra = post('extra'); + $direccion->comuna = post('comuna'); + $direccion->save(); + } + + $proyecto->direccion = $direccion->id; + $proyecto->save(); + + $fecha = Carbon::parse(post('year'), post('month'), post('day'), config('app.timezone')); + $estado = model(EstadoProyecto::class)->create(); + $estado->proyecto = $proyecto->id; + $estado->estado = 1; + $estado->fecha = $fecha->format('Y-m-d'); + $estado->save(); + header('Location: ' . url('', ['p' => 'proyectos', 'a' => 'show', 'proyecto' => $proyecto->id])); + } + public static function disponibles() + { + $id = get('proyecto'); + $proyecto = model(Proyecto::class)->findOne($id); + + return view('proyectos.disponibles', compact('proyecto')); + } + public static function list_unidades() + { + $id = get('proyecto'); + $proyecto = model(Proyecto::class)->findOne($id); + $libres = model(Unidad::class)->where('proyecto', $proyecto->id)->where('pt', 0)->findMany(); + + return view('proyectos.unidades.list', compact('proyecto', 'libres')); + } + public static function add_tipo_unidad() + { + $id = get('proyecto'); + $proyecto = model(Proyecto::class)->findOne($id); + $tipos = model(TipoUnidad::class)->findMany(); + + return view('proyectos.tipo_unidades.add', compact('proyecto', 'tipos')); + } + public static function agregar_tipo_unidad() + { + $id = get('proyecto'); + $proyecto = model(Proyecto::class)->findOne($id); + $data = post(); + $data['proyecto'] = $proyecto->id; + $tipo = model(ProyectoTipoUnidad::class)->where('proyecto', $data['proyecto']) + ->where('tipo', $data['tipo'])->where('nombre', $data['nombre'])->findOne(); + if ($tipo === false) { + $tipo = model(ProyectoTipoUnidad::class)->create($data); + $tipo->save(); + } + header('Location: ' . nUrl('proyectos', 'list_unidades', ['proyecto' => $proyecto->id])); + } + public static function construccion() + { + $id = get('proyecto'); + $proyecto = model(Proyecto::class)->findOne($id); + return view('proyectos.construccion', compact('proyecto')); + } + public static function editar_avance() + { + $avance = model(AvanceConstruccion::class)->findOne(get('avance')); + return view('proyectos.avances.edit', compact('avance')); + } + public static function edit_avance() + { + $avance = model(AvanceConstruccion::class)->findOne(get('avance')); + $cols = [ + 'day', + 'month', + 'year', + 'avance', + 'estado_pago', + 'pagado', + 'day_pago', + 'month_pago', + 'year_pago' + ]; + $data = array_filter(post(), function($key) use ($cols) { + return (array_search($key, $cols) !== false); + }, \ARRAY_FILTER_USE_KEY); + $data['fecha'] = implode('-', [$data['year'], $data['month'], $data['day']]); + unset($data['year']); + unset($data['month']); + unset($data['day']); + $data['fecha_pagado'] = implode('-', [$data['year_pago'], $data['month_pago'], $data['day_pago']]); + unset($data['year_pago']); + unset($data['month_pago']); + unset($data['day_pago']); + $data['avance'] /= 100; + $avance->edit($data); + + header('Location: ' . nUrl('proyectos', 'construccion', ['proyecto' => $avance->proyecto])); + } + public static function reservas() + { + $proyecto = model(Proyecto::class)->findOne(get('proyecto')); + $pisos = []; + $totales = []; + foreach ($proyecto->unidades('departamento') as $unidad) { + if (!isset($pisos[$unidad->piso - 1])) { + $piso = (object) ['descripcion' => $unidad->piso, 'unidades' => []]; + $pisos[$unidad->piso - 1] = $piso; + } + if (!isset($totales[$unidad->linea()])) { + $totales[$unidad->linea()] = (object) ['ventas' => 0, 'reservas' => 0]; + } + $pisos[$unidad->piso - 1]->unidades[$unidad->linea()] = $unidad; + if ($unidad->isVendida()) { + $totales[$unidad->linea()]->ventas ++; + } + if ($unidad->isReservada()) { + $totales[$unidad->linea()]->reservas ++; + } + } + ksort($pisos); + $max_unidades = 0; + foreach ($pisos as $piso) { + if (count($piso->unidades) > $max_unidades) { + $max_unidades = count($piso->unidades); + } + } + return view('proyectos.reservas.base', compact('proyecto', 'pisos', 'max_unidades', 'totales')); + } + public function unidades() + { + if (get('proyecto')) { + $proyecto = model(Proyecto::class)->findOne(get('proyecto')); + $libres = model(Unidad::class)->where('proyecto', $proyecto->id)->where('pt', 0)->findMany(); + + return view('proyectos.unidades.list', compact('proyecto', 'libres')); + } + $proyectos = model(Proyecto::class)->order_by_asc('descripcion')->findMany(); + return view('proyectos.unidades.proyectos', compact('proyectos')); + } +} +?> diff --git a/resources/less/Controller/Reajustes.php b/resources/less/Controller/Reajustes.php new file mode 100644 index 0000000..4c6c938 --- /dev/null +++ b/resources/less/Controller/Reajustes.php @@ -0,0 +1,90 @@ +findOne($id); + return view('ventas.pies.reajustes.edit', compact('venta')); + } + public static function editar() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $uf = uf($f); + + $valor = correctNumber(post('valor')); + if ($valor == '') { + $valor_uf = correctNumber(post('valor_uf')); + $valor = $valor_uf * $uf->uf->value; + } + $pago = $venta->pie()->reajuste(); + if ($pago->valor != $valor) { + $pago->valor = $valor; + } + if ($pago->fecha != $f->format('Y-m-d')) { + $pago->fecha = $f->format('Y-m-d'); + $pago->uf = $uf->uf->value; + } + + $pago->save(); + header('Location: ' . url('', ['p' => 'ventas', 'a' => 'show', 'venta' => $venta->id])); + } + public static function pagar() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + + return view('ventas.pies.reajustes.pagar', compact('venta')); + } + public static function pagado() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + + $data = [ + 'pago' => $venta->pie()->reajuste()->id, + 'fecha' => $f->format('Y-m-d'), + 'estado' => 1 + ]; + $estado = model(EstadoPago::class)->create($data); + $estado->save(); + header('Location: ' . url('', ['p' => 'ventas', 'a' => 'show', 'venta' => $venta->id])); + } + public static function abonar() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + + return view('ventas.pies.reajustes.abonar', compact('venta')); + } + public static function abonado() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + + $data = [ + 'pago' => $venta->pie()->reajuste()->id, + 'fecha' => $f->format('Y-m-d'), + 'estado' => 2 + ]; + $estado = model(EstadoPago::class)->create($data); + $estado->save(); + header('Location: ' . url('', ['p' => 'ventas', 'a' => 'show', 'venta' => $venta->id])); + } +} +?> diff --git a/resources/less/Controller/Registros.php b/resources/less/Controller/Registros.php new file mode 100644 index 0000000..546fece --- /dev/null +++ b/resources/less/Controller/Registros.php @@ -0,0 +1,39 @@ +orderByDesc('time')->findMany(); + $ini = new Color(0, 100, 0); + $end = new Color(255, 255, 255); + $colores = self::colores($end, $ini, 100); + return view('admin.registros.list', compact('registros', 'colores')); + } + public static function show() + { + $registro = model(RModel::class)->findOne(get('registro')); + $ini = new Color(0, 100, 0); + $end = new Color(255, 255, 255); + $colores = self::colores($end, $ini, 100); + return view('admin.registros.show', compact('registro', 'colores')); + } + protected static function colores($ini, $end, $max) + { + $current = $ini->toVector(); + $colores = []; + $line = new Line($ini->toVector(), $end->toVector()); + for ($i = 0; $i < $max; $i ++) { + $colores[$i] = new Color($current); + $current = $line->move($current, $line->length() / $max); + } + return $colores; + } +} diff --git a/resources/less/Controller/Subsidios.php b/resources/less/Controller/Subsidios.php new file mode 100644 index 0000000..5107fc3 --- /dev/null +++ b/resources/less/Controller/Subsidios.php @@ -0,0 +1,184 @@ +findOne($id); + echo view('ventas.subsidios.add', compact('venta')); + } + public static function do_add() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $uf = uf($f); + + $pago1 = model(Pago::class)->create(); + $valor = post('ahorro_uf') * $uf->uf->value; + if (post('ahorro') != null) { + $valor = post('ahorro'); + } + $pago1->valor = $valor; + $pago1->fecha = $f->format('Y-m-d'); + $pago1->uf = $uf->uf->value; + + $pago2 = model(Pago::class)->create(); + $valor = post('subsidio_uf') * $uf->uf->value; + if (post('subsidio') != null) { + $valor = post('subsidio'); + } + $pago2->valor = $valor; + $pago2->fecha = $f->format('Y-m-d'); + $pago2->uf = $uf->uf->value; + + $pago1->new(); + $pago2->new(); + + $subsidio = model(Subsidio::class)->create(); + $subsidio->pago = $pago1->id; + $subsidio->subsidio = $pago2->id; + + $subsidio->save(); + $venta->subsidio = $subsidio->id(); + $venta->save(); + header('Location: ' . nUrl('ventas', 'show', ['venta' => $venta->id])); + } + public static function edit() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + echo view('ventas.subsidios.edit', compact('venta')); + } + public static function do_edit() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $uf = uf($f); + + $pago1 = $venta->subsidio()->pago(); + $valor = post('ahorro_uf') * $uf->uf->value; + if (post('ahorro') != null) { + $valor = post('ahorro'); + } + $pago1->valor = $valor; + $pago1->fecha = $f->format('Y-m-d'); + $pago1->uf = $uf->uf->value; + + $pago2 = $venta->subsidio()->subsidio(); + $valor = post('subsidio_uf') * $uf->uf->value; + if (post('subsidio') != null) { + $valor = post('subsidio'); + } + $pago2->valor = $valor; + $pago2->fecha = $f->format('Y-m-d'); + $pago2->uf = $uf->uf->value; + + $pago1->save(); + $pago2->save(); + header('Location: ' . nUrl('ventas', 'show', ['venta' => $venta->id])); + } + public static function pagar() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + $tipo = get('tipo'); + switch($tipo) { + case 'subsidio': + $pago = $venta->subsidio()->subsidio(); + break; + case 'pago': + $pago = $venta->subsidio()->pago(); + break; + default: + $pago = null; + } + echo view('ventas.subsidios.pagar', compact('venta', 'pago')); + } + public static function do_pagar() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $tipo = post('tipo'); + switch($tipo) { + case 'subsidio': + $pago = $venta->subsidio()->subsidio(); + break; + case 'pago': + $pago = $venta->subsidio()->pago(); + break; + default: + $pago = null; + } + $pago->valor = post('valor'); + $tipo = model(TipoEstadoPago::class)->where('descripcion', 'depositado')->findOne(); + $data = [ + 'pago' => $pago->id, + 'fecha' => $f->format('Y-m-d'), + 'estado' => $tipo->id + ]; + $estado = model(EstadoPago::class)->create($data); + $pago->save(); + $estado->save(); + header('Location: ' . nUrl('ventas', 'show', ['venta' => $venta->id])); + } + public static function abonar() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + $tipo = get('tipo'); + switch($tipo) { + case 'subsidio': + $pago = $venta->subsidio()->subsidio(); + break; + case 'pago': + $pago = $venta->subsidio()->pago(); + break; + default: + $pago = null; + } + echo view('ventas.subsidios.abonar', compact('venta', 'pago')); + } + public static function do_abonar() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $tipo = post('tipo'); + switch($tipo) { + case 'subsidio': + $pago = $venta->subsidio()->subsidio(); + break; + case 'pago': + $pago = $venta->subsidio()->pago(); + break; + default: + $pago = null; + } + $pago->valor = post('valor'); + $tipo = model(TipoEstadoPago::class)->where('descripcion', 'abonado')->findOne(); + $data = [ + 'pago' => $pago->id, + 'fecha' => $f->format('Y-m-d'), + 'estado' => $tipo->id + ]; + $estado = model(EstadoPago::class)->create($data); + $pago->save(); + $estado->save(); + header('Location: ' . nUrl('ventas', 'show', ['venta' => $venta->id])); + } +} diff --git a/resources/less/Controller/Temas.php b/resources/less/Controller/Temas.php new file mode 100644 index 0000000..24b121a --- /dev/null +++ b/resources/less/Controller/Temas.php @@ -0,0 +1,111 @@ +orderByAsc('descripcion')->findMany(); + return view('temas.add', compact('proyectos')); + } + public static function agregar() + { + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $data = [ + "proyecto_id" => post('proyecto'), + "inicio" => $f->format('Y-m-d'), + "texto" => post('texto') + ]; + $tema = model(Tema::class)->create($data); + + $tema->save(); + header('Location: ' . url('', ['p' => 'temas', 'a' => 'list'])); + } + public static function list() + { + $temas = model(Tema::class)->findMany(); + $t = Carbon::today(config('app.timezone')); + foreach ($temas as $i => $tema) { + if ($tema->cierre()->year != -1 and $t->diff($tema->cierre())->days > 10) { + unset($temas[$i]); + } + } + $temas = array_values($temas); + usort($temas, function($a, $b) { + $p = strcmp($a->proyecto()->descripcion, $b->proyecto()->descripcion); + if ($p == 0) { + $f = $b->inicio()->diff($a->inicio())->format('%r%a'); + if ($f == 0) { + return $a->id - $b->id; + } + return $f; + } + return $p; + }); + + return view('temas.list', compact('temas')); + } + public static function edit() + { + $id = get('tema'); + $tema = model(Tema::class)->findOne($id); + $proyectos = model(Proyecto::class)->orderByAsc('descripcion')->findMany(); + return view('temas.edit', compact('tema', 'proyectos')); + } + public static function editar() + { + $id = get('tema'); + $tema = model(Tema::class)->findOne($id); + + $proyecto = post('proyecto'); + $changed = false; + if ($tema->proyecto_id != $proyecto) { + $tema->proyecto_id = $proyecto; + $changed = true; + } + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + if ($tema->inicio() != $f) { + $tema->inicio = $f->format('Y-m-d'); + $changed = true; + } + $texto = post('texto'); + if ($tema->texto != $texto) { + $tema->texto = $texto; + $changed = true; + } + + if ($changed) { + $tema->save(); + } + header('Location: ' . url('', ['p' => 'temas', 'a' => 'list'])); + } + public static function cerrar() + { + $id = get('tema'); + $tema = model(Tema::class)->findOne($id); + $f = Carbon::today(config('app.timezone')); + $tema->cierre = $f->format('Y-m-d'); + + $tema->save(); + header('Location: ' . url('', ['p' => 'temas', 'a' => 'list'])); + } + public static function abrir() + { + $id = get('tema'); + $tema = model(Tema::class)->findOne($id)->as_array(); + unset($tema['id'], $tema['cierre'], $tema['created_at'], $tema['updated_at']); + + $tema = model(Tema::class)->create($tema); + + $tema->save(); + header('Location: ' . url('', ['p' => 'temas', 'a' => 'list'])); + } +} +?> diff --git a/resources/less/Controller/Unidades.php b/resources/less/Controller/Unidades.php new file mode 100644 index 0000000..9f0da01 --- /dev/null +++ b/resources/less/Controller/Unidades.php @@ -0,0 +1,126 @@ +findOne($id); + $len = strlen(post('total')); + + $unis = json_decode(post('unidades')); + $data = []; + foreach ($unis as $n_unidad) { + if ($tipo->tipo()->descripcion == 'departamento') { + $ini = post('piso_ini' . $n_unidad); + $end = post('piso_end' . $n_unidad); + $subtipo = post('linea' . $n_unidad); + $orientacion = post('orientacion' . $n_unidad); + for ($piso = $ini; $piso <= $end; $piso ++) { + $descripcion = $piso . str_pad(post('linea' . $n_unidad), $len, '0', \STR_PAD_LEFT); + + $data []= [ + 'proyecto' => $tipo->proyecto()->id, + 'tipo' => $tipo->tipo()->id, + 'subtipo' => $subtipo, + 'piso' => $piso, + 'descripcion' => $descripcion, + 'abreviacion' => $tipo->abreviacion, + 'm2' => $tipo->m2, + 'terraza' => $tipo->terraza, + 'logia' => $tipo->logia, + 'orientacion' => $orientacion, + 'pt' => $tipo->id + ]; + } + } else { + $descripcion = post('descripcion' . $n_unidad); + $piso = post('piso' . $n_unidad); + $data []= [ + 'proyecto' => $tipo->proyecto()->id, + 'tipo' => $tipo->tipo()->id, + 'piso' => $piso, + 'descripcion' => $descripcion, + 'abreviacion' => $tipo->abreviacion, + 'm2' => $tipo->m2, + 'terraza' => $tipo->terraza, + 'logia' => $tipo->logia, + 'pt' => $tipo->id + ]; + } + } + + foreach ($data as $uni) { + $unidad = model(Unidad::class) + ->where('descripcion', $uni['descripcion']) + ->where('proyecto', $uni['proyecto']) + ->where('tipo', $uni['tipo']) + ->findOne(); + if ($unidad) { + continue; + } + $unidad = model(Unidad::class)->create($uni); + $unidad->save(); + } + header('Location: ' . url('', ['p' => 'proyectos', 'a' => 'list_unidades', 'proyecto' => $tipo->proyecto()->id])); + } + public static function edit() + { + $id = get('unidad'); + $unidad = model(Unidad::class)->findOne($id); + $tipos = model(ProyectoTipoUnidad::class)->where('proyecto', $unidad->proyecto()->id)->findMany(); + $abreviaciones = ['N', 'NE', 'E', 'SE', 'S', 'SO', 'O', 'NO']; + $descripciones = ['Norte', 'Noreste', 'Este', 'Sureste', 'Sur', 'Suroeste', 'Oeste', 'Noroeste']; + $orientaciones = []; + foreach ($abreviaciones as $i => $ab) { + $orientaciones []= (object) ['abreviacion' => $ab, 'descripcion' => $descripciones[$i]]; + } + + return view('proyectos.unidades.edit', compact('unidad', 'tipos', 'orientaciones')); + } + public static function editar() + { + $id = get('unidad'); + $unidad = model(Unidad::class)->findOne($id); + + $change = false; + $fields = ['descripcion', 'tipo', 'piso', 'linea', 'orientacion']; + foreach ($fields as $field) { + $f = $field; + if ($f == 'tipo') { + $f = 'pt'; + } + if ($f == 'linea') { + $f = 'subtipo'; + } + if ($unidad->{$f} != post($field)) { + $unidad->{$f} = post($field); + $change = true; + } + } + + if ($change) { + $unidad->save(); + } + header('Location: ' . nUrl('proyectos', 'list_unidades', ['proyecto' => $unidad->proyecto()->id])); + } + public static function remove() + { + $id = get('unidad'); + $unidad = model(Unidad::class)->findOne($id); + $unidad->delete(); + + $id = get('proyecto'); + header('Location: ' . nUrl('proyectos', 'list_unidades', ['proyecto' => $id])); + } +} +?> diff --git a/resources/less/Controller/UnidadesBloqueadas.php b/resources/less/Controller/UnidadesBloqueadas.php new file mode 100644 index 0000000..9bd4107 --- /dev/null +++ b/resources/less/Controller/UnidadesBloqueadas.php @@ -0,0 +1,83 @@ +findMany(); + echo view('ventas.operadores.unidades.list', compact('proyectos')); + } + public static function add() + { + $proyectos = model(Proyecto::class)->findMany(); + echo view('ventas.operadores.unidades.add', compact('proyectos')); + } + public static function bloquear() + { + $operador = model(ProyectoAgente::class)->findOne(get('operador')); + echo view('ventas.operadores.unidades.bloquear', compact('operador')); + } + public static function do_bloquear() + { + $operador = model(ProyectoAgente::class)->findOne(get('operador')); + $fecha = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $unidades = self::getUnidades([], 'departamentos', 1); + $unidades = self::getUnidades($unidades, 'estacionamientos', 2); + $unidades = self::getUnidades($unidades, 'bodegas', 3); + if (post('unidad') != null) { + foreach (post('unidad') as $u) { + $unidad = model(Unidad::class)->findOne($u); + if (array_search($unidad, $unidades) === false) { + $unidades []= $unidad; + } + } + } + + foreach ($unidades as $unidad) { + $data = [ + 'agente' => $operador->id, + 'unidad' => $unidad->id + ]; + $ub = model(UnidadBloqueada::class)->create($data); + $ub->new($fecha); + } + header('Location: ' . nUrl('unidades_bloqueadas', 'list')); + } + protected static function getUnidades(array $unidades, string $name, int $tipo): array + { + if (trim(post($name)) == '') { + return $unidades; + } + $unis = []; + $separators = [PHP_EOL, ';', ',', '-']; + foreach ($separators as $separator) { + if (strpos(post($name), $separator) !== false) { + $unis = explode($separator, post($name)); + break; + } + } + if (count($unis) == 0) { + return $unidades; + } + array_walk($unis, function(&$item) { + $item = trim($item); + $item = model(Unidad::class)->where('descripcion', $item)->where('tipo', 1)->findOne(); + }); + foreach ($unis as $uni) { + if (array_search($uni, $unidades) === false) { + $unidades []= $uni; + } + } + return $unidades; + } +} diff --git a/resources/less/Controller/Ventas.php b/resources/less/Controller/Ventas.php new file mode 100644 index 0000000..e66faf2 --- /dev/null +++ b/resources/less/Controller/Ventas.php @@ -0,0 +1,623 @@ +findOne($proyecto); + $ventas = $proyecto->ventas(); + self::sort($ventas); + return view('ventas.list', compact('proyecto', 'ventas')); + } + protected static function sort(&$ventas) + { + $sort = get('sort'); + if ($sort == null) { + $sort = 'departamento'; + } + $direction = get('sort_dir'); + if ($direction == null) { + $direction = 1; + } + switch ($sort) { + case 'departamento': + usort($ventas, function($a, $b) use ($direction) { + return ($a->propiedad()->unidad()->descripcion - $b->propiedad()->unidad()->descripcion) * $direction; + }); + break; + case 'propietario': + usort($ventas, function($a, $b) use ($direction) { + $pa = trim($a->propietario()->nombreCompleto(true), ', '); + $pb = trim($b->propietario()->nombreCompleto(true), ', '); + return $direction * strcasecmp($pa, $pb); + }); + break; + case 'valor_uf': + usort($ventas, function($a, $b) use ($direction) { + return $direction * ($a->valor_uf - $b->valor_uf); + }); + break; + case 'uf_m2': + usort($ventas, function($a, $b) use ($direction) { + return $direction * ($a->uf_m2() - $b->uf_m2()); + }); + break; + case 'fecha_venta': + usort($ventas, function($a, $b) use ($direction) { + return ($a->fecha()->timestamp - $b->fecha()->timestamp) * $direction; + }); + break; + } + if ($direction == 'desc') { + $ventas = array_reverse($ventas); + } + } + public static function listProyectos() + { + $proyectos = model(Proyecto::class) + ->select('proyecto.*') + ->join('estado_proyecto', ['estado.proyecto', '=', 'proyecto.id'], 'estado') + ->join('tipo_estado_proyecto', ['tipo.id', '=', 'estado.estado'], 'tipo') + ->join('etapa_proyecto', ['etapa.id', '=', 'tipo.etapa'], 'etapa') + ->whereGte('etapa.orden', 4) + ->orderByAsc('proyecto.descripcion') + ->groupBy('proyecto.id') + ->findMany(); + echo view('ventas.proyectos', compact('proyectos')); + } + public static function show() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + + return view('ventas.show', compact('venta')); + } + public static function new() + { + $proyectos = model(Proyecto::class) + ->select('proyecto.*') + ->join('estado_proyecto', ['estado.proyecto', '=', 'proyecto.id'], 'estado') + ->join('tipo_estado_proyecto', ['tipo.id', '=', 'estado.estado'], 'tipo') + ->join('etapa_proyecto', ['etapa.id', '=', 'tipo.etapa'], 'etapa') + ->whereGte('etapa.orden', 3) + ->orderByAsc('proyecto.descripcion') + ->groupBy('proyecto.id') + ->findMany(); + $regiones = model(Region::class)->order_by_asc('numeracion')->findMany(); + return view('ventas.add', compact('proyectos', 'regiones')); + } + public static function agregar() + { + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $t = Carbon::today(config('app.timezone')); + $uf = uf($f); + + $calle = trim(post('calle')); + $numero = post('numero'); + $extra = trim(post('extra')); + $comuna = post('comuna'); + $direccion = model(Direccion::class) + ->where('calle', $calle) + ->where('numero', $numero) + ->where('extra', $extra) + ->where('comuna', $comuna) + ->findOne(); + if (!$direccion) { + $direccion = model(Direccion::class)->create(); + $direccion->calle = $calle; + $direccion->numero = $numero; + $direccion->extra = $extra; + $direccion->comuna = $comuna; + $direccion->save(); + } + + list($rut, $dv) = explode('-', str_replace('.', '', post('rut'))); + $propietario = model(Propietario::class)->where('rut', $rut)->findOne(); + if (!$propietario) { + $propietario = model(Propietario::class)->create(); + $propietario->rut = $rut; + $propietario->dv = $dv; + $propietario->nombres = trim(post('nombres')); + $propietario->apellido_paterno = trim(post('paterno')); + $propietario->apellido_materno = trim(post('materno')); + $propietario->direccion = $direccion->id; + if (post('otro') != null) { + $propietario->otro = 1; + } + + $propietario->save(); + } + + $unis = json_decode(post('unidades')); + $id_principal = array_shift($unis); + $principal = model(Unidad::class)->findOne(post('unidad' . $id_principal)); + $propiedad = model(Propiedad::class) + ->select('propiedad.*') + ->join('unidad', ['unidad.id', '=', 'propiedad.unidad_principal']) + ->where('propiedad.unidad_principal', $principal->id) + ->where('unidad.proyecto', post('proyecto')) + ->orderByDesc('propiedad.id') + ->findOne(); + // Revisar si existe la propiedad y si está vigente. + if (!$propiedad or ($propiedad->venta() and $propiedad->venta()->estado() and $propiedad->venta()->estado()->tipo()->descripcion != 'vigente')) { + if (!$propiedad) { + $propiedad = model(Propiedad::class)->create(); + } + $propiedad->unidad_principal = $principal->id; + $propiedad->save(); + $data = [ + 'propiedad' => $propiedad->id, + 'unidad' => $principal->id, + 'principal' => 1 + ]; + $pu = model(PropiedadUnidad::class)->create($data); + $pu->save(); + foreach ($unis as $id_unidad) { + $data = [ + 'propiedad' => $propiedad->id, + 'unidad' => post('unidad' . $id_unidad), + 'principal' => 0 + ]; + $pu = model(PropiedadUnidad::class)->create($data); + $pu->save(); + } + /*$ests = []; + $bods = []; + foreach ($unis as $id_unidad) { + $unidad = model(Unidad::class)->findOne(post('unidad' . $id_unidad)); + if ($unidad->tipo == 2) { + $ests []= $unidad->id; + } + if ($unidad->tipo == 3) { + $bods []= $unidad->id; + } + } + $propiedad->estacionamientos = implode(';', $ests); + $propiedad->bodegas = implode(';', $bods); + $propiedad->save();*/ + } elseif ($propiedad->venta() and $propiedad->venta()->estado()->tipo()->descripcion == 'vigente') { + // Existe la propiedad en este proyecto y está vigente. Error, no se debiese vender si está vigente. + throw new \Exception('Existe la propiedad en este proyecto y está vigente. Error, no se debiese vender si está vigente.'); + } + + $venta = model(Venta::class)->create(); + $venta->propietario = $propietario->rut; + $venta->propiedad = $propiedad->id; + if (post('pie')) { + $pie = model(Pie::class)->create(); + $pie->valor = post('pie'); + $pie->fecha = $f->format('Y-m-d'); + $pie->cuotas = post('cuotas'); + $pie->uf = $uf->uf->value; + $pie->save(); + + $venta->pie = $pie->id; + } + if (post('bono_pie')) { + $bono = model(BonoPie::class)->create(); + $bono->valor = post('bono_pie'); + + $pago = model(Pago::class)->create(); + $pago->fecha = $f->format('Y-m-d'); + $pago->uf = $uf->uf->value; + $pago->valor = $bono->valor * $uf->uf->value; + $pago->tipo = 8; + $pago->new(); + + $bono->pago = $pago->id; + $bono->save(); + + $venta->bono_pie = $bono->id; + } + if (post('credito')) { + $pago = model(Pago::class)->create(); + $pago->fecha = $f->format('Y-m-d'); + $pago->uf = $uf->uf->value; + $pago->valor = post('credito') * $uf->uf->value; + $pago->tipo = 2; + $pago->new(); + + $credito = model(Credito::class)->create(); + $credito->pago = $pago->id; + $credito->save(); + + $venta->credito = $credito->id; + } + + $venta->fecha = $f->format('Y-m-d'); + $venta->valor_uf = post('valor'); + $venta->fecha_ingreso = $t->format('Y-m-d'); + if (post('operador') != 0) { + $venta->agente = post('operador'); + } + $venta->uf = $uf->uf->value; + $venta->new(); + + if (post('promociones') != 0) { + $promos = json_decode(post('promociones')); + foreach ($promos as $id_promo) { + $promocion = model(Promocion::class)->findOne(post('promocion' . $id_promo)); + $promo = model(PromocionVenta::class)->create(); + $promo->promocion = $promocion->id; + $promo->venta = $venta->id; + $promo->valor = post('promo' . $id_promo); + $promo->save(); + } + } + header('Location: ' . url('', ['p' => 'ventas', 'a' => 'show', 'venta' => $venta->id])); + } + public static function edit() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + $proyectos = model(Proyecto::class)->order_by_asc('descripcion')->findMany(); + $regiones = model(Region::class)->order_by_asc('numeracion')->findMany(); + return view('ventas.edit', compact('venta', 'proyectos', 'regiones')); + } + public static function editar() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $uf = uf($f); + + $valor = correctNumber(post('valor')); + $change = false; + if ($venta->fecha != $f->format('Y-m-d')) { + $venta->fecha = $f->format('Y-m-d'); + $venta->uf = $uf->uf->value; + $change = true; + } + if ($venta->valor_uf != $valor) { + $venta->valor_uf = $valor; + $change = true; + } + if ($change) { + $venta->save(); + } + + $direccion = $venta->propietario()->direccion(); + $calle = post('calle'); + $numero = post('numero'); + $extra = post('extra'); + $comuna = post('comuna'); + $change = false; + if ($direccion->calle != $calle) { + $direccion->calle = $calle; + $change = true; + } + if ($direccion->numero != $numero) { + $direccion->numero = $numero; + $change = true; + } + if ($direccion->extra != $extra) { + $direccion->extra = $extra; + $change = true; + } + if ($direccion->comuna != $comuna) { + $direccion->comuna = $comuna; + $change = true; + } + if ($change) { + $direccion->save(); + } + + $propietario = $venta->propietario(); + list($rut, $dv) = explode('-', str_replace('.', '', post('rut'))); + $nombres = post('nombres'); + $paterno = post('paterno'); + $materno = post('materno'); + $change = false; + if ($propietario->rut != $rut) { + $propietario->rut = $rut; + $propietario->dv = $dv; + $venta->propietario = $rut; + $venta->save(); + $change = true; + } + if ($propietario->nombres != $nombres) { + $propietario->nombres = $nombres; + $change = true; + } + if ($propietario->apellido_paterno != $paterno) { + $propietario->apellido_paterno = $paterno; + $change = true; + } + if ($propietario->apellido_materno != $materno) { + $propietario->apellido_materno = $materno; + $change = true; + } + if ($change) { + $propietario->save(); + } + + $unidades = json_decode(post('unidades')); + if (count($unidades) > 0) { + $propiedad = $venta->propiedad(); + $ests = explode(';', $propiedad->estacionamientos); + $bods = explode(';', $propiedad->bodegas); + $change = false; + foreach ($unidades as $n) { + $id = post('unidad' . $n); + $unidad = model(Unidad::class)->findOne($id); + if ($unidad->tipo == 1 and $propiedad->unidad_principal != $unidad->id) { + $propiedad->unidad_principal = $unidad->id; + $change = true; + } + if ($unidad->tipo == 2 and array_search($unidad->id, $ests) === false) { + $ests []= $unidad->id; + } + if ($unidad->tipo == 3 and array_search($unidad->id, $bods) === false) { + $bods []= $unidad->id; + } + } + $ests = implode(';', $ests); + $bods = implode(';', $bods); + if ($propiedad->estacionamientos != $ests) { + $propiedad->estacionamientos = $ests; + $change = true; + } + if ($propiedad->bodegas != $bods) { + $propiedad->bodegas = $bods; + $change = true; + } + if ($change) { + $propiedad->save(); + } + } + + if (post('pie')) { + $pie = $venta->pie(); + $valor = correctNumber(post('pie')); + $cuotas = post('cuotas'); + $change = false; + if ($pie->valor != $valor) { + $pie->valor = $valor; + $change = true; + } + if ($pie->cuotas != $cuotas) { + $pie->cuotas = $cuotas; + $change = true; + } + if ($change) { + $pie->save(); + } + } + + $credito = $venta->credito(); + $valor = post('credito'); + header('Location: ' . url('', ['p' => 'ventas', 'a' => 'show', 'venta' => $venta->id])); + } + public static function desistir() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + + return view('ventas.desist', compact('venta')); + } + public static function desistiendo() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $valor = correctNumber(post('pago')); + $uf = uf($f); + + $venta->estado = 0; + $tipo = model(TipoEstadoVenta::class)->where('descripcion', 'desistida')->findOne(); + $data = [ + 'venta' => $venta->id, + 'estado' => $tipo->id, + 'fecha' => $f->format('Y-m-d') + ]; + $estado = model(EstadoVenta::class)->create($data); + $propiedad = $venta->propiedad(); + $propiedad->estado = 0; + $pago = model(Pago::class)->create(); + $pago->fecha = $f->format('Y-m-d'); + $pago->valor = (double) $valor; + $pago->uf = $uf->uf->value; + $pago->tipo = 1; + + $pago->new(); + $propiedad->save(); + $estado->save(); + $venta->resciliacion = $pago->id; + $venta->save(); + header('Location: ' . url('', ['p' => 'ventas', 'a' => 'show', 'venta' => $venta->id])); + } + public static function ceder() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + + return view('ventas.ceder', compact('venta')); + } + public static function cediendo() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + $nueva_venta = model(Venta::class)->create(); + + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + + list($rut, $dv) = explode('-', str_replace('.', '', post('rut'))); + $propietario = model(Propietario::class)->where('rut', $rut)->findOne(); + if (!$propietario) { + $propietario = model(Propietario::class)->create(); + $propietario->rut = $rut; + $propietario->dv = $dv; + $propietario->nombres = trim(post('nombres')); + $propietario->apellido_paterno = trim(post('paterno')); + $propietario->apellido_materno = trim(post('materno')); + $propietario->direccion = $direccion->id; + if (post('otro') != null) { + $propietario->otro = 1; + } + + $propietario->save(); + } + + $nueva_venta->fecha_ingreso = $f->format(); + $nueva_venta->estado = 1; + $cols = [ + 'propiedad', + 'pie', + 'bono_pie', + 'credito', + 'escritura', + 'subsidio', + 'fecha', + 'valor_uf', + 'agente', + 'uf' + ]; + foreach ($cols as $col) { + $nueva_venta->{$col} = $venta->{$col}; + } + $nueva_venta->new(); + + $venta->estado = -1; + $tipo = model(TipoEstadoVenta::class)->where('descripcion', 'cedida')->findOne(); + $data = [ + 'venta' => $venta->id, + 'estado' => $tipo->id, + 'fecha' => $f->format('Y-m-d') + ]; + $estado = model(EstadoVenta::class)->create($data); + $estado->save(); + + $venta->save(); + header('Location: ' . url('', ['p' => 'ventas', 'a' => 'show', 'venta' => $venta->id])); + } + public static function entregar() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + + return view('ventas.entregar', compact('venta')); + } + public static function consolidacion() + { + if (get('proyecto')) { + $id_proyecto = get('proyecto'); + $proyecto = model(Proyecto::class)->findOne($id_proyecto); + + $ventas = $proyecto->ventas(); + set_time_limit(count($ventas)); + + $f = Carbon::today(config('app.timezone')); + setlocale(LC_TIME, 'es'); + + return view('ventas.consolidacion.show', compact('ventas', 'f')); + } else { + $proyectos = model(Proyecto::class)->order_by_asc('descripcion')->find_many(); + return view('ventas.consolidacion.proyectos', compact('proyectos')); + } + } + public static function devolucion() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + $uf = uf(Carbon::now(config('app.config')))->uf->value; + $valor = round($venta->saldo() * $uf); + + return view('ventas.devolucion', compact('venta', 'valor', 'uf')); + } + public static function devolver() + { + $id = get('venta'); + $venta = model(Venta::class)->findOne($id); + + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $uf = uf($f); + $valor = correctNumber(post('valor')); + + $data = [ + 'fecha' => $f->format('Y-m-d'), + 'valor' => $valor, + 'tipo' => 1, + 'uf' => $uf->uf->value, + 'identificador' => post('identificador'), + 'banco' => 0 + ]; + + $banco = model(Banco::class)->where('nombre', post('banco'))->findOne(); + if ($banco) { + $data['banco'] = $banco->id; + } + + $pago = model(Pago::class)->create($data); + $pago->newPagado(); + + $venta->devolucion = $pago->id; + $venta->save(); + header('Location: ' . url('', ['p' => 'ventas', 'a' => 'show', 'venta' => $venta->id])); + } + public static function resciliaciones() + { + $resciliaciones = model(Venta::class)->where('estado', 0)->findMany(); + + return view('ventas.resciliaciones', compact('resciliaciones')); + } + public static function firmar() + { + $venta = \model(Venta::class)->findOne(get('venta')); + return view('ventas.firmar', compact('venta')); + } + public static function firmando() + { + $venta = \model(Venta::class)->findOne(get('venta')); + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $venta->firmar($f); + header('Location: ' . nUrl('ventas', 'show', ['venta' => $venta->id])); + + } + public static function archivar() + { + $venta = \model(Venta::class)->findOne(get('venta')); + return view('ventas.archivar', compact('venta')); + } + public static function archivando() + { + $venta = \model(Venta::class)->findOne(get('venta')); + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $venta->archivar($f); + header('Location: ' . nUrl('ventas', 'show', ['venta' => $venta->id])); + } +} +?> diff --git a/resources/less/_variables.less b/resources/less/_variables.less new file mode 100644 index 0000000..85dc592 --- /dev/null +++ b/resources/less/_variables.less @@ -0,0 +1,9 @@ +@icon-font-path: '~bootstrap/dist/fonts'; + +@palette1: #333; +@palette2: #f78820; + +@page_heading: #14153c; +@grey: #a9a9a9; +@dark-grey: #808080; +@light-grey: #d3d3d3; \ No newline at end of file diff --git a/resources/less/app.less b/resources/less/app.less new file mode 100644 index 0000000..3a7c1c2 --- /dev/null +++ b/resources/less/app.less @@ -0,0 +1,9 @@ +@import "_variables"; + +@import "bootstrap"; + +//@import "node_modules/font-awesome/less/font-awesome"; + +@import "custom"; + +@import (less) "node_modules/jquery-ui-bootstrap/jquery.ui.theme.css"; \ No newline at end of file diff --git a/resources/less/bootstrap.less b/resources/less/bootstrap.less new file mode 100644 index 0000000..bfca78f --- /dev/null +++ b/resources/less/bootstrap.less @@ -0,0 +1,2 @@ +@import "node_modules/bootstrap/less/bootstrap"; +//@import "node_modules/bootstrap-datepicker/less/datepicker3"; \ No newline at end of file diff --git a/resources/less/custom.less b/resources/less/custom.less new file mode 100644 index 0000000..c7a938a --- /dev/null +++ b/resources/less/custom.less @@ -0,0 +1,50 @@ +@import "submenu"; +@import "print"; + +.logo_cabezal { + padding: 1%; + img { + height: @line-height-base * @font-size-base * 5; + } +} + +.dropdown-submenu { + position: relative; + + .dropdown-menu { + top: 0; + left: 100%; + margin-top: -1px; + } +} + +.error { + background-color: darken(@brand-danger, .9); +} + +.page-heading { + padding: 3px 10px; + margin: auto 0; + background-color: @page_heading; + color: white; + + a { + color: inherit; + } +} + +.section-heading { + background-color: @dark-grey !important; + color: white !important; + + a { + color: inherit !important; + } +} +.subsection-heading { + background-color: @light-grey !important; +} + +.agregar, .remover, .click { + cursor: pointer; +} \ No newline at end of file diff --git a/resources/less/print.less b/resources/less/print.less new file mode 100644 index 0000000..cbae777 --- /dev/null +++ b/resources/less/print.less @@ -0,0 +1,101 @@ +@media print { + header, footer, .benchmark { + display: none; + } +} +#print { + width: 100%; + + div.title { + font-size: 15pt; + font-weight: bold; + border-bottom: 3px solid black; + text-align: center; + } + + table.data-box { + width: 100%; + border-collapse: collapse; + td { + border: thin solid black; + padding-left: 2px; + } + } + + table.details { + width: 100%; + border-collapse: collapse; + + thead { + color: white; + background-color: black; + font-weight: bold; + } + + tbody { + tr { + border: thin solid black; + &:nth-child(odd) { + background-color: lightgray; + } + &.total { + font-weight: bold; + td { + border-top-style: double; + border-top-width: 3px; + } + } + } + } + + td, th { + border: thin solid black; + padding-left: 2px; + } + } + + label { + font-variant: small-caps; + font-size: 10pt; + } + + div.data { + float: left; + } + div.data-value { + float: right; + } + div.total { + float: left; + font-weight: bold; + } + div.total-value { + float: right; + font-weight: bold; + } + br.clear { + clear: both; + } + + table.signature { + width: 75%; + tr { + &.double { + height: 12pt * 2; + } + &.triple { + height: 12pt * 3; + } + &.quadruple { + height: 12pt * 4; + } + td { + padding-left: 2px; + border: thin solid black; + &:nth-child(2) { + width: 70%; + } + } + } + } +} \ No newline at end of file diff --git a/resources/less/submenu.less b/resources/less/submenu.less new file mode 100644 index 0000000..6a73c4b --- /dev/null +++ b/resources/less/submenu.less @@ -0,0 +1,42 @@ +.dropdown-submenu { + position: relative; + .dropdown-menu { + top: 0; + left: 100%; + margin-top: -6px; + margin-left: -1px; + -webkit-border-radius: 0 6px 6px 6px; + -moz-border-radius: 0 6px 6px; + border-radius: 0 6px 6px 6px; + } + &:hover>.dropdown-menu { + display: block; + a:after { + border-left-color: #fff; + } + } + a:after { + display: block; + content: " "; + float: right; + width: 0; + height: 0; + border-color: transparent; + border-style: solid; + border-width: 5px 0 5px 5px; + border-left-color: #ccc; + margin-top: 5px; + margin-right: -10px; + } + .pull-left { + float: none; + + .dropdown-menu { + left: -100%; + margin-left: 10px; + -webkit-border-radius: 6px 0 6px 6px; + -moz-border-radius: 6px 0 6px 6px; + border-radius: 6px 0 6px 6px; + } + } +} \ No newline at end of file diff --git a/resources/views/admin/base.blade.php b/resources/views/admin/base.blade.php new file mode 100644 index 0000000..079c553 --- /dev/null +++ b/resources/views/admin/base.blade.php @@ -0,0 +1,43 @@ + + + + + + @if (isset($titulo)) + {{$titulo}} - + @endif + Incoviba S. A. + + + + + @stack('styles') + + +
+
+
+
+
+ +
+
+
+
+
+ @include('admin.menu') +
+
+
+
+
+
+
+ @yield('content') +
+
+
+@include('layout.footer') +@stack('scripts') + + \ No newline at end of file diff --git a/resources/views/admin/menu.blade.php b/resources/views/admin/menu.blade.php new file mode 100644 index 0000000..f98cf2d --- /dev/null +++ b/resources/views/admin/menu.blade.php @@ -0,0 +1,40 @@ + diff --git a/resources/views/admin/menu/models.blade.php b/resources/views/admin/menu/models.blade.php new file mode 100644 index 0000000..905537c --- /dev/null +++ b/resources/views/admin/menu/models.blade.php @@ -0,0 +1,3 @@ + diff --git a/resources/views/admin/menu/registros.blade.php b/resources/views/admin/menu/registros.blade.php new file mode 100644 index 0000000..c86be14 --- /dev/null +++ b/resources/views/admin/menu/registros.blade.php @@ -0,0 +1,3 @@ + diff --git a/resources/views/admin/menu/roles.blade.php b/resources/views/admin/menu/roles.blade.php new file mode 100644 index 0000000..f885743 --- /dev/null +++ b/resources/views/admin/menu/roles.blade.php @@ -0,0 +1,4 @@ + diff --git a/resources/views/admin/menu/users.blade.php b/resources/views/admin/menu/users.blade.php new file mode 100644 index 0000000..6061b94 --- /dev/null +++ b/resources/views/admin/menu/users.blade.php @@ -0,0 +1,4 @@ + diff --git a/resources/views/admin/models.blade.php b/resources/views/admin/models.blade.php new file mode 100644 index 0000000..95c40e7 --- /dev/null +++ b/resources/views/admin/models.blade.php @@ -0,0 +1,31 @@ +@extends('layout.base') + +@section('content') +
+
DB to Models
+
+
+
+
DB
+
+ +
+
+
+
+
+
+
+
+
+
+
+@endsection + +@push('scripts') + +@endpush \ No newline at end of file diff --git a/resources/views/admin/registros/controles_avance.blade.php b/resources/views/admin/registros/controles_avance.blade.php new file mode 100644 index 0000000..9cfd93e --- /dev/null +++ b/resources/views/admin/registros/controles_avance.blade.php @@ -0,0 +1,31 @@ +
+
+ @if ($start > 0) + + + + @endif +
+
+ @if ($start > 0) + + + + @endif +
+
{{$start + 1}} - {{$end}}
+
+ @if ($end < $total) + + + + @endif +
+
+ @if ($end < $total) + + + + @endif +
+
diff --git a/resources/views/admin/registros/list.blade.php b/resources/views/admin/registros/list.blade.php new file mode 100644 index 0000000..f744930 --- /dev/null +++ b/resources/views/admin/registros/list.blade.php @@ -0,0 +1,41 @@ +@extends('admin.base') + +@section('content') +
+
Registros
+
+ @include('admin.registros.controles_avance') + + + + + + + + + + + + @foreach ($registros as $registro) + + + + + + + + @endforeach + +
UsuarioRolesFecha - HoraModeloCambios
{{$registro->user()->name}} + @foreach ($registro->user()->roles() as $rol) + {{ucwords($rol->description)}} + @endforeach + {{$registro->time()->format('d-m-Y - H:i:s')}} hrs.{{$registro->model()}}{{count($registro->actions())}}
+ @include('admin.registros.controles_avance') +
+
+@endsection diff --git a/resources/views/admin/registros/show.blade.php b/resources/views/admin/registros/show.blade.php new file mode 100644 index 0000000..7c0a98f --- /dev/null +++ b/resources/views/admin/registros/show.blade.php @@ -0,0 +1,62 @@ +@extends('admin.base') + +@section('content') +
+
Ver Registro
+
+
+
Usuario
+
{{$registro->user()->name}}
+
+
+
Roles
+
+ @foreach ($registro->user()->roles() as $rol) + {{ucwords($rol->description)}} + @endforeach +
+
+
+
Fecha - Hora
+
{{$registro->time()->format('d-m-Y - H:i:s')}}
+
+
+
Modelo
+
{{$registro->model()}}
+
+
+
Cambios
+
+ + + + + + + + + + + + + @foreach ($registro->actions() as $column => $action) + + + + + + @endforeach + +
ColumnaValor
AntiguoNuevo
{{$column}}{{$action->old}}{{$action->new}}
+
+
+
+ Volver +
+
+
+@endsection diff --git a/resources/views/admin/roles/add.blade.php b/resources/views/admin/roles/add.blade.php new file mode 100644 index 0000000..dc9274e --- /dev/null +++ b/resources/views/admin/roles/add.blade.php @@ -0,0 +1,17 @@ +@extends('admin.base') + +@section('content') +
+
Agregar Rol
+
+
+
+
+
Descripción
+
+
+
+
+
+
+@endsection diff --git a/resources/views/admin/roles/add_permissions.blade.php b/resources/views/admin/roles/add_permissions.blade.php new file mode 100644 index 0000000..d18c126 --- /dev/null +++ b/resources/views/admin/roles/add_permissions.blade.php @@ -0,0 +1,40 @@ +@extends('admin.base') + +@section('content') +
+
Agregar Permisos - {{$role->description}}
+
+
+
+
+
Permitidos
+
+
+ +
Denegados
+
+ + */ ?> +
+
+
+
+@endsection diff --git a/resources/views/admin/roles/add_users.blade.php b/resources/views/admin/roles/add_users.blade.php new file mode 100644 index 0000000..34e2e7e --- /dev/null +++ b/resources/views/admin/roles/add_users.blade.php @@ -0,0 +1,24 @@ +@extends('admin.base') + +@section('content') +
+
Agregar Usuario - {{$role->description}}
+
+
+
+
+
Ususarios
+
+
+
+
+
+
+@endsection diff --git a/resources/views/admin/roles/list.blade.php b/resources/views/admin/roles/list.blade.php new file mode 100644 index 0000000..efbd9bc --- /dev/null +++ b/resources/views/admin/roles/list.blade.php @@ -0,0 +1,32 @@ +@extends('admin.base') + +@section('content') +
+
Roles
+
+
+ + + + + + + + + + +@foreach ($roles as $role) + + + + + + +@endforeach + +
DescripciónNivelUsuarios
{{$role->description}}{{$role->level}} + @foreach ($role->users() as $user) + {{$user->name}} + @endforeach +
+@endsection diff --git a/resources/views/admin/roles/show.blade.php b/resources/views/admin/roles/show.blade.php new file mode 100644 index 0000000..97a0d57 --- /dev/null +++ b/resources/views/admin/roles/show.blade.php @@ -0,0 +1,63 @@ +@extends('admin.base') + +@section('content') +
+
{{$role->description}}
+
+
+
Usuarios
+
+
+ + @foreach ($role->users() as $user) + + + + + @endforeach +
{{$user->name}}
+
+
Permisos
+
+
+@if ($role->permissions()) + + + + + + + + + + @foreach ($permissions as $permission) + + + + + + @endforeach + +
AcciónEstadoHeredado
{{$permission->description}} + @if ($permission->status) Permitido @else Denegado @endif + + @if ($permission->inherited) + Si + @else + No + @endif +
+@endif +@endsection diff --git a/resources/views/admin/users/add.blade.php b/resources/views/admin/users/add.blade.php new file mode 100644 index 0000000..5f67fdb --- /dev/null +++ b/resources/views/admin/users/add.blade.php @@ -0,0 +1,21 @@ +@extends('admin.base') + +@section('content') +
+
Agregar Ususario
+
+
+
+
+
Usuario
+
+
+
+
Password
+
+
+
+
+
+
+@endsection diff --git a/resources/views/admin/users/add_role.blade.php b/resources/views/admin/users/add_role.blade.php new file mode 100644 index 0000000..acad3d7 --- /dev/null +++ b/resources/views/admin/users/add_role.blade.php @@ -0,0 +1,24 @@ +@extends('admin.base') + +@section('content') +
+
Agregar Rol - {{$user->name}}
+
+
+
+
+
Rol
+
+
+
+
+
+
+@endsection diff --git a/resources/views/admin/users/list.blade.php b/resources/views/admin/users/list.blade.php new file mode 100644 index 0000000..d660684 --- /dev/null +++ b/resources/views/admin/users/list.blade.php @@ -0,0 +1,29 @@ +@extends('admin.base') + +@section('content') +
+
Usuarios
+
+
+ + + + + + + + +@foreach ($users as $user) + + + + + +@endforeach + +
NombreRoles
{{$user->name}} + @foreach ($user->roles() as $role) + {{$role->description}} + @endforeach +
+@endsection diff --git a/resources/views/admin/users/show.blade.php b/resources/views/admin/users/show.blade.php new file mode 100644 index 0000000..8efdee3 --- /dev/null +++ b/resources/views/admin/users/show.blade.php @@ -0,0 +1,62 @@ +@extends('admin.base') + +@section('content') +
+
{{$user->name}}
+
+ + Resetear Clave + +
+
Roles
+
+
+ + @foreach ($user->roles() as $role) + + + + + @endforeach +
{{$role->description}}
+
+
Permisos
+
+
+@if ($user->permissions()) + + + + + + + + + + @foreach ($user->permissions() as $permission) + + + + + + @endforeach + +
PáginasRolAcceso
+ {{$permission->action()->description}} + + @if ($permission->type == 2) + {{$permission->who()->description}} + @endif + + @if ($permission->all == 0) + @if ($permission->access == 1) + Permitido + @else + Denegado + @endif + @else + Permitido + @endif +
+@endif +@endsection diff --git a/resources/views/auth/base.blade.php b/resources/views/auth/base.blade.php new file mode 100644 index 0000000..cef48cf --- /dev/null +++ b/resources/views/auth/base.blade.php @@ -0,0 +1,57 @@ + + + + + + @if (isset($titulo)) + {{$titulo}} - + @endif + Incoviba S. A. + + + + + @stack('styles') + + +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+ @yield('content') +
+
+
+@include('layout.footer') +@stack('scripts') + + diff --git a/resources/views/auth/change_pass.blade.php b/resources/views/auth/change_pass.blade.php new file mode 100644 index 0000000..859c91e --- /dev/null +++ b/resources/views/auth/change_pass.blade.php @@ -0,0 +1,78 @@ +@extends('auth.base') + +@section('content') +
+
Cambio de Cláve
+
+
+
+
+
Cláve anterior
+
+
+
+
+
Cláve nueva
+
+
+
+
+
Repetir cláve
+
+
+
+
+
+
+
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php new file mode 100644 index 0000000..4e2cbdd --- /dev/null +++ b/resources/views/auth/login.blade.php @@ -0,0 +1,17 @@ +@extends('auth.base') + +@section('content') +
+
+
Usuario
+
+
+
+
Cláve
+
+
+
+
+
+
+@endsection diff --git a/resources/views/benchmark.blade.php b/resources/views/benchmark.blade.php new file mode 100644 index 0000000..65e2ccb --- /dev/null +++ b/resources/views/benchmark.blade.php @@ -0,0 +1,7 @@ +
+
+
+
Tiempo demorado
+
{{$benchmark->time}} s
+
+
\ No newline at end of file diff --git a/resources/views/buscar/buscar.blade.php b/resources/views/buscar/buscar.blade.php new file mode 100644 index 0000000..c6544bf --- /dev/null +++ b/resources/views/buscar/buscar.blade.php @@ -0,0 +1,77 @@ +@extends('layout.base') + +@section('content') +
+
Buscar
+
+
+ +
+
+
+
+
+ + {{ucwords($tipos[0])}} +
+ @foreach ($tipos as $i => $tipo) + @if ($tipo == 'cualquiera') + @continue + @endif +
+ + {{ucwords($tipo)}} +
+ @endforeach +
+
+
+
+
+@if ($results != null) +
+
Resultados
+
+ + + + + + + + + + + + + + + @foreach ($results as $resultado) + @include('buscar.resultado') + @endforeach + +
ProyectoDepartamentoPropietarioTipoValor [UF]Fecha VentaFecha Entrega
+
+
+@endif +@endsection diff --git a/resources/views/buscar/resultado.blade.php b/resources/views/buscar/resultado.blade.php new file mode 100644 index 0000000..9d47106 --- /dev/null +++ b/resources/views/buscar/resultado.blade.php @@ -0,0 +1,46 @@ + + + proyecto()->descripcion . '"'), 't' => 'proyecto'])}}"> + {{$resultado->proyecto()->descripcion}} + + + @if (method_exists($resultado, 'unidad')) + + + {{$resultado->unidad()->descripcion}} + @if ($resultado->estado == 0) + (r) + @elseif ($resultado->estado == -1) + (c) + @endif + + + + + propietario()->nombreCompleto() . '"'), 't' => 'propietario'])}}"> + {{$resultado->propietario()->nombreCompleto()}} + + + {{ucwords($resultado->unidad()->tipo()->descripcion)}} + {{\App\Helper\Format::m2($resultado->unidad()->m2())}} + {{\App\Helper\Format::ufs($resultado->valor_uf)}} + {{\App\Helper\Format::shortDate($resultado->fecha)}} + + @if ($resultado->entrega != 0) + {{\App\Helper\Format::shortDate($resultado->entrega()->fecha)}} + @endif + + @else + + {{$resultado->descripcion}} + + {{ucwords($resultado->tipo()->descripcion)}} + {{\App\Helper\Format::m2($resultado->m2())}} + @if ($resultado->valor) + {{format('ufs', $resultado->valor)}} + @else + + @endif + + @endif + \ No newline at end of file diff --git a/resources/views/calendario.blade.php b/resources/views/calendario.blade.php new file mode 100644 index 0000000..3a415fa --- /dev/null +++ b/resources/views/calendario.blade.php @@ -0,0 +1,17 @@ +
+ @foreach ($dias as $dia => $proyectos) +
+
{{format('localDate', $dia, 'ddd DD [de] MMMM [de] YYYY', true)}}
+
+ @foreach ($proyectos as $proyecto => $cantidad) +
+
+
{{$proyecto}}
+
+
{{$cantidad}}
+
+ @endforeach +
+
+ @endforeach +
diff --git a/resources/views/cierres.blade.php b/resources/views/cierres.blade.php new file mode 100644 index 0000000..aca4e46 --- /dev/null +++ b/resources/views/cierres.blade.php @@ -0,0 +1,31 @@ +

Cierres Vigentes

+
+ @foreach ($cierres as $proyecto => $cierre) +
+
{{$proyecto}} [{{$cierre->total}}]
+
+
+
+
Promesados
+
+
{{count($cierre->vigentes)}}
+
+
+
+
Pendientes
+ @if (count($cierre->pendientes) > 0) +
Desde {{$cierre->pendientes[0]->periodo()}} días atrás
+ @endif +
+
{{count($cierre->pendientes)}}
+
+
+
+
Rechazados
+
+
{{count($cierre->rechazados)}}
+
+
+
+ @endforeach +
diff --git a/resources/views/construccion.blade.php b/resources/views/construccion.blade.php new file mode 100644 index 0000000..2e4a1f9 --- /dev/null +++ b/resources/views/construccion.blade.php @@ -0,0 +1,5 @@ +@extends('layout.base') + +@section('content') +Sección en construcción. +@endsection \ No newline at end of file diff --git a/resources/views/contabilidad/pago.blade.php b/resources/views/contabilidad/pago.blade.php new file mode 100644 index 0000000..dd024a0 --- /dev/null +++ b/resources/views/contabilidad/pago.blade.php @@ -0,0 +1,20 @@ +@extends('layout.base') + +@section('content') +
+

Pagos del Mes - {{$proyecto->descripcion}} - {{$proyecto->inmobiliaria()->abreviacion}}

+
+

{{$fecha->format('d / m / Y')}}

+ {{!d($pagos)}} + + @foreach ($pagos as $pago) + + + + + + + + @endforeach +
{{$pago->Departamento}}{{$pago->Numero}}{{$pago->Total}}{{format('ufs', $pago->Valor->UF)}}{{format('pesos', $pago->Valor->Pesos)}}
+@endsection diff --git a/resources/views/contabilidad/pagos.blade.php b/resources/views/contabilidad/pagos.blade.php new file mode 100644 index 0000000..eda0d3e --- /dev/null +++ b/resources/views/contabilidad/pagos.blade.php @@ -0,0 +1,74 @@ +@extends('layout.base') + +@section('content') +
+

Pagos del Mes

+
+ + + + + + + + + + + + + +
Proyectos
NombreInmobiliaria
+@endsection + + +@push('scripts') + +@endpush diff --git a/resources/views/form/fecha.blade.php b/resources/views/form/fecha.blade.php new file mode 100644 index 0000000..9137a8f --- /dev/null +++ b/resources/views/form/fecha.blade.php @@ -0,0 +1,38 @@ + +
+
+
\ No newline at end of file diff --git a/resources/views/guest.blade.php b/resources/views/guest.blade.php new file mode 100644 index 0000000..fc12734 --- /dev/null +++ b/resources/views/guest.blade.php @@ -0,0 +1,57 @@ + + + + + + @if (isset($titulo)) + {{$titulo}} - + @endif + Incoviba S. A. + + + + + @stack('styles') + + +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+ Hola invitad@, favor ingresar. +
+
+
+@include('layout.footer') +@stack('scripts') + + \ No newline at end of file diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php new file mode 100644 index 0000000..1f7015e --- /dev/null +++ b/resources/views/home.blade.php @@ -0,0 +1,28 @@ +@extends('layout.base') + +@section('content') +@if ($hoy > 0) +
+
Hay {{$hoy}} deposito{{($hoy > 1) ? 's' : ''}} para hoy.
+
+@endif +@if ($pendientes > 0) + +@endif + + +@if (count($dias) > 0) + +@endif +@if (count($cierres) > 0) + +@endif + +
+ @include('calendario') + + @include('cierres') +
+@endsection diff --git a/resources/views/informes/comisiones.blade.php b/resources/views/informes/comisiones.blade.php new file mode 100644 index 0000000..235e714 --- /dev/null +++ b/resources/views/informes/comisiones.blade.php @@ -0,0 +1,49 @@ +@extends('layout.base') + +@section('content') +
+

Comisiones - {{$proyecto->descripcion}}

+
+ + + + + + + + + + + + + + + + + + + + + @foreach ($ventas as $venta) + + + + + + + + + + + + @endforeach + + + + + + + +
DepartamentoPropietarioEstacionamientosBodegasPrecioComisiónOperador
PromesaNeto%UF
{{$venta->unidad()->descripcion}}{{$venta->propietario()->nombreCompleto()}}{{implode(' - ', $venta->propiedad()->estacionamientos('array'))}}{{implode(' - ', $venta->propiedad()->bodegas('array'))}}{{format('ufs', $venta->valor_uf, null, true)}}{{format('ufs', $venta->valorCorredora(), null, true)}}1,5 %{{format('ufs', $venta->valorCorredora() * 1.5 / 100, null, true)}}{{($venta->agente != 0 and $venta->agente()->agente != 1) ? $venta->agente()->agente()->descripcion : ''}}
Total{{format('ufs', $totales->precio, null, true)}}{{format('ufs', $totales->neto, null, true)}}1,5 %{{format('ufs', $totales->comision, null, true)}}
+ +@endsection diff --git a/resources/views/informes/contabilidad.blade.php b/resources/views/informes/contabilidad.blade.php new file mode 100644 index 0000000..ff48b18 --- /dev/null +++ b/resources/views/informes/contabilidad.blade.php @@ -0,0 +1,68 @@ +@extends('layout.base') + +@section('content') +

Contabilidad

+
+
+
Mes
+
+
+
+
+@include('informes.proyectos', ['a' => 'contabilidad']) +
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/informes/escrituras.blade.php b/resources/views/informes/escrituras.blade.php new file mode 100644 index 0000000..069a1c7 --- /dev/null +++ b/resources/views/informes/escrituras.blade.php @@ -0,0 +1,6 @@ +@extends('layout.base') + +@section('content') +

Escrituras

+@include('informes.proyectos', ['a' => 'escrituras']) +@endsection \ No newline at end of file diff --git a/resources/views/informes/gantt_entregas.blade.php b/resources/views/informes/gantt_entregas.blade.php new file mode 100644 index 0000000..cca849f --- /dev/null +++ b/resources/views/informes/gantt_entregas.blade.php @@ -0,0 +1,6 @@ +@extends('layout.base') + +@section('content') +

Gantt de Entregas

+@include('informes.proyectos', ['a' => 'gantt_entregas']) +@endsection \ No newline at end of file diff --git a/resources/views/informes/para_comision.blade.php b/resources/views/informes/para_comision.blade.php new file mode 100644 index 0000000..5c369e4 --- /dev/null +++ b/resources/views/informes/para_comision.blade.php @@ -0,0 +1,25 @@ +@extends('layout.base') + +@section('content') +
+

Comisiones

+
+
+
+
+
Proyecto
+
+
+
+
Unidades
+
+
+
+
+
+ +@endsection diff --git a/resources/views/informes/proyectos.blade.php b/resources/views/informes/proyectos.blade.php new file mode 100644 index 0000000..f85f302 --- /dev/null +++ b/resources/views/informes/proyectos.blade.php @@ -0,0 +1,12 @@ +
+
Proyectos
+ +
diff --git a/resources/views/informes/resciliaciones.blade.php b/resources/views/informes/resciliaciones.blade.php new file mode 100644 index 0000000..5a527c3 --- /dev/null +++ b/resources/views/informes/resciliaciones.blade.php @@ -0,0 +1,6 @@ +@extends('layout.base') + +@section('content') +

Resciliaciones

+@include('informes.proyectos', ['a' => 'resciliaciones']) +@endsection diff --git a/resources/views/informes/resumen_contabilidad.blade.php b/resources/views/informes/resumen_contabilidad.blade.php new file mode 100644 index 0000000..abd6a68 --- /dev/null +++ b/resources/views/informes/resumen_contabilidad.blade.php @@ -0,0 +1,71 @@ +@extends('layout.base') + +@section('content') +

Resumen para Contabilidad

+ +
+
+
Hasta Mes
+
+
+
+
+@include('informes.proyectos', ['a' => 'resumen_contabilidad']) +
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/informes/ventas.blade.php b/resources/views/informes/ventas.blade.php new file mode 100644 index 0000000..0072b3f --- /dev/null +++ b/resources/views/informes/ventas.blade.php @@ -0,0 +1,6 @@ +@extends('layout.base') + +@section('content') +

Ventas

+@include('informes.proyectos', ['a' => 'ventas']) +@endsection diff --git a/resources/views/inmobiliarias/add.blade.php b/resources/views/inmobiliarias/add.blade.php new file mode 100644 index 0000000..e1fb3f0 --- /dev/null +++ b/resources/views/inmobiliarias/add.blade.php @@ -0,0 +1,50 @@ +@extends('layout.base') + +@section('content') +
+

Agregar Inmobiliaria

+
+
+
+
+
RUT
+
+
+
+
Razón Social
+
+
+ +
+
+
+
Abreviación
+
+
+
+
+
+
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/inmobiliarias/edit.blade.php b/resources/views/inmobiliarias/edit.blade.php new file mode 100644 index 0000000..036da70 --- /dev/null +++ b/resources/views/inmobiliarias/edit.blade.php @@ -0,0 +1,54 @@ +@extends('layout.base') + +@section('content') + +
+
+
+
RUT
+
+
+
+
+
Abreviación
+
+
+
+
Razón Social
+
+
+ +
+
+
+
Banco
+
+
+
+
Cuenta
+
+
+
+
+
+
+@endsection diff --git a/resources/views/inmobiliarias/list.blade.php b/resources/views/inmobiliarias/list.blade.php new file mode 100644 index 0000000..6a130ae --- /dev/null +++ b/resources/views/inmobiliarias/list.blade.php @@ -0,0 +1,31 @@ +@extends('layout.base') + +@section('content') +
+
Inmobiliarias
+
+ + + +
+
+
+
+ @foreach ($inmobiliarias as $inmobiliaria) +
+
+ +
+ {{$inmobiliaria->rut()}} +
+
+ {{$inmobiliaria->razon(true)}} +
+
+
+ @endforeach +
+
+@endsection diff --git a/resources/views/inmobiliarias/show.blade.php b/resources/views/inmobiliarias/show.blade.php new file mode 100644 index 0000000..baa2de8 --- /dev/null +++ b/resources/views/inmobiliarias/show.blade.php @@ -0,0 +1,47 @@ +@extends('layout.base') + +@section('content') +
+
+

Inmobiliaria {{$inmobiliaria->nombre()}}

+
+
+ + + +
+
+
+
+
RUT
+
{{format('rut', $inmobiliaria->rut)}}-{{$inmobiliaria->dv}}
+
+
+
Razón Social
+
{{$inmobiliaria->razon(true)}}
+
+@if ($inmobiliaria->banco != 0) +
+
Cuenta
+
{{$inmobiliaria->banco()->nombre}}
+
{{$inmobiliaria->cuenta}}
+
+@endif +
+
+
Proyectos
+
+
+
+
+ + @foreach ($inmobiliaria->proyectos() as $proyecto) + + + + + @endforeach +
{{$proyecto->descripcion}}{{$proyecto->estado()->tipo()->etapa()->descripcion}}
+
+
+@endsection diff --git a/resources/views/install/admin.blade.php b/resources/views/install/admin.blade.php new file mode 100644 index 0000000..aff2dc3 --- /dev/null +++ b/resources/views/install/admin.blade.php @@ -0,0 +1,47 @@ +@extends('install.base') + +@section('content') +

Create Admin

+
+
+
Username
+
+
+
+
Password
+
+
+
+
+
+
+
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/install/base.blade.php b/resources/views/install/base.blade.php new file mode 100644 index 0000000..5e0d73f --- /dev/null +++ b/resources/views/install/base.blade.php @@ -0,0 +1,38 @@ + + + + + + @if (isset($titulo)) + {{$titulo}} - + @endif + Incoviba S. A. + + + + + @stack('styles') + + +
+
+
+
+
+ +
+
+
+
+
+
+
+
+ @yield('content') +
+
+
+@include('layout.footer') +@stack('scripts') + + diff --git a/resources/views/install/end.blade.php b/resources/views/install/end.blade.php new file mode 100644 index 0000000..aeb7692 --- /dev/null +++ b/resources/views/install/end.blade.php @@ -0,0 +1,5 @@ +@extends('install.base') + +@section('content') +Installation ended. Go to Inicio. Remember to remove install folder. +@endsection diff --git a/resources/views/install/start.blade.php b/resources/views/install/start.blade.php new file mode 100644 index 0000000..2b18d4f --- /dev/null +++ b/resources/views/install/start.blade.php @@ -0,0 +1,6 @@ +@extends('install.base') + +@section('content') +Start Installation +Create Tables +@endsection diff --git a/resources/views/layout/base.blade.php b/resources/views/layout/base.blade.php new file mode 100644 index 0000000..ac17257 --- /dev/null +++ b/resources/views/layout/base.blade.php @@ -0,0 +1,31 @@ + + + + + + @if (isset($titulo)) + {{$titulo}} - + @endif + Incoviba S. A. + + + + + + + + @stack('styles') + + +@include('layout.header') +
+
+
+ @yield('content') +
+
+
+@include('layout.footer') +@stack('scripts') + + diff --git a/resources/views/layout/footer.blade.php b/resources/views/layout/footer.blade.php new file mode 100644 index 0000000..e69de29 diff --git a/resources/views/layout/header.blade.php b/resources/views/layout/header.blade.php new file mode 100644 index 0000000..fe8bc64 --- /dev/null +++ b/resources/views/layout/header.blade.php @@ -0,0 +1,16 @@ +
+
+
+
+
+ +
+
+
+
+
+ @include('layout.menu') +
+
+
+
\ No newline at end of file diff --git a/resources/views/layout/icons/abonar.blade.php b/resources/views/layout/icons/abonar.blade.php new file mode 100644 index 0000000..8530ae1 --- /dev/null +++ b/resources/views/layout/icons/abonar.blade.php @@ -0,0 +1 @@ + diff --git a/resources/views/layout/icons/add.blade.php b/resources/views/layout/icons/add.blade.php new file mode 100644 index 0000000..105550d --- /dev/null +++ b/resources/views/layout/icons/add.blade.php @@ -0,0 +1,5 @@ + diff --git a/resources/views/layout/icons/edit.blade.php b/resources/views/layout/icons/edit.blade.php new file mode 100644 index 0000000..cbd6f12 --- /dev/null +++ b/resources/views/layout/icons/edit.blade.php @@ -0,0 +1,5 @@ + diff --git a/resources/views/layout/icons/pagar.blade.php b/resources/views/layout/icons/pagar.blade.php new file mode 100644 index 0000000..5d5a5e7 --- /dev/null +++ b/resources/views/layout/icons/pagar.blade.php @@ -0,0 +1 @@ + diff --git a/resources/views/layout/icons/remove.blade.php b/resources/views/layout/icons/remove.blade.php new file mode 100644 index 0000000..d52922f --- /dev/null +++ b/resources/views/layout/icons/remove.blade.php @@ -0,0 +1,5 @@ + diff --git a/resources/views/layout/icons/show.blade.php b/resources/views/layout/icons/show.blade.php new file mode 100644 index 0000000..2fbeba9 --- /dev/null +++ b/resources/views/layout/icons/show.blade.php @@ -0,0 +1,9 @@ + diff --git a/resources/views/layout/menu.blade.php b/resources/views/layout/menu.blade.php new file mode 100644 index 0000000..670e00d --- /dev/null +++ b/resources/views/layout/menu.blade.php @@ -0,0 +1,62 @@ + diff --git a/resources/views/layout/menu.blade.php.save b/resources/views/layout/menu.blade.php.save new file mode 100644 index 0000000..c82be1c --- /dev/null +++ b/resources/views/layout/menu.blade.php.save @@ -0,0 +1,62 @@ + diff --git a/resources/views/layout/menu/herramientas.blade.php b/resources/views/layout/menu/herramientas.blade.php new file mode 100644 index 0000000..9c8cf05 --- /dev/null +++ b/resources/views/layout/menu/herramientas.blade.php @@ -0,0 +1,3 @@ + diff --git a/resources/views/layout/menu/informes.blade.php b/resources/views/layout/menu/informes.blade.php new file mode 100644 index 0000000..b5a9221 --- /dev/null +++ b/resources/views/layout/menu/informes.blade.php @@ -0,0 +1,4 @@ + diff --git a/resources/views/layout/menu/inmobiliarias.blade.php b/resources/views/layout/menu/inmobiliarias.blade.php new file mode 100644 index 0000000..cbaf3e8 --- /dev/null +++ b/resources/views/layout/menu/inmobiliarias.blade.php @@ -0,0 +1,3 @@ + diff --git a/resources/views/layout/menu/login.blade.php b/resources/views/layout/menu/login.blade.php new file mode 100644 index 0000000..2e310b1 --- /dev/null +++ b/resources/views/layout/menu/login.blade.php @@ -0,0 +1,8 @@ + diff --git a/resources/views/layout/menu/proyectos.blade.php b/resources/views/layout/menu/proyectos.blade.php new file mode 100644 index 0000000..cd4f349 --- /dev/null +++ b/resources/views/layout/menu/proyectos.blade.php @@ -0,0 +1,4 @@ + diff --git a/resources/views/layout/menu/ventas.blade.php b/resources/views/layout/menu/ventas.blade.php new file mode 100644 index 0000000..1505f1d --- /dev/null +++ b/resources/views/layout/menu/ventas.blade.php @@ -0,0 +1,24 @@ + diff --git a/resources/views/other/capacidades.blade.php b/resources/views/other/capacidades.blade.php new file mode 100644 index 0000000..54abaa3 --- /dev/null +++ b/resources/views/other/capacidades.blade.php @@ -0,0 +1,21 @@ +@extends('layout.base') + +@section('content') +
+

Capacidades

+
+ + +@foreach ($capacidades as $method) +@if ($class != $method->class) +class ?> + + + +@endif + + + +@endforeach +
{{\Stringy\Stringy::create($method->class)->replace('App\\Controller\\', '')}}
{{\Stringy\Stringy::create($method->class)->replace('App\\Controller\\', '')}}::{{$method->name}}
+@endsection \ No newline at end of file diff --git a/resources/views/other/entregar_multiple.blade.php b/resources/views/other/entregar_multiple.blade.php new file mode 100644 index 0000000..fe131d5 --- /dev/null +++ b/resources/views/other/entregar_multiple.blade.php @@ -0,0 +1,26 @@ +@extends('layout.base') + +@section('content') +
+
+
Archivo
+
+
+
+
archivo CSV con separador ';'. 2 columnas: Departamento; Fecha
+
+
+
Proyecto
+
+ +
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/print/devolucion.blade.php b/resources/views/print/devolucion.blade.php new file mode 100644 index 0000000..8ed35c1 --- /dev/null +++ b/resources/views/print/devolucion.blade.php @@ -0,0 +1,136 @@ +@extends('layout.base') + +@section('content') +
+
Devolución Por Pago Excesivo
+

+ + + + + + + + + + + + + + + + + + + + + + + + +
Fecha{{$f->formatLocalized('%A, %d de %B de %Y')}}
Inmobiliaria{{$venta->proyecto()->inmobiliaria()->razon}}
Proyecto{{$venta->proyecto()->descripcion}}
Propiedad{{$venta->unidad()->descripcion}}
Propietario{{$venta->propietario()->nombreCompleto()}}
+
+ + + + + + + + + + + + @if ($venta->pie) + pie()->valorAbonado('ufs') ?> + + + + + + @if ($venta->pie()->reajuste and $venta->pie()->reajuste()->estado()->estado == 2) + pie()->reajuste()->valor('ufs') ?> + + + + + + @endif + @endif + @if ($venta->escritura and $venta->escritura()->estado()->estado == 2) + pie()->escritura()->valor('ufs') ?> + + + + + + @endif + @if ($venta->subsidio) + subsidio()->total('ufs') ?> + + + + + + @endif + @if ($venta->bono_pie) + bonoPie()->pago()->valor('ufs') ?> + + + + + + @endif + @if ($venta->credito) + credito()->pago()->valor('ufs') ?> + + + + + + @endif + + + + + +
PagoDetalleValor Pagado
Pie@if ($venta->pie()->cuotas > 1) {{count($venta->pie()->abonadas())}} cuotas @else contado @endif{{format('ufs', $venta->pie()->valorAbonado('ufs'), null, true)}}
Reajuste de Pie{{format('ufs', $venta->pie()->reajuste()->valor('ufs'), null, true)}}
Abono en Escritura{{format('ufs', $venta->escritura()->valor('ufs'), null, true)}}
SubsidioAhorro: {{format('ufs', $venta->subsidio()->pago()->valor('ufs'), null, true)}}{{format('ufs', $venta->subsidio()->total('ufs'), null, true)}}
Bono Pie{{format('ufs', $venta->bonoPie()->pago()->valor('ufs'))}}
CréditoBanco: {{$venta->credito()->pago()->banco()->nombre}}{{format('ufs', $venta->credito()->pago()->valor('ufs'), null, true)}}
TOTAL{{format('ufs', $sum, null, true)}}
+
+
Valor Venta
+
{{format('ufs', $venta->valor('ufs'), null, true)}}
+
+
Devolución
+
{{format('ufs', $venta->saldo('ufs'), null, true)}}
+
+
+
Valor de UF a la fecha
+
$ {{format('ufs', $uf = uf($f)->uf->value)}}
+
+
+
Total a Devolver
+
{{format('pesos', $uf * $venta->saldo('ufs'), null, true)}}
+
+
+
+
+ + + + + + + + + + + + + + + + + + +
Nombre
RUT
Fecha
Firma
+
+@endsection diff --git a/resources/views/proyectos/add.blade.php b/resources/views/proyectos/add.blade.php new file mode 100644 index 0000000..f6dc269 --- /dev/null +++ b/resources/views/proyectos/add.blade.php @@ -0,0 +1,80 @@ +@extends('layout.base') + +@section('content') +
+

Agregar Proyecto

+
+
+
+
+
Nombre
+
+
+
+
Inmobiliaria
+
+
+
+
Dirección
+
+
+
+
+
+
+
+
+
+
Fecha de Inicio
+ @include('form.fecha') +
+
+
+
+
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/proyectos/advance.blade.php b/resources/views/proyectos/advance.blade.php new file mode 100644 index 0000000..78b2dd1 --- /dev/null +++ b/resources/views/proyectos/advance.blade.php @@ -0,0 +1,98 @@ +@extends('layout.base') + +@section('content') +
+

Avanzar Proyecto

+
+
+@if ($proyecto->estado()->tipo()->etapa()->descripcion == 'Construcción' and (float) $proyecto->avances()[count($proyecto->avances())-1]->avance < 1) +
+
+

{{$proyecto->descripcion}}

+
+
+
{{$proyecto->estado()->tipo()->descripcion}}
+
{{format('shortDate', $proyecto->estado()->fecha)}}
+
+
+
Fecha
+ @include('form.fecha') +
+
+
% Avance
+
+
+
+
Estado de Pago
+
+
+
+
Valor Estado de Pago [UF]
+
+
+
+
+
+
+@else +
+
+

{{$proyecto->descripcion}}

+
+
+
{{$proyecto->estado()->tipo()->descripcion}}
+
{{format('shortDate', $proyecto->estado()->fecha)}}
+
+
+
Nuevo Estado
+
+
+
+
Fecha
+
+
+
+
+
+
+
+
+@endif +@endsection diff --git a/resources/views/proyectos/avance.blade.php b/resources/views/proyectos/avance.blade.php new file mode 100644 index 0000000..50eb3be --- /dev/null +++ b/resources/views/proyectos/avance.blade.php @@ -0,0 +1,15 @@ +
+ estado()->tipo()->orden < max($estados) - 1 and count($proyecto->estados()) > 1) { + $tf = \Carbon\Carbon::parse($proyecto->estado()->fecha, config('app.timezone')); + $t0 = \Carbon\Carbon::parse($proyecto->estados()[0]->fecha, config('app.timezone')); + $df = $tf->diffInSeconds($t0); + $hoy = \Carbon\Carbon::now(config('app.timezone')); + $dh = $hoy->diffInSeconds($t0); + $total = $df / $dh; + } + $valor = round(($proyecto->estado()->tipo()->orden + 1) / max($estados) * 100 * $total); + ?> +
{{$valor}}%
+
diff --git a/resources/views/proyectos/avances/edit.blade.php b/resources/views/proyectos/avances/edit.blade.php new file mode 100644 index 0000000..d7a621f --- /dev/null +++ b/resources/views/proyectos/avances/edit.blade.php @@ -0,0 +1,39 @@ +@extends('layout.base') + +@section('content') +
+

Edit Avance - {{$avance->proyecto()->descripcion}}

+
+
+
+
+
Estado de Pago
+
{{$avance->numero}}
+
+
+
Fecha
+ fecha() ?> + @include('form.fecha') +
+
+
% Avance
+
+
+
+
Valor Estado de Pago [UF]
+
+
+
+
Pagado [$]
+
+
+
+
Fecha
+ fechaPago(); $id = '_pago' ?> + @include('form.fecha') +
+
+
+
+
+@endsection diff --git a/resources/views/proyectos/avances_row.blade.php b/resources/views/proyectos/avances_row.blade.php new file mode 100644 index 0000000..e6a4ae5 --- /dev/null +++ b/resources/views/proyectos/avances_row.blade.php @@ -0,0 +1,27 @@ + + EP {{$avance->numero}} + {{$avance->pagare()->id}} + +
+
+ {{format('percent', round($avance->avance * 100, 2))}}% + @if ($avance->avance > 0.3) + {{format('percent', round($avance->avance * 100, 2))}}% + @endif +
+
+ {{format('percent', round(100 - $avance->avance * 100, 2))}}% + @if ($avance->avance <= 0.3) + {{format('percent', round($avance->avance * 100, 2))}}% + @endif +
+
+ + {{format('shortDate', $avance->fecha)}} + {{format('ufs', $avance->estado_pago)}} + {{format('shortDate', $avance->pagare()->fecha)}} + {{format('ufs', $avance->pagare()->valor())}} + {{format('ufs', $total_avance)}} + {{format('ufs', $total_deuda)}} + {{format('ufs', $total_dif)}} + diff --git a/resources/views/proyectos/construccion.blade.php b/resources/views/proyectos/construccion.blade.php new file mode 100644 index 0000000..6472ba2 --- /dev/null +++ b/resources/views/proyectos/construccion.blade.php @@ -0,0 +1,336 @@ +@extends('layout.base') + +@section('content') +
+
+

Construcción Proyecto {{$proyecto->descripcion}}

+
+
+
+
+
+
Estado de Pago
+
Avance
+
+
+
+ @foreach ($proyecto->avances() as $avance) +
+
+ @if ($avance->numero == 0) + Anticipo + @else + {{$avance->numero}} + @endif +
+
+
+
+ {{format('percent', round($avance->avance * 100, 2))}}% + @if ($avance->avance > 0.3) + {{format('percent', round($avance->avance * 100, 2))}}% + @endif +
+
+ {{format('percent', round(100 - $avance->avance * 100, 2))}}% + @if ($avance->avance <= 0.3) + {{format('percent', round($avance->avance * 100, 2))}}% + @endif +
+
+
+
+ @endforeach +
+
+ + + + + + + + + + + + + + + + + + + + + + + (object) [ + 'pagado' => 0, + 'real' => 0, + 'dif' => 0 + ], + 'deuda' => (object) [ + 'pagare' => 0, + 'abonado' => 0, + 'dif' => 0, + 'intereses' => 0 + ], + 'dif' => 0, + 'dif_real' => 0 + ] ?> + @foreach ($proyecto->avances() as $i => $avance) + avance->pagado += $avance->estado_pago; + $totales->avance->real += $avance->pagado(); + if ($avance->pagado() > 0) { + $totales->avance->dif += $avance->pagado() - $avance->estado_pago; + } + if ($avance->pagares()) { + $arr = $avance->pagares(); + $totales->deuda->pagare += array_reduce($arr, function($sum, $item) { + return $sum + $item->valor(); + }); + $totales->deuda->abonado += array_reduce($arr, function($sum, $item) { + return $sum + $item->abonado(); + }); + $totales->deuda->dif += array_reduce($arr, function($sum, $item) { + return $sum + $item->abonado() - $item->valor(); + }); + $totales->deuda->intereses += array_reduce($arr, function($sum, $item) { + return $sum + $item->intereses(); + }); + $totales->dif += array_reduce($arr, function($sum, $item) { + return $sum + $item->valor(); + }) - $avance->estado_pago; + } + ?> + + + + + + + + + + + + + + + @endforeach + + + + + + + + + + + + + +
+ Estado de Pago + + + + Pagado + Pagaré + + + + Deuda
FechaValorRealDiferenciaFechaValorAbonadoDiferenciaIntereses% Intereses
+ + @if ($avance->numero == 0) + Anticipo + @else + {{$avance->numero}} + @endif + + {{format('shortDate', $avance->fecha)}}{{format('ufs', $avance->estado_pago)}} + @if ($avance->pagado() > 0) + {{format('ufs', $avance->pagado())}} + @endif + + @if ($avance->pagado() > 0) + {{format('ufs', $avance->estado_pago - $avance->pagado())}} + @endif + + @if ($avance->pagares()) + @foreach ($avance->pagares() as $pagare) + + {{$pagare->id}} ({{$pagare->moneda()->descripcion}}) +
+ @endforeach + @else + -- + @endif +
+ @if ($avance->pagares()) + @foreach ($avance->pagares() as $pagare) + {{format('shortDate', $pagare->fecha)}} ({{$pagare->duracion}})
+ @endforeach + @endif +
+ @if ($avance->pagares()) + @foreach ($avance->pagares() as $pagare) + {{format('ufs', $pagare->valor())}}
+ @endforeach + @endif +
+ @if ($avance->pagares()) + @foreach ($avance->pagares() as $pagare) + {{format('ufs', $pagare->abonado())}}
+ @endforeach + @endif +
+ @if ($avance->pagare()) + {{format('ufs', $pagare->abonado() - $pagare->valor())}} + @endif + + @if ($avance->pagares()) + @foreach ($avance->pagares() as $pagare) + {{format('ufs', - $pagare->intereses())}}
+ @endforeach + @endif +
+ @if ($avance->pagares()) + @foreach ($avance->pagares() as $pagare) + {{format('percent', round($pagare->intereses() / $pagare->valor() * 100, 2), null, true)}}
+ @endforeach + @endif +
Total{{format('ufs', $totales->avance->pagado)}}{{format('ufs', $totales->avance->real)}}{{format('ufs', - $totales->avance->dif)}}{{format('ufs', $totales->deuda->pagare)}}{{format('ufs', $totales->deuda->abonado)}}{{format('ufs', $totales->deuda->dif)}}{{format('ufs', - $totales->deuda->intereses)}}
+
+
+ Diferencias en Caja +
+
+ +
+
+
+
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/proyectos/disponibles.blade.php b/resources/views/proyectos/disponibles.blade.php new file mode 100644 index 0000000..ae0ed0b --- /dev/null +++ b/resources/views/proyectos/disponibles.blade.php @@ -0,0 +1,36 @@ +@extends('layout.base') + +@section('content') +
+
Unidades Disponibles - {{$proyecto->descripcion}} [{{count($proyecto->unidadesDisponibles())}}]
+
+
+
+ + + + + + + + + + + + @foreach ($proyecto->unidadesDisponibles() as $unidad) + + + + + + + + @endforeach + +
TipoUnidadPisom² VendiblesValor Referencial
{{ucwords($unidad->tipo()->descripcion)}}{{$unidad->descripcion}}{{$unidad->piso}} + @if ($unidad->tipo == 1) + {{$unidad->m2('vendible')}} + @endif + {{format('ufs', (($unidad->precio()) ? $unidad->precio()->valor : $unidad->valor) ?: 0, null, true)}}
+
+@endsection \ No newline at end of file diff --git a/resources/views/proyectos/estimado.blade.php b/resources/views/proyectos/estimado.blade.php new file mode 100644 index 0000000..c650e26 --- /dev/null +++ b/resources/views/proyectos/estimado.blade.php @@ -0,0 +1,42 @@ +@if (count($proyecto->ventas()) > 0 and $proyecto->valores()->estimados->departamentos->cantidad > 0) + + Estimado Total + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ UF Total
+ Bruto - Neto +
UF/m² NetoUF Promedio
{{format('ufs', $proyecto->valores()->vendidos->ingreso->bruto + $proyecto->valores()->estimados->ingreso->bruto, null, true)}} - {{format('ufs', $proyecto->valores()->vendidos->ingreso->neto + $proyecto->valores()->estimados->ingreso->neto, null, true)}}{{format('ufs', ($proyecto->valores()->vendidos->ingreso->neto + $proyecto->valores()->estimados->ingreso->neto) / $proyecto->superficie('vendible'), null, true)}}{{format('ufs', ($proyecto->valores()->vendidos->ingreso->neto + $proyecto->valores()->estimados->ingreso->neto) / count($proyecto->unidades(1)), null, true)}}
Estacionamientos y Bodegas
{{format('ufs', $proyecto->valores()->vendidos->otros->valor + $proyecto->valores()->estimados->otros->valor, null, true)}}
Total{{format('ufs', $proyecto->valores()->vendidos->ingreso->neto + $proyecto->valores()->estimados->ingreso->neto + $proyecto->valores()->vendidos->otros->valor + $proyecto->valores()->estimados->otros->valor, null, true)}}
+ + +@endif diff --git a/resources/views/proyectos/historia.blade.php b/resources/views/proyectos/historia.blade.php new file mode 100644 index 0000000..cc36840 --- /dev/null +++ b/resources/views/proyectos/historia.blade.php @@ -0,0 +1,74 @@ +@extends('layout.base') + +@section('content') +
+
+

+
+ Historial Proyecto {{$proyecto->descripcion}} +
+
+ + + +
+

+
+
+ + + + + + + + + + + estados() as $estado) { + $estados[$estado->fecha] []= $estado; + } + ksort($estados); + $ff = null; + ?> + @foreach ($estados as $fecha => $es) + tipo()->orden - $b->tipo()->orden; + }); + $estado = $es[count($es) - 1]; + ?> + + + + + + + + @endforeach + +
EtapaEstadoFechaDuración
+ @if ($estado->tipo()->etapa()->descripcion == 'Construcción') + + @endif + {{$estado->tipo()->etapa()->descripcion}} + @if ($estado->tipo()->etapa()->descripcion == 'Construcción') + + @endif + {{$estado->tipo()->descripcion}} + @if ($f->timestamp > 0) + {{$f->format('d M Y')}} + @else + -- + @endif + + @if ($ff !== null) + {{$f->longAbsoluteDiffForHumans($ff)}} + @endif +
+
+
+@endsection diff --git a/resources/views/proyectos/historia.blade.php.old b/resources/views/proyectos/historia.blade.php.old new file mode 100644 index 0000000..62497c9 --- /dev/null +++ b/resources/views/proyectos/historia.blade.php.old @@ -0,0 +1,82 @@ +@extends('layout.base') + +@section('content') +
+
+

+
+ Historial Proyecto {{$proyecto->descripcion}} +
+
+ + + +
+

+
+
+ + + + + + + + + + estados() as $estado) { + $estados[$estado->fecha] []= $estado; + } + ksort($estados); + $ff = \Carbon\Carbon::parse('0', config('app.timezone')); + ?> + @foreach ($estados as $fecha => $es) + tipo()->orden - $b->tipo()->orden; + }); + ?> + + + + + + + @endforeach + +
FechaDuración
{{$f->format('d M Y')}} + + + + + + + + + @foreach ($es as $estado) + + + + + @endforeach + +
EtapaEstado
+ @if ($estado->tipo()->etapa()->descripcion == 'Construcción') + + @endif + {{$estado->tipo()->etapa()->descripcion}} + @if ($estado->tipo()->etapa()->descripcion == 'Construcción') + + @endif + {{$estado->tipo()->descripcion}}
+
+ @if ($f->diffInYears($ff) < 100) + {{$f->longAbsoluteDiffForHumans($ff)}} + @endif +
+
+
+@endsection diff --git a/resources/views/proyectos/list.blade.php b/resources/views/proyectos/list.blade.php new file mode 100644 index 0000000..51c3365 --- /dev/null +++ b/resources/views/proyectos/list.blade.php @@ -0,0 +1,42 @@ +@extends('layout.base') + +@section('content') +
+
+
+
+ Proyectos +
+
+ + + +
+
+
+
+ + + + + + + + + + + + @foreach ($proyectos as $proyecto) + + + + + + + + @endforeach + +
ProyectoInmobiliariaEtapaEstadoTiempo Total
{{$proyecto->descripcion}}{{$proyecto->inmobiliaria()->abreviacion}}{{$proyecto->estado()->tipo()->etapa()->descripcion}}{{$proyecto->estado()->tipo()->descripcion}} ({{\Carbon\Carbon::parse($proyecto->estado()->fecha, config('app.timezone'))->diffForHumans()}}) + {{\Carbon\Carbon::parse($proyecto->estados()[0]->fecha, config('app.timezone'))->diffForHumans()}} +
+@endsection diff --git a/resources/views/proyectos/operadores/add.blade.php b/resources/views/proyectos/operadores/add.blade.php new file mode 100644 index 0000000..4bf6a7a --- /dev/null +++ b/resources/views/proyectos/operadores/add.blade.php @@ -0,0 +1,29 @@ +@extends('layout.base') + +@section('content') +
+

Agregar Operadores - {{$proyecto->descripcion}}

+
+
+
+
+
Operadores
+
+ +
+
+
+
+ +
+
+
+@endsection diff --git a/resources/views/proyectos/pagares/add.blade.php b/resources/views/proyectos/pagares/add.blade.php new file mode 100644 index 0000000..2975bc8 --- /dev/null +++ b/resources/views/proyectos/pagares/add.blade.php @@ -0,0 +1,62 @@ +@extends('layout.base') + +@section('content') +
+

Agregar Pagaré + + + +

+
+
+
+
+
Estado Pago
+
+
+
+
Número
+
+
+
+
Moneda
+
+ +
+
+
+
Capital
+
+
+
+
Tasa [%]
+
+
+
+
Fecha Otorgado
+ + @include('form.fecha') +
+
+
Duración
+
+
+
+
Fecha Abonado
+ + @include('form.fecha') +
+
+
Monto Abonado [$]
+
+
+
+
+ +
+
+
+@endsection diff --git a/resources/views/proyectos/pagares/add_renovacion.blade.php b/resources/views/proyectos/pagares/add_renovacion.blade.php new file mode 100644 index 0000000..5bfa350 --- /dev/null +++ b/resources/views/proyectos/pagares/add_renovacion.blade.php @@ -0,0 +1,44 @@ +@extends('layout.base') + +@section('content') +
+

Agregar Renovación Pagaré {{$pagare->id}} +

+
+
+
+
+
Fecha
+ + @include('form.fecha') +
+
+
Duración [días]
+
+
* Pagaré {{$pagare->duracion}}
+
+
+
Monto Insoluto [{{$pagare->moneda()->descripcion}}]
+
+
+
+
Tasa [%]
+
+
* Pagaré {{format('percent', $pagare->tasa, null, true)}}
+
+
+
Intereses [$]
+
+
+
+
Fecha Abono
+ + @include('form.fecha') +
+
+
+ +
+
+
+@endsection diff --git a/resources/views/proyectos/pagares/edit.blade.php b/resources/views/proyectos/pagares/edit.blade.php new file mode 100644 index 0000000..16e33b3 --- /dev/null +++ b/resources/views/proyectos/pagares/edit.blade.php @@ -0,0 +1,66 @@ +@extends('layout.base') + +@section('content') +
+

Pagaré {{$pagare->id}}

+
+
+
+
+
Estado Pago
+
+
+
+
Número
+
+
+
+
Moneda
+
+ +
+
+
+
Capital
+
+
+
+
Tasa [%]
+
+
+
+
Fecha Otorgado
+ fechaBanco(); $id = '_banco' ?> + @include('form.fecha') +
+
+
Duración
+
+
+
+
Fecha Abonado
+ fecha(); unset($id) ?> + @include('form.fecha') +
+
+
Monto Abonado [$]
+
+
+
+
+ +
+
+
+@endsection diff --git a/resources/views/proyectos/pagares/edit_renovacion.blade.php b/resources/views/proyectos/pagares/edit_renovacion.blade.php new file mode 100644 index 0000000..54bae95 --- /dev/null +++ b/resources/views/proyectos/pagares/edit_renovacion.blade.php @@ -0,0 +1,45 @@ +@extends('layout.base') + +@section('content') +
+

Renovación + {{array_search($renovacion, $renovacion->pagare()->renovaciones()) + 1}} + Pagaré {{$renovacion->pagare}} +

+
+
+
+
+
Fecha
+ fechaBanco(); $id = '_banco' ?> + @include('form.fecha') +
+
+
Duración [días]
+
+
+
+
Monto Insoluto [{{$renovacion->pagare()->moneda()->descripcion}}]
+
+
+
+
Tasa [%]
+
+
* Pagaré {{format('percent', $renovacion->pagare()->tasa, null, true)}}
+
+
+
Intereses [$]
+
+
+
+
Fecha Abono
+ fecha(); unset($id) ?> + @include('form.fecha') +
+
+
+ +
+
+
+@endsection diff --git a/resources/views/proyectos/pagares/show.blade.php b/resources/views/proyectos/pagares/show.blade.php new file mode 100644 index 0000000..25750b5 --- /dev/null +++ b/resources/views/proyectos/pagares/show.blade.php @@ -0,0 +1,100 @@ +@extends('layout.base') + +@section('content') +
+
+ Pagaré {{$pagare->id}} + + + +
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Estado Pago + {{$pagare->estado_pago}} +
Moneda{{$pagare->moneda()->descripcion}}
Capital{{format('ufs', $pagare->valor(), null, true)}}{{format('pesos', $pagare->valor('pesos'), null, true)}}{{format('shortDate', $pagare->fecha_banco)}}
Abonado{{format('ufs', $pagare->abonado(), null, true)}}{{format('pesos', $pagare->abonado('pesos'), null, true)}} + @if ($pagare->fecha != '0000-00-00') + {{format('shortDate', $pagare->fecha)}} + @endif +
Tasa Anualizada{{format('percent', $pagare->tasa, null, true)}}
Duración{{$pagare->duracion}}{{format('shortDate', $pagare->vencimiento()->format('Y-m-d'))}}
+ @if ($pagare->renovaciones()) + + + + + + + + + + + + + + @foreach ($pagare->renovaciones() as $renovacion) + intereses() ?> + + + + + + @endforeach + + + + + +
Renovaciones
Fecha RenovaciónIntereses Pagados + + + +
+ {{format('shortDate', $renovacion->fecha)}} + ({{$renovacion->duracion}}) + {{format('shortDate', $renovacion->vencimiento()->format('Y-m-d'))}} + {{format('ufs', $renovacion->intereses(), null, true)}} + + + +
Total{{format('ufs', $total, null, true)}}
+ @else + Agregar Renovación + @endif +@endsection diff --git a/resources/views/proyectos/por_vender.blade.php b/resources/views/proyectos/por_vender.blade.php new file mode 100644 index 0000000..4be7573 --- /dev/null +++ b/resources/views/proyectos/por_vender.blade.php @@ -0,0 +1,66 @@ +@if (count($proyecto->unidades()) > 0 and $proyecto->valores()->estimados->departamentos->cantidad > 0) + + Por vender + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#% Por Venderm² promedio
{{$proyecto->valores()->estimados->departamentos->cantidad}}{{\App\Helper\Format::number($proyecto->valores()->estimados->departamentos->cantidad / count($proyecto->unidades(1)) * 100, 2)}} %{!!format('m2', $proyecto->valores()->estimados->departamentos->mts->vendibles->promedio, null, true)!!}
UF Estimado
+ Bruto - Neto +
UF/m² NetoUF promedio
{{format('ufs', $proyecto->valores()->estimados->ingreso->bruto, null, true)}} - {{format('ufs', $proyecto->valores()->estimados->ingreso->neto, null, true)}}{{format('ufs', $proyecto->valores()->estimados->departamentos->uf_m2->promedio, null, true)}}{{format('ufs', $proyecto->valores()->estimados->departamentos->precio->promedio, null, true)}}
EstacionamientosBodegasValor Estimado
{{count($proyecto->unidadesDisponibles(2))}}{{count($proyecto->unidadesDisponibles(3))}}{{format('ufs', $proyecto->valores()->estimados->otros->valor, null, true)}}
OperadorBono PiePremios
{{format('ufs', $proyecto->valores()->estimados->comision, null, true)}}{{format('ufs', $proyecto->valores()->estimados->bono->valor, null, true)}}{{format('ufs', $proyecto->valores()->estimados->premios(), null, true)}}
+ + +@endif diff --git a/resources/views/proyectos/reservas/base.blade.php b/resources/views/proyectos/reservas/base.blade.php new file mode 100644 index 0000000..eb54ae1 --- /dev/null +++ b/resources/views/proyectos/reservas/base.blade.php @@ -0,0 +1,72 @@ +@extends('layout.base') + +@section('content') +

+ + + Ventas y Reservas - {{$proyecto->descripcion}} +

+ + + + + @for ($i = 1; $i <= $max_unidades; $i ++) + + @endfor + + + + @foreach ($pisos as $piso) + + + @for ($i = 1; $i <= $max_unidades; $i ++) + @if (!isset($piso->unidades[$i])) + + @continue + @endif + unidades[$i] ?> + + @endfor + + @endforeach + + + @for ($i = 1; $i <= $max_unidades; $i ++) + + @endfor + + +
Piso{{$i}}
{{$piso->descripcion}} + {{$unidad->descripcion}} +
+ {{$unidad->tipologia()->tipologia()->descripcion}} +
+ {{format('ufs', $unidad->precio()->valor, null, true)}} +
+ @if ($unidad->isVendida()) + {{format('shortDate', $unidad->venta()->fecha)}} + @endif +
+ @if ($unidad->isReservada()) + {{format('shortDate', $unidad->cierre()->fecha)}} + @endif +
+
+ + {{array_reduce($totales, function($sum, $item) { + return $sum + $item->ventas; + })}} + +
+
+ + {{array_reduce($totales, function($sum, $item) { + return $sum + $item->reservas; + })}} + +
+
+
{{$totales[$i]->ventas}}
+
{{$totales[$i]->reservas}}
+
+@endsection diff --git a/resources/views/proyectos/show.blade.php b/resources/views/proyectos/show.blade.php new file mode 100644 index 0000000..9f07003 --- /dev/null +++ b/resources/views/proyectos/show.blade.php @@ -0,0 +1,230 @@ +@extends('layout.base') + +@section('content') +
+
Proyecto - {{$proyecto->descripcion}}
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + @include('proyectos.superficies') + @if (count($proyecto->proyectoTipoUnidades()) > 0) + + + + + + + + + @else + + + + + @endif + @include('proyectos.ventas') + @include('proyectos.por_vender') + @include('proyectos.estimado') + + + + + + + + + +
Dirección{{$proyecto->direccion()->completa(true)}}
Inmobiliaria{{$proyecto->inmobiliaria()->abreviacion}}
Inicio{{$proyecto->estados()[0]->tipo()->descripcion}} [{{$proyecto->estados()[0]->tipo()->etapa()->descripcion}}]] ({{format('shortDate', $proyecto->estados()[0]->fecha)}}) + (estados()[0]->fecha, config('app.timezone')); + ?>{{$f->diffForHumans($today)}}) +
Estado {{$proyecto->estado()->tipo()->descripcion}} + @if ($proyecto->estado()->tipo()->etapa()->descripcion == 'Construcción') + + @endif + [{{$proyecto->estado()->tipo()->etapa()->descripcion}}] + @if ($proyecto->estado()->tipo()->etapa()->descripcion == 'Construcción') + + @endif + ({{format('shortDate', $proyecto->estado()->fecha)}}) (estado()->fecha, config('app.timezone')); + ?>{{$f->diffForHumans($today)}}) +
@include('proyectos.avance') +
Operadores + @if ($proyecto->operadoresVigentes()) + {{array_reduce($proyecto->operadoresVigentes(), function($list, $item) { + return trim($list . ', ' . $item->agente()->agente()->abreviacion, ', '); + })}} + @endif + + + +
Departamentos{{count($proyecto->unidades(1))}}
Pisos{{$proyecto->pisos()}}
Agregar tipo de unidad
+ + +
+ + +
+
+ +
+@endsection + +@push('scripts') + @if (count($proyecto->unidades()) > 0) + + @endif +@endpush diff --git a/resources/views/proyectos/superficies.blade.php b/resources/views/proyectos/superficies.blade.php new file mode 100644 index 0000000..024bab4 --- /dev/null +++ b/resources/views/proyectos/superficies.blade.php @@ -0,0 +1,97 @@ +@if ($proyecto->superficie('total') != null) + + Superficies + + + + + + + + + + + + + + + + + + + + @if (count($proyecto->ventas()) > 0) + + + + + + + + + @endif +
Total{!!format('m2', $proyecto->superficie('total'), null, true)!!} + +
Sobre Nivel{!!format('m2', $proyecto->superficie('snt'), null, true)!!}
Bajo Nivel{!!format('m2', $proyecto->superficie('bnt'), null, true)!!}
Vendible{!!format('m2', $proyecto->superficie('vendible'), null, true)!!}
Vendido{!!format('m2', $proyecto->superficie('vendida'), null, true)!!}
Por Vender{!!format('m2', $proyecto->superficie('por vender'), null, true)!!}
+ + +@endif + +@push('scripts') +@if ($proyecto->superficie('total') != null) + +@endif +@endpush diff --git a/resources/views/proyectos/tipo_unidades/add.blade.php b/resources/views/proyectos/tipo_unidades/add.blade.php new file mode 100644 index 0000000..91c4043 --- /dev/null +++ b/resources/views/proyectos/tipo_unidades/add.blade.php @@ -0,0 +1,44 @@ +@extends('layout.base') + +@section('content') +
+

Agregar Tipo Unidad - {{$proyecto->descripcion}}

+
+
+
+
+
Tipo
+
+
+
+
Nombre
+
+
+
+
Abreviación
+
+
+
+
+
Interior
+
Logia
+
Terraza
+
+
+
+
+
+
+
+
Descripción
+
+
+
+
+
+
+@endsection diff --git a/resources/views/proyectos/tipo_unidades/edit.blade.php b/resources/views/proyectos/tipo_unidades/edit.blade.php new file mode 100644 index 0000000..2632e9a --- /dev/null +++ b/resources/views/proyectos/tipo_unidades/edit.blade.php @@ -0,0 +1,43 @@ +@extends('layout.base') + +@section('content') +
+

Editar Tipo Unidad - {{$tipo->proyecto()->descripcion}}

+
+
+
+
+
Tipo
+
+
+
+
Nombre
+
+
+
+
Abreviación
+
+
+
+
+
+
+
+
+
+
Descripción
+
+
+
+
+
+
+@endsection diff --git a/resources/views/proyectos/unidades/add.blade.php b/resources/views/proyectos/unidades/add.blade.php new file mode 100644 index 0000000..24fb337 --- /dev/null +++ b/resources/views/proyectos/unidades/add.blade.php @@ -0,0 +1,110 @@ +@extends('layout.base') + +@section('content') +
+

Agregar Unidades - {{$tipo->proyecto()->descripcion}} - {{$tipo->nombre}}

+
+
+
+
Tipo
+
{{$tipo->nombre}}
+
+ @if ($tipo->tipologia()) + {{$tipo->tipologia()->descripcion}} + @else + {{$tipo->abreviacion}} + @endif +
+
{{format('m2', $tipo->m2())}} m²
+
+
+
+
+
Total Departamentos por Piso
+
+
+
+ +
+
+
Línea
+
+
Orientación
+
+ + +
+
Pisos
+
+
+
+
+
+
+
+
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/proyectos/unidades/add2.blade.php b/resources/views/proyectos/unidades/add2.blade.php new file mode 100644 index 0000000..99ab026 --- /dev/null +++ b/resources/views/proyectos/unidades/add2.blade.php @@ -0,0 +1,86 @@ +@extends('layout.base') + +@section('content') +
+

Agregar Unidades - {{$tipo->proyecto()->descripcion}} - {{$tipo->nombre}}

+
+
+
+
Tipo
+
{{$tipo->nombre}}
+
{{$tipo->abreviacion}}
+
{{format('m2', $tipo->m2())}} m²
+
+
+
+
+
Unidades
+
+
+
+ +
+
+
Descripción
+
+
Piso
+
+
+
+
+
+
+
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/proyectos/unidades/assign.blade.php b/resources/views/proyectos/unidades/assign.blade.php new file mode 100644 index 0000000..da7aea1 --- /dev/null +++ b/resources/views/proyectos/unidades/assign.blade.php @@ -0,0 +1,38 @@ +@extends('layout.base') + +@section('content') +
+

Asignar Tipo a Unidades - {{$proyecto->descripcion}}

+
+
+ + + + + + + + + + @foreach ($libres as $unidad) + + + + + @endforeach + +
UnidadTipoPT
{{$unidad->descripcion}}{{$unidad->tipo()->descripcion}}
+
+
+
+
+@endsection diff --git a/resources/views/proyectos/unidades/edit.blade.php b/resources/views/proyectos/unidades/edit.blade.php new file mode 100644 index 0000000..e19b5a0 --- /dev/null +++ b/resources/views/proyectos/unidades/edit.blade.php @@ -0,0 +1,52 @@ +@extends('layout.base') + +@section('content') +
+

Editar Unidad - {{$unidad->proyecto()->descripcion}} - {{$unidad->descripcion}}

+
+
+
+
+
Tipo
+
+
+
+
Descripción
+
+
+
+
Piso
+
+
Línea
+
+
+
+
Orientación
+
+
+
+
+
+
+@endsection diff --git a/resources/views/proyectos/unidades/list.blade.php b/resources/views/proyectos/unidades/list.blade.php new file mode 100644 index 0000000..0df444f --- /dev/null +++ b/resources/views/proyectos/unidades/list.blade.php @@ -0,0 +1,198 @@ +@extends('layout.base') + +@section('content') + + + + + + + + + + + + + + + + + + + + @foreach ($proyecto->proyectoTipoUnidades() as $tipo) + + + + + + + + + + + + + + + + + + @endforeach + @if (count($libres) > 0) + + + + + + + + + + @endif + +
TipoNombreAbreviación#Líneasm² Útilm² Terrazam² Vendiblem² TotalDescripción
{{ucwords($tipo->tipo()->descripcion)}}{{$tipo->nombre}} + @if ($tipo->tipologia()) + {{$tipo->tipologia()->descripcion}} + @else + {{$tipo->abreviacion}} + @endif + {{count($tipo->unidades())}}{{$tipo->lineas()}}{{format('m2', $tipo->m2 + $tipo->logia)}}{{format('m2', $tipo->terraza)}}{{format('m2', $tipo->m2())}}{{format('m2', $tipo->m2('total'))}} + @if ($tipo->tipologia()) + {{$tipo->tipologia()->detalle}} + @else + {{$tipo->descripcion}} + @endif +
+ + + + + + + + + + + + + + @foreach ($tipo->unidades() as $unidad) + @if ($subtipo != $unidad->subtipo) + subtipo; $cnt[$tipo->nombre."-".$subtipo] = 0; $pisos[$tipo->nombre."-".$subtipo] = [] ?> + + + + + + + + @endif + + + + + + + + nombre."-".$subtipo] ++; + $pisos[$tipo->nombre."-".$subtipo] []= $unidad->piso; + } + ?> + @endforeach + +
Descripción#PisoLíneaOrientación + + + +
Línea {{$subtipo}}{{$subtipo}}{{$unidad->orientacion}}
{{$unidad->descripcion}}{{$unidad->piso}}{{$unidad->subtipo}}{{$unidad->orientacion}} + + +
+
Libres
+ + + + + + + + + + + + + @foreach ($libres as $unidad) + + + + + + + + + @endforeach + +
DescripciónPisoLíneaOrientaciónValor
{{$unidad->descripcion}}{{$unidad->piso}}{{$unidad->subtipo}}{{$unidad->orientacion}}{{format('ufs', $unidad->valor, null, true)}} + + +
+
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/proyectos/unidades/proyectos.blade.php b/resources/views/proyectos/unidades/proyectos.blade.php new file mode 100644 index 0000000..53ef4eb --- /dev/null +++ b/resources/views/proyectos/unidades/proyectos.blade.php @@ -0,0 +1,29 @@ +@extends('layout.base') + +@section('content') +
+
+
+
+ Unidades de Proyectos +
+
+
+
+ + + + + + + + + @foreach ($proyectos as $proyecto) + + + + + @endforeach + +
ProyectoInmobiliaria
{{$proyecto->descripcion}}{{$proyecto->inmobiliaria()->abreviacion}}
+@endsection diff --git a/resources/views/proyectos/ventas.blade.php b/resources/views/proyectos/ventas.blade.php new file mode 100644 index 0000000..c2bda98 --- /dev/null +++ b/resources/views/proyectos/ventas.blade.php @@ -0,0 +1,87 @@ +@if (count($proyecto->ventas()) > 0) + + + Ventas + @if ($proyecto->estado()->tipo()->etapa()->orden >= 4) +
+ + + + @endif + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#% Vendidom² promedio
{{count($proyecto->ventas())}}{{\App\Helper\Format::number(count($proyecto->ventas())/count($proyecto->unidades(1)) * 100, 2)}} %{{\App\Helper\Format::number($proyecto->valores()->vendidos->departamentos->mts->vendibles->promedio, 2)}}
+ UF vendido
+ Bruto - Neto +
UF/m² NetoUF promedio
+ {{format('ufs', $proyecto->valores()->vendidos->ingreso->bruto, null, true)}} - {{\App\Helper\Format::ufs($proyecto->valores()->vendidos->ingreso->neto, true)}} +
+ {{format('ufs', $proyecto->valores()->vendidos->ingreso->abonado, null, true)}} ({{format('ufs', $proyecto->valores()->vendidos->ingreso->pagado, null, true)}}) +
{{\App\Helper\Format::ufs($proyecto->valores()->vendidos->departamentos->uf_m2->promedio, true)}}{{\App\Helper\Format::ufs($proyecto->valores()->vendidos->departamentos->precio->promedio, true)}}
EstacionamientosBodegasValor Total
{{count($proyecto->unidades(2)) - count($proyecto->unidadesDisponibles(2))}}{{count($proyecto->unidades(3)) - count($proyecto->unidadesDisponibles(3))}}{{format('ufs', $proyecto->valores()->vendidos->otros->valor, null, true)}}
OperadoresBono PiePremios
{{format('ufs', $proyecto->valores()->vendidos->comision, null, true)}} ({{format('percent', $proyecto->valores()->vendidos->comision / $proyecto->valores()->vendidos->ingreso->neto * 100, null, true)}} Neto){{format('ufs', $proyecto->valores()->vendidos->bono->valor, null, true)}} ({{format('percent', $proyecto->valores()->vendidos->bono->valor / $proyecto->valores()->vendidos->ingreso->neto * 100, null, true)}} Neto){{format('ufs', $proyecto->valores()->vendidos->premios(), null, true)}} ({{format('percent', $proyecto->valores()->vendidos->premios() / $proyecto->valores()->vendidos->ingreso->neto * 100, null, true)}} Neto)
Ingreso Total{{format('ufs', $proyecto->valores()->vendidos->ingreso->neto + $proyecto->valores()->vendidos->otros->valor, null, true)}}
+ + +@endif diff --git a/resources/views/temas/add.blade.php b/resources/views/temas/add.blade.php new file mode 100644 index 0000000..31488f9 --- /dev/null +++ b/resources/views/temas/add.blade.php @@ -0,0 +1,31 @@ +@extends('layout.base') + +@section('content') +
+

Nuevo Tema

+
+
+
+
+
Proyecto
+
+
+
+
Fecha
+ @include('form.fecha') +
+
+
Contenido
+
+ +
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/temas/edit.blade.php b/resources/views/temas/edit.blade.php new file mode 100644 index 0000000..6679f7d --- /dev/null +++ b/resources/views/temas/edit.blade.php @@ -0,0 +1,36 @@ +@extends('layout.base') + +@section('content') +
+

Editar Tema

+
+
+
+
+
Proyecto
+
+
+
+
Fecha
+ inicio() ?> + @include('form.fecha') +
+
+
Contenido
+
+ +
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/temas/list.blade.php b/resources/views/temas/list.blade.php new file mode 100644 index 0000000..488af9b --- /dev/null +++ b/resources/views/temas/list.blade.php @@ -0,0 +1,57 @@ +@extends('layout.base') + +@section('content') + +
+
Temas Abiertos {{strftime('%d de %B de %Y', \Carbon\Carbon::today(config('app.timezone'))->timestamp)}}
+
+
+ +@foreach ($temas as $tema) +@if ($tema->proyecto_id != $proyecto) +proyecto_id ?> +
+
{{$tema->proyecto()->descripcion}}
+
{{$tema->proyecto()->estado()->descripcion}}
+
+@endif +
+
+
+
{{format('shortDate', $tema->inicio)}}
+
+ @if ($tema->cierre()->year != -1) + {{format('shortDate', $tema->cierre)}} + @endif +
+
+
+
+ {!!$tema->texto()!!} + @if ($tema->cierre()->year != -1) + [Cerrado] + @endif +
+
+ + @if ($tema->cierre()->year != -1) + + @else + + @endif +
+
+@endforeach +@endsection \ No newline at end of file diff --git a/resources/views/ventas/add.blade.php b/resources/views/ventas/add.blade.php new file mode 100644 index 0000000..89726e5 --- /dev/null +++ b/resources/views/ventas/add.blade.php @@ -0,0 +1,542 @@ +@extends('layout.base') + +@section('content') +
+
Nueva Venta
+
+
+
+
+
Fecha de Venta
+ +
+
+
+
+
PROPIETARIO
+
+
+
RUT
+
+
+
+
Nombre
+
+
+
+
+
+
+
Dirección
+
+
+
+
+
+
+
+
+
PROPIEDAD
+
+
+
Proyecto
+
+
+
+ +
+
Unidades
+
+
+
+
+
+
FORMA DE PAGO
+
+
+
Valor
+
+
UF
+
+
+
Pie
+
+
+
+
Subsidio
+
+
+
+
Crédito
+
+
+
OTRAS CONDICIONES
+
+
+
Bono Pie
+
+
+
+
Operador
+
+
+
+ +
+
Promociones
+
+
+
+
+
+
+
+
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/ventas/archivar.blade.php b/resources/views/ventas/archivar.blade.php new file mode 100644 index 0000000..35800cf --- /dev/null +++ b/resources/views/ventas/archivar.blade.php @@ -0,0 +1,16 @@ +@extends('layout.base') + +@section('content') +
+
Archivar Venta {{$venta->unidad()->descripcion}}
+
+
+
+
Fecha
+ @include('form.fecha') +
+
+
+
+
+@endsection diff --git a/resources/views/ventas/bonos/add.blade.php b/resources/views/ventas/bonos/add.blade.php new file mode 100644 index 0000000..15ae5cb --- /dev/null +++ b/resources/views/ventas/bonos/add.blade.php @@ -0,0 +1,29 @@ +@extends('layout.base') + +@section('content') +
+

Agregar Bono Pie

+
+
+
+
+
Pie
+
+ @if ($venta->pie()) + {{format('ufs', $venta->pie()->valor, null, true)}} + @endif +
+
+
+
+
Valor
+
+
UF
+
+
+
+ +
+
+
+@endsection diff --git a/resources/views/ventas/bonos/edit.blade.php b/resources/views/ventas/bonos/edit.blade.php new file mode 100644 index 0000000..e69de29 diff --git a/resources/views/ventas/ceder.blade.php b/resources/views/ventas/ceder.blade.php new file mode 100644 index 0000000..82fca7d --- /dev/null +++ b/resources/views/ventas/ceder.blade.php @@ -0,0 +1,143 @@ +@extends('layout.base') + +@section('content') +
+

Ceder - {{$venta->unidad()->descripcion}} - {{$venta->proyecto()->descripcion}}

+
+
+
+
+
Fecha
+ +
+
+
+
+
NUEVO PROPIETARIO
+
+
+
RUT
+
+
+
+
Nombre
+
+
+
+
+
+
+
Dirección
+
+
+
+
+
+
+
+
+
+
+
+
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/ventas/cierres/add.blade.php b/resources/views/ventas/cierres/add.blade.php new file mode 100644 index 0000000..0201fb4 --- /dev/null +++ b/resources/views/ventas/cierres/add.blade.php @@ -0,0 +1,374 @@ +@extends('layout.base') + +@section('content') +
+

Nuevo Cierre

+
+
+
+
+
Fecha
+ @include('form.fecha') +
+
PROPIEDAD
+
+
+
Proyecto
+
+
+
+
Agente
+
+
+
+ +
+
Unidades
+
+
+
+
+
FORMA DE PAGO
+
+
+
Valor
+
+
UF
+
+
+
Pie
+
+
+
+
Crédito
+
+
+
PROPIETARIO
+
+
+
RUT
+
+
+
+
Nombre
+
+
+
+
+
+
Sexo
+
Hombre
+
Mujer
+
+
+
Estado Civil
+
+
+
+
Profesión
+
+
+
+
Teléfono
+
+56
+
+
+
+
+
E-Mail
+
+
@
+
+
+
+
Dirección
+
+
+
+
+
+
+
+
+
+
+
+
+@endsection + +@push('scripts') + +@endpush \ No newline at end of file diff --git a/resources/views/ventas/cierres/edit.blade.php b/resources/views/ventas/cierres/edit.blade.php new file mode 100644 index 0000000..aaf9729 --- /dev/null +++ b/resources/views/ventas/cierres/edit.blade.php @@ -0,0 +1,473 @@ +@extends('layout.base') + +@section('content') +
+

Editar Cierre

+
+
+
+
+
Proyecto
+
+
+
+
Fecha
+ fecha() ?> + @include('form.fecha') +
+
+
Departamento
+
+ +
+
+
+
Precio
+
+
+ @foreach ($cierre->unidades() as $unidad) +
+
{{ucwords($unidad->unidad()->tipo()->descripcion)}}
+
+ +
+
+ @endforeach + @foreach ($valores as $valor) +
+
{{ucwords($valor->descripcion)}}
+
+ valor($valor->descripcion)) + value="{{$cierre->valor($valor->descripcion)->valor}}" + @endif + class="form-control" /> +
+
+ @endforeach +
PROPIETARIO
+
+
+
RUT
+
propietario()) + value="{{$cierre->propietario()->rut()}}" + @endif + class="form-control" />
+
+
+
Nombre
+
propietario()) + value="{{$cierre->propietario()->nombres}}" + @endif + class="form-control" autocomplete="off" />
+
propietario()) + value="{{$cierre->propietario()->apellido_paterno}}" + @endif + class="form-control" autocomplete="off" />
+
propietario()) + value="{{$cierre->propietario()->apellido_materno}}" + @endif + class="form-control" autocomplete="off" />
+
+
+
Sexo
+
propietario() and $cierre->propietario()->sexo == 'm') + selected="selected" + @endif + class="form-radio" /> Hombre
+
propietario() and $cierre->propietario()->sexo == 'f') + selected="selected" + @endif + class="form-radio" /> Mujer
+
+
+
Estado Civil
+
+
+
+
Profesión
+
propietario()) + value="{{$cierre->propietario()->profesion}}" + @endif + class="form-control" />
+
+
+
Teléfono
+
+56
+
propietario()) + value="{{substr($cierre->propietario()->telefono, 0, 1)}}" + @endif + maxlength="1" class="form-control" />
+
propietario()) + value="{{substr($cierre->propietario()->telefono, 1)}}" + @endif + class="form-control" maxlength="8" />
+
+
+
E-Mail
+
propietario()) + value="{{explode('@', $cierre->propietario()->email)[0]}}" + @endif + class="form-control" />
+
@
+
propietario()) + value="{{explode('@', $cierre->propietario()->email)[1]}}" + @endif + class="form-control" />
+
+
+
Dirección
+
propietario()) + value="{{$cierre->propietario()->direccion()->calle}}" + @endif + class="form-control" autocomplete="off" />
+
propietario()) + value="{{$cierre->propietario()->direccion()->numero}}" + @endif + class="form-control" />
+
propietario()) + value="{{$cierre->propietario()->direccion()->extra}}" + @endif + class="form-control" autocomplete="off" />
+
+
+
+
+
+
+
+ +
+
+
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/ventas/cierres/evaluar.blade.php b/resources/views/ventas/cierres/evaluar.blade.php new file mode 100644 index 0000000..d7e88bc --- /dev/null +++ b/resources/views/ventas/cierres/evaluar.blade.php @@ -0,0 +1,449 @@ +@extends('layout.base') + +@section('content') +
+

Evaluar Cierre

+
+
+
+
+
Proyecto
+
+
+
+
Fecha
+ @include('form.fecha') +
+
+
Departamento
+
+
+
+
Precio
+
+
+
+
Estacionamientos
+
+
Bodegas
+
+
+ + + +
+
Pie
+
+
+
+
Bono Pie
+
+
Promocion
+
+
Relacionado
Subrelacionado
+
+ +
+ +
+
+
+
Operador
+
+
%
+
+
+
+
+
+
+
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/ventas/cierres/list.blade.php b/resources/views/ventas/cierres/list.blade.php new file mode 100644 index 0000000..ae27fec --- /dev/null +++ b/resources/views/ventas/cierres/list.blade.php @@ -0,0 +1,190 @@ +@extends('layout.base') + +@section('content') +
+

Cierres

+
+ + + + + + + + @foreach ($proyectos as $proyecto) + + + + @if (count($proyecto->cierres(2)) > 0) + + + + + + + + + + + + @foreach ($proyecto->cierres(2) as $cierre) + + + + + + + + @endforeach + @endif + @if (count($proyecto->cierres(3)) > 0) + + + + + + + + + + + + @foreach ($proyecto->cierres(3) as $cierre) + + + + + + + + @endforeach + @endif + @if (count($proyecto->cierres(-1))) + + + + + + + + + + + + @foreach ($proyecto->cierres(-1) as $cierre) + + + + + + + + @endforeach + @endif + @endforeach + +
Proyecto
+ {{$proyecto->descripcion}} + + [{{count($proyecto->cierres())}}] +
+ Aprobado + + [{{count($proyecto->cierres(2))}}] {{format('percent', count($proyecto->cierres(2)) / count($proyecto->cierres()) * 100, null, true)}} +
DepartamentoFechaValorEstado
+ + {{$cierre->unidadPrincipal()->unidad()->descripcion}} + ({{$cierre->unidadPrincipal()->unidad()->tipologia()->tipologia()->descripcion}}) + + {{format('shortDate', $cierre->fecha)}} + {{format('ufs', $cierre->neto(), null, true)}} + ({{format('ufs', $cierre->uf_m2(), null, true)}}/m²) + + {{ucfirst($cierre->estado()->tipo()->descripcion)}} + @if (!$cierre->propietario()) + (Sin propietario) + @endif +
+ Promesado + + [{{count($proyecto->cierres(3))}}] {{format('percent', count($proyecto->cierres(3)) / count($proyecto->cierres()) * 100, null, true)}} +
DepartamentoFechaValorEstado
+ + {{$cierre->unidadPrincipal()->unidad()->descripcion}} + ({{$cierre->unidadPrincipal()->unidad()->tipologia()->tipologia()->descripcion}}) + + {{format('shortDate', $cierre->fecha)}} + {{format('ufs', $cierre->precio, null, true)}} + ({{format('ufs', $cierre->precio / $cierre->unidadPrincipal()->unidad()->m2(), null, true)}}/m²) + + @if ($cierre->estado()->tipo()->descripcion == 'promesado') + + @endif + {{ucfirst($cierre->estado()->tipo()->descripcion)}} + @if (!$cierre->propietario()) + (Sin propietario) + @endif + @if ($cierre->estado()->tipo()->descripcion == 'promesado') + + + @endif +
+ Abandonado/Rechazado + + [{{count($proyecto->cierres(-1))}}] {{format('percent', count($proyecto->cierres(-1)) / count($proyecto->cierres()) * 100, null, true)}} +
DepartamentoFechaValorEstado
+ + {{$cierre->unidadPrincipal()->unidad()->descripcion}} + ({{$cierre->unidadPrincipal()->unidad()->tipologia()->tipologia()->descripcion}}) + + {{format('shortDate', $cierre->fecha)}} + {{format('ufs', $cierre->precio, null, true)}} + ({{format('ufs', $cierre->precio / $cierre->unidadPrincipal()->unidad()->m2(), null, true)}}/m²) + + {{ucfirst($cierre->estado()->tipo()->descripcion)}} + @if (!$cierre->propietario()) + (Sin propietario) + @endif +
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/ventas/cierres/show.blade.php b/resources/views/ventas/cierres/show.blade.php new file mode 100644 index 0000000..24c0212 --- /dev/null +++ b/resources/views/ventas/cierres/show.blade.php @@ -0,0 +1,168 @@ +@extends('layout.base') + +@section('content') +
+
+ + Cierre {{$cierre->unidadPrincipal()->unidad()->descripcion}} - {{$cierre->proyecto()->descripcion}} +
+
+ +
+
+
+
Fecha
+
{{format('shortDate', $cierre->fecha)}}
+
+@if ($cierre->propietario()) +
PROPIETARIO
+
+
{{$cierre->propietario()->rut()}}
+
{{$cierre->propietario()->nombreCompleto()}}
+
{{$cierre->propietario()->direccion()->completa(true)}}
+
+@endif +
PROPIEDAD
+
+
{{ucwords($cierre->unidadPrincipal()->unidad()->tipologia()->tipo()->descripcion)}}
+
{{$cierre->unidadPrincipal()->unidad()->descripcion}}
+
{{$cierre->unidadPrincipal()->unidad()->tipologia()->nombre}}
+
{{$cierre->unidadPrincipal()->unidad()->tipologia()->tipologia()->descripcion}}
+
{!!format('m2', $cierre->unidadPrincipal()->unidad()->m2(), null, true)!!}
+
+@foreach ($cierre->unidades() as $unidad) +
+
{{ucwords($unidad->unidad()->tipologia()->tipo()->descripcion)}}
+
{{$unidad->unidad()->descripcion}}
+
{{format('ufs', $unidad->unidad()->precio($cierre->fecha())->valor, null, true)}}
+
+@endforeach +
Lista
+
+
Fecha
+
{{format('shortDate', $cierre->unidadPrincipal()->unidad()->precio($cierre->fecha())->estado()->fecha)}}
+
+
+
Valor
+
{{format('ufs', $cierre->unidadPrincipal()->unidad()->precio($cierre->fecha())->valor, null, true)}}
+
{{format('ufs', $cierre->unidadPrincipal()->unidad()->precio($cierre->fecha())->valor / $cierre->unidadPrincipal()->unidad()->m2(), null, true)}}/m²
+
+@if ($cierre->isRelacionado()) +
+
Valor Relacionado
+
{{format('ufs', $cierre->unidadPrincipal()->unidad()->precio($cierre->fecha())->valor * (1-6/100), null, true)}}
+
{{format('ufs', $cierre->unidadPrincipal()->unidad()->precio($cierre->fecha())->valor * (1-6/100) / $cierre->unidadPrincipal()->unidad()->m2(), null, true)}}/m²
+
+@endif +@if ($cierre->isSubrelacionado()) +
+
Valor Relacionado
+
{{format('ufs', $cierre->unidadPrincipal()->unidad()->precio($cierre->fecha())->valor * (1-3/100), null, true)}}
+
{{format('ufs', $cierre->unidadPrincipal()->unidad()->precio($cierre->fecha())->valor * (1-3/100) / $cierre->unidadPrincipal()->unidad()->m2(), null, true)}}/m²
+
+@endif +
Oferta
+
+
Precio
+
{{format('ufs', $cierre->precio, null, true)}}
+
+
+ +
Neto
+
{{format('ufs', $cierre->neto(), null, true)}}
+
{{format('ufs', $cierre->uf_m2(), null, true)}}/m² + @if ($cierre->uf_m2() >= ($cierre->unidadPrincipal()->unidad()->precio($cierre->fecha())->valor * (($cierre->isRelacionado()) ? (1 - 6/100) : 1) * (($cierre->isSubrelacionado()) ? (1 - 3/100) : 1)) / $cierre->unidadPrincipal()->unidad()->m2()) + + @elseif ($cierre->uf_m2() < ($cierre->unidadPrincipal()->unidad()->precio($cierre->fecha())->valor * (($cierre->isRelacionado()) ? (1 - 6/100) : 1) * (($cierre->isSubrelacionado()) ? (1 - 3/100) : 1)) / $cierre->unidadPrincipal()->unidad()->m2()) + + @endif +
+
+
+@if ($cierre->valores()) + @foreach ($cierre->valores() as $valor) +
+
{{ucwords($valor->tipo()->descripcion)}}
+
{{format('ufs', $valor->valor, null, true)}}
+
{{format('percent', $valor->valor / $cierre->precio * 100)}} %
+
+ @endforeach +@endif +
Diferencia
+
+
Neto
+
{{format('ufs', $cierre->neto() - $cierre->unidadPrincipal()->unidad()->precio($cierre->fecha())->valor, null, true)}}
+
+@if ($cierre->isRelacionado()) +
+
Neto Relacionado
+
{{format('ufs', $cierre->neto() - $cierre->unidadPrincipal()->unidad()->precio($cierre->fecha())->valor * (1 - 6/100), null, true)}}
+
+@endif +@if ($cierre->isSubrelacionado()) +
+
Neto Relacionado
+
{{format('ufs', $cierre->neto() - $cierre->unidadPrincipal()->unidad()->precio($cierre->fecha())->valor * (1 - 3/100), null, true)}}
+
+@endif +
Estado
+
+
+ + @if ($cierre->estado()->tipo()->descripcion == 'aprobado') +
+
+ @elseif ($cierre->estado()->tipo()->descripcion == 'rechazado') +
+ + + +
+
+ + + +
+ @endif +
+
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/ventas/comentarios/add.blade.php b/resources/views/ventas/comentarios/add.blade.php new file mode 100644 index 0000000..51a42d1 --- /dev/null +++ b/resources/views/ventas/comentarios/add.blade.php @@ -0,0 +1,23 @@ +@extends('layout.base') + +@section('content') +
+
{{$venta->proyecto()->descripcion}} - {{$venta->unidad()->descripcion}}
+
+
+
+
+
Fecha
+
{{\Carbon\Carbon::now(config('app.timezone'))->format('d-m-Y')}}
+
+
+
Comentario
+
+
+
+
+
+
+
+
+@endsection diff --git a/resources/views/ventas/consolidacion/pago.blade.php b/resources/views/ventas/consolidacion/pago.blade.php new file mode 100644 index 0000000..f256955 --- /dev/null +++ b/resources/views/ventas/consolidacion/pago.blade.php @@ -0,0 +1,12 @@ + + {{format('shortDate', $pago->estado()->fecha)}} + {{$glosa}} ({{format('ufs', $pago->valor('ufs'))}} UF) + + $ {{format('pesos', $pago->valor())}} + $ {{format('pesos', $sum)}} + + @if ($pago->estado()->estado < 2) + No esta abonado. + @endif + + \ No newline at end of file diff --git a/resources/views/ventas/consolidacion/proyectos.blade.php b/resources/views/ventas/consolidacion/proyectos.blade.php new file mode 100644 index 0000000..d14fff4 --- /dev/null +++ b/resources/views/ventas/consolidacion/proyectos.blade.php @@ -0,0 +1,13 @@ +@extends('layout.base') + +@section('content') +

Consolidación de Ventas

+
+
Proyectos
+ +
+@endsection \ No newline at end of file diff --git a/resources/views/ventas/consolidacion/show.blade.php b/resources/views/ventas/consolidacion/show.blade.php new file mode 100644 index 0000000..5fc9408 --- /dev/null +++ b/resources/views/ventas/consolidacion/show.blade.php @@ -0,0 +1,60 @@ +@extends('layout.base') + +@section('content') +

Consolidación de Ventas - {{$ventas[0]->proyecto()->descripcion}} Excel

+

{{strftime('%d de %B de %Y', $f->timestamp)}}

+
+@foreach ($ventas as $venta) +

Departamento {{$venta->unidad()->descripcion}} ({{format('ufs', $venta->valor_uf)}} UF)

+ + + + + + + + + + + + + +@if ($venta->pie != 0) + @foreach ($venta->pie()->cuotas() as $cuota) + numero() . ' - ' . $venta->pie()->cuotas; $pago = $cuota->pago() ?> + valor(); $ufs += $pago->valor('ufs'); $sum += $pago->valor() ?> + @include('ventas.consolidacion.pago') + @endforeach + @if ($venta->pie()->reajuste != 0) + pie()->reajuste() ?> + valor(); $ufs += $pago->valor('ufs'); $sum += $pago->valor() ?> + @include('ventas.consolidacion.pago') + @endif +@endif +@if ($venta->escritura != 0) + escritura()->pago() ?> + valor(); $ufs += $pago->valor('ufs'); $sum += $pago->valor() ?> + @include('ventas.consolidacion.pago') +@endif +@if ($venta->credito != 0) + credito()->pago() ?> + valor(); $ufs += $pago->valor('ufs'); $sum += $pago->valor() ?> + @include('ventas.consolidacion.pago') +@endif +@if ($venta->devolucion != 0) + devolucion() ?> + valor(); $ufs -= $pago->valor('ufs'); $sum -= $pago->valor() ?> + @include('ventas.consolidacion.pago') +@endif + + + + + + + + + +
FechaGlosaDebeHaberSaldoComentario
TOTAL ({{format('ufs', $ufs)}} UF)$ {{format('pesos', $debe)}}$ {{format('pesos', $haber)}}$ {{format('pesos', $sum)}}
+@endforeach +@endsection \ No newline at end of file diff --git a/resources/views/ventas/creditos/abonar.blade.php b/resources/views/ventas/creditos/abonar.blade.php new file mode 100644 index 0000000..9ee409c --- /dev/null +++ b/resources/views/ventas/creditos/abonar.blade.php @@ -0,0 +1,31 @@ +@extends('layout.base') + +@section('content') +
+
Abonar Crédito - {{$venta->unidad()->descripcion}} - {{$venta->proyecto()->descripcion}}
+
+
+
+
Crédito
+
{{format('ufs', $venta->credito()->pago()->valor('ufs'))}} UF
+
+
+
Fecha Pago
+
{{format('shortDate', $venta->credito()->pago()->estado()->fecha)}}
+
+
+
Valor [$]
+
+
+
+
Fecha Abono
+ credito()->pago()->estado()->fecha) ?> + @include('form.fecha') +
+
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/ventas/creditos/add.blade.php b/resources/views/ventas/creditos/add.blade.php new file mode 100644 index 0000000..8715ef1 --- /dev/null +++ b/resources/views/ventas/creditos/add.blade.php @@ -0,0 +1,61 @@ +@extends('layout.base') + +@section('content') +
+
Agregar Crédito - {{$venta->unidad()->descripcion}} - {{$venta->proyecto()->descripcion}}
+
+
+
+
Banco
+
+
+
+
Valor [UF]
+
+
UF
+
+
+
Fecha
+
+ +
+
+
+
+
+
+
+
+
+
+@endsection + +@push('scripts') + +@endpush \ No newline at end of file diff --git a/resources/views/ventas/creditos/edit.blade.php b/resources/views/ventas/creditos/edit.blade.php new file mode 100644 index 0000000..5642c5f --- /dev/null +++ b/resources/views/ventas/creditos/edit.blade.php @@ -0,0 +1,42 @@ +@extends('layout.base') + +@section('content') +
+
Editar Crédito - {{$venta->unidad()->descripcion}} - {{$venta->proyecto()->descripcion}}
+
+
+
+
Banco
+
credito()->pago()->banco != 0) + value="{{$venta->credito()->pago()->banco()->nombre}}" + @endif + />
+
+
+
Valor [UF]
+
+
UF
+
+
+
Fecha
+ credito()->pago()->fecha, config('app.timezone')) ?> + @include('form.fecha') +
+
+
+
+
+
+
+@endsection + +@push('scripts') + +@endpush \ No newline at end of file diff --git a/resources/views/ventas/creditos/pagar.blade.php b/resources/views/ventas/creditos/pagar.blade.php new file mode 100644 index 0000000..ea9fe4f --- /dev/null +++ b/resources/views/ventas/creditos/pagar.blade.php @@ -0,0 +1,31 @@ +@extends('layout.base') + +@section('content') +
+
Pagar Crédito - {{$venta->unidad()->descripcion}} - {{$venta->proyecto()->descripcion}}
+
+
+
+
Crédito
+
{{format('ufs', $venta->credito()->pago()->valor('ufs'))}} UF
+
+
+
Fecha Escritura
+
{{format('shortDate', $venta->credito()->pago()->fecha)}}
+
+
+
Valor [$]
+
+
+
+
Fecha Pago
+ credito()->pago()->fecha) ?> + @include('form.fecha') +
+
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/ventas/creditos/pendientes.blade.php b/resources/views/ventas/creditos/pendientes.blade.php new file mode 100644 index 0000000..34846c1 --- /dev/null +++ b/resources/views/ventas/creditos/pendientes.blade.php @@ -0,0 +1,35 @@ +@extends('layout.base') + +@section('content') +
+
Créditos Pendientes
+
+
+ + + + + + + + + + + + + +@foreach ($creditos as $credito) + + + + + + + + +@endforeach + +
ProyectoDepartamentoValor [$]Valor [UF]Fecha EscrituraEstado
{{$credito->venta()->proyecto()->descripcion}}{{$credito->venta()->unidad()->descripcion}}{{format('pesos', $credito->pago()->valor('pesos'), null, true)}}{{format('ufs', $credito->pago()->valor('ufs'), null, true)}}{{format('shortDate', (($credito->venta()->escriturado) ? $credito->venta()->escriturado : $credito->pago()->estado()->fecha))}}{{ucwords($credito->pago()->estado()->tipo()->descripcion)}}
+@endsection \ No newline at end of file diff --git a/resources/views/ventas/creditos/show.blade.php b/resources/views/ventas/creditos/show.blade.php new file mode 100644 index 0000000..c0a3221 --- /dev/null +++ b/resources/views/ventas/creditos/show.blade.php @@ -0,0 +1,53 @@ +@extends('layout.base') + +@section('content') +
+
+

+
+
+ Crédito - {{$venta->unidad()->descripcion}} - {{$venta->proyecto()->descripcion}} +
+ +
+

+
+
+
+
Banco
+
+ @if ($venta->credito()->pago()->banco != 0) + {{$venta->credito()->pago()->banco()->nombre}} + @else + --- + @endif +
+
+
+
Valor
+
{{format('ufs', $venta->credito()->pago()->valor('ufs'), null, true)}}
+
{{format('pesos', $venta->credito()->pago()->valor('pesos'), null, true)}}
+
+
+
Fecha
+
{{format('shortDate', $venta->credito()->pago()->fecha)}}
+
+ + @foreach ($venta->credito()->pago()->estados() as $estado) + tipo()->active == 0) + class="danger" + @endif + > + + + + @endforeach +
{{ucwords($estado->tipo()->descripcion)}}{{format('shortDate', $estado->fecha)}}
+
+
+@endsection diff --git a/resources/views/ventas/desist.blade.php b/resources/views/ventas/desist.blade.php new file mode 100644 index 0000000..b11e95b --- /dev/null +++ b/resources/views/ventas/desist.blade.php @@ -0,0 +1,44 @@ +@extends('layout.base') + +@section('content') +
+

Desistir - {{$venta->unidad()->descripcion}} - {{$venta->proyecto()->descripcion}}

+
+
+
+
+
Fecha
+ +
+
+
+
+
+
Devolución [$]
+
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/ventas/devolucion.blade.php b/resources/views/ventas/devolucion.blade.php new file mode 100644 index 0000000..1697300 --- /dev/null +++ b/resources/views/ventas/devolucion.blade.php @@ -0,0 +1,63 @@ +@extends('layout.base') + +@section('content') + +
+
+
+
Saldo
+
{{format('ufs', $venta->saldo('ufs'), null, true)}}
+
{{format('pesos', $valor, null, true)}}
+
$ {{format('ufs', $uf)}}
+
+
+
Fecha
+ @include('form.fecha') +
+
+
Valor [$]
+
+
+
+
(Identificador)
+
+
+
+
(Banco)
+
+
+
+
+
+
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/ventas/edit.blade.php b/resources/views/ventas/edit.blade.php new file mode 100644 index 0000000..4090eb5 --- /dev/null +++ b/resources/views/ventas/edit.blade.php @@ -0,0 +1,546 @@ +@extends('layout.base') + +@section('content') +
+
Editar Venta - {{$venta->unidad()->descripcion}} - {{$venta->proyecto()->descripcion}}
+
+
+
+
+
Fecha de Venta
+ fecha, config('app.timezone')) ?> + @include('form.fecha') +
+
PROPIETARIO
+
+
+
RUT
+
+
+
+
Nombre
+
+
+
+
+
+
+
Dirección
+
+
+
+
+
+
+
+
+
PROPIEDAD
+
+
+
Proyecto
+
+
+
+ +
+
Unidades
+
+
+
+
+
FORMA DE PAGO
+
+
+
Valor
+
+
UF
+
+
+
Pie
+
+
+
+
Crédito
+
+
+
OTRAS CONDICIONES
+
+
+
Bono Pie
+
+
+
+
Operador
+
+
+
+ +
+
Promociones
+
+
+
+
+
+
+
+
+@endsection + +@push('scripts') + +@endpush \ No newline at end of file diff --git a/resources/views/ventas/entregar.blade.php b/resources/views/ventas/entregar.blade.php new file mode 100644 index 0000000..f538e33 --- /dev/null +++ b/resources/views/ventas/entregar.blade.php @@ -0,0 +1,125 @@ +@extends('layout.base') + +@section('content') +
+

Entregar - {{$venta->unidad()->descripcion}} - {{$venta->proyecto()->descripcion}}

+
+
+
+
+
Fecha
+ @include('form.fecha') +
+
+
Mediciones
+ +
+
+
+
+
+
Observaciones
+ +
+
+
+
+
+
+
+@endsection + +@push('scripts') + +@endpush \ No newline at end of file diff --git a/resources/views/ventas/escrituras/abonar.blade.php b/resources/views/ventas/escrituras/abonar.blade.php new file mode 100644 index 0000000..517ce7a --- /dev/null +++ b/resources/views/ventas/escrituras/abonar.blade.php @@ -0,0 +1,25 @@ +@extends('layout.base') + +@section('content') + +
+
+
+
Fecha Pago
+
{{format('shortDate', $venta->escritura()->pago()->estado()->fecha)}}
+
+
+
Fecha
+ escritura()->pago()->estado()->fecha, config('app.timezone')) ?> + @include('form.fecha') +
+
+
Valor Abonado [$]
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/ventas/escrituras/add.blade.php b/resources/views/ventas/escrituras/add.blade.php new file mode 100644 index 0000000..2efb948 --- /dev/null +++ b/resources/views/ventas/escrituras/add.blade.php @@ -0,0 +1,219 @@ +@extends('layout.base', ['titulo' => 'Escriturar']) + +@section('content') + +
+
+
Faltante
+
$ {{format('pesos', -$venta->saldo('pesos'))}}
+
{{format('ufs', -$venta->saldo())}} UF
+
+
+ +
+
Fecha
+ +
+ +
+
+ +
+
+ +
+
+ @if ($venta->pie != 0 and $venta->pie()->reajuste == 0) +
+
Reajuste
+
+
+
Valor [$]
+
+
+
+
Fecha
+
+ +
+
+ +
+
+ +
+
+
+
+ @endif + @if ($venta->escritura == 0) +
+
Pago en Escritura
+
+
+
Valor [$]
+
+
+
+
(Valor [UF])
+
+
+
+
Fecha
+
+ +
+
+ +
+
+ +
+
+
+
+ @endif + @if ($venta->subsidio == 0) +
+
Subsidio
+
+
+
Valor Ahorrado [UF]
+
+
+
+
Valor Subsidio [UF]
+
+
+
+
Total
+
+
UF
+
+
+
+ @endif + @if ($venta->credito == 0) +
+
Crédito
+
+
+
Banco
+
+
+
+
Valor [UF]
+
+
+
+
+ @elseif ($venta->credito()->pago()->banco == 0) +
+
Crédito
+
+
+
Valor [UF]
+
{{format('ufs', $venta->credito()->pago()->valor('ufs'), null, true)}}
+
+
+
Banco
+
+
+
+
+ @endif +
+
+
+
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/ventas/escrituras/edit.blade.php b/resources/views/ventas/escrituras/edit.blade.php new file mode 100644 index 0000000..b45ea1f --- /dev/null +++ b/resources/views/ventas/escrituras/edit.blade.php @@ -0,0 +1,53 @@ +@extends('layout.base') + +@section('content') +
+
Editar Pago de Escritura - {{$venta->unidad()->descripcion}} - {{$venta->proyecto()->descripcion}}
+
+
+
+
Valor [$]
+
+
+
+
(Valor [UF])
+
+
+
+
Fecha
+ escritura()->pago()->fecha, config('app.timezone')) ?> +
+
+
+
+
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/ventas/escrituras/informe.blade.php b/resources/views/ventas/escrituras/informe.blade.php new file mode 100644 index 0000000..e20d473 --- /dev/null +++ b/resources/views/ventas/escrituras/informe.blade.php @@ -0,0 +1,95 @@ +@extends('layout.base') + +@section('content') +
+ +
+ El departamento {{$venta->unidad()->descripcion}}:
+ @if (count($venta->propiedad()->estacionamientos()) > 0) + @if (count($venta->propiedad()->estacionamientos()) > 1) + tiene los estacionamientos + @foreach ($venta->propiedad()->estacionamientos() as $i => $est) + @if ($i == count($venta->propiedad()->estacionamientos()) - 1) + y + @elseif ($i > 0) + , + @endif + {{$est->descripcion}} + @endforeach + @else + tiene el estacionamiento {{$venta->propiedad()->estacionamientos()[0]->descripcion}} + @endif + @else + no tiene estacionamientos + @endif + y + @if (count($venta->propiedad()->bodegas()) > 0) + @if (count($venta->propiedad()->bodegas()) > 1) + tiene las bodegas + @foreach ($venta->propiedad()->bodegas() as $i => $est) + @if ($i == count($venta->propiedad()->bodegas()) - 1) + y + @elseif ($i > 0) + , + @endif + {{$est->descripcion}} + @endforeach + @else + tiene la bodega {{$venta->propiedad()->bodegas()[0]->descripcion}}. + @endif + @else + no tiene bodegas. + @endif +
+
+ PRECIO {{format('ufs', $venta->valor('ufs'))}} UF.
+ @if ($venta->pie != 0) + PIE {{count($venta->pie()->cuotas())}} cuota{{(count($venta->pie()->cuotas()) > 1) ? 's que suman' : ' de'}} + $ {{format('pesos', $venta->pie()->valorPagado('pesos'))}} equivalente a {{format('ufs', $venta->pieReajustado())}} UF.
+ @if ($venta->pie()->reajuste != 0) + REAJUSTE + @if ($venta->pie()->reajuste()->estado()->estado >= 1) + $ {{format('pesos', $venta->pie()->reajuste()->valor)}} el {{format('shortDate', $venta->pie()->reajuste()->fecha)}} + equivalente a {{format('ufs', $venta->pie()->reajuste()->valor('ufs'))}} UF. + @else + {{format('ufs', $venta->pie()->reajuste()->valor('ufs'))}} UF por pagar. + @endif +
+ @endif + @endif + @if ($venta->escritura != 0) + ESCRITURA + @if ($venta->escritura()->pago()->estado()->estado >= 1) + $ {{format('pesos', $venta->escritura()->pago()->valor)}} el {{format('shortDate', $venta->escritura()->pago()->fecha)}} + equivalente a {{format('ufs', $venta->escritura()->pago()->valor('ufs'))}} UF. + @else + {{format('ufs', $venta->escritura()->pago()->valor('ufs'))}} UF por pagar. + @endif +
+ @endif + @if ($venta->saldo() / $venta->valor_uf > 0.01) + (DEVOLVER {{format('ufs', $venta->saldo())}} UF).
+ @endif + @if ($venta->anticipo() > 0) + TOTAL ANTICIPO {{format('ufs', $venta->anticipo())}} UF.
+ @endif + @if ($venta->bono_pie != 0) + BONO {{format('ufs', $venta->bonoPie()->pago()->valor('ufs'))}} UF.
+ @endif + @if ($venta->subsidio != 0) + SUBSIDIO {{format('ufs', $venta->subsidio()->pago()->valor('ufs'))}} UF con ahorro y + {{format('ufs', $venta->subsidio()->subsidio()->valor('ufs'))}} UF con subsidio.
+ @endif + @if ($venta->credito != 0) + Saldo {{format('ufs', $venta->credito()->pago()->valor('ufs'))}} UF con CRÉDITO en {{$venta->credito()->pago()->banco()->nombreCompleto()}}.
+ @endif + TOTAL {{format('ufs', $venta->pagado())}} UF. + + @if ($venta->saldo() > 0.0001) +
+
+ Diferencia {{format('ufs', $venta->saldo())}} UF ({{\App\Helper\Format::number(($venta->saldo()) / $venta->valor_uf * 100, 2)}}%). + @endif +
+
+@endsection \ No newline at end of file diff --git a/resources/views/ventas/escrituras/pagar.blade.php b/resources/views/ventas/escrituras/pagar.blade.php new file mode 100644 index 0000000..7524f41 --- /dev/null +++ b/resources/views/ventas/escrituras/pagar.blade.php @@ -0,0 +1,24 @@ +@extends('layout.base') + +@section('content') + +
+
+
+
Fecha Pago
+
{{format('shortDate', $venta->escritura()->pago()->fecha)}}
+
+
+
Fecha
+ @include('form.fecha') +
+
+
Valor Pagado [$]
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/ventas/firmar.blade.php b/resources/views/ventas/firmar.blade.php new file mode 100644 index 0000000..da16f27 --- /dev/null +++ b/resources/views/ventas/firmar.blade.php @@ -0,0 +1,16 @@ +@extends('layout.base') + +@section('content') +
+
Firmar Venta {{$venta->unidad()->descripcion}}
+
+ +
+
Fecha
+ @include('form.fecha') +
+
+ +
+
+@endsection diff --git a/resources/views/ventas/forma_pago.blade.php b/resources/views/ventas/forma_pago.blade.php new file mode 100644 index 0000000..0824d85 --- /dev/null +++ b/resources/views/ventas/forma_pago.blade.php @@ -0,0 +1,283 @@ + + + + + + + +@if ($venta->pie != 0) + + + + + + + + + + + + @if ($venta->pie()->reajuste == 0) + @if ($venta->escriturado == 0) + + + @else + + @endif + @else + + + + + + + + @endif + +@endif +@if ($venta->escritura != 0) + + + + + + + +@endif + + + + + + +@if ($venta->bono_pie != 0) + + + + + + +@else + + + +@endif +@if ($venta->subsidio != 0) + + + + + + + + + + + + + +@else + + + +@endif +@if ($venta->credito != 0) + + + + + + +@elseif ($venta->escriturado == null and $venta->estado == 1) + + + + + + +@endif +@if ($venta->saldo() / $venta->valor_uf > 0.01 or $venta->devolucion) +devolucion) +class="warning" +@endif +> + + @if (!$venta->devolucion) + + + + + @else + + + + @endif + +@endif +@if ($venta->estado == 0) + + + + + @if ($venta->resciliacion) + + @else + + @endif + +@endif + + + + + + + + +
FORMA DE PAGO
Pie + @include('layout.icons.edit', ['small' => true]) + {{format('ufs', $venta->pie()->valor)}} UF$ {{format('pesos', $venta->pie()->valorPesos())}}Cuotas + + {{count($venta->pie()->pagadas())}} / {{$venta->pie()->cuotas}} + @if (count($venta->pie()->rebotadas()) > 0) + [-{{count($venta->pie()->rebotadas())}}] + @endif + + @if (count($venta->pie()->cuotas()) < $venta->pie()->cuotas) + + @include('layout.icons.add', ['small' => true]) + + @endif +
Pagado + {{format('ufs', $venta->pieReajustado())}} UF + + $ {{format('pesos', $venta->pie()->valorPagado('pesos'))}} + + + Reajustar @include('layout.icons.add') + +
Reajuste + @include('layout.icons.edit', ['small' => true]) + {{format('ufs', $venta->pie()->reajuste()->valor('ufs'))}} UF$ {{format('pesos', $venta->pie()->reajuste()->valor)}}{{format('shortDate', $venta->pie()->reajuste()->estado()->fecha)}} + @if ($venta->pie()->reajuste()->estado()->estado < 1) + + @include('layout.icons.pagar') + + @elseif ($venta->pie()->reajuste()->estado()->estado < 2) + + @include('layout.icons.abonar') + + @else + + @include('layout.icons.edit') + + @endif +
Escritura + @include('layout.icons.edit', ['small' => true]) + {{format('ufs', $venta->escritura()->pago()->valor('ufs'))}} UF$ {{format('pesos', $venta->escritura()->pago()->valor())}}{{format('shortDate', $venta->escritura()->pago()->estado()->fecha)}} + @if ($venta->escritura()->pago()->estado()->estado == 1) + + @include('layout.icons.abonar') + + @elseif ($venta->escritura()->pago()->estado()->estado == 0) + + @include('layout.icons.pagar') + + @endif +
Anticipo{{format('ufs', $venta->anticipo())}} UF$ {{format('pesos', $venta->anticipo('pesos'))}}
Bono Pie + @include('layout.icons.edit', ['small' => true]) + {{format('ufs', $venta->bonoPie()->pago()->valor('ufs'))}} UF$ {{format('pesos', $venta->bonoPie()->pago()->valor)}}
Bono Pie + @include('layout.icons.add', ['small' => true]) +
Subsidio + @include('layout.icons.edit', ['small' => true]) + {{format('ufs', $venta->subsidio()->subsidio()->valor('ufs'))}} UF $ {{format('pesos', $venta->subsidio()->subsidio()->valor())}}{{format('shortDate', $venta->subsidio()->subsidio()->estado()->fecha)}} + @if ($venta->subsidio()->subsidio()->estado()->estado < 1) + + @include('layout.icons.pagar') + + @elseif($venta->subsidio()->subsidio()->estado()->estado < 2) + + @include('layout.icons.abonar') + + @endif + + Subsidio + + + +
{{format('ufs', $venta->subsidio()->pago()->valor('ufs'))}} UF $ {{format('pesos', $venta->subsidio()->pago()->valor())}}{{format('shortDate', $venta->subsidio()->pago()->estado()->fecha)}} + @if ($venta->subsidio()->pago()->estado()->estado < 1) + + @include('layout.icons.pagar') + + @elseif ($venta->subsidio()->pago()->estado()->estado < 2) + + @include('layout.icons.abonar') + + @endif + + Libreta de Ahorro + + + +
Subsidio + @include('layout.icons.add', ['small' => true]) +
+ Crédito + + @include('layout.icons.show', ['icon' => 'eye-open', 'small' => true]) + + + @include('layout.icons.remove', ['small' => true]) + + {{format('ufs', $venta->credito()->pago()->valor('ufs'))}} UF$ {{format('pesos', $venta->credito()->pago()->valor)}}{{format('shortDate', $venta->credito()->pago()->estado()->fecha)}} + @if ($venta->credito()->pago()->estado()->estado < 1) + + @include('layout.icons.pagar') + + @elseif ($venta->credito()->pago()->estado()->estado < 2) + + @include('layout.icons.abonar') + + @endif + Banco: @if ($venta->credito()->pago()->banco != 0) {{$venta->credito()->pago()->banco()->nombre}} @endif
Crédito{{format('ufs', $venta->valor_uf - $venta->pagado())}} UF + @include('layout.icons.add') +
Devolución + @if (!$venta->devolucion) + + @else + + @include('layout.icons.edit') + + @endif + -{{format('ufs', $venta->saldo('ufs'))}} UF-$ {{format('pesos', $venta->saldo('pesos'))}} + @include('layout.icons.add') + -{{format('ufs', $venta->devolucion()->valor('ufs'))}} UF-$ {{format('pesos', $venta->devolucion()->valor('pesos'))}}{{format('shortDate', $venta->devolucion()->estado()->fecha)}} + @if ($venta->devolucion()->estado()->estado < 1) + + @include('layout.icons.pagar') + + @elseif ($venta->devolucion()->estado()->estado < 2) + + @include('layout.icons.abonar') + + @endif +
Resciliación-{{format('ufs', (($venta->resciliacion) ? $venta->resciliacion()->valor('ufs') : $venta->anticipo('ufs')), null, true)}}-{{format('pesos', (($venta->resciliacion) ? $venta->resciliacion()->valor('pesos') : $venta->anticipo('pesos')), null, true)}} + @if ($venta->resciliacion()->estado()->estado < 1) + + @include('layout.icons.pagar') + + @elseif ($venta->resciliacion()->estado()->estado < 2) + + @include('layout.icons.abonar') + + @endif +
Total{{format('ufs', $venta->pagado())}} UF$ {{format('pesos', $venta->pagado('pesos'))}}{{format('ufs', $venta->saldo())}} UF
diff --git a/resources/views/ventas/forma_pago/edit.blade.php b/resources/views/ventas/forma_pago/edit.blade.php new file mode 100644 index 0000000..2b9d7f1 --- /dev/null +++ b/resources/views/ventas/forma_pago/edit.blade.php @@ -0,0 +1,227 @@ +@extends('layout.base') + +@section('content') +
+

Editar Forma de Pago - {{$venta->unidad()->descripcion}} - {{$venta->proyecto()->descripcion}}

+
+
+@if ($venta->pie != 0) +
+
Pie
+
+
+
+
Valor [UF]
+
+
+
+
Cuotas
+
+
+@if ($venta->pie()->reajuste != 0) +
+
Reajuste
+
+
+
+
Fecha
+ pie()->reajuste()->fecha, config('app.timezone')) ?> + @include('form.fecha') +
+
+
Valor [$]
+
+
+@else +
+
Fecha
+ + @include('form.fecha') +
+@endif +@endif +
+
Escritura
+
+
+@if ($venta->escritura != 0) +
+
Fecha
+ escritura()->pago()->fecha, config('app.timezone')) ?> + @include('form.fecha') +
+
+
Valor [$]
+
+
+@else +
+
Fecha
+ + @include('form.fecha') +
+
+
Valor [$]
+
+
+@endif +
+
Crédito
+
+
+@if ($venta->credito != 0) + +@endif +
+
+
+
+@endsection + + +@if ($venta->pie != 0) + + Pie + pie()->valorPagado('pesos'); + $total_uf = $venta->pie()->valorPagado(); + $anticipo += $venta->pie()->valorPagado('pesos'); + $anticipo_uf += $venta->pie()->valorPagado() + ?> + {{format('ufs', $venta->pie()->valor)}} UF + $ {{format('pesos', $venta->pie()->valorPesos())}} + Cuotas + + {{count($venta->pie()->pagadas())}} / {{$venta->pie()->cuotas}} + @if (count($venta->pie()->cuotas()) < $venta->pie()->cuotas) + + @endif + + + + Pagado + {{format('ufs', $venta->pie()->valorPagado())}} UF + $ {{format('pesos', $venta->pie()->valorPagado('pesos'))}} + @if ($venta->pie()->reajuste == 0) + @if ($venta->escriturado == 0) + Reajustar + + @else + + @endif + @else + pie()->reajuste()->valor; + $total_uf += $venta->pie()->reajuste()->valor('ufs'); + $anticipo += $venta->pie()->reajuste()->valor; + $anticipo_uf += $venta->pie()->reajuste()->valor('ufs'); + ?> + + + + Reajuste + {{format('ufs', $venta->pie()->reajuste()->valor('ufs'))}} UF + $ {{format('pesos', $venta->pie()->reajuste()->valor)}} + {{format('shortDate', $venta->pie()->reajuste()->estado()->fecha)}} + @if ($venta->pie()->reajuste()->estado()->estado < 2) + + @endif + + @endif + +@endif +@if ($venta->bono_pie != 0) + + Bono Pie + bonoPie()->pago()->valor; + $total_uf += $venta->bonoPie()->pago()->valor('ufs'); + $anticipo += $venta->bonoPie()->pago()->valor; + $anticipo_uf += $venta->bonoPie()->pago()->valor('ufs'); + ?> + {{format('ufs', $venta->bonoPie()->pago()->valor('ufs'))}} UF + $ {{format('pesos', $venta->bonoPie()->pago()->valor)}} + + +@endif +@if ($venta->escritura != 0) +escritura()->pago()->valor; +$total_uf += $venta->escritura()->pago()->valor('ufs'); +$anticipo += $venta->escritura()->pago()->valor; +$anticipo_uf += $venta->escritura()->pago()->valor('ufs'); +?> + + Escritura + {{format('ufs', $venta->escritura()->pago()->valor('ufs'))}} UF + $ {{format('pesos', $venta->escritura()->pago()->valor)}} + {{format('shortDate', $venta->escritura()->pago()->estado()->fecha)}} + @if ($venta->escritura()->pago()->estado()->estado == 1) + + @elseif ($venta->escritura()->pago()->estado()->estado == 0) + + @endif + + + +@endif + + Anticipo + {{format('ufs', $anticipo_uf)}} UF + $ {{format('pesos', $anticipo)}} + + +@if ($venta->subsidio != 0) +subsidio()->total(); $total_uf += $venta->subsidio()->total('ufs') ?> + + Subsidio + {{format('ufs', $venta->subsidio()->total('ufs'))}} UF + $ {{format('pesos', $venta->subsidio()->total())}} + {{format('shortDate', $venta->subsidio()->pago()->fecha)}} + @if ($venta->subsidio()->pago()->estado()->estado < 2) + + @endif + + +@endif +@if ($venta->credito != 0) + + Crédito @if ($venta->credito != 0) @endif +credito()->pago()->valor; $total_uf += $venta->credito()->pago()->valor('ufs') ?> + {{format('ufs', $venta->credito()->pago()->valor('ufs'))}} UF + $ {{format('pesos', $venta->credito()->pago()->valor)}} + {{format('shortDate', $venta->credito()->pago()->estado()->fecha)}} + @if ($venta->credito()->pago()->estado()->estado < 1) + + @elseif ($venta->credito()->pago()->estado()->estado < 2) + + @endif + + Banco: @if ($venta->credito()->pago()->banco != 0) {{$venta->credito()->pago()->banco()->nombre}} @endif +@elseif ($venta->escriturado == null) + + Crédito @if ($venta->credito != 0) @endif + {{format('ufs', $venta->valor_uf - $total_uf)}} UF + + + +@endif + + Total + {{format('ufs', $total_uf)}} UF + $ {{format('pesos', $total)}} + {{format('ufs', $total_uf - $venta->valor_uf)}} UF + + + + + \ No newline at end of file diff --git a/resources/views/ventas/list.blade.php b/resources/views/ventas/list.blade.php new file mode 100644 index 0000000..aef16a3 --- /dev/null +++ b/resources/views/ventas/list.blade.php @@ -0,0 +1,42 @@ +@extends('layout.base') + +@section('content') +
+

Ventas de {{$proyecto->descripcion}} [{{count($ventas)}}]

+
+ + + + + + + + + + + + + + @foreach ($ventas as $venta) + + + + + + + + + + @endforeach + +
@include('ventas.sort_title', ['title' => 'Departamento'])@include('ventas.sort_title', ['title' => 'Propietario'])@include('ventas.sort_title', ['title' => 'Valor [UF]'])@include('ventas.sort_title', ['title' => 'Tipología'])@include('ventas.sort_title', ['title' => 'UF/m²'])@include('ventas.sort_title', ['title' => 'Fecha Venta'])@include('ventas.sort_title', ['title' => 'Estado'])
+ + {{trim(array_reduce($venta->propiedad()->departamentos(), function($carry, $item) { + return implode(' - ', [$carry, $item->descripcion]); + }), ' -')}} + {{(count($venta->propiedad()->estacionamientos('array')) > 0) ? ' - E' . implode(', ', $venta->propiedad()->estacionamientos('array')) : ''}} + {{(count($venta->propiedad()->bodegas('array')) > 0) ? ' - B' . implode(', ', $venta->propiedad()->bodegas('array')) : ''}} + + + propietario()->nombreCompleto() . '"')}}">{{$venta->propietario()->nombreCompleto()}} {{\App\Helper\Format::ufs($venta->valor_uf)}}{{$venta->propiedad()->unidad()->tipologia()->tipologia()->descripcion}} ({{format('m2', $venta->propiedad()->unidad()->tipologia()->m2())}} m²){{\App\Helper\Format::ufs($venta->uf_m2())}}{{$venta->fecha()->format('d-m-Y')}}{{ucwords($venta->estado()->tipo()->descripcion)}}
+@endsection diff --git a/resources/views/ventas/operadores/unidades/bloquear.blade.php b/resources/views/ventas/operadores/unidades/bloquear.blade.php new file mode 100644 index 0000000..096de7b --- /dev/null +++ b/resources/views/ventas/operadores/unidades/bloquear.blade.php @@ -0,0 +1,61 @@ +@extends('layout.base') + +@section('content') +
+

Bloquear Unidades - {{$operador->proyecto()->descripcion}}

+
+
+
Operador
+
{{$operador->agente()->agente()->abreviacion}}
+
+
+
+
+
Fecha
+ @include('form.fecha') +
+
+
Departamentos
+
+
+
+
Estacionamientos
+
+
+
+
Bodegas
+
+
+ + + + + + + + + + + + @foreach ($operador->proyecto()->unidadesDisponibles() as $unidad) + + + + + + + + @endforeach + +
TipoNúmeroTipología
{{ucwords($unidad->tipo()->descripcion)}}{{$unidad->descripcion}} + @if ($unidad->tipologia()->tipologia()) + {{$unidad->tipologia()->tipologia()->descripcion}} + @endif + {!!format('m2', $unidad->m2(), null, true)!!}
+
+
+ +
+
+
+@endsection diff --git a/resources/views/ventas/operadores/unidades/list.blade.php b/resources/views/ventas/operadores/unidades/list.blade.php new file mode 100644 index 0000000..544f1a2 --- /dev/null +++ b/resources/views/ventas/operadores/unidades/list.blade.php @@ -0,0 +1,82 @@ +@extends('layout.base') + +@section('content') +
+

Unidades Bloqueadas

+
+ + + + + + + + + @foreach ($proyectos as $proyecto) + + + + + @endforeach + +
ProyectoOperadores
{{$proyecto->descripcion}} + + + + + + + + + @foreach ($proyecto->operadoresVigentes() as $operador) + + + + + @endforeach + +
NombreUnidades
+ {{$operador->agente()->agente()->abreviacion}} + + @if ($operador->unidadesBloqueadas()) + + + + [{{count($operador->unidadesBloqueadas())}}] + + + + + + + + + + + + + + @foreach ($operador->unidadesBloqueadas() as $unidad) + + + + + + + + + + @endforeach + +
TipoNúmeroTipologíam² VendibleFechaPrecio ListaUF/m²
+ {{ucwords($unidad->unidad()->tipo()->descripcion)}} + {{$unidad->unidad()->descripcion}}{{$unidad->unidad()->tipologia()->tipologia()->descripcion}}{{$unidad->unidad()->m2()}}{{format('shortDate', $unidad->estado()->fecha())}}{{format('ufs', $unidad->unidad()->precio($unidad->estado()->fecha())->valor)}} UF{{format('ufs', $unidad->unidad()->precio($unidad->estado()->fecha())->valor / $unidad->unidad()->m2())}}
+ @else + No hay unidades bloqueadas. + + + + @endif +
+
+@endsection diff --git a/resources/views/ventas/pagos/edit.blade.php b/resources/views/ventas/pagos/edit.blade.php new file mode 100644 index 0000000..41d1b25 --- /dev/null +++ b/resources/views/ventas/pagos/edit.blade.php @@ -0,0 +1,77 @@ +@extends('layout.base') + +@section('content') +
+

Editar Pago

+
+
+
+
+
Fecha
+ fecha, config('app.timezone')) ?> + @include('form.fecha') +
+
+
Tipo
+
+
+
+
(Identificador)
+
+
+
+
Banco
+
banco()) + value="{{$pago->banco()->nombre}}" + @endif + id="banco" autocomplete="off" />
+
+
+
Valor [$]
+
+
+
+
(Pagador)
+
+
+
+
Estado
+
+
+
+
Fecha Estado
+ estado()->fecha, config('app.timezone')); $id = 'estado' ?> + @include('form.fecha') +
+
+
+
+
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/ventas/pagos/pendientes.blade.php b/resources/views/ventas/pagos/pendientes.blade.php new file mode 100644 index 0000000..1201fa8 --- /dev/null +++ b/resources/views/ventas/pagos/pendientes.blade.php @@ -0,0 +1,268 @@ +@extends('layout.base') + +@section('content') +

Pagos Pendientes

+
+
Históricos
+
+
+
+
+
+ +
+
+

Para Abonar [
]

+ + + + + + + + + + + + + +
ProyectoDepartamentoPropietarioTipoFecha DepositoValor
+

Pagos Rebotados Pendientes [
]

+ + + + + + + + + + + + + +
ProyectoDepartamentoPropietarioTipoFecha ReboteValor
+@endsection + +@push('styles') + +@endpush + +@push('scripts') + +@endpush diff --git a/resources/views/ventas/pagos/show.blade.php b/resources/views/ventas/pagos/show.blade.php new file mode 100644 index 0000000..36db674 --- /dev/null +++ b/resources/views/ventas/pagos/show.blade.php @@ -0,0 +1,61 @@ +@extends('layout.base') + +@section('content') +
+
Pago
+ +
+
+
+
Tipo
+
+ @if ($pago->tipo()) + {{ucwords($pago->tipo()->descripcion)}} + @endif +
+
+
+
Fecha
+
{{format('shortDate', $pago->fecha)}}
+
+
+
Valor
+
{{format('pesos', $pago->valor('pesos'), null, true)}}
+
{{format('ufs', $pago->valor('ufs'), null, true)}}
+
+
+
Valor de UF
+
{{format('pesos', $pago->uf, null, true)}}
+
+@if ($pago->banco != 0) +
+
Banco
+
{{$pago->banco()->descripcion}}
+
+@endif +@if ($pago->identificador != '') +
+
Identificador
+
{{$pago->identificador}}
+
+@endif + + + + + + + + +@foreach ($pago->estados() as $estado) + + + + +@endforeach + +
EstadoFecha
{{ucwords($estado->tipo()->descripcion)}}{{format('shortDate', $estado->fecha)}}
+Volver +@endsection diff --git a/resources/views/ventas/pies/cuotas/abonar.blade.php b/resources/views/ventas/pies/cuotas/abonar.blade.php new file mode 100644 index 0000000..d306560 --- /dev/null +++ b/resources/views/ventas/pies/cuotas/abonar.blade.php @@ -0,0 +1,197 @@ +@extends('layout.base') + +@section('content') +
+
Abonar Cuotas
+
+ Hay {{$total}} cuotas para abonar.
+
+
Se están viendo de ha
+
+
en {{$pages}} páginas.
+
+
+
Filtro
+
+
+
+
+
+ @if (get('start') > 0) + + @endif +
+
+ @if (get('start') > 0) + + @endif +
+
{{$current}} / {{$pages}}
+
+ @if (get('start') + ((get('step')) ? get('step') : 30) < $total) + + @endif +
+
+ @if (get('start') + ((get('step')) ? get('step') : 30) < $total) + + @endif +
+
+ + + + + + + + + + + + + + + + + + + @foreach ($cuotas as $cuota) + + + + + + + + + + + + + + @endforeach + +
ProyectoDepartamentoValor CuotaFecha Depositada
PropietarioFecha CuotaFecha Abono / Devolución
{{$cuota->pie()->venta()->proyecto()->descripcion}}{{$cuota->pie()->venta()->unidad()->descripcion}}$ {{format('pesos', $cuota->pago()->valor)}}{{format('shortDate', $cuota->pago()->estado()->fecha)}}
{{$cuota->pie()->venta()->propietario()->nombreCompleto()}}{{format('shortDate', $cuota->pago()->fecha)}} +
+
+
+
+
+
X
+
+
+ @if (get('start') > 0) + + @endif +
+
+ @if (get('start') > 0) + + @endif +
+
{{$current}} / {{$pages}}
+
+ @if (get('start') + ((get('step')) ? get('step') : 30) < $total) + + @endif +
+
+ @if (get('start') + ((get('step')) ? get('step') : 30) < $total) + + @endif +
+
+
+
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/ventas/pies/cuotas/add.blade.php b/resources/views/ventas/pies/cuotas/add.blade.php new file mode 100644 index 0000000..941fbef --- /dev/null +++ b/resources/views/ventas/pies/cuotas/add.blade.php @@ -0,0 +1,123 @@ +@extends('layout.base') @section('content') +
+
Agregar Cuotas - Departamento {{$pie->venta()->unidad()->descripcion}} - {{$pie->venta()->proyecto()->descripcion}}
+
+ @if (count($pie->venta()->propietario()->ventas()) > 1) +
+
+
+ +
+
+
+
+ @endif +
+ + + + + + + + + + + + + cuotas - count($pie->cuotas()); $ini = count($pie->cuotas()) + 1 ?> + @for ($n = 0; $n < $cant; $n ++) + + + + + + + + + + @endfor + +
#FechaBancoIdentificadorValor [$]
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+ +
+
+
+
+
+
+@endsection + +@push('scripts') + + +@endpush diff --git a/resources/views/ventas/pies/cuotas/edit.blade.php b/resources/views/ventas/pies/cuotas/edit.blade.php new file mode 100644 index 0000000..1298777 --- /dev/null +++ b/resources/views/ventas/pies/cuotas/edit.blade.php @@ -0,0 +1,69 @@ +@extends('layout.base') @section('content') +
+
Editar Cuota - Departamento {{$cuota->pie()->venta()->unidad()->descripcion}} - {{$cuota->pie()->venta()->proyecto()->descripcion}}
+
+
+ fecha, config('app.timezone')); $t = \Carbon\Carbon::today(config('app.timezone')) ?> +
+
#
+
+
+
+
Fecha
+
+
+
+
+
+
Banco
+
+
+
+
Identificador
+
+
+
+
Valor [$]
+
+
+
+
+
+
+
+
+@endsection + +@push('scripts') + +@endpush \ No newline at end of file diff --git a/resources/views/ventas/pies/cuotas/estado.blade.php b/resources/views/ventas/pies/cuotas/estado.blade.php new file mode 100644 index 0000000..f480bfd --- /dev/null +++ b/resources/views/ventas/pies/cuotas/estado.blade.php @@ -0,0 +1,10 @@ +@if ($cuota->pago()->estado()->tipo()->descripcion == 'abonado') +success +@elseif ($cuota->pago()->estado()->tipo()->descripcion == 'depositado') +warning +@elseif ($cuota->pago()->estado()->tipo()->descripcion == 'devuelto') +error +@elseif ($cuota->pago()->estado()->tipo()->descripcion == 'no pagado') +@else +danger +@endif \ No newline at end of file diff --git a/resources/views/ventas/pies/cuotas/pendientes.blade.php b/resources/views/ventas/pies/cuotas/pendientes.blade.php new file mode 100644 index 0000000..ca4d150 --- /dev/null +++ b/resources/views/ventas/pies/cuotas/pendientes.blade.php @@ -0,0 +1,139 @@ +@extends('layout.base') + +@section('content') +
+
Cuotas Pendientes
+
+
+
Total
+
{{count($cuotas)}}
+
$ {{format('pesos', $sum)}}
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + @foreach ($cuotas as $cuota) + pago()->fecha, config('app.timezone')); + if ($f->dayOfWeek == \Carbon\Carbon::SATURDAY or $f->dayOfWeek == \Carbon\Carbon::SUNDAY) { + $f->next(\Carbon\Carbon::MONDAY); + } + ?> + + + + + + + + + + + + + + + + @endforeach + +
ProyectoDepartamento$DíaCuota
PropietarioBancoFecha ChequeDepositar
{{$cuota->pie()->venta()->proyecto()->descripcion}}{{$cuota->pie()->venta()->unidad()->descripcion}}$ {{format('pesos', $cuota->pago()->valor)}}{{format('localDate', $f, 'EEEE dd')}}{{str_pad($cuota->numero, 2, '0', STR_PAD_LEFT)}} - {{str_pad($cuota->pie()->cuotas, 2, '0', STR_PAD_LEFT)}}
{{$cuota->pie()->venta()->propietario()->nombreCompleto()}}@if ($cuota->pago()->banco()) {{$cuota->pago()->banco()->nombre}} @endif{{format('shortDate', $cuota->pago()->fecha)}} + + + +
+
+
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/ventas/pies/cuotas/show.blade.php b/resources/views/ventas/pies/cuotas/show.blade.php new file mode 100644 index 0000000..b540714 --- /dev/null +++ b/resources/views/ventas/pies/cuotas/show.blade.php @@ -0,0 +1,64 @@ +@extends('layout.base') + +@section('content') + +
+
+
Número
+
{{$cuota->numero()}}
+
+
+
Fecha
+
{{format('shortDate', $cuota->pago()->fecha)}}
+
+
+
Identificador
+
{{$cuota->pago()->identificador}}
+
+
+
Banco
+
{{($cuota->pago()->banco != 0) ? $cuota->pago()->banco()->nombre : ''}}
+
+
+
Valor
+
$ {{format('pesos', $cuota->pago()->valor())}}
+
{{format('ufs', $cuota->pago()->valor('ufs'))}} UF
+
+
+
Historial
+
+ + + + + + + + +@foreach ($cuota->pago()->estados() as $estado) + + + + +@endforeach + +
FechaEstado
{{format('shortDate', $estado->fecha)}}{{ucwords($estado->tipo()->descripcion)}}
+@endsection \ No newline at end of file diff --git a/resources/views/ventas/pies/edit.blade.php b/resources/views/ventas/pies/edit.blade.php new file mode 100644 index 0000000..1406a4b --- /dev/null +++ b/resources/views/ventas/pies/edit.blade.php @@ -0,0 +1,23 @@ +@extends('layout.base') + +@section('content') +
+
Editar Pie - {{$venta->unidad()->descripcion}} - {{$venta->proyecto()->descripcion}}
+
+
+
+
Monto
+
+
UF
+
+
+
Cuotas
+
+
+
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/ventas/pies/reajustar.blade.php b/resources/views/ventas/pies/reajustar.blade.php new file mode 100644 index 0000000..95b952c --- /dev/null +++ b/resources/views/ventas/pies/reajustar.blade.php @@ -0,0 +1,48 @@ +@extends('layout.base') + +@section('content') +
+
Reajustar - {{$venta->unidad()->descripcion}} - {{$venta->proyecto()->descripcion}}
+
+
+
+
Pie Pagado
+
$ {{format('pesos', $venta->pie()->valorPagado('pesos'))}}
+
{{format('ufs', $venta->pie()->valorPagado())}} UF
+
+
+
Reajuste
+
$
+
+
+
+
+
+
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/ventas/pies/reajustes/abonar.blade.php b/resources/views/ventas/pies/reajustes/abonar.blade.php new file mode 100644 index 0000000..62c987a --- /dev/null +++ b/resources/views/ventas/pies/reajustes/abonar.blade.php @@ -0,0 +1,25 @@ +@extends('layout.base') + +@section('content') + +
+
+
+
Fecha Pago
+
{{format('shortDate', $venta->pie()->reajuste()->estado()->fecha)}}
+
+
+
Fecha
+ pie()->reajuste()->estado()->fecha, config('app.timezone')) ?> + @include('form.fecha') +
+
+
Valor Abonado [$]
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/ventas/pies/reajustes/edit.blade.php b/resources/views/ventas/pies/reajustes/edit.blade.php new file mode 100644 index 0000000..035da6c --- /dev/null +++ b/resources/views/ventas/pies/reajustes/edit.blade.php @@ -0,0 +1,53 @@ +@extends('layout.base') + +@section('content') +
+
Editar Reajuste - {{$venta->unidad()->descripcion}} - {{$venta->proyecto()->descripcion}}
+
+ +
+
Valor [$]
+
+
+
+
(Valor [UF])
+
+
+
+
Fecha
+ pie()->reajuste()->fecha, config('app.timezone')) ?> +
+
+
+
+
+
+
+ +
+
+@endsection \ No newline at end of file diff --git a/resources/views/ventas/pies/reajustes/pagar.blade.php b/resources/views/ventas/pies/reajustes/pagar.blade.php new file mode 100644 index 0000000..5bd5e28 --- /dev/null +++ b/resources/views/ventas/pies/reajustes/pagar.blade.php @@ -0,0 +1,24 @@ +@extends('layout.base') + +@section('content') + +
+
+
+
Fecha Pago
+
{{format('shortDate', $venta->pie()->reajuste()->fecha)}}
+
+
+
Fecha
+ @include('form.fecha') +
+
+
Valor Pagado [$]
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/ventas/pies/resumen.blade.php b/resources/views/ventas/pies/resumen.blade.php new file mode 100644 index 0000000..39dfe3e --- /dev/null +++ b/resources/views/ventas/pies/resumen.blade.php @@ -0,0 +1,276 @@ +@extends('layout.base') + +@section('content') +
+
+

+ {{$venta->unidad()->descripcion}} - {{$venta->unidad()->proyecto()->descripcion}} + @if ($venta->pie()->asociados() != null) +
+ @foreach ($venta->pie()->asociados() as $asociado) + {{$asociado->venta()->unidad()->descripcion}} + @endforeach + @elseif ($venta->pie()->asociado() != null) +
+ {{$venta->pie()->asociado()->venta()->unidad()->descripcion}} + @foreach ($venta->pie()->asociado()->asociados() as $asociado) + @if ($asociado->venta()->id == $venta->id) + @continue + @endif + {{$asociado->venta()->unidad()->descripcion}} + @endforeach + @endif +

+
+
+ + + + + + + + + + + + + + + + +
PIE
Fecha{{\App\Helper\Format::shortDate($venta->pie()->fecha)}}Valor{{\App\Helper\Format::ufs($venta->pie()->valor)}} UF$ {{\App\Helper\Format::pesos($venta->pie()->valorPesos())}}Cuotas({{count($venta->pie()->abonadas())}}) {{count($venta->pie()->pagadas())}} / {{$venta->pie()->cuotas}} +
+ + + + + + + + + + + + + + + 0, + 'pagado_uf' => 0, + 'por_pagar' => 0, + 'por_pagar_uf' => 0, + 'cuotas' => 0, + 'cuotas_uf' => 0, + 'dif' => 0, + 'dif_uf' => 0 + ]; + $t = \Carbon\Carbon::today(config('app.timezone')); + ?> + @foreach ($venta->pie()->cuotas() as $cuota) + + + + + + + + + + + @endforeach + dif = $venta->pie()->valorPesos() - $total->cuotas; + $total->dif_uf = $venta->pie()->valor - $total->cuotas_uf; + + $valores = (object) [ + 'titulo' => 'Total Pagado', + 'pesos' => $total->pagado, + 'ufs' => $total->pagado_uf + ]; + ?> + @include('ventas.pies.totales') + titulo = 'Por Pagar'; + $valores->pesos = $total->por_pagar; + $valores->ufs = $total->por_pagar_uf; + ?> + @include('ventas.pies.totales') + titulo = 'Total Cuotas'; + $valores->pesos = $total->cuotas; + $valores->ufs = $total->cuotas_uf; + ?> + @include('ventas.pies.totales') + titulo = 'Diferencia c/Pie'; + $valores->pesos = $total->dif; + $valores->ufs = $total->dif_uf; + ?> + @include('ventas.pies.totales') + +
#FechaBancoIdentificadorValorUF +
+
Fecha
+
+
Deposito
+
Abono
+
+
+
+ Depositar
+ Abonar +
+ {{++$cnt}} + {{\App\Helper\Format::shortDate($cuota->pago()->fecha)}}{{($cuota->pago()->banco()) ? $cuota->pago()->banco()->nombre : ''}} + @if ($cuota->pago()->identificador == '') + + @else + {{$cuota->pago()->identificador}} + @endif + $ {{\App\Helper\Format::pesos($cuota->valor())}}{{\App\Helper\Format::ufs($cuota->valor('ufs'))}} UF + {{\App\Helper\Format::shortDate($cuota->pago()->estado()->fecha)}} + + + @if ($cuota->pago()->estado()->estado == 0 or $cuota->pago()->estado()->estado == -1) + por_pagar += $cuota->valor(); + $total->por_pagar_uf += $cuota->valor('ufs'); + ?> +
+
+
+
+
+
+
+
+ @elseif ($cuota->pago()->estado()->estado == 1) + pagado += $cuota->pago()->valor; + $total->pagado_uf += $cuota->pago()->valor('ufs'); + ?> +
+
+ pago()->estado()->fecha, config('app.timezone')) ?> +
+
+
+
+
+ +
+
+
+ @else + pagado += $cuota->pago()->valor; + $total->pagado_uf += $cuota->pago()->valor('ufs'); + ?> + @endif + cuotas += $cuota->pago()->valor; + $total->cuotas_uf += $cuota->pago()->valor('ufs'); + ?> +
+
+ Exportar +
+
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/ventas/pies/totales.blade.php b/resources/views/ventas/pies/totales.blade.php new file mode 100644 index 0000000..83d1d1f --- /dev/null +++ b/resources/views/ventas/pies/totales.blade.php @@ -0,0 +1,15 @@ +titulo == 'Diferencia c/Pie') + @if ($valores->ufs > 0) + class="danger" + @else + class="success" + @endif +@endif > + + {{$valores->titulo}} + $ {{format('pesos', $valores->pesos)}} + {{format('ufs', $valores->ufs)}} UF + {{format('percent', $valores->ufs / $venta->valor_uf * 100)}} % + + \ No newline at end of file diff --git a/resources/views/ventas/postventas/add.blade.php b/resources/views/ventas/postventas/add.blade.php new file mode 100644 index 0000000..23e1215 --- /dev/null +++ b/resources/views/ventas/postventas/add.blade.php @@ -0,0 +1,71 @@ +@extends('layout.base') + +@section('content') +
+

Agregar Postventa

+
+
+
+
+
Fecha
+ @include('form.fecha') +
+ +
+
Observaciones
+
+
+
+
+
+
+@endsection + +@push('scripts') + +@endpush \ No newline at end of file diff --git a/resources/views/ventas/postventas/show.blade.php b/resources/views/ventas/postventas/show.blade.php new file mode 100644 index 0000000..7d02816 --- /dev/null +++ b/resources/views/ventas/postventas/show.blade.php @@ -0,0 +1,26 @@ +@extends('layout.base') + +@section('content') +
+

Postventa - {{$venta->unidad()->descripcion}} - {{$venta->proyecto()->descripcion}}

+
+
+
+
Estado
+
{{ucwords($postventa->estado()->tipo()->descripcion)}}
+
{{format('shortDate', $postventa->estado()->fecha)}}
+
+
+
+
Observaciones
+
[{{count($postventa->observacionesPendientes())}} / {{count($postventa->observaciones())}}]
+
+@foreach ($postventa->observaciones() as $observacion) +
+
{{$observacion->texto}}
+
{{ucwords($observacion->estado()->tipo()->descripcion)}}
+
{{format('shortDate', $observacion->estado()->fecha)}}
+
+
+@endforeach +@endsection \ No newline at end of file diff --git a/resources/views/ventas/precios/add.blade.php b/resources/views/ventas/precios/add.blade.php new file mode 100644 index 0000000..17c7c69 --- /dev/null +++ b/resources/views/ventas/precios/add.blade.php @@ -0,0 +1,130 @@ +@extends('layout.base') + +@section('content') +
+

Agregar Precios - {{$proyecto->descripcion}}

+
+
+
+
+
Fecha
+ @include('form.fecha') +
+ + + + + + + + + + + + + + + + + + @foreach ($proyecto->proyectoTipoUnidades() as $tipo) + + + + + + + + + + + + + + + @endforeach + +
TipoNombreAbreviaciónLíneasm² Vendible#Precio
AnteriorNuevo
{{ucwords($tipo->tipo()->descripcion)}}{{$tipo->nombre}}{{$tipo->abreviacion}}{{$tipo->lineas()}}{{$tipo->m2()}}{{count($tipo->unidades())}}{{format('ufs', $tipo->precio(), true)}}
+ + + + + + + + + + + + + + + + + + @foreach ($tipo->unidades() as $unidad) + @if ($subtipo != $unidad->subtipo) + subtipo; ?> + + + + + + @endif + + + + + + + + + @endforeach + +
DescripciónPisoLíneaOrientaciónPrecio
AnteriorNuevo
Línea {{$subtipo}}{{format('ufs', $tipo->precioSubtipo($subtipo), true)}}
{{$unidad->descripcion}}{{$unidad->piso}}{{$unidad->subtipo}}{{$unidad->orientacion}} + @if ($unidad->precio()) + {{format('ufs', $unidad->precio()->valor, true)}} + @else + -- + @endif +
+
+
+
+
+
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/ventas/precios/import.blade.php b/resources/views/ventas/precios/import.blade.php new file mode 100644 index 0000000..bfe7242 --- /dev/null +++ b/resources/views/ventas/precios/import.blade.php @@ -0,0 +1,37 @@ +@extends('layout.base') + +@section('content') +
+

Importar Precios

+
+
+
+
+
Proyecto
+
+
+
+
Fecha
+ @include('form.fecha') +
+
+
Archivo CSV *
+
+
+
+

+ (*) Columnas: tipo [departamento, estacionamiento, bodega], numeracion, valor +
+ Muestra +

+
+
+
+
+
+@endsection diff --git a/resources/views/ventas/precios/list.blade.php b/resources/views/ventas/precios/list.blade.php new file mode 100644 index 0000000..e2f27a1 --- /dev/null +++ b/resources/views/ventas/precios/list.blade.php @@ -0,0 +1,134 @@ +@extends('layout.base') + +@section('content') +
+

+
+
+ Precios - {{$proyecto->descripcion}} +
+
+
+

+
+
+ + + + + + + + + + + + + + + @foreach ($proyecto->ProyectoTipoUnidades() as $tipo) + + + + + + + + + + + + + + + @endforeach + +
TipoNombreTipologíaLíneasm² Vendibles#Precio PromedioUF/m²
{{ucwords($tipo->tipo()->descripcion)}}{{$tipo->nombre}} + @if ($tipo->tipologia()) + {{$tipo->tipologia()->descripcion}} + @else + {{$tipo->abreviacion}} + @endif + {{$tipo->lineas()}}{{$tipo->m2()}}{{count($tipo->unidades())}}{{format('ufs', $tipo->precio(), true)}} + @if ($tipo->m2() > 0) + {{format('ufs', $tipo->precio() / $tipo->m2(), true)}}/m² + @else + - + @endif +
+ + + + + + + + + + + + @foreach ($tipo->unidades() as $unidad) + @if ($subtipo != $unidad->subtipo) + subtipo; ?> + + + + + + + @endif + + + @if ($unidad->precio()) + + + + @else + + @endif + + @endforeach + +
UnidadDesdePrecioUF/m²
Línea {{$subtipo}}{{format('ufs', $tipo->precioSubtipo($subtipo), null, true)}}{{format('ufs', $tipo->precioSubtipo($subtipo) / $tipo->m2(), null, true)}}/m²
{{$unidad->descripcion}}{{format('shortDate', $unidad->precio()->estado()->fecha)}}{{format('ufs', $unidad->precio()->valor, null, true)}} + @if ($unidad->m2('vendible') > 0) + {{format('ufs', $unidad->precio()->valor / $unidad->m2('vendible'), null, true)}}/m² + @else + - + @endif + --
+
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/ventas/precios/proyectos.blade.php b/resources/views/ventas/precios/proyectos.blade.php new file mode 100644 index 0000000..095b5b6 --- /dev/null +++ b/resources/views/ventas/precios/proyectos.blade.php @@ -0,0 +1,14 @@ +@extends('layout.base') + +@section('content') +
+

Precios

+
+ + @foreach ($proyectos as $proyecto) + + + @endforeach +
{{$proyecto->descripcion}} +
+@endsection diff --git a/resources/views/ventas/propietarios/edit.blade.php b/resources/views/ventas/propietarios/edit.blade.php new file mode 100644 index 0000000..b8edef8 --- /dev/null +++ b/resources/views/ventas/propietarios/edit.blade.php @@ -0,0 +1,246 @@ +@extends('layout.base') + +@section('content') +
+

Editar Propietario

+
+
+
+
+
RUT
+
+
+
+
+
Nombre
+
+
+
+
+@if ($propietario->direccion != 0) +
+
Dirección
+
+
+
+
+
+
+
+
+@else +
+
Dirección
+
+
+
+
+
+
+
+
+@endif +
+
+
+
+@endsection + +@push('scripts') + +@endpush \ No newline at end of file diff --git a/resources/views/ventas/proyectos.blade.php b/resources/views/ventas/proyectos.blade.php new file mode 100644 index 0000000..043fc60 --- /dev/null +++ b/resources/views/ventas/proyectos.blade.php @@ -0,0 +1,18 @@ +@extends('layout.base') + +@section('content') +
+

Ventas de Proyectos

+
+
+
+ + @foreach ($proyectos as $proyecto) + + + + @endforeach +
{{$proyecto->descripcion}}
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/ventas/resciliaciones.blade.php b/resources/views/ventas/resciliaciones.blade.php new file mode 100644 index 0000000..fd87e03 --- /dev/null +++ b/resources/views/ventas/resciliaciones.blade.php @@ -0,0 +1,38 @@ +@extends('layout.base') + +@section('content') +
+
Resciliaciones [{{count($resciliaciones)}}]
+
+
+ + + + + + + + + + + + + + +@foreach ($resciliaciones as $resciliacion) + + + + + + + + + + + +@endforeach + +
ProyectoDepartamentoFecha PromesaFecha ResciliaciónUF/m²Anticipo [UF]Anticipo [$] + Devolución [UF]Devolución [$]
{{$resciliacion->proyecto()->descripcion}}{{$resciliacion->unidad()->descripcion}}{{format('shortDate', $resciliacion->fecha)}}{{(($resciliacion->resciliacion) ? format('shortDate', $resciliacion->resciliacion()->estado()->fecha) : '')}}{{format('ufs', $resciliacion->uf_m2())}}{{format('ufs', $resciliacion->anticipo())}}{{format('pesos', $resciliacion->anticipo('pesos'))}}{{(($resciliacion->resciliacion) ? format('ufs', $resciliacion->resciliacion()->valor('ufs')) : '')}}{{(($resciliacion->resciliacion) ? format('pesos', $resciliacion->resciliacion()->valor('pesos')) : '')}}
+@endsection \ No newline at end of file diff --git a/resources/views/ventas/show.blade.php b/resources/views/ventas/show.blade.php new file mode 100644 index 0000000..7ca6a0e --- /dev/null +++ b/resources/views/ventas/show.blade.php @@ -0,0 +1,287 @@ +@extends('layout.base') + +@section('content') +
+
Venta - {{$venta->unidad()->descripcion}} - {{$venta->proyecto()->descripcion}}
+
+
+ + + + + + + + + + + +
PROYECTO
{{$venta->proyecto()->descripcion}}
+ + + + + + + + + + + + + + + +
PROPIETARIO +
{{\App\Helper\Format::number($venta->propietario()->rut, 0)}}-{{$venta->propietario()->dv}}{{($venta->propietario()->direccion()) ? $venta->propietario()->direccion()->completa() : ''}}
+ propietario()->nombreCompleto() . '"')])}}"> + {{$venta->propietario()->nombreCompleto()}} + + {{($venta->propietario()->direccion()) ? $venta->propietario()->direccion()->comuna()->descripcion : ''}} +
+
+ @if ($venta->estado()->tipo()->activa()) + +
+ Ceder +
+ @else +
+ @if (!$venta->estado()->tipo()->activa() and $venta->estado()->tipo()->descripcion == 'desistida') + Desistida + @if ($venta->resciliacion != null) + ($ {{format('pesos', $venta->resciliacion()->valor)}}) + @endif + @elseif (!$venta->estado()->tipo()->activa() and $venta->estado()->tipo()->descripcion == 'cedida') + Cedida + @endif +
+ @endif +
+ + + + + + + + + + + + + + + + + + + + + + + + + @foreach ($venta->propiedad()->unidades() as $unidad) + @if ($unidad->unidad()->id == $venta->unidad()->id) + @continue + @endif + + + + + + + + + + @endforeach + + + + + + + +
PROPIEDAD
UnidadPisoMetros VendiblesValor BaseUF/m²Orientación
{{ucwords($venta->unidad()->tipo()->descripcion)}} {{$venta->unidad()->tipologia()->tipologia()->descripcion}}{{$venta->unidad()->descripcion}}{{$venta->unidad()->piso}}{{\App\Helper\Format::number($venta->unidad()->m2(), 2)}} m² + @if ($venta->unidad()->precio($venta->fecha())) + {{format('ufs', $venta->unidad()->precio($venta->fecha())->valor)}} UF + @else + {{format('ufs', $venta->unidad()->valor)}} UF + @endif + + @if ($venta->unidad()->precio($venta->fecha())) + {{format('ufs', $venta->unidad()->precio($venta->fecha())->valor / $venta->unidad()->m2(), null, true)}}/m² + @else + {{format('ufs', $venta->unidad()->valor / $venta->unidad()->m2(), null, true)}}/m² + @endif + {{$venta->unidad()->orientacion}}
+ {{ucwords($unidad->unidad()->tipo()->descripcion)}} + @if ($unidad->unidad()->tipo()->descripcion == 'departamento') + {{$unidad->unidad()->tipologia()->tipologia()->descripcion}} + @endif + {{$unidad->unidad()->descripcion}}{{$unidad->unidad()->piso}} + @if ($unidad->unidad()->tipo()->descripcion == 'departamento') + {{\App\Helper\Format::number($unidad->unidad()->m2(), 2)}} m² + @endif + + @if ($unidad->unidad()->precio($venta->fecha())) + {{format('ufs', $unidad->unidad()->precio($venta->fecha())->valor, null, true)}} + @else + {{format('ufs', $unidad->unidad()->valor, null, true)}} + @endif + + @if ($unidad->unidad()->tipo()->descripcion == 'departamento') + @if ($unidad->unidad()->precio($venta->fecha())) + {{format('ufs', $unidad->unidad()->precio($venta->fecha())->valor / $unidad->unidad()->m2(), null, true)}}/m² + @else + {{format('ufs', $unidad->unidad()->valor / $unidad->unidad()->m2(), null, true)}}/m² + @endif + @endif + + @if ($unidad->unidad()->tipo()->descripcion == 'departamento') + {{$unidad->unidad()->orientacion}} + @endif +
Total + + {{format('ufs', $venta->valorUnidades(), null, true)}} + + + + {{format('ufs', $venta->valorDepartamentos() / $venta->superficie(), null, true)}}/m² + +
+ + + + + + + + + + + + + + + + + + + + + + @if (count($venta->promociones()) > 0) + @foreach ($venta->promociones() as $promo) + + + + + + @endforeach + @endif + +
VENTA
Valor TotalValor UtilUF/m²OperadorFecha Promesa
Fecha Ingreso
{{format('ufs', $venta->valor_uf)}} UF{{format('ufs', $venta->valorFinal())}} UF{{format('ufs', $venta->uf_m2(), null, true)}}/m²{{format('ufs', $venta->valorComision())}} UF ({{\App\Helper\Format::number($venta->comision() * 100, 2)}}%) + @if ($venta->agente != 0) +
+ {{$venta->agente()->agente()->agente()->descripcion}} + @endif +
{{format('shortDate', $venta->fecha)}}
{{format('shortDate', $venta->fecha_ingreso)}}
{{$promo->promocion()->descripcion}}{{format('ufs', $promo->valor, null, true)}}
+@include('ventas.forma_pago') + + + + + + + + + + + +
ESCRITURA
+ @if ($venta->escriturado == 0) + Escriturar + @elseif ($venta->estado()->tipo()->activa()) + Escriturado {{format('shortDate', $venta->estado('escriturando')->fecha)}} Informe + @if ($venta->estado()->tipo()->descripcion == 'escriturando') +
Firmar + @elseif ($venta->estado()->tipo()->descripcion == 'firmado por inmobiliaria') +
Firmado {{format('shortDate', $venta->estado('firmado por inmobiliaria')->fecha)}} +
Archivar + @elseif ($venta->estado()->tipo()->descripcion == 'archivado') +
Archivado {{format('shortDate', $venta->estado('archivado')->fecha)}} + @endif + @if ($venta->saldo() / $venta->valor_uf > 0.01) +
Devolver: $ {{format('pesos', $venta->saldo('pesos'))}} ({{format('ufs', $venta->saldo())}} UF) + @endif + @endif +
+ + + + + + + + + + + +
+ @if ($venta->entregado == 0) + ENTREGA + @else + ENTREGADO + @endif +
+ @if ($venta->entregado == 0) + No + @else + Agregar observaciones de entrega. + @endif +
+@if ($venta->entregado != 0) + + + + + + + + + + @if ($venta->postventas() != null) + @foreach ($venta->postventas() as $postventa) + + + + @endforeach + @endif + +
POSTVENTA
+
({{format('shortDate', $postventa->estado()->fecha)}}) [{{count($postventa->observacionesPendientes())}} / {{count($postventa->observaciones())}}]
+@endif + + + + + + + + @foreach ($venta->comentarios() as $comentario) + @if ($comentario->estado == 1) + + + + + + @endif + @endforeach + +
COMENTARIOS +
{{format('shortDate', $comentario->fecha)}}{{$comentario->texto}}
+@endsection diff --git a/resources/views/ventas/sort_title.blade.php b/resources/views/ventas/sort_title.blade.php new file mode 100644 index 0000000..b7ea11c --- /dev/null +++ b/resources/views/ventas/sort_title.blade.php @@ -0,0 +1,24 @@ + 'ventas', 'a' => 'list', 'proyecto' => $proyecto->id, 'sort' => $name]; +if (get('sort') == $name or (get('sort') == null and $name == 'departamento')) { + if (get('sort_dir')) { + $url_base['sort_dir'] = get('sort_dir'); + } else { + $url_base['sort_dir'] = 1; + } + $url_base['sort_dir'] *= -1; +} +?> + + {{$title}} + @if (get('sort') == $name or (get('sort') == null and $name == 'departamento')) + @if (get('sort_dir') == 1 or get('sort_dir') == null) + + @else + + + + @endif + @endif + diff --git a/resources/views/ventas/subsidios/abonar.blade.php b/resources/views/ventas/subsidios/abonar.blade.php new file mode 100644 index 0000000..242095e --- /dev/null +++ b/resources/views/ventas/subsidios/abonar.blade.php @@ -0,0 +1,23 @@ +@extends('layout.base') + +@section('content') +
+

Abonar Subsidio - {{$venta->proyecto()->descripcion}} - {{$venta->unidad()->descripcion}} - {{ucwords(get('tipo'))}}

+
+
+
+ +
+
Fecha
+ fecha, config('app.timezone')); ?> + @include('form.fecha') +
+
+
Valor
+
+
+
+
+
+
+@endsection diff --git a/resources/views/ventas/subsidios/add.blade.php b/resources/views/ventas/subsidios/add.blade.php new file mode 100644 index 0000000..97c68a0 --- /dev/null +++ b/resources/views/ventas/subsidios/add.blade.php @@ -0,0 +1,32 @@ +@extends('layout.base') + +@section('content') +
+

Agregar Subsidio - {{$venta->proyecto()->descripcion}} - {{$venta->unidad()->descripcion}}

+
+
+
+
+
Fecha
+ fecha, config('app.timezone')); ?> + @include('form.fecha') +
+
+
$
+
UF
+
+
+
Subsidio
+
+
+
+
+
Ahorro
+
+
+
+
+
+
+
+@endsection diff --git a/resources/views/ventas/subsidios/edit.blade.php b/resources/views/ventas/subsidios/edit.blade.php new file mode 100644 index 0000000..62e2e85 --- /dev/null +++ b/resources/views/ventas/subsidios/edit.blade.php @@ -0,0 +1,32 @@ +@extends('layout.base') + +@section('content') +
+

Subsidio - {{$venta->proyecto()->descripcion}} - {{$venta->unidad()->descripcion}}

+
+
+
+
+
Fecha
+ subsidio()->pago()->fecha, config('app.timezone')); ?> + @include('form.fecha') +
+
+
$
+
UF
+
+
+
Subsidio
+
+
+
+
+
Ahorro
+
+
+
+
+
+
+
+@endsection diff --git a/resources/views/ventas/subsidios/pagar.blade.php b/resources/views/ventas/subsidios/pagar.blade.php new file mode 100644 index 0000000..49528da --- /dev/null +++ b/resources/views/ventas/subsidios/pagar.blade.php @@ -0,0 +1,23 @@ +@extends('layout.base') + +@section('content') +
+

Pagar Subsidio - {{$venta->proyecto()->descripcion}} - {{$venta->unidad()->descripcion}} - {{ucwords(get('tipo'))}}

+
+
+
+ +
+
Fecha
+ fecha, config('app.timezone')); ?> + @include('form.fecha') +
+
+
Valor
+
+
+
+
+
+
+@endsection