コード例 #1
0
 public function clearDebtors()
 {
     // exclusion
     if ($recovery = Model_Debt_Recovery::find_by_id($this->DebtRecoveryId)) {
         foreach (Model_Debt_Recovery_Run::find_all_by_debt_recovery_id($recovery->id) as $run) {
             // find message count
             if (Model_Message_Log::count(array('conditions' => array('debt_recovery_id = ?', $run->id)) == 0)) {
                 $run->delete();
             }
         }
     }
     $this->Debtors = array();
     return $this;
 }
                }
                $message = str_replace("{{client-name}}", $client->get_customer()->get_fullname(), $template->template);
                $message = str_replace("{{outstanding-amount}}", number_format($client->amount_due, 2), $message);
                $message = str_replace("{{billing-number}}", $client->customer_id, $message);
                $mailer = new PHPMailer();
                $mailer->From = '*****@*****.**';
                $mailer->FromName = "Tracetec Debt Recovery";
                $mailer->addAddress($email, $client->get_customer()->get_fullname());
                $mailer->addBCC("*****@*****.**", "Gavin Murambadoro");
                $mailer->addReplyTo("*****@*****.**", "Tracetec Direct Marketing");
                $mailer->Subject = 'Tracetec Debt Recovery';
                $mailer->Body = $message;
                $mailer->AltBody = $message;
                if ($mailer->send()) {
                    $email_count++;
                    if (Model_Message_Log::create(array('billing_id' => $client->customer_id, 'user_id' => 0, 'firstname' => $client->get_customer()->custfirstname, 'surname' => $client->get_customer()->custsurname, 'date_sent' => date('Y-m-d H:i:s'), 'debt_recovery_id' => $client->id, 'message' => $message, 'reference_number' => uniqid(), 'status' => 0, 'module_name' => 'phpmailer', 'created_by' => $user_id, 'cell_number' => $client->get_customer()->custcellno, 'email' => $email)) != null) {
                        // add note
                        Model_Customer_Note::create(array('notescustomerid' => $client->customer_id, 'notescreated' => date('Y-m-d H:i:s'), 'notes' => 'Debt Recovery (Email) (Sent to ' . $email . ') => ' . $message, 'notescreatedby' => $user_id));
                    }
                }
            }
            $debt_recovery->email_sent = $email_count;
            $debt_recovery->save();
        } else {
            //
        }
        header('Location: admin-debt-recovery-debtors.php?debt_recovery_id=' . $debt_recovery->id);
        exit;
        break;
}
?>
    $recovery_id = isset($_REQUEST['debt_recovery_id']) ? trim(strtolower($_REQUEST['debt_recovery_id'])) : 0;
    if ($recovery_id > 0) {
        $ids = Model_Debt_Recovery_Run::find_all_by_debt_recovery_id($recovery_id);
        switch ($message_type) {
            case 'sms':
                $messages = Model_Message_Log::all(array('conditions' => array('debt_recovery_id in (?) and module_name in (?) ', ActiveRecord\collect($ids, 'id'), array('higate'))));
                break;
            case 'email':
                $messages = Model_Message_Log::all(array('conditions' => array('debt_recovery_id in (?) and module_name in (?) ', ActiveRecord\collect($ids, 'id'), array('phpmailer'))));
                break;
            default:
                $messages = Model_Message_Log::all(array('order' => 'created_at desc', 'limit' => 100, 'offset' => 0, 'conditions' => array('debt_recovery_id in (?) ', ActiveRecord\collect($ids, 'id'))));
                break;
        }
    } else {
        $messages = Model_Message_Log::all(array('order' => 'created_at desc', 'limit' => 100, 'offset' => 0));
    }
}
if (count($messages) > 0) {
    ?>
<table width="100%" border="1">
    <thead>
        <tr>
            <th>Billing ID</th>
            <th>Customer</th>
            <th>Date Sent</th>
            <th>Cell Number</th>
            <th>Email</th>
            <th>Status</th>
            <th>Reference</th>
            <th>Module</th>