Bug gantt.config.xml_date?

Hi,
I have the strange problem and i don’t have idea.

If add task in date 2014-03-30 or 2014-03-31, my browser crash. I have no problem if add task after o before with two dates.

Here is my code:

gantt.config.duration_unit = 60*60*1000;
gantt.config.duration_step = 1; 
gantt.config.xml_date = "%Y-%m-%d %H:%i:%s";
gantt.config.scale_unit = "day";
gantt.config.step = 1;
gantt.config.date_scale = "%d %M";
gantt.config.subscales = [
{unit:"hour", step:1, date:"%H:%i"}
];
gantt.templates.scale_cell_class = function(date){
if(date.getDay()==0||date.getDay()==6){
return "weekend";
}
};
gantt.templates.task_cell_class = function(item,date){
if(date.getDay()==0||date.getDay()==6){
return "weekend"
}
};


gantt.config.lightbox.sections = [

  {name:"id_abaco", height:22, map_to:"id_abaco", type:"select", options: [ 
      {key:<?=$_REQUEST['id_abaco']?>, label: "<?=$_REQUEST['id_abaco']?>"}                                                 
   ]},     
  {name:"id_operaio", height:22, map_to:"id_operaio", type:"select", options: [ 
      <?=$operai_gantt?>                                                 
   ]},

  {name:"id_mezzo", height:22, map_to:"id_mezzo", type:"select", options: [ 
      <?=$mezzi_gantt?>                                                 
   ]},

  {name:"id_attrezzatura", height:22, map_to:"id_attrezzatura", type:"select", options: [ 
      <?=$attrezzatura_gantt?>                                                 
   ]},
   
  {name: "description", height: 70, map_to: "text", type: "textarea", focus: true},

  {name: "n_pezzi", height: 40, map_to: "n_pezzi", type: "textarea"},
  
  {name: "valore_unitario", height: 40, map_to: "valore_unitario", type: "textarea"},

  
  {name: "time", height: 80, type: "duration", map_to: "auto", time_format:["%d", "%m", "%Y", "%H:%i"]}
];

   
gantt.locale.labels.section_id_abaco = "ID Abaco";
gantt.locale.labels.section_id_operaio = "Collaboratore";
gantt.locale.labels.section_id_mezzo = "Mezzo";
gantt.locale.labels.section_id_attrezzatura = "Attrezzatura";

gantt.locale.labels.section_valore_unitario = "Valore UN";
gantt.locale.labels.section_n_pezzi = "N Pezzi";


gantt.config.columns=[
    {name:"text", label:"Task name",  tree:true, width:'250px' },
    {name:"n_pezzi", label:"N Pezzi", align:'center' },

    {name:"valore_unitario", label:"Valore UN",  align:'center' },

    {name:"start_date", label:"Start time", align: "center" },
    {name:"duration", label:"Duration", align: "center" },
    {name:"id_operaio", label:"Collaboratore", align: "center" },
    {name:"id_mezzo", label:"Mezzo", align: "center" },
    {name:"id_attrezzatura", label:"Attr.", align: "center" },

    {name:"add", label:"" }
];

gantt.config.grid_width = 750;
gantt.config.date_grid = "%d/%m/%y";
gantt.config.min_column_width = 40;
      
gantt.templates.progress_text = function(start, end, task){
	return "<span style='text-align:left;'>"+Math.round(task.progress*100)+ "% </span>";
};
      

gantt.config.order_branch = true;

gantt.init("gantt_here");
gantt.load("gantt/common/connector.php");
   

var dp = new dataProcessor("gantt/common/connector.php");
        

dp.defineAction("error",function(sid,response){
//var message = response.getAttribute("message");

alert("Il collaboratore selezionato è già impegnato nell'arco di tempo selezionato per questo task");

return false;// return false to cancel default data processing at all
})		
dp.init(gantt);

What’s happened? Thanks for reply

Hi,
can you provide an example of data you loading?
The package has a working example for loading data with end dates in similar format you have, please check it
docs.dhtmlx.com/gantt/samples/01 … ddate.html

I use startdate and duration, no end date

here is my connector.php

session_start();
include ('config.php');

$gantt = new JSONGanttConnector($res, $dbtype);

$gantt->mix("open", 0);
$gantt->enable_order("sortorder");




function myUpdate($action){
  $id = $action->get_value('id');       
  $id_operaio = $action->get_value('id_operaio');
  $start_date = $action->get_value('start_date');
  $duration = $action->get_value('duration');
  $id_mezzo = $action->get_value('id_mezzo');
  $id_attrezzatura = $action->get_value('id_attrezzatura');


$date = date_create($start_date);
date_add($date, date_interval_create_from_date_string("$duration hours"));
$finish_date = date_format($date, 'Y-m-d H:i:s');

if ($id_operaio!="---") {

$sql7 = "SELECT *
FROM gantt_tasks 
WHERE id_operaio LIKE '%$id_operaio%' and id != '$id'
and 
('$start_date' > start_date and '$start_date' < DATE_ADD(start_date,INTERVAL duration HOUR)
or '$finish_date' > start_date and '$finish_date' < DATE_ADD(start_date,INTERVAL duration HOUR))";
  $risultato7 = mysql_query($sql7) or die("Impossibile inserier finiture nel carrello");
       if (mysql_num_rows($risultato7)>0) {
            $action->error();
       } else {
          $sql8 = "SELECT *
          FROM gantt_tasks 
          WHERE id_operaio LIKE '%$id_operaio%' and id != '$id'
          and 
          ('$start_date' <= start_date 
          and '$finish_date' >= DATE_ADD(start_date,INTERVAL duration HOUR))";       
          $risultato8 = mysql_query($sql8) or die("Impossibile inserier finiture nel carrello");
          
          if (mysql_num_rows($risultato8)>0) {       
           $action->error();
          }
       }       
  }      
                 

if ($id_mezzo!="---") {

$sql7 = "SELECT *
FROM gantt_tasks 
WHERE id_mezzo LIKE '%$id_mezzo%' and id != '$id'
and 
('$start_date' > start_date and '$start_date' < DATE_ADD(start_date,INTERVAL duration HOUR)
or '$finish_date' > start_date and '$finish_date' < DATE_ADD(start_date,INTERVAL duration HOUR))";
  $risultato7 = mysql_query($sql7) or die("Impossibile inserier finiture nel carrello");
       if (mysql_num_rows($risultato7)>0) {
            $action->error();
       } else {
          $sql8 = "SELECT *
          FROM gantt_tasks 
          WHERE id_mezzo LIKE '%$id_mezzo%' and id != '$id'
          and 
          ('$start_date' <= start_date 
          and '$finish_date' >= DATE_ADD(start_date,INTERVAL duration HOUR))";       
          $risultato8 = mysql_query($sql8) or die("Impossibile inserier finiture nel carrello");
          
          if (mysql_num_rows($risultato8)>0) {       
           $action->error();
          }
       }       
  } 
  

if ($id_attrezzatura!="---") {

$sql7 = "SELECT *
FROM gantt_tasks 
WHERE id_attrezzatura LIKE '%$id_attrezzatura%' and id != '$id'
and 
('$start_date' > start_date and '$start_date' < DATE_ADD(start_date,INTERVAL duration HOUR)
or '$finish_date' > start_date and '$finish_date' < DATE_ADD(start_date,INTERVAL duration HOUR))";
  $risultato7 = mysql_query($sql7) or die("Impossibile inserier finiture nel carrello");
       if (mysql_num_rows($risultato7)>0) {
            $action->error();
       } else {
          $sql8 = "SELECT *
          FROM gantt_tasks 
          WHERE id_attrezzatura LIKE '%$id_attrezzatura%' and id != '$id'
          and 
          ('$start_date' <= start_date 
          and '$finish_date' >= DATE_ADD(start_date,INTERVAL duration HOUR))";       
          $risultato8 = mysql_query($sql8) or die("Impossibile inserier finiture nel carrello");
          
          if (mysql_num_rows($risultato8)>0) {       
           $action->error();
          }
       }       
  }   



} 
$gantt->event->attach("beforeUpdate","myUpdate");




$gantt->render_links("gantt_links", "id", "source,target,type");


if ($gantt->is_select_mode()) {//code for loading data
  $gantt->render_sql("Select * from gantt_tasks where id_abaco = '".$_SESSION["id_abaco_gantt"]."'","id","start_date,duration,text,progress,sortorder,parent,id_abaco,id_operaio,valore_unitario,n_pezzi,id_mezzo,id_attrezzatura");
}else{ //code for other operations - i.e. update/insert/delete
        $gantt->render_table("gantt_tasks","id","start_date,duration,text,progress,sortorder,parent,id_abaco,id_operaio,valore_unitario,n_pezzi,id_mezzo,id_attrezzatura");
}

Please provide a sample of JSON data (a response from connector.php file, that is loaded to the client-side).

{ “data”:[{“id”:“931”,“start_date”:“2014-03-30 12:00:00”,“duration”:“1”,“text”:"",“progress”:“0”,“sortorder”:“0”,“parent”:“0”,“id_abaco”:“4945”,“id_operaio”:“chiusa commessa”,“valore_unitario”:“0.00”,“n_pezzi”:“0”,“id_mezzo”:"—",“id_attrezzatura”:"—",“open”:0}], “collections”: {“links”:[]}}

Hello,
sorry for the inconvenience. The type of ‘duration_init’ setting has changed, and we didn’t mention that in the release notes.
Try changing this line:

gantt.config.duration_unit = 60*60*1000;

To this:

gantt.config.duration_unit = "hour";

Hello,
i try the code gantt.config.duration_unit = "hour"; but the problem is not solved. :cry:

Hello,
there must be something else that causes the problem. I’ve added your code (except for lightbox configuration which is dependant from server side variables and initialization of the data processor) to the page and used your data.
Gantt showed up without an error, I was also able to add tasks
screencast.com/t/C1r87PYeR

Can you provide a complete demo (page with all files required to run it and dump of the data), or a link to the page where it can be tested?

This link and this id_abaco is ok

http://www.kreisa.it/demo/?id_abaco=4342

This id with the date 2014-03-30 crash browser

http://www.kreisa.it/demo/index.php?id_abaco=4945

sorry try this link

OK:
http://www.kreisa.it/demo/index_5106.php

Crash Browser:
http://www.kreisa.it/demo/index_4945.php

Hello,
We’ve confirmed the problem. It is caused due to switch to Daylight Saving Time, which happens 30th March. We are going to release fix soon. For now please try the attached package
dhtmlxGantt_v2.1.1.zip (603 KB)

Hello, the problem is solved! Thanks :smiley:

Hi everyone.

I’m having the same issue. Fixed with the new version provided.

Just remember DST happens 2 times in a year!! :wink:

Thank you for your great job. This gantt is amazing!!