Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2018
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. require_once('PHPMailer/PHPMailerAutoload.php');
  5. $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");
  6. $p->execute();
  7. $res= $p->fetchAll();
  8. foreach ($res as $result) {
  9. if (isset($result['id'])){
  10. $iddb = $result['id'];
  11.  
  12. $q = $db->prepare("select * from rates WHERE pdf_id='$iddb'");
  13. $q->execute();
  14. $resrates = $q->fetchAll();
  15. $rateInput = $resrates;
  16. $printRates = "";
  17. $size = count ($resrates);
  18.  
  19. for($i=0;$i<$size;$i++){
  20. $rates[$i] = $resrates[$i]['rate'];
  21. }
  22.  
  23. for($i=$size;$i<20;$i++){
  24. $rates[$i] = "";
  25. }
  26.  
  27. $j = $size-1;
  28. if ($size % 2 != 0)
  29. {
  30. for($i=0;$i<=$size/2;$i++){
  31. if ($i==$j)
  32. break;
  33.  
  34. $temp=$rates[$i];
  35. $rates[$i]=$rates[$j];
  36. $rates[$j]=$temp;
  37. $j--;
  38. }
  39. }
  40.  
  41. else{
  42. for($i=0;$i<$size/2;$i++){
  43. if ($i==$j)
  44. break;
  45.  
  46. $temp=$rates[$i];
  47. $rates[$i]=$rates[$j];
  48. $rates[$j]=$temp;
  49. $j--;
  50. }
  51. }
  52.  
  53. for ($i=0;$i<$size;$i++){
  54. $printRates .= "{$rates[$i]}, " ;
  55. }
  56. }
  57. }
  58.  
  59.  
  60. $q=$db->prepare("SELECT six_id FROM sixmonths");
  61. $q->execute();
  62. $res2= $q->fetchAll();
  63. $checkid = array();
  64. foreach ($res2 as $result2) {
  65. array_push($checkid,$result2['six_id']);
  66. }
  67.  
  68. $sizeid = count ($checkid);
  69. $bol = false;
  70.  
  71.  
  72. foreach($res as $result)
  73. {
  74.  
  75. $mail = new PHPMailer();
  76. $mail-> isSMTP();
  77. $mail->SMTPAuth = true;
  78. $mail->SMTPSecure='ssl';
  79. $mail->Host ='smtp.gmail.com';
  80. $mail->Port='465';
  81. $mail->isHTML();
  82. $mail->Username ='pdfcontractsweb@gmail.com';
  83. $mail->Password ='pdfcontracts1212';
  84. $mail->SetFrom('no-reply@pdfs.org');
  85. $mail->Subject = ("{$result['category']}-{$result['locations']}-6 month warning");
  86. $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']}");
  87. $mail->AddAddress('dawidw-k@wp.pl');
  88.  
  89.  
  90. for ($i=0;$i<$sizeid;$i++){
  91. if ($result['id'] == $checkid[$i]){
  92. $bol=true;
  93. }
  94. }
  95. if ($bol==false){
  96. $mail->Send();
  97. $r = $db->prepare("INSERT INTO sixmonths(six_id) VALUES (:iddb)");
  98. $r->bindParam(":iddb",$iddb);
  99. $r->execute();
  100. }
  101.  
  102. }
  103.  
  104. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement