diff --git a/app/Alias/Excel/Style/Mes.php b/app/Alias/Excel/Style/Mes.php new file mode 100644 index 0000000..368246b --- /dev/null +++ b/app/Alias/Excel/Style/Mes.php @@ -0,0 +1,18 @@ +setNumFormat('mmm-YY'); + $format->setAlign('center'); + } +} diff --git a/app/Alias/Format.php b/app/Alias/Format.php new file mode 100644 index 0000000..f2067aa --- /dev/null +++ b/app/Alias/Format.php @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/app/Alias/Model.php b/app/Alias/Model.php new file mode 100644 index 0000000..9f8f579 --- /dev/null +++ b/app/Alias/Model.php @@ -0,0 +1,87 @@ +id; + $orm = $this->orm; + $ref = new \ReflectionObject($orm); + if (!$ref->hasProperty('_dirty_fields')) { + return; + } + $dirty = $ref->getProperty('_dirty_fields'); + $dirty->setAccessible(true); + $new_values = $dirty->getValue($orm); + $changes = array_combine(array_keys($new_values), array_fill(0, count($new_values), ['old' => '', 'new' => ''])); + if ($this->isNew()) { + $old = (object) array_combine(array_keys($new_values), array_fill(0, count($new_values), '')); + } else { + $old = model(get_called_class())->findOne($this->{$this->getId()}); + } + foreach ($new_values as $column => $value) { + $changes[$column] = ['column' => $column, 'old' => $old->$column, 'new' => $value]; + } + $action = '[' . get_called_class() . ']'; + doLog($user, $action, $changes); + } + public function getId() + { + if (property_exists(get_called_class(), '_id_column')) { + return static::$_id_column; + } + return $this->id; + } + public function save() + { + $ref = new \ReflectionObject($this); + if ($ref->hasProperty('_timestamps')) { + $ref = $ref->getProperty('_timestamps'); + $ref->setAccessible(true); + if ($ref->getValue()) { + if ($this->is_new()) { + $this->setExpr('created_at', 'NOW()'); + } + $this->setExpr('updated_at', 'NOW()'); + } + } + if (!\ORM::getDb()->inTransaction()) { + \ORM::getDb()->beginTransaction(); + } + try { + parent::save(); + if (\ORM::getDb()->inTransaction()) { + \ORM::getDb()->commit(); + } + } catch (\Exception $e) { + if (\ORM::getDb()->inTransaction()) { + \ORM::getDb()->rollBack(); + } + throw $e; + } + $this->log(); + } + public function __call($method, $args) + { + if (!method_exists($this, $method)) { + $str = '' . Stringy::create($method)->underscored(); + if (method_exists($this, $str)) { + return call_user_func_array([$this, $str], $args); + } + throw new \BadMethodCallException($method . ' not found in ' . get_class($this)); + } + return call_user_func_array([$this, $str], $args); + } +} +?> diff --git a/app/Alias/NewEstado.php b/app/Alias/NewEstado.php new file mode 100644 index 0000000..4bf9089 --- /dev/null +++ b/app/Alias/NewEstado.php @@ -0,0 +1,20 @@ +fecha, config('app.timezone')); + } +} +?> \ No newline at end of file diff --git a/app/Alias/NewModel.php b/app/Alias/NewModel.php new file mode 100644 index 0000000..1c513b4 --- /dev/null +++ b/app/Alias/NewModel.php @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/app/Alias/NewTipo.php b/app/Alias/NewTipo.php new file mode 100644 index 0000000..b5fa3fb --- /dev/null +++ b/app/Alias/NewTipo.php @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/app/Alias/OldModel.php b/app/Alias/OldModel.php new file mode 100644 index 0000000..b3f9730 --- /dev/null +++ b/app/Alias/OldModel.php @@ -0,0 +1,8 @@ + diff --git a/app/Alias/PHPExcel.php b/app/Alias/PHPExcel.php new file mode 100644 index 0000000..de0ac75 --- /dev/null +++ b/app/Alias/PHPExcel.php @@ -0,0 +1,155 @@ +name = $name; + $this->filename = $filename; + } + public function addColumns($fields) + { + $columns = []; + foreach ($fields as $i => $field) { + if (is_object($field)) { + if (isset($field->style)) { + $style = $this->getExcelStyle($field->style); + } else { + $style = $this->getExcelStyle(); + } + $column = new ExcelHelper\Column($field->name, $field->name, 10, $style); + } elseif (is_array($field)) { + if (isset($field['style'])) { + $style = $this->getExcelStyle($field['style']); + } else { + $style = $this->getExcelStyle(); + } + $column = new ExcelHelper\Column($field['name'], $field['name'], 10, $style); + } else { + $style = $this->getExcelStyle(); + $column = new ExcelHelper\Column($field, $field, 10, $style); + } + $columns []= $column; + } + $collection = new ExcelHelper\ColumnCollection($columns); + $this->columns = $collection; + } + protected function getExcelStyle($style = 'text') + { + switch (strtolower($style)) { + case 'date': + return new ExcelHelper\CellStyle\Date(); + case 'mes': + return new Excel\Style\Mes(); + case 'currency': + case 'amount': + return new ExcelHelper\CellStyle\Amount(); + case 'number': + case 'integer': + return new ExcelHelper\CellStyle\Integer(); + case 'percent': + case 'percentage': + return new ExcelHelper\CellStyle\Percentage(); + case 'text': + case 'string': + default: + return new ExcelHelper\CellStyle\Text(); + } + } + public function addData($data) + { + if ($this->data == null) { + $this->data = []; + } + $this->data = array_merge($data); + } + public function addRow($rowData) + { + if ($this->data == null) { + $this->data = []; + } + $this->data []= $rowData; + } + public function addTotals($totals) + { + $columns = (array) $this->columns; + $columns = array_pop($columns); + $ts = []; + foreach ($columns as $column) { + $col = $column->getHeading(); + if (isset($totals[$col])) { + $ts[$col] = $this->getTotal($col, $totals[$col]); + continue; + } + $ts[$col] = ''; + } + $this->data []= $ts; + } + protected function getTotal($col, $aggr) + { + $col_num = $this->getColNumber($col); + $col = $this->getColName($col_num); + switch(strtolower($aggr)) { + case 'sum': + $num = 109; + break; + case 'count': + $num = 102; + break; + case 'counta': + $num = 103; + break; + default: + $num = 0; + } + if ($num > 0) { + $end = count($this->data) + 2; + $str = "=SUBTOTAL({$num};{$col}3:{$col}{$end})"; + return $str; + } + return $aggr; + } + protected function getColNumber($col) + { + $columns = (array) $this->columns; + $columns = array_keys(array_pop($columns)); + return array_search($col, $columns); + } + protected function getColName($col_num) + { + $cols = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $N = strlen($cols); + $name = ''; + if ($col_num > $N) { + $name .= $cols[floor($col_num / $N)]; + $col_num = $N * ($col_num / $N - floor($col_num / $N)); + } + $name .= $cols[$col_num]; + return $name; + } + public function informe() + { + header("Content-Type: application/octet-stream; charset=utf-8"); + header('Content-Transfer-Encoding: binary'); + header('Content-Disposition: attachment; filename="' . $this->filename . '"'); + header('Cache-Control: max-age=0'); + + $pE = new ExcelHelper\TableWorkbook('php://output'); + $ws = $pE->addWorksheet($this->name); + + $table = new ExcelHelper\Table($ws, 0, 0, $this->name, new \ArrayIterator($this->data)); + $table->setColumnCollection($this->columns); + + $pE->writeTable($table); + + $pE->close(); + } +} diff --git a/app/Contract/Auth.php b/app/Contract/Auth.php new file mode 100644 index 0000000..fb2e3b6 --- /dev/null +++ b/app/Contract/Auth.php @@ -0,0 +1,27 @@ + \ No newline at end of file diff --git a/app/Contract/Route.php b/app/Contract/Route.php new file mode 100644 index 0000000..fd4a84c --- /dev/null +++ b/app/Contract/Route.php @@ -0,0 +1,27 @@ + \ No newline at end of file diff --git a/app/Controller/Admin.php b/app/Controller/Admin.php new file mode 100644 index 0000000..137057c --- /dev/null +++ b/app/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/app/Controller/Ajax.php b/app/Controller/Ajax.php new file mode 100644 index 0000000..912c979 --- /dev/null +++ b/app/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/app/Controller/Auth.php b/app/Controller/Auth.php new file mode 100644 index 0000000..c7ca497 --- /dev/null +++ b/app/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/app/Controller/Bonos.php b/app/Controller/Bonos.php new file mode 100644 index 0000000..837c3f0 --- /dev/null +++ b/app/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/app/Controller/Buscar.php b/app/Controller/Buscar.php new file mode 100644 index 0000000..ef62a9e --- /dev/null +++ b/app/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/app/Controller/Cierres.php b/app/Controller/Cierres.php new file mode 100644 index 0000000..077a5ce --- /dev/null +++ b/app/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/app/Controller/Comentarios.php b/app/Controller/Comentarios.php new file mode 100644 index 0000000..494fcc6 --- /dev/null +++ b/app/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/app/Controller/Creditos.php b/app/Controller/Creditos.php new file mode 100644 index 0000000..60a72da --- /dev/null +++ b/app/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/app/Controller/Cuotas.php b/app/Controller/Cuotas.php new file mode 100644 index 0000000..4d457ba --- /dev/null +++ b/app/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/app/Controller/Devoluciones.php b/app/Controller/Devoluciones.php new file mode 100644 index 0000000..8d9c41c --- /dev/null +++ b/app/Controller/Devoluciones.php @@ -0,0 +1,19 @@ +findOne($id); + + return view('print.devolucion', compact('venta')); + } +} +?> diff --git a/app/Controller/Escrituras.php b/app/Controller/Escrituras.php new file mode 100644 index 0000000..f2cb056 --- /dev/null +++ b/app/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/app/Controller/FormaPago.php b/app/Controller/FormaPago.php new file mode 100644 index 0000000..6ccc7b3 --- /dev/null +++ b/app/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/app/Controller/Informes.php b/app/Controller/Informes.php new file mode 100644 index 0000000..c6a37bd --- /dev/null +++ b/app/Controller/Informes.php @@ -0,0 +1,907 @@ +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(); + + $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; + } + + $name = 'Informe de Ventas'; + $hoy = Carbon::now(config('app.timezone')); + $filename = str_replace('ñ', 'n', $name . ' - ' . $proyecto->descripcion . ' - ' . $hoy->format('Y-m-d') . '.xlsx'); + + $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'] + ]; + + $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]); + }), ' -'); + $es = $venta->propiedad()->estacionamientos(); + $info['Estacionamientos'] = implode(', ', array_map(function($item) { + return $item->descripcion; + }, $es)); + $bs = $venta->propiedad()->bodegas(); + $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(); + $ps = $venta->promociones(); + $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; + } + + $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(); + + } 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; + $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()); + $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(); + $body = [ + "Proyecto" => $proyecto->descripcion, + "Compañía" => $proyecto->inmobiliaria()->abreviacion, + "Mes" => $mes, + "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(); + } 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/app/Controller/Informes.php.save b/app/Controller/Informes.php.save new file mode 100644 index 0000000..efd5035 --- /dev/null +++ b/app/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/app/Controller/Inmobiliarias.php b/app/Controller/Inmobiliarias.php new file mode 100644 index 0000000..f0b8910 --- /dev/null +++ b/app/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/app/Controller/Operadores.php b/app/Controller/Operadores.php new file mode 100644 index 0000000..765ba2a --- /dev/null +++ b/app/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/app/Controller/Other.php b/app/Controller/Other.php new file mode 100644 index 0000000..eb90f31 --- /dev/null +++ b/app/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/app/Controller/Pagares.php b/app/Controller/Pagares.php new file mode 100644 index 0000000..f05b24e --- /dev/null +++ b/app/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/app/Controller/Pagos.php b/app/Controller/Pagos.php new file mode 100644 index 0000000..f279b9e --- /dev/null +++ b/app/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/app/Controller/Pies.php b/app/Controller/Pies.php new file mode 100644 index 0000000..38c2fcb --- /dev/null +++ b/app/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/app/Controller/Postventas.php b/app/Controller/Postventas.php new file mode 100644 index 0000000..7b38cb6 --- /dev/null +++ b/app/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/app/Controller/Precios.php b/app/Controller/Precios.php new file mode 100644 index 0000000..6975b73 --- /dev/null +++ b/app/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/app/Controller/Propietarios.php b/app/Controller/Propietarios.php new file mode 100644 index 0000000..5d38ee7 --- /dev/null +++ b/app/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/app/Controller/ProyectoTipoUnidades.php b/app/Controller/ProyectoTipoUnidades.php new file mode 100644 index 0000000..32c0c1d --- /dev/null +++ b/app/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/app/Controller/Proyectos.php b/app/Controller/Proyectos.php new file mode 100644 index 0000000..f6a4e45 --- /dev/null +++ b/app/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/app/Controller/Reajustes.php b/app/Controller/Reajustes.php new file mode 100644 index 0000000..4c6c938 --- /dev/null +++ b/app/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/app/Controller/Registros.php b/app/Controller/Registros.php new file mode 100644 index 0000000..546fece --- /dev/null +++ b/app/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/app/Controller/Subsidios.php b/app/Controller/Subsidios.php new file mode 100644 index 0000000..5107fc3 --- /dev/null +++ b/app/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/app/Controller/Temas.php b/app/Controller/Temas.php new file mode 100644 index 0000000..24b121a --- /dev/null +++ b/app/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/app/Controller/Unidades.php b/app/Controller/Unidades.php new file mode 100644 index 0000000..9f0da01 --- /dev/null +++ b/app/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/app/Controller/UnidadesBloqueadas.php b/app/Controller/UnidadesBloqueadas.php new file mode 100644 index 0000000..9bd4107 --- /dev/null +++ b/app/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/app/Controller/Ventas.php b/app/Controller/Ventas.php new file mode 100644 index 0000000..f204c70 --- /dev/null +++ b/app/Controller/Ventas.php @@ -0,0 +1,598 @@ +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); + + $f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone')); + $valor = correctNumber(post('pago')); + $uf = uf($f); + + $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); + $propiedad = $venta->propiedad(); + $propiedad->estado = 0; + $pago = model(Pago::class)->create(); + $pago->fecha = $f->format('Y-m-d'); + $pago->valor = $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 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/app/Definition/Controller.php b/app/Definition/Controller.php new file mode 100644 index 0000000..c0e3dae --- /dev/null +++ b/app/Definition/Controller.php @@ -0,0 +1,31 @@ +isPublic()) { + + return self::{$action}(); + } + } + if (self::$default == null and \method_exists(self::class, 'setDefault')) { + self::setDefault(); + } + if (self::$default == null) { + header('Location: .'); + return; + } + return self::$default; + } +} +?> \ No newline at end of file diff --git a/app/Definition/hasEstado.php b/app/Definition/hasEstado.php new file mode 100644 index 0000000..014fe8a --- /dev/null +++ b/app/Definition/hasEstado.php @@ -0,0 +1,38 @@ +getTable(); + $self = Stringy::create(get_class($this)); + $ns = $self->substr(0, $self->indexOfLast('\\')); + $self = $self->substr($self->indexOfLast('\\') + 1); + $column = $self->underscored(); + $class = $ns . '\\Estado' . $self; + if (substr($table, -1, 1) == 's') { + $column .= '_id'; + } + + return $this->has_many($class, $column)->findMany(); + } + public function estado() + { + $table = $this->getTable(); + $self = Stringy::create(get_class($this)); + $ns = $self->substr(0, $self->indexOfLast('\\')); + $self = $self->substr($self->indexOfLast('\\') + 1); + $column = $self->underscored(); + $class = $ns . '\\Estado' . $self; + if (substr($table, -1, 1) == 's') { + $column .= '_id'; + } + + $id = $this->has_many($class, $column)->max('id'); + return $this->has_many($class, $column)->findOne($id); + } +} +?> \ No newline at end of file diff --git a/app/Definition/hasRUT.php b/app/Definition/hasRUT.php new file mode 100644 index 0000000..8ba3d80 --- /dev/null +++ b/app/Definition/hasRUT.php @@ -0,0 +1,20 @@ +rut) . '-' . $this->dv; + } +} +?> \ No newline at end of file diff --git a/app/Exception/PropertyNotFound.php b/app/Exception/PropertyNotFound.php new file mode 100644 index 0000000..a35e537 --- /dev/null +++ b/app/Exception/PropertyNotFound.php @@ -0,0 +1,16 @@ +class = $class; + $this->property = $property; + $msg = "Property '" . $property . "' for class '" . $class . "' not found."; + parent::__construct($msg); + } +} \ No newline at end of file diff --git a/app/Helper/Color.php b/app/Helper/Color.php new file mode 100644 index 0000000..68c3199 --- /dev/null +++ b/app/Helper/Color.php @@ -0,0 +1,169 @@ +color = $args[0]; + break; + } + $this->color = $this->hex2dec($this->hex2array($args[0])); + break; + case 2: + if (is_array($args[0])) { + $this->color = $args[0]; + $this->color []= $args[1]; + break; + } + $color = $this->hex2array($args[0]); + $color []= $args[1]; + $this->color = $this->hex2dec($color); + break; + case 3: + case 4: + if (is_numeric($args[0])) { + $this->color = $args; + break; + } + $this->color = $this->hex2dec($args); + break; + } + } + protected function hex2dec(array $hex) + { + return array_map('hexdec', $hex); + } + protected function dec2hex(array $bin) + { + return array_map('dechex', $bin); + } + protected function hex2array(string $hex) + { + switch (strlen($hex)) { + case 3: + case 4: + case 6: + case 7: + return str_split($hex, 2); + default: + throw new OutOfBoundsException('The string ' . $hex . ' is not a correct color code.'); + } + } + protected function array2hex(array $arr) + { + return implode('', $arr); + } + + public function convertTo($type) + { + switch (strtolower($type)) { + case 'hex': + if (is_numeric($this->color[0])) { + $this->color = $this->dec2hex($this->color); + } + break; + case 'dec': + if (!is_numeric($this->color[0])) { + $this->color = $this->hex2dec($this->color); + } + break; + default: + throw new InvalidArgumentException($type . ' is not a valid argument.'); + } + } + public function add($base_color, $amount) + { + $changed = false; + if (!is_numeric($this->color)) { + $this->convertTo('dec'); + $changed = true; + } + switch (strtolower($base_color)) { + case 'r': + $base_color = 0; + break; + case 'g': + $base_color = 1; + break; + case 'b': + $base_color = 2; + break; + case 'a': + $base_color = 3; + break; + default: + throw new OutOfBoundsException("Base color '" . $base_color . "' does not exist."); + } + $this->color[$base_color] += $amount; + if ($changed) { + $this->convertTo('hex'); + } + } + public function print() + { + $this->convertTo('hex'); + return implode('', $this->color); + } + public function toRGB() + { + $changed = false; + $this->convertTo('dec'); + $str = 'rgb(' . implode(', ', array_map(function($a) { + return round($a, 2); + }, $this->color)) . ')'; + if ($changed) { + $this->convertTo('hex'); + } + return $str; + } + public function __toString() + { + return $this->print(); + } + public function toArray() + { + return $this->color; + } + public function toVector() + { + $changed = false; + $this->convertTo('dec'); + $arr = $this->toArray(); + if ($changed) { + $this->convertTo('hex'); + } + return $arr; + } + public function luminosity() + { + $changed = false; + $this->convertTo('dec'); + //sqrt( 0.299*R^2 + 0.587*G^2 + 0.114*B^2 ) + $str = sqrt(0.299 * pow($this->color[0], 2) + 0.587 * pow($this->color[1], 2) + 0.114 * pow($this->color[2], 2)) / 255 * 100; + if ($changed) { + $this->convertTo('hex'); + } + return $str; + } + public function isDark() + { + if ($this->luminosity() < 50) { + return true; + } + return false; + } + public function isBright() + { + if ($this->luminosity() > 75) { + return true; + } + return false; + } +} diff --git a/app/Helper/Line.php b/app/Helper/Line.php new file mode 100644 index 0000000..02cc0d9 --- /dev/null +++ b/app/Helper/Line.php @@ -0,0 +1,61 @@ +origin = $point_a; + $this->length = $this->distance($point_a, $point_b); + $this->direction = $this->gradient($point_a, $point_b); + } + public function origin() + { + return $this->origin; + } + public function length() + { + return $this->length; + } + public function direction() + { + return $this->direction; + } + /** + * Calculate the gradient to move from point a to point b + * @param array $point_a [Vector] + * @param array $point_b [Vector] + * @return array [Vector] + */ + public function gradient($point_a, $point_b) + { + $distance = $this->distance($point_a, $point_b); + return array_map(function($a, $b) use ($distance) { + return ($a - $b) / $distance; + }, $point_b, $point_a); + } + // sqrt((a0-b0)²+(a1-b1)²+(a2-b2)²) + public function distance($point_a, $point_b) + { + return sqrt(array_sum(array_map(function($a, $b) { + return pow($a - $b, 2); + }, $point_a, $point_b))); + } + /** + * Move from point in the direction of the gradient acording to step_size + * @param array $point [Vector] + * @param int $step_size [step size] + * @return array [Vector] + */ + public function move($point, $step_size) + { + $gradient = $this->direction; + return array_map(function($a, $b) use ($step_size) { + return $a + $b * $step_size; + }, $point, $gradient); + } +} diff --git a/app/Helper/functions.php b/app/Helper/functions.php new file mode 100644 index 0000000..78aa822 --- /dev/null +++ b/app/Helper/functions.php @@ -0,0 +1,102 @@ +copy()->endOfMonth()->addDays(9); + if ($date->greaterThanOrEqualTo($next_m_9)) { + return (object) ['total' => 0]; + } + $url = 'http://' . config('locations.money') . '/api/uf/value/' . $date->format('Y-m-d'); + $client = new \Goutte\Client(); + $client->setHeader('Accept', 'application/json'); + $client->request('GET', $url); + + $response = $client->getResponse(); + if (!$response) { + return (object) ['total' => 0]; + } + $status = $response->getStatusCode(); + if ($status >= 200 and $status < 300) { + $data = json_decode($response->getContent()); + return $data; + } + return (object) ['total' => 0]; +} +function format($tipo, $valor, $format = null, $print = false) { + if (strtolower($tipo) == 'localdate') { + $d = \Carbon\Carbon::parse($valor); + $d->locale('es_ES'); + if ($format == null) { + $format = 'DD [de] MMMM [de] YYYY'; + } + return $d->isoFormat($format); + } + if (method_exists('\App\Helper\Format', $tipo)) { + if ($print) { + return \App\Helper\Format::$tipo($valor, $print); + } else { + return \App\Helper\Format::$tipo($valor); + } + } else { + switch ($tipo) { + case 'localDate': + if (isset($format)) { + $intl = new IntlDateFormatter('es_ES', IntlDateFormatter::SHORT, IntlDateFormatter::SHORT, 'America/Santiago'); + $intl->setPattern($format); + return ucwords($intl->format($valor)); + } + case 'percent': + return \App\Helper\Format::number($valor, 2); + case 'rut': + return \App\Helper\Format::number($valor, 0); + } + } +} +function model(string $class_name) { + return \Model::factory($class_name); +} +function correctNumber($number) { + if (strpos($number, ',') !== false) { + return str_replace(',', '.', str_replace('.', '', $number)); + } elseif (substr_count($number, '.') > 1) { + return str_replace('.', '', $number); + } + return $number; +} +function parseRanges($range, $numeric = true, $negatives = true) { + $rns = preg_split('/[,;]+/', $range); + $data = []; + foreach ($rns as $p) { + if (!$negatives) { + if (strpos($p, '-') !== false) { + list($ini, $end) = explode('-', $p); + $data = array_merge($data, range($ini, $end)); + continue; + } + } + if ($numeric) { + $data []= (float) $p; + continue; + } + $data []= $p; + } + return $data; +} +function nUrl($p, $a = null, $data = null) { + $query = ['p' => $p]; + if ($a != null) { + $query['a'] = $a; + if ($data != null) { + $query = array_merge($query, $data); + } + } + return url('', $query); +} +function doLog($user, $action, $variables) { + App\Service\Register::log($user, $action, $variables); +} +?> diff --git a/app/Service/Auth.php b/app/Service/Auth.php new file mode 100644 index 0000000..7af1f48 --- /dev/null +++ b/app/Service/Auth.php @@ -0,0 +1,163 @@ +getCookie(); + } + protected function getCookie() + { + if (isset($_COOKIE['rememberMe'])) { + list($s, $t) = \explode(':', $_COOKIE['rememberMe']); + $this->selector = $s; + $this->token = $t; + } + } + protected function saveCookie() + { + $now = \Carbon\Carbon::now(config('app.timezone')); + $exp = $now->addHours(config('app.login_hours')); + \setcookie('rememberMe', $this->selector . ':' . $this->token, $exp->timestamp); + } + protected function clearCookie() + { + \setcookie('rememberMe', '', \Carbon\Carbon::now(config('app.timezone'))->timestamp); + } + protected function generateToken() + { + $this->selector = bin2hex(\random_bytes(12)); + $this->token = bin2hex(\random_bytes(20)); + } + public function login($username, $password) + { + $user = \Model::factory(\Incoviba\common\User::class)->where('name', $username)->where('enabled', 1)->findOne(); + if ($user !== false) { + if (\password_verify($password, $user->password) === false) { + $this->clearCookie(); + return false; + } + + $this->generateToken(); + $now = \Carbon\Carbon::now(config('app.timezone')); + $exp = $now->addHours(-config('app.login_hours')); + $auth = \Model::factory(\Incoviba\common\Auth::class)->where('user_id', $user->id)->whereGt('time', $exp->timestamp)->where('status', 1)->findOne(); + if ($auth !== false) { + $auth->time('now'); + $auth->selector = $this->selector; + $auth->token($this->token); + $auth->save(); + $this->saveCookie(); + return true; + } + + $auth = \Model::factory(\Incoviba\common\Auth::class)->create(); + $auth->user_id = $user->id; + $auth->time('now'); + $auth->selector = $this->selector; + $auth->token($this->token); + + try { + $auth->save(); + $this->saveCookie(); + return true; + } catch (\Exception $e) { + $this->clearCookie(); + return false; + } + } + return false; + } + public function isIn() + { + if ($this->selector == null) { + return false; + } + $auths = \Model::factory(\Incoviba\common\Auth::class)->where('selector', $this->selector)->findMany(); + if ($auths === false) { + $this->clearCookie(); + return false; + } + foreach ($auths as $auth) { + if (\password_verify($this->token, $auth->token)) { + return $auth->isIn(); + } + } + return false; + } + public function User() + { + if ($this->selector == null) { + return false; + } + $auths = \Model::factory(\Incoviba\common\Auth::class)->where('selector', $this->selector)->findMany(); + if ($auths === false) { + return false; + } + foreach ($auths as $auth) { + if (\password_verify($this->token, $auth->token)) { + return $auth->user(); + } + } + return false; + } + public function hasAccess() + { + if ($this->selector == null) { + return false; + } + $auths = \Model::factory(\Incoviba\common\Auth::class)->where('selector', $this->selector)->findMany(); + if ($auths === false) { + return false; + } + foreach ($auths as $auth) { + if (\password_verify($this->token, $auth->token)) { + return $auth->user()->hasAccess(); + } + } + return false; + } + public function checkAccess($controller, $action = null) + { + if ($this->selector == null) { + return false; + } + $auths = \Model::factory(\Incoviba\common\Auth::class)->where('selector', $this->selector)->findMany(); + if ($auths === false) { + return false; + } + foreach ($auths as $auth) { + if (\password_verify($this->token, $auth->token)) { + return $auth->user()->checkAccess($controller, $action); + } + } + return false; + } + public function logout() + { + $this->clearCookie(); + if ($this->selector == null) { + return true; + } + $auths = \Model::factory(\Incoviba\common\Auth::class)->where('selector', $this->selector)->findMany(); + if ($auths === false) { + return true; + } + foreach ($auths as $auth) { + if (\password_verify($this->token, $auth->token)) { + $auth->status = 0; + try { + $auth->save(); + return true; + } catch (\Exception $e) { + return false; + } + } + } + return true; + } +} diff --git a/app/Service/Borrador.php b/app/Service/Borrador.php new file mode 100644 index 0000000..4f4b3af --- /dev/null +++ b/app/Service/Borrador.php @@ -0,0 +1,118 @@ +cierre = $cierre; + $this->lineas = []; + } + protected function add(string $str, int $new_line = 0) + { + $this->lineas []= $str; + if ($new_line > 0) { + $this->newLine($new_line); + } + } + protected function newLine($n = 1) + { + for ($i = 0; $i < $n; $i ++) { + $this->lineas []= ''; + } + } + protected function load() + { + $this->word = IOFactory::load('borrador-' . $this->cierre->proyecto()->nombre . '.docx'); + } + protected function extract() + { + $this->load(); + $data = []; + foreach ($this->word->getSections() as $section) { + foreach ($section->getElements() as $element) { + $r = $this->elementGet($element); + $data []= $r; + } + } + if (count($data) > 0) { + $this->text = $data; + } + } + protected function elementGet($element) + { + if ($element instanceof TextBreak) { + return PHP_EOL; + } + if ($element instanceof TextRun) { + $data = []; + foreach ($element->getElements() as $e) { + $data []= $this->elementGet($e); + } + return implode('', $data); + } + if (!method_exists($element, 'getText')) { + d($element); + } + return $element->getText(); + } + protected function build() + { + if ($this->text == null) { + $this->extract(); + } + foreach ($this->text as $line) { + if ($line == PHP_EOL) { + $this->newLine(); + continue; + } + if (strpos($line, '[[') !== false) { + $replacer = new Replacer(); + $this->add($replacer->replace($line, $this->cierre)); + continue; + } + $this->add($line); + } + } + public function create() + { + $output = new PhpWord(); + + $output->getSettings()->setDecimalSymbol(','); + $output->getSettings()->setThemeFontLang(new Language(Language::ES_ES)); + + $section = $output->addSection(); + foreach ($this->lineas as $linea) { + if ($linea == '') { + $section->addTextBreak(); + continue; + } + $section->addText($linea); + } + + $output->getSettings()->setTrackRevisions(true); + + $writer = IOFactory::createWriter($output); + $filename = 'Borrador ' . $this->cierre->propietario()->nombreCompleto() . ' con ' . $this->cierre->proyecto()->inmobiliaria()->razon_social . '.docx'; + $writer->save($filename); + } + public function show() + { + $this->build(); + return implode(PHP_EOL, $this->lineas); + } +} +?> \ No newline at end of file diff --git a/app/Service/DBToModel.php b/app/Service/DBToModel.php new file mode 100644 index 0000000..158e85c --- /dev/null +++ b/app/Service/DBToModel.php @@ -0,0 +1,158 @@ +name = $name; + $this->db = \ORM::get_db($name); + } + + public function run() + { + $this->getTables(); + foreach ($this->tables as $table) { + if ($this->createClass($table)) { + echo 'ok
', PHP_EOL; + } + } + } + protected function getType($type) + { + if (strpos($type, '(') !== false) { + $type = substr($type, 0, strpos($type, '(')); + } + if (strpos($type, ' ') !== false) { + $type = substr($type, 0, strpos($type, ' ')); + } + switch ($type) { + case 'int': + case 'float': + case 'double': + case 'char': + return trim($type); + case 'date': + case 'datetime': + return trim(strtolower($type)); + case 'varchar': + case 'text': + case 'blob': + return 'string'; + case 'bigint': + case 'tinyint': + case 'enum': + return 'int'; + default: + d($type); + } + } + protected function getTables() + { + $q = "SHOW TABLES"; + $st = $this->db->query($q); + $results = $st->fetchAll(\PDO::FETCH_COLUMN); + $this->tables = []; + foreach ($results as $result) { + $this->tables []= $result; + } + } + protected function getColumns($table) + { + $q = "SHOW COLUMNS FROM `" . $table . "`"; + $st = $this->db->query($q); + $results = $st->fetchAll(\PDO::FETCH_OBJ); + return $results; + } + protected function phpDoc($columns) + { + $str = ['/**']; + $str []= ' *'; + foreach ($columns as $column) { + $str []= ' * @property ' . $this->getType($column->Type) . ' ' . $column->Field; + } + $str []= ' *'; + $str []= ' */'; + + return implode(PHP_EOL, $str); + } + protected function className($table) + { + $name = Stringy::create($table)->upperCamelize(); + return $name; + } + protected function createClass($table) + { + $class = '' . $this->className($table); + $columns = $this->getColumns($table); + $docs = $this->phpDoc($columns); + + $output = ['name}';"; + $output []= '}'; + $output []= '?>'; + + //d(implode(PHP_EOL, $output)); + + $filename = realpath(root() . '/src') . DIRECTORY_SEPARATOR . $class . '.php'; + return file_put_contents($filename, implode(PHP_EOL, $output)); + } + public function create($namespace, $table) + { + $class = '' . $this->className($table); + $columns = $this->getColumns($table); + $docs = $this->phpDoc($columns); + + $namespace = trim($namespace, '\\'); + + $output = ['name}';"; + $output []= '}'; + $output []= '?>'; + $output = implode(PHP_EOL, $output); + + $namespace = explode('\\', $namespace); + array_shift($namespace); + $namespace = implode('/', $namespace); + + $filename = realpath(root() . '/src/' . $namespace) . DIRECTORY_SEPARATOR . $class . '.php'; + + $result = [ + 'result' => false, + 'filename' => $filename, + 'output' => $output + ]; + if (!file_exists($filename)) { + $result['result'] = file_put_contents($filename, $output); + } else { + $result['result'] = true; + } + return json_encode($result); + } + public function list() + { + $this->getTables(); + $output = []; + foreach ($this->tables as $table) { + $output []= ['table' => $table, 'model' => '' . $this->className($table)]; + } + + return json_encode(['models' => $output]); + } +} +?> \ No newline at end of file diff --git a/app/Service/Factory.php b/app/Service/Factory.php new file mode 100644 index 0000000..ac7386a --- /dev/null +++ b/app/Service/Factory.php @@ -0,0 +1,204 @@ +class = $class; + $this->is_aggregator = true; + if (is_subclass_of($class, 'Model')) { + $this->is_aggregator = false; + } + } + public function new() + { + $class = $this->class; + if ($this->is_aggregator) { + return new $class(); + } + return model($class)->create(); + } + public function create($data) + { + $class = $this->class; + if ($this->is_aggregator) { + $obj = new $class(); + $obj->create($data); + return $obj; + } + return model($class)->create($data); + } + /** + * [column => value, column => [value, operator]] + * @var array + */ + protected $conditions; + public function where(array $data) + { + if ($this->conditions == null) { + $this->conditions = $data; + return $this; + } + $this->conditions = array_merge($this->conditions, $data); + return $this; + } + /** + * [column, column => order] + * @var array + */ + protected $order; + public function order(array $data) + { + if ($this->order == null) { + $this->order = $data; + return $this; + } + $this->order = array_merge($this->order, $data); + return $this; + } + protected $limit; + public function limit(array $data) + { + if (!isset($data['limit'])) { + $data['limit'] = $data[0]; + } + if (!isset($data['offset'])) { + $data['offset'] = 0; + if (isset($data[1])) { + $data['offset'] = $data[1]; + } + } + $this->limit = (object) ['limit' => $data['limit'], 'offset' => $data['offset']]; + return $this; + } + protected $many; + public function find($many = false) + { + $this->many = $many; + if ($this->is_aggregator) { + return $this->findAggregator(); + } + return $this->findModel(); + } + + protected function findModel() + { + $objs = model($this->class); + $objs = $this->parseLimit($this->parseOrder($this->parseConditions($objs))); + + if ($this->many) { + return $objs->findMany(); + } + return $objs->findOne(); + } + protected function parseConditions($orm) + { + if ($this->conditions == null) { + return $orm; + } + foreach ($this->conditions as $column => $value) { + if (is_array($value)) { + list($value, $op) = $value; + switch ($op) { + case '>': + case 'gt': + $orm = $orm->whereGt($column, $value); + break; + } + } else { + $orm = $orm->where($column, $value); + } + } + return $orm; + } + protected function parseOrder($orm) + { + if ($this->order == null) { + return $orm; + } + foreach ($this->order as $column => $order) { + if (is_numeric($column)) { + $column = $order; + $order = 'asc'; + } + switch (strtolower($order)) { + case 'asc': + default: + $orm = $orm->orderByAsc($column); + break; + case 'desc': + $orm = $orm->orderByDesc($column); + break; + case 'expr': + $orm = $orm->orderByExpr($column); + break; + } + } + return $orm; + } + protected function parseLimit($orm) + { + if ($this->limit == null) { + return $orm; + } + $orm = $orm->limit($this->limit->limit); + if (isset($this->limit->offset)) { + $orm = $orm->offset($this->limit->offset); + } + return $orm; + } + protected function findAggregator() + { + $model = $this->modelName($this->class); + $ids = $this->getIds($model); + $class = $this->class; + if (count($ids) == 0) { + return false; + } + if ($this->many) { + $objs = []; + foreach ($ids as $id) { + $objs []= new $class($id); + } + } else { + $objs = new $class($ids[0]); + } + return $objs; + } + protected function getIds($model) + { + $id = $this->getModelId($model); + $table = $this->getTable($model); + $st = \ORM::forTable($table)->select($id); + $st = $this->parseConditions($st); + $results = $st->findArray(); + $output = array_map(function($a) use($id) { + return $a[$id]; + }, $results); + return $output; + } + protected function modelName($class) + { + $arr = explode("\\", $class); + \array_push($arr, end($arr)); + return implode("\\", $arr); + } + protected function getModelId($model) + { + $table = $this->getTable($model); + $query = "SHOW KEYS FROM {$table} WHERE Key_name = 'PRIMARY'"; + $st = \ORM::getDb()->query($query); + $results = $st->fetchAll(\PDO::FETCH_OBJ); + return $results[0]->Column_name; + } + protected function getTable($model) + { + $arr = explode("\\", $model); + return Stringy::create(end($arr))->toLowerCase() . ''; + } +} diff --git a/app/Service/Informador.php b/app/Service/Informador.php new file mode 100644 index 0000000..c64db26 --- /dev/null +++ b/app/Service/Informador.php @@ -0,0 +1,463 @@ +title = $title; + } else { + $this->title = 'Informe'; + } + } + + public function addColumn(string $title, $col = '') + { + if ($col == '') { + if ($this->columns == null) { + $i = 0; + } else{ + $i = count($this->columns); + } + $col = $this->mapColumn($i); + } + + if (isset($this->columns[$col])) { + $columns = []; + foreach ($this->columns as $c => $data) { + if (ord($c) < ord($col)) { + $columns[$c] = $data; + } elseif (ord($c) == ord($col)) { + $columns[$col] = $title; + } else { + $columns[chr(ord($c) + 1)] = $data; + } + } + $this->columns = $columns; + } else { + $this->columns[$col] = $title; + } + } + public function mapColumn($n) + { + $letters = range('A', 'Z'); + $max = count($letters); + $r = $n / $max + 1; + $p = floor($r - 1) - 1; + $i = $n % $max; + if ($r >= 2) { + return $letters[$p] . $letters[$i]; + } + return $letters[$i]; + } + public function getColumn($col_title) + { + return array_search($col_title, $this->columns); + } + public function getColumnNumber($col) + { + $letters = range('A', 'Z'); + if (strlen($col) > 1) { + $ls = str_split($col); + $n = 0; + foreach ($ls as $i => $l) { + $n += array_search($l, $letters) + $i * count($letters) + 1; + } + return $n; + } + return array_search($col, $letters); + } + public function addColumns(array $columns) + { + foreach ($columns as $column) { + $this->addColumn($column); + } + } + public function addData(int $row, $data, $col = '') + { + if (!isset($this->data[$row])) { + $this->data[$row] = []; + } + if ($col == '') { + $i = count($this->data[$row]); + $col = $this->mapColumn($i); + } elseif (ctype_print($col)) { + $col = $this->getColumn($col); + } else { + $col = $this->mapColumn($col); + } + + if (isset($this->data[$row][$col])) { + $data_array = []; + foreach ($this->data[$row] as $c => $d) { + if (ord($c) < ord($col)) { + $data_array[$c] = $d; + } elseif (ord($c) == ord($col)) { + $data_array[$col] = $this->parseData($data); + } else { + $data_array[chr(ord($c) + 1)] = $d; + } + } + $this->data[$row] = $data_array; + } else { + $this->data[$row][$col] = $this->parseData($data); + } + } + protected function parseData($data) + { + if ($this->isDate($data)) { + // Date + return Date::PHPToExcel($data); + } + return $data; + } + protected function isDate($data) + { + try { + if (strpos($data, '-') === false) { + return false; + } + $fecha = explode('-', $data); + if (count($fecha) != 3) { + return false; + } + list($year, $month, $day) = $fecha; + if (strlen($year) == 4 and strlen($month) <= 2 and strlen($day) <= 2) { + return true; + } + if (ctype_digit($year) and ctype_digit($month) and ctype_digit($day)) { + $f = Carbon::parse($data, config('app.timezone')); + return true; + } + return false; + } catch(\Exception $e) { + return false; + } + return false; + } + public function addDataRow(int $row, array $data_array) + { + foreach ($data_array as $data) { + $this->addData($row, $data); + } + } + public function addDatas(array $data_matrix) + { + foreach ($data_matrix as $row => $data_array) { + $this->addDataRow($row, $data_array); + } + } + protected function findTitleColumn($title) + { + return array_search($title, $this->columns); + } + public function addFormat($format, $title = '') + { + $col = 'A'; + if ($title == '') { + $i = count($this->col_formats); + $col = $this->mapColumn($i); + } else { + $col = $this->findTitleColumn($title); + } + + if (isset($this->col_formats[$col])) { + $columns = []; + foreach ($this->col_formats as $c => $data) { + if (ord($c) < ord($col)) { + $columns[$c] = $data; + } elseif (ord($c) == ord($col)) { + $columns[$col] = $this->translateFormat($format); + } else { + $columns[chr(ord($c) + 1)] = $data; + } + } + $this->col_formats = $columns; + } else { + $this->col_formats[$col] = $this->translateFormat($format); + } + + uksort($this->col_formats, function($ak, $bk) { + return strcmp($ak, $bk); + }); + } + protected function translateFormat(array $format) + { + $translated = []; + foreach ($format as $category => $values) { + switch ($category) { + case 'numberFormat': + $data = $this->translateNumberFormat($values); + break; + case 'alignment': + $data = $this->translateAlignment($values); + break; + case 'font': + $data = $this->translateFont($values); + break; + case 'fill': + $data = $this->translateFill($values); + break; + case 'borders': + $data = $this->translateBorders($values); + break; + } + $translated[$category] = $data; + } + return $translated; + } + protected function translateNumberFormat(array $values) + { + $translated = []; + foreach ($values as $value) { + switch ($value) { + case 'short-date': + $translated['formatCode'] = 'dd-mm-yyyy'; + break; + case 'date': + $translated['formatCode'] = 'dd mmmm, yyyy'; + break; + case 'thousands': + $translated['formatCode'] = NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1; + break; + case 'pesos': + $translated['formatCode'] = '$ #.###'; + break; + default: + $translated['formatCode'] = $value; + } + } + return $translated; + } + protected function translateAlignment(array $values) + { + $translated = []; + foreach ($values as $type => $value) { + switch ($type) { + case 'horizontal': + switch ($value) { + case 'center': + $new = Alignment::HORIZONTAL_CENTER; + break; + } + break; + case 'vertical': + switch ($value) { + case 'middle': + case 'center': + $new = Alignment::VERTICAL_CENTER; + } + default: + $new = $value; + break; + } + $translated[$type] = $new; + } + return $translated; + } + protected function translateFont(array $values) + { + $translated = []; + foreach ($values as $type => $value) { + switch ($type) { + case 'color': + $new = $this->translateColor($value); + break; + default: + $new = $value; + break; + } + $translated[$type] = $new; + } + return $translated; + } + protected function translateFill(array $values) + { + $translated = []; + foreach ($values as $type => $value) { + switch ($type) { + case 'fillType': + switch ($value) { + case 'solid': + $new = Fill::FILL_SOLID; + break; + default: + $new = $value; + break; + } + break; + case 'color': + $new = $this->translateColor($value); + break; + default: + $new = $value; + break; + } + $translated[$type] = $new; + } + return $translated; + } + protected function translateBorders(array $values) + { + $translated = []; + foreach ($format as $category => $value) { + switch ($category) { + case 'allBorders': + case 'left': + case 'right': + case 'top': + case 'bottom': + case 'diagonal': + case 'vertical': + case 'horizontal': + $data = $this->translateBorder($value); + break; + default: + $data = $value; + } + $translated[$category] = $data; + } + return $translated; + } + protected function translateBorder(array $values) + { + $translated = []; + foreach ($values as $type => $value) { + switch ($type) { + case 'color': + $new = $this->translateColor($value); + break; + default: + $new = $value; + break; + } + $translated[$type] = $new; + } + return $translated; + } + protected function translateColor($color) + { + $color_definitions = [ + 'red' => 'ff0000', + 'light-red' => 'ffcccc', + 'dark-red' => 'a00000' + ]; + if (is_array($color)) { + $t = dechex(255 * $color['transparency'] / 100); + $c = $color_definitions[$color['color']]; + $hex = $t . $c; + return ['argb' => $hex]; + } + return ['rgb' => $color_definitions[$color]]; + } + public function addFormats(array $formats) + { + foreach ($formats as $title => $format) { + $this->addFormat($format, $title); + } + } + public function addTotal(string $col) + { + if (isset($this->columns[$col])) { + $sum = 0; + foreach ($this->data as $row => $data) { + $sum += $data[$col]; + } + $this->totals[$col] = $sum; + } + } + public function addAverage(string $col) + { + $this->addTotal($col); + $this->totals[$col] /= count($this->data); + } + + protected function fillData() + { + foreach ($this->data as $row => $data) { + $this->data[$row] = $this->fillAndSort($data); + } + if (count($this->totals) > 0) { + $this->totals = $this->fillAndSort($this->totals); + } + } + protected function fillAndSort(array $row) + { + foreach ($this->columns as $val) { + if (!isset($row[$val])) { + $row[$val] = ''; + } + } + function sortArrayByArray(Array $array, Array $orderArray) { + $ordered = array(); + foreach($orderArray as $key) { + if(array_key_exists($key, $array)) { + $ordered[$key] = $array[$key]; + unset($array[$key]); + } + } + return $ordered + $array; + } + $row = sortArrayByArray($row, $this->columns); + + return $row; + } + + public function informe() + { + $ea = new Spreadsheet(); + $ea->getProperties()->setCreator('Juan Pablo Vial B.'); + $ea->getProperties()->setTitle($this->title); + $ea->getProperties()->setCompany('Incoviba S.A.'); + + $ews = $ea->getActiveSheet(); + + $ews->fromArray(array($this->columns), '', 'A1'); + $ews->fromArray($this->data, '', 'A2'); + $end = 2; + if ($this->totals != null and count($this->totals) > 0) { + $ews->fromArray($this->totals, '', 'A' . count($data) + 2); + $end = 3; + } + + if ($this->col_formats != null and count($this->col_formats) > 0) { + foreach ($this->col_formats as $col => $format) { + $ews->getStyleByColumnAndRow($this->getColumnNumber($col), 2, $this->getColumnNumber($col), count($this->data) + $end)->applyFromArray($format); + } + } + + for ($col = 0; $col < count($this->columns); $col ++) { + $ews->getColumnDimensionByColumn($col)->setAutoSize(true); + } + + $ews->setAutoFilterByColumnAndRow(0, 1, count($this->columns) - 1, count($this->data)); + + $hoy = Carbon::now(config('app.timezone')); + $filename = str_replace('ñ', 'n', $this->title . ' - ' . $hoy->format('Y-m-d') . '.xlsx'); + + $writer = IOFactory::createWriter($ea, "Xlsx"); + + header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=utf-8"); + header('Content-Transfer-Encoding: binary'); + header('Content-Disposition: attachment; filename="' . $filename . '"'); + header('Cache-Control: max-age=0'); + + $writer->save('php://output'); + } +} +?> diff --git a/app/Service/Register.php b/app/Service/Register.php new file mode 100644 index 0000000..03f96e0 --- /dev/null +++ b/app/Service/Register.php @@ -0,0 +1,34 @@ + $user, + 'action' => $action, + 'time' => Carbon::now(config('app.timezone'))->toDateTimeString()//->format('Y-m-d HH:mm:ss') + ]; + $registry = model(RModel::class) + ->where('user', $user) + ->where('action', $action) + ->where('time', $data['time']) + ->findOne(); + if (!$registry) { + $registry = model(RModel::class)->create($data); + $registry->save(); + } + foreach ($variables as $data) { + $data['registry'] = $registry->id; + $log = (new Factory(RegistryData::class))->where($data)->find(); + if (!$log) { + $log = model(RegistryData::class)->create($data); + $log->save(); + } + } + } +} diff --git a/app/Service/Replacer.php b/app/Service/Replacer.php new file mode 100644 index 0000000..bf61513 --- /dev/null +++ b/app/Service/Replacer.php @@ -0,0 +1,127 @@ +parseLine($line); + + $output = $line; + foreach ($instructions as $instruction) { + $output = str_replace($instruction['original'], $this->buildLine($instruction['instruction'], $data), $output); + } + return $output; + } + protected function parseLine($line) + { + $ini_el = '[['; + $end_el = ']]'; + + $instructions = []; + $offset = 0; + while (strpos($line, $ini_el, $offset) !== false) { + $ini = strpos($line, $ini_el, $offset) + strlen($ini_el); + $end = strpos($line, $end_el, $offset); + $find = substr($line, $ini, $end - $ini); + $instructions []= ['original' => $ini_el . $find . $end_el, 'instruction' => $find]; + $offset = $end + 1; + } + return $instructions; + } + protected function buildLine($instructions, $data) + { + if (strpos($instructions, '|') !== false) { + $instructions = explode('|', $instructions); + } else { + $instructions = [$instructions]; + } + $output = ''; + foreach ($instructions as $instruction) { + $output = $this->buildReplace($instruction, $data, $output); + } + return $output; + } + protected function buildReplace($instruction, $data, $output = null) + { + if (strpos($instruction, '(') !== false) { + $ini = strpos($instruction, '(') + 1; + $end = strpos($instruction, ')'); + $mod = substr($instruction, $ini, $end - $ini); + $instruction = substr($instruction, 0, $ini - 1); + } + switch ($instruction) { + case 'UPPER': + return strtoupper($output); + case 'LOWER': + return strtolower($output); + case 'ISSET': + if ($output != '') { + return ', ' . $output; + } + return ''; + case 'UFS': + return format('ufs', $output); + case 'PESOS': + return format('pesos', $output); + } + + if (isset($mod)) { + $obj = $this->find($instruction . '(' . $mod .')', $data); + } else { + $obj = $this->find($instruction, $data); + } + if ($obj) { + return $obj; + } + if (is_object($output) and method_exists($output, $instruction)) { + if (isset($mod)) { + return $output->$instruction($mod); + } + return $output->$instruction(); + } + if (is_object($output) and isset($output->$instruction)) { + return $output->$instruction; + } + if ($instruction == 'strftime') { + setlocale(LC_TIME, 'es-CL', 'es'); + $f = Carbon::parse($output, config('app.timezone')); + $output = strftime($mod, $f->timestamp); + return $output; + } + + d($output, $instruction, function_exists($instruction), is_object($output), is_object($output) and isset($output->$instruction)); + } + protected function find($instruction, $data) + { + if (strpos($instruction, '(') !== false) { + $ini = strpos($instruction, '(') + 1; + $end = strpos($instruction, ')'); + $mod = substr($instruction, $ini, $end - $ini); + $instruction = substr($instruction, 0, $ini - 1); + } + if (method_exists($data, $instruction)) { + if (isset($mod)) { + return $data->$instruction($mod); + } + return $data->$instruction(); + } + if (isset($data->$instruction)) { + return $data->$instruction; + } + switch ($instruction) { + case 'Unidades': + $str = 'Departamento ' . $data->reserva()->unidad()->numeracion; + foreach ($data->reserva()->unidades() as $unidad) { + $str .= ', ' . ucwords($unidad->unidadProyecto()->tipo()->descripcion) . ' ' . $unidad->numeracion; + } + return $str; + case 'inmobiliaria': + return $data->proyecto()->inmobiliaria(); + } + return false; + } +} +?> \ No newline at end of file diff --git a/app/Service/Route.php b/app/Service/Route.php new file mode 100644 index 0000000..f910f87 --- /dev/null +++ b/app/Service/Route.php @@ -0,0 +1,131 @@ +add($t, $query, $callback); + } + } else { + switch (strtoupper($type)) { + case 'GET': + $this->get($query, $callback); + break; + case 'POST': + $this->post($query, $callback); + break; + } + } + } + public function get($query, $callback) + { + if ($this->exists('get', $query)) { + return; + } + $this->routes['get'][$query] = (object) ['query' => $query, 'callback' => $this->parseCallback($callback)]; + } + public function post($query, $callback) + { + if ($this->exists('post', $query)) { + return; + } + $this->routes['post'][$query] = (object) ['query' => $query, 'callback' => $this->parseCallback($callback)]; + } + protected function exists($type, $query) + { + return isset($this->routes['post'][$query]); + } + protected function parseCallback($callback) + { + if (is_callable($callback)) { + return $callback; + } + elseif (is_object($callback)) { + return [$callback, 'index']; + } + elseif (is_string($callback) and strpos($callback, '@') !== false) { + list($class, $method) = explode('@', $callback); + $class = '\\App\\Controller\\' . $class; + if (method_exists($class, $method)) { + return [$class, $method]; + } + } + elseif (is_string($callback)) { + $class = '\\App\\Controller\\' . $callback; + return [$class, 'index']; + } + } + public function route() + { + $url = $_SERVER['SCRIPT_NAME']; + $query = $_SERVER['QUERY_STRING']; + $method = $_SERVER['REQUEST_METHOD']; + $route = null; + switch (strtoupper($method)) { + case 'GET': + $route = $this->getGet($url, $query); + break; + case 'POST': + $route = $this->getPost($url, $query); + break; + } + if ($route) { + return $this->run($route->callback); + } + return false; + } + protected function getGet($url, $query) + { + if (isset($this->routes['get'][$url])) { + return $this->routes['get'][$url]; + } + $p = get('p'); + if ($p == null) { + $p = get('page'); + if ($p == null) { + $p = get('m'); + if ($p == null) { + $p = get('module'); + } + } + } + if (isset($this->routes['get'][$p])) { + return $this->routes['get'][$p]; + } + return false; + } + protected function getPost($url, $query) + { + if (isset($this->routes['post'][$url])) { + return $this->routes['post'][$url]; + } + $p = get('p'); + if ($p == null) { + $p = get('page'); + if ($p == null) { + $p = get('m'); + if ($p == null) { + $p = get('module'); + } + } + } + if (isset($this->routes['post'][$p])) { + return $this->routes['post'][$p]; + } + return false; + } + protected function run($callback) + { + return call_user_func($callback); + } +} +?> \ No newline at end of file diff --git a/bootstrap/autoload.php b/bootstrap/autoload.php new file mode 100644 index 0000000..b346078 --- /dev/null +++ b/bootstrap/autoload.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/bootstrap/database.php b/bootstrap/database.php new file mode 100644 index 0000000..23d964c --- /dev/null +++ b/bootstrap/database.php @@ -0,0 +1,30 @@ + $data) { + load($data, $name); +} + +function load($data, $name = '') { + if (!isset($data['port'])) { + $port = 3306; + } else { + $port = $data['port']; + } + $dsn = 'mysql:host=' . $data['host'] . ';port=' . $port . ';dbname=' . $data['database'] . ';charset=utf8'; + + if ($name != '') { + ORM::configure($dsn, null, $name); + ORM::configure('username', $data['username'], $name); + ORM::configure('password', $data['password'], $name); + } else { + ORM::configure($dsn, null); + ORM::configure('username', $data['username']); + ORM::configure('password', $data['password']); + } +} + +Model::$short_table_names = true; +?> diff --git a/bootstrap/errors.php b/bootstrap/errors.php new file mode 100644 index 0000000..dca55eb --- /dev/null +++ b/bootstrap/errors.php @@ -0,0 +1,7 @@ +pushHandler(new \Whoops\Handler\PrettyPageHandler); + $whoops->register(); +} +?> \ No newline at end of file diff --git a/bootstrap/routes.php b/bootstrap/routes.php new file mode 100644 index 0000000..2140f1b --- /dev/null +++ b/bootstrap/routes.php @@ -0,0 +1,21 @@ +underscored(); + Route::add(['GET', 'POST'], $route, $name); +} + +Route::add(['GET', 'POST'], 'buscar', 'Buscar'); +?> \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..3f42a1b --- /dev/null +++ b/composer.json @@ -0,0 +1,57 @@ +{ + "name" : "aldarien/incoviba", + "description" : "Intranet portal for Incoviba", + "type" : "project", + "require" : { + "aldarien/config" : "1.0.10", + "aldarien/asset" : "^1.0", + "aldarien/format" : "^1", + "aldarien/response" : "^1.0", + "aldarien/view" : "^1.0", + "aldarien/session" : "^1.0", + "j4mie/paris" : "^1.5", + "danielstjules/stringy" : "^3.1", + "phpoffice/phpspreadsheet": "1-beta", + "aldarien/url": "^1", + "nesbot/carbon": "^2", + "phpoffice/phpword": "^0.14.0", + "slam/php-excel": "^4.4", + "fabpot/goutte": "^3.2", + "incoviba/modelos": "dev-master", + "aldarien/models": "dev-master", + "incoviba/auth": "dev-master" + }, + "require-dev" : { + "phpunit/phpunit" : "^6.3", + "kint-php/kint" : "^2.1", + "filp/whoops" : "^2.1" + }, + "license" : "GNU AGPLv3", + "authors" : [{ + "name" : "Aldarien", + "email" : "jpvial@gmail.com" + } + ], + "autoload" : { + "psr-4" : { + "App\\" : "app" + }, + "files" : [ + "app/Helper/functions.php" + ] + }, + "repositories": [ + { + "type": "git", + "url": "//192.168.1.100/git/modelos.git" + }, + { + "type": "git", + "url": "//192.168.1.100/git/models.git" + }, + { + "type": "git", + "url": "//192.168.1.100/git/auth.git" + } + ] +} diff --git a/config/app.php b/config/app.php new file mode 100644 index 0000000..ce713ab --- /dev/null +++ b/config/app.php @@ -0,0 +1,10 @@ + 'America/Santiago', + 'locale' => 'es', + 'database' => 'mysql', + 'debug' => false, + 'benchmark' => false, + 'login_hours' => 5*24 +]; +?> \ No newline at end of file diff --git a/config/databases.php b/config/databases.php new file mode 100644 index 0000000..16cd719 --- /dev/null +++ b/config/databases.php @@ -0,0 +1,17 @@ + [ + 'host' => 'localhost', + //'port' => 3306, + 'database' => 'incoviba', + 'username' => 'incoviba', + 'password' => '5GQYFvRjVw2A4KcD' + ], + 'mysql_copy' => [ + 'host' => 'localhost', + 'database' => 'incoviba3', + 'username' => 'incoviba', + 'password' => '5GQYFvRjVw2A4KcD' + ] +] +?> diff --git a/config/incoviba.php b/config/incoviba.php new file mode 100644 index 0000000..d21d9e8 --- /dev/null +++ b/config/incoviba.php @@ -0,0 +1,6 @@ + [ + 'caducidad' => 30 + ] +]; diff --git a/config/locations.php b/config/locations.php new file mode 100644 index 0000000..49f1082 --- /dev/null +++ b/config/locations.php @@ -0,0 +1,15 @@ + root(), + 'cache' => '{locations.base}/cache', + 'public' => '{locations.base}/public', + 'resources' => '{locations.base}/resources', + 'views' => '{locations.resources}/views', + 'src' => '{locations.base}/src', + //'languages' => '{locations.resources}/languages' + 'app' => '{locations.base}/app', + 'controllers' => '{locations.app}/Controller', + 'money' => 'provm.cl/optimus/money', + 'api' => '192.168.1.100/intranet/api' +]; +?> diff --git a/public/Pipfile b/public/Pipfile new file mode 100644 index 0000000..b5846df --- /dev/null +++ b/public/Pipfile @@ -0,0 +1,11 @@ +[[source]] +name = "pypi" +url = "https://pypi.org/simple" +verify_ssl = true + +[dev-packages] + +[packages] + +[requires] +python_version = "3.8" diff --git a/public/css/app.css b/public/css/app.css new file mode 100644 index 0000000..ab445ec --- /dev/null +++ b/public/css/app.css @@ -0,0 +1,14 @@ +/*! + * Bootstrap v3.3.7 (http://getbootstrap.com) + * Copyright 2011-2016 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + *//*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}h1{font-size:2em;margin:0.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace, monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-appearance:textfield;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:0.35em 0.625em 0.75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:bold}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}/*! Source: https://github.com/h5bp/html5-boilerplate/blob/master/src/css/main.css */@media print{*,*:before,*:after{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a,a:visited{text-decoration:underline}a[href]:after{content:" (" attr(href) ")"}abbr[title]:after{content:" (" attr(title) ")"}a[href^="#"]:after,a[href^="javascript:"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}.navbar{display:none}.btn>.caret,.dropup>.btn>.caret{border-top-color:#000 !important}.label{border:1px solid #000}.table{border-collapse:collapse !important}.table td,.table th{background-color:#fff !important}.table-bordered th,.table-bordered td{border:1px solid #ddd !important}}@font-face{font-family:'Glyphicons Halflings';src:url('../fonts/glyphicons-halflings-regular.eot');src:url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),url('../fonts/glyphicons-halflings-regular.woff2') format('woff2'),url('../fonts/glyphicons-halflings-regular.woff') format('woff'),url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'),url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg')}.glyphicon{position:relative;top:1px;display:inline-block;font-family:'Glyphicons Halflings';font-style:normal;font-weight:normal;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.glyphicon-asterisk:before{content:"\002a"}.glyphicon-plus:before{content:"\002b"}.glyphicon-euro:before,.glyphicon-eur:before{content:"\20ac"}.glyphicon-minus:before{content:"\2212"}.glyphicon-cloud:before{content:"\2601"}.glyphicon-envelope:before{content:"\2709"}.glyphicon-pencil:before{content:"\270f"}.glyphicon-glass:before{content:"\e001"}.glyphicon-music:before{content:"\e002"}.glyphicon-search:before{content:"\e003"}.glyphicon-heart:before{content:"\e005"}.glyphicon-star:before{content:"\e006"}.glyphicon-star-empty:before{content:"\e007"}.glyphicon-user:before{content:"\e008"}.glyphicon-film:before{content:"\e009"}.glyphicon-th-large:before{content:"\e010"}.glyphicon-th:before{content:"\e011"}.glyphicon-th-list:before{content:"\e012"}.glyphicon-ok:before{content:"\e013"}.glyphicon-remove:before{content:"\e014"}.glyphicon-zoom-in:before{content:"\e015"}.glyphicon-zoom-out:before{content:"\e016"}.glyphicon-off:before{content:"\e017"}.glyphicon-signal:before{content:"\e018"}.glyphicon-cog:before{content:"\e019"}.glyphicon-trash:before{content:"\e020"}.glyphicon-home:before{content:"\e021"}.glyphicon-file:before{content:"\e022"}.glyphicon-time:before{content:"\e023"}.glyphicon-road:before{content:"\e024"}.glyphicon-download-alt:before{content:"\e025"}.glyphicon-download:before{content:"\e026"}.glyphicon-upload:before{content:"\e027"}.glyphicon-inbox:before{content:"\e028"}.glyphicon-play-circle:before{content:"\e029"}.glyphicon-repeat:before{content:"\e030"}.glyphicon-refresh:before{content:"\e031"}.glyphicon-list-alt:before{content:"\e032"}.glyphicon-lock:before{content:"\e033"}.glyphicon-flag:before{content:"\e034"}.glyphicon-headphones:before{content:"\e035"}.glyphicon-volume-off:before{content:"\e036"}.glyphicon-volume-down:before{content:"\e037"}.glyphicon-volume-up:before{content:"\e038"}.glyphicon-qrcode:before{content:"\e039"}.glyphicon-barcode:before{content:"\e040"}.glyphicon-tag:before{content:"\e041"}.glyphicon-tags:before{content:"\e042"}.glyphicon-book:before{content:"\e043"}.glyphicon-bookmark:before{content:"\e044"}.glyphicon-print:before{content:"\e045"}.glyphicon-camera:before{content:"\e046"}.glyphicon-font:before{content:"\e047"}.glyphicon-bold:before{content:"\e048"}.glyphicon-italic:before{content:"\e049"}.glyphicon-text-height:before{content:"\e050"}.glyphicon-text-width:before{content:"\e051"}.glyphicon-align-left:before{content:"\e052"}.glyphicon-align-center:before{content:"\e053"}.glyphicon-align-right:before{content:"\e054"}.glyphicon-align-justify:before{content:"\e055"}.glyphicon-list:before{content:"\e056"}.glyphicon-indent-left:before{content:"\e057"}.glyphicon-indent-right:before{content:"\e058"}.glyphicon-facetime-video:before{content:"\e059"}.glyphicon-picture:before{content:"\e060"}.glyphicon-map-marker:before{content:"\e062"}.glyphicon-adjust:before{content:"\e063"}.glyphicon-tint:before{content:"\e064"}.glyphicon-edit:before{content:"\e065"}.glyphicon-share:before{content:"\e066"}.glyphicon-check:before{content:"\e067"}.glyphicon-move:before{content:"\e068"}.glyphicon-step-backward:before{content:"\e069"}.glyphicon-fast-backward:before{content:"\e070"}.glyphicon-backward:before{content:"\e071"}.glyphicon-play:before{content:"\e072"}.glyphicon-pause:before{content:"\e073"}.glyphicon-stop:before{content:"\e074"}.glyphicon-forward:before{content:"\e075"}.glyphicon-fast-forward:before{content:"\e076"}.glyphicon-step-forward:before{content:"\e077"}.glyphicon-eject:before{content:"\e078"}.glyphicon-chevron-left:before{content:"\e079"}.glyphicon-chevron-right:before{content:"\e080"}.glyphicon-plus-sign:before{content:"\e081"}.glyphicon-minus-sign:before{content:"\e082"}.glyphicon-remove-sign:before{content:"\e083"}.glyphicon-ok-sign:before{content:"\e084"}.glyphicon-question-sign:before{content:"\e085"}.glyphicon-info-sign:before{content:"\e086"}.glyphicon-screenshot:before{content:"\e087"}.glyphicon-remove-circle:before{content:"\e088"}.glyphicon-ok-circle:before{content:"\e089"}.glyphicon-ban-circle:before{content:"\e090"}.glyphicon-arrow-left:before{content:"\e091"}.glyphicon-arrow-right:before{content:"\e092"}.glyphicon-arrow-up:before{content:"\e093"}.glyphicon-arrow-down:before{content:"\e094"}.glyphicon-share-alt:before{content:"\e095"}.glyphicon-resize-full:before{content:"\e096"}.glyphicon-resize-small:before{content:"\e097"}.glyphicon-exclamation-sign:before{content:"\e101"}.glyphicon-gift:before{content:"\e102"}.glyphicon-leaf:before{content:"\e103"}.glyphicon-fire:before{content:"\e104"}.glyphicon-eye-open:before{content:"\e105"}.glyphicon-eye-close:before{content:"\e106"}.glyphicon-warning-sign:before{content:"\e107"}.glyphicon-plane:before{content:"\e108"}.glyphicon-calendar:before{content:"\e109"}.glyphicon-random:before{content:"\e110"}.glyphicon-comment:before{content:"\e111"}.glyphicon-magnet:before{content:"\e112"}.glyphicon-chevron-up:before{content:"\e113"}.glyphicon-chevron-down:before{content:"\e114"}.glyphicon-retweet:before{content:"\e115"}.glyphicon-shopping-cart:before{content:"\e116"}.glyphicon-folder-close:before{content:"\e117"}.glyphicon-folder-open:before{content:"\e118"}.glyphicon-resize-vertical:before{content:"\e119"}.glyphicon-resize-horizontal:before{content:"\e120"}.glyphicon-hdd:before{content:"\e121"}.glyphicon-bullhorn:before{content:"\e122"}.glyphicon-bell:before{content:"\e123"}.glyphicon-certificate:before{content:"\e124"}.glyphicon-thumbs-up:before{content:"\e125"}.glyphicon-thumbs-down:before{content:"\e126"}.glyphicon-hand-right:before{content:"\e127"}.glyphicon-hand-left:before{content:"\e128"}.glyphicon-hand-up:before{content:"\e129"}.glyphicon-hand-down:before{content:"\e130"}.glyphicon-circle-arrow-right:before{content:"\e131"}.glyphicon-circle-arrow-left:before{content:"\e132"}.glyphicon-circle-arrow-up:before{content:"\e133"}.glyphicon-circle-arrow-down:before{content:"\e134"}.glyphicon-globe:before{content:"\e135"}.glyphicon-wrench:before{content:"\e136"}.glyphicon-tasks:before{content:"\e137"}.glyphicon-filter:before{content:"\e138"}.glyphicon-briefcase:before{content:"\e139"}.glyphicon-fullscreen:before{content:"\e140"}.glyphicon-dashboard:before{content:"\e141"}.glyphicon-paperclip:before{content:"\e142"}.glyphicon-heart-empty:before{content:"\e143"}.glyphicon-link:before{content:"\e144"}.glyphicon-phone:before{content:"\e145"}.glyphicon-pushpin:before{content:"\e146"}.glyphicon-usd:before{content:"\e148"}.glyphicon-gbp:before{content:"\e149"}.glyphicon-sort:before{content:"\e150"}.glyphicon-sort-by-alphabet:before{content:"\e151"}.glyphicon-sort-by-alphabet-alt:before{content:"\e152"}.glyphicon-sort-by-order:before{content:"\e153"}.glyphicon-sort-by-order-alt:before{content:"\e154"}.glyphicon-sort-by-attributes:before{content:"\e155"}.glyphicon-sort-by-attributes-alt:before{content:"\e156"}.glyphicon-unchecked:before{content:"\e157"}.glyphicon-expand:before{content:"\e158"}.glyphicon-collapse-down:before{content:"\e159"}.glyphicon-collapse-up:before{content:"\e160"}.glyphicon-log-in:before{content:"\e161"}.glyphicon-flash:before{content:"\e162"}.glyphicon-log-out:before{content:"\e163"}.glyphicon-new-window:before{content:"\e164"}.glyphicon-record:before{content:"\e165"}.glyphicon-save:before{content:"\e166"}.glyphicon-open:before{content:"\e167"}.glyphicon-saved:before{content:"\e168"}.glyphicon-import:before{content:"\e169"}.glyphicon-export:before{content:"\e170"}.glyphicon-send:before{content:"\e171"}.glyphicon-floppy-disk:before{content:"\e172"}.glyphicon-floppy-saved:before{content:"\e173"}.glyphicon-floppy-remove:before{content:"\e174"}.glyphicon-floppy-save:before{content:"\e175"}.glyphicon-floppy-open:before{content:"\e176"}.glyphicon-credit-card:before{content:"\e177"}.glyphicon-transfer:before{content:"\e178"}.glyphicon-cutlery:before{content:"\e179"}.glyphicon-header:before{content:"\e180"}.glyphicon-compressed:before{content:"\e181"}.glyphicon-earphone:before{content:"\e182"}.glyphicon-phone-alt:before{content:"\e183"}.glyphicon-tower:before{content:"\e184"}.glyphicon-stats:before{content:"\e185"}.glyphicon-sd-video:before{content:"\e186"}.glyphicon-hd-video:before{content:"\e187"}.glyphicon-subtitles:before{content:"\e188"}.glyphicon-sound-stereo:before{content:"\e189"}.glyphicon-sound-dolby:before{content:"\e190"}.glyphicon-sound-5-1:before{content:"\e191"}.glyphicon-sound-6-1:before{content:"\e192"}.glyphicon-sound-7-1:before{content:"\e193"}.glyphicon-copyright-mark:before{content:"\e194"}.glyphicon-registration-mark:before{content:"\e195"}.glyphicon-cloud-download:before{content:"\e197"}.glyphicon-cloud-upload:before{content:"\e198"}.glyphicon-tree-conifer:before{content:"\e199"}.glyphicon-tree-deciduous:before{content:"\e200"}.glyphicon-cd:before{content:"\e201"}.glyphicon-save-file:before{content:"\e202"}.glyphicon-open-file:before{content:"\e203"}.glyphicon-level-up:before{content:"\e204"}.glyphicon-copy:before{content:"\e205"}.glyphicon-paste:before{content:"\e206"}.glyphicon-alert:before{content:"\e209"}.glyphicon-equalizer:before{content:"\e210"}.glyphicon-king:before{content:"\e211"}.glyphicon-queen:before{content:"\e212"}.glyphicon-pawn:before{content:"\e213"}.glyphicon-bishop:before{content:"\e214"}.glyphicon-knight:before{content:"\e215"}.glyphicon-baby-formula:before{content:"\e216"}.glyphicon-tent:before{content:"\26fa"}.glyphicon-blackboard:before{content:"\e218"}.glyphicon-bed:before{content:"\e219"}.glyphicon-apple:before{content:"\f8ff"}.glyphicon-erase:before{content:"\e221"}.glyphicon-hourglass:before{content:"\231b"}.glyphicon-lamp:before{content:"\e223"}.glyphicon-duplicate:before{content:"\e224"}.glyphicon-piggy-bank:before{content:"\e225"}.glyphicon-scissors:before{content:"\e226"}.glyphicon-bitcoin:before{content:"\e227"}.glyphicon-btc:before{content:"\e227"}.glyphicon-xbt:before{content:"\e227"}.glyphicon-yen:before{content:"\00a5"}.glyphicon-jpy:before{content:"\00a5"}.glyphicon-ruble:before{content:"\20bd"}.glyphicon-rub:before{content:"\20bd"}.glyphicon-scale:before{content:"\e230"}.glyphicon-ice-lolly:before{content:"\e231"}.glyphicon-ice-lolly-tasted:before{content:"\e232"}.glyphicon-education:before{content:"\e233"}.glyphicon-option-horizontal:before{content:"\e234"}.glyphicon-option-vertical:before{content:"\e235"}.glyphicon-menu-hamburger:before{content:"\e236"}.glyphicon-modal-window:before{content:"\e237"}.glyphicon-oil:before{content:"\e238"}.glyphicon-grain:before{content:"\e239"}.glyphicon-sunglasses:before{content:"\e240"}.glyphicon-text-size:before{content:"\e241"}.glyphicon-text-color:before{content:"\e242"}.glyphicon-text-background:before{content:"\e243"}.glyphicon-object-align-top:before{content:"\e244"}.glyphicon-object-align-bottom:before{content:"\e245"}.glyphicon-object-align-horizontal:before{content:"\e246"}.glyphicon-object-align-left:before{content:"\e247"}.glyphicon-object-align-vertical:before{content:"\e248"}.glyphicon-object-align-right:before{content:"\e249"}.glyphicon-triangle-right:before{content:"\e250"}.glyphicon-triangle-left:before{content:"\e251"}.glyphicon-triangle-bottom:before{content:"\e252"}.glyphicon-triangle-top:before{content:"\e253"}.glyphicon-console:before{content:"\e254"}.glyphicon-superscript:before{content:"\e255"}.glyphicon-subscript:before{content:"\e256"}.glyphicon-menu-left:before{content:"\e257"}.glyphicon-menu-right:before{content:"\e258"}.glyphicon-menu-down:before{content:"\e259"}.glyphicon-menu-up:before{content:"\e260"}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}*:before,*:after{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}html{font-size:10px;-webkit-tap-highlight-color:rgba(0,0,0,0)}body{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:1.42857143;color:#333;background-color:#fff}input,button,select,textarea{font-family:inherit;font-size:inherit;line-height:inherit}a{color:#337ab7;text-decoration:none}a:hover,a:focus{color:#23527c;text-decoration:underline}a:focus{outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}figure{margin:0}img{vertical-align:middle}.img-responsive,.thumbnail>img,.thumbnail a>img,.carousel-inner>.item>img,.carousel-inner>.item>a>img{display:block;max-width:100%;height:auto}.img-rounded{border-radius:6px}.img-thumbnail{padding:4px;line-height:1.42857143;background-color:#fff;border:1px solid #ddd;border-radius:4px;-webkit-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;transition:all .2s ease-in-out;display:inline-block;max-width:100%;height:auto}.img-circle{border-radius:50%}hr{margin-top:20px;margin-bottom:20px;border:0;border-top:1px solid #eee}.sr-only{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0, 0, 0, 0);border:0}.sr-only-focusable:active,.sr-only-focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto}[role="button"]{cursor:pointer}h1,h2,h3,h4,h5,h6,.h1,.h2,.h3,.h4,.h5,.h6{font-family:inherit;font-weight:500;line-height:1.1;color:inherit}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small,.h1 small,.h2 small,.h3 small,.h4 small,.h5 small,.h6 small,h1 .small,h2 .small,h3 .small,h4 .small,h5 .small,h6 .small,.h1 .small,.h2 .small,.h3 .small,.h4 .small,.h5 .small,.h6 .small{font-weight:normal;line-height:1;color:#777}h1,.h1,h2,.h2,h3,.h3{margin-top:20px;margin-bottom:10px}h1 small,.h1 small,h2 small,.h2 small,h3 small,.h3 small,h1 .small,.h1 .small,h2 .small,.h2 .small,h3 .small,.h3 .small{font-size:65%}h4,.h4,h5,.h5,h6,.h6{margin-top:10px;margin-bottom:10px}h4 small,.h4 small,h5 small,.h5 small,h6 small,.h6 small,h4 .small,.h4 .small,h5 .small,.h5 .small,h6 .small,.h6 .small{font-size:75%}h1,.h1{font-size:36px}h2,.h2{font-size:30px}h3,.h3{font-size:24px}h4,.h4{font-size:18px}h5,.h5{font-size:14px}h6,.h6{font-size:12px}p{margin:0 0 10px}.lead{margin-bottom:20px;font-size:16px;font-weight:300;line-height:1.4}@media (min-width:768px){.lead{font-size:21px}}small,.small{font-size:85%}mark,.mark{background-color:#fcf8e3;padding:.2em}.text-left{text-align:left}.text-right{text-align:right}.text-center{text-align:center}.text-justify{text-align:justify}.text-nowrap{white-space:nowrap}.text-lowercase{text-transform:lowercase}.text-uppercase{text-transform:uppercase}.text-capitalize{text-transform:capitalize}.text-muted{color:#777}.text-primary{color:#337ab7}a.text-primary:hover,a.text-primary:focus{color:#286090}.text-success{color:#3c763d}a.text-success:hover,a.text-success:focus{color:#2b542c}.text-info{color:#31708f}a.text-info:hover,a.text-info:focus{color:#245269}.text-warning{color:#8a6d3b}a.text-warning:hover,a.text-warning:focus{color:#66512c}.text-danger{color:#a94442}a.text-danger:hover,a.text-danger:focus{color:#843534}.bg-primary{color:#fff;background-color:#337ab7}a.bg-primary:hover,a.bg-primary:focus{background-color:#286090}.bg-success{background-color:#dff0d8}a.bg-success:hover,a.bg-success:focus{background-color:#c1e2b3}.bg-info{background-color:#d9edf7}a.bg-info:hover,a.bg-info:focus{background-color:#afd9ee}.bg-warning{background-color:#fcf8e3}a.bg-warning:hover,a.bg-warning:focus{background-color:#f7ecb5}.bg-danger{background-color:#f2dede}a.bg-danger:hover,a.bg-danger:focus{background-color:#e4b9b9}.page-header{padding-bottom:9px;margin:40px 0 20px;border-bottom:1px solid #eee}ul,ol{margin-top:0;margin-bottom:10px}ul ul,ol ul,ul ol,ol ol{margin-bottom:0}.list-unstyled{padding-left:0;list-style:none}.list-inline{padding-left:0;list-style:none;margin-left:-5px}.list-inline>li{display:inline-block;padding-left:5px;padding-right:5px}dl{margin-top:0;margin-bottom:20px}dt,dd{line-height:1.42857143}dt{font-weight:bold}dd{margin-left:0}@media (min-width:768px){.dl-horizontal dt{float:left;width:160px;clear:left;text-align:right;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-horizontal dd{margin-left:180px}}abbr[title],abbr[data-original-title]{cursor:help;border-bottom:1px dotted #777}.initialism{font-size:90%;text-transform:uppercase}blockquote{padding:10px 20px;margin:0 0 20px;font-size:17.5px;border-left:5px solid #eee}blockquote p:last-child,blockquote ul:last-child,blockquote ol:last-child{margin-bottom:0}blockquote footer,blockquote small,blockquote .small{display:block;font-size:80%;line-height:1.42857143;color:#777}blockquote footer:before,blockquote small:before,blockquote .small:before{content:'\2014 \00A0'}.blockquote-reverse,blockquote.pull-right{padding-right:15px;padding-left:0;border-right:5px solid #eee;border-left:0;text-align:right}.blockquote-reverse footer:before,blockquote.pull-right footer:before,.blockquote-reverse small:before,blockquote.pull-right small:before,.blockquote-reverse .small:before,blockquote.pull-right .small:before{content:''}.blockquote-reverse footer:after,blockquote.pull-right footer:after,.blockquote-reverse small:after,blockquote.pull-right small:after,.blockquote-reverse .small:after,blockquote.pull-right .small:after{content:'\00A0 \2014'}address{margin-bottom:20px;font-style:normal;line-height:1.42857143}code,kbd,pre,samp{font-family:Menlo,Monaco,Consolas,"Courier New",monospace}code{padding:2px 4px;font-size:90%;color:#c7254e;background-color:#f9f2f4;border-radius:4px}kbd{padding:2px 4px;font-size:90%;color:#fff;background-color:#333;border-radius:3px;box-shadow:inset 0 -1px 0 rgba(0,0,0,0.25)}kbd kbd{padding:0;font-size:100%;font-weight:bold;box-shadow:none}pre{display:block;padding:9.5px;margin:0 0 10px;font-size:13px;line-height:1.42857143;word-break:break-all;word-wrap:break-word;color:#333;background-color:#f5f5f5;border:1px solid #ccc;border-radius:4px}pre code{padding:0;font-size:inherit;color:inherit;white-space:pre-wrap;background-color:transparent;border-radius:0}.pre-scrollable{max-height:340px;overflow-y:scroll}.container{margin-right:auto;margin-left:auto;padding-left:15px;padding-right:15px}@media (min-width:768px){.container{width:750px}}@media (min-width:992px){.container{width:970px}}@media (min-width:1200px){.container{width:1170px}}.container-fluid{margin-right:auto;margin-left:auto;padding-left:15px;padding-right:15px}.row{margin-left:-15px;margin-right:-15px}.col-xs-1, .col-sm-1, .col-md-1, .col-lg-1, .col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, .col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, .col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, .col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, .col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, .col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, .col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, .col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, .col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, .col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, .col-xs-12, .col-sm-12, .col-md-12, .col-lg-12{position:relative;min-height:1px;padding-left:15px;padding-right:15px}.col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12{float:left}.col-xs-12{width:100%}.col-xs-11{width:91.66666667%}.col-xs-10{width:83.33333333%}.col-xs-9{width:75%}.col-xs-8{width:66.66666667%}.col-xs-7{width:58.33333333%}.col-xs-6{width:50%}.col-xs-5{width:41.66666667%}.col-xs-4{width:33.33333333%}.col-xs-3{width:25%}.col-xs-2{width:16.66666667%}.col-xs-1{width:8.33333333%}.col-xs-pull-12{right:100%}.col-xs-pull-11{right:91.66666667%}.col-xs-pull-10{right:83.33333333%}.col-xs-pull-9{right:75%}.col-xs-pull-8{right:66.66666667%}.col-xs-pull-7{right:58.33333333%}.col-xs-pull-6{right:50%}.col-xs-pull-5{right:41.66666667%}.col-xs-pull-4{right:33.33333333%}.col-xs-pull-3{right:25%}.col-xs-pull-2{right:16.66666667%}.col-xs-pull-1{right:8.33333333%}.col-xs-pull-0{right:auto}.col-xs-push-12{left:100%}.col-xs-push-11{left:91.66666667%}.col-xs-push-10{left:83.33333333%}.col-xs-push-9{left:75%}.col-xs-push-8{left:66.66666667%}.col-xs-push-7{left:58.33333333%}.col-xs-push-6{left:50%}.col-xs-push-5{left:41.66666667%}.col-xs-push-4{left:33.33333333%}.col-xs-push-3{left:25%}.col-xs-push-2{left:16.66666667%}.col-xs-push-1{left:8.33333333%}.col-xs-push-0{left:auto}.col-xs-offset-12{margin-left:100%}.col-xs-offset-11{margin-left:91.66666667%}.col-xs-offset-10{margin-left:83.33333333%}.col-xs-offset-9{margin-left:75%}.col-xs-offset-8{margin-left:66.66666667%}.col-xs-offset-7{margin-left:58.33333333%}.col-xs-offset-6{margin-left:50%}.col-xs-offset-5{margin-left:41.66666667%}.col-xs-offset-4{margin-left:33.33333333%}.col-xs-offset-3{margin-left:25%}.col-xs-offset-2{margin-left:16.66666667%}.col-xs-offset-1{margin-left:8.33333333%}.col-xs-offset-0{margin-left:0%}@media (min-width:768px){.col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12{float:left}.col-sm-12{width:100%}.col-sm-11{width:91.66666667%}.col-sm-10{width:83.33333333%}.col-sm-9{width:75%}.col-sm-8{width:66.66666667%}.col-sm-7{width:58.33333333%}.col-sm-6{width:50%}.col-sm-5{width:41.66666667%}.col-sm-4{width:33.33333333%}.col-sm-3{width:25%}.col-sm-2{width:16.66666667%}.col-sm-1{width:8.33333333%}.col-sm-pull-12{right:100%}.col-sm-pull-11{right:91.66666667%}.col-sm-pull-10{right:83.33333333%}.col-sm-pull-9{right:75%}.col-sm-pull-8{right:66.66666667%}.col-sm-pull-7{right:58.33333333%}.col-sm-pull-6{right:50%}.col-sm-pull-5{right:41.66666667%}.col-sm-pull-4{right:33.33333333%}.col-sm-pull-3{right:25%}.col-sm-pull-2{right:16.66666667%}.col-sm-pull-1{right:8.33333333%}.col-sm-pull-0{right:auto}.col-sm-push-12{left:100%}.col-sm-push-11{left:91.66666667%}.col-sm-push-10{left:83.33333333%}.col-sm-push-9{left:75%}.col-sm-push-8{left:66.66666667%}.col-sm-push-7{left:58.33333333%}.col-sm-push-6{left:50%}.col-sm-push-5{left:41.66666667%}.col-sm-push-4{left:33.33333333%}.col-sm-push-3{left:25%}.col-sm-push-2{left:16.66666667%}.col-sm-push-1{left:8.33333333%}.col-sm-push-0{left:auto}.col-sm-offset-12{margin-left:100%}.col-sm-offset-11{margin-left:91.66666667%}.col-sm-offset-10{margin-left:83.33333333%}.col-sm-offset-9{margin-left:75%}.col-sm-offset-8{margin-left:66.66666667%}.col-sm-offset-7{margin-left:58.33333333%}.col-sm-offset-6{margin-left:50%}.col-sm-offset-5{margin-left:41.66666667%}.col-sm-offset-4{margin-left:33.33333333%}.col-sm-offset-3{margin-left:25%}.col-sm-offset-2{margin-left:16.66666667%}.col-sm-offset-1{margin-left:8.33333333%}.col-sm-offset-0{margin-left:0%}}@media (min-width:992px){.col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12{float:left}.col-md-12{width:100%}.col-md-11{width:91.66666667%}.col-md-10{width:83.33333333%}.col-md-9{width:75%}.col-md-8{width:66.66666667%}.col-md-7{width:58.33333333%}.col-md-6{width:50%}.col-md-5{width:41.66666667%}.col-md-4{width:33.33333333%}.col-md-3{width:25%}.col-md-2{width:16.66666667%}.col-md-1{width:8.33333333%}.col-md-pull-12{right:100%}.col-md-pull-11{right:91.66666667%}.col-md-pull-10{right:83.33333333%}.col-md-pull-9{right:75%}.col-md-pull-8{right:66.66666667%}.col-md-pull-7{right:58.33333333%}.col-md-pull-6{right:50%}.col-md-pull-5{right:41.66666667%}.col-md-pull-4{right:33.33333333%}.col-md-pull-3{right:25%}.col-md-pull-2{right:16.66666667%}.col-md-pull-1{right:8.33333333%}.col-md-pull-0{right:auto}.col-md-push-12{left:100%}.col-md-push-11{left:91.66666667%}.col-md-push-10{left:83.33333333%}.col-md-push-9{left:75%}.col-md-push-8{left:66.66666667%}.col-md-push-7{left:58.33333333%}.col-md-push-6{left:50%}.col-md-push-5{left:41.66666667%}.col-md-push-4{left:33.33333333%}.col-md-push-3{left:25%}.col-md-push-2{left:16.66666667%}.col-md-push-1{left:8.33333333%}.col-md-push-0{left:auto}.col-md-offset-12{margin-left:100%}.col-md-offset-11{margin-left:91.66666667%}.col-md-offset-10{margin-left:83.33333333%}.col-md-offset-9{margin-left:75%}.col-md-offset-8{margin-left:66.66666667%}.col-md-offset-7{margin-left:58.33333333%}.col-md-offset-6{margin-left:50%}.col-md-offset-5{margin-left:41.66666667%}.col-md-offset-4{margin-left:33.33333333%}.col-md-offset-3{margin-left:25%}.col-md-offset-2{margin-left:16.66666667%}.col-md-offset-1{margin-left:8.33333333%}.col-md-offset-0{margin-left:0%}}@media (min-width:1200px){.col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12{float:left}.col-lg-12{width:100%}.col-lg-11{width:91.66666667%}.col-lg-10{width:83.33333333%}.col-lg-9{width:75%}.col-lg-8{width:66.66666667%}.col-lg-7{width:58.33333333%}.col-lg-6{width:50%}.col-lg-5{width:41.66666667%}.col-lg-4{width:33.33333333%}.col-lg-3{width:25%}.col-lg-2{width:16.66666667%}.col-lg-1{width:8.33333333%}.col-lg-pull-12{right:100%}.col-lg-pull-11{right:91.66666667%}.col-lg-pull-10{right:83.33333333%}.col-lg-pull-9{right:75%}.col-lg-pull-8{right:66.66666667%}.col-lg-pull-7{right:58.33333333%}.col-lg-pull-6{right:50%}.col-lg-pull-5{right:41.66666667%}.col-lg-pull-4{right:33.33333333%}.col-lg-pull-3{right:25%}.col-lg-pull-2{right:16.66666667%}.col-lg-pull-1{right:8.33333333%}.col-lg-pull-0{right:auto}.col-lg-push-12{left:100%}.col-lg-push-11{left:91.66666667%}.col-lg-push-10{left:83.33333333%}.col-lg-push-9{left:75%}.col-lg-push-8{left:66.66666667%}.col-lg-push-7{left:58.33333333%}.col-lg-push-6{left:50%}.col-lg-push-5{left:41.66666667%}.col-lg-push-4{left:33.33333333%}.col-lg-push-3{left:25%}.col-lg-push-2{left:16.66666667%}.col-lg-push-1{left:8.33333333%}.col-lg-push-0{left:auto}.col-lg-offset-12{margin-left:100%}.col-lg-offset-11{margin-left:91.66666667%}.col-lg-offset-10{margin-left:83.33333333%}.col-lg-offset-9{margin-left:75%}.col-lg-offset-8{margin-left:66.66666667%}.col-lg-offset-7{margin-left:58.33333333%}.col-lg-offset-6{margin-left:50%}.col-lg-offset-5{margin-left:41.66666667%}.col-lg-offset-4{margin-left:33.33333333%}.col-lg-offset-3{margin-left:25%}.col-lg-offset-2{margin-left:16.66666667%}.col-lg-offset-1{margin-left:8.33333333%}.col-lg-offset-0{margin-left:0%}}table{background-color:transparent}caption{padding-top:8px;padding-bottom:8px;color:#777;text-align:left}th{text-align:left}.table{width:100%;max-width:100%;margin-bottom:20px}.table>thead>tr>th,.table>tbody>tr>th,.table>tfoot>tr>th,.table>thead>tr>td,.table>tbody>tr>td,.table>tfoot>tr>td{padding:8px;line-height:1.42857143;vertical-align:top;border-top:1px solid #ddd}.table>thead>tr>th{vertical-align:bottom;border-bottom:2px solid #ddd}.table>caption+thead>tr:first-child>th,.table>colgroup+thead>tr:first-child>th,.table>thead:first-child>tr:first-child>th,.table>caption+thead>tr:first-child>td,.table>colgroup+thead>tr:first-child>td,.table>thead:first-child>tr:first-child>td{border-top:0}.table>tbody+tbody{border-top:2px solid #ddd}.table .table{background-color:#fff}.table-condensed>thead>tr>th,.table-condensed>tbody>tr>th,.table-condensed>tfoot>tr>th,.table-condensed>thead>tr>td,.table-condensed>tbody>tr>td,.table-condensed>tfoot>tr>td{padding:5px}.table-bordered{border:1px solid #ddd}.table-bordered>thead>tr>th,.table-bordered>tbody>tr>th,.table-bordered>tfoot>tr>th,.table-bordered>thead>tr>td,.table-bordered>tbody>tr>td,.table-bordered>tfoot>tr>td{border:1px solid #ddd}.table-bordered>thead>tr>th,.table-bordered>thead>tr>td{border-bottom-width:2px}.table-striped>tbody>tr:nth-of-type(odd){background-color:#f9f9f9}.table-hover>tbody>tr:hover{background-color:#f5f5f5}table col[class*="col-"]{position:static;float:none;display:table-column}table td[class*="col-"],table th[class*="col-"]{position:static;float:none;display:table-cell}.table>thead>tr>td.active,.table>tbody>tr>td.active,.table>tfoot>tr>td.active,.table>thead>tr>th.active,.table>tbody>tr>th.active,.table>tfoot>tr>th.active,.table>thead>tr.active>td,.table>tbody>tr.active>td,.table>tfoot>tr.active>td,.table>thead>tr.active>th,.table>tbody>tr.active>th,.table>tfoot>tr.active>th{background-color:#f5f5f5}.table-hover>tbody>tr>td.active:hover,.table-hover>tbody>tr>th.active:hover,.table-hover>tbody>tr.active:hover>td,.table-hover>tbody>tr:hover>.active,.table-hover>tbody>tr.active:hover>th{background-color:#e8e8e8}.table>thead>tr>td.success,.table>tbody>tr>td.success,.table>tfoot>tr>td.success,.table>thead>tr>th.success,.table>tbody>tr>th.success,.table>tfoot>tr>th.success,.table>thead>tr.success>td,.table>tbody>tr.success>td,.table>tfoot>tr.success>td,.table>thead>tr.success>th,.table>tbody>tr.success>th,.table>tfoot>tr.success>th{background-color:#dff0d8}.table-hover>tbody>tr>td.success:hover,.table-hover>tbody>tr>th.success:hover,.table-hover>tbody>tr.success:hover>td,.table-hover>tbody>tr:hover>.success,.table-hover>tbody>tr.success:hover>th{background-color:#d0e9c6}.table>thead>tr>td.info,.table>tbody>tr>td.info,.table>tfoot>tr>td.info,.table>thead>tr>th.info,.table>tbody>tr>th.info,.table>tfoot>tr>th.info,.table>thead>tr.info>td,.table>tbody>tr.info>td,.table>tfoot>tr.info>td,.table>thead>tr.info>th,.table>tbody>tr.info>th,.table>tfoot>tr.info>th{background-color:#d9edf7}.table-hover>tbody>tr>td.info:hover,.table-hover>tbody>tr>th.info:hover,.table-hover>tbody>tr.info:hover>td,.table-hover>tbody>tr:hover>.info,.table-hover>tbody>tr.info:hover>th{background-color:#c4e3f3}.table>thead>tr>td.warning,.table>tbody>tr>td.warning,.table>tfoot>tr>td.warning,.table>thead>tr>th.warning,.table>tbody>tr>th.warning,.table>tfoot>tr>th.warning,.table>thead>tr.warning>td,.table>tbody>tr.warning>td,.table>tfoot>tr.warning>td,.table>thead>tr.warning>th,.table>tbody>tr.warning>th,.table>tfoot>tr.warning>th{background-color:#fcf8e3}.table-hover>tbody>tr>td.warning:hover,.table-hover>tbody>tr>th.warning:hover,.table-hover>tbody>tr.warning:hover>td,.table-hover>tbody>tr:hover>.warning,.table-hover>tbody>tr.warning:hover>th{background-color:#faf2cc}.table>thead>tr>td.danger,.table>tbody>tr>td.danger,.table>tfoot>tr>td.danger,.table>thead>tr>th.danger,.table>tbody>tr>th.danger,.table>tfoot>tr>th.danger,.table>thead>tr.danger>td,.table>tbody>tr.danger>td,.table>tfoot>tr.danger>td,.table>thead>tr.danger>th,.table>tbody>tr.danger>th,.table>tfoot>tr.danger>th{background-color:#f2dede}.table-hover>tbody>tr>td.danger:hover,.table-hover>tbody>tr>th.danger:hover,.table-hover>tbody>tr.danger:hover>td,.table-hover>tbody>tr:hover>.danger,.table-hover>tbody>tr.danger:hover>th{background-color:#ebcccc}.table-responsive{overflow-x:auto;min-height:0.01%}@media screen and (max-width:767px){.table-responsive{width:100%;margin-bottom:15px;overflow-y:hidden;-ms-overflow-style:-ms-autohiding-scrollbar;border:1px solid #ddd}.table-responsive>.table{margin-bottom:0}.table-responsive>.table>thead>tr>th,.table-responsive>.table>tbody>tr>th,.table-responsive>.table>tfoot>tr>th,.table-responsive>.table>thead>tr>td,.table-responsive>.table>tbody>tr>td,.table-responsive>.table>tfoot>tr>td{white-space:nowrap}.table-responsive>.table-bordered{border:0}.table-responsive>.table-bordered>thead>tr>th:first-child,.table-responsive>.table-bordered>tbody>tr>th:first-child,.table-responsive>.table-bordered>tfoot>tr>th:first-child,.table-responsive>.table-bordered>thead>tr>td:first-child,.table-responsive>.table-bordered>tbody>tr>td:first-child,.table-responsive>.table-bordered>tfoot>tr>td:first-child{border-left:0}.table-responsive>.table-bordered>thead>tr>th:last-child,.table-responsive>.table-bordered>tbody>tr>th:last-child,.table-responsive>.table-bordered>tfoot>tr>th:last-child,.table-responsive>.table-bordered>thead>tr>td:last-child,.table-responsive>.table-bordered>tbody>tr>td:last-child,.table-responsive>.table-bordered>tfoot>tr>td:last-child{border-right:0}.table-responsive>.table-bordered>tbody>tr:last-child>th,.table-responsive>.table-bordered>tfoot>tr:last-child>th,.table-responsive>.table-bordered>tbody>tr:last-child>td,.table-responsive>.table-bordered>tfoot>tr:last-child>td{border-bottom:0}}fieldset{padding:0;margin:0;border:0;min-width:0}legend{display:block;width:100%;padding:0;margin-bottom:20px;font-size:21px;line-height:inherit;color:#333;border:0;border-bottom:1px solid #e5e5e5}label{display:inline-block;max-width:100%;margin-bottom:5px;font-weight:bold}input[type="search"]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}input[type="radio"],input[type="checkbox"]{margin:4px 0 0;margin-top:1px \9;line-height:normal}input[type="file"]{display:block}input[type="range"]{display:block;width:100%}select[multiple],select[size]{height:auto}input[type="file"]:focus,input[type="radio"]:focus,input[type="checkbox"]:focus{outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}output{display:block;padding-top:7px;font-size:14px;line-height:1.42857143;color:#555}.form-control{display:block;width:100%;height:34px;padding:6px 12px;font-size:14px;line-height:1.42857143;color:#555;background-color:#fff;background-image:none;border:1px solid #ccc;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-webkit-transition:border-color ease-in-out .15s, box-shadow ease-in-out .15s;-o-transition:border-color ease-in-out .15s, box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s, box-shadow ease-in-out .15s}.form-control:focus{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6)}.form-control::-moz-placeholder{color:#999;opacity:1}.form-control:-ms-input-placeholder{color:#999}.form-control::-webkit-input-placeholder{color:#999}.form-control::-ms-expand{border:0;background-color:transparent}.form-control[disabled],.form-control[readonly],fieldset[disabled] .form-control{background-color:#eee;opacity:1}.form-control[disabled],fieldset[disabled] .form-control{cursor:not-allowed}textarea.form-control{height:auto}input[type="search"]{-webkit-appearance:none}@media screen and (-webkit-min-device-pixel-ratio:0){input[type="date"].form-control,input[type="time"].form-control,input[type="datetime-local"].form-control,input[type="month"].form-control{line-height:34px}input[type="date"].input-sm,input[type="time"].input-sm,input[type="datetime-local"].input-sm,input[type="month"].input-sm,.input-group-sm input[type="date"],.input-group-sm input[type="time"],.input-group-sm input[type="datetime-local"],.input-group-sm input[type="month"]{line-height:30px}input[type="date"].input-lg,input[type="time"].input-lg,input[type="datetime-local"].input-lg,input[type="month"].input-lg,.input-group-lg input[type="date"],.input-group-lg input[type="time"],.input-group-lg input[type="datetime-local"],.input-group-lg input[type="month"]{line-height:46px}}.form-group{margin-bottom:15px}.radio,.checkbox{position:relative;display:block;margin-top:10px;margin-bottom:10px}.radio label,.checkbox label{min-height:20px;padding-left:20px;margin-bottom:0;font-weight:normal;cursor:pointer}.radio input[type="radio"],.radio-inline input[type="radio"],.checkbox input[type="checkbox"],.checkbox-inline input[type="checkbox"]{position:absolute;margin-left:-20px;margin-top:4px \9}.radio+.radio,.checkbox+.checkbox{margin-top:-5px}.radio-inline,.checkbox-inline{position:relative;display:inline-block;padding-left:20px;margin-bottom:0;vertical-align:middle;font-weight:normal;cursor:pointer}.radio-inline+.radio-inline,.checkbox-inline+.checkbox-inline{margin-top:0;margin-left:10px}input[type="radio"][disabled],input[type="checkbox"][disabled],input[type="radio"].disabled,input[type="checkbox"].disabled,fieldset[disabled] input[type="radio"],fieldset[disabled] input[type="checkbox"]{cursor:not-allowed}.radio-inline.disabled,.checkbox-inline.disabled,fieldset[disabled] .radio-inline,fieldset[disabled] .checkbox-inline{cursor:not-allowed}.radio.disabled label,.checkbox.disabled label,fieldset[disabled] .radio label,fieldset[disabled] .checkbox label{cursor:not-allowed}.form-control-static{padding-top:7px;padding-bottom:7px;margin-bottom:0;min-height:34px}.form-control-static.input-lg,.form-control-static.input-sm{padding-left:0;padding-right:0}.input-sm{height:30px;padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}select.input-sm{height:30px;line-height:30px}textarea.input-sm,select[multiple].input-sm{height:auto}.form-group-sm .form-control{height:30px;padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}.form-group-sm select.form-control{height:30px;line-height:30px}.form-group-sm textarea.form-control,.form-group-sm select[multiple].form-control{height:auto}.form-group-sm .form-control-static{height:30px;min-height:32px;padding:6px 10px;font-size:12px;line-height:1.5}.input-lg{height:46px;padding:10px 16px;font-size:18px;line-height:1.3333333;border-radius:6px}select.input-lg{height:46px;line-height:46px}textarea.input-lg,select[multiple].input-lg{height:auto}.form-group-lg .form-control{height:46px;padding:10px 16px;font-size:18px;line-height:1.3333333;border-radius:6px}.form-group-lg select.form-control{height:46px;line-height:46px}.form-group-lg textarea.form-control,.form-group-lg select[multiple].form-control{height:auto}.form-group-lg .form-control-static{height:46px;min-height:38px;padding:11px 16px;font-size:18px;line-height:1.3333333}.has-feedback{position:relative}.has-feedback .form-control{padding-right:42.5px}.form-control-feedback{position:absolute;top:0;right:0;z-index:2;display:block;width:34px;height:34px;line-height:34px;text-align:center;pointer-events:none}.input-lg+.form-control-feedback,.input-group-lg+.form-control-feedback,.form-group-lg .form-control+.form-control-feedback{width:46px;height:46px;line-height:46px}.input-sm+.form-control-feedback,.input-group-sm+.form-control-feedback,.form-group-sm .form-control+.form-control-feedback{width:30px;height:30px;line-height:30px}.has-success .help-block,.has-success .control-label,.has-success .radio,.has-success .checkbox,.has-success .radio-inline,.has-success .checkbox-inline,.has-success.radio label,.has-success.checkbox label,.has-success.radio-inline label,.has-success.checkbox-inline label{color:#3c763d}.has-success .form-control{border-color:#3c763d;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.has-success .form-control:focus{border-color:#2b542c;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #67b168;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #67b168}.has-success .input-group-addon{color:#3c763d;border-color:#3c763d;background-color:#dff0d8}.has-success .form-control-feedback{color:#3c763d}.has-warning .help-block,.has-warning .control-label,.has-warning .radio,.has-warning .checkbox,.has-warning .radio-inline,.has-warning .checkbox-inline,.has-warning.radio label,.has-warning.checkbox label,.has-warning.radio-inline label,.has-warning.checkbox-inline label{color:#8a6d3b}.has-warning .form-control{border-color:#8a6d3b;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.has-warning .form-control:focus{border-color:#66512c;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #c0a16b;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #c0a16b}.has-warning .input-group-addon{color:#8a6d3b;border-color:#8a6d3b;background-color:#fcf8e3}.has-warning .form-control-feedback{color:#8a6d3b}.has-error .help-block,.has-error .control-label,.has-error .radio,.has-error .checkbox,.has-error .radio-inline,.has-error .checkbox-inline,.has-error.radio label,.has-error.checkbox label,.has-error.radio-inline label,.has-error.checkbox-inline label{color:#a94442}.has-error .form-control{border-color:#a94442;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.has-error .form-control:focus{border-color:#843534;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #ce8483;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #ce8483}.has-error .input-group-addon{color:#a94442;border-color:#a94442;background-color:#f2dede}.has-error .form-control-feedback{color:#a94442}.has-feedback label~.form-control-feedback{top:25px}.has-feedback label.sr-only~.form-control-feedback{top:0}.help-block{display:block;margin-top:5px;margin-bottom:10px;color:#737373}@media (min-width:768px){.form-inline .form-group{display:inline-block;margin-bottom:0;vertical-align:middle}.form-inline .form-control{display:inline-block;width:auto;vertical-align:middle}.form-inline .form-control-static{display:inline-block}.form-inline .input-group{display:inline-table;vertical-align:middle}.form-inline .input-group .input-group-addon,.form-inline .input-group .input-group-btn,.form-inline .input-group .form-control{width:auto}.form-inline .input-group>.form-control{width:100%}.form-inline .control-label{margin-bottom:0;vertical-align:middle}.form-inline .radio,.form-inline .checkbox{display:inline-block;margin-top:0;margin-bottom:0;vertical-align:middle}.form-inline .radio label,.form-inline .checkbox label{padding-left:0}.form-inline .radio input[type="radio"],.form-inline .checkbox input[type="checkbox"]{position:relative;margin-left:0}.form-inline .has-feedback .form-control-feedback{top:0}}.form-horizontal .radio,.form-horizontal .checkbox,.form-horizontal .radio-inline,.form-horizontal .checkbox-inline{margin-top:0;margin-bottom:0;padding-top:7px}.form-horizontal .radio,.form-horizontal .checkbox{min-height:27px}.form-horizontal .form-group{margin-left:-15px;margin-right:-15px}@media (min-width:768px){.form-horizontal .control-label{text-align:right;margin-bottom:0;padding-top:7px}}.form-horizontal .has-feedback .form-control-feedback{right:15px}@media (min-width:768px){.form-horizontal .form-group-lg .control-label{padding-top:11px;font-size:18px}}@media (min-width:768px){.form-horizontal .form-group-sm .control-label{padding-top:6px;font-size:12px}}.btn{display:inline-block;margin-bottom:0;font-weight:normal;text-align:center;vertical-align:middle;touch-action:manipulation;cursor:pointer;background-image:none;border:1px solid transparent;white-space:nowrap;padding:6px 12px;font-size:14px;line-height:1.42857143;border-radius:4px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.btn:focus,.btn:active:focus,.btn.active:focus,.btn.focus,.btn:active.focus,.btn.active.focus{outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn:hover,.btn:focus,.btn.focus{color:#333;text-decoration:none}.btn:active,.btn.active{outline:0;background-image:none;-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,0.125);box-shadow:inset 0 3px 5px rgba(0,0,0,0.125)}.btn.disabled,.btn[disabled],fieldset[disabled] .btn{cursor:not-allowed;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;box-shadow:none}a.btn.disabled,fieldset[disabled] a.btn{pointer-events:none}.btn-default{color:#333;background-color:#fff;border-color:#ccc}.btn-default:focus,.btn-default.focus{color:#333;background-color:#e6e6e6;border-color:#8c8c8c}.btn-default:hover{color:#333;background-color:#e6e6e6;border-color:#adadad}.btn-default:active,.btn-default.active,.open>.dropdown-toggle.btn-default{color:#333;background-color:#e6e6e6;border-color:#adadad}.btn-default:active:hover,.btn-default.active:hover,.open>.dropdown-toggle.btn-default:hover,.btn-default:active:focus,.btn-default.active:focus,.open>.dropdown-toggle.btn-default:focus,.btn-default:active.focus,.btn-default.active.focus,.open>.dropdown-toggle.btn-default.focus{color:#333;background-color:#d4d4d4;border-color:#8c8c8c}.btn-default:active,.btn-default.active,.open>.dropdown-toggle.btn-default{background-image:none}.btn-default.disabled:hover,.btn-default[disabled]:hover,fieldset[disabled] .btn-default:hover,.btn-default.disabled:focus,.btn-default[disabled]:focus,fieldset[disabled] .btn-default:focus,.btn-default.disabled.focus,.btn-default[disabled].focus,fieldset[disabled] .btn-default.focus{background-color:#fff;border-color:#ccc}.btn-default .badge{color:#fff;background-color:#333}.btn-primary{color:#fff;background-color:#337ab7;border-color:#2e6da4}.btn-primary:focus,.btn-primary.focus{color:#fff;background-color:#286090;border-color:#122b40}.btn-primary:hover{color:#fff;background-color:#286090;border-color:#204d74}.btn-primary:active,.btn-primary.active,.open>.dropdown-toggle.btn-primary{color:#fff;background-color:#286090;border-color:#204d74}.btn-primary:active:hover,.btn-primary.active:hover,.open>.dropdown-toggle.btn-primary:hover,.btn-primary:active:focus,.btn-primary.active:focus,.open>.dropdown-toggle.btn-primary:focus,.btn-primary:active.focus,.btn-primary.active.focus,.open>.dropdown-toggle.btn-primary.focus{color:#fff;background-color:#204d74;border-color:#122b40}.btn-primary:active,.btn-primary.active,.open>.dropdown-toggle.btn-primary{background-image:none}.btn-primary.disabled:hover,.btn-primary[disabled]:hover,fieldset[disabled] .btn-primary:hover,.btn-primary.disabled:focus,.btn-primary[disabled]:focus,fieldset[disabled] .btn-primary:focus,.btn-primary.disabled.focus,.btn-primary[disabled].focus,fieldset[disabled] .btn-primary.focus{background-color:#337ab7;border-color:#2e6da4}.btn-primary .badge{color:#337ab7;background-color:#fff}.btn-success{color:#fff;background-color:#5cb85c;border-color:#4cae4c}.btn-success:focus,.btn-success.focus{color:#fff;background-color:#449d44;border-color:#255625}.btn-success:hover{color:#fff;background-color:#449d44;border-color:#398439}.btn-success:active,.btn-success.active,.open>.dropdown-toggle.btn-success{color:#fff;background-color:#449d44;border-color:#398439}.btn-success:active:hover,.btn-success.active:hover,.open>.dropdown-toggle.btn-success:hover,.btn-success:active:focus,.btn-success.active:focus,.open>.dropdown-toggle.btn-success:focus,.btn-success:active.focus,.btn-success.active.focus,.open>.dropdown-toggle.btn-success.focus{color:#fff;background-color:#398439;border-color:#255625}.btn-success:active,.btn-success.active,.open>.dropdown-toggle.btn-success{background-image:none}.btn-success.disabled:hover,.btn-success[disabled]:hover,fieldset[disabled] .btn-success:hover,.btn-success.disabled:focus,.btn-success[disabled]:focus,fieldset[disabled] .btn-success:focus,.btn-success.disabled.focus,.btn-success[disabled].focus,fieldset[disabled] .btn-success.focus{background-color:#5cb85c;border-color:#4cae4c}.btn-success .badge{color:#5cb85c;background-color:#fff}.btn-info{color:#fff;background-color:#5bc0de;border-color:#46b8da}.btn-info:focus,.btn-info.focus{color:#fff;background-color:#31b0d5;border-color:#1b6d85}.btn-info:hover{color:#fff;background-color:#31b0d5;border-color:#269abc}.btn-info:active,.btn-info.active,.open>.dropdown-toggle.btn-info{color:#fff;background-color:#31b0d5;border-color:#269abc}.btn-info:active:hover,.btn-info.active:hover,.open>.dropdown-toggle.btn-info:hover,.btn-info:active:focus,.btn-info.active:focus,.open>.dropdown-toggle.btn-info:focus,.btn-info:active.focus,.btn-info.active.focus,.open>.dropdown-toggle.btn-info.focus{color:#fff;background-color:#269abc;border-color:#1b6d85}.btn-info:active,.btn-info.active,.open>.dropdown-toggle.btn-info{background-image:none}.btn-info.disabled:hover,.btn-info[disabled]:hover,fieldset[disabled] .btn-info:hover,.btn-info.disabled:focus,.btn-info[disabled]:focus,fieldset[disabled] .btn-info:focus,.btn-info.disabled.focus,.btn-info[disabled].focus,fieldset[disabled] .btn-info.focus{background-color:#5bc0de;border-color:#46b8da}.btn-info .badge{color:#5bc0de;background-color:#fff}.btn-warning{color:#fff;background-color:#f0ad4e;border-color:#eea236}.btn-warning:focus,.btn-warning.focus{color:#fff;background-color:#ec971f;border-color:#985f0d}.btn-warning:hover{color:#fff;background-color:#ec971f;border-color:#d58512}.btn-warning:active,.btn-warning.active,.open>.dropdown-toggle.btn-warning{color:#fff;background-color:#ec971f;border-color:#d58512}.btn-warning:active:hover,.btn-warning.active:hover,.open>.dropdown-toggle.btn-warning:hover,.btn-warning:active:focus,.btn-warning.active:focus,.open>.dropdown-toggle.btn-warning:focus,.btn-warning:active.focus,.btn-warning.active.focus,.open>.dropdown-toggle.btn-warning.focus{color:#fff;background-color:#d58512;border-color:#985f0d}.btn-warning:active,.btn-warning.active,.open>.dropdown-toggle.btn-warning{background-image:none}.btn-warning.disabled:hover,.btn-warning[disabled]:hover,fieldset[disabled] .btn-warning:hover,.btn-warning.disabled:focus,.btn-warning[disabled]:focus,fieldset[disabled] .btn-warning:focus,.btn-warning.disabled.focus,.btn-warning[disabled].focus,fieldset[disabled] .btn-warning.focus{background-color:#f0ad4e;border-color:#eea236}.btn-warning .badge{color:#f0ad4e;background-color:#fff}.btn-danger{color:#fff;background-color:#d9534f;border-color:#d43f3a}.btn-danger:focus,.btn-danger.focus{color:#fff;background-color:#c9302c;border-color:#761c19}.btn-danger:hover{color:#fff;background-color:#c9302c;border-color:#ac2925}.btn-danger:active,.btn-danger.active,.open>.dropdown-toggle.btn-danger{color:#fff;background-color:#c9302c;border-color:#ac2925}.btn-danger:active:hover,.btn-danger.active:hover,.open>.dropdown-toggle.btn-danger:hover,.btn-danger:active:focus,.btn-danger.active:focus,.open>.dropdown-toggle.btn-danger:focus,.btn-danger:active.focus,.btn-danger.active.focus,.open>.dropdown-toggle.btn-danger.focus{color:#fff;background-color:#ac2925;border-color:#761c19}.btn-danger:active,.btn-danger.active,.open>.dropdown-toggle.btn-danger{background-image:none}.btn-danger.disabled:hover,.btn-danger[disabled]:hover,fieldset[disabled] .btn-danger:hover,.btn-danger.disabled:focus,.btn-danger[disabled]:focus,fieldset[disabled] .btn-danger:focus,.btn-danger.disabled.focus,.btn-danger[disabled].focus,fieldset[disabled] .btn-danger.focus{background-color:#d9534f;border-color:#d43f3a}.btn-danger .badge{color:#d9534f;background-color:#fff}.btn-link{color:#337ab7;font-weight:normal;border-radius:0}.btn-link,.btn-link:active,.btn-link.active,.btn-link[disabled],fieldset[disabled] .btn-link{background-color:transparent;-webkit-box-shadow:none;box-shadow:none}.btn-link,.btn-link:hover,.btn-link:focus,.btn-link:active{border-color:transparent}.btn-link:hover,.btn-link:focus{color:#23527c;text-decoration:underline;background-color:transparent}.btn-link[disabled]:hover,fieldset[disabled] .btn-link:hover,.btn-link[disabled]:focus,fieldset[disabled] .btn-link:focus{color:#777;text-decoration:none}.btn-lg,.btn-group-lg>.btn{padding:10px 16px;font-size:18px;line-height:1.3333333;border-radius:6px}.btn-sm,.btn-group-sm>.btn{padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}.btn-xs,.btn-group-xs>.btn{padding:1px 5px;font-size:12px;line-height:1.5;border-radius:3px}.btn-block{display:block;width:100%}.btn-block+.btn-block{margin-top:5px}input[type="submit"].btn-block,input[type="reset"].btn-block,input[type="button"].btn-block{width:100%}.fade{opacity:0;-webkit-transition:opacity .15s linear;-o-transition:opacity .15s linear;transition:opacity .15s linear}.fade.in{opacity:1}.collapse{display:none}.collapse.in{display:block}tr.collapse.in{display:table-row}tbody.collapse.in{display:table-row-group}.collapsing{position:relative;height:0;overflow:hidden;-webkit-transition-property:height, visibility;transition-property:height, visibility;-webkit-transition-duration:.35s;transition-duration:.35s;-webkit-transition-timing-function:ease;transition-timing-function:ease}.caret{display:inline-block;width:0;height:0;margin-left:2px;vertical-align:middle;border-top:4px dashed;border-top:4px solid \9;border-right:4px solid transparent;border-left:4px solid transparent}.dropup,.dropdown{position:relative}.dropdown-toggle:focus{outline:0}.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:160px;padding:5px 0;margin:2px 0 0;list-style:none;font-size:14px;text-align:left;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.15);border-radius:4px;-webkit-box-shadow:0 6px 12px rgba(0,0,0,0.175);box-shadow:0 6px 12px rgba(0,0,0,0.175);background-clip:padding-box}.dropdown-menu.pull-right{right:0;left:auto}.dropdown-menu .divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}.dropdown-menu>li>a{display:block;padding:3px 20px;clear:both;font-weight:normal;line-height:1.42857143;color:#333;white-space:nowrap}.dropdown-menu>li>a:hover,.dropdown-menu>li>a:focus{text-decoration:none;color:#262626;background-color:#f5f5f5}.dropdown-menu>.active>a,.dropdown-menu>.active>a:hover,.dropdown-menu>.active>a:focus{color:#fff;text-decoration:none;outline:0;background-color:#337ab7}.dropdown-menu>.disabled>a,.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{color:#777}.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{text-decoration:none;background-color:transparent;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);cursor:not-allowed}.open>.dropdown-menu{display:block}.open>a{outline:0}.dropdown-menu-right{left:auto;right:0}.dropdown-menu-left{left:0;right:auto}.dropdown-header{display:block;padding:3px 20px;font-size:12px;line-height:1.42857143;color:#777;white-space:nowrap}.dropdown-backdrop{position:fixed;left:0;right:0;bottom:0;top:0;z-index:990}.pull-right>.dropdown-menu{right:0;left:auto}.dropup .caret,.navbar-fixed-bottom .dropdown .caret{border-top:0;border-bottom:4px dashed;border-bottom:4px solid \9;content:""}.dropup .dropdown-menu,.navbar-fixed-bottom .dropdown .dropdown-menu{top:auto;bottom:100%;margin-bottom:2px}@media (min-width:768px){.navbar-right .dropdown-menu{left:auto;right:0}.navbar-right .dropdown-menu-left{left:0;right:auto}}.btn-group,.btn-group-vertical{position:relative;display:inline-block;vertical-align:middle}.btn-group>.btn,.btn-group-vertical>.btn{position:relative;float:left}.btn-group>.btn:hover,.btn-group-vertical>.btn:hover,.btn-group>.btn:focus,.btn-group-vertical>.btn:focus,.btn-group>.btn:active,.btn-group-vertical>.btn:active,.btn-group>.btn.active,.btn-group-vertical>.btn.active{z-index:2}.btn-group .btn+.btn,.btn-group .btn+.btn-group,.btn-group .btn-group+.btn,.btn-group .btn-group+.btn-group{margin-left:-1px}.btn-toolbar{margin-left:-5px}.btn-toolbar .btn,.btn-toolbar .btn-group,.btn-toolbar .input-group{float:left}.btn-toolbar>.btn,.btn-toolbar>.btn-group,.btn-toolbar>.input-group{margin-left:5px}.btn-group>.btn:not(:first-child):not(:last-child):not(.dropdown-toggle){border-radius:0}.btn-group>.btn:first-child{margin-left:0}.btn-group>.btn:first-child:not(:last-child):not(.dropdown-toggle){border-bottom-right-radius:0;border-top-right-radius:0}.btn-group>.btn:last-child:not(:first-child),.btn-group>.dropdown-toggle:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0}.btn-group>.btn-group{float:left}.btn-group>.btn-group:not(:first-child):not(:last-child)>.btn{border-radius:0}.btn-group>.btn-group:first-child:not(:last-child)>.btn:last-child,.btn-group>.btn-group:first-child:not(:last-child)>.dropdown-toggle{border-bottom-right-radius:0;border-top-right-radius:0}.btn-group>.btn-group:last-child:not(:first-child)>.btn:first-child{border-bottom-left-radius:0;border-top-left-radius:0}.btn-group .dropdown-toggle:active,.btn-group.open .dropdown-toggle{outline:0}.btn-group>.btn+.dropdown-toggle{padding-left:8px;padding-right:8px}.btn-group>.btn-lg+.dropdown-toggle{padding-left:12px;padding-right:12px}.btn-group.open .dropdown-toggle{-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,0.125);box-shadow:inset 0 3px 5px rgba(0,0,0,0.125)}.btn-group.open .dropdown-toggle.btn-link{-webkit-box-shadow:none;box-shadow:none}.btn .caret{margin-left:0}.btn-lg .caret{border-width:5px 5px 0;border-bottom-width:0}.dropup .btn-lg .caret{border-width:0 5px 5px}.btn-group-vertical>.btn,.btn-group-vertical>.btn-group,.btn-group-vertical>.btn-group>.btn{display:block;float:none;width:100%;max-width:100%}.btn-group-vertical>.btn-group>.btn{float:none}.btn-group-vertical>.btn+.btn,.btn-group-vertical>.btn+.btn-group,.btn-group-vertical>.btn-group+.btn,.btn-group-vertical>.btn-group+.btn-group{margin-top:-1px;margin-left:0}.btn-group-vertical>.btn:not(:first-child):not(:last-child){border-radius:0}.btn-group-vertical>.btn:first-child:not(:last-child){border-top-right-radius:4px;border-top-left-radius:4px;border-bottom-right-radius:0;border-bottom-left-radius:0}.btn-group-vertical>.btn:last-child:not(:first-child){border-top-right-radius:0;border-top-left-radius:0;border-bottom-right-radius:4px;border-bottom-left-radius:4px}.btn-group-vertical>.btn-group:not(:first-child):not(:last-child)>.btn{border-radius:0}.btn-group-vertical>.btn-group:first-child:not(:last-child)>.btn:last-child,.btn-group-vertical>.btn-group:first-child:not(:last-child)>.dropdown-toggle{border-bottom-right-radius:0;border-bottom-left-radius:0}.btn-group-vertical>.btn-group:last-child:not(:first-child)>.btn:first-child{border-top-right-radius:0;border-top-left-radius:0}.btn-group-justified{display:table;width:100%;table-layout:fixed;border-collapse:separate}.btn-group-justified>.btn,.btn-group-justified>.btn-group{float:none;display:table-cell;width:1%}.btn-group-justified>.btn-group .btn{width:100%}.btn-group-justified>.btn-group .dropdown-menu{left:auto}[data-toggle="buttons"]>.btn input[type="radio"],[data-toggle="buttons"]>.btn-group>.btn input[type="radio"],[data-toggle="buttons"]>.btn input[type="checkbox"],[data-toggle="buttons"]>.btn-group>.btn input[type="checkbox"]{position:absolute;clip:rect(0, 0, 0, 0);pointer-events:none}.input-group{position:relative;display:table;border-collapse:separate}.input-group[class*="col-"]{float:none;padding-left:0;padding-right:0}.input-group .form-control{position:relative;z-index:2;float:left;width:100%;margin-bottom:0}.input-group .form-control:focus{z-index:3}.input-group-lg>.form-control,.input-group-lg>.input-group-addon,.input-group-lg>.input-group-btn>.btn{height:46px;padding:10px 16px;font-size:18px;line-height:1.3333333;border-radius:6px}select.input-group-lg>.form-control,select.input-group-lg>.input-group-addon,select.input-group-lg>.input-group-btn>.btn{height:46px;line-height:46px}textarea.input-group-lg>.form-control,textarea.input-group-lg>.input-group-addon,textarea.input-group-lg>.input-group-btn>.btn,select[multiple].input-group-lg>.form-control,select[multiple].input-group-lg>.input-group-addon,select[multiple].input-group-lg>.input-group-btn>.btn{height:auto}.input-group-sm>.form-control,.input-group-sm>.input-group-addon,.input-group-sm>.input-group-btn>.btn{height:30px;padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}select.input-group-sm>.form-control,select.input-group-sm>.input-group-addon,select.input-group-sm>.input-group-btn>.btn{height:30px;line-height:30px}textarea.input-group-sm>.form-control,textarea.input-group-sm>.input-group-addon,textarea.input-group-sm>.input-group-btn>.btn,select[multiple].input-group-sm>.form-control,select[multiple].input-group-sm>.input-group-addon,select[multiple].input-group-sm>.input-group-btn>.btn{height:auto}.input-group-addon,.input-group-btn,.input-group .form-control{display:table-cell}.input-group-addon:not(:first-child):not(:last-child),.input-group-btn:not(:first-child):not(:last-child),.input-group .form-control:not(:first-child):not(:last-child){border-radius:0}.input-group-addon,.input-group-btn{width:1%;white-space:nowrap;vertical-align:middle}.input-group-addon{padding:6px 12px;font-size:14px;font-weight:normal;line-height:1;color:#555;text-align:center;background-color:#eee;border:1px solid #ccc;border-radius:4px}.input-group-addon.input-sm{padding:5px 10px;font-size:12px;border-radius:3px}.input-group-addon.input-lg{padding:10px 16px;font-size:18px;border-radius:6px}.input-group-addon input[type="radio"],.input-group-addon input[type="checkbox"]{margin-top:0}.input-group .form-control:first-child,.input-group-addon:first-child,.input-group-btn:first-child>.btn,.input-group-btn:first-child>.btn-group>.btn,.input-group-btn:first-child>.dropdown-toggle,.input-group-btn:last-child>.btn:not(:last-child):not(.dropdown-toggle),.input-group-btn:last-child>.btn-group:not(:last-child)>.btn{border-bottom-right-radius:0;border-top-right-radius:0}.input-group-addon:first-child{border-right:0}.input-group .form-control:last-child,.input-group-addon:last-child,.input-group-btn:last-child>.btn,.input-group-btn:last-child>.btn-group>.btn,.input-group-btn:last-child>.dropdown-toggle,.input-group-btn:first-child>.btn:not(:first-child),.input-group-btn:first-child>.btn-group:not(:first-child)>.btn{border-bottom-left-radius:0;border-top-left-radius:0}.input-group-addon:last-child{border-left:0}.input-group-btn{position:relative;font-size:0;white-space:nowrap}.input-group-btn>.btn{position:relative}.input-group-btn>.btn+.btn{margin-left:-1px}.input-group-btn>.btn:hover,.input-group-btn>.btn:focus,.input-group-btn>.btn:active{z-index:2}.input-group-btn:first-child>.btn,.input-group-btn:first-child>.btn-group{margin-right:-1px}.input-group-btn:last-child>.btn,.input-group-btn:last-child>.btn-group{z-index:2;margin-left:-1px}.nav{margin-bottom:0;padding-left:0;list-style:none}.nav>li{position:relative;display:block}.nav>li>a{position:relative;display:block;padding:10px 15px}.nav>li>a:hover,.nav>li>a:focus{text-decoration:none;background-color:#eee}.nav>li.disabled>a{color:#777}.nav>li.disabled>a:hover,.nav>li.disabled>a:focus{color:#777;text-decoration:none;background-color:transparent;cursor:not-allowed}.nav .open>a,.nav .open>a:hover,.nav .open>a:focus{background-color:#eee;border-color:#337ab7}.nav .nav-divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}.nav>li>a>img{max-width:none}.nav-tabs{border-bottom:1px solid #ddd}.nav-tabs>li{float:left;margin-bottom:-1px}.nav-tabs>li>a{margin-right:2px;line-height:1.42857143;border:1px solid transparent;border-radius:4px 4px 0 0}.nav-tabs>li>a:hover{border-color:#eee #eee #ddd}.nav-tabs>li.active>a,.nav-tabs>li.active>a:hover,.nav-tabs>li.active>a:focus{color:#555;background-color:#fff;border:1px solid #ddd;border-bottom-color:transparent;cursor:default}.nav-tabs.nav-justified{width:100%;border-bottom:0}.nav-tabs.nav-justified>li{float:none}.nav-tabs.nav-justified>li>a{text-align:center;margin-bottom:5px}.nav-tabs.nav-justified>.dropdown .dropdown-menu{top:auto;left:auto}@media (min-width:768px){.nav-tabs.nav-justified>li{display:table-cell;width:1%}.nav-tabs.nav-justified>li>a{margin-bottom:0}}.nav-tabs.nav-justified>li>a{margin-right:0;border-radius:4px}.nav-tabs.nav-justified>.active>a,.nav-tabs.nav-justified>.active>a:hover,.nav-tabs.nav-justified>.active>a:focus{border:1px solid #ddd}@media (min-width:768px){.nav-tabs.nav-justified>li>a{border-bottom:1px solid #ddd;border-radius:4px 4px 0 0}.nav-tabs.nav-justified>.active>a,.nav-tabs.nav-justified>.active>a:hover,.nav-tabs.nav-justified>.active>a:focus{border-bottom-color:#fff}}.nav-pills>li{float:left}.nav-pills>li>a{border-radius:4px}.nav-pills>li+li{margin-left:2px}.nav-pills>li.active>a,.nav-pills>li.active>a:hover,.nav-pills>li.active>a:focus{color:#fff;background-color:#337ab7}.nav-stacked>li{float:none}.nav-stacked>li+li{margin-top:2px;margin-left:0}.nav-justified{width:100%}.nav-justified>li{float:none}.nav-justified>li>a{text-align:center;margin-bottom:5px}.nav-justified>.dropdown .dropdown-menu{top:auto;left:auto}@media (min-width:768px){.nav-justified>li{display:table-cell;width:1%}.nav-justified>li>a{margin-bottom:0}}.nav-tabs-justified{border-bottom:0}.nav-tabs-justified>li>a{margin-right:0;border-radius:4px}.nav-tabs-justified>.active>a,.nav-tabs-justified>.active>a:hover,.nav-tabs-justified>.active>a:focus{border:1px solid #ddd}@media (min-width:768px){.nav-tabs-justified>li>a{border-bottom:1px solid #ddd;border-radius:4px 4px 0 0}.nav-tabs-justified>.active>a,.nav-tabs-justified>.active>a:hover,.nav-tabs-justified>.active>a:focus{border-bottom-color:#fff}}.tab-content>.tab-pane{display:none}.tab-content>.active{display:block}.nav-tabs .dropdown-menu{margin-top:-1px;border-top-right-radius:0;border-top-left-radius:0}.navbar{position:relative;min-height:50px;margin-bottom:20px;border:1px solid transparent}@media (min-width:768px){.navbar{border-radius:4px}}@media (min-width:768px){.navbar-header{float:left}}.navbar-collapse{overflow-x:visible;padding-right:15px;padding-left:15px;border-top:1px solid transparent;box-shadow:inset 0 1px 0 rgba(255,255,255,0.1);-webkit-overflow-scrolling:touch}.navbar-collapse.in{overflow-y:auto}@media (min-width:768px){.navbar-collapse{width:auto;border-top:0;box-shadow:none}.navbar-collapse.collapse{display:block !important;height:auto !important;padding-bottom:0;overflow:visible !important}.navbar-collapse.in{overflow-y:visible}.navbar-fixed-top .navbar-collapse,.navbar-static-top .navbar-collapse,.navbar-fixed-bottom .navbar-collapse{padding-left:0;padding-right:0}}.navbar-fixed-top .navbar-collapse,.navbar-fixed-bottom .navbar-collapse{max-height:340px}@media (max-device-width:480px) and (orientation:landscape){.navbar-fixed-top .navbar-collapse,.navbar-fixed-bottom .navbar-collapse{max-height:200px}}.container>.navbar-header,.container-fluid>.navbar-header,.container>.navbar-collapse,.container-fluid>.navbar-collapse{margin-right:-15px;margin-left:-15px}@media (min-width:768px){.container>.navbar-header,.container-fluid>.navbar-header,.container>.navbar-collapse,.container-fluid>.navbar-collapse{margin-right:0;margin-left:0}}.navbar-static-top{z-index:1000;border-width:0 0 1px}@media (min-width:768px){.navbar-static-top{border-radius:0}}.navbar-fixed-top,.navbar-fixed-bottom{position:fixed;right:0;left:0;z-index:1030}@media (min-width:768px){.navbar-fixed-top,.navbar-fixed-bottom{border-radius:0}}.navbar-fixed-top{top:0;border-width:0 0 1px}.navbar-fixed-bottom{bottom:0;margin-bottom:0;border-width:1px 0 0}.navbar-brand{float:left;padding:15px 15px;font-size:18px;line-height:20px;height:50px}.navbar-brand:hover,.navbar-brand:focus{text-decoration:none}.navbar-brand>img{display:block}@media (min-width:768px){.navbar>.container .navbar-brand,.navbar>.container-fluid .navbar-brand{margin-left:-15px}}.navbar-toggle{position:relative;float:right;margin-right:15px;padding:9px 10px;margin-top:8px;margin-bottom:8px;background-color:transparent;background-image:none;border:1px solid transparent;border-radius:4px}.navbar-toggle:focus{outline:0}.navbar-toggle .icon-bar{display:block;width:22px;height:2px;border-radius:1px}.navbar-toggle .icon-bar+.icon-bar{margin-top:4px}@media (min-width:768px){.navbar-toggle{display:none}}.navbar-nav{margin:7.5px -15px}.navbar-nav>li>a{padding-top:10px;padding-bottom:10px;line-height:20px}@media (max-width:767px){.navbar-nav .open .dropdown-menu{position:static;float:none;width:auto;margin-top:0;background-color:transparent;border:0;box-shadow:none}.navbar-nav .open .dropdown-menu>li>a,.navbar-nav .open .dropdown-menu .dropdown-header{padding:5px 15px 5px 25px}.navbar-nav .open .dropdown-menu>li>a{line-height:20px}.navbar-nav .open .dropdown-menu>li>a:hover,.navbar-nav .open .dropdown-menu>li>a:focus{background-image:none}}@media (min-width:768px){.navbar-nav{float:left;margin:0}.navbar-nav>li{float:left}.navbar-nav>li>a{padding-top:15px;padding-bottom:15px}}.navbar-form{margin-left:-15px;margin-right:-15px;padding:10px 15px;border-top:1px solid transparent;border-bottom:1px solid transparent;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1);box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1);margin-top:8px;margin-bottom:8px}@media (min-width:768px){.navbar-form .form-group{display:inline-block;margin-bottom:0;vertical-align:middle}.navbar-form .form-control{display:inline-block;width:auto;vertical-align:middle}.navbar-form .form-control-static{display:inline-block}.navbar-form .input-group{display:inline-table;vertical-align:middle}.navbar-form .input-group .input-group-addon,.navbar-form .input-group .input-group-btn,.navbar-form .input-group .form-control{width:auto}.navbar-form .input-group>.form-control{width:100%}.navbar-form .control-label{margin-bottom:0;vertical-align:middle}.navbar-form .radio,.navbar-form .checkbox{display:inline-block;margin-top:0;margin-bottom:0;vertical-align:middle}.navbar-form .radio label,.navbar-form .checkbox label{padding-left:0}.navbar-form .radio input[type="radio"],.navbar-form .checkbox input[type="checkbox"]{position:relative;margin-left:0}.navbar-form .has-feedback .form-control-feedback{top:0}}@media (max-width:767px){.navbar-form .form-group{margin-bottom:5px}.navbar-form .form-group:last-child{margin-bottom:0}}@media (min-width:768px){.navbar-form{width:auto;border:0;margin-left:0;margin-right:0;padding-top:0;padding-bottom:0;-webkit-box-shadow:none;box-shadow:none}}.navbar-nav>li>.dropdown-menu{margin-top:0;border-top-right-radius:0;border-top-left-radius:0}.navbar-fixed-bottom .navbar-nav>li>.dropdown-menu{margin-bottom:0;border-top-right-radius:4px;border-top-left-radius:4px;border-bottom-right-radius:0;border-bottom-left-radius:0}.navbar-btn{margin-top:8px;margin-bottom:8px}.navbar-btn.btn-sm{margin-top:10px;margin-bottom:10px}.navbar-btn.btn-xs{margin-top:14px;margin-bottom:14px}.navbar-text{margin-top:15px;margin-bottom:15px}@media (min-width:768px){.navbar-text{float:left;margin-left:15px;margin-right:15px}}@media (min-width:768px){.navbar-left{float:left !important}.navbar-right{float:right !important;margin-right:-15px}.navbar-right~.navbar-right{margin-right:0}}.navbar-default{background-color:#f8f8f8;border-color:#e7e7e7}.navbar-default .navbar-brand{color:#777}.navbar-default .navbar-brand:hover,.navbar-default .navbar-brand:focus{color:#5e5e5e;background-color:transparent}.navbar-default .navbar-text{color:#777}.navbar-default .navbar-nav>li>a{color:#777}.navbar-default .navbar-nav>li>a:hover,.navbar-default .navbar-nav>li>a:focus{color:#333;background-color:transparent}.navbar-default .navbar-nav>.active>a,.navbar-default .navbar-nav>.active>a:hover,.navbar-default .navbar-nav>.active>a:focus{color:#555;background-color:#e7e7e7}.navbar-default .navbar-nav>.disabled>a,.navbar-default .navbar-nav>.disabled>a:hover,.navbar-default .navbar-nav>.disabled>a:focus{color:#ccc;background-color:transparent}.navbar-default .navbar-toggle{border-color:#ddd}.navbar-default .navbar-toggle:hover,.navbar-default .navbar-toggle:focus{background-color:#ddd}.navbar-default .navbar-toggle .icon-bar{background-color:#888}.navbar-default .navbar-collapse,.navbar-default .navbar-form{border-color:#e7e7e7}.navbar-default .navbar-nav>.open>a,.navbar-default .navbar-nav>.open>a:hover,.navbar-default .navbar-nav>.open>a:focus{background-color:#e7e7e7;color:#555}@media (max-width:767px){.navbar-default .navbar-nav .open .dropdown-menu>li>a{color:#777}.navbar-default .navbar-nav .open .dropdown-menu>li>a:hover,.navbar-default .navbar-nav .open .dropdown-menu>li>a:focus{color:#333;background-color:transparent}.navbar-default .navbar-nav .open .dropdown-menu>.active>a,.navbar-default .navbar-nav .open .dropdown-menu>.active>a:hover,.navbar-default .navbar-nav .open .dropdown-menu>.active>a:focus{color:#555;background-color:#e7e7e7}.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a,.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a:hover,.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a:focus{color:#ccc;background-color:transparent}}.navbar-default .navbar-link{color:#777}.navbar-default .navbar-link:hover{color:#333}.navbar-default .btn-link{color:#777}.navbar-default .btn-link:hover,.navbar-default .btn-link:focus{color:#333}.navbar-default .btn-link[disabled]:hover,fieldset[disabled] .navbar-default .btn-link:hover,.navbar-default .btn-link[disabled]:focus,fieldset[disabled] .navbar-default .btn-link:focus{color:#ccc}.navbar-inverse{background-color:#222;border-color:#080808}.navbar-inverse .navbar-brand{color:#9d9d9d}.navbar-inverse .navbar-brand:hover,.navbar-inverse .navbar-brand:focus{color:#fff;background-color:transparent}.navbar-inverse .navbar-text{color:#9d9d9d}.navbar-inverse .navbar-nav>li>a{color:#9d9d9d}.navbar-inverse .navbar-nav>li>a:hover,.navbar-inverse .navbar-nav>li>a:focus{color:#fff;background-color:transparent}.navbar-inverse .navbar-nav>.active>a,.navbar-inverse .navbar-nav>.active>a:hover,.navbar-inverse .navbar-nav>.active>a:focus{color:#fff;background-color:#080808}.navbar-inverse .navbar-nav>.disabled>a,.navbar-inverse .navbar-nav>.disabled>a:hover,.navbar-inverse .navbar-nav>.disabled>a:focus{color:#444;background-color:transparent}.navbar-inverse .navbar-toggle{border-color:#333}.navbar-inverse .navbar-toggle:hover,.navbar-inverse .navbar-toggle:focus{background-color:#333}.navbar-inverse .navbar-toggle .icon-bar{background-color:#fff}.navbar-inverse .navbar-collapse,.navbar-inverse .navbar-form{border-color:#101010}.navbar-inverse .navbar-nav>.open>a,.navbar-inverse .navbar-nav>.open>a:hover,.navbar-inverse .navbar-nav>.open>a:focus{background-color:#080808;color:#fff}@media (max-width:767px){.navbar-inverse .navbar-nav .open .dropdown-menu>.dropdown-header{border-color:#080808}.navbar-inverse .navbar-nav .open .dropdown-menu .divider{background-color:#080808}.navbar-inverse .navbar-nav .open .dropdown-menu>li>a{color:#9d9d9d}.navbar-inverse .navbar-nav .open .dropdown-menu>li>a:hover,.navbar-inverse .navbar-nav .open .dropdown-menu>li>a:focus{color:#fff;background-color:transparent}.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a,.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a:hover,.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a:focus{color:#fff;background-color:#080808}.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a,.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a:hover,.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a:focus{color:#444;background-color:transparent}}.navbar-inverse .navbar-link{color:#9d9d9d}.navbar-inverse .navbar-link:hover{color:#fff}.navbar-inverse .btn-link{color:#9d9d9d}.navbar-inverse .btn-link:hover,.navbar-inverse .btn-link:focus{color:#fff}.navbar-inverse .btn-link[disabled]:hover,fieldset[disabled] .navbar-inverse .btn-link:hover,.navbar-inverse .btn-link[disabled]:focus,fieldset[disabled] .navbar-inverse .btn-link:focus{color:#444}.breadcrumb{padding:8px 15px;margin-bottom:20px;list-style:none;background-color:#f5f5f5;border-radius:4px}.breadcrumb>li{display:inline-block}.breadcrumb>li+li:before{content:"/\00a0";padding:0 5px;color:#ccc}.breadcrumb>.active{color:#777}.pagination{display:inline-block;padding-left:0;margin:20px 0;border-radius:4px}.pagination>li{display:inline}.pagination>li>a,.pagination>li>span{position:relative;float:left;padding:6px 12px;line-height:1.42857143;text-decoration:none;color:#337ab7;background-color:#fff;border:1px solid #ddd;margin-left:-1px}.pagination>li:first-child>a,.pagination>li:first-child>span{margin-left:0;border-bottom-left-radius:4px;border-top-left-radius:4px}.pagination>li:last-child>a,.pagination>li:last-child>span{border-bottom-right-radius:4px;border-top-right-radius:4px}.pagination>li>a:hover,.pagination>li>span:hover,.pagination>li>a:focus,.pagination>li>span:focus{z-index:2;color:#23527c;background-color:#eee;border-color:#ddd}.pagination>.active>a,.pagination>.active>span,.pagination>.active>a:hover,.pagination>.active>span:hover,.pagination>.active>a:focus,.pagination>.active>span:focus{z-index:3;color:#fff;background-color:#337ab7;border-color:#337ab7;cursor:default}.pagination>.disabled>span,.pagination>.disabled>span:hover,.pagination>.disabled>span:focus,.pagination>.disabled>a,.pagination>.disabled>a:hover,.pagination>.disabled>a:focus{color:#777;background-color:#fff;border-color:#ddd;cursor:not-allowed}.pagination-lg>li>a,.pagination-lg>li>span{padding:10px 16px;font-size:18px;line-height:1.3333333}.pagination-lg>li:first-child>a,.pagination-lg>li:first-child>span{border-bottom-left-radius:6px;border-top-left-radius:6px}.pagination-lg>li:last-child>a,.pagination-lg>li:last-child>span{border-bottom-right-radius:6px;border-top-right-radius:6px}.pagination-sm>li>a,.pagination-sm>li>span{padding:5px 10px;font-size:12px;line-height:1.5}.pagination-sm>li:first-child>a,.pagination-sm>li:first-child>span{border-bottom-left-radius:3px;border-top-left-radius:3px}.pagination-sm>li:last-child>a,.pagination-sm>li:last-child>span{border-bottom-right-radius:3px;border-top-right-radius:3px}.pager{padding-left:0;margin:20px 0;list-style:none;text-align:center}.pager li{display:inline}.pager li>a,.pager li>span{display:inline-block;padding:5px 14px;background-color:#fff;border:1px solid #ddd;border-radius:15px}.pager li>a:hover,.pager li>a:focus{text-decoration:none;background-color:#eee}.pager .next>a,.pager .next>span{float:right}.pager .previous>a,.pager .previous>span{float:left}.pager .disabled>a,.pager .disabled>a:hover,.pager .disabled>a:focus,.pager .disabled>span{color:#777;background-color:#fff;cursor:not-allowed}.label{display:inline;padding:.2em .6em .3em;font-size:75%;font-weight:bold;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;border-radius:.25em}a.label:hover,a.label:focus{color:#fff;text-decoration:none;cursor:pointer}.label:empty{display:none}.btn .label{position:relative;top:-1px}.label-default{background-color:#777}.label-default[href]:hover,.label-default[href]:focus{background-color:#5e5e5e}.label-primary{background-color:#337ab7}.label-primary[href]:hover,.label-primary[href]:focus{background-color:#286090}.label-success{background-color:#5cb85c}.label-success[href]:hover,.label-success[href]:focus{background-color:#449d44}.label-info{background-color:#5bc0de}.label-info[href]:hover,.label-info[href]:focus{background-color:#31b0d5}.label-warning{background-color:#f0ad4e}.label-warning[href]:hover,.label-warning[href]:focus{background-color:#ec971f}.label-danger{background-color:#d9534f}.label-danger[href]:hover,.label-danger[href]:focus{background-color:#c9302c}.badge{display:inline-block;min-width:10px;padding:3px 7px;font-size:12px;font-weight:bold;color:#fff;line-height:1;vertical-align:middle;white-space:nowrap;text-align:center;background-color:#777;border-radius:10px}.badge:empty{display:none}.btn .badge{position:relative;top:-1px}.btn-xs .badge,.btn-group-xs>.btn .badge{top:0;padding:1px 5px}a.badge:hover,a.badge:focus{color:#fff;text-decoration:none;cursor:pointer}.list-group-item.active>.badge,.nav-pills>.active>a>.badge{color:#337ab7;background-color:#fff}.list-group-item>.badge{float:right}.list-group-item>.badge+.badge{margin-right:5px}.nav-pills>li>a>.badge{margin-left:3px}.jumbotron{padding-top:30px;padding-bottom:30px;margin-bottom:30px;color:inherit;background-color:#eee}.jumbotron h1,.jumbotron .h1{color:inherit}.jumbotron p{margin-bottom:15px;font-size:21px;font-weight:200}.jumbotron>hr{border-top-color:#d5d5d5}.container .jumbotron,.container-fluid .jumbotron{border-radius:6px;padding-left:15px;padding-right:15px}.jumbotron .container{max-width:100%}@media screen and (min-width:768px){.jumbotron{padding-top:48px;padding-bottom:48px}.container .jumbotron,.container-fluid .jumbotron{padding-left:60px;padding-right:60px}.jumbotron h1,.jumbotron .h1{font-size:63px}}.thumbnail{display:block;padding:4px;margin-bottom:20px;line-height:1.42857143;background-color:#fff;border:1px solid #ddd;border-radius:4px;-webkit-transition:border .2s ease-in-out;-o-transition:border .2s ease-in-out;transition:border .2s ease-in-out}.thumbnail>img,.thumbnail a>img{margin-left:auto;margin-right:auto}a.thumbnail:hover,a.thumbnail:focus,a.thumbnail.active{border-color:#337ab7}.thumbnail .caption{padding:9px;color:#333}.alert{padding:15px;margin-bottom:20px;border:1px solid transparent;border-radius:4px}.alert h4{margin-top:0;color:inherit}.alert .alert-link{font-weight:bold}.alert>p,.alert>ul{margin-bottom:0}.alert>p+p{margin-top:5px}.alert-dismissable,.alert-dismissible{padding-right:35px}.alert-dismissable .close,.alert-dismissible .close{position:relative;top:-2px;right:-21px;color:inherit}.alert-success{background-color:#dff0d8;border-color:#d6e9c6;color:#3c763d}.alert-success hr{border-top-color:#c9e2b3}.alert-success .alert-link{color:#2b542c}.alert-info{background-color:#d9edf7;border-color:#bce8f1;color:#31708f}.alert-info hr{border-top-color:#a6e1ec}.alert-info .alert-link{color:#245269}.alert-warning{background-color:#fcf8e3;border-color:#faebcc;color:#8a6d3b}.alert-warning hr{border-top-color:#f7e1b5}.alert-warning .alert-link{color:#66512c}.alert-danger{background-color:#f2dede;border-color:#ebccd1;color:#a94442}.alert-danger hr{border-top-color:#e4b9c0}.alert-danger .alert-link{color:#843534}@-webkit-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}.progress{overflow:hidden;height:20px;margin-bottom:20px;background-color:#f5f5f5;border-radius:4px;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1)}.progress-bar{float:left;width:0%;height:100%;font-size:12px;line-height:20px;color:#fff;text-align:center;background-color:#337ab7;-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-webkit-transition:width .6s ease;-o-transition:width .6s ease;transition:width .6s ease}.progress-striped .progress-bar,.progress-bar-striped{background-image:-webkit-linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);background-image:-o-linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);background-image:linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);background-size:40px 40px}.progress.active .progress-bar,.progress-bar.active{-webkit-animation:progress-bar-stripes 2s linear infinite;-o-animation:progress-bar-stripes 2s linear infinite;animation:progress-bar-stripes 2s linear infinite}.progress-bar-success{background-color:#5cb85c}.progress-striped .progress-bar-success{background-image:-webkit-linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);background-image:-o-linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);background-image:linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent)}.progress-bar-info{background-color:#5bc0de}.progress-striped .progress-bar-info{background-image:-webkit-linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);background-image:-o-linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);background-image:linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent)}.progress-bar-warning{background-color:#f0ad4e}.progress-striped .progress-bar-warning{background-image:-webkit-linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);background-image:-o-linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);background-image:linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent)}.progress-bar-danger{background-color:#d9534f}.progress-striped .progress-bar-danger{background-image:-webkit-linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);background-image:-o-linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);background-image:linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent)}.media{margin-top:15px}.media:first-child{margin-top:0}.media,.media-body{zoom:1;overflow:hidden}.media-body{width:10000px}.media-object{display:block}.media-object.img-thumbnail{max-width:none}.media-right,.media>.pull-right{padding-left:10px}.media-left,.media>.pull-left{padding-right:10px}.media-left,.media-right,.media-body{display:table-cell;vertical-align:top}.media-middle{vertical-align:middle}.media-bottom{vertical-align:bottom}.media-heading{margin-top:0;margin-bottom:5px}.media-list{padding-left:0;list-style:none}.list-group{margin-bottom:20px;padding-left:0}.list-group-item{position:relative;display:block;padding:10px 15px;margin-bottom:-1px;background-color:#fff;border:1px solid #ddd}.list-group-item:first-child{border-top-right-radius:4px;border-top-left-radius:4px}.list-group-item:last-child{margin-bottom:0;border-bottom-right-radius:4px;border-bottom-left-radius:4px}a.list-group-item,button.list-group-item{color:#555}a.list-group-item .list-group-item-heading,button.list-group-item .list-group-item-heading{color:#333}a.list-group-item:hover,button.list-group-item:hover,a.list-group-item:focus,button.list-group-item:focus{text-decoration:none;color:#555;background-color:#f5f5f5}button.list-group-item{width:100%;text-align:left}.list-group-item.disabled,.list-group-item.disabled:hover,.list-group-item.disabled:focus{background-color:#eee;color:#777;cursor:not-allowed}.list-group-item.disabled .list-group-item-heading,.list-group-item.disabled:hover .list-group-item-heading,.list-group-item.disabled:focus .list-group-item-heading{color:inherit}.list-group-item.disabled .list-group-item-text,.list-group-item.disabled:hover .list-group-item-text,.list-group-item.disabled:focus .list-group-item-text{color:#777}.list-group-item.active,.list-group-item.active:hover,.list-group-item.active:focus{z-index:2;color:#fff;background-color:#337ab7;border-color:#337ab7}.list-group-item.active .list-group-item-heading,.list-group-item.active:hover .list-group-item-heading,.list-group-item.active:focus .list-group-item-heading,.list-group-item.active .list-group-item-heading>small,.list-group-item.active:hover .list-group-item-heading>small,.list-group-item.active:focus .list-group-item-heading>small,.list-group-item.active .list-group-item-heading>.small,.list-group-item.active:hover .list-group-item-heading>.small,.list-group-item.active:focus .list-group-item-heading>.small{color:inherit}.list-group-item.active .list-group-item-text,.list-group-item.active:hover .list-group-item-text,.list-group-item.active:focus .list-group-item-text{color:#c7ddef}.list-group-item-success{color:#3c763d;background-color:#dff0d8}a.list-group-item-success,button.list-group-item-success{color:#3c763d}a.list-group-item-success .list-group-item-heading,button.list-group-item-success .list-group-item-heading{color:inherit}a.list-group-item-success:hover,button.list-group-item-success:hover,a.list-group-item-success:focus,button.list-group-item-success:focus{color:#3c763d;background-color:#d0e9c6}a.list-group-item-success.active,button.list-group-item-success.active,a.list-group-item-success.active:hover,button.list-group-item-success.active:hover,a.list-group-item-success.active:focus,button.list-group-item-success.active:focus{color:#fff;background-color:#3c763d;border-color:#3c763d}.list-group-item-info{color:#31708f;background-color:#d9edf7}a.list-group-item-info,button.list-group-item-info{color:#31708f}a.list-group-item-info .list-group-item-heading,button.list-group-item-info .list-group-item-heading{color:inherit}a.list-group-item-info:hover,button.list-group-item-info:hover,a.list-group-item-info:focus,button.list-group-item-info:focus{color:#31708f;background-color:#c4e3f3}a.list-group-item-info.active,button.list-group-item-info.active,a.list-group-item-info.active:hover,button.list-group-item-info.active:hover,a.list-group-item-info.active:focus,button.list-group-item-info.active:focus{color:#fff;background-color:#31708f;border-color:#31708f}.list-group-item-warning{color:#8a6d3b;background-color:#fcf8e3}a.list-group-item-warning,button.list-group-item-warning{color:#8a6d3b}a.list-group-item-warning .list-group-item-heading,button.list-group-item-warning .list-group-item-heading{color:inherit}a.list-group-item-warning:hover,button.list-group-item-warning:hover,a.list-group-item-warning:focus,button.list-group-item-warning:focus{color:#8a6d3b;background-color:#faf2cc}a.list-group-item-warning.active,button.list-group-item-warning.active,a.list-group-item-warning.active:hover,button.list-group-item-warning.active:hover,a.list-group-item-warning.active:focus,button.list-group-item-warning.active:focus{color:#fff;background-color:#8a6d3b;border-color:#8a6d3b}.list-group-item-danger{color:#a94442;background-color:#f2dede}a.list-group-item-danger,button.list-group-item-danger{color:#a94442}a.list-group-item-danger .list-group-item-heading,button.list-group-item-danger .list-group-item-heading{color:inherit}a.list-group-item-danger:hover,button.list-group-item-danger:hover,a.list-group-item-danger:focus,button.list-group-item-danger:focus{color:#a94442;background-color:#ebcccc}a.list-group-item-danger.active,button.list-group-item-danger.active,a.list-group-item-danger.active:hover,button.list-group-item-danger.active:hover,a.list-group-item-danger.active:focus,button.list-group-item-danger.active:focus{color:#fff;background-color:#a94442;border-color:#a94442}.list-group-item-heading{margin-top:0;margin-bottom:5px}.list-group-item-text{margin-bottom:0;line-height:1.3}.panel{margin-bottom:20px;background-color:#fff;border:1px solid transparent;border-radius:4px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,0.05);box-shadow:0 1px 1px rgba(0,0,0,0.05)}.panel-body{padding:15px}.panel-heading{padding:10px 15px;border-bottom:1px solid transparent;border-top-right-radius:3px;border-top-left-radius:3px}.panel-heading>.dropdown .dropdown-toggle{color:inherit}.panel-title{margin-top:0;margin-bottom:0;font-size:16px;color:inherit}.panel-title>a,.panel-title>small,.panel-title>.small,.panel-title>small>a,.panel-title>.small>a{color:inherit}.panel-footer{padding:10px 15px;background-color:#f5f5f5;border-top:1px solid #ddd;border-bottom-right-radius:3px;border-bottom-left-radius:3px}.panel>.list-group,.panel>.panel-collapse>.list-group{margin-bottom:0}.panel>.list-group .list-group-item,.panel>.panel-collapse>.list-group .list-group-item{border-width:1px 0;border-radius:0}.panel>.list-group:first-child .list-group-item:first-child,.panel>.panel-collapse>.list-group:first-child .list-group-item:first-child{border-top:0;border-top-right-radius:3px;border-top-left-radius:3px}.panel>.list-group:last-child .list-group-item:last-child,.panel>.panel-collapse>.list-group:last-child .list-group-item:last-child{border-bottom:0;border-bottom-right-radius:3px;border-bottom-left-radius:3px}.panel>.panel-heading+.panel-collapse>.list-group .list-group-item:first-child{border-top-right-radius:0;border-top-left-radius:0}.panel-heading+.list-group .list-group-item:first-child{border-top-width:0}.list-group+.panel-footer{border-top-width:0}.panel>.table,.panel>.table-responsive>.table,.panel>.panel-collapse>.table{margin-bottom:0}.panel>.table caption,.panel>.table-responsive>.table caption,.panel>.panel-collapse>.table caption{padding-left:15px;padding-right:15px}.panel>.table:first-child,.panel>.table-responsive:first-child>.table:first-child{border-top-right-radius:3px;border-top-left-radius:3px}.panel>.table:first-child>thead:first-child>tr:first-child,.panel>.table-responsive:first-child>.table:first-child>thead:first-child>tr:first-child,.panel>.table:first-child>tbody:first-child>tr:first-child,.panel>.table-responsive:first-child>.table:first-child>tbody:first-child>tr:first-child{border-top-left-radius:3px;border-top-right-radius:3px}.panel>.table:first-child>thead:first-child>tr:first-child td:first-child,.panel>.table-responsive:first-child>.table:first-child>thead:first-child>tr:first-child td:first-child,.panel>.table:first-child>tbody:first-child>tr:first-child td:first-child,.panel>.table-responsive:first-child>.table:first-child>tbody:first-child>tr:first-child td:first-child,.panel>.table:first-child>thead:first-child>tr:first-child th:first-child,.panel>.table-responsive:first-child>.table:first-child>thead:first-child>tr:first-child th:first-child,.panel>.table:first-child>tbody:first-child>tr:first-child th:first-child,.panel>.table-responsive:first-child>.table:first-child>tbody:first-child>tr:first-child th:first-child{border-top-left-radius:3px}.panel>.table:first-child>thead:first-child>tr:first-child td:last-child,.panel>.table-responsive:first-child>.table:first-child>thead:first-child>tr:first-child td:last-child,.panel>.table:first-child>tbody:first-child>tr:first-child td:last-child,.panel>.table-responsive:first-child>.table:first-child>tbody:first-child>tr:first-child td:last-child,.panel>.table:first-child>thead:first-child>tr:first-child th:last-child,.panel>.table-responsive:first-child>.table:first-child>thead:first-child>tr:first-child th:last-child,.panel>.table:first-child>tbody:first-child>tr:first-child th:last-child,.panel>.table-responsive:first-child>.table:first-child>tbody:first-child>tr:first-child th:last-child{border-top-right-radius:3px}.panel>.table:last-child,.panel>.table-responsive:last-child>.table:last-child{border-bottom-right-radius:3px;border-bottom-left-radius:3px}.panel>.table:last-child>tbody:last-child>tr:last-child,.panel>.table-responsive:last-child>.table:last-child>tbody:last-child>tr:last-child,.panel>.table:last-child>tfoot:last-child>tr:last-child,.panel>.table-responsive:last-child>.table:last-child>tfoot:last-child>tr:last-child{border-bottom-left-radius:3px;border-bottom-right-radius:3px}.panel>.table:last-child>tbody:last-child>tr:last-child td:first-child,.panel>.table-responsive:last-child>.table:last-child>tbody:last-child>tr:last-child td:first-child,.panel>.table:last-child>tfoot:last-child>tr:last-child td:first-child,.panel>.table-responsive:last-child>.table:last-child>tfoot:last-child>tr:last-child td:first-child,.panel>.table:last-child>tbody:last-child>tr:last-child th:first-child,.panel>.table-responsive:last-child>.table:last-child>tbody:last-child>tr:last-child th:first-child,.panel>.table:last-child>tfoot:last-child>tr:last-child th:first-child,.panel>.table-responsive:last-child>.table:last-child>tfoot:last-child>tr:last-child th:first-child{border-bottom-left-radius:3px}.panel>.table:last-child>tbody:last-child>tr:last-child td:last-child,.panel>.table-responsive:last-child>.table:last-child>tbody:last-child>tr:last-child td:last-child,.panel>.table:last-child>tfoot:last-child>tr:last-child td:last-child,.panel>.table-responsive:last-child>.table:last-child>tfoot:last-child>tr:last-child td:last-child,.panel>.table:last-child>tbody:last-child>tr:last-child th:last-child,.panel>.table-responsive:last-child>.table:last-child>tbody:last-child>tr:last-child th:last-child,.panel>.table:last-child>tfoot:last-child>tr:last-child th:last-child,.panel>.table-responsive:last-child>.table:last-child>tfoot:last-child>tr:last-child th:last-child{border-bottom-right-radius:3px}.panel>.panel-body+.table,.panel>.panel-body+.table-responsive,.panel>.table+.panel-body,.panel>.table-responsive+.panel-body{border-top:1px solid #ddd}.panel>.table>tbody:first-child>tr:first-child th,.panel>.table>tbody:first-child>tr:first-child td{border-top:0}.panel>.table-bordered,.panel>.table-responsive>.table-bordered{border:0}.panel>.table-bordered>thead>tr>th:first-child,.panel>.table-responsive>.table-bordered>thead>tr>th:first-child,.panel>.table-bordered>tbody>tr>th:first-child,.panel>.table-responsive>.table-bordered>tbody>tr>th:first-child,.panel>.table-bordered>tfoot>tr>th:first-child,.panel>.table-responsive>.table-bordered>tfoot>tr>th:first-child,.panel>.table-bordered>thead>tr>td:first-child,.panel>.table-responsive>.table-bordered>thead>tr>td:first-child,.panel>.table-bordered>tbody>tr>td:first-child,.panel>.table-responsive>.table-bordered>tbody>tr>td:first-child,.panel>.table-bordered>tfoot>tr>td:first-child,.panel>.table-responsive>.table-bordered>tfoot>tr>td:first-child{border-left:0}.panel>.table-bordered>thead>tr>th:last-child,.panel>.table-responsive>.table-bordered>thead>tr>th:last-child,.panel>.table-bordered>tbody>tr>th:last-child,.panel>.table-responsive>.table-bordered>tbody>tr>th:last-child,.panel>.table-bordered>tfoot>tr>th:last-child,.panel>.table-responsive>.table-bordered>tfoot>tr>th:last-child,.panel>.table-bordered>thead>tr>td:last-child,.panel>.table-responsive>.table-bordered>thead>tr>td:last-child,.panel>.table-bordered>tbody>tr>td:last-child,.panel>.table-responsive>.table-bordered>tbody>tr>td:last-child,.panel>.table-bordered>tfoot>tr>td:last-child,.panel>.table-responsive>.table-bordered>tfoot>tr>td:last-child{border-right:0}.panel>.table-bordered>thead>tr:first-child>td,.panel>.table-responsive>.table-bordered>thead>tr:first-child>td,.panel>.table-bordered>tbody>tr:first-child>td,.panel>.table-responsive>.table-bordered>tbody>tr:first-child>td,.panel>.table-bordered>thead>tr:first-child>th,.panel>.table-responsive>.table-bordered>thead>tr:first-child>th,.panel>.table-bordered>tbody>tr:first-child>th,.panel>.table-responsive>.table-bordered>tbody>tr:first-child>th{border-bottom:0}.panel>.table-bordered>tbody>tr:last-child>td,.panel>.table-responsive>.table-bordered>tbody>tr:last-child>td,.panel>.table-bordered>tfoot>tr:last-child>td,.panel>.table-responsive>.table-bordered>tfoot>tr:last-child>td,.panel>.table-bordered>tbody>tr:last-child>th,.panel>.table-responsive>.table-bordered>tbody>tr:last-child>th,.panel>.table-bordered>tfoot>tr:last-child>th,.panel>.table-responsive>.table-bordered>tfoot>tr:last-child>th{border-bottom:0}.panel>.table-responsive{border:0;margin-bottom:0}.panel-group{margin-bottom:20px}.panel-group .panel{margin-bottom:0;border-radius:4px}.panel-group .panel+.panel{margin-top:5px}.panel-group .panel-heading{border-bottom:0}.panel-group .panel-heading+.panel-collapse>.panel-body,.panel-group .panel-heading+.panel-collapse>.list-group{border-top:1px solid #ddd}.panel-group .panel-footer{border-top:0}.panel-group .panel-footer+.panel-collapse .panel-body{border-bottom:1px solid #ddd}.panel-default{border-color:#ddd}.panel-default>.panel-heading{color:#333;background-color:#f5f5f5;border-color:#ddd}.panel-default>.panel-heading+.panel-collapse>.panel-body{border-top-color:#ddd}.panel-default>.panel-heading .badge{color:#f5f5f5;background-color:#333}.panel-default>.panel-footer+.panel-collapse>.panel-body{border-bottom-color:#ddd}.panel-primary{border-color:#337ab7}.panel-primary>.panel-heading{color:#fff;background-color:#337ab7;border-color:#337ab7}.panel-primary>.panel-heading+.panel-collapse>.panel-body{border-top-color:#337ab7}.panel-primary>.panel-heading .badge{color:#337ab7;background-color:#fff}.panel-primary>.panel-footer+.panel-collapse>.panel-body{border-bottom-color:#337ab7}.panel-success{border-color:#d6e9c6}.panel-success>.panel-heading{color:#3c763d;background-color:#dff0d8;border-color:#d6e9c6}.panel-success>.panel-heading+.panel-collapse>.panel-body{border-top-color:#d6e9c6}.panel-success>.panel-heading .badge{color:#dff0d8;background-color:#3c763d}.panel-success>.panel-footer+.panel-collapse>.panel-body{border-bottom-color:#d6e9c6}.panel-info{border-color:#bce8f1}.panel-info>.panel-heading{color:#31708f;background-color:#d9edf7;border-color:#bce8f1}.panel-info>.panel-heading+.panel-collapse>.panel-body{border-top-color:#bce8f1}.panel-info>.panel-heading .badge{color:#d9edf7;background-color:#31708f}.panel-info>.panel-footer+.panel-collapse>.panel-body{border-bottom-color:#bce8f1}.panel-warning{border-color:#faebcc}.panel-warning>.panel-heading{color:#8a6d3b;background-color:#fcf8e3;border-color:#faebcc}.panel-warning>.panel-heading+.panel-collapse>.panel-body{border-top-color:#faebcc}.panel-warning>.panel-heading .badge{color:#fcf8e3;background-color:#8a6d3b}.panel-warning>.panel-footer+.panel-collapse>.panel-body{border-bottom-color:#faebcc}.panel-danger{border-color:#ebccd1}.panel-danger>.panel-heading{color:#a94442;background-color:#f2dede;border-color:#ebccd1}.panel-danger>.panel-heading+.panel-collapse>.panel-body{border-top-color:#ebccd1}.panel-danger>.panel-heading .badge{color:#f2dede;background-color:#a94442}.panel-danger>.panel-footer+.panel-collapse>.panel-body{border-bottom-color:#ebccd1}.embed-responsive{position:relative;display:block;height:0;padding:0;overflow:hidden}.embed-responsive .embed-responsive-item,.embed-responsive iframe,.embed-responsive embed,.embed-responsive object,.embed-responsive video{position:absolute;top:0;left:0;bottom:0;height:100%;width:100%;border:0}.embed-responsive-16by9{padding-bottom:56.25%}.embed-responsive-4by3{padding-bottom:75%}.well{min-height:20px;padding:19px;margin-bottom:20px;background-color:#f5f5f5;border:1px solid #e3e3e3;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.05);box-shadow:inset 0 1px 1px rgba(0,0,0,0.05)}.well blockquote{border-color:#ddd;border-color:rgba(0,0,0,0.15)}.well-lg{padding:24px;border-radius:6px}.well-sm{padding:9px;border-radius:3px}.close{float:right;font-size:21px;font-weight:bold;line-height:1;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;filter:alpha(opacity=20)}.close:hover,.close:focus{color:#000;text-decoration:none;cursor:pointer;opacity:.5;filter:alpha(opacity=50)}button.close{padding:0;cursor:pointer;background:transparent;border:0;-webkit-appearance:none}.modal-open{overflow:hidden}.modal{display:none;overflow:hidden;position:fixed;top:0;right:0;bottom:0;left:0;z-index:1050;-webkit-overflow-scrolling:touch;outline:0}.modal.fade .modal-dialog{-webkit-transform:translate(0, -25%);-ms-transform:translate(0, -25%);-o-transform:translate(0, -25%);transform:translate(0, -25%);-webkit-transition:-webkit-transform 0.3s ease-out;-moz-transition:-moz-transform 0.3s ease-out;-o-transition:-o-transform 0.3s ease-out;transition:transform 0.3s ease-out}.modal.in .modal-dialog{-webkit-transform:translate(0, 0);-ms-transform:translate(0, 0);-o-transform:translate(0, 0);transform:translate(0, 0)}.modal-open .modal{overflow-x:hidden;overflow-y:auto}.modal-dialog{position:relative;width:auto;margin:10px}.modal-content{position:relative;background-color:#fff;border:1px solid #999;border:1px solid rgba(0,0,0,0.2);border-radius:6px;-webkit-box-shadow:0 3px 9px rgba(0,0,0,0.5);box-shadow:0 3px 9px rgba(0,0,0,0.5);background-clip:padding-box;outline:0}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1040;background-color:#000}.modal-backdrop.fade{opacity:0;filter:alpha(opacity=0)}.modal-backdrop.in{opacity:.5;filter:alpha(opacity=50)}.modal-header{padding:15px;border-bottom:1px solid #e5e5e5}.modal-header .close{margin-top:-2px}.modal-title{margin:0;line-height:1.42857143}.modal-body{position:relative;padding:15px}.modal-footer{padding:15px;text-align:right;border-top:1px solid #e5e5e5}.modal-footer .btn+.btn{margin-left:5px;margin-bottom:0}.modal-footer .btn-group .btn+.btn{margin-left:-1px}.modal-footer .btn-block+.btn-block{margin-left:0}.modal-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll}@media (min-width:768px){.modal-dialog{width:600px;margin:30px auto}.modal-content{-webkit-box-shadow:0 5px 15px rgba(0,0,0,0.5);box-shadow:0 5px 15px rgba(0,0,0,0.5)}.modal-sm{width:300px}}@media (min-width:992px){.modal-lg{width:900px}}.tooltip{position:absolute;z-index:1070;display:block;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-style:normal;font-weight:normal;letter-spacing:normal;line-break:auto;line-height:1.42857143;text-align:left;text-align:start;text-decoration:none;text-shadow:none;text-transform:none;white-space:normal;word-break:normal;word-spacing:normal;word-wrap:normal;font-size:12px;opacity:0;filter:alpha(opacity=0)}.tooltip.in{opacity:.9;filter:alpha(opacity=90)}.tooltip.top{margin-top:-3px;padding:5px 0}.tooltip.right{margin-left:3px;padding:0 5px}.tooltip.bottom{margin-top:3px;padding:5px 0}.tooltip.left{margin-left:-3px;padding:0 5px}.tooltip-inner{max-width:200px;padding:3px 8px;color:#fff;text-align:center;background-color:#000;border-radius:4px}.tooltip-arrow{position:absolute;width:0;height:0;border-color:transparent;border-style:solid}.tooltip.top .tooltip-arrow{bottom:0;left:50%;margin-left:-5px;border-width:5px 5px 0;border-top-color:#000}.tooltip.top-left .tooltip-arrow{bottom:0;right:5px;margin-bottom:-5px;border-width:5px 5px 0;border-top-color:#000}.tooltip.top-right .tooltip-arrow{bottom:0;left:5px;margin-bottom:-5px;border-width:5px 5px 0;border-top-color:#000}.tooltip.right .tooltip-arrow{top:50%;left:0;margin-top:-5px;border-width:5px 5px 5px 0;border-right-color:#000}.tooltip.left .tooltip-arrow{top:50%;right:0;margin-top:-5px;border-width:5px 0 5px 5px;border-left-color:#000}.tooltip.bottom .tooltip-arrow{top:0;left:50%;margin-left:-5px;border-width:0 5px 5px;border-bottom-color:#000}.tooltip.bottom-left .tooltip-arrow{top:0;right:5px;margin-top:-5px;border-width:0 5px 5px;border-bottom-color:#000}.tooltip.bottom-right .tooltip-arrow{top:0;left:5px;margin-top:-5px;border-width:0 5px 5px;border-bottom-color:#000}.popover{position:absolute;top:0;left:0;z-index:1060;display:none;max-width:276px;padding:1px;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-style:normal;font-weight:normal;letter-spacing:normal;line-break:auto;line-height:1.42857143;text-align:left;text-align:start;text-decoration:none;text-shadow:none;text-transform:none;white-space:normal;word-break:normal;word-spacing:normal;word-wrap:normal;font-size:14px;background-color:#fff;background-clip:padding-box;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);box-shadow:0 5px 10px rgba(0,0,0,0.2)}.popover.top{margin-top:-10px}.popover.right{margin-left:10px}.popover.bottom{margin-top:10px}.popover.left{margin-left:-10px}.popover-title{margin:0;padding:8px 14px;font-size:14px;background-color:#f7f7f7;border-bottom:1px solid #ebebeb;border-radius:5px 5px 0 0}.popover-content{padding:9px 14px}.popover>.arrow,.popover>.arrow:after{position:absolute;display:block;width:0;height:0;border-color:transparent;border-style:solid}.popover>.arrow{border-width:11px}.popover>.arrow:after{border-width:10px;content:""}.popover.top>.arrow{left:50%;margin-left:-11px;border-bottom-width:0;border-top-color:#999;border-top-color:rgba(0,0,0,0.25);bottom:-11px}.popover.top>.arrow:after{content:" ";bottom:1px;margin-left:-10px;border-bottom-width:0;border-top-color:#fff}.popover.right>.arrow{top:50%;left:-11px;margin-top:-11px;border-left-width:0;border-right-color:#999;border-right-color:rgba(0,0,0,0.25)}.popover.right>.arrow:after{content:" ";left:1px;bottom:-10px;border-left-width:0;border-right-color:#fff}.popover.bottom>.arrow{left:50%;margin-left:-11px;border-top-width:0;border-bottom-color:#999;border-bottom-color:rgba(0,0,0,0.25);top:-11px}.popover.bottom>.arrow:after{content:" ";top:1px;margin-left:-10px;border-top-width:0;border-bottom-color:#fff}.popover.left>.arrow{top:50%;right:-11px;margin-top:-11px;border-right-width:0;border-left-color:#999;border-left-color:rgba(0,0,0,0.25)}.popover.left>.arrow:after{content:" ";right:1px;border-right-width:0;border-left-color:#fff;bottom:-10px}.carousel{position:relative}.carousel-inner{position:relative;overflow:hidden;width:100%}.carousel-inner>.item{display:none;position:relative;-webkit-transition:.6s ease-in-out left;-o-transition:.6s ease-in-out left;transition:.6s ease-in-out left}.carousel-inner>.item>img,.carousel-inner>.item>a>img{line-height:1}@media all and (transform-3d),(-webkit-transform-3d){.carousel-inner>.item{-webkit-transition:-webkit-transform 0.6s ease-in-out;-moz-transition:-moz-transform 0.6s ease-in-out;-o-transition:-o-transform 0.6s ease-in-out;transition:transform 0.6s ease-in-out;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;backface-visibility:hidden;-webkit-perspective:1000px;-moz-perspective:1000px;perspective:1000px}.carousel-inner>.item.next,.carousel-inner>.item.active.right{-webkit-transform:translate3d(100%, 0, 0);transform:translate3d(100%, 0, 0);left:0}.carousel-inner>.item.prev,.carousel-inner>.item.active.left{-webkit-transform:translate3d(-100%, 0, 0);transform:translate3d(-100%, 0, 0);left:0}.carousel-inner>.item.next.left,.carousel-inner>.item.prev.right,.carousel-inner>.item.active{-webkit-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0);left:0}}.carousel-inner>.active,.carousel-inner>.next,.carousel-inner>.prev{display:block}.carousel-inner>.active{left:0}.carousel-inner>.next,.carousel-inner>.prev{position:absolute;top:0;width:100%}.carousel-inner>.next{left:100%}.carousel-inner>.prev{left:-100%}.carousel-inner>.next.left,.carousel-inner>.prev.right{left:0}.carousel-inner>.active.left{left:-100%}.carousel-inner>.active.right{left:100%}.carousel-control{position:absolute;top:0;left:0;bottom:0;width:15%;opacity:.5;filter:alpha(opacity=50);font-size:20px;color:#fff;text-align:center;text-shadow:0 1px 2px rgba(0,0,0,0.6);background-color:rgba(0,0,0,0)}.carousel-control.left{background-image:-webkit-linear-gradient(left, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.0001) 100%);background-image:-o-linear-gradient(left, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.0001) 100%);background-image:linear-gradient(to right, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.0001) 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#80000000', endColorstr='#00000000', GradientType=1)}.carousel-control.right{left:auto;right:0;background-image:-webkit-linear-gradient(left, rgba(0,0,0,0.0001) 0%, rgba(0,0,0,0.5) 100%);background-image:-o-linear-gradient(left, rgba(0,0,0,0.0001) 0%, rgba(0,0,0,0.5) 100%);background-image:linear-gradient(to right, rgba(0,0,0,0.0001) 0%, rgba(0,0,0,0.5) 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000', endColorstr='#80000000', GradientType=1)}.carousel-control:hover,.carousel-control:focus{outline:0;color:#fff;text-decoration:none;opacity:.9;filter:alpha(opacity=90)}.carousel-control .icon-prev,.carousel-control .icon-next,.carousel-control .glyphicon-chevron-left,.carousel-control .glyphicon-chevron-right{position:absolute;top:50%;margin-top:-10px;z-index:5;display:inline-block}.carousel-control .icon-prev,.carousel-control .glyphicon-chevron-left{left:50%;margin-left:-10px}.carousel-control .icon-next,.carousel-control .glyphicon-chevron-right{right:50%;margin-right:-10px}.carousel-control .icon-prev,.carousel-control .icon-next{width:20px;height:20px;line-height:1;font-family:serif}.carousel-control .icon-prev:before{content:'\2039'}.carousel-control .icon-next:before{content:'\203a'}.carousel-indicators{position:absolute;bottom:10px;left:50%;z-index:15;width:60%;margin-left:-30%;padding-left:0;list-style:none;text-align:center}.carousel-indicators li{display:inline-block;width:10px;height:10px;margin:1px;text-indent:-999px;border:1px solid #fff;border-radius:10px;cursor:pointer;background-color:#000 \9;background-color:rgba(0,0,0,0)}.carousel-indicators .active{margin:0;width:12px;height:12px;background-color:#fff}.carousel-caption{position:absolute;left:15%;right:15%;bottom:20px;z-index:10;padding-top:20px;padding-bottom:20px;color:#fff;text-align:center;text-shadow:0 1px 2px rgba(0,0,0,0.6)}.carousel-caption .btn{text-shadow:none}@media screen and (min-width:768px){.carousel-control .glyphicon-chevron-left,.carousel-control .glyphicon-chevron-right,.carousel-control .icon-prev,.carousel-control .icon-next{width:30px;height:30px;margin-top:-10px;font-size:30px}.carousel-control .glyphicon-chevron-left,.carousel-control .icon-prev{margin-left:-10px}.carousel-control .glyphicon-chevron-right,.carousel-control .icon-next{margin-right:-10px}.carousel-caption{left:20%;right:20%;padding-bottom:30px}.carousel-indicators{bottom:20px}}.clearfix:before,.clearfix:after,.dl-horizontal dd:before,.dl-horizontal dd:after,.container:before,.container:after,.container-fluid:before,.container-fluid:after,.row:before,.row:after,.form-horizontal .form-group:before,.form-horizontal .form-group:after,.btn-toolbar:before,.btn-toolbar:after,.btn-group-vertical>.btn-group:before,.btn-group-vertical>.btn-group:after,.nav:before,.nav:after,.navbar:before,.navbar:after,.navbar-header:before,.navbar-header:after,.navbar-collapse:before,.navbar-collapse:after,.pager:before,.pager:after,.panel-body:before,.panel-body:after,.modal-header:before,.modal-header:after,.modal-footer:before,.modal-footer:after{content:" ";display:table}.clearfix:after,.dl-horizontal dd:after,.container:after,.container-fluid:after,.row:after,.form-horizontal .form-group:after,.btn-toolbar:after,.btn-group-vertical>.btn-group:after,.nav:after,.navbar:after,.navbar-header:after,.navbar-collapse:after,.pager:after,.panel-body:after,.modal-header:after,.modal-footer:after{clear:both}.center-block{display:block;margin-left:auto;margin-right:auto}.pull-right{float:right !important}.pull-left{float:left !important}.hide{display:none !important}.show{display:block !important}.invisible{visibility:hidden}.text-hide{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.hidden{display:none !important}.affix{position:fixed}@-ms-viewport{width:device-width}.visible-xs,.visible-sm,.visible-md,.visible-lg{display:none !important}.visible-xs-block,.visible-xs-inline,.visible-xs-inline-block,.visible-sm-block,.visible-sm-inline,.visible-sm-inline-block,.visible-md-block,.visible-md-inline,.visible-md-inline-block,.visible-lg-block,.visible-lg-inline,.visible-lg-inline-block{display:none !important}@media (max-width:767px){.visible-xs{display:block !important}table.visible-xs{display:table !important}tr.visible-xs{display:table-row !important}th.visible-xs,td.visible-xs{display:table-cell !important}}@media (max-width:767px){.visible-xs-block{display:block !important}}@media (max-width:767px){.visible-xs-inline{display:inline !important}}@media (max-width:767px){.visible-xs-inline-block{display:inline-block !important}}@media (min-width:768px) and (max-width:991px){.visible-sm{display:block !important}table.visible-sm{display:table !important}tr.visible-sm{display:table-row !important}th.visible-sm,td.visible-sm{display:table-cell !important}}@media (min-width:768px) and (max-width:991px){.visible-sm-block{display:block !important}}@media (min-width:768px) and (max-width:991px){.visible-sm-inline{display:inline !important}}@media (min-width:768px) and (max-width:991px){.visible-sm-inline-block{display:inline-block !important}}@media (min-width:992px) and (max-width:1199px){.visible-md{display:block !important}table.visible-md{display:table !important}tr.visible-md{display:table-row !important}th.visible-md,td.visible-md{display:table-cell !important}}@media (min-width:992px) and (max-width:1199px){.visible-md-block{display:block !important}}@media (min-width:992px) and (max-width:1199px){.visible-md-inline{display:inline !important}}@media (min-width:992px) and (max-width:1199px){.visible-md-inline-block{display:inline-block !important}}@media (min-width:1200px){.visible-lg{display:block !important}table.visible-lg{display:table !important}tr.visible-lg{display:table-row !important}th.visible-lg,td.visible-lg{display:table-cell !important}}@media (min-width:1200px){.visible-lg-block{display:block !important}}@media (min-width:1200px){.visible-lg-inline{display:inline !important}}@media (min-width:1200px){.visible-lg-inline-block{display:inline-block !important}}@media (max-width:767px){.hidden-xs{display:none !important}}@media (min-width:768px) and (max-width:991px){.hidden-sm{display:none !important}}@media (min-width:992px) and (max-width:1199px){.hidden-md{display:none !important}}@media (min-width:1200px){.hidden-lg{display:none !important}}.visible-print{display:none !important}@media print{.visible-print{display:block !important}table.visible-print{display:table !important}tr.visible-print{display:table-row !important}th.visible-print,td.visible-print{display:table-cell !important}}.visible-print-block{display:none !important}@media print{.visible-print-block{display:block !important}}.visible-print-inline{display:none !important}@media print{.visible-print-inline{display:inline !important}}.visible-print-inline-block{display:none !important}@media print{.visible-print-inline-block{display:inline-block !important}}@media print{.hidden-print{display:none !important}}.dropdown-submenu{position:relative}.dropdown-submenu .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}.dropdown-submenu:hover>.dropdown-menu{display:block}.dropdown-submenu:hover>.dropdown-menu a:after{border-left-color:#fff}.dropdown-submenu 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}.dropdown-submenu .pull-left{float:none}.dropdown-submenu .pull-left .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}@media print{header,footer,.benchmark{display:none}}#print{width:100%}#print div.title{font-size:15pt;font-weight:bold;border-bottom:3px solid black;text-align:center}#print table.data-box{width:100%;border-collapse:collapse}#print table.data-box td{border:thin solid black;padding-left:2px}#print table.details{width:100%;border-collapse:collapse}#print table.details thead{color:white;background-color:black;font-weight:bold}#print table.details tbody tr{border:thin solid black}#print table.details tbody tr:nth-child(odd){background-color:lightgray}#print table.details tbody tr.total{font-weight:bold}#print table.details tbody tr.total td{border-top-style:double;border-top-width:3px}#print table.details td,#print table.details th{border:thin solid black;padding-left:2px}#print label{font-variant:small-caps;font-size:10pt}#print div.data{float:left}#print div.data-value{float:right}#print div.total{float:left;font-weight:bold}#print div.total-value{float:right;font-weight:bold}#print br.clear{clear:both}#print table.signature{width:75%}#print table.signature tr.double{height:24pt}#print table.signature tr.triple{height:36pt}#print table.signature tr.quadruple{height:48pt}#print table.signature tr td{padding-left:2px;border:thin solid black}#print table.signature tr td:nth-child(2){width:70%}.logo_cabezal{padding:1%}.logo_cabezal img{height:100.00000003px}.dropdown-submenu{position:relative}.dropdown-submenu .dropdown-menu{top:0;left:100%;margin-top:-1px}.error{background-color:#d84f4b}.page-heading{padding:3px 10px;margin:auto 0;background-color:#14153c;color:white}.page-heading a{color:inherit}.section-heading{background-color:#808080 !important;color:white !important}.section-heading a{color:inherit !important}.subsection-heading{background-color:#d3d3d3 !important}.agregar,.remover,.click{cursor:pointer}/*! + * jQuery UI Bootstrap 0.2.5 + * Theme created by @gustavohenke for the jQuery UI Framework 1.9+ + * + * Useful links: + * http://jqueryui.com + * http://gustavohenke.github.com/jquery-ui-bootstrap + * + * Licensed under MIT. + */.ui-widget{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px}.ui-widget input,.ui-widget select,.ui-widget textarea,.ui-widget button{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif}.ui-widget-content{border:1px solid #ddd;background:#fff;color:#222222}.ui-widget-content a{color:#222222}.ui-widget-header{border:1px solid #aaaaaa;color:#222222;font-weight:bold}.ui-widget-header a{color:#222222}.ui-state-default,.ui-widget-content .ui-state-default,.ui-widget-header .ui-state-default{font-weight:normal;color:#555555}.ui-state-default a,.ui-state-default a:link,.ui-state-default a:visited{color:#555555;text-decoration:none}.ui-state-default,.ui-widget-content .ui-state-default{border:1px solid #bbb;background-color:#e6e6e6;background-repeat:no-repeat;background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));background-image:-webkit-linear-gradient(top, #ffffff, #e6e6e6);background-image:-moz-linear-gradient(top, #ffffff, #e6e6e6);background-image:-ms-linear-gradient(top, #ffffff, #e6e6e6);background-image:-o-linear-gradient(top, #ffffff, #e6e6e6);background-image:linear-gradient(to bottom, #ffffff, #e6e6e6);color:#555;text-shadow:0 1px 1px rgba(255,255,255,0.75)}.ui-state-hover,.ui-widget-content .ui-state-hover,.ui-widget-header .ui-state-hover{border:1px solid #999999;background-position:0 -15px;font-weight:normal;-webkit-transition:.1s linear background-position;-moz-transition:.1s linear background-position;-ms-transition:.1s linear background-position;-o-transition:.1s linear background-position;transition:.1s linear background-position}.ui-state-hover a,.ui-state-hover a:hover,.ui-state-hover a:link,.ui-state-hover a:visited{color:#212121;text-decoration:none}.ui-state-active,.ui-widget-content .ui-state-active,.ui-widget-header .ui-state-active{border:1px solid #aaaaaa;font-weight:normal}.ui-state-active a,.ui-state-active a:link,.ui-state-active a:visited{color:#212121;text-decoration:none}.ui-state-highlight,.ui-widget-content .ui-state-highlight,.ui-widget-header .ui-state-highlight{border:1px solid #fbeed5;background:#fcf8e3;color:#c09853}.ui-state-highlight a,.ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a{color:#363636}.ui-state-error,.ui-widget-content .ui-state-error,.ui-widget-header .ui-state-error{border:1px solid #eed3d7;background:#f2dede;color:#b94a48}.ui-state-error a,.ui-widget-content .ui-state-error a,.ui-widget-header .ui-state-error a{color:#cd0a0a}.ui-state-error-text,.ui-widget-content .ui-state-error-text,.ui-widget-header .ui-state-error-text{color:#cd0a0a}.ui-state-disabled,.ui-widget-content .ui-state-disabled,.ui-widget-header .ui-state-disabled{opacity:.35;filter:alpha(opacity=35);background-image:none}.ui-state-disabled .ui-icon{filter:alpha(opacity=35)}.ui-icon{width:16px;height:16px;background-image:url(images/ui-icons_333333_256x240.png)}.ui-widget-content .ui-icon{background-image:url(images/ui-icons_333333_256x240.png)}.ui-widget-header .ui-icon{background-image:url(images/ui-icons_333333_256x240.png)}.ui-state-default .ui-icon{background-image:url(images/ui-icons_888888_256x240.png)}.ui-state-hover .ui-icon,.ui-state-focus .ui-icon{background-image:url(images/ui-icons_454545_256x240.png)}.ui-state-active .ui-icon{background-image:url(images/ui-icons_454545_256x240.png)}.ui-state-highlight .ui-icon{background-image:url(images/ui-icons_888888_256x240.png)}.ui-state-error .ui-icon,.ui-state-error-text .ui-icon{background-image:url(images/ui-icons_B94A48_256x240.png)}.ui-icon-carat-1-n{background-position:0 0}.ui-icon-carat-1-ne{background-position:-16px 0}.ui-icon-carat-1-e{background-position:-32px 0}.ui-icon-carat-1-se{background-position:-48px 0}.ui-icon-carat-1-s{background-position:-64px 0}.ui-icon-carat-1-sw{background-position:-80px 0}.ui-icon-carat-1-w{background-position:-96px 0}.ui-icon-carat-1-nw{background-position:-112px 0}.ui-icon-carat-2-n-s{background-position:-128px 0}.ui-icon-carat-2-e-w{background-position:-144px 0}.ui-icon-triangle-1-n{background-position:0 -16px}.ui-icon-triangle-1-ne{background-position:-16px -16px}.ui-icon-triangle-1-e{background-position:-32px -16px}.ui-icon-triangle-1-se{background-position:-48px -16px}.ui-icon-triangle-1-s{background-position:-64px -16px}.ui-icon-triangle-1-sw{background-position:-80px -16px}.ui-icon-triangle-1-w{background-position:-96px -16px}.ui-icon-triangle-1-nw{background-position:-112px -16px}.ui-icon-triangle-2-n-s{background-position:-128px -16px}.ui-icon-triangle-2-e-w{background-position:-144px -16px}.ui-icon-arrow-1-n{background-position:0 -32px}.ui-icon-arrow-1-ne{background-position:-16px -32px}.ui-icon-arrow-1-e{background-position:-32px -32px}.ui-icon-arrow-1-se{background-position:-48px -32px}.ui-icon-arrow-1-s{background-position:-64px -32px}.ui-icon-arrow-1-sw{background-position:-80px -32px}.ui-icon-arrow-1-w{background-position:-96px -32px}.ui-icon-arrow-1-nw{background-position:-112px -32px}.ui-icon-arrow-2-n-s{background-position:-128px -32px}.ui-icon-arrow-2-ne-sw{background-position:-144px -32px}.ui-icon-arrow-2-e-w{background-position:-160px -32px}.ui-icon-arrow-2-se-nw{background-position:-176px -32px}.ui-icon-arrowstop-1-n{background-position:-192px -32px}.ui-icon-arrowstop-1-e{background-position:-208px -32px}.ui-icon-arrowstop-1-s{background-position:-224px -32px}.ui-icon-arrowstop-1-w{background-position:-240px -32px}.ui-icon-arrowthick-1-n{background-position:0 -48px}.ui-icon-arrowthick-1-ne{background-position:-16px -48px}.ui-icon-arrowthick-1-e{background-position:-32px -48px}.ui-icon-arrowthick-1-se{background-position:-48px -48px}.ui-icon-arrowthick-1-s{background-position:-64px -48px}.ui-icon-arrowthick-1-sw{background-position:-80px -48px}.ui-icon-arrowthick-1-w{background-position:-96px -48px}.ui-icon-arrowthick-1-nw{background-position:-112px -48px}.ui-icon-arrowthick-2-n-s{background-position:-128px -48px}.ui-icon-arrowthick-2-ne-sw{background-position:-144px -48px}.ui-icon-arrowthick-2-e-w{background-position:-160px -48px}.ui-icon-arrowthick-2-se-nw{background-position:-176px -48px}.ui-icon-arrowthickstop-1-n{background-position:-192px -48px}.ui-icon-arrowthickstop-1-e{background-position:-208px -48px}.ui-icon-arrowthickstop-1-s{background-position:-224px -48px}.ui-icon-arrowthickstop-1-w{background-position:-240px -48px}.ui-icon-arrowreturnthick-1-w{background-position:0 -64px}.ui-icon-arrowreturnthick-1-n{background-position:-16px -64px}.ui-icon-arrowreturnthick-1-e{background-position:-32px -64px}.ui-icon-arrowreturnthick-1-s{background-position:-48px -64px}.ui-icon-arrowreturn-1-w{background-position:-64px -64px}.ui-icon-arrowreturn-1-n{background-position:-80px -64px}.ui-icon-arrowreturn-1-e{background-position:-96px -64px}.ui-icon-arrowreturn-1-s{background-position:-112px -64px}.ui-icon-arrowrefresh-1-w{background-position:-128px -64px}.ui-icon-arrowrefresh-1-n{background-position:-144px -64px}.ui-icon-arrowrefresh-1-e{background-position:-160px -64px}.ui-icon-arrowrefresh-1-s{background-position:-176px -64px}.ui-icon-arrow-4{background-position:0 -80px}.ui-icon-arrow-4-diag{background-position:-16px -80px}.ui-icon-extlink{background-position:-32px -80px}.ui-icon-newwin{background-position:-48px -80px}.ui-icon-refresh{background-position:-64px -80px}.ui-icon-shuffle{background-position:-80px -80px}.ui-icon-transfer-e-w{background-position:-96px -80px}.ui-icon-transferthick-e-w{background-position:-112px -80px}.ui-icon-folder-collapsed{background-position:0 -96px}.ui-icon-folder-open{background-position:-16px -96px}.ui-icon-document{background-position:-32px -96px}.ui-icon-document-b{background-position:-48px -96px}.ui-icon-note{background-position:-64px -96px}.ui-icon-mail-closed{background-position:-80px -96px}.ui-icon-mail-open{background-position:-96px -96px}.ui-icon-suitcase{background-position:-112px -96px}.ui-icon-comment{background-position:-128px -96px}.ui-icon-person{background-position:-144px -96px}.ui-icon-print{background-position:-160px -96px}.ui-icon-trash{background-position:-176px -96px}.ui-icon-locked{background-position:-192px -96px}.ui-icon-unlocked{background-position:-208px -96px}.ui-icon-bookmark{background-position:-224px -96px}.ui-icon-tag{background-position:-240px -96px}.ui-icon-home{background-position:0 -112px}.ui-icon-flag{background-position:-16px -112px}.ui-icon-calendar{background-position:-32px -112px}.ui-icon-cart{background-position:-48px -112px}.ui-icon-pencil{background-position:-64px -112px}.ui-icon-clock{background-position:-80px -112px}.ui-icon-disk{background-position:-96px -112px}.ui-icon-calculator{background-position:-112px -112px}.ui-icon-zoomin{background-position:-128px -112px}.ui-icon-zoomout{background-position:-144px -112px}.ui-icon-search{background-position:-160px -112px}.ui-icon-wrench{background-position:-176px -112px}.ui-icon-gear{background-position:-192px -112px}.ui-icon-heart{background-position:-208px -112px}.ui-icon-star{background-position:-224px -112px}.ui-icon-link{background-position:-240px -112px}.ui-icon-cancel{background-position:0 -128px}.ui-icon-plus{background-position:-16px -128px}.ui-icon-plusthick{background-position:-32px -128px}.ui-icon-minus{background-position:-48px -128px}.ui-icon-minusthick{background-position:-64px -128px}.ui-icon-close{background-position:-80px -128px}.ui-icon-closethick{background-position:-96px -128px}.ui-icon-key{background-position:-112px -128px}.ui-icon-lightbulb{background-position:-128px -128px}.ui-icon-scissors{background-position:-144px -128px}.ui-icon-clipboard{background-position:-160px -128px}.ui-icon-copy{background-position:-176px -128px}.ui-icon-contact{background-position:-192px -128px}.ui-icon-image{background-position:-208px -128px}.ui-icon-video{background-position:-224px -128px}.ui-icon-script{background-position:-240px -128px}.ui-icon-alert{background-position:0 -144px}.ui-icon-info{background-position:-16px -144px}.ui-icon-notice{background-position:-32px -144px}.ui-icon-help{background-position:-48px -144px}.ui-icon-check{background-position:-64px -144px}.ui-icon-bullet{background-position:-80px -144px}.ui-icon-radio-on{background-position:-96px -144px}.ui-icon-radio-off{background-position:-112px -144px}.ui-icon-pin-w{background-position:-128px -144px}.ui-icon-pin-s{background-position:-144px -144px}.ui-icon-play{background-position:0 -160px}.ui-icon-pause{background-position:-16px -160px}.ui-icon-seek-next{background-position:-32px -160px}.ui-icon-seek-prev{background-position:-48px -160px}.ui-icon-seek-end{background-position:-64px -160px}.ui-icon-seek-start{background-position:-80px -160px}.ui-icon-seek-first{background-position:-80px -160px}.ui-icon-stop{background-position:-96px -160px}.ui-icon-eject{background-position:-112px -160px}.ui-icon-volume-off{background-position:-128px -160px}.ui-icon-volume-on{background-position:-144px -160px}.ui-icon-power{background-position:0 -176px}.ui-icon-signal-diag{background-position:-16px -176px}.ui-icon-signal{background-position:-32px -176px}.ui-icon-battery-0{background-position:-48px -176px}.ui-icon-battery-1{background-position:-64px -176px}.ui-icon-battery-2{background-position:-80px -176px}.ui-icon-battery-3{background-position:-96px -176px}.ui-icon-circle-plus{background-position:0 -192px}.ui-icon-circle-minus{background-position:-16px -192px}.ui-icon-circle-close{background-position:-32px -192px}.ui-icon-circle-triangle-e{background-position:-48px -192px}.ui-icon-circle-triangle-s{background-position:-64px -192px}.ui-icon-circle-triangle-w{background-position:-80px -192px}.ui-icon-circle-triangle-n{background-position:-96px -192px}.ui-icon-circle-arrow-e{background-position:-112px -192px}.ui-icon-circle-arrow-s{background-position:-128px -192px}.ui-icon-circle-arrow-w{background-position:-144px -192px}.ui-icon-circle-arrow-n{background-position:-160px -192px}.ui-icon-circle-zoomin{background-position:-176px -192px}.ui-icon-circle-zoomout{background-position:-192px -192px}.ui-icon-circle-check{background-position:-208px -192px}.ui-icon-circlesmall-plus{background-position:0 -208px}.ui-icon-circlesmall-minus{background-position:-16px -208px}.ui-icon-circlesmall-close{background-position:-32px -208px}.ui-icon-squaresmall-plus{background-position:-48px -208px}.ui-icon-squaresmall-minus{background-position:-64px -208px}.ui-icon-squaresmall-close{background-position:-80px -208px}.ui-icon-grip-dotted-vertical{background-position:0 -224px}.ui-icon-grip-dotted-horizontal{background-position:-16px -224px}.ui-icon-grip-solid-vertical{background-position:-32px -224px}.ui-icon-grip-solid-horizontal{background-position:-48px -224px}.ui-icon-gripsmall-diagonal-se{background-position:-64px -224px}.ui-icon-grip-diagonal-se{background-position:-80px -224px}.ui-corner-all,.ui-corner-top,.ui-corner-left,.ui-corner-tl{-moz-border-radius-topleft:4px;-webkit-border-top-left-radius:4px;-khtml-border-top-left-radius:4px;border-top-left-radius:4px}.ui-corner-all,.ui-corner-top,.ui-corner-right,.ui-corner-tr{-moz-border-radius-topright:4px;-webkit-border-top-right-radius:4px;-khtml-border-top-right-radius:4px;border-top-right-radius:4px}.ui-corner-all,.ui-corner-bottom,.ui-corner-left,.ui-corner-bl{-moz-border-radius-bottomleft:4px;-webkit-border-bottom-left-radius:4px;-khtml-border-bottom-left-radius:4px;border-bottom-left-radius:4px}.ui-corner-all,.ui-corner-bottom,.ui-corner-right,.ui-corner-br{-moz-border-radius-bottomright:4px;-webkit-border-bottom-right-radius:4px;-khtml-border-bottom-right-radius:4px;border-bottom-right-radius:4px}.ui-widget-overlay{background:#aaa;opacity:.3;filter:alpha(opacity=30)}.ui-widget-shadow{margin:-8px 0 0 -8px;padding:8px;background:#aaaaaa;opacity:.3;filter:alpha(opacity=30);-moz-border-radius:8px;-khtml-border-radius:8px;-webkit-border-radius:8px;border-radius:8px}.ui-button,.ui-button.ui-state-default,.ui-slider .ui-slider-handle{-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05)}.ui-buttonset .ui-button.ui-state-active,.ui-slider .ui-slider-handle.ui-state-active{background-image:none;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05)}.ui-button[disabled],.ui-button.ui-state-disabled{background-image:none;opacity:0.65;filter:alpha(opacity=65)}.ui-tabs{border:0}.ui-tabs .ui-tabs-nav{margin-bottom:5px;border-width:0 0 1px;border-bottom-color:#ddd;background:transparent;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.ui-tabs .ui-tabs-nav li{padding-bottom:1px;border-color:transparent;background:none;filter:none}.ui-tabs .ui-tabs-nav li a{padding:0 15px;line-height:34px;color:#0088CC}.ui-tabs .ui-tabs-nav li:hover{background:#eee}.ui-tabs .ui-tabs-nav li a:hover{color:#005580}.ui-tabs .ui-tabs-nav li.ui-tabs-active,.ui-tabs .ui-tabs-nav li.ui-tabs-active:hover{border:1px solid #ddd;border-bottom-color:#fff;background:#fff}.ui-tabs .ui-tabs-nav li.ui-tabs-active a{color:#555}.ui-tabs .ui-tabs-panel{padding:0}.ui-dialog{padding:0;-webkit-box-shadow:0 3px 7px rgba(0,0,0,0.3);-moz-box-shadow:0 3px 7px rgba(0,0,0,0.3);box-shadow:0 3px 7px rgba(0,0,0,0.3)}.ui-dialog .ui-dialog-titlebar{padding:9px 15px;border-width:0 0 1px;border-color:#eee;font-size:18px;background:transparent;-webkit-border-radius:0;-khtml-border-radius:0;-moz-border-radius:0;border-radius:0;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.ui-dialog .ui-dialog-titlebar-close{right:15px}.ui-dialog a.ui-dialog-titlebar-close{color:#CCC}.ui-dialog a.ui-dialog-titlebar-close.ui-state-hover{border:none;background:transparent}.ui-dialog a.ui-dialog-titlebar-close:hover,.ui-dialog a.ui-dialog-titlebar-close:focus{padding:1px;color:#454545}.ui-dialog .ui-dialog-buttonpane{border-color:#ddd;background:#f5f5f5;text-align:right;-webkit-box-shadow:inset 0 1px 0 #ffffff;-moz-box-shadow:inset 0 1px 0 #ffffff;box-shadow:inset 0 1px 0 #ffffff}.ui-datepicker{width:20em;padding:0}.ui-datepicker .ui-datepicker-header{border-width:0 0 1px;border-color:#ddd;background:#f6f6f6;-webkit-border-radius:4px 4px 0 0;-khtml-border-radius:4px 4px 0 0;-moz-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0}.ui-datepicker .ui-datepicker-prev-hover,.ui-datepicker .ui-datepicker-next-hover{top:2px;border:0;background:transparent}.ui-datepicker .ui-datepicker-prev-hover{left:2px}.ui-datepicker .ui-datepicker-next-hover{right:2px}.ui-datepicker td .ui-state-default{padding:5px;border:none;background:transparent;text-align:center;-webkit-box-shadow:0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:0 1px 2px rgba(0,0,0,0.05);box-shadow:0 1px 2px rgba(0,0,0,0.05);-webkit-border-radius:4px;-khtml-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.ui-datepicker th{color:#555}.ui-datepicker td.ui-datepicker-week-col{padding-left:5px}.ui-datepicker td .ui-state-active{background:#bfbfbf;color:#fff}.ui-accordion .ui-accordion-content{padding:1em}.ui-spinner{border:0}.ui-spinner .ui-spinner-input{margin:0}.ui-spinner a.ui-spinner-button{border:1px solid #ddd}.ui-spinner a.ui-spinner-up{border-bottom-width:0}.ui-spinner a.ui-spinner-down{border-top-width:0}.ui-menu .ui-menu-item a{padding:6px .5em}.ui-menu .ui-menu-item a.ui-state-focus,.ui-menu .ui-menu-item a.ui-state-active{margin:0}.ui-menu .ui-menu-item a.ui-state-active{border:0}.ui-tooltip{border:0;background:transparent;opacity:0.8;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.ui-tooltip .ui-tooltip-content{padding:3px 8px;background:#000;color:#fff;-webkit-border-radius:4px;-khtml-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.ui-autocomplete{z-index:3 !important}.ui-progressbar .ui-progressbar-value,.ui-slider .ui-slider-range,.ui-menu .ui-menu-item a.ui-state-focus,.ui-menu .ui-menu-item a.ui-state-active,.ui-widget-content .ui-priority-primary,.ui-datepicker td .ui-state-hover,.ui-datepicker .ui-datepicker-today a{background-color:#006dcc;background-image:-khtml-gradient(linear, left top, left bottom, from(#08c), to(#04c));background-image:-moz-linear-gradient(top, #08c, #04c);background-image:-ms-linear-gradient(top, #08c, #04c);background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #08c), color-stop(100%, #04c));background-image:-webkit-linear-gradient(top, #08c, #04c);background-image:-o-linear-gradient(top, #08c, #04c);background-image:linear-gradient(top, #08c, #04c);color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25)}.ui-button.ui-priority-primary{border-color:#04c #04c #002a80}.ui-priority-primary.ui-state-hover{background-color:#04c;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.ui-icon.ui-icon-inline{display:inline-block}.ui-progressbar-striped .ui-progressbar-value{background-color:#0079CC;background-image:-webkit-gradient(linear, 0 100%, 100% 0, color-stop(.25, rgba(255,255,255,0.15)), color-stop(.25, transparent), color-stop(.5, transparent), color-stop(.5, rgba(255,255,255,0.15)), color-stop(.75, rgba(255,255,255,0.15)), color-stop(.75, transparent), to(transparent));background-image:-webkit-linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);background-image:-moz-linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);background-image:-o-linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);background-image:linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);-webkit-background-size:4em 4em;-moz-background-size:4em 4em;-o-background-size:4em 4em;background-size:4em 4em}@-webkit-keyframes progressbar-stripes{from{background-position:4em 0}to{background-position:0 0}}@-moz-keyframes progressbar-stripes{from{background-position:4em 0}to{background-position:0 0}}@-o-keyframes progressbar-stripes{from{background-position:0 0}to{background-position:4em 0}}@keyframes progressbar-stripes{from{background-position:4em 0}to{background-position:0 0}}.ui-progressbar-striped.ui-progressbar-animated .ui-progressbar-value{-webkit-animation:progressbar-stripes 1.5s linear infinite;-moz-animation:progressbar-stripes 1.5s linear infinite;-ms-animation:progressbar-stripes 1.5s linear infinite;-o-animation:progressbar-stripes 1.5s linear infinite;animation:progressbar-stripes 1.5s linear infinite} \ No newline at end of file diff --git a/public/css/custom.css b/public/css/custom.css new file mode 100644 index 0000000..3cd0e32 --- /dev/null +++ b/public/css/custom.css @@ -0,0 +1,6 @@ +.success { + background-color: #a0ff80 !important; +} +.warning { + background-color: #ffe050 !important; +} diff --git a/public/fonts/FontAwesome.otf b/public/fonts/FontAwesome.otf new file mode 100644 index 0000000..401ec0f Binary files /dev/null and b/public/fonts/FontAwesome.otf differ diff --git a/public/fonts/fontawesome-webfont.eot b/public/fonts/fontawesome-webfont.eot new file mode 100644 index 0000000..e9f60ca Binary files /dev/null and b/public/fonts/fontawesome-webfont.eot differ diff --git a/public/fonts/fontawesome-webfont.svg b/public/fonts/fontawesome-webfont.svg new file mode 100644 index 0000000..855c845 --- /dev/null +++ b/public/fonts/fontawesome-webfont.svg @@ -0,0 +1,2671 @@ + + + + +Created by FontForge 20120731 at Mon Oct 24 17:37:40 2016 + By ,,, +Copyright Dave Gandy 2016. All rights reserved. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/fonts/fontawesome-webfont.ttf b/public/fonts/fontawesome-webfont.ttf new file mode 100644 index 0000000..35acda2 Binary files /dev/null and b/public/fonts/fontawesome-webfont.ttf differ diff --git a/public/fonts/fontawesome-webfont.woff b/public/fonts/fontawesome-webfont.woff new file mode 100644 index 0000000..400014a Binary files /dev/null and b/public/fonts/fontawesome-webfont.woff differ diff --git a/public/fonts/fontawesome-webfont.woff2 b/public/fonts/fontawesome-webfont.woff2 new file mode 100644 index 0000000..4d13fc6 Binary files /dev/null and b/public/fonts/fontawesome-webfont.woff2 differ diff --git a/public/fonts/glyphicons-halflings-regular.eot b/public/fonts/glyphicons-halflings-regular.eot new file mode 100644 index 0000000..b93a495 Binary files /dev/null and b/public/fonts/glyphicons-halflings-regular.eot differ diff --git a/public/fonts/glyphicons-halflings-regular.svg b/public/fonts/glyphicons-halflings-regular.svg new file mode 100644 index 0000000..94fb549 --- /dev/null +++ b/public/fonts/glyphicons-halflings-regular.svg @@ -0,0 +1,288 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/fonts/glyphicons-halflings-regular.ttf b/public/fonts/glyphicons-halflings-regular.ttf new file mode 100644 index 0000000..1413fc6 Binary files /dev/null and b/public/fonts/glyphicons-halflings-regular.ttf differ diff --git a/public/fonts/glyphicons-halflings-regular.woff b/public/fonts/glyphicons-halflings-regular.woff new file mode 100644 index 0000000..9e61285 Binary files /dev/null and b/public/fonts/glyphicons-halflings-regular.woff differ diff --git a/public/fonts/glyphicons-halflings-regular.woff2 b/public/fonts/glyphicons-halflings-regular.woff2 new file mode 100644 index 0000000..64539b5 Binary files /dev/null and b/public/fonts/glyphicons-halflings-regular.woff2 differ diff --git a/public/images/Isotipo 16.png b/public/images/Isotipo 16.png new file mode 100644 index 0000000..9ff2811 Binary files /dev/null and b/public/images/Isotipo 16.png differ diff --git a/public/images/Isotipo 32.png b/public/images/Isotipo 32.png new file mode 100644 index 0000000..981a219 Binary files /dev/null and b/public/images/Isotipo 32.png differ diff --git a/public/images/Isotipo 64.png b/public/images/Isotipo 64.png new file mode 100644 index 0000000..8b503d1 Binary files /dev/null and b/public/images/Isotipo 64.png differ diff --git a/public/images/logo_cabezal.png b/public/images/logo_cabezal.png new file mode 100644 index 0000000..29fd059 Binary files /dev/null and b/public/images/logo_cabezal.png differ diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..e93e8eb --- /dev/null +++ b/public/index.php @@ -0,0 +1,88 @@ + microtime(true)]; + } +} + +Carbon::setLocale(config('app.locale')); +setlocale(LC_TIME, 'es_ES'); + +sanitize(); + +try { + Auth::isIn(); +} catch (PDOException $e) { + header('Location: install'); + die(); +} +if (Auth::isIn()) { + if ((get('p') !== false or get('page') !== false or get('m') !== false or get('module') !== false)) { + if (($route = route()) !== false) { + echo $route; + } else { + echo view('construccion'); + } + } else { + $proyectos = model(Proyecto::class)->findMany(); + $dias = []; + $cierres = []; + $pendientes = 0; + $hoy = 0; + foreach ($proyectos as $proyecto) { + $pendientes += $proyecto->cuotasPendientes(); + $hoy += $proyecto->cuotasHoy(); + foreach ($proyecto->cuotasMes() as $cuota) { + $f = $cuota->pago()->fecha(); + if ($f->isoWeekday() == 6 or $f->isoWeekDay() == 7) { + $f = $f->copy()->addDays(2)->startOfWeek(); + } + $dia = $f->format('Y-m-d'); + if (!isset($dias[$dia])) { + $dias[$dia] = [$proyecto->descripcion => 0]; + } + if (!isset($dias[$dia][$proyecto->descripcion])) { + $dias[$dia][$proyecto->descripcion] = 0; + } + $dias[$dia][$proyecto->descripcion] ++; + } + if (count($proyecto->cierres()) > 0) { + $cierres[$proyecto->descripcion] = (object) ['total' => count($proyecto->cierres()),'vigentes' => $proyecto->cierres(3), 'rechazados' => $proyecto->cierres(-1), 'pendientes' => $proyecto->cierres(2)]; + } + } + uksort($dias, function($a, $b) { + return strcmp($a, $b); + }); + uksort($cierres, function($a, $b) { + return strcmp($a, $b); + }); + echo view('home', compact('pendientes', 'hoy', 'dias', 'cierres')); + } +} elseif (get('p') == 'auth' or get('page') == 'auth') { + $route = route(); + if ($route !== false) { + echo $route; + } else { + echo view('guest'); + } +} else { + echo view('guest'); +} + +if (config('app.debug') == 'true') { + if (config('app.benchmark') == 'true') { + $benchmark->time = microtime(true) - $benchmark->time; + if (get('ajax') != '1' and get('p') != 'ajax' and get('p') != 'informes') { + echo view('benchmark', compact('benchmark')); + } + } +} +?> diff --git a/public/install/create_admin.php b/public/install/create_admin.php new file mode 100644 index 0000000..5d03999 --- /dev/null +++ b/public/install/create_admin.php @@ -0,0 +1,40 @@ +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(); + echo 'Created'; + } + $role = Model::factory(\Incoviba\common\Role::class)->where('description', 'administrador')->findOne(); + if ($role == false) { + $role = Model::factory(\Incoviba\common\Role::class)->create(['description' => 'administrador']); + $role->save(); + } + $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(); + } + $perm = Model::factory(\Incoviba\common\Permission::class)->where('type', 2)->where('ext_id', $role->id)->where('all', 1)->where('access', 1)->findOne(); + if ($perm == false) { + $perm = Model::factory(\Incoviba\common\Permission::class)->create([ + 'type' => 2, + 'ext_id' => $role->id, + 'all' => 1, + 'access' => 1 + ]); + $perm->save(); + } + header('Location: next_step.php?step=create_admin'); +} else { + echo view('install.admin'); +} +?> diff --git a/public/install/create_guest.php b/public/install/create_guest.php new file mode 100644 index 0000000..53492ba --- /dev/null +++ b/public/install/create_guest.php @@ -0,0 +1,36 @@ +where('name', 'guest')->findOne(); +if ($user === false) { + $user = Model::factory(\Incoviba\common\User::class)->create(['name' => 'guest']); + $user->save(); +} +$role = Model::factory(\Incoviba\common\Role::class)->where('description', 'guest')->findOne(); +if ($role === false) { + $role = Model::factory(\Incoviba\common\Role::class)->create(['description' => 'guest']); + $role->save(); +} +$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(); +} +$locations = Model::factory(\Incoviba\common\Location::class)->where('controller', 'auth')->findMany(); +foreach ($locations as $location) { + $permission = Model::factory(\Incoviba\common\Permission::class)->where('type', 2)->where('ext_id', $role->id)->where('access', 1)->where('location', $location->id)->findOne(); + if ($permission === false) { + $permission = Model::factory(\Incoviba\common\Permission::class)->create([ + 'type' => 2, + 'ext_id' => $role->id, + 'access' => 1, + 'location' => $location->id + ]); + $permission->save(); + } +} + +header('Location: next_step.php?step=create_guest'); +?> diff --git a/public/install/create_user_base.php b/public/install/create_user_base.php new file mode 100644 index 0000000..4fe56d4 --- /dev/null +++ b/public/install/create_user_base.php @@ -0,0 +1,128 @@ + 0) { + $q .= ', PRIMARY KEY (' . implode(', ', $keys) . ')'; + } + if (count($foreigns) > 0) { + $q .= ', CONSTRAINT ' . implode(', CONSTRAINT ', $foreigns); + } + $q .= ') ENGINE=InnoDB DEFAULT CHARSET=utf8;'; + + return $q; +} + +$cnt = 0; +$queries = []; +foreach ($models as $model) { + $class = '\\Incoviba\\common\\' . $model; + $ref = new ReflectionClass($class); + + $table = $ref->getProperty('_table')->getValue(); + $comments = explode(PHP_EOL, $ref->getDocComment()); + + $columns = []; + $keys = []; + $foreigns = []; + foreach ($comments as $comment) { + if (strpos($comment, '@property') === false) { + continue; + } + $info = explode(' ', substr($comment, strpos($comment, '@property') + strlen('@property '))); + $column = extractColumn($table, $info, $keys, $foreigns); + + $columns []= columnQuery($column); + } + + $q = tableQuery($table, $columns, $keys, $foreigns); + $queries []= $q; +} +try { + \ORM::getDb()->beginTransaction(); + foreach ($queries as $q) { + \ORM::getDb()->query($q); + } + \ORM::getDb()->commit(); + header('Location: next_step.php?step=create_user_base'); +} catch (Exception $e) { + \ORM::getDb()->rollBack(); + throw $e; +} +?> diff --git a/public/install/end_install.php b/public/install/end_install.php new file mode 100644 index 0000000..94eafcc --- /dev/null +++ b/public/install/end_install.php @@ -0,0 +1,7 @@ + diff --git a/public/install/index.php b/public/install/index.php new file mode 100644 index 0000000..9a5d75c --- /dev/null +++ b/public/install/index.php @@ -0,0 +1,7 @@ + diff --git a/public/install/log_locations.php b/public/install/log_locations.php new file mode 100644 index 0000000..9de5bc5 --- /dev/null +++ b/public/install/log_locations.php @@ -0,0 +1,39 @@ +underscored(); + $class = '\\App\\Controller\\' . $name; + $ref = new ReflectionClass($class); + $methods = $ref->getMethods(ReflectionMethod::IS_STATIC); + + try { + foreach ($methods as $method) { + $data = [ + 'controller' => $controller, + 'action' => $method->name + ]; + $location = Model::factory(\Incoviba\common\Location::class)->where('controller', $controller)->where('action', $method->name)->findOne(); + if ($location !== false) { + continue; + } + + $location = Model::factory(\Incoviba\common\Location::class)->create($data); + $location->save(); + $cnt ++; + } + } catch (Exception $e) { + d($e); + $errors ++; + } +} + +if ($errors == 0) { + header('Location: next_step.php?step=log_locations'); +} +?> diff --git a/public/install/next_step.php b/public/install/next_step.php new file mode 100644 index 0000000..c370b67 --- /dev/null +++ b/public/install/next_step.php @@ -0,0 +1,20 @@ + diff --git a/public/js/admin.js b/public/js/admin.js new file mode 100644 index 0000000..a5a69bc --- /dev/null +++ b/public/js/admin.js @@ -0,0 +1,81 @@ +$(document).ready(function() { + $('#databases').submit(function(e) { + e.preventDefault(); + + var db = $("[name='database']").val(); + var models = []; + var namespaces = []; + $.post('?p=admin&action=listModels', {"database": db}).done(function(data) { + //console.debug(data); + var info = $.parseJSON(data); + //console.debug(info.models); + + models = info.models; + //console.debug(models); + + $.post('?p=admin&action=listNamespaces').done(function(data) { + //console.debug(data); + info = $.parseJSON(data); + //console.debug(info.models); + + namespaces = info.namespaces; + //console.debug(namespaces); + + $.each(models, function(i, elem) { + var div = $('
').attr('class', 'row'); + div.append($('
').attr('class', 'col-md-2').html(elem.model)); + var div2 = $('
').attr('class', 'row'); + $.each(namespaces, function(j, ns) { + div2.append($('
').attr('class', 'col-md-3').append($('').attr('class', 'ns').attr('data-table', elem.table).attr('data-ns', ns).html(ns))); + }); + div.append($('
').attr('class', 'col-md-9').append(div2)); + div.append($('
').attr('class', 'col-md-1 remove').append($('').attr('class', 'glyphicon glyphicon-remove'))); + $('#results').append(div); + }); + + $('.ns').css('cursor', 'pointer'); + $('.remove').css('cursor', 'pointer'); + + $('.ns').mouseover(function(e) { + $(this).parent().addClass('bg-success'); + $(this).parent().parent().parent().parent().addClass('bg-warning'); + }).mouseout(function(e) { + $(this).parent().removeClass('bg-success'); + $(this).parent().parent().parent().parent().removeClass('bg-warning'); + }); + + $('.remove').mouseover(function(e) { + $(this).parent().addClass('bg-danger'); + }).mouseout(function(e) { + $(this).parent().removeClass('bg-danger'); + }); + + $('.ns').click(function(e) { + var table = $(this).attr('data-table'); + var ns = $(this).attr('data-ns'); + execute(table, ns); + }); + $('.remove').click(function(e) { + $(this).parent().remove(); + }); + }); + }); + + return false; + }); +}); + +function execute(table, ns) { + console.debug(table, ns); + var db = $("[name='database']").val(); + $.post('?p=admin&action=createModel', {"table": table, "namespace": ns, "database": db}).done(function(data) { + console.debug(data); + var info = $.parseJSON(data); + console.debug(info); + if (info.result) { + $(".ns[data-table='" + table + "']").parent().parent().parent().parent().remove(); + } else { + alert('Error'); + } + }); +} \ No newline at end of file diff --git a/public/js/app.js b/public/js/app.js new file mode 100644 index 0000000..7e4c9f3 --- /dev/null +++ b/public/js/app.js @@ -0,0 +1,89 @@ +!function(e){var a={};function i(t){if(a[t])return a[t].exports;var n=a[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,i),n.l=!0,n.exports}i.m=e,i.c=a,i.d=function(e,a,t){i.o(e,a)||Object.defineProperty(e,a,{enumerable:!0,get:t})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,a){if(1&a&&(e=i(e)),8&a)return e;if(4&a&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(i.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&a&&"string"!=typeof e)for(var n in e)i.d(t,n,function(a){return e[a]}.bind(null,n));return t},i.n=function(e){var a=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(a,"a",a),a},i.o=function(e,a){return Object.prototype.hasOwnProperty.call(e,a)},i.p="",i(i.s=219)}([function(e,a,i){(function(e){e.exports=function(){"use strict";var a,t;function n(){return a.apply(null,arguments)}function r(e){return e instanceof Array||"[object Array]"===Object.prototype.toString.call(e)}function s(e){return null!=e&&"[object Object]"===Object.prototype.toString.call(e)}function o(e){return void 0===e}function l(e){return"number"==typeof e||"[object Number]"===Object.prototype.toString.call(e)}function d(e){return e instanceof Date||"[object Date]"===Object.prototype.toString.call(e)}function c(e,a){var i,t=[];for(i=0;i>>0,t=0;t0)for(i=0;i=0;return(r?i?"+":"":"-")+Math.pow(10,Math.max(0,n)).toString().substr(1)+t}var I=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,F=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,N={},R={};function $(e,a,i,t){var n=t;"string"==typeof t&&(n=function(){return this[t]()}),e&&(R[e]=n),a&&(R[a[0]]=function(){return W(n.apply(this,arguments),a[1],a[2])}),i&&(R[i]=function(){return this.localeData().ordinal(n.apply(this,arguments),e)})}function B(e){return e.match(/\[[\s\S]/)?e.replace(/^\[|\]$/g,""):e.replace(/\\/g,"")}function V(e,a){return e.isValid()?(a=U(a,e.localeData()),N[a]=N[a]||function(e){var a,i,t=e.match(I);for(a=0,i=t.length;a=0&&F.test(e);)e=e.replace(F,t),F.lastIndex=0,i-=1;return e}var J=/\d/,G=/\d\d/,K=/\d{3}/,Z=/\d{4}/,X=/[+-]?\d{6}/,Q=/\d\d?/,ee=/\d\d\d\d?/,ae=/\d\d\d\d\d\d?/,ie=/\d{1,3}/,te=/\d{1,4}/,ne=/[+-]?\d{1,6}/,re=/\d+/,se=/[+-]?\d+/,oe=/Z|[+-]\d\d:?\d\d/gi,le=/Z|[+-]\d\d(?::?\d\d)?/gi,de=/[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,ce={};function ue(e,a,i){ce[e]=T(a)?a:function(e,t){return e&&i?i:a}}function me(e,a){return u(ce,e)?ce[e](a._strict,a._locale):new RegExp(function(e){return he(e.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(e,a,i,t,n){return a||i||t||n}))}(e))}function he(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}var ge={};function pe(e,a){var i,t=a;for("string"==typeof e&&(e=[e]),l(a)&&(t=function(e,i){i[a]=x(e)}),i=0;i68?1900:2e3)};var De,Te=qe("FullYear",!0);function qe(e,a){return function(i){return null!=i?(He(this,e,i),n.updateOffset(this,a),this):Se(this,e)}}function Se(e,a){return e.isValid()?e._d["get"+(e._isUTC?"UTC":"")+a]():NaN}function He(e,a,i){e.isValid()&&!isNaN(i)&&("FullYear"===a&&Ye(e.year())&&1===e.month()&&29===e.date()?e._d["set"+(e._isUTC?"UTC":"")+a](i,e.month(),Ce(i,e.month())):e._d["set"+(e._isUTC?"UTC":"")+a](i))}function Ce(e,a){if(isNaN(e)||isNaN(a))return NaN;var i=function(e,a){return(e%a+a)%a}(a,12);return e+=(a-i)/12,1===i?Ye(e)?29:28:31-i%7%2}De=Array.prototype.indexOf?Array.prototype.indexOf:function(e){var a;for(a=0;a=0&&isFinite(a.getUTCFullYear())&&a.setUTCFullYear(e),a}function $e(e,a,i){var t=7+a-i,n=(7+Re(e,0,t).getUTCDay()-a)%7;return-n+t-1}function Be(e,a,i,t,n){var r,s,o=(7+i-t)%7,l=$e(e,t,n),d=1+7*(a-1)+o+l;return d<=0?s=Le(r=e-1)+d:d>Le(e)?(r=e+1,s=d-Le(e)):(r=e,s=d),{year:r,dayOfYear:s}}function Ve(e,a,i){var t,n,r=$e(e.year(),a,i),s=Math.floor((e.dayOfYear()-r-1)/7)+1;return s<1?(n=e.year()-1,t=s+Ue(n,a,i)):s>Ue(e.year(),a,i)?(t=s-Ue(e.year(),a,i),n=e.year()+1):(n=e.year(),t=s),{week:t,year:n}}function Ue(e,a,i){var t=$e(e,a,i),n=$e(e+1,a,i);return(Le(e)-t+n)/7}$("w",["ww",2],"wo","week"),$("W",["WW",2],"Wo","isoWeek"),C("week","w"),C("isoWeek","W"),E("week",5),E("isoWeek",5),ue("w",Q),ue("ww",Q,G),ue("W",Q),ue("WW",Q,G),be(["w","ww","W","WW"],function(e,a,i,t){a[t.substr(0,1)]=x(e)}),$("d",0,"do","day"),$("dd",0,0,function(e){return this.localeData().weekdaysMin(this,e)}),$("ddd",0,0,function(e){return this.localeData().weekdaysShort(this,e)}),$("dddd",0,0,function(e){return this.localeData().weekdays(this,e)}),$("e",0,0,"weekday"),$("E",0,0,"isoWeekday"),C("day","d"),C("weekday","e"),C("isoWeekday","E"),E("day",11),E("weekday",11),E("isoWeekday",11),ue("d",Q),ue("e",Q),ue("E",Q),ue("dd",function(e,a){return a.weekdaysMinRegex(e)}),ue("ddd",function(e,a){return a.weekdaysShortRegex(e)}),ue("dddd",function(e,a){return a.weekdaysRegex(e)}),be(["dd","ddd","dddd"],function(e,a,i,t){var n=i._locale.weekdaysParse(e,t,i._strict);null!=n?a.d=n:g(i).invalidWeekday=e}),be(["d","e","E"],function(e,a,i,t){a[t]=x(e)});var Je="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),Ge="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),Ke="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),Ze=de,Xe=de,Qe=de;function ea(){function e(e,a){return a.length-e.length}var a,i,t,n,r,s=[],o=[],l=[],d=[];for(a=0;a<7;a++)i=h([2e3,1]).day(a),t=this.weekdaysMin(i,""),n=this.weekdaysShort(i,""),r=this.weekdays(i,""),s.push(t),o.push(n),l.push(r),d.push(t),d.push(n),d.push(r);for(s.sort(e),o.sort(e),l.sort(e),d.sort(e),a=0;a<7;a++)o[a]=he(o[a]),l[a]=he(l[a]),d[a]=he(d[a]);this._weekdaysRegex=new RegExp("^("+d.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+l.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+o.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+s.join("|")+")","i")}function aa(){return this.hours()%12||12}function ia(e,a){$(e,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),a)})}function ta(e,a){return a._meridiemParse}$("H",["HH",2],0,"hour"),$("h",["hh",2],0,aa),$("k",["kk",2],0,function(){return this.hours()||24}),$("hmm",0,0,function(){return""+aa.apply(this)+W(this.minutes(),2)}),$("hmmss",0,0,function(){return""+aa.apply(this)+W(this.minutes(),2)+W(this.seconds(),2)}),$("Hmm",0,0,function(){return""+this.hours()+W(this.minutes(),2)}),$("Hmmss",0,0,function(){return""+this.hours()+W(this.minutes(),2)+W(this.seconds(),2)}),ia("a",!0),ia("A",!1),C("hour","h"),E("hour",13),ue("a",ta),ue("A",ta),ue("H",Q),ue("h",Q),ue("k",Q),ue("HH",Q,G),ue("hh",Q,G),ue("kk",Q,G),ue("hmm",ee),ue("hmmss",ae),ue("Hmm",ee),ue("Hmmss",ae),pe(["H","HH"],we),pe(["k","kk"],function(e,a,i){var t=x(e);a[we]=24===t?0:t}),pe(["a","A"],function(e,a,i){i._isPm=i._locale.isPM(e),i._meridiem=e}),pe(["h","hh"],function(e,a,i){a[we]=x(e),g(i).bigHour=!0}),pe("hmm",function(e,a,i){var t=e.length-2;a[we]=x(e.substr(0,t)),a[_e]=x(e.substr(t)),g(i).bigHour=!0}),pe("hmmss",function(e,a,i){var t=e.length-4,n=e.length-2;a[we]=x(e.substr(0,t)),a[_e]=x(e.substr(t,2)),a[xe]=x(e.substr(n)),g(i).bigHour=!0}),pe("Hmm",function(e,a,i){var t=e.length-2;a[we]=x(e.substr(0,t)),a[_e]=x(e.substr(t))}),pe("Hmmss",function(e,a,i){var t=e.length-4,n=e.length-2;a[we]=x(e.substr(0,t)),a[_e]=x(e.substr(t,2)),a[xe]=x(e.substr(n))});var na,ra=qe("Hours",!0),sa={calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},longDateFormat:{LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},invalidDate:"Invalid date",ordinal:"%d",dayOfMonthOrdinalParse:/\d{1,2}/,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},months:Pe,monthsShort:Oe,week:{dow:0,doy:6},weekdays:Je,weekdaysMin:Ke,weekdaysShort:Ge,meridiemParse:/[ap]\.?m?\.?/i},oa={},la={};function da(e){return e?e.toLowerCase().replace("_","-"):e}function ca(a){var t=null;if(!oa[a]&&void 0!==e&&e&&e.exports)try{t=na._abbr,i(168)("./"+a),ua(t)}catch(e){}return oa[a]}function ua(e,a){var i;return e&&((i=o(a)?ha(e):ma(e,a))?na=i:"undefined"!=typeof console&&console.warn&&console.warn("Locale "+e+" not found. Did you forget to load it?")),na._abbr}function ma(e,a){if(null!==a){var i,t=sa;if(a.abbr=e,null!=oa[e])D("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),t=oa[e]._config;else if(null!=a.parentLocale)if(null!=oa[a.parentLocale])t=oa[a.parentLocale]._config;else{if(null==(i=ca(a.parentLocale)))return la[a.parentLocale]||(la[a.parentLocale]=[]),la[a.parentLocale].push({name:e,config:a}),null;t=i._config}return oa[e]=new S(q(t,a)),la[e]&&la[e].forEach(function(e){ma(e.name,e.config)}),ua(e),oa[e]}return delete oa[e],null}function ha(e){var a;if(e&&e._locale&&e._locale._abbr&&(e=e._locale._abbr),!e)return na;if(!r(e)){if(a=ca(e))return a;e=[e]}return function(e){for(var a,i,t,n,r=0;r0;){if(t=ca(n.slice(0,a).join("-")))return t;if(i&&i.length>=a&&j(n,i,!0)>=a-1)break;a--}r++}return na}(e)}function ga(e){var a,i=e._a;return i&&-2===g(e).overflow&&(a=i[ke]<0||i[ke]>11?ke:i[ve]<1||i[ve]>Ce(i[ye],i[ke])?ve:i[we]<0||i[we]>24||24===i[we]&&(0!==i[_e]||0!==i[xe]||0!==i[je])?we:i[_e]<0||i[_e]>59?_e:i[xe]<0||i[xe]>59?xe:i[je]<0||i[je]>999?je:-1,g(e)._overflowDayOfYear&&(ave)&&(a=ve),g(e)._overflowWeeks&&-1===a&&(a=ze),g(e)._overflowWeekday&&-1===a&&(a=Me),g(e).overflow=a),e}function pa(e,a,i){return null!=e?e:null!=a?a:i}function ba(e){var a,i,t,r,s,o=[];if(!e._d){for(t=function(e){var a=new Date(n.now());return e._useUTC?[a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate()]:[a.getFullYear(),a.getMonth(),a.getDate()]}(e),e._w&&null==e._a[ve]&&null==e._a[ke]&&function(e){var a,i,t,n,r,s,o,l;if(null!=(a=e._w).GG||null!=a.W||null!=a.E)r=1,s=4,i=pa(a.GG,e._a[ye],Ve(qa(),1,4).year),t=pa(a.W,1),((n=pa(a.E,1))<1||n>7)&&(l=!0);else{r=e._locale._week.dow,s=e._locale._week.doy;var d=Ve(qa(),r,s);i=pa(a.gg,e._a[ye],d.year),t=pa(a.w,d.week),null!=a.d?((n=a.d)<0||n>6)&&(l=!0):null!=a.e?(n=a.e+r,(a.e<0||a.e>6)&&(l=!0)):n=r}t<1||t>Ue(i,r,s)?g(e)._overflowWeeks=!0:null!=l?g(e)._overflowWeekday=!0:(o=Be(i,t,n,r,s),e._a[ye]=o.year,e._dayOfYear=o.dayOfYear)}(e),null!=e._dayOfYear&&(s=pa(e._a[ye],t[ye]),(e._dayOfYear>Le(s)||0===e._dayOfYear)&&(g(e)._overflowDayOfYear=!0),i=Re(s,0,e._dayOfYear),e._a[ke]=i.getUTCMonth(),e._a[ve]=i.getUTCDate()),a=0;a<3&&null==e._a[a];++a)e._a[a]=o[a]=t[a];for(;a<7;a++)e._a[a]=o[a]=null==e._a[a]?2===a?1:0:e._a[a];24===e._a[we]&&0===e._a[_e]&&0===e._a[xe]&&0===e._a[je]&&(e._nextDay=!0,e._a[we]=0),e._d=(e._useUTC?Re:function(e,a,i,t,n,r,s){var o=new Date(e,a,i,t,n,r,s);return e<100&&e>=0&&isFinite(o.getFullYear())&&o.setFullYear(e),o}).apply(null,o),r=e._useUTC?e._d.getUTCDay():e._d.getDay(),null!=e._tzm&&e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm),e._nextDay&&(e._a[we]=24),e._w&&void 0!==e._w.d&&e._w.d!==r&&(g(e).weekdayMismatch=!0)}}var fa=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,ya=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,ka=/Z|[+-]\d\d(?::?\d\d)?/,va=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/]],wa=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],_a=/^\/?Date\((\-?\d+)/i;function xa(e){var a,i,t,n,r,s,o=e._i,l=fa.exec(o)||ya.exec(o);if(l){for(g(e).iso=!0,a=0,i=va.length;a0&&g(e).unusedInput.push(s),o=o.slice(o.indexOf(i)+i.length),d+=i.length),R[r]?(i?g(e).empty=!1:g(e).unusedTokens.push(r),fe(r,i,e)):e._strict&&!i&&g(e).unusedTokens.push(r);g(e).charsLeftOver=l-d,o.length>0&&g(e).unusedInput.push(o),e._a[we]<=12&&!0===g(e).bigHour&&e._a[we]>0&&(g(e).bigHour=void 0),g(e).parsedDateParts=e._a.slice(0),g(e).meridiem=e._meridiem,e._a[we]=function(e,a,i){var t;return null==i?a:null!=e.meridiemHour?e.meridiemHour(a,i):null!=e.isPM?((t=e.isPM(i))&&a<12&&(a+=12),t||12!==a||(a=0),a):a}(e._locale,e._a[we],e._meridiem),ba(e),ga(e)}else La(e);else xa(e)}function Da(e){var a=e._i,i=e._f;return e._locale=e._locale||ha(e._l),null===a||void 0===i&&""===a?b({nullInput:!0}):("string"==typeof a&&(e._i=a=e._locale.preparse(a)),w(a)?new v(ga(a)):(d(a)?e._d=a:r(i)?function(e){var a,i,t,n,r;if(0===e._f.length)return g(e).invalidFormat=!0,void(e._d=new Date(NaN));for(n=0;nthis?this:e:b()});function Ca(e,a){var i,t;if(1===a.length&&r(a[0])&&(a=a[0]),!a.length)return qa();for(i=a[0],t=1;tr&&(a=r),function(e,a,i,t,n){var r=Be(e,a,i,t,n),s=Re(r.year,0,r.dayOfYear);return this.year(s.getUTCFullYear()),this.month(s.getUTCMonth()),this.date(s.getUTCDate()),this}.call(this,e,a,i,t,n))}$(0,["gg",2],0,function(){return this.weekYear()%100}),$(0,["GG",2],0,function(){return this.isoWeekYear()%100}),ni("gggg","weekYear"),ni("ggggg","weekYear"),ni("GGGG","isoWeekYear"),ni("GGGGG","isoWeekYear"),C("weekYear","gg"),C("isoWeekYear","GG"),E("weekYear",1),E("isoWeekYear",1),ue("G",se),ue("g",se),ue("GG",Q,G),ue("gg",Q,G),ue("GGGG",te,Z),ue("gggg",te,Z),ue("GGGGG",ne,X),ue("ggggg",ne,X),be(["gggg","ggggg","GGGG","GGGGG"],function(e,a,i,t){a[t.substr(0,2)]=x(e)}),be(["gg","GG"],function(e,a,i,t){a[t]=n.parseTwoDigitYear(e)}),$("Q",0,"Qo","quarter"),C("quarter","Q"),E("quarter",7),ue("Q",J),pe("Q",function(e,a){a[ke]=3*(x(e)-1)}),$("D",["DD",2],"Do","date"),C("date","D"),E("date",9),ue("D",Q),ue("DD",Q,G),ue("Do",function(e,a){return e?a._dayOfMonthOrdinalParse||a._ordinalParse:a._dayOfMonthOrdinalParseLenient}),pe(["D","DD"],ve),pe("Do",function(e,a){a[ve]=x(e.match(Q)[0])});var si=qe("Date",!0);$("DDD",["DDDD",3],"DDDo","dayOfYear"),C("dayOfYear","DDD"),E("dayOfYear",4),ue("DDD",ie),ue("DDDD",K),pe(["DDD","DDDD"],function(e,a,i){i._dayOfYear=x(e)}),$("m",["mm",2],0,"minute"),C("minute","m"),E("minute",14),ue("m",Q),ue("mm",Q,G),pe(["m","mm"],_e);var oi=qe("Minutes",!1);$("s",["ss",2],0,"second"),C("second","s"),E("second",15),ue("s",Q),ue("ss",Q,G),pe(["s","ss"],xe);var li,di=qe("Seconds",!1);for($("S",0,0,function(){return~~(this.millisecond()/100)}),$(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),$(0,["SSS",3],0,"millisecond"),$(0,["SSSS",4],0,function(){return 10*this.millisecond()}),$(0,["SSSSS",5],0,function(){return 100*this.millisecond()}),$(0,["SSSSSS",6],0,function(){return 1e3*this.millisecond()}),$(0,["SSSSSSS",7],0,function(){return 1e4*this.millisecond()}),$(0,["SSSSSSSS",8],0,function(){return 1e5*this.millisecond()}),$(0,["SSSSSSSSS",9],0,function(){return 1e6*this.millisecond()}),C("millisecond","ms"),E("millisecond",16),ue("S",ie,J),ue("SS",ie,G),ue("SSS",ie,K),li="SSSS";li.length<=9;li+="S")ue(li,re);function ci(e,a){a[je]=x(1e3*("0."+e))}for(li="S";li.length<=9;li+="S")pe(li,ci);var ui=qe("Milliseconds",!1);$("z",0,0,"zoneAbbr"),$("zz",0,0,"zoneName");var mi=v.prototype;function hi(e){return e}mi.add=Xa,mi.calendar=function(e,a){var i=e||qa(),t=Na(i,this).startOf("day"),r=n.calendarFormat(this,t)||"sameElse",s=a&&(T(a[r])?a[r].call(this,i):a[r]);return this.format(s||this.localeData().calendar(r,this,qa(i)))},mi.clone=function(){return new v(this)},mi.diff=function(e,a,i){var t,n,r;if(!this.isValid())return NaN;if(!(t=Na(e,this)).isValid())return NaN;switch(n=6e4*(t.utcOffset()-this.utcOffset()),a=A(a)){case"year":r=ei(this,t)/12;break;case"month":r=ei(this,t);break;case"quarter":r=ei(this,t)/3;break;case"second":r=(this-t)/1e3;break;case"minute":r=(this-t)/6e4;break;case"hour":r=(this-t)/36e5;break;case"day":r=(this-t-n)/864e5;break;case"week":r=(this-t-n)/6048e5;break;default:r=this-t}return i?r:_(r)},mi.endOf=function(e){return void 0===(e=A(e))||"millisecond"===e?this:("date"===e&&(e="day"),this.startOf(e).add(1,"isoWeek"===e?"week":e).subtract(1,"ms"))},mi.format=function(e){e||(e=this.isUtc()?n.defaultFormatUtc:n.defaultFormat);var a=V(this,e);return this.localeData().postformat(a)},mi.from=function(e,a){return this.isValid()&&(w(e)&&e.isValid()||qa(e).isValid())?Ua({to:this,from:e}).locale(this.locale()).humanize(!a):this.localeData().invalidDate()},mi.fromNow=function(e){return this.from(qa(),e)},mi.to=function(e,a){return this.isValid()&&(w(e)&&e.isValid()||qa(e).isValid())?Ua({from:this,to:e}).locale(this.locale()).humanize(!a):this.localeData().invalidDate()},mi.toNow=function(e){return this.to(qa(),e)},mi.get=function(e){return T(this[e=A(e)])?this[e]():this},mi.invalidAt=function(){return g(this).overflow},mi.isAfter=function(e,a){var i=w(e)?e:qa(e);return!(!this.isValid()||!i.isValid())&&("millisecond"===(a=A(o(a)?"millisecond":a))?this.valueOf()>i.valueOf():i.valueOf()9999?V(i,a?"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYYYY-MM-DD[T]HH:mm:ss.SSSZ"):T(Date.prototype.toISOString)?a?this.toDate().toISOString():new Date(this.valueOf()+60*this.utcOffset()*1e3).toISOString().replace("Z",V(i,"Z")):V(i,a?"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYY-MM-DD[T]HH:mm:ss.SSSZ")},mi.inspect=function(){if(!this.isValid())return"moment.invalid(/* "+this._i+" */)";var e="moment",a="";this.isLocal()||(e=0===this.utcOffset()?"moment.utc":"moment.parseZone",a="Z");var i="["+e+'("]',t=0<=this.year()&&this.year()<=9999?"YYYY":"YYYYYY",n=a+'[")]';return this.format(i+t+"-MM-DD[T]HH:mm:ss.SSS"+n)},mi.toJSON=function(){return this.isValid()?this.toISOString():null},mi.toString=function(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},mi.unix=function(){return Math.floor(this.valueOf()/1e3)},mi.valueOf=function(){return this._d.valueOf()-6e4*(this._offset||0)},mi.creationData=function(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}},mi.year=Te,mi.isLeapYear=function(){return Ye(this.year())},mi.weekYear=function(e){return ri.call(this,e,this.week(),this.weekday(),this.localeData()._week.dow,this.localeData()._week.doy)},mi.isoWeekYear=function(e){return ri.call(this,e,this.isoWeek(),this.isoWeekday(),1,4)},mi.quarter=mi.quarters=function(e){return null==e?Math.ceil((this.month()+1)/3):this.month(3*(e-1)+this.month()%3)},mi.month=We,mi.daysInMonth=function(){return Ce(this.year(),this.month())},mi.week=mi.weeks=function(e){var a=this.localeData().week(this);return null==e?a:this.add(7*(e-a),"d")},mi.isoWeek=mi.isoWeeks=function(e){var a=Ve(this,1,4).week;return null==e?a:this.add(7*(e-a),"d")},mi.weeksInYear=function(){var e=this.localeData()._week;return Ue(this.year(),e.dow,e.doy)},mi.isoWeeksInYear=function(){return Ue(this.year(),1,4)},mi.date=si,mi.day=mi.days=function(e){if(!this.isValid())return null!=e?this:NaN;var a=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=e?(e=function(e,a){return"string"!=typeof e?e:isNaN(e)?"number"==typeof(e=a.weekdaysParse(e))?e:null:parseInt(e,10)}(e,this.localeData()),this.add(e-a,"d")):a},mi.weekday=function(e){if(!this.isValid())return null!=e?this:NaN;var a=(this.day()+7-this.localeData()._week.dow)%7;return null==e?a:this.add(e-a,"d")},mi.isoWeekday=function(e){if(!this.isValid())return null!=e?this:NaN;if(null!=e){var a=function(e,a){return"string"==typeof e?a.weekdaysParse(e)%7||7:isNaN(e)?null:e}(e,this.localeData());return this.day(this.day()%7?a:a-7)}return this.day()||7},mi.dayOfYear=function(e){var a=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return null==e?a:this.add(e-a,"d")},mi.hour=mi.hours=ra,mi.minute=mi.minutes=oi,mi.second=mi.seconds=di,mi.millisecond=mi.milliseconds=ui,mi.utcOffset=function(e,a,i){var t,r=this._offset||0;if(!this.isValid())return null!=e?this:NaN;if(null!=e){if("string"==typeof e){if(null===(e=Fa(le,e)))return this}else Math.abs(e)<16&&!i&&(e*=60);return!this._isUTC&&a&&(t=Ra(this)),this._offset=e,this._isUTC=!0,null!=t&&this.add(t,"m"),r!==e&&(!a||this._changeInProgress?Za(this,Ua(e-r,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,n.updateOffset(this,!0),this._changeInProgress=null)),this}return this._isUTC?r:Ra(this)},mi.utc=function(e){return this.utcOffset(0,e)},mi.local=function(e){return this._isUTC&&(this.utcOffset(0,e),this._isUTC=!1,e&&this.subtract(Ra(this),"m")),this},mi.parseZone=function(){if(null!=this._tzm)this.utcOffset(this._tzm,!1,!0);else if("string"==typeof this._i){var e=Fa(oe,this._i);null!=e?this.utcOffset(e):this.utcOffset(0,!0)}return this},mi.hasAlignedHourOffset=function(e){return!!this.isValid()&&(e=e?qa(e).utcOffset():0,(this.utcOffset()-e)%60==0)},mi.isDST=function(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()},mi.isLocal=function(){return!!this.isValid()&&!this._isUTC},mi.isUtcOffset=function(){return!!this.isValid()&&this._isUTC},mi.isUtc=$a,mi.isUTC=$a,mi.zoneAbbr=function(){return this._isUTC?"UTC":""},mi.zoneName=function(){return this._isUTC?"Coordinated Universal Time":""},mi.dates=M("dates accessor is deprecated. Use date instead.",si),mi.months=M("months accessor is deprecated. Use month instead",We),mi.years=M("years accessor is deprecated. Use year instead",Te),mi.zone=M("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",function(e,a){return null!=e?("string"!=typeof e&&(e=-e),this.utcOffset(e,a),this):-this.utcOffset()}),mi.isDSTShifted=M("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",function(){if(!o(this._isDSTShifted))return this._isDSTShifted;var e={};if(y(e,this),(e=Da(e))._a){var a=e._isUTC?h(e._a):qa(e._a);this._isDSTShifted=this.isValid()&&j(e._a,a.toArray())>0}else this._isDSTShifted=!1;return this._isDSTShifted});var gi=S.prototype;function pi(e,a,i,t){var n=ha(),r=h().set(t,a);return n[i](r,e)}function bi(e,a,i){if(l(e)&&(a=e,e=void 0),e=e||"",null!=a)return pi(e,a,i,"month");var t,n=[];for(t=0;t<12;t++)n[t]=pi(e,t,i,"month");return n}function fi(e,a,i,t){"boolean"==typeof e?(l(a)&&(i=a,a=void 0),a=a||""):(i=a=e,e=!1,l(a)&&(i=a,a=void 0),a=a||"");var n,r=ha(),s=e?r._week.dow:0;if(null!=i)return pi(a,(i+s)%7,t,"day");var o=[];for(n=0;n<7;n++)o[n]=pi(a,(n+s)%7,t,"day");return o}gi.calendar=function(e,a,i){var t=this._calendar[e]||this._calendar.sameElse;return T(t)?t.call(a,i):t},gi.longDateFormat=function(e){var a=this._longDateFormat[e],i=this._longDateFormat[e.toUpperCase()];return a||!i?a:(this._longDateFormat[e]=i.replace(/MMMM|MM|DD|dddd/g,function(e){return e.slice(1)}),this._longDateFormat[e])},gi.invalidDate=function(){return this._invalidDate},gi.ordinal=function(e){return this._ordinal.replace("%d",e)},gi.preparse=hi,gi.postformat=hi,gi.relativeTime=function(e,a,i,t){var n=this._relativeTime[i];return T(n)?n(e,a,i,t):n.replace(/%d/i,e)},gi.pastFuture=function(e,a){var i=this._relativeTime[e>0?"future":"past"];return T(i)?i(a):i.replace(/%s/i,a)},gi.set=function(e){var a,i;for(i in e)T(a=e[i])?this[i]=a:this["_"+i]=a;this._config=e,this._dayOfMonthOrdinalParseLenient=new RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+"|"+/\d{1,2}/.source)},gi.months=function(e,a){return e?r(this._months)?this._months[e.month()]:this._months[(this._months.isFormat||Ae).test(a)?"format":"standalone"][e.month()]:r(this._months)?this._months:this._months.standalone},gi.monthsShort=function(e,a){return e?r(this._monthsShort)?this._monthsShort[e.month()]:this._monthsShort[Ae.test(a)?"format":"standalone"][e.month()]:r(this._monthsShort)?this._monthsShort:this._monthsShort.standalone},gi.monthsParse=function(e,a,i){var t,n,r;if(this._monthsParseExact)return function(e,a,i){var t,n,r,s=e.toLocaleLowerCase();if(!this._monthsParse)for(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[],t=0;t<12;++t)r=h([2e3,t]),this._shortMonthsParse[t]=this.monthsShort(r,"").toLocaleLowerCase(),this._longMonthsParse[t]=this.months(r,"").toLocaleLowerCase();return i?"MMM"===a?-1!==(n=De.call(this._shortMonthsParse,s))?n:null:-1!==(n=De.call(this._longMonthsParse,s))?n:null:"MMM"===a?-1!==(n=De.call(this._shortMonthsParse,s))?n:-1!==(n=De.call(this._longMonthsParse,s))?n:null:-1!==(n=De.call(this._longMonthsParse,s))?n:-1!==(n=De.call(this._shortMonthsParse,s))?n:null}.call(this,e,a,i);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),t=0;t<12;t++){if(n=h([2e3,t]),i&&!this._longMonthsParse[t]&&(this._longMonthsParse[t]=new RegExp("^"+this.months(n,"").replace(".","")+"$","i"),this._shortMonthsParse[t]=new RegExp("^"+this.monthsShort(n,"").replace(".","")+"$","i")),i||this._monthsParse[t]||(r="^"+this.months(n,"")+"|^"+this.monthsShort(n,""),this._monthsParse[t]=new RegExp(r.replace(".",""),"i")),i&&"MMMM"===a&&this._longMonthsParse[t].test(e))return t;if(i&&"MMM"===a&&this._shortMonthsParse[t].test(e))return t;if(!i&&this._monthsParse[t].test(e))return t}},gi.monthsRegex=function(e){return this._monthsParseExact?(u(this,"_monthsRegex")||Ne.call(this),e?this._monthsStrictRegex:this._monthsRegex):(u(this,"_monthsRegex")||(this._monthsRegex=Fe),this._monthsStrictRegex&&e?this._monthsStrictRegex:this._monthsRegex)},gi.monthsShortRegex=function(e){return this._monthsParseExact?(u(this,"_monthsRegex")||Ne.call(this),e?this._monthsShortStrictRegex:this._monthsShortRegex):(u(this,"_monthsShortRegex")||(this._monthsShortRegex=Ie),this._monthsShortStrictRegex&&e?this._monthsShortStrictRegex:this._monthsShortRegex)},gi.week=function(e){return Ve(e,this._week.dow,this._week.doy).week},gi.firstDayOfYear=function(){return this._week.doy},gi.firstDayOfWeek=function(){return this._week.dow},gi.weekdays=function(e,a){return e?r(this._weekdays)?this._weekdays[e.day()]:this._weekdays[this._weekdays.isFormat.test(a)?"format":"standalone"][e.day()]:r(this._weekdays)?this._weekdays:this._weekdays.standalone},gi.weekdaysMin=function(e){return e?this._weekdaysMin[e.day()]:this._weekdaysMin},gi.weekdaysShort=function(e){return e?this._weekdaysShort[e.day()]:this._weekdaysShort},gi.weekdaysParse=function(e,a,i){var t,n,r;if(this._weekdaysParseExact)return function(e,a,i){var t,n,r,s=e.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],t=0;t<7;++t)r=h([2e3,1]).day(t),this._minWeekdaysParse[t]=this.weekdaysMin(r,"").toLocaleLowerCase(),this._shortWeekdaysParse[t]=this.weekdaysShort(r,"").toLocaleLowerCase(),this._weekdaysParse[t]=this.weekdays(r,"").toLocaleLowerCase();return i?"dddd"===a?-1!==(n=De.call(this._weekdaysParse,s))?n:null:"ddd"===a?-1!==(n=De.call(this._shortWeekdaysParse,s))?n:null:-1!==(n=De.call(this._minWeekdaysParse,s))?n:null:"dddd"===a?-1!==(n=De.call(this._weekdaysParse,s))?n:-1!==(n=De.call(this._shortWeekdaysParse,s))?n:-1!==(n=De.call(this._minWeekdaysParse,s))?n:null:"ddd"===a?-1!==(n=De.call(this._shortWeekdaysParse,s))?n:-1!==(n=De.call(this._weekdaysParse,s))?n:-1!==(n=De.call(this._minWeekdaysParse,s))?n:null:-1!==(n=De.call(this._minWeekdaysParse,s))?n:-1!==(n=De.call(this._weekdaysParse,s))?n:-1!==(n=De.call(this._shortWeekdaysParse,s))?n:null}.call(this,e,a,i);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),t=0;t<7;t++){if(n=h([2e3,1]).day(t),i&&!this._fullWeekdaysParse[t]&&(this._fullWeekdaysParse[t]=new RegExp("^"+this.weekdays(n,"").replace(".","\\.?")+"$","i"),this._shortWeekdaysParse[t]=new RegExp("^"+this.weekdaysShort(n,"").replace(".","\\.?")+"$","i"),this._minWeekdaysParse[t]=new RegExp("^"+this.weekdaysMin(n,"").replace(".","\\.?")+"$","i")),this._weekdaysParse[t]||(r="^"+this.weekdays(n,"")+"|^"+this.weekdaysShort(n,"")+"|^"+this.weekdaysMin(n,""),this._weekdaysParse[t]=new RegExp(r.replace(".",""),"i")),i&&"dddd"===a&&this._fullWeekdaysParse[t].test(e))return t;if(i&&"ddd"===a&&this._shortWeekdaysParse[t].test(e))return t;if(i&&"dd"===a&&this._minWeekdaysParse[t].test(e))return t;if(!i&&this._weekdaysParse[t].test(e))return t}},gi.weekdaysRegex=function(e){return this._weekdaysParseExact?(u(this,"_weekdaysRegex")||ea.call(this),e?this._weekdaysStrictRegex:this._weekdaysRegex):(u(this,"_weekdaysRegex")||(this._weekdaysRegex=Ze),this._weekdaysStrictRegex&&e?this._weekdaysStrictRegex:this._weekdaysRegex)},gi.weekdaysShortRegex=function(e){return this._weekdaysParseExact?(u(this,"_weekdaysRegex")||ea.call(this),e?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(u(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=Xe),this._weekdaysShortStrictRegex&&e?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)},gi.weekdaysMinRegex=function(e){return this._weekdaysParseExact?(u(this,"_weekdaysRegex")||ea.call(this),e?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(u(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=Qe),this._weekdaysMinStrictRegex&&e?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)},gi.isPM=function(e){return"p"===(e+"").toLowerCase().charAt(0)},gi.meridiem=function(e,a,i){return e>11?i?"pm":"PM":i?"am":"AM"},ua("en",{dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(e){var a=e%10,i=1===x(e%100/10)?"th":1===a?"st":2===a?"nd":3===a?"rd":"th";return e+i}}),n.lang=M("moment.lang is deprecated. Use moment.locale instead.",ua),n.langData=M("moment.langData is deprecated. Use moment.localeData instead.",ha);var yi=Math.abs;function ki(e,a,i,t){var n=Ua(a,i);return e._milliseconds+=t*n._milliseconds,e._days+=t*n._days,e._months+=t*n._months,e._bubble()}function vi(e){return e<0?Math.floor(e):Math.ceil(e)}function wi(e){return 4800*e/146097}function _i(e){return 146097*e/4800}function xi(e){return function(){return this.as(e)}}var ji=xi("ms"),zi=xi("s"),Mi=xi("m"),Li=xi("h"),Yi=xi("d"),Di=xi("w"),Ti=xi("M"),qi=xi("y");function Si(e){return function(){return this.isValid()?this._data[e]:NaN}}var Hi=Si("milliseconds"),Ci=Si("seconds"),Ai=Si("minutes"),Pi=Si("hours"),Oi=Si("days"),Ei=Si("months"),Wi=Si("years"),Ii=Math.round,Fi={ss:44,s:45,m:45,h:22,d:26,M:11},Ni=Math.abs;function Ri(e){return(e>0)-(e<0)||+e}function $i(){if(!this.isValid())return this.localeData().invalidDate();var e,a,i=Ni(this._milliseconds)/1e3,t=Ni(this._days),n=Ni(this._months);e=_(i/60),a=_(e/60),i%=60,e%=60;var r=_(n/12),s=n%=12,o=t,l=a,d=e,c=i?i.toFixed(3).replace(/\.?0+$/,""):"",u=this.asSeconds();if(!u)return"P0D";var m=u<0?"-":"",h=Ri(this._months)!==Ri(u)?"-":"",g=Ri(this._days)!==Ri(u)?"-":"",p=Ri(this._milliseconds)!==Ri(u)?"-":"";return m+"P"+(r?h+r+"Y":"")+(s?h+s+"M":"")+(o?g+o+"D":"")+(l||d||c?"T":"")+(l?p+l+"H":"")+(d?p+d+"M":"")+(c?p+c+"S":"")}var Bi=Pa.prototype;return Bi.isValid=function(){return this._isValid},Bi.abs=function(){var e=this._data;return this._milliseconds=yi(this._milliseconds),this._days=yi(this._days),this._months=yi(this._months),e.milliseconds=yi(e.milliseconds),e.seconds=yi(e.seconds),e.minutes=yi(e.minutes),e.hours=yi(e.hours),e.months=yi(e.months),e.years=yi(e.years),this},Bi.add=function(e,a){return ki(this,e,a,1)},Bi.subtract=function(e,a){return ki(this,e,a,-1)},Bi.as=function(e){if(!this.isValid())return NaN;var a,i,t=this._milliseconds;if("month"===(e=A(e))||"year"===e)return a=this._days+t/864e5,i=this._months+wi(a),"month"===e?i:i/12;switch(a=this._days+Math.round(_i(this._months)),e){case"week":return a/7+t/6048e5;case"day":return a+t/864e5;case"hour":return 24*a+t/36e5;case"minute":return 1440*a+t/6e4;case"second":return 86400*a+t/1e3;case"millisecond":return Math.floor(864e5*a)+t;default:throw new Error("Unknown unit "+e)}},Bi.asMilliseconds=ji,Bi.asSeconds=zi,Bi.asMinutes=Mi,Bi.asHours=Li,Bi.asDays=Yi,Bi.asWeeks=Di,Bi.asMonths=Ti,Bi.asYears=qi,Bi.valueOf=function(){return this.isValid()?this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*x(this._months/12):NaN},Bi._bubble=function(){var e,a,i,t,n,r=this._milliseconds,s=this._days,o=this._months,l=this._data;return r>=0&&s>=0&&o>=0||r<=0&&s<=0&&o<=0||(r+=864e5*vi(_i(o)+s),s=0,o=0),l.milliseconds=r%1e3,e=_(r/1e3),l.seconds=e%60,a=_(e/60),l.minutes=a%60,i=_(a/60),l.hours=i%24,s+=_(i/24),n=_(wi(s)),o+=n,s-=vi(_i(n)),t=_(o/12),o%=12,l.days=s,l.months=o,l.years=t,this},Bi.clone=function(){return Ua(this)},Bi.get=function(e){return e=A(e),this.isValid()?this[e+"s"]():NaN},Bi.milliseconds=Hi,Bi.seconds=Ci,Bi.minutes=Ai,Bi.hours=Pi,Bi.days=Oi,Bi.weeks=function(){return _(this.days()/7)},Bi.months=Ei,Bi.years=Wi,Bi.humanize=function(e){if(!this.isValid())return this.localeData().invalidDate();var a=this.localeData(),i=function(e,a,i){var t=Ua(e).abs(),n=Ii(t.as("s")),r=Ii(t.as("m")),s=Ii(t.as("h")),o=Ii(t.as("d")),l=Ii(t.as("M")),d=Ii(t.as("y")),c=n<=Fi.ss&&["s",n]||n0,c[4]=i,function(e,a,i,t,n){return n.relativeTime(a||1,!!i,e,t)}.apply(null,c)}(this,!e,a);return e&&(i=a.pastFuture(+this,i)),a.postformat(i)},Bi.toISOString=$i,Bi.toString=$i,Bi.toJSON=$i,Bi.locale=ai,Bi.localeData=ti,Bi.toIsoString=M("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",$i),Bi.lang=ii,$("X",0,0,"unix"),$("x",0,0,"valueOf"),ue("x",se),ue("X",/[+-]?\d+(\.\d{1,3})?/),pe("X",function(e,a,i){i._d=new Date(1e3*parseFloat(e,10))}),pe("x",function(e,a,i){i._d=new Date(x(e))}),n.version="2.22.2",function(e){a=e}(qa),n.fn=mi,n.min=function(){return Ca("isBefore",[].slice.call(arguments,0))},n.max=function(){return Ca("isAfter",[].slice.call(arguments,0))},n.now=function(){return Date.now?Date.now():+new Date},n.utc=h,n.unix=function(e){return qa(1e3*e)},n.months=function(e,a){return bi(e,a,"months")},n.isDate=d,n.locale=ua,n.invalid=b,n.duration=Ua,n.isMoment=w,n.weekdays=function(e,a,i){return fi(e,a,i,"weekdays")},n.parseZone=function(){return qa.apply(null,arguments).parseZone()},n.localeData=ha,n.isDuration=Oa,n.monthsShort=function(e,a){return bi(e,a,"monthsShort")},n.weekdaysMin=function(e,a,i){return fi(e,a,i,"weekdaysMin")},n.defineLocale=ma,n.updateLocale=function(e,a){if(null!=a){var i,t,n=sa;null!=(t=ca(e))&&(n=t._config),a=q(n,a),(i=new S(a)).parentLocale=oa[e],oa[e]=i,ua(e)}else null!=oa[e]&&(null!=oa[e].parentLocale?oa[e]=oa[e].parentLocale:null!=oa[e]&&delete oa[e]);return oa[e]},n.locales=function(){return L(oa)},n.weekdaysShort=function(e,a,i){return fi(e,a,i,"weekdaysShort")},n.normalizeUnits=A,n.relativeTimeRounding=function(e){return void 0===e?Ii:"function"==typeof e&&(Ii=e,!0)},n.relativeTimeThreshold=function(e,a){return void 0!==Fi[e]&&(void 0===a?Fi[e]:(Fi[e]=a,"s"===e&&(Fi.ss=a-1),!0))},n.calendarFormat=function(e,a){var i=e.diff(a,"days",!0);return i<-6?"sameElse":i<-1?"lastWeek":i<0?"lastDay":i<1?"sameDay":i<2?"nextDay":i<7?"nextWeek":"sameElse"},n.prototype=mi,n.HTML5_FMT={DATETIME_LOCAL:"YYYY-MM-DDTHH:mm",DATETIME_LOCAL_SECONDS:"YYYY-MM-DDTHH:mm:ss",DATETIME_LOCAL_MS:"YYYY-MM-DDTHH:mm:ss.SSS",DATE:"YYYY-MM-DD",TIME:"HH:mm",TIME_SECONDS:"HH:mm:ss",TIME_MS:"HH:mm:ss.SSS",WEEK:"YYYY-[W]WW",MONTH:"YYYY-MM"},n}()}).call(this,i(169)(e))},function(e,a,i){"use strict";e.exports=i(9),e.exports.easing=i(195),e.exports.canvas=i(194),e.exports.options=i(193)},function(e,a,i){"use strict";var t=i(1);e.exports={_set:function(e,a){return t.merge(this[e]||(this[e]={}),a)}}},function(e,a,i){var t; +/*! + * jQuery JavaScript Library v3.3.1 + * https://jquery.com/ + * + * Includes Sizzle.js + * https://sizzlejs.com/ + * + * Copyright JS Foundation and other contributors + * Released under the MIT license + * https://jquery.org/license + * + * Date: 2018-01-20T17:24Z + */ +/*! + * jQuery JavaScript Library v3.3.1 + * https://jquery.com/ + * + * Includes Sizzle.js + * https://sizzlejs.com/ + * + * Copyright JS Foundation and other contributors + * Released under the MIT license + * https://jquery.org/license + * + * Date: 2018-01-20T17:24Z + */ +!function(a,i){"use strict";"object"==typeof e&&"object"==typeof e.exports?e.exports=a.document?i(a,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return i(e)}:i(a)}("undefined"!=typeof window?window:this,function(i,n){"use strict";var r=[],s=i.document,o=Object.getPrototypeOf,l=r.slice,d=r.concat,c=r.push,u=r.indexOf,m={},h=m.toString,g=m.hasOwnProperty,p=g.toString,b=p.call(Object),f={},y=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},k=function(e){return null!=e&&e===e.window},v={type:!0,src:!0,noModule:!0};function w(e,a,i){var t,n=(a=a||s).createElement("script");if(n.text=e,i)for(t in v)i[t]&&(n[t]=i[t]);a.head.appendChild(n).parentNode.removeChild(n)}function _(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?m[h.call(e)]||"object":typeof e}var x=function(e,a){return new x.fn.init(e,a)},j=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;function z(e){var a=!!e&&"length"in e&&e.length,i=_(e);return!y(e)&&!k(e)&&("array"===i||0===a||"number"==typeof a&&a>0&&a-1 in e)}x.fn=x.prototype={jquery:"3.3.1",constructor:x,length:0,toArray:function(){return l.call(this)},get:function(e){return null==e?l.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var a=x.merge(this.constructor(),e);return a.prevObject=this,a},each:function(e){return x.each(this,e)},map:function(e){return this.pushStack(x.map(this,function(a,i){return e.call(a,i,a)}))},slice:function(){return this.pushStack(l.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var a=this.length,i=+e+(e<0?a:0);return this.pushStack(i>=0&&i+~]|"+P+")"+P+"*"),$=new RegExp("="+P+"*([^\\]'\"]*?)"+P+"*\\]","g"),B=new RegExp(W),V=new RegExp("^"+O+"$"),U={ID:new RegExp("^#("+O+")"),CLASS:new RegExp("^\\.("+O+")"),TAG:new RegExp("^("+O+"|[*])"),ATTR:new RegExp("^"+E),PSEUDO:new RegExp("^"+W),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+P+"*(even|odd|(([+-]|)(\\d*)n|)"+P+"*(?:([+-]|)"+P+"*(\\d+)|))"+P+"*\\)|)","i"),bool:new RegExp("^(?:"+A+")$","i"),needsContext:new RegExp("^"+P+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+P+"*((?:-\\d)?\\d*)"+P+"*\\)|)(?=[^-]|$)","i")},J=/^(?:input|select|textarea|button)$/i,G=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,X=/[+~]/,Q=new RegExp("\\\\([\\da-f]{1,6}"+P+"?|("+P+")|.)","ig"),ee=function(e,a,i){var t="0x"+a-65536;return t!=t||i?a:t<0?String.fromCharCode(t+65536):String.fromCharCode(t>>10|55296,1023&t|56320)},ae=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,a){return a?"\0"===e?"�":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},te=function(){m()},ne=ye(function(e){return!0===e.disabled&&("form"in e||"label"in e)},{dir:"parentNode",next:"legend"});try{S.apply(D=H.call(w.childNodes),w.childNodes),D[w.childNodes.length].nodeType}catch(e){S={apply:D.length?function(e,a){q.apply(e,H.call(a))}:function(e,a){for(var i=e.length,t=0;e[i++]=a[t++];);e.length=i-1}}}function re(e,a,t,n){var r,o,d,c,u,g,f,y=a&&a.ownerDocument,_=a?a.nodeType:9;if(t=t||[],"string"!=typeof e||!e||1!==_&&9!==_&&11!==_)return t;if(!n&&((a?a.ownerDocument||a:w)!==h&&m(a),a=a||h,p)){if(11!==_&&(u=Z.exec(e)))if(r=u[1]){if(9===_){if(!(d=a.getElementById(r)))return t;if(d.id===r)return t.push(d),t}else if(y&&(d=y.getElementById(r))&&k(a,d)&&d.id===r)return t.push(d),t}else{if(u[2])return S.apply(t,a.getElementsByTagName(e)),t;if((r=u[3])&&i.getElementsByClassName&&a.getElementsByClassName)return S.apply(t,a.getElementsByClassName(r)),t}if(i.qsa&&!M[e+" "]&&(!b||!b.test(e))){if(1!==_)y=a,f=e;else if("object"!==a.nodeName.toLowerCase()){for((c=a.getAttribute("id"))?c=c.replace(ae,ie):a.setAttribute("id",c=v),o=(g=s(e)).length;o--;)g[o]="#"+c+" "+fe(g[o]);f=g.join(","),y=X.test(e)&&pe(a.parentNode)||a}if(f)try{return S.apply(t,y.querySelectorAll(f)),t}catch(e){}finally{c===v&&a.removeAttribute("id")}}}return l(e.replace(F,"$1"),a,t,n)}function se(){var e=[];return function a(i,n){return e.push(i+" ")>t.cacheLength&&delete a[e.shift()],a[i+" "]=n}}function oe(e){return e[v]=!0,e}function le(e){var a=h.createElement("fieldset");try{return!!e(a)}catch(e){return!1}finally{a.parentNode&&a.parentNode.removeChild(a),a=null}}function de(e,a){for(var i=e.split("|"),n=i.length;n--;)t.attrHandle[i[n]]=a}function ce(e,a){var i=a&&e,t=i&&1===e.nodeType&&1===a.nodeType&&e.sourceIndex-a.sourceIndex;if(t)return t;if(i)for(;i=i.nextSibling;)if(i===a)return-1;return e?1:-1}function ue(e){return function(a){return"input"===a.nodeName.toLowerCase()&&a.type===e}}function me(e){return function(a){var i=a.nodeName.toLowerCase();return("input"===i||"button"===i)&&a.type===e}}function he(e){return function(a){return"form"in a?a.parentNode&&!1===a.disabled?"label"in a?"label"in a.parentNode?a.parentNode.disabled===e:a.disabled===e:a.isDisabled===e||a.isDisabled!==!e&&ne(a)===e:a.disabled===e:"label"in a&&a.disabled===e}}function ge(e){return oe(function(a){return a=+a,oe(function(i,t){for(var n,r=e([],i.length,a),s=r.length;s--;)i[n=r[s]]&&(i[n]=!(t[n]=i[n]))})})}function pe(e){return e&&void 0!==e.getElementsByTagName&&e}for(a in i=re.support={},r=re.isXML=function(e){var a=e&&(e.ownerDocument||e).documentElement;return!!a&&"HTML"!==a.nodeName},m=re.setDocument=function(e){var a,n,s=e?e.ownerDocument||e:w;return s!==h&&9===s.nodeType&&s.documentElement?(g=(h=s).documentElement,p=!r(h),w!==h&&(n=h.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",te,!1):n.attachEvent&&n.attachEvent("onunload",te)),i.attributes=le(function(e){return e.className="i",!e.getAttribute("className")}),i.getElementsByTagName=le(function(e){return e.appendChild(h.createComment("")),!e.getElementsByTagName("*").length}),i.getElementsByClassName=K.test(h.getElementsByClassName),i.getById=le(function(e){return g.appendChild(e).id=v,!h.getElementsByName||!h.getElementsByName(v).length}),i.getById?(t.filter.ID=function(e){var a=e.replace(Q,ee);return function(e){return e.getAttribute("id")===a}},t.find.ID=function(e,a){if(void 0!==a.getElementById&&p){var i=a.getElementById(e);return i?[i]:[]}}):(t.filter.ID=function(e){var a=e.replace(Q,ee);return function(e){var i=void 0!==e.getAttributeNode&&e.getAttributeNode("id");return i&&i.value===a}},t.find.ID=function(e,a){if(void 0!==a.getElementById&&p){var i,t,n,r=a.getElementById(e);if(r){if((i=r.getAttributeNode("id"))&&i.value===e)return[r];for(n=a.getElementsByName(e),t=0;r=n[t++];)if((i=r.getAttributeNode("id"))&&i.value===e)return[r]}return[]}}),t.find.TAG=i.getElementsByTagName?function(e,a){return void 0!==a.getElementsByTagName?a.getElementsByTagName(e):i.qsa?a.querySelectorAll(e):void 0}:function(e,a){var i,t=[],n=0,r=a.getElementsByTagName(e);if("*"===e){for(;i=r[n++];)1===i.nodeType&&t.push(i);return t}return r},t.find.CLASS=i.getElementsByClassName&&function(e,a){if(void 0!==a.getElementsByClassName&&p)return a.getElementsByClassName(e)},f=[],b=[],(i.qsa=K.test(h.querySelectorAll))&&(le(function(e){g.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&b.push("[*^$]="+P+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||b.push("\\["+P+"*(?:value|"+A+")"),e.querySelectorAll("[id~="+v+"-]").length||b.push("~="),e.querySelectorAll(":checked").length||b.push(":checked"),e.querySelectorAll("a#"+v+"+*").length||b.push(".#.+[+~]")}),le(function(e){e.innerHTML="";var a=h.createElement("input");a.setAttribute("type","hidden"),e.appendChild(a).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&b.push("name"+P+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&b.push(":enabled",":disabled"),g.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&b.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),b.push(",.*:")})),(i.matchesSelector=K.test(y=g.matches||g.webkitMatchesSelector||g.mozMatchesSelector||g.oMatchesSelector||g.msMatchesSelector))&&le(function(e){i.disconnectedMatch=y.call(e,"*"),y.call(e,"[s!='']:x"),f.push("!=",W)}),b=b.length&&new RegExp(b.join("|")),f=f.length&&new RegExp(f.join("|")),a=K.test(g.compareDocumentPosition),k=a||K.test(g.contains)?function(e,a){var i=9===e.nodeType?e.documentElement:e,t=a&&a.parentNode;return e===t||!(!t||1!==t.nodeType||!(i.contains?i.contains(t):e.compareDocumentPosition&&16&e.compareDocumentPosition(t)))}:function(e,a){if(a)for(;a=a.parentNode;)if(a===e)return!0;return!1},L=a?function(e,a){if(e===a)return u=!0,0;var t=!e.compareDocumentPosition-!a.compareDocumentPosition;return t||(1&(t=(e.ownerDocument||e)===(a.ownerDocument||a)?e.compareDocumentPosition(a):1)||!i.sortDetached&&a.compareDocumentPosition(e)===t?e===h||e.ownerDocument===w&&k(w,e)?-1:a===h||a.ownerDocument===w&&k(w,a)?1:c?C(c,e)-C(c,a):0:4&t?-1:1)}:function(e,a){if(e===a)return u=!0,0;var i,t=0,n=e.parentNode,r=a.parentNode,s=[e],o=[a];if(!n||!r)return e===h?-1:a===h?1:n?-1:r?1:c?C(c,e)-C(c,a):0;if(n===r)return ce(e,a);for(i=e;i=i.parentNode;)s.unshift(i);for(i=a;i=i.parentNode;)o.unshift(i);for(;s[t]===o[t];)t++;return t?ce(s[t],o[t]):s[t]===w?-1:o[t]===w?1:0},h):h},re.matches=function(e,a){return re(e,null,null,a)},re.matchesSelector=function(e,a){if((e.ownerDocument||e)!==h&&m(e),a=a.replace($,"='$1']"),i.matchesSelector&&p&&!M[a+" "]&&(!f||!f.test(a))&&(!b||!b.test(a)))try{var t=y.call(e,a);if(t||i.disconnectedMatch||e.document&&11!==e.document.nodeType)return t}catch(e){}return re(a,h,null,[e]).length>0},re.contains=function(e,a){return(e.ownerDocument||e)!==h&&m(e),k(e,a)},re.attr=function(e,a){(e.ownerDocument||e)!==h&&m(e);var n=t.attrHandle[a.toLowerCase()],r=n&&Y.call(t.attrHandle,a.toLowerCase())?n(e,a,!p):void 0;return void 0!==r?r:i.attributes||!p?e.getAttribute(a):(r=e.getAttributeNode(a))&&r.specified?r.value:null},re.escape=function(e){return(e+"").replace(ae,ie)},re.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},re.uniqueSort=function(e){var a,t=[],n=0,r=0;if(u=!i.detectDuplicates,c=!i.sortStable&&e.slice(0),e.sort(L),u){for(;a=e[r++];)a===e[r]&&(n=t.push(r));for(;n--;)e.splice(t[n],1)}return c=null,e},n=re.getText=function(e){var a,i="",t=0,r=e.nodeType;if(r){if(1===r||9===r||11===r){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)i+=n(e)}else if(3===r||4===r)return e.nodeValue}else for(;a=e[t++];)i+=n(a);return i},(t=re.selectors={cacheLength:50,createPseudo:oe,match:U,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(Q,ee),e[3]=(e[3]||e[4]||e[5]||"").replace(Q,ee),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||re.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&re.error(e[0]),e},PSEUDO:function(e){var a,i=!e[6]&&e[2];return U.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":i&&B.test(i)&&(a=s(i,!0))&&(a=i.indexOf(")",i.length-a)-i.length)&&(e[0]=e[0].slice(0,a),e[2]=i.slice(0,a)),e.slice(0,3))}},filter:{TAG:function(e){var a=e.replace(Q,ee).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===a}},CLASS:function(e){var a=j[e+" "];return a||(a=new RegExp("(^|"+P+")"+e+"("+P+"|$)"))&&j(e,function(e){return a.test("string"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,a,i){return function(t){var n=re.attr(t,e);return null==n?"!="===a:!a||(n+="","="===a?n===i:"!="===a?n!==i:"^="===a?i&&0===n.indexOf(i):"*="===a?i&&n.indexOf(i)>-1:"$="===a?i&&n.slice(-i.length)===i:"~="===a?(" "+n.replace(I," ")+" ").indexOf(i)>-1:"|="===a&&(n===i||n.slice(0,i.length+1)===i+"-"))}},CHILD:function(e,a,i,t,n){var r="nth"!==e.slice(0,3),s="last"!==e.slice(-4),o="of-type"===a;return 1===t&&0===n?function(e){return!!e.parentNode}:function(a,i,l){var d,c,u,m,h,g,p=r!==s?"nextSibling":"previousSibling",b=a.parentNode,f=o&&a.nodeName.toLowerCase(),y=!l&&!o,k=!1;if(b){if(r){for(;p;){for(m=a;m=m[p];)if(o?m.nodeName.toLowerCase()===f:1===m.nodeType)return!1;g=p="only"===e&&!g&&"nextSibling"}return!0}if(g=[s?b.firstChild:b.lastChild],s&&y){for(k=(h=(d=(c=(u=(m=b)[v]||(m[v]={}))[m.uniqueID]||(u[m.uniqueID]={}))[e]||[])[0]===_&&d[1])&&d[2],m=h&&b.childNodes[h];m=++h&&m&&m[p]||(k=h=0)||g.pop();)if(1===m.nodeType&&++k&&m===a){c[e]=[_,h,k];break}}else if(y&&(k=h=(d=(c=(u=(m=a)[v]||(m[v]={}))[m.uniqueID]||(u[m.uniqueID]={}))[e]||[])[0]===_&&d[1]),!1===k)for(;(m=++h&&m&&m[p]||(k=h=0)||g.pop())&&((o?m.nodeName.toLowerCase()!==f:1!==m.nodeType)||!++k||(y&&((c=(u=m[v]||(m[v]={}))[m.uniqueID]||(u[m.uniqueID]={}))[e]=[_,k]),m!==a)););return(k-=n)===t||k%t==0&&k/t>=0}}},PSEUDO:function(e,a){var i,n=t.pseudos[e]||t.setFilters[e.toLowerCase()]||re.error("unsupported pseudo: "+e);return n[v]?n(a):n.length>1?(i=[e,e,"",a],t.setFilters.hasOwnProperty(e.toLowerCase())?oe(function(e,i){for(var t,r=n(e,a),s=r.length;s--;)e[t=C(e,r[s])]=!(i[t]=r[s])}):function(e){return n(e,0,i)}):n}},pseudos:{not:oe(function(e){var a=[],i=[],t=o(e.replace(F,"$1"));return t[v]?oe(function(e,a,i,n){for(var r,s=t(e,null,n,[]),o=e.length;o--;)(r=s[o])&&(e[o]=!(a[o]=r))}):function(e,n,r){return a[0]=e,t(a,null,r,i),a[0]=null,!i.pop()}}),has:oe(function(e){return function(a){return re(e,a).length>0}}),contains:oe(function(e){return e=e.replace(Q,ee),function(a){return(a.textContent||a.innerText||n(a)).indexOf(e)>-1}}),lang:oe(function(e){return V.test(e||"")||re.error("unsupported lang: "+e),e=e.replace(Q,ee).toLowerCase(),function(a){var i;do{if(i=p?a.lang:a.getAttribute("xml:lang")||a.getAttribute("lang"))return(i=i.toLowerCase())===e||0===i.indexOf(e+"-")}while((a=a.parentNode)&&1===a.nodeType);return!1}}),target:function(a){var i=e.location&&e.location.hash;return i&&i.slice(1)===a.id},root:function(e){return e===g},focus:function(e){return e===h.activeElement&&(!h.hasFocus||h.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:he(!1),disabled:he(!0),checked:function(e){var a=e.nodeName.toLowerCase();return"input"===a&&!!e.checked||"option"===a&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!t.pseudos.empty(e)},header:function(e){return G.test(e.nodeName)},input:function(e){return J.test(e.nodeName)},button:function(e){var a=e.nodeName.toLowerCase();return"input"===a&&"button"===e.type||"button"===a},text:function(e){var a;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(a=e.getAttribute("type"))||"text"===a.toLowerCase())},first:ge(function(){return[0]}),last:ge(function(e,a){return[a-1]}),eq:ge(function(e,a,i){return[i<0?i+a:i]}),even:ge(function(e,a){for(var i=0;i=0;)e.push(t);return e}),gt:ge(function(e,a,i){for(var t=i<0?i+a:i;++t1?function(a,i,t){for(var n=e.length;n--;)if(!e[n](a,i,t))return!1;return!0}:e[0]}function ve(e,a,i,t,n){for(var r,s=[],o=0,l=e.length,d=null!=a;o-1&&(r[d]=!(s[d]=u))}}else f=ve(f===s?f.splice(g,f.length):f),n?n(null,s,f,l):S.apply(s,f)})}function _e(e){for(var a,i,n,r=e.length,s=t.relative[e[0].type],o=s||t.relative[" "],l=s?1:0,c=ye(function(e){return e===a},o,!0),u=ye(function(e){return C(a,e)>-1},o,!0),m=[function(e,i,t){var n=!s&&(t||i!==d)||((a=i).nodeType?c(e,i,t):u(e,i,t));return a=null,n}];l1&&ke(m),l>1&&fe(e.slice(0,l-1).concat({value:" "===e[l-2].type?"*":""})).replace(F,"$1"),i,l0,n=e.length>0,r=function(r,s,o,l,c){var u,g,b,f=0,y="0",k=r&&[],v=[],w=d,x=r||n&&t.find.TAG("*",c),j=_+=null==w?1:Math.random()||.1,z=x.length;for(c&&(d=s===h||s||c);y!==z&&null!=(u=x[y]);y++){if(n&&u){for(g=0,s||u.ownerDocument===h||(m(u),o=!p);b=e[g++];)if(b(u,s||h,o)){l.push(u);break}c&&(_=j)}i&&((u=!b&&u)&&f--,r&&k.push(u))}if(f+=y,i&&y!==f){for(g=0;b=a[g++];)b(k,v,s,o);if(r){if(f>0)for(;y--;)k[y]||v[y]||(v[y]=T.call(l));v=ve(v)}S.apply(l,v),c&&!r&&v.length>0&&f+a.length>1&&re.uniqueSort(l)}return c&&(_=j,d=w),k};return i?oe(r):r}(r,n))).selector=e}return o},l=re.select=function(e,a,i,n){var r,l,d,c,u,m="function"==typeof e&&e,h=!n&&s(e=m.selector||e);if(i=i||[],1===h.length){if((l=h[0]=h[0].slice(0)).length>2&&"ID"===(d=l[0]).type&&9===a.nodeType&&p&&t.relative[l[1].type]){if(!(a=(t.find.ID(d.matches[0].replace(Q,ee),a)||[])[0]))return i;m&&(a=a.parentNode),e=e.slice(l.shift().value.length)}for(r=U.needsContext.test(e)?0:l.length;r--&&(d=l[r],!t.relative[c=d.type]);)if((u=t.find[c])&&(n=u(d.matches[0].replace(Q,ee),X.test(l[0].type)&&pe(a.parentNode)||a))){if(l.splice(r,1),!(e=n.length&&fe(l)))return S.apply(i,n),i;break}}return(m||o(e,h))(n,a,!p,i,!a||X.test(e)&&pe(a.parentNode)||a),i},i.sortStable=v.split("").sort(L).join("")===v,i.detectDuplicates=!!u,m(),i.sortDetached=le(function(e){return 1&e.compareDocumentPosition(h.createElement("fieldset"))}),le(function(e){return e.innerHTML="","#"===e.firstChild.getAttribute("href")})||de("type|href|height|width",function(e,a,i){if(!i)return e.getAttribute(a,"type"===a.toLowerCase()?1:2)}),i.attributes&&le(function(e){return e.innerHTML="",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||de("value",function(e,a,i){if(!i&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),le(function(e){return null==e.getAttribute("disabled")})||de(A,function(e,a,i){var t;if(!i)return!0===e[a]?a.toLowerCase():(t=e.getAttributeNode(a))&&t.specified?t.value:null}),re}(i);x.find=M,x.expr=M.selectors,x.expr[":"]=x.expr.pseudos,x.uniqueSort=x.unique=M.uniqueSort,x.text=M.getText,x.isXMLDoc=M.isXML,x.contains=M.contains,x.escapeSelector=M.escape;var L=function(e,a,i){for(var t=[],n=void 0!==i;(e=e[a])&&9!==e.nodeType;)if(1===e.nodeType){if(n&&x(e).is(i))break;t.push(e)}return t},Y=function(e,a){for(var i=[];e;e=e.nextSibling)1===e.nodeType&&e!==a&&i.push(e);return i},D=x.expr.match.needsContext;function T(e,a){return e.nodeName&&e.nodeName.toLowerCase()===a.toLowerCase()}var q=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function S(e,a,i){return y(a)?x.grep(e,function(e,t){return!!a.call(e,t,e)!==i}):a.nodeType?x.grep(e,function(e){return e===a!==i}):"string"!=typeof a?x.grep(e,function(e){return u.call(a,e)>-1!==i}):x.filter(a,e,i)}x.filter=function(e,a,i){var t=a[0];return i&&(e=":not("+e+")"),1===a.length&&1===t.nodeType?x.find.matchesSelector(t,e)?[t]:[]:x.find.matches(e,x.grep(a,function(e){return 1===e.nodeType}))},x.fn.extend({find:function(e){var a,i,t=this.length,n=this;if("string"!=typeof e)return this.pushStack(x(e).filter(function(){for(a=0;a1?x.uniqueSort(i):i},filter:function(e){return this.pushStack(S(this,e||[],!1))},not:function(e){return this.pushStack(S(this,e||[],!0))},is:function(e){return!!S(this,"string"==typeof e&&D.test(e)?x(e):e||[],!1).length}});var H,C=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(x.fn.init=function(e,a,i){var t,n;if(!e)return this;if(i=i||H,"string"==typeof e){if(!(t="<"===e[0]&&">"===e[e.length-1]&&e.length>=3?[null,e,null]:C.exec(e))||!t[1]&&a)return!a||a.jquery?(a||i).find(e):this.constructor(a).find(e);if(t[1]){if(a=a instanceof x?a[0]:a,x.merge(this,x.parseHTML(t[1],a&&a.nodeType?a.ownerDocument||a:s,!0)),q.test(t[1])&&x.isPlainObject(a))for(t in a)y(this[t])?this[t](a[t]):this.attr(t,a[t]);return this}return(n=s.getElementById(t[2]))&&(this[0]=n,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):y(e)?void 0!==i.ready?i.ready(e):e(x):x.makeArray(e,this)}).prototype=x.fn,H=x(s);var A=/^(?:parents|prev(?:Until|All))/,P={children:!0,contents:!0,next:!0,prev:!0};function O(e,a){for(;(e=e[a])&&1!==e.nodeType;);return e}x.fn.extend({has:function(e){var a=x(e,this),i=a.length;return this.filter(function(){for(var e=0;e-1:1===i.nodeType&&x.find.matchesSelector(i,e))){r.push(i);break}return this.pushStack(r.length>1?x.uniqueSort(r):r)},index:function(e){return e?"string"==typeof e?u.call(x(e),this[0]):u.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,a){return this.pushStack(x.uniqueSort(x.merge(this.get(),x(e,a))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),x.each({parent:function(e){var a=e.parentNode;return a&&11!==a.nodeType?a:null},parents:function(e){return L(e,"parentNode")},parentsUntil:function(e,a,i){return L(e,"parentNode",i)},next:function(e){return O(e,"nextSibling")},prev:function(e){return O(e,"previousSibling")},nextAll:function(e){return L(e,"nextSibling")},prevAll:function(e){return L(e,"previousSibling")},nextUntil:function(e,a,i){return L(e,"nextSibling",i)},prevUntil:function(e,a,i){return L(e,"previousSibling",i)},siblings:function(e){return Y((e.parentNode||{}).firstChild,e)},children:function(e){return Y(e.firstChild)},contents:function(e){return T(e,"iframe")?e.contentDocument:(T(e,"template")&&(e=e.content||e),x.merge([],e.childNodes))}},function(e,a){x.fn[e]=function(i,t){var n=x.map(this,a,i);return"Until"!==e.slice(-5)&&(t=i),t&&"string"==typeof t&&(n=x.filter(t,n)),this.length>1&&(P[e]||x.uniqueSort(n),A.test(e)&&n.reverse()),this.pushStack(n)}});var E=/[^\x20\t\r\n\f]+/g;function W(e){return e}function I(e){throw e}function F(e,a,i,t){var n;try{e&&y(n=e.promise)?n.call(e).done(a).fail(i):e&&y(n=e.then)?n.call(e,a,i):a.apply(void 0,[e].slice(t))}catch(e){i.apply(void 0,[e])}}x.Callbacks=function(e){e="string"==typeof e?function(e){var a={};return x.each(e.match(E)||[],function(e,i){a[i]=!0}),a}(e):x.extend({},e);var a,i,t,n,r=[],s=[],o=-1,l=function(){for(n=n||e.once,t=a=!0;s.length;o=-1)for(i=s.shift();++o-1;)r.splice(i,1),i<=o&&o--}),this},has:function(e){return e?x.inArray(e,r)>-1:r.length>0},empty:function(){return r&&(r=[]),this},disable:function(){return n=s=[],r=i="",this},disabled:function(){return!r},lock:function(){return n=s=[],i||a||(r=i=""),this},locked:function(){return!!n},fireWith:function(e,i){return n||(i=[e,(i=i||[]).slice?i.slice():i],s.push(i),a||l()),this},fire:function(){return d.fireWith(this,arguments),this},fired:function(){return!!t}};return d},x.extend({Deferred:function(e){var a=[["notify","progress",x.Callbacks("memory"),x.Callbacks("memory"),2],["resolve","done",x.Callbacks("once memory"),x.Callbacks("once memory"),0,"resolved"],["reject","fail",x.Callbacks("once memory"),x.Callbacks("once memory"),1,"rejected"]],t="pending",n={state:function(){return t},always:function(){return r.done(arguments).fail(arguments),this},catch:function(e){return n.then(null,e)},pipe:function(){var e=arguments;return x.Deferred(function(i){x.each(a,function(a,t){var n=y(e[t[4]])&&e[t[4]];r[t[1]](function(){var e=n&&n.apply(this,arguments);e&&y(e.promise)?e.promise().progress(i.notify).done(i.resolve).fail(i.reject):i[t[0]+"With"](this,n?[e]:arguments)})}),e=null}).promise()},then:function(e,t,n){var r=0;function s(e,a,t,n){return function(){var o=this,l=arguments,d=function(){var i,d;if(!(e=r&&(t!==I&&(o=void 0,l=[i]),a.rejectWith(o,l))}};e?c():(x.Deferred.getStackHook&&(c.stackTrace=x.Deferred.getStackHook()),i.setTimeout(c))}}return x.Deferred(function(i){a[0][3].add(s(0,i,y(n)?n:W,i.notifyWith)),a[1][3].add(s(0,i,y(e)?e:W)),a[2][3].add(s(0,i,y(t)?t:I))}).promise()},promise:function(e){return null!=e?x.extend(e,n):n}},r={};return x.each(a,function(e,i){var s=i[2],o=i[5];n[i[1]]=s.add,o&&s.add(function(){t=o},a[3-e][2].disable,a[3-e][3].disable,a[0][2].lock,a[0][3].lock),s.add(i[3].fire),r[i[0]]=function(){return r[i[0]+"With"](this===r?void 0:this,arguments),this},r[i[0]+"With"]=s.fireWith}),n.promise(r),e&&e.call(r,r),r},when:function(e){var a=arguments.length,i=a,t=Array(i),n=l.call(arguments),r=x.Deferred(),s=function(e){return function(i){t[e]=this,n[e]=arguments.length>1?l.call(arguments):i,--a||r.resolveWith(t,n)}};if(a<=1&&(F(e,r.done(s(i)).resolve,r.reject,!a),"pending"===r.state()||y(n[i]&&n[i].then)))return r.then();for(;i--;)F(n[i],s(i),r.reject);return r.promise()}});var N=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;x.Deferred.exceptionHook=function(e,a){i.console&&i.console.warn&&e&&N.test(e.name)&&i.console.warn("jQuery.Deferred exception: "+e.message,e.stack,a)},x.readyException=function(e){i.setTimeout(function(){throw e})};var R=x.Deferred();function $(){s.removeEventListener("DOMContentLoaded",$),i.removeEventListener("load",$),x.ready()}x.fn.ready=function(e){return R.then(e).catch(function(e){x.readyException(e)}),this},x.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--x.readyWait:x.isReady)||(x.isReady=!0,!0!==e&&--x.readyWait>0||R.resolveWith(s,[x]))}}),x.ready.then=R.then,"complete"===s.readyState||"loading"!==s.readyState&&!s.documentElement.doScroll?i.setTimeout(x.ready):(s.addEventListener("DOMContentLoaded",$),i.addEventListener("load",$));var B=function(e,a,i,t,n,r,s){var o=0,l=e.length,d=null==i;if("object"===_(i))for(o in n=!0,i)B(e,a,o,i[o],!0,r,s);else if(void 0!==t&&(n=!0,y(t)||(s=!0),d&&(s?(a.call(e,t),a=null):(d=a,a=function(e,a,i){return d.call(x(e),i)})),a))for(;o1,null,!0)},removeData:function(e){return this.each(function(){Q.remove(this,e)})}}),x.extend({queue:function(e,a,i){var t;if(e)return a=(a||"fx")+"queue",t=X.get(e,a),i&&(!t||Array.isArray(i)?t=X.access(e,a,x.makeArray(i)):t.push(i)),t||[]},dequeue:function(e,a){a=a||"fx";var i=x.queue(e,a),t=i.length,n=i.shift(),r=x._queueHooks(e,a);"inprogress"===n&&(n=i.shift(),t--),n&&("fx"===a&&i.unshift("inprogress"),delete r.stop,n.call(e,function(){x.dequeue(e,a)},r)),!t&&r&&r.empty.fire()},_queueHooks:function(e,a){var i=a+"queueHooks";return X.get(e,i)||X.access(e,i,{empty:x.Callbacks("once memory").add(function(){X.remove(e,[a+"queue",i])})})}}),x.fn.extend({queue:function(e,a){var i=2;return"string"!=typeof e&&(a=e,e="fx",i--),arguments.length\x20\t\r\n\f]+)/i,ge=/^$|^module$|\/(?:java|ecma)script/i,pe={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function be(e,a){var i;return i=void 0!==e.getElementsByTagName?e.getElementsByTagName(a||"*"):void 0!==e.querySelectorAll?e.querySelectorAll(a||"*"):[],void 0===a||a&&T(e,a)?x.merge([e],i):i}function fe(e,a){for(var i=0,t=e.length;i-1)n&&n.push(r);else if(d=x.contains(r.ownerDocument,r),s=be(u.appendChild(r),"script"),d&&fe(s),i)for(c=0;r=s[c++];)ge.test(r.type||"")&&i.push(r);return u}!function(){var e=s.createDocumentFragment().appendChild(s.createElement("div")),a=s.createElement("input");a.setAttribute("type","radio"),a.setAttribute("checked","checked"),a.setAttribute("name","t"),e.appendChild(a),f.checkClone=e.cloneNode(!0).cloneNode(!0).lastChild.checked,e.innerHTML="",f.noCloneChecked=!!e.cloneNode(!0).lastChild.defaultValue}();var ve=s.documentElement,we=/^key/,_e=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,xe=/^([^.]*)(?:\.(.+)|)/;function je(){return!0}function ze(){return!1}function Me(){try{return s.activeElement}catch(e){}}function Le(e,a,i,t,n,r){var s,o;if("object"==typeof a){for(o in"string"!=typeof i&&(t=t||i,i=void 0),a)Le(e,o,i,t,a[o],r);return e}if(null==t&&null==n?(n=i,t=i=void 0):null==n&&("string"==typeof i?(n=t,t=void 0):(n=t,t=i,i=void 0)),!1===n)n=ze;else if(!n)return e;return 1===r&&(s=n,(n=function(e){return x().off(e),s.apply(this,arguments)}).guid=s.guid||(s.guid=x.guid++)),e.each(function(){x.event.add(this,a,n,t,i)})}x.event={global:{},add:function(e,a,i,t,n){var r,s,o,l,d,c,u,m,h,g,p,b=X.get(e);if(b)for(i.handler&&(i=(r=i).handler,n=r.selector),n&&x.find.matchesSelector(ve,n),i.guid||(i.guid=x.guid++),(l=b.events)||(l=b.events={}),(s=b.handle)||(s=b.handle=function(a){return void 0!==x&&x.event.triggered!==a.type?x.event.dispatch.apply(e,arguments):void 0}),d=(a=(a||"").match(E)||[""]).length;d--;)h=p=(o=xe.exec(a[d])||[])[1],g=(o[2]||"").split(".").sort(),h&&(u=x.event.special[h]||{},h=(n?u.delegateType:u.bindType)||h,u=x.event.special[h]||{},c=x.extend({type:h,origType:p,data:t,handler:i,guid:i.guid,selector:n,needsContext:n&&x.expr.match.needsContext.test(n),namespace:g.join(".")},r),(m=l[h])||((m=l[h]=[]).delegateCount=0,u.setup&&!1!==u.setup.call(e,t,g,s)||e.addEventListener&&e.addEventListener(h,s)),u.add&&(u.add.call(e,c),c.handler.guid||(c.handler.guid=i.guid)),n?m.splice(m.delegateCount++,0,c):m.push(c),x.event.global[h]=!0)},remove:function(e,a,i,t,n){var r,s,o,l,d,c,u,m,h,g,p,b=X.hasData(e)&&X.get(e);if(b&&(l=b.events)){for(d=(a=(a||"").match(E)||[""]).length;d--;)if(h=p=(o=xe.exec(a[d])||[])[1],g=(o[2]||"").split(".").sort(),h){for(u=x.event.special[h]||{},m=l[h=(t?u.delegateType:u.bindType)||h]||[],o=o[2]&&new RegExp("(^|\\.)"+g.join("\\.(?:.*\\.|)")+"(\\.|$)"),s=r=m.length;r--;)c=m[r],!n&&p!==c.origType||i&&i.guid!==c.guid||o&&!o.test(c.namespace)||t&&t!==c.selector&&("**"!==t||!c.selector)||(m.splice(r,1),c.selector&&m.delegateCount--,u.remove&&u.remove.call(e,c));s&&!m.length&&(u.teardown&&!1!==u.teardown.call(e,g,b.handle)||x.removeEvent(e,h,b.handle),delete l[h])}else for(h in l)x.event.remove(e,h+a[d],i,t,!0);x.isEmptyObject(l)&&X.remove(e,"handle events")}},dispatch:function(e){var a,i,t,n,r,s,o=x.event.fix(e),l=new Array(arguments.length),d=(X.get(this,"events")||{})[o.type]||[],c=x.event.special[o.type]||{};for(l[0]=o,a=1;a=1))for(;d!==this;d=d.parentNode||this)if(1===d.nodeType&&("click"!==e.type||!0!==d.disabled)){for(r=[],s={},i=0;i-1:x.find(n,this,null,[d]).length),s[n]&&r.push(t);r.length&&o.push({elem:d,handlers:r})}return d=this,l\x20\t\r\n\f]*)[^>]*)\/>/gi,De=/\s*$/g;function Se(e,a){return T(e,"table")&&T(11!==a.nodeType?a:a.firstChild,"tr")&&x(e).children("tbody")[0]||e}function He(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Ce(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Ae(e,a){var i,t,n,r,s,o,l,d;if(1===a.nodeType){if(X.hasData(e)&&(r=X.access(e),s=X.set(a,r),d=r.events))for(n in delete s.handle,s.events={},d)for(i=0,t=d[n].length;i1&&"string"==typeof g&&!f.checkClone&&Te.test(g))return e.each(function(n){var r=e.eq(n);p&&(a[0]=g.call(this,n,r.html())),Oe(r,a,i,t)});if(m&&(r=(n=ke(a,e[0].ownerDocument,!1,e,t)).firstChild,1===n.childNodes.length&&(n=r),r||t)){for(o=(s=x.map(be(n,"script"),He)).length;u")},clone:function(e,a,i){var t,n,r,s,o=e.cloneNode(!0),l=x.contains(e.ownerDocument,e);if(!(f.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||x.isXMLDoc(e)))for(s=be(o),t=0,n=(r=be(e)).length;t0&&fe(s,!l&&be(e,"script")),o},cleanData:function(e){for(var a,i,t,n=x.event.special,r=0;void 0!==(i=e[r]);r++)if(K(i)){if(a=i[X.expando]){if(a.events)for(t in a.events)n[t]?x.event.remove(i,t):x.removeEvent(i,t,a.handle);i[X.expando]=void 0}i[Q.expando]&&(i[Q.expando]=void 0)}}}),x.fn.extend({detach:function(e){return Ee(this,e,!0)},remove:function(e){return Ee(this,e)},text:function(e){return B(this,function(e){return void 0===e?x.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return Oe(this,arguments,function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||Se(this,e).appendChild(e)})},prepend:function(){return Oe(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var a=Se(this,e);a.insertBefore(e,a.firstChild)}})},before:function(){return Oe(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return Oe(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,a=0;null!=(e=this[a]);a++)1===e.nodeType&&(x.cleanData(be(e,!1)),e.textContent="");return this},clone:function(e,a){return e=null!=e&&e,a=null==a?e:a,this.map(function(){return x.clone(this,e,a)})},html:function(e){return B(this,function(e){var a=this[0]||{},i=0,t=this.length;if(void 0===e&&1===a.nodeType)return a.innerHTML;if("string"==typeof e&&!De.test(e)&&!pe[(he.exec(e)||["",""])[1].toLowerCase()]){e=x.htmlPrefilter(e);try{for(;i=0&&(l+=Math.max(0,Math.ceil(e["offset"+a[0].toUpperCase()+a.slice(1)]-r-l-o-.5))),l}function Qe(e,a,i){var t=Ie(e),n=Ne(e,a,t),r="border-box"===x.css(e,"boxSizing",!1,t),s=r;if(We.test(n)){if(!i)return n;n="auto"}return s=s&&(f.boxSizingReliable()||n===e.style[a]),("auto"===n||!parseFloat(n)&&"inline"===x.css(e,"display",!1,t))&&(n=e["offset"+a[0].toUpperCase()+a.slice(1)],s=!0),(n=parseFloat(n)||0)+Xe(e,a,i||(r?"border":"content"),s,t,n)+"px"}function ea(e,a,i,t,n){return new ea.prototype.init(e,a,i,t,n)}x.extend({cssHooks:{opacity:{get:function(e,a){if(a){var i=Ne(e,"opacity");return""===i?"1":i}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,a,i,t){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var n,r,s,o=G(a),l=Be.test(a),d=e.style;if(l||(a=Ke(o)),s=x.cssHooks[a]||x.cssHooks[o],void 0===i)return s&&"get"in s&&void 0!==(n=s.get(e,!1,t))?n:d[a];"string"===(r=typeof i)&&(n=ne.exec(i))&&n[1]&&(i=le(e,a,n),r="number"),null!=i&&i==i&&("number"===r&&(i+=n&&n[3]||(x.cssNumber[o]?"":"px")),f.clearCloneStyle||""!==i||0!==a.indexOf("background")||(d[a]="inherit"),s&&"set"in s&&void 0===(i=s.set(e,i,t))||(l?d.setProperty(a,i):d[a]=i))}},css:function(e,a,i,t){var n,r,s,o=G(a);return Be.test(a)||(a=Ke(o)),(s=x.cssHooks[a]||x.cssHooks[o])&&"get"in s&&(n=s.get(e,!0,i)),void 0===n&&(n=Ne(e,a,t)),"normal"===n&&a in Ue&&(n=Ue[a]),""===i||i?(r=parseFloat(n),!0===i||isFinite(r)?r||0:n):n}}),x.each(["height","width"],function(e,a){x.cssHooks[a]={get:function(e,i,t){if(i)return!$e.test(x.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?Qe(e,a,t):oe(e,Ve,function(){return Qe(e,a,t)})},set:function(e,i,t){var n,r=Ie(e),s="border-box"===x.css(e,"boxSizing",!1,r),o=t&&Xe(e,a,t,s,r);return s&&f.scrollboxSize()===r.position&&(o-=Math.ceil(e["offset"+a[0].toUpperCase()+a.slice(1)]-parseFloat(r[a])-Xe(e,a,"border",!1,r)-.5)),o&&(n=ne.exec(i))&&"px"!==(n[3]||"px")&&(e.style[a]=i,i=x.css(e,a)),Ze(0,i,o)}}}),x.cssHooks.marginLeft=Re(f.reliableMarginLeft,function(e,a){if(a)return(parseFloat(Ne(e,"marginLeft"))||e.getBoundingClientRect().left-oe(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),x.each({margin:"",padding:"",border:"Width"},function(e,a){x.cssHooks[e+a]={expand:function(i){for(var t=0,n={},r="string"==typeof i?i.split(" "):[i];t<4;t++)n[e+re[t]+a]=r[t]||r[t-2]||r[0];return n}},"margin"!==e&&(x.cssHooks[e+a].set=Ze)}),x.fn.extend({css:function(e,a){return B(this,function(e,a,i){var t,n,r={},s=0;if(Array.isArray(a)){for(t=Ie(e),n=a.length;s1)}}),x.Tween=ea,ea.prototype={constructor:ea,init:function(e,a,i,t,n,r){this.elem=e,this.prop=i,this.easing=n||x.easing._default,this.options=a,this.start=this.now=this.cur(),this.end=t,this.unit=r||(x.cssNumber[i]?"":"px")},cur:function(){var e=ea.propHooks[this.prop];return e&&e.get?e.get(this):ea.propHooks._default.get(this)},run:function(e){var a,i=ea.propHooks[this.prop];return this.options.duration?this.pos=a=x.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=a=e,this.now=(this.end-this.start)*a+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),i&&i.set?i.set(this):ea.propHooks._default.set(this),this}},ea.prototype.init.prototype=ea.prototype,ea.propHooks={_default:{get:function(e){var a;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(a=x.css(e.elem,e.prop,""))&&"auto"!==a?a:0},set:function(e){x.fx.step[e.prop]?x.fx.step[e.prop](e):1!==e.elem.nodeType||null==e.elem.style[x.cssProps[e.prop]]&&!x.cssHooks[e.prop]?e.elem[e.prop]=e.now:x.style(e.elem,e.prop,e.now+e.unit)}}},ea.propHooks.scrollTop=ea.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},x.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},x.fx=ea.prototype.init,x.fx.step={};var aa,ia,ta=/^(?:toggle|show|hide)$/,na=/queueHooks$/;function ra(){ia&&(!1===s.hidden&&i.requestAnimationFrame?i.requestAnimationFrame(ra):i.setTimeout(ra,x.fx.interval),x.fx.tick())}function sa(){return i.setTimeout(function(){aa=void 0}),aa=Date.now()}function oa(e,a){var i,t=0,n={height:e};for(a=a?1:0;t<4;t+=2-a)n["margin"+(i=re[t])]=n["padding"+i]=e;return a&&(n.opacity=n.width=e),n}function la(e,a,i){for(var t,n=(da.tweeners[a]||[]).concat(da.tweeners["*"]),r=0,s=n.length;r1)},removeAttr:function(e){return this.each(function(){x.removeAttr(this,e)})}}),x.extend({attr:function(e,a,i){var t,n,r=e.nodeType;if(3!==r&&8!==r&&2!==r)return void 0===e.getAttribute?x.prop(e,a,i):(1===r&&x.isXMLDoc(e)||(n=x.attrHooks[a.toLowerCase()]||(x.expr.match.bool.test(a)?ca:void 0)),void 0!==i?null===i?void x.removeAttr(e,a):n&&"set"in n&&void 0!==(t=n.set(e,i,a))?t:(e.setAttribute(a,i+""),i):n&&"get"in n&&null!==(t=n.get(e,a))?t:null==(t=x.find.attr(e,a))?void 0:t)},attrHooks:{type:{set:function(e,a){if(!f.radioValue&&"radio"===a&&T(e,"input")){var i=e.value;return e.setAttribute("type",a),i&&(e.value=i),a}}}},removeAttr:function(e,a){var i,t=0,n=a&&a.match(E);if(n&&1===e.nodeType)for(;i=n[t++];)e.removeAttribute(i)}}),ca={set:function(e,a,i){return!1===a?x.removeAttr(e,i):e.setAttribute(i,i),i}},x.each(x.expr.match.bool.source.match(/\w+/g),function(e,a){var i=ua[a]||x.find.attr;ua[a]=function(e,a,t){var n,r,s=a.toLowerCase();return t||(r=ua[s],ua[s]=n,n=null!=i(e,a,t)?s:null,ua[s]=r),n}});var ma=/^(?:input|select|textarea|button)$/i,ha=/^(?:a|area)$/i;function ga(e){return(e.match(E)||[]).join(" ")}function pa(e){return e.getAttribute&&e.getAttribute("class")||""}function ba(e){return Array.isArray(e)?e:"string"==typeof e&&e.match(E)||[]}x.fn.extend({prop:function(e,a){return B(this,x.prop,e,a,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[x.propFix[e]||e]})}}),x.extend({prop:function(e,a,i){var t,n,r=e.nodeType;if(3!==r&&8!==r&&2!==r)return 1===r&&x.isXMLDoc(e)||(a=x.propFix[a]||a,n=x.propHooks[a]),void 0!==i?n&&"set"in n&&void 0!==(t=n.set(e,i,a))?t:e[a]=i:n&&"get"in n&&null!==(t=n.get(e,a))?t:e[a]},propHooks:{tabIndex:{get:function(e){var a=x.find.attr(e,"tabindex");return a?parseInt(a,10):ma.test(e.nodeName)||ha.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),f.optSelected||(x.propHooks.selected={get:function(e){var a=e.parentNode;return a&&a.parentNode&&a.parentNode.selectedIndex,null},set:function(e){var a=e.parentNode;a&&(a.selectedIndex,a.parentNode&&a.parentNode.selectedIndex)}}),x.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){x.propFix[this.toLowerCase()]=this}),x.fn.extend({addClass:function(e){var a,i,t,n,r,s,o,l=0;if(y(e))return this.each(function(a){x(this).addClass(e.call(this,a,pa(this)))});if((a=ba(e)).length)for(;i=this[l++];)if(n=pa(i),t=1===i.nodeType&&" "+ga(n)+" "){for(s=0;r=a[s++];)t.indexOf(" "+r+" ")<0&&(t+=r+" ");n!==(o=ga(t))&&i.setAttribute("class",o)}return this},removeClass:function(e){var a,i,t,n,r,s,o,l=0;if(y(e))return this.each(function(a){x(this).removeClass(e.call(this,a,pa(this)))});if(!arguments.length)return this.attr("class","");if((a=ba(e)).length)for(;i=this[l++];)if(n=pa(i),t=1===i.nodeType&&" "+ga(n)+" "){for(s=0;r=a[s++];)for(;t.indexOf(" "+r+" ")>-1;)t=t.replace(" "+r+" "," ");n!==(o=ga(t))&&i.setAttribute("class",o)}return this},toggleClass:function(e,a){var i=typeof e,t="string"===i||Array.isArray(e);return"boolean"==typeof a&&t?a?this.addClass(e):this.removeClass(e):y(e)?this.each(function(i){x(this).toggleClass(e.call(this,i,pa(this),a),a)}):this.each(function(){var a,n,r,s;if(t)for(n=0,r=x(this),s=ba(e);a=s[n++];)r.hasClass(a)?r.removeClass(a):r.addClass(a);else void 0!==e&&"boolean"!==i||((a=pa(this))&&X.set(this,"__className__",a),this.setAttribute&&this.setAttribute("class",a||!1===e?"":X.get(this,"__className__")||""))})},hasClass:function(e){var a,i,t=0;for(a=" "+e+" ";i=this[t++];)if(1===i.nodeType&&(" "+ga(pa(i))+" ").indexOf(a)>-1)return!0;return!1}});var fa=/\r/g;x.fn.extend({val:function(e){var a,i,t,n=this[0];return arguments.length?(t=y(e),this.each(function(i){var n;1===this.nodeType&&(null==(n=t?e.call(this,i,x(this).val()):e)?n="":"number"==typeof n?n+="":Array.isArray(n)&&(n=x.map(n,function(e){return null==e?"":e+""})),(a=x.valHooks[this.type]||x.valHooks[this.nodeName.toLowerCase()])&&"set"in a&&void 0!==a.set(this,n,"value")||(this.value=n))})):n?(a=x.valHooks[n.type]||x.valHooks[n.nodeName.toLowerCase()])&&"get"in a&&void 0!==(i=a.get(n,"value"))?i:"string"==typeof(i=n.value)?i.replace(fa,""):null==i?"":i:void 0}}),x.extend({valHooks:{option:{get:function(e){var a=x.find.attr(e,"value");return null!=a?a:ga(x.text(e))}},select:{get:function(e){var a,i,t,n=e.options,r=e.selectedIndex,s="select-one"===e.type,o=s?null:[],l=s?r+1:n.length;for(t=r<0?l:s?r:0;t-1)&&(i=!0);return i||(e.selectedIndex=-1),r}}}}),x.each(["radio","checkbox"],function(){x.valHooks[this]={set:function(e,a){if(Array.isArray(a))return e.checked=x.inArray(x(e).val(),a)>-1}},f.checkOn||(x.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})}),f.focusin="onfocusin"in i;var ya=/^(?:focusinfocus|focusoutblur)$/,ka=function(e){e.stopPropagation()};x.extend(x.event,{trigger:function(e,a,t,n){var r,o,l,d,c,u,m,h,p=[t||s],b=g.call(e,"type")?e.type:e,f=g.call(e,"namespace")?e.namespace.split("."):[];if(o=h=l=t=t||s,3!==t.nodeType&&8!==t.nodeType&&!ya.test(b+x.event.triggered)&&(b.indexOf(".")>-1&&(b=(f=b.split(".")).shift(),f.sort()),c=b.indexOf(":")<0&&"on"+b,(e=e[x.expando]?e:new x.Event(b,"object"==typeof e&&e)).isTrigger=n?2:3,e.namespace=f.join("."),e.rnamespace=e.namespace?new RegExp("(^|\\.)"+f.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,e.result=void 0,e.target||(e.target=t),a=null==a?[e]:x.makeArray(a,[e]),m=x.event.special[b]||{},n||!m.trigger||!1!==m.trigger.apply(t,a))){if(!n&&!m.noBubble&&!k(t)){for(d=m.delegateType||b,ya.test(d+b)||(o=o.parentNode);o;o=o.parentNode)p.push(o),l=o;l===(t.ownerDocument||s)&&p.push(l.defaultView||l.parentWindow||i)}for(r=0;(o=p[r++])&&!e.isPropagationStopped();)h=o,e.type=r>1?d:m.bindType||b,(u=(X.get(o,"events")||{})[e.type]&&X.get(o,"handle"))&&u.apply(o,a),(u=c&&o[c])&&u.apply&&K(o)&&(e.result=u.apply(o,a),!1===e.result&&e.preventDefault());return e.type=b,n||e.isDefaultPrevented()||m._default&&!1!==m._default.apply(p.pop(),a)||!K(t)||c&&y(t[b])&&!k(t)&&((l=t[c])&&(t[c]=null),x.event.triggered=b,e.isPropagationStopped()&&h.addEventListener(b,ka),t[b](),e.isPropagationStopped()&&h.removeEventListener(b,ka),x.event.triggered=void 0,l&&(t[c]=l)),e.result}},simulate:function(e,a,i){var t=x.extend(new x.Event,i,{type:e,isSimulated:!0});x.event.trigger(t,null,a)}}),x.fn.extend({trigger:function(e,a){return this.each(function(){x.event.trigger(e,a,this)})},triggerHandler:function(e,a){var i=this[0];if(i)return x.event.trigger(e,a,i,!0)}}),f.focusin||x.each({focus:"focusin",blur:"focusout"},function(e,a){var i=function(e){x.event.simulate(a,e.target,x.event.fix(e))};x.event.special[a]={setup:function(){var t=this.ownerDocument||this,n=X.access(t,a);n||t.addEventListener(e,i,!0),X.access(t,a,(n||0)+1)},teardown:function(){var t=this.ownerDocument||this,n=X.access(t,a)-1;n?X.access(t,a,n):(t.removeEventListener(e,i,!0),X.remove(t,a))}}});var va=i.location,wa=Date.now(),_a=/\?/;x.parseXML=function(e){var a;if(!e||"string"!=typeof e)return null;try{a=(new i.DOMParser).parseFromString(e,"text/xml")}catch(e){a=void 0}return a&&!a.getElementsByTagName("parsererror").length||x.error("Invalid XML: "+e),a};var xa=/\[\]$/,ja=/\r?\n/g,za=/^(?:submit|button|image|reset|file)$/i,Ma=/^(?:input|select|textarea|keygen)/i;function La(e,a,i,t){var n;if(Array.isArray(a))x.each(a,function(a,n){i||xa.test(e)?t(e,n):La(e+"["+("object"==typeof n&&null!=n?a:"")+"]",n,i,t)});else if(i||"object"!==_(a))t(e,a);else for(n in a)La(e+"["+n+"]",a[n],i,t)}x.param=function(e,a){var i,t=[],n=function(e,a){var i=y(a)?a():a;t[t.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==i?"":i)};if(Array.isArray(e)||e.jquery&&!x.isPlainObject(e))x.each(e,function(){n(this.name,this.value)});else for(i in e)La(i,e[i],a,n);return t.join("&")},x.fn.extend({serialize:function(){return x.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=x.prop(this,"elements");return e?x.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!x(this).is(":disabled")&&Ma.test(this.nodeName)&&!za.test(e)&&(this.checked||!me.test(e))}).map(function(e,a){var i=x(this).val();return null==i?null:Array.isArray(i)?x.map(i,function(e){return{name:a.name,value:e.replace(ja,"\r\n")}}):{name:a.name,value:i.replace(ja,"\r\n")}}).get()}});var Ya=/%20/g,Da=/#.*$/,Ta=/([?&])_=[^&]*/,qa=/^(.*?):[ \t]*([^\r\n]*)$/gm,Sa=/^(?:GET|HEAD)$/,Ha=/^\/\//,Ca={},Aa={},Pa="*/".concat("*"),Oa=s.createElement("a");function Ea(e){return function(a,i){"string"!=typeof a&&(i=a,a="*");var t,n=0,r=a.toLowerCase().match(E)||[];if(y(i))for(;t=r[n++];)"+"===t[0]?(t=t.slice(1)||"*",(e[t]=e[t]||[]).unshift(i)):(e[t]=e[t]||[]).push(i)}}function Wa(e,a,i,t){var n={},r=e===Aa;function s(o){var l;return n[o]=!0,x.each(e[o]||[],function(e,o){var d=o(a,i,t);return"string"!=typeof d||r||n[d]?r?!(l=d):void 0:(a.dataTypes.unshift(d),s(d),!1)}),l}return s(a.dataTypes[0])||!n["*"]&&s("*")}function Ia(e,a){var i,t,n=x.ajaxSettings.flatOptions||{};for(i in a)void 0!==a[i]&&((n[i]?e:t||(t={}))[i]=a[i]);return t&&x.extend(!0,e,t),e}Oa.href=va.href,x.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:va.href,type:"GET",isLocal:/^(?:about|app|app-storage|.+-extension|file|res|widget):$/.test(va.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Pa,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":x.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,a){return a?Ia(Ia(e,x.ajaxSettings),a):Ia(x.ajaxSettings,e)},ajaxPrefilter:Ea(Ca),ajaxTransport:Ea(Aa),ajax:function(e,a){"object"==typeof e&&(a=e,e=void 0),a=a||{};var t,n,r,o,l,d,c,u,m,h,g=x.ajaxSetup({},a),p=g.context||g,b=g.context&&(p.nodeType||p.jquery)?x(p):x.event,f=x.Deferred(),y=x.Callbacks("once memory"),k=g.statusCode||{},v={},w={},_="canceled",j={readyState:0,getResponseHeader:function(e){var a;if(c){if(!o)for(o={};a=qa.exec(r);)o[a[1].toLowerCase()]=a[2];a=o[e.toLowerCase()]}return null==a?null:a},getAllResponseHeaders:function(){return c?r:null},setRequestHeader:function(e,a){return null==c&&(e=w[e.toLowerCase()]=w[e.toLowerCase()]||e,v[e]=a),this},overrideMimeType:function(e){return null==c&&(g.mimeType=e),this},statusCode:function(e){var a;if(e)if(c)j.always(e[j.status]);else for(a in e)k[a]=[k[a],e[a]];return this},abort:function(e){var a=e||_;return t&&t.abort(a),z(0,a),this}};if(f.promise(j),g.url=((e||g.url||va.href)+"").replace(Ha,va.protocol+"//"),g.type=a.method||a.type||g.method||g.type,g.dataTypes=(g.dataType||"*").toLowerCase().match(E)||[""],null==g.crossDomain){d=s.createElement("a");try{d.href=g.url,d.href=d.href,g.crossDomain=Oa.protocol+"//"+Oa.host!=d.protocol+"//"+d.host}catch(e){g.crossDomain=!0}}if(g.data&&g.processData&&"string"!=typeof g.data&&(g.data=x.param(g.data,g.traditional)),Wa(Ca,g,a,j),c)return j;for(m in(u=x.event&&g.global)&&0==x.active++&&x.event.trigger("ajaxStart"),g.type=g.type.toUpperCase(),g.hasContent=!Sa.test(g.type),n=g.url.replace(Da,""),g.hasContent?g.data&&g.processData&&0===(g.contentType||"").indexOf("application/x-www-form-urlencoded")&&(g.data=g.data.replace(Ya,"+")):(h=g.url.slice(n.length),g.data&&(g.processData||"string"==typeof g.data)&&(n+=(_a.test(n)?"&":"?")+g.data,delete g.data),!1===g.cache&&(n=n.replace(Ta,"$1"),h=(_a.test(n)?"&":"?")+"_="+wa+++h),g.url=n+h),g.ifModified&&(x.lastModified[n]&&j.setRequestHeader("If-Modified-Since",x.lastModified[n]),x.etag[n]&&j.setRequestHeader("If-None-Match",x.etag[n])),(g.data&&g.hasContent&&!1!==g.contentType||a.contentType)&&j.setRequestHeader("Content-Type",g.contentType),j.setRequestHeader("Accept",g.dataTypes[0]&&g.accepts[g.dataTypes[0]]?g.accepts[g.dataTypes[0]]+("*"!==g.dataTypes[0]?", "+Pa+"; q=0.01":""):g.accepts["*"]),g.headers)j.setRequestHeader(m,g.headers[m]);if(g.beforeSend&&(!1===g.beforeSend.call(p,j,g)||c))return j.abort();if(_="abort",y.add(g.complete),j.done(g.success),j.fail(g.error),t=Wa(Aa,g,a,j)){if(j.readyState=1,u&&b.trigger("ajaxSend",[j,g]),c)return j;g.async&&g.timeout>0&&(l=i.setTimeout(function(){j.abort("timeout")},g.timeout));try{c=!1,t.send(v,z)}catch(e){if(c)throw e;z(-1,e)}}else z(-1,"No Transport");function z(e,a,s,o){var d,m,h,v,w,_=a;c||(c=!0,l&&i.clearTimeout(l),t=void 0,r=o||"",j.readyState=e>0?4:0,d=e>=200&&e<300||304===e,s&&(v=function(e,a,i){for(var t,n,r,s,o=e.contents,l=e.dataTypes;"*"===l[0];)l.shift(),void 0===t&&(t=e.mimeType||a.getResponseHeader("Content-Type"));if(t)for(n in o)if(o[n]&&o[n].test(t)){l.unshift(n);break}if(l[0]in i)r=l[0];else{for(n in i){if(!l[0]||e.converters[n+" "+l[0]]){r=n;break}s||(s=n)}r=r||s}if(r)return r!==l[0]&&l.unshift(r),i[r]}(g,j,s)),v=function(e,a,i,t){var n,r,s,o,l,d={},c=e.dataTypes.slice();if(c[1])for(s in e.converters)d[s.toLowerCase()]=e.converters[s];for(r=c.shift();r;)if(e.responseFields[r]&&(i[e.responseFields[r]]=a),!l&&t&&e.dataFilter&&(a=e.dataFilter(a,e.dataType)),l=r,r=c.shift())if("*"===r)r=l;else if("*"!==l&&l!==r){if(!(s=d[l+" "+r]||d["* "+r]))for(n in d)if((o=n.split(" "))[1]===r&&(s=d[l+" "+o[0]]||d["* "+o[0]])){!0===s?s=d[n]:!0!==d[n]&&(r=o[0],c.unshift(o[1]));break}if(!0!==s)if(s&&e.throws)a=s(a);else try{a=s(a)}catch(e){return{state:"parsererror",error:s?e:"No conversion from "+l+" to "+r}}}return{state:"success",data:a}}(g,v,j,d),d?(g.ifModified&&((w=j.getResponseHeader("Last-Modified"))&&(x.lastModified[n]=w),(w=j.getResponseHeader("etag"))&&(x.etag[n]=w)),204===e||"HEAD"===g.type?_="nocontent":304===e?_="notmodified":(_=v.state,m=v.data,d=!(h=v.error))):(h=_,!e&&_||(_="error",e<0&&(e=0))),j.status=e,j.statusText=(a||_)+"",d?f.resolveWith(p,[m,_,j]):f.rejectWith(p,[j,_,h]),j.statusCode(k),k=void 0,u&&b.trigger(d?"ajaxSuccess":"ajaxError",[j,g,d?m:h]),y.fireWith(p,[j,_]),u&&(b.trigger("ajaxComplete",[j,g]),--x.active||x.event.trigger("ajaxStop")))}return j},getJSON:function(e,a,i){return x.get(e,a,i,"json")},getScript:function(e,a){return x.get(e,void 0,a,"script")}}),x.each(["get","post"],function(e,a){x[a]=function(e,i,t,n){return y(i)&&(n=n||t,t=i,i=void 0),x.ajax(x.extend({url:e,type:a,dataType:n,data:i,success:t},x.isPlainObject(e)&&e))}}),x._evalUrl=function(e){return x.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,throws:!0})},x.fn.extend({wrapAll:function(e){var a;return this[0]&&(y(e)&&(e=e.call(this[0])),a=x(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&a.insertBefore(this[0]),a.map(function(){for(var e=this;e.firstElementChild;)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(e){return y(e)?this.each(function(a){x(this).wrapInner(e.call(this,a))}):this.each(function(){var a=x(this),i=a.contents();i.length?i.wrapAll(e):a.append(e)})},wrap:function(e){var a=y(e);return this.each(function(i){x(this).wrapAll(a?e.call(this,i):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){x(this).replaceWith(this.childNodes)}),this}}),x.expr.pseudos.hidden=function(e){return!x.expr.pseudos.visible(e)},x.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},x.ajaxSettings.xhr=function(){try{return new i.XMLHttpRequest}catch(e){}};var Fa={0:200,1223:204},Na=x.ajaxSettings.xhr();f.cors=!!Na&&"withCredentials"in Na,f.ajax=Na=!!Na,x.ajaxTransport(function(e){var a,t;if(f.cors||Na&&!e.crossDomain)return{send:function(n,r){var s,o=e.xhr();if(o.open(e.type,e.url,e.async,e.username,e.password),e.xhrFields)for(s in e.xhrFields)o[s]=e.xhrFields[s];for(s in e.mimeType&&o.overrideMimeType&&o.overrideMimeType(e.mimeType),e.crossDomain||n["X-Requested-With"]||(n["X-Requested-With"]="XMLHttpRequest"),n)o.setRequestHeader(s,n[s]);a=function(e){return function(){a&&(a=t=o.onload=o.onerror=o.onabort=o.ontimeout=o.onreadystatechange=null,"abort"===e?o.abort():"error"===e?"number"!=typeof o.status?r(0,"error"):r(o.status,o.statusText):r(Fa[o.status]||o.status,o.statusText,"text"!==(o.responseType||"text")||"string"!=typeof o.responseText?{binary:o.response}:{text:o.responseText},o.getAllResponseHeaders()))}},o.onload=a(),t=o.onerror=o.ontimeout=a("error"),void 0!==o.onabort?o.onabort=t:o.onreadystatechange=function(){4===o.readyState&&i.setTimeout(function(){a&&t()})},a=a("abort");try{o.send(e.hasContent&&e.data||null)}catch(e){if(a)throw e}},abort:function(){a&&a()}}}),x.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),x.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return x.globalEval(e),e}}}),x.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),x.ajaxTransport("script",function(e){var a,i;if(e.crossDomain)return{send:function(t,n){a=x(" + + @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/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..c64d7b4 --- /dev/null +++ b/resources/views/informes/resumen_contabilidad.blade.php @@ -0,0 +1,8 @@ +@extends('layout.base') + +@section('content') +

Resumen para Contabilidad

+
+@include('informes.proyectos', ['a' => 'resumen_contabilidad']) +
+@endsection 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..db67849 --- /dev/null +++ b/resources/views/proyectos/unidades/list.blade.php @@ -0,0 +1,197 @@ +@extends('layout.base') + +@section('content') + + + + + + + + + + + + + + + + + + + + @foreach ($proyecto->proyectoTipoUnidades() as $tipo) + + + + + + + + + + + + + + + + + + @endforeach + @if (count($libres) > 0) + + + + + + + + + + @endif + +
TipoNombreAbreviaciónLíneasm² Útilm² Terrazam² Vendiblem² TotalDescripción#
{{ucwords($tipo->tipo()->descripcion)}}{{$tipo->nombre}} + @if ($tipo->tipologia()) + {{$tipo->tipologia()->descripcion}} + @else + {{$tipo->abreviacion}} + @endif + {{$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 + {{count($tipo->unidades())}}
+ + + + + + + + + + + + + @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ónPisoLí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..3a23ad1 --- /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 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#% Vendido
{{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->total, 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/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..7de8730 --- /dev/null +++ b/resources/views/ventas/cierres/evaluar.blade.php @@ -0,0 +1,447 @@ +@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..87c0aa8 --- /dev/null +++ b/resources/views/ventas/precios/list.blade.php @@ -0,0 +1,126 @@ +@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)}}{{format('ufs', $tipo->precio() / $tipo->m2(), true)}}/m²
+ + + + + + + + + + + + @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² + @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