public static function loadLatestDebtRecovery($user_id, $year, $month) { foreach (Model_Debit_Date::all() as $debit_date) { if (!is_numeric($month) || !in_array(intval($month), range(1, 12))) { $month = intval(date('m')); } if (!is_numeric($year) || intval($year) < 2015) { $year = intval(date('Y')); } $debt_recovery = Model_Debt_Recovery::find_by_debit_date_id_and_year_and_month($debit_date->id, $year, $month); if (is_null($debt_recovery)) { $debt_recovery = Model_Debt_Recovery::create(array('debit_date_id' => $debit_date->id, 'year' => intval($year), 'month' => intval($month), 'user_id' => $user_id)); if (is_null($debt_recovery)) { continue; } } // sms template try { $debt_recovery->sms_template_id = Model_Message_Template::find_by_key('debt_manager.recovery.sms')->id; $debt_recovery->save(); } catch (Exception $ex) { echo $ex->getMessage(); } // email template try { $debt_recovery->email_template_id = Model_Message_Template::find_by_key('debt_manager.recovery.email')->id; $debt_recovery->save(); } catch (Exception $ex) { echo $ex->getMessage(); } } }
<div class="container"> <b>Tracetec Debt Recovery - Reports</b> <p><br>Below is a list of debt recovery runs for the selected month period:</p> <p><?php echo $date_picker->render(true); ?> </p> <p> </p> <?php $debt_recovery = Model_Debt_Recovery::find_all_by_month_and_year($date_picker->getMonth(), $date_picker->getYear()); if (count($debt_recovery) > 0) { ?> <table width="95%" border="1"> <thead> <tr> <th>Month</th> <th>Debit Date</th> <th>Data File</th> <th>Debtors</th> <th>Templates</th> <th>Actions</th> </tr> </thead> <tbody> <?php
<?php if (session_id() == '') { session_start(); } ob_start(); require_once dirname(__FILE__) . '/_autoload.php'; $user_id = isset($_SESSION['adminId']) && intval($_SESSION['adminId']) > 0 ? intval($_SESSION['adminId']) : 0; if ($user_id < 1) { header('Location: login.php'); exit; } // http://dev.tracetec.co.za/debt-recovery-runs.php?debt_recovery_id=2 $recovery_id = isset($_REQUEST['debt_recovery_id']) ? intval($_REQUEST['debt_recovery_id']) : 0; $debt_recovery = Model_Debt_Recovery::find_by_id($recovery_id); if (is_null($debt_recovery)) { header('Location: debt-recovery.php'); exit; } $date_picker = new Date_Picker($debt_recovery->year, $debt_recovery->month); $subMenus = Tracetec_Debt_Manager::getSubMenus(); include "include/head.php"; $option = isset($_REQUEST['option']) ? trim(strtolower($_REQUEST['option'])) : ''; switch ($option) { case 'send-sms-to-all': // take as much time as you want :) set_time_limit(0); require_once dirname(__FILE__) . '/debt-recovery/lib/higate.php'; $errmsg = ''; $debug = true; $return = array();