[ 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 13 require_once ('include/utils/utils.php'); 14 require_once 'Excel/reader.php'; 15 require_once ('modules/Users/Users.php'); 16 require_once ('include/database/PearDatabase.php'); 17 18 $data = new Spreadsheet_Excel_Reader(); 19 $data->setOutputEncoding('CP1251'); 20 global $log; 21 $filename = $HTTP_GET_VARS['filename']; 22 $log->info("filename is ".$filename); 23 //$filename = $_REQUEST['filename']; 24 $data->read($filename); 25 26 //echo 'First Name'; 27 28 $firstname = $HTTP_POST_VARS['First_Name']; 29 30 $log->info("firstname is ".$firstname); 31 $lastname = $HTTP_POST_VARS['Last_Name']; 32 33 $log->info("lastname is ".$lastname); 34 $phone = $HTTP_POST_VARS['Phone']; 35 $log->info("phone is ".$phone); 36 $mobile = $HTTP_POST_VARS['Mobile']; 37 $log->info("mobile is ".$mobile); 38 39 $company = $HTTP_POST_VARS['Company']; 40 $log->info("company is ".$company); 41 //echo $company; 42 43 $fax = $HTTP_POST_VARS['Fax']; 44 $log->info("fax is ".$fax); 45 46 $designation = $HTTP_POST_VARS['Designation']; 47 48 $log->info("designation is ".$designation); 49 $email = $HTTP_POST_VARS['Email']; 50 51 $log->info("email is ".$email); 52 $salutation = $HTTP_POST_VARS['Salutation']; 53 //not being used 54 55 $log->info("salutation is ".$salutation); 56 //echo 'LeadSource'; 57 $leadsource = $HTTP_POST_VARS['LeadSource']; 58 59 $log->info("leadsource is ".$leadsource); 60 $website = $HTTP_POST_VARS['Website']; 61 $log->info("website is ".$website); 62 //echo 'Industry'; 63 $industry = $HTTP_POST_VARS['Industry']; 64 $log->info("industry is ".$industry); 65 //echo $industry; 66 67 //echo 'LeadStatus'; 68 $leadstatus = $HTTP_POST_VARS['LeadStatus']; 69 $log->info("leadstatus is ".$leadstatus); 70 //echo $leadstatus; 71 72 //echo 'AnnualRevenue'; 73 $annualrevenue = $HTTP_POST_VARS['Annual_Revenue']; 74 $log->info("annualrevenue is ".$annualrevenue); 75 //echo $annualrevenue; 76 77 78 //echo 'Rating'; 79 $rating = $HTTP_POST_VARS['Rating']; 80 //echo $rating; 81 82 83 //echo 'LicenseKey'; 84 $licensekey = $HTTP_POST_VARS['License_Key']; 85 //echo $licensekey; 86 87 //echo 'EmpCount'; 88 $employeecount = $HTTP_POST_VARS['Number_of_Employees']; 89 //echo $employeecount; 90 91 //echo 'Assto'; 92 $assignedto = $HTTP_POST_VARS['Assigned_To']; 93 //echo $assignedto; 94 95 96 //echo 'yahooid'; 97 $yahooid = $HTTP_POST_VARS['Yahoo_ID']; 98 //echo $yahooid; 99 100 101 //echo 'Street'; 102 $street = $HTTP_POST_VARS['Street']; 103 //echo 'Postal'; 104 $postalcode = $HTTP_POST_VARS['Postal_Code']; 105 //echo $postalcode; 106 107 //echo 'City'; 108 $city = $HTTP_POST_VARS['City']; 109 //echo $city; 110 111 //echo 'COuntry'; 112 $country = $HTTP_POST_VARS['Country']; 113 //echo $country; 114 $description = $HTTP_POST_VARS['Description']; 115 //echo $description; 116 $stage = $HTTP_POST_VARS['Stage']; 117 //echo $description; 118 function deleteFile($filename) 119 { 120 global $log; 121 $log->debug("Entering deleteFile(".$filename.") method ..."); 122 unlink($filename); 123 $log->debug("Exiting deleteFile method ..."); 124 } 125 126 127 for($i=2;$i<=$data->sheets[0]['numRows']; $i++) 128 { 129 130 $value_firstname = $data->sheets[0]['cells'][$i][$firstname]; 131 $value_lastname = $data->sheets[0]['cells'][$i][$lastname]; 132 $value_company = $data->sheets[0]['cells'][$i][$company]; 133 $value_salutation = $data->sheets[0]['cells'][$i][$salutation]; 134 $value_email = $data->sheets[0]['cells'][$i][$email]; 135 $value_phone = $data->sheets[0]['cells'][$i][$phone]; 136 $value_fax = $data->sheets[0]['cells'][$i][$fax]; 137 $value_mobile = $data->sheets[0]['cells'][$i][$mobile]; 138 //echo 'mobile ' .$value_mobile; 139 $value_designation = $data->sheets[0]['cells'][$i][$designation]; 140 //echo 'designation ' .$value_designation; 141 $value_website= $data->sheets[0]['cells'][$i][$website]; 142 //echo 'websiteval ' .$value_website; 143 $value_leadsource = $data->sheets[0]['cells'][$i][$leadsource]; 144 $value_industry = $data->sheets[0]['cells'][$i][$industry]; 145 //echo 'industry ' .$value_industry; 146 $value_leadstatus = $data->sheets[0]['cells'][$i][$leadstatus]; 147 //echo 'leadstatus ' .$value_leadstatus; 148 $value_annualrevenue = $data->sheets[0]['cells'][$i][$annualrevenue]; 149 //echo 'annualrevenue ' .$value_annualrevenue; 150 $value_rating = $data->sheets[0]['cells'][$i][$rating]; 151 //echo 'rating ' .$value_rating; 152 $value_licensekey = $data->sheets[0]['cells'][$i][$licensekey]; 153 //echo 'licensekey ' .$value_licensekey; 154 $value_employeecount = $data->sheets[0]['cells'][$i][$employeecount]; 155 //echo 'employees ' .$value_employeecount; 156 $value_assignedto = $data->sheets[0]['cells'][$i][$assignedto]; 157 $value_yahooid = $data->sheets[0]['cells'][$i][$yahooid]; 158 //echo 'yahooid ' .$value_yahooid; 159 $value_street = $data->sheets[0]['cells'][$i][$street]; 160 //echo 'street ' .$value_street; 161 $value_postalcode = $data->sheets[0]['cells'][$i][$postalcode]; 162 //echo 'postalcode ' .$value_postalcode; 163 $value_city = $data->sheets[0]['cells'][$i][$city]; 164 //echo 'city ' .$value_city; 165 $value_country = $data->sheets[0]['cells'][$i][$country]; 166 //echo 'country ' .$value_country; 167 $value_description = $data->sheets[0]['cells'][$i][$description]; 168 //echo 'description ' .$value_description; 169 $value_stage = $data->sheets[0]['cells'][$i][$stage]; 170 //echo 'stage ' .$value_stage; 171 $id = insert2DB($value_salutation,$value_firstname,$value_lastname,$value_company,$value_designation,$value_leadsource,$value_industry,$value_annualrevenue,$value_licensekey,$value_phone,$value_mobile,$value_fax,$value_email,$value_yahooid,$value_website,$value_leadstatus,$value_rating,$value_employeecount); 172 //Inserting Custom Field Values 173 $dbquery="select * from customfields where module='Leads'"; 174 $custresult = $adb->query($dbquery); 175 if($adb->num_rows($custresult) != 0) 176 { 177 $noofrows = $adb->num_rows($custresult); 178 $columns=''; 179 $values=''; 180 for($j=0; $j<$noofrows; $j++) 181 { 182 $fldLabel=$adb->query_result($custresult,$j,"fieldlabel"); 183 $colName=$adb->query_result($custresult,$j,"column_name"); 184 $colNameMapping = $HTTP_POST_VARS[$colName]; 185 $value_colName = $data->sheets[0]['cells'][$i][$colNameMapping]; 186 187 if($j == 0) 188 { 189 $columns='leadid, '.$colName; 190 $values='"'.$id.'", "'.$value_colName.'"'; 191 } 192 else 193 { 194 $columns .= ', '.$colName; 195 $values .= ', "'.$value_colName.'"'; 196 } 197 } 198 $insert_custfld_query = 'insert into leadcf ('.$columns.') values('.$values.')'; 199 $adb->query($insert_custfld_query); 200 } 201 202 } 203 204 deleteFile($filename); 205 206 function insert2DB($salutation,$firstname,$lastname,$company,$designation,$leadsrc,$industry,$annualrevenue,$licensekey,$phone,$mobile,$fax,$email,$yahooid,$website,$leadstatus,$rating,$empct) 207 { 208 global $log; 209 $log->debug("Entering insert2DB(".$salutation.",".$firstname.",".$lastname.",".$company.",".$designation.",".$leadsrc.",".$industry.",".$annualrevenue.",".$licensekey.",".$phone.",".$mobile.",".$fax.",".$email.",".$yahooid.",".$website.",".$leadstatus.",".$rating.",".$empct.") method ..."); 210 $id = create_guid(); 211 $date_entered = date('YmdHis'); 212 $date_modified = date('YmdHis'); 213 global $current_user; 214 215 $modified_user_id = $current_user->id; 216 $assigned_user_id = $current_user->id; 217 $sql = "INSERT INTO leads (id,date_entered,date_modified,modified_user_id,assigned_user_id,salutation,first_name,last_name,company,designation,lead_source,industry,annual_revenue,license_key,phone,mobile,fax,email,yahoo_id,website,lead_status,rating,employees) VALUES ('$id',".$adb->formatString('leads','date_entered',$date_entered).",".$adb->formatString('leads','date_modified',$date_modified).",'$modified_user_id','$assigned_user_id','$salutation','$firstname','$lastname','$company','$designation','$leadsrc','$industry','$annualrevenue','$licensekey','$phone','$mobile','$fax','$email','$yahooid','$website','$leadstatus','$rating','$empcount')"; 218 219 $result = $adb->query($sql); 220 $log->debug("Exiting insert2DB method ..."); 221 return $id; 222 223 } 224 225 header("Location: index.php?module=Leads&action=index"); 226 // echo 'Thank You! Your data has been stored! <br> 227 // <a href="index.php?module=Leads&action=index">Continue</a>'; 228 ?>
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 |