From 31d6346432e4f140e4c84d6a68d77f0966034d24 Mon Sep 17 00:00:00 2001 From: Mollie Gentry Date: Thu, 12 Jan 2017 14:52:11 -0500 Subject: [PATCH 1/4] Button added to email contract to student, no actions --- templates/internshipView.tpl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/templates/internshipView.tpl b/templates/internshipView.tpl index 0e9172ba..152f4398 100644 --- a/templates/internshipView.tpl +++ b/templates/internshipView.tpl @@ -41,10 +41,15 @@ +
-
+ +
+ +
+
From 6f4bfd47ccb70317c5cc6e9aa02ad4d053bb62c5 Mon Sep 17 00:00:00 2001 From: Mollie Gentry Date: Thu, 12 Jan 2017 19:18:09 -0500 Subject: [PATCH 2/4] Split 'generate contract' button, 'email contract' drop down --- class/Email.php | 61 +++++ class/InternshipInventory.php | 7 + composer.json | 3 +- composer.lock | 362 ++++++++++++++++++++----- index.php | 2 + javascript/formGoodies/otherGoodies.js | 23 +- templates/internshipView.tpl | 19 +- 7 files changed, 397 insertions(+), 80 deletions(-) diff --git a/class/Email.php b/class/Email.php index f3acd21f..cb5b6bf4 100644 --- a/class/Email.php +++ b/class/Email.php @@ -101,6 +101,38 @@ public static function logEmail($message) fclose($fd); } + /** + * Logs a Swift_Message object to a text file + */ + public static function logSwiftmailMessageLong(\Swift_Message $message) + { + $fd = fopen(PHPWS_SOURCE_DIR . 'logs/email.log', 'a'); + fprintf($fd, "=======================\n"); + foreach($message->getFrom() as $address => $name) { + fprintf($fd, "From: %s <%s>\n", $name, $address); + } + foreach($message->getTo() as $address => $name) { + fprintf($fd, "To: %s <%s>\n", $name, $address); + } + $cc = $message->getCc(); + if(!empty($cc)){ + foreach($cc() as $address => $name) { + fprintf($fd, "Cc: %s <%s>\n", $name, $address); + } + } + $bcc = $message->getBcc(); + if(!empty($bcc)){ + foreach($bcc as $address => $name) { + fprintf($fd, "Bcc: %s <%s>\n", $name, $address); + } + } + fprintf($fd, "Sender: %s\n", $message->getSender()); + fprintf($fd, "Subject: %s\n", $message->getSubject()); + fprintf($fd, "Date: %s\n", date('Y-m-d H:i:s')); + fprintf($fd, "Content: \n"); + fprintf($fd, "%s\n\n", $message->toString()); + } + /** * Sends an email to the registrar notifying them to register * the student for the appropriate internship course. @@ -505,6 +537,35 @@ public static function sendRegistrationConfirmationEmail(Internship $i, Agency $ email::sendTemplateMessage($to, $subject, 'email/RegistrationConfirmation.tpl', $tpl, $cc); } + /** + * Sends the internship contract to the student. + * + *@param Inernship $i + *@param InternshipContractPdfView $pdfView + */ + public static function emailContractToStudent(Internship $i, InternshipContractPdfView $pdfView) + { + $settings = InternSettings::getInstance(); + + try{ + $message = \Swift_Message::newInstance(); + $message->setSubject('Internship Contract'); + $message->setFrom(array(('no-reply' . $settings->getEmailDomain()) => $settings->getSystemName())); + $message->setTo(array(($i->email . $settings->getEmailDomain()) => $i->getFullName())); + $message->setBody('Attached is a copy of your internship contract. If you have any issues with your contract, please contact your faculty supervisor.'); + $attachment = \Swift_Attachment::newInstance($pdfView->getPdf()->output('internship-contract.pdf', 'S'), $i->getFullName() . ' Internship Contract.pdf'); + $message->attach($attachment); + + // $transport = \Swift_SmtpTransport::newInstance('localhost', 80); + // $mailer = \Swift_Mailer::newInstance($transport); + + self::logSwiftmailMessageLong($message); + }catch(\Swift_TransportException $e){ + $transport->stop(); + } + + } + /** * Sends the 'Registration Issue' notification email. * diff --git a/class/InternshipInventory.php b/class/InternshipInventory.php index 7b57bd93..54248946 100644 --- a/class/InternshipInventory.php +++ b/class/InternshipInventory.php @@ -153,6 +153,13 @@ public function handleRequest() $pdf = $pdfView->getPdf(); $pdf->output(); exit; + case 'emailPdf' : + $i = InternshipFactory::getInternshipById($_REQUEST['internship_id']); + $emgContacts = EmergencyContactFactory::getContactsForInternship($i); + $pdfView = new InternshipContractPdfView($i, $emgContacts); + + Email::emailContractToStudent($i, $pdfView); + exit; case 'upload_document_form': $docManager = new DocumentManager(); echo $docManager->edit(); diff --git a/composer.json b/composer.json index b733d871..68c0749d 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,7 @@ { "require": { - "setasign/fpdi-fpdf": "^1.6" + "setasign/fpdi-fpdf": "^1.6", + "swiftmailer/swiftmailer": "@stable" }, "require-dev": { "phpunit/phpunit": "^4.8", diff --git a/composer.lock b/composer.lock index ab1fa9be..8ec96d5f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "02cf9ad1002253558eec1e6d43595160", - "content-hash": "863237413e15112036774a60975f42ee", + "hash": "cc411380b97e50ffacf118622e808d99", + "content-hash": "d2199edc7787b31b8d3f2ba225bf2d10", "packages": [ { "name": "setasign/fpdf", @@ -138,6 +138,60 @@ "pdf" ], "time": "2015-11-30 11:10:35" + }, + { + "name": "swiftmailer/swiftmailer", + "version": "v5.4.5", + "source": { + "type": "git", + "url": "https://github.com/swiftmailer/swiftmailer.git", + "reference": "cd142238a339459b10da3d8234220963f392540c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/cd142238a339459b10da3d8234220963f392540c", + "reference": "cd142238a339459b10da3d8234220963f392540c", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "mockery/mockery": "~0.9.1", + "symfony/phpunit-bridge": "~3.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.4-dev" + } + }, + "autoload": { + "files": [ + "lib/swift_required.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Chris Corbyn" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Swiftmailer, free feature-rich PHP mailer", + "homepage": "http://swiftmailer.org", + "keywords": [ + "email", + "mail", + "mailer" + ], + "time": "2016-12-29 10:02:40" } ], "packages-dev": [ @@ -195,39 +249,136 @@ ], "time": "2015-06-14 21:17:01" }, + { + "name": "phpdocumentor/reflection-common", + "version": "1.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c", + "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "time": "2015-12-27 11:43:31" + }, { "name": "phpdocumentor/reflection-docblock", - "version": "2.0.4", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" + "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", - "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/8331b5efe816ae05461b7ca1e721c01b46bafb3e", + "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.5", + "phpdocumentor/reflection-common": "^1.0@dev", + "phpdocumentor/type-resolver": "^0.2.0", + "webmozart/assert": "^1.0" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^4.4" }, - "suggest": { - "dflydev/markdown": "~1.0", - "erusev/parsedown": "~1.0" + "type": "library", + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "time": "2016-09-30 07:12:33" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "0.2.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", + "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", + "shasum": "" + }, + "require": { + "php": ">=5.5", + "phpdocumentor/reflection-common": "^1.0" + }, + "require-dev": { + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^5.2||^4.8.24" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { - "psr-0": { - "phpDocumentor": [ + "psr-4": { + "phpDocumentor\\Reflection\\": [ "src/" ] } @@ -239,39 +390,40 @@ "authors": [ { "name": "Mike van Riel", - "email": "mike.vanriel@naenius.com" + "email": "me@mikevanriel.com" } ], - "time": "2015-02-03 12:10:50" + "time": "2016-11-25 06:54:22" }, { "name": "phpspec/prophecy", - "version": "v1.6.0", + "version": "v1.6.2", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "3c91bdf81797d725b14cb62906f9a4ce44235972" + "reference": "6c52c2722f8460122f96f86346600e1077ce22cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/3c91bdf81797d725b14cb62906f9a4ce44235972", - "reference": "3c91bdf81797d725b14cb62906f9a4ce44235972", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/6c52c2722f8460122f96f86346600e1077ce22cb", + "reference": "6c52c2722f8460122f96f86346600e1077ce22cb", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "~2.0", - "sebastian/comparator": "~1.1", - "sebastian/recursion-context": "~1.0" + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2", + "sebastian/comparator": "^1.1", + "sebastian/recursion-context": "^1.0|^2.0" }, "require-dev": { - "phpspec/phpspec": "~2.0" + "phpspec/phpspec": "^2.0", + "phpunit/phpunit": "^4.8 || ^5.6.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.5.x-dev" + "dev-master": "1.6.x-dev" } }, "autoload": { @@ -304,7 +456,7 @@ "spy", "stub" ], - "time": "2016-02-15 07:46:21" + "time": "2016-11-21 14:58:47" }, { "name": "phpunit/php-code-coverage", @@ -370,16 +522,16 @@ }, { "name": "phpunit/php-file-iterator", - "version": "1.4.1", + "version": "1.4.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0" + "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/6150bf2c35d3fc379e50c7602b75caceaa39dbf0", - "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", + "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", "shasum": "" }, "require": { @@ -413,7 +565,7 @@ "filesystem", "iterator" ], - "time": "2015-06-21 13:08:43" + "time": "2016-10-03 07:40:28" }, { "name": "phpunit/php-invoker", @@ -504,21 +656,24 @@ }, { "name": "phpunit/php-timer", - "version": "1.0.7", + "version": "1.0.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b" + "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3e82f4e9fc92665fafd9157568e4dcb01d014e5b", - "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/38e9124049cf1a164f1e4537caf19c99bf1eb260", + "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260", "shasum": "" }, "require": { "php": ">=5.3.3" }, + "require-dev": { + "phpunit/phpunit": "~4|~5" + }, "type": "library", "autoload": { "classmap": [ @@ -541,20 +696,20 @@ "keywords": [ "timer" ], - "time": "2015-06-21 08:01:12" + "time": "2016-05-12 18:03:57" }, { "name": "phpunit/php-token-stream", - "version": "1.4.8", + "version": "1.4.9", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da" + "reference": "3b402f65a4cc90abf6e1104e388b896ce209631b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da", - "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3b402f65a4cc90abf6e1104e388b896ce209631b", + "reference": "3b402f65a4cc90abf6e1104e388b896ce209631b", "shasum": "" }, "require": { @@ -590,20 +745,20 @@ "keywords": [ "tokenizer" ], - "time": "2015-09-15 10:49:45" + "time": "2016-11-15 14:06:22" }, { "name": "phpunit/phpunit", - "version": "4.8.24", + "version": "4.8.31", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "a1066c562c52900a142a0e2bbf0582994671385e" + "reference": "98b2b39a520766bec663ff5b7ff1b729db9dbfe3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a1066c562c52900a142a0e2bbf0582994671385e", - "reference": "a1066c562c52900a142a0e2bbf0582994671385e", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/98b2b39a520766bec663ff5b7ff1b729db9dbfe3", + "reference": "98b2b39a520766bec663ff5b7ff1b729db9dbfe3", "shasum": "" }, "require": { @@ -617,9 +772,9 @@ "phpunit/php-code-coverage": "~2.1", "phpunit/php-file-iterator": "~1.4", "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": ">=1.0.6", + "phpunit/php-timer": "^1.0.6", "phpunit/phpunit-mock-objects": "~2.3", - "sebastian/comparator": "~1.1", + "sebastian/comparator": "~1.2.2", "sebastian/diff": "~1.2", "sebastian/environment": "~1.3", "sebastian/exporter": "~1.2", @@ -662,7 +817,7 @@ "testing", "xunit" ], - "time": "2016-03-14 06:16:08" + "time": "2016-12-09 02:45:31" }, { "name": "phpunit/phpunit-mock-objects", @@ -722,22 +877,22 @@ }, { "name": "sebastian/comparator", - "version": "1.2.0", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "937efb279bd37a375bcadf584dec0726f84dbf22" + "reference": "6a1ed12e8b2409076ab22e3897126211ff8b1f7f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22", - "reference": "937efb279bd37a375bcadf584dec0726f84dbf22", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/6a1ed12e8b2409076ab22e3897126211ff8b1f7f", + "reference": "6a1ed12e8b2409076ab22e3897126211ff8b1f7f", "shasum": "" }, "require": { "php": ">=5.3.3", "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2" + "sebastian/exporter": "~1.2 || ~2.0" }, "require-dev": { "phpunit/phpunit": "~4.4" @@ -782,7 +937,7 @@ "compare", "equality" ], - "time": "2015-07-26 15:48:44" + "time": "2016-11-19 09:18:40" }, { "name": "sebastian/diff", @@ -838,23 +993,23 @@ }, { "name": "sebastian/environment", - "version": "1.3.5", + "version": "1.3.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "dc7a29032cf72b54f36dac15a1ca5b3a1b6029bf" + "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/dc7a29032cf72b54f36dac15a1ca5b3a1b6029bf", - "reference": "dc7a29032cf72b54f36dac15a1ca5b3a1b6029bf", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/be2c607e43ce4c89ecd60e75c6a85c126e754aea", + "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^5.3.3 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^4.8 || ^5.0" }, "type": "library", "extra": { @@ -884,20 +1039,20 @@ "environment", "hhvm" ], - "time": "2016-02-26 18:40:46" + "time": "2016-08-18 05:49:44" }, { "name": "sebastian/exporter", - "version": "1.2.1", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "7ae5513327cb536431847bcc0c10edba2701064e" + "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/7ae5513327cb536431847bcc0c10edba2701064e", - "reference": "7ae5513327cb536431847bcc0c10edba2701064e", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/42c4c2eec485ee3e159ec9884f95b431287edde4", + "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4", "shasum": "" }, "require": { @@ -905,12 +1060,13 @@ "sebastian/recursion-context": "~1.0" }, "require-dev": { + "ext-mbstring": "*", "phpunit/phpunit": "~4.4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "1.3.x-dev" } }, "autoload": { @@ -950,7 +1106,7 @@ "export", "exporter" ], - "time": "2015-06-21 07:55:53" + "time": "2016-06-17 09:04:28" }, { "name": "sebastian/global-state", @@ -1093,25 +1249,31 @@ }, { "name": "symfony/yaml", - "version": "v3.0.4", + "version": "v3.2.2", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "0047c8366744a16de7516622c5b7355336afae96" + "reference": "50eadbd7926e31842893c957eca362b21592a97d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/0047c8366744a16de7516622c5b7355336afae96", - "reference": "0047c8366744a16de7516622c5b7355336afae96", + "url": "https://api.github.com/repos/symfony/yaml/zipball/50eadbd7926e31842893c957eca362b21592a97d", + "reference": "50eadbd7926e31842893c957eca362b21592a97d", "shasum": "" }, "require": { "php": ">=5.5.9" }, + "require-dev": { + "symfony/console": "~2.8|~3.0" + }, + "suggest": { + "symfony/console": "For validating YAML files using the lint command" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.2-dev" } }, "autoload": { @@ -1138,12 +1300,64 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2016-03-04 07:55:57" + "time": "2017-01-03 13:51:32" + }, + { + "name": "webmozart/assert", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/assert.git", + "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", + "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "time": "2016-11-23 20:04:58" } ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "swiftmailer/swiftmailer": 0 + }, "prefer-stable": false, "prefer-lowest": false, "platform": [], diff --git a/index.php b/index.php index 5a10d980..a7dd4f3e 100644 --- a/index.php +++ b/index.php @@ -11,6 +11,8 @@ exit(); } +require_once(PHPWS_SOURCE_DIR . 'mod/intern/vendor/autoload.php'); + require_once(PHPWS_SOURCE_DIR . 'mod/intern/inc/defines.php'); // Check some permissions diff --git a/javascript/formGoodies/otherGoodies.js b/javascript/formGoodies/otherGoodies.js index 31c2bdc3..b1257324 100644 --- a/javascript/formGoodies/otherGoodies.js +++ b/javascript/formGoodies/otherGoodies.js @@ -22,7 +22,7 @@ function setupContractButton() function generateContractHandler() { - // Diable the button + // Disable the button $('.generateContract').prop('disabled', 'disabled'); // Change the button text @@ -35,6 +35,27 @@ function generateContractHandler() 'json'); } +function setupEmailContractButton() +{ + $('.emailContract').click(EmailContractHandler); +} + +function EmailContractHandler() +{ + // Disable the button + $('.emailContract').prop('disabled', 'disabled'); + + // Change the button text + $('.emailContract').html(' Sending...'); + + $.post('index.php?module=intern&action=SaveInternship', $('#internship').serialize() + '&emailContract=true', + function(data){ + window.location = 'index.php?module=intern&action=emailPdf&internship_id=' + data.id; + }, + 'json'); + +} + function addFormErrors() { // Add error class to parent object (hopefully a div.form-group) diff --git a/templates/internshipView.tpl b/templates/internshipView.tpl index 152f4398..bab8d2d2 100644 --- a/templates/internshipView.tpl +++ b/templates/internshipView.tpl @@ -41,14 +41,25 @@
-
+ + +
+ + +
From ad2bdd04a30ed66d6daadf856a8f549b83a9f5b8 Mon Sep 17 00:00:00 2001 From: Mollie Gentry Date: Mon, 23 Jan 2017 15:17:14 -0500 Subject: [PATCH 3/4] 'email sent' success notification added after button pressed --- class/Email.php | 4 ++-- class/InternshipInventory.php | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/class/Email.php b/class/Email.php index cb5b6bf4..afb5f8a3 100644 --- a/class/Email.php +++ b/class/Email.php @@ -412,7 +412,7 @@ public static function sendIntlInternshipCreateNoticeStudent(Internship $i) $dept = new Department($i->department_id); $tpl['DEPARTMENT'] = $dept->getName(); - $to = $i->email . '@appstate.edu'; + $to = $i->email . $settings->getEmailDomain(); $subject = "International Internship Created - {$i->first_name} {$i->last_name}"; @@ -550,7 +550,7 @@ public static function emailContractToStudent(Internship $i, InternshipContractP try{ $message = \Swift_Message::newInstance(); $message->setSubject('Internship Contract'); - $message->setFrom(array(('no-reply' . $settings->getEmailDomain()) => $settings->getSystemName())); + $message->setFrom(array(('noreply' . $settings->getEmailDomain()) => $settings->getSystemName())); $message->setTo(array(($i->email . $settings->getEmailDomain()) => $i->getFullName())); $message->setBody('Attached is a copy of your internship contract. If you have any issues with your contract, please contact your faculty supervisor.'); $attachment = \Swift_Attachment::newInstance($pdfView->getPdf()->output('internship-contract.pdf', 'S'), $i->getFullName() . ' Internship Contract.pdf'); diff --git a/class/InternshipInventory.php b/class/InternshipInventory.php index 54248946..f307cb17 100644 --- a/class/InternshipInventory.php +++ b/class/InternshipInventory.php @@ -155,10 +155,15 @@ public function handleRequest() exit; case 'emailPdf' : $i = InternshipFactory::getInternshipById($_REQUEST['internship_id']); + $address = 'index.php?module=intern&action=ShowInternship&internship_id=' . $i->getId(); + $i = $i->save(); + $i = InternshipFactory::getInternshipById($i); $emgContacts = EmergencyContactFactory::getContactsForInternship($i); $pdfView = new InternshipContractPdfView($i, $emgContacts); - Email::emailContractToStudent($i, $pdfView); + \NQ::simple('intern', \Intern\UI\NotifyUI::SUCCESS, 'Contract emailed to student.'); + \NQ::close(); + \PHPWS_Core::reroute($address); exit; case 'upload_document_form': $docManager = new DocumentManager(); From 1cb56af64bba730d3a93052c09657c10bd70baa8 Mon Sep 17 00:00:00 2001 From: Mollie Gentry Date: Tue, 24 Jan 2017 12:43:31 -0500 Subject: [PATCH 4/4] saves internship on click with email contract REF #170 --- class/Email.php | 5 ++--- class/InternshipInventory.php | 5 +---- javascript/formGoodies/otherGoodies.js | 7 ++++--- templates/internshipView.tpl | 11 +---------- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/class/Email.php b/class/Email.php index afb5f8a3..d63f5135 100644 --- a/class/Email.php +++ b/class/Email.php @@ -556,14 +556,13 @@ public static function emailContractToStudent(Internship $i, InternshipContractP $attachment = \Swift_Attachment::newInstance($pdfView->getPdf()->output('internship-contract.pdf', 'S'), $i->getFullName() . ' Internship Contract.pdf'); $message->attach($attachment); - // $transport = \Swift_SmtpTransport::newInstance('localhost', 80); - // $mailer = \Swift_Mailer::newInstance($transport); + $transport = \Swift_SmtpTransport::newInstance('localhost'); + $mailer = \Swift_Mailer::newInstance($transport); self::logSwiftmailMessageLong($message); }catch(\Swift_TransportException $e){ $transport->stop(); } - } /** diff --git a/class/InternshipInventory.php b/class/InternshipInventory.php index f307cb17..ccfb07ee 100644 --- a/class/InternshipInventory.php +++ b/class/InternshipInventory.php @@ -155,15 +155,12 @@ public function handleRequest() exit; case 'emailPdf' : $i = InternshipFactory::getInternshipById($_REQUEST['internship_id']); - $address = 'index.php?module=intern&action=ShowInternship&internship_id=' . $i->getId(); - $i = $i->save(); - $i = InternshipFactory::getInternshipById($i); $emgContacts = EmergencyContactFactory::getContactsForInternship($i); $pdfView = new InternshipContractPdfView($i, $emgContacts); Email::emailContractToStudent($i, $pdfView); \NQ::simple('intern', \Intern\UI\NotifyUI::SUCCESS, 'Contract emailed to student.'); \NQ::close(); - \PHPWS_Core::reroute($address); + \PHPWS_Core::reroute("index.php?module=intern&action=ShowInternship&internship_id=" . $i->getId()); exit; case 'upload_document_form': $docManager = new DocumentManager(); diff --git a/javascript/formGoodies/otherGoodies.js b/javascript/formGoodies/otherGoodies.js index b1257324..3174647f 100644 --- a/javascript/formGoodies/otherGoodies.js +++ b/javascript/formGoodies/otherGoodies.js @@ -43,12 +43,12 @@ function setupEmailContractButton() function EmailContractHandler() { // Disable the button - $('.emailContract').prop('disabled', 'disabled'); + $('#contract-button').prop('disabled', 'disabled'); // Change the button text - $('.emailContract').html(' Sending...'); + $('#contract-button').html(' Sending...'); - $.post('index.php?module=intern&action=SaveInternship', $('#internship').serialize() + '&emailContract=true', + $.post('index.php?module=intern&action=SaveInternship', $('#internship').serialize() + '&generateContract=true', function(data){ window.location = 'index.php?module=intern&action=emailPdf&internship_id=' + data.id; }, @@ -352,4 +352,5 @@ function otherStuff() setupFormSubmit(); setupContractButton(); + setupEmailContractButton(); } diff --git a/templates/internshipView.tpl b/templates/internshipView.tpl index bab8d2d2..82d3b8ca 100644 --- a/templates/internshipView.tpl +++ b/templates/internshipView.tpl @@ -41,15 +41,6 @@
-
@@ -58,7 +49,7 @@ Toggle Dropdown