Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Richard Trussler
Added: Mar 21, 2018 3:00 PM
Views: 14
Tags: no tags
  1.      public function createCSVandEmail($result){
  2.               var_dump($result);
  3.               // die();
  4.                 $filename = date('d-m-Y') . "_taggingData.csv";
  5.                // $live_absolute_path = "var/www/html/themes/sainsburys/export/" . $filename;
  6.                 $live_absolute_path = '/' . $filename;
  7.                 // $live_absolute_path = yii::app()->basePath . "/themes/" . $filename;
  8.                 // $test_absolute_path = "/home/sscgiirp/public_html/themes/sainsburys/export/" . $filename;
  9.                 // $test_download_path = "http://sainsburys.giirp.com/themes/sainsburys/export/" . $filename;
  10.  
  11.                 $fp = fopen($live_absolute_path , 'w');
  12.  
  13.                 fputcsv($fp, array_keys($result[0]));
  14.  
  15.                 foreach ($result as $fields) {
  16.                     fputcsv($fp, $fields);
  17.                 }
  18.  
  19.                 fclose($fp);
  20.                 // rename('/'. $filename, '/var/www/html/themes/sainsburys/export/'.$filename );
  21.  
  22. //                $message = "Hi Terry," . "\r\n" .
  23. //                        "you can access the latest copy of DWF recovery data from $live_download_path";
  24. //                $headers = 'From: noreply@testing.giirp.com' . "\r\n" .
  25. //                        'Reply-To: noreply@testing.giirp.com' . "\r\n" .
  26. //                        'X-Mailer: PHP/' . phpversion();
  27. //                mail($to, $subject, $message, $headers);
  28. //            }else{
  29. //
  30. //
  31. //                $message = "Hi Terry," . "\r\n" .
  32. //                        "The script to get the recovery data for DWF ran but didn't return any results.";
  33. //                $headers = 'From: noreply@testing.giirp.com' . "\r\n" .
  34. //                        'Reply-To: noreply@testing.giirp.com' . "\r\n" .
  35. //                        'X-Mailer: PHP/' . phpversion();
  36. //                mail($to, $subject, $message, $headers);
  37.             }