function egresos_guardar() { $fechaPago = normalize_date2($_POST["fechaPago"]); //ACTUALIZAMOS FECHA DE PAGO, CTA DE PAGO Y TIPO DE PAGO liberar_bd(); $updateEgresoPagoCta = 'CALL sp_sistema_update_egreso_pago_cta( ' . $_SESSION["idEgresoActual"] . ', "' . $fechaPago . '", ' . $_POST["optFormaPago"] . ', ' . $_POST["idCta"] . ');'; $updateEPC = consulta($updateEgresoPagoCta); if ($updateEPC) { //DATOS DE LA CUENTA liberar_bd(); $selectDatosCuenta = 'CALL sp_sistema_select_datos_cuentas(' . $_POST["idCta"] . ');'; $datosCuenta = consulta($selectDatosCuenta); $cuenta = siguiente_registro($datosCuenta); $nvoSaldo = $cuenta["monto"] - $_POST["totalEgreso"]; //GUARDAMOS NUEVO SALDO liberar_bd(); $updateCuenta = 'CALL sp_sistema_update_saldo_cuenta(' . $_POST["idCta"] . ', "' . $nvoSaldo . '", ' . $_SESSION[$varIdUser] . ');'; $update = consulta($updateCuenta); //ACTUALIZAMOS ESTATUS DE DETALLES DE EGRESO liberar_bd(); $updateEstatusDetallesEgreso = 'CALL sp_sistema_update_estatus_detalles_egreso(' . $_SESSION["idEgresoActual"] . ', 1, ' . $_SESSION[$varIdUser] . ');'; $updateEDE = consulta($updateEstatusDetallesEgreso); //ACTUALIZAMOS ESTATUS DE EGRESO liberar_bd(); $updateEstatusEgreso = 'CALl sp_sistema_update_estatus_egreso(' . $_SESSION["idEgresoActual"] . ', 1, ' . $_SESSION[$varIdUser] . ');'; $updateE = consulta($updateEstatusEgreso); //CREAMOS EL RECIBO //DATOS DE LA EMPRESA liberar_bd(); $selecDatosEmpresa = "CALL sp_sistema_select_datos_empresa();"; $datosEmpresa = consulta($selecDatosEmpresa); $empresa = siguiente_registro($datosEmpresa); //DATOS DEL EGRESO liberar_bd(); $selectDatosEgreso = 'CALL sp_sistema_select_datos_egreso(' . $_SESSION["idEgresoActual"] . ');'; $datosEgresos = consulta($selectDatosEgreso); $dateEgr = siguiente_registro($datosEgresos); $subtotalEgr = $dateEgr["subtotal"]; $ivaEgr = $dateEgr["iva"]; $totalEgr = $dateEgr["total"]; //CHECAMOS SI SE ASIGNO PROVEEDOR liberar_bd(); $selectProveedorEgreso = 'CALL sp_sistema_select_proveedor_egreso(' . $_SESSION["idEgresoActual"] . ');'; $proveedorEgreso = consulta($selectProveedorEgreso); $ctaProveedorEgreso = cuenta_registros($proveedorEgreso); if ($ctaProveedorEgreso != 0) { $provEgr = siguiente_registro($proveedorEgreso); $datosProveedor = 'Proveedor: ' . utf8_encode($provEgr["proveedor"]); } else { $datosProveedor = 'Proveedor: Sin proveedor'; } //DATOS DEL PROYECTO if ($_SESSION["idProyectoActual"] != '') { liberar_bd(); $selectProyecto = 'CALL sp_sistema_select_datos_proyecto(' . $_SESSION["idProyectoActual"] . ');'; $proyecto = consulta($selectProyecto); $proy = siguiente_registro($proyecto); $datosProyecto = ' Proyecto: ' . utf8_encode($proy["nombre"]); } else { $datosProyecto = ''; } $fechaFormt = date('Y-m-d'); $primerDia = date('Y-m'); $fechaFormtFiltro = date('d/m/Y'); $primerDiaFiltro = date('m/Y'); $header = ' <style> @page { } body { color: #666666; font-family: Arial,Helvetica,sans-serif; font-size: 13px; line-height: 16px; font: 13px/1.231 sans-serif; text-align: justify !important; } .tablaDetalles { width:100%; } .tablaDetalles-header + .table { border-top: 0; } .tablaDetalles thead, .tablaDetalles tbody tr th, .tablaDetalles tfoot tr th { text-align: center; } .tablaDetalles tbody tr .tdNumerico, .tablaDetalles tfoot tr .tdNumerico { text-align:right !important; } .txtFecha { text-align:right !important; } .contenedorImg { width: 100%; display: table; text-align: center; } .divImg { vertical-align: middle; display: table-cell; table-layout: fixed; } .divImgHojas { width: 100%; } .imgHojas { float: right; margin-top: -40px; margin-right: -40px; } .imgLogo { } .contenedorImgs { width: 100%; display: table; text-align: center; } .divImgPre { width: 33%; float: left; } .imgPre { width: 90%; } .contenedor { padding:0 25px; } </style> '; $htmlHeader = ''; $html = ' <div class="contenedor"> <table class="tablaDetalles"> <tbody> <tr> <td> <p id="txtDatos">' . convertMayus($datosProveedor) . '<br> ' . convertMayus($datosProyecto) . '<br> Fecha del Documento: ' . normalize_date($dateEgr["fechaDoc"]) . '<br> Folio Documento: ' . $dateEgr["folioDoc"] . '<br> Concepto: ' . utf8_encode($dateEgr["concepto"]) . '<br> Observación: ' . utf8_encode($dateEgr["observacion"]) . '</p> </td> <td style="text-align:right;"> <div class="contenedorImg"> <div class="divImg"> <img width="100px" alt="" src="imagenes/empresa/' . $empresa["logo"] . '" /> <p>Tel. ' . utf8_encode($empresa["telefono"]) . '</p> </div> </div> </td> </tr> </tbody> </table> </div> <div class="contenedor"> <table class="tablaDetalles"> <thead> <th>CANTIDAD</th> <th>PRODUCTO</th> <th>TIPO EGRESO</th> <th class="thProyecto">PROYECTO</th> <th>TOTAL</th> </thead> <tbody>'; //DETALLES DEL EGRESO liberar_bd(); $selectDetallesEgreso = 'CALL sp_sistema_select_detalles_idEgreso(' . $_SESSION["idEgresoActual"] . ');'; $detallesEgreso = consulta($selectDetallesEgreso); while ($det = siguiente_registro($detallesEgreso)) { //CHECAMOS PROYECTO DEL DETALLE liberar_bd(); $selectProyectoDetalle = 'CALL sp_sistema_select_proyecto_detalle_egreso(' . $det["id"] . ');'; $proyectoDetalle = consulta($selectProyectoDetalle); $ctaProyectoDetalle = cuenta_registros($proyectoDetalle); if ($ctaProyectoDetalle != 0) { $proyDet = siguiente_registro($proyectoDetalle); $detProyecto = utf8_encode($proyDet["nombre"]); } else { $detProyecto = ''; } $html .= '<tr> <td>' . $det["cantidad"] . '</td> <td>' . $det["producto"] . '</td> <td>' . $det["tipo"] . '</td> <td>' . $detProyecto . '</td> <td class="tdNumerico">' . number_format($det["total"], 2) . '</td> </tr>'; } $html .= ' </tbody> <tfoot> <tr> <th class="tdNumerico" colspan="4">TOTAL</th> <th class="tdNumerico">$' . number_format($totalEgr, 2) . '</th> </tr> <tr> <th class="tdNumerico" colspan="4"></th> <th class="tdNumerico"></th> </tr> </tfoot> </table> </div> <div class="contenedor"> <p id="txtDatos">Recibí de Claustro Santa Fe la cantidad de $' . number_format($totalEgr, 2) . '<br> Por concepto ' . utf8_encode($dateEgr["observacion"]) . '<br><br><br> Nombre: _________________________________________________________<br><br> Firma: ___________________________________________________________</p> </div>'; $htmlFooter = ''; include_once '../clases/mpdf/mpdf.php'; $src = date("YmdHis") . ".pdf"; $htmlSalidas = utf8_encode($html); $mpdf = new mPDF('utf-8'); $mpdf->SetHTMLHeader($htmlHeader); $mpdf->DefHTMLHeaderByName('Chapter2Header', '<div style="text-align: right; border-bottom: 1px solid #000000; font-weight: bold; font-size: 10pt;">Chapter 2</div>'); $mpdf->WriteHTML($header); $mpdf->WriteHTML($htmlSalidas); $mpdf->SetHTMLFooter($htmlFooter); $mpdf->Output("imagenes/egresos/" . $src, "F"); //GUARDAMOS URL DEL EGRESO liberar_bd(); $updateUrlEgreso = 'CALL sp_sistema_update_url_egreso(' . $_SESSION["idEgresoActual"] . ', "' . $src . '");'; $updateUE = consulta($updateUrlEgreso); if ($_POST["idTipoEntrega"] == 1) { $imprimeDoc = ''; } elseif ($_POST["idTipoEntrega"] == 2) { $imprimeDoc = '<script> var idArchivo = \'' . $src . '\'; $(document).ready( function() { $("#myModal2").modal("toggle"); var archivo = "imagenes/egresos/"+idArchivo; $("#divVerEgreso").html(""); $("#divVerEgreso").html(\'<embed src="" style="width:100%; height:500px;">\'); $("#divVerEgreso embed").attr("src", archivo); }); </script>'; } $error = 'Se ha creado el egreso.'; $msj = sistema_mensaje("exito", $error); $res = $msj . egresos_menuInicio() . $imprimeDoc; } else { $error = 'No se ha podido guardar el egreso.'; $msj = sistema_mensaje("error", $error); $res = $msj . egresos_menuInicio(); } return $res . $pagina; }
function cuentas_eliminarCuenta() { //CHECAMOS SI LA CUENTA TIENE SUBCUENTAS liberar_bd(); $selectSubcuentasCuentas = 'CALL sp_sistema_select_subcuentas_cuentas_contables(' . $_POST["idCuenta"] . ');'; $subCueCuen = consulta($selectSubcuentasCuentas); $ctaSubCueCue = cuenta_registros($subCueCuen); if ($ctaSubCueCue == 0) { liberar_bd(); $deleteCtaContable = "CALL sp_sistema_delete_cuenta_contable(" . $_POST["idCuenta"] . ", " . $_SESSION[$varIdUser] . ");"; $delete = consulta($deleteCtaContable); if ($delete) { //DATOS DE LA CUENTA liberar_bd(); $selectDatosCuenta = 'CALL sp_sistema_select_datos_cuenta_contableId(' . $_POST["idCuenta"] . ');'; $datosCuenta = consulta($selectDatosCuenta); $cuen = siguiente_registro($datosCuenta); //NUMERO DE HIJOS DE LA CUENTA PADRE liberar_bd(); $selectNumeroHijos = 'CALL sp_sistema_select_datos_cuenta_contableId(' . $cuen["padre"] . ');'; $numeroHijos = consulta($selectNumeroHijos); $hijos = siguiente_registro($numeroHijos); $ctaNumeroHijos = $hijos["numHijos"] - 1; //ACTUALIZAMOS NUMERO DE HIJOS DE LA CUENTA PADRE liberar_bd(); $updateNumeroHijos = 'CALL sp_sistema_update_numeroHijos_cuenta_contableId(' . $cuen["padre"] . ', ' . $ctaNumeroHijos . ');'; $upNumHijos = consulta($updateNumeroHijos); $res = $msj . cuentas_menuInicio(); } else { $error = 'No se ha podido eliminar la categoría.'; $msj = sistema_mensaje("error", $error); $res = $msj . cuentas_menuInicio(); } } else { $error = 'Esta categoría tiene subcategorias activas.'; $msj = sistema_mensaje("error", $error); $res = $msj . cuentas_menuInicio(); } return $res . $updateNumeroHijos; }