$criteria = array('columns' => "employers.id, employers.name, employers.contact_person, employers.email_addr", 'joins' => "employers ON employers.id = invoices.employer", 'match' => "invoices.id = " . $_POST['id'], 'limit' => "1"); $result = Invoice::find($criteria); if ($result === false || is_null($result) || count($result) <= 0) { echo '0'; exit; } $response = array('employer' => $result); header('Content-type: text/xml'); echo $xml_dom->get_xml_from_array($response); exit; } if ($_POST['action'] == 'resend') { $invoice = Invoice::get($_POST['id']); $invoice[0]['items'] = Invoice::getItems($_POST['id']); $employer = new Employer($invoice[0]['employer']); $recipients = $employer->getEmailAddress(); if (isset($_POST['recipients'])) { if (!empty($_POST['recipients'])) { $recipients = str_replace(';', ',', $_POST['recipients']); } } $branch = $employer->getAssociatedBranch(); $sales = 'sales.' . strtolower($branch[0]['country']) . '@yellowelevator.com'; $branch[0]['address'] = str_replace(array("\r\n", "\r"), "\n", $branch[0]['address']); $branch['address_lines'] = explode("\n", $branch[0]['address']); $currency = Currency::getSymbolFromCountryCode($branch[0]['country']); $amount_payable = 0.0; foreach ($invoice[0]['items'] as $i => $item) { $amount_payable += $item['amount']; $items[$i]['amount'] = number_format($item['amount'], 2, '.', ', '); }
$headers .= 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-Type: multipart/mixed; boundary="yel_mail_sep_' . $attached_filename . '";' . "\n\n"; $body = '--yel_mail_sep_' . $attached_filename . "\n"; $body .= 'Content-Type: multipart/alternative; boundary="yel_mail_sep_alt_' . $attached_filename . '"' . "\n"; $body .= '--yel_mail_sep_alt_' . $attached_filename . "\n"; $body .= 'Content-Type: text/plain; charset="iso-8859-1"' . "\n"; $body .= 'Content-Transfer-Encoding: 7bit"' . "\n"; $body .= $message . "\n"; $body .= '--yel_mail_sep_alt_' . $attached_filename . "--\n\n"; $body .= '--yel_mail_sep_' . $attached_filename . "\n"; $body .= 'Content-Type: ' . $filetype . '; name="' . $attached_filename . '"' . "\n"; $body .= 'Content-Transfer-Encoding: base64' . "\n"; $body .= 'Content-Disposition: attachment' . "\n"; $body .= $attachment . "\n"; $body .= '--yel_mail_sep_' . $attached_filename . "--\n\n"; $employer_emails = $employer->getEmailAddress(); if (!empty($_POST['hr_contacts'])) { $hr_contacts = explode(',', $_POST['hr_contacts']); foreach ($hr_contacts as $i => $hr_contact) { $hr_contacts[$i] = trim($hr_contact); } $employer_emails = implode(',', $hr_contacts); } $send = mail($employer_emails, $subject, $body, $headers); // $handle = fopen('/tmp/email_to_'. $employer->getEmailAddress(). '.txt', 'w'); // fwrite($handle, 'To: '. $employer_emails. "\n\n"); // fwrite($handle, 'Header: '. $headers. "\n\n"); // fwrite($handle, 'Subject: '. $subject. "\n\n"); // fwrite($handle, $body); // // if ($send === false) {
$employer = new Employer($_POST['id']); $employer->setAdmin(true); if ($employer->update($data) === false) { echo 'ko'; exit; } $lines = file(dirname(__FILE__) . '/../private/mail/employer_password_reset_admin.txt'); $message = ''; foreach ($lines as $line) { $message .= $line; } $message = str_replace('%user_id%', $_POST['id'], $message); $message = str_replace('%temporary_password%', $new_password, $message); $subject = "Employer Password Reset"; $headers = 'From: YellowElevator.com <*****@*****.**>' . "\n"; mail($employer->getEmailAddress(), $subject, $message, $headers); // $handle = fopen('/tmp/email_to_'. $employer->getEmailAddress(). '.txt', 'w'); // fwrite($handle, 'Subject: '. $subject. "\n\n"); // fwrite($handle, $message); // fclose($handle); echo 'ok'; exit; } /* if ($_POST['action'] == 'get_employer') { $employer = new Employer($_POST['id']); $result = $employer->get(); if (!$result) { echo "ko"; exit(); }
$message = str_replace('%amount%', $amount_payable, $message); $message = str_replace('%currency%', $currency, $message); $body .= $message . "\n"; $body .= '--yel_mail_sep_alt_' . $filename . "--\n\n"; $body .= '--yel_mail_sep_' . $filename . "\n"; $body .= 'Content-Type: application/pdf; name="yel_invoice_' . pad($invoice, 11, '0') . '.pdf"' . "\n"; $body .= 'Content-Transfer-Encoding: base64' . "\n"; $body .= 'Content-Disposition: attachment' . "\n"; $body .= $attachment . "\n"; $body .= '--yel_mail_sep_' . $filename . "\n"; $body .= 'Content-Type: application/pdf; name="yel_invoice_' . pad($invoice_copy, 11, '0') . '.pdf"' . "\n"; $body .= 'Content-Transfer-Encoding: base64' . "\n"; $body .= 'Content-Disposition: attachment' . "\n"; $body .= $attachment_copy . "\n"; $body .= '--yel_mail_sep_' . $filename . "--\n\n"; mail($employer->getEmailAddress(), $subject, $body, $headers); // $handle = fopen('/tmp/email_to_'. $employer->getEmailAddress(). '.txt', 'w'); // fwrite($handle, 'To: '. $employer->getEmailAddress(). "\n\n"); // fwrite($handle, 'Header: '. $headers. "\n\n"); // fwrite($handle, 'Subject: '. $subject. "\n\n"); // fwrite($handle, $body); unlink($GLOBALS['data_path'] . '/general_invoice/' . $filename . '.pdf'); unlink($GLOBALS['data_path'] . '/general_invoice/' . $filename_copy . '.pdf'); } else { if ($credit_amount > 0) { $credit_note_desc = 'Refund of balance for Invoice: ' . pad($previous_invoice, 11, '0'); $filename = generate_random_string_of(8) . '.' . generate_random_string_of(8); $expire_on = sql_date_add($issued_on, 30, 'day'); Invoice::accompanyCreditNoteWith($previous_invoice, $invoice, $issued_on, $credit_amount); $branch = $employer->getAssociatedBranch(); $sales = 'sales.' . strtolower($branch[0]['country']) . '@yellowelevator.com';