public function actionStatistics() { $males = User::find()->where(['sex' => 'MALE', 'type' => 'CLIENT'])->count(); $females = User::find()->where(['sex' => 'FEMALE', 'type' => 'CLIENT'])->count(); $sellc = Sell::find()->where(['status' => 'COMPLETE'])->count(); $selli = Sell::find()->where(['status' => 'INCOMPLETE'])->count(); $totalsell = Sell::find()->all(); return $this->render('statistics', ['males' => $males, 'females' => $females, 'sellc' => $sellc, 'selli' => $selli, 'totalsell' => $totalsell]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params, $isBack = false) { $query = Sell::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, 'sellnum' => $this->sellnum, 'count' => $this->count, 'price' => $this->price, 'addprice' => $this->addprice, 'create_at' => $this->create_at, 'update_at' => $this->update_at, 'status' => $isBack ? 1 : 0, 'pid' => $this->pid, 'uid' => Yii::$app->user->id]); $query->andFilterWhere(['like', 'brand', $this->brand])->andFilterWhere(['like', 'model', $this->model])->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; }
public function actionDreturn() { //Yii::app()->request->enableCsrfValidation = false; $vector = "JbEFFDiOkRc="; $xmlGenerateKey = $_POST["XMLGENERATEKEY"]; $filePubFI = Yii::getAlias('@app') . "/PUBLICA_FIRMA_INTERDIN.pem"; $filePriKC = Yii::getAlias('@app') . "/PRIVADA_CIFRADA_ESTABLECIMIENTO.pem"; $pluginr = new PlugInClientRecive(); $pluginr->setIV($vector); $pluginr->setSignPublicKey("file://" . $filePubFI); $pluginr->setCipherPrivateKey("file://" . $filePriKC); $error = $pluginr->setXMLGENERATEKEY($xmlGenerateKey); $msg = ""; if ($error != "") { $msg = "Error:" . $error; return; } $cadeEnc = $_POST["XMLRESPONSE"]; $firmaCorrecta = $pluginr->XMLProcess($cadeEnc, $_POST["XMLDIGITALSIGN"]); if ($firmaCorrecta == 0) { //echo "<b>Los datos han sido alterados.</b><br>"; return; } else { if ($firmaCorrecta != 1) { $msg = "<br><br>Error: {$firmaCorrecta}"; return; } else { $msg = "<b>Los datos no han sido alterados.</b><br>"; } } $transactionID = $pluginr->getTransacctionID(); $tax1 = $pluginr->getTaxValue1() / 100; $tax2 = $pluginr->getTaxValue2() / 100; $tip = $pluginr->getTipValue(); $value = $pluginr->getTransacctionValue() / 100; $status = $pluginr->getAuthorizationState(); $auth = $pluginr->getAuthorizationCode(); $referencia1 = $pluginr->getReferencia1(); $sell = Sell::findOne($referencia1); $transactionid = $sell->transactionid; if ($status == "Y") { $xml = simplexml_load_file("https://www3.optar.ec/webmpi/qvpos?RucEstab=1790241483001&NoTransaccion={$transactionid}"); if ($xml->TRANSACCION->RESULTADO == "OK") { Yii::$app->cart->removeAll(); } else { $sell->status == "INCOMPLETE"; $sell->save(); } } return $this->render('response', ['transactionID' => $transactionID, 'tax1' => $tax1, 'tax2' => $tax2, 'tip' => $tip, 'value' => $value, 'status' => $status, 'auth' => $auth, 'xml' => $xml]); }
public function getSells() { return $this->hasMany(Sell::className(), ['id' => 'sell_id'])->viaTable('detail', ['product_id' => 'id']); }
public function actionBackbill() { if (isset($_POST['id'])) { $id = $_POST['id']; } if ($id != null) { Sell::updateAll(['status' => 0], 'id=:id', [':id' => $id]); } }
public function actionViewsell($id) { $model = Sell::findOne($id); $xml = $this->Consultsell($model->transactionid); return $this->render('sell', ['model' => $model, 'xml' => $xml]); }
$isNewbill = false; //是否为新单据 if ($sellNum == "") { $isNewbill = true; $num = date("Ymd", time()); $count = 0; $sql = "SELECT * FROM tbl_sell WHERE uid=" . Yii::$app->user->id . " AND left(sellnum,8)=" . $num . " order by id desc"; $sell = Sell::findBySql($sql)->one(); if ($sell) { $sellNum = $sell->getAttribute('sellnum'); $sellNum += 1; } else { $sellNum = $num . "01"; } } else { $sell = Sell::find()->where(['uid' => Yii::$app->user->id, 'sellnum' => $sellNum, 'status' => 0])->all(); } ?> <?php echo Html::label('单据号:'); ?> <?php echo Html::label($sellNum, null, ['id' => 'sellNum']); ?> <button id="sell-save-bill">保存单据</button> <div id="debug">1</div> <table class="table table-bordered"> <thead> <tr> <th>#</th> <th>条码</th>
public function getSells() { return $this->hasMany(Sell::className(), ['user_id' => 'id'])->orderBy(['id' => SORT_DESC]); }