- Adds new column to the newsletter table

- Adds new newsletter notification history type
This commit is contained in:
Vlad
2016-07-14 20:22:14 -04:00
parent a5300624c2
commit 2c98270084
2 changed files with 21 additions and 2 deletions

View File

@@ -173,6 +173,7 @@ class Migrator {
function newsletters() { function newsletters() {
$attributes = array( $attributes = array(
'id mediumint(9) NOT NULL AUTO_INCREMENT,', 'id mediumint(9) NOT NULL AUTO_INCREMENT,',
'parent_id mediumint(9) NULL,',
'subject varchar(250) NOT NULL DEFAULT "",', 'subject varchar(250) NOT NULL DEFAULT "",',
'type varchar(20) NOT NULL DEFAULT "standard",', 'type varchar(20) NOT NULL DEFAULT "standard",',
'sender_address varchar(150) NOT NULL DEFAULT "",', 'sender_address varchar(150) NOT NULL DEFAULT "",',

View File

@@ -10,6 +10,7 @@ class Newsletter extends Model {
const TYPE_STANDARD = 'standard'; const TYPE_STANDARD = 'standard';
const TYPE_WELCOME = 'welcome'; const TYPE_WELCOME = 'welcome';
const TYPE_NOTIFICATION = 'notification'; const TYPE_NOTIFICATION = 'notification';
const TYPE_NOTIFICATION_HISTORY = 'notification_history';
// standard newsletters // standard newsletters
const STATUS_DRAFT = 'draft'; const STATUS_DRAFT = 'draft';
@@ -230,6 +231,15 @@ class Newsletter extends Model {
} }
static function filters($data = array()) { static function filters($data = array()) {
$type = isset($data['tab']) ? $data['tab'] : null;
// newsletter types without filters
if(in_array($type, array(
self::TYPE_NOTIFICATION_HISTORY
))) {
return false;
}
$segments = Segment::orderByAsc('name')->findMany(); $segments = Segment::orderByAsc('name')->findMany();
$segment_list = array(); $segment_list = array();
$segment_list[] = array( $segment_list[] = array(
@@ -239,7 +249,7 @@ class Newsletter extends Model {
foreach($segments as $segment) { foreach($segments as $segment) {
$newsletters = $segment->newsletters() $newsletters = $segment->newsletters()
->filter('filterType', $data['tab']) ->filter('filterType', $type)
->filter('groupBy', $data); ->filter('groupBy', $data);
$newsletters_count = $newsletters->count(); $newsletters_count = $newsletters->count();
@@ -308,6 +318,13 @@ class Newsletter extends Model {
static function groups($data = array()) { static function groups($data = array()) {
$type = isset($data['tab']) ? $data['tab'] : null; $type = isset($data['tab']) ? $data['tab'] : null;
// newsletter types without groups
if(in_array($type, array(
self::TYPE_NOTIFICATION_HISTORY
))) {
return false;
}
$groups = array( $groups = array(
array( array(
'name' => 'all', 'name' => 'all',
@@ -431,7 +448,8 @@ class Newsletter extends Model {
if(in_array($type, array( if(in_array($type, array(
self::TYPE_STANDARD, self::TYPE_STANDARD,
self::TYPE_WELCOME, self::TYPE_WELCOME,
self::TYPE_NOTIFICATION self::TYPE_NOTIFICATION,
self::TYPE_NOTIFICATION_HISTORY
))) { ))) {
$orm->where('type', $type); $orm->where('type', $type);
} }