svn commit: r609535 - in /ofbiz/trunk/specialpurpose/projectmgr: script/org/ofbiz/project/ProjectServices.xml servicedef/services.xml webapp/projectmgr/WEB-INF/actions/EditWeekTimesheet.bsh widget/forms/TimeSheetForms.xml

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r609535 - in /ofbiz/trunk/specialpurpose/projectmgr: script/org/ofbiz/project/ProjectServices.xml servicedef/services.xml webapp/projectmgr/WEB-INF/actions/EditWeekTimesheet.bsh widget/forms/TimeSheetForms.xml

hansbak-2
Author: hansbak
Date: Mon Jan  7 01:12:32 2008
New Revision: 609535

URL: http://svn.apache.org/viewvc?rev=609535&view=rev
Log:
set the assignment to 'complete' on the timesheet

Modified:
    ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectServices.xml
    ofbiz/trunk/specialpurpose/projectmgr/servicedef/services.xml
    ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/WEB-INF/actions/EditWeekTimesheet.bsh
    ofbiz/trunk/specialpurpose/projectmgr/widget/forms/TimeSheetForms.xml

Modified: ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectServices.xml?rev=609535&r1=609534&r2=609535&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectServices.xml (original)
+++ ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectServices.xml Mon Jan  7 01:12:32 2008
@@ -74,8 +74,12 @@
             </then>
             <else>
                 <!-- status changed or assignment ended -->
-                <log level="always" message="=====get====parameters: ${parameters}"></log>
-                <entity-one entity-name="WorkEffortPartyAssignment" value-name="assignment"/>
+                <entity-one entity-name="WorkEffortPartyAssignment" value-name="assignment">
+                    <field-map field-name="workEffortId" env-name="parameters.workEffortId"/>
+                    <field-map field-name="partyId" env-name="parameters.partyId"/>
+                    <field-map field-name="roleTypeId" env-name="parameters.roleTypeId"/>
+                    <field-map field-name="fromDate" env-name="parameters.fromDate"/>
+                </entity-one>
                 <if-compare field-name="parameters.statusId" value="PAS_ENDED" operator="equals">
                     <!-- special case to indicate end of assignment -->
                     <now-date-to-env env-name="assignment.thruDate"/>
@@ -187,6 +191,7 @@
             <return/>
         </if-compare>
         <entity-one entity-name="Timesheet" value-name="timesheet"/>
+        <field-to-result field-name="parameters.timesheetId" result-name="timesheetId"/>
         
         <entity-and entity-name="ProjectAndPhaseAndTask" list-name="projects">
             <field-map field-name="workEffortId" env-name="parameters.workEffortId"/>
@@ -214,13 +219,13 @@
             <field-map field-name="workEffortId" env-name="project.workEffortId"/>
             <field-map field-name="partyId" env-name="timesheet.partyId"/>
         </entity-and>
+        <!-- also needed for status update lateron -->
+        <set field="parameters.partyId" from-field="timesheet.partyId"/>
         <if-empty field-name="assigns">
             <first-from-list entry-name="projectAssign" list-name="projectAssigns"/>
-            <set field="parameters.partyId" from-field="timesheet.partyId"/>
             <set field="parameters.roleTypeId" from-field="projectAssign.roleTypeId"/>
             <set field="parameters.statusId" value="PAS_ASSIGNED"/>
             <call-simple-method method-name="assignPartyToWorkEffort" xml-resource="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml"/>
-            
         </if-empty>
         
         <!-- check if the actual start date is set, when not set it to todays date -->
@@ -276,7 +281,13 @@
             </call-class-method>
             <call-simple-method method-name="updateTimeEntry"/>                        
         </loop>
-        
+        <if-compare field-name="parameters.checkComplete" value="Y" operator="equals">
+            <entity-one entity-name="WorkEffortPartyAssignment" value-name="alreadyAssign"/>
+            <if-compare field-name="alreadyAssign.statusId" value="PAS_COMPLETED" operator="not-equals">
+                <set field="parameters.statusId" value="PAS_COMPLETED"/>
+                <call-simple-method method-name="updateTaskAssigment"/>
+            </if-compare>
+        </if-compare>
     </simple-method>          
 
     <simple-method method-name="getProjectIdAndName" short-description="Get the projectId when a phase or task is provided." login-required="true">

Modified: ofbiz/trunk/specialpurpose/projectmgr/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/servicedef/services.xml?rev=609535&r1=609534&r2=609535&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/projectmgr/servicedef/services.xml (original)
+++ ofbiz/trunk/specialpurpose/projectmgr/servicedef/services.xml Mon Jan  7 01:12:32 2008
@@ -51,11 +51,12 @@
     
     <service name="updateTimeEntryByWorkeffort" engine="simple"
         location="org/ofbiz/project/ProjectServices.xml" invoke="updateTimeEntryByWorkeffort">
-        <description>Update workeffort by workeffort and timesheetId </description>
+        <description>Update workeffort by workeffortId and timesheetId </description>
         <permission-service service-name="projectMgrPermission" main-action="UPDATE"/>
-        <attribute name="timesheetId" type="String" mode="IN" optional="false"/>
-        <attribute name="workEffortId" type="String" mode="IN" optional="true"/><!-- when empty will be ignored -->
-        <attribute name="fromDate" type="Timestamp" mode="OUT" optional="true"/>
+        <attribute name="timesheetId" type="String" mode="INOUT" optional="true"/>
+        <attribute name="workEffortId" type="String" mode="INOUT" optional="true"/><!-- when empty will be ignored -->
+        <attribute name="fromDate" type="Timestamp" mode="INOUT" optional="true"/>
+        <attribute name="roleTypeId" type="String" mode="IN" optional="true"/>
         <attribute name="hoursDay0" type="Double" mode="IN" optional="true"/>
         <attribute name="hoursDay1" type="Double" mode="IN" optional="true"/>
         <attribute name="hoursDay2" type="Double" mode="IN" optional="true"/>
@@ -63,6 +64,7 @@
         <attribute name="hoursDay4" type="Double" mode="IN" optional="true"/>
         <attribute name="hoursDay5" type="Double" mode="IN" optional="true"/>
         <attribute name="hoursDay6" type="Double" mode="IN" optional="true"/>
+        <attribute name="checkComplete" type="String" mode="IN" optional="true"/>
     </service>
 
     <service name="getProject" engine="simple"

Modified: ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/WEB-INF/actions/EditWeekTimesheet.bsh
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/WEB-INF/actions/EditWeekTimesheet.bsh?rev=609535&r1=609534&r2=609535&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/WEB-INF/actions/EditWeekTimesheet.bsh (original)
+++ ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/WEB-INF/actions/EditWeekTimesheet.bsh Mon Jan  7 01:12:32 2008
@@ -82,14 +82,10 @@
 pHours = 0.00;
 timeEntry = null;
 lastTimeEntry = null;
-while(te.hasNext()) {
- if (timeEntry!=void) {
- lastTimeEntry = timeEntry;
- }
-    timeEntry = te.next();
-    
-    if (lastWorkEffortId != null && !lastWorkEffortId.equals(timeEntry.getString("workEffortId"))) {
-        entry.put("total", taskTotal);
+
+// retrieve work effort data when the workeffortId has changed.
+void retrieveWorkEffortData() {
+       entry.put("total", taskTotal);
         // get the planned number of hours
         entryWorkEffort = lastTimeEntry.getRelatedOne("WorkEffort");
         if (entryWorkEffort != null) {
@@ -103,10 +99,33 @@
             }
         }
         entry.put("plannedHours", pHours);
+        
+        // to be able to set the task to complete
+    workEffortPartyAssigns = EntityUtil.filterByDate(entryWorkEffort.getRelatedByAnd("WorkEffortPartyAssignment", UtilMisc.toMap("partyId", partyId)));
+        Debug.logInfo("======== list of assigns:" + workEffortPartyAssigns, "");    
+        if (workEffortPartyAssigns != null) {
+            workEffortPartyAssign = workEffortPartyAssigns.get(0);
+            entry.put("fromDate", workEffortPartyAssign.getTimestamp("fromDate"));
+            entry.put("roleTypeId", workEffortPartyAssign.getString("roleTypeId"));
+            if (workEffortPartyAssign.getString("statusId").equals("PAS_COMPLETED")) {
+                entry.put("checkComplete", "Y");
+            }
+        }
         }
         entries.add(entry);
         taskTotal = 0.00;
         entry = UtilMisc.toMap("timesheetId", timesheet.get("timesheetId"));
+}
+
+
+while(te.hasNext()) {
+ if (timeEntry!=void) {
+ lastTimeEntry = timeEntry;
+ }
+    timeEntry = te.next();
+    
+    if (lastWorkEffortId != null && !lastWorkEffortId.equals(timeEntry.getString("workEffortId"))) {
+     retrieveWorkEffortData();
     }
     if (UtilValidate.isNotEmpty(timeEntry.get("workEffortId"))) {
         workEffort = timeEntry.getRelatedOne("WorkEffort");
@@ -116,7 +135,7 @@
             entry.put("phaseId",result.get("phaseId"));    
             entry.put("phaseName",result.get("phaseName"));  
             entry.put("projectId",result.get("projectId"));  
-            entry.put("projectName",result.get("projectName"));    
+            entry.put("projectName",result.get("projectName"));  
     }
     entry.put("timesheetId", timesheet.get("timesheetId"));
     if (timeEntry.get("hours") != null) {
@@ -135,15 +154,7 @@
     lastWorkEffortId = timeEntry.getString("workEffortId");
 }
 if (lastWorkEffortId != null) {
-        plannedHours = timeEntry.getRelatedOne("WorkEffort").getRelated("WorkEffortSkillStandard");
-        ph = plannedHours.iterator();
-        pHours = 0.00;
-        while(ph.hasNext()) {
-            plannedHour = ph.next();
-            if (plannedHour.get("estimatedDuration") != null) {
-                pHours += plannedHour.get("estimatedDuration");
-            }
-        }
+   retrieveWorkEffortData();
     entry.put("plannedHours", pHours);
     entry.put("total", taskTotal);
     entries.add(entry);

Modified: ofbiz/trunk/specialpurpose/projectmgr/widget/forms/TimeSheetForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/widget/forms/TimeSheetForms.xml?rev=609535&r1=609534&r2=609535&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/projectmgr/widget/forms/TimeSheetForms.xml (original)
+++ ofbiz/trunk/specialpurpose/projectmgr/widget/forms/TimeSheetForms.xml Mon Jan  7 01:12:32 2008
@@ -21,7 +21,9 @@
         xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-form.xsd">
     <form name="EditWeekTimesheet" type="multi" list-name="timeEntries" use-row-submit="true"
         separate-columns="true" target="updateMyTimesheet">
-        <field name="timesheetId"><hidden/></field>
+        <field name="timesheetId"><hidden/></field>
+        <field name="roleTypeId"><hidden/></field>
+        <field name="fromDate"><hidden/></field>
         <field name="workEffortId" title="${uiLabelMap.ProjectMgrTaskName}">
             <drop-down allow-empty="true">
                 <entity-options entity-name="ProjectPartyAndPhaseAndTask" description="${workEffortName} -- ${phaseName} -- ${projectName}">
@@ -31,9 +33,10 @@
                     <entity-order-by field-name="phaseName"/>
                     <entity-order-by field-name="workEffortName"/>
                 </entity-options>
-                <sub-hyperlink target="taskView?workEffortId=${workEffortId}" link-style="buttontext" description="${bsh:workEffortId!=&quot;Totals&quot;?workEffortId:void}"/>
+                <sub-hyperlink target="taskView?workEffortId=${workEffortId}" link-style="buttontext" description="${bsh:workEffortId != void &amp;&amp; !workEffortId.equals(&quot;Totals&quot;) ? workEffortId : &quot;&quot;}"/>
             </drop-down>
         </field>
+        <field name="checkComplete"><check/></field>
         <field name="0" parameter-name="hoursDay0" title="Sun"><text size="5"/></field>
         <field name="1" parameter-name="hoursDay1" title="Mon"><text size="5"/></field>
         <field name="2" parameter-name="hoursDay2" title="Tue"><text size="5"/></field>