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