$length) { $string = substr($string, 0, $length); } } function add_to_history($table,$id,$field,$value) { error_reporting(0); $z="select id from ecmhistory where field_name='".$field."' and field_value='".$value."' and table_id='".$id."' and table_name='".$table."' order by date_modified desc limit 1"; $w=mysql_query($z); $r=mysql_fetch_array($w); $fn=$r['field_value']; if($fn!=$field) { if($value)mysql_query("insert into ecmhistory(id,table_name,table_id,field_name,field_value,date_modified) values('".create_guid1()."','".$table."','".$id."','".$field."','".$value."','".date("Y-m-d H:i:s")."')"); } } function display_history($table,$id,$field) { $html=""; $z="select field_value,date_modified from ecmhistory where table_name='".$table."' and table_id='".$id."' and field_name='".$field."' order by date_modified asc"; $w=mysql_query($z); while($r=mysql_fetch_array($w)) { if($field=="assigned_user_id") { $rr=mysql_fetch_array(mysql_query("select user_name from users where id='".$r['field_value']."' and status='Active'")); $f=$rr['user_name']; } else $f=$r['field_value']; if($f)$html.="
".$r['date_modified']." - ".$f."
"; } return $html; } ?>