37 lines
1.4 KiB
PHP
37 lines
1.4 KiB
PHP
<?php
|
|
$job_name ='parsedemail_item_fix_missing email';
|
|
echo "[" . date("Y-m-d H:i:s") . "] ".$job_name." job is starting.\n";
|
|
|
|
require 'common/utils.php';
|
|
require 'common/config.php';
|
|
require 'common/address_city.php';
|
|
require 'common/parser.php';
|
|
require 'common/Geocode.php';
|
|
|
|
$total = $success = $failed = 0;
|
|
$path = "/Users/admin/Work/FloatAdmin/adminsavvy/data/receipts/";
|
|
$prefix = "grab_";
|
|
$condition =" subject ilike '%your grab e-receipt%' and message_from ilike '%grab%' ";
|
|
$prefix = "uber_";
|
|
$condition =" subject ilike '%trip with uber%' OR subject ilike '%trip receipt%' OR subject ilike '%took an uber trip on%'";
|
|
$prefix = "gojek_";
|
|
$condition =" subject ilike '%your trip with gojek%' and message_from ilike '%go-jek%' ";
|
|
/* $prefix = "comfortdelgro_";
|
|
$condition =" subject ilike '%comfortdelgro taxi e-receipt%'";
|
|
$condition =" subject ilike '%your trip with gojek%'";
|
|
$prefix = "lyft_";
|
|
$condition =" subject ilike '%your ride with%'"; */
|
|
$q="SELECT DISTINCT ON (to_char(message_date,'YYYY-MM')) message, (to_char(message_date,'YYYY-MM')) as monthyear FROM trackedemail_item
|
|
WHERE ".$condition." AND message_date is not null
|
|
ORDER by monthyear DESC";
|
|
$r = pg_query($conn, $q);
|
|
|
|
while ($f = pg_fetch_assoc($r)) {
|
|
$total++;
|
|
$message = $f['message'];
|
|
$monthyear = $f['monthyear'];
|
|
$file_name = $path.$prefix.$monthyear.".html";
|
|
file_put_contents($file_name, $message);
|
|
}
|
|
echo "[" . date("Y-m-d H:i:s") . "] ".$job_name." job complete.\n";
|