Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once('PHPMailer/PHPMailerAutoload.php');
- $p=$db->prepare("SELECT id,category,date_serviced,contract_date,locations,contract_expiry,past_due_penalty,billing_mail_address,billing_email_address,billing_name,billing_phone,AccountNumber,Signed FROM pdfs WHERE contract_expiry BETWEEN CURDATE()+INTERVAL 90 DAY AND CURDATE()+INTERVAL 180 DAY");
- $p->execute();
- $res= $p->fetchAll();
- foreach ($res as $result) {
- if (isset($result['id'])){
- $iddb = $result['id'];
- $q = $db->prepare("select * from rates WHERE pdf_id='$iddb'");
- $q->execute();
- $resrates = $q->fetchAll();
- $rateInput = $resrates;
- $printRates = "";
- $size = count ($resrates);
- for($i=0;$i<$size;$i++){
- $rates[$i] = $resrates[$i]['rate'];
- }
- for($i=$size;$i<20;$i++){
- $rates[$i] = "";
- }
- $j = $size-1;
- if ($size % 2 != 0)
- {
- for($i=0;$i<=$size/2;$i++){
- if ($i==$j)
- break;
- $temp=$rates[$i];
- $rates[$i]=$rates[$j];
- $rates[$j]=$temp;
- $j--;
- }
- }
- else{
- for($i=0;$i<$size/2;$i++){
- if ($i==$j)
- break;
- $temp=$rates[$i];
- $rates[$i]=$rates[$j];
- $rates[$j]=$temp;
- $j--;
- }
- }
- for ($i=0;$i<$size;$i++){
- $printRates .= "{$rates[$i]}, " ;
- }
- }
- }
- $q=$db->prepare("SELECT six_id FROM sixmonths");
- $q->execute();
- $res2= $q->fetchAll();
- $checkid = array();
- foreach ($res2 as $result2) {
- array_push($checkid,$result2['six_id']);
- }
- $sizeid = count ($checkid);
- $bol = false;
- foreach($res as $result)
- {
- $mail = new PHPMailer();
- $mail-> isSMTP();
- $mail->SMTPAuth = true;
- $mail->SMTPSecure='ssl';
- $mail->Host ='smtp.gmail.com';
- $mail->Port='465';
- $mail->isHTML();
- $mail->Username ='pdfcontractsweb@gmail.com';
- $mail->Password ='pdfcontracts1212';
- $mail->SetFrom('no-reply@pdfs.org');
- $mail->Subject = ("{$result['category']}-{$result['locations']}-6 month warning");
- $mail->Body =nl2br(" Contract with ID: {$result['id']}\nCATEGORY: {$result['category']}\n SERVICE DATE: {$result['date_serviced']}\n CONTRACT DATE: {$result['contract_date']}\n LOCATION: {$result['locations']}\n RATES: $printRates\n PAST DUE PENALTY {$result['past_due_penalty']}\n BILLING MAIL ADDRESS:{$result['billing_mail_address']}\n BILLING EMAIL: {$result['billing_email_address']}\n NAME: {$result['billing_name']}\n PHONE: {$result['billing_phone']}\n ACCOUNT NUMBER: {$result['AccountNumber']}\n SIGNED: {$result['Signed']}\n expires {$result['contract_expiry']}");
- $mail->AddAddress('dawidw-k@wp.pl');
- for ($i=0;$i<$sizeid;$i++){
- if ($result['id'] == $checkid[$i]){
- $bol=true;
- }
- }
- if ($bol==false){
- $mail->Send();
- $r = $db->prepare("INSERT INTO sixmonths(six_id) VALUES (:iddb)");
- $r->bindParam(":iddb",$iddb);
- $r->execute();
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement