Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Invoice::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, 'due_date' => $this->due_date, 'account_no' => $this->account_no, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'invoice_no', $this->invoice_no])->andFilterWhere(['like', 'bank_name', $this->bank_name])->andFilterWhere(['like', 'customer', $this->customer])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'telephone', $this->telephone])->andFilterWhere(['like', 'fax', $this->fax])->andFilterWhere(['like', 'pic', $this->pic])->andFilterWhere(['like', 'mobile', $this->mobile]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Invoice::find()->with('registration')->andWhere(['deleted' => [0, 5]]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'registration_id' => $this->registration_id, 'order_number' => $this->order_number, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by, 'deleted' => $this->deleted]);
     $query->andFilterWhere(['like', 'pay_number', $this->pay_number])->andFilterWhere(['like', 'invoice', $this->invoice])->andFilterWhere(['like', 'currency', $this->currency])->andFilterWhere(['like', 'payment_type', $this->payment_type])->andFilterWhere(['like', 'financial_institution', $this->financial_institution])->andFilterWhere(['like', 'ref_number', $this->ref_number])->andFilterWhere(['like', 'contract_number', $this->contract_number]);
     return $dataProvider;
 }
Ejemplo n.º 3
0
 /** 发票申请 */
 public function actionInvoiceApply()
 {
     $applyInvoiceForm = new ApplyInvoiceForm();
     CommonFunctions::createAlertMessage("为了更好的为您提供服务,请认真填写相关信息!<br>\n        说明:申请金额至少50元起,不得大于可申请金额,且发票将采用到付方式快递给您。", "info");
     if ($applyInvoiceForm->load(Yii::$app->request->post()) && $applyInvoiceForm->validate()) {
         if ($applyInvoiceForm->record()) {
             CommonFunctions::createAlertMessage("您的申请已经记录,请耐心等待管理员审核和配送", "success");
         }
     }
     $user = Yii::$app->session->get('user');
     $query = Invoice::find()->where(['userId' => $user['userId']])->orderBy(['createDate' => SORT_DESC]);
     $pagination = new Pagination(['defaultPageSize' => 20, 'totalCount' => $query->count()]);
     $invoices = $query->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render('invoice-apply', ['applyInvoiceForm' => $applyInvoiceForm, 'invoices' => $invoices, 'pages' => $pagination]);
 }
Ejemplo n.º 4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Invoice::find()->andWhere(['not', ['status_id' => Invoice::STATUS_CURRENT]])->with('location.client');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => false, 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]]]);
     $dataProvider->sort->attributes['location_id'] = ['asc' => [Client::tableName() . '.name' => SORT_ASC, Location::tableName() . '.name' => SORT_ASC], 'desc' => [Client::tableName() . '.name' => SORT_DESC, Location::tableName() . '.name' => SORT_DESC]];
     $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([Invoice::tableName() . '.location_id' => $this->location_id, Invoice::tableName() . '.status_id' => $this->status_id]);
     $query->andFilterWhere(['like', Invoice::tableName() . '.id', (int) $this->id]);
     return $dataProvider;
 }
Ejemplo n.º 5
0
 public function beforeAction($action)
 {
     //$css_file_id='';
     $test = 11;
     $ref = Yii::$app->request->get('ref', '');
     $id = Yii::$app->request->get('id', '');
     $user_id = 0;
     if (!\Yii::$app->user->isGuest) {
         $user_id = \Yii::$app->user->identity->getId();
     }
     if (!empty($ref)) {
         $user_id = AlphaId::id($ref, true);
     }
     $user_setting = UserSetting::findByUserId($user_id);
     if ($user_setting) {
         $this->getView()->params['css_file_id'] = $user_setting->css_file_id;
         $this->getView()->params['logo_url'] = $user_setting->logo_url;
         $this->getView()->params['ref_user_id'] = $user_id;
         $this->getView()->params['id'] = $id;
         $this->getView()->params['ref'] = $ref;
     } else {
         $this->getView()->params['css_file_id'] = '';
         $this->getView()->params['logo_url'] = '';
     }
     if ($user_id != 0) {
         $cartForm = new CartForm();
         $rows = $cartForm->getUserCart($user_id, true);
         $this->getView()->params['cart_count'] = count($rows);
         $invoicies = Invoice::find()->where(['user_id' => $user_id, 'status' => Invoice::STATUS_NEW])->all();
         $invoice = Invoice::findOne(['user_id' => $user_id, 'status' => Invoice::STATUS_NEW]);
         $invoice_id = 0;
         if ($invoice) {
             $invoice_id = $invoice->id;
         }
         $this->getView()->params['invoice_count'] = count($invoicies);
         $this->getView()->params['invoice_id'] = $invoice_id;
         if (!Yii::$app->user->isGuest && Yii::$app->user && Yii::$app->user->identity) {
             $this->getView()->params['demo'] = Yii::$app->user->identity->role == User::ROLE_DEMO ? true : false;
         }
     } else {
         $this->getView()->params['demo'] = 0;
     }
     return parent::beforeAction($action);
 }
 /** 发票查询 */
 public function actionSearch()
 {
     $user = Yii::$app->session->get('user');
     $request = Yii::$app->request;
     $session = Yii::$app->session;
     $query = $session->getFlash('query');
     if ($request->isPost) {
         $type = $request->post('type');
         $content = $request->post('content');
     } else {
         $type = $request->get('type');
         $content = trim($request->get('content'));
     }
     if ($type || !$query) {
         switch ($type) {
             case 'orderNumber':
                 $query = Invoice::find()->where(['userId' => $user['userId']])->andWhere(['like', 'orderNumber', $content]);
                 break;
             case 'state':
                 $query = Invoice::find()->where(['userId' => $user['userId'], 'state' => $content]);
                 break;
             case 'money-more':
                 $query = Invoice::find()->where(['userId' => $user['userId']])->andWhere(['>=', 'money', $content]);
                 break;
             case 'money-equal':
                 $query = Invoice::find()->where(['userId' => $user['userId']])->andWhere(['==', 'money', $content]);
                 break;
             case 'money-less':
                 $query = Invoice::find()->where(['userId' => $user['userId']])->andWhere(['<=', 'money', $content]);
                 break;
             default:
                 $query = Invoice::find()->where(['like', $type, $content]);
                 break;
         }
     }
     $pagination = new Pagination(['defaultPageSize' => Yii::$app->params['pageSize'], 'totalCount' => $query->count()]);
     $models = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['createDate' => SORT_DESC])->all();
     return $this->render('index', ['models' => $models, 'pages' => $pagination]);
 }
Ejemplo n.º 7
0
 /**
  * 查询用户正在申请中的发票
  * @param $userId
  * @return array|\yii\db\ActiveRecord[]
  */
 public static function findApplyingByUser($userId)
 {
     return Invoice::find()->where(['userId' => $userId])->andWhere(['state' => Invoice::STATE_ING])->orWhere(['state' => Invoice::STATE_PASS])->orderBy(['createDate' => SORT_DESC])->all();
 }
Ejemplo n.º 8
0
 /** 发票查询 */
 public function actionSearch()
 {
     $request = Yii::$app->request;
     $session = Yii::$app->session;
     $query = $session->getFlash('query');
     if ($request->isPost) {
         $type = $request->post('type');
         $content = $request->post('content');
     } else {
         $type = $request->get('type');
         $content = trim($request->get('content'));
     }
     if ($type || !$query) {
         switch ($type) {
             case 'nickname':
                 $table_a = Invoice::tableName();
                 $table_b = Users::tableName();
                 $query = Invoice::find()->leftJoin($table_b, "{$table_a}.userId={$table_b}.userId")->where(['like', "{$table_b}.nickname", $content]);
                 break;
             case 'money-more':
                 $query = Invoice::find()->Where(['>=', 'money', $content]);
                 break;
             case 'money-equal':
                 $query = Invoice::find()->where(['==', 'money', $content]);
                 break;
             case 'money-less':
                 $query = Invoice::find()->Where(['<=', 'money', $content]);
                 break;
             case 'role':
                 $role = '';
                 if ($content == 'a' || $content == 'A' || $content == 'A级') {
                     $role = Users::ROLE_A;
                 } elseif (strstr('金牌伙伴', $content)) {
                     $role = Users::ROLE_AA;
                 } elseif (strstr('钻石伙伴', $content)) {
                     $role = Users::ROLE_AAA;
                 } elseif ($content == '管理员') {
                     $role = Users::ROLE_ADMIN;
                 }
                 $table_a = Invoice::tableName();
                 $table_b = Users::tableName();
                 $query = Invoice::find()->leftJoin($table_b, "{$table_a}.userId={$table_b}.userId")->where(["{$table_b}.role" => $role]);
                 break;
             default:
                 $query = Invoice::find()->where(['like', $type, $content]);
                 break;
         }
     }
     $view = $session->getFlash('view');
     if (!$view) {
         //非下一页
         $view = $request->get('view');
         //取哪个页面的搜索
         if (!$view) {
             //不存在即为index的搜索
             $view = 'index';
         }
     }
     if ($view == 'apply') {
         //发票申请的搜索
         $query->andWhere(['state' => Invoice::STATE_ING]);
     } elseif ($view == 'opener') {
         //发票开具的搜索
         $query->andWhere(['state' => Invoice::STATE_PASS]);
     }
     $session->setFlash('view', $view);
     $session->setFlash('query', $query);
     $pagination = new Pagination(['defaultPageSize' => Yii::$app->params['pageSize'], 'totalCount' => $query->count()]);
     $models = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['createDate' => SORT_DESC])->all();
     return $this->render($view, ['models' => $models, 'pages' => $pagination]);
 }