|
@@ -3828,11 +3828,11 @@ function processWorkForm(
|
|
|
|
|
|
$consideredWorkingTime = api_get_configuration_value('considered_working_time');
|
|
|
|
|
|
- if ($consideredWorkingTime) {
|
|
|
+ if (!empty($consideredWorkingTime)) {
|
|
|
|
|
|
$fieldValue = new ExtraFieldValue('work');
|
|
|
$resultExtra = $fieldValue->getAllValuesForAnItem(
|
|
|
- $workId,
|
|
|
+ $workInfo['iid'],
|
|
|
true
|
|
|
);
|
|
|
|
|
@@ -4298,41 +4298,57 @@ function deleteWorkItem($item_id, $courseInfo)
|
|
|
WHERE c_id = $course_id AND id = $item_id";
|
|
|
$result = Database::query($sql);
|
|
|
$row = Database::fetch_array($result);
|
|
|
+ $count = Database::num_rows($result);
|
|
|
|
|
|
- if (Database::num_rows($result) > 0) {
|
|
|
+ if ($count > 0) {
|
|
|
|
|
|
|
|
|
|
|
|
$consideredWorkingTime = api_get_configuration_value('considered_working_time');
|
|
|
if ($consideredWorkingTime) {
|
|
|
-
|
|
|
- $fieldValue = new ExtraFieldValue('work');
|
|
|
- $resultExtra = $fieldValue->getAllValuesForAnItem(
|
|
|
+ $userWorks = get_work_user_list(
|
|
|
+ 0,
|
|
|
+ 100,
|
|
|
+ null,
|
|
|
+ null,
|
|
|
$row['parent_id'],
|
|
|
- true
|
|
|
+ null,
|
|
|
+ $row['user_id'],
|
|
|
+ false,
|
|
|
+ $course_id,
|
|
|
+ $row['session_id']
|
|
|
);
|
|
|
+
|
|
|
+ if (count($userWorks) == 1) {
|
|
|
+
|
|
|
+ $fieldValue = new ExtraFieldValue('work');
|
|
|
+ $resultExtra = $fieldValue->getAllValuesForAnItem(
|
|
|
+ $row['parent_id'],
|
|
|
+ true
|
|
|
+ );
|
|
|
|
|
|
- $workingTime = null;
|
|
|
- foreach ($resultExtra as $field) {
|
|
|
- $field = $field['value'];
|
|
|
+ $workingTime = null;
|
|
|
+ foreach ($resultExtra as $field) {
|
|
|
+ $field = $field['value'];
|
|
|
|
|
|
- if ($consideredWorkingTime == $field->getField()->getVariable()) {
|
|
|
- $workingTime = $field->getValue();
|
|
|
+ if ($consideredWorkingTime == $field->getField()->getVariable()) {
|
|
|
+ $workingTime = $field->getValue();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($workingTime)) {
|
|
|
+ $sessionId = empty($row['session_id']) ? 0 : $row['session_id'];
|
|
|
+
|
|
|
+
|
|
|
+ $removalResult = Event::eventRemoveVirtualCourseTime(
|
|
|
+ $course_id,
|
|
|
+ $row['user_id'],
|
|
|
+ $sessionId,
|
|
|
+ $workingTime
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if (!empty($workingTime)) {
|
|
|
- $sessionId = empty($row['session_id']) ? 0 : $row['session_id'];
|
|
|
-
|
|
|
-
|
|
|
- $removalResult = Event::eventRemoveVirtualCourseTime(
|
|
|
- $course_id,
|
|
|
- $row['user_id'],
|
|
|
- $sessionId,
|
|
|
- $workingTime
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
$sql = "UPDATE $work_table SET active = 2
|
|
|
WHERE c_id = $course_id AND id = $item_id";
|