add login email sending
This commit is contained in:
@@ -1,101 +1,184 @@
|
||||
<?php
|
||||
|
||||
namespace common\components;
|
||||
|
||||
use \Yii;
|
||||
|
||||
class Helper
|
||||
{
|
||||
|
||||
public static function hufRound($m){
|
||||
$result = round($m/5, 0) * 5;
|
||||
class Helper {
|
||||
public static function hufRound($m) {
|
||||
$result = round ( $m / 5, 0 ) * 5;
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function notInInterval($query ,$field , $start,$end ){
|
||||
$query->andFilterWhere( ['or', [ '<', $field , isset( $start ) ? $start : '1900-01-01' ] ,[ '>=' , $field , isset($end) ? $end : '3000-01-01' ] ] );
|
||||
public static function notInInterval($query, $field, $start, $end) {
|
||||
$query->andFilterWhere ( [
|
||||
'or',
|
||||
[
|
||||
'<',
|
||||
$field,
|
||||
isset ( $start ) ? $start : '1900-01-01'
|
||||
],
|
||||
[
|
||||
'>=',
|
||||
$field,
|
||||
isset ( $end ) ? $end : '3000-01-01'
|
||||
]
|
||||
] );
|
||||
}
|
||||
|
||||
public static function notPaid($query ,$field , $start,$end ){
|
||||
$query->andFilterWhere( ['or', [ '<', $field , isset( $start ) ? $start : '1900-01-01' ] ,[ '>=' , $field , isset($end) ? $end : '3000-01-01' ] ,[ "transfer.status" => Transfer::STATUS_NOT_PAID ] ] );
|
||||
public static function notPaid($query, $field, $start, $end) {
|
||||
$query->andFilterWhere ( [
|
||||
'or',
|
||||
[
|
||||
'<',
|
||||
$field,
|
||||
isset ( $start ) ? $start : '1900-01-01'
|
||||
],
|
||||
[
|
||||
'>=',
|
||||
$field,
|
||||
isset ( $end ) ? $end : '3000-01-01'
|
||||
],
|
||||
[
|
||||
"transfer.status" => Transfer::STATUS_NOT_PAID
|
||||
]
|
||||
] );
|
||||
}
|
||||
public static function inInterval($query ,$field , $start,$end ){
|
||||
$query->andFilterWhere([ '>=', $field , $start ] );
|
||||
$query->andFilterWhere([ '<' , $field , $end ] );
|
||||
public static function inInterval($query, $field, $start, $end) {
|
||||
$query->andFilterWhere ( [
|
||||
'>=',
|
||||
$field,
|
||||
$start
|
||||
] );
|
||||
$query->andFilterWhere ( [
|
||||
'<',
|
||||
$field,
|
||||
$end
|
||||
] );
|
||||
}
|
||||
|
||||
public static function queryInIntervalRule( $field , $start,$end ){
|
||||
return ['and',[ '>=', $field , $start ] , [ '<' , $field , $end ] ];
|
||||
public static function queryInIntervalRule($field, $start, $end) {
|
||||
return [
|
||||
'and',
|
||||
[
|
||||
'>=',
|
||||
$field,
|
||||
$start
|
||||
],
|
||||
[
|
||||
'<',
|
||||
$field,
|
||||
$end
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public static function queryExpireRule( $field_start,$field_end , $start,$end ){
|
||||
|
||||
return ['and' ,['<',$field_start, $end], ['>=' , $field_end , $start ], ['<=' , $field_end , $end ] ];
|
||||
public static function queryExpireRule($field_start, $field_end, $start, $end) {
|
||||
return [
|
||||
'and',
|
||||
[
|
||||
'<',
|
||||
$field_start,
|
||||
$end
|
||||
],
|
||||
[
|
||||
'>=',
|
||||
$field_end,
|
||||
$start
|
||||
],
|
||||
[
|
||||
'<=',
|
||||
$field_end,
|
||||
$end
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public static function queryValidRule( $field_start ,$field_end , $start,$end ){
|
||||
return ['and' ,['<',$field_start, $end], ['>=' , $field_end , $start ] ];
|
||||
public static function queryValidRule($field_start, $field_end, $start, $end) {
|
||||
return [
|
||||
'and',
|
||||
[
|
||||
'<',
|
||||
$field_start,
|
||||
$end
|
||||
],
|
||||
[
|
||||
'>=',
|
||||
$field_end,
|
||||
$start
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public static function sqlInIntervalRule( $field , $paramStart,$paramEnd ){
|
||||
return ' ' .$field . ' >= ' . $paramStart . ' and ' . $field . ' < ' . $paramEnd ;
|
||||
public static function sqlInIntervalRule($field, $paramStart, $paramEnd) {
|
||||
return ' ' . $field . ' >= ' . $paramStart . ' and ' . $field . ' < ' . $paramEnd;
|
||||
}
|
||||
|
||||
public static function sqlExpireRule( $field_start,$field_end , $paramStart,$paramEnd ){
|
||||
return ' ' .$field_start . ' < ' . $paramEnd . ' and ' . $field_end . ' < ' . $paramEnd ;
|
||||
public static function sqlExpireRule($field_start, $field_end, $paramStart, $paramEnd) {
|
||||
return ' ' . $field_start . ' < ' . $paramEnd . ' and ' . $field_end . ' < ' . $paramEnd;
|
||||
}
|
||||
|
||||
public static function sqlValidRule( $field_start ,$field_end , $paramStart,$paramEnd ){
|
||||
return ' ' .$field_start . ' < ' . $paramEnd . ' and ' . $field_end . ' >=' . $paramStart ;
|
||||
public static function sqlValidRule($field_start, $field_end, $paramStart, $paramEnd) {
|
||||
return ' ' . $field_start . ' < ' . $paramEnd . ' and ' . $field_end . ' >=' . $paramStart;
|
||||
}
|
||||
|
||||
public static function queryAccountConstraint($query,$field){
|
||||
if ( !RoleDefinition::isAdmin() ){
|
||||
$query->innerJoin("user_account_assignment", $field . ' = user_account_assignment.id_account' );
|
||||
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id ]);
|
||||
public static function queryAccountConstraint($query, $field) {
|
||||
if (! RoleDefinition::isAdmin ()) {
|
||||
$query->innerJoin ( "user_account_assignment", $field . ' = user_account_assignment.id_account' );
|
||||
$query->andWhere ( [
|
||||
'user_account_assignment.id_user' => Yii::$app->user->id
|
||||
] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function roleLabels(){
|
||||
return [
|
||||
'reception' => Yii::t('common/role' ,'Reception'),
|
||||
'admin' => Yii::t('common/role' ,'Administrator'),
|
||||
'employee' => Yii::t('common/role' ,'Alkalmazott'),
|
||||
public static function roleLabels() {
|
||||
return [
|
||||
'reception' => Yii::t ( 'common/role', 'Reception' ),
|
||||
'admin' => Yii::t ( 'common/role', 'Administrator' ),
|
||||
'employee' => Yii::t ( 'common/role', 'Alkalmazott' )
|
||||
];
|
||||
}
|
||||
|
||||
public static function roleDefinitions(){
|
||||
return [
|
||||
'employee' => [
|
||||
'canAllow' => [ 'employee'],
|
||||
public static function roleDefinitions() {
|
||||
return [
|
||||
'employee' => [
|
||||
'canAllow' => [
|
||||
'employee'
|
||||
]
|
||||
],
|
||||
'admin' => [
|
||||
'canAllow' => ['admin','reception','employee'],
|
||||
],
|
||||
'reception' => [
|
||||
'canAllow' => [ ],
|
||||
'admin' => [
|
||||
'canAllow' => [
|
||||
'admin',
|
||||
'reception',
|
||||
'employee'
|
||||
]
|
||||
],
|
||||
'reception' => [
|
||||
'canAllow' => [ ]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public static function flash($mode,$message){
|
||||
\Yii::$app->session->setFlash($mode, $message );
|
||||
public static function flash($mode, $message) {
|
||||
\Yii::$app->session->setFlash ( $mode, $message );
|
||||
}
|
||||
|
||||
|
||||
public static function fixAsciiChars($in){
|
||||
$out = str_replace("ö", "0", $in);
|
||||
$out = str_replace("Ö", "0", $out);
|
||||
public static function fixAsciiChars($in) {
|
||||
$out = str_replace ( "ö", "0", $in );
|
||||
$out = str_replace ( "Ö", "0", $out );
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function isCompanyMovar(){
|
||||
return \Yii::$app->params['company'] == 'movar';
|
||||
public static function isCompanyMovar() {
|
||||
return \Yii::$app->params ['company'] == 'movar';
|
||||
}
|
||||
public static function isProductVisibilityAccount(){
|
||||
return \Yii::$app->params['product_visiblity'] == 'account';
|
||||
public static function isProductVisibilityAccount() {
|
||||
return \Yii::$app->params ['product_visiblity'] == 'account';
|
||||
}
|
||||
public static function getRealUserIp() {
|
||||
$client = @$_SERVER ['HTTP_CLIENT_IP'];
|
||||
$forward = @$_SERVER ['HTTP_X_FORWARDED_FOR'];
|
||||
$remote = $_SERVER ['REMOTE_ADDR'];
|
||||
|
||||
if (filter_var ( $client, FILTER_VALIDATE_IP )) {
|
||||
$ip = $client;
|
||||
} elseif (filter_var ( $forward, FILTER_VALIDATE_IP )) {
|
||||
$ip = $forward;
|
||||
} else {
|
||||
$ip = $remote;
|
||||
}
|
||||
|
||||
return $ip;
|
||||
}
|
||||
public static function getGeoIp() {
|
||||
$ip = Helper::getRealUserIp ();
|
||||
$details = json_decode ( file_get_contents ( "http://ipinfo.io/{$ip}/json" ) );
|
||||
return $details;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user