mirror of
https://github.com/Oreolek/kangana.git
synced 2024-06-26 03:40:56 +03:00
Sending mail bugfix
This commit is contained in:
parent
105661d598
commit
717a755417
|
@ -66,7 +66,8 @@ class Model_Course extends ORM {
|
|||
|
||||
public static function count_letters($id)
|
||||
{
|
||||
return DB::select(array(DB::expr('COUNT(*)'), 'cnt'))->from('letters')->where('course_id', '=', $id)->execute()->get('cnt');
|
||||
$query = DB::select(array(DB::expr('COUNT(*)'), 'cnt'))->from('letters')->where('course_id', '=', $id);
|
||||
return $query->execute()->get('cnt');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,28 +84,29 @@ class Model_Course extends ORM {
|
|||
return ($count == 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ID of all courses which have subscribers
|
||||
**/
|
||||
public static function get_ids()
|
||||
{
|
||||
return DB::select('id')->from('courses')->execute()->get('id');
|
||||
return DB::select('course_id')->from('clients_courses')->execute()->get('course_id');
|
||||
}
|
||||
|
||||
public static function get_period($course_id)
|
||||
{
|
||||
return DB::select('period')
|
||||
$query = DB::select('period')
|
||||
->from('courses')
|
||||
->where('course_id', '=', $course_id)
|
||||
->execute()
|
||||
->get('period');
|
||||
->where('id', '=', $course_id);
|
||||
return $query->execute()->get('period');
|
||||
}
|
||||
|
||||
public static function get_letter_ids($course_id)
|
||||
{
|
||||
return DB::select('id')
|
||||
$query = DB::select('id')
|
||||
->from('letters')
|
||||
->where('course_id', '=', $course_id)
|
||||
->order_by('order')
|
||||
->execute()
|
||||
->get('id');
|
||||
->order_by('order');
|
||||
return $query->execute()->as_array(NULL, 'id');
|
||||
}
|
||||
public static function get_client_ids($course_id)
|
||||
{
|
||||
|
|
|
@ -93,7 +93,7 @@ class Model_Task extends ORM {
|
|||
->and_where('status', '=', self::STATUS_SENT)
|
||||
->and_where('client_id', '=', $client_id)
|
||||
->execute()
|
||||
->get('letter_id');
|
||||
->as_array(NULL, 'letter_id');
|
||||
if (is_array($letters))
|
||||
{
|
||||
$diff = array_diff($letters, $sent_letters);
|
||||
|
|
|
@ -14,6 +14,11 @@ class Task_Prepare extends Minion_Task
|
|||
**/
|
||||
protected function prepare_course($course)
|
||||
{
|
||||
if (is_null($course))
|
||||
{
|
||||
Log::instance()->add(Log::ERROR, 'Course ID is NULL when preparing');
|
||||
return;
|
||||
}
|
||||
$count = Model_Course::count_letters($course);
|
||||
if ($count == 0)
|
||||
return;
|
||||
|
@ -58,6 +63,7 @@ class Task_Prepare extends Minion_Task
|
|||
$db->begin();
|
||||
try
|
||||
{
|
||||
// get courses which have subscribers
|
||||
$courses = Model_Course::get_ids();
|
||||
if (!is_array($courses))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue