Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
35921 vikas 1
package com.spice.profitmandi.web.controller;
2
 
35927 vikas 3
import java.time.LocalDateTime;
35948 vikas 4
import java.time.format.DateTimeFormatter;
35927 vikas 5
import java.util.ArrayList;
6
import java.util.List;
7
 
8
import javax.mail.internet.InternetAddress;
9
import javax.mail.internet.MimeMessage;
35921 vikas 10
import javax.servlet.http.HttpServletRequest;
11
 
12
import org.apache.logging.log4j.LogManager;
13
import org.apache.logging.log4j.Logger;
14
import org.springframework.beans.factory.annotation.Autowired;
15
import org.springframework.http.MediaType;
16
import org.springframework.http.ResponseEntity;
35927 vikas 17
import org.springframework.mail.javamail.JavaMailSender;
18
import org.springframework.mail.javamail.MimeMessageHelper;
35921 vikas 19
import org.springframework.stereotype.Controller;
20
import org.springframework.transaction.annotation.Transactional;
35948 vikas 21
import org.springframework.web.bind.annotation.PathVariable;
35927 vikas 22
import org.springframework.web.bind.annotation.RequestBody;
35921 vikas 23
import org.springframework.web.bind.annotation.RequestMapping;
24
import org.springframework.web.bind.annotation.RequestMethod;
25
import org.springframework.web.bind.annotation.RequestParam;
26
 
27
import com.spice.profitmandi.common.model.ProfitMandiConstants;
35927 vikas 28
import com.spice.profitmandi.common.model.UserInfo;
35921 vikas 29
import com.spice.profitmandi.common.web.util.ResponseSender;
30
import com.spice.profitmandi.dao.entity.auth.AuthUser;
35927 vikas 31
import com.spice.profitmandi.dao.entity.dtr.User;
35921 vikas 32
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
33
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
35948 vikas 34
import com.spice.profitmandi.dao.entity.dtr.Retailer;
35
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
35927 vikas 36
import com.spice.profitmandi.dao.repository.cs.CallbackRequestRepository;
35921 vikas 37
import com.spice.profitmandi.dao.repository.cs.CsService;
35948 vikas 38
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
39
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
35927 vikas 40
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
41
import com.spice.profitmandi.web.req.CallbackRequest;
35948 vikas 42
import com.spice.profitmandi.web.req.ResolveCallbackRequest;
43
import com.spice.profitmandi.web.res.AssignedRequestResponse;
44
import com.spice.profitmandi.web.res.CallbackRequestResponse;
35921 vikas 45
import com.spice.profitmandi.web.res.SupportTeamResponse;
35927 vikas 46
import com.spice.profitmandi.web.res.SupportTeamResponse.ContactDetail;
35921 vikas 47
 
48
import io.swagger.annotations.ApiImplicitParam;
49
import io.swagger.annotations.ApiImplicitParams;
50
import io.swagger.annotations.ApiOperation;
51
 
52
@Controller
53
@Transactional(rollbackFor = Throwable.class)
54
public class SupportController {
55
 
56
    private static final Logger LOGGER = LogManager.getLogger(SupportController.class);
57
 
58
    @Autowired
59
    private ResponseSender<?> responseSender;
60
 
61
    @Autowired
62
    private CsService csService;
63
 
64
    @Autowired
65
    private AuthRepository authRepository;
66
 
35927 vikas 67
    @Autowired
68
    private UserRepository userRepository;
69
 
70
    @Autowired
71
    private JavaMailSender mailSender;
72
 
73
    @Autowired
74
    private CallbackRequestRepository callbackRequestRepository;
75
 
35948 vikas 76
    @Autowired
77
    private RetailerRepository retailerRepository;
78
 
79
    @Autowired
80
    private FofoStoreRepository fofoStoreRepository;
81
 
35921 vikas 82
    @RequestMapping(value = "/support/team", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
83
    @ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
35927 vikas 84
    @ApiOperation(value = "Get assigned support team for a FOFO store grouped by escalation level")
35921 vikas 85
    public ResponseEntity<?> getSupportTeam(HttpServletRequest request, @RequestParam(value = "fofoId") int fofoId) throws Throwable {
86
        LOGGER.info("Getting support team for fofoId: {}", fofoId);
87
 
35927 vikas 88
        List<SupportTeamResponse> response = new ArrayList<>();
89
 
90
        // --- LEVEL 1 - IMMEDIATE SUPPORT ---
91
        List<ContactDetail> l1Contacts = new ArrayList<>();
92
 
93
        // RBM = RBM category, L1
35921 vikas 94
        try {
35927 vikas 95
            int rbmAuthUserId = csService.getAuthUserId(ProfitMandiConstants.TICKET_CATEGORY_RBM, EscalationType.L1, fofoId);
96
            if (rbmAuthUserId > 0) {
97
                AuthUser user = authRepository.selectById(rbmAuthUserId);
98
                if (user != null) {
99
                    l1Contacts.add(buildContact(user, "RBM", "#1a7a4c",
100
                            "First point of contact for all queries", true, true, false, true));
35921 vikas 101
                }
102
            }
103
        } catch (Exception e) {
35927 vikas 104
            LOGGER.warn("Could not fetch RBM for fofoId: {}", fofoId, e);
35921 vikas 105
        }
106
 
35927 vikas 107
        // ABM = SALES category, L1
35921 vikas 108
        try {
35927 vikas 109
            int abmAuthUserId = csService.getAuthUserId(ProfitMandiConstants.TICKET_CATEGORY_SALES, EscalationType.L1, fofoId);
110
            if (abmAuthUserId > 0) {
111
                AuthUser user = authRepository.selectById(abmAuthUserId);
112
                if (user != null) {
113
                    l1Contacts.add(buildContact(user, "ASM", "#1a7a4c",
114
                            "Sales support and regional queries", true, true, false, false));
35921 vikas 115
                }
116
            }
117
        } catch (Exception e) {
35927 vikas 118
            LOGGER.warn("Could not fetch ABM for fofoId: {}", fofoId, e);
35921 vikas 119
        }
120
 
35927 vikas 121
        if (!l1Contacts.isEmpty()) {
122
            response.add(new SupportTeamResponse("LEVEL 1 - IMMEDIATE SUPPORT", l1Contacts));
35921 vikas 123
        }
124
 
35927 vikas 125
        // --- LEVEL 2 - SPECIALIZED SUPPORT ---
126
        List<ContactDetail> l2Contacts = new ArrayList<>();
127
 
35921 vikas 128
        // RBM Manager = RBM category, L2
129
        try {
130
            int rbmManagerAuthUserId = csService.getAuthUserId(ProfitMandiConstants.TICKET_CATEGORY_RBM, EscalationType.L2, fofoId);
131
            if (rbmManagerAuthUserId > 0) {
35927 vikas 132
                AuthUser user = authRepository.selectById(rbmManagerAuthUserId);
133
                if (user != null) {
134
                    l2Contacts.add(buildContact(user, "RBM MANAGER", "#7c3aed",
135
                            "For escalated regional matters", false, false, true, true));
35921 vikas 136
                }
137
            }
138
        } catch (Exception e) {
139
            LOGGER.warn("Could not fetch RBM Manager for fofoId: {}", fofoId, e);
140
        }
141
 
35927 vikas 142
        // BM = SALES category, L2
35921 vikas 143
        try {
35927 vikas 144
            int bmAuthUserId = csService.getAuthUserId(ProfitMandiConstants.TICKET_CATEGORY_SALES, EscalationType.L2, fofoId);
145
            if (bmAuthUserId > 0) {
146
                AuthUser user = authRepository.selectById(bmAuthUserId);
147
                if (user != null) {
148
                    l2Contacts.add(buildContact(user, "BM", "#1e6091",
35948 vikas 149
                            "Handles: Orders, Stock, Schemes", true, false, false, true));
35921 vikas 150
                }
151
            }
152
        } catch (Exception e) {
35927 vikas 153
            LOGGER.warn("Could not fetch BM for fofoId: {}", fofoId, e);
35921 vikas 154
        }
155
 
35927 vikas 156
        // Affordability Operations = FINANCIAL_SERVICES category, L2
35921 vikas 157
        try {
35927 vikas 158
            int affordAuthUserId = csService.getAuthUserId(ProfitMandiConstants.TICKET_CATEGORY_FINANCIAL_SERVICES, EscalationType.L2, fofoId);
159
            if (affordAuthUserId > 0) {
160
                AuthUser user = authRepository.selectById(affordAuthUserId);
161
                if (user != null) {
35948 vikas 162
                    l2Contacts.add(buildContact(user, "Finance Partner Mapping", "#d97706",
35927 vikas 163
                            "Credit, payment plans, and operations", false, false, true, false));
35921 vikas 164
                }
165
            }
166
        } catch (Exception e) {
167
            LOGGER.warn("Could not fetch Affordability Manager for fofoId: {}", fofoId, e);
168
        }
169
 
35927 vikas 170
        // Branding Manager = DESIGN category, L1
35921 vikas 171
        try {
35927 vikas 172
            int brandingAuthUserId = csService.getAuthUserId(ProfitMandiConstants.TICKET_CATEGORY_DESIGN, EscalationType.L1, fofoId);
173
            if (brandingAuthUserId > 0) {
174
                AuthUser user = authRepository.selectById(brandingAuthUserId);
175
                if (user != null) {
176
                    l2Contacts.add(buildContact(user, "BRANDING", "#1a7a4c",
177
                            "Brand guidelines and marketing support", false, false, true, false));
35921 vikas 178
                }
179
            }
180
        } catch (Exception e) {
181
            LOGGER.warn("Could not fetch Branding Manager for fofoId: {}", fofoId, e);
182
        }
183
 
35927 vikas 184
        if (!l2Contacts.isEmpty()) {
185
            response.add(new SupportTeamResponse("LEVEL 2 - SPECIALIZED SUPPORT", l2Contacts));
186
        }
187
 
188
        // --- LEVEL 3 - ESCALATION ---
189
        List<ContactDetail> l3Contacts = new ArrayList<>();
190
 
191
        // Grievance Manager = LEGAL category, L3
192
        try {
193
            int grievanceAuthUserId = csService.getAuthUserId(ProfitMandiConstants.TICKET_CATEGORY_LEGAL, EscalationType.L1, fofoId);
194
            if (grievanceAuthUserId > 0) {
195
                AuthUser user = authRepository.selectById(grievanceAuthUserId);
196
                if (user != null) {
197
                    l3Contacts.add(buildContact(user, "GRIEVANCE OFFICER", "#dc2626",
198
                            "For unresolved issues & formal complaints", false, false, true, true));
199
                }
200
            }
201
        } catch (Exception e) {
202
            LOGGER.warn("Could not fetch Grievance Manager for fofoId: {}", fofoId, e);
203
        }
204
 
205
        if (!l3Contacts.isEmpty()) {
206
            response.add(new SupportTeamResponse("LEVEL 3 - ESCALATION", l3Contacts));
207
        }
208
 
35921 vikas 209
        return responseSender.ok(response);
210
    }
211
 
35927 vikas 212
    @RequestMapping(value = "/support/callback-request", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
213
    @ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
214
    @ApiOperation(value = "Submit a callback request to a support contact")
215
    public ResponseEntity<?> requestCallback(HttpServletRequest request, @RequestBody CallbackRequest callbackRequest) throws Throwable {
216
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
217
        User user = userRepository.selectById(userInfo.getUserId());
218
 
219
        LOGGER.info("Callback request from userId: {} to contactId: {} subject: {}",
220
                userInfo.getUserId(), callbackRequest.getContactId(), callbackRequest.getSubject());
221
 
222
        // Save to database
223
        com.spice.profitmandi.dao.entity.cs.CallbackRequest entity = new com.spice.profitmandi.dao.entity.cs.CallbackRequest();
224
        entity.setFofoId(userInfo.getRetailerId());
225
        entity.setUserId(userInfo.getUserId());
226
        entity.setContactId(callbackRequest.getContactId());
227
        entity.setContactName(callbackRequest.getContactName());
228
        entity.setContactRole(callbackRequest.getContactRole());
229
        entity.setSubject(callbackRequest.getSubject());
230
        entity.setMessage(callbackRequest.getMessage());
231
        entity.setTiming(callbackRequest.getTiming());
232
        entity.setStatus("PENDING");
233
        entity.setCreateTimestamp(LocalDateTime.now());
234
        entity.setUpdateTimestamp(LocalDateTime.now());
235
        callbackRequestRepository.persist(entity);
236
        LOGGER.info("Callback request saved with id: {}", entity.getId());
237
 
238
        String timingLabel = "11-15".equals(callbackRequest.getTiming()) ? "11:00 AM - 3:00 PM" : "3:00 PM - 7:00 PM";
239
 
240
        // Send email to the support contact
241
        AuthUser contactUser = authRepository.selectById(callbackRequest.getContactId());
242
        if (contactUser == null || contactUser.getEmailId() == null) {
243
            LOGGER.warn("Contact user not found or has no email for contactId: {}", callbackRequest.getContactId());
244
            return responseSender.ok(true);
245
        }
246
 
247
        MimeMessage message = mailSender.createMimeMessage();
248
        MimeMessageHelper helper = new MimeMessageHelper(message);
249
        helper.setSubject("Callback Request: " + callbackRequest.getSubject());
250
 
251
        String emailContent = "<html>"
252
                + "<body style='font-family: Arial, sans-serif; color: #333;'>"
253
                + "<h2 style='color: #d5282c;'>New Callback Request</h2>"
254
                + "<table style='border-collapse: collapse; width: 100%; max-width: 500px;'>"
255
                + "<tr><td style='padding: 8px; font-weight: bold; color: #555;'>From:</td>"
256
                + "<td style='padding: 8px;'>" + user.getFirstName() + " (" + user.getMobileNumber() + ")</td></tr>"
257
                + "<tr><td style='padding: 8px; font-weight: bold; color: #555;'>Email:</td>"
258
                + "<td style='padding: 8px;'>" + user.getEmailId() + "</td></tr>"
259
                + "<tr><td style='padding: 8px; font-weight: bold; color: #555;'>To:</td>"
260
                + "<td style='padding: 8px;'>" + callbackRequest.getContactName() + " (" + callbackRequest.getContactRole() + ")</td></tr>"
261
                + "<tr><td style='padding: 8px; font-weight: bold; color: #555;'>Subject:</td>"
262
                + "<td style='padding: 8px;'>" + callbackRequest.getSubject() + "</td></tr>"
263
                + "<tr><td style='padding: 8px; font-weight: bold; color: #555;'>Message:</td>"
264
                + "<td style='padding: 8px;'>" + callbackRequest.getMessage() + "</td></tr>"
265
                + "<tr><td style='padding: 8px; font-weight: bold; color: #555;'>Preferred Timing:</td>"
266
                + "<td style='padding: 8px;'>" + timingLabel + "</td></tr>"
267
                + "</table>"
268
                + "<br><p style='color: #999; font-size: 12px;'>This callback request was submitted via the SmartDukaan Support page.</p>"
269
                + "</body></html>";
270
 
271
        helper.setText(emailContent, true);
272
        InternetAddress senderAddress = new InternetAddress("care@smartdukaan.com", "SmartDukaan Support");
273
        helper.setFrom(senderAddress);
274
        helper.setTo(contactUser.getEmailId());
275
        helper.setReplyTo(user.getEmailId());
276
 
277
        mailSender.send(message);
278
        LOGGER.info("Callback request email sent to: {}", contactUser.getEmailId());
279
 
280
        return responseSender.ok(true);
35921 vikas 281
    }
35927 vikas 282
 
35948 vikas 283
    @RequestMapping(value = "/support/callback-requests", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
284
    @ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
285
    @ApiOperation(value = "Get callback requests for the logged-in fofo associate")
286
    public ResponseEntity<?> getCallbackRequests(HttpServletRequest request) throws Throwable {
287
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
288
        int fofoId = userInfo.getRetailerId();
289
        LOGGER.info("Getting callback requests for fofoId: {}", fofoId);
290
 
291
        List<com.spice.profitmandi.dao.entity.cs.CallbackRequest> callbackRequests = callbackRequestRepository.selectAllByFofoId(fofoId);
292
 
293
        List<CallbackRequestResponse> responseList = new ArrayList<>();
294
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd MMM yyyy, hh:mm a");
295
 
296
        for (com.spice.profitmandi.dao.entity.cs.CallbackRequest entity : callbackRequests) {
297
            CallbackRequestResponse res = new CallbackRequestResponse();
298
            res.setId(entity.getId());
299
            res.setContactId(entity.getContactId());
300
            res.setContactName(entity.getContactName());
301
            res.setContactInitials(getInitials(entity.getContactName()));
302
            res.setContactRole(entity.getContactRole());
303
            res.setSubject(entity.getSubject());
304
            res.setMessage(entity.getMessage());
305
            res.setTiming(entity.getTiming());
306
            res.setTimingLabel("11-15".equals(entity.getTiming()) ? "11:00 AM - 3:00 PM" : "3:00 PM - 7:00 PM");
307
            res.setStatus(entity.getStatus());
308
            if (entity.getCreateTimestamp() != null) {
309
                res.setCreateTimestamp(entity.getCreateTimestamp().format(formatter));
310
            }
311
            responseList.add(res);
312
        }
313
 
314
        return responseSender.ok(responseList);
315
    }
316
 
317
    @RequestMapping(value = "/support/assigned-requests", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
318
    @ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
319
    @ApiOperation(value = "Get callback requests assigned to the logged-in internal user")
320
    public ResponseEntity<?> getAssignedRequests(HttpServletRequest request) throws Throwable {
321
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
322
        int contactId = userInfo.getUserId();
323
        LOGGER.info("Getting assigned requests for contactId: {}", contactId);
324
 
325
        List<com.spice.profitmandi.dao.entity.cs.CallbackRequest> callbackRequests = callbackRequestRepository.selectAllByContactId(contactId);
326
 
327
        List<AssignedRequestResponse> responseList = new ArrayList<>();
328
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd MMM yyyy, hh:mm a");
329
 
330
        for (com.spice.profitmandi.dao.entity.cs.CallbackRequest entity : callbackRequests) {
331
            AssignedRequestResponse res = new AssignedRequestResponse();
332
            res.setId(entity.getId());
333
            res.setSubject(entity.getSubject());
334
            res.setMessage(entity.getMessage());
335
            res.setTiming(entity.getTiming());
336
            res.setTimingLabel("11-15".equals(entity.getTiming()) ? "11:00 AM - 3:00 PM" : "3:00 PM - 7:00 PM");
337
            res.setStatus(entity.getStatus());
338
            res.setResolutionNotes(entity.getResolutionNotes());
339
 
340
            if (entity.getCreateTimestamp() != null) {
341
                res.setCreateTimestamp(entity.getCreateTimestamp().format(formatter));
342
            }
343
            if (entity.getUpdateTimestamp() != null) {
344
                res.setUpdateTimestamp(entity.getUpdateTimestamp().format(formatter));
345
            }
346
 
347
            // Fetch retailer info
348
            try {
349
                User retailerUser = userRepository.selectById(entity.getUserId());
350
                if (retailerUser != null) {
351
                    res.setRetailerName(retailerUser.getFirstName());
352
                    res.setRetailerPhone(retailerUser.getMobileNumber());
353
                }
354
            } catch (Exception e) {
355
                LOGGER.warn("Could not fetch user for userId: {}", entity.getUserId(), e);
356
            }
357
 
358
            // Fetch store info
359
            try {
360
                Retailer retailer = retailerRepository.selectById(entity.getFofoId());
361
                if (retailer != null) {
362
                    res.setStoreName(retailer.getName());
363
                }
364
                FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(entity.getFofoId());
365
                if (fofoStore != null) {
366
                    res.setStoreCode(fofoStore.getCode());
367
                }
368
            } catch (Exception e) {
369
                LOGGER.warn("Could not fetch store info for fofoId: {}", entity.getFofoId(), e);
370
            }
371
 
372
            responseList.add(res);
373
        }
374
 
375
        return responseSender.ok(responseList);
376
    }
377
 
378
    @RequestMapping(value = "/support/assigned-requests/{id}/resolve", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
379
    @ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
380
    @ApiOperation(value = "Update status and resolution notes for a callback request")
381
    public ResponseEntity<?> resolveAssignedRequest(HttpServletRequest request, @PathVariable("id") int id,
382
                                                     @RequestBody ResolveCallbackRequest resolveRequest) throws Throwable {
383
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
384
        LOGGER.info("Resolving callback request id: {} by userId: {} status: {}", id, userInfo.getUserId(), resolveRequest.getStatus());
385
 
386
        com.spice.profitmandi.dao.entity.cs.CallbackRequest entity = callbackRequestRepository.selectById(id);
387
        if (entity == null) {
388
            LOGGER.warn("Callback request not found for id: {}", id);
389
            return responseSender.ok(false);
390
        }
391
 
392
        entity.setStatus(resolveRequest.getStatus());
393
        entity.setResolutionNotes(resolveRequest.getResolutionNotes());
394
        entity.setUpdateTimestamp(LocalDateTime.now());
395
        callbackRequestRepository.persist(entity);
396
 
397
        LOGGER.info("Callback request id: {} resolved with status: {}", id, resolveRequest.getStatus());
398
        return responseSender.ok(true);
399
    }
400
 
35927 vikas 401
    private ContactDetail buildContact(AuthUser authUser, String badge, String badgeColor,
402
                                       String description, boolean showCall, boolean showMessage,
403
                                       boolean showCallback, boolean expanded) {
404
        ContactDetail contact = new ContactDetail();
405
        contact.setId(authUser.getId());
406
        contact.setName(authUser.getFullName());
407
        contact.setInitials(getInitials(authUser.getFirstName(), authUser.getLastName()));
408
        contact.setRole(badge);
409
        contact.setBadge(badge);
410
        contact.setBadgeColor(badgeColor);
411
        contact.setDescription(description);
412
        contact.setPhone("tel:+91" + authUser.getMobileNumber());
413
        contact.setWhatsapp("https://wa.me/91" + authUser.getMobileNumber());
414
        contact.setEmail(authUser.getEmailId());
415
        contact.setShowCall(showCall);
416
        contact.setShowMessage(showMessage);
417
        contact.setShowCallback(showCallback);
418
        contact.setExpanded(expanded);
419
        return contact;
420
    }
421
 
422
    private String getInitials(String firstName, String lastName) {
423
        StringBuilder initials = new StringBuilder();
424
        if (firstName != null && !firstName.isEmpty()) {
425
            initials.append(firstName.charAt(0));
426
        }
427
        if (lastName != null && !lastName.isEmpty()) {
428
            initials.append(lastName.charAt(0));
429
        }
430
        return initials.toString().toUpperCase();
431
    }
35948 vikas 432
 
433
    private String getInitials(String fullName) {
434
        if (fullName == null || fullName.isEmpty()) {
435
            return "";
436
        }
437
        String[] parts = fullName.trim().split("\\s+");
438
        StringBuilder initials = new StringBuilder();
439
        initials.append(parts[0].charAt(0));
440
        if (parts.length > 1) {
441
            initials.append(parts[parts.length - 1].charAt(0));
442
        }
443
        return initials.toString().toUpperCase();
444
    }
35921 vikas 445
}