public function actionSearch($term) { $model = Clients::find()->where(['like', 'name', $term])->limit(10)->all(); foreach ($model as $key => $data) { $orders = Orders::find()->where(['clientId' => $data->id])->count(); $array[$key]['id'] = $data->id; $array[$key]['label'] = $data->name . ' ' . $orders . ' Заказа(ов)'; } echo json_encode($array); }
public function actionUpdate($id) { $model = Orders::findOne($id); if ($model->load(Yii::$app->request->post())) { $model->editTimestamp = date('Y-m-d H:i:s'); $model->editName = Yii::$app->user->identity->full_name; $model->save(); return true; } return $this->renderAjax('form', ['model' => $model, 'clients' => ArrayHelper::map(Clients::find()->all(), 'id', 'name'), 'delivery' => ArrayHelper::map(Delivery::find()->all(), 'id', 'name'), 'action' => 'create']); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Clients::find(); $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, 'birthday' => $this->birthday]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'email', $this->email]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Clients::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, 'status' => $this->status, 'create_time' => $this->create_time, 'update_time' => $this->update_time, 'user_create' => $this->user_create]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'tel', $this->tel])->andFilterWhere(['like', 'fax', $this->fax])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'site', $this->site])->andFilterWhere(['like', 'info', $this->info]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Clients::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, 'timestamp' => $this->timestamp]); $query->andFilterWhere(['like', 'clientAcc', $this->clientAcc])->andFilterWhere(['like', 'client_name', $this->client_name])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'cellphone', $this->cellphone])->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'bonus_days', $this->bonus_days])->andFilterWhere(['like', 'lastpayment_date', $this->lastpayment_date])->andFilterWhere(['like', 'balances', $this->balances])->andFilterWhere(['like', 'arrears', $this->arrears]); return $dataProvider; }
public function actionCronjob() { $number = cal_days_in_month(CAL_GREGORIAN, date('m'), date('Y')); // 31 $billing = Bills::findOne(['id' => 1]); $rate = $billing->monthly_charge / $number; //ATTRIBUTES NEEDED FOR DIACTIVATION $attribute = "Auth-Type"; $operation = ":="; $value = "Reject"; //BILL ALL THE CLIENTS WHOSE STATUS IS 'yes' THE SYSTEM EXCLUDES THE CLIENTS WITH NO. $clients = Clients::find()->where(['status' => 'yes'])->all(); foreach ($clients as $key => $client) { # code... //echo $client->clientAcc."<br>"; $client = Clients::findOne([$client->id]); //IF CLIENT BALANCE IS GREATER THAN THE DAILY BILLING, SUBTRACT THE DAILY FEE. if ($client->balances > $rate) { $client->balances = (string) $client->balances - $rate; echo "Client Balance" . $client->balances; $client->save(); } elseif ($rate > $client->balances) { //DISCONNECT THE CLIENT $customer_radreply = Radreply::findOne(['username' => $client->username]); if (count($customer_radreply) >= 1) { //DO NOTHING SINCE THE USER IS DEACTIVATED } else { $victim_client = new Radreply(); $victim_client->username = $client->username; $victim_client->attribute = $attribute; $victim_client->op = $operation; $victim_client->value = $value; $victim_client->save(); } } elseif ($billing->monthly_charge * 4 > $client->balances && count(Radusergroup::findOne(['username' => $client->username])) == 0) { //SEND SMSES AND EMAILS TO ALERT THE THAT DISCONNECTION IS ABOUT TO TRIGGER // $customer_radgroup = Radreply::findOne(['username' => $client->username]); // $deactivate = Radgroupcheck::findOne(['id'=>1]); $email = Yii::$app->mailer->compose()->setFrom('*****@*****.**')->setTo('*****@*****.**')->setSubject('Message subject')->setHtmlBody('<b>HTML content</b>')->send(); echo "Email sent!"; echo "<pre>"; print_r($email); echo "</pre>"; } //SAVE CHANGES } return $this->render('cronjob'); }