CREATE OR REPLACE VIEW public.v_reporte_documento3
AS SELECT ( SELECT np2.string_value
           FROM alf_namespace ns2, 
            alf_qname qn2, 
            alf_node_properties np2, 
            alf_node nd2
          WHERE ns.id = qn.ns_id AND qn2.id = np2.qname_id AND nd2.id = np2.node_id AND np2.node_id = np.node_id AND ns2.uri::text = 'http://www.alfresco.org/model/content/1.0'::text AND qn2.local_name::text = 'name'::text) AS id, 
    ( SELECT np8.string_value
           FROM alf_namespace ns8, 
            alf_qname qn8, 
            alf_node_properties np8, 
            alf_node nd8
          WHERE ns.id = qn.ns_id AND qn8.id = np8.qname_id AND nd8.id = np8.node_id AND np8.node_id = np.node_id AND ns8.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn8.local_name::text = 'numerodocumento'::text) AS numero_documento, 
    ( SELECT np2.string_value
           FROM alf_namespace ns2, 
            alf_qname qn2, 
            alf_node_properties np2, 
            alf_node nd2
          WHERE ns.id = qn.ns_id AND qn2.id = np2.qname_id AND nd2.id = np2.node_id AND np2.node_id = np.node_id AND ns2.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn2.local_name::text = 'notaproceso'::text) AS notaproceso, 
    ( SELECT np3.string_value
           FROM alf_namespace ns3, 
            alf_qname qn3, 
            alf_node_properties np3, 
            alf_node nd3
          WHERE ns3.id = qn3.ns_id AND qn3.id = np3.qname_id AND nd3.id = np3.node_id AND np3.node_id = np.node_id AND ns3.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn3.local_name::text = 'pais'::text) AS pais, 
    ( SELECT np4.string_value
           FROM alf_namespace ns4, 
            alf_qname qn4, 
            alf_node_properties np4, 
            alf_node nd4
          WHERE ns4.id = qn4.ns_id AND qn4.id = np4.qname_id AND nd4.id = np4.node_id AND np4.node_id = np.node_id AND ns4.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn4.local_name::text = 'tipodocumento'::text) AS tipo_documento, 
    ( SELECT np5.string_value
           FROM alf_namespace ns5, 
            alf_qname qn5, 
            alf_node_properties np5, 
            alf_node nd5
          WHERE ns5.id = qn5.ns_id AND qn5.id = np5.qname_id AND nd5.id = np5.node_id AND np5.node_id = np.node_id AND ns5.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn5.local_name::text = 'codigoempresa'::text) AS codigo_cliente, 
    ( SELECT np6.string_value
           FROM alf_namespace ns6, 
            alf_qname qn6, 
            alf_node_properties np6, 
            alf_node nd6
          WHERE ns6.id = qn6.ns_id AND qn6.id = np6.qname_id AND nd6.id = np6.node_id AND np6.node_id = np.node_id AND ns6.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn6.local_name::text = 'nombreproveedor'::text) AS nombre_proveedor, 
    ( SELECT np7.string_value
           FROM alf_namespace ns7, 
            alf_qname qn7, 
            alf_node_properties np7, 
            alf_node nd7
          WHERE ns7.id = qn7.ns_id AND qn7.id = np7.qname_id AND nd7.id = np7.node_id AND np7.node_id = np.node_id AND ns7.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn7.local_name::text = 'numerosap'::text) AS numero_sap, 
    ( SELECT np14.string_value
           FROM alf_namespace ns14, 
            alf_qname qn14, 
            alf_node_properties np14, 
            alf_node nd14
          WHERE ns14.id = qn14.ns_id AND qn14.id = np14.qname_id AND nd14.id = np14.node_id AND np14.node_id = np.node_id AND ns14.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn14.local_name::text = 'periodocontable'::text) AS periodo_contable, 
    ( SELECT np8.string_value
           FROM alf_namespace ns8, 
            alf_qname qn8, 
            alf_node_properties np8, 
            alf_node nd8
          WHERE ns8.id = qn8.ns_id AND qn8.id = np8.qname_id AND nd8.id = np8.node_id AND np8.node_id = np.node_id AND ns8.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn8.local_name::text = 'numeroradicado'::text) AS numero_radicado, 
    ( SELECT np9.string_value
           FROM alf_namespace ns9, 
            alf_qname qn9, 
            alf_node_properties np9, 
            alf_node nd9
          WHERE ns9.id = qn9.ns_id AND qn9.id = np9.qname_id AND nd9.id = np9.node_id AND np9.node_id = np.node_id AND ns9.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn9.local_name::text = 'validador'::text) AS validador, 
    ( SELECT np10.string_value
           FROM alf_namespace ns10, 
            alf_qname qn10, 
            alf_node_properties np10, 
            alf_node nd10
          WHERE ns10.id = qn10.ns_id AND qn10.id = np10.qname_id AND nd10.id = np10.node_id AND np10.node_id = np.node_id AND ns10.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn10.local_name::text = 'fechavalidacion'::text) AS fecha_validacion, 
    ( SELECT np11.string_value
           FROM alf_namespace ns11, 
            alf_qname qn11, 
            alf_node_properties np11, 
            alf_node nd11
          WHERE ns11.id = qn11.ns_id AND qn11.id = np11.qname_id AND nd11.id = np11.node_id AND np11.node_id = np.node_id AND ns11.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn11.local_name::text = 'motivorechazo'::text) AS motivo_rechazo, 
    ( SELECT np12.string_value
           FROM alf_namespace ns12, 
            alf_qname qn12, 
            alf_node_properties np12, 
            alf_node nd12
          WHERE ns12.id = qn12.ns_id AND qn12.id = np12.qname_id AND nd12.id = np12.node_id AND np12.node_id = np.node_id AND ns12.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn12.local_name::text = 'aprobador'::text) AS aprobador, 
    ( SELECT np13.string_value
           FROM alf_namespace ns13, 
            alf_qname qn13, 
            alf_node_properties np13, 
            alf_node nd13
          WHERE ns13.id = qn13.ns_id AND qn13.id = np13.qname_id AND nd13.id = np13.node_id AND np13.node_id = np.node_id AND ns13.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn13.local_name::text = 'fechaaprobacion'::text) AS fecha_aprobacion, 
    ( SELECT np14.string_value
           FROM alf_namespace ns14, 
            alf_qname qn14, 
            alf_node_properties np14, 
            alf_node nd14
          WHERE qn14.id = np14.qname_id AND nd14.id = np14.node_id AND np14.node_id = np.node_id AND ns14.id = qn14.ns_id AND ns14.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn14.local_name::text = 'pagina'::text) AS pagina, 
    ( SELECT np15.string_value
           FROM alf_namespace ns15, 
            alf_qname qn15, 
            alf_node_properties np15, 
            alf_node nd15
          WHERE qn15.id = np15.qname_id AND nd15.id = np15.node_id AND np15.node_id = np.node_id AND ns15.id = qn15.ns_id AND ns15.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn15.local_name::text = 'moneda'::text) AS moneda, 
    ( SELECT np16.string_value
           FROM alf_namespace ns16, 
            alf_qname qn16, 
            alf_node_properties np16, 
            alf_node nd16
          WHERE qn16.id = np16.qname_id AND nd16.id = np16.node_id AND np16.node_id = np.node_id AND ns16.id = qn16.ns_id AND ns16.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn16.local_name::text = 'asociacion'::text) AS asociacion, 
    ( SELECT np17.string_value
           FROM alf_namespace ns17, 
            alf_qname qn17, 
            alf_node_properties np17, 
            alf_node nd17
          WHERE qn17.id = np17.qname_id AND nd17.id = np17.node_id AND np17.node_id = np.node_id AND ns17.id = qn17.ns_id AND ns17.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn17.local_name::text = 'aprobar2'::text) AS validado, 
    ( SELECT np18.string_value
           FROM alf_namespace ns18, 
            alf_qname qn18, 
            alf_node_properties np18, 
            alf_node nd18
          WHERE qn18.id = np18.qname_id AND nd18.id = np18.node_id AND np18.node_id = np.node_id AND ns18.id = qn18.ns_id AND ns18.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn18.local_name::text = 'contabilizado'::text) AS contabilizado, 
    ( SELECT np19.string_value
           FROM alf_namespace ns19, 
            alf_qname qn19, 
            alf_node_properties np19, 
            alf_node nd19
          WHERE qn19.id = np19.qname_id AND nd19.id = np19.node_id AND np19.node_id = np.node_id AND ns19.id = qn19.ns_id AND ns19.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn19.local_name::text = 'fechacontabilizado'::text) AS fechacontabilizado, 
    ( SELECT np15.string_value
           FROM alf_namespace ns15, 
            alf_qname qn15, 
            alf_node_properties np15, 
            alf_node nd15
          WHERE qn15.id = np15.qname_id AND nd15.id = np15.node_id AND np15.node_id = np.node_id AND ns15.id = qn15.ns_id AND ns15.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn15.local_name::text = 'vertical'::text) AS vertical, 
    ( SELECT np15.string_value
           FROM alf_namespace ns15, 
            alf_qname qn15, 
            alf_node_properties np15, 
            alf_node nd15
          WHERE qn15.id = np15.qname_id AND nd15.id = np15.node_id AND np15.node_id = np.node_id AND ns15.id = qn15.ns_id AND ns15.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn15.local_name::text = 'tipomoneda'::text) AS tipomoneda, 
    ( SELECT np15.string_value
           FROM alf_namespace ns15, 
            alf_qname qn15, 
            alf_node_properties np15, 
            alf_node nd15
          WHERE qn15.id = np15.qname_id AND nd15.id = np15.node_id AND np15.node_id = np.node_id AND ns15.id = qn15.ns_id AND ns15.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn15.local_name::text = 'responsablecxp'::text) AS responsablecxp, 
    ( SELECT np15.string_value
           FROM alf_namespace ns15, 
            alf_qname qn15, 
            alf_node_properties np15, 
            alf_node nd15
          WHERE qn15.id = np15.qname_id AND nd15.id = np15.node_id AND np15.node_id = np.node_id AND ns15.id = qn15.ns_id AND ns15.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn15.local_name::text = 'responsable'::text) AS responsable, 
    ( SELECT np15.string_value
           FROM alf_namespace ns15, 
            alf_qname qn15, 
            alf_node_properties np15, 
            alf_node nd15
          WHERE qn15.id = np15.qname_id AND nd15.id = np15.node_id AND np15.node_id = np.node_id AND ns15.id = qn15.ns_id AND ns15.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn15.local_name::text = 'documentosradicados'::text) AS documentosradicados, 
    ( SELECT np15.string_value
           FROM alf_namespace ns15, 
            alf_qname qn15, 
            alf_node_properties np15, 
            alf_node nd15
          WHERE qn15.id = np15.qname_id AND nd15.id = np15.node_id AND np15.node_id = np.node_id AND ns15.id = qn15.ns_id AND ns15.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn15.local_name::text = 'tipofactura'::text) AS tipofactura, 
    ( SELECT np15.string_value
           FROM alf_namespace ns15, 
            alf_qname qn15, 
            alf_node_properties np15, 
            alf_node nd15
          WHERE qn15.id = np15.qname_id AND nd15.id = np15.node_id AND np15.node_id = np.node_id AND ns15.id = qn15.ns_id AND ns15.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn15.local_name::text = 'numerodefacturas'::text) AS numerodefacturas, 
    ( SELECT np15.string_value
           FROM alf_namespace ns15, 
            alf_qname qn15, 
            alf_node_properties np15, 
            alf_node nd15
          WHERE qn15.id = np15.qname_id AND nd15.id = np15.node_id AND np15.node_id = np.node_id AND ns15.id = qn15.ns_id AND ns15.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn15.local_name::text = 'numerodedigitalizados'::text) AS numerodedigitalizados, 
    ( SELECT np15.string_value
           FROM alf_namespace ns15, 
            alf_qname qn15, 
            alf_node_properties np15, 
            alf_node nd15
          WHERE qn15.id = np15.qname_id AND nd15.id = np15.node_id AND np15.node_id = np.node_id AND ns15.id = qn15.ns_id AND ns15.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn15.local_name::text = 'nodedocumentos'::text) AS nodedocumentos, 
    ( SELECT np15.string_value
           FROM alf_namespace ns15, 
            alf_qname qn15, 
            alf_node_properties np15, 
            alf_node nd15
          WHERE qn15.id = np15.qname_id AND nd15.id = np15.node_id AND np15.node_id = np.node_id AND ns15.id = qn15.ns_id AND ns15.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn15.local_name::text = 'etapa'::text) AS etapa, 
    ( SELECT np15.string_value
           FROM alf_namespace ns15, 
            alf_qname qn15, 
            alf_node_properties np15, 
            alf_node nd15
          WHERE qn15.id = np15.qname_id AND nd15.id = np15.node_id AND np15.node_id = np.node_id AND ns15.id = qn15.ns_id AND ns15.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn15.local_name::text = 'hade'::text) AS hade, 
    ( SELECT np15.string_value
           FROM alf_namespace ns15, 
            alf_qname qn15, 
            alf_node_properties np15, 
            alf_node nd15
          WHERE qn15.id = np15.qname_id AND nd15.id = np15.node_id AND np15.node_id = np.node_id AND ns15.id = qn15.ns_id AND ns15.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn15.local_name::text = 'documentooriginal'::text) AS documentooriginal, 
    np.string_value AS estados, 
    nd.audit_creator, 
    nd.audit_created, 
    nd.audit_modifier, 
    nd.audit_modified, 
    nd.acl_id - 1 AS acl_id, 
    nd.type_qname_id, 
    ( SELECT np15.string_value
           FROM alf_namespace ns15, 
            alf_qname qn15, 
            alf_node_properties np15, 
            alf_node nd15
          WHERE qn15.id = np15.qname_id AND nd15.id = np15.node_id AND np15.node_id = np.node_id AND ns15.id = qn15.ns_id AND ns15.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn15.local_name::text = 'analista'::text) AS analista, 
    ( SELECT np15.string_value
           FROM alf_namespace ns15, 
            alf_qname qn15, 
            alf_node_properties np15, 
            alf_node nd15
          WHERE qn15.id = np15.qname_id AND nd15.id = np15.node_id AND np15.node_id = np.node_id AND ns15.id = qn15.ns_id AND ns15.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn15.local_name::text = 'contrato'::text) AS contrato, 
    ( SELECT np15.string_value
           FROM alf_namespace ns15, 
            alf_qname qn15, 
            alf_node_properties np15, 
            alf_node nd15
          WHERE qn15.id = np15.qname_id AND nd15.id = np15.node_id AND np15.node_id = np.node_id AND ns15.id = qn15.ns_id AND ns15.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn15.local_name::text = 'gerente'::text) AS gerente
   FROM alf_namespace ns, 
    alf_qname qn, 
    alf_node_properties np, 
    alf_node nd
  WHERE ns.id = qn.ns_id AND qn.id = np.qname_id AND nd.id = np.node_id AND nd.store_id = 6 AND ns.uri::text = 'http://www.alfresco.com/model/customModel/1.0'::text AND qn.local_name::text = 'estadodocumento'::text AND (nd.type_qname_id <> ALL (ARRAY[309::bigint, 26::bigint, 68::bigint, 194::bigint]))
  ORDER BY np.string_value;

