public function actionUpdateNews($id) { $client = ModelClients::findOne($id); $client->name = $_POST['name']; $client->second = $_POST['second']; $client->middle = $_POST['middle']; $client->phone = $_POST['phone']; $client->update(); header("Location: http://" . $_SERVER['SERVER_NAME'] . "/"); }
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 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; }
/** * 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; }
/** * @return \yii\db\ActiveQuery */ public function getClients() { return $this->hasMany(Clients::className(), ['city_id' => 'id']); }
<h2><?php echo Html::encode($this->title); ?> </h2> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('Добавить новую', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php /*= ListView::widget([ 'dataProvider' => $dataProvider, 'itemOptions' => ['class' => 'item'], 'itemView' => function ($model, $key, $index, $widget) { return Html::a(Html::encode($model->name), ['view', 'id' => $model->id]); }, ]) */ ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'name', 'tel', 'email', ['attribute' => 'status', 'value' => 'statusName', 'filter' => Html::activeDropDownList($searchModel, 'status', Clients::getStatusesArray(), ['class' => 'form-control', 'prompt' => 'Все'])], ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>
<table width="100%"> <tr> <td style="width: 270px; vertical-align: top"> <div> <label>Плановая дата</label> <div class="well well-sm" style="background-color: #fff; width:245px;"> <?php echo DatePicker::widget(['model' => $model, 'attribute' => 'plan_date', 'type' => DatePicker::TYPE_INLINE, 'language' => 'ru', 'pluginOptions' => ['format' => 'yyyy-mm-dd']]); ?> </div> </div> </td> <td style="vertical-align: top"> <?php echo $form->field($model, 'client')->dropDownList(Clients::getClients()); ?> <?php //= $form->field($model, 'client')->textInput(['maxlength' => true]) ?> <?php //= $form->field($model, 'plan_date')->textInput() ?> <?php echo $form->field($model, 'plan')->textarea(array('rows' => 3)); ?> <?php //= $form->field($model, 'plan')->textInput(['maxlength' => true]) ?>
public function getClientName() { return $this->hasOne(Clients::className(), ['id' => 'client']); }
$form = ActiveForm::begin(); ?> <?php //= $form->field($model, 'user_create')->textInput(['maxlength' => true]) ?> <div class="col-md-10" style="padding-left: 0;"> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> </div> <div class="col-md-2" style="padding-right: 0;"> <?php echo $form->field($model, 'status')->dropDownList(Clients::getStatusesArray()); ?> </div> <?php echo $form->field($model, 'address')->textInput(['maxlength' => true]); ?> <div class="col-md-6" style="padding-left: 0;"> <?php echo $form->field($model, 'tel')->textInput(['maxlength' => true]); ?> </div> <div class="col-md-6" style="padding-right: 0;"> <?php
/** * Finds the Clients model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Clients the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Clients::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getClients() { return $this->hasMany(Clients::className(), ['responsable_id' => 'id']); }
//= $form->field($model, 'date_create') ?> <?php //= $form->field($model, 'user_create') ?> <div class="col-md-10" style="padding-left: 0;"> <?php echo $form->field($model, 'name'); ?> </div> <div class="col-md-2" style="padding-right: 0;"> <?php echo $form->field($model, 'status')->dropDownList(Clients::getStatusesArray(), array('prompt' => 'Все')); ?> </div> <?php //= $form->field($model, 'address') ?> <?php // echo $form->field($model, 'tel') ?> <?php // echo $form->field($model, 'fax') ?>
public function actionOneShow() { $id = $_GET['id']; $this->view->items = Model::findOne($id); $this->view->display('client'); }
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'); }
/** * Updates an existing Suspense model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->status == 'yes') { try { //FIND CUSTOMER RECORDS $customer = Clients::findOne(['clientAcc' => $model->mpesa_acc]); //HOW MUCH MONEY CLIENTS SHOULD PAY A MONTH $billing = Bills::findOne(['id' => 1]); //IF NO CLIENT FOUND, SUBMIT THIS TO SUSPENSE ACCOUNT if (count($customer) >= 1) { // IF A CLIENT IS FOUND, THEN DO THE FOLLOWING AND SAVE $payment = new Payments(); $payment->mpesa_id = $model->mpesa_id; $payment->original = $model->original; $payment->destination = $model->destination; $payment->customer_id = $model->customer_id; $payment->test = $model->test; $payment->mpesa_code = $model->mpesa_code; $payment->mpesa_acc = $model->mpesa_acc; $payment->mpesa_msidn = $model->mpesa_msidn; $payment->mpesa_amount = $model->mpesa_amount; $payment->mpesa_sender = $model->mpesa_sender; $payment->timestamp = $model->timestamp; $payment->save(); echo "<pre>"; //print_r($payment); echo "</pre>"; //IS THE CLIENT ACTIVE OR INACTIVE? BASED ON THE PROFILE $customer_radgroup = Radusergroup::findOne(['username' => $customer->username]); //print_r($customer_radgroup); //COLLECT ALL RADGROUPS $radgroups = Radgroupcheck::find()->all(); if ($payment->mpesa_amount >= $billing->monthly_charge) { //IF USER WAS DISCONNECTED, AND HAS PAID MORE THAN THE BILLING AMOUNT, SAY: 3000, THEN ACTIVATE THAT USER if (count($customer_radgroup) >= 1) { if ($customer_radgroup->groupname == "daloRADIUS-Disabled-Users") { try { //Yii::$app->db->createCommand()->delete('radusergroup', ['username' => $customer->username])->execute(); if ($customer_radgroup->delete()) { echo "Deleted"; } } catch (Exception $e) { } } } if ($customer->arrears < 0 && $customer->balances >= $billing->monthly_charge) { $customer->arrears += $payment->mpesa_amount; if ($customer->arrears > 0) { $customer->balances += $customer->arrears; } } elseif ($customer->arrears < 0 && $customer->balances < $billing->monthly_charge) { $difference = $billing->monthly_charge - $customer->balances; $topup = $billing->monthly_charge - $customer->balances; //$customer->balances = 2500; //$billing->monthly_charge = 3000; //$difference = 1000; //$payment->mpesa_amount = 2000 if ($payment->mpesa_amount > $topup) { $remainder = $payment->mpesa_amount - $topup; $customer->balances += $billing->monthly_charge; $customer->arrears += $remainder; if ($customer->arrears > 0) { $customer->balances += $customer->arrears; } } else { $customer->balances += $payment->mpesa_amount; } } else { $customer->balances += $payment->mpesa_amount; } } else { if ($customer->balances >= $billing->monthly_charge && $customer->arrears < 0) { //$customer->balances = 2000; //$billing->monthly_charge = 3000; //$difference = 1000; //$payment->mpesa_amount = 2000 $customer->arrears += $payment->mpesa_amount; if ($customer->arrears > 0) { $customer->balances += $customer->arrears; } } elseif ($customer->balances <= $billing->monthly_charge && $customer->arrears < 0) { if ($payment->mpesa_amount + $customer->balances > $billing->monthly_charge) { $topup = $billing->monthly_charge - $customer->balances; $customer->balances += $topup; // $excess = $payment->mpesa_amount - $topup; $customer->arrears += $excess; } else { $customer->balances += $payment->mpesa_amount; } } if ($customer->balances >= $billing->monthly_charge && count($customer_radgroup) >= 1) { if ($customer_radgroup->groupname == "daloRADIUS-Disabled-Users") { try { //Yii::$app->db->createCommand()->delete('radusergroup', ['username' => $customer->username])->execute(); if ($customer_radgroup->delete()) { echo "Deleted"; } } catch (Exception $e) { } } } } try { $customer->balances = (string) $customer->balances; $customer->arrears = (string) $customer->arrears; $customer->save(); } catch (Exception $e) { } } //return $this->render('collection', ["status"=>"Records saved"] ); } catch (Exception $e) { //return $this->render('collection', ["status"=>"Client Account details not found!"] ); } if ($model->save()) { //return $this->redirect(['view', 'id' => $model->id]); return $this->render('update', ['model' => $model, 'result' => $payment]); } } elseif ($model->load(Yii::$app->request->post()) && $model->save() && $model->status == 'no') { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', ['model' => $model]); } }
<?php $form = ActiveForm::begin(['action' => ['index'], 'method' => 'get']); ?> <?php //= $form->field($model, 'id') ?> <div style="clear: both;"> <div class="col-md-2" style="margin-left: 0; padding-left: 0;"> <?php echo $form->field($model, 'active')->dropDownList(Tasks::getStatusesArray(), array('prompt' => 'Все')); ?> </div> <div class="col-md-4"> <?php echo $form->field($model, 'client')->dropDownList(Clients::getClients(), array('prompt' => 'Любой')); ?> </div> <div class="col-md-3"> <?php echo '<label class="control-label">Даты</label>'; echo DatePicker::widget(['model' => $model, 'attribute' => 'fromDate', 'attribute2' => 'toDate', 'type' => DatePicker::TYPE_RANGE, 'form' => $form, 'pluginOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']]); ?> </div> <div class="col-md-3"> <?php if (User::isUserAdmin(Yii::$app->user->identity->username) or User::isUserModer(Yii::$app->user->identity->username)) { echo $form->field($model, 'user_ispol')->dropDownList(User::getUsers(), array('prompt' => 'Все')); } else { //echo $form->field($model, 'user_ispol')->dropDownList(Clients::getStatusesArray(), array('prompt'=>'Все')); }