コード例 #1
0
ファイル: AddSearch.php プロジェクト: vbboy2012/1861886
 /**
  * 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;
 }
コード例 #2
0
ファイル: bill.php プロジェクト: vbboy2012/1861886
$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"]);
?>
コード例 #3
0
ファイル: SellController.php プロジェクト: vbboy2012/1861886
 /**
  * AJAX匹配查询条码
  * "SELECT addnum,brand,model,color,price,barcode,status FROM tbl_add WHERE barcode LIKE '%".$barcode."%'";
  */
 public function actionSearchcode()
 {
     if (isset($_POST['barcode'])) {
         $barcode = $_POST['barcode'];
     }
     if ($barcode != null) {
         $sql = "SELECT * FROM tbl_barcode WHERE uid=" . Yii::$app->user->id . " AND status=0 AND barcode LIKE '%" . $barcode . "'";
         $codeModel = Barcode::findBySql($sql)->all();
         if ($codeModel) {
             $json['return_code'] = 1;
             $barcodeArray = array();
             $productArray = array();
             $priceArray = array();
             $colorArray = array();
             $numArray = array();
             $supplierArray = array();
             $warehouseArray = array();
             $pidArray = array();
             $count = 0;
             foreach ($codeModel as $item) {
                 $add = Add::find()->where(['uid' => Yii::$app->user->id, 'id' => $item->getAttribute('addid')])->one();
                 if ($add) {
                     $count++;
                     $barcodeArray[] = $item->getAttribute('barcode');
                     $brand = $add->getAttribute('brand');
                     $model = $add->getAttribute('model');
                     if ($model == "") {
                         $product = $brand;
                     } else {
                         $product = $brand . "-" . $model;
                     }
                     $productArray[] = $product;
                     $priceArray[] = $add->getAttribute('price');
                     $colorArray[] = $add->getAttribute('color');
                     $numArray[] = $add->getAttribute('addnum');
                     $supplierArray[] = $add->getAttribute('supplier');
                     $warehouseArray[] = $add->getAttribute('warehouse');
                     $pidArray[] = $add->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);
     }
 }
コード例 #4
0
ファイル: AddController.php プロジェクト: vbboy2012/1861886
 public function actionDeletebill()
 {
     if (isset($_POST['id'])) {
         $id = $_POST['id'];
     }
     if ($id != null) {
         $uid = Yii::$app->user->id;
         Add::updateAll(['status' => 1], 'id=:id AND uid=:uid', [':id' => $id, ':uid' => $uid]);
         $add = Add::find()->where(['uid' => $uid, 'id' => $id])->one();
         if ($add) {
             $barcode = $add->getAttribute('barcode');
             $codeArray = explode(",", $barcode);
             for ($i = 0; $i < count($codeArray); $i++) {
                 Barcode::updateAll(['del' => 1, 'uid' => $uid], 'barcode=:barcode', [':barcode' => $codeArray[$i]]);
             }
         }
     }
 }