public function actionUpdate($id)
{
$model = $this->findModel($id);
$sectionsList = EstimateSection::listOfSection($model->id);
foreach ($sectionsList as $section) {
$resources = new ActiveDataProvider([
'query' => EstimateResource::find()->where(['estimate_section_id' => $section->id])
]);
$sections[] = [
'section' => $section,
'resources' => $resources,
];
}
if ($this->request->isPost && $model->load($this->request->post()) && $model->save()) {
return $this->render('update', [
'model' => $model,
'sections' => $sections
]);
}
return $this->render('update', [
'model' => $model,
'sections' => $sections
]);
}
public function actionAjaxCreateSection($estimate_id) {
$section = new EstimateSection();
$section->estimate_id = $estimate_id;
$section->save();
$resources = new ActiveDataProvider([
'query' => EstimateResource::find()->where(['estimate_section_id' => $section->id])
]);
return $this->renderAjax('_new_section', [
'resources' => $resources,
'section_id' => $section->id,
]);
}
public function search($params)
{
$query = In::find()
->joinWith(['couple', 'tur'])
->joinWith(['couple.dancerId1'=> function($q){
$q->from('dancer c1');
}])
->joinWith(['couple.dancerId2'=> function($q){
$q->from('dancer c2');
}]);
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
return $dataProvider;
}
$query
->andFilterWhere(['like', 'couple.nomer', $this->couple_nomer])
->andFilterWhere(['like', 'c1.sname', $this->dancerId1])
->andFilterWhere(['like', 'c2.sname', $this->dancerId2]);
return $dataProvider;
}