Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/bcgov/EDUC-CAPS
Browse files Browse the repository at this point in the history
  • Loading branch information
ITK-klo committed Nov 13, 2024
2 parents de93bbf + f5afebc commit fb41ba8
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 10 deletions.
16 changes: 11 additions & 5 deletions CAPS/CustomWorkflowActivities/CustomWorkflowActivities.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Crm.Sdk.Proxy, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CrmSdk.CoreAssemblies.9.0.2.52\lib\net462\Microsoft.Crm.Sdk.Proxy.dll</HintPath>
<HintPath>..\packages\Microsoft.CrmSdk.CoreAssemblies.9.0.2.56\lib\net462\Microsoft.Crm.Sdk.Proxy.dll</HintPath>
</Reference>
<Reference Include="microsoft.identitymodel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.7.0.0\lib\net35\microsoft.identitymodel.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CrmSdk.CoreAssemblies.9.0.2.52\lib\net462\Microsoft.Xrm.Sdk.dll</HintPath>
<HintPath>..\packages\Microsoft.CrmSdk.CoreAssemblies.9.0.2.56\lib\net462\Microsoft.Xrm.Sdk.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Xrm.Sdk.Workflow, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CrmSdk.Workflow.9.0.2.52\lib\net462\Microsoft.Xrm.Sdk.Workflow.dll</HintPath>
<HintPath>..\packages\Microsoft.CrmSdk.Workflow.9.0.2.56\lib\net462\Microsoft.Xrm.Sdk.Workflow.dll</HintPath>
</Reference>
<Reference Include="PresentationFramework" />
<Reference Include="System" />
Expand All @@ -76,12 +76,18 @@
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceModel.Http, Version=4.10.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.ServiceModel.Http.4.10.3\lib\net461\System.ServiceModel.Http.dll</HintPath>
</Reference>
<Reference Include="System.ServiceModel.Primitives, Version=4.10.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.ServiceModel.Primitives.4.10.3\lib\net461\System.ServiceModel.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.ServiceModel.Web" />
<Reference Include="System.Text.Encodings.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.8.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=8.0.0.3, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.8.0.3\lib\net462\System.Text.Json.dll</HintPath>
<Reference Include="System.Text.Json, Version=8.0.0.5, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.8.0.5\lib\net462\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion CAPS/CustomWorkflowActivities/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.3" newVersion="8.0.0.3" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.5" newVersion="8.0.0.5" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Expand Down
8 changes: 5 additions & 3 deletions CAPS/CustomWorkflowActivities/packages.config
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net462" />
<package id="Microsoft.CrmSdk.CoreAssemblies" version="9.0.2.52" targetFramework="net462" />
<package id="Microsoft.CrmSdk.Workflow" version="9.0.2.52" targetFramework="net462" />
<package id="Microsoft.CrmSdk.CoreAssemblies" version="9.0.2.56" targetFramework="net462" />
<package id="Microsoft.CrmSdk.Workflow" version="9.0.2.56" targetFramework="net462" />
<package id="Microsoft.IdentityModel" version="7.0.0" targetFramework="net462" />
<package id="System.Buffers" version="4.5.1" targetFramework="net462" />
<package id="System.Memory" version="4.5.5" targetFramework="net462" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net462" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net462" />
<package id="System.ServiceModel.Http" version="4.10.3" targetFramework="net462" />
<package id="System.ServiceModel.Primitives" version="4.10.3" targetFramework="net462" />
<package id="System.Text.Encodings.Web" version="8.0.0" targetFramework="net462" />
<package id="System.Text.Json" version="8.0.3" targetFramework="net462" />
<package id="System.Text.Json" version="8.0.5" targetFramework="net462" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net462" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net462" />
</packages>
114 changes: 113 additions & 1 deletion CAPS/WebResources/Scripts/FormHandler/caps_ChildCareFacility.Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CAPS.ChildCareFacility = CAPS.ChildCareFacility || {};
CAPS.ChildCareFacility.form_onload = function (executionContext) {
var formContext = executionContext.getFormContext();
CAPS.ChildCareFacility.updateAddressFields(formContext);
CAPS.ChildCareFacility.UpdateActualProjectedEnrolment(executionContext);

formContext.getAttribute("caps_sameaddressasschoolfacility").addOnChange(function () {
CAPS.ChildCareFacility.updateAddressFields(formContext, true);
Expand Down Expand Up @@ -89,4 +90,115 @@ CAPS.ChildCareFacility.updateAddressFields = function (formContext, forceClear =
formContext.getAttribute("caps_streetaddress").setValue(null);
formContext.getAttribute("caps_postalcode").setValue(null);
}
};
};

CAPS.ChildCareFacility.UpdateActualProjectedEnrolment = function (executionContext) {

var formContext = executionContext.getFormContext();
var currentCCActualEnrolment = CAPS.ChildCareFacility.GetLookup("caps_currentchildcareactualenrolment", formContext);
if (currentCCActualEnrolment !== undefined) {
var options = "?$select=caps_capacityunder36months,caps_capacity30monthstoschoolage,caps_capacitypreschool,caps_capacitymultiage,caps_capacityschoolage,caps_capacitysasg";
Xrm.WebApi.retrieveRecord("caps_childcareactualenrolment", CAPS.ChildCareFacility.RemoveCurlyBraces(currentCCActualEnrolment.id), options).then(
function success(result) {
var capacityUnder36Months = result.caps_capacityunder36months;
var capacity30MonthsToSchoolAge = result.caps_capacity30monthstoschoolage;
var capacityPreSchool = result.caps_capacitypreschool;
var capacityMultiAge = result.caps_capacitymultiage;
var capacitySchoolAge = result.caps_capacityschoolage;
var capacitySASG = result.caps_capacitysasg;

formContext.getAttribute("caps_under36months_currentenrolment").setValue(capacityUnder36Months);
formContext.getAttribute("caps_30monthstoschoolage_currentenrolment").setValue(capacity30MonthsToSchoolAge);
formContext.getAttribute("caps_preschool_currentenrolment").setValue(capacityPreSchool);
formContext.getAttribute("caps_multiage_currentenrolment").setValue(capacityMultiAge);
formContext.getAttribute("caps_schoolage_currentenrolment").setValue(capacitySchoolAge);
formContext.getAttribute("caps_sasg_currentenrolment").setValue(capacitySASG);

},
function (error) {
console.log(error.message);
}
);
}
else if (currentCCActualEnrolment === undefined) {
var recordId = formContext.data.entity.getId().replace("{", "").replace("}", "");
Xrm.WebApi.retrieveMultipleRecords("edu_year", "?$filter=edu_type eq 757500001 and statuscode eq 1").then(
function retrieveCurrentYearSuccess(currentYearRecord) {
if (currentYearRecord == null || currentYearRecord.entities.length == 0) {
// Not Found for some reason
return;
}
// Get Current Enrolment Projection
// Statuscdoe = 714430001 - Current
// Projection Year matching that obtained from previous query
// Facility matching that of current record
var childCareEnrolmentProjectionOptions = "?$filter=statuscode eq 714430001 and _caps_childcarefacility_value eq '" + recordId + "' and _caps_schoolyear_value eq '" + currentYearRecord.entities[0].edu_yearid + "'";
Xrm.WebApi.retrieveMultipleRecords("caps_childcareenrolmentprojection", childCareEnrolmentProjectionOptions).then(
function success(result) {
if (result == null || result.entities.length == 0) {
return; // Nothing to process
}
var hasChanges = false;
var enrolmentProjUnder36Months = result.entities[0].caps_under36months;
var enrolmentProj30MonthsToSchoolAge = result.entities[0].caps_monthstoschoolage;
var enrolmentProjePreSchool = result.entities[0].caps_preschool;
var enrolmentProjeMultiAge = result.entities[0].caps_multiage;
var enrolmentProjSchoolAge = result.entities[0].caps_schoolage;
var enrolmentProjSASG = result.entities[0].caps_schoolageonschoolgrounds;
if (enrolmentProjUnder36Months != null) {

formContext.getAttribute("caps_under36months_currentenrolment").setValue(enrolmentProjUnder36Months);
hasChanges = true;
}
if (enrolmentProj30MonthsToSchoolAge !== null) {
formContext.getAttribute("caps_30monthstoschoolage_currentenrolment").setValue(enrolmentProj30MonthsToSchoolAge);
hasChanges = true;
}
if (enrolmentProjePreSchool !== null) {
formContext.getAttribute("caps_preschool_currentenrolment").setValue(enrolmentProjePreSchool);
hasChanges = true;
}
if (enrolmentProjeMultiAge !== null) {
formContext.getAttribute("caps_multiage_currentenrolment").setValue(enrolmentProjeMultiAge);
hasChanges = true;
}
if (enrolmentProjSchoolAge !== null) {
formContext.getAttribute("caps_schoolage_currentenrolment").setValue(enrolmentProjSchoolAge);
hasChanges = true;
}
if (enrolmentProjSASG !== null) {
formContext.getAttribute("caps_sasg_currentenrolment").setValue(enrolmentProjSASG);
hasChanges = true;
}

if (hasChanges) {
formContext.data.entity.save(); // Save the record if there were changes made.
}

// Should only have 1 record
return;

});
});
}

};

CAPS.ChildCareFacility.GetLookup = function (fieldName, formContext) {
var lookupFieldObject = formContext.data.entity.attributes.get(fieldName);
if (lookupFieldObject !== null && lookupFieldObject.getValue() !== null && lookupFieldObject.getValue()[0] !== null) {
var entityId = lookupFieldObject.getValue()[0].id;
var entityName = lookupFieldObject.getValue()[0].entityType;
var entityLabel = lookupFieldObject.getValue()[0].name;
var obj = {
id: entityId,
type: entityName,
value: entityLabel
};
return obj;
}
};

CAPS.ChildCareFacility.RemoveCurlyBraces = function (str) {
return str.replace(/[{}]/g, "");
}
7 changes: 7 additions & 0 deletions CAPS/WebResources/Scripts/FormHandler/caps_Project.Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,7 @@ CAPS.Project.ToggleBUSReplacement = function (executionContext) {
formContext.getAttribute("caps_bus").setRequiredLevel("required");
if (executionContext.getFormContext() != FORM_STATE.CREATE) {
formContext.getControl("caps_currentkilometers").setVisible(true);
formContext.getAttribute("caps_currentkilometers").setRequiredLevel("required");
}

}
Expand All @@ -1321,6 +1322,8 @@ CAPS.Project.ToggleBUSReplacement = function (executionContext) {
formContext.getControl("caps_bus").setVisible(false);
formContext.getAttribute("caps_bus").setRequiredLevel("none");
formContext.getControl("caps_currentkilometers").setVisible(false);
formContext.getAttribute("caps_currentkilometers").setRequiredLevel("none");
formContext.getAttribute("caps_currentkilometers").setValue(null);
if (formContext.getAttribute("caps_bus").getValue() != null && executionContext.getFormContext() != FORM_STATE.READ_ONLY) {
formContext.getAttribute("caps_bus").setValue(null);
}
Expand Down Expand Up @@ -2065,10 +2068,14 @@ CAPS.Project.ShowHideOnCCPRFSFields = function (executionContext) {
formContext.getAttribute("caps_operatorname").setValue(null);
formContext.getControl("caps_operatorleaseloi").setVisible(false);
formContext.getAttribute("caps_operatorleaseloi").setValue(null);
formContext.getAttribute("caps_operatorname").setRequiredLevel("none");
formContext.getAttribute("caps_operatorleaseloi").setRequiredLevel("none");
}
else {
formContext.getControl("caps_operatorname").setVisible(true);
formContext.getControl("caps_operatorleaseloi").setVisible(true);
formContext.getAttribute("caps_operatorname").setRequiredLevel("required");
formContext.getAttribute("caps_operatorleaseloi").setRequiredLevel("required");
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,5 @@ CAPS.ChildCareActualEnrolment.UnsubmitReport = function (primaryControl) {
);
}
});

};

0 comments on commit fb41ba8

Please sign in to comment.