コード例 #1
0
ファイル: Logs.php プロジェクト: juanchi008/playa_auto
 /**
  * @inheritdoc
  */
 public static function Add($nombre = null, $role = null, $module = null, $submodule = null, $result = null, $info = null)
 {
     $model = new Logs();
     $model->load(['Logs' => ['nombre' => $nombre, 'role' => $role, 'module' => $module, 'submodule' => $submodule, 'result' => $result, 'info' => $info, 'ip_address' => $_SERVER['REMOTE_ADDR'], 'fecha_registro' => Yii::$app->fn->GetDate('none'), 'hora_registro' => date("h:m")]]);
     //Fn::PrintVar($model);
     //exit;
     $model->save();
 }
コード例 #2
0
 /**
  * Displays a single Clients model.
  * @param string $id
  * @return mixed
  */
 public function actionView($id)
 {
     $type = 3;
     $logs = new Logs();
     $logs->setAttributes(['date' => time(), 'type' => $type, 'client_name' => $this->findModel($id)->name, 'user_id' => Yii::$app->user->identity->id]);
     $logs->save(false);
     return $this->render('view', ['model' => $this->findModel($id)]);
 }
コード例 #3
0
 public function store($companyId, $request)
 {
     $cacheTag = ['companies', 'company' . $companyId, 'domains'];
     $cacheKey = 'index';
     $_companies = Companies::find($companyId);
     if ($_companies) {
         if (!empty($request['domains'])) {
             foreach ($request['domains'] as $value) {
                 if (strpos($value, 'localhost') !== 0) {
                     $validator = $this->validate($value);
                     if ($validator->fails()) {
                         return new \Exception($validator->errors()->first());
                     }
                 }
                 if (Domains::where('domain', '=', $value)->where('company_id', '<>', $companyId)->count() > 0) {
                     return new \Exception('O domínio ' . $value . ' já está sendo usado por outro company');
                 }
             }
             $_companies->domains()->delete();
             foreach ($request['domains'] as $value) {
                 Logs::create(['activity' => 'store', 'module' => 'companies_domains', 'ref' => $value]);
                 $_companies->domains()->create(['company_id' => $companyId, 'domain' => $value]);
             }
             Cache::tags($cacheTag)->flush();
             return true;
         } else {
             return true;
         }
     } else {
         return new \Exception("Houve um erro ao localizar registro (id not found)");
     }
 }
コード例 #4
0
 /**
  * Finds the Logs model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Logs the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Logs::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #5
0
ファイル: Clients.php プロジェクト: p0vidl0/mediamax
 public function afterSave($insert, $changedAttributes)
 {
     $time = time();
     $client_name = $this->name;
     if ($insert) {
         $type = 1;
         $logs = new Logs();
         $logs->setAttributes(['date' => $time, 'type' => $type, 'client_name' => $client_name, 'user_id' => Yii::$app->user->identity->id]);
         $logs->save(false);
     } else {
         $type = 2;
         $logs = new Logs();
         foreach ($changedAttributes as $field => $value) {
             $logs = new Logs();
             $logs->setAttributes(['date' => $time, 'type' => $type, 'client_name' => $client_name, 'user_id' => Yii::$app->user->identity->id, 'field' => $this->getAttributeLabel($field), 'old_value' => $value, 'new_value' => $this->{$field}]);
             $logs->save(false);
             unset($logs);
         }
     }
     parent::afterSave($insert, $changedAttributes);
 }
コード例 #6
0
 public static function loger($user)
 {
     $data = User::findByUsername($user['username']);
     $role = Yii::$app->authManager->getRolesByUser($data->id);
     $time = time();
     $loger = new Logs();
     $loger->user_id = $data->id;
     $loger->operation = $user['operation'];
     $loger->sql = '';
     $loger->path_operation_text = $user['text'];
     $loger->path_operation_link = $user['url'];
     $loger->message = $user['message'];
     $loger->email = $data->username;
     $loger->files = '';
     if (!empty($role['user']->name)) {
         $loger->user_role = $role['user']->name;
     } else {
         $loger->user_role = $role['admin']->name;
     }
     $loger->date_post = $time;
     $loger->user_name = $data->u_snp;
     $check = $loger->save();
 }
コード例 #7
0
ファイル: LogsSearch.php プロジェクト: juanchi008/playa_auto
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Logs::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, 'fecha_registro' => $this->fecha_registro, 'hora_registro' => $this->hora_registro]);
     $query->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'role', $this->role])->andFilterWhere(['like', 'module', $this->module])->andFilterWhere(['like', 'submodule', $this->submodule])->andFilterWhere(['like', 'result', $this->result])->andFilterWhere(['like', 'info', $this->info])->andFilterWhere(['like', 'ip_address', $this->ip_address]);
     return $dataProvider;
 }
コード例 #8
0
ファイル: LogsSearch.php プロジェクト: liubo2055/lazadatest
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Logs::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, 'model_id' => $this->model_id, 'created' => $this->created]);
     $query->andFilterWhere(['like', 'model', $this->model])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
コード例 #9
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Logs::find()->orderBy(['id' => SORT_DESC]);
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'date' => $this->date]);
     $query->andFilterWhere(['like', 'logs', $this->logs]);
     return $dataProvider;
 }
コード例 #10
0
 public function destroy($companyId, $managerId)
 {
     $cacheTag = ['companies', 'company' . $companyId, 'managers'];
     $_company = Companies::find($companyId);
     if ($_company) {
         $_manager = $_company->managers()->select(['id'])->where('id', '=', $managerId);
         if ($_manager->count() > 0) {
             Cache::tags($cacheTag)->flush();
             Logs::create(['activity' => 'destroy', 'module' => 'companies_managers', 'ref' => $managerId]);
             return $_company->managers()->detach($_manager->first()->id);
         } else {
             return new \Exception("Houve um erro ao localizar registro (manager not found)");
         }
     } else {
         return new \Exception("Houve um erro ao localizar registro (id not found)");
     }
 }
コード例 #11
0
 public function fields(Request $request)
 {
     $company = config('global.companies.current.name');
     $managers = config('global.companies.current.managers');
     if ($request->get('data')) {
         Mail::send('emails.fields', ['data' => $request->get('data')], function ($message) use($managers, $company) {
             $message->from("*****@*****.**", $company)->subject("Você recebeu uma nova mensagem através do site.");
             foreach ($managers as $manager) {
                 $message->to($manager['email']);
             }
         });
         if (count(Mail::failures()) === 0) {
             Logs::create(['activity' => 'store', 'module' => 'emails', 'ref' => config('global.companies.current.id')]);
             return $this->jsonResponse();
         } else {
             return $this->jsonDataResponse(new \Exception('Tivemos um problema ao enviar email'));
         }
     } else {
         return $this->jsonDataResponse(new \Exception('Houve um erro ao enviar seu email, tente novamente mais tarde (no data)'));
     }
 }
コード例 #12
0
 public function store($request)
 {
     $cacheTag = ['configurations'];
     $validator = $this->validate($request);
     if (!$validator->fails()) {
         $_model = Configurations::getConfigutationsByCompanyId(config('global.companies.current.id'));
         if ($_model) {
             Logs::create(['activity' => 'update', 'module' => 'configurations']);
             Cache::tags(['delivery'])->flush();
             Cache::tags($cacheTag)->flush();
             if ($_model->company_id === config('global.companies.current.id')) {
                 return $_model->update($request);
             } else {
                 return new \Exception("Você não tem permissão para atualizar este registro");
             }
         } else {
             return new \Exception("Houve um erro ao localizar registro (id not found)");
         }
     } else {
         return new \Exception($validator->errors()->first());
     }
 }
コード例 #13
0
ファイル: FilesController.php プロジェクト: acrixl/Reportula
 public function files($job)
 {
     $find = Filessearch::where('jobid', '=', $job)->get();
     $find = $find->toArray();
     if (empty($find)) {
         $filessearch = new Filessearch();
         $files = Files::select(array($this->tables['path'] . '.path', $this->tables['filename'] . '.name as filename', 'jobid'))->join($this->tables['filename'], $this->tables['file'] . '.filenameid', '=', $this->tables['filename'] . '.filenameid')->join($this->tables['path'], $this->tables['file'] . '.pathid', '=', $this->tables['path'] . '.pathid')->where('jobid', '=', $job)->remember(10)->get();
         // ->where('jobid','=', $job);
         $files = $files->toArray();
         if (!empty($files)) {
             foreach (array_chunk($files, 1000) as $chunked_files) {
                 $t = Filessearch::insert($chunked_files);
             }
         }
         //$filessearch->getConnection()->insert("INSERT INTO ".($filessearch->getTable())." (path, filename, jobid) ".$files->toSql(), array($job));
     }
     /* Mostra o log do Job */
     $logs = Logs::select(array('logtext'))->where('jobid', '=', $job)->get();
     $logs2 = "";
     foreach ($logs as $log) {
         $logs2[] = preg_replace("/[\t\n]+/", '</br>', $log->logtext);
     }
     //////
     $files = Filessearch::select(array('path', 'filename'))->where('jobid', '=', $job)->orderBy('path', 'asc');
     $files = $files->get();
     //->toArray();
     //$files="";
     if (empty($files)) {
         foreach ($files as $file) {
             $ficheiro[$file->path . $file->name] = '';
         }
         $tree = $this->explodeTree($ficheiro, "/");
         $tree = $this->recursion($tree);
     } else {
         $tree = "";
     }
     // $menu = $this->recursion($tree);
     return View::make('files', array('jobid' => $job, 'logs' => implode($logs2), 'menu' => $menu = $tree));
 }
コード例 #14
0
 public function image($request)
 {
     if (!empty($request->product_id)) {
         $_model = Products::find($request->product_id);
         if ($request->hasFile('file')) {
             $_file = $request->file('file');
             if ($_model->image) {
                 Storage::delete($_model->image);
             }
             $filename = md5(time() . $_file->getClientOriginalName() . $request->product_id) . '.' . $_file->guessClientExtension();
             $request->file('file')->move(config('filesystems.disks.local.root'), $filename);
             $_model->image = $filename;
             $_model->save();
             Logs::create(['activity' => 'image', 'module' => 'products']);
             Cache::tags(['products'])->flush();
             return true;
         } else {
             return new \Exception("Parece que você não selecionou nenhum arquivo");
         }
     } else {
         return new \Exception("Produto não encontrado.");
     }
 }
コード例 #15
0
 public function destroy($userId, $addressId)
 {
     $cacheTag = ['users', 'user' . $userId, 'address'];
     $_user = Users::find($userId);
     if ($_user) {
         $_address = $_user->address()->select(['id'])->where('id', '=', $addressId);
         if ($_address->count() > 0) {
             Cache::tags($cacheTag)->flush();
             Logs::create(['activity' => 'destroy', 'module' => 'users_address', 'ref' => $addressId]);
             return $_address->delete();
         } else {
             return new \Exception("Houve um erro ao localizar registro (address not found)");
         }
     } else {
         return new \Exception("Houve um erro ao localizar registro (id not found)");
     }
 }
コード例 #16
0
 public function destroy($id)
 {
     $cacheTag = ['managers'];
     $_model = Managers::find($id);
     if ($_model) {
         Logs::create(['activity' => 'destroy', 'module' => 'profile']);
         Cache::tags($cacheTag)->flush();
         return $_model->delete();
     } else {
         return new \Exception("Houve um erro ao localizar registro (id not found)");
     }
 }
コード例 #17
0
 /**
  * Deletes an existing Autos model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $this->findModel($id)->delete();
     Logs::Add(\Yii::$app->user->Identity->nombre . ' | ' . \Yii::$app->user->Identity->id, \Yii::$app->user->Identity->GetRole(null, true), 'autos', 'borrar', 'exito', \Yii::$app->fn->GetLogText('autos', 'borrar', 'exito'));
     return $this->redirect(['index']);
 }
コード例 #18
0
ファイル: routes.php プロジェクト: PingadoWeb/deliveryApi
<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
    \App\Models\Logs::create();
    return view('welcome');
});
/*FILES*/
Route::get('files/{filename}', 'Files\\IndexController@index');
Route::get('image/{filename}', 'Files\\IndexController@image');
Route::group(['middleware' => ['getCompany', 'getManager', 'getUser']], function () {
    /*EMAILS*/
    Route::post('emails/fields', 'Emails\\IndexController@fields');
    Route::post('emails', 'Emails\\IndexController@index');
    /*STATUS*/
    Route::get('status', 'Status\\IndexController@index');
    Route::get('status/database', 'Status\\IndexController@database');
    Route::get('status/cache', 'Status\\IndexController@cache');
    Route::get('status/emails', 'Status\\IndexController@emails');
    Route::get('status/checkouts', 'Status\\IndexController@checkouts');
    Route::get('status/categories', 'Status\\IndexController@categories');
    Route::get('status/products', 'Status\\IndexController@products');
コード例 #19
0
 public function destroy($id)
 {
     $cacheTag = ['companies'];
     if ($this->isManager($id)) {
         $_model = Companies::find($id);
         if ($_model) {
             Logs::create(['activity' => 'destroy', 'module' => 'companies', 'ref' => $id]);
             Cache::tags($cacheTag)->flush();
             return $_model->delete();
         } else {
             return new \Exception("Houve um erro ao localizar registro (id not found)");
         }
     } else {
         return new \Exception('Você não tem permissão para realizar esta ação >:(');
     }
 }
コード例 #20
0
 public function actionLogin()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         $data = Yii::$app->request->post('LoginForm');
         $data['operation'] = 'login';
         $data['url'] = Url::to('');
         $data['text'] = 'Сайт, страница входа на сайт';
         $data['message'] = 'Вошел на сайт пользователь, почтовый ящик -> ' . $data['username'];
         $logs = Logs::loger($data);
         return $this->goBack();
     }
     return $this->render('login', ['model' => $model]);
 }
コード例 #21
0
 public function destroy($id)
 {
     $cacheTag = ['checkouts'];
     $_model = Checkouts::find($id);
     if ($_model) {
         Logs::create(['activity' => 'destroy', 'module' => 'checkouts', 'ref' => $id]);
         Cache::tags($cacheTag)->flush();
         if ($_model->company_id === config('global.companies.current.id')) {
             return $_model->delete();
         } else {
             return new \Exception("Você não tem permissão para realizar esta ação");
         }
     } else {
         return new \Exception("Houve um erro ao localizar registro (id not found)");
     }
 }
コード例 #22
0
 public function actionDpostprocess($xmlReq)
 {
     //Yii::app()->request->enableCsrfValidation = false;
     $lsdata = $xmlReq;
     $d3 = new TripleDESEncryption();
     $llave = "N2dYKcI9ivQEPlHN0/TCBJHp1c7OYtV5";
     $iv = "JbEFFDiOkRc=";
     $lsdata = $d3->decrypt($lsdata, $llave, $iv);
     list($datos, $aut, $Cre, $mes, $ttar, $sub, $Iva, $Ice, $Int, $Tot, $tNo, $cD, $tipo) = split('[&]', $lsdata);
     list($p0, $DATOS) = split('[=]', $datos);
     list($p1, $AUT) = split('[=]', $aut);
     list($p3, $CRE) = split('[=]', $Cre);
     list($p4, $MES) = split('[=]', $mes);
     list($p5, $TTAR) = split('[=]', $ttar);
     list($p6, $SUB) = split('[=]', $sub);
     list($p7, $IVA) = split('[=]', $Iva);
     list($p8, $ICE) = split('[=]', $Ice);
     list($p9, $INT) = split('[=]', $Int);
     list($p10, $TOT) = split('[=]', $Tot);
     list($p11, $TNO) = split('[=]', $tNo);
     list($p12, $CD) = split('[=]', $cD);
     list($p13, $TIPO) = split('[=]', $tipo);
     $logs = new Logs();
     $logs->type = "POSTPROCESS";
     $logs->description = "TIPO:" . $TIPO . "DATOS:" . $DATOS . "AUT:" . $AUT . "CRE:" . $CRE . "MES:" . $MES . "TTAR:" . $TTAR . "SUB:" . $SUB . "IVA:" . $IVA . "ICE:" . $ICE . "INT:" . $INT . "TOTAL:" . $TOT . "TNO:" . $TNO . "CD:" . $CD;
     $logs->creation_date = date("Y-m-d H:i:s");
     $logs->save();
     if ($TIPO == 'P') {
         $sell = Sell::findOne($DATOS);
         $user = User::findOne($sell->user_id);
         $id = $user->id;
         $sell->status = "COMPLETE";
         $carshop = CarShop::find()->where(['user_id' => $sell->user_id])->all();
         if ($sell->save()) {
             foreach ($carshop as $item) {
                 $detail = new Detail();
                 $detail->product_id = $item->product_id;
                 $detail->quantity = $item->quantity;
                 $detail->sell_id = $DATOS;
                 $detail->sap_id = $item->sap_id;
                 $detail->save();
             }
             CarShop::deleteAll("user_id = {$id}");
             $dinerstransaction = new DinersTransaction();
             $dinerstransaction->fecha = date("Ymd");
             $dinerstransaction->hora = date("His");
             $dinerstransaction->orden = $TNO;
             $dinerstransaction->marca = $TTAR;
             $dinerstransaction->subtotal = strval($SUB / 100);
             $dinerstransaction->iva = strval($IVA / 100);
             $dinerstransaction->impuesto = "0.00";
             $dinerstransaction->interes = "0.00";
             $dinerstransaction->total = strval($TOT / 100);
             $dinerstransaction->autorizacion = $AUT;
             $dinerstransaction->ruc = "1790241483001";
             $dinerstransaction->credito = $CRE;
             $dinerstransaction->meses = $MES;
             $dinerstransaction->estado = $TIPO;
             $dinerstransaction->conciliado = "";
             $dinerstransaction->extra = "n/a";
             $dinerstransaction->save();
             $email = Yii::$app->mailer->compose('transaction', ['name' => $user->names, 'aut' => $sell->transactionid, 'total' => $TOT / 100])->setFrom('*****@*****.**')->setTo($user->username)->setSubject($user->names . " " . "tu transacción fue completada con éxito")->send();
             if ($email) {
                 echo 'ESTADO=OK';
             } else {
                 echo 'ESTADO=KO';
             }
         } else {
             echo 'ESTADO=KO';
         }
     } else {
         echo 'ESTADO=KO';
     }
 }
コード例 #23
0
 public function emails()
 {
     $count = Logs::select(\DB::raw('count(id) as total'))->where('ref', config('global.companies.current.id'))->where('activity', 'store')->where('module', 'emails')->where('created_at', '>', Carbon::now()->subDays(30))->count();
     return $this->jsonResponse(['data' => $count]);
 }