diff --git a/CRM/Volunteer/BAO/Project.php b/CRM/Volunteer/BAO/Project.php
index 000215de..e780dc1c 100644
--- a/CRM/Volunteer/BAO/Project.php
+++ b/CRM/Volunteer/BAO/Project.php
@@ -35,6 +35,13 @@
class CRM_Volunteer_BAO_Project extends CRM_Volunteer_DAO_Project {
+ /**
+ * Static field for all the case information that we can potentially export.
+ *
+ * @var array
+ */
+ public static $_exportableFields = NULL;
+
/**
* Array of attributes on the related entity, translated to a common vocabulary.
*
@@ -362,7 +369,7 @@ public static function create(array $params) {
*
* @see CRM_Volunteer_BAO_Assignment::setActivityDefaults()
*/
- public function updateAssociatedActivities () {
+ public function updateAssociatedActivities() {
$activities = CRM_Volunteer_BAO_Assignment::retrieve(array(
'project_id' => $this->id,
));
@@ -688,7 +695,7 @@ public function getEntityAttributes() {
* @param int $project_id
* @return mixed Integer on success, else NULL
*/
- public static function getFlexibleNeedID ($project_id) {
+ public static function getFlexibleNeedID($project_id) {
$result = NULL;
if (is_int($project_id) || ctype_digit($project_id)) {
@@ -833,8 +840,7 @@ public static function getDefaultProjectContacts() {
*
* @var array
*/
- public static function getProjectProfileAudienceTypes()
- {
+ public static function getProjectProfileAudienceTypes() {
return array(
"primary" => array(
"type" => "primary",
@@ -853,6 +859,29 @@ public static function getProjectProfileAudienceTypes()
),
);
}
+
+ /**
+ * Combine all the exportable fields from the lower levels object.
+ *
+ * @return array
+ * array of exportable Fields
+ */
+ public static function &exportableFields() {
+ if (!self::$_exportableFields) {
+ if (!self::$_exportableFields) {
+ self::$_exportableFields = array();
+ }
+
+ $fields = CRM_Volunteer_DAO_Project::export();
+
+ // add custom data for volunteer projects
+ $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('VolunteerProject'));
+
+ self::$_exportableFields = $fields;
+ }
+ return self::$_exportableFields;
+ }
+
/**
* Sets and returns the start date of the entity associated with this Project
*
@@ -957,7 +986,6 @@ private function _get_roles() {
return $this->roles;
}
-
/**
* Sets and returns $this->open_needs. Delegate of __get().
*
diff --git a/CRM/Volunteer/Form/CustomData.php b/CRM/Volunteer/Form/CustomData.php
new file mode 100644
index 00000000..4030d189
--- /dev/null
+++ b/CRM/Volunteer/Form/CustomData.php
@@ -0,0 +1,147 @@
+_entityName = CRM_Utils_Request::retrieve('entityName', 'String', $this, TRUE);
+ $this->_entityID = CRM_Utils_Request::retrieve('entityID', 'Positive', $this, TRUE);
+ $this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this, FALSE);
+ // $this->_subTypeID = CRM_Utils_Request::retrieve('subType', 'Positive', $this, TRUE);
+
+ if (!in_array($this->_entityName, ['VolunteerProject'])) {
+ $this->_entityName = 'VolunteerProject';
+ }
+
+ $groupTree = CRM_Core_BAO_CustomGroup::getTree($this->_entityName,
+ NULL,
+ $this->_entityID,
+ $this->_groupID,
+ NULL // $this->_subTypeID
+ );
+ // simplified formatted groupTree
+ $groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, $this);
+ // Array contains only one item
+ foreach ($groupTree as $groupValues) {
+ $this->_customTitle = $groupValues['title'];
+ CRM_Utils_System::setTitle(ts('Edit %1', [1 => $groupValues['title']]));
+ }
+
+ $this->_defaults = [];
+ CRM_Core_BAO_CustomGroup::setDefaults($groupTree, $this->_defaults);
+ $this->setDefaults($this->_defaults);
+
+ CRM_Core_BAO_CustomGroup::buildQuickForm($this, $groupTree);
+
+ //need to assign custom data type and subtype to the template
+ $this->assign('entityName', $this->_entityName);
+ $this->assign('entityID', $this->_entityID);
+ $this->assign('groupID', $this->_groupID);
+ // $this->assign('subType', $this->_subTypeID);
+ }
+
+ /**
+ * Build the form object.
+ */
+ public function buildQuickForm() {
+ // make this form an upload since we dont know if the custom data injected dynamically
+ // is of type file etc
+ $this->addButtons([
+ [
+ 'type' => 'upload',
+ 'name' => ts('Save'),
+ 'isDefault' => TRUE,
+ ],
+ [
+ 'type' => 'cancel',
+ 'name' => ts('Cancel'),
+ ],
+ ]);
+ }
+
+ /**
+ * Process the user submitted custom data values.
+ */
+ public function postProcess() {
+ $params = $this->controller->exportValues($this->_name);
+
+ $transaction = new CRM_Core_Transaction();
+
+ $entityTable = 'civicrm_volunteer_project';
+
+ CRM_Core_BAO_CustomValueTable::postProcess($params,
+ $entityTable,
+ $this->_entityID,
+ $this->_entityName
+ );
+
+ $session = CRM_Core_Session::singleton();
+ $session->pushUserContext(CRM_Utils_System::url('civicrm/vol', "#/volunteer/manage/{$this->_entityID}"));
+
+ $transaction->commit();
+ }
+
+}
diff --git a/ang/volunteer.js b/ang/volunteer.js
index 8f8ff5be..96d4b99b 100644
--- a/ang/volunteer.js
+++ b/ang/volunteer.js
@@ -164,6 +164,38 @@
};
})
+ // Editable custom data blocks
+ .directive('volunteerEditCustomData', function($timeout) {
+ return {
+ restrict: 'A',
+ link: function (scope, elem, attrs) {
+ elem
+ .addClass('crm-editable-enabled')
+ .on('click', function(e) {
+ var url = CRM.url('civicrm/volunteer/cd/edit', {
+ action: 'update',
+ reset: 1,
+ entityName: 'VolunteerProject',
+ entityID: scope.project.id,
+ groupID: scope.customGroup.id,
+ // subType: scope.item.case_type_id,
+ });
+
+ var settings = {
+ dialog: {
+ width: "85%",
+ height:"80%",
+ },
+ };
+ CRM
+ .loadForm(url, settings)
+ .on('crmFormSuccess', function(e, data) {
+ scope.refreshCustomData();
+ });
+ });
+ }
+ };
+ })
/**
* This is a service for loading the backbone-based volunteer UIs (and their
diff --git a/ang/volunteer/CustomData.html b/ang/volunteer/CustomData.html
new file mode 100644
index 00000000..97f04c80
--- /dev/null
+++ b/ang/volunteer/CustomData.html
@@ -0,0 +1,9 @@
+
\ No newline at end of file
diff --git a/ang/volunteer/Project.html b/ang/volunteer/Project.html
index ffefa74b..c27d60fc 100644
--- a/ang/volunteer/Project.html
+++ b/ang/volunteer/Project.html
@@ -107,10 +107,15 @@
-