1 5 package com.dotmarketing.portlets.event_registrations.action; 6 7 import java.util.ArrayList ; 8 import java.util.Date ; 9 import java.util.HashMap ; 10 import java.util.Hashtable ; 11 import java.util.Iterator ; 12 import java.util.List ; 13 14 import javax.portlet.ActionRequest; 15 import javax.portlet.ActionResponse; 16 import javax.portlet.PortletConfig; 17 import javax.portlet.PortletRequest; 18 import javax.portlet.PortletResponse; 19 import javax.portlet.RenderRequest; 20 import javax.portlet.RenderResponse; 21 import javax.portlet.WindowState; 22 import javax.servlet.ServletOutputStream ; 23 import javax.servlet.http.HttpServletResponse ; 24 import javax.servlet.http.HttpSession ; 25 26 import org.apache.commons.beanutils.BeanUtils; 27 import org.apache.struts.action.ActionForm; 28 import org.apache.struts.action.ActionForward; 29 import org.apache.struts.action.ActionMapping; 30 31 import com.dotmarketing.beans.UserProxy; 32 import com.dotmarketing.cms.factories.PublicUserFactory; 33 import com.dotmarketing.db.DbConnectionFactory; 34 import com.dotmarketing.db.DotHibernate; 35 import com.dotmarketing.factories.InodeFactory; 36 import com.dotmarketing.factories.UserProxyFactory; 37 import com.dotmarketing.util.Config; 38 import com.dotmarketing.util.UtilMethods; 39 import com.dotmarketing.util.WebKeys; 40 import com.liferay.portal.ejb.UserLocalManagerUtil; 41 import com.liferay.portal.model.User; 42 import com.liferay.portal.struts.PortletAction; 43 import com.liferay.portal.util.Constants; 44 import com.liferay.portlet.ActionRequestImpl; 45 import com.liferay.portlet.ActionResponseImpl; 46 import com.liferay.portlet.RenderRequestImpl; 47 import com.liferay.util.servlet.SessionMessages; 48 import com.dotmarketing.portlets.event_registrations.factories.WebEventAttendeeFactory; 49 import com.dotmarketing.portlets.event_registrations.factories.WebEventRegistrationFactory; 50 import com.dotmarketing.portlets.event_registrations.model.WebEventAttendee; 51 import com.dotmarketing.portlets.event_registrations.model.WebEventRegistration; 52 import com.dotmarketing.portlets.event_registrations.struts.ViewRegistrationsForm; 53 import com.dotmarketing.portlets.event_registrations.struts.WebEventAttendeeForm; 54 import com.dotmarketing.portlets.event_registrations.struts.WebEventRegistrationForm; 55 import com.dotmarketing.portlets.webevents.factories.WebEventFactory; 56 import com.dotmarketing.portlets.webevents.factories.WebEventLocationFactory; 57 import com.dotmarketing.portlets.webevents.model.WebEvent; 58 import com.dotmarketing.portlets.webevents.model.WebEventLocation; 59 import com.dotmarketing.portlets.organization.factories.OrganizationFactory; 60 import com.dotmarketing.portlets.organization.model.Organization; 61 62 63 64 68 public class ViewRegistrationsAction extends PortletAction { 69 public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig config, RenderRequest req, 70 RenderResponse res) throws Exception { 71 72 String cmd = req.getParameter(Constants.CMD); 73 74 if (com.liferay.portal.util.Constants.DELETE.equals(cmd)) { 75 _deleteEventRegistration(form, req, res); 76 cmd = com.liferay.portal.util.Constants.SEARCH; 77 } 78 if(cmd != null && cmd.equals("viewLocations")){ 79 _viewLocations(mapping, form, config, req, res); 80 return mapping.findForward("portlet.ext.webevents_registration.view_registrations"); 81 } 82 if (req.getWindowState().equals(WindowState.NORMAL)) { 83 _viewTodaysRegistrations(mapping, form, config, req, res); 84 _getRegistrationStatus(req); 85 86 return mapping.findForward("portlet.ext.webevents_registration.view"); 87 } else { 88 _viewRegistrations(mapping, form, config, req, res); 89 _getRegistrationStatus(req); 90 91 ((ViewRegistrationsForm) form).setInstitute(0); 92 93 return mapping.findForward("portlet.ext.webevents_registration.view_registrations"); 94 } 95 } 96 97 public void processAction( 98 ActionMapping mapping, ActionForm form, PortletConfig config, 99 ActionRequest req, ActionResponse res) 100 throws Exception { 101 102 String cmd = req.getParameter(Constants.CMD); 103 104 if(cmd != null && cmd.equals("exportRegistration")){ 105 _exportRegistration(req, res,config,form); 106 setForward(req,"portlet.ext.webevents_registration.view_registrations"); 107 } 108 if(cmd != null && cmd.equals("exportGenesys")){ 109 _exportGenesys(req, res,config,form); 110 setForward(req,"portlet.ext.webevents_registration.view_registrations"); 111 } 112 if(cmd != null && cmd.equals("exportRegistrationToQB")){ 113 _exportRegistrationToQB(req, res,config,form); 114 setForward(req,"portlet.ext.webevents_registration.view_registrations"); 115 } 116 if(cmd != null && cmd.equals("exportRegistrationsFinance")){ 117 _exportRegistrationsFinance(req, res,config,form); 118 setForward(req,"portlet.ext.webevents_registration.view_registrations"); 119 } 120 121 if(cmd != null && cmd.equals("exportCEOLetters")){ 122 _exportCEOLetters(req, res,config,form); 123 setForward(req,"portlet.ext.webevents_registration.view_registrations"); 124 } 125 if(cmd != null && cmd.equals("exportAttendees")){ 126 _exportAttendees(req, res,config,form); 127 setForward(req,"portlet.ext.webevents_registration.view_registrations"); 128 } 129 130 if(cmd != null && cmd.equals("printBadges")){ 131 _printBadges(req, res,config,form); 132 setForward(req,"portlet.ext.webevents_registration.view_registrations"); 133 } 134 if(cmd != null && cmd.equals("exportCertificates")){ 135 _exportCertificates(req, res,config,form); 136 setForward(req,"portlet.ext.webevents_registration.view_registrations"); 137 } 138 } 139 140 141 private void _viewTodaysRegistrations(ActionMapping mapping, ActionForm form, PortletConfig config, PortletRequest req, 142 PortletResponse res) throws Exception { 143 144 List registrations = WebEventRegistrationFactory.getTodayWebEventRegistrations(); 145 req.setAttribute(WebKeys.WEBEVENTS_REG_VIEW, registrations); 146 147 } 148 149 private void _getRegistrationStatus(PortletRequest req) { 150 151 String [] statusesArray = com.dotmarketing.util.Config.getStringArrayProperty("EREG_STATUSES"); 153 java.util.HashMap <String , String > statuses = new java.util.HashMap <String , String >(); 154 for (int i=0;i<statusesArray.length;i++) { 155 String status = statusesArray[i]; 156 statuses.put(com.dotmarketing.util.Config.getStringProperty(status),com.dotmarketing.util.Config.getStringProperty(status + "_FN")); 157 } 158 req.setAttribute(WebKeys.WEBEVENTS_REG_STATUSES, statuses); 159 160 } 161 162 private void _viewLocations(ActionMapping mapping, ActionForm form, PortletConfig config, PortletRequest req, 163 PortletResponse res) throws Exception { 164 String isAttendeesLinkVisible = "0"; 165 String isWebinar = "false"; 166 167 HttpSession session = ((RenderRequestImpl)req).getHttpServletRequest().getSession(); 168 ViewRegistrationsForm vForm = (ViewRegistrationsForm) form; 169 String eventInode = vForm.getEventInode(); 170 WebEvent event = WebEventFactory.getWebEvent(eventInode); 171 172 req.setAttribute("isAttendeesLinkVisible", isAttendeesLinkVisible); 173 req.setAttribute("isWebinar", isWebinar); 174 175 List events = WebEventFactory.getAllWebEvents(); 177 Iterator eventsIter = events.iterator(); 178 req.setAttribute("events", eventsIter); 179 180 181 List locations = new ArrayList (); 183 if (UtilMethods.isSet(eventInode)) { 184 long eventInodeLong = Long.parseLong(eventInode); 185 locations = WebEventLocationFactory.getWebEventLocationsPerEvent(eventInodeLong,"start_date desc"); 186 } 187 Iterator locationsIter = locations.iterator(); 188 List <HashMap > finalLocations = new ArrayList <HashMap >(); 189 while (locationsIter.hasNext()) { 190 WebEventLocation location = (WebEventLocation) locationsIter.next(); 191 String locationStr = location.toString(); 192 HashMap <String ,String > hs = new HashMap <String ,String >(); 193 hs.put("optionName", locationStr); 194 hs.put("optionValue", String.valueOf(location.getInode())); 195 finalLocations.add(hs); 196 } 197 req.setAttribute("locations", finalLocations.iterator()); 198 199 200 List systems = OrganizationFactory.getAllSystems(); 202 Iterator systemsIter = systems.iterator(); 203 req.setAttribute("systems", systemsIter); 204 205 List facilities = new ArrayList (); 207 Iterator facilitiesIter = facilities.iterator(); 208 req.setAttribute("facilities", facilitiesIter); 209 210 List <WebEventRegistration> resultsRegistrations = new ArrayList <WebEventRegistration>(); 212 req.setAttribute(WebKeys.WEBEVENTS_REG_VIEW, resultsRegistrations); 213 session.setAttribute(WebKeys.WEBEVENTS_REG_VIEW, resultsRegistrations); 214 } 215 216 private void _viewRegistrations(ActionMapping mapping, ActionForm form, PortletConfig config, PortletRequest req, 217 PortletResponse res) throws Exception { 218 219 String isAttendeesLinkVisible; 220 String isWebinar = "false"; 221 String orderBy = (req.getParameter("orderBy")!=null ? req.getParameter("orderBy") : ""); 222 String orderDirection; 223 String previousColumn; 224 HttpSession session = ((RenderRequestImpl)req).getHttpServletRequest().getSession(); 225 226 ViewRegistrationsForm vForm = (ViewRegistrationsForm) form; 227 if (UtilMethods.isSet(orderBy)){ 228 vForm.setOrderBy(orderBy); 229 orderDirection = vForm.getSelectedDirection(); 230 previousColumn = vForm.getSelectedColumn(); 231 if (UtilMethods.isSet(previousColumn)){ 232 if (previousColumn.equals(orderBy)){ 233 if (UtilMethods.isSet(orderDirection)){ 234 if (orderDirection.equals("DESC")) 235 orderDirection = "ASC"; 236 else 237 orderDirection = "DESC"; 238 } 239 else 240 orderDirection = "DESC"; 241 } 242 else{ 243 previousColumn = orderBy; 244 orderDirection = "DESC"; 245 } 246 } 247 else{ 248 previousColumn = orderBy; 249 orderDirection = "DESC"; 250 } 251 } 252 else{ 253 previousColumn = ""; 254 orderDirection = ""; 255 } 256 vForm.setSelectedColumn(previousColumn); 257 vForm.setSelectedDirection(orderDirection); 258 vForm.setOrderBy(orderBy); 259 String eventInode = vForm.getEventInode(); 260 String locationInode = vForm.getLocationInode(); 261 262 WebEvent event = WebEventFactory.getWebEvent(eventInode); 263 264 if ((eventInode != null) && (locationInode != null)) 266 if (eventInode.equals("0") || (locationInode.equals("0"))) 267 isAttendeesLinkVisible = "0"; 268 else { 269 if (event.isInstitute()) { 270 isAttendeesLinkVisible = "1"; 271 isWebinar = "false"; 272 } 273 else { 274 isAttendeesLinkVisible = "0"; 275 isWebinar = "true"; 276 } 277 } 278 else 279 isAttendeesLinkVisible = "0"; 280 281 282 req.setAttribute("isAttendeesLinkVisible", isAttendeesLinkVisible); 283 req.setAttribute("isWebinar", isWebinar); 284 String systemInode = vForm.getSystem(); 285 String firstName = vForm.getFirstName(); 286 String lastName = vForm.getLastName(); 287 String facilityInode = vForm.getFacility(); 288 String facilityTitle = vForm.getFacilityTitle(); 289 String registrationNumber = vForm.getRegistrationNumber(); 290 String invoiceNumber = vForm.getInvoiceNumber(); 291 int paymentStatus = vForm.getPaymentStatus(); 292 List events = WebEventFactory.getAllWebEvents(); 294 Iterator eventsIter = events.iterator(); 295 req.setAttribute("events", eventsIter); 296 297 298 List locations = new ArrayList (); 300 if (UtilMethods.isSet(eventInode)) { 301 long eventInodeLong = Long.parseLong(eventInode); 302 locations = WebEventLocationFactory.getWebEventLocationsPerEvent(eventInodeLong,"start_date desc"); 303 } 304 Iterator locationsIter = locations.iterator(); 305 List <HashMap > finalLocations = new ArrayList <HashMap >(); 306 while (locationsIter.hasNext()) { 307 WebEventLocation location = (WebEventLocation) locationsIter.next(); 308 String locationStr = location.toString(); 309 HashMap <String ,String > hs = new HashMap <String ,String >(); 310 hs.put("optionName", locationStr); 311 hs.put("optionValue", String.valueOf(location.getInode())); 312 finalLocations.add(hs); 313 } 314 req.setAttribute("locations", finalLocations.iterator()); 315 316 317 List systems = OrganizationFactory.getAllSystems(); 319 Iterator systemsIter = systems.iterator(); 320 req.setAttribute("systems", systemsIter); 321 322 List facilities = new ArrayList (); 324 if (UtilMethods.isSet(systemInode)) { 325 Organization parentSystem = OrganizationFactory.getOrganization(systemInode); 326 facilities = OrganizationFactory.getChildrenOrganizations(parentSystem,"title"); 327 } 328 Iterator facilitiesIter = facilities.iterator(); 329 req.setAttribute("facilities", facilitiesIter); 330 331 long facilityInodeLong = (UtilMethods.isSet(facilityInode)) ? Long.parseLong(facilityInode) : 0; 332 long systemInodeLong = (UtilMethods.isSet(systemInode)) ? Long.parseLong(systemInode) : 0; 333 334 if (UtilMethods.isSet(invoiceNumber) || UtilMethods.isSet(firstName) || UtilMethods.isSet(lastName) 336 || facilityInodeLong > 0 || systemInodeLong > 0 337 || UtilMethods.isSet(eventInode) || UtilMethods.isSet(locationInode) 338 || UtilMethods.isSet(facilityTitle) || UtilMethods.isSet(registrationNumber)|| paymentStatus > 0) { 339 340 List registrations = WebEventRegistrationFactory.getFilteredRegistrations(vForm); 342 343 if (UtilMethods.isSet(firstName) || UtilMethods.isSet(lastName) || facilityInodeLong > 0 || systemInodeLong > 0 || UtilMethods.isSet(facilityTitle)) { 345 346 List <WebEventRegistration> resultsRegistrations = new ArrayList <WebEventRegistration>(); 347 List <WebEventRegistrationForm> resultsRegistrationsForm = new ArrayList <WebEventRegistrationForm>(); 348 Iterator registrationsIter = registrations.iterator(); 349 350 while (registrationsIter.hasNext()) { 351 WebEventRegistration registration = (WebEventRegistration) registrationsIter.next(); 352 UserProxy userProxy = UserProxyFactory.getUserProxy(registration.getUserInode()); 355 String userId = userProxy.getUserId(); 356 String companyId = com.dotmarketing.cms.factories.PublicCompanyFactory.getDefaultCompany().getCompanyId(); 357 try { 358 359 User user = UserLocalManagerUtil.getUserById(companyId, userId); 360 361 if ((user.getFirstName().toLowerCase().startsWith(firstName.toLowerCase()) || !UtilMethods.isSet(firstName)) 362 && (user.getLastName().toLowerCase().startsWith(lastName.toLowerCase()) || !UtilMethods.isSet(lastName))) { 363 364 if (facilityInodeLong > 0) { 365 Organization organization = (Organization) InodeFactory.getParentOfClass(userProxy, Organization.class); 367 if (organization.getInode() == facilityInodeLong) { 368 resultsRegistrations.add(registration); 370 } 371 } 372 else { 373 if (systemInodeLong > 0) { 375 Organization organization = (Organization) InodeFactory.getParentOfClass(userProxy, Organization.class); 376 Organization parentSystem = OrganizationFactory.getParentOrganization(organization); 377 if (parentSystem.getInode() == systemInodeLong) { 378 resultsRegistrations.add(registration); 380 } 381 } 382 else { 383 if (UtilMethods.isSet(facilityTitle)) { 386 Organization organization = (Organization) InodeFactory.getParentOfClass(userProxy, Organization.class); 387 if (organization.getTitle().toLowerCase().contains(facilityTitle.toLowerCase())) { 388 resultsRegistrations.add(registration); 390 } 391 } 392 else { 393 resultsRegistrations.add(registration); 396 } 397 } 398 } 399 } 400 } catch (Exception e) { 401 } 403 } 404 req.setAttribute(WebKeys.WEBEVENTS_REG_VIEW, resultsRegistrations); 406 session.setAttribute(WebKeys.WEBEVENTS_REG_VIEW, resultsRegistrations); 407 } else { 408 req.setAttribute(WebKeys.WEBEVENTS_REG_VIEW, registrations); 410 session.setAttribute(WebKeys.WEBEVENTS_REG_VIEW, registrations); 411 } 412 } else { 413 List registrations = WebEventRegistrationFactory.getTodayWebEventRegistrations(); 415 req.setAttribute(WebKeys.WEBEVENTS_REG_VIEW, registrations); 416 session.setAttribute(WebKeys.WEBEVENTS_REG_VIEW, registrations); 417 418 } 419 } 420 421 private List <WebEventAttendeeForm> getAttendeesByEventRegistration(WebEventRegistrationForm registrationForm){ 422 List <WebEventAttendeeForm> attendeesResult = new ArrayList <WebEventAttendeeForm>(); 423 List <WebEventAttendee> attendees = WebEventRegistrationFactory.getEventAttendees(registrationForm); 424 Iterator attendeesIter = attendees.iterator(); 425 try{ 426 while (attendeesIter.hasNext()) { 427 WebEventAttendee attendee = (WebEventAttendee) attendeesIter.next(); 428 WebEventAttendeeForm attendeeForm = new WebEventAttendeeForm(); 429 BeanUtils.copyProperties(attendeeForm,attendee); 430 attendeesResult.add(attendeeForm); 431 } 432 } 433 catch(Exception e){ 434 attendeesResult = new ArrayList <WebEventAttendeeForm>(); 435 } 436 return attendeesResult; 437 } 438 439 @SuppressWarnings ("unchecked") 440 private void _exportRegistration(ActionRequest req, ActionResponse res, PortletConfig config, ActionForm form) throws Exception { 441 442 HttpSession session = ((ActionRequestImpl)req).getHttpServletRequest().getSession(); 443 444 ActionResponseImpl resImpl = (ActionResponseImpl)res; 445 HttpServletResponse httpRes = resImpl.getHttpServletResponse(); 446 447 List <HashMap > paymentTypes = getpaymentTypes(); 448 449 List <WebEventRegistration> registrations = (List <WebEventRegistration>) session.getAttribute(WebKeys.WEBEVENTS_REG_VIEW); 450 451 httpRes.setContentType("application/octet-stream"); 452 httpRes.setHeader("Content-Disposition", "attachment; filename=\"registrations_" + UtilMethods.dateToHTMLDate(new Date (),"M_d_yyyy") +".csv\""); 453 454 ServletOutputStream out = httpRes.getOutputStream(); 455 try { 456 457 if(registrations != null && registrations.size() > 0) { 458 459 out.print("WebOrderID,Contact FirstName,Contact LastName,Company,Contact Email,Contact Phone,Payment Type,"); 460 out.print("Card Type,Card Number,Card ExpMonth,Card ExpYear,Card Name,Check number,Bank name (check),PO Number,Billing Name,"); 461 out.println("Bill Address1,Bill Address2,Bill City,Bill State,Bill Zip,Bill Country,Institute/Webinar name,Location and Date,Institute/Webinar,Total,Number of attendees"); 462 out.print("\r\n"); 463 464 Iterator registrationsIter = registrations.iterator(); 465 466 while (registrationsIter.hasNext()) { 467 WebEventRegistration registration = (WebEventRegistration) registrationsIter.next(); 468 if (registration.getRegistrationStatus() == 6) 469 continue; 470 try { 471 472 WebEvent event = WebEventFactory.getWebEvent(registration.getEventInode()); 473 WebEventLocation eventLocation = WebEventLocationFactory.getWebEventLocation(registration.getEventLocationInode()); 474 475 if(event.getInode() != 0 && eventLocation.getInode() !=0){ 476 477 478 UserProxy registrantUser = UserProxyFactory.getUserProxy(registration.getUserInode()); 479 User user = PublicUserFactory.getUserByUserId(registrantUser.getUserId()); 480 481 String orgName = ""; 482 if (registrantUser.getInode()>0) { 483 Organization organization = (Organization) InodeFactory.getParentOfClass(registrantUser,Organization.class); 484 if (organization.getTitle()!=null) { 485 orgName = organization.getTitle().trim(); 486 }else{ 487 orgName = "No Facility"; 488 } 489 } 490 491 String paymentType = ""; 492 for(HashMap paymentMethod : paymentTypes) { 493 if(paymentMethod.get("paymentTypeValue").equals(String.valueOf(registration.getPaymentType()))){ 494 paymentType = ((String ) paymentMethod.get("paymentTypeName")); 495 } 496 } 497 498 499 out.print("\"" +registration.getInode() +"\","); 500 out.print((user.getFirstName() == null ? "," : "\"" + user.getFirstName() + "\",")); 501 out.print((user.getLastName() == null ? "," : "\"" + user.getLastName() + "\",")); 502 out.print("\"" +orgName + "\","); 503 out.print((user.getEmailAddress() == null ? "," : "\"" + user.getEmailAddress() + "\",")); 504 out.print((registration.getBillingContactPhone() == null ? "," : "\"" + registration.getBillingContactPhone() + "\",")); 505 506 507 out.print((registration.getPaymentType() == 0 ? "," : "\"" + paymentType + "\",")); 508 out.print((registration.getCardType() == null ? "," : "\"" + registration.getCardType() + "\",")); 509 out.print((registration.getCardNumber() == null ? "," : "\"" + registration.getCardNumber() + "\",")); 510 out.print((registration.getCardExpMonth() == null ? "," : "\"" + UtilMethods.getMonthName(Integer.parseInt(registration.getCardExpMonth())) + "\",")); 511 out.print((registration.getCardExpYear() == null ? "," : "\"" + registration.getCardExpYear() + "\",")); 512 out.print((registration.getCardName() == null ? "," : "\"" + registration.getCardName() + "\",")); 513 out.print((registration.getCheckNumber() == null ? "," : "\"" + registration.getCheckNumber() + "\",")); 514 out.print((registration.getCheckBankName() == null ? "," : "\"" + registration.getCheckBankName() + "\",")); 515 out.print((registration.getPoNumber() == null ? "," : "\"" + registration.getPoNumber() + "\",")); 516 517 518 out.print((registration.getBillingContactName() == null ? "," : "\"" + registration.getBillingContactName() + "\",")); 519 out.print((registration.getBillingAddress1() == null ? "," : "\"" + registration.getBillingAddress1() + "\",")); 520 out.print((registration.getBillingAddress2() == null ? "," : "\"" + registration.getBillingAddress2() + "\",")); 521 out.print((registration.getBillingCity() == null ? "," : "\"" + registration.getBillingCity() + "\",")); 522 out.print((registration.getBillingState() == null ? "," : "\"" + registration.getBillingState() + "\",")); 523 out.print((registration.getBillingZip() == null ? "," : "\"" + registration.getBillingZip() + "\",")); 524 out.print(","); 525 526 527 528 out.print((event.getTitle() == null ? "," : "\"" + event.getTitle() + "\",")); 529 String location = ""; 530 if (event.isInstitute()) { 531 location = (eventLocation == null ? ",":"\"" +eventLocation.getHotelName().trim()+" "+ UtilMethods.dateToHTMLDate(eventLocation.getStartDate())+". "+eventLocation.getCity().trim() +"-"+ eventLocation.getShortDescription().trim()+"\","); 532 } 533 else { 534 location = "\"" + eventLocation.toString() + "\","; 535 } 536 location.replaceAll("\n",""); 537 out.print(location); 538 out.print((event.isInstitute() ? "\"Institute\"," : "\"Webinar\",")); 539 540 541 out.print(("\"$ "+registration.getTotalRegistration() + "\",")); 542 543 544 545 List <WebEventAttendee> attendees = WebEventRegistrationFactory.getEventAttendees(registration); 546 out.print(("\""+attendees.size() + "\"")); 547 out.print("\r\n"); 548 549 } 550 551 }catch(Exception p){ 552 553 } 554 555 556 } 557 }else { 558 out.print("There are no Registrations to show"); 559 out.print("\r\n"); 560 } 561 out.flush(); 562 out.close(); 563 DotHibernate.closeSession(); 564 }catch(Exception p){ 565 566 out.print("There are no Registrations to show"); 569 out.print("\r\n"); 570 out.flush(); 571 out.close(); 572 DotHibernate.closeSession(); 573 } 574 } 575 576 @SuppressWarnings ("unchecked") 577 private void _exportGenesys(ActionRequest req, ActionResponse res, PortletConfig config, ActionForm form) throws Exception { 578 579 HttpSession session = ((ActionRequestImpl)req).getHttpServletRequest().getSession(); 580 581 ActionResponseImpl resImpl = (ActionResponseImpl)res; 582 HttpServletResponse httpRes = resImpl.getHttpServletResponse(); 583 584 List <WebEventRegistration> registrations = (List <WebEventRegistration>) session.getAttribute(WebKeys.WEBEVENTS_REG_VIEW); 585 586 httpRes.setContentType("application/octet-stream"); 587 httpRes.setHeader("Content-Disposition", "attachment; filename=\"registrations_" + UtilMethods.dateToHTMLDate(new Date (),"M_d_yyyy") +".csv\""); 588 589 ServletOutputStream out = httpRes.getOutputStream(); 590 try { 591 592 if(registrations != null && registrations.size() > 0) { 593 594 out.print("FirstName,LastName,Email,Webinar,Date and Time"); 595 out.print("\r\n"); 596 597 Iterator registrationsIter = registrations.iterator(); 598 599 while (registrationsIter.hasNext()) { 600 WebEventRegistration registration = (WebEventRegistration) registrationsIter.next(); 601 if (registration.getRegistrationStatus() == 6) 602 continue; 603 try { 604 605 WebEvent event = WebEventFactory.getWebEvent(registration.getEventInode()); 606 WebEventLocation eventLocation = WebEventLocationFactory.getWebEventLocation(registration.getEventLocationInode()); 607 608 if(event.getInode() != 0 && eventLocation.getInode() !=0){ 609 610 UserProxy registrantUser = UserProxyFactory.getUserProxy(registration.getUserInode()); 611 User user = PublicUserFactory.getUserByUserId(registrantUser.getUserId()); 612 613 614 out.print((user.getFirstName() == null ? "," : "\"" + user.getFirstName() + "\",")); 615 out.print((user.getLastName() == null ? "," : "\"" + user.getLastName() + "\",")); 616 out.print((user.getEmailAddress() == null ? "," : "\"" + user.getEmailAddress() + "\",")); 617 618 619 out.print((event.getTitle() == null ? "," : "\"" + event.getTitle() + "\",")); 620 621 String location = (eventLocation == null ? ",":"\"" +eventLocation.toString() +"\","); 622 location.replaceAll("\n",""); 623 out.print(location); 624 625 out.print("\r\n"); 626 627 } 628 629 }catch(Exception p){ 630 631 } 632 633 634 } 635 }else { 636 out.print("There are no Registrations to show"); 637 out.print("\r\n"); 638 } 639 out.flush(); 640 out.close(); 641 DotHibernate.closeSession(); 642 }catch(Exception p){ 643 644 out.print("There are no Registrations to show"); 647 out.print("\r\n"); 648 out.flush(); 649 out.close(); 650 DotHibernate.closeSession(); 651 } 652 } 653 654 @SuppressWarnings ("unchecked") 655 private void _exportRegistrationToQB(ActionRequest req, ActionResponse res, PortletConfig config, ActionForm form) throws Exception { 656 657 ActionResponseImpl resImpl = (ActionResponseImpl)res; 658 HttpServletResponse httpRes = resImpl.getHttpServletResponse(); 659 660 List <HashMap > paymentTypes = getpaymentTypes(); 661 662 String condition = " registration_status in ("+Config.getStringProperty("EREG_INVOICED")+","+Config.getStringProperty("EREG_PAID")+") and (invoice_number is NULL or invoice_number = '' or modified_QB = " + DbConnectionFactory.getDBTrue() + ")"; 664 List <WebEventRegistration> registrations = (List <WebEventRegistration>) WebEventRegistrationFactory.getWebEventRegistrationsByCondition(condition); 665 666 httpRes.setContentType("application/octet-stream"); 667 httpRes.setHeader("Content-Disposition", "attachment; filename=\"quickbooks_" + UtilMethods.dateToHTMLDate(new Date (),"M_d_yyyy") +".csv\""); 668 ServletOutputStream out = httpRes.getOutputStream(); 669 try { 670 671 if(registrations != null && registrations.size() > 0) { 672 673 out.print("WebOrderID,Contact FirstName,Contact LastName,Company,Contact Email,Contact Phone,Payment Type,"); 674 out.print("Card Type,Card Number,Card ExpMonth,Card ExpYear,Card Name,Check number,Bank name (check),PO Number,Billing Name,"); 675 out.println("Bill Address1,Bill Address2,Bill City,Bill State,Bill Zip,Bill Country,Event name,Location,Total,Number of attendees"); 676 out.print("\r\n"); 677 678 Iterator registrationsIter = registrations.iterator(); 679 680 while (registrationsIter.hasNext()) { 681 WebEventRegistration registration = (WebEventRegistration) registrationsIter.next(); 682 if (registration.getRegistrationStatus() == 6) 683 continue; 684 try { 685 686 WebEvent event = WebEventFactory.getWebEvent(registration.getEventInode()); 687 WebEventLocation eventLocation = WebEventLocationFactory.getWebEventLocation(registration.getEventLocationInode()); 688 689 if(event.getInode() != 0 && eventLocation.getInode() !=0){ 690 691 692 UserProxy registrantUser = UserProxyFactory.getUserProxy(registration.getUserInode()); 693 User user = PublicUserFactory.getUserByUserId(registrantUser.getUserId()); 694 695 String orgName = ""; 696 if (registrantUser.getInode()>0) { 697 Organization organization = (Organization) InodeFactory.getParentOfClass(registrantUser,Organization.class); 698 if ((organization != null) && (organization.getInode() > 0)){ 699 if (organization.getTitle()!=null) { 700 orgName = organization.getTitle().trim(); 701 }else{ 702 orgName = ""; 703 } 704 } 705 else 706 orgName = user.getFirstName() + " " + user.getLastName(); 707 } 708 709 String paymentType = ""; 710 for(HashMap paymentMethod : paymentTypes) { 711 if(paymentMethod.get("paymentTypeValue").equals(String.valueOf(registration.getPaymentType()))){ 712 paymentType = ((String ) paymentMethod.get("paymentTypeName")); 713 } 714 } 715 716 717 out.print("\"" +registration.getInode() +"\","); 718 out.print((user.getFirstName() == null ? "," : "\"" + user.getFirstName() + "\",")); 719 out.print((user.getLastName() == null ? "," : "\"" + user.getLastName() + "\",")); 720 out.print("\"" +orgName + "\","); 721 out.print((user.getEmailAddress() == null ? "," : "\"" + user.getEmailAddress() + "\",")); 722 out.print((registration.getBillingContactPhone() == null ? "," : "\"" + registration.getBillingContactPhone() + "\",")); 723 724 725 out.print((registration.getPaymentType() == 0 ? "," : "\"" + paymentType + "\",")); 726 out.print((registration.getCardType() == null ? "," : "\"" + registration.getCardType() + "\",")); 727 out.print((registration.getCardNumber() == null ? "," : "\"" + registration.getCardNumber() + "\",")); 728 out.print((registration.getCardExpMonth() == null ? "," : "\"" + UtilMethods.getMonthName(Integer.parseInt(registration.getCardExpMonth())) + "\",")); 729 out.print((registration.getCardExpYear() == null ? "," : "\"" + registration.getCardExpYear() + "\",")); 730 out.print((registration.getCardName() == null ? "," : "\"" + registration.getCardName() + "\",")); 731 out.print((registration.getCheckNumber() == null ? "," : "\"" + registration.getCheckNumber() + "\",")); 732 out.print((registration.getCheckBankName() == null ? "," : "\"" + registration.getCheckBankName() + "\",")); 733 out.print((registration.getPoNumber() == null ? "," : "\"" + registration.getPoNumber() + "\",")); 734 735 736 out.print((registration.getBillingContactName() == null ? "," : "\"" + registration.getBillingContactName() + "\",")); 737 out.print((registration.getBillingAddress1() == null ? "," : "\"" + registration.getBillingAddress1() + "\",")); 738 out.print((registration.getBillingAddress2() == null ? "," : "\"" + registration.getBillingAddress2() + "\",")); 739 out.print((registration.getBillingCity() == null ? "," : "\"" + registration.getBillingCity() + "\",")); 740 out.print((registration.getBillingState() == null ? "," : "\"" + registration.getBillingState() + "\",")); 741 out.print((registration.getBillingZip() == null ? "," : "\"" + registration.getBillingZip() + "\",")); 742 out.print((registration.getBillingCountry() == null ? "," : "\"" + registration.getBillingCountry() + "\",")); 743 744 745 746 out.print((event.getTitle() == null ? "," : "\"" + event.getTitle() + "\",")); 747 748 String location = (eventLocation == null ? ",":"\"" +eventLocation.getHotelName().trim()+" "+ UtilMethods.dateToHTMLDate(eventLocation.getStartDate())+". "+eventLocation.getCity().trim() +"-"+ eventLocation.getShortDescription().trim()+"\","); 749 location.replaceAll("\n",""); 750 out.print(location); 751 752 753 out.print(("\"$ "+registration.getTotalRegistration() + "\",")); 754 755 756 757 List <WebEventAttendee> attendees = WebEventRegistrationFactory.getEventAttendees(registration); 758 out.print(("\""+attendees.size() + "\"")); 759 out.print("\r\n"); 760 761 } 762 763 }catch(Exception p){ 764 765 } 766 } 767 }else { 768 out.print("There are no Registrations to show"); 769 out.print("\r\n"); 770 } 771 out.flush(); 772 out.close(); 773 DotHibernate.closeSession(); 774 }catch(Exception p){ 775 out.print("There are no Registrations to show"); 778 out.print("\r\n"); 779 out.flush(); 780 out.close(); 781 DotHibernate.closeSession(); 782 } 783 } 784 785 786 787 @SuppressWarnings ("unchecked") 788 private void _exportRegistrationsFinance(ActionRequest req, ActionResponse res, PortletConfig config, ActionForm form) throws Exception { 789 HttpSession session = ((ActionRequestImpl)req).getHttpServletRequest().getSession(); 790 ActionResponseImpl resImpl = (ActionResponseImpl)res; 791 HttpServletResponse httpRes = resImpl.getHttpServletResponse(); 792 List <HashMap > paymentTypes = getpaymentTypes(); 793 List <WebEventRegistration> registrations = (List <WebEventRegistration>) session.getAttribute(WebKeys.WEBEVENTS_REG_VIEW); 794 httpRes.setContentType("application/octet-stream"); 795 httpRes.setHeader("Content-Disposition", "attachment; filename=\"registrationsFinance_" + UtilMethods.dateToHTMLDate(new Date (),"M_d_yyyy") +".csv\""); 796 ServletOutputStream out = httpRes.getOutputStream(); 797 StringBuffer sb = new StringBuffer (); 798 float total = 0; 799 int numAttendees = 0; 800 float regTotal = 0; 801 try { 802 803 if(registrations != null && registrations.size() > 0) { 804 sb.append("WebOrderID,Company,Payment Type,Total,Number of attendees\n\n"); 806 Iterator registrationsIter = registrations.iterator(); 807 while (registrationsIter.hasNext()) { 808 WebEventRegistration registration = (WebEventRegistration) registrationsIter.next(); 809 if (registration.getRegistrationStatus() == 6) 810 continue; 811 WebEvent event = WebEventFactory.getWebEvent(registration.getEventInode()); 812 WebEventLocation eventLocation = WebEventLocationFactory.getWebEventLocation(registration.getEventLocationInode()); 813 814 if(event.getInode() != 0 && eventLocation.getInode() !=0){ 815 UserProxy registrantUser = UserProxyFactory.getUserProxy(registration.getUserInode()); 816 String orgName = ""; 818 if (registrantUser.getInode()>0) { 819 Organization organization = (Organization) InodeFactory.getParentOfClass(registrantUser,Organization.class); 820 if (organization.getTitle()!=null) { 821 orgName = organization.getTitle().trim(); 822 }else{ 823 orgName = "No Facility"; 824 } 825 } 826 String paymentType = ""; 828 for(HashMap paymentMethod : paymentTypes) { 829 if(paymentMethod.get("paymentTypeValue").equals(String.valueOf(registration.getPaymentType()))){ 830 paymentType = ((String ) paymentMethod.get("paymentTypeName")); 831 } 832 } 833 sb.append("\"" +registration.getInode() +"\","); 834 sb.append("\"" +orgName + "\","); 835 sb.append((registration.getPaymentType() == 0 ? "," : "\"" + paymentType + "\",")); 836 regTotal = registration.getTotalDue() + registration.getTotalPaid(); 838 total += regTotal; 839 sb.append(("\"$ "+ regTotal + "\",")); 841 List <WebEventAttendee> attendees = WebEventRegistrationFactory.getEventAttendees(registration); 842 numAttendees += attendees.size(); 843 sb.append(("\""+attendees.size() + "\"\r\n")); 844 } 845 } 846 sb.append(",,,\"" + total +" \","+ numAttendees); 847 }else { 848 sb.append("There are no Information to show"); 849 sb.append("\r\n"); 850 } 851 out.print(sb.toString()); 852 out.flush(); 853 out.close(); 854 DotHibernate.closeSession(); 855 }catch(Exception p){ 856 out.print("There are no Registrations to show"); 857 out.print("\r\n"); 858 out.flush(); 859 out.close(); 860 DotHibernate.closeSession(); 861 } 862 } 863 @SuppressWarnings ("unchecked") 864 public List <HashMap > getpaymentTypes () { 865 List <HashMap > paymentTypes = new ArrayList <HashMap >(); 866 String [] paymentTypesArray = Config.getStringArrayProperty("EREG_PAYMENT_TYPES"); 867 for (int i=0;i<paymentTypesArray.length;i++) { 868 String pType = paymentTypesArray[i]; 869 HashMap <String , String > hs = new HashMap <String , String >(); 870 hs.put("paymentTypeName",Config.getStringProperty(pType + "_FN")); 871 hs.put("paymentTypeValue",Config.getStringProperty(pType)); 872 paymentTypes.add(hs); 873 } 874 875 return paymentTypes; 876 } 877 878 879 880 @SuppressWarnings ("unchecked") 881 private void _exportAttendees(ActionRequest req, ActionResponse res, PortletConfig config, ActionForm form) throws Exception { 882 HttpSession session = ((ActionRequestImpl)req).getHttpServletRequest().getSession(); 883 ActionResponseImpl resImpl = (ActionResponseImpl)res; 884 HttpServletResponse httpRes = resImpl.getHttpServletResponse(); 885 boolean firstRegistration = true; 886 List <WebEventRegistration> registrations = (List <WebEventRegistration>) session.getAttribute(WebKeys.WEBEVENTS_REG_VIEW); 887 888 httpRes.setContentType("application/octet-stream"); 889 httpRes.setHeader("Content-Disposition", "attachment; filename=\"attendees_" + UtilMethods.dateToHTMLDate(new Date (),"M_d_yyyy") +".xls\""); 890 Hashtable statesTable = new Hashtable (); 891 Hashtable organizationsTable = new Hashtable (); 892 int numStates = 0; 893 int numOrganizations = 0; 894 String eventStartDate = null; 895 String eventEndDate = null; 896 String eventTitle = null; 897 String facility = null; 898 String facilityCity = null; 899 String facilityState = null; 900 String eventLoc = null; 901 ServletOutputStream out = httpRes.getOutputStream(); 902 try { 903 StringBuffer sb = new StringBuffer (); 904 StringBuffer sbHeader = new StringBuffer (); 905 sbHeader.append("<head>"); 906 sbHeader.append("<meta http-equiv=Content-Type content=\"text/html; charset=windows-1252\">"); 907 sbHeader.append("<meta name=ProgId content=Excel.Sheet>"); 908 sbHeader.append(_setStyleAttendessListHTML()); 909 sbHeader.append("</head>"); 910 if(registrations != null && registrations.size() > 0) { 911 Iterator registrationsIter = registrations.iterator(); 912 913 while (registrationsIter.hasNext()) { 914 WebEventRegistration registration = (WebEventRegistration) registrationsIter.next(); 915 if (registration.getRegistrationStatus() == 6) 916 continue; 917 try { 918 List <WebEventAttendee> attendees = WebEventRegistrationFactory.getEventAttendees(registration); 919 WebEvent event = WebEventFactory.getWebEvent(registration.getEventInode()); 920 WebEventLocation eventLocation = WebEventLocationFactory.getWebEventLocation(registration.getEventLocationInode()); 921 UserProxy userProxy = UserProxyFactory.getUserProxy(registration.getUserInode()); 922 Organization organization = (Organization) InodeFactory.getParentOfClass(userProxy,Organization.class); 923 if (organization.getInode() > 0){ 924 if (organizationsTable.get(organization.getInode()) == null){ 925 ++numOrganizations; 926 organizationsTable.put(organization.getInode(),organization.getTitle()); 927 } 928 if (statesTable.get(organization.getState()) == null){ 929 ++numStates; 930 statesTable.put(organization.getState(),""); 931 } 932 } 933 if (firstRegistration) { 934 eventStartDate = UtilMethods.dateToHTMLDate(eventLocation.getStartDate()); 935 eventEndDate = UtilMethods.dateToHTMLDate(eventLocation.getEndDate()); 936 eventTitle = event.getTitle(); 937 eventLoc = eventLocation.getState() + ", " + eventLocation.getCity(); 938 firstRegistration = false; 939 } 940 for(WebEventAttendee attendee : attendees){ 941 facility = organization.getTitle(); 942 facilityCity = organization.getCity(); 943 facilityState = organization.getState(); 944 if (facility == null) 945 facility = "No Facility"; 946 if (facilityCity == null) 947 facilityCity = "--"; 948 if (facilityState == null) 949 facilityState = "--"; 950 sb.append("<tr height=16 style='mso-height-source:userset;height:12.0pt'>"); 951 sb.append("<td class=xl32 width=90>" + attendee.getFirstName() + "</td>"); 952 sb.append("<td class=xl32 width=90>" + attendee.getLastName() + "</td>"); 953 sb.append("<td class=xl32 width=90>" + attendee.getTitle() + "</td>"); 954 sb.append("<td class=xl32 width=90>" + facility + "</td>"); 955 sb.append("<td class=xl32 width=90>" + facilityCity + "</td>"); 956 sb.append("<td class=xl32 width=90>" + facilityState + "</td>"); 957 sb.append("<td class=xl32 width=90>" +attendee.getEmail()+"</td>"); 958 sb.append("</tr>"); 959 } 960 }catch(Exception p){ 961 962 } 963 } 964 sbHeader.append("<body link=blue vlink=purple class=xl31>"); 965 sbHeader.append("<table width=1000 border=0 cellpadding=0 cellspacing=0>"); 966 sbHeader.append("<tr class=xl29>"); 967 sbHeader.append("<td class=xl24></td>"); 968 sbHeader.append("<td class=xl24></td>"); 969 sbHeader.append("<td class=xl24></td>"); 970 sbHeader.append("<td class=xl24>" + eventTitle + "</td>"); 971 sbHeader.append("<td class=xl24></td>"); 972 sbHeader.append("<td class=xl24></td>"); 973 sbHeader.append("<td class=xl24></td>"); 974 sbHeader.append("</tr>"); 975 sbHeader.append("<tr class=xl29>"); 976 sbHeader.append("<td class=xl24></td>"); 977 sbHeader.append("<td class=xl24></td>"); 978 sbHeader.append("<td class=xl24></td>"); 979 sbHeader.append("<td class=xl30>Attendee List</td>"); 980 sbHeader.append("<td class=xl24></td>"); 981 sbHeader.append("<td class=xl24></td>"); 982 sbHeader.append("<td class=xl24></td>"); 983 sbHeader.append("</tr>"); 984 sbHeader.append("<tr class=xl29>"); 985 sbHeader.append("<td class=xl24></td>"); 986 sbHeader.append("<td class=xl30></td>"); 987 sbHeader.append("<td class=xl24></td>"); 988 sbHeader.append("<td class=xl30>" + eventStartDate + "-" + eventEndDate + " " + eventLoc + "</td>"); 989 sbHeader.append("<td class=xl30></td>"); 990 sbHeader.append("<td class=xl24></td>"); 991 sbHeader.append("<td class=xl24></td>"); 992 sbHeader.append("</tr>"); 993 sbHeader.append("<tr class=xl29>"); 994 sbHeader.append("<td class=xl24></td>"); 995 sbHeader.append("<td class=xl30></td>"); 996 sbHeader.append("<td class=xl24></td>"); 997 sbHeader.append("<td class=xl30>" + String.valueOf(numOrganizations) + " Organizations~" + String.valueOf(numStates)+ " States</td>"); 998 sbHeader.append("<td class=xl30></td>"); 999 sbHeader.append("<td class=xl24></td>"); 1000 sbHeader.append("<td class=xl24></td>"); 1001 sbHeader.append("</tr>"); 1002 sbHeader.append("<tr class=xl27 style='mso-height-source:userset;height:15.0pt'>"); 1003 sbHeader.append("<td class=xl27 style='height:15.0pt'>First Name</td>"); 1004 sbHeader.append("<td class=xl27>Last Name</td>"); 1005 sbHeader.append("<td class=xl27>Title</td>"); 1006 sbHeader.append("<td class=xl27>Facility</td>"); 1007 sbHeader.append("<td class=xl27>City</td>"); 1008 sbHeader.append("<td class=xl27>St</td>"); 1009 sbHeader.append("<td class=xl27>Email</td>"); 1010 sbHeader.append("</tr>"); 1011 }else { 1012 sbHeader.append("<tr class=xl29 height=26 style='mso-height-source:userset;height:20.1pt'>"); 1013 sbHeader.append("<td height=26 class=xl24 width=90 style='height:20.1pt;width:68pt'></td>"); 1014 sbHeader.append("<td class=xl24 width=90 style='width:68pt'></td>"); 1015 sbHeader.append("<td class=xl24 width=185 style='width:139pt'></td>"); 1016 sbHeader.append("<td class=xl30 width=199 style='width:149pt'>There are no Attendees Registrations to show</td>"); 1017 sbHeader.append("<td class=xl24 width=67 style='width:50pt'></td>"); 1018 sbHeader.append("<td class=xl24 width=26 style='width:20pt'></td>"); 1019 sbHeader.append("<td class=xl24 width=230 style='width:173pt'></td>"); 1020 sbHeader.append("</tr>"); 1021 } 1022 sb.append("</table>"); 1023 sb.append("</body>"); 1024 out.print(sbHeader.toString()); 1025 out.print(sb.toString()); 1026 out.flush(); 1027 out.close(); 1028 DotHibernate.closeSession(); 1029 }catch(Exception p){ 1030 out.print("\r\n"); 1031 out.print("There are no Attendees Registrations to show"); 1032 out.print("\r\n"); 1033 out.flush(); 1034 out.close(); 1035 DotHibernate.closeSession(); 1036 } 1037 } 1038 1039 @SuppressWarnings ("unchecked") 1040 private void _exportCertificates(ActionRequest req, ActionResponse res, PortletConfig config, ActionForm form) throws Exception { 1041 HttpSession session = ((ActionRequestImpl)req).getHttpServletRequest().getSession(); 1042 ActionResponseImpl resImpl = (ActionResponseImpl)res; 1043 HttpServletResponse httpRes = resImpl.getHttpServletResponse(); 1044 List <WebEventRegistration> registrations = (List <WebEventRegistration>) session.getAttribute(WebKeys.WEBEVENTS_REG_VIEW); 1045 1046 httpRes.setContentType("application/octet-stream"); 1047 httpRes.setHeader("Content-Disposition", "attachment; filename=\"certificates_" + UtilMethods.dateToHTMLDate(new Date (),"M_d_yyyy") +".csv\""); 1048 1049 String facility = null; 1050 ServletOutputStream out = httpRes.getOutputStream(); 1051 try { 1052 StringBuffer sb = new StringBuffer (); 1053 sb.append("First_Name,"); 1054 sb.append("Last_Name,"); 1055 sb.append("Company"); 1056 sb.append("\r\n"); 1057 1058 if(registrations != null && registrations.size() > 0) { 1059 Iterator registrationsIter = registrations.iterator(); 1060 1061 while (registrationsIter.hasNext()) { 1062 WebEventRegistration registration = (WebEventRegistration) registrationsIter.next(); 1063 if (registration.getRegistrationStatus() == 6) 1064 continue; 1065 try { 1066 List <WebEventAttendee> attendees = WebEventRegistrationFactory.getEventAttendees(registration); 1067 UserProxy userProxy = UserProxyFactory.getUserProxy(registration.getUserInode()); 1068 Organization organization = (Organization) InodeFactory.getParentOfClass(userProxy,Organization.class); 1069 for(WebEventAttendee attendee : attendees){ 1070 facility = organization.getTitle(); 1071 1072 if (facility == null) 1073 facility = "No Facility"; 1074 1075 sb.append("\"" + attendee.getFirstName() + "\","); 1076 sb.append("\"" + attendee.getLastName() + "\","); 1077 sb.append("\"" + facility + "\""); 1078 sb.append("\r\n"); 1079 } 1080 }catch(Exception p){ 1081 1082 } 1083 } 1084 }else { 1085 sb.append("There are no Attendees Registrations to show"); 1086 } 1087 out.print(sb.toString()); 1088 out.flush(); 1089 out.close(); 1090 DotHibernate.closeSession(); 1091 }catch(Exception p){ 1092 out.print("\r\n"); 1093 out.print("An Exception Ocurred! - There are no Attendees Registrations to show"); 1094 out.print("\r\n"); 1095 out.flush(); 1096 out.close(); 1097 DotHibernate.closeSession(); 1098 } 1099 } 1100 1101 @SuppressWarnings ("unchecked") 1102 private void _exportCEOLetters(ActionRequest req, ActionResponse res, PortletConfig config, ActionForm form) throws Exception { 1103 StringBuffer sb = new StringBuffer (); 1104 StringBuffer sbHeader = new StringBuffer (); 1105 StringBuffer sbAttendees = null; 1106 String ceoFirstName; 1107 String ceoLastName; 1108 String ceoFullName; 1109 String facilityTitle; 1110 String facilityCity; 1111 String facilityState; 1112 String facilityZip; 1113 String facilityStreet; 1114 int posCeoName = 0; 1115 HttpSession session = ((ActionRequestImpl)req).getHttpServletRequest().getSession(); 1116 ActionResponseImpl resImpl = (ActionResponseImpl)res; 1117 HttpServletResponse httpRes = resImpl.getHttpServletResponse(); 1118 1119 List <WebEventRegistration> registrations = (List <WebEventRegistration>) session.getAttribute(WebKeys.WEBEVENTS_REG_VIEW); 1120 httpRes.setContentType("application/octet-stream\n"); 1121 httpRes.setHeader("Content-Disposition", "attachment; filename=\"ceoLetters_" + UtilMethods.dateToHTMLDate(new Date (),"M_d_yyyy") +".xls\"\n"); 1122 ServletOutputStream out = httpRes.getOutputStream(); 1123 try { 1124 1125 1126 if(registrations != null && registrations.size() > 0) { 1127 sbHeader.append("<head>\n"); 1129 sbHeader.append("<meta http-equiv=Content-Type content=\"text/html; charset=windows-1252\">\n"); 1130 sbHeader.append("<meta name=ProgId content=Excel.Sheet>\n"); 1131 sbHeader.append(_setStyleCEOLettersHTML()); 1132 sbHeader.append("</head>\n"); 1133 sbHeader.append("<body>\n"); 1134 sbHeader.append("<table border=0 cellpadding=0 cellspacing=0 width=914>\n"); 1135 1136 sbHeader.append(" <tr class=xl2>\n"); 1137 sbHeader.append(" <td width=64>First Name</td>\n"); 1138 sbHeader.append(" <td width=64>Last Name</td>\n"); 1139 sbHeader.append(" <td width=212>Attendees</td>\n"); 1140 sbHeader.append(" <td width=286>Company</td>\n"); 1141 sbHeader.append(" <td width=64>Address</td>\n"); 1142 sbHeader.append(" <td width=64>City</td>\n"); 1143 sbHeader.append(" <td width=47>State</td>\n"); 1144 sbHeader.append(" <td width=49>Zip</td>\n"); 1145 sbHeader.append(" <td width=64>Location</td>\n"); 1146 sbHeader.append(" </tr>\n"); 1147 1148 Iterator registrationsIter = registrations.iterator(); 1149 while (registrationsIter.hasNext()) { 1150 1151 WebEventRegistration registration = (WebEventRegistration) registrationsIter.next(); 1152 if (registration.getRegistrationStatus() == 6) 1153 continue; 1154 WebEventLocation eventLocation = WebEventLocationFactory.getWebEventLocation(registration.getEventLocationInode()); 1155 UserProxy userProxy = UserProxyFactory.getUserProxy(registration.getUserInode()); 1156 Organization organization = (Organization) InodeFactory.getParentOfClass(userProxy,Organization.class); 1157 List <WebEventAttendee> attendees = WebEventRegistrationFactory.getEventAttendees(registration); 1158 sbAttendees = new StringBuffer (); 1159 1160 for(WebEventAttendee attendee : attendees){ 1161 if (sbAttendees.length() == 0) 1162 sbAttendees.append(attendee.getFirstName() + " " + attendee.getLastName()); 1163 else 1164 sbAttendees.append(", " + attendee.getFirstName() + " " + attendee.getLastName()); 1165 } 1166 1167 ceoFullName = registration.getCeoName(); 1168 if ((ceoFullName != null) && !ceoFullName.equals("")){ 1169 ceoFullName = ceoFullName.trim(); 1170 posCeoName = ceoFullName.indexOf(" "); 1171 if (posCeoName > -1){ 1172 ceoFirstName = ceoFullName.substring(0,posCeoName); 1173 ceoLastName = ceoFullName.substring(posCeoName + 1); 1174 } 1175 else{ 1176 ceoFirstName = ceoFullName; 1177 ceoLastName = ""; 1178 } 1179 } 1180 else{ 1181 ceoFirstName = ""; 1182 ceoLastName = ""; 1183 } 1184 if (organization != null){ 1185 facilityTitle = organization.getTitle(); 1186 if (facilityTitle == null) 1187 facilityTitle = "No Facility"; 1188 facilityStreet = organization.getStreet1(); 1189 if (facilityStreet == null) 1190 facilityStreet = "--"; 1191 facilityCity = organization.getCity(); 1192 if (facilityCity == null) 1193 facilityCity = "--"; 1194 facilityState = organization.getState(); 1195 if (facilityState == null) 1196 facilityState = "--"; 1197 facilityZip = organization.getZip(); 1198 if (facilityZip == null) 1199 facilityZip = "--"; 1200 } 1201 else{ 1202 facilityTitle = "No Facility"; 1203 facilityStreet = "--"; 1204 facilityCity = "--"; 1205 facilityState = "--"; 1206 facilityZip = "--"; 1207 } 1208 sbHeader.append(" <tr class=xl1>\n"); 1209 sbHeader.append(" <td width=64>" + ceoFirstName + "</td>\n"); 1210 sbHeader.append(" <td width=64>" + ceoLastName + "</td>\n"); 1211 sbHeader.append(" <td width=212>" + sbAttendees.toString() + "</td>\n"); 1212 sbHeader.append(" <td width=286>" + facilityTitle + "</td>\n"); 1213 sbHeader.append(" <td width=64>" + facilityStreet + "</td>\n"); 1214 sbHeader.append(" <td width=64>" + facilityCity + "</td>\n"); 1215 sbHeader.append(" <td width=47>" + facilityState + "</td>\n"); 1216 sbHeader.append(" <td align=right width=49>" + facilityZip + "</td>\n"); 1217 sbHeader.append(" <td width=64>" + eventLocation.getCity() + "</td>\n"); 1218 sbHeader.append(" </tr>\n"); 1219 } 1220 sb.append("</table>"); 1221 sb.append("</body>"); 1222 sb.append("</html>"); 1223 }else { 1224 sbHeader.append("\n"); 1225 sbHeader.append("There are no Registrations to show"); 1226 sbHeader.append("\n"); 1227 } 1228 1229 out.print(sbHeader.toString()); 1230 out.print(sb.toString()); 1231 out.flush(); 1232 out.close(); 1233 DotHibernate.closeSession(); 1234 }catch(Exception p){ 1235 out.print("\r\n"); 1236 out.print("There are no information to show."); 1237 out.print("\r\n"); 1238 out.flush(); 1239 out.close(); 1240 DotHibernate.closeSession(); 1241 } 1242 } 1243 1244 @SuppressWarnings ("unchecked") 1245 private void _printBadges(ActionRequest req, ActionResponse res, PortletConfig config, ActionForm form) throws Exception { 1246 String facilityCity; 1247 String facilityState; 1248 String facilityTitle; 1249 HttpSession session = ((ActionRequestImpl)req).getHttpServletRequest().getSession(); 1250 ActionResponseImpl resImpl = (ActionResponseImpl)res; 1251 HttpServletResponse httpRes = resImpl.getHttpServletResponse(); 1252 1253 List <WebEventRegistration> registrations = (List <WebEventRegistration>) session.getAttribute(WebKeys.WEBEVENTS_REG_VIEW); 1254 1255 httpRes.setContentType("application/octet-stream"); 1256 httpRes.setHeader("Content-Disposition", "attachment; filename=\"badges_" + UtilMethods.dateToHTMLDate(new Date (),"M_d_yyyy") +".xls\""); 1257 1258 ServletOutputStream out = httpRes.getOutputStream(); 1259 StringBuffer sb = new StringBuffer (); 1260 1261 sb.append("<head>\n"); 1263 sb.append("<meta http-equiv=Content-Type content=\"text/html; charset=windows-1252\">\n"); 1264 sb.append("<meta name=ProgId content=Excel.Sheet>\n"); 1265 sb.append(_setStyleprintBadgesHTML()); 1266 sb.append("</head>\n"); 1267 sb.append("<body>\n"); 1268 try { 1269 if(registrations != null && registrations.size() > 0) { 1270 sb.append("<table width=469>\n"); 1271 sb.append(" <tr>\n"); 1272 sb.append(" <td class=xl1 width=78>First_Name</td>\n"); 1273 sb.append(" <td class=xl1 width=71>Last_Name</td>\n"); 1274 sb.append(" <td class=xl1 width=64>Badge</td>\n"); 1275 sb.append(" <td class=xl1 width=64>Title</td>\n"); 1276 sb.append(" <td class=xl1 width=64>Facility</td>\n"); 1277 sb.append(" <td class=xl1 width=64>City</td>\n"); 1278 sb.append(" <td class=xl1 width=64>State</td>\n"); 1279 sb.append(" </tr>\n"); 1280 Iterator registrationsIter = registrations.iterator(); 1281 1283 while (registrationsIter.hasNext()) { 1284 WebEventRegistration registration = (WebEventRegistration) registrationsIter.next(); 1285 if (registration.getRegistrationStatus() == 6) 1286 continue; 1287 UserProxy userProxy = UserProxyFactory.getUserProxy(registration.getUserInode()); 1289 Organization organization = (Organization) InodeFactory.getParentOfClass(userProxy,Organization.class); 1290 if (organization != null){ 1291 facilityCity = organization.getCity(); 1292 facilityState = organization.getState(); 1293 facilityTitle = organization.getTitle(); 1294 } 1295 else{ 1296 facilityCity = ""; 1297 facilityState = ""; 1298 facilityTitle = "No Facility"; 1299 } 1300 List <WebEventAttendee> attendees = WebEventRegistrationFactory.getEventAttendees(registration); 1302 1303 registration.setBadgePrinted(true); 1304 InodeFactory.saveInode(registration); 1305 1306 for(WebEventAttendee attendee : attendees){ 1307 sb.append("<tr>\n"); 1308 sb.append("<td class=xl2 width=78>" + attendee.getFirstName() + "</td>\n"); 1309 sb.append("<td class=xl2 width=71>"+attendee.getLastName()+"</td>\n"); 1310 sb.append("<td class=xl2 width=64>" +attendee.getBadgeName()+"</td>\n"); 1311 sb.append("<td class=xl2 width=64>" +attendee.getTitle() + "</td>\n"); 1312 sb.append("<td class=xl2 width=64>" + facilityTitle + "</td>\n"); 1313 sb.append("<td class=xl2 width=64>" + facilityCity + "</td>\n"); 1314 sb.append("<td class=xl2 width=64>" + facilityState + "</td>\n"); 1315 sb.append("</tr>\n"); 1316 } 1317 } 1319 1324 }else { 1325 out.print("0"); 1326 out.print("\r\n"); 1327 out.print("There are no Badges to print"); 1328 out.print("\r\n"); 1329 } 1330 out.print(sb.toString()); 1331 out.flush(); 1332 out.close(); 1333 DotHibernate.closeSession(); 1334 }catch(Exception p){ 1335 1336 out.print("0"); 1337 out.print("\r\n"); 1338 out.print("There are no Badges to print"); 1339 out.print("\r\n"); 1340 out.flush(); 1341 out.close(); 1342 DotHibernate.closeSession(); 1343 } 1344 } 1345 1346 private String _setStyleAttendessListHTML(){ 1347 StringBuffer sb = new StringBuffer (); 1348 sb.append("<style>"); 1349 sb.append("<!--table"); 1350 sb.append("@page"); 1351 sb.append(" {margin:.98in .79in .98in .79in;"); 1352 sb.append(" mso-header-margin:.5in;"); 1353 sb.append(" mso-footer-margin:.5in;"); 1354 sb.append(" mso-page-orientation:landscape;}"); 1355 sb.append("tr"); 1356 sb.append(" {mso-height-source:auto;}"); 1357 sb.append("col"); 1358 sb.append(" {mso-width-source:auto;}"); 1359 sb.append("br"); 1360 sb.append(" {mso-data-placement:same-cell;}"); 1361 sb.append(".style0"); 1362 sb.append(" {mso-number-format:General;"); 1363 sb.append(" text-align:general;"); 1364 sb.append(" vertical-align:bottom;"); 1365 sb.append(" white-space:nowrap;"); 1366 sb.append(" mso-rotate:0;"); 1367 sb.append(" mso-background-source:auto;"); 1368 sb.append(" mso-pattern:auto;"); 1369 sb.append(" color:windowtext;"); 1370 sb.append(" font-size:10.0pt;"); 1371 sb.append(" font-weight:400;"); 1372 sb.append(" font-style:normal;"); 1373 sb.append(" text-decoration:none;"); 1374 sb.append(" font-family:Arial;"); 1375 sb.append(" mso-generic-font-family:auto;"); 1376 sb.append(" mso-font-charset:0;"); 1377 sb.append(" border:none;"); 1378 sb.append(" mso-protection:locked visible;"); 1379 sb.append(" mso-style-name:Normal;"); 1380 sb.append(" mso-style-id:0;}"); 1381 sb.append("td"); 1382 sb.append(" {mso-style-parent:style0;"); 1383 sb.append(" padding-top:1px;"); 1384 sb.append(" padding-right:1px;"); 1385 sb.append(" padding-left:1px;"); 1386 sb.append(" mso-ignore:padding;"); 1387 sb.append(" color:windowtext;"); 1388 sb.append(" font-size:10.0pt;"); 1389 sb.append(" font-weight:400;"); 1390 sb.append(" font-style:normal;"); 1391 sb.append(" text-decoration:none;"); 1392 sb.append(" font-family:Arial;"); 1393 sb.append(" mso-generic-font-family:auto;"); 1394 sb.append(" mso-font-charset:0;"); 1395 sb.append(" mso-number-format:General;"); 1396 sb.append(" text-align:general;"); 1397 sb.append(" vertical-align:bottom;"); 1398 sb.append(" border:none;"); 1399 sb.append(" mso-background-source:auto;"); 1400 sb.append(" mso-pattern:auto;"); 1401 sb.append(" mso-protection:locked visible;"); 1402 sb.append(" white-space:nowrap;"); 1403 sb.append(" mso-rotate:0;}"); 1404 sb.append(".xl24"); 1405 sb.append(" {mso-style-parent:style0;"); 1406 sb.append(" font-size:16.0pt;"); 1407 sb.append(" font-weight:700;"); 1408 sb.append(" font-family:Arial, sans-serif;"); 1409 sb.append(" mso-font-charset:0;"); 1410 sb.append(" text-align:center;}"); 1411 sb.append(".xl25"); 1412 sb.append(" {mso-style-parent:style0;"); 1413 sb.append(" font-size:10.0pt;"); 1414 sb.append(" font-weight:700;"); 1415 sb.append(" font-family:Arial, sans-serif;"); 1416 sb.append(" mso-font-charset:0;"); 1417 sb.append(" text-align:right;}"); 1418 sb.append(".xl26"); 1419 sb.append(" {mso-style-parent:style0;"); 1420 sb.append(" font-size:10.0pt;"); 1421 sb.append(" font-weight:700;"); 1422 sb.append(" font-family:Arial, sans-serif;"); 1423 sb.append(" mso-font-charset:0;}"); 1424 sb.append(".xl27"); 1425 sb.append(" {mso-style-parent:style0;"); 1426 sb.append(" font-size:12.0pt;"); 1427 sb.append(" text-decoration:underline;"); 1428 sb.append(" text-underline-style:single;"); 1429 sb.append(" font-family:Arial, sans-serif;"); 1430 sb.append(" mso-font-charset:0;"); 1431 sb.append(" white-space:normal;}"); 1432 sb.append(".xl30"); 1433 sb.append(" {mso-style-parent:style0;"); 1434 sb.append(" font-size:12.0pt;"); 1435 sb.append(" font-weight:700;"); 1436 sb.append(" font-family:Arial, sans-serif;"); 1437 sb.append(" mso-font-charset:0;"); 1438 sb.append(" text-align:center;}"); 1439 sb.append(".xl32"); 1440 sb.append(" {mso-style-parent:style0;"); 1441 sb.append(" font-size:8.0pt;"); 1442 sb.append(" font-family:Arial, sans-serif;"); 1443 sb.append(" mso-font-charset:0;"); 1444 sb.append(" border:.5pt solid windowtext;"); 1445 sb.append(" background:white;"); 1446 sb.append(" mso-pattern:auto none;"); 1447 sb.append(" white-space:normal;}"); 1448 sb.append("-->"); 1449 sb.append("</style>"); 1450 return sb.toString(); 1451 } 1452 private String _setStyleCEOLettersHTML(){ 1453 StringBuffer sb = new StringBuffer (); 1454 sb.append("<style>\n"); 1455 sb.append(" <!--\n"); 1456 sb.append(" .xl1\n"); 1457 sb.append(" {padding-top:1px;\n"); 1458 sb.append(" padding-right:1px;\n"); 1459 sb.append(" padding-left:1px;\n"); 1460 sb.append(" mso-ignore:padding;\n"); 1461 sb.append(" color:windowtext;\n"); 1462 sb.append(" font-size:7.5pt;\n"); 1463 sb.append(" font-weight:400;\n"); 1464 sb.append(" font-style:normal;\n"); 1465 sb.append(" text-decoration:none;\n"); 1466 sb.append(" font-family:Verdana, sans-serif;\n"); 1467 sb.append(" mso-font-charset:0;\n"); 1468 sb.append(" mso-number-format:General;\n"); 1469 sb.append(" text-align:general;\n"); 1470 sb.append(" vertical-align:bottom;\n"); 1471 sb.append(" border:.5pt solid windowtext;\n"); 1472 sb.append(" mso-background-source:auto;\n"); 1473 sb.append(" mso-pattern:auto;\n"); 1474 sb.append(" white-space:normal;}\n"); 1475 sb.append(" .xl2\n"); 1476 sb.append(" {padding-top:1px;\n"); 1477 sb.append(" padding-right:1px;\n"); 1478 sb.append(" padding-left:1px;\n"); 1479 sb.append(" mso-ignore:padding;\n"); 1480 sb.append(" color:windowtext;\n"); 1481 sb.append(" font-size:7.5pt;\n"); 1482 sb.append(" font-weight:700;\n"); 1483 sb.append(" font-style:normal;\n"); 1484 sb.append(" text-decoration:none;\n"); 1485 sb.append(" font-family:Verdana, sans-serif;\n"); 1486 sb.append(" mso-font-charset:0;\n"); 1487 sb.append(" mso-number-format:General;\n"); 1488 sb.append(" text-align:general;\n"); 1489 sb.append(" vertical-align:bottom;\n"); 1490 sb.append(" border:.5pt solid windowtext;\n"); 1491 sb.append(" mso-background-source:auto;\n"); 1492 sb.append(" mso-pattern:auto;\n"); 1493 sb.append(" white-space:normal;}\n"); 1494 sb.append(" -->\n"); 1495 sb.append("</style>\n"); 1496 return sb.toString(); 1497 } 1498 private String _setStyleprintBadgesHTML(){ 1499 StringBuffer sb = new StringBuffer (); 1500 sb.append("<style>\n"); 1501 sb.append("<!--\n"); 1502 sb.append(".xl1\n"); 1503 sb.append("{padding-top:1px;\n"); 1504 sb.append("padding-right:1px;\n"); 1505 sb.append("padding-left:1px;\n"); 1506 sb.append("mso-ignore:padding;\n"); 1507 sb.append("color:black;\n"); 1508 sb.append("font-size:10.0pt;\n"); 1509 sb.append("font-weight:400;\n"); 1510 sb.append("font-style:normal;\n"); 1511 sb.append("text-decoration:none;\n"); 1512 sb.append("font-family:Arial;\n"); 1513 sb.append("mso-generic-font-family:auto;\n"); 1514 sb.append("mso-font-charset:0;\n"); 1515 sb.append("mso-number-format:General;\n"); 1516 sb.append("text-align:center;\n"); 1517 sb.append("vertical-align:bottom;\n"); 1518 sb.append("border:.5pt solid black;\n"); 1519 sb.append("background:silver;\n"); 1520 sb.append("mso-pattern:black none;\n"); 1521 sb.append("white-space:nowrap;}\n"); 1522 sb.append(".xl2\n"); 1523 sb.append("{padding-top:1px;\n"); 1524 sb.append("padding-right:1px;\n"); 1525 sb.append("padding-left:1px;\n"); 1526 sb.append("mso-ignore:padding;\n"); 1527 sb.append("color:black;\n"); 1528 sb.append("font-size:10.0pt;\n"); 1529 sb.append("font-weight:400;\n"); 1530 sb.append("font-style:normal;\n"); 1531 sb.append("text-decoration:none;\n"); 1532 sb.append("font-family:Arial;\n"); 1533 sb.append("mso-generic-font-family:auto;\n"); 1534 sb.append("mso-font-charset:0;\n"); 1535 sb.append("mso-number-format:General;\n"); 1536 sb.append("text-align:general;\n"); 1537 sb.append("vertical-align:bottom;\n"); 1538 sb.append("border:.5pt solid silver;\n"); 1539 sb.append("mso-background-source:auto;\n"); 1540 sb.append("mso-pattern:auto;\n"); 1541 sb.append("white-space:normal;}\n"); 1542 sb.append("-->\n"); 1543 sb.append("</style>\n"); 1544 return sb.toString(); 1545 } 1546 private void _deleteEventRegistration(ActionForm form, RenderRequest req, RenderResponse res) 1547 throws Exception { 1548 1549 String inode = (req.getParameter("inode")!=null) ? req.getParameter("inode") : "0"; 1550 WebEventRegistration e = null; 1551 if(inode.equals("0")){ 1552 e = WebEventRegistrationFactory.newInstance(); 1553 } else { 1554 e = WebEventRegistrationFactory.getWebEventRegistration(inode); 1555 } 1556 1557 java.util.List attendees = WebEventRegistrationFactory.getEventAttendees(e); 1559 Iterator attendeesIter = attendees.iterator(); 1560 while (attendeesIter.hasNext()) { 1561 WebEventAttendee attendee = (WebEventAttendee) attendeesIter.next(); 1562 WebEventAttendeeFactory.deleteWebEventAttendee(attendee); 1563 } 1564 WebEventRegistrationFactory.deleteWebEventRegistration(e); 1566 SessionMessages.add(req, "message", "message.webevent_registration.deleted"); 1567 1568 } 1569 1570} 1571 | Popular Tags |