示例#1
0
文件: Category.php 项目: apuc/admin
 public static function getBlind($id)
 {
     /*$html = '<div class="catalog_blocks">';*/
     $blinds = BlindCatid::find()->where(['id_cat' => $id])->all();
     $html = '';
     foreach ($blinds as $bl) {
         $product = Blind::find()->where(['id' => $bl->id_blind])->one();
         //Debag::prn($product);
         $html .= '<div class="product">
                 <a href="#">' . $product->name . '</a>
                 <div class="info">
                     <span></span>
                     <div class="hint">
                        ' . $product->description . '
                     </div>
                 </div>
             </div>';
     }
     /*$html .= '</div>';*/
     return $html;
 }
示例#2
0
 /**
  * Updates an existing Blind model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $blind = Blind::find()->where(['id' => $id])->one();
     $model = new BlindForm();
     $model->name = $blind->name;
     $model->status = $blind->status;
     $model->description = $blind->description;
     $model->tab = $blind->tab;
     $cat = BlindCatid::find()->where(['id_blind' => $id])->all();
     $blindMaterialHeader = BlindMaterials::find()->where(['id_blind' => $id])->all();
     //Debag::prn($_POST);
     foreach ($cat as $c) {
         $arr_catid[$c->id_cat] = ['selected ' => 'selected'];
     }
     $media = Media::find()->orderBy('id DESC')->all();
     $supples = BlindIdmaterials::find()->where(['id_blind' => $id])->all();
     foreach ($supples as $supl) {
         $arr_supl[$supl->id_materials] = ['selected ' => 'selected'];
     }
     $materials = \backend\modules\supplies\models\Supplies::find()->all();
     foreach ($materials as $v) {
         $arr_materials[$v->id] = $v->code;
     }
     $arr_cat = CategoryTree::getTreeSelect(0);
     unset($arr_cat[0]);
     $blImg = new BlindImg();
     $imgages = $blImg->find()->where(['id_blind' => $id])->all();
     $addMaterials = \common\classes\Supplies::getAddSupplies();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $blind->name = $model->name;
         $blind->status = $model->status;
         $blind->description = $model->description;
         $blind->tab = $model->tab;
         $blind->save();
         $delBmt = new BlindMaterials();
         $delBmt->deleteAll(['id_blind' => $blind->id]);
         if (isset($_POST['blindTitle'])) {
             foreach ($_POST['blindTitle'] as $bt) {
                 $arrBt = explode('*', $bt);
                 $bmt = new BlindMaterials();
                 $bmt->id_blind = $blind->id;
                 $bmt->id_materials = $arrBt[0];
                 $bmt->title = $arrBt[1];
                 $bmt->save();
             }
         }
         $cat = BlindCatid::deleteAll(['id_blind' => $blind->id]);
         foreach ($model->categories as $cat) {
             $blindCatId = new BlindCatid();
             $blindCatId->id_blind = $blind->id;
             $blindCatId->id_cat = $cat;
             $blindCatId->save();
         }
         $blindImg = new BlindImg();
         $cat = $blindImg->deleteAll(['id_blind' => $blind->id]);
         if (!empty($_POST['blind_image'])) {
             foreach ($_POST['blind_image'] as $img) {
                 $blindImg = new BlindImg();
                 $imgarr = explode('*', $img);
                 $blindImg->id_blind = $blind->id;
                 $blindImg->images = $imgarr[0];
                 $blindImg->main = $imgarr[1];
                 $blindImg->save();
             }
         }
         $cat = BlindIdmaterials::deleteAll(['id_blind' => $blind->id]);
         if (!empty($model->materials)) {
             foreach ($model->materials as $mat) {
                 $blindMat = new BlindIdmaterials();
                 $blindMat->id_blind = $blind->id;
                 $blindMat->id_materials = $mat;
                 $blindMat->save();
             }
         }
         //Debag::prn($_POST['infoPage']);
         $zag = PageToBlind::find()->where(['id_blind' => $blind->id])->all();
         foreach ($zag as $v) {
             PageBlinds::deleteAll(['id' => $v->id_pages]);
         }
         PageToBlind::deleteAll(['id_blind' => $blind->id]);
         if (isset($_POST['infoPage'])) {
             foreach ($_POST['infoPage'] as $v) {
                 $input = explode('*', $v);
                 $s = str_replace('_', ' ', $input[0]);
                 $pb = PageBlinds::find()->where(['name' => $s])->one();
                 if (empty($pb->id)) {
                     $pb = new PageBlinds();
                     $pb->name = $s;
                     $pb->save();
                 }
                 //$pb->name = $input[0];
                 //$pb->save();
                 unset($input[0]);
                 $del = PageToBlind::deleteAll(['id_pages' => $pb->id]);
                 $ptb = new PageToBlind();
                 $ptb->id_pages = $pb->id;
                 $ptb->id_blind = $blind->id;
                 $ptb->save();
                 $cat = PageItem::deleteAll(['id_page' => $pb->id]);
                 foreach ($input as $in) {
                     //Debag::prn($in);
                     $pageItem = new PageItem();
                     $item = explode('_', $in);
                     if ($item[1] == 'materials') {
                         $pageItem->id_page = $pb->id;
                         $pageItem->id_item = $item[0];
                         $pageItem->item_type = 'materials';
                     } else {
                         $pageTitle = PageForTitle::find()->where(['title' => $item[0]])->one();
                         if (empty($pageTitle->id)) {
                             $pageTitle = new PageForTitle();
                             $pageTitle->title = $item[0];
                             $pageTitle->save();
                         }
                         /*$pageTitle = new PageForTitle();
                           $pageTitle->title = $item[0];
                           $pageTitle->save();*/
                         $pageItem->id_page = $pb->id;
                         $pageItem->id_item = $pageTitle->id;
                         $pageItem->item_type = 'zagolovok';
                     }
                     $pageItem->id_blind = $blind->id;
                     $pageItem->save();
                 }
             }
         } else {
         }
         return $this->redirect(['update', 'id' => $blind->id]);
     } else {
         return $this->render('update', ['model' => $model, 'categories' => $arr_cat, 'catselect' => $arr_catid, 'materials' => $arr_materials, 'materialselect' => $arr_supl, 'media' => $media, 'img' => $imgages, 'bmt' => $blindMaterialHeader, 'blind' => $blind, 'addMat' => $addMaterials]);
     }
 }
示例#3
0
文件: index.php 项目: apuc/admin
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Создать', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'name', 'format' => 'html', 'value' => function ($model) {
    return "<div>{$model->name}</div>";
}], ['class' => DataColumn::className(), 'header' => 'Раздел', 'format' => 'html', 'value' => function ($model) {
    $cat = \common\models\BlindCatid::find()->where(['id_blind' => $model->id])->all();
    $title = '<ul>';
    foreach ($cat as $c) {
        $catObj = \backend\modules\category\models\Category::find()->where(['id' => $c->id_cat])->one();
        $title .= "<li>" . $catObj->name . "</li>";
    }
    $title .= "</ul>";
    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();
示例#4
0
文件: PrintBlind.php 项目: apuc/admin
 public static function getCountItems($id, $num)
 {
     $cat = Categories::find()->where(['id' => $id])->one();
     $count = $cat->count_product;
     $blinds = BlindCatid::find()->where(['id_cat' => $id])->offset($num * $count)->orderBy('id_blind DESC')->all();
     //Debag::prn($count);
     //Debag::prn(count($blinds));
     if (count($blinds) <= $count) {
         return 1;
     } else {
         return 0;
     }
 }