/** * Display a listing of the resource. * * @param $catalog_id * @param Request $request * @return Response */ public function index($catalog_id, Request $request) { $catalog_model = \App\Models\Catalog::findOrFail($catalog_id); if ($catalog_model->user->id != $this->user->id) { \App::abort(403, 'Access denied'); } return view('admin.catalog.pricing-column.index', ['catalog_id' => $catalog_id, 'route_base_url' => $catalog_id . '/pricing-column', 'model_name' => '\\App\\Models\\PricingColumn', 'model_items' => $catalog_model->pricing_columns()->paginate()]); }
public function actionDelete() { $request = Yii::$app->request; $adminproductid = $request->get('id'); $model = Catalog::getOne($adminproductid); $model->delete(); $alltable = Catalog::getAllTable(); return $this->render('index', ['alltable' => $alltable]); }
public function actionCheckout() { $session = Yii::$app->session; $session->open(); $order_id = Index::addOrder(); $dbarray = Catalog::getCartDbData(); Checkout::checkoutCart($order_id, $dbarray); return Yii::$app->response->redirect(['site/cart']); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Catalog::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, 'operation_id' => $this->operation_id, 'user_id' => $this->user_id]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Catalog::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, 'year' => $this->year, 'price' => $this->price, 'sale' => $this->sale, 'sold' => $this->sold]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'author', $this->author])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'img', $this->img])->andFilterWhere(['like', 'category', $this->category]); return $dataProvider; }
/** * Display a listing of the resource. * * @param $catalog_id * @param Request $request * @return Response */ public function index($catalog_id, Request $request) { $catalog_model = \App\Models\Catalog::findOrFail($catalog_id); if ($catalog_model->user->id != $this->user->id) { \App::abort(403, 'Access denied'); } $model_items = $catalog_model->products()->paginate(30); foreach ($model_items as $product_model) { if (empty($product_model->title)) { continue; } $title = str_limit($product_model->title, 60); $product_model->display_title = $title; } return view('admin.catalog.product.index', ['catalog_id' => $catalog_id, 'route_base_url' => $catalog_id . '/product', 'model_name' => '\\App\\Models\\Product', 'model_items' => $model_items]); }
/** * Finds the Catalog model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Catalog the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Catalog::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getCatalog() { return $this->hasOne(Catalog::className(), ['id_catalog' => 'catalog_id']); }
?> <p> <button class="btn btn-link"> <span class="glyphicon glyphicon-menu-hamburger"></span> Отобразить информацию о всех товарах </button> <a href="/deferred" class="btn btn-default">Отложенные товары</a> <a href="/history" class="btn btn-default">История заказов</a> <a href="/history" class="btn btn-primary" title="Список оплаченных заказов, ожидающих доставки" data-toggle="tooltip" data-placement="right"> Мои заказы, ожидающие доставки </a> </p> @foreach($open_orders_catalogs_ids_arr as $open_orders_catalog_id) <?php $catalog_model = \App\Models\Catalog::find($open_orders_catalog_id); $deferred_products = $user->deferredProducts($open_orders_catalog_id)->get(); ?> <div class="panel panel-default"> <div class="panel-heading"> <div class="row"> <div class="col-lg-9"> <strong>Название закупки</strong> <a href="#" class="glyphicon glyphicon-link"></a> </div> <div class="col-lg-3 text-right"> @if( count($deferred_products) > 0 ) <a href="#"><span class="glyphicon glyphicon-eye-close" style="padding-right: 5px"></span> <strong>{{ count($deferred_products) }} отложенных товаров</strong></a> @endif </div> </div>
/** * selection product */ public function actionSelection() { $model = new ContactForm(); $arr_catalog = Catalog::find()->all(); foreach ($arr_catalog as $vlCatalog) { $id[] = $vlCatalog->id_catalog; $name[] = $vlCatalog->catalog_name; } $catalog = array_combine($id, $name); return $this->render('selection', ['model' => $model, 'catalog' => $catalog]); }
</td> <td><?php echo $item->Cost; ?> </td> <td><?php echo $item->Number; ?> </td> <td><?php echo Html::a('Добавить в корзину', ['/site/add', 'addid' => $item->Item_Id], ['class' => 'btn btn-primary']); ?> </td> </tr> <?php } ?> </tbody> </table> <?php use yii\grid\GridView; use yii\data\ActiveDataProvider; use app\models\Catalog; use yii\grid\CheckboxColumn; use yii\grid\SerialColumn; use yii\grid\DataColumn; $dataProvider = new ActiveDataProvider(['query' => Catalog::find(), 'pagination' => ['pageSize' => 20]]); echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => ['Name', 'Description', 'Cost', 'Number', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{link}', 'buttons' => ['link' => function ($url, $Index, $key) { return Html::a('Добавить в корзину', ['/site/add', 'addid' => $Index->Item_Id]); }]]]]);
@extends('admin.layout') @section('content') <?php $catalog_model = \App\Models\Catalog::findOrFail($catalog_id); $model = new $model_name(); $fields_arr = array_diff($model->getFillable(), $model->getHidden()); if (!isset($paginate_count)) { $paginate_count = 30; } if (!isset($model_items)) { $model_items = $model_name::paginate($paginate_count); } ?> <h3><a class="btn btn-default" href="/admin/catalog/{{ $catalog_model->id }}/edit">Вернуться к каталогу</a> {{ $catalog_model->name }}</h3> <h4>{{ $catalog_model->description }}</h4> <ul class="nav nav-pills"> <li><a href="/admin/{{ $catalog_id }}/template-purchase">Шаблоны закупок</a></li> <li><a href="/admin/{{ $catalog_id }}/pricing-column">Ценовые колонки</a></li> <li class="active"><a href="/admin/{{ $catalog_id }}/product">Товары</a></li> </ul> <h3>{{ $model_name }}</h3> <div class="row"> <div class="col-lg-1"> <div class="btn-toolbar" role="toolbar" style="margin-bottom: 10px">
use yii\widgets\ActiveForm; use yii\helpers\ArrayHelper; use app\models\Catalog; /* @var $this yii\web\View */ /* @var $model app\models\Section */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="section-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'catalog_id')->label('Каталог')->dropDownList(ArrayHelper::map(Catalog::find()->all(), 'id_catalog', 'catalog_name'), ['prompt' => 'Выберите значение']); ?> <?php echo $form->field($model, 'section_name')->label('Раздел')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'section_photo')->label('Фото')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'id_section')->label('')->hiddenInput(['maxlength' => true]); ?> <div class="form-group">
/** * @return \yii\db\ActiveQuery */ public function getCatalogs() { return $this->hasMany(Catalog::className(), ['user_id' => 'id']); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(Request $request, $id) { $catalog_model = \App\Models\Catalog::findOrFail($id); $catalog_model->update($request->all()); return redirect('/admin/catalog'); }