local logo = display.newImageRect( "img/logo.png", 219, 153)
logo.x = CX
- logo.y = CY - 1/8 * VH
+ logo.y = CY/2 - VH/32
+
+ transition.to( logo, { time = 2000, y = VH/4, alpha = 1, transition = easing.outExpo })
connexion:insert( logo )
connexion.logo = logo
+ local title = display.newText( "Tickets d'Utilité Publique", CX, logo.y + logo.height - 20, "Dosis-Medium", 26 )
+ title.alpha = 0
+
+ transition.to( title, { time = 2000, y = logo.y + logo.height - 40, alpha = 1, transition = easing.outExpo })
+
+ connexion:insert( title )
+
end
local function initTextFields()
- local mailField = native.newTextField( 0, 0, 200, 30 )
- mailField.x=CX
- mailField.y=connexion.logo.y + 1/2 * connexion.logo.height + 40
- mailField.inputType = "email"
- connexion:insert(mailField)
- connexion.mailField = mailField
- --mailField.text = mail
- mailField.placeholder = "E-Mail"
-
- local mdpField = native.newTextField( 0, 0, 200, 30 )
- mdpField.anchorY = 0
- mdpField.x = CX
- mdpField.y = mailField.y + 1/2 * mailField.height + 10
- mdpField.placeholder = "Password"
- mdpField.isSecure = true
- connexion:insert(mdpField)
- connexion.mdpField = mdpField
+
+ local isAndroid = "Android" == system.getInfo( "platformName" )
+ local inputFontSize = 18
+ local tHeight = 40
+
+ if ( isAndroid ) then
+
+ inputFontSize = inputFontSize - 4
+ tHeight = tHeight + 10
+
+ end
+
+ local mailField = native.newTextField( -100, -100, 200, tHeight )
+ mailField.x = CX
+ mailField.y = connexion.logo.y + 1/2 * connexion.logo.height + 100
+ mailField.inputType = "email"
+ mailField.placeholder = "Adresse mail"
+ mailField.size = inputFontSize + 6
+ mailField.align = "center"
+ mailField.alpha = .9
+
+ connexion:insert(mailField)
+ connexion.mailField = mailField
+
+ local mdpField = native.newTextField( -100, -100, 200, tHeight )
+ mdpField.x = CX
+ mdpField.y = mailField.y + mailField.height + 10
+ mdpField.isSecure = true
+ mdpField.placeholder = "Mot de passe"
+ mdpField.size = inputFontSize + 6
+ mdpField.align = "center"
+ mdpField.alpha = .9
+
+ connexion:insert(mdpField)
+ connexion.mdpField = mdpField
+
end
width = connexion.mailField.width,
height = 1/11 * VH,
sheet = buttonSheet,
- label = "Se Connecter",
+ label = "Connexion",
labelColor = { default={ 0, 0, 0 } },
defaultFile = "green_texture.png",
onPress = onConnect
function Details:new(id)
details = display.newGroup()
+
local data
local statut = "en cours"
local isFavoris
+local latitude = 0
+local longitude = 0
+
local function initBackground()
local bg = display.newRect(SX, SY, VW, VH)
bg.anchorX, bg.anchorY = 0,0
- bg:setFillColor(0,0.706,0.314,.8)
+ bg:setFillColor( 240/255, 238/255, 221/255, 1 )
details:insert( bg )
+ -- bordure du haut
+ local border1 = display.newRect( 0, 0, VW, 40 )
+ border1:setFillColor( 146/255, 114/255, 79/255 )
+ border1.anchorX = 0
+ border1.anchorY = 0
+ border1.x = SX
+ border1.y = SY
+ details:insert( border1 )
+ details.border1 = border1
+
+ -- bordure du bas
+ local border2 = display.newRect( 0, 0, VW, 40 )
+ border2:setFillColor( 146/255, 114/255, 79/255 )
+ border2.anchorX = 0
+ border2.anchorY = 0
+ border2.x = SX
+ border2.y = VH - border2.height
+ details:insert( border2 )
+ details.border2 = border2
+
+ local circle1 = {}
+ local circle2 = {}
+
+ for i = 0, 11 do
+
+ -- cercles du haut
+ circle1[i] = display.newCircle( 0, 0, 8 )
+ circle1[i]:setFillColor( 0, 0, 0 )
+ circle1[i].x = (VW/10)*i
+ circle1[i].y = SY - 3
+ details:insert( circle1[i] )
+
+ -- cercles du bas
+ circle2[i] = display.newCircle( 0, 0, 8 )
+ circle2[i]:setFillColor( 0, 0, 0 )
+ circle2[i].x = (VW/10)*i
+ circle2[i].y = VH + 3
+ details:insert( circle2[i] )
+
+ end
+
+ local b = display.newRect( 0, 0, 8, 60 )
+ b:setFillColor( 0, 0, 0 )
+ b.anchorX = 0
+ b.anchorY = 0
+ b.x = SX
+ b.y = border2.height
+ details:insert( b )
+ details.b = b
+
end
local function onRetour(event)
local latlong = string.split( ""..data[""..1][11], "," )
lat = latlong[1]
- print(lat)
+ print(mime.b64(lat))
lng = latlong[2]
- print(lng)
-
- local map = native.newWebView( CX, CY, VW - 30, 200 )
- map:request( "http://tup.url.ph/gestion/map.php?lat="..lat.."&lng="..lng.."&adresse=".."blabla" )
+ print(mime.b64(lng))
+
+ print(mime.b64(latitude))
+ print(mime.b64(longitude))
+ local mimlatlng = ""..latitude..","..longitude
+ print(mimlatlng)
+ print(mime.b64(mimlatlng))
+
+ local map = native.newWebView( CX, 0, VW, 330 )
+ map.anchorY = 0
+ map.y = details.b.y + details.b.height + 15
+ map:request( "http://tup.url.ph/gestion/map.php?lat="..mime.b64(lat).."&lng="..mime.b64(lng).."&myCoord="..mimlatlng.."&adresse=1OENADKPMEAL" )
details:insert( map )
details.map = map
network.request(url, "GET", updateCallback)
end
-local function onTraite(e)
- statut = "traite"
+local function onComplete( event )
+statut = "traite"
update()
+
+ if "clicked" == event.action then
+ local i = event.index
+
+ if 1 == i then
+ -- Do nothing; dialog will simply dismiss
+ elseif 2 == i then
+ -- Open URL if "Learn More" (the 2nd button) was clicked
+ system.openURL( "http://www.coronalabs.com" )
+ end
+ end
+
+
+end
+
+local function onTraite(e)
+
+ local function onComplete( event )
+ if "clicked" == event.action then
+ local i = event.index
+ if 1 == i then
+ statut = "traite"
+ update()
+ elseif 2 == i then
+ end
+ end
+ end
+
+ native.showAlert( "Confirmer.", "Voulez-vous traiter ce ticket ?", { "Oui", "Non" }, onComplete )
+
end
local function onRejet(e)
- statut = "refuse"
- update()
+
+ local function onComplete( event )
+ if "clicked" == event.action then
+ local i = event.index
+ if 1 == i then
+ statut = "refuse"
+ update()
+ elseif 2 == i then
+ end
+ end
+ end
+
+ native.showAlert( "Confirmer.", "Voulez-vous rejeter ce ticket ?", { "Oui", "Non" }, onComplete )
+
end
local function onFavoris(e)
oTicket.y = SY + 5
-- Type du ticket
- local tTicket = display.newText( data[""..1][3], SX + 10, oTicket.y + oTicket.height + 5, "Dosis-Book", 16 )
+ local tTicket = display.newText( data[""..1][3], SX + 15, oTicket.y + oTicket.height + 5, "Dosis-Book", 16 )
+ tTicket:setFillColor( 0,0,0 )
tTicket.anchorY = 0
tTicket.anchorX = 0
-- Lieu
- local lTicket = display.newText( data[""..1][5], SX + 10, tTicket.y + tTicket.height + 5, "Dosis-Book", 14)
+ local lTicket = display.newText( data[""..1][5], SX + 15, tTicket.y + tTicket.height + 5, "Dosis-Book", 14)
+ lTicket:setFillColor( 0,0,0 )
lTicket.anchorY = 0
lTicket.anchorX = 0
-- choix de traitement du ticket
local btnTraite = widget.newButton
{
+ shape = "rect",
width = 1/3 * VW,
height = 50,
label = "Traité",
- labelColor = { default={ 1, 1, 1 } },
- onPress = onTraite,
- font = "Dosis-Book"
+ labelColor = { default={ 0, 0, 0 } },
+ fillColor = { default={ .2, .8, .4, .3 }, over={ .2, .8, .4, .3 } },
+ onRelease = onTraite,
+ font = "Dosis-Bold"
}
btnTraite.anchorX = 0
btnTraite.x = SX
- btnTraite.y = VH - CY/2
+ btnTraite.y = VH - 80
local btnRejet = widget.newButton
{
+ shape = "rect",
width = 1/3 * VW,
height = 50,
label = "Rejeté",
- labelColor = { default={ 1, 1, 1 } },
- onPress = onRejet,
- font = "Dosis-Book"
+ labelColor = { default={ 0, 0, 0 } },
+ fillColor = { default={ 1, 0, 0, .3 }, over={ 1, 0, 0, .3 } },
+ onRelease = onRejet,
+ font = "Dosis-Bold",
}
btnRejet.anchorX = 0
btnRejet.x = btnTraite.x + btnTraite.width
- btnRejet.y = VH - CY/2
+ btnRejet.y = VH - 80
local btnFavoris = widget.newButton
{
+ shape = "rect",
width = 1/3 * VW,
height = 50,
label = "Favoris",
- labelColor = { default={ 1, 1, 1 } },
- onPress = onFavoris,
- font = "Dosis-Book"
+ labelColor = { default={ 0, 0, 0 } },
+ fillColor = { default={ 1, .9, .3, .3 }, over={ 1, .9, .3, .3 } },
+ onRelease = onFavoris,
+ font = "Dosis-Bold"
}
if (data[""..1][8] == "a faire") then -- si le ticket est déjà en favoris, on affiche le label Favoris - pour proposer de l'enlever des favoris
btnFavoris:setLabel( "Favoris -" )
btnFavoris.anchorX = 0
btnFavoris.x = btnRejet.x + btnRejet.width
- btnFavoris.y = VH - CY/2
+ btnFavoris.y = VH - 80
details:insert( btnTraite )
details:insert( btnRejet )
details:insert(oTicket)
details:insert(tTicket)
- -- Priorité
+ if ((data[""..1][4]) == '0') then
+ details.b:setFillColor( .2, .8, .4, .9 )
+ elseif ((data[""..1][4]) == '1') then
+ details.b:setFillColor( 1, .9, .3, .9 )
+ elseif ((data[""..1][4]) == '2') then
+ details.b:setFillColor( 1, 0, 0, .9 )
+ else
+ details.b:setFillColor( .2, .8, .4, .9 )
+ end
+
+-- Priorité
-- data[""..1][4]
-- Lieu
elseif ( data.result == 400 ) then
print("Une erreur est survenue.")
- native.showAlert( "Erreur.", "Une erreur est survenue." )
+ native.showAlert( "Erreur.", "Une erreur est survenue.", {"OK"} )
end
local url = "http://tup.url.ph/gestion/get_details.php?id="..id
- -- envoi des données du formulaire de connextion en GET
+ -- envoi des données du formulaire de connexion en GET
network.request( url, "GET", ticketsCallBack )
end
end
+local function locationHandler( event )
+
+ if ( event.errorCode ) then
+ native.showAlert( "Erreur GPS", "Erreur : "..event.errorMessage, {"OK"} )
+ else
+ latitude = event.latitude
+ longitude = event.longitude
+ end
+
+end
local function init()
getTicketsInfos()
initButtons()
-- print("Ticket id:"..id)
+ Runtime:addEventListener( "location", locationHandler )
end
local function initScrollView()
- -- Create image sheet for custom scroll bar
- local scrollBarOpt = {
- width = 20,
- height = 20,
- numFrames = 3,
- sheetContentWidth = 20,
- sheetContentHeight = 60
- }
- local scrollBarSheet = graphics.newImageSheet( "widget-scrollbar.png", scrollBarOpt )
-
-- Create the widget
local scrollView = widget.newScrollView
{
top = SY + 55, --10 + 50 pour la tab Bar
- left = SX + 10,
- width = VW - 20,
+ left = SX + 5,
+ width = VW - 10,
height = VH - 40,
scrollHeight = VH,
backgroundColor = { 0,0,0,0 },
listener = scrollListener,
- scrollBarOptions = {
- sheet = scrollBarSheet,
- topFrame = 1,
- middleFrame = 2,
- bottomFrame = 3
- }
}
scrollView._view._isHorizontalScrollingDisabled = true
-- print ( "pas de ticket" )
local noTicket = display.newText( "Pas de ticket en cours.", CX, CY, native.systemFont, 16 )
+ noTicket:setFillColor( 0,0,0 )
listeTickets:insert( noTicket )
else
--Bouton pour ajouter la ticket aux tâches à faire
local addTicket = display.newRect( 0,0, 25, 25)
- addTicket.x = listeTickets.s.width - 1/2 * addTicket.width - 5
+ addTicket.x = listeTickets.s.width - 1/2 * addTicket.width - 15
addTicket.y = 20
addTicket.alpha= 0.01
local plus = display.newText("...",details.x,details.y,native.systemFont, 16 )
details:addEventListener( "tap", getDetails )
plus.x = details.x + details.width - 20
- plus.y = details.y + details.height/3
+ plus.y = details.y + details.height/2
-- print(data[""..i][4])
plus:setFillColor( 0,0,0 )