示例#1
0
function getStandardReportData($filterHeaderArray, $outputType)
{
    $daoHandler = new DAO();
    require_once APP_BASEPATH . "/includes/Entities/Task/TaskCore.php";
    require_once APP_BASEPATH . "/includes/Entities/User/UserCore.php";
    require_once APP_BASEPATH . "/includes/Entities/FlowSettings/FlowSettingsCore.php";
    require_once APP_BASEPATH . "/includes/Entities/RequestMetadata/RequestMetadataCore.php";
    require_once $_SESSION["environment_path"] . "/customcode/RecepcionDocumentos/includes/Entities/DocumentoCabecera/DocumentoCabeceraCore.php";
    require_once $_SESSION["environment_path"] . "/customcode/RecepcionDocumentos/includes/Entities/DocumentoLinea/DocumentoLineaCore.php";
    require_once $_SESSION["environment_path"] . "/customcode/RecepcionDocumentos/includes/Entities/DistribucionCabecera/DistribucionCabeceraCore.php";
    require_once $_SESSION["environment_path"] . "/customcode/RecepcionDocumentos/includes/Entities/DistribucionLinea/DistribucionLineaCore.php";
    $flowSettingsHandler = new FlowSettingsCore();
    $handlerTaskCore = new TaskCore();
    $handlerRequestMetadataCore = new RequestMetadataCore();
    $flow = $_SESSION["user_flow"];
    $step = $flowSettingsHandler->getSettingValue($_SESSION["user_flow"], "RDE_STEP_PROC_CONTABLE");
    $sql = "select\t\tCONCAT(docc.estab, '-', docc.ptoEmi, '-', docc.secuencial) documento,\r\n\t\t\t\t\t\t\tdocc.fechaEmision fecha,\r\n\t\t\t\t\t\t\tdocc.tipo_doc,\r\n\t\t\t\t            docc.ruc ruc, \r\n\t\t\t\t            docc.razonSocial nombre,\r\n\t\t\t\t            docc.ef_id ef_id\r\n\r\n\t\t\t\tfrom \t\trde_documento docc\r\n\t\t\t\twhere \t\t?\r\n\t\t\t\tand \t\tdocc.tipo_doc = 'FAC' \t";
    // Build filters
    foreach ($filterHeaderArray as $headerRecord) {
        if ($headerRecord["field_filtered"] == 1) {
            if ($headerRecord["field_data_type"] != "date") {
                $sql .= " AND " . $headerRecord["field_filter_string"] . " BETWEEN " . $headerRecord["field_min"] . " AND " . $headerRecord["field_max"] . " ";
            } else {
                $start_date = $headerRecord["field_min"] . " 00:00:00";
                $end_date = $headerRecord["field_max"] . " 23:59:59";
            }
        }
    }
    $daoHandler->resetDAO();
    $daoHandler->setQuery($sql);
    $daoHandler->setParameter('i', 1);
    $reportData = $daoHandler->executeQuery();
    foreach ($reportData as &$record) {
        $record["numero_oc"] = $handlerRequestMetadataCore->getVariable($record["ef_id"], "RDE-NUMERO-OC");
        unset($record["ef_id"]);
    }
    return $reportData;
}
示例#2
0
function getHtmlDistribucion($cabeceraRecord)
{
    $handlerTaskCore = new TaskCore();
    $handlerUserCore = new UserCore();
    $flowSettingsHandler = new FlowSettingsCore();
    $handlerDocumentoCabeceraCore = new DocumentoCabeceraCore();
    $handlerDocumentoLineaCore = new DocumentoLineaCore();
    $handlerDistribucionCabeceraCore = new DistribucionCabeceraCore();
    $handlerDistribucionLineaCore = new DistribucionLineaCore();
    $handlerRequestMetadataCore = new RequestMetadataCore();
    $cabeceraData = $handlerDocumentoCabeceraCore->getRecordById($cabeceraRecord["id"]);
    $lineasData = $handlerDocumentoLineaCore->getRecordsByFieldFilter(array(array("field" => "id_documento", "type" => "i", "value" => $cabeceraRecord["id"])));
    $numero_req = $handlerRequestMetadataCore->getVariable($cabeceraRecord["ef_id"], "RDE-NUMERO-REQ");
    $numero_oc = $handlerRequestMetadataCore->getVariable($cabeceraRecord["ef_id"], "RDE-NUMERO-OC");
    $reclamo_seguro = $handlerRequestMetadataCore->getVariable($cabeceraRecord["ef_id"], "RDE-RECLAMO-SEGURO");
    $comentarios = $handlerRequestMetadataCore->getVariable($cabeceraRecord["ef_id"], "RDE-COMENTARIO");
    $dataPasosAprobador1 = $handlerTaskCore->getTaskDataByRequestFlowStep($cabeceraRecord["ef_id"], $_SESSION["user_flow"], $flowSettingsHandler->getSettingValue($_SESSION["user_flow"], "RDE_STEP_APROBACION_1"));
    $dataPasosAprobador2 = $handlerTaskCore->getTaskDataByRequestFlowStep($cabeceraRecord["ef_id"], $_SESSION["user_flow"], $flowSettingsHandler->getSettingValue($_SESSION["user_flow"], "RDE_STEP_APROBACION_2"));
    $aprobador1 = "";
    $aprobador2 = "";
    if (count($dataPasosAprobador1) > 0) {
        $dataAprobador1 = $handlerUserCore->getUserData($dataPasosAprobador1[0]["task_assignedto"]);
        $aprobador1 = $dataAprobador1["user_name"];
    }
    if (count($dataPasosAprobador2) > 0) {
        $dataAprobador2 = $handlerUserCore->getUserData($dataPasosAprobador2[0]["task_assignedto"]);
        $aprobador2 = $dataAprobador2["user_name"];
    }
    $lineasHtml = "";
    foreach ($lineasData as $linea) {
        $distribucionLineaHtml = '';
        if ($cabeceraRecord["tipo_distribucion"] == "detallada") {
            $lineasDistribucionData = $handlerDistribucionLineaCore->getRecordsByFieldFilter(array(array("field" => "id_documento_linea", "type" => "i", "value" => $linea["id"])));
            foreach ($lineasDistribucionData as $lineaDist) {
                $distribucionLineaHtml .= $lineaDist["cc_id"] . '  : ' . $lineaDist["porcentaje"] . '% ($ ' . number_format($lineaDist["valor_distribuido"], 2, '.', '') . ')<br />';
            }
        }
        $lineasHtml .= '<tr>';
        $lineasHtml .= '<td>' . $linea["descripcion"] . '</td>';
        $lineasHtml .= '<td>' . number_format($linea["cantidad"], 2, '.', '') . '</td>';
        $lineasHtml .= '<td>$ ' . number_format($linea["precioUnitario"], 2, '.', '') . '</td>';
        $lineasHtml .= '<td>' . $distribucionLineaHtml . '</td>';
        $lineasHtml .= '<td>$ ' . number_format($linea["precioTotalSinImpuesto"], 2, '.', '') . '</td>';
        $lineasHtml .= '</tr>';
    }
    $lineasHtml .= '<tr>
                            <td colspan="4" class="subtitle" style="text-align: right; background-color: #eee;">Subtotal IVA 12%</td>
                            <td>$ ' . number_format($cabeceraData["subtotalIva12"], 2, '.', '') . '</td>
                        </tr>';
    $lineasHtml .= '<tr>
                            <td colspan="4" class="subtitle" style="text-align: right; background-color: #eee;">IVA 12%</td>
                            <td>$ ' . number_format($cabeceraData["subtotalIva12"], 2, '.', '') . '</td>
                        </tr>';
    $lineasHtml .= '<tr>
                            <td colspan="4" class="subtitle" style="text-align: right; background-color: #eee;">Subtotal IVA 0%</td>
                            <td>$ ' . number_format($cabeceraData["subtotalIva0"], 2, '.', '') . '</td>
                        </tr>';
    $lineasHtml .= '<tr>
                            <td colspan="4" class="subtitle" style="text-align: right; background-color: #eee;">Subtotal Sin IVA</td>
                            <td>$ ' . number_format($cabeceraData["subtotalSinIva"], 2, '.', '') . '</td>
                        </tr>';
    $lineasHtml .= '<tr>
                            <td colspan="4" class="subtitle" style="text-align: right; background-color: #eee;">Importe Total</td>
                            <td>$ ' . number_format($cabeceraData["importeTotal"], 2, '.', '') . '</td>
                        </tr>';
    $distribucionGlobalHtml = '';
    if ($cabeceraData["distribucion"] == "global") {
        $cabeceraDistribucionData = $handlerDistribucionCabeceraCore->getRecordsByFieldFilter(array(array("field" => "id_documento", "type" => "i", "value" => $cabeceraData["id"])));
        if (count($cabeceraDistribucionData) > 0) {
            $distribucionGlobalHtml .= '<h3>Distribución global</h3> 
                                            <table style="width: 100%;">
                                                <tr style="background-color: #ddd;">
                                                    <td class="strong centered subtitle" style="width: 70%; font-weight: bold;">Centro de costo</td>
                                                    <td class="strong centered subtitle" style="width: 15%; font-weight: bold;">Porcentaje</td>
                                                    <td class="strong centered subtitle" style="width: 15%; font-weight: bold;">Valor distribuido</td>
                                                </tr>';
            foreach ($cabeceraDistribucionData as $cabecera) {
                $distribucionGlobalHtml .= '<tr>';
                $distribucionGlobalHtml .= '<td style="width: 70%;">' . $cabecera["cc_id"] . ' - ' . $cabecera["cc_nombre"] . '</td>';
                $distribucionGlobalHtml .= '<td style="width: 15%;">' . $cabecera["porcentaje"] . '</td>';
                $distribucionGlobalHtml .= '<td style="width: 15%;">$ ' . number_format($cabecera["valor_distribuido"], 2, '.', '') . '</td>';
                $distribucionGlobalHtml .= '</tr>';
            }
            $distribucionGlobalHtml .= ' </table>';
        }
    }
    $html = '	<table style="width: 100%;">
						<tr>
	                        <td><strong>Tipo: </strong></td>
	                        <td>Factura</td>
	                        <td><strong>Número: </strong></td>
	                        <td>' . $cabeceraRecord["factura"] . '</td>
	                        <td><strong>Fecha: </strong></td>
	                        <td>' . $cabeceraRecord["fecha"] . '</td>
	                    </tr>
	                    <tr>
	                        <td><strong>Proveedor: </strong></td>
	                        <td>' . $cabeceraRecord["proveedor"] . '</td>
	                        <td><strong>N° requisición: </strong></td>
	                        <td>' . $numero_req . '</td>
	                        <td><strong>N° orden de compra: </strong></td>
	                        <td>' . $numero_oc . '</td>
	                    </tr>

	                    <tr>
	                        <td><strong>Comentarios: </strong></td>
	                        <td colspan="5">' . $comentarios . '</td>
	                    </tr>

	                    <tr>
	                        <td colspan="6" class="unbordered">&nbsp;</td>
	                    </tr>
	                    <tr>
	                        <td colspan="6">
	                            
	                            <h3>Detalles de documento</h3>

	                            <table style="width: 100%;">
	                                <tr style="background-color: #ddd;">
	                                    <td><strong>Descripción</strong></td>
	                                    <td style="width: 10%;"><strong>Cantidad</strong></td>
	                                    <td style="width: 10%;"><strong>V. Uni</strong>.</td>
	                                    <td><strong>Distribución</strong></td>
	                                    <td style="width: 10%;"><strong>Total</strong></td>
	                                </tr>
	                                ' . $lineasHtml . '
	                            </table>

	                            <br /> 

	                            ' . $distribucionGlobalHtml . '

	                            <br /> 

	                        </td>
	                    </tr>
	                    <tr>
	                        <td colspan="6" class="unbordered">&nbsp;</td>
	                    </tr>
	                </table>

					';
    return $html;
}