pquery($sql, array($mergeFileName));
$temparray = $adb->fetch_array($result);
$fileContent = $temparray['data'];
$filename=html_entity_decode($temparray['filename'], ENT_QUOTES, $default_charset);
// Fix For: http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/2107
$filename= $randomfilename . "_word.doc";
$filesize=$temparray['filesize'];
$wordtemplatedownloadpath =$_SERVER['DOCUMENT_ROOT'] ."/test/wordtemplatedownload/";
checkFileAccess($wordtemplatedownloadpath);
$handle = fopen($wordtemplatedownloadpath .$filename,"wb") ;
fwrite($handle,base64_decode($fileContent),$filesize);
fclose($handle);
$query = "SELECT * FROM " .$adb->sql_escape_string($_REQUEST["module"]) ." WHERE id = ?";
$result = $adb->pquery($query, array($_REQUEST['record']));
$y=$adb->num_fields($result);
for ($x=0; $x<$y; $x++)
{
$columnNames[$x] = "CONTACT_".strtoupper($adb->field_name($result, $x));
}
$columnValues = $adb->fetch_array($result);
for ($x=0; $x<$y; $x++)
{
$columnValString[$x] = $columnValues[$x];
}
$columnString = implode(",",$columnNames);
$columnValString = implode(",",$columnValString);
echo"";
?>