File: /home/awaldron/_buildinmotion/bim_ci/app/Controllers/Contact.php
<?php namespace App\Controllers;
class Contact extends BaseController
{
public function index()
{
$data = [];
$data['title'] = 'Contact Us';
$data['description'] = 'Build in Motion is a custom software engineering firm headquartered in Pittsburgh, PA. Contact us today to discuss your unique project requirements.';
$data['canon'] = 'https://buildinmotion.com/contact';
$data['nav'] = 'contact';
$html = view('_header', $data);
$html .= view('_header_ui', $data);
$html .= view('contact');
$html .= view('_footer', $data);
$html .= view('_footer_ui');
return $html;
}
//--------------------------------------------------------------------
public function sendcontact()
{
$post = $this->request->getPost();
$session = \Config\Services::session();
$locale = $session->get('locale');
// $msg = "<!channel|channel>" .
// "\n*Name*.........: " . $post['name'] .
// "\n*Email*........: " . $post['email'] .
// "\n*Phone*........: " . $post['phone'] .
// "\n*Date*.........: " . date("F j, Y, g:i a") .
// "\n*Referral*.....: " . $post['referral'] .
// "\n*Locale*.......: " . $locale .
// (strlen($post['message']) > 0 ? "\n\n*Description of Work*:\n".$post['message'] : '');
// SUBMIT TO SLACK
// $data = '{
// "blocks": [{
// "type": "section",
// "text": {
// "type": "mrkdwn",
// "text": "'.$msg.'"
// }
// },{
// "type": "divider"
// },{
// "type": "section",
// "text": {
// "type": "mrkdwn",
// "text": "*Reply to '.$post['name'].'*"
// },
// "accessory": {
// "type": "button",
// "text": {
// "type": "plain_text",
// "text": "Reply",
// "emoji": true
// },
// "value": "click_me_123",
// "url": "mailto:'.$post['email'].'?subject=RE:%20Build%20in%20Motion%20-%20Contact%20Us",
// "action_id": "button-action"
// }
// }]
// }';
//
// $url = 'https://hooks.slack.com/services/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';
// $ch = curl_init($url);
// curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
// curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// $result = curl_exec($ch);
// curl_close($ch);
// SUBMIT TO TEAMS
date_default_timezone_set('America/New_York');
$msg = date("F j, Y, g:i a") .
"<br/><br/>Name.........: " . $post['name'] .
"<br/>Company......: " . $post['company'] .
"<br/>Email........: " . $post['email'] .
"<br/>Phone........: " . $post['phone'] .
"<br/>Referral.....: " . $post['referral'] .
"<br/>Locale.......: " . $locale .
(strlen($post['message']) > 0 ? "<br/><br/>Description of Work:<br/>".$post['message'] : '');
$webhook_url = 'https://mayvuecom.webhook.office.com/webhookb2/5627bfd5-6a23-42db-80e9-80b63487b8aa@ff7a3e78-b2e3-4501-bdf4-48ed30b3d6f6/IncomingWebhook/388a9da83c9b488aa015ba95656aba82/e330f68c-84a8-4f13-8a0f-56fe37cd1ef1/V2yg7ZAhN2P-PPoi77K9AbnzYefXxvL3OSF9DzaRewzSM1';
$form_data = [
'title' => $post['name'] . (strlen($post['company']) > 0 ? ' @ '.$post['company'] : ''),
'text' => $msg
];
$options = [
'http' => [
'header' => "Content-Type: application/json\r\n",
'method' => 'POST',
'content' => json_encode($form_data),
],
];
$context = stream_context_create($options);
$result = file_get_contents($webhook_url, false, $context);
// if ($result === FALSE) {
// echo "Error posting to Teams";
// } else {
// echo "Message posted to Teams";
// }
$json['success'] = $result;
header('Content-Type: application/json; charset=utf-8');
echo json_encode($json);
}
//--------------------------------------------------------------------
public function sendresume()
{
$post = $this->request->getPost();
$file = $this->request->getFile('file');
$file->move(WRITEPATH . 'uploads');
$filepath = WRITEPATH . 'uploads/' . $file->getName();
/* SEND TO SLACK *****************************************************************************************/
$msg = "<!channel|channel>" .
"\n*New applicaiton for " . $post['jobtitle'] . "*" .
"\n" .
"\n*Name*.........: " . $post['name'] .
"\n*Email*.........: " . $post['email'] .
"\n*Phone*........: " . $post['phone'] .
"\n*Date*..........: " . date("F j, Y, g:i a") .
"\n\n*Pay Range*.....: " . $post['salary'] .
"\n*Eligibility*........: " . $post['eligibility'] .
"\n*Employment Type*..: " . $post['employStatus'] .
(strlen($post['message']) > 0 ? "\n\n*Message*:\n".$post['message'] : '');
// SEND FILE TO SLACK
$header = array();
$header[] = 'Content-Type: multipart/form-data';
$curlFile = curl_file_create($filepath);
$channel = "C038SC1UG7N";
if ((($post['salaryNum'] <= 125000 && $post['salaryTerm']==='year') ||
($post['salaryNum'] <= 75 && $post['salaryTerm']==='hour') ||
$post['jobtitle'] === "Business Development Manager")
&&
$post['eligibility'] === "I am a US citizen and can work in the US"
) {
$channel = "C04LSANAZ8T";
}
$postitems = array(
'token' => "xoxb-474975102758-3308682216273-XaU0cQlotoOTM6uLwjTOI5Bh",
'channels' => $channel,
'file' => $curlFile,
'title' => $file->getName(),
'initial_comment' => $msg,
'filename' => $file->getName()
);
$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch2, CURLOPT_URL, "https://slack.com/api/files.upload");
curl_setopt($ch2, CURLOPT_POST, 1);
curl_setopt($ch2, CURLOPT_POSTFIELDS, $postitems);
//Execute curl and store in variable
$res2 = curl_exec($ch2);
curl_close($ch2);
unlink($filepath);
$json['success'] = true;
header('Content-Type: application/json; charset=utf-8');
echo json_encode($json);
}
public function sendresumebackup()
{
$email = \Config\Services::email();
$post = $this->request->getPost();
$file = $this->request->getFile('file');
$file->move(ROOTPATH . 'public/resups');
$filepath = ROOTPATH . 'public/resups/' . $file->getName();
/* SEND TO SLACK *****************************************************************************************/
$msg = "<!channel|channel>" .
"\n*" . $post['jobtitle'] . "*" .
"\n" .
"\n*Name*.........: " . $post['name'] .
"\n*Email*........: " . $post['email'] .
"\n*Phone*........: " . $post['phone'] .
"\n*Date*.........: " . date("F j, Y, g:i a") .
(strlen($post['message']) > 0 ? "\n\n*Message*:\n".$post['message'] : '');
$data = '{
"blocks": [{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "'.$msg.'"
}
},{
"type": "divider"
},{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*View '.$post['name'].'\'s Resume*"
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "View",
"emoji": true
},
"value": "click_me_123",
"url": "https://buildinmotion.com/resups/'.$file->getName().'",
"action_id": "button-action"
}
}]
}';
if (strlen($post['comments']) === 0) {
$url = 'https://hooks.slack.com/services/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';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
}
$json['success'] = true;
header('Content-Type: application/json; charset=utf-8');
echo json_encode($json);
}
public function sendresumeviaemail()
{
$email = \Config\Services::email();
$config['protocol'] = 'smtp';
$config['SMTPHost'] = 'mail.smtp2go.com';
$config['SMTPPort'] = '2525'; // 8025, 587 and 25 can also be used. Use Port 465 for SSL.
$config['SMTPCrypto'] = 'tls';
$config['SMTPUser'] = 'buildinmotion';
$config['SMTPPass'] = 'Y3FldXgwejZlaGww';
$config['charset'] = 'utf-8';
$config['mailtype'] = 'html';
$config['newline'] = "rn";
$post = $this->request->getPost();
$file = $this->request->getFile('file');
$file->move(WRITEPATH . 'uploads');
$filepath = WRITEPATH . 'uploads/' . $file->getName();
$msg = "<p style='line-height:1.6em'>" .
"<b>Position</b>.......: " . $post['jobtitle'] .
"<br/> " .
"<br/><b>Name</b>.......: " . $post['name'] .
"<br/><b>Email</b>........: " . $post['email'] .
"<br/><b>Phone</b>......: " . $post['phone'] .
"<br/><b>Date</b>.........: " . date("F j, Y, g:i a") .
"<p style='line-height:1.6em'><b>Message</b>:<br/>".$post['message']."</p>";
if (strlen($post['comments']) === 0) {
$email->initialize($config);
$email->setFrom('noreply@buildinmotion.com');
//$email->setTo('resumes-aaaaf77yrxziixco4jvhmr36ia@buildinmotion.slack.com');
$email->setTo('awaldron@buildinmotion.com, sbechtold@buildinmotion.com, cmckenna@buildinmotion.com');
$email->setSubject('Build in Motion: Submit Resume');
$email->setMessage($msg);
$email->attach($filepath);
$email->send();
// DELETE FILE FROM SERVER
unlink($filepath);
}
$json['success'] = true;
header('Content-Type: application/json; charset=utf-8');
echo json_encode($json);
}
public function sendcontactviaemail()
{
$email = \Config\Services::email();
$config['protocol'] = 'smtp';
$config['SMTPHost'] = 'mail.smtp2go.com';
$config['SMTPPort'] = '2525'; // 8025, 587 and 25 can also be used. Use Port 465 for SSL.
$config['SMTPCrypto'] = 'tls';
$config['SMTPUser'] = 'buildinmotion';
$config['SMTPPass'] = 'Y3FldXgwejZlaGww';
$config['charset'] = 'utf-8';
$config['mailtype'] = 'html';
$config['newline'] = "rn";
$post = $this->request->getPost();
$msg = "<p style='line-height:1.6em'><b>Name</b>.......: " . $post['name'] .
"<br/><b>Email</b>........: " . $post['email'] .
"<br/><b>Phone</b>......: " . $post['phone'] .
"<br/><b>Date</b>.........: " . date("F j, Y, g:i a") .
"<br/><b>Referral</b>...: " . $post['referral'] . "</p>" .
"<p style='line-height:1.6em'><b>Description of Work</b>:<br/>".$post['message']."</p>";
if (strlen($post['comments']) === 0) {
$email->initialize($config);
$email->setFrom('noreply@buildinmotion.com');
$email->setTo('awaldron@buildinmotion.com, sbechtold@buildinmotion.com, cmckenna@buildinmotion.com');
$email->setSubject('Build in Motion: Contact Us');
$email->setMessage($msg);
$email->send();
}
$json['success'] = true;
header('Content-Type: application/json; charset=utf-8');
echo json_encode($json);
}
}