Exemple #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  * $isBack 获取回收站删除数据,TRUE获取status为1,默认为false
  * @return ActiveDataProvider
  */
 public function search($params, $isBack = false)
 {
     $query = Add::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, 'addnum' => $this->addnum, 'count' => $this->count, 'price' => $this->price, 'addprice' => $this->addprice, 'create_at' => $this->create_at, 'update_at' => $this->update_at, 'status' => $isBack ? 1 : 0, 'uid' => Yii::$app->user->id]);
     $query->andFilterWhere(['like', 'brand', $this->brand])->andFilterWhere(['like', 'model', $this->model])->andFilterWhere(['like', 'color', $this->color])->andFilterWhere(['like', 'barcode', $this->barcode])->andFilterWhere(['like', 'supplier', $this->supplier])->andFilterWhere(['like', 'warehouse', $this->warehouse])->andFilterWhere(['like', 'remark', $this->remark])->andFilterWhere(['like', 'employee', $this->employee]);
     return $dataProvider;
 }
Exemple #2
0
$isNewbill = false;
//是否为新单据
if ($addnum == "") {
    $isNewbill = true;
    $num = date("Ymd", time());
    $count = 0;
    $sql = "SELECT * FROM tbl_add WHERE uid=" . Yii::$app->user->id . " AND left(addnum,8)=" . $num . " order by id desc";
    $add = Add::findBySql($sql)->one();
    if ($add) {
        $addnum = $add->getAttribute('addnum');
        $addnum += 1;
    } else {
        $addnum = $num . "01";
    }
} else {
    $add = Add::find()->where(['uid' => Yii::$app->user->id, 'addnum' => $addnum, 'status' => 0])->all();
    foreach ($add as $item) {
        $supplier = $item->getAttribute('supplier');
        $warehouse = $item->getAttribute('warehouse');
        break;
    }
}
?>
                <label>供应商</label>
                <?php 
echo Html::input("text", null, $supplier, ["id" => "addSuppliers", "style" => "width:100px", "readonly" => "readonly"]);
?>
                <label>仓库</label>
                <?php 
echo Html::input("text", null, $warehouse, ["id" => "addWarehouse", "style" => "width:100px", "readonly" => "readonly"]);
?>
Exemple #3
0
 /**
  * AJAX匹配查询产品
  */
 public function actionSearchproduct()
 {
     if (isset($_POST['product'])) {
         $product = $_POST['product'];
     }
     if ($product != null) {
         $sql = "SELECT * FROM tbl_add WHERE uid=" . Yii::$app->user->id . " AND brand LIKE '%" . $product . "%' or model LIKE '%" . $product . "%'";
         $add = Add::findBySql($sql)->all();
         if ($add) {
             $json['return_code'] = 1;
             $count = 0;
             $barcodeArray = array();
             $productArray = array();
             $priceArray = array();
             $colorArray = array();
             $numArray = array();
             $supplierArray = array();
             $warehouseArray = array();
             $pidArray = array();
             foreach ($add as $item) {
                 $brand = $item->getAttribute('brand');
                 $model = $item->getAttribute('model');
                 if ($model == "") {
                     $myProduct = $brand;
                 } else {
                     $myProduct = $brand . "-" . $model;
                 }
                 $barcode = $item->getAttribute('barcode');
                 if (strlen($barcode) > 0) {
                     $codeArray = explode(",", $barcode);
                     for ($i = 0; $i < count($codeArray); $i++) {
                         $barcodeModel = Barcode::find()->where(['uid' => Yii::$app->user->id, 'barcode' => $codeArray[$i], 'status' => 0])->one();
                         if ($barcodeModel) {
                             $count++;
                             $barcodeArray[] = $codeArray[$i];
                             $productArray[] = $myProduct;
                             $priceArray[] = $item->getAttribute('price');
                             $colorArray[] = $item->getAttribute('color');
                             $numArray[] = $item->getAttribute('addnum');
                             $supplierArray[] = $item->getAttribute('supplier');
                             $warehouseArray[] = $item->getAttribute('warehouse');
                             $pidArray[] = $item->getAttribute('pid');
                         }
                     }
                 } else {
                     if ($item->getAttribute('imeilen') == 0) {
                         $count++;
                         $barcodeArray[] = "无";
                         $productArray[] = $myProduct;
                         $priceArray[] = $item->getAttribute('price');
                         $colorArray[] = $item->getAttribute('color');
                         $numArray[] = $item->getAttribute('addnum');
                         $supplierArray[] = $item->getAttribute('supplier');
                         $warehouseArray[] = $item->getAttribute('warehouse');
                         $pidArray[] = $item->getAttribute('pid');
                     }
                 }
             }
             $json['barcodeArray'] = $barcodeArray;
             $json['productArray'] = $productArray;
             $json['priceArray'] = $priceArray;
             $json['colorArray'] = $colorArray;
             $json['numArray'] = $numArray;
             $json['supplierArray'] = $supplierArray;
             $json['warehouseArray'] = $warehouseArray;
             $json['pidArray'] = $pidArray;
             $json['count'] = $count;
         } else {
             $json['return_code'] = 0;
         }
         echo json_encode($json);
     }
 }
Exemple #4
0
 /**
  * Finds the Add model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Add the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Add::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }