<%@ language = "JavaScript" %> <% /* $Revision$ $Id$ File: prs_phonebook_list.asp Description: Toont telefoonboek zoekresultaten Parameters: mode: 1 personen, 2 locaties, 3 bedrijven, 4 usrrap (maar die nooit hier) xxxxxxx: Diverse filtervelden Global settings: S("prs_plaats_key"): als >-1: gebruik een flexkenmerk (stand)plaats ipv. locatie via werkplek Bij mijn weten gebruikt CONN deze alleen maar S("locphone_kenmerk_key"): als >-1 dan heeft locatie een flexkenmerk telefoon S("locfax_kenmerk_key"): als >-1 dan heeft locatie een flexkenmerk fax Context: Workframe van prs_phonebook.asp Note: De oplossing voor meerdere werkplekken -> 1 regel */ %> <% FCLTHeader.Requires({ plugins:["jQuery"], js: ["jquery-ui.js"] }); var mode = getQParamInt("mode"); var outputmode = getQParamInt("outputmode", 0); var showall = getQParamInt("showall", 0) == 1; var met_foto = getQParam("pb_photo","off")=="on"; %>
<% FCLTHeader.Generate({ outputmode: outputmode }); var autfunction = "WEB_PHONEB"; var authparams = user.checkAutorisation(autfunction); %>
<% if (outputmode == 0) // alleen naar scherm { %>
<%=L("lcl_prs_max_mailing")%>
<% } name = getQParam("Naam", -1); func = getQParamInt("func", -1 ); locat = getQParamInt("locatiekey", -1); bld = getQParamInt("gebouwkey", -1); flr = getQParamInt("verdiepingkey", -1); tel = getQParam("Telefoon", -1); if (tel == "") tel = -1; // PF: de GET geeft &Telefoon= mee, en dat leidde niet tot -1 ?? // en daarmee werden mensen zonder telefoonnr niet getoond. dept = getQParamInt("dept", -1); place = getQParam("place", -1); comp = getQParamInt('bedrijf', -1); nivwc = getQParam('nivwc', -1); sql = ""; switch (mode) { case 1: // Personen zoeken // Virtuele worden door prs_v_hoofdperslidwerkplek volkomen genegeerd // Als je iemand niet in de gids wilt zet dan maar het vinkje 'Tonen in gids' uit (5.0.10) // we laten maar 1 regel per persoon zien // en indien een wp dan de hoofdwp, indien geen wp dan geen wp var RealWP = "(SELECT prs_alg_ruimte_key, ppw.prs_perslid_key, 0 prs_perslidwerkplek_volgnr" + " FROM prs_werkplek pw, prs_v_hoofdperslidwerkplek2 ppw" + " WHERE ppw.prs_werkplek_key = pw.prs_werkplek_key)" sql = "SELECT DISTINCT " /// pf: distinct is used here to handle multiple workplaces for authorization only + "p.prs_perslid_key, " + "p.prs_perslid_naam, " + "p.prs_perslid_voornaam, " + "p.prs_perslid_tussenvoegsel, " + "p.prs_perslid_voorletters, " + "p.prs_perslid_geslacht, " + lcl.xsqla("prs_srtperslid_omschrijving", "p.prs_srtperslid_key")+ ", " + S("prs_pers_string") + " Naam," + S("prs_dep_string") + " Afdeling," if (S("prs_plaats_key") > -1) sql += " prs_kenmerklink_waarde Locatie,"; else sql += " prs_perslidwerkplek_volgnr, alg_ruimte_aanduiding Locatie," + " w.prs_alg_ruimte_key alg_ruimte_key,"; // For FGraph sql +="p.prs_perslid_telefoonnr Telefoonnr," + "p.prs_perslid_mobiel Mobielnr," + "p.prs_perslid_email Email"; if (S("prs_photo_kenmerk_key")>0 && S("ph_rowdetails")!=1) // Photo via symbooltje { sql += ", (select PRS_KENMERKLINK_WAARDE " + " from PRS_v_aanwezigKENMERKLINK PIC" + " WHERE PIC.PRS_KENMERK_KEY = " + S("prs_photo_kenmerk_key") + " AND PIC.PRS_LINK_KEY = P.PRS_PERSLID_KEY) FOTOPUBLIEK"; } sql += ", (SELECT prs_afdeling_omschrijving FROM prs_afdeling" + " WHERE prs_afdeling_key = d.prs_afdeling_parentkey) parentafdeling"; sql += ", p.prs_perslid_upper" // for sorting only + " FROM prs_v_aanwezigperslid p" + ", prs_v_aanwezigafdeling d"; if (S("prs_plaats_key") > -1) { sql += ", prs_v_aanwezigkenmerklink plts"; } else { sql += ", "+RealWP+" w" + ", alg_v_ruimte_gegevens r" + ", alg_v_aanweziglocatie l"; } sql += ", prs_v_afdeling_familie ab" + ", prs_bedrijf b" + ", prs_srtperslid ps" + " WHERE ps.prs_srtperslid_key(+) = p.prs_srtperslid_key" + " AND d.prs_afdeling_key(+) = p.prs_afdeling_key" + " AND d.prs_afdeling_key = ab.prs_afdeling_key" + " AND d.prs_bedrijf_key=b.prs_bedrijf_key " + " AND (b.prs_bedrijf_ingids = 1 OR b.prs_bedrijf_intern = 1)"; // PF: deze mag wel helemaal weg? sql += getKenmerkSql("PRS", "p.prs_perslid_key"); if (S("ph_cust_flexsearch_key") > 0) // TODO #ifdef UWVA#20021 { var cust_flex = getQParam("cust_flexval", ""); if (cust_flex != "") { sql += " AND p.prs_perslid_key IN" + " (SELECT prs_link_key" + " FROM prs_kenmerklink" + " WHERE prs_kenmerk_key = " + S("ph_cust_flexsearch_key") + " AND prs_kenmerklink_waarde = " + safe.quoted_sql(cust_flex) + " AND prs_kenmerklink_niveau = 'P'" + " AND prs_kenmerklink_verwijder IS NULL)" } } if (S("prs_plaats_key") > -1) { sql += " AND plts.prs_kenmerk_key(+) = " + S("prs_plaats_key"); sql += " AND plts.prs_link_key(+) = p.prs_perslid_key"; } else { sql +=" AND p.prs_perslid_key = w.prs_perslid_key(+)" + " AND w.prs_alg_ruimte_key = r.alg_ruimte_key(+)" + " AND r.alg_locatie_key = l.alg_locatie_key(+)"; } if (name != -1 && name != "") { sql += " AND (p.prs_perslid_upper LIKE " + safe.quoted_sql_wild(name + "%") + " OR UPPER(p.prs_perslid_voornaam) LIKE " + safe.quoted_sql_wild(name + "%") +")"; } if (func != -1) { sql += " AND p.prs_srtperslid_key = " + func; } if (tel != -1) { sql += " AND (REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(UPPER(p.prs_perslid_telefoonnr), '-'), ' '), '('), ')'), '+31', '0') LIKE REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(UPPER(" + safe.quoted_sql_wild("%" + tel + "%") + "), '-'), ' '), '('), ')'), '+31', '0')" + " OR REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(UPPER(p.prs_perslid_mobiel), '-'), ' '), '('), ')'), '+31', '0') LIKE REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(UPPER(" + safe.quoted_sql_wild("%" + tel + "%") + "), '-'), ' '), '('), ')'), '+31', '0'))"; } if (S("prs_plaats_key") != -1 && place != -1) sql += " AND UPPER(plts.prs_kenmerklink_waarde) LIKE " + safe.quoted_sql_wild("%" + place + "%"); if (locat != -1) { sql += " AND l.alg_locatie_key = " + locat; } if (bld != -1) { sql += " AND r.alg_gebouw_key = " + bld; } if (flr != -1) { sql += " AND r.alg_verdieping_key = " + flr; } // authorization of location/place if (authparams.ALGreadlevel > -1) { sql += " AND l.alg_locatie_key IN (SELECT alg_locatie_key FROM fac_v_my_locations" + " WHERE prs_perslid_key="+user_key+" AND niveau="+authparams.ALGreadlevel+")"; } if ( S("prs_plaats_key") == -1 && place != -1) { sql += " AND UPPER(l.alg_locatie_plaats) LIKE " + safe.quoted_sql_wild(place + "%"); } if (comp != -1) { sql += " AND d.prs_bedrijf_key = " + comp; } if (dept > 0) { sql += " AND ab.prs_afdeling_elder_key = " + dept; } if ( nivwc != -1 && nivwc != "") { sql += " AND UPPER("+S("prs_dep_string")+") LIKE " + safe.quoted_sql_wild("%" + nivwc + "%"); } // authorization of organization if (authparams.PRSreadlevel == 0) { sql += " AND d.prs_afdeling_key IN " + " (SELECT a.prs_afdeling_key FROM prs_v_afdeling a " + " WHERE a.prs_bedrijf_key = " + user.afdeling().prs_bedrijf_key() + ")"; } if (authparams.PRSreadlevel>S("prs_max_dep_level")) { //No rights sql += " AND 1=0"; } else { // JGL: Kan dit niet slimmer? for(i = 1;i <= authparams.PRSreadlevel; i++){ sql += " AND ab.prs_afdeling_key" + i + " IN " + "(SELECT ab.prs_afdeling_key" + i + " FROM prs_v_afdeling_boom ab, prs_v_aanwezigperslid p" + " WHERE ab.prs_afdeling_key = p.prs_afdeling_key" + " AND p.prs_perslid_key = " + user_key + ")"; } } sql += " AND prs_perslid_ingids = 1"; // filtert ook de 'speciale' personen if (S("prs_plaats_key") > -1) { sql += " ORDER BY naam"; } else { sql += " ORDER BY naam, prs_perslidwerkplek_volgnr"; } break; case 2: // Locaties zoeken sql = "SELECT l.alg_locatie_key, l.alg_locatie_omschrijving, l.alg_locatie_adres, l.alg_locatie_email, " + " l.alg_locatie_postcode, alg_locatie_plaats, l.alg_locatie_upper" // for sorting only if (S("locphone_kenmerk_key") > -1) { sql += ",(select alg_onrgoedkenmerk_waarde" + " from alg_onrgoedkenmerk where alg_kenmerk_key = " + S("locphone_kenmerk_key") + " AND alg_onrgoedkenmerk_verwijder IS NULL" + " AND alg_onrgoed_key(+) = l.alg_locatie_key) ph"; } if (S("locfax_kenmerk_key") > -1) { sql += ",(select alg_onrgoedkenmerk_waarde" + " from alg_onrgoedkenmerk where alg_kenmerk_key = " + S("locfax_kenmerk_key") + " AND alg_onrgoedkenmerk_verwijder IS NULL" + " AND alg_onrgoed_key(+) = l.alg_locatie_key) fx"; } sql +=" FROM alg_v_aanweziglocatie l"; sql += " WHERE 1=1"; if ( ((locat != 0) && (locat != "") && (locat != -1) && (!isNaN(locat)) )) { sql += " AND l.alg_locatie_key = " + locat; } // authorization of location/place if (authparams.ALGreadlevel > -1) { sql += " AND l.alg_locatie_key IN (SELECT alg_locatie_key FROM fac_v_my_locations" + " WHERE prs_perslid_key="+user_key+" AND niveau="+authparams.ALGreadlevel+")"; } if (name != -1) { sql += " AND UPPER(l.alg_locatie_plaats) LIKE " + safe.quoted_sql_wild(name + "%"); } if (place != -1) { sql += " AND UPPER(l.alg_locatie_plaats) LIKE " + safe.quoted_sql_wild("%" + place + "%"); } sql += " ORDER BY l.alg_locatie_upper "; break; case 3: // Bedrijven zoeken sql = "SELECT prs_bedrijf_key, prs_bedrijf_naam, prs_bedrijf_telefoon, " + " prs_bedrijf_fax, prs_bedrijf_bezoek_adres, prs_bedrijf_bezoek_plaats, " + " prs_bedrijf_email Email" + " FROM prs_bedrijf" + " WHERE prs_bedrijf_ingids = 1" + " AND prs_bedrijf_verwijder IS NULL"; if ( name != -1) { sql += " AND prs_bedrijf_naam_upper LIKE " + safe.quoted_sql_wild("%" + name + "%"); } if (place != -1) { sql += " AND UPPER(prs_bedrijf_bezoek_plaats) LIKE " + safe.quoted_sql_wild("%" + place + "%"); } if ( ((comp != 0) && (comp != "") && (comp != -1) && (!isNaN(comp)) )) { sql += " AND prs_bedrijf_key = " + comp; } sql += " ORDER BY prs_bedrijf_naam_upper"; break; default:sql = "SELECT 'internal error' FROM DUAL"; } function fnrowData(oRs) { var data = {mail: oRs("Email").Value}; return JSON.stringify(data); } function fnEmail (oRs) { if ( oRs("Email").Value != null ) if (outputmode == 0) return ""+safe.html(oRs("Email").value)+""; else return safe.html(oRs("Email").value); else return ""; } function fnGeslacht (oRs) { if (oRs("prs_perslid_geslacht").value===null) return ""; return oRs("prs_perslid_geslacht").value==0?L("lcl_prs_person_geslachtV"):L("lcl_prs_person_geslachtM"); } function fnLocatie (oRs) { if (S("ph_placeFG")==1 && oRs("alg_ruimte_key").Value != null) return ""+safe.html(oRs("locatie").value)+""; else return oRs("locatie").value==null ? "" : safe.html(oRs("locatie").Value); } function fnPhoto (oRs) { if (S("prs_photo_kenmerk_key")>0 && S("ph_rowdetails")!=1) { // Photo link als we geen andere details mogen zien if ( oRs("fotopubliek").Value==S("prs_photo_kenmerk_showval")) if (outputmode == 0) return ""; else return "[P]"; // niet erg zinvol, maar alla else return ""; // Geen foto } } function fnInlinePhoto (oRs) { var thisPrsFoto = new Perslid(oRs("prs_perslid_key").Value).photoinfo(oRs("prs_perslid_geslacht").value); if (outputmode == 3) // XML return thisPrsFoto.photopaththumb; var html = ""; return html; } // alleen XML-mode function fnInlinePhotoFull (oRs) { var thisPrsFoto = new Perslid(oRs("prs_perslid_key").Value).photoinfo(oRs("prs_perslid_geslacht").value); return thisPrsFoto.photopath; } switch (mode) { case 1: // personen var canBookmarkf = user.func_enabled("FAC", null, null, null, null, true); // laatste true: isOptional var canBookmark = canBookmarkf && canBookmarkf.canRead("WEB_HLPADM"); var rst = new ResultsetTable({ keyColumn: "prs_perslid_key", sql: sql, ID: "phonebooktable", rowData: fnrowData, outputmode: outputmode, advancedprint: S("ph_export_advanced"), advancedprint_title: L("lcl_pb_export_advanced"), flexModule: "PRS", flexId: "prs_perslid_key", title: L("lcl_search_pers"), showAll: showall, canBookmark: canBookmark }); var dofotos = met_foto && outputmode==0 && !showall; if (outputmode==3) // XML { dofotos = true; rst.addColumn(new Column({caption: "", content: "prs_perslid_key" })); rst.addColumn(new Column({caption: "", content: fnInlinePhotoFull })); rst.addColumn(new Column({caption: "", content: "prs_perslid_voornaam" })); rst.addColumn(new Column({caption: "", content: "prs_perslid_voorletters" })); rst.addColumn(new Column({caption: "", content: "prs_perslid_tussenvoegsel" })); rst.addColumn(new Column({caption: "", content: "prs_perslid_naam" })); } if (outputmode==2 || outputmode==6 || outputmode==3) // XSL/ XML { rst.addColumn(new Column({caption: L("lcl_prs_person_geslacht"), content: fnGeslacht })); rst.addColumn(new Column({caption: L("lcl_prs_person_function"), content: "prs_srtperslid_omschrijving" })); } if (dofotos) // screen, niet te veel rst.addColumn(new Column({caption: "", content: fnInlinePhoto })); rst.addColumn(new Column({caption: L("lcl_name"), content: "Naam" })); rst.addColumn(new Column({caption: L("lcl_pb_afdeling"), content: "Afdeling" })); if (S("ph_showparentafdeling")) rst.addColumn(new Column({caption: L("lcl_dep_name_level1"), content: "parentafdeling" })); if (S("ph_showfunctie")) rst.addColumn(new Column({caption: L("lcl_prs_person_function"), content: "prs_srtperslid_omschrijving" })); rst.addColumn(new Column({caption: L("lcl_location"), content: fnLocatie })); rst.addColumn(new Column({caption: L("lcl_phone"), content: "Telefoonnr" })); rst.addColumn(new Column({caption: L("lcl_pb_mobile"), content: "Mobielnr", combine:dofotos })); rst.addColumn(new Column({caption: L("lcl_prs_email"), content: fnEmail })); if (S("prs_photo_kenmerk_key") > 0 && S("ph_rowdetails")!=1) rst.addColumn(new Column({caption: "", content: fnPhoto })); if (S("ph_rowdetails") == 1 && (outputmode==0 || outputmode==1 || outputmode==5)) rst.addAction({action: "gotoProfiel", caption: L("lcl_edit"), isDefault: true}); if (S("prs_bulk_mail_max") > 0) rst.addAction({ action: "doMailing", caption: L("lcl_prs_mailing"), single: false, multi: true, multiOnce: true}); break; case 2: // locaties var rst = new ResultsetTable({ keyColumn: "alg_locatie_key", sql: sql, ID: "loctable", outputmode: outputmode, title: L("lcl_search_org"), showAll: showall }); rst.addColumn(new Column({caption: L("lcl_location"), content: "alg_locatie_omschrijving" })); if (S("locphone_kenmerk_key") > -1) rst.addColumn(new Column({caption: L("lcl_dep_name_level1"), content: "ph" })); if (S("locfax_kenmerk_key") > -1) rst.addColumn(new Column({caption: L("lcl_location"), content: "fx" })); rst.addColumn(new Column({caption: L("lcl_alg_loc_adres"), content: "alg_locatie_adres" })); rst.addColumn(new Column({caption: L("lcl_alg_loc_postcode"), content: "alg_locatie_postcode" })); rst.addColumn(new Column({caption: L("lcl_alg_loc_plaats"), content: "alg_locatie_plaats" })); rst.addColumn(new Column({caption: L("lcl_prs_email"), content: "alg_locatie_email" })); break; case 3: // bedrijven var rst = new ResultsetTable({ keyColumn: "prs_bedrijf_key", sql: sql, ID: "bedrijftable", outputmode: outputmode, title: L("lcl_search_bedr"), showAll: showall }); rst.addColumn(new Column({caption: L("lcl_prs_companies_name"), content: "prs_bedrijf_naam" })); rst.addColumn(new Column({caption: L("lcl_prs_companies_telefoon"), content: "prs_bedrijf_telefoon" })); rst.addColumn(new Column({caption: L("lcl_prs_companies_fax"), content: "prs_bedrijf_fax" })); rst.addColumn(new Column({caption: L("lcl_prs_companies_bezoek_adres"), content: "prs_bedrijf_bezoek_adres" })); rst.addColumn(new Column({caption: L("lcl_prs_companies_bezoek_plaats"), content: "prs_bedrijf_bezoek_plaats" })); rst.addColumn(new Column({caption: L("lcl_prs_companies_email"), content: fnEmail })); break; } var cnt = rst.processResultset(); %>