1 procedure Tf_htcityq.qry_prprBeforeOpen(DataSet: TDataSet);
  2 var
  3 logMapId : string;
  4 begin
  5 inherited;
  6 with TQuery(Dataset) do
  7 begin
  8 sql.clear;
  9 sql.Add('Select prp_Name Name');
 10 sql.Add(', prp_Type Type');
 11 sql.Add(', prp_Id Id');
 12 sql.Add(', prp_Contact Contact');
 13 sql.Add(', prp_Phone Phone');
 14 sql.Add(', prp_Fax Fax');
 15 sql.Add(', prp_Addr1 Address');
 16 sql.Add(', (prp_City || '', '' ||  prp_St || '' '' || prp_PCode) As CitySTZip');
 17 sql.Add(', prp_UnitCnt Units');
 18 sql.Add(', (''$'' || prp_MoPriceLR || ''-$'' || prp_MoPriceHR) As Rent');
 19 sql.Add(', (prp_RmLR || ''-'' || prp_RmHR) as Beds');
 20 sql.Add(', (prp_BathLR || ''-'' || prp_BathHR) as Baths');
 21 sql.Add(', (prp_keymap) As KeyMap');
 22 sql.Add(', (prp_MapLocId) As CityQMap');
 23 sql.Add(', (prp_JMPURL) As URL');
 24 sql.Add(', prp_status Status');
 25 sql.Add(', (mc_name) As Management');
 26 //features start here
 27 if WebDemoApp.checked['ziShowPrpFeatures']= true then
 28 begin
 29 // LogString := 'ShowPrpFeatures';
 30 sql.Add(', prp_Id');
 31 sql.add(', PRP_P_ACCESS_GATES');
 32 sql.add(', PRP_P_COVERED_PARKING');
 33 sql.add(', PRP_P_EXCERSIZE_FACILITY');
 34 sql.add(', PRP_P_HIGH_RISE');
 35 sql.add(', PRP_P_LAUNDRY_ROOM');
 36 sql.add(', PRP_P_PLAYGROUND');
 37 sql.add(', PRP_P_POOL');
 38 sql.add(', PRP_PL_BUS_LINE');
 39 sql.add(', PRP_U_CABLE');
 40 sql.add(', PRP_U_CORPORATE_HOUSING');
 41 sql.add(', PRP_U_FIREPLACE');
 42 sql.add(', PRP_U_FURNISHED');
 43 sql.add(', PRP_U_INTERNAL_ALARMS');
 44 sql.add(', PRP_U_MICROWAVE');
 45 sql.add(', PRP_U_PATIO');
 46 sql.add(', PRP_U_PETS');
 47 sql.add(', PRP_U_SHORT_TERM_LEASE');
 48 sql.add(', PRP_U_TOWN_HOMES');
 49 sql.add(', PRP_U_UTILITIES_PAID');
 50 sql.add(', PRP_U_WD_CONNECTIONS');
 51 sql.add(', PRP_U_WD_IN_UNIT');
 52 end;
 53 //features end here
 54 sql.Add('FROM prp, mc');
 55 sql.Add('WHERE (prp_mcids = mc_id)');
 56 sql.Add('AND (prp_Id > 0)');
 57 //start OR clause for property type
 58 sql.Add(')');
 59 //end OR clause for property type
 60 if (WebDemoApp.Literal['ziApt_Pmt'] <> '') then
 61 begin
 62 //LogString := LogString + ', Pmt=' + WebDemoApp.Literal['ziApt_Pmt']);
 63 sql.Add('AND (prp_MoPriceLR IS NOT Null) AND 
                 (prp_MoPriceLR <= ' + WebDemoApp.Literal['ziApt_Pmt'] + ')' );
 64 sql.Add('AND (prp_MoPriceHR IS NOT Null) AND 
                 (prp_MoPriceHR >= ' + WebDemoApp.Literal['ziApt_Pmt'] + ')' );
 65 end;
 66 if (WebDemoApp.Literal['ziApt_Loc'] <> '') then
 67 begin
 68 sql.Add('AND (prp_MapLocId IS NOT Null) AND (prp_MapLocId >= 0) AND 
                 (prp_MapLocId in(' + WebDemoApp.Literal['ziApt_Loc'] + '))' );
 69 logMapId := WebDemoApp.Literal['ziApt_Loc'];
 70 end;
 71 if (WebDemoApp.Literal['ziApt_KeyMapLoc'] <> '') then
 72 begin
 73 sql.Add('AND (prp_KeyMap IS NOT Null) AND 
                 (prp_KeyMap in(' + WebDemoApp.Literal['ziApt_KeyMapLoc'] + '))' );
 74 end;
 75 if (WebDemoApp.Literal['ziApt_ZipCode'] <> '') then
 76 begin
 77 sql.Add('AND (prp_PCODE IS NOT Null) AND 
                 (prp_PCODE in(' + WebDemoApp.Literal['ziApt_ZipCode'] + '))' );
 78 end;
 79 if (WebDemoApp.Literal['ziApt_Bed'] <> '') then
 80 begin
 81 sql.Add('AND (prp_RmLR IS NOT Null) AND 
                 (prp_RmLR <= ' + WebDemoApp.Literal['ziApt_Bed'] + ')' );
 82 sql.Add('AND (prp_RmHR IS NOT Null) AND 
                 (prp_RmHR >= ' + WebDemoApp.Literal['ziApt_Bed'] + ')' );
 83 end;
 84 if (WebDemoApp.Literal['ziApt_Bath'] <> '') then
 85 begin
 86 sql.Add('AND (prp_BathLR IS NOT Null) AND 
                 (prp_BathLR <= ' + WebDemoApp.Literal['ziApt_Bath'] + ')' );
 87 sql.Add('AND (prp_BathHR IS NOT Null) AND 
                 (prp_BathHR >= ' + WebDemoApp.Literal['ziApt_Bath'] + ')' );
 88 end;
 89 if (WebDemoApp.Literal['ziApt_Name'] <> '') then
 90 sql.Add('AND (prp_Name LIKE ''%'+ WebDemoApp.Literal['ziApt_Name'] + '%'')');
 91 if (WebDemoApp.Literal['ziApt_Id'] <> '') then
 92 begin
 93 sql.Add('AND (prp_Id IS NOT Null) AND 
        (prp_Id >= 0) AND (prp_Id in(' + WebDemoApp.Literal['ziApt_Id'] + '))' );
 94 end;
 95 if WebDemoApp.checked['ziApt_BrochureOnly']=true then
 96 sql.Add('AND 
         (prp_Status >= ' + mem_options.lines.values['Prp_Brochure_Show'] + ')');
 97 //ORDER BY CLAUSE
 98 sql.Add('Order By Prp_Status Desc');
 99 if comparetext(WebDemoApp.Literal['ziApt_SortBy'],'RentPriceHL')=0 then
100 sql.Add(',  prp_MoPriceHR Desc')
101 else if comparetext(WebDemoApp.Literal['ziApt_SortBy'],'RentPriceLH')=0 then
102 sql.Add(',  prp_MoPriceHR Asc')
103 else if comparetext(WebDemoApp.Literal['ziApt_SortBy'],'aptname')=0 then
104 sql.Add(',  prp_Name Asc')
105 else if comparetext(WebDemoApp.Literal['ziApt_SortBy'],'aptId')=0 then
106 sql.Add(',  prp_Id Asc')
107 else if comparetext(WebDemoApp.Literal['ziApt_SortBy'],'cityqmap')=0 then
108 sql.Add(',  prp_MapLocId Asc')
109 else if comparetext(WebDemoApp.Literal['ziApt_SortBy'],'KeyMap')=0 then
110 sql.Add(',  prp_KeyMap Asc')
111 else
112 sql.Add(',  prp_Name Asc');
113 mem_sql.lines := sql;
114 mem_sql.lines.add('');
115 mem_sql.lines.add(' ----- End of SQL Statement -----');
116 mem_sql.lines.add('');
117 mem_sql.lines.add(WebDemoApp.Literal['test']);
118 mem_sql.lines.add(WebDemoApp.Literal['ziApt_Pmt']);
119 mem_sql.lines.add(WebDemoApp.Literal['ziApt_Bed']);
120 mem_sql.lines.add(WebDemoApp.Literal['ziApt_Bath']);
121 mem_sql.lines.add(WebDemoApp.Literal['ziApt_Name']);
122 mem_sql.lines.add(' ----- End of Literal Values -----');
123 end;
124 with qry_insert do
125 begin
126 if active then
127 active:=false;
128 sql.clear;
129 sql.add('insert into log(log_system,log_type,log_strval) 
                   values("htcityq","cityq.txhou.aptsrch"," ' + logMapId + '")');
130 execsql;
131 end;
132 end;