mirror of
				https://github.com/grocy/grocy.git
				synced 2025-10-31 02:36:54 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			35 lines
		
	
	
		
			711 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			711 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace Grocy\Services;
 | |
| 
 | |
| class TasksService extends BaseService
 | |
| {
 | |
| 	public function GetCurrent()
 | |
| 	{
 | |
| 		$sql = 'SELECT * from tasks_current';
 | |
| 		return $this->DatabaseService->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ);
 | |
| 	}
 | |
| 
 | |
| 	public function MarkTaskAsCompleted($taskId, $doneTime)
 | |
| 	{
 | |
| 		if (!$this->TaskExists($taskId))
 | |
| 		{
 | |
| 			throw new \Exception('Task does not exist');
 | |
| 		}
 | |
| 
 | |
| 		$taskRow = $this->Database->tasks()->where('id = :1', $taskId)->fetch();
 | |
| 		$taskRow->update(array(
 | |
| 			'done' => 1,
 | |
| 			'done_timestamp' => $doneTime
 | |
| 		));
 | |
| 
 | |
| 		return true;
 | |
| 	}
 | |
| 
 | |
| 	private function TaskExists($taskId)
 | |
| 	{
 | |
| 		$taskRow = $this->Database->tasks()->where('id = :1', $taskId)->fetch();
 | |
| 		return $taskRow !== null;
 | |
| 	}
 | |
| }
 |