Exemplo n.º 1
0
 public function actionCategories()
 {
     $model = new Categories();
     $categories = Categories::find()->all();
     $categories_roots = Categories::find()->roots()->all();
     if ($model->load(Yii::$app->request->post())) {
         if (Yii::$app->user->can('createPost') && $model->addCategory()) {
             Yii::$app->getSession()->addFlash('success', '<b>Категория успешно добавлена!</b>');
         } else {
             Yii::$app->getSession()->addFlash('error', '<b>Произошла ошибка. Запись не добавлена</b>');
         }
     }
     return $this->render('categories', ['categories' => $categories, 'roots' => $categories_roots, 'model' => $model]);
 }
Exemplo n.º 2
0
 public function indexAction()
 {
     $categories = Categories::find();
     echo "TESTING";
     $this->logger->info('INDEX');
     $this->view->categories = $categories;
 }
Exemplo n.º 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Categories::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(['categoryId' => $this->categoryId, 'createdDate' => $this->createdDate, 'updatedDate' => $this->updatedDate]);
     $query->andFilterWhere(['like', 'categoryName', $this->categoryName])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
Exemplo n.º 4
0
 public function addCategory()
 {
     if ($this->validate()) {
         $category = new Categories();
         $category->name = $this->name;
         $category->slug = $this->slug;
         if (Yii::$app->request->post('cats') == 0 && $category->makeRoot()) {
             return $category;
         } else {
             $parent = Categories::findOne(['id' => Yii::$app->request->post('cats')]);
             $category->makeRoot();
             $category->appendTo($parent);
             return $category;
         }
     }
     return null;
 }
Exemplo n.º 5
0
?>
</td>
                    
                            <td id="productId<?php 
echo $model['Saleid'];
?>
" contentEditable="true"><?php 
echo $model['productId'];
?>
</td>
                            <td  contentEditable="true"><?php 
echo Html::activeDropDownList($model, 'Brand', ArrayHelper::map(Brandsmaster::find()->all(), 'brandName', 'brandName'), ['id' => 'brand' . $model['Saleid']]);
?>
</td>
                            <td  contentEditable="true"><?php 
echo Html::activeDropDownList($model, 'categoryName', ArrayHelper::map(Categories::find()->all(), 'categoryName', 'categoryName'), ['id' => 'categoryId' . $model['Saleid']]);
?>
</td>
                            <td id="quntity<?php 
echo $model['Saleid'];
?>
" contentEditable="true"><?php 
echo $model['Quantity'];
?>
</td>
                            <td id="uom<?php 
echo $model['Saleid'];
?>
" contentEditable="true"><?php 
echo $model['uom'];
?>
Exemplo n.º 6
0
 public function actionCreatenew()
 {
     $model = new Products();
     $model->scenario = 'productsupload';
     if ($model->load(Yii::$app->request->post())) {
         $model->FileUpload = UploadedFile::getInstance($model, 'FileUpload');
         $k = 0;
         if ($model->FileUpload) {
             $time = time();
             $model->FileUpload->saveAs(realpath(Yii::$app->basePath) . '/csv/' . $time . '.' . $model->FileUpload->extension);
             $model->FileUpload = realpath(Yii::$app->basePath) . '/csv/' . $time . '.' . $model->FileUpload->extension;
             $handle = fopen($model->FileUpload, "r");
             $i = 0;
             $m = 0;
             while (($fileop = fgetcsv($handle, 1000, ",")) !== false) {
                 if ($i >= 1) {
                     /* products external images
                     		    $model->externalFiles = file_get_contents($fileop[5]);
                     			$find = ".'\'.";
                     			$ent = str_replace ("/\\/","/",$fileop[5]);
                     			$a = "\\";
                     			$a = preg_replace('/\\\\/','/',$fileop[5]);
                     			
                     			$getstrpos = strripos($a,"/");
                     			$imageName = substr($fileop[5],$getstrpos+1);
                     			$time2 = time();
                     			$img = realpath(Yii::$app->basePath).'/web/uploads/products/'.$time2.$imageName;
                     			$fileimageUrl = 'uploads/products/'.$time2.$imageName;
                     			file_put_contents($img, file_get_contents($fileop[5])); */
                     /* $model->externalFiles = UploadedFile::getInstance(file_get_contents($fileop[5]));
                     			$time2 = time();
                     			$model->externalFiles->saveAs(realpath(Yii::$app->basePath).'/csv/' .$time2. '.' . $model->FileUpload->extension);
                     			$model->externalFiles = realpath(Yii::$app->basePath).'/csv/' .$time2. '.' . $model->FileUpload->extension; */
                     date_default_timezone_set('Asia/Calcutta');
                     $model->createdDate = date("Y-m-d H:i:s");
                     $model->updatedDate = date("Y-m-d H:i:s");
                     try {
                         $userInfo = Yii::$app->db->createCommand()->insert('products', ['productCode' => $fileop[0], 'productName' => $fileop[1], 'categoryId' => Categories::getCategoryId($fileop[2]), 'description' => $fileop[3], 'status' => 'Active', 'createdDate' => $model->createdDate, 'updatedDate' => $model->updatedDate])->execute();
                         if ($userInfo) {
                             $m++;
                         }
                     } catch (\Exception $e) {
                         $duplicaterrors = $e->errorInfo[0];
                         if ($duplicaterrors == 23000) {
                             $k++;
                         }
                     }
                 }
                 $i++;
             }
             if ($m > 0) {
                 Yii::$app->getSession()->setFlash('success', 'Your are successfully Uploaded ' . $m . ' Products');
             }
             if ($k > 0) {
                 Yii::$app->getSession()->setFlash('error', 'Your Trying to add ' . $k . ' duplicate records');
             }
             return $this->redirect(['createnew']);
         }
     } else {
         return $this->render('createfile', ['model' => $model]);
     }
 }
Exemplo n.º 7
0
echo Html::submitButton('Добавить', ['class' => 'btn btn-primary', 'name' => 'signup-button']);
?>
            </div>

            <?php 
ActiveForm::end();
?>

        </div>

    </div>

    <h1 style="text-align:center;">Список категорий</h1>

    <?php 
$categories = Categories::find()->orderBy('tree,lft, rgt')->all();
$level = 0;
foreach ($categories as $n => $category) {
    if ($category->depth == $level) {
        echo "</li> \n";
    } else {
        if ($category->depth > $level) {
            echo "<ul>\n";
        } else {
            echo "</li>\n";
            for ($i = $level - $category->depth; $i; $i--) {
                echo "</ul>\n";
                echo "</li>\n";
            }
        }
    }
Exemplo n.º 8
0
                        <div id="imaginary_container">
                          <div class="input-group stylish-input-group">
                            <?php 
echo $form->field($searchModel, 'productId')->textInput(array('placeholder' => 'Product code'))->label(false);
?>
 </div>
                        </div>
                      </div>
                      <div class="col-md-3">
                        <?php 
echo $form->field($searchModel, 'Brand')->dropDownList(ArrayHelper::map(Brandsmaster::find()->all(), 'brandName', 'brandName'), ['prompt' => 'Select Brand'])->label(false);
?>
                      </div>
                      <div class="col-md-3">
                         <?php 
echo $form->field($searchModel, 'categoryName')->dropDownList(ArrayHelper::map(Categories::find()->all(), 'categoryName', 'categoryName'), ['prompt' => 'Select Category'])->label(false);
?>
                      </div>
                      <?php 
ActiveForm::end();
?>
                    </div>
                    <div class="row">
                    <div class="col-md-12">
                    <div class="student-form">
    

    

    
</div>
Exemplo n.º 9
0
?>
">Brand</label>
                                <?php 
echo Html::activeDropDownList($model, 'Brand', ArrayHelper::map(Brandsmaster::find()->all(), 'brandName', 'brandName'), ['prompt' => 'Select Brand', 'class' => 'form-control', 'id' => 'vendorproducts-brand' . $cnt]);
?>
                              </div>
					</div>
					
					<div class="col-md-4">
						<div class="form-group">
                          <label class="control-label" for="vendorproducts-categoryname<?php 
echo $cnt;
?>
">Category Name</label>
                           <?php 
echo Html::activeDropDownList($model, 'categoryName', ArrayHelper::map(Categories::find()->all(), 'categoryName', 'categoryName'), ['prompt' => 'Select categoryName', 'class' => 'form-control', 'id' => 'vendorproducts-categoryname' . $cnt]);
?>
                              </div>
					</div>
				</div>
				<!--row 1 end-->

				<div class="row">
					<!--row 2-->
					<div class="col-md-4">
						<div class="form-group">
                                <label class="control-label" for="vendorproducts-quantity">Qty</label>
                                <?php 
echo Html::activeInput('text', $model, 'Quantity[]', ['class' => 'form-control', 'id' => 'vendorproducts-quantity']);
?>
                              </div>
Exemplo n.º 10
0
 public static function getCategoryId($catName)
 {
     $categoryName = Categories::find()->select('categoryId')->where(['categoryName' => $catName])->one();
     return $categoryName['categoryId'];
 }
Exemplo n.º 11
0
                                <?php 
echo $form->field($model, 'productId')->dropDownList(ArrayHelper::map(Products::find()->all(), 'productCode', 'productName'), ['prompt' => 'Select Product']);
?>
                              </div>
					</div>
					<div class="col-md-4">
						<div class="form-group">
                             <?php 
echo $form->field($model, 'Brand')->dropDownList(ArrayHelper::map(Brandsmaster::find()->all(), 'brandName', 'brandName'), ['prompt' => 'Select Brand']);
?>
                              </div>
					</div>
					<div class="col-md-4">
						<div class="form-group">
                          <?php 
echo $form->field($model, 'categoryName')->dropDownList(ArrayHelper::map(Categories::find()->all(), 'categoryName', 'categoryName'), ['prompt' => 'categoryName']);
?>
                              </div>
					</div>
				</div>
				<!--row 1 end-->

				<div class="row">
					<!--row 2-->
					<div class="col-md-4">
						<div class="form-group">
                                <?php 
echo $form->field($model, 'Quantity')->textInput(['maxlength' => true]);
?>
                                
                              </div>
Exemplo n.º 12
0
?>
               <div class="form-group col-lg-6 col-sm-12">
			      <?php 
echo $form->field($model, 'productCode')->textInput(['maxlength' => true]);
?>
			    </div>
			    
			    <div class="form-group col-lg-6 col-sm-12">
			      <?php 
echo $form->field($model, 'productName')->textInput(['maxlength' => true]);
?>
			    </div>

				 <div class="form-group col-lg-6 col-sm-12">
							       <?php 
echo $form->field($model, 'categoryId')->dropDownList(ArrayHelper::map(Categories::find()->orderBy(['categoryName' => SORT_ASC])->all(), 'categoryId', 'categoryName'), ['prompt' => 'categoryName']);
?>
				 </div>
    
			      
			      
			   	   <div class="form-group col-lg-6 col-sm-12">
			         	  <?php 
echo $form->field($model, 'status')->dropDownList(['Active' => 'Active', 'In-active' => 'In-active'], ['prompt' => 'Status']);
?>
			       </div>
			       
                   <!-- image file upload process -->
			       
			       <div class="form-group col-lg-6 col-sm-12">
				      <?php 
Exemplo n.º 13
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdcategory()
 {
     return $this->hasOne(Categories::className(), ['idcategory' => 'idcategory']);
 }
Exemplo n.º 14
0
 /**
  * Finds the Categories model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Categories the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Categories::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 15
0
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'dname')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'description')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'price')->textInput();
?>

    <?php 
echo $form->field($model, 'idcategory')->dropDownList(ArrayHelper::map(Categories::find()->all(), 'idcategory', 'cname'), ['prompt' => 'Select category']);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
Exemplo n.º 16
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPIdC0()
 {
     return $this->hasOne(Categories::className(), ['categoryId' => 'categoryId']);
 }