--ABS-158969
create or replace procedure remove_webusersearchsettings is
begin
for x in (select ws.webusersearchsettings_id 
            from webusersearchsettings ws 
           where ws.property = 'fromDate' 
             and ws.page in ('absgroup.webportal.model.billing.ShowPaymentsForm',
                             'absgroup.webportal.model.billing.ShowInvoicesForm',
                             'absgroup.webportal.model.billing.StatementsForm',
                             'absgroup.webportal.model.billing.ShowEUInvoicesForm')) loop
  begin
      delete from webusersearchsettings w where w.webusersearchsettings_id = x.webusersearchsettings_id;
    exception
      when others then
      begin
        rollback;
        abslogwrite.abslog_write(5, 'Delete record from webusersearchsettings', null, 3, 'For web user search setting ' || x.webusersearchsettings_id || ' ' || sqlerrm, 1);
      end;          
   end;
   commit;
 end loop;
        
for y in (select ws.webusersearchsettings_id 
            from webusersearchsettings ws 
           where ws.property ='searchModelsearchDate'
             and ws.page in ('absgroup.webportal.model.delivery.ConsignmentNotesForm',
                            'absgroup.webportal.model.delivery.DeliveryNotesForm',
                            'absgroup.webportal.model.garment.GarmentForm',
                            'absgroup.webportal.model.garment.GarmentOrderApprovalForm',
                            'absgroup.webportal.model.garment.GarmentOrderForm',
                            'absgroup.webportal.model.garment.SearchWearerForm',
                            'absgroup.webportal.model.pwbresidential.ClientGarmentsForm',
                            'absgroup.webportal.model.pwbresidential.ClientsForm')) loop
  begin
      delete from webusersearchsettings w where w.webusersearchsettings_id = y.webusersearchsettings_id;
    exception
      when others then
      begin
        rollback;
        abslogwrite.abslog_write(5, 'Delete record from webusersearchsettings', null, 3, 'For webusersearchsetting ' || y.webusersearchsettings_id || ' ' || sqlerrm, 1);
      end;    
  end;
  commit;  
end loop;


for z in (select ws.webusersearchsettings_id 
            from webusersearchsettings ws 
           where ws.property ='searchModelsearchFilterDate'
             and ws.page in ('absgroup.webportal.model.delivery.ConsignmentNotesForm',
                            'absgroup.webportal.model.delivery.DeliveryNotesForm',
                            'absgroup.webportal.model.garment.GarmentForm',
                            'absgroup.webportal.model.garment.GarmentOrderApprovalForm',
                            'absgroup.webportal.model.garment.GarmentOrderForm',
                            'absgroup.webportal.model.garment.SearchWearerForm',
                            'absgroup.webportal.model.pwbresidential.ClientGarmentsForm',
                            'absgroup.webportal.model.pwbresidential.ClientsForm')) loop
  begin
      delete from webusersearchsettings w where w.webusersearchsettings_id = z.webusersearchsettings_id;
   exception
      when others then
      begin
        rollback;
        abslogwrite.abslog_write(5, 'Delete record from webusersearchsettings', null, 3, 'For web user search setting ' || z.webusersearchsettings_id || ' ' || sqlerrm, 1);
      end;      
  end;
  commit;
end loop;        
        
        
for xx in (select ws.webusersearchsettings_id 
            from webusersearchsettings ws 
           where ws.property ='defaultStartDate'
             and ws.page = 'absgroup.webportal.model.garment.RptWearerPricesForm') loop
  begin
     delete from webusersearchsettings w where w.webusersearchsettings_id = xx.webusersearchsettings_id;
exception
      when others then
      begin
        rollback;
        abslogwrite.abslog_write(5, 'Delete record from webusersearchsettings', null, 3, 'For webusersearchsetting ' || xx.webusersearchsettings_id || ' ' || sqlerrm, 1);
      end;    
  end;
  commit;
end loop;             
end remove_webusersearchsettings;
/
execute remove_webusersearchsettings; 
drop procedure remove_webusersearchsettings;
