From 05131d0726c46da409a720d88912faed54be3188 Mon Sep 17 00:00:00 2001
From: nicrausaz <n.crausaz99@gmail.com>
Date: Thu, 13 Dec 2018 14:28:28 +0100
Subject: [PATCH] mail

---
 canapEPFL/cible.php                           |   2 +-
 canapEPFL/helpers.php                         |   4 +-
 canapEPFL/templates/mailToApp.php             |  14 -
 .../mails/apprenticeMailTemplate.html         | 298 ++++++++++++++++++
 canapEPFL/templates/mails/mailToApp.php       |  10 +
 .../templates/{ => mails}/mailToResp.php      |   0
 6 files changed, 311 insertions(+), 17 deletions(-)
 delete mode 100644 canapEPFL/templates/mailToApp.php
 create mode 100644 canapEPFL/templates/mails/apprenticeMailTemplate.html
 create mode 100644 canapEPFL/templates/mails/mailToApp.php
 rename canapEPFL/templates/{ => mails}/mailToResp.php (100%)

diff --git a/canapEPFL/cible.php b/canapEPFL/cible.php
index ec97a87..130e5a9 100644
--- a/canapEPFL/cible.php
+++ b/canapEPFL/cible.php
@@ -29,7 +29,7 @@
         insertFiles($pdo, $candidateData->fichiers, $candidateId, $candidateData->rootpath);
 
         if ($SENDEMAILS) {
-          mailToResp($candidateData->prenomApprenti, $candidateData->nomApprenti, $candidateData->formation);
+          // mailToResp($candidateData->prenomApprenti, $candidateData->nomApprenti, $candidateData->formation);
           mailToApprenti($candidateData->mailApprenti, $candidateData->formation);
         }
         // kill session
diff --git a/canapEPFL/helpers.php b/canapEPFL/helpers.php
index bf18dc9..8a1a4b0 100644
--- a/canapEPFL/helpers.php
+++ b/canapEPFL/helpers.php
@@ -1,12 +1,12 @@
 <?php
 #region [Mail Sendings]
 function mailToResp($surname, $name, $job){
-  require_once("templates/mailToResp.php");
+  require_once("templates/mails/mailToResp.php");
   mail($to, $subject, $message, $headers);
 }
 
 function mailToApprenti($to, $job){
-  require_once("templates/mailToApp.php");
+  require_once("templates/mails/mailToApp.php");
   mail($to, $subject, $message, $headers);
 }
 #endregion
diff --git a/canapEPFL/templates/mailToApp.php b/canapEPFL/templates/mailToApp.php
deleted file mode 100644
index 2938000..0000000
--- a/canapEPFL/templates/mailToApp.php
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-$subject = 'Votre candidature pour une place d\'apprentissage';
-
-$message = "Nous venons d'enregistrer votre candidature et vous remercions de votre intérêt pour la "."\n".
-"formation professionnelle à l’Ecole polytechnique fédérale de Lausanne."."\n\n".
-"Nous allons étudier votre dossier avec la plus grande attention et nous ne manquerons "."\n".
-"pas de vous contacter si votre profil répond à nos attentes."."\n\n";
-$message .= "Avec nos meilleures salutations."."\n\n".
-"Formation Apprentis EPFL";
-
-$headers = 'From: noreply+formulaireApprentis@epfl.ch' . "\r\n" .
-'Reply-To: formation.apprentis@epfl.ch' . "\r\n" .
-'X-Mailer: PHP/' . phpversion();
-?>
\ No newline at end of file
diff --git a/canapEPFL/templates/mails/apprenticeMailTemplate.html b/canapEPFL/templates/mails/apprenticeMailTemplate.html
new file mode 100644
index 0000000..ad90a9a
--- /dev/null
+++ b/canapEPFL/templates/mails/apprenticeMailTemplate.html
@@ -0,0 +1,298 @@
+<!DOCTYPE html>
+<html lang="fr">
+<head>
+  <title>Votre candidature pour une place d'apprentissage</title>
+  <meta charset="utf-8">
+  <meta name="viewport" content="width=device-width">
+  <style type="text/css">
+    /* CLIENT-SPECIFIC STYLES */
+    #outlook a {
+      padding: 0;
+    }
+
+    /* Force Outlook to provide a "view in browser" message */
+    .ReadMsgBody {
+      width: 100%;
+    }
+
+    .ExternalClass {
+      width: 100%;
+    }
+
+    /* Force Hotmail to display emails at full width */
+    .ExternalClass,
+    .ExternalClass p,
+    .ExternalClass span,
+    .ExternalClass font,
+    .ExternalClass td,
+    .ExternalClass div {
+      line-height: 100%;
+    }
+
+    /* Force Hotmail to display normal line spacing */
+    body,
+    table,
+    td,
+    a {
+      -webkit-text-size-adjust: 100%;
+      -ms-text-size-adjust: 100%;
+    }
+
+    /* Prevent WebKit and Windows mobile changing default text sizes */
+    table,
+    td {
+      mso-table-lspace: 0pt;
+      mso-table-rspace: 0pt;
+    }
+
+    /* Remove spacing between tables in Outlook 2007 and up */
+    img {
+      -ms-interpolation-mode: bicubic;
+    }
+
+    /* Allow smoother rendering of resized image in Internet Explorer */
+    /* RESET STYLES */
+    body {
+      margin: 0;
+      padding: 0;
+    }
+
+    img {
+      border: 0;
+      height: auto;
+      line-height: 100%;
+      outline: none;
+      text-decoration: none;
+    }
+
+    table {
+      border-collapse: collapse !important;
+    }
+
+    body {
+      height: 100% !important;
+      margin: 0;
+      padding: 0;
+      width: 100% !important;
+    }
+
+    /* iOS BLUE LINKS */
+    .appleBody a {
+      color: #68440a;
+      text-decoration: none;
+    }
+
+    .appleFooter a {
+      color: #999999;
+      text-decoration: none;
+    }
+
+    /* MOBILE STYLES */
+    @media screen and (max-width: 525px) {
+
+      /* ALLOWS FOR FLUID TABLES */
+      table[class="wrapper"] {
+        width: 100% !important;
+      }
+
+      /* ADJUSTS LAYOUT OF LOGO IMAGE */
+      td[class="logo"] {
+        text-align: left;
+        padding: 20px 0 20px 0 !important;
+      }
+
+      td[class="logo"] img {
+        margin: 0 auto !important;
+      }
+
+      /* USE THESE CLASSES TO HIDE CONTENT ON MOBILE */
+      td[class="mobile-hide"] {
+        display: none;
+      }
+
+      img[class="mobile-hide"] {
+        display: none !important;
+      }
+
+      img[class="img-max"] {
+        max-width: 100% !important;
+        height: auto !important;
+      }
+
+      /* FULL-WIDTH TABLES */
+      table[class="responsive-table"] {
+        width: 100% !important;
+      }
+
+      /* UTILITY CLASSES FOR ADJUSTING PADDING ON MOBILE */
+      td[class="padding"] {
+        padding: 10px 5% 15px 5% !important;
+      }
+
+      td[class="padding-copy"] {
+        padding: 10px 5% 10px 5% !important;
+        text-align: center;
+      }
+
+      td[class="padding-meta"] {
+        padding: 30px 5% 0px 5% !important;
+        text-align: center;
+      }
+
+      td[class="no-pad"] {
+        padding: 0 0 20px 0 !important;
+      }
+
+      td[class="no-padding"] {
+        padding: 0 !important;
+      }
+
+      td[class="section-padding"] {
+        padding: 50px 15px 50px 15px !important;
+      }
+
+      td[class="section-padding-bottom-image"] {
+        padding: 50px 15px 0 15px !important;
+      }
+
+      /* ADJUST BUTTONS ON MOBILE */
+      td[class="mobile-wrapper"] {
+        padding: 10px 5% 15px 5% !important;
+      }
+
+      table[class="mobile-button-container"] {
+        margin: 0 auto;
+        width: 100% !important;
+      }
+
+      a[class="mobile-button"] {
+        width: 80% !important;
+        padding: 15px !important;
+        border: 0 !important;
+        font-size: 16px !important;
+      }
+    }
+  </style>
+</head>
+
+<body style="margin: 0; padding: 0;">
+  <!-- HEADER -->
+  <table border="0" cellpadding="0" cellspacing="0" width="100%">
+    <tr>
+      <td bgcolor="#ffffff">
+        <div align="center" style="padding: 0px 15px 0px 15px;">
+          <table border="0" cellpadding="0" cellspacing="0" width="500" class="wrapper">
+            <tr>
+              <td style="padding: 20px 0px 30px 0px;" class="logo">
+                <table border="0" cellpadding="0" cellspacing="0" width="100%">
+                  <tr>
+                    <!-- Mettre a jour les liens quand ils seront accessibles-->
+                    <td bgcolor="#ffffff" width="100" align="left"><img alt="Logo" src="https://canap.epfl.ch/assets/img/FA.png" width="200"
+                        style="display: block; font-family: Helvetica, Arial, sans-serif; color: #666666; font-size: 16px;"
+                        border="0"></a></td>
+                    <td bgcolor="#ffffff" width="400" align="right"><img alt="Logo" src="http://epflform.local/assets/epfl2018/svg/epfl-logo.svg"
+                        width="200" style="display: block; font-family: Helvetica, Arial, sans-serif; color: #666666; font-size: 16px;"
+                        border="0"></a></td>
+                  </tr>
+                </table>
+              </td>
+            </tr>
+          </table>
+        </div>
+      </td>
+    </tr>
+  </table>
+
+  <table border="0" cellpadding="0" cellspacing="0" width="100%">
+    <tr>
+      <td bgcolor="#f8f8f8" align="center" style="padding: 20px;" class="section-padding-bottom-image">
+        <table border="0" cellpadding="0" cellspacing="0" width="500" class="responsive-table">
+          <tr>
+            <td>
+              <table width="100%" border="0" cellspacing="0" cellpadding="0">
+                <tr>
+                  <td>
+                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
+                      <tr>
+                        <td align="center" style="font-size: 25px; font-family: Helvetica, Arial, sans-serif; color: #333333;"class="padding-copy">
+                          Votre candidature pour une place d'apprentissage
+                        </td>
+                      </tr>
+                      <tr>
+                        <td align="center" style="padding: 20px 0 0 0; font-size: 16px; line-height: 25px; font-family: Helvetica, Arial, sans-serif; color: #666666;"
+                          class="padding-copy">
+                          <div>
+                            <p>
+                              Nous venons d'enregistrer votre candidature et vous remercions de votre intérêt pour la
+                              formation professionnelle
+                              à l’Ecole polytechnique fédérale de Lausanne.
+                            </p>
+                            <p>
+                              Nous allons étudier votre dossier avec la plus grande attention et nous ne manquerons
+                              pas de vous contacter si votre profil répond à nos attentes.
+                            </p>
+                            <p>
+                              Avec nos meilleures salutations.
+                            </p>
+                            <p>
+                              <b>Formation Apprentis EPFL</b>
+                            </p>
+                          </div>
+                        </td>
+                      </tr>
+                    </table>
+                  </td>
+                </tr>
+                <tr>
+                  <td>
+                    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="mobile-button-container">
+                      <tr>
+                        <td align="center" style="padding: 25px 0 25px 0;" class="padding-copy">
+                          <table border="0" cellspacing="0" cellpadding="0" class="responsive-table">
+                            <tr>
+                              <td align="center">
+                                <a href="http://epflform.local/viewpostulation.php" target="_blank" style="font-size: 16px; font-family: Helvetica, Arial, sans-serif; font-weight: normal; color: #ffffff; text-decoration: none; background-color: #e30713; border-top: 15px solid #e30713; border-bottom: 15px solid #e30713; border-left: 25px solid #e30713; border-right: 25px solid #e30713; border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px; display: inline-block;"
+                                  class="mobile-button">Consulter votre postulation</a>
+                              </td>
+                            </tr>
+                          </table>
+                        </td>
+                      </tr>
+                    </table>
+                  </td>
+                </tr>
+              </table>
+            </td>
+          </tr>
+        </table>
+      </td>
+    </tr>
+  </table>
+
+  <!-- FOOTER -->
+  <table border="0" cellpadding="0" cellspacing="0" width="100%">
+    <tr>
+      <td bgcolor="#ffffff" align="center">
+        <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
+          <tr>
+            <td style="padding: 20px 0px 20px 0px;">
+              <!-- UNSUBSCRIBE COPY -->
+              <table width="500" border="0" cellspacing="0" cellpadding="0" align="center" class="responsive-table">
+                <tr>
+                  <td align="center" valign="middle" style="font-size: 12px; line-height: 18px; font-family: Helvetica, Arial, sans-serif; color:#666666;">
+                    <span class="appleFooter" style="color:#666666;">Formation Apprentis EPFL</span><br>
+                    <a class="original-only" href="mailto:formation.apprentis@epfl.ch" style="color: #666666; text-decoration: none;">formation.apprentis@epfl.ch</a>
+                    <span class="original-only" style="font-family: Arial, sans-serif; font-size: 12px; color: #444444;">|</span>
+                    <a href="https://apprentis.epfl.ch" target="_blank" style="color: #666666; text-decoration: none;">apprentis.epfl.ch</a>
+                  </td>
+                </tr>
+              </table>
+            </td>
+          </tr>
+        </table>
+      </td>
+    </tr>
+  </table>
+</body>
+
+</html>
\ No newline at end of file
diff --git a/canapEPFL/templates/mails/mailToApp.php b/canapEPFL/templates/mails/mailToApp.php
new file mode 100644
index 0000000..483d15f
--- /dev/null
+++ b/canapEPFL/templates/mails/mailToApp.php
@@ -0,0 +1,10 @@
+<?php
+$subject = 'Votre candidature pour une place d\'apprentissage';
+
+$message = file_get_contents('./templates/mails/apprenticeMailTemplate.html');
+
+$headers = 'From: noreply+formulaireApprentis@epfl.ch' . "\r\n" .
+'Content-type: text/html; charset= utf8' . "\r\n" .
+'Reply-To: formation.apprentis@epfl.ch' . "\r\n" .
+'X-Mailer: PHP/' . phpversion();
+?>
\ No newline at end of file
diff --git a/canapEPFL/templates/mailToResp.php b/canapEPFL/templates/mails/mailToResp.php
similarity index 100%
rename from canapEPFL/templates/mailToResp.php
rename to canapEPFL/templates/mails/mailToResp.php
-- 
GitLab