Subversion Repositories SmartDukaan

Rev

Rev 1891 | Rev 3105 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1494 vikas 1
package in.shop2020.support.controllers;
2
 
3
import in.shop2020.model.v1.order.LineItem;
4
import in.shop2020.model.v1.order.Order;
5
import in.shop2020.model.v1.order.Transaction;
6
import in.shop2020.model.v1.order.TransactionServiceException;
7
import in.shop2020.model.v1.user.Address;
8
import in.shop2020.model.v1.user.User;
1608 vikas 9
import in.shop2020.model.v1.user.UserCommunication;
1494 vikas 10
import in.shop2020.model.v1.user.UserContextService.Client;
11
import in.shop2020.payments.Payment;
1941 ankur.sing 12
import in.shop2020.support.utils.ReportsUtils;
1494 vikas 13
import in.shop2020.thrift.clients.PaymentServiceClient;
14
import in.shop2020.thrift.clients.TransactionServiceClient;
15
import in.shop2020.thrift.clients.UserContextServiceClient;
16
 
17
import java.io.ByteArrayOutputStream;
18
import java.io.IOException;
19
import java.text.ParseException;
1608 vikas 20
import java.util.Collections;
1494 vikas 21
import java.util.Date;
1608 vikas 22
import java.util.HashMap;
1494 vikas 23
import java.util.List;
24
import java.util.Map;
25
 
1941 ankur.sing 26
import javax.servlet.ServletContext;
1494 vikas 27
import javax.servlet.ServletOutputStream;
1941 ankur.sing 28
import javax.servlet.http.HttpServletRequest;
29
import javax.servlet.http.HttpServletResponse;
30
import javax.servlet.http.HttpSession;
1494 vikas 31
 
32
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
33
import org.apache.poi.ss.usermodel.Cell;
34
import org.apache.poi.ss.usermodel.CellStyle;
1738 vikas 35
import org.apache.poi.ss.usermodel.CreationHelper;
1494 vikas 36
import org.apache.poi.ss.usermodel.Font;
37
import org.apache.poi.ss.usermodel.Row;
38
import org.apache.poi.ss.usermodel.Sheet;
39
import org.apache.poi.ss.usermodel.Workbook;
40
import org.apache.poi.ss.util.CellRangeAddress;
1891 ankur.sing 41
import org.apache.struts2.convention.annotation.InterceptorRef;
42
import org.apache.struts2.convention.annotation.InterceptorRefs;
1941 ankur.sing 43
import org.apache.struts2.interceptor.ServletRequestAware;
44
import org.apache.struts2.interceptor.ServletResponseAware;
45
import org.apache.struts2.util.ServletContextAware;
1494 vikas 46
 
1891 ankur.sing 47
@InterceptorRefs({
1941 ankur.sing 48
    @InterceptorRef("defaultStack"),
1891 ankur.sing 49
    @InterceptorRef("login")
50
})
1494 vikas 51
 
1941 ankur.sing 52
public class UserOrdersController implements ServletRequestAware, ServletResponseAware, ServletContextAware {
1891 ankur.sing 53
 
1941 ankur.sing 54
    private HttpServletRequest request;
55
    private HttpSession session;
56
    private HttpServletResponse response;
57
    private ServletContext context;
58
 
1738 vikas 59
	//private static final DateFormat DATE_TIME_FORMAT = new SimpleDateFormat("yyyy/MM/dd HH:mm");
1608 vikas 60
 
1494 vikas 61
	private String errorMsg = "";
62
 
63
	public String index()	{
1941 ankur.sing 64
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getServletPath())) {
1891 ankur.sing 65
            return "exception";
66
        }
1494 vikas 67
		return "report";
68
	}
69
 
70
	// Handles the POST request (Form Submission)
71
	public String create(){
72
		try	{
73
			//Formatting Form input parameters
1941 ankur.sing 74
			String email = request.getParameter("email");
75
			String orderid = request.getParameter("orderid");
1494 vikas 76
 
77
			TransactionServiceClient transactionServiceClient = new TransactionServiceClient();
78
			in.shop2020.model.v1.order.TransactionService.Client transactionClient = transactionServiceClient.getClient();
79
 
80
			UserContextServiceClient userContextServiceClient = new UserContextServiceClient();
81
			Client userClient = userContextServiceClient.getClient();
82
 
83
			PaymentServiceClient paymentServiceClient = new PaymentServiceClient();
84
			in.shop2020.payments.PaymentService.Client paymentClient = paymentServiceClient.getClient();
1608 vikas 85
 
1494 vikas 86
			User user = null;
87
			if (email != null && !email.isEmpty()) {
88
				user = userClient.getUserByEmail(email);
89
				if(user.getUserId() == -1){
90
				    errorMsg = "No user for this id.";
91
					return "report";
92
				}
93
			}
94
			else {
1498 vikas 95
				try {
96
				    user = userClient.getUserById(transactionClient.getOrder(Long.parseLong(orderid)).getCustomer_id());
97
				} catch (NumberFormatException e)	{
98
					errorMsg = "Order Id should be a number.";
99
					return "report";
100
				}
1494 vikas 101
			}
102
 
103
			if (user == null) {
104
				errorMsg = "Could not find user.";
105
				return "report";
106
			}
107
 
1608 vikas 108
			//Retrieving all user communications
109
			List<UserCommunication> userCommunications = userClient.getUserCommunicationByUser(user.getUserId());
110
 
111
			//Retrieving all the transactions
112
			List <Transaction> transactions = transactionClient.getTransactionsForCustomer(user.getUserId(), 0, (new Date()).getTime(), null);
113
			Collections.reverse(transactions);
1494 vikas 114
 
115
			//Retrieving all the payments 
1608 vikas 116
			List <Payment> payments = paymentClient.getPaymentsForUser(user.getUserId(), 0,
117
					(new Date()).getTime(), null, 0);
118
 
119
			Map<Long, Payment> txnIdToPaymentMap = new HashMap<Long, Payment>();
120
			for(Payment payment : payments) {
121
				txnIdToPaymentMap.put(payment.getMerchantTxnId(), payment);
122
			}
123
 
1494 vikas 124
			// Preparing XLS file for output
1941 ankur.sing 125
			response.setContentType("application/vnd.ms-excel");
1494 vikas 126
 
1941 ankur.sing 127
			response.setHeader("Content-disposition", "inline; filename=user-orders" + ".xls");
1494 vikas 128
 
129
			ServletOutputStream sos;
130
			try {
1608 vikas 131
				ByteArrayOutputStream baos = getSpreadSheetData(user,
1738 vikas 132
						transactions, txnIdToPaymentMap, userCommunications, userClient);
1941 ankur.sing 133
				sos = response.getOutputStream();
1494 vikas 134
				baos.writeTo(sos);
135
				sos.flush();
136
			} catch (IOException e) {
137
				errorMsg = "Failed to write to response.";
138
				e.printStackTrace();
139
			}
140
 
141
		} catch (ParseException e)	{
1498 vikas 142
			errorMsg = e.getMessage();
1494 vikas 143
			e.printStackTrace();
144
		} catch (TransactionServiceException e)	{
1498 vikas 145
			errorMsg = e.getMessage();
1494 vikas 146
			e.printStackTrace();
147
		} catch (Exception e)	{
1498 vikas 148
			errorMsg = e.getMessage();
1494 vikas 149
			e.printStackTrace();
150
		}
151
		return "report";
152
	}
153
 
154
	// Prepares the XLS worksheet object and fills in the data with proper formatting
1608 vikas 155
	private ByteArrayOutputStream getSpreadSheetData(User user,
156
			List<Transaction> transactions,
157
			Map<Long, Payment> txnIdToPaymentMap,
158
			List<UserCommunication> userCommunications,
1738 vikas 159
			Client userClient) 
1608 vikas 160
	{
161
	    ByteArrayOutputStream baosXLS = new ByteArrayOutputStream();
1494 vikas 162
 
1608 vikas 163
		Workbook wb = new HSSFWorkbook();
1494 vikas 164
 
165
	    Font font = wb.createFont();
166
	    font.setBoldweight(Font.BOLDWEIGHT_BOLD);
167
	    CellStyle style = wb.createCellStyle();
168
	    style.setFont(font);
169
 
1738 vikas 170
	    CreationHelper createHelper = wb.getCreationHelper();
171
	    CellStyle dateCellStyle = wb.createCellStyle();
172
	    dateCellStyle.setDataFormat(createHelper.createDataFormat().getFormat("DD/MM/YYYY HH:MM"));
173
 
174
	    createUserSheet(user, userCommunications, wb, style, dateCellStyle);
175
	    createTransactionSheet(transactions, txnIdToPaymentMap, wb, style, dateCellStyle);
1494 vikas 176
 
177
		// Write the workbook to the output stream
178
		try {
179
			wb.write(baosXLS);
180
			baosXLS.close();
181
		} catch (IOException e) {
182
			e.printStackTrace();
183
		}		
184
		return baosXLS;
185
	}
186
 
1738 vikas 187
	private void createTransactionSheet(List<Transaction> transactions, Map<Long, Payment> txnIdToPaymentMap, Workbook wb, CellStyle style, CellStyle dateCellStyle) {
1494 vikas 188
		// TRANSACTION SHEET
1608 vikas 189
	    Sheet transactionSheet = wb.createSheet("Transactions and Payments");
1494 vikas 190
	    short transactionSerialNo = 0;
191
 
192
	    Row orderTitleRow = transactionSheet.createRow(transactionSerialNo ++);
193
	    Cell orderTitleCell = orderTitleRow.createCell(0);
1608 vikas 194
	    orderTitleCell.setCellValue("User Transactions and Payments");
1494 vikas 195
	    orderTitleCell.setCellStyle(style);
196
 
197
	    transactionSheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));
198
 
199
	    transactionSheet.createRow(transactionSerialNo ++);
200
 
201
	    Row orderHeaderRow = transactionSheet.createRow(transactionSerialNo ++);
202
	    orderHeaderRow.createCell(0).setCellValue("Transaction Id");
203
	    orderHeaderRow.createCell(1).setCellValue("Transaction Date");
204
	    orderHeaderRow.createCell(2).setCellValue("Transaction Status");
205
	    orderHeaderRow.createCell(3).setCellValue("Order Id");
206
	    orderHeaderRow.createCell(4).setCellValue("Billing Number");
207
	    orderHeaderRow.createCell(5).setCellValue("Billing Date");
208
	    orderHeaderRow.createCell(6).setCellValue("Order Status");
1608 vikas 209
 
1494 vikas 210
	    orderHeaderRow.createCell(7).setCellValue("Brand");
211
	    orderHeaderRow.createCell(8).setCellValue("Model Name");
212
	    orderHeaderRow.createCell(9).setCellValue("Model Number");
213
	    orderHeaderRow.createCell(10).setCellValue("Color");
214
	    orderHeaderRow.createCell(11).setCellValue("Quantity");
215
	    orderHeaderRow.createCell(12).setCellValue("Unit Price");
216
	    orderHeaderRow.createCell(13).setCellValue("Total Price");
1608 vikas 217
 
1494 vikas 218
	    orderHeaderRow.createCell(14).setCellValue("User Id");
219
	    orderHeaderRow.createCell(15).setCellValue("Name");
220
	    orderHeaderRow.createCell(16).setCellValue("Address1");
221
	    orderHeaderRow.createCell(17).setCellValue("Address2");
1738 vikas 222
	    orderHeaderRow.createCell(18).setCellValue("City");
1494 vikas 223
	    orderHeaderRow.createCell(19).setCellValue("State");
224
	    orderHeaderRow.createCell(20).setCellValue("Pin Code");
225
	    orderHeaderRow.createCell(21).setCellValue("Mobile Number");
226
	    orderHeaderRow.createCell(22).setCellValue("email");
1608 vikas 227
 
1494 vikas 228
	    orderHeaderRow.createCell(23).setCellValue("Airway Bill No.");
229
	    orderHeaderRow.createCell(24).setCellValue("Billed By");
230
	    orderHeaderRow.createCell(25).setCellValue("Receiver");
231
	    orderHeaderRow.createCell(26).setCellValue("Tracking Id");
232
	    orderHeaderRow.createCell(27).setCellValue("Accepted Timestamp");
233
	    orderHeaderRow.createCell(28).setCellValue("Delivery Timestamp");
234
	    orderHeaderRow.createCell(29).setCellValue("Expected Delivery Time");
1608 vikas 235
 
236
	    orderHeaderRow.createCell(30).setCellValue("Payment Id");
237
	    orderHeaderRow.createCell(31).setCellValue("Payment Status");
238
	    orderHeaderRow.createCell(32).setCellValue("Gateway Payment Id");
239
	    orderHeaderRow.createCell(33).setCellValue("Gateway Transaction Date");
240
	    orderHeaderRow.createCell(34).setCellValue("Gateway Txn Id");
241
	    orderHeaderRow.createCell(35).setCellValue("Gateway Txn Status");
242
	    orderHeaderRow.createCell(36).setCellValue("Reference Code");
243
	    orderHeaderRow.createCell(37).setCellValue("Gateway Id");
244
	    orderHeaderRow.createCell(38).setCellValue("Amount");
245
	    orderHeaderRow.createCell(39).setCellValue("Description");
246
	    orderHeaderRow.createCell(40).setCellValue("Auth Code");
247
	    orderHeaderRow.createCell(41).setCellValue("Error Code");
1494 vikas 248
 
1738 vikas 249
	    for (int i=0; i<42 ;i++) {
250
            orderHeaderRow.getCell(i).setCellStyle(style);
251
        }
252
 
1494 vikas 253
	    for(Transaction transaction : transactions)	{
254
	    	List<Order> orders = transaction.getOrders();
255
	    	Date transactionDate = new Date(transaction.getCreatedOn());
256
	    	long transactionId = transaction.getId();
257
	    	String transactionStatus = transaction.getStatusDescription();
258
	    	for(Order order : orders)	{
259
		    	transactionSerialNo ++;
260
		    	Row contentRow = transactionSheet.createRow(transactionSerialNo);
261
			    LineItem lineItem = order.getLineitems().get(0);
1608 vikas 262
			    Payment payment = txnIdToPaymentMap.get(transactionId);
1494 vikas 263
 
264
			    contentRow.createCell(0).setCellValue(transactionId);
1738 vikas 265
			    contentRow.createCell(1).setCellValue(transactionDate);
266
			    contentRow.getCell(1).setCellStyle(dateCellStyle);
1494 vikas 267
			    contentRow.createCell(2).setCellValue(transactionStatus);
268
			    contentRow.createCell(3).setCellValue(order.getId());
269
			    contentRow.createCell(4).setCellValue(order.getInvoice_number());
1744 vikas 270
			    contentRow.createCell(5).setCellValue(new Date(order.getBilling_timestamp()));
1738 vikas 271
			    contentRow.getCell(5).setCellStyle(dateCellStyle);
1494 vikas 272
			    contentRow.createCell(6).setCellValue(order.getStatusDescription());
1608 vikas 273
 
1494 vikas 274
			    contentRow.createCell(7).setCellValue(getValueForEmptyString(lineItem.getBrand()));
275
			    contentRow.createCell(8).setCellValue(getValueForEmptyString(lineItem.getModel_name()));
276
			    contentRow.createCell(9).setCellValue(getValueForEmptyString(lineItem.getModel_number()));
277
			    contentRow.createCell(10).setCellValue(getValueForEmptyString(lineItem.getColor()));
278
			    contentRow.createCell(11).setCellValue(lineItem.getQuantity());
279
			    contentRow.createCell(12).setCellValue(lineItem.getUnit_price());
280
			    contentRow.createCell(13).setCellValue(lineItem.getTotal_price());
1608 vikas 281
 
1494 vikas 282
			    contentRow.createCell(14).setCellValue(order.getCustomer_id());
283
			    contentRow.createCell(15).setCellValue(order.getCustomer_name());
284
			    contentRow.createCell(16).setCellValue(order.getCustomer_address1());
285
			    contentRow.createCell(17).setCellValue(order.getCustomer_address2());
286
			    contentRow.createCell(18).setCellValue(order.getCustomer_city());
287
			    contentRow.createCell(19).setCellValue(order.getCustomer_state());
288
			    contentRow.createCell(20).setCellValue(order.getCustomer_pincode());
289
			    contentRow.createCell(21).setCellValue(order.getCustomer_mobilenumber());
290
			    contentRow.createCell(22).setCellValue(order.getCustomer_email());
1608 vikas 291
 
1494 vikas 292
			    contentRow.createCell(23).setCellValue(order.getAirwaybill_no());
293
			    contentRow.createCell(24).setCellValue(order.getBilled_by());
294
			    contentRow.createCell(25).setCellValue(order.getReceiver());
295
			    contentRow.createCell(26).setCellValue(order.getTracking_id());
1744 vikas 296
			    contentRow.createCell(27).setCellValue(new Date(order.getAccepted_timestamp()));
1738 vikas 297
			    contentRow.getCell(27).setCellStyle(dateCellStyle);
1744 vikas 298
			    contentRow.createCell(28).setCellValue(new Date(order.getDelivery_timestamp()));
1738 vikas 299
			    contentRow.getCell(28).setCellStyle(dateCellStyle);
1744 vikas 300
			    contentRow.createCell(29).setCellValue(new Date(order.getExpected_delivery_time()));
1738 vikas 301
			    contentRow.getCell(29).setCellStyle(dateCellStyle);
1608 vikas 302
 
303
				if (payment != null) {
304
					contentRow.createCell(30).setCellValue(payment.getPaymentId());
305
					contentRow.createCell(31).setCellValue(payment.getStatus().name());
306
					contentRow.createCell(32).setCellValue(payment.getGatewayPaymentId());
307
					contentRow.createCell(33).setCellValue(payment.getGatewayTxnDate());
308
					contentRow.createCell(34).setCellValue(payment.getGatewayTxnId());
309
					contentRow.createCell(35).setCellValue(payment.getGatewayTxnStatus());
310
					contentRow.createCell(36).setCellValue(payment.getReferenceCode());
311
					contentRow.createCell(37).setCellValue(payment.getGatewayId());
312
					contentRow.createCell(38).setCellValue(payment.getAmount());
313
					contentRow.createCell(39).setCellValue(payment.getDescription());
314
					contentRow.createCell(40).setCellValue(payment.getAuthCode());
315
					contentRow.createCell(41).setCellValue(payment.getErrorCode());
316
				}
1494 vikas 317
		    }
318
	    }
319
	}
320
 
321
	private String getValueForEmptyString(String s){
322
		if(s==null || s.equals(""))
323
			return "-";
324
		else
325
			return s; 
326
	}
327
 
1738 vikas 328
	private void createUserSheet(User user, List<UserCommunication> userCommunications, Workbook wb, CellStyle style, CellStyle dateCellStyle) {
1494 vikas 329
	    Sheet userSheet = wb.createSheet("User");
330
	    short userSerialNo = 0;
331
    	// Create the header row and put all the titles in it. Rows are 0 based.
332
 
333
	    Row titleRow = userSheet.createRow(userSerialNo++);
334
	    Cell titleCell = titleRow.createCell(0);
335
	    titleCell.setCellValue("User Details");
336
	    titleCell.setCellStyle(style);
337
 
338
	    userSheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));
339
 
340
	    Row userHeaderRow = userSheet.createRow(userSerialNo++);
341
	    userHeaderRow.createCell(0).setCellValue("Name");
342
	    userHeaderRow.createCell(1).setCellValue("Email");
343
	    userHeaderRow.createCell(2).setCellValue("Communication Email");
344
	    userHeaderRow.createCell(3).setCellValue("Date Of Birth");
345
	    userHeaderRow.createCell(4).setCellValue("Mobile Number");
346
	    userHeaderRow.createCell(5).setCellValue("Sex");
347
	    userHeaderRow.createCell(6).setCellValue("User Id");
1738 vikas 348
	    for (int i=0; i<7 ;i++) {
349
            userHeaderRow.getCell(i).setCellStyle(style);
350
        }
1494 vikas 351
 
352
	    Row userContentRow = userSheet.createRow(userSerialNo++);
353
 
354
    	userContentRow.createCell(0).setCellValue(user.getName());
355
    	userContentRow.createCell(1).setCellValue(user.getEmail());
356
    	userContentRow.createCell(2).setCellValue(user.getCommunicationEmail());
357
    	userContentRow.createCell(3).setCellValue(user.getDateOfBirth());
358
    	userContentRow.createCell(4).setCellValue(user.getMobileNumber());
359
    	userContentRow.createCell(5).setCellValue(user.getSex().name());
360
    	userContentRow.createCell(6).setCellValue(user.getUserId());
361
 
1498 vikas 362
    	userSerialNo+=2;
363
		Row addressHeaderRow = userSheet.createRow(userSerialNo++);
364
	    addressHeaderRow.createCell(0).setCellValue("Name");
365
	    addressHeaderRow.createCell(1).setCellValue("Line1");
366
	    addressHeaderRow.createCell(2).setCellValue("Line2");
367
	    addressHeaderRow.createCell(3).setCellValue("City");
368
	    addressHeaderRow.createCell(4).setCellValue("State");
369
	    addressHeaderRow.createCell(5).setCellValue("Pincode");
370
	    addressHeaderRow.createCell(6).setCellValue("Phone");
1738 vikas 371
	    for (int i=0; i<7 ;i++) {
372
            addressHeaderRow.getCell(i).setCellStyle(style);
373
        }
1498 vikas 374
 
1514 vikas 375
		List<Address> user_addresses = user.getAddresses();
376
		if (user_addresses != null && !user_addresses.isEmpty()) {
377
			for (Address address : user.getAddresses()) {
378
				if (user.getDefaultAddressId() == address.getId()) {
379
					userContentRow = userSheet.createRow(userSerialNo);
380
					userSheet.addMergedRegion(new CellRangeAddress(
381
							userSerialNo, userSerialNo, 0, 6));
382
					userContentRow.createCell(0)
383
							.setCellValue("Primary Address");
1738 vikas 384
					userContentRow.getCell(0).setCellStyle(style);
1514 vikas 385
 
386
					userSerialNo++;
387
					userContentRow = userSheet.createRow(userSerialNo);
388
					userContentRow.createCell(0)
389
							.setCellValue(address.getName());
390
					userContentRow.createCell(1).setCellValue(
391
							address.getLine1());
392
					userContentRow.createCell(2).setCellValue(
393
							address.getLine2());
394
					userContentRow.createCell(3)
395
							.setCellValue(address.getCity());
396
					userContentRow.createCell(4).setCellValue(
397
							address.getState());
398
					userContentRow.createCell(5).setCellValue(address.getPin());
399
					userContentRow.createCell(6).setCellValue(
400
							address.getPhone());
401
					userSerialNo += 3;
402
				}
1494 vikas 403
			}
1514 vikas 404
 
405
			userContentRow = userSheet.createRow(userSerialNo);
406
			userSheet.addMergedRegion(new CellRangeAddress(userSerialNo,
407
					userSerialNo, 0, 6));
408
			userContentRow.createCell(0).setCellValue("Other Addresses");
1738 vikas 409
			userContentRow.getCell(0).setCellStyle(style);
1514 vikas 410
 
411
			for (Address address : user.getAddresses()) {
412
				if (user.getDefaultAddressId() != address.getId()) {
413
					userSerialNo++;
414
					userContentRow = userSheet.createRow(userSerialNo);
415
					userContentRow.createCell(0)
416
							.setCellValue(address.getName());
417
					userContentRow.createCell(1).setCellValue(
418
							address.getLine1());
419
					userContentRow.createCell(2).setCellValue(
420
							address.getLine2());
421
					userContentRow.createCell(3)
422
							.setCellValue(address.getCity());
423
					userContentRow.createCell(4).setCellValue(
424
							address.getState());
425
					userContentRow.createCell(5).setCellValue(address.getPin());
426
					userContentRow.createCell(6).setCellValue(
427
							address.getPhone());
428
				}
1494 vikas 429
			}
430
 
431
 
1608 vikas 432
			userSerialNo+=2;
433
			userContentRow = userSheet.createRow(userSerialNo);
434
			userSheet.addMergedRegion(new CellRangeAddress(userSerialNo,
435
					userSerialNo, 0, 6));
436
			userContentRow.createCell(0).setCellValue("User Communication");
1738 vikas 437
			userContentRow.getCell(0).setCellStyle(style);
1608 vikas 438
			userSerialNo++;
439
			Row commHeaderRow = userSheet.createRow(userSerialNo);
440
		    commHeaderRow.createCell(0).setCellValue("Order Id");
441
		    commHeaderRow.createCell(1).setCellValue("Communication Type");
442
		    commHeaderRow.createCell(2).setCellValue("AirwayBill No");
443
		    commHeaderRow.createCell(3).setCellValue("TimeStamp");
444
		    commHeaderRow.createCell(4).setCellValue("Product Name");
445
		    commHeaderRow.createCell(5).setCellValue("Reply To");
446
		    commHeaderRow.createCell(6).setCellValue("Subject");
447
		    commHeaderRow.createCell(7).setCellValue("Message");
1738 vikas 448
		    for (int i=0; i<8 ;i++) {
449
	            commHeaderRow.getCell(i).setCellStyle(style);
450
	        }
1608 vikas 451
 
452
			for( UserCommunication userComm : userCommunications) {
453
				userSerialNo++;
454
				userContentRow = userSheet.createRow(userSerialNo);
455
				userContentRow.createCell(0).setCellValue(userComm.getOrderId());
456
				if (userComm.getCommunicationType() != null) {
457
					userContentRow.createCell(1).setCellValue(userComm.getCommunicationType().name());
458
				}
459
				userContentRow.createCell(2).setCellValue(userComm.getAirwaybillNo());
1744 vikas 460
				userContentRow.createCell(3).setCellValue(new Date(userComm.getCommunication_timestamp()));
461
				userContentRow.getCell(3).setCellStyle(dateCellStyle);
1608 vikas 462
				userContentRow.createCell(4).setCellValue(userComm.getProductName());
463
				userContentRow.createCell(5).setCellValue(userComm.getReplyTo());
464
				userContentRow.createCell(6).setCellValue(userComm.getSubject());
465
				userContentRow.createCell(7).setCellValue(userComm.getMessage());
1494 vikas 466
			}
1608 vikas 467
		}
1494 vikas 468
	}
1608 vikas 469
 
1494 vikas 470
	public String getErrorMsg() {
471
		return errorMsg;
472
	}
1941 ankur.sing 473
 
474
    @Override
475
    public void setServletRequest(HttpServletRequest req) {
476
        this.request = req;
477
        this.session = req.getSession();        
478
    }
479
 
480
    @Override
481
    public void setServletResponse(HttpServletResponse res) {
482
        this.response = res;
483
    }
484
 
485
    @Override
486
    public void setServletContext(ServletContext context) {
487
        this.context = context;
488
    }
489
 
490
    public String getServletContextPath() {
491
        return context.getContextPath();
492
    }
1608 vikas 493
}