Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions assets/css/page-widgets/suggested-tasks.css
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@
font-weight: 600;
}
}

.prpl-montly-completed-tasks-list {

li {
display: flex;
justify-content: space-between;
}
}
}

.prpl-dashboard-widget-suggested-tasks {
Expand Down
60 changes: 46 additions & 14 deletions classes/badges/class-monthly.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,34 @@
return $saved_progress;
}

$activities = $this->get_monthly_activities();

$points = 0;
foreach ( $activities as $activity ) {
$points += $activity->get_points( $activity->date );
}

$return_progress = ( $points > self::TARGET_POINTS )
? [
'progress' => 100,
'remaining' => 0,
] : [
'progress' => (int) max( 0, min( 100, floor( 100 * $points / self::TARGET_POINTS ) ) ),
'remaining' => self::TARGET_POINTS - $points,
];

$this->save_progress( $return_progress );

return $return_progress;
}

/**
* Get the monthly activities.
*
* @return array
*/
protected function get_monthly_activities() {

$month = self::get_months()[ 'm' . $this->get_month() ];
$year = $this->get_year();
$month_num = (int) $this->get_month();
Expand All @@ -216,22 +244,26 @@
],
);

$points = 0;
foreach ( $activities as $activity ) {
$points += $activity->get_points( $activity->date );
}
return $activities;
}

$return_progress = ( $points > self::TARGET_POINTS )
? [
'progress' => 100,
'remaining' => 0,
] : [
'progress' => (int) max( 0, min( 100, floor( 100 * $points / self::TARGET_POINTS ) ) ),
'remaining' => self::TARGET_POINTS - $points,
];
/**
* Get the tasks for the badge.
*
* @return array
*/
public function get_monthly_tasks() {
$activities = $this->get_monthly_activities();

$this->save_progress( $return_progress );
$tasks = [];
foreach ( $activities as $activity ) {
$task = \progress_planner()->get_suggested_tasks()->get_tasks_by( 'task_id', $activity->data_id );

return $return_progress;
if ( isset( $task[0] ) && isset( $task[0]['provider_id'] ) ) {
$tasks[] = \progress_planner()->get_suggested_tasks()->get_local()->get_task_details( $task[0]['task_id'] );

Check failure on line 263 in classes/badges/class-monthly.php

View workflow job for this annotation

GitHub Actions / Static Analysis

Call to an undefined method Progress_Planner\Suggested_Tasks::get_local().
}
}

return $tasks;
}
}
20 changes: 20 additions & 0 deletions views/page-widgets/suggested-tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,26 @@
</span>
</div>

<?php $prpl_monthly_tasks = $prpl_badge->get_monthly_tasks(); ?>

Check failure on line 62 in views/page-widgets/suggested-tasks.php

View workflow job for this annotation

GitHub Actions / Static Analysis

Call to an undefined method Progress_Planner\Badges\Badge::get_monthly_tasks().

<?php if ( ! empty( $prpl_monthly_tasks ) ) : ?>
<hr>
<div class="prpl-widget-content-tasks-list">
<h2 class="prpl-widget-title">
<?php \esc_html_e( 'Completed tasks', 'progress-planner' ); ?>
</h2>

<ul class="prpl-montly-completed-tasks-list">
<?php foreach ( $prpl_badge->get_monthly_tasks() as $prpl_monthly_task ) : ?>

Check failure on line 72 in views/page-widgets/suggested-tasks.php

View workflow job for this annotation

GitHub Actions / Static Analysis

Call to an undefined method Progress_Planner\Badges\Badge::get_monthly_tasks().
<li>
<span><?php echo esc_html( $prpl_monthly_task['title'] ); ?></span>
<span><?php echo esc_html( $prpl_monthly_task['points'] ); ?>pt</span>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>

<hr>
<?php endif; ?>

Expand Down
Loading