@ -1,9 +1,9 @@
package controller . admin ;
package controller . admin ;
import haxe . web . Dispatch ;
import haxe . web . Dispatch ;
import Common ;
import Common ;
class Admin extends Controller {
class Admin extends Controller {
public function n e w ( ) {
public function n e w ( ) {
super ( ) ;
super ( ) ;
view . category = ' a d m i n ' ;
view . category = ' a d m i n ' ;
@ -13,7 +13,6 @@ class Admin extends Controller {
var e = Nav ( nav , " a d m i n " ) ;
var e = Nav ( nav , " a d m i n " ) ;
app . event ( e ) ;
app . event ( e ) ;
view . nav = e . getParameters ( ) [ 0 ] ;
view . nav = e . getParameters ( ) [ 0 ] ;
}
}
@ tpl ( " a d m i n / d e f a u l t . m t t " )
@ tpl ( " a d m i n / d e f a u l t . m t t " )
@ -30,24 +29,18 @@ class Admin extends Controller {
var count = sugoi . db . BufferedMail . manager . count ( $sdate == null ) ;
var count = sugoi . db . BufferedMail . manager . count ( $sdate == null ) ;
view . browser = new sugoi . tools . ResultsBrowser ( count , 10 , browse ) ;
view . browser = new sugoi . tools . ResultsBrowser ( count , 10 , browse ) ;
view . num = count ;
view . num = count ;
}
}
@ tpl ( " f o r m . m t t " )
@ tpl ( " f o r m . m t t " )
function doSmtp ( ) {
function doSmtp ( ) {
var f = new sugoi . form . Form ( " e m a i l s " ) ;
var f = new sugoi . form . Form ( " e m a i l s " ) ;
var data = [
{ label : " S M T P " , value : " s m t p " } ,
{ label : " M a n d r i l l A P I " , value : " m a n d r i l l " } ,
] ;
var data = [ { label : " S M T P " , value : " s m t p " } , { label : " M a n d r i l l A P I " , value : " m a n d r i l l " } , ] ;
var mailer = sugoi . db . Variable . get ( " m a i l e r " ) == null ? " s m t p " : sugoi . db . Variable . get ( " m a i l e r " ) ;
var mailer = sugoi . db . Variable . get ( " m a i l e r " ) == null ? " s m t p " : sugoi . db . Variable . get ( " m a i l e r " ) ;
var host = sugoi . db . Variable . get ( " s m t p _ h o s t " ) == null ? App . config . get ( " s m t p _ h o s t " ) : sugoi . db . Variable . get ( " s m t p _ h o s t " ) ;
var port = sugoi . db . Variable . get ( " s m t p _ p o r t " ) == null ? App . config . get ( " s m t p _ p o r t " ) : sugoi . db . Variable . get ( " s m t p _ p o r t " ) ;
var user = sugoi . db . Variable . get ( " s m t p _ u s e r " ) == null ? App . config . get ( " s m t p _ u s e r " ) : sugoi . db . Variable . get ( " s m t p _ u s e r " ) ;
var pass = sugoi . db . Variable . get ( " s m t p _ p a s s " ) == null ? App . config . get ( " s m t p _ p a s s " ) : sugoi . db . Variable . get ( " s m t p _ p a s s " ) ;
var host = sugoi . db . Variable . get ( " s m t p _ h o s t " ) == null ? " < S M T P _ S E R V E R > " : sugoi . db . Variable . get ( " s m t p _ h o s t " ) ;
var port = sugoi . db . Variable . get ( " s m t p _ p o r t " ) == null ? " 5 8 7 " : sugoi . db . Variable . get ( " s m t p _ p o r t " ) ;
var user = sugoi . db . Variable . get ( " s m t p _ u s e r " ) == null ? " " : sugoi . db . Variable . get ( " s m t p _ u s e r " ) ;
var pass = sugoi . db . Variable . get ( " s m t p _ p a s s " ) == null ? " " : sugoi . db . Variable . get ( " s m t p _ p a s s " ) ;
f . addElement ( new sugoi . form . elements . StringSelect ( " m a i l e r " , " M a i l e r " , data , mailer ) ) ;
f . addElement ( new sugoi . form . elements . StringSelect ( " m a i l e r " , " M a i l e r " , data , mailer ) ) ;
f . addElement ( new sugoi . form . elements . StringInput ( " s m t p _ h o s t " , " h o s t " , host ) ) ;
f . addElement ( new sugoi . form . elements . StringInput ( " s m t p _ h o s t " , " h o s t " , host ) ) ;
@ -55,13 +48,11 @@ class Admin extends Controller {
f . addElement ( new sugoi . form . elements . StringInput ( " s m t p _ u s e r " , " u s e r " , user ) ) ;
f . addElement ( new sugoi . form . elements . StringInput ( " s m t p _ u s e r " , " u s e r " , user ) ) ;
f . addElement ( new sugoi . form . elements . StringInput ( " s m t p _ p a s s " , " p a s s " , pass ) ) ;
f . addElement ( new sugoi . form . elements . StringInput ( " s m t p _ p a s s " , " p a s s " , pass ) ) ;
if ( f . isValid ( ) ) {
if ( f . isValid ( ) ) {
for ( k in [ " m a i l e r " , " s m t p _ h o s t " , " s m t p _ p o r t " , " s m t p _ u s e r " , " s m t p _ p a s s " ] ) {
for ( k in [ " m a i l e r " , " s m t p _ h o s t " , " s m t p _ p o r t " , " s m t p _ u s e r " , " s m t p _ p a s s " ] ) {
sugoi . db . Variable . set ( k , f . getValueOf ( k ) ) ;
sugoi . db . Variable . set ( k , f . getValueOf ( k ) ) ;
}
}
throw Ok ( " / a d m i n / e m a i l s " , t . _ ( " C o n f i g u r a t i o n u p d a t e d " ) ) ;
throw Ok ( " / a d m i n / e m a i l s " , t . _ ( " C o n f i g u r a t i o n u p d a t e d " ) ) ;
}
}
view . title = t . _ ( " E m a i l s e r v i c e c o n f i g u r a t i o n " ) ;
view . title = t . _ ( " E m a i l s e r v i c e c o n f i g u r a t i o n " ) ;
@ -72,12 +63,9 @@ class Admin extends Controller {
d . dispatch ( new controller . admin . Plugins ( ) ) ;
d . dispatch ( new controller . admin . Plugins ( ) ) ;
}
}
@ tpl ( " a d m i n / t a x o . m t t " )
@ tpl ( " a d m i n / t a x o . m t t " )
function doTaxo ( ) {
function doTaxo ( ) {
view . categ = db . TxpCategory . manager . all ( ) ;
view . categ = db . TxpCategory . manager . all ( ) ;
}
}
/ * *
/ * *
@ -91,31 +79,31 @@ class Admin extends Controller {
view . like = args . like != null ? args . like : " " ;
view . like = args . like != null ? args . like : " " ;
var sql = " " ;
var sql = " " ;
if ( args . user != null ) sql += " A N D u i d = " + args . user ;
if ( args . user != null )
sql += " A N D u i d = " + args . user ;
// if( args.like!=null && args.like != "" ) sql += " AND error like "+sys.db.Manager.cnx.quote("%"+args.like+"%");
// if( args.like!=null && args.like != "" ) sql += " AND error like "+sys.db.Manager.cnx.quote("%"+args.like+"%");
if ( args . empty ) {
if ( args . empty ) {
sys . db . Manager . cnx . request ( " t r u n c a t e t a b l e E r r o r " ) ;
sys . db . Manager . cnx . request ( " t r u n c a t e t a b l e E r r o r " ) ;
}
}
var errorsStats = sys . db . Manager . cnx . request ( " s e l e c t c o u n t ( i d ) a s c , D A T E _ F O R M A T ( d a t e , ' % y - % m - % d ' ) a s d a y f r o m E r r o r w h e r e d a t e > N O W ( ) - I N T E R V A L 1 M O N T H " + sql + " g r o u p b y d a y o r d e r b y d a y " ) . results ( ) ;
var errorsStats = sys . db . Manager . cnx . request ( " s e l e c t c o u n t ( i d ) a s c , D A T E _ F O R M A T ( d a t e , ' % y - % m - % d ' ) a s d a y f r o m E r r o r w h e r e d a t e > N O W ( ) - I N T E R V A L 1 M O N T H "
+ sql
+ " g r o u p b y d a y o r d e r b y d a y " )
. results ( ) ;
view . errorsStats = errorsStats ;
view . errorsStats = errorsStats ;
view . browser = new sugoi . tools . ResultsBrowser (
sugoi . db . Error . manager . unsafeCount ( " S E L E C T c o u n t ( * ) F R O M E r r o r W H E R E 1 " + sql ) ,
20 ,
function ( start , limit ) { return sugoi . db . Error . manager . unsafeObjects ( " S E L E C T * F R O M E r r o r W H E R E 1 " + sql + " O R D E R B Y d a t e D E S C L I M I T " + start + " , " + limit , false ) ; }
) ;
view . browser = new sugoi . tools . ResultsBrowser ( sugoi . db . Error . manager . unsafeCount ( " S E L E C T c o u n t ( * ) F R O M E r r o r W H E R E 1 " + sql ) , 20 ,
function ( start , limit ) {
return sugoi . db . Error . manager . unsafeObjects ( " S E L E C T * F R O M E r r o r W H E R E 1 " + sql + " O R D E R B Y d a t e D E S C L I M I T " + start + " , " + limit , false ) ;
} ) ;
}
}
@ tpl ( " a d m i n / g r a p h . m t t " )
@ tpl ( " a d m i n / g r a p h . m t t " )
function doGraph ( ? key : String , ? year : Int , ? month : Int ) {
function doGraph ( ? key : String , ? year : Int , ? month : Int ) {
var from = new Date ( year , month , 1 , 0 , 0 , 0 ) ;
var from = new Date ( year , month , 1 , 0 , 0 , 0 ) ;
var to = new Date ( year , month + 1 , 0 , 23 , 59 , 59 ) ;
var to = new Date ( year , month + 1 , 0 , 23 , 59 , 59 ) ;
if ( app . params . exists ( " r e c o m p u t e " ) ) {
if ( app . params . exists ( " r e c o m p u t e " ) ) {
switch ( key ) {
switch ( key ) {
c ase " b a s k e t " :
c ase " b a s k e t " :
for ( d in 1 ... to . getDate ( ) ) {
for ( d in 1 ... to . getDate ( ) ) {
@ -124,12 +112,8 @@ class Admin extends Controller {
var value = db . Basket . manager . count ( $cdate >= _from && $cdate <= _to ) ;
var value = db . Basket . manager . count ( $cdate >= _from && $cdate <= _to ) ;
var g = db . Graph . record ( key , value , _from ) ;
var g = db . Graph . record ( key , value , _from ) ;
// trace(value,_from,g);
// trace(value,_from,g);
}
}
}
}
}
}
var data = db . Graph . getRange ( key , from , to ) ;
var data = db . Graph . getRange ( key , from , to ) ;
@ -140,18 +124,14 @@ class Admin extends Controller {
var averageValue = 0.0 ;
var averageValue = 0.0 ;
var total = 0.0 ;
var total = 0.0 ;
for ( d in data ) total += d . value ;
for ( d in data )
total += d . value ;
averageValue = total / data . length ;
averageValue = total / data . length ;
view . total = total ;
view . total = total ;
view . averageValue = averageValue ;
view . averageValue = averageValue ;
}
}
function doFixDistribValidation ( ) {
function doFixDistribValidation ( ) {
Sys . println ( " = = = = = L i s t e d e s d i s t r i b u t i o n s a y a n t é t é r e - v a l i d é e s = = = = < b r > " ) ;
Sys . println ( " = = = = = L i s t e d e s d i s t r i b u t i o n s a y a n t é t é r e - v a l i d é e s = = = = < b r > " ) ;
// Get the current group
// Get the current group
@ -161,18 +141,14 @@ class Admin extends Controller {
// Get all the validated distributions for this given group
// Get all the validated distributions for this given group
var validatedDistribs = db . Distribution . manager . search ( ( $contractId in contractIds ) && $validated == true , { orderBy : date } , false ) ;
var validatedDistribs = db . Distribution . manager . search ( ( $contractId in contractIds ) && $validated == true , { orderBy : date } , false ) ;
for ( distrib in validatedDistribs ) {
for ( distrib in validatedDistribs ) {
service . PaymentService . validateDistribution ( distrib ) ;
service . PaymentService . validateDistribution ( distrib ) ;
Sys . println ( distrib . toString ( ) + " < b r > " ) ;
Sys . println ( distrib . toString ( ) + " < b r > " ) ;
}
}
Sys . println ( " = = = = = F i n d e l a l i s t e = = = = " ) ;
Sys . println ( " = = = = = F i n d e l a l i s t e = = = = " ) ;
}
}
function doCheckDistribValidation ( ) {
function doCheckDistribValidation ( ) {
Sys . println ( " = = = = = L i s t e d e s d i s t r i b u t i o n s v a l i d é e s a y a n t d e s o p é r a t i o n s / p a i e m e n t s n o n v a l i d é s = = = = < b r > " ) ;
Sys . println ( " = = = = = L i s t e d e s d i s t r i b u t i o n s v a l i d é e s a y a n t d e s o p é r a t i o n s / p a i e m e n t s n o n v a l i d é s = = = = < b r > " ) ;
// Get the current group
// Get the current group
@ -182,11 +158,10 @@ class Admin extends Controller {
// Get all the validated distributions for this given group
// Get all the validated distributions for this given group
var validatedDistribs = db . Distribution . manager . search ( ( $contractId in contractIds ) && $validated == true , { orderBy : date } , false ) ;
var validatedDistribs = db . Distribution . manager . search ( ( $contractId in contractIds ) && $validated == true , { orderBy : date } , false ) ;
for ( distrib in validatedDistribs ) {
for ( distrib in validatedDistribs ) {
for ( user in distrib . getUsers ( ) ) {
for ( user in distrib . getUsers ( ) ) {
var basket = db . Basket . get ( user , distrib . place , distrib . date ) ;
var basket = db . Basket . get ( user , distrib . place , distrib . date ) ;
if ( basket == null || basket . isValidated ( ) ) continue ;
if ( basket == null || basket . isValidated ( ) )
continue ;
for ( order in basket . getOrders ( ) ) {
for ( order in basket . getOrders ( ) ) {
if ( ! order . paid ) {
if ( ! order . paid ) {
@ -197,27 +172,21 @@ class Admin extends Controller {
var operation = basket . getOrderOperation ( false ) ;
var operation = basket . getOrderOperation ( false ) ;
if ( operation != null ) {
if ( operation != null ) {
if ( operation . pending ) {
if ( operation . pending ) {
Sys . println ( distrib . toString ( ) + " < b r > " ) ;
Sys . println ( distrib . toString ( ) + " < b r > " ) ;
Sys . println ( operation . toString ( ) + " < b r > " ) ;
Sys . println ( operation . toString ( ) + " < b r > " ) ;
}
}
for ( payment in basket . getPayments ( ) ) {
for ( payment in basket . getPayments ( ) ) {
if ( payment . pending ) {
if ( payment . pending ) {
Sys . println ( distrib . toString ( ) + " < b r > " ) ;
Sys . println ( distrib . toString ( ) + " < b r > " ) ;
Sys . println ( payment . toString ( ) + " < b r > " ) ;
Sys . println ( payment . toString ( ) + " < b r > " ) ;
}
}
}
}
}
}
}
}
}
}
Sys . println ( " = = = = = F i n d e l a l i s t e = = = = " ) ;
Sys . println ( " = = = = = F i n d e l a l i s t e = = = = " ) ;
}
}
}
}