diff --git a/dev/skeletons/build_class_from_table.php b/dev/skeletons/build_class_from_table.php index d1ecc82e268..ff045901041 100644 --- a/dev/skeletons/build_class_from_table.php +++ b/dev/skeletons/build_class_from_table.php @@ -226,7 +226,7 @@ foreach($property as $key => $prop) $varprop.="\t\t\$sql.= \" "; if ($prop['istime']) { - $varprop.='".(! isset($this->'.$prop['field'].') || strval($this->'.$prop['field'].')==\'\'?\'NULL\':$this->db->idate('; + $varprop.='".(! isset($this->'.$prop['field'].') || strlen($this->'.$prop['field'].')==0?\'NULL\':$this->db->idate('; $varprop.="\$this->".$prop['field'].""; $varprop.='))."'; if ($i < sizeof($property)) $varprop.=","; @@ -267,8 +267,8 @@ foreach($property as $key => $prop) $varprop.=$prop['field'].'='; if ($prop['istime']) { - // (strval($this->datep)!='' ? "'".$this->db->idate($this->datep)."'" : 'null') - $varprop.='".(strval($this->'.$prop['field'].')!=\'\' ? "\'".$this->db->idate('; + // (strlen($this->datep)!=0 ? "'".$this->db->idate($this->datep)."'" : 'null') + $varprop.='".(strlen($this->'.$prop['field'].')!=0 ? "\'".$this->db->idate('; $varprop.='$this->'.$prop['field']; $varprop.=')."\'" : \'null\').'; $varprop.='"'; diff --git a/htdocs/contrat/contrat.class.php b/htdocs/contrat/contrat.class.php index b3fc67f16e7..32c13bb9f2b 100644 --- a/htdocs/contrat/contrat.class.php +++ b/htdocs/contrat/contrat.class.php @@ -100,8 +100,8 @@ class Contrat extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = 4,"; - $sql.= " date_ouverture = '".$this->db->idate($date)."',"; - if ($date_end) $sql.= " date_fin_validite = '".$this->db->idate($date_end)."',"; + $sql.= " date_ouverture = ".(strlen($date)!=0?"'".$this->db->idate($date)."'":"null").","; + $sql.= " date_fin_validite = ".(strlen($date_end)!=0?"'".$this->db->idate($date_end)."'":"null").","; $sql.= " fk_user_ouverture = ".$user->id.","; $sql.= " date_cloture = null"; $sql.= " WHERE rowid = ".$line_id . " AND (statut = 0 OR statut = 3 OR statut = 5)";