mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Add filters for task start date
This commit is contained in:
parent
5fff511869
commit
a028456a09
@ -101,9 +101,6 @@ class TaskRepository extends BaseRepository
|
||||
$key_values = array_column($time_log, 0);
|
||||
array_multisort($key_values, SORT_ASC, $time_log);
|
||||
|
||||
// array_multisort($time_log);
|
||||
// ksort($time_log);
|
||||
|
||||
if (isset($data['action'])) {
|
||||
if ($data['action'] == 'start') {
|
||||
$task->is_running = true;
|
||||
@ -121,8 +118,12 @@ class TaskRepository extends BaseRepository
|
||||
$task->is_running = $data['is_running'] ? 1 : 0;
|
||||
}
|
||||
|
||||
$task->calculated_start_date = $this->harvestStartDate($time_log);
|
||||
|
||||
$task->time_log = json_encode($time_log);
|
||||
|
||||
|
||||
|
||||
$task->saveQuietly();
|
||||
|
||||
if (array_key_exists('documents', $data)) {
|
||||
@ -132,6 +133,17 @@ class TaskRepository extends BaseRepository
|
||||
return $task;
|
||||
}
|
||||
|
||||
private function harvestStartDate($time_log)
|
||||
{
|
||||
|
||||
if(isset($time_log[0][0])){
|
||||
return \Carbon\Carbon::createFromTimestamp($time_log[0][0]);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Store tasks in bulk.
|
||||
*
|
||||
@ -199,8 +211,12 @@ class TaskRepository extends BaseRepository
|
||||
if (strlen($task->time_log) < 5) {
|
||||
$log = [];
|
||||
|
||||
$log = array_merge($log, [[time(), 0]]);
|
||||
$start_time = time();
|
||||
|
||||
$log = array_merge($log, [[$start_time, 0]]);
|
||||
$task->time_log = json_encode($log);
|
||||
$task->calculated_start_date = \Carbon\Carbon::createFromTimestamp($start_time);
|
||||
|
||||
$task->saveQuietly();
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('tasks', function (Blueprint $table) {
|
||||
$table->date('calculated_start_date')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
};
|
@ -31,6 +31,8 @@ class TaskApiTest extends TestCase
|
||||
use DatabaseTransactions;
|
||||
use MockAccountData;
|
||||
|
||||
private $faker;
|
||||
|
||||
protected function setUp() :void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -100,6 +102,20 @@ class TaskApiTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function testStartDate()
|
||||
{
|
||||
$x = [];
|
||||
|
||||
$this->assertFalse(isset($x[0][0]));
|
||||
|
||||
$x[0][0] = 'a';
|
||||
|
||||
$this->assertTrue(isset($x[0][0]));
|
||||
|
||||
$this->assertNotNull(\Carbon\Carbon::createFromTimestamp($x[0][0]));
|
||||
|
||||
}
|
||||
|
||||
public function testMultiSortArray()
|
||||
{
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user