/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function getDetail($id) { $client = Client::find($id); $data_clients = DataClient::with("client")->where("client_id", "=", $id)->get(); return view("clients.detail")->with(array('client' => $client, 'data_client' => $data_clients)); return redirect()->back(); }
public function actionIndex() { // remove session 'msetting' Yii::$app->session->remove('msetting'); $clients = Client::find()->all(); return $this->render('index', ['clients' => $clients]); }
public function getPedidos($id) { $client = Client::find($id); $pedido = Pedido::with('client')->where('client_id', '=', $id)->get(); //dd($pedido->toArray()); return view("data_clients.pedidos")->with(array('client' => $client, 'pedido' => $pedido)); return redirect()->back(); }
/** * Updates an existing Event 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->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', ['model' => $model, 'zal' => Zal::find()->asArray()->all(), 'client' => Client::find()->asArray()->orderBy('name_client')->all(), 'users' => Users::find()->asArray()->where(['status' => 10])->orderBy('username')->all()]); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Client::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'client_type_id' => $this->client_type_id, 'discipline_id' => $this->discipline_id, 'status' => $this->status]); $query->andFilterWhere(['like', 'client_id', $this->client_id])->andFilterWhere(['like', 'first_name', $this->first_name])->andFilterWhere(['like', 'last_name', $this->last_name]); return $dataProvider; }
public function actionLists($id) { $countPosts = Client::find()->where(['iddirection' => $id])->count(); $posts = \app\models\Client::find()->where(['iddirection' => $id])->orderBy('nameclient')->all(); if ($countPosts > 0) { foreach ($posts as $post) { echo "<option value='" . $post->id . "'>" . $post->nameclient . " - " . $post->namevid . "</option>"; } } else { echo "<option>-</option>"; } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Client::find()->select("CONCAT_WS(' ',`surname`,clients.`name`) as name,phone,address, sum(cost*count) as cost,clients.id as id")->leftJoin(Order::tableName(), Order::tableName() . '.id_client=' . Client::tableName() . '.id')->groupBy('id_client'); $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(['name' => $this->name, 'surname' => $this->surname, 'phone' => $this->phone, 'address' => $this->address]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Client::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['name_client' => SORT_ASC]]]); $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]); $query->andFilterWhere(['like', 'name_client', $this->name_client])->andFilterWhere(['like', 'phone', $this->phone])->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 = Client::find()->active(); $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]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'cuit', $this->cuit])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'delivery_address', $this->delivery_address])->andFilterWhere(['like', 'payment_conditions', $this->payment_conditions])->andFilterWhere(['like', 'notes', $this->notes]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Client::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(['clientNumber' => $this->clientNumber, 'salesRepEmployeeNumber' => $this->salesRepEmployeeNumber, 'creditLimit' => $this->creditLimit]); $query->andFilterWhere(['like', 'clientName', $this->clientName])->andFilterWhere(['like', 'contactLastName', $this->contactLastName])->andFilterWhere(['like', 'contactFirstName', $this->contactFirstName])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'addressLine1', $this->addressLine1])->andFilterWhere(['like', 'addressLine2', $this->addressLine2])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'state', $this->state])->andFilterWhere(['like', 'postalCode', $this->postalCode])->andFilterWhere(['like', 'country', $this->country]); return $dataProvider; }
public function add_advertiser(Request $request) { if (Auth::check()) { if (in_array('ADD_EDIT_ADVERTISER', $this->permission)) { $validate = \Validator::make($request->all(), Advertiser::$rule); if ($validate->passes()) { if (User::isSuperAdmin()) { $client_obj = Client::find($request->input('client_id')); } else { $usr_company = $this->user_company(); $client_obj = Client::whereIn('user_id', $usr_company)->find($request->input('client_id')); } if ($client_obj) { $active = 'Inactive'; if ($request->input('active') == 'on') { $active = 'Active'; } $audit = new AuditsController(); $audit_key = $audit->generateRandomString(); $advertiser = new Advertiser(); $advertiser->name = $request->input('name'); $advertiser->domain_name = $request->input('domain_name'); $advertiser->status = $active; $advertiser->description = $request->input('description'); $advertiser->client_id = $request->input('client_id'); $advertiser->save(); if ($request->has('to_model')) { foreach ($request->input('to_model') as $index) { $adv_mdl_map = new Advertiser_Model_Map(); $adv_mdl_map->advertiser_id = $advertiser->id; $adv_mdl_map->model_id = $index; $adv_mdl_map->save(); $audit->store('adv_mdl_map', $index, $advertiser->id, 'add', $audit_key); } } $audit->store('advertiser', $advertiser->id, null, 'add', $audit_key); return Redirect::to(url('/client/cl' . $request->input('client_id') . '/advertiser/adv' . $advertiser->id . '/edit'))->withErrors(['success' => true, 'msg' => "Advertiser added successfully"]); } return Redirect::back()->withErrors(['success' => false, 'msg' => 'please Select your Client'])->withInput(); } return Redirect::back()->withErrors(['success' => false, 'msg' => $validate->messages()->all()])->withInput(); } return Redirect::back()->withErrors(['success' => false, 'msg' => "You don't have permission"]); } return Redirect::to(url('user/login')); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Client::find(); $query->joinWith(['clientType', 'discipline']); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->sort->attributes['clientType'] = ['asc' => ['client_type.type' => SORT_ASC], 'desc' => ['client_type.type' => SORT_DESC]]; $dataProvider->sort->attributes['discipline'] = ['asc' => ['discipline.name' => SORT_ASC], 'desc' => ['discipline.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(['id' => $this->id, 'client.active' => $this->active]); $query->andFilterWhere(['like', 'client_id', $this->client_id])->andFilterWhere(['like', 'full_name', $this->full_name])->andFilterWhere(['like', 'client_type.type', $this->clientType])->andFilterWhere(['like', 'discipline.name', $this->discipline]); //->andFilterWhere(['like', 'active', ($this->active) ? 'Si' : 'No']); return $dataProvider; }
/** * filter for group * @return array json */ public function actionGroup() { $fil = Yii::$app->request->post()['name']; Yii::$app->response->format = 'json'; if ($fil && $fil !== 'all') { $group = Group::find()->where(['name' => trim($fil)])->one(); if ($group) { if (!empty($group->groupsClients)) { $clients = []; foreach ($group->groupsClients as $key => $gc) { array_push($clients, $gc->client); } return ['errors' => '', 'data' => $this->renderPartial('_clients', ['results' => $clients])]; } } return ['errors' => '', 'data' => '']; } elseif ($fil && $fil === 'all') { return ['errors' => '', 'data' => $this->renderPartial('_clients', ['results' => Client::find()->all()])]; } }
public function postDelete() { if (Input::has('id')) { DB::transaction(function () { $client = Client::find(Input::get('id')); if (!empty($client->logo)) { File::delete($client->logo); } Client::destroy(Input::get('id')); echo "1"; }); $this->clearCache(); } else { echo "0"; } }
<p> <?php echo Html::a('Добавить командировку', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php $gridColumns = [['class' => 'yii\\grid\\ActionColumn'], ['attribute' => 'numbertrip', 'label' => '№ Командировки'], ['attribute' => 'iduserdata', 'filter' => ArrayHelper::map(\app\models\Userdata::find()->orderBy('pib')->asArray()->all(), 'id', 'pib'), 'label' => 'Фамилия Имя Отчество', 'value' => function ($data) { return $data->userdata1->pib; }], ['attribute' => 'depart', 'filter' => ArrayHelper::map(\app\models\Depart::find()->orderBy('name_depart')->asArray()->all(), 'id', 'name_depart'), 'value' => function ($data) { return $data->userdata1->idDepart->name_depart; }], ['attribute' => 'test', 'value' => function ($data) { return $data->client1->directions->sity; }], ['attribute' => 'idclient', 'label' => 'Предприятие для командировки ', 'headerOptions' => ['width' => '380'], 'filter' => ArrayHelper::map(\app\models\Client::find()->orderBy('nameclient')->asArray()->all(), 'id', 'nameclient'), 'width' => '150px', 'value' => function ($data) { return $data->client1->nameclient; }], ['attribute' => 'idproject', 'label' => 'Проект/Клиент для командировки', 'filter' => ArrayHelper::map(\app\models\Project::find()->orderBy('name_project')->asArray()->all(), 'id', 'name_project'), 'value' => function ($data) { return $data->project1->name_project; }], ['attribute' => 'date_otpr', 'label' => 'Дата отправления', 'format' => 'datetime'], ['attribute' => 'date_pr', 'label' => 'Дата прибытия.', 'format' => 'datetime'], ['attribute' => 'date_otpr1', 'label' => 'Дата отправления', 'format' => 'datetime'], ['attribute' => 'date_pr1', 'label' => 'Дата прибытия.', 'format' => 'datetime'], ['label' => 'Количество дней', 'value' => function ($data) { $datetime1 = new DateTime(date('Y-m-d', $data->date_otpr)); $datetime2 = new DateTime(date('Y-m-d', $data->date_pr1)); $interval = $datetime1->diff($datetime2); $interval = $interval->format('%R%a'); $interval = $interval + 1; return $interval; }], ['attribute' => 'daily', 'format' => ['decimal', 2]], ['label' => 'Командировочные', 'format' => ['decimal', 2], 'value' => function ($data) { $datetime1 = new DateTime(date('Y-m-d', $data->date_otpr)); $datetime2 = new DateTime(date('Y-m-d', $data->date_pr1)); $interval = $datetime1->diff($datetime2); $interval = $interval->format('%R%a');
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $client = Client::find($id); $client->delete(); return back(); }
private function setClientSession($id) { if ($getClient = Client::find($id)) { \Session::put('current_client', array('id' => $id, 'name' => $getClient->name, 'client_logo' => $getClient->client_logo)); } }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { if (\Auth::guest()) { return redirect('auth/login'); } $client = Client::find($id); if (!$client) { return view('clients/show')->withErrors(['cardID' => 'Пользователя с данным номером карты не существует!']); } else { return view('clients/show')->with('client', $client); } }
<?php use yii\helpers\Html; use yii\helpers\Url; use yii\widgets\ActiveForm; use app\models\Estimate; use app\models\Client; use yii\helpers\ArrayHelper; use kartik\depdrop\DepDrop; /* @var $this yii\web\View */ /* @var $model app\models\Estimate */ /* @var $form yii\widgets\ActiveForm */ $clients = Client::find()->active()->orderBy(['name' => SORT_ASC])->all(); ?> <div class="estiamte-form"> <?php $form = ActiveForm::begin(['enableClientValidation' => false]); ?> <?php echo $form->field($model, 'client_id')->dropDownList(ArrayHelper::map($clients, 'id', 'name'), ['prompt' => 'Elegir cliente', 'id' => 'client_id']); ?> <?php if ($model->isNewRecord) { ?> <div class="form-group"> <?php echo Html::submitButton('Crear cliente', ['class' => 'btn btn-primary', 'name' => 'action', 'value' => 'add-client']); ?>
]) ?--> <!--?= $form->field($model, 'client_id')->widget(Select2::classname(), [ 'data' => ArrayHelper::map( Client::find()->all(), 'id', 'client_id', 'full_name' ), 'options' => ['placeholder' => 'Selecciona una opción...'], 'pluginOptions' => [ 'allowClear' => true ], ]); ?--> <?php echo $form->field($model, 'client_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(Client::find()->all(), 'id', 'searchableName'), 'options' => ['placeholder' => 'Selecciona un Cliente...'], 'pluginOptions' => ['allowClear' => true]]); ?> <?php echo $form->field($model, 'user_id')->dropDownList(ArrayHelper::map(User::find()->all(), 'id', 'user_name')); ?> <?php echo $form->field($model, 'solved')->checkbox([], false); ?> <!--?= $form->field($model, 'date_solved')->textInput() ?--> <?php echo $form->field($model, 'date_solved')->widget(DateTimePicker::classname(), ['type' => DateTimePicker::TYPE_INPUT, 'pluginOptions' => ['minuteStep' => 1, 'autoclose' => true, 'format' => 'yyyy-mm-dd H:ii:s', 'todayBtn' => true]]); ?>
public function SubAudit($audit) { $audit_obj = array(); foreach ($audit as $index) { $entity_obj = null; switch ($index->entity_type) { case 'user': if (in_array('VIEW_USER', $this->permission)) { $entity_obj = User::find($index->entity_id); } break; case 'company': if (User::isSuperAdmin()) { $entity_obj = \App\Models\Company::find($index->entity_id); } break; case 'inventory': if (User::isSuperAdmin()) { $entity_obj = Inventory::find($index->entity_id); } break; case 'client': if (in_array('VIEW_CLIENT', $this->permission)) { $entity_obj = Client::find($index->entity_id); } break; case 'advertiser': if (in_array('VIEW_ADVERTISER', $this->permission)) { $entity_obj = Advertiser::with('GetClientID')->find($index->entity_id); } break; case 'creative': if (in_array('VIEW_CREATIVE', $this->permission)) { $entity_obj = Creative::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'campaign': if (in_array('VIEW_CAMPAIGN', $this->permission)) { $entity_obj = Campaign::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'offer': if (in_array('VIEW_OFFER', $this->permission)) { $entity_obj = Offer::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'pixel': if (in_array('VIEW_PIXEL', $this->permission)) { $entity_obj = Pixel::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'targetgroup': if (in_array('VIEW_TARGETGROUP', $this->permission)) { $entity_obj = Targetgroup::find($index->entity_id); } break; case 'targetgroup_geolocation_map': if (in_array('VIEW_TARGETGROUP', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = Geolocation::find($index->after_value); } else { $entity_obj = Geolocation::find($index->entity_id); } } break; case 'targetgroup_creative_map': if (in_array('VIEW_TARGETGROUP', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = Creative::find($index->after_value); } else { $entity_obj = Creative::find($index->entity_id); } } break; case 'targetgroup_segment_map': if (in_array('VIEW_TARGETGROUP', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = Segment::find($index->after_value); } else { $entity_obj = Segment::find($index->entity_id); } } break; case 'targetgroup_geosegment_map': if (in_array('VIEW_TARGETGROUP', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = GeoSegmentList::find($index->after_value); } else { $entity_obj = GeoSegmentList::find($index->entity_id); } } break; case 'targetgroup_bwlist_map': if (in_array('VIEW_TARGETGROUP', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = BWList::find($index->after_value); } else { $entity_obj = BWList::find($index->entity_id); } } break; case 'targetgroup_bidprofile_map': if (in_array('VIEW_TARGETGROUP', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = Bid_Profile::find($index->after_value); } else { $entity_obj = Bid_Profile::find($index->entity_id); } } break; case 'geosegment': if (in_array('VIEW_GEOSEGMENTLIST', $this->permission)) { $entity_obj = GeoSegmentList::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'geosegmententrie': if (in_array('VIEW_GEOSEGMENTLIST', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = GeoSegment::find($index->after_value); } else { $entity_obj = GeoSegment::find($index->entity_id); } } break; case 'bwlist': if (in_array('VIEW_BWLIST', $this->permission)) { $entity_obj = BWList::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'bwlistentrie': if (in_array('VIEW_BWLIST', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = BWEntries::find($index->after_value); } else { $entity_obj = BWEntries::find($index->entity_id); } } break; case 'bid_profile': if (in_array('VIEW_BIDPROFILE', $this->permission)) { $entity_obj = Bid_Profile::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'bid_profile_entry': if (in_array('VIEW_BIDPROFILE', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = Bid_Profile::where('id', $index->after_value)->first(); } else { $entity_obj = Bid_Profile_Entry::with('getParent')->find($index->entity_id); } } break; case 'modelTable': if (in_array('VIEW_MODEL', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = BWList::where('id', $index->after_value)->first(); } else { $entity_obj = ModelTable::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } } break; case 'offer_pixel_map': if (in_array('VIEW_OFFER', $this->permission)) { $entity_obj = Pixel::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'advertiser_model_map': if (in_array('VIEW_ADVERTISER', $this->permission)) { $entity_obj = ModelTable::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'positive_offer_model': if (in_array('VIEW_MODEL', $this->permission)) { $entity_obj = Offer::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'negative_offer_model': if (in_array('VIEW_MODEL', $this->permission)) { $entity_obj = Offer::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; } if (!is_null($entity_obj)) { array_push($audit_obj, $index); array_push($audit_obj, $entity_obj); } } return $audit_obj; }
public function postSingle(Request $request) { //try{ //$value = $request->session()->get('cardNo'); /* | | Getting user`s card number | */ $userInfo = array(); foreach (\Input::all() as $key => $value) { $userInfo[$key] = $value; } //var_dump($userInfo); $cardID = $userInfo['cardNo']; $nowPoints = $userInfo['nowPoints']; //echo $cardID; //echo $nowPoints; /* | | Connecting to the turbosms api via soap connection | */ $soapClient = new SoapClient('http://turbosms.in.ua/api/wsdl.html'); $auth = array('login' => 'bandson', 'password' => '031194vela'); $result = $soapClient->Auth($auth); //echo $result->AuthResult . ' '; /* | | Getting data from the database and creating message | */ if (!Client::find($cardID)) { return redirect('/send/single')->withErrors(['cardID' => 'Пользователя с данным номером карты не существует!']); } $client = Client::find($cardID); $client->nowPoints = $nowPoints; $client->allPoints = $client->allPoints + $nowPoints; // If we add points we also change overallPoints, if not - we do not change it if ($nowPoints > 0) { $client->overallPoints = $client->overallPoints + $nowPoints; } // Change discount value if ($client->overallPoints > 0 && $client->overallPoints < 1000) { $client->discount = 0; } else { if ($client->overallPoints >= 1000 && $client->overallPoints < 5000) { $client->discount = 10; } else { if ($client->overallPoints >= 5000 && $client->overallPoints < 10000) { $client->discount = 15; } else { if ($client->overallPoints >= 10000) { $client->discount = 20; } } } } // Save changes $client->save(); //echo $client->allPoints; // Zeroing nowPoints $client->nowPoints = 0; $client->save(); //echo $client; $m = ''; $m = ($client->state == "male" ? 'Shanovnyi ' : 'Shanovna ') . $client->lastName . ' ' . $client->firstName . '! Zmina baliv: ' . $nowPoints . '. Vash zagalnyi balans: ' . $client->allPoints . '. Vasha procentna skydka - ' . $client->discount . '%.'; $sms = array('sender' => 'Bandson', 'destination' => $client->mobNum, 'text' => $m); var_dump($sms); die; /* | | Sending SMS | */ //$res=$client->SendSMS($sms); //echo $res->SendSMSResult->ResultArray[0] . ' //'; /* | | Putting activity into log | */ $activityToLog = new ActivityLog(); $activityToLog->activity = "Sent report! Turbosms Login: "******". Destination: " . $sms['destination'] . ". Message: " . $sms['text']; $activityToLog->user = \Auth::user()->name; $activityToLog->save(); \Session::flash('messageSentSingle', 'Отчет отправлен!'); return redirect('/send/single'); //} /*catch(\Exception $e) { \Session::flash('messageSentSingleFail', $e->value()); return redirect('/send/single'); }*/ }
echo DatePicker::widget(['name' => 'from_date', 'type' => DatePicker::TYPE_RANGE, 'name2' => 'to_date', 'pluginOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']]); echo '<br>'; echo Html::submitButton('Создать отчет', ['class' => 'btn btn-primary']); ActiveForm::end(); ?> <br><br> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'rowOptions' => function ($model, $key, $index, $grid) { if ($model->updated_at !== $model->created_at) { return ['style' => 'background-color:#8ECEE7;']; } }, 'columns' => [['attribute' => 'date_event', 'label' => 'Дата', 'format' => 'date'], ['attribute' => 'date_ned', 'label' => 'День недели', 'value' => function ($data) { return Yii::$app->formatter->asDate($data->date_event, 'EEEE'); }], 'name_event', 'oborud', ['attribute' => 'id_zal', 'filter' => ArrayHelper::map(\app\models\Zal::find()->orderBy('name_zal')->asArray()->all(), 'id', 'name_zal'), 'label' => 'Зал', 'value' => function ($data) { return $data->idZal->name_zal; }], 'time_event', 'kofebrayk', 'furshet', ['attribute' => 'id_client', 'filter' => ArrayHelper::map(\app\models\Client::find()->orderBy('name_client')->asArray()->all(), 'id', 'name_client'), 'label' => 'Клиент', 'value' => function ($data) { return $data->idClient->name_client; }], ['attribute' => 'id_users', 'filter' => ArrayHelper::map(\app\models\Users::find()->orderBy('username')->asArray()->all(), 'id', 'username'), 'label' => 'Регистратор', 'value' => function ($data) { return $data->idUsers->username; }], ['attribute' => 'id_users1', 'filter' => ArrayHelper::map(\app\models\Users::find()->orderBy('username')->asArray()->all(), 'id', 'username'), 'label' => 'Ответственный', 'value' => function ($data) { return $data->idUsers1->username; }], 'dopinfo']]); ?> </div>
public function actionIndex() { $count = ['clients' => count(Client::find()->all()), 'websites' => count(Website::find()->all()), 'checklists' => count(Checklist::find()->all()), 'messages' => count(Message::find()->all())]; return $this->render('index', ['count' => $count]); }
public function ChangeStatus($id) { if (Auth::check()) { if (in_array('ADD_EDIT_CLIENT', $this->permission)) { $client_id = $id; if (User::isSuperAdmin()) { $client = Client::find($client_id); } else { $usr_company = $this->user_company(); $client = Client::whereIn('user_id', $usr_company)->find($id); } if ($client) { $data = array(); $audit = new AuditsController(); if ($client->status == 'Active') { array_push($data, 'status'); array_push($data, $client->status); array_push($data, 'Inactive'); $client->status = 'Inactive'; $msg = 'disable'; } elseif ($client->status == 'Inactive') { array_push($data, 'status'); array_push($data, $client->status); array_push($data, 'Active'); $client->status = 'Active'; $msg = 'actived'; } $audit->store('client', $client_id, $data, 'edit'); $client->save(); return $msg; } return Redirect::back()->withErrors(['success' => false, 'msg' => 'please Select your Client'])->withInput(); } return Redirect::back()->withErrors(['success' => false, 'msg' => "You don't have permission"]); } return Redirect::to(url('user/login')); }
<!-- General Data Title --> <div class="block-title"> <h2><i class="fa fa-pencil"></i> General</h2> </div> <!-- END General Data Title --> <!-- General Data Content --> <?php $form = ActiveForm::begin(['id' => 'web-form', 'layout' => 'horizontal', 'options' => ['class' => 'form-horizontal form-bordered'], 'fieldConfig' => ['horizontalCssClasses' => ['label' => 'col-md-3 control-label']]]); ?> <?php echo $form->field($website, 'active')->checkbox(['template' => "{label}<div class='col-md-9'><label class='switch switch-primary'>{input}<span></span></label></div>\n"])->label('Active?', ['class' => 'col-md-3 control-label']); ?> <?php echo $form->field($website, 'domain', ['template' => "{label}<div class='col-md-9'><div class='input-group'>{input}<span class='input-group-addon'><i class='gi gi-globe'></i></span></div></div>\n{hint}\n{error}"])->textInput(array('placeholder' => 'Domain', 'class' => 'form-control')); ?> <?php echo $form->field($website, 'online_date', ['template' => "{label}<div class='col-md-9'>{input}</div>\n{hint}\n{error}"])->textInput(array('placeholder' => 'dd/mm/yyyy', 'class' => 'form-control input-datepicker', 'data-date-format' => 'dd/mm/yyyy')); ?> <?php $dataList = ArrayHelper::map(Client::find()->asArray()->all(), 'id', 'firstname'); ?> <?php echo $form->field($website, 'clients_id', ['template' => "{label}<div class='col-md-9'>{input}</div>\n{hint}\n{error}"])->listBox($dataList, ['data-placeholder' => 'Choose one..', 'class' => 'select-select2', 'style' => 'width: 100%', 'id' => 'example-select2'])->label('Clients'); ?> <!-- END General Data Content --> </div>
public function upload() { if ($this->validate()) { $isValidFormat = true; $isValidEncoding = true; if (($handle = fopen($this->csvFile->tempName, "r")) !== FALSE) { if (($firstLine = fgetcsv($handle)) !== FALSE) { if (count($firstLine) >= 2) { if (mb_detect_encoding($firstLine[0]) !== 'ASCII') { $isValidEncoding = false; $firstLine = $this->convert_to_ASCII($firstLine); } } else { $isValidFormat = false; } if ($isValidFormat) { if ($firstLine[0] !== 'client_id' || $firstLine[1] !== 'full_name' || $firstLine[2] !== 'client_type_id' || $firstLine[3] !== 'discipline_id' || $firstLine[4] !== 'active') { $isValidFormat = false; } } } if ($isValidFormat) { $success = true; $row = 1; while (($data = fgetcsv($handle)) !== FALSE) { if (!$isValidEncoding) { $data = $this->convert_to_ASCII($data); } $row++; $model = new Client(); $model->client_id = $data[0]; $model->full_name = $data[1]; $model->client_type_id = $data[2]; $model->discipline_id = $data[3]; $model->active = $data[4]; if (!$model->save()) { $idClient = Client::find()->where(['client_id' => $model->client_id])->exists(); $typeClient = ClientType::find()->where(['id' => $model->client_type_id])->exists(); $idDiscipline = Discipline::find()->where(['id' => $model->discipline_id])->exists(); $activo = Client::find()->where(['active' => $model->active])->exists(); if ($idClient == true) { Yii::$app->session->addFlash("error-upload", "Error en línea: [" . $row . "] ----- El cliente con id: [" . $model->client_id . "] ya se encuentra registrado."); } else { if ($typeClient == false || $idDiscipline == false || $activo == false) { if ($typeClient == false) { $typeClient = "[client_type_id] No Válido. "; } else { $typeClient = ""; } if ($idDiscipline == false) { $idDiscipline = "[discipline_id] No Válido. "; } else { $idDiscipline = ""; } if ($activo == false) { $activo = "[active] No Válido."; } else { $activo = ""; } Yii::$app->session->addFlash("error-upload", "Error en línea: [" . $row . "] ----- " . $typeClient . "" . $idDiscipline . "" . $activo . ""); } } } } if (!feof($handle)) { $success = false; Yii::$app->session->setFlash('error', Yii::t('app', 'Unexpected error.')); } } else { Yii::$app->session->setFlash('error', Yii::t('app', 'El formato del archivo No es válido. El formato válido es: ') . "<div class=\"panel panel-default\">\n\t\t\t\t\t\t\t<div class=\"panel-body\">\n\t\t\t\t\t\t\t\t<p>client_id,full_name,client_type_id,discipline_id,active</p>\n\t\t\t\t\t\t\t\t<p>98341245,Pedro Salazar Dos,1,5,1</p>\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>"); } fclose($handle); } return $isValidFormat && $success; } else { return false; } }
$form = ActiveForm::begin(['layout' => 'horizontal', 'options' => ['enctype' => 'multipart/form-data']]); ?> <!--?= $form->field($model, 'client_id')->widget(\yii\jui\AutoComplete::classname(), [ 'clientOptions' => [ //'source' => ['usr', 'asr', 'pois'], /* 'source' => ArrayHelper::map( Location::find()->all(), 'id', 'name'), */ 'source' => ArrayHelper::getColumn(Client::find()->all(), 'client_id'),//[ArrayHelper::getColumn($model, 'id')], ], ]) ?--> <?php echo $form->field($model, 'client_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(Client::find()->all(), 'id', 'searchableName'), 'options' => ['placeholder' => 'Select a client...'], 'pluginOptions' => ['allowClear' => true]])->hint(Html::a('', ['client/create-from-assignation'], ['class' => 'btn btn-info btn-xs btn-right glyphicon glyphicon-plus'])); ?> <?php echo $form->field($model, 'room_id')->dropDownList(ArrayHelper::map(Room::find()->orderBy('name ASC')->where(['available' => 1])->all(), 'id', 'name'), ['prompt' => 'Selecciona un Salón...', 'onchange' => '$.post("' . Yii::$app->urlManager->createUrl('assignation/list-locations?id=') . '"+$(this).val(), function(data){ $("#assignation-location_id").html(data); })']); ?> <?php $locationData = []; if (!empty($model->room_id)) { $locationData = ArrayHelper::map(Location::find()->orderBy('location ASC')->where(['room_id' => $model->room_id])->all(), 'id', 'location'); }