Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Development
Core
Commits
b334d9ad
Commit
b334d9ad
authored
Oct 30, 2014
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
recurring activities in create mode
parent
c79bc8d0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
35 deletions
+71
-35
CRM/Activity/Form/Activity.php
CRM/Activity/Form/Activity.php
+37
-16
CRM/Core/Form/RecurringEntity.php
CRM/Core/Form/RecurringEntity.php
+15
-5
CRM/Core/Page/AJAX/RecurringEntity.php
CRM/Core/Page/AJAX/RecurringEntity.php
+8
-8
templates/CRM/Activity/Form/Activity.tpl
templates/CRM/Activity/Form/Activity.tpl
+6
-4
templates/CRM/Core/Form/RecurringEntity.tpl
templates/CRM/Core/Form/RecurringEntity.tpl
+5
-2
No files found.
CRM/Activity/Form/Activity.php
View file @
b334d9ad
...
...
@@ -223,7 +223,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
$this
->
assign
(
'cdType'
,
TRUE
);
return
CRM_Custom_Form_CustomData
::
preProcess
(
$this
);
}
CRM_Core_Form_RecurringEntity
::
preProcess
(
'civicrm_activity'
);
$this
->
_atypefile
=
CRM_Utils_Array
::
value
(
'atypefile'
,
$_GET
);
$this
->
assign
(
'atypefile'
,
FALSE
);
if
(
$this
->
_atypefile
)
{
...
...
@@ -638,6 +638,10 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
//freeze for update mode.
if
(
$this
->
_action
&
CRM_Core_Action
::
UPDATE
)
{
$element
->
freeze
();
}
//Call to RecurringEntity buildQuickForm for add/update mode
if
(
$this
->
_action
&
(
CRM_Core_Action
::
UPDATE
|
CRM_Core_Action
::
ADD
))
{
CRM_Core_Form_RecurringEntity
::
buildQuickForm
(
$this
);
}
...
...
@@ -949,23 +953,40 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
else
{
// save activity
$activity
=
$this
->
processActivity
(
$params
);
$params
[
'dateColumns'
]
=
array
(
'activity_date_time'
);
$params
[
'entity_table'
]
=
'civicrm_activity'
;
//Unset activity id
unset
(
$params
[
'id'
]);
$linkedEntities
=
array
(
array
(
'table'
=>
'civicrm_activity_contact'
,
'findCriteria'
=>
array
(
'activity_id'
=>
$this
->
_activityId
,
),
'linkedColumns'
=>
array
(
'activity_id'
),
'isRecurringEntityRecord'
=>
FALSE
,
)
);
CRM_Core_Form_RecurringEntity
::
postProcess
(
$params
,
'civicrm_activity'
,
$linkedEntities
);
}
//Set for repeat configuration in create mode
$params
[
'entity_id'
]
=
$this
->
_activityId
;
$params
[
'entity_table'
]
=
'civicrm_activity'
;
$scheduleReminderDetails
=
array
();
if
(
!
empty
(
$params
[
'entity_id'
])
&&
!
empty
(
$params
[
'entity_table'
]))
{
$checkParentExistsForThisId
=
CRM_Core_BAO_RecurringEntity
::
getParentFor
(
$params
[
'entity_id'
],
$params
[
'entity_table'
]);
if
(
$checkParentExistsForThisId
)
{
$params
[
'parent_entity_id'
]
=
$checkParentExistsForThisId
;
$scheduleReminderDetails
=
CRM_Core_BAO_RecurringEntity
::
getReminderDetailsByEntityId
(
$checkParentExistsForThisId
,
$params
[
'entity_table'
]);
}
else
{
$params
[
'parent_entity_id'
]
=
$params
[
'entity_id'
];
$scheduleReminderDetails
=
CRM_Core_BAO_RecurringEntity
::
getReminderDetailsByEntityId
(
$params
[
'entity_id'
],
$params
[
'entity_table'
]);
}
$params
[
'schedule_reminder_id'
]
=
$scheduleReminderDetails
->
id
;
}
$params
[
'dateColumns'
]
=
array
(
'activity_date_time'
);
//Unset activity id
unset
(
$params
[
'id'
]);
$linkedEntities
=
array
(
array
(
'table'
=>
'civicrm_activity_contact'
,
'findCriteria'
=>
array
(
'activity_id'
=>
$this
->
_activityId
,
),
'linkedColumns'
=>
array
(
'activity_id'
),
'isRecurringEntityRecord'
=>
FALSE
,
)
);
CRM_Core_Form_RecurringEntity
::
postProcess
(
$params
,
'civicrm_activity'
,
$linkedEntities
);
return
array
(
'activity'
=>
$activity
);
}
...
...
CRM/Core/Form/RecurringEntity.php
View file @
b334d9ad
...
...
@@ -310,13 +310,23 @@ class CRM_Core_Form_RecurringEntity {
* @return None
*/
static
function
postProcess
(
$params
=
array
(),
$type
,
$linkedEntities
=
array
())
{
$params
[
'entity_id'
]
=
self
::
$_entityId
;
//Check entity_id not present in params take it from class variable
if
(
!
CRM_Utils_Array
::
value
(
'entity_id'
,
$params
))
{
$params
[
'entity_id'
]
=
self
::
$_entityId
;
}
//Process this function only when you get this variable
if
(
$params
[
'allowRepeatConfigToSubmit'
]
==
1
)
{
if
(
CRM_Utils_Array
::
value
(
'entity_table'
,
$params
)
&&
CRM_Utils_Array
::
value
(
'entity_id'
,
$params
)
&&
$type
)
{
$params
[
'used_for'
]
=
$type
;
$params
[
'parent_entity_id'
]
=
self
::
$_parentEntityId
;
$params
[
'id'
]
=
self
::
$_scheduleReminderID
;
if
(
!
CRM_Utils_Array
::
value
(
'parent_entity_id'
,
$params
))
{
$params
[
'parent_entity_id'
]
=
self
::
$_parentEntityId
;
}
if
(
CRM_Utils_Array
::
value
(
'schedule_reminder_id'
,
$params
))
{
$params
[
'id'
]
=
$params
[
'schedule_reminder_id'
];
}
else
{
$params
[
'id'
]
=
self
::
$_scheduleReminderID
;
}
//Save post params to the schedule reminder table
$dbParams
=
CRM_Core_BAO_RecurringEntity
::
mapFormValuesToDB
(
$params
);
...
...
@@ -330,7 +340,7 @@ class CRM_Core_Form_RecurringEntity {
//exclude dates
$excludeDateList
=
array
();
if
(
CRM_Utils_Array
::
value
(
'copyExcludeDates'
,
$params
)
&&
CRM_Utils_Array
::
value
(
'parent_entity_id'
,
$params
))
{
if
(
CRM_Utils_Array
::
value
(
'copyExcludeDates'
,
$params
)
&&
CRM_Utils_Array
::
value
(
'parent_entity_id'
,
$params
)
&&
$actionScheduleObj
->
entity_value
)
{
//Since we get comma separated values lets get them in array
$excludeDates
=
array
();
$excludeDates
=
explode
(
","
,
$params
[
'copyExcludeDates'
]);
...
...
@@ -346,7 +356,7 @@ class CRM_Core_Form_RecurringEntity {
}
$optionGroupParams
=
array
(
'name'
=>
$type
.
'_repeat_exclude_dates_'
.
$
params
[
'parent_
entity_
id'
]
,
'name'
=>
$type
.
'_repeat_exclude_dates_'
.
$
actionScheduleObj
->
entity_
value
,
'title'
=>
$type
.
' recursion'
,
'is_reserved'
=>
0
,
'is_active'
=>
1
...
...
CRM/Core/Page/AJAX/RecurringEntity.php
View file @
b334d9ad
...
...
@@ -54,8 +54,7 @@ class CRM_Core_Page_AJAX_RecurringEntity {
$params
=
$formValues
=
$genericResult
=
array
();
$formValues
=
$_REQUEST
;
if
(
!
empty
(
$formValues
)
&&
CRM_Utils_Array
::
value
(
'entity_table'
,
$formValues
)
&&
CRM_Utils_Array
::
value
(
'entity_id'
,
$formValues
))
{
CRM_Utils_Array
::
value
(
'entity_table'
,
$formValues
))
{
$startDateColumnName
=
CRM_Core_BAO_RecurringEntity
::
$_dateColumns
[
$formValues
[
'entity_table'
]][
'dateColumns'
][
0
];
$endDateColumnName
=
CRM_Core_BAO_RecurringEntity
::
$_dateColumns
[
$formValues
[
'entity_table'
]][
'intervalDateColumns'
][
0
];
...
...
@@ -71,16 +70,17 @@ class CRM_Core_Page_AJAX_RecurringEntity {
$recursion
->
excludeDateRangeColumns
=
CRM_Core_BAO_RecurringEntity
::
$_dateColumns
[
$formValues
[
'entity_table'
]][
'excludeDateRangeColumns'
];
}
$parentEventId
=
CRM_Core_BAO_RecurringEntity
::
getParentFor
(
$formValues
[
'entity_id'
],
$formValues
[
'entity_table'
]);
if
(
!
$parentEventId
)
{
$parentEventId
=
$formValues
[
'entity_id'
];
if
(
CRM_Utils_Array
::
value
(
'entity_id'
,
$formValues
))
{
$parentEventId
=
CRM_Core_BAO_RecurringEntity
::
getParentFor
(
$formValues
[
'entity_id'
],
$formValues
[
'entity_table'
]);
}
//Check if there is any enddate column defined to find out the interval between the two range
if
(
CRM_Utils_Array
::
value
(
'intervalDateColumns'
,
CRM_Core_BAO_RecurringEntity
::
$_dateColumns
[
$formValues
[
'entity_table'
]]))
{
$daoName
=
CRM_Core_BAO_RecurringEntity
::
$_tableDAOMapper
[
$formValues
[
'entity_table'
]];
$startDate
=
CRM_Core_DAO
::
getFieldValue
(
$daoName
,
$parentEventId
,
$startDateColumnName
);
$endDate
=
CRM_Core_DAO
::
getFieldValue
(
$daoName
,
$parentEventId
,
$endDateColumnName
);
if
(
$parentEventId
)
{
$startDate
=
CRM_Core_DAO
::
getFieldValue
(
$daoName
,
$parentEventId
,
$startDateColumnName
);
$endDate
=
CRM_Core_DAO
::
getFieldValue
(
$daoName
,
$parentEventId
,
$endDateColumnName
);
}
if
(
$endDate
)
{
$interval
=
$recursion
->
getInterval
(
$startDate
,
$endDate
);
$recursion
->
intervalDateColumns
=
array
(
$endDateColumnName
=>
$interval
);
...
...
@@ -101,7 +101,7 @@ class CRM_Core_Page_AJAX_RecurringEntity {
}
//Show the list of participants registered for the events if any
if
(
$formValues
[
'entity_table'
])
{
if
(
$formValues
[
'entity_table'
]
==
"civicrm_event"
)
{
$getConnectedEntities
=
CRM_Core_BAO_RecurringEntity
::
getEntitiesForParent
(
$parentEventId
,
'civicrm_event'
,
TRUE
);
if
(
$getConnectedEntities
)
{
$participantDetails
=
CRM_Event_Form_ManageEvent_Repeat
::
getParticipantCountforEvent
(
$getConnectedEntities
);
...
...
templates/CRM/Activity/Form/Activity.tpl
View file @
b334d9ad
...
...
@@ -205,7 +205,7 @@
</tr>
{/
if
}
{
if
$action
eq
2
}
{
if
$action
eq
2
OR
$action
eq
1
}
<tr
class=
"crm-activity-form-block-recurring_activity"
>
<td
colspan=
"2"
>
{
include
file
=
"CRM/Core/Form/RecurringEntity.tpl"
}
...
...
@@ -213,14 +213,16 @@
<script
type=
"text/javascript"
>
CRM
.
$
(
function
(
$
)
{
if
(
$
(
'
#activity_date_time
'
).
val
()
!==
""
&&
$
(
'
#activity_date_time_time
'
).
val
()
!==
""
)
{
$
(
'
#repetition_start_date
'
).
val
(
$
(
'
#activity_date_time
'
).
val
());
$
(
'
#repetition_start_date
, #repetition_start_date_display
'
).
val
(
$
(
'
#activity_date_time
'
).
val
());
$
(
'
#repetition_start_date_time
'
).
val
(
$
(
'
#activity_date_time_time
'
).
val
());
}
$
(
'
#activity_date_time_display
'
).
blur
(
function
()
{
$
(
'
#repetition_start_date
'
).
val
(
$
(
'
#activity_date_time
'
).
val
());
$
(
'
#repetition_start_date
, #repetition_start_date_display
'
).
val
(
$
(
'
#activity_date_time
'
).
val
());
$
(
'
#repetition_start_date_time
'
).
val
(
$
(
'
#activity_date_time_time
'
).
val
());
});
$
(
'
#recurring-entity-block
'
).
addClass
(
'
collapsed
'
);
if
(
$
(
'
#start_action_offset
'
).
val
()
==
""
&&
$
(
'
#repeat_absolute_date_display
'
).
val
()
==
""
)
{
$
(
'
#recurring-entity-block
'
).
addClass
(
'
collapsed
'
);
}
});
</script>
{/
literal
}
...
...
templates/CRM/Core/Form/RecurringEntity.tpl
View file @
b334d9ad
...
...
@@ -255,8 +255,11 @@
var
ajaxurl
=
CRM
.
url
(
"
civicrm/ajax/recurringentity/generate-preview
"
);
var
entityID
=
parseInt
(
'
{/
literal
}{
$currentEntityId
}{
literal
}
'
);
var
entityTable
=
'
{/
literal
}{
$entityTable
}{
literal
}
'
;
if
(
entityID
!=
""
&&
entityTable
!=
""
)
{
ajaxurl
+=
"
?entity_id=
"
+
entityID
+
"
&entity_table=
"
+
entityTable
;
if
(
entityTable
!=
""
)
{
ajaxurl
+=
"
?entity_table=
"
+
entityTable
;
}
if
(
entityID
!=
""
)
{
ajaxurl
+=
"
&entity_id=
"
+
entityID
;
}
var
formData
=
cj
(
'
form
'
).
serializeArray
();
cj
.
ajax
({
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment