Exemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Offer::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'is_available' => $this->is_available, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'announcement', $this->announcement])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'title', $this->title]);
     return $dataProvider;
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Offer::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'email' => $this->email, 'catgry' => $this->catgry, 'priority' => $this->priority, 'expires' => $this->expires, 'added' => $this->added]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'website', $this->website])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'location', $this->location])->andFilterWhere(['like', 'descript', $this->descript]);
     return $dataProvider;
 }
Exemplo n.º 3
0
 public function actionFeed($type = 'xml')
 {
     Yii::$app->response->format = \yii\web\Response::FORMAT_RAW;
     $headers = Yii::$app->response->headers;
     switch ($type) {
         case 'xml':
             $offers = Offer::find()->all();
             $headers->add('Content-Type', 'text/xml; charset=utf-8');
             $data = '<rss><channel>';
             $data .= '<title> *** GdeZaVikend Ponude *** </title><items>';
             foreach ($offers as $offer) {
                 $data .= '<item><name>' . $offer->name . '</name>' . '<description><![CDATA[' . $offer->descript . ']]></description>' . '<website><![CDATA[' . $offer->website . ']]></website>' . '<published>' . $offer->added . '</published></item>';
             }
             $data .= '</items></channel>';
             $data .= '</rss>';
             echo $data;
             break;
         case 'json':
             $offers = Offer::find()->select('name, descript, website, email')->asArray()->all();
             $headers->add('Content-Type', 'application/json');
             echo json_encode($offers);
             break;
         default:
             echo "Requested data format is unavailible at the moment...";
             break;
     }
 }
Exemplo n.º 4
0
 public function ChangeStatus($id)
 {
     if (Auth::check()) {
         if (in_array('ADD_EDIT_OFFER', $this->permission)) {
             if (User::isSuperAdmin()) {
                 $entity = Offer::find($id);
             } else {
                 $usr_company = $this->user_company();
                 $entity = Offer::whereHas('getAdvertiser', function ($q) use($usr_company) {
                     $q->whereHas('GetClientID', function ($p) use($usr_company) {
                         $p->whereIn('user_id', $usr_company);
                     });
                 })->find($id);
                 if (!$entity) {
                     return 'please Select your Client';
                 }
             }
             if ($entity) {
                 $data = array();
                 $audit = new AuditsController();
                 if ($entity->status == 'Active') {
                     array_push($data, 'status');
                     array_push($data, $entity->status);
                     array_push($data, 'Inactive');
                     $entity->status = 'Inactive';
                     $msg = 'disable';
                 } elseif ($entity->status == 'Inactive') {
                     array_push($data, 'status');
                     array_push($data, $entity->status);
                     array_push($data, 'Active');
                     $entity->status = 'Active';
                     $msg = 'actived';
                 }
                 $audit->store('offer', $id, $data, 'edit');
                 $entity->save();
                 return $msg;
             }
         }
         return "You don't have permission";
     }
     return Redirect::to(url('user/login'));
 }