public static function saveSettingsChanged($settings, $model, $id) { // save checklist configruatiion for this client if (!empty($settings)) { $one_time = FALSE; foreach ($settings as $key => $value) { if (isset($value['checklists_id'])) { $setting = new Csetting(); $setting->checklists_id = $value['checklists_id']; } elseif (isset($value['messages_id'])) { $setting = new Msetting(); $setting->messages_id = $value['messages_id']; } $setting->belong_to = $value['belong_to']; $setting->clients_or_webs_id = $id; // remove all current settings only one time by $one_time flag if (!$one_time) { $model->deleteAll(['clients_or_webs_id' => $setting->clients_or_webs_id, 'belong_to' => $setting->belong_to]); } $one_time = TRUE; $setting->save(); } } else { $model->deleteAll(['clients_or_webs_id' => $id]); } }
public function getMsetting() { return $this->hasMany(Msetting::className(), ['clients_or_webs_id' => 'id'])->where('belong_to =:belong_to', [':belong_to' => 1])->orderBy('id'); }
<div class="block-title"> <h2><i class="fa fa-envelope"></i> Messages</h2> </div> <!-- END Message Title --> <span class="help-block">Activate automatically messages which will be sent to the client email address.</span> <!-- Message Content --> <div class="form-horizontal form-bordered" id="setting-messages"> <?php $messages = Message::getMessageBelong($belong_to); if (!empty($messages)) { foreach ($messages as $key => $message) { if (!empty($message->mschedule)) { $checked = FALSE; $msetting = Msetting::find()->where(['clients_or_webs_id' => $idcow, 'belong_to' => $belong_to, 'messages_id' => $message->id])->one(); if (isset($msetting)) { $checked = TRUE; } ?> <div class="form-group"> <label class="col-md-6 control-label"><?php echo $message->subject; ?> </label> <div class="col-md-6"> <label class="switch switch-primary"> <input type="checkbox" id="product-status mswitch-<?php echo $message->id; ?> " name="product-status" class="switch-action" data-messages-id="<?php
public function getMsettings() { return $this->hasMany(Msetting::className(), ['messages_id' => 'messages_id']); }
/** * @inheritdoc */ public function afterDelete() { // remove all messages settings Msetting::deleteAll('clients_or_webs_id = :clients_or_webs_id AND belong_to = :belong_to', [':clients_or_webs_id' => $this->id, ':belong_to' => 2]); Csetting::deleteAll('clients_or_webs_id = :clients_or_webs_id AND belong_to = :belong_to', [':clients_or_webs_id' => $this->id, ':belong_to' => 2]); parent::afterDelete(); }