Add initial implementation of Simple Gantt chart and sample names list
- Created index.html for the Gantt chart with sample tasks and configurations. - Added styles for the Gantt chart and linked necessary CSS and JS files. - Introduced a names.txt file containing a list of names for potential use in the application.
This commit is contained in:
@@ -2,40 +2,15 @@
|
||||
namespace controls;
|
||||
class Tasks
|
||||
{
|
||||
static public function gantt_json() {
|
||||
static public function task_change_dates() {
|
||||
global $mdb;
|
||||
|
||||
$tasks = $mdb -> query( 'SELECT t.id, t.name, t.date_start, t.date_end, t.status, t.client_id FROM tasks AS t WHERE show_in_calendar = 1 AND status != 2 ORDER BY date_start ASC' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
foreach ( $tasks as $task ) {
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zmiany daty wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
|
||||
$class = '';
|
||||
if ( $task['status'] == 6 )
|
||||
$class = 'ganttGrey';
|
||||
elseif ( $task['status'] == 5 )
|
||||
$class = 'ganttRed';
|
||||
if ( \factory\Tasks::task_change_dates( \S::get( 'task_id' ), \S::get( 'date_start' ), \S::get( 'date_end' ) ) )
|
||||
$response = [ 'status' => 'success', 'msg' => 'Data została zmieniona.' ];
|
||||
|
||||
$task_json['name'] = $task['client_id'] ? \factory\Crm::get_client_name( (int)$task['client_id'] ) : $task['name'];
|
||||
$task_json['desc'] = 'Lorem ipsum dolor sit amet.';
|
||||
$task_json['id'] = $task['id'];
|
||||
$task_json['cssClass'] = 'redLabel';
|
||||
$task_json['values'] = [
|
||||
[
|
||||
'from' => $task['date_start'] . ' 08:00',
|
||||
'to' => $task['date_end'] . ' 16:00',
|
||||
'label' => $task['name'],
|
||||
'desc' => '',
|
||||
'customClass' => $class,
|
||||
'dataObj' => [
|
||||
'task_id' => $task['id'],
|
||||
]
|
||||
]
|
||||
];
|
||||
$data[] = $task_json;
|
||||
}
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Zwróć dane jako JSON
|
||||
echo json_encode($data);
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -195,6 +170,7 @@ class Tasks
|
||||
'show_tasks_bulk' => $show_tasks_bulk,
|
||||
'show_tasks_to_review' => $show_tasks_to_review,
|
||||
'users' => \factory\Users::users_list(),
|
||||
'tasks_gantt' => \factory\Tasks::get_tasks_gantt(),
|
||||
] );
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,46 @@ class Tasks
|
||||
{
|
||||
public static $statuses = [ 0 => 'nowe', 3 => 'do rozliczenia', 5 => 'do zrobienia', 4 => 'zaplanowane', 1 => 'do sprawdzenia', 6 => 'faktury', 2 => 'zamknięte' ];
|
||||
|
||||
static public function task_change_dates( $task_id, $date_start, $date_end )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$task_id )
|
||||
return false;
|
||||
|
||||
return $mdb -> update( 'tasks', [
|
||||
'date_start' => $date_start,
|
||||
'date_end' => $date_end
|
||||
], [
|
||||
'id' => $task_id
|
||||
] );
|
||||
}
|
||||
|
||||
static public function get_tasks_gantt() {
|
||||
global $mdb;
|
||||
|
||||
$tasks = $mdb -> query( 'SELECT t.id, t.name, t.date_start, t.date_end, t.status, t.client_id FROM tasks AS t WHERE show_in_calendar = 1 AND status != 2 ORDER BY date_start ASC' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
foreach ( $tasks as $task ) {
|
||||
$task_json = [];
|
||||
$task_json['name'] = $task['client_id'] ? \factory\Crm::get_client_name( (int)$task['client_id'] ) : $task['name'];
|
||||
// start
|
||||
$task_json['start'] = $task['date_start'];
|
||||
// end
|
||||
$task_json['end'] = $task['date_end'];
|
||||
// id
|
||||
$task_json['id'] = $task['id'];
|
||||
// custom class
|
||||
if ( $task['date_start'] <= date( 'Y-m-d H:i:s' ) )
|
||||
$task_json['custom_class'] = 'gantt-task-backlog';
|
||||
// progress
|
||||
$task_json['progress'] = 0;
|
||||
|
||||
$data[] = $task_json;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
static public function work_delete( $work_id ) {
|
||||
global $mdb;
|
||||
return $mdb -> update( 'tasks_work', [ 'deleted' => 1 ], [ 'id' => $work_id ] );
|
||||
|
||||
Reference in New Issue
Block a user