added new custom logical mails for preorder
This commit is contained in:
@@ -286,7 +286,12 @@ class Preordercampaign extends mfBaseModel {
|
||||
return [];
|
||||
}
|
||||
foreach($snmts as $snmt) {
|
||||
$this->statusnotifcation_mailtemplates[$snmt->status_code] = $snmt;
|
||||
if ($snmt->status_code !== null) {
|
||||
$this->statusnotifcation_mailtemplates[$snmt->status_code] = $snmt;
|
||||
} else {
|
||||
$logical_config = json_decode($snmt->logical_config, true);
|
||||
$this->statusnotifcation_mailtemplates[$logical_config['type']] = $snmt;
|
||||
}
|
||||
}
|
||||
return $this->statusnotifcation_mailtemplates;
|
||||
}
|
||||
|
||||
@@ -476,39 +476,50 @@ class PreordercampaignController extends mfBaseController {
|
||||
$allow_on_skip = $status_data["allow_on_skip"];
|
||||
$prevent_previous = $status_data["prevent_previous"];
|
||||
|
||||
/*if($status_code == 920) {
|
||||
var_dump($status_data);exit;
|
||||
}*/
|
||||
|
||||
if(!$mailtemplate_id && !$allow_on_skip && !$prevent_previous) {
|
||||
$mailtemplates_delete[] = $status_code;
|
||||
continue;
|
||||
}
|
||||
|
||||
if($status_code == 920) {
|
||||
//var_dump($status_data, $allow_on_skip, $prevent_previous);exit;
|
||||
}
|
||||
|
||||
|
||||
if($mailtemplate_id) {
|
||||
// check if Mailtemplate exists
|
||||
$mailtemplate = new Mailtemplate($mailtemplate_id);
|
||||
if(!$mailtemplate || !$mailtemplate->id) continue;
|
||||
}
|
||||
|
||||
$mt_data = [
|
||||
"preordercampaign_id" => $campaign->id,
|
||||
"status_code" => $status_code,
|
||||
"mailtemplate_id" => ($mailtemplate_id) ? $mailtemplate->id : null,
|
||||
"allow_on_skip" => ($allow_on_skip) ? 1 : 0,
|
||||
"prevent_previous" => ($prevent_previous) ? 1 : 0,
|
||||
];
|
||||
// if status_code is only numbers then log it and die for debugging
|
||||
if(preg_match("/^\d+$/", $status_code)) {
|
||||
$mt_data = [
|
||||
"preordercampaign_id" => $campaign->id,
|
||||
"status_code" => $status_code,
|
||||
"mailtemplate_id" => ($mailtemplate_id) ? $mailtemplate->id : null,
|
||||
"allow_on_skip" => ($allow_on_skip) ? 1 : 0,
|
||||
"prevent_previous" => ($prevent_previous) ? 1 : 0,
|
||||
];
|
||||
|
||||
$statusmailtemplate = PreordercampaignStatusnotificationMailtemplate::getFirst(["preordercampaign_id" => $campaign->id, "status_code" => $status_code]);
|
||||
if($statusmailtemplate) {
|
||||
$statusmailtemplate->update($mt_data);
|
||||
$statusmailtemplate = PreordercampaignStatusnotificationMailtemplate::getFirst(["preordercampaign_id" => $campaign->id, "status_code" => $status_code]);
|
||||
if($statusmailtemplate) {
|
||||
$statusmailtemplate->update($mt_data);
|
||||
} else {
|
||||
$statusmailtemplate = PreordercampaignStatusnotificationMailtemplate::create($mt_data);
|
||||
}
|
||||
} else {
|
||||
$statusmailtemplate = PreordercampaignStatusnotificationMailtemplate::create($mt_data);
|
||||
$mt_data = [
|
||||
"preordercampaign_id" => $campaign->id,
|
||||
"notification_type" => "logical",
|
||||
"logical_config" => json_encode(["type" => $status_code]),
|
||||
"mailtemplate_id" => ($mailtemplate_id) ? $mailtemplate->id : null,
|
||||
"allow_on_skip" => ($allow_on_skip) ? 1 : 0,
|
||||
"prevent_previous" => ($prevent_previous) ? 1 : 0,
|
||||
];
|
||||
|
||||
$statusmailtemplate = PreordercampaignStatusnotificationMailtemplate::getFirst(["preordercampaign_id" => $campaign->id, "logical_config" => json_encode(["type" => $status_code])]);
|
||||
if($statusmailtemplate) {
|
||||
$statusmailtemplate->update($mt_data);
|
||||
} else {
|
||||
|
||||
$statusmailtemplate = PreordercampaignStatusnotificationMailtemplate::create($mt_data);
|
||||
}
|
||||
}
|
||||
|
||||
if(!$statusmailtemplate->save()) {
|
||||
|
||||
+10
-1
@@ -46,7 +46,7 @@ class PreordercampaignStatusnotificationMailtemplate extends mfBaseModel {
|
||||
$model = new PreordercampaignStatusnotificationMailtemplate();
|
||||
|
||||
$table_fields = [
|
||||
"preordercampaign_id", "status_code", "mailtemplate_id", "allow_on_skip", "prevent_previous",
|
||||
"preordercampaign_id", "status_code", "mailtemplate_id", "allow_on_skip", "prevent_previous","notification_type","logical_config",
|
||||
"result","create_by","edit_by","create","edit"
|
||||
];
|
||||
|
||||
@@ -174,6 +174,15 @@ class PreordercampaignStatusnotificationMailtemplate extends mfBaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("logical_config", $filter)) {
|
||||
$logical_config = $filter['logical_config'];
|
||||
if(is_array($logical_config) && count($logical_config)) {
|
||||
$where .= " AND PreordercampaignStatusnotificationMailtemplate.notification_type='logical' AND PreordercampaignStatusnotificationMailtemplate.logical_config = '" . json_encode($logical_config) . "'";
|
||||
} elseif(is_string($logical_config)) {
|
||||
$where .= " AND PreordercampaignStatusnotificationMailtemplate.notification_type='logical' AND PreordercampaignStatusnotificationMailtemplate.logical_config LIKE '%" . $logical_config . "%'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("mailtemplate_id", $filter)) {
|
||||
$mailtemplate_id = $filter['mailtemplate_id'];
|
||||
if(is_numeric($mailtemplate_id)) {
|
||||
|
||||
Reference in New Issue
Block a user