/** * @param string $description ---> enter the title or entry of model * @param object $model ---> enter lastest saved model * @param object $user ---> creater of the notification record (mostly current user model) * @param string $type ---> current controller name or a manualy hard coded string for comments (comment,journal,mood,event,photo,activity) * @param string $shared_with ---> shared_with values if latest saved model has a column named shared_with, else need to enter customized values */ public function notify($description, $model, $user, $type, $shared_with = null) { //create notification record - DTR $sharedWith = array(); if ($shared_with != null) { if ($shared_with == '*') { $sharedWith = yii\helpers\ArrayHelper::getColumn($user->others, 'id'); } else { $sharedWith = explode(',', $shared_with); } } else { $sharedWith = yii\helpers\ArrayHelper::getColumn($user->findParents()->all(), 'id'); } foreach ($sharedWith as $shared_id) { $notify = new Notification(); $notify->date = date("Y-m-d h:i:s"); $notify->shared_id = (int) $shared_id; $notify->type_id = $model->id; $notify->description = $description; $notify->type = $type; $notify->user_id = $user->id; $notify->status = 0; $notify->save(); } //end of notification record entry }
public function getSharedWith($withoutWrapper = false) { $shared_users = User::find()->where(['id' => explode(",", $this->shared_with)])->all(); if ($withoutWrapper) { return implode(', ', yii\helpers\ArrayHelper::getColumn($shared_users, 'fullname')); } else { return "<span class='label label-success'>" . implode('</span> <span class="label label-success">', yii\helpers\ArrayHelper::getColumn($shared_users, 'fullname')) . "</span>"; } }
$items = yii\helpers\ArrayHelper::map(\app\models\Category::find()->all(), 'id_categoria', 'nombre_categoria'); echo Html::label('Categorias'); echo Html::dropDownList('lista-categorias', '', $items, ['class' => 'form-control', 'prompt' => 'Elija una categoria Superior', 'onchange' => 'cambiarChecklist($(this).val())']); ?> </div> </div> <?php \yii\widgets\Pjax::begin(); ?> <?php $items = yii\helpers\ArrayHelper::map(\app\models\CategoryGoogle::find()->all(), 'id', 'nombre'); $model->categoryGoogles = yii\helpers\ArrayHelper::getColumn($model->getCategoryGoogles(), 'id'); echo $form->field($model, 'categoryGoogles')->checkboxList($items, ['class' => '']); ?> <?php \yii\widgets\Pjax::end(); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> <?php