Delay days are displayed on the Gantt chart

Hello,
I am a newbie and have just been studying for a week.
I have a few questions, please help.

  1. How to enter the actual completion date on the taskbar, the different colors and delay days are displayed on the Gantt chart.
  2. How to write the end date back to the database.
  3. Display tasks after search conditions.

Thanks!!

Hello Kevin,

How to enter the actual completion date on the taskbar, the different colors and delay days are displayed on the Gantt chart.

You can change the time control in the lightbox and display both start_date and end_date:
https://docs.dhtmlx.com/gantt/desktop__time.html
Here is an example:
https://docs.dhtmlx.com/gantt/samples/05_lightbox/07_time.html

There are several ways of how to colorize tasks. Please, check the following article:
https://docs.dhtmlx.com/gantt/desktop__colouring_tasks.html

Here are the examples:
https://snippet.dhtmlx.com/b9be92972
http://snippet.dhtmlx.com/10c4986ee
http://snippet.dhtmlx.com/e855e1977
https://snippet.dhtmlx.com/3cb799a16
http://snippet.dhtmlx.com/66111aa93
http://snippet.dhtmlx.com/82ebe840a

Please, clarify what kind of delay days you mean.

How to write the end date back to the database.

It depends on the backend and the database. Usually, you can use the Data processor:
https://docs.dhtmlx.com/dataprocessor__index.html
https://docs.dhtmlx.com/gantt/desktop__filtering.html
You can check the guides for the backend configuration:
https://docs.dhtmlx.com/gantt/desktop__howtostart_guides.html

Display tasks after search conditions.

You can do that by using onBeforeTaskDisplay event handler:
https://docs.dhtmlx.com/gantt/api__gantt_onbeforetaskdisplay_event.html
https://docs.dhtmlx.com/gantt/desktop__filtering.html

Please, check the following examples:
https://docs.dhtmlx.com/gantt/samples/07_grid/03_filtering.html
https://snippet.dhtmlx.com/9f24ffdef
https://snippet.dhtmlx.com/62a932277
https://snippet.dhtmlx.com/88bcce46a

Hello Ramil,
Thank you for your reply, I will study, thank you very much.

Hello Ramil,

I modified gantt.php, and can not achieve the end date to write to the database, the database I added a field end_date, please help me, thank you.

function addTask($request, $response, $args) {
$task = getTask($request->getParsedBody());
$db = getConnection();

$maxOrderQuery = "SELECT MAX(sortorder) AS maxOrder FROM gantt_tasks";
$statement = $db->prepare($maxOrderQuery);
$statement->execute();

$maxOrder = $statement->fetchColumn();
if(!$maxOrder)
	$maxOrder = 0;

$task[":sortorder"] = $maxOrder + 1;

$query = "INSERT INTO gantt_tasks(text, start_date,duration, progress, parent, sortorder) ".
	"VALUES (:text,:start_date,:duration,:progress,:parent, :sortorder)";
$db->prepare($query)->execute($task);

return $response->withJson([
	"action"=>"inserted",
	"tid"=> $db->lastInsertId()
]);

}

// update task
function updateTask($request, $response, $args) {
$sid = $request->getAttribute(“id”);
$params = $request->getParsedBody();/!/
$task = getTask($params);
$db = getConnection();
$query = "UPDATE gantt_tasks ".
"SET text = :text, start_date = :start_date, duration = :duration, progress = :progress, parent = :parent ".
“WHERE id = :sid”;

$db->prepare($query)->execute(array_merge($task, [":sid"=>$sid]));

if(isset($params["target"]) && $params["target"])/*!*/
	updateOrder($sid, $params["target"], $db);

return $response->withJson([
	"action"=>"updated"
]);

}

Hello Kevin,
You need to add the end_date field to that file, but you need to do that in the column order. For example, if you have the following order in the database:

+----+------+------------+----------+----------+----------+--------+-----------+
| id | text | start_date | end_date | duration | progress | parent | sortorder |
+----+------+------------+----------+----------+----------+--------+-----------+

You need to add the field this way:

$query = "INSERT INTO gantt_tasks(text, start_date,end_date,duration, progress, parent, sortorder) ".
	"VALUES (:text,:start_date,:end_date,:duration,:progress,:parent, :sortorder)";
 "SET text = :text, start_date = :start_date, end_date = :end_date, duration = :duration, progress = :progress, parent = :parent ".

Hello Ramil,
After modifying gantt.php, all tasks can’t be added, always showing bold, reloading the web task and emptying it. Is there anything I am doing wrong?
Slides2
Slides1

function addTask($request, $response, $args) {
$task = getTask($request->getParsedBody());
$db = getConnection();

$maxOrderQuery = "SELECT MAX(sortorder) AS maxOrder FROM gantt_tasks";
$statement = $db->prepare($maxOrderQuery);
$statement->execute();

$maxOrder = $statement->fetchColumn();
if(!$maxOrder)
	$maxOrder = 0;

$task[":sortorder"] = $maxOrder + 1;

$query = "INSERT INTO gantt_tasks(text, start_date,end_date,duration, progress, parent, sortorder) ".
"VALUES (:text,:start_date,:end_date,:duration,:progress,:parent, :sortorder)";
$db->prepare($query)->execute($task);

return $response->withJson([
	"action"=>"inserted",
	"tid"=> $db->lastInsertId()
]);

}

// update task
function updateTask($request, $response, $args) {
$sid = $request->getAttribute(“id”);
$params = $request->getParsedBody();/!/
$task = getTask($params);
$db = getConnection();
$query = "UPDATE gantt_tasks ".
"SET text = :text, start_date = :start_date, end_date = :end_date, duration = :duration, progress = :progress, parent = :parent ".
“WHERE id = :sid”;

$db->prepare($query)->execute(array_merge($task, [":sid"=>$sid]));

if(isset($params["target"]) && $params["target"])/*!*/
	updateOrder($sid, $params["target"], $db);

return $response->withJson([
	"action"=>"updated"
]);

}

Hello Kevin,
The configuration you sent should be correct, but maybe there is something wrong in other configuration files. Please, send me your full project so that I can reproduce the issue locally and I will check that everything is correct outside the database.

You can also check if the issue is on the server side:

  1. Open the web console on the network tab.
  2. Clear all messages there.
  3. Create a task.
  4. Check that there is a request about sending the data.
  5. If there is the request, click on it and send me the screenshot.
    http://prnt.sc/n43i5r