/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Supplies::find()->orderBy('id DESC'); $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, 'type_mat' => $this->type_mat, 'type_blind' => $this->type_blind, 'color' => $this->color, 'status' => $this->status]); $query->andFilterWhere(['like', 'images', $this->images])->andFilterWhere(['like', 'type_width', $this->type_width])->andFilterWhere(['like', 'price', $this->price])->andFilterWhere(['like', 'code', $this->code]); return $dataProvider; }
public function actionGet_order() { $blind = Blind::find()->where(['id' => $_GET['blId']])->one(); $materials = \backend\modules\supplies\models\Supplies::find()->where(['id' => $_GET['mtId']])->one(); $telephone = $_GET['tel']; $order = new Orders(); $order->blind = (string) $blind->name; $order->materials = (string) $materials->code; $order->telephone = (string) $telephone; $order->dt_add = time(); $order->save(); echo $order->id; $email = Options::find()->where(['key' => 'email_to_prod'])->one(); mail($email->value, "Заказ с вашего сайта", "С вашего сайта заказали:<br>Номер заказа: {$blind->id}<br>Название жалюзи: {$blind->name}<br>Код материала: {$materials->code}<br>Телефон для связ: {$telephone}", "Content-type: text/html; charset=UTF-8\r\n"); }
return $title; }], ['attribute' => 'status', 'format' => 'text', 'value' => function ($model) { if ($model->status == 1) { return 'Опубликовано'; } else { return 'Не опубликовано'; } }], ['class' => DataColumn::className(), 'header' => 'Цена', 'format' => 'html', 'value' => function ($model) { $page2BlindID = PageToBlind::find()->where(['id_blind' => $model->id])->all(); $supIds = []; foreach ($page2BlindID as $page) { $s = PageItem::find()->where(['id_page' => $page->id_pages, 'item_type' => 'materials'])->all(); $supIds = array_merge($supIds, $s); } foreach ($supIds as $s) { $sup = Supplies::find()->where(['id' => $s->id_item])->one(); $prices[] = $sup->price; } if (isset($prices) && !empty($prices)) { $pricesMin = min($prices); $pricesMax = max($prices); } return "<div style='width: 100px'>" . $pricesMin . " - " . $pricesMax . "</div>"; }], ['class' => DataColumn::className(), 'header' => 'Действия', 'format' => 'html', 'value' => function ($model) { /*$view = Html::a("<img src='".\yii\helpers\Url::base()."crud_img/view.png' width='20px' title='Просмотр'></a>", ['/blind/blind/view','id'=>$model->id]);*/ $view = Html::a("<img src='" . \yii\helpers\Url::base() . "crud_img/edit.png' width='20px' title='Редактировать'></a>", ['/blind/blind/update', 'id' => $model->id]); $view .= Html::a("<img src='" . \yii\helpers\Url::base() . "crud_img/del.png' width='20px' title='Удалить'></a>", ['/blind/blind/delete', 'id' => $model->id]); return $view; }]]]); ?>
public function actionChange_sup() { if (isset($_GET['code_val'])) { $id = explode('_', $_GET['id']); $sup = Supplies::find()->where(['id' => $id[1]])->one(); $sup->code = $_GET['code_val']; $sup->save(); } if (isset($_GET['mat_val'])) { $id = explode('_', $_GET['id']); $sup = Supplies::find()->where(['id' => $id[1]])->one(); $sup->type_mat = $_GET['mat_val']; $sup->save(); } if (isset($_GET['blind_val'])) { $id = explode('_', $_GET['id']); $sup = Supplies::find()->where(['id' => $id[1]])->one(); $sup->type_blind = $_GET['blind_val']; $sup->save(); } if (isset($_GET['price_val'])) { $id = explode('_', $_GET['id']); $sup = Supplies::find()->where(['id' => $id[1]])->one(); $sup->price = $_GET['price_val']; $sup->save(); } if (isset($_GET['width_val'])) { $id = explode('_', $_GET['id']); $sup = Supplies::find()->where(['id' => $id[1]])->one(); $sup->type_width = $_GET['width_val']; $sup->save(); } if (isset($_GET['color_val'])) { $sup = Supplies::find()->where(['id' => $_GET['id']])->one(); $sup->color = $_GET['color_val']; $sup->save(); } if (isset($_GET['img_val'])) { $sup = Supplies::find()->where(['id' => $_GET['id']])->one(); $sup->images = $_GET['img_val']; $sup->save(); } if (isset($_GET['id_mat']) && $_GET['id_page']) { // $pageItem = PageItem::find()->where(['id_item'=>$_GET['id_mat'],'id_blind'=>$_GET['id_page']])->all(); $pageItem = PageItem::deleteAll(['id_item' => $_GET['id_mat'], 'id_blind' => $_GET['id_page']]); } }
public function actionPubl_materials() { $arr = explode(",", $_GET['val']); $html = ''; foreach ($arr as $a) { if (!empty($a)) { $sup = \backend\modules\supplies\models\Supplies::find()->where(['code' => $a])->one(); if (isset($sup->id)) { $html .= \common\classes\Supplies::getOneAddSupplies($sup->id, $_GET['id_page']); } } } return $html; }
public static function getOneAddSupplies($id, $title) { $supl = \backend\modules\supplies\models\Supplies::find()->where(['id' => $id])->one(); $html = ''; $html .= '<tr class="itemPage" page-id="' . $title . '" materials-id="' . $supl->id . '" item-type="materials">'; $html .= '<td><img src="' . $supl->images . '" style = "width:100px;"/></td>'; $html .= '<td>' . $supl->code . '</td>'; $type_materials = Material::find()->where(['id' => $supl->type_mat])->one(); $html .= '<td>' . $type_materials->name . '</td>'; if ($supl->type_blind == 1) { $html .= '<td>Горизонтальные</td>'; } if ($supl->type_blind == 2) { $html .= '<td>Вертикальные</td>'; } if ($supl->type_blind == 3) { $html .= '<td>Рулонные</td>'; } $html .= '<td>' . $supl->type_width . '</td>'; $color = Color::find()->where(['id' => $supl->color])->one(); $html .= '<td><div class="colorSuplies" style="width:50px;height:25px;background: ' . $color->value . '"></div></td>'; $html .= '<td>' . $supl->price . '</td>'; $html .= '<td><a id-materials="' . $supl->id . '"class = "delSuplies" href="#">Открепить</a></td>'; $html .= '</tr>'; return $html; }
public static function getCount($id) { //Debag::prn($id); //$sup = Supplies::find()->where(['type_blind' => $id])->all(); $page2BlindID = PageToBlind::find()->where(['id_blind' => $id])->all(); $supIds = []; foreach ($page2BlindID as $page) { $s = PageItem::find()->where(['id_page' => $page->id_pages, 'item_type' => 'materials'])->all(); $supIds = array_merge($supIds, $s); } $colors = []; $materials = []; $count = []; $prices = []; foreach ($supIds as $s) { $sup = Supplies::find()->where(['id' => $s->id_item])->one(); //Debag::prn($sup); $colors[] = $sup->color; $materials[] = $sup->type_mat; $prices[] = $sup->price; } $colors = count(array_unique($colors)); $materials = count(array_unique($materials)); //Debag::prn($prices); if (isset($prices) && !empty($prices)) { $prices = min($prices); $count['min_price'] = $prices; } $count['colors'] = $colors; $count['materials'] = $materials; //$count['min_price']= $prices; // Debag::prn($colors); return $count; }