[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 <?php 2 /********************************************************************************* 3 ** The contents of this file are subject to the vtiger CRM Public License Version 1.0 4 * ("License"); You may not use this file except in compliance with the License 5 * The Original Code is: vtiger CRM Open Source 6 * The Initial Developer of the Original Code is vtiger. 7 * Portions created by vtiger are Copyright (C) vtiger. 8 * All Rights Reserved. 9 * 10 ********************************************************************************/ 11 ?> 12 <html> 13 <body> 14 <script> 15 if (document.layers) 16 { 17 document.write("This feature requires IE 5.5 or higher for Windows on Microsoft Windows 2000, Windows NT4 SP6, Windows XP."); 18 document.write("<br><br>Click <a href='#' onclick='window.history.back();'>here</a> to return to the previous page"); 19 } 20 else if (document.layers || (!document.all && document.getElementById)) 21 { 22 document.write("This feature requires IE 5.5 or higher for Windows on Microsoft Windows 2000, Windows NT4 SP6, Windows XP."); 23 document.write("<br><br>Click <a href='#' onclick='window.history.back();'>here</a> to return to the previous page"); 24 } 25 else if(document.all) 26 { 27 document.write("<OBJECT Name='vtigerCRM' codebase='modules/Settings/vtigerCRM.CAB#version=1,5,0,0' id='objMMPage' classid='clsid:0FC436C2-2E62-46EF-A3FB-E68E94705126' width=0 height=0></object>"); 28 } 29 </script> 30 <?php 31 require_once ('include/database/PearDatabase.php'); 32 require_once ('config.php'); 33 34 $templateid = $_REQUEST['mergefile']; 35 if($templateid == "") 36 { 37 die("Select Mail Merge Template"); 38 } 39 //get the particular file from db and store it in the local hard disk. 40 //store the path to the location where the file is stored and pass it as parameter to the method 41 $sql = "select filename,data,filesize from vtiger_wordtemplates where templateid=".$templateid; 42 43 $result = $adb->query($sql); 44 $temparray = $adb->fetch_array($result); 45 46 $fileContent = $temparray['data']; 47 $filename=$temparray['filename']; 48 $filesize=$temparray['filesize']; 49 $wordtemplatedownloadpath =$root_directory ."/test/wordtemplatedownload/"; 50 51 52 $handle = fopen($wordtemplatedownloadpath .$temparray['filename'],"wb"); 53 fwrite($handle,base64_decode($fileContent),$filesize); 54 fclose($handle); 55 56 //for mass merge 57 $mass_merge = $_REQUEST['idlist']; 58 $single_record = $_REQUEST['record']; 59 60 if($mass_merge != "") 61 { 62 $mass_merge = explode(";",$mass_merge); 63 //array_pop($mass_merge); 64 $temp_mass_merge = $mass_merge; 65 if(array_pop($temp_mass_merge)=="") 66 array_pop($mass_merge); 67 $mass_merge = implode(",",$mass_merge); 68 }else if($single_record != "") 69 { 70 $mass_merge = $single_record; 71 }else 72 { 73 die("Record Id is not found"); 74 } 75 76 //<<<<<<<<<<<<<<<<header for csv and select columns for query>>>>>>>>>>>>>>>>>>>>>>>> 77 $query1="select tablename,columnname,fieldlabel from vtiger_field where tabid=7 order by tablename"; 78 $result = $adb->query($query1); 79 $y=$adb->num_rows($result); 80 81 for ($x=0; $x<$y; $x++) 82 { 83 $tablename = $adb->query_result($result,$x,"tablename"); 84 $columnname = $adb->query_result($result,$x,"columnname"); 85 $querycolumns[$x] = $tablename.".".$columnname; 86 if($columnname == "smownerid") 87 { 88 $querycolumns[$x] = "concat(vtiger_users.last_name,' ',vtiger_users.first_name) as username,vtiger_users.first_name,vtiger_users.last_name,vtiger_users.user_name,vtiger_users.yahoo_id,vtiger_users.title,vtiger_users.phone_work,vtiger_users.department,vtiger_users.phone_mobile,vtiger_users.phone_other,vtiger_users.phone_fax,vtiger_users.email1,vtiger_users.phone_home,vtiger_users.email2,vtiger_users.address_street,vtiger_users.address_city,vtiger_users.address_state,vtiger_users.address_postalcode,vtiger_users.address_country"; 89 } 90 $field_label[$x] = "LEAD_".strtoupper(str_replace(" ","",$adb->query_result($result,$x,"fieldlabel"))); 91 if($columnname == "smownerid") 92 { 93 $field_label[$x] = $field_label[$x].",USER_FIRSTNAME,USER_LASTNAME,USER_USERNAME,USER_YAHOOID,USER_TITLE,USER_OFFICEPHONE,USER_DEPARTMENT,USER_MOBILE,USER_OTHERPHONE,USER_FAX,USER_EMAIL,USER_HOMEPHONE,USER_OTHEREMAIL,USER_PRIMARYADDRESS,USER_CITY,USER_STATE,USER_POSTALCODE,USER_COUNTRY"; 94 } 95 } 96 $csvheader = implode(",",$field_label); 97 //<<<<<<<<<<<<<<<<End>>>>>>>>>>>>>>>>>>>>>>>> 98 99 if(count($querycolumns) > 0) 100 { 101 $selectcolumns = implode($querycolumns,","); 102 103 $query = "select ".$selectcolumns." from vtiger_leaddetails 104 inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_leaddetails.leadid 105 inner join vtiger_leadsubdetails on vtiger_leadsubdetails.leadsubscriptionid=vtiger_leaddetails.leadid 106 inner join vtiger_leadaddress on vtiger_leadaddress.leadaddressid=vtiger_leadsubdetails.leadsubscriptionid 107 inner join vtiger_leadscf on vtiger_leaddetails.leadid = vtiger_leadscf.leadid 108 left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid 109 where vtiger_crmentity.deleted=0 and vtiger_leaddetails.leadid in (".$mass_merge.")"; 110 111 $result = $adb->query($query); 112 113 while($columnValues = $adb->fetch_array($result)) 114 { 115 $y=$adb->num_fields($result); 116 for($x=0; $x<$y; $x++) 117 { 118 $value = $columnValues[$x]; 119 //<<<<<<<<<<<<<<< For Blank Fields >>>>>>>>>>>>>>>>>>>>>>>>>>>> 120 if($value == "0") 121 { 122 $value = ""; 123 } 124 if(trim($value) == "--None--" || trim($value) == "--none--") 125 { 126 $value = ""; 127 } 128 //<<<<<<<<<<<<<<< End >>>>>>>>>>>>>>>>>>>>>>>>>>>> 129 $actual_values[$x] = $value; 130 $actual_values[$x] = str_replace('"'," ",$actual_values[$x]); 131 //if value contains any line feed or carriage return replace the value with ".value." 132 if (preg_match ("/(\r\n)/", $actual_values[$x])) 133 { 134 $actual_values[$x] = '"'.$actual_values[$x].'"'; 135 } 136 $actual_values[$x] = str_replace(","," ",$actual_values[$x]); 137 } 138 $mergevalue[] = implode($actual_values,","); 139 } 140 $csvdata = implode($mergevalue,"###"); 141 }else 142 { 143 die("No vtiger_fields to do Merge"); 144 } 145 146 $handle = fopen($wordtemplatedownloadpath."datasrc.csv","wb"); 147 fwrite($handle,$csvheader."\r\n"); 148 fwrite($handle,str_replace("###","\r\n",$csvdata)); 149 fclose($handle); 150 151 ?> 152 153 <script> 154 if (window.ActiveXObject){ 155 try 156 { 157 ovtigerVM = eval("new ActiveXObject('vtigerCRM.ActiveX');"); 158 if(ovtigerVM) 159 { 160 var filename = "<?php echo $filename?>"; 161 if(filename != "") 162 { 163 if(objMMPage.bDLTempDoc("<?php echo $site_URL?>/test/wordtemplatedownload/<?php echo $filename?>","MMTemplate.doc")) 164 { 165 try 166 { 167 if(objMMPage.Init()) 168 { 169 objMMPage.vLTemplateDoc(); 170 objMMPage.bBulkHDSrc("<?php echo $site_URL;?>/test/wordtemplatedownload/datasrc.csv"); 171 objMMPage.vBulkOpenDoc(); 172 objMMPage.UnInit() 173 window.history.back(); 174 } 175 }catch(errorObject) 176 { 177 document.write("Error while processing mail merge operation"); 178 } 179 }else 180 { 181 document.write("Cannot get template document"); 182 } 183 } 184 } 185 } 186 catch(e) { 187 document.write("Requires to download ActiveX Control from vtigerCRM. Please, ensure that you have administration privilage"); 188 } 189 } 190 </script> 191 </body> 192 </html>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |