public function getOperacion($folio, $expediente) { $operacion = array('abonos_mensualidad' => null, 'abonos_capital' => null, 'abonos_enganche' => null, 'folio' => $folio, 'cliente' => null, 'expediente' => $expediente, 'plazo' => DB::table('solicitud')->where('fk_expediente', $expediente)->select('solicitud.plazo')->get()[0], 'fecha_contrato' => DB::table('solicitud')->where('fk_expediente', $expediente)->join('contrato', 'contrato.fk_solicitud', '=', 'solicitud.id_solicitud')->select('contrato.fecha_realizacion')->get()[0]); $abonos_mensualidad = $this->mysqli->query("select * from abono_mensualidad where fk_operacion='" . $folio . "'"); $abonos_mensualidad = Estatica::getObjetos($abonos_mensualidad); for ($abono = 0; $abono < count($abonos_mensualidad); $abono++) { $operacion['abonos_mensualidad'][$abono] = array('abono' => $abonos_mensualidad[$abono], 'mensualidad' => DB::table('mensualidad')->where('id_mensualidad', $abonos_mensualidad[$abono]->fk_mensualidad)->select('mensualidad.numero', 'mensualidad.fecha_vence', 'mensualidad.estado', 'mensualidad.capital', 'mensualidad.interes_aplicable', 'mensualidad.gas_admon_cob', 'mensualidad.actualizacion', 'mensualidad.id_mensualidad', 'mensualidad.moratorios')->get()[0]); //Se recuperan todos los abonos a la mensualidad para sacar la cantidad que se adeuda en ella $a = DB::table('abono_mensualidad')->where('fk_mensualidad', $operacion['abonos_mensualidad'][$abono]['mensualidad']->id_mensualidad)->get(); $actualizacion = 0; $capital = 0; $adm_cobra = 0; $interes = 0; for ($i = 0; $i < count($a); $i++) { $actualizacion += $a[$i]->actualizacion; $capital += $a[$i]->pago_capital; $adm_cobra += $a[$i]->gas_admon_cob; $interes += $a[$i]->interes_aplicable; } $operacion['abonos_mensualidad'][$abono]['mensualidad']->interes_aplicable -= $interes; $operacion['abonos_mensualidad'][$abono]['mensualidad']->gas_admon_cob -= $adm_cobra; $operacion['abonos_mensualidad'][$abono]['mensualidad']->capital -= $capital; $operacion['abonos_mensualidad'][$abono]['mensualidad']->actualizacion -= $actualizacion; } $abonos_capital = $this->mysqli->query("select * from abono_capital where fk_operacion='" . $folio . "'"); $operacion['abonos_capital'] = Estatica::getObjetos($abonos_capital); $abonos_enganche = $this->mysqli->query("select * from abono_enganche where fk_operacion='" . $folio . "'"); $abonos_enganche = Estatica::getObjetos($abonos_enganche); for ($abono = 0; $abono < count($abonos_enganche); $abono++) { $operacion['abonos_enganche'][$abono] = array('abono' => $abonos_enganche[$abono], 'enganche' => DB::table('enganche_parcial')->where('id_enganche_parcial', $abonos_enganche[$abono]->fk_enganche_parcial)->select('enganche_parcial.importe', 'enganche_parcial.fecha_promesa')->get()[0]); } $operacion['cliente'] = DB::table('expediente')->where('id_expediente', $expediente)->join('cliente', 'cliente.rfc', '=', 'expediente.fk_rfc')->get()[0]; return $operacion; }
public function getContrato($contrato) { $contrato = $this->mysqli->query('select * from contrato, solicitud where contrato.id_contrato=' . $contrato . ' and solicitud.id_solicitud=contrato.fk_solicitud')->fetch_object(); $cuenta = $this->mysqli->query('select * from cuenta where fk_contrato=' . $contrato->id_contrato . ' and activa=1')->fetch_object(); $expediente = $this->mysqli->query('select * from expediente where id_expediente="' . $contrato->fk_expediente . '"')->fetch_object(); $cliente = $this->mysqli->query('select rfc, nombre, ape_mate, ape_pate, denominacion from cliente where rfc="' . $expediente->fk_rfc . '"')->fetch_object(); $lote = $this->mysqli->query('select id_lote, fk_manzana, fk_categoria, etapa, superficie from lote where id_lote=' . $contrato->fk_lote)->fetch_object(); $categoria = $this->mysqli->query('select * from categoria where id_categoria="' . $lote->fk_categoria . '"')->fetch_object(); $manzana = $this->mysqli->query('select id_manzana, fk_desarrollo from manzana where id_manzana=' . $lote->fk_manzana)->fetch_object(); $manzanas = $this->mysqli->query('select * from manzana where fk_desarrollo="' . $manzana->fk_desarrollo . '"'); $manzanas = Estatica::getObjetos($manzanas); $lotes = $this->mysqli->query('select * from lote where fk_manzana=' . $manzana->id_manzana); $lotes = Estatica::getObjetos($lotes); $prepagos = $this->mysqli->query('select * from prepago where fk_cuenta=' . $cuenta->id_cuenta); $prepagos = Estatica::getObjetos($prepagos); $excepciones = $this->mysqli->query('select * from excepcion_Accesorios where fk_cuenta=' . $cuenta->id_cuenta); $excepciones = Estatica::getObjetos($excepciones); $tipo = 1; if ($excepciones == null) { $excepciones = $this->mysqli->query('select * from excepcion_Monto_Fijo where fk_cuenta=' . $cuenta->id_cuenta); $excepciones = Estatica::getObjetos($excepciones); $tipo = 2; } $enganchesParciales = $this->mysqli->query('select * from enganche_parcial where fk_cuenta=' . $cuenta->id_cuenta); $enganchesParciales = Estatica::getObjetos($enganchesParciales); $variables = $this->mysqli->query('select * from conjunto_variables where fk_desarrollo="' . $manzana->fk_desarrollo . '"')->fetch_object(); return array('contrato' => $contrato, 'por_interes' => $cuenta->inflacion, 'porc_gas_admonYcobra' => $cuenta->porgastadmon, 'cliente' => $cliente, 'cuenta' => $cuenta, 'lote' => $lote, 'categoria' => $categoria, 'manzana' => $manzana, 'manzanas' => $manzanas, 'lotes' => $lotes, 'prepagos' => $prepagos, 'enganches' => $enganchesParciales, 'excepciones' => array('excepciones' => $excepciones, 'tipo' => $tipo)); }
public function postRecibos() { if (!empty(Input::get('recibo'))) { require_once "dompdf/dompdf_config.inc.php"; $operacion = $this->response->getOperacion(Input::get('folio'), Input::get('expediente')); $descripciones_efectivo = Estatica::getObjetos($this->mysqli->query('select * from descripcion_efectivo where fk_operacion=' . Input::get('folio'))); $descripciones_cheque = Estatica::getObjetos($this->mysqli->query('select * from descripcion_cheque where fk_operacion=' . Input::get('folio'))); $descripciones_transferencia = Estatica::getObjetos($this->mysqli->query('select * from descripcion_transferencia where fk_operacion=' . Input::get('folio'))); $descripciones_convenio = Estatica::getObjetos($this->mysqli->query('select * from descripcion_convenio where fk_operacion=' . Input::get('folio'))); $capital = 0; $actualizacion = 0; $gas_admon_cob = 0; $interes_aplicable = 0; $moratorios = 0; $total = 0; for ($abono = 0; $abono < count($operacion['abonos_mensualidad']); $abono++) { $capital += $operacion['abonos_mensualidad'][$abono]['abono']->pago_capital; $actualizacion += $operacion['abonos_mensualidad'][$abono]['abono']->actualizacion; $gas_admon_cob += $operacion['abonos_mensualidad'][$abono]['abono']->gas_admon_cob; $interes_aplicable += $operacion['abonos_mensualidad'][$abono]['abono']->interes_aplicable; $moratorios += $operacion['abonos_mensualidad'][$abono]['abono']->moratorios; } $total += $interes_aplicable + $gas_admon_cob + $moratorios + $actualizacion; // return numtoletras($total); $recibo = null; $nombre = null; if (Input::get('recibo') == 1) { // return View::make('cobranza/reportes/reciboPosterior2014')->with('info', array('operacion'=>$operacion, 'total'=>numtoletras($total)) )->render(); if (strtotime($operacion['fecha_contrato']->fecha_realizacion) >= strtotime('2014-01-01')) { $recibo = View::make('cobranza/reportes/reciboPosterior2014')->with('info', array('operacion' => $operacion, 'total' => numtoletras($total)))->render(); } else { $recibo = View::make('cobranza/reportes/reciboAntes2014')->with('info', array('operacion' => $operacion, 'total' => numtoletras($total))); } $nombre = "recibo_folio_" . Input::get('folio'); } else { if (Input::get('recibo') == 2) { $capital = 0; for ($abono = 0; $abono < count($operacion['abonos_mensualidad']); $abono++) { $capital += $operacion['abonos_mensualidad'][$abono]['abono']->pago_capital; } $recibo = View::make('cobranza/reportes/reciboAuxiliar')->with('info', array('operacion' => $operacion, 'total' => $capital))->render(); $nombre = "recAuxiliar_folio_" . Input::get('folio'); } else { $recibo = View::make('cobranza/reportes/prefactura')->with('info', array('descripciones_efectivo' => $descripciones_efectivo, 'descripciones_cheque' => $descripciones_cheque, 'descripciones_transferencia' => $descripciones_transferencia, 'descripciones_convenio' => $descripciones_convenio, 'expediente' => Input::get('expediente'), 'abonos' => $operacion['abonos_mensualidad'], 'plazo' => $operacion['plazo'])); $nombre = "prefactura"; } } $dompdf = new DOMPDF(); $dompdf->set_paper('A4', 'landscape'); $dompdf->load_html($recibo); $dompdf->render(); $dompdf->stream($nombre . ".pdf"); } else { return View::make('cobranza/reportes/recibosContrato')->with('operaciones', $this->response->getOperaciones(Input::get('contratos'))); } }
public function getDoc($expediente) { $cliente = $this->mysqli->query('select * from expediente, cliente where id_expediente="' . $expediente . '" and cliente.rfc=expediente.fk_rfc')->fetch_object(); //$cliente = DB::table('expediente')->where('id_expediente', $expediente)->join('cliente', 'cliente.rfc', '=', 'expediente.fk_rfc')->get()[0]; $lote = $this->mysqli->query('select * from expediente, solicitud, contrato, contrato_lote, lote, manzana, desarrollo where expediente.id_expediente="' . $expediente . '" and solicitud.fk_expediente=expediente.id_expediente and contrato.fk_solicitud=solicitud.id_solicitud and contrato_lote.fk_contrato=contrato.id_contrato and lote.id_lote=contrato_lote.fk_lote and manzana.id_manzana=lote.fk_manzana and desarrollo.id_desarrollo=manzana.fk_desarrollo')->fetch_object(); //$lote=DB::table('expediente')->where('id_expediente', $expediente)->join('solicitud', 'fk_expediente', '=','expediente.id_expediente')->join('contrato', 'contrato.fk_solicitud', '=','solicitud.id_solicitud')->join('contrato_lote','contrato_lote.fk_contrato', '=' ,'contrato.id_contrato')->join('lote','lote.id_lote', '=', 'contrato_lote.fk_lote')->join('manzana', 'manzana.id_manzana', '=', 'lote.fk_manzana')->join('desarrollo', 'desarrollo.id_desarrollo', '=', 'manzana.fk_desarrollo')->get()[0]; $contrato = $this->mysqli->query('select * from contrato where id_contrato=' . $lote->id_contrato)->fetch_object(); $categoria = $this->mysqli->query('select * from categoria where id_categoria=' . '"' . $lote->fk_categoria . '"')->fetch_object(); //$categoria = DB::table('categoria')->where('id_categoria', $lote->fk_categoria)->get()[0]; $cuenta = $this->mysqli->query('select * from cuenta where fk_contrato=' . $lote->id_contrato)->fetch_object(); //$cuenta = DB::table('cuenta')->where('fk_contrato', $lote->id_contrato)->get()[0]; $enganches = Estatica::getObjetos($this->mysqli->query('select * from enganche_parcial where fk_cuenta=' . $cuenta->id_cuenta)); //$enganches = DB::table('enganche_parcial')->where('fk_cuenta', $cuenta->id_cuenta)->get(); $partesContrato = DB::table('parte_contrato')->where('fk_desarrollo', $lote->fk_desarrollo)->get(); $ala_Firma = 0; $textoEnganches = ''; $bool_no_parciales = true; for ($e = 0; $e < count($enganches); $e++) { if (strtotime($enganches[$e]->fecha_promesa) > strtotime($contrato->fecha_realizacion)) { $textoEnganches = $textoEnganches . " Complemento de enganche por \$" . round($enganches[$e]->importe, 2) . ' ' . numtoletras(round($enganches[$e]->importe, 2)) . " que depositara en la fecha " . $enganches[$e]->fecha_promesa; $bool_no_parciales = false; } else { $ala_Firma += $enganches[$e]->importe; } } if ($bool_no_parciales == true) { $textoEnganches = 'Ningun enganche parcial.'; } $PHPWord = new PHPWord(); if ($lote->tipo_operacion == 1) { $document = $PHPWord->loadTemplate(dirname(__FILE__) . '/PHPWord/contrato_contado.docx'); } else { $document = $PHPWord->loadTemplate(dirname(__FILE__) . '/PHPWord/Plantilla_Contrato_Credito.docx'); $document->setValue('Plazo', $lote->plazo); $document->setValue('DiaCorte', $lote->dia_corte); $document->setValue('PlazoLetra', numtoletras_2($lote->plazo)); $lote->fecha_inicial_pago = explode('-', $lote->fecha_inicial_pago); $document->setValue('IniciaDia', $lote->fecha_inicial_pago[2]); for ($parte = 0; $parte < count($partesContrato); $parte++) { $document->setValue('Parte' . ($parte + 1), $partesContrato[$parte]->texto); } $document->setValue('MesInicia', $this->mes($lote->fecha_inicial_pago[1])); $document->setValue('AnioInicia', $lote->fecha_inicial_pago[0]); } $document->setValue('Contrato', $expediente); $document->setValue('Cliente', $cliente->nombre . " " . $cliente->ape_pate . " " . $cliente->ape_mate); $document->setValue('CP', $cliente->cp); if ($cliente->estado_civil == 1) { $document->setValue('Edo_Civil', 'Soltero'); $document->setValue('Regimen', ' '); } else { $document->setValue('Edo_Civil', 'Casado'); if ($cliente->regimenMatrimonial == 1) { $document->setValue('Regimen', ' bajo el regimen de Bienes mancomunados'); } else { $document->setValue('Regimen', 'bajo el regimen de Bienes separados'); } } $document->setValue('Profesion', $cliente->profesion); $document->setValue('RFC', $cliente->rfc); $document->setValue('CURP', $cliente->curp); $document->setValue('Tel_Casa', $cliente->telefono); $document->setValue('Tel_Celular', $cliente->movil); $document->setValue('Email', $cliente->email); $document->setValue('Calle', $cliente->calle); $document->setValue('No', $cliente->numero_casa); $document->setValue('Colonia', $cliente->colonia); $document->setValue('Nacionalidad', $cliente->nacionalidad); $document->setValue('Desarrollo', $lote->nombre); $document->setValue('Lote', $lote->lote); $document->setValue('LoteLetra', numtoletras_2($lote->lote)); $document->setValue('Manzana', $lote->num_letra); $document->setValue('ManzanaLetra', numtoletras_2($lote->num_letra)); $document->setValue('MtNorte', $lote->metlinor); $document->setValue('LindaNorte', $lote->metlinor); $document->setValue('MtSur', $lote->metlinsur); $document->setValue('LindaSur', $lote->lindasur); $document->setValue('MtOriente', $lote->metlinoeste); $document->setValue('LindaOriente', $lote->lindaoriente); $document->setValue('MtPoniente', $lote->metlineste); $document->setValue('LindaPoniente', $lote->lindaponiente); $document->setValue('Total', round($categoria->precio * $lote->superficie), 2); $document->setValue('TotalLetra', numtoletras(round($categoria->precio * $lote->superficie), 2)); $document->setValue('Precio_Metro', round($categoria->precio, 2)); $document->setValue('PrecioMetroLetra', numtoletras(round($categoria->precio, 2))); $document->setValue('Superficie', round($lote->superficie, 2)); $document->setValue('SuperficieLetra', numtoletras_2(round($lote->superficie, 2))); $document->setValue('SaldoFinanciar', round($cuenta->saldo_inicial)); $document->setValue('SaldoFinanciarLetra', numtoletras(round($cuenta->saldo_inicial))); $document->setValue('Enganche', round($ala_Firma)); $document->setValue('EngancheLetra', numtoletras(round($ala_Firma))); $document->setValue('Complementos', $textoEnganches); $lote->fecha_realizacion = explode("-", $lote->fecha_realizacion); $document->setValue('Dia', $lote->fecha_realizacion[2]); $document->setValue('Mes', $this->mes($lote->fecha_realizacion[1])); $document->setValue('Anio', $lote->fecha_realizacion[0]); $document->setValue('Referencia', $lote->fk_referencia); $document->setValue('Municipio', $cliente->municipio); $document->setValue('Complemento', $cliente->estado); if ($lote->tipo_operacion == 1) { $document->save($expediente . '_Contado.docx'); } else { $document->save($expediente . '_Credito.docx'); } }
private function getDiasInhabiles($fecha_inicio, $fecha_final) { if (strtotime($fecha_inicio) > strtotime($fecha_final)) { return 0; } $anio_inicia = explode('-', $fecha_inicio)[0]; $anio_final = explode('-', $fecha_final)[0]; return count(Estatica::getObjetos($this->mysqli->query('select d.dia from anio_fiscal a, dia_inhabil d where a.anio>="' . $anio_inicia . '" and a.anio<=' . $anio_final . ' and d.fk_anio_fiscal=a.anio and d.dia>="' . $fecha_inicio . '" and d.dia<="' . $fecha_final . '" order By d.dia ASC'))); }