Example #1
0
 public static function getShippings()
 {
     $shippings = \Yii::$app->cache->get('shippings');
     if ($shippings === false) {
         $shippings = ShippingModel::find()->all();
         \Yii::$app->cache->add('shippings', $shippings);
     }
     return $shippings;
 }
Example #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ShippingModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'systemName', $this->systemName])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
Example #3
0
 public function actionView()
 {
     $cart_info = \Yii::$app->request->cookies->getValue('cart');
     $cart_info = unserialize($cart_info);
     if (is_array($cart_info)) {
         $products = ProductModel::getProducts(array_keys($cart_info));
         //find()->where(['id'=>array_keys($cart_info)])->all();
         $shippings = ShippingModel::getShippings();
         //find()->all();
         return $this->render('view', ['cart' => $cart_info, 'products' => $products, 'shippings' => $shippings]);
     } else {
         return $this->render('empty');
     }
 }
Example #4
0
?>

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

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

    <?php 
echo $form->field($model, 'idPayment')->dropDownList(ArrayHelper::map(PaymentModel::find()->all(), 'id', 'name'));
?>

    <?php 
echo $form->field($model, 'idShipping')->dropDownList(ArrayHelper::map(ShippingModel::find()->all(), 'id', 'name'));
?>

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

    <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();
?>
Example #5
0
 /**
  * Finds the ShippingModel model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ShippingModel the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ShippingModel::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdShipping0()
 {
     return $this->hasOne(ShippingModel::className(), ['id' => 'idShipping']);
 }