예제 #1
0
 /**
  * Finds the CsServicesTranslation model based on its translated title.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return CsServices the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModelByTitle($title)
 {
     if (($model = CsProducts::find()->where('name=:name', [':name' => str_replace('-', ' ', $title)])->one()) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #2
0
 /**
  * Displays a single CsObjects model.
  * @param string $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     $query = \common\models\CsObjectProperties::find()->where(['object_id' => $model->id]);
     if ($model->getPath($model)) {
         foreach ($model->getPath($model) as $key => $objectpp) {
             if ($objectPropertiespp = $objectpp->objectProperties) {
                 foreach ($objectPropertiespp as $objectPropertypp) {
                     if ($objectPropertypp->property_class != 'private') {
                         $query->orWhere(['object_id' => $objectpp->id]);
                     }
                 }
             }
         }
     }
     return $this->render('view', ['model' => $model, 'products' => new ActiveDataProvider(['query' => \common\models\CsProducts::find()->where(['object_id' => $model->id])]), 'issues' => new ActiveDataProvider(['query' => \common\models\CsObjectIssues::find()->where(['object_id' => $model->id])]), 'properties' => new ActiveDataProvider(['query' => $query->orderBy('property_type')->groupBy('id')]), 'methods' => new ActiveDataProvider(['query' => \common\models\CsServices::find()->where(['object_id' => $model->id])])]);
 }
예제 #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = CsProducts::find();
     $query->joinWith(['object', 'objectProperty']);
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'object_id' => $this->object_id, 'object_property_id' => $this->object_property_id, 'product_id' => $this->product_id, 'base_product_id' => $this->base_product_id, 'predecessor_id' => $this->predecessor_id, 'successor_id' => $this->successor_id]);
     $query->andFilterWhere(['like', 'cs_products.name', $this->name])->andFilterWhere(['like', 'cs_products.level', $this->level])->andFilterWhere(['like', 'cs_products.class', $this->class])->andFilterWhere(['like', 'cs_products.description', $this->description]);
     return $dataProvider;
 }
예제 #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProduct()
 {
     return $this->hasOne(CsProducts::className(), ['id' => 'product_id']);
 }
예제 #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProducts()
 {
     return $this->hasMany(CsProducts::className(), ['object_id' => 'id']);
 }
예제 #6
0
 /**
  * Izlistava izabrane proizvode izabranog predmeta usluga.
  */
 protected function getProducts($products = null)
 {
     if ($products != null) {
         $product_container = [];
         foreach ($products as $product_m) {
             $product = \common\models\CsProducts::findOne($product_m);
             if ($product) {
                 $product_container[] = $product;
             }
         }
         return $product_container;
     }
     return null;
 }
예제 #7
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSuccessor()
 {
     return $this->hasOne(CsProducts::className(), ['id' => 'successor_id']);
 }
 /**
  * Lists all CsServices models.
  * @return mixed
  */
 public function actionIndex()
 {
     $request = Yii::$app->request;
     $post = $request->post('CsServicesSearch');
     // industry
     if (isset($post['industry_id']) && $post['industry_id'] != null && $post['industry_id'] != '') {
         $industry = CsIndustries::findOne($post['industry_id']);
         return $this->redirect(['/services/i/' . slug($industry->tName)]);
     }
     // object
     if (isset($post['object_id']) && $post['object_id'] != null && $post['object_id'] != '') {
         $object = CsObjects::findOne($post['object_id']);
         return $this->redirect(['/services/o/' . slug($object->tName)]);
     }
     // product
     if (isset($post['product_id']) && $post['product_id'] != null && $post['product_id'] != '') {
         $product = CsProducts::findOne($post['product_id']);
         return $this->redirect(['/services/p/' . slug($product->name)]);
     }
     // action
     if (isset($post['action_id']) && $post['action_id'] != null && $post['action_id'] != '') {
         $action = CsActions::findOne($post['action_id']);
         return $this->redirect(['/services/a/' . slug($action->tName)]);
     }
     // service
     if (isset($post['id']) && $post['id'] != null && $post['id'] != '') {
         $service = CsServices::findOne($post['id']);
         return $this->redirect(['/s/' . slug($service->tName)]);
     }
     // tags
     if (isset($post['tag_id']) && $post['tag_id'] != null && $post['tag_id'] != '') {
         $tag = CsTags::findOne($post['tag_id']);
         switch ($tag->entity) {
             case 'action':
                 return $this->redirect(['/services', 'a' => $tag->entity_id]);
                 break;
             case 'object':
                 return $this->redirect(['/services', 'o' => $tag->entity_id]);
                 break;
             case 'industry':
                 return $this->redirect(['/services', 'i' => $tag->entity_id]);
                 break;
             case 'service':
                 $service = CsServices::findOne($tag->entity_id);
                 return $this->redirect(['/s/' . slug($service->tName)]);
                 break;
             default:
                 return $this->redirect(['/services']);
                 break;
         }
     }
     if (isset($post['name']) && $post['name'] != null && $post['name'] != '') {
         return $this->redirect(['/services', 'q' => $post['name']]);
     }
 }
예제 #9
0
 /**
  * Finds the CsProducts model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return CsProducts the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = CsProducts::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }