예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Watches::find();
     /* $query->joinWith(['marketplace']);*/
     $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, 'brands_id' => $this->brands_id, 'marketplace_id' => $this->marketplace_id, 'price' => $this->price]);
     $query->andFilterWhere(['like', 'modelno', $this->modelno]);
     return $dataProvider;
 }
예제 #2
0
 * User: napster
 * Date: 10/11/2015
 * Time: 4:25 PM
 */
use frontend\models\Watches;
use kartik\select2\Select2;
use yii\helpers\ArrayHelper;
?>
    <td><?php 
$i = $count + 1;
echo $i;
?>
    </td>
    <td>
        <?php 
echo Select2::widget(['model' => $model, 'attribute' => 'watches_id[' . $count . ']', 'data' => Arrayhelper::map(Watches::find()->all(), 'id', 'modelno'), 'options' => ['placeholder' => '', 'onchange' => '
                                            $.post("/index.php/bills/bcontent?id=' . '"+$(this).val(),function(data){

                                                    $("#bills-description-' . $count . '").val(data["brand"]);
                                                    $("#bills-price-' . $count . '").val(data["price"]);
                                            },"json");
                                            '], 'pluginOptions' => ['allowClear' => true]]);
?>
    </td>
    <td>
        <div class="form-group field-bills-description-<?php 
echo $count;
?>
">
            <input type="text" id="bills-description-<?php 
echo $count;
예제 #3
0
    <?php 
$form = ActiveForm::begin();
?>


    <?php 
echo $form->field($model, 'brand_id')->dropDownList(ArrayHelper::map(Brands::find()->all(), 'id', 'name'), ['prompt' => 'select brand', 'onchange' => '
                        $.post("/index.php/watches/lists?id=' . '"+$(this).val(),function(data){
                                    $("select#inventorystock-watches_id").html(data);
                        });
              ']);
?>


    <?php 
echo $form->field($model, 'watches_id')->dropDownList(ArrayHelper::map(Watches::find()->all(), 'id', 'modelno'), ['prompt' => 'select model no']);
?>

    <?php 
echo $form->field($model, 'quantity')->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();
?>
예제 #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getWatches()
 {
     return $this->hasOne(Watches::className(), ['id' => 'watches_id']);
 }
예제 #5
0
 /**
  * Finds the Watches model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Watches the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Watches::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #6
0
 public function actionBcontent($id)
 {
     $watch = Watches::find()->joinWith('brands')->where(['watches.id' => $id])->one();
     echo Json::encode(['modelno' => $watch->modelno, 'price' => $watch->price, 'brand' => $watch->brands->name]);
     /*foreach($watches as $watch){
           echo $watch->brands_id;
       }*/
     /* if($countPosts > 0 )
        {
            foreach($watches as $watch){
                echo "<input id='bills-description-0' value='".$watch->brands_id."' '>";
                echo "<option value='".$watch->id."'>" .$watch->modelno."</option>";
            }
        }else{
            echo "<option></option>";
        }*/
 }