Changeset 20552

Show
Ignore:
Timestamp:
03/09/10 00:51:30 (5 months ago)
Author:
ritesh
Message:

- applying charge code while work capture.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/core/src/net/project/resource/AssignmentWorkCaptureHelper.java

    r19882 r20552  
    12511251                Set workLogsToStore = new HashSet(); 
    12521252                        String comments = request.getParameter("comments"); 
     1253                        String chargeCodeId = request.getParameter("chargeCodeId"); 
    12531254                        if(StringUtils.isNotBlank(comments)){ 
    12541255                                this.comments = comments; 
     
    12651266                                log.error("Error occurred while parsing work assigned" + pnetEx.getMessage()); 
    12661267                        } 
    1267                 storeUserChanges(workLogsToStore, tasksToStore, scheduleCache); 
     1268                storeUserChanges(workLogsToStore, tasksToStore, scheduleCache, chargeCodeId); 
    12681269 
    12691270                // add the pervious work performed in the week to total work 
     
    12811282            } 
    12821283 
    1283             public void storeUserChanges(Set workLogsToStore, Set tasksToStore, Map scheduleCache) throws PersistenceException { 
     1284            public void storeUserChanges(Set workLogsToStore, Set tasksToStore, Map scheduleCache, String chargeCodeId) throws PersistenceException { 
     1285                Integer[] assignmentWorkId = null; 
    12841286                if (!errors.errorsFound()) { 
    12851287                    DBBean db = new DBBean(); 
     
    12941296                        for (Iterator it = workLogsToStore.iterator(); it.hasNext();) { 
    12951297                            List workLogs = (List) it.next(); 
    1296                             new AssignmentWorkLogDAO().store(workLogs, db); 
     1298                            assignmentWorkId = new AssignmentWorkLogDAO().store(workLogs, db); 
    12971299                        } 
    12981300                        //Converting Set tasksToStore to scheduleEntryToStoreArray array. 
     
    13571359                    } 
    13581360                } 
     1361                // Assign charge code to assignment work capture. 
     1362            if(StringUtils.isNotEmpty(chargeCodeId)){ 
     1363                for(Integer workCaptureId : assignmentWorkId){ 
     1364                        if(workCaptureId != null) 
     1365                                ServiceFactory.getInstance().getPnObjectHasChargeCodeService().save(workCaptureId, Integer.valueOf(chargeCodeId), Integer.valueOf(SessionManager.getUser().getCurrentSpace().getID())); 
     1366                } 
     1367            } 
    13591368            } 
    13601369 
  • trunk/core/src/net/project/view/pages/assignments/Timesheet.java

    r20525 r20552  
    3030import net.project.calendar.workingtime.IWorkingTimeCalendar; 
    3131import net.project.calendar.workingtime.WorkingTimeCalendarDefinition; 
     32import net.project.chargecode.ChargeCodeManager; 
    3233import net.project.form.assignment.FormAssignment; 
     34import net.project.hibernate.model.PnChargeCode; 
    3335import net.project.resource.ActivityAssignment; 
    3436import net.project.resource.Assignment; 
     
    4850import net.project.view.pages.base.BasePage; 
    4951 
     52import org.apache.commons.collections.CollectionUtils; 
    5053import org.apache.commons.lang.StringUtils; 
    5154import org.apache.log4j.Logger; 
    5255import org.apache.tapestry5.annotations.Property; 
     56import org.apache.tapestry5.ioc.annotations.Inject; 
    5357 
    5458/** 
     
    176180        private boolean userAssigned; 
    177181     
     182    @Property 
     183    private List<PnChargeCode> chargeCodeList; 
     184     
     185    @Property 
     186    private PnChargeCode chargeCode; 
     187 
    178188    public void onActivate() { 
    179189                if (net.project.security.SessionManager.getUser() == null) { 
     
    225235                userAssigned = isUserHasAssignment(objectId); 
    226236                 
     237                Integer spaceId = Integer.valueOf(getUser().getCurrentSpace().getID()); 
     238                chargeCodeList = getPnChargeCodeService().getChargeCodeByProjectId(spaceId); 
     239                chargeCode = getPnChargeCodeService().getChargeCodeApliedOnTask(Integer.valueOf(objectId), spaceId); 
     240                if(chargeCode == null) 
     241                        chargeCode = getPnChargeCodeService().getChargeCodeAppliedOnPersonInSpace(Integer.valueOf(SessionManager.getUser().getID()), spaceId); 
    227242        } 
    228          
     243 
    229244        /** 
    230245         * Get the Saved/Non Saved timeWorkedDiv for blogit.js for the first time only. 
     
    387402        } 
    388403     
     404    /** 
     405     * To Check weather charge codes available for owning project of this assignment 
     406     * @return boolean 
     407     */ 
     408    public boolean isChargeCodeAvailable() { 
     409        return CollectionUtils.isNotEmpty(chargeCodeList);       
     410    } 
     411     
     412    /** 
     413     * To check weather charge code is assigned to this assignment. 
     414     * @return boolean 
     415     */ 
     416    public boolean isChargeCodeAssigned() { 
     417        return chargeCode != null; 
     418    } 
    389419} 
  • trunk/core/web/html/assignments/Timesheet.tml

    r20515 r20552  
    227227                                                                        <td class="table-content-estimates-right"></td> 
    228228                                                        </tr>                                                            
     229                                                        <t:if test="chargeCodeAvailable"> 
     230                                                                <tr class="oldWorkForDay-content" id="charge-code-row"> 
     231                                                                        <t:if test="scrollTypeIsWeek"> 
     232                                                                                        <td></td>  <!-- used extra td for week type only  --> 
     233                                                                                </t:if> 
     234                                                                                <td class="work-label"><t:Message value="prm.business.chargecode.label" /></td> 
     235                                                                                <td> 
     236                                                                        <t:if test="chargeCodeAssigned"> 
     237                                                                                        <t:ComboBox id="chargeCodeList" displayField="codeName" valueField="codeId"  
     238                                                                                        list="chargeCodeList" value="${chargeCode.codeId}" defaultOption="true"  
     239                                                                                        defaultOptionText="prm.business.chargecode.dropdownlist.defaultoption.label" /> 
     240                                                                        <t:parameter name="else"> 
     241                                                                                                <t:ComboBox id="chargeCodeList" displayField="codeName" valueField="codeId"  
     242                                                                                                list="chargeCodeList" defaultOption="true"  
     243                                                                                                defaultOptionText="prm.business.chargecode.dropdownlist.defaultoption.label" /> 
     244                                                                                        </t:parameter>                                                                                           
     245                                                                                </t:if> 
     246                                                                                </td> 
     247                                                                                <td colspan="5" class="oldWorkForDay-border"> 
     248                                                                                </td> 
     249                                                                </tr> 
     250                                                                </t:if>                                                   
    229251                                                </table> <!-- End of table timecard --> 
    230252                                         
  • trunk/core/web/src/workCapture.js

    r20168 r20552  
    311311function submitTimeSheet(objectId) {     
    312312        var urlParams = ''+moduleId 
     313        var chargeCodeId; 
     314        if(document.getElementById('chargeCodeList')) 
     315                chargeCodeId = getSelectedValue(document.getElementById('chargeCodeList')); 
    313316        urlParams += typeof hiddenElement != 'undefined' ? hiddenElement : ''; 
    314317        urlParams += typeof paramString != 'undefined' ? paramString : ''; 
    315318        Ext.Ajax.request({ 
    316319           url: JSPRootURL +'/assignments/My/Submit_Time_Sheet_Entries?module='+urlParams, 
    317            params: {module: moduleId, objectId: objectId}, 
     320           params: {module: moduleId, objectId: objectId, chargeCodeId: chargeCodeId}, 
    318321           method: 'POST', 
    319322           success: function(result, request){