コード例 #1
0
ファイル: UserJob.php プロジェクト: quynhvv/stepup
 public static function getFavouriteJob($seekerId = null)
 {
     //get job ids favourites by current seeker
     $favourites = UserFavourite::findAll(['object_type' => 'job', 'created_by' => $seekerId]);
     $ids = array();
     if ($favourites) {
         foreach ($favourites as $favourite) {
             $ids[] = $favourite->object_id;
         }
     }
     //search candidate by ids
     $dataProvider = null;
     if ($ids) {
         $model = new Job();
         $model->setScenario('search');
         $params = Yii::$app->request->getQueryParams();
         $params['Job']['_ids'] = $ids;
         $dataProvider = $model->search($params, 20);
     }
     return $dataProvider;
 }
コード例 #2
0
ファイル: job-detail.php プロジェクト: quynhvv/stepup
<!-- MAIN -->
<main id="main" class="main-container">
    <!-- SECTION 1 -->
    <div class="section section-1">
        <div class="container">
            <div class="section-inner">
                <div class="section-content layout-2cols-right">
                    <div class="row">
                        <div class="col-xs-12 col-sm-9 col-main section-gap">
                            <div class="table-responsive">
                                <table id="jobdetail" class="table table-bordered table-striped table-hover">
                                    <tbody>
                                    <tr>
                                        <th colspan="2">
                                            <?php 
if (\app\modules\job\models\UserFavourite::isFavourite($model->_id, 'job', Yii::$app->user->id)) {
    $class = "favourites";
    $title = Yii::t('job', 'Remove from favourites list?');
} else {
    $class = "un-favourites";
    $title = Yii::t('job', 'Add to favourites list?');
}
echo Html::a('<i class="fa fa-star"></i>', ['account/favourite'], ['title' => $title, 'class' => $class, 'onclick' => 'js:favourite($(this)); return false', 'data-id' => $model->_id, 'data-type' => 'job']);
?>
                                        </th>
                                        <th class="text-center"><a href="javascript:history.back()">Back</a></th>
                                    </tr>
                                    <tr>
                                        <td align="left" colspan="2">
                                            <h4>Job Overview</h4>
                                        </td>
コード例 #3
0
ファイル: AccountController.php プロジェクト: quynhvv/stepup
 public function actionFavourite()
 {
     Yii::$app->response->format = 'json';
     $params = Yii::$app->request->post();
     $result = array();
     $model = UserFavourite::findOne(['object_id' => $params['object_id'], 'object_type' => $params['object_type'], 'created_by' => Yii::$app->user->id]);
     if (!$model) {
         $model = new UserFavourite();
         $model->setScenario('create');
         $model->object_id = $params['object_id'];
         $model->object_type = $params['object_type'];
         $model->created_by = Yii::$app->user->id;
         $model->created_time = new \MongoDate();
         if ($model->save()) {
             $result['status'] = 'ok';
             $result['action'] = 'add';
             $result['message'] = Yii::t('job', 'Added to favourites list successfully.');
         } else {
             $result['status'] = 'fail';
             $result['message'] = Yii::t('job', 'There is a error. Please try a gain.');
         }
     } else {
         //unfavourite
         if ($model->delete()) {
             $result['status'] = 'ok';
             $result['action'] = 'remove';
             $result['message'] = Yii::t('job', 'Removed from favourites list successfully.');
         } else {
             $result['status'] = 'fail';
             $result['message'] = Yii::t('job', 'There is a error. Please try a gain.');
         }
     }
     return $result;
 }
コード例 #4
0
ファイル: UserFavourite.php プロジェクト: quynhvv/stepup
 public static function isFavourite($objectId, $objectType, $createdBy)
 {
     $model = UserFavourite::findOne(['object_id' => $objectId, 'object_type' => $objectType, 'created_by' => $createdBy]);
     return $model ? true : false;
 }
コード例 #5
0
use yii\helpers\Url;
?>

<?php 
$form = ActiveForm::begin([]);
?>

<!-- MAIN -->
<main id="main" class="main-container">
    <!-- SECTION 1 -->
    <div class="section section-1">
        <div class="container">
            <div class="section-title section-title-style-1">
                <h2 class="title">
                    <?php 
if (\app\modules\job\models\UserFavourite::isFavourite($user->_id, 'seeker', Yii::$app->user->id)) {
    $class = "favourites";
    $title = Yii::t('job', 'Remove from favourites list?');
} else {
    $class = "un-favourites";
    $title = Yii::t('job', 'Add to favourites list?');
}
echo Html::a('<i class="fa fa-star"></i>', ['account/favourite'], ['title' => $title, 'class' => $class, 'onclick' => 'js:favourite($(this)); return false', 'data-id' => $user->_id, 'data-type' => 'seeker']);
?>
                    <?php 
echo $this->title;
?>
                </h2>
            </div>

            <div class="row">