/** * @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(); }
/** * 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)]); }
/** * Creates a new Logs model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Logs(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
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); }
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(); }
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'; } }