2011-06-08 09:07:15 +00:00
pscript [ 'onload_Event Updates' ] = function ( ) {
if ( user == 'Guest' ) {
loadpage ( 'Login Page' ) ;
return ;
}
pscript . home _make _body ( ) ;
pscript . home _make _status ( ) ;
pscript . home _pre _process ( ) ;
pscript . home _make _widgets ( ) ;
}
// ==================================
pscript . home _make _body = function ( ) {
var wrapper = page _body . pages [ 'Event Updates' ] ;
// body
wrapper . main _tab = make _table ( wrapper , 1 , 2 , '100%' , [ '70%' , '30%' ] ) ;
$y ( wrapper . main _tab , { tableLayout : 'fixed' } ) ;
wrapper . body = $a ( $td ( wrapper . main _tab , 0 , 0 ) , 'div' , 'layout_wrapper' ) ;
wrapper . head = $a ( wrapper . body , 'div' ) ;
wrapper . banner _area = $a ( wrapper . head , 'div' ) ;
wrapper . toolbar _area = $a ( wrapper . head , 'div' ) ;
wrapper . system _message _area = $a ( wrapper . body , 'div' , '' ,
{ marginBottom : '16px' , padding : '8px' , backgroundColor : '#FFD' , border : '1px dashed #AA6' , display : 'none' } )
}
// ==================================
pscript . home _pre _process = function ( wrapper ) {
var wrapper = page _body . pages [ 'Event Updates' ] ;
var cp = locals [ 'Control Panel' ] [ 'Control Panel' ] ;
// banner
if ( cp . client _name ) {
var banner = $a ( wrapper . banner _area , 'div' , '' , { paddingBottom : '4px' } )
banner . innerHTML = cp . client _name ;
}
// complete registration
if ( in _list ( user _roles , 'System Manager' ) ) { pscript . complete _registration ( ) ; }
}
// Widgets
// ==================================
pscript . home _make _widgets = function ( ) {
var wrapper = page _body . pages [ 'Event Updates' ] ;
var cell = $td ( wrapper . main _tab , 0 , 1 ) ;
// sidebar
sidebar = new wn . widgets . PageSidebar ( cell , {
sections : [
{
title : 'Calendar' ,
display : function ( ) { return ! has _common ( user _roles , [ 'Guest' , 'Customer' , 'Vendor' ] ) } ,
render : function ( wrapper ) {
new HomeCalendar ( new HomeWidget ( wrapper , 'Calendar' , 'Event' ) , wrapper ) ;
}
} ,
{
title : 'To Do' ,
display : function ( ) { return ! has _common ( user _roles , [ 'Guest' , 'Customer' , 'Vendor' ] ) } ,
render : function ( wrapper ) {
new HomeToDo ( new HomeWidget ( wrapper , 'To Do' , 'Item' ) ) ;
}
} ,
{
title : 'Online Users' ,
display : function ( ) { return ! has _common ( user _roles , [ 'Guest' , 'Customer' , 'Vendor' ] ) } ,
render : function ( wrapper ) {
pscript . online _users _obj = new OnlineUsers ( wrapper ) ;
}
}
]
} )
sidebar . refresh ( )
/ * $ y ( c e l l , { p a d d i n g : ' 0 p x 8 p x ' } ) ;
new HomeCalendar ( new HomeWidget ( cell , 'Calendar' , 'Event' ) ) ;
new HomeToDo ( new HomeWidget ( cell , 'To Do' , 'Item' ) ) ; * /
new FeedList ( wrapper . body ) ;
}
OnlineUsers = function ( wrapper ) {
var me = this ;
this . wrapper = wrapper ;
this . my _company _link = function ( ) {
$a ( $a ( wrapper , 'div' , '' , { marginBottom : '7px' } ) , 'span' , 'link_type' ,
{ color : '#777' , 'color:hover' : '#FFF' , fontSize : '11px' } ,
'See all users' , function ( ) { loadpage ( 'My Company' ) ; } ) ;
}
this . render = function ( online _users ) {
me . my _company _link ( ) ;
if ( online _users . length ) {
var max = online _users . length ; max = ( max > 10 ? 10 : max )
for ( var i = 0 ; i < max ; i ++ ) {
new OneOnlineUser ( me . wrapper , online _users [ i ] ) ;
}
} else {
$a ( wrapper , 'div' , '' , { 'color' : '#888' } , 'No user online!' )
}
}
}
OneOnlineUser = function ( wrapper , det ) {
var name = cstr ( det [ 1 ] ) + ' ' + cstr ( det [ 2 ] ) ;
if ( det [ 1 ] == user ) name = 'You'
var div = $a ( wrapper , 'div' , '' , { padding : '3px 0px' } ) ;
$a ( div , 'div' , '' , { width : '7px' , height : '7px' , cssFloat : 'left' , margin : '5px' , backgroundColor : 'green' } ) ;
$a ( div , 'div' , '' , { marginLeft : '3px' } , name ) ;
}
HomeWidget = function ( parent , heading , item ) {
var me = this ; this . item = item ;
this . wrapper = $a ( parent , 'div' ) ;
// body
this . body = $a ( this . wrapper , 'div' , '' , { paddingBottom : '16px' } ) ;
this . footer = $a ( this . wrapper , 'div' ) ;
// add button
this . add _btn = $btn ( this . footer , '+ Add ' + item , function ( ) { me . add ( ) } ) ;
// refresh
this . refresh _btn = $ln ( this . footer , 'Refresh' , function ( ) { me . refresh ( ) ; } , { fontSize : '11px' , marginLeft : '7px' , color : '#888' } ) ;
}
HomeWidget . prototype . refresh = function ( ) {
var me = this ;
$di ( this . working _img ) ;
var callback = function ( r , rt ) {
$dh ( me . working _img ) ;
me . body . innerHTML = '' ;
// prepare (for calendar?)
if ( me . decorator . setup _body ) me . decorator . setup _body ( ) ;
for ( var i = 0 ; i < r . message . length ; i ++ ) {
new HomeWidgetItem ( me , r . message [ i ] ) ;
}
if ( ! r . message . length ) {
$a ( me . body , 'div' , '' , { color : '#777' } , me . no _items _message ) ;
}
}
$c _obj ( 'Home Control' , this . get _list _method , '' , callback ) ;
}
HomeWidget . prototype . make _dialog = function ( ) {
var me = this ;
if ( ! this . dialog ) {
this . dialog = new wn . widgets . Dialog ( ) ;
this . dialog . make ( {
width : 480 ,
title : 'New ' + this . item ,
fields : this . dialog _fields
} ) ;
this . dialog . fields _dict . save . input . onclick = function ( ) {
this . set _working ( ) ;
me . decorator . save ( this ) ;
}
}
}
HomeWidget . prototype . add = function ( ) {
this . make _dialog ( ) ;
this . decorator . clear _dialog ( ) ;
this . dialog . show ( ) ;
}
// Item
// --------
HomeWidgetItem = function ( widget , det ) {
var me = this ; this . det = det ; this . widget = widget ;
this . widget = widget ; this . det = det ;
// parent
if ( widget . decorator . get _item _parent ) parent = widget . decorator . get _item _parent ( det ) ;
else parent = widget . body ;
if ( ! parent ) return ;
// wrapper
this . wrapper = $a ( parent , 'div' ) ;
this . tab = make _table ( this . wrapper , 1 , 3 , '100%' , [ '90%' , '5%' , '5%' ] , { paddingRight : '4px' } ) ;
// buttons
this . edit _btn = $a ( $td ( this . tab , 0 , 1 ) , 'div' , 'wn-icon ' + 'ic-doc_edit' , { cursor : 'pointer' } ) ;
this . edit _btn . onclick = function ( ) { me . edit ( ) ; }
this . del _btn = $a ( $td ( this . tab , 0 , 2 ) , 'div' , 'wn-icon ' + 'ic-trash' , { cursor : 'pointer' } ) ;
this . del _btn . onclick = function ( ) { me . delete _item ( ) ; }
widget . decorator . render _item ( this , det ) ;
}
HomeWidgetItem . prototype . edit = function ( ) {
this . widget . make _dialog ( ) ;
this . widget . decorator . set _dialog _values ( this . det ) ;
this . widget . dialog . show ( ) ;
}
HomeWidgetItem . prototype . delete _item = function ( ) {
var me = this ;
this . wrapper . innerHTML = '<span style="color:#888">Deleting...</span>' ;
var callback = function ( r , rt ) {
$ ( me . wrapper ) . slideUp ( ) ;
}
$c _obj ( 'Home Control' , this . widget . delete _method , this . widget . get _item _id ( this . det ) , callback ) ;
}
// Calendar
// ===========================
HomeCalendar = function ( widget , wrapper ) {
// calendar link
$ln ( widget . footer , 'Full Calendar' , function ( ) { loadpage ( '_calendar' ) ; } , { marginLeft : '7px' , fontSize : '11px' , color : '#888' } )
this . widget = widget ;
// methods
this . widget . get _list _method = 'get_events_list'
this . widget . delete _method = 'delete_event' ;
this . widget . no _items _message = 'You have no events in the next 7 days' ;
this . widget . get _item _id = function ( det ) { return det . name ; }
this . widget . decorator = this ;
var hl = [ ] ;
for ( var i = 0 ; i < 24 ; i ++ ) {
hl . push ( ( ( i + 8 ) % 24 ) + ':00' ) ;
}
this . widget . dialog _fields = [
{ fieldtype : 'Date' , fieldname : 'event_date' , label : 'Event Date' , reqd : 1 } ,
{ fieldtype : 'Time' , fieldname : 'event_hour' , label : 'Event Time' , reqd : 1 } ,
{ fieldtype : 'Text' , fieldname : 'description' , label : 'Description' , reqd : 1 } ,
{ fieldtype : 'Button' , fieldname : 'save' , label : 'Save' }
] ;
this . widget . refresh ( ) ;
}
// create calendar grid
// --------------------
HomeCalendar . prototype . setup _body = function ( ) {
var w = this . widget ;
w . date _blocks = { } ;
for ( var i = 0 ; i < 7 ; i ++ ) {
var dt = dateutil . obj _to _str ( dateutil . add _days ( new Date ( ) , i ) ) ;
var div = $a ( w . body , 'div' , '' , { padding : '4px 0px' , borderBottom : '1px solid #AAA' , display : 'none' } ) ;
div . head = $a ( div , 'div' , '' , { fontWeight : 'bold' , paddingBottom : '4px' } ) ;
div . head . innerHTML = ( i == 0 ? 'Today' : ( i == 1 ? 'Tomorrow' : dateutil . str _to _user ( dt ) ) )
w . date _blocks [ dt ] = div ;
}
}
HomeCalendar . prototype . get _item _parent = function ( det ) {
var d = this . widget . date _blocks [ det . event _date ] ; $ds ( d ) ;
return d ;
}
HomeCalendar . prototype . render _item = function ( item , det ) {
var tab = make _table ( $td ( item . tab , 0 , 0 ) , 1 , 2 , '100%' , [ '48px' , null ] , { padding : '2px' , lineHeight : '1.5em' } ) ;
$y ( tab , { tableLayout : 'fixed' } ) ;
$td ( tab , 0 , 0 ) . innerHTML = '<span style="color:#888">' + det . event _hour + ':</span> ' ;
$a ( $td ( tab , 0 , 1 ) , 'span' , 'social' , { } , replace _newlines ( det . description ) ) ;
if ( det . ref _type && det . ref _name && det . ref _name != 'None' ) {
var span = $a ( $a ( $td ( tab , 0 , 1 ) , 'div' ) , 'span' , 'link_type' ) ;
span . innerHTML = det . ref _name ; span . dt = det . ref _type ;
span . onclick = function ( ) { loaddoc ( this . dt , this . innerHTML ) ; }
}
}
HomeCalendar . prototype . clear _dialog = function ( ) {
this . set _dialog _values ( { event _date : get _today ( ) , event _hour : '8:00' , description : '' } ) ;
}
HomeCalendar . prototype . set _dialog _values = function ( det ) {
var d = this . widget . dialog ;
d . set _values ( det ) ;
d . det = det ;
}
HomeCalendar . prototype . save = function ( btn ) {
var d = this . widget . dialog ;
var me = this ;
var det = d . get _values ( ) ;
if ( ! det ) {
btn . done _working ( ) ;
return ;
}
det . name = d . det . name ;
det . owner = user ;
if ( ! det . event _type )
det . event _type = 'Private' ;
var callback = function ( r , rt ) {
btn . done _working ( ) ;
me . widget . dialog . hide ( ) ;
me . widget . refresh ( ) ;
}
$c _obj ( 'Home Control' , 'edit_event' , JSON . stringify ( det ) , callback ) ;
}
// Todo
// ===========================
HomeToDo = function ( widget ) {
this . widget = widget ;
// methods
this . widget . get _list _method = 'get_todo_list' ;
this . widget . delete _method = 'remove_todo_item' ;
this . widget . no _items _message = 'Nothing to do?' ;
this . widget . get _item _id = function ( det ) { return det [ 0 ] ; }
this . widget . decorator = this ;
this . widget . dialog _fields = [
{ fieldtype : 'Date' , fieldname : 'date' , label : 'Event Date' , reqd : 1 } ,
{ fieldtype : 'Text' , fieldname : 'description' , label : 'Description' , reqd : 1 } ,
{ fieldtype : 'Check' , fieldname : 'checked' , label : 'Completed' } ,
{ fieldtype : 'Select' , fieldname : 'priority' , label : 'Priority' , reqd : 1 , 'options' : [ 'Medium' , 'High' , 'Low' ] . join ( '\n' ) } ,
{ fieldtype : 'Button' , fieldname : 'save' , label : 'Save' }
] ;
this . widget . refresh ( ) ;
}
HomeToDo . prototype . render _item = function ( item , det ) {
// priority tag
var tab = make _table ( $td ( item . tab , 0 , 0 ) , 1 , 2 , '100%' , [ '48px' , null ] , { padding : '2px' } ) ;
$y ( tab , { tableLayout : 'fixed' } ) ;
var span = $a ( $td ( tab , 0 , 0 ) , 'span' , '' , { padding : '2px' , color : '#FFF' , fontSize : '10px'
, backgroundColor : ( det [ 3 ] == 'Low' ? '#888' : ( det [ 3 ] == 'High' ? '#EDA857' : '#687FD3' ) ) } ) ;
$ ( span ) . css ( '-moz-border-radius' , '3px' ) . css ( '-webkit-border-radius' , '3px' ) ;
span . innerHTML = det [ 3 ] ;
// text
var span = $a ( $td ( tab , 0 , 1 ) , 'span' , 'social' , { lineHeight : '1.5em' } , replace _newlines ( det [ 1 ] ) ) ;
if ( det [ 4 ] ) $y ( span , { textDecoration : 'line-through' } ) ;
// if expired & open, then in red
if ( ! det [ 4 ] && dateutil . str _to _obj ( det [ 2 ] ) < new Date ( ) ) {
$y ( span , { color : 'RED' } ) ;
$a ( $td ( tab , 0 , 1 ) , 'div' , '' , { fontSize : '10px' , color : '#666' } , dateutil . str _to _user ( det [ 2 ] ) + ' (Overdue)' ) ;
} else {
$a ( $td ( tab , 0 , 1 ) , 'div' , '' , { fontSize : '10px' , color : '#666' } , dateutil . str _to _user ( det [ 2 ] ) ) ;
}
}
HomeToDo . prototype . clear _dialog = function ( ) {
this . set _dialog _values ( [ '' , '' , get _today ( ) , 'Medium' , 0 ] ) ;
}
HomeToDo . prototype . set _dialog _values = function ( det ) {
var d = this . widget . dialog ;
d . set _values ( {
date : det [ 2 ] ,
priority : det [ 3 ] ,
description : det [ 1 ] ,
checked : det [ 4 ]
} ) ;
d . det = det ;
}
HomeToDo . prototype . save = function ( btn ) {
var d = this . widget . dialog ;
var me = this ;
var det = d . get _values ( )
if ( ! det ) {
btn . done _working ( ) ;
return ;
}
det . name = d . det ? d . det [ 0 ] : '' ;
var callback = function ( r , rt ) {
btn . done _working ( ) ;
me . widget . dialog . hide ( ) ;
me . widget . refresh ( ) ;
}
$c _obj ( 'Home Control' , 'add_todo_item' , JSON . stringify ( det ) , callback ) ;
}
// Feed
// ==================================
FeedList = function ( parent ) {
// settings
this . auto _feed _off = cint ( sys _defaults . auto _feed _off ) ;
this . wrapper = $a ( parent , 'div' ) ;
this . make _head ( ) ;
this . make _list ( ) ;
this . list . run ( ) ;
}
FeedList . prototype . make _head = function ( ) {
var me = this ;
this . head = $a ( this . wrapper , 'div' , '' , { marginBottom : '8px' } ) ;
// head
$a ( this . head , 'h1' , '' , { display : 'inline' } , 'Home' ) ;
$a ( this . head , 'span' , 'link_type' , { marginLeft : '7px' } , '[?]' , function ( ) {
msgprint ( '<b>What appears here?</b> This is where you get updates of everything you are allowed to access and generates an update' )
} )
// refresh
$a ( this . head , 'span' , 'link_type' ,
{ cursor : 'pointer' , marginLeft : '7px' , fontSize : '11px' } , 'refresh' ,
function ( ) { me . run ( ) ; }
) ;
}
FeedList . prototype . run = function ( ) {
this . prev _date = null ;
this . list . run ( ) ;
}
FeedList . prototype . make _list = function ( ) {
this . list _area = $a ( this . wrapper , 'div' )
this . no _result = $a ( this . wrapper , 'div' , 'help_box' , { display : 'none' } , 'Nothing to show yet. Your feed will be updated as you start your activities' )
var l = new Listing ( 'Feed List' , 1 ) ;
var me = this ;
// style
l . colwidths = [ '100%' ] ; l . page _len = 20 ;
l . opts . cell _style = { padding : '0px' } ;
l . opts . hide _rec _label = 1 ;
// build query
l . get _query = function ( ) {
this . query = repl ( ' select \
distinct t1 . name , t1 . doc _type , t1 . doc _name , t1 . subject , t1 . modified _by , \
concat ( ifnull ( t2 . first _name , "" ) , " " , ifnull ( t2 . last _name , "" ) ) , t1 . modified , t1 . color \
from tabFeed t1 , tabProfile t2 , tabUserRole t3 , tabDocPerm t4 \
where t1 . doc _type = t4 . parent \
and t2 . name = t1 . owner \
and t3 . parent = "%(user)s" \
and t4 . role = t3 . role \
and ifnull ( t4 . ` read ` , 0 ) = 1 \
order by t1 . modified desc ' , { user : user } )
this . query _max = ''
}
// render list ui
l . show _cell = function ( cell , ri , ci , d ) { me . render _feed ( cell , ri , ci , d ) ; }
// onrun
l . onrun = function ( ) { $ ( me . wrapper ) . fadeIn ( ) ; if ( me . after _run ) me . after _run ( ) ; }
// make
l . make ( this . list _area ) ;
$dh ( l . btn _area ) ;
this . list = l ;
}
FeedList . prototype . after _run = function ( ) {
this . list . has _data ( ) ? $dh ( this . no _result ) : $ds ( this . no _result )
}
FeedList . prototype . render _feed = function ( cell , ri , ci , d ) {
new FeedItem ( cell , d [ ri ] , this ) ;
}
// Item
// -------------------------------
FeedItem = function ( cell , det , feedlist ) {
var me = this ;
this . det = det ; this . feedlist = feedlist ;
this . wrapper = $a ( cell , 'div' , '' , { paddingBottom : '4px' } ) ;
this . head = $a ( this . wrapper , 'div' ) ;
this . tab = make _table ( this . wrapper , 1 , 2 , '100%' , [ ( 100 / 7 ) + '%' , ( 600 / 7 ) + '%' ] ) ;
$y ( this . tab , { tableLayout : 'fixed' } )
// image
$y ( $td ( this . tab , 0 , 0 ) , { textAlign : 'right' , paddingRight : '4px' } ) ;
// text
this . text _area = $a ( $td ( this . tab , 0 , 1 ) , 'div' ) ;
this . render _references ( this . text _area , det ) ;
this . render _tag ( det ) ;
// add day separator
this . add _day _sep ( det ) ;
}
// Day separator
// -------------------------------------------------
FeedItem . prototype . add _day _sep = function ( det ) {
var me = this ;
var prev _date = det [ 6 ] . split ( ' ' ) [ 0 ] ;
var make _div = function ( ) {
var div = $a ( me . head , 'div' , '' ,
{ borderBottom : '1px solid #888' , margin : '8px 0px' , padding : '2px 0px' , color : '#888' , fontSize : '11px' } ) ;
div . innerHTML = comment _when ( det [ 6 ] , 1 ) ;
// today?
if ( prev _date == get _today ( ) ) {
div . innerHTML = '' ;
span = $a ( div , 'span' , '' , { padding : '2px' , color : '#000' , fontWeight : 'bold' } ) ;
span . innerHTML = 'Today' ;
}
}
if ( this . feedlist . prev _date && this . feedlist . prev _date != prev _date ) { make _div ( ) ; }
if ( ! this . feedlist . prev _date ) { make _div ( ) ; }
this . feedlist . prev _date = prev _date ;
}
// Tag
// -------------------------------------------------
FeedItem . prototype . render _tag = function ( det ) {
tag = $a ( $td ( this . tab , 0 , 0 ) , 'div' , '' ,
{ color : '#FFF' , padding : '3px' , textAlign : 'right' , fontSize : '11px' , whiteSpace : 'nowrap' , overflow : 'hidden' , cursor : 'pointer' } ) ;
$br ( tag , '3px' ) ;
$y ( tag , { backgroundColor : ( det [ 7 ] ? det [ 7 ] : '#273' ) } ) ;
tag . innerHTML = get _doctype _label ( det [ 1 ] ) ;
tag . dt = det [ 1 ]
tag . onclick = function ( ) { loaddocbrowser ( this . dt ) ; }
}
FeedItem . prototype . render _references = function ( div , det ) {
// name
div . tab = make _table ( div , 1 , 2 , '100%' , [ null , '15%' ] )
//div.innerHTML = '<b>' + (strip(det[11]) ? det[11] : det[2]) + ' (' + cint(det[12]) + '): </b> has ' + det[7] + ' ';
var dt = det [ 1 ] ; var dn = det [ 2 ]
// link
var allow = in _list ( profile . can _read , dt ) ;
var span = $a ( $td ( div . tab , 0 , 0 ) , 'span' , ( allow ? 'link_type' : '' ) , null , det [ 2 ] ) ;
span . dt = dt ; span . dn = dn ;
if ( allow ) span . onclick = function ( ) { loaddoc ( this . dt , this . dn ) ; }
// subject
if ( det [ 3 ] ) {
$a ( $td ( div . tab , 0 , 0 ) , 'span' , '' , { marginLeft : '7px' , color : '#444' } , det [ 3 ] ) ;
}
// by
$y ( $td ( div . tab , 0 , 1 ) , { fontSize : '11px' } ) . innerHTML = ( strip ( det [ 5 ] ) ? det [ 5 ] : det [ 4 ] ) ;
}
HomeStatusBar = function ( ) {
var me = this ;
var parent = page _body . pages [ 'Event Updates' ] ;
this . wrapper = $a ( $td ( parent . main _tab , 0 , 1 ) , 'div' , 'home-status' , { } , 'Loading...' ) ;
$br ( this . wrapper , '3px' ) ;
this . render = function ( r ) {
this . wrapper . innerHTML = '' ;
this . span = $a ( this . wrapper , 'span' , 'home-status-link' )
this . span . onclick = function ( ) { loadpage ( 'My Company' ) }
if ( r . unread _messages ) {
this . span . innerHTML = '<span class="home-status-unread">' + r . unread _messages + '</span> unread message' + ( cint ( r . unread _messages ) > 1 ? 's' : '' ) ;
} else {
this . span . innerHTML = 'No unread messages.' ;
}
}
}
pscript . home _make _status = function ( ) {
var home _status _bar = new HomeStatusBar ( )
var wrapper = page _body . pages [ 'Event Updates' ] ;
// get values
2011-06-14 08:05:31 +00:00
$c _page ( 'home' , 'event_updates' , 'get_status_details' , user ,
2011-06-08 09:07:15 +00:00
function ( r , rt ) {
home _status _bar . render ( r . message ) ;
// system_messages
if ( r . message . system _message )
pscript . show _system _message ( wrapper , r . message . system _message ) ;
// trial
if ( pscript . is _erpnext _saas && cint ( r . message . is _trial ) && in _list ( user _roles , 'System Manager' ) ) {
pscript . trial _box = $a ( div , 'div' , 'help_box' , { margin : '2px 8px 2px 0px' } , "Your Free Trial expires in " +
r . message . days _to _expiry + " days. When you are satisfied, please <span class='link_type' onclick='pscript.convert_to_paid()'>please click here</span> to convert to a paid account." +
"<br>To get help, view <a href='http://erpnext.blogspot.com/2011/02/getting-started-with-your-erpnext.html' target='_blank'>Getting Started with Your System</a> (opens in a new page)" ) ;
}
// render online users
pscript . online _users _obj . render ( r . message . online _users ) ;
pscript . online _users = r . message . online _users ;
}
) ;
}
// show system message
// -------------------
pscript . convert _to _paid = function ( ) {
var callback = function ( r , rt ) {
if ( r . exc ) { msgprint ( r . exc ) ; return ; }
$ ( pscript . trial _box ) . slideUp ( ) ;
}
2011-06-14 08:05:31 +00:00
$c _page ( 'home' , 'event_updates' , 'convert_to_paid' , '' , callback )
2011-06-08 09:07:15 +00:00
}
// show system message
// -------------------
pscript . show _system _message = function ( wrapper , msg ) {
$ds ( wrapper . system _message _area ) ;
var txt = $a ( wrapper . system _message _area , 'div' , '' , { lineHeight : '1.6em' } ) ;
txt . innerHTML = msg ;
var span = $ln ( $a ( wrapper . system _message _area , 'div' ) , 'Dismiss' ,
function ( me ) {
me . set _working ( ) ;
$c _obj ( 'Home Control' , 'dismiss_message' , '' , function ( r , rt ) {
me . done _working ( ) ;
$ ( wrapper . system _message _area ) . slideUp ( ) ;
} ) ;
} , { fontSize : '11px' }
)
}
// complete my company registration
// --------------------------------
pscript . complete _registration = function ( )
{
var reg _callback = function ( r , rt ) {
if ( r . message == 'No' ) {
var d = new Dialog ( 400 , 200 , "Please Complete Your Registration" ) ;
if ( user != 'Administrator' ) {
d . no _cancel ( ) ; // Hide close image
$dh ( page _body . wntoolbar . wrapper ) ;
}
$ ( $a ( d . body , 'div' , '' , { margin : '8px' , color : '#888' } ) ) . html ( '<b>Company Name : </b>' + locals [ 'Control Panel' ] [ 'Control Panel' ] . company _name ) ;
d . make _body (
[
[ 'Data' , 'Company Abbreviation' ] ,
[ 'Select' , 'Fiscal Year Start Date' ] ,
[ 'Select' , 'Default Currency' ] ,
[ 'Button' , 'Save' ] ,
] ) ;
//d.widgets['Save'].disabled = true; // disable Save button
pscript . make _dialog _field ( d ) ;
// submit details
d . widgets [ 'Save' ] . onclick = function ( )
{
d . widgets [ 'Save' ] . set _working ( ) ;
flag = pscript . validate _fields ( d ) ;
if ( flag )
{
var args = [
locals [ 'Control Panel' ] [ 'Control Panel' ] . company _name ,
d . widgets [ 'Company Abbreviation' ] . value ,
d . widgets [ 'Fiscal Year Start Date' ] . value ,
d . widgets [ 'Default Currency' ] . value
] ;
$c _obj ( 'Setup Control' , 'setup_account' , JSON . stringify ( args ) , function ( r , rt ) {
sys _defaults = r . message ;
d . hide ( ) ;
$ds ( page _body . wntoolbar . wrapper ) ;
} ) ;
}
}
d . show ( ) ;
}
}
$c _obj ( 'Home Control' , 'registration_complete' , '' , reg _callback ) ;
}
// make dialog fields
// ------------------
pscript . make _dialog _field = function ( d )
{
// fiscal year format
fisc _format = d . widgets [ 'Fiscal Year Start Date' ] ;
add _sel _options ( fisc _format , [ '' , '1st Jan' , '1st Apr' , '1st Jul' , '1st Oct' ] ) ;
// default currency
currency _list = [ '' , 'AED' , 'AFN' , 'ALL' , 'AMD' , 'ANG' , 'AOA' , 'ARS' , 'AUD' , 'AZN' , 'BAM' , 'BBD' , 'BDT' , 'BGN' , 'BHD' , 'BIF' , 'BMD' , 'BND' , 'BOB' , 'BRL' , 'BSD' , 'BTN' , 'BYR' , 'BZD' , 'CAD' , 'CDF' , 'CFA' , 'CFP' , 'CHF' , 'CLP' , 'CNY' , 'COP' , 'CRC' , 'CUC' , 'CZK' , 'DJF' , 'DKK' , 'DOP' , 'DZD' , 'EEK' , 'EGP' , 'ERN' , 'ETB' , 'EUR' , 'EURO' , 'FJD' , 'FKP' , 'FMG' , 'GBP' , 'GEL' , 'GHS' , 'GIP' , 'GMD' , 'GNF' , 'GQE' , 'GTQ' , 'GYD' , 'HKD' , 'HNL' , 'HRK' , 'HTG' , 'HUF' , 'IDR' , 'ILS' , 'INR' , 'IQD' , 'IRR' , 'ISK' , 'JMD' , 'JOD' , 'JPY' , 'KES' , 'KGS' , 'KHR' , 'KMF' , 'KPW' , 'KRW' , 'KWD' , 'KYD' , 'KZT' , 'LAK' , 'LBP' , 'LKR' , 'LRD' , 'LSL' , 'LTL' , 'LVL' , 'LYD' , 'MAD' , 'MDL' , 'MGA' , 'MKD' , 'MMK' , 'MNT' , 'MOP' , 'MRO' , 'MUR' , 'MVR' , 'MWK' , 'MXN' , 'MYR' , 'MZM' , 'NAD' , 'NGN' , 'NIO' , 'NOK' , 'NPR' , 'NRs' , 'NZD' , 'OMR' , 'PAB' , 'PEN' , 'PGK' , 'PHP' , 'PKR' , 'PLN' , 'PYG' , 'QAR' , 'RMB' , 'RON' , 'RSD' , 'RUB' , 'RWF' , 'SAR' , 'SCR' , 'SDG' , 'SDR' , 'SEK' , 'SGD' , 'SHP' , 'SOS' , 'SRD' , 'STD' , 'SYP' , 'SZL' , 'THB' , 'TJS' , 'TMT' , 'TND' , 'TRY' , 'TTD' , 'TWD' , 'TZS' , 'UAE' , 'UAH' , 'UGX' , 'USD' , 'USh' , 'UYU' , 'UZS' , 'VEB' , 'VND' , 'VUV' , 'WST' , 'XAF' , 'XCD' , 'XDR' , 'XOF' , 'XPF' , 'YEN' , 'YER' , 'YTL' , 'ZAR' , 'ZMK' , 'ZWR' ] ;
currency = d . widgets [ 'Default Currency' ] ;
add _sel _options ( currency , currency _list ) ;
}
// validate fields
// ---------------
pscript . validate _fields = function ( d )
{
var lst = [ 'Company Abbreviation' , 'Fiscal Year Start Date' , 'Default Currency' ] ;
var msg = 'Please enter the following fields' ;
var flag = 1 ;
for ( var i = 0 ; i < lst . length ; i ++ )
{
if ( ! d . widgets [ lst [ i ] ] . value ) {
flag = 0 ;
msg = msg + NEWLINE + lst [ i ] ;
}
}
if ( ! flag ) alert ( msg ) ;
return flag ;
}