--- /dev/null
+BDD TUP
+
+a6268487_tup
+s3rvertup123
+
+twevisjikyegdyofkov0
+
+NOTES :
+
+
+√ !! BOUTONS NAVBAR GRIS
+√ !!! RUNTIME ERROR mapAdressHandler
+√ !!! remove all textFields on exit
+√ bug de la map qui part en sortant du ticket (ticket, accueil, ticket)
+√ !! à faire partout native.setKeyboardFocus( nil )
+
+√ !! GLITCH VISUEL BLANC TOPLEFT TRANSITION CONNEXION/INSCRIPTION
+√ !! TRANSITION ACCUEIL PROFIL (gérer toutes les transitions)
+
+√ !!! LISTVIEW TICKETS EN COURS
+
+A AMELIORER √ !! DESIGN
+
+
+POWERPOINT
+
+TUP
+
+Présentation du projet
+
+Qu'est-ce que TUP ?
+Application mobile de recensement des problèmes urbains, etc.
+
+
+Technologie employée : justification, etc.
+
+
+!!!!!
+
+TRES IMPORTANT
+
+
+!! débugger l'adresse dans le ticket
+ + remove les marqueurs labelAdresse.text = "Entré dans la fonction"
+
+!! tickets > 0 : autoriser newTicket
+!! faire tourner le logo onTouch (easter egg)
+
+focus nil clavier
+!!! --> listener sur le ok pour l'envoi
+
+
+
+tester les champs modifier mdp
+
+!!!!!
+
+---
+
+-- LOW
+
+!! BUG : nouveau ticket -> accueil rapidement avant chargement du ticket -> retour accueil vide
+SOLUTION : rajouter un delay sur le listener
+
+!! BUG TICKETS EN COURS -> RETOUR ACCUEIL
+-- à corriger de suite : rajouter un timer avant activation du bouton retour
+
+
+-- LOW
+
+
+- Design gestion
+ - bug favoris
+
+- Refaire logo TUP pour l'app TUP
+
+GESTION
+-------
+
+dans le fichier Connexion.lua
+
+mets ça à l aligne 91-92
+
+local mail = "service@tup.url.ph"
+local pwd = "s3rvertup123"
+
+et commentes les deux affectations après
+
+-------
+!!!!!!!!! Fonction faire pression sur la mairie
+
+
+!!! CHECK INTERNET -> newAlert
+
+!! bug textField de gestion encore présent !!
+
+
+!! BUG : enterframe démarre au changement de scène
+CONNEXION/INSCRIPTION
+
+
+!! bug déconnexion internet depuis modifier mdp -> retour connexion avec les 2 champs
+! rajouter fonction adresse automatique
+! supprimer ancien marqueur sur map
+
+
+! Flouter les fonds d'écran
+
+OK faire bouton valider pour add et descr (sous la map)
+
+(√) à la place de OK en fonction de l'état du ticket : rempli ou non
+
+rayer les boutons inactifs ?
+
+-- design général
+-- design + listView liste tickets en cours
+
+-- faire l'écran de confirmation + envoi du ticket
+
+rajouter tous les éléments de ListeType dans self
+
+après le choix du type, la scène Ecran_ListeType semble encore présente
+
+
+
+
+Centre
+Audiovisuel
+de
+Documentation
+
+logo à faire
+
+
+aligner adresse
+
+
+IPOD SHUFFLE : TRIER CHARGER
+
+ 1 2 3 4 5 6 7 8 9 10
+ ___|__|__|__|__|__|__|__|__|__|
+ |1 | Priorité | |
+ |__|______________| |
+ |2 | Photo |
+ | Type | |
+ |3 | |
+ |_________________|___________|
+ |4 |
+ | Précisions |
+ |5 |
+ |_____________________________|
+ |6
+ |__
+ |7
+ |__
+ |8
+ |__
+ |9
+ |__
+ |10
+ |__
+ |11
+ |__
+ |12
+ |__
+ |13
+ |__
+ |14
+ |__
+ |15
+ |__
+ |16
+ |_______________
+
+myMap=native.newMapView( 20, 20, 280, 300 )
+lat, long = myMap:getAddressLocation( " Eiffel Tower" )
+myMap:setCenter( lat, long )
+myMap.mapType="normal"
+myMap:addMarker( lat, long )
\ No newline at end of file
--- /dev/null
+-- Ecran_Accueil.lua
+
+-- Chargement des modules
+
+local composer = require( "composer" )
+
+-- Instanciation de la scène
+
+local scene = composer.newScene()
+
+-- ----------------------------------------- --
+-- Définition des gestionnaires d'événements --
+-- ----------------------------------------- --
+
+-- Création de la scène
+
+function scene:create( event )
+
+ local sceneGroup = self.view
+
+ -- initialisation de la scène
+ local Accueil = require "lib.Accueil"
+ local objetAccueil = Accueil:new()
+
+ sceneGroup:insert( objetAccueil )
+
+ -- le contenu objet de la scène
+ self.objet = objetAccueil
+
+end
+
+-- Apparition de la scène
+
+function scene:show( event )
+
+ local sceneGroup = self.view
+ local phase = event.phase
+
+ if ( phase == "will" ) then
+
+ elseif ( phase == "did" ) then
+ -- on active les écouteurs quand
+ -- la scène est affichée
+ self.objet:enableListeners()
+
+ end
+
+end
+
+-- Disparition de la scène
+
+function scene:hide( event )
+
+ local sceneGroup = self.view
+ local phase = event.phase
+
+ if ( phase == "will" ) then
+ -- on désactive les écouteurs quand
+ -- la scène est sn train d'être changée
+ self.objet:disableListeners()
+
+ elseif ( phase == "did" ) then
+
+ end
+
+end
+
+-- Desctruction de la scène
+
+function scene:destroy( event )
+
+ local sceneGroup = self.view
+
+ -- destruction de la scène (sans recyclage)
+ -- composer.removeScene( "Ecran_Accueil", false )
+
+end
+
+-- -------------------------------- --
+-- Ajout des écouteurs d'événements --
+-- -------------------------------- --
+
+scene:addEventListener( "create", scene )
+scene:addEventListener( "show", scene )
+scene:addEventListener( "hide", scene )
+scene:addEventListener( "destroy", scene )
+
+--
+
+return scene
\ No newline at end of file
--- /dev/null
+-- Ecran_Connexion.lua
+
+-- Chargement des modules
+
+local composer = require( "composer" )
+
+-- Instanciation de la scène
+
+local scene = composer.newScene()
+
+-- ----------------------------------------- --
+-- Définition des gestionnaires d'événements --
+-- ----------------------------------------- --
+
+-- Création de la scène
+
+function scene:create( event )
+
+ local sceneGroup = self.view
+
+ -- initialisation de la scène
+ local Connexion = require "lib.Connexion"
+ local objetConnexion = Connexion:new()
+
+ sceneGroup:insert( objetConnexion )
+
+ -- le contenu objet de la scène
+ self.objet = objetConnexion
+
+end
+
+-- Apparition de la scène
+
+function scene:show( event )
+
+ local sceneGroup = self.view
+ local phase = event.phase
+
+ if ( phase == "will" ) then
+
+ elseif ( phase == "did" ) then
+ -- on active les écouteurs quand
+ -- la scène est affichée
+ self.objet:enableListeners()
+
+ end
+
+end
+
+-- Disparition de la scène
+
+function scene:hide( event )
+
+ local sceneGroup = self.view
+ local phase = event.phase
+
+ if ( phase == "will" ) then
+ -- on désactive les écouteurs quand
+ -- la scène est sn train d'être changée
+ self.objet:disableListeners()
+ -- destruction de la scène (avec recyclage)
+ composer.removeScene( "Ecran_Connexion", true )
+
+ elseif ( phase == "did" ) then
+
+ end
+
+end
+
+-- Desctruction de la scène
+
+function scene:destroy( event )
+
+ local sceneGroup = self.view
+
+ -- destruction de la scène (sans recyclage)
+ -- composer.removeScene( "Ecran_Connexion", false )
+
+end
+
+-- -------------------------------- --
+-- Ajout des écouteurs d'événements --
+-- -------------------------------- --
+
+scene:addEventListener( "create", scene )
+scene:addEventListener( "show", scene )
+scene:addEventListener( "hide", scene )
+scene:addEventListener( "destroy", scene )
+
+--
+
+return scene
\ No newline at end of file
--- /dev/null
+-- Ecran_Accueil.lua
+
+-- Chargement des modules
+
+local composer = require( "composer" )
+
+-- Instanciation de la scène
+
+local scene = composer.newScene()
+
+-- ----------------------------------------- --
+-- Définition des gestionnaires d'événements --
+-- ----------------------------------------- --
+
+-- Création de la scène
+
+function scene:create( event )
+
+ local sceneGroup = self.view
+
+ -- initialisation de la scène
+ local GestionProfil = require "lib.GestionProfil"
+ local objetGestion = GestionProfil:new()
+
+ sceneGroup:insert( objetGestion )
+
+ -- le contenu objet de la scène
+ self.objet = objetGestion
+
+end
+
+-- Apparition de la scène
+
+function scene:show( event )
+
+ local sceneGroup = self.view
+ local phase = event.phase
+
+ if ( phase == "will" ) then
+
+ elseif ( phase == "did" ) then
+ -- on active les écouteurs quand
+ -- la scène est affichée
+ self.objet:enableListeners()
+
+ end
+
+end
+
+-- Disparition de la scène
+
+function scene:hide( event )
+
+ local sceneGroup = self.view
+ local phase = event.phase
+
+ if ( phase == "will" ) then
+ -- on désactive les écouteurs quand
+ -- la scène est sn train d'être changée
+ self.objet:disableListeners()
+ -- destruction de la scène (avec recyclage)
+ composer.removeScene( "Ecran_Gestion", false )
+
+ elseif ( phase == "did" ) then
+
+ end
+
+end
+
+-- Desctruction de la scène
+
+function scene:destroy( event )
+
+ local sceneGroup = self.view
+
+ --self.objet:exit()
+
+end
+
+-- -------------------------------- --
+-- Ajout des écouteurs d'événements --
+-- -------------------------------- --
+
+scene:addEventListener( "create", scene )
+scene:addEventListener( "show", scene )
+scene:addEventListener( "hide", scene )
+scene:addEventListener( "destroy", scene )
+
+--
+
+return scene
\ No newline at end of file
--- /dev/null
+-- Ecran_Inscription.lua
+
+-- Chargement des modules
+
+local composer = require( "composer" )
+
+-- Instanciation de la scène
+
+local scene = composer.newScene()
+
+-- ----------------------------------------- --
+-- Définition des gestionnaires d'événements --
+-- ----------------------------------------- --
+
+-- Création de la scène
+
+function scene:create( event )
+
+ local sceneGroup = self.view
+
+ -- initialisation de la scène
+ local Inscription = require "lib.Inscription"
+ local objetInscription = Inscription:new()
+
+ sceneGroup:insert( objetInscription )
+
+ -- le contenu objet de la scène
+ self.objet = objetInscription
+
+end
+
+-- Apparition de la scène
+
+function scene:show( event )
+
+ local sceneGroup = self.view
+ local phase = event.phase
+
+ if ( phase == "will" ) then
+
+ elseif ( phase == "did" ) then
+ -- on active les écouteurs quand
+ -- la scène est affichée
+ self.objet:enableListeners()
+
+ end
+
+end
+
+-- Disparition de la scène
+
+function scene:hide( event )
+
+ local sceneGroup = self.view
+ local phase = event.phase
+
+ if ( phase == "will" ) then
+ -- on désactive les écouteurs quand
+ -- la scène est sn train d'être changée
+ self.objet:disableListeners()
+ -- destruction de la scène (avec recyclage)
+ composer.removeScene( "Ecran_Inscription", true )
+
+ elseif ( phase == "did" ) then
+
+ end
+
+end
+
+-- Desctruction de la scène
+
+function scene:destroy( event )
+
+ local sceneGroup = self.view
+
+ self.objet:disableListeners()
+
+ -- destruction de la scène (sans recyclage)
+ -- composer.removeScene( "Ecran_Inscription", false )
+
+end
+
+-- -------------------------------- --
+-- Ajout des écouteurs d'événements --
+-- -------------------------------- --
+
+scene:addEventListener( "create", scene )
+scene:addEventListener( "show", scene )
+scene:addEventListener( "hide", scene )
+scene:addEventListener( "destroy", scene )
+
+--
+
+return scene
\ No newline at end of file
--- /dev/null
+-- Ecran_ListeTickets.lua
+
+-- Chargement des modules
+
+local composer = require( "composer" )
+
+-- Instanciation de la scène
+
+local scene = composer.newScene()
+
+-- ----------------------------------------- --
+-- Définition des gestionnaires d'événements --
+-- ----------------------------------------- --
+
+-- Création de la scène
+
+function scene:create( event )
+
+ local sceneGroup = self.view
+
+ -- initialisation de la scène
+ local ListeTickets = require "lib.ListeTickets"
+ local objetListeTickets = ListeTickets:new()
+
+ sceneGroup:insert( objetListeTickets )
+
+ -- le contenu objet de la scène
+ self.objet = objetListeTickets
+
+end
+
+-- Apparition de la scène
+
+function scene:show( event )
+
+ local sceneGroup = self.view
+ local phase = event.phase
+
+ if ( phase == "will" ) then
+
+ elseif ( phase == "did" ) then
+ -- on active les écouteurs quand
+ -- la scène est affichée
+ self.objet:enableListeners()
+
+ end
+
+end
+
+-- Disparition de la scène
+
+function scene:hide( event )
+
+ local sceneGroup = self.view
+ local phase = event.phase
+
+ if ( phase == "will" ) then
+ -- on désactive les écouteurs quand
+ -- la scène est sn train d'être changée
+ self.objet:disableListeners()
+ -- destruction de la scène (avec recyclage)
+ composer.removeScene( "Ecran_ListeTickets", true )
+
+ elseif ( phase == "did" ) then
+
+ end
+
+end
+
+-- Desctruction de la scène
+
+function scene:destroy( event )
+
+ local sceneGroup = self.view
+
+ -- destruction de la scène (sans recyclage)
+ -- composer.removeScene( "Ecran_ListeTickets", false )
+
+end
+
+-- -------------------------------- --
+-- Ajout des écouteurs d'événements --
+-- -------------------------------- --
+
+scene:addEventListener( "create", scene )
+scene:addEventListener( "show", scene )
+scene:addEventListener( "hide", scene )
+scene:addEventListener( "destroy", scene )
+
+--
+
+return scene
\ No newline at end of file
--- /dev/null
+-- Ecran_ListeType.lua
+
+-- Chargement des modules
+
+local composer = require( "composer" )
+
+-- Instanciation de la scène
+
+local scene = composer.newScene()
+
+-- ----------------------------------------- --
+-- Définition des gestionnaires d'événements --
+-- ----------------------------------------- --
+
+-- Création de la scène
+
+function scene:create( event )
+
+ local sceneGroup = self.view
+
+ -- initialisation de la scène
+ local ListeType = require "lib.ListeType"
+ local objetListeType = ListeType:new()
+
+ sceneGroup:insert( objetListeType )
+
+ -- le contenu objet de la scène
+ self.objet = objetListeType
+
+end
+
+-- Apparition de la scène
+
+function scene:show( event )
+
+ local sceneGroup = self.view
+ local phase = event.phase
+
+ if ( phase == "will" ) then
+
+ elseif ( phase == "did" ) then
+ -- on active les écouteurs quand
+ -- la scène est affichée
+ self.objet:enableListeners()
+
+ end
+
+end
+
+-- Disparition de la scène
+
+function scene:hide( event )
+
+ local sceneGroup = self.view
+ local phase = event.phase
+
+ if ( phase == "will" ) then
+ -- on désactive les écouteurs quand
+ -- la scène est sn train d'être changée
+
+ -- self.objet:disableListeners()
+
+ elseif ( phase == "did" ) then
+
+ -- destruction de la scène (avec recyclage)
+ composer.removeScene( "Ecran_ListeType", true )
+
+ end
+
+end
+
+-- Desctruction de la scène
+
+function scene:destroy( event )
+
+ local sceneGroup = self.view
+
+ -- destruction de la scène (sans recyclage)
+ --composer.removeScene( "Ecran_Ticket", false )
+
+end
+
+-- -------------------------------- --
+-- Ajout des écouteurs d'événements --
+-- -------------------------------- --
+
+scene:addEventListener( "create", scene )
+scene:addEventListener( "show", scene )
+scene:addEventListener( "hide", scene )
+scene:addEventListener( "destroy", scene )
+
+--
+
+return scene
\ No newline at end of file
--- /dev/null
+-- Ecran_Ticket.lua
+
+-- Chargement des modules
+
+local composer = require( "composer" )
+
+-- Instanciation de la scène
+
+local scene = composer.newScene()
+
+-- ----------------------------------------- --
+-- Définition des gestionnaires d'événements --
+-- ----------------------------------------- --
+
+-- Création de la scène
+
+function scene:create( event )
+
+ local sceneGroup = self.view
+
+ -- initialisation de la scène
+ local Ticket = require "lib.Ticket"
+ local objetTicket = Ticket:new()
+
+ sceneGroup:insert( objetTicket )
+
+ -- le contenu objet de la scène
+ self.objet = objetTicket
+
+end
+
+-- Apparition de la scène
+
+function scene:show( event )
+
+ local sceneGroup = self.view
+ local phase = event.phase
+
+ if ( phase == "will" ) then
+
+ elseif ( phase == "did" ) then
+
+ --self.objet:enableListeners()
+
+ end
+
+end
+
+-- Disparition de la scène
+
+function scene:hide( event )
+
+ local sceneGroup = self.view
+ local phase = event.phase
+
+ if ( phase == "will" ) then
+
+ --self.objet:disableListeners()
+
+ elseif ( phase == "did" ) then
+
+ end
+
+end
+
+-- Desctruction de la scène
+
+function scene:destroy( event )
+
+ local sceneGroup = self.view
+
+ -- destruction de la scène (avec recyclage)
+ composer.removeScene( "Ecran_Ticket", true )
+
+end
+
+-- -------------------------------- --
+-- Ajout des écouteurs d'événements --
+-- -------------------------------- --
+
+scene:addEventListener( "create", scene )
+scene:addEventListener( "show", scene )
+scene:addEventListener( "hide", scene )
+scene:addEventListener( "destroy", scene )
+
+Runtime:addEventListener( "onShowOverlay", scene )
+Runtime:addEventListener( "onHideOverlay", scene )
+
+--
+
+return scene
\ No newline at end of file
--- /dev/null
+-- Supported values for orientation:
+-- portrait, portraitUpsideDown, landscapeLeft, landscapeRight
+
+settings = {
+
+ orientation = {
+ default = "portrait",
+ supported = { "portrait" },
+ },
+
+ iphone = {
+ plist = {
+ UIStatusBarHidden = false,
+ UIPrerenderedIcon = true, -- set to false for "shine" overlay
+ --UIApplicationExitsOnSuspend = true, -- uncomment to quit app on suspend
+
+ --[[
+ -- iOS app URL schemes:
+ CFBundleURLTypes =
+ {
+ {
+ CFBundleURLSchemes =
+ {
+ "fbXXXXXXXXXXXXXX", -- example scheme for facebook
+ "coronasdkapp", -- example second scheme
+ }
+ }
+ }
+ --]]
+ }
+ },
+
+ -- Android permissions
+
+ android =
+ {
+ usesPermissions =
+ {
+ "android.permission.INTERNET",
+
+ -- Persmission to access camera
+ "android.permission.CAMERA",
+ "android.permission.WRITE_EXTERNAL_STORAGE",
+
+ -- Permission to retrieve current location from the GPS.
+ "android.permission.ACCESS_FINE_LOCATION",
+
+ -- Permission to retrieve current location from WiFi or cellular service.
+ "android.permission.ACCESS_COARSE_LOCATION",
+ },
+ usesFeatures =
+ {
+ -- If you set permissions "ACCESS_FINE_LOCATION" and "ACCESS_COARSE_LOCATION" above,
+ -- then you may want to set up your app to not require location services as follows.
+ -- Otherwise, devices that do not have location sevices (such as a GPS) will be unable
+ -- to purchase this app in the app store.
+ { name = "android.hardware.location", required = false },
+ { name = "android.hardware.location.gps", required = false },
+ { name = "android.hardware.location.network", required = false },
+ },
+ },
+}
--- /dev/null
+if string.sub(system.getInfo("model"),1,4) == "iPad" then
+ application =
+ {
+ content =
+ {
+ width = 360,
+ height = 480,
+ scale = "letterBox",
+ xAlign = "center",
+ yAlign = "center",
+ imageSuffix =
+ {
+ ["@2x"] = 1.5,
+ ["@4x"] = 3.0,
+ },
+ },
+ notification =
+ {
+ iphone = {
+ types = {
+ "badge", "sound", "alert"
+ }
+ }
+ }
+ }
+
+elseif string.sub(system.getInfo("model"),1,2) == "iP" and display.pixelHeight > 960 then
+ application =
+ {
+ content =
+ {
+ width = 320,
+ height = 568,
+ scale = "letterBox",
+ xAlign = "center",
+ yAlign = "center",
+ imageSuffix =
+ {
+ ["@2x"] = 1.5,
+ ["@4x"] = 3.0,
+ },
+ },
+ notification =
+ {
+ iphone = {
+ types = {
+ "badge", "sound", "alert"
+ }
+ }
+ }
+ }
+
+elseif string.sub(system.getInfo("model"),1,2) == "iP" then
+ application =
+ {
+ content =
+ {
+ width = 320,
+ height = 480,
+ scale = "letterBox",
+ xAlign = "center",
+ yAlign = "center",
+ imageSuffix =
+ {
+ ["@2x"] = 1.5,
+ ["@4x"] = 3.0,
+ },
+ },
+ notification =
+ {
+ iphone = {
+ types = {
+ "badge", "sound", "alert"
+ }
+ }
+ }
+ }
+elseif display.pixelHeight / display.pixelWidth > 1.72 then
+ application =
+ {
+ content =
+ {
+ width = 320,
+ height = 570,
+ scale = "letterBox",
+ xAlign = "center",
+ yAlign = "center",
+ imageSuffix =
+ {
+ ["@2x"] = 1.5,
+ ["@4x"] = 3.0,
+ },
+ },
+ }
+else
+ application =
+ {
+ content =
+ {
+ width = 320,
+ height = 512,
+ scale = "letterBox",
+ xAlign = "center",
+ yAlign = "center",
+ imageSuffix =
+ {
+ ["@2x"] = 1.5,
+ ["@4x"] = 3.0,
+ },
+ },
+ notification =
+ {
+ iphone = {
+ types = {
+ "badge", "sound", "alert"
+ }
+ }
+ }
+ }
+end
--- /dev/null
+-- Accueil.lua
+
+-- Constantes métriques
+
+local SX = display.screenOriginX -- Origine X
+local SY = display.screenOriginY -- Origine Y
+local CX = display.contentCenterX -- Centre X
+local CY = display.contentCenterY -- Centre Y
+local VW = display.viewableContentWidth -- Largeur visuelle
+local VH = display.viewableContentHeight -- Hauteur visuelle
+
+-- Chargement des modules
+
+local widget = require( "widget" )
+local tab = require ("lib.Tab")
+local json = require("json")
+local sqlite3 = require("sqlite3")
+local mime = require("mime")
+
+-- Instanciation de l'objet
+
+Accueil = {}
+
+-- Constructeur
+
+function Accueil:new()
+
+accueil = display.newGroup()
+
+local function initBackground()
+
+ local bg = display.newImageRect( "img/bg.jpg", 390, 580 )
+
+ bg.x = CX
+ bg.y = CY
+
+ accueil:insert( bg )
+
+end
+
+local function initLogo()
+
+ local logo = display.newImageRect( "img/logo.png", 200, 154.4 )
+
+ logo.anchorY = 0
+
+ logo.x = CX
+ logo.y = CY/2 - VH/32
+
+ logo.alpha = 0
+
+ transition.to( logo, { time = 2000, y = VH/7, alpha = 1, transition = easing.outExpo })
+
+ accueil:insert( logo )
+
+ local title = display.newText( "Tickets d'Utilité Publique", CX, CY + 20, "Dosis-Medium", 26 )
+ title.alpha = 0
+
+ transition.to( title, { time = 2000, y = logo.y + logo.height - 10, alpha = 1, transition = easing.outExpo })
+
+ local ribbon = display.newRect( CX, logo.y + logo.height + 15, title.width + 10, 35 )
+ ribbon:setFillColor( 0,0,0 )
+ ribbon.alpha = 0
+
+ transition.to( ribbon, { time = 2000, y = logo.y + logo.height - 10, alpha = .3, transition = easing.outExpo })
+
+ accueil:insert( ribbon )
+ accueil:insert( title )
+
+
+end
+
+local function initNbTicketsCallback(event)
+ if ( event.isError ) then
+ print("Network error!")
+ native.showAlert( "Erreur réseau.", "Veuillez vérifier votre connexion internet." )
+ else
+ print("RESPONSE:" .. event.response)
+ local data = json.decode(event.response)
+ if (data.result == 200) then
+
+ -- nombre de tickets
+ print(data.nb[1])
+ accueil.nb = data.nb[1]
+
+ elseif (data.result == 403) then
+ accueil.nb = 0
+ print("Erreur")
+ end
+ end
+
+end
+
+local function initNbTickets()
+ local mail
+ local path = system.pathForFile( "login.sqlite", system.DocumentsDirectory )
+ db = sqlite3.open( path )
+ local sql = "select * from log"
+ for row in db:nrows(sql) do
+ mail = row.mail
+ end
+ db:close()
+
+ local url = "http://tup.url.ph/app/recup_nb_tickets.php?mail="..mime.b64(mail)
+ network.request(url, "GET", initNbTicketsCallback)
+end
+
+
+local function onListeTickets( event )
+
+ transition.to(accueil.tab,{time=100,x=accueil.tab.x,y=accueil.tab.y - accueil.tab.height})
+ Runtime:dispatchEvent{ name = "MenuEvent", type = "listetickets" }
+
+end
+
+local function onCreerTicket( event )
+
+ transition.to(accueil.tab,{time=100,x=accueil.tab.x,y=accueil.tab.y - accueil.tab.height})
+ Runtime:dispatchEvent{ name = "MenuEvent", type = "ticket" }
+
+end
+
+local function initButtons()
+
+ -- Create the widget
+ local enCours = widget.newButton
+ {
+ width = 5/8 * VW,
+ height = 1/11 * VH,
+ sheet = buttonSheet,
+ --font = "Dosis-Book",
+ defaultFile = "blue_texture.png",
+ labelColor = { default={ 1,1,1 }, over={ 0, 0, 0, 0.5 } },
+ onPress = onListeTickets
+ }
+
+ --enCours:setFillColor = {246/255,226/255,53/255}
+
+ -- Center the button
+ enCours.x = CX
+ enCours.y = CY + 1/8 * VH + 1/11 * VH + 25
+
+ -- Change the button's label text
+ enCours:setLabel( "Tickets en cours" )
+
+ accueil:insert(enCours)
+ accueil.enCours = enCours
+
+ local creerTicket = widget.newButton
+ {
+ width = 5/8 * VW,
+ height = 1/11 * VH,
+ sheet = buttonSheet,
+ --font = "Dosis-Book",
+ defaultFile = "blue_texture.png",
+ labelColor = { default={ 1,1,1 }, over={ 0, 0, 0, 0.5 } },
+ onPress = onCreerTicket
+ }
+
+ -- Center the button
+ creerTicket.x = CX
+ creerTicket.y = CY + 1/8 * VH + 10
+
+ -- Change the button's label text
+ creerTicket:setLabel( "Nouveau ticket" )
+
+ accueil:insert(creerTicket)
+ accueil.creerTicket = creerTicket
+
+end
+
+local function initMenu()
+
+ local tab = Tab:new()
+ accueil.tab = tab
+
+end
+
+local function init()
+ initBackground()
+ initLogo()
+ initNbTickets()
+ initButtons()
+ initMenu()
+end
+
+init()
+
+function accueil:enableListeners()
+ -- On démarre les listeners
+ --Runtime:addEventListener("enterFrame", frame)
+ -- transition d'entrée de la barre d'onglets
+ transition.to(accueil.tab,{time=100,x=tab.x,y=SY})
+end
+
+function accueil:disableListeners()
+ -- On détruit les listeners
+ -- Et on supprime les éléments 1 par 1
+ --[[accueil.enCours:removeSelf()
+ accueil.enCours = nil
+ accueil.creerTicket:removeSelf()
+ accueil.creerTicket = nil
+ accueil.logout:removeSelf()
+ accueil.logout = nil
+ --]]
+end
+
+return accueil
+
+end
+
+return Accueil
\ No newline at end of file
--- /dev/null
+-- Connexion.lua
+
+-- Constantes métriques
+
+local SX = display.screenOriginX -- Origine X
+local SY = display.screenOriginY -- Origine Y
+local CX = display.contentCenterX -- Centre X
+local CY = display.contentCenterY -- Centre Y
+local VW = display.viewableContentWidth -- Largeur visuelle
+local VH = display.viewableContentHeight -- Hauteur visuelle
+
+-- Chargement des modules
+
+--system.setIdleTimer( false )
+local widget = require( "widget" )
+local json = require("json")
+local sqlite3 = require ("sqlite3")
+local mime = require("mime")
+
+-- Instanciation de l'objet
+
+Connexion = {}
+
+-- Constructeur
+
+function Connexion:new()
+
+connexion = display.newGroup()
+local mail = ""
+
+local function initBg()
+
+ local bg = display.newImageRect( "img/bg.jpg", 380, 570 )
+ bg.x = CX
+ bg.y = CY
+ bg.alpha = .4
+ connexion:insert( bg )
+
+end
+
+local function initTitle()
+
+ local title = display.newText( "Connexion", -100, -100, "Dosis-Book", 30 )
+ title.x = CX
+ title.y = SY + ( connexion.mailField.y - connexion.mailField.height/2 )/2
+
+ connexion:insert( title )
+
+end
+
+local function initTextFields()
+
+ 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, VW, tHeight )
+ mailField.x=CX
+ mailField.y=SY + 160
+ mailField.inputType = "email"
+ mailField.placeholder = "Adresse mail"
+ mailField.size = inputFontSize
+ mailField.align = "center"
+ mailField.alpha = .9
+
+ connexion:insert(mailField)
+ connexion.mailField = mailField
+
+ local mdpField = native.newTextField( -100, -100, VW, tHeight )
+ mdpField.x = CX
+ mdpField.y = mailField.y + mailField.height + 10
+ mdpField.isSecure = true
+ mdpField.placeholder = "Mot de passe"
+ mdpField.size = inputFontSize
+ mdpField.align = "center"
+ mdpField.alpha = .9
+
+ connexion:insert(mdpField)
+ connexion.mdpField = mdpField
+
+ local function onMail( event )
+
+ if ( event.phase == "submitted" ) then
+ -- on passe le focus au mot de passe
+ native.setKeyboardFocus( mdpField )
+ end
+
+ end
+
+ local function onPassword( event )
+
+ if ( event.phase == "submitted" ) then
+ -- on masque le clavier
+ native.setKeyboardFocus( nil )
+ end
+
+ end
+
+ mailField:addEventListener( "userInput", onMail )
+ mdpField:addEventListener( "userInput", onPassword )
+
+end
+
+local function fileExists() -- fonction permettant de vérifier si le fichier login.sqlite existe ou pas, pour la sécurité avant tout
+ local filePath = system.pathForFile("login.sqlite", system.DocumentsDirectory)
+ if (filePath) then
+ filePath = io.open( filePath, "r" )
+ end
+
+ if (filePath) then -- si le fichier existe
+ filePath:close()
+ return true
+ else
+ return false
+ end
+end
+
+
+local function loginCallback(event)
+ if ( event.isError ) then
+ print("Network error!")
+ native.showAlert( "Erreur réseau.", "Veuillez vérifier votre connexion internet." )
+ else
+ print("RESPONSE:" .. event.response)
+ local data = json.decode(event.response)
+ if (data.result == 200) then
+ -- client connecté
+ --print("Bienvenue", data.mail)
+ -- booléen persistance = 1 pour permettre la persistance de connexion tant qu'il n'y a pas déconnexion manuelle
+ local mdpT = "123" -- pour test
+ if (fileExists()) then -- si le fichier login.sqlite existe, la table aussi, donc on ne fait qu'updater le profil de l'utilisateur
+ local path = system.pathForFile("login.sqlite", system.DocumentsDirectory)
+ db = sqlite3.open( path )
+ local tablesetup = "update log set mail = '" ..data.mail.. "', mdp = '" ..connexion.mdpField.text.. "', persistance = 1 where id = 1" --connexion.mdpField.text
+ db:exec( tablesetup )
+ else -- si le fichier login.sqlite n'existe pas encore et la personne arrive quand même à se connecter on créer la table log pour la suite
+ local path = system.pathForFile("login.sqlite", system.DocumentsDirectory)
+ db = sqlite3.open( path ) -- on créer le fichier même s'il n'existait pas avant
+ local tablesetup = "CREATE TABLE IF NOT EXISTS log (id INTEGER PRIMARY KEY, mail, mdp, persistance);"
+ db:exec( tablesetup )
+ -- pour test
+ --local maiil = "piano-b-a-r@hotmail.fr"
+ --local pwd = "123"
+ -------------
+ local tablefill ="INSERT INTO log VALUES (NULL,'" .. data.mail .. "','" ..connexion.mdpField.text.. "', 1);"--connexion.mdpField.text
+ db:exec( tablefill )
+ end
+ db:close()
+
+ connexion.mdpField:removeSelf()
+ connexion.mailField:removeSelf()
+
+ -- rediriger le client vers la scène accueil
+ Runtime:dispatchEvent{name="MenuEvent", type="accueil"}
+ elseif (data.result == 403) then
+ native.showAlert( "Erreur.", "Adresse mail ou mot de passe incorrect(e).", { "OK" } )
+ -- reproposer la connexion
+ elseif (data.result == 450) then
+ native.showAlert( "Erreur.","Votre compte n'est pas encore activé, veuillez vérifier votre boîte mail.", { "OK" } )
+ -- reproposer la connexion
+ end
+ end
+end
+
+local function connectFile()
+ if (fileExists()) then -- on test l'existence du fichier avant de fouiller dedans
+ local pwd
+ local pers
+ local path = system.pathForFile("login.sqlite", system.DocumentsDirectory)
+ db = sqlite3.open( path )
+ local sql = "SELECT * FROM log"
+ for row in db:nrows(sql) do
+ mail = row.mail
+ pwd = row.mdp
+ pers = row.persistance
+ end
+ db:close()
+ -- on test si la persistance == 1, si oui on test la connexion, si réussie, on va à la page accueil, si persistance == 0, on ne fait rien
+ if (pers == 1) then
+ connexion.mdpField.text = pwd
+ local url = "http://tup.url.ph/app/login.php?loginid="..mime.b64(mail).."&pwd="..mime.b64(pwd)
+ network.request(url, "GET", loginCallback)
+ end
+ end
+end
+
+local function onConnect(event)
+ --local mail = "piano-b-a-r@hotmail.fr"
+ --local pwd = "123"
+
+ local mail = connexion.mailField.text
+ local pwd = connexion.mdpField.text
+
+ -- on vérifie que l'adresse mail est correcte
+ if not ( mail:match("[A-Za-z0-9%.%%%+%-]+@[A-Za-z0-9%.%%%+%-]+%.%w%w%w?%w?")) then
+ native.showAlert( "Erreur.", "Veuillez entrer une adresse mail correcte.", { "Oups !" } )
+ end
+
+ -- on vérifie que le mot de passe est bien entré
+ if not ( pwd ~= "" ) then
+
+ native.showAlert( "Erreur.", "Veuillez entrer votre mot de passe.", { "OK" } )
+
+ elseif ( mail ~= "" and pwd ~= "" ) then
+
+ local url = "http://tup.url.ph/app/login.php?loginid="..mime.b64(mail).."&pwd="..mime.b64(pwd)
+ -- on envoie les données du formulaire de connexion en GET
+ network.request(url, "GET", loginCallback)
+
+ end
+
+end
+
+local function onInscription(event)
+
+ Runtime:dispatchEvent{name="MenuEvent", type="inscription"}
+
+end
+
+local function switchPwdCallback( event )
+ if ( event.isError ) then
+ print("Network error!")
+ else
+ print("RESPONSE:" .. event.response)
+ local data = json.decode(event.response)
+ if (data.result == 200) then
+
+ native.showAlert( "Succès.", "Veuillez vérifier vos mails.", { "OK" } )
+
+ elseif (data.result == 403) then
+
+ native.showAlert( "Echec de l'envoi.", "Veuillez réessayer.", { "OK" } )
+ print ("Echec de l'envoi du nouveau mot de passe, réessayez")
+ -- reproposer la tentative
+
+ end
+ end
+end
+
+local function onRetour( event )
+
+ connexion.recup.x = CX
+ connexion.valider.x = CX
+ connexion.retour:removeSelf()
+ connexion.retour = nil
+ connexion.mdpField.isVisible = true
+ transition.to( connexion.mailField, { time = 400, y = SY + 160, transition = easing.outBounce } )
+ connexion.indication:removeSelf()
+ connexion.indication = nil
+ connexion.changer:removeSelf()
+ connexion.changer = nil
+
+end
+
+local function initRetour()
+
+ local retour = widget.newButton
+ {
+ width = VW,
+ height = .12*VH,
+ label = "Retour",
+ fontSize = 24,
+ defaultFile = "blue_texture.png",
+ labelColor = { default = {1,1,1}, over = {0,0,0,.5} },
+ onPress = onRetour,
+ font = "Dosis-Book"
+ }
+ retour.x = CX
+ retour.y = VH - retour.height*3/2
+
+ connexion:insert( retour )
+ connexion.retour = retour
+
+end
+
+local function onSwitchPwd ( event )
+
+ local mail = connexion.mailField.text
+
+ -- on vérifie que l'adresse mail est correcte
+ if not ( mail:match("[A-Za-z0-9%.%%%+%-]+@[A-Za-z0-9%.%%%+%-]+%.%w%w%w?%w?")) then
+ native.showAlert( "Erreur.", "Veuillez entrer une adresse mail correcte.", { "Oups !" } )
+ else
+
+ local url = "http://tup.url.ph/app/change_pwd.php?mail="..mail
+ -- on envoie les données du formulaire de connexion en GET
+ network.request(url, "GET", switchPwdCallback)
+
+ end
+
+end
+
+local function onChangePwd(event)
+
+ connexion.mdpField.isVisible = false
+ transition.to( connexion.mailField, { time = 400, y = connexion.mdpField.y, transition = easing.outBounce } )
+ local indication = display.newText( "Indiquez votre adresse E-mail", CX, connexion.mailField.y, "Dosis-Book", 20 )
+ initRetour()
+ connexion.recup.x = SX + VW + connexion.recup.width
+ connexion.valider.x = SX + VW + connexion.valider.width
+ connexion:insert( indication )
+ connexion.indication = indication
+
+ -- création du bouton valider le changement de mot de passe
+ local changer = widget.newButton
+ {
+ width = 200,
+ height = 50,
+ fillColor = { default = { 0, 0, 0, .01 } },
+ label = "Obtenir un nouveau mot de passe",
+ onPress = onSwitchPwd,
+ font = "Dosis-Book"
+ }
+
+ changer.x = CX
+ changer.y = connexion.mdpField.y + connexion.mdpField.height + 10
+
+ connexion:insert( changer )
+ connexion.changer = changer
+
+
+end
+
+local function initButtonPwd()
+
+ local recup = widget.newButton
+ {
+ width = 200,
+ height = 50,
+ fillColor = { default = { 0, 0, 0, .01 } },
+ label = "Récuperer mot de passe",
+ onPress = onChangePwd,
+ font = "Dosis-Book"
+ }
+
+ recup.x = CX
+ recup.y = connexion.mdpField.y + connexion.mdpField.height + 10
+
+ connexion:insert( recup )
+ connexion.recup = recup
+
+end
+
+local function initButtonConnect( listener )
+
+ local valider = widget.newButton
+ {
+ width = 5/8 * VW,
+ height = 1/11 * VH,
+ label = "Se Connecter",
+ defaultFile = "blue_texture.png",
+ labelColor = { default = {1,1,1}, over = {0,0,0,.5} },
+ onPress = listener,
+ }
+ valider.x = CX
+ valider.y = VH - valider.height*3/2
+
+ connexion:insert(valider)
+ connexion.valider = valider
+
+end
+
+local function initButtonIns()
+ -- bouton pour aller à la scène d'inscription
+ local ins = widget.newButton
+ {
+ width = 5/8 * VW,
+ height = 1/11 * VH,
+ label = "S'inscrire >",
+ labelColor = { default = {1,1,1}, over = {0,0,0,.5} },
+ defaultFile = "vert.png",
+ onPress = onInscription,
+ }
+ ins.x = CX
+ ins.y = VH - ins.height/2
+
+ connexion:insert(ins)
+ connexion.ins = ins
+end
+
+local function initButtons()
+ initButtonConnect( onConnect )
+ initButtonIns()
+ initButtonPwd()
+end
+
+local function init()
+
+ initBg()
+ initTextFields()
+ initTitle()
+ initButtons()
+ connectFile()
+
+end
+
+init()
+
+function connexion:enableListeners()
+
+
+end
+
+function connexion:disableListeners()
+
+ --connexion.mdpField:removeSelf()
+ --connexion.mailField:removeSelf()
+
+end
+
+return connexion
+
+end
+
+return Connexion
--- /dev/null
+-- GestionProfil.lua
+
+-- Constantes métriques
+
+local SX = display.screenOriginX -- Origine X
+local SY = display.screenOriginY -- Origine Y
+local CX = display.contentCenterX -- Centre X
+local CY = display.contentCenterY -- Centre Y
+local VW = display.viewableContentWidth -- Largeur visuelle
+local VH = display.viewableContentHeight -- Hauteur visuelle
+
+-- Chargement des modules
+
+local widget = require( "widget" )
+local json = require("json")
+local sqlite3 = require ("sqlite3")
+local mime = require("mime")
+
+-- Instanciation de l'objet
+
+GestionProfil = {}
+
+-- Constructeur
+
+function GestionProfil:new()
+
+gestionProfil = display.newGroup()
+local mail = ""
+
+local function initBackground()
+ local bg = display.newImageRect("img/bg_transition.jpg",380,570)
+ bg.x, bg.y = CX, CY
+ gestionProfil:insert(bg)
+
+end
+
+local function initFields()
+
+ local mailInfo = display.newText("", CX, SY + 1/4 * VH, "Dosis-Book", 16 )
+ gestionProfil:insert(mailInfo)
+
+ local textMail = display.newText( "Votre adresse mail :", CX, mailInfo.y - mailInfo.height, "Dosis-Book", 16 )
+ gestionProfil:insert(textMail)
+ gestionProfil.textMail = textMail
+
+ local textMdp = display.newText( "Nouveau mot de passe :", CX, CY - 1/8 * VH , "Dosis-Book", 16 )
+ gestionProfil:insert(textMdp)
+
+ local mdpField = native.newTextField( CX, textMdp.y + textMdp.height + 10, 200, 30 )
+ mdpField.isSecure = true
+ gestionProfil:insert(mdpField)
+ gestionProfil.mdpField = mdpField
+
+ local textMdpVerif = display.newText( "Confirmer le mot de passe :", CX, mdpField.y + mdpField.height, "Dosis-Book", 16 )
+ gestionProfil:insert(textMdpVerif)
+
+ local mdpFieldVerif = native.newTextField( CX, textMdpVerif.y + textMdpVerif.height + 10, 200, 30 )
+ mdpFieldVerif.isSecure = true
+ gestionProfil:insert(mdpFieldVerif)
+ gestionProfil.mdpFieldVerif = mdpFieldVerif
+
+
+local function onPass1( event )
+
+ if ( event.phase == "submitted" ) then
+
+ -- on passe le focus à pass1
+ native.setKeyboardFocus( mdpFieldVerif )
+
+ end
+
+end
+
+local function onPass2( event )
+
+ if ( event.phase == "submitted" ) then
+
+ -- on masque le clavier
+ native.setKeyboardFocus( nil )
+
+ end
+
+end
+
+ mdpField:addEventListener( "userInput", onPass1 )
+ mdpFieldVerif:addEventListener( "userInput", onPass2 )
+
+ gestionProfil.mailInfo = mailInfo
+ gestionProfil.mdp = mdpField
+ gestionProfil.mdpV = mdpFieldVerif
+
+end
+
+
+
+local function initGetMail()
+
+ -- on récupère le mail
+ local path = system.pathForFile("login.sqlite", system.DocumentsDirectory)
+ db = sqlite3.open( path )
+ local sql = "select * from log"
+ for row in db:nrows(sql) do
+ mail = row.mail
+ gestionProfil.mailInfo.text = gestionProfil.mailInfo.text..mail
+ end
+ db:close()
+
+end
+
+local function saveCallback(event)
+
+ if ( event.isError ) then
+ print("Network error!")
+ else
+ print("RESPONSE:" .. event.response)
+ local data = json.decode(event.response)
+ if (data.result == 200) then -- le changement de mot de passe à réussis, on l'effectue maintenant au niveau local, en changeant la persistance à 0 pour permettre au client de se reconnecter à la prochaine fermeture de l'app
+ local path = system.pathForFile("login.sqlite", system.DocumentsDirectory)
+ db = sqlite3.open( path )
+ local tablesetup = "update log set mdp = '" ..data.newPwd.. "',persistance = 0 where id = 1"
+ db:exec( tablesetup )
+ db:close()
+ elseif (data.result == 403) then
+ print ("Une erreur est survenue, veuillez réessayer")
+ -- reproposer la tentative de changement de mot de passe
+ end
+ end
+
+
+end
+
+
+local function onSaveInfos(event)
+
+ -- envoi des nouvelles données à enregistrer dans la base de donnée
+ --local mail = "piano-b-a-r@hotmail.fr"
+ --local mdpNouveau = "789"
+ local mdpNouveau = gestionProfil.mdp.text
+ local mdpNouveauV = gestionProfil.mdpV.text
+
+ if mdpNouveau ~= mdpNouveauV then
+
+ native.showAlert( "Erreur.", "Les mots de passe ne sont pas identiques.", { "Oups !" } )
+
+ elseif mdpNouveau == "" then
+
+ native.showAlert( "Erreur.", "Veuillez entrer un mot de passe.", { "Oups !" } )
+
+ else
+
+ local url = "http://tup.url.ph/app/change_profil.php?mail="..mime.b64(mail).."&pwd="..mime.b64(mdpNouveau)
+ -- on envoit les données du formulaire de connexion en GET
+ network.request(url, "GET", saveCallback)
+
+ end
+
+end
+
+local function initButtonSave()
+ local btnSave = widget.newButton
+ {
+ width = 5/8 * VW,
+ height = 1/11 * VH,
+ sheet = buttonSheet,
+ label = "Sauvegarder",
+ defaultFile = "blue_texture.png",
+ labelColor = { default={ 1,1,1 }, over={ 0, 0, 0, 0.5 } },
+ onPress = onSaveInfos
+ }
+
+ btnSave.font = "Dosis-Book"
+
+ btnSave.x, btnSave.y = CX, gestionProfil.mdpV.y + gestionProfil.mdpV.height + 1/8 * VH
+
+ gestionProfil:insert(btnSave)
+ gestionProfil.btnSave = btnSave
+
+end
+
+local function init()
+
+ initBackground()
+ initFields()
+ initButtonSave()
+ initGetMail()
+
+end
+
+function gestionProfil:enableListeners()
+
+end
+
+function gestionProfil:disableListeners()
+
+end
+
+function gestionProfil:exit()
+
+ gestionProfil.mdpField:removeSelf()
+ gestionProfil.mdpField = nil
+ gestionProfil.mdpFieldVerif:removeSelf()
+ gestionProfil.mdpFieldVerif = nil
+
+ gestionProfil.btnSave:removeSelf()
+ gestionProfil.btnSave = nil
+
+end
+
+init()
+
+return gestionProfil
+
+end
+
+return GestionProfil
\ No newline at end of file
--- /dev/null
+-- Inscription.lua
+
+-- Constantes métriques
+
+local SX = display.screenOriginX -- Origine X
+local SY = display.screenOriginY -- Origine Y
+local CX = display.contentCenterX -- Centre X
+local CY = display.contentCenterY -- Centre Y
+local VW = display.viewableContentWidth -- Largeur visuelle
+local VH = display.viewableContentHeight -- Hauteur visuelle
+
+-- Chargement des modules
+
+--system.setIdleTimer( false )
+local widget = require( "widget" )
+local json = require( "json" )
+local sqlite3 = require( "sqlite3" )
+local mime = require( "mime" )
+
+-- Instanciation de l'objet
+
+Inscription = {}
+
+-- Constructeur
+
+function Inscription:new()
+
+inscription = display.newGroup()
+
+-- Initialiser le fond
+
+local function initBg()
+
+ local bg = display.newImageRect( "img/bg.jpg", 380, 570 )
+ bg.x = CX
+ bg.y = CY
+ bg.alpha = .4
+ inscription:insert( bg )
+
+end
+
+-- Initialiser le texte
+
+local function initText()
+
+ local txt_title = display.newText( "Inscription", -100, -100, "Dosis-Book", 30 )
+
+ txt_title:setFillColor(1,1,1)
+ txt_title.x = CX
+ txt_title.y = 30
+
+ inscription:insert( txt_title )
+ inscription.txt_title = txt_title
+
+end
+
+-- Initialiser les champs
+
+local function initFields()
+
+ local isAndroid = "Android" == system.getInfo( "platformName" )
+ local inputFontSize = 18
+ local tHeight = 40
+
+ if ( isAndroid ) then
+
+ inputFontSize = inputFontSize - 4
+ tHeight = tHeight + 10
+
+ end
+
+ local inp_mail = native.newTextField( -100, -100, 5/8 * VW, tHeight )
+
+ inp_mail.anchorY = 0
+ inp_mail.x = CX
+ inp_mail.y = inscription.txt_title.y + 20 + inp_mail.height/2
+ inp_mail.inputType = "email"
+ inp_mail.placeholder = "Adresse mail"
+ inp_mail.align = "center"
+ inp_mail.size = inputFontSize
+ inp_mail.alpha = .9
+
+ local inp_pass1 = native.newTextField( -100, -100, 5/8 * VW, tHeight )
+
+ inp_pass1.anchorY = 0
+ inp_pass1.x = CX
+ inp_pass1.y = inp_mail.y + inp_mail.height + 10
+ inp_pass1.isSecure = true
+ inp_pass1.placeholder = "Mot de passe"
+ inp_pass1.align = "center"
+ inp_pass1.size = inputFontSize
+ inp_pass1.alpha = .9
+
+ local inp_pass2 = native.newTextField( -100, -100, 5/8 * VW, tHeight )
+
+ inp_pass2.anchorY = 0
+ inp_pass2.x = CX
+ inp_pass2.y = inp_pass1.y + inp_pass1.height + 10
+ inp_pass2.isSecure = true
+ inp_pass2.placeholder = "Confirmer mot de passe"
+ inp_pass2.align = "center"
+ inp_pass2.size = inputFontSize
+ inp_pass2.alpha = .9
+
+ inscription:insert( inp_mail )
+ inscription:insert( inp_pass1 )
+ inscription:insert( inp_pass2 )
+
+ inscription.inp_mail = inp_mail
+ inscription.inp_pass1 = inp_pass1
+ inscription.inp_pass2 = inp_pass2
+
+ local function onMail( event )
+
+ if ( event.phase == "submitted" ) then
+
+ -- on passe le focus à pass1
+ native.setKeyboardFocus( inp_pass1 )
+
+ end
+
+ end
+
+ local function onPass1( event )
+
+ if ( event.phase == "submitted" ) then
+
+ -- on passe le focus à pass2
+ native.setKeyboardFocus( inp_pass2 )
+
+ end
+
+ end
+
+ local function onPass2( event )
+
+ if ( event.phase == "submitted" ) then
+
+ -- on masque le clavier
+ native.setKeyboardFocus( nil )
+
+ end
+
+ end
+
+ inp_mail:addEventListener( "userInput", onMail )
+ inp_pass1:addEventListener( "userInput", onPass1 )
+ inp_pass2:addEventListener( "userInput", onPass2 )
+
+end
+
+-- Initialiser le texte d'accueil
+
+local function initTexteAccueil()
+
+ local z = inscription.inp_pass2.y + inscription.inp_pass2.height
+ local H = inscription.bValidation.y - z
+
+ local txt_accueil = display.newText( "Bienvenue dans Tickets d'Utilité Publique !", 0, 0, "Dosis-Book", 18 )
+ txt_accueil:setFillColor(1,1,1)
+
+ txt_accueil.anchorY = 0
+ txt_accueil.x = CX
+ txt_accueil.y = z + 11
+
+ inscription:insert( txt_accueil )
+ inscription.txt_accueil = txt_accueil
+
+ local options =
+ {
+ text = "Veuillez vous inscrire pour commencer à utiliser cette application de recensement de problèmes urbains.",
+ x = CX,
+ y = z + H/2,
+ width = VW - 20,
+ font = "Dosis-Book",
+ fontSize = 14,
+ align = "center"
+
+ }
+
+ local txt_exp1 = display.newText( options )
+
+ inscription:insert( txt_exp1 )
+ inscription.txt_exp1 = txt_exp1
+
+ local txt_exp2 = display.newText( "Vous recevrez un mail afin de confirmer votre compte.", 0, 0, "Dosis-Book", 13 )
+
+ txt_exp2.anchorY = 0
+
+ txt_exp2.x = CX
+ txt_exp2.y = z + H - txt_exp2.height - 15
+
+ inscription:insert( txt_exp2 )
+ inscription.txt_exp2 = txt_exp2
+
+end
+
+-- Supprimer le fichier d'inscription
+
+local removeFile = function ()
+
+ local results, reason = os.remove( system.pathForFile( "login.sqlite", system.DocumentsDirectory ) )
+
+ if results then print( "Fichier supprimé" )
+
+ else print( "Le fichier n'existe pas : ", reason )
+
+ end
+
+end
+
+-- Ecouteur d'événements réseau (gestion des requêtes)
+
+local function inscriptionCallBack( event )
+
+ if ( event.isError ) then
+
+ print( "Erreur réseau" )
+ native.showAlert( "Erreur réseau.", "Veuillez vérifier votre connexion internet." )
+
+ else
+
+ print( "RESPONSE : "..event.response )
+
+ data = json.decode( event.response )
+
+ -- Requête réussie : utilisateur inscrit
+ if ( data.result == 200 ) then
+
+ --on supprime le fichier d'inscription pour qu'il soit mis à jour proprement
+ removeFile()
+
+ local path = system.pathForFile( "login.sqlite", system.DocumentsDirectory )
+
+ db = sqlite3.open( path )
+
+ print( path )
+
+ local tableSetup = "CREATE TABLE IF NOT EXISTS log (id INTEGER PRIMARY KEY, mail, mdp, persistance);"
+
+ db:exec( tableSetup )
+
+ local mail = "piano-b-a-r@hotmail.fr"
+ local password = "123"
+ local tableFill = "INSERT INTO log VALUES (NULL,'" .. inscription.mail.text .. "','" ..inscription.mdp.text.. "' 0);"--inscription.mail.text
+
+ db:exec( tableFill )
+
+ native.showAlert( "Inscription validée.", "Veuillez vérifier votre boîte mail." )
+
+ -- on va à l'écran de connexion
+ Runtime:dispatchEvent{ name = "MenuEvent", type = "connexion" }
+
+ -- Adresse déjà référencée sur le serveur
+ elseif ( data.result == 400 ) then
+
+ native.showAlert( "Erreur.", "Vous êtes déjà inscrit, veuillez vous connecter." )
+
+ -- on va à l'écran de connexion
+ Runtime:dispatchEvent{ name = "MenuEvent", type = "connexion" }
+
+ elseif ( data.result == 403 ) then
+
+ print( "Echec de l'inscription, veuillez recommencer." )
+
+ end
+
+ end
+
+end
+
+-- Action du bouton valider (envoi des données)
+
+local function onValidation( event )
+
+ local mail = inscription.inp_mail.text
+
+ local p1 = inscription.inp_pass1.text
+ local p2 = inscription.inp_pass2.text
+
+ -- on vérifie que l'adresse mail est correcte
+ if not ( mail:match("[A-Za-z0-9%.%%%+%-]+@[A-Za-z0-9%.%%%+%-]+%.%w%w%w?%w?")) then
+ native.showAlert( "Erreur.", "Veuillez entrer une adresse mail correcte.", { "Oups !" } )
+
+--modification 06/09/14
+ -- elseif au lieu du end
+
+ -- on vérifie que tous les champs sont remplis correctement et que les mots de passe sont identiques
+ elseif ( mail ~= "" and p1 ~= "" and p2 ~= "" and p1 == p2 ) then
+
+ local url = "http://tup.url.ph/app/lien_valid_mail.php?mail="..mime.b64(mail).."&pwd="..mime.b64(p1)
+ network.request( url, "GET", inscriptionCallBack )
+
+ else
+
+ if ( mail == nil or p1 == nil or p2 == nil ) then
+ native.showAlert( "Erreur.", "Veuillez remplir tous les champs.", { "OK" } )
+ elseif ( p1 ~= p2 ) then
+ native.showAlert( "Erreur.", "Les mots de passe ne sont pas identiques.", { "Oups !" } )
+ end
+
+ end
+
+end
+
+-- Action du bouton connexion (vers l'écran de connexion)
+
+local function onConnect( event )
+
+ Runtime:dispatchEvent{ name = "MenuEvent", type = "connexion" }
+
+end
+
+-- Initialiser les boutons
+
+local function initButtons()
+
+ -- bouton de validation de l'inscription
+ local bValidation = widget.newButton
+ {
+ width = 5/8 * VW,
+ height = 1/11 * VH,
+ sheet = buttonSheet,
+ label = "S'inscrire",
+ defaultFile = "vert.png",
+ labelColor = { default = {1,1,1}, over = {0,0,0,.5} },
+ onPress = onValidation,
+ }
+
+ bValidation.anchorY = 0
+
+ bValidation.x = CX
+ bValidation.y = VH - 2*bValidation.height
+
+ inscription:insert( bValidation )
+ inscription.bValidation = bValidation
+
+ -- bouton pour aller à la scène de connexion
+ local bConnect = widget.newButton
+ {
+ width = 5/8 * VW,
+ height = 1/11 * VH,
+ sheet = buttonSheet,
+ label = "Se Connecter >",
+ defaultFile = "blue_texture.png",
+ labelColor = { default = {1,1,1}, over = {0,0,0,.5} },
+ onPress = onConnect,
+ }
+
+ bConnect.anchorY = 0
+
+ bConnect.x = CX
+ bConnect.y = VH - bConnect.height
+
+ inscription:insert( bConnect )
+ inscription.bConnect = bConnect
+
+end
+
+-- Contrôler les champs :
+-- on ne peut pas valider si les champs ne sont pas bien remplis
+
+local function frame( event )
+
+ local mail = inscription.inp_mail.text
+ local p1 = inscription.inp_pass1.text
+ local p2 = inscription.inp_pass2.text
+
+ -- BUG : enterframe démarre au changement de scène
+
+ --print(inscription.inp_mail.text)
+ --print(inscription.inp_pass1.text)
+ --print(inscription.inp_pass2.text)
+
+ if ( mail ~= nil and p1 ~= nil and p2 ~= nil and p1 == p2 ) then
+
+ inscription.bValidation:setEnabled( true )
+ inscription.bValidation.size = 20
+
+ else
+
+ inscription.bValidation:setEnabled( false )
+ inscription.bValidation.size = 10
+
+ end
+
+end
+
+-- Initialiser l'objet
+
+local function init()
+
+ initBg()
+ initText()
+ initFields()
+ initButtons()
+ initTexteAccueil()
+-- Runtime:addEventListener( "enterFrame", frame )
+
+end
+
+-- Activation des écouteurs d'événements
+
+function inscription:enableListeners()
+
+end
+
+-- Suppression des écouteurs d'événements
+
+function inscription:disableListeners()
+
+-- inscription.inp_mail:removeSelf()
+-- inscription.inp_pass1:removeSelf()
+-- inscription.inp_pass2:removeSelf()
+-- inscription.inp_mail = nil
+-- inscription.inp_pass1 = nil
+-- inscription.inp_pass2 = nil
+
+end
+
+-- L'objet est initialisé
+
+init()
+
+return inscription
+
+end
+
+return Inscription
--- /dev/null
+-- ListeTickets.lua
+
+-- Constantes métriques
+
+local SX = display.screenOriginX -- Origine X
+local SY = display.screenOriginY -- Origine Y
+local CX = display.contentCenterX -- Centre X
+local CY = display.contentCenterY -- Centre Y
+local VW = display.viewableContentWidth -- Largeur visuelle
+local VH = display.viewableContentHeight -- Hauteur visuelle
+
+-- Chargement des modules
+
+local widget = require( "widget" )
+local json = require( "json" )
+local sqlite3 = require( "sqlite3" )
+local mime = require( "mime" )
+
+-- Instanciation de l'objet
+
+ListeTickets = {}
+
+-- Constructeur
+
+function ListeTickets:new()
+
+listeTickets = display.newGroup()
+
+local nbTickets = -2
+-- -2 pour pouvoir enlever du compteur les clés "result" et "message"
+local data
+
+local function initBackground()
+
+ local bg = display.newRect(SX, SY, VW, VH)
+ bg.anchorX, bg.anchorY = 0,0
+
+ bg:setFillColor( 146/255, 114/255, 79/255 )
+
+ listeTickets:insert(bg)
+
+ local title = display.newText( "T i c k e t s e n c o u r s", CX, SY + 20, "Dosis-Book", 14 )
+ listeTickets:insert( title )
+
+end
+
+-- ScrollView listener
+
+local function scrollListener( event )
+
+ local phase = event.phase
+ if ( phase == "began" ) then
+ -- print( "Scroll view was touched" )
+ elseif ( phase == "moved" ) then
+ -- print( "Scroll view was moved" )
+ elseif ( phase == "ended" ) then
+ -- print( "Scroll view was released" )
+ end
+
+ -- In the event a scroll limit is reached...
+ if ( event.limitReached ) then
+ if ( event.direction == "up" ) then
+ -- print( "Reached top limit" )
+ elseif ( event.direction == "down" ) then
+ -- print( "Reached bottom limit" )
+ elseif ( event.direction == "left" ) then
+ -- print( "Reached left limit" )
+ elseif ( event.direction == "right" ) then
+ -- print( "Reached right limit" )
+ end
+ end
+
+ return true
+
+end
+
+-- Création de la ScrollView
+
+local function initScrollView()
+
+ -- Scrollbar
+ local scrollBarOpt = {
+ width = 20,
+ height = 20,
+ numFrames = 3,
+ sheetContentWidth = 20,
+ sheetContentHeight = 60
+ }
+
+ local scrollBarSheet = graphics.newImageSheet( "widget-scrollbar.png", scrollBarOpt )
+
+ -- Objet scrollView
+ local scrollView = widget.newScrollView
+ {
+ top = SY + 40,
+ left = SX,
+ width = VW,
+ height = VH - 80,
+ scrollHeight = VH - 76,
+ setScrollWidth = VW,
+ backgroundColor = { 240/255, 238/255, 221/255 },
+ listener = scrollListener,
+ scrollBarOptions = {
+ sheet = scrollBarSheet,
+ topFrame = 1,
+ middleFrame = 2,
+ bottomFrame = 3
+ }
+ }
+
+ scrollView._view._isHorizontalScrollingDisabled = true
+
+ listeTickets:insert( scrollView )
+ listeTickets.scrollView = scrollView
+
+end
+
+-- Affichage des tickets
+
+local function initView( n )
+
+ -- si il n'y pas de tickets en cours
+ if ( n == 0 ) then
+
+ -- print ( "pas de ticket" )
+ local noTicket = display.newText( "Pas de ticket en cours.", CX, CY, "Dosis-Book", 20 )
+ listeTickets:insert( noTicket )
+
+ else
+
+ -- print( n.." ticket" )
+ for i = 1,n do
+
+ -- instanciation d'un groupe PAR TICKET
+ local ticketView = display.newGroup()
+
+ -- fond de chaque ticket
+ local bg = display.newRect( 0, 25, VW, 70 )
+ bg.anchorX = 0
+ bg:setFillColor( 1,1,1,.5 )
+
+
+ -- objet du ticket
+ local oTicket = display.newText( data[""..i][1], SX + 20, 5, "Dosis-Book", 21 )
+ oTicket:setFillColor( 0,0,0 )
+ oTicket.anchorX = 0
+ oTicket.text = oTicket.text.." : "
+
+ -- type de problème
+ local tTicket = display.newText( data[""..i][2], SX + 25, 27, "Dosis-Book", 17 )
+ tTicket:setFillColor( 0,0,0 )
+ tTicket.anchorX = 0
+
+ -- priorité du ticket
+ local pTicket = display.newRect( bg.x, bg.y, 20, 70 )
+ pTicket.anchorX = .5
+ pTicket.anchorY = .5
+
+ if (data[""..i][3] == "0") then
+ pTicket:setFillColor(68/255,206/255,114/255)
+ elseif(data[""..i][3] == "1") then
+ pTicket:setFillColor(252/255,228/255,90/255)
+ elseif(data[""..i][3]== "2") then
+ pTicket:setFillColor(252/255,24/255,23/255)
+ end
+
+ -- adresse du ticket
+ local aTicket = display.newText( "À : "..data[""..i][4], SX + 30, 46, "Dosis-Book", 14 )
+ aTicket:setFillColor( 0,0,0 )
+ aTicket.anchorX = 0
+
+ -- insertion des propriétés dans le groupe
+ ticketView:insert( bg )
+ ticketView:insert( oTicket )
+ ticketView:insert( tTicket )
+ ticketView:insert( pTicket )
+ ticketView:insert( aTicket )
+
+ -- position du ticket affiché dans la liste
+ ticketView.x = SX
+ ticketView.y = (SY - 70) + 80 * i
+
+ -- insertion du ticket dans la liste
+ listeTickets.scrollView:insert( ticketView )
+
+ end
+
+ end
+
+end
+
+-- Ecouteur d'événements réseau (gestion des requêtes)
+
+local function ticketsCallBack( event )
+
+ if ( event.isError ) then print( "Erreur réseau" )
+
+ else
+
+ print( "RESPONSE : "..event.response )
+
+ data = json.decode( event.response )
+
+ -- Requête réussie : envoi des tickets
+ if ( data.result == 200 ) then
+
+ -- data.[""..i][n] avec :
+ -- n = 1 : objet
+ -- n = 2 : type
+ -- n = 3 : priorité
+ -- n = 4 : statut
+
+ -- print( data[""..1][2] )
+
+ -- comptage des tickets récupérés pour l'affichage des textes
+ for k,v in pairs( data ) do nbTickets = nbTickets + 1 end
+
+ -- print( nbTickets )
+
+ -- création des champs pour l'affichage des tickets
+ initView( nbTickets )
+
+ -- Pas de ticket en cours
+ elseif ( data.result == 400 ) then
+
+ initView( 0 )
+
+ end
+
+ end
+
+end
+
+-- Récupération des tickets
+
+local function initTickets()
+
+ local mail = "k"
+ local path = system.pathForFile( "login.sqlite", system.DocumentsDirectory )
+
+ db = sqlite3.open( path )
+
+ local sql = "select * from log"
+
+ for row in db:nrows( sql ) do
+ print()
+ print(row)
+ print(row.mail)
+ mail = row.mail
+ end
+
+ print("DEBUG ")
+ print("mail : ")
+ print( mail )
+
+ db:close()
+ local x = mime.b64( mail )
+
+ print("DEBUG ")
+ print(x)
+
+ local url = "http://tup.url.ph/app/recup_tickets.php?mail="..x
+
+ -- envoi des données du formulaire de connextion en GET
+ network.request( url, "GET", ticketsCallBack )
+
+end
+
+-- Initialiser les boutons
+
+local function initButtons()
+
+ local boutonRetour = display.newRect( 0, 0, 60, 40 )
+ boutonRetour.alpha = .01
+
+ boutonRetour.anchorX = 0
+
+ boutonRetour.x = SX
+ boutonRetour.y = VH - boutonRetour.height/2
+
+ listeTickets:insert( boutonRetour )
+ listeTickets.boutonRetour = boutonRetour
+
+ -- Action du bouton retour (vers l'accueil)
+
+ function boutonRetour:touch( event )
+
+ if event.phase == "began" then
+
+ Runtime:dispatchEvent{ name = "MenuEvent", type = "accueilSlideRight" }
+
+ end
+
+ end
+
+ local labelRetour = display.newText( "< Accueil", 8, SY + VH - 20, "Dosis-Book", 14 )
+ labelRetour.anchorX = 0
+
+ listeTickets:insert( labelRetour )
+
+end
+
+function enableBoutonRetour()
+
+ listeTickets.boutonRetour:addEventListener( "touch", boutonRetour )
+
+end
+
+-- Définition de l'initialisation de l'objet
+
+local function init()
+
+ initBackground()
+ initScrollView()
+ initTickets()
+ initButtons()
+ -- on active le bouton retour un peu après pour éviter des conflits de chargement
+ timer.performWithDelay( 500, enableBoutonRetour )
+
+end
+
+-- Activation des écouteurs d'événements
+
+function listeTickets:enableListeners()
+
+end
+
+-- Suppression des écouteurs d'événements
+
+function listeTickets:disableListeners()
+
+ --bReturn:removeSelf()
+ --listeTickets.bReturn = nil
+
+end
+
+-- L'objet est initialisé
+
+init()
+
+return listeTickets
+
+end
+
+return ListeTickets
\ No newline at end of file
--- /dev/null
+-- ListeType.lua
+
+-- Constantes métriques
+
+local SX = display.screenOriginX -- Origine X
+local SY = display.screenOriginY -- Origine Y
+local CX = display.contentCenterX -- Centre X
+local CY = display.contentCenterY -- Centre Y
+local VW = display.viewableContentWidth -- Largeur visuelle
+local VH = display.viewableContentHeight -- Hauteur visuelle
+
+-- Chargement des modules
+
+local widget = require( "widget" )
+
+local LEFT_PADDING = 10
+
+-- Instanciation de l'objet
+
+ListeType = {}
+
+-- Constructeur
+
+function ListeType:new()
+
+listeType = display.newGroup()
+
+-- Initialisation de la liste
+
+-- fond du titre de la liste
+local titleBar = display.newRect( 0, 0, VW, 40 )
+
+titleBar:setFillColor( 116/255, 101/255, 83/255 )
+
+titleBar.anchorX = 0
+titleBar.anchorY = 0
+
+titleBar.x = SX
+titleBar.y = SY
+
+listeType:insert( titleBar )
+
+-- titre de la liste
+local titleText = display.newText( "T y p e d e p r o b l è m e", 0, 0, "Dosis", 14 )
+titleText:setFillColor( 1, 1, 1 )
+titleText.anchorY = 0
+titleText.height = 40
+titleText.x = CX
+titleText.y = SY + 2
+listeType:insert( titleText )
+
+-- pour la tableview
+local list
+local rowTitles = {}
+
+-- Initialisation de la décoration du haut (cercles)
+
+local function initCircles()
+
+ local circle1 = {}
+ local circle2 = {}
+
+ for i = 0, 11 do
+
+ circle1[i] = display.newCircle( 0, 0, 8 )
+ circle1[i]:setFillColor( 0, 0, 0 )
+ circle1[i].x = (VW/10)*i
+ circle1[i].y = SY - 3
+ listeType:insert( circle1[i] )
+
+ end
+
+end
+
+-- affichage des items de la liste
+local function onRowRender( event )
+ local phase = event.phase
+ local row = event.row
+ local isCategory = row.isCategory
+ local groupContentHeight = row.contentHeight
+
+ local rowTitle = display.newText( row, rowTitles[row.index], 0, 0, "Dosis", 18 )
+
+ rowTitle.anchorX = 0
+
+ rowTitle.x = LEFT_PADDING/2
+
+ rowTitle.y = groupContentHeight * 0.5 - 2
+ rowTitle:setFillColor( 0, 0, 0 )
+
+ if not isCategory then
+
+ rowTitle.size = 16
+ rowTitle.x = LEFT_PADDING*2
+
+ local rowArrow = display.newImage( row, "rowArrow.png", false )
+ rowArrow.x = row.contentWidth - LEFT_PADDING
+
+ -- x-anchored : right
+ rowArrow.anchorX = 1
+
+ rowArrow.y = groupContentHeight * 0.5
+ end
+end
+
+-- Sélection d'un type
+local function onRowTouch( event )
+ local phase = event.phase
+ local row = event.target
+
+ -- sélection quand le bouton est relâché
+ -- pour permettre de faire défiler la liste
+ if "release" == phase then
+ -- Update the item selected text
+ print("You selected: " .. rowTitles[row.index])
+
+ -- pour indiquer la catégorie
+ -- catégories : 1, 5, 9, 26, 30
+ local k = 0
+
+ if( row.index > 1 and row.index < 5 ) then k = 1
+ elseif( row.index > 5 and row.index < 9 ) then k = 5
+ elseif( row.index > 9 and row.index < 26 ) then k = 9
+ elseif( row.index > 26 and row.index < 30 ) then k = 26
+ elseif( row.index > 30 ) then k = 30
+ end
+
+ Runtime:dispatchEvent{ name = "MenuEvent", type = "ticketTop", choice = rowTitles[row.index], category = rowTitles[k] }
+
+ end
+end
+
+-- création de la tableView
+list = widget.newTableView
+{
+ top = SY + 40,
+ left = SX,
+ width = VW,
+ height = VH - 40,
+ maskFile = "mask-320x448.png",
+ onRowRender = onRowRender,
+ onRowTouch = onRowTouch,
+ noLines = true
+}
+
+-- ajout des objets à la liste des types
+listeType:insert( list )
+listeType:insert( titleBar )
+listeType:insert( titleText )
+--widgetGroup:insert( shadow )
+
+-- Objet principal
+-- liste des types de problèmes + détails
+
+local listItems = {
+ { title = "Chaussée déformée", items = { "Bosses", "Dos-d`âne trop haut", "Racines sous la chaussée" } },
+ { title = "Chaussée endommagée", items = { "Fissures", "Nids-de-poule", "Trous" } },
+ { title = "Obstacles sur la route", items = { "Arbre", "Animal", "Bouche d'égouts ouverte", "Branchages", "Câbles électriques", "Débris", "Déchets", "Déviation non signalée", "Éboulement", "Flaque d`huile", "Flaque d`essence", "Fossé dangereux", "Gravats", "Inondation", "Radier submergé", "Travaux non signalés" } },
+ { title = "Pollution", items = { "Animal mort", "Déchets matériels", "Déchets toxiques" } },
+ { title = "Problèmes de signalisation", items = { "Danger non signalé", "Déviation non signalée", "Manque de panneau", "Marquage au sol incohérent", "Marquage au sol manquant", "Marquage au sol pas assez visible", "Panneau incohérent", "Panneau mal placé", "Panneau cassé", "Panneau dégradé", "Sens de circulation incohérent", "Travaux non signalés" } },
+}
+
+-- insert rows into list (tableView widget)
+-- insertion de la liste des types dans la tableView
+for i = 1, #listItems do
+ --Add the rows category title
+ rowTitles[ #rowTitles + 1 ] = listItems[i].title
+
+ --Insert the category
+ list:insertRow{
+
+ rowHeight = 32,
+ rowColor =
+ {
+ default = { 245/255, 171/255, 111/255, .9 }
+ },
+ isCategory = true,
+
+ }
+
+ --Insert the item
+ for j = 1, #listItems[i].items do
+
+ --Add the rows item title
+ rowTitles[ #rowTitles + 1 ] = listItems[i].items[j]
+
+ --Insert the item
+ list:insertRow{
+
+ rowHeight = 42,
+ rowColor = { 46/255, 204/255, 113/255, 0/255 },
+ isCategory = false,
+ listener = onRowTouch
+
+ }
+
+ end
+
+end
+
+initCircles()
+
+-- Démarrer les listeners
+
+function listeType:enableListeners()
+
+end
+
+return listeType
+
+end
+
+return ListeType
\ No newline at end of file
--- /dev/null
+-- GestionProfil.lua
+
+-- Constantes métriques
+
+local SX = display.screenOriginX -- Origine X
+local SY = display.screenOriginY -- Origine Y
+local CX = display.contentCenterX -- Centre X
+local CY = display.contentCenterY -- Centre Y
+local VW = display.viewableContentWidth -- Largeur visuelle
+local VH = display.viewableContentHeight -- Hauteur visuelle
+
+-- Chargement des modules
+
+local widget = require( "widget" )
+local sqlite3 = require ("sqlite3")
+
+-- Instanciation de l'objet
+
+Tab = {}
+
+-- Constructeur
+
+function Tab:new()
+
+tab = display.newGroup()
+local whichScene = 0 -- variable permettant de savoir on est sur quelle scène, 0=accueil, 1=gestion de profil. Par défaut on est à la page d'accueil lorsqu'on appel cette "classe"
+
+local function onLogout(event)
+
+ -- persistance = 0
+ local path = system.pathForFile("login.sqlite", system.DocumentsDirectory)
+ db = sqlite3.open( path )
+ local tablesetup = "update log set persistance = 0 where id = 1"
+ db:exec( tablesetup )
+ db:close()
+
+ -- on redirige le client vers la page de connexion
+ transition.to( tab, { time = 200, y = SY - tab.height } )
+ Runtime:dispatchEvent{name="MenuEvent", type="connexion"}
+
+end
+
+local function onAccueil(event)
+ if (whichScene == 1) then -- si on est sur la scène de gestion de profil, alors on permet le changement vers la scène d'accueil
+ Runtime:dispatchEvent{ name = "MenuEvent", type = "accueilSlideRight" }
+ whichScene = 0
+ -- on change l'onglet actif nouveau à "accueil"
+ tab.a.isVisible = true
+ tab.p.isVisible = false
+ end
+end
+
+local function onProfil(event)
+ if (whichScene == 0) then -- si on est sur la scène d'accueil alors on permet le changement vers la scène gestion de profil
+ Runtime:dispatchEvent{ name = "MenuEvent", type = "gestionProfil" }
+ whichScene = 1
+ -- on change l'onglet actif nouveau à gestion de profil
+ tab.p.isVisible = true
+ tab.a.isVisible = false
+ end
+end
+
+local function initButtons()
+
+ local fondOnglets = display.newRect( 0, 0, VW, 55)
+ fondOnglets.anchorX = 0
+ fondOnglets.anchorY = 0
+ fondOnglets:setFillColor(147/255,125/255,91/255)
+ fondOnglets.alpha = 0.6
+
+ local btnAccueil = display.newRect( 0, 0, VW/3, 55 )
+ btnAccueil:setFillColor( 0,0,0,.01 )
+
+ btnAccueil.anchorX = 0
+ btnAccueil.x = 0
+ btnAccueil.y = fondOnglets.height/2
+
+ btnAccueil:addEventListener( "touch", onAccueil )
+
+ local btnProfil = display.newRect( 0, 0, VW/3, 55 )
+ btnProfil:setFillColor( 0,0,0,.01 )
+
+ btnProfil.anchorX = 0
+ btnProfil.x, btnProfil.y = btnAccueil.x + btnAccueil.width,0 + 1/2 * btnProfil.height
+
+ btnProfil:addEventListener( "touch", onProfil )
+
+ local btnLogout = display.newRect( 0, 0, VW/3, 55 )
+ btnLogout:setFillColor( 0,0,0,.01 )
+
+ btnLogout.anchorX = 0
+ btnLogout.x, btnLogout.y = SX + VW - btnLogout.width,0 + 1/2 * btnLogout.height
+
+ btnLogout:addEventListener( "touch", onLogout )
+
+ -- On ajoute les images manuellement
+
+ tab:insert(fondOnglets)
+ tab:insert(btnAccueil)
+ tab:insert(btnProfil)
+ tab:insert(btnLogout)
+ tab.fond = fondOnglets
+ tab.bA = btnAccueil
+ tab.bP = btnProfil
+ tab.bL = btnLogout
+
+end
+
+local function initImages()
+ --Images qui vont plus tard servir aux Actives (bordures basse de 1 pixel de hauteur)
+ local accueilActive = display.newRect(SX, 0 + tab.fond.height - .5, tab.bA.width, 1)
+ local profilActive = display.newRect(SX + accueilActive.width, 0 + tab.fond.height - .5, tab.bA.width, 1)
+ accueilActive.anchorX = 0
+ profilActive.anchorX = 0
+ --Par défaut on est sur la page d'accueil
+ accueilActive.isVisible = true
+ profilActive.isVisible = false
+
+ --Icones de la tabBar
+ local accueil = display.newImageRect("img/btn_home.png", 28, 25 )
+ accueil.x, accueil.y = SX + 1/2 * tab.bA.width, 0 + 1/2 * tab.fond.height
+
+ local profil = display.newImageRect("img/btn_profil.png", 24, 25 )
+ profil.x, profil.y = tab.bP.x + 1/2 * tab.bP.width, 0 + 1/2 * tab.fond.height
+
+ local logout = display.newImageRect("img/btn_logout.png", 24, 28 )
+ logout.x, logout.y = tab.bL.x + 1/2 * tab.bL.width, 0 + 1/2 * tab.fond.height
+
+ tab:insert(accueil)
+ tab:insert(profil)
+ tab:insert(logout)
+ tab:insert(accueilActive)
+ tab:insert(profilActive)
+ tab.a = accueilActive
+ tab.p = profilActive
+
+end
+
+
+ local function init()
+
+ initButtons()
+ initImages()
+
+ end
+
+ init()
+
+
+ tab.anchorY = 0
+ tab.y = SY - tab.height
+
+return tab
+
+end
+
+return Tab
\ No newline at end of file
--- /dev/null
+-- Ticket.lua
+
+-- Constantes métriques
+
+local SX = display.screenOriginX -- Origine X
+local SY = display.screenOriginY -- Origine Y
+local CX = display.contentCenterX -- Centre X
+local CY = display.contentCenterY -- Centre Y
+local VW = display.viewableContentWidth -- Largeur visuelle
+local VH = display.viewableContentHeight -- Hauteur visuelle
+
+-- Chargement des modules
+
+local widget = require( "widget" )
+local json = require("json")
+local sqlite3 = require ("sqlite3")
+local mime = require("mime")
+
+-- Instanciation de l'objet
+
+Ticket = {}
+
+-- Constructeur
+
+function Ticket:new()
+
+ticket = display.newGroup()
+
+-- Attributs du ticket
+
+local photoName = ""
+local photoT = "Pas de photo."
+local prioriteT = 0
+local categorieT = "Pas de catégorie."
+local typeT = "Pas de type."
+local adresseT = "Pas d'adresse."
+local descriptionT = "Pas de description."
+local coordT = "0,0" -- lat,long
+
+local mail = ""
+
+-- Booléens : le ticket est-il rempli ?
+
+local isPhotoTaken = false -- variable qui va nous indiquer si une photo a été prise ou non
+local isTypeChosen = false -- variable qui va nous indiquer si un type a été choisi ou non
+local isAddressWritten = false -- variable qui va nous indiquer si une adresse a été écrite ou non
+
+-- Booléens : les objets sont-ils actifs ou réceptifs ?
+
+local editDescription = false
+local editAdresse = false
+
+local isPhotoActive = false
+local isPriorityActive = false
+local isTypeActive = false
+local isMapActive = false
+local isAddressActive = false
+local isLocaliserActive = false
+local isDescriptionActive = false
+local isEnvoyerActive = false
+local isAccueilActive = false
+
+
+-- désactiver les objets
+local function disableObjects()
+
+ print("disable")
+
+ isPhotoActive = false
+ isPriorityActive = false
+ isTypeActive = false
+ isMapActive = false
+ isAddressActive = false
+ isLocaliserActive = false
+ isDescriptionActive = false
+ isEnvoyerActive = false
+ isAccueilActive = false
+
+ ticket.map.x = CX + ticket.placeholder.width*2
+ ticket.placeholder.x = CX + ticket.placeholder.width*2
+
+end
+
+-- réactiver les objets
+local function enableObjects()
+
+ print("enable")
+
+ isPhotoActive = true
+ isPriorityActive = true
+ isTypeActive = true
+ isMapActive = true
+ isAddressActive = true
+ isLocaliserActive = true
+ isDescriptionActive = true
+ isEnvoyerActive = true
+ isAccueilActive = true
+
+ ticket.map.x = CX
+ ticket.placeholder.x = CX
+
+end
+
+-- Tous les 1 m, GPS event
+
+system.setLocationThreshold( 1 )
+
+-- Constante de marge
+
+local m = (.5/10)*VW
+
+-- Initialisation du fond
+
+local function initFond()
+
+ local bg = display.newRect( CX, CY, VW, VH)
+
+ bg:setFillColor( 240/255, 238/255, 221/255, 1 )
+
+ ticket:insert( bg )
+ ticket.bg = bg
+
+end
+
+-- Initialisation de la décoration du ticket (cercles)
+
+local function initCircles()
+
+ local circle1 = {}
+ local circle2 = {}
+
+ for i = 0, 11 do
+
+ circle1[i] = display.newCircle( 0, 0, 8 )
+ circle1[i]:setFillColor( 0, 0, 0 )
+ circle1[i].x = (VW/10)*i
+ circle1[i].y = SY - 3
+ ticket:insert( circle1[i] )
+
+ circle2[i] = display.newCircle( 0, 0, 8 )
+ circle2[i]:setFillColor( 0, 0, 0 )
+ circle2[i].x = (VW/10)*i
+ circle2[i].y = VH + 3
+ ticket:insert( circle2[i] )
+
+ end
+
+end
+
+-- Initialisation des bordures du ticket
+
+local function initBorders()
+
+ 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
+
+ local topTitle = display.newText( "T i c k e t d ' U t i l i t é P u b l i q u e", 0, 0, "Dosis-Book", 14 )
+ topTitle:setFillColor( 1, 1, 1 )
+
+ topTitle.anchorY = 0
+
+ topTitle.height = 40
+
+ topTitle.x = CX
+ topTitle.y = SY - topTitle.height
+
+ 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
+
+ local boutonRetour = display.newRect( 0, 0, 60, 40 )
+ boutonRetour.alpha = .01
+
+ boutonRetour.anchorX = 0
+
+ boutonRetour.x = SX - boutonRetour.width
+ boutonRetour.y = border2.y + border2.height/2
+
+ function boutonRetour:touch( event )
+
+ if event.phase == "began" and isAccueilActive then
+
+ if ticket.map then
+
+ ticket.map.x = CX + VW*2
+
+ end
+
+ Runtime:dispatchEvent{ name = "MenuEvent", type = "accueilSlideRight" }
+
+ end
+
+ end
+
+ local labelRetour = display.newText( "< Accueil", 0, 0, "Dosis-Book", 14 )
+
+ labelRetour.x = boutonRetour.x
+ labelRetour.y = boutonRetour.y
+
+ local labelObligatoire = display.newText( "*Obligatoires", 0, 0, "Dosis-Book", 14 )
+ labelObligatoire:setFillColor( 0, 0, 0, 1 )
+
+ labelObligatoire.anchorX = 0
+
+ labelObligatoire.x = VW - labelObligatoire.width - 5
+ labelObligatoire.y = border2.y + border2.height/2
+
+ -- insertions
+
+ ticket:insert( boutonRetour )
+ ticket.boutonRetour = boutonRetour
+
+ isAccueilActive = true
+
+ ticket:insert( border1 )
+ ticket.border1 = border1
+
+ ticket:insert( topTitle )
+ ticket.topTitle = topTitle
+
+ ticket:insert( border2 )
+ ticket.border2 = border2
+
+ ticket:insert( boutonRetour )
+ ticket.boutonRetour = boutonRetour
+
+ ticket:insert( labelRetour )
+ ticket.labelRetour = labelRetour
+
+ ticket:insert( labelObligatoire )
+ ticket.labelObligatoire = labelObligatoire
+
+end
+
+-- Initialisation du bouton prise de photo
+
+local function initPhoto()
+
+ local boutonPhoto = display.newRect( 0, 0, 70, 70 )
+ boutonPhoto:setFillColor( 253/255, 105/255, 0, .5 )
+
+ boutonPhoto.strokeWidth = 0
+ boutonPhoto:setStrokeColor( 0, 0, 0, .7 )
+
+ boutonPhoto.anchorX = 0
+ boutonPhoto.anchorY = 0
+
+ boutonPhoto.x = SX - boutonPhoto.width
+ boutonPhoto.y = SY + 60
+
+ ticket:insert( boutonPhoto )
+ ticket.boutonPhoto = boutonPhoto
+
+ isPhotoActive = true
+
+ local icon = display.newImage( "photoIcon.png", 0, 0 )
+
+ icon.x = SX - 80
+ icon.y = SY + boutonPhoto.height/2 + 60
+
+ icon.width = 42
+ icon.height = 32
+
+ icon.alpha = .4
+
+ ticket:insert( icon )
+ ticket.icon = icon
+
+ photo = display.newRect( 0, 0, 80, 80 )
+
+ photo.alpha = 0
+
+ ticket:insert( photo )
+
+ -- gestion de la prise de photo
+ function boutonPhoto:touch( event )
+
+ if event.phase == "began" and isPhotoActive then
+
+ print("photo")
+ -- on fait une photo
+ local function onComplete( event )
+
+ local newPhoto = event.target
+
+ -- si la prise de photo n'est pas annulée
+ if newPhoto ~= nil then
+ -- Une photo a été prise
+
+ isPhotoTaken = true
+
+ -- sauvegarder l'anciennce photo
+ display.save( newPhoto, { filename = "photo.jpg", baseDir = system.TemporaryDirectory, isFullResolution=true } )
+
+ -- masquer l'ancienne photo
+ local clear = display.newRect( 0, 0, boutonPhoto.width, boutonPhoto.height )
+ clear:setFillColor( 0, 0, 0 )
+
+ clear.anchorX = 0
+ clear.anchorY = 0
+
+ clear.x = boutonPhoto.x
+ clear.y = boutonPhoto.y
+
+ ticket:insert( clear )
+
+ -- nouvelle photo
+ photo = newPhoto
+
+ photo.anchorX = 0
+ photo.anchorY = 0
+
+ photo.x = boutonPhoto.x
+ photo.y = boutonPhoto.y
+
+ photo.width = boutonPhoto.width
+ photo.height = boutonPhoto.height
+
+ photo.alpha = 1
+
+ ticket:insert( photo )
+
+ end
+
+ end
+
+ if media.hasSource( media.Camera ) then
+
+ --photo = nil
+
+ media.capturePhoto( { listener = onComplete } )
+
+ else
+
+ native.showAlert( "Hum.", "Cet appareil n'a pas d'appareil photo.", { "OK" } )
+
+ end
+
+ end
+
+ end
+
+ photoT = system.pathForFile( "photo.jpg", system.TemporaryDirectory )
+
+end
+
+-- Initialisation des boutons de priorité du ticket
+
+local function initPriorite()
+
+ -- Priorité
+
+ local labelBg = display.newRect( 0, 0, (3.5/16)*VW, (.8/16)*VH )
+ labelBg.alpha = 0
+
+ labelBg.x = SX + (7.4/16)*VW
+ labelBg.y = ticket.boutonPhoto.y + labelBg.height/2
+
+ ticket:insert( labelBg )
+
+ local labelBg2 = display.newRect( 0, 0, (5/16)*VW, (.8/16)*VH )
+ labelBg2.alpha = 0
+
+ labelBg2.anchorX = 1
+
+ labelBg2.x = SX + VW - 20--SX + (12.7/16)*VW
+ labelBg2.y = ticket.boutonPhoto.y + labelBg2.height/2
+
+ ticket:insert( labelBg2 )
+
+ -- labels de priorité
+ local label = display.newText( "Choisissez une priorité :", 0, 0, "Dosis-Book", 20 )
+ label:setFillColor( 0, 0, 0, .9 )
+
+ label.x = SX + (10.5/16)*VW
+ label.y = labelBg.y
+
+ ticket:insert( label )
+
+ local label2 = display.newText( "", 0, 0, "Dosis-Bold", 20 )
+ label2:setFillColor( 255/255, 101/255, 83/255 )
+
+ label2.x = labelBg2.x - labelBg2.width/2
+ label2.y = labelBg2.y
+
+ label2.align = "center"
+
+ ticket:insert( label2 )
+
+ -- bouton de priorité faible
+ local prioriteL = display.newCircle( 0, 0, 16 )
+ prioriteL:setFillColor( .2, .8, .4, .9 )
+
+ prioriteL.anchorX = 0
+ prioriteL.anchorY = 0
+
+ prioriteL.strokeWidth = 0
+ prioriteL:setStrokeColor( .2, .8, .4, .5 )
+
+ prioriteL.x = SX + (6.5/16)*VW
+ prioriteL.y = SY - prioriteL.height
+
+ -- fonction d'action du bouton de priorité faible
+ function prioriteL:touch( event )
+
+ if event.phase == "began" and isPriorityActive then
+
+-- ticket.bg:setFillColor( 0/255, 180/255, 80/255, .9 )
+
+ label.text = "Ticket : "
+ label.x = SX + (7.6/16)*VW
+
+ label2.text = "Commun"
+-- label2.x = SX + (12.7/16)*VW
+ label2:setFillColor( .1, .7, .3, 1 )
+
+ labelBg.alpha = .5
+ labelBg2.alpha = .5
+
+ ticket.prioriteL:setFillColor( .2, .8, .4, .9 )
+ ticket.prioriteL.strokeWidth = 2
+
+ ticket.prioriteM:setFillColor( 1, .9, .3, .2 )
+ ticket.prioriteM.strokeWidth = 0
+
+ ticket.prioriteH:setFillColor( 1, 0, 0, .2 )
+ ticket.prioriteH.strokeWidth = 0
+
+ prioriteT = 0
+
+ priorite64 = mime.b64( prioriteT )
+ print(prioriteT)
+ print(priorite64)
+
+ end
+
+ end
+
+ -- bouton de priorité moyenne
+ local prioriteM = display.newCircle( 0, 0, 16 )
+ prioriteM:setFillColor( 1, .9, .3, .9 )
+
+ prioriteM.anchorX = 0
+ prioriteM.anchorY = 0
+
+ prioriteM.strokeWidth = 0
+ prioriteM:setStrokeColor( 1, .9, .3, .5 )
+
+ prioriteM.x = SX + (9.5/16)*VW
+ prioriteM.y = SY - prioriteM.height*2
+
+ -- fonction d'action du bouton de priorité moyenne
+ function prioriteM:touch( event )
+
+ if event.phase == "began" and isPriorityActive then
+
+-- ticket.bg:setFillColor( 241/255, 196/255, 15/255, .9 )
+
+ label.text = "Ticket : "
+ label.x = SX + (7.6/16)*VW
+
+ label2.text = "Important"
+-- label2.size = 21
+-- label2.x = SX + (12.7/16)*VW
+ label2:setFillColor( 1, 194/255, 0, 1 )
+
+ labelBg.alpha = .5
+ labelBg2.alpha = .5
+
+ ticket.prioriteL:setFillColor( 0, 1, 0, .2 )
+ ticket.prioriteL.strokeWidth = 0
+
+ ticket.prioriteM:setFillColor( 1, .9, .3, .9 )
+ ticket.prioriteM.strokeWidth = 2
+
+ ticket.prioriteH:setFillColor( 1, 0, 0, .2 )
+ ticket.prioriteH.strokeWidth = 0
+
+ prioriteT = 1
+
+ priorite64 = mime.b64( prioriteT )
+ print(prioriteT)
+ print(priorite64)
+
+ end
+
+ end
+
+ -- bouton de priorité forte
+ local prioriteH = display.newCircle( 0, 0, 16 )
+ prioriteH:setFillColor( 1, 0, 0, .9 )
+
+ prioriteH.anchorX = 0
+ prioriteH.anchorY = 0
+
+ prioriteH.strokeWidth = 0
+ prioriteH:setStrokeColor( 1, 0, 0, .5 )
+
+ prioriteH.x = SX + (12.5/16)*VW
+ prioriteH.y = SY - prioriteH.height*3
+
+ -- fonction d'action du bouton de priorité haute
+ function prioriteH:touch( event )
+
+ if event.phase == "began" and isPriorityActive then
+
+ --ticket.bg:setFillColor( 231/255, 76/255, 60/255, .8 )
+
+ label.text = "Ticket : "
+ label.x = SX + (7.6/16)*VW
+
+ label2.text = "Urgent"
+ label2:setFillColor( 1, 0, 0, 1 )
+-- label2.x = SX + (12.7/16)*VW
+
+ labelBg.alpha = .5
+ labelBg2.alpha = .5
+
+ ticket.prioriteL:setFillColor( 0, 1, 0, .2 )
+ ticket.prioriteL.strokeWidth = 0
+
+ ticket.prioriteM:setFillColor( 1, .9, .3, .2 )
+ ticket.prioriteM.strokeWidth = 0
+
+ ticket.prioriteH:setFillColor( 1, 0, 0, .9 )
+ ticket.prioriteH.strokeWidth = 2
+
+ prioriteT = 2
+
+ priorite64 = mime.b64( prioriteT )
+ print(prioriteT)
+ print(priorite64)
+
+ end
+
+ end
+
+-- prioriteL:addEventListener( "touch", prioriteL )
+-- prioriteM:addEventListener( "touch", prioriteM )
+-- prioriteH:addEventListener( "touch", prioriteH )
+
+ ticket:insert( prioriteL )
+ ticket:insert( prioriteM )
+ ticket:insert( prioriteH )
+
+ ticket.prioriteL = prioriteL
+ ticket.prioriteM = prioriteM
+ ticket.prioriteH = prioriteH
+
+ isPriorityActive = true
+
+end
+
+-- Initialisation du bouton type de problème
+
+local function initType()
+
+ local boutonType = display.newRect( 0, 0, VW, 55 )
+
+ boutonType:setFillColor( 1, 1, 1, .7 )
+
+ boutonType.anchorX = 0
+ boutonType.anchorY = 0
+
+ boutonType.x = SX
+ boutonType.y = SY + 150
+
+ -- fonction d'action du bouton de type de ticket
+ function boutonType:touch( event )
+
+ if event.phase == "began" and isTypeActive then
+
+ -- on demande à afficher la liste des types
+ Runtime:dispatchEvent{ name = "MenuEvent", type = "listetype" }
+ -- on cache la map (car objet natif)
+ ticket.description.alpha = 1
+ ticket.map.x = SX + VW*2
+ ticket.placeholder.x = SX + VW*2
+
+ end
+
+ end
+
+ ticket:insert( boutonType )
+ ticket.boutonType = boutonType
+
+ isTypeActive = true
+
+ -- label initial du bouton type de problème
+ local labelType = display.newText( "*Quel est le problème ?", 0, 0, "Dosis-Medium", 26 )
+
+ labelType:setFillColor( 0, 0, 0 )
+
+ labelType.height = 50
+
+ labelType.anchorY = 0
+
+ labelType.x = CX
+ labelType.y = boutonType.y
+
+ ticket:insert( labelType )
+ ticket.labelType = labelType
+
+ local categorie = display.newText( "", 0, 0, "Dosis-Book", 16 )
+
+ categorie:setFillColor( 0, 0, 0, 1 )
+
+ categorie.height = 50
+
+ categorie.x = CX
+ categorie.y = boutonType.y + .25*boutonType.height
+
+ ticket:insert( categorie )
+ ticket.categorie = categorie
+
+ -- texte qui affiche le type de problème sur le bouton
+ local textType = display.newText( "", 0, 0, "Dosis-Bold", 22 )
+
+ textType:setFillColor( 0, 0, 0, 0 )
+
+ textType.height = 50
+
+ textType.x = CX
+ textType.y = boutonType.y + .7*boutonType.height
+
+ ticket:insert( textType )
+ ticket.textType = textType
+
+end
+-- fin type
+
+-- Initialisation de la carte Google Maps
+
+local function initMap()
+
+ --- A SUPPRIMER
+ ---
+
+ local placeholder = display.newRect( 0, 0, VW, 100 )
+ placeholder:setFillColor( 0, 0, 0, .5 )
+
+ placeholder.anchorY = 0
+
+ placeholder.x = CX
+ placeholder.y = ticket.boutonType.y + ticket.boutonType.height
+
+ ticket:insert( placeholder )
+ ticket.placeholder = placeholder
+
+ ---
+ --- A SUPPRIMER
+
+ -- carte pour le positionnement gps
+ local map = native.newMapView( 0, 0, VW, 100 )
+
+ local function goToAddress( address )
+
+ map:requestLocation( address, resultHandler )
+
+ end
+
+ map.anchorY = 0
+
+ map.x = CX
+ map.y = ticket.boutonType.y + ticket.boutonType.height
+
+ -- pour la lisibilité de l'adresse
+ local adresseBg = display.newRect( 0, 0, VW - 40, 40 )
+
+ adresseBg:setFillColor( 1, 1, 1, .7 )
+
+ adresseBg.anchorX = 0
+ adresseBg.anchorY = 0
+
+ adresseBg.x = SX
+
+ ticket:insert( adresseBg )
+ ticket.adresseBg = adresseBg
+
+ isAddressActive = true
+
+ -- adresse de la localisation
+ local labelAdresse = display.newText( "*Adresse", 0, 0, adresseBg.width, (1/16)*VH, "Dosis-Book", 18 )
+
+ labelAdresse:setFillColor( 0, 0, 0 )
+
+ labelAdresse.anchorX = 0
+
+ labelAdresse.x = SX + 10
+
+ ticket:insert( labelAdresse )
+ ticket.labelAdresse = labelAdresse
+
+ local function adresseListener( event )
+
+ if event.phase == "submitted" or event.phase == "ended" then
+
+ if event.target.text == "" or event.target.text == " " or event.target.text == " " then
+
+ labelAdresse.text = "*Veuillez vous localiser ou entrer une adresse."
+ adresseT = "Pas d'adresse."
+
+ else
+
+ if #event.target.text > 27 then
+
+ labelAdresse.text = event.target.text:sub(1,27).."..."
+
+ else labelAdresse.text = event.target.text
+
+ end
+
+ adresseT = event.target.text
+
+ -- on met à les données relatives à la position (adresse entrée au clavier)
+
+ -- on supprime tous les marqueurs déjà présents à chaque activation
+ map:removeAllMarkers()
+
+ local function mapLocationHandler( event )
+ -- handle mapLocation event here
+ if event.isError then
+ print( "Error: " .. event.errorMessage )
+ native.showAlert( "Erreur !", ""..event.errorMessage, { "OK" } )
+ else
+ coordT = ""..event.latitude..","..event.longitude
+ -- on centre la map sur la position
+ map:setCenter( location.latitude, location.longitude, true )
+ -- on place le marqueur
+ map:addMarker( location.latitude, location.longitude )
+ end
+ end
+
+ -- on récupère les coordonnées de l'adresse entrée au clavier
+ map:requestLocation( adresseT, mapLocationHandler )
+
+ -- l'adresse est écrite
+ isAddressWritten = true
+
+ end
+
+ end
+
+ end
+
+ local adresseManuelle = native.newTextField( 0, 0, VW, 40 )
+
+ adresseManuelle.size = 18
+ adresseManuelle.align = "center"
+
+ adresseManuelle.x = CX
+ adresseManuelle.y = SY - adresseManuelle.height
+
+ adresseManuelle:addEventListener( "userInput", adresseListener )
+
+ ticket:insert( adresseManuelle )
+ ticket.adresseManuelle = adresseManuelle
+
+ -- label simulant un bouton valider pour l'adresse ou la description (plus tard dans le code)
+ local labelValider = display.newText( "Valider", 0, 0, "Dosis-Book", 26 )
+ labelValider:setFillColor( 1, 1, 1 )
+
+ labelValider.x = CX
+ labelValider.y = SY - 80
+
+ ticket:insert( labelValider )
+ ticket.labelValider = labelValider
+
+ function adresseBg:touch( event )
+
+ if event.phase == "began" and isAddressActive then
+
+ -- lorsqu'on édite l'adresse, on désactive les autres objets
+ disableObjects()
+
+ editAdresse = true
+
+ -- on place l'écran grisé devant les objets désactivés
+ ticket.block.y = CY
+ ticket.block:toFront()
+
+ -- on fait descendre le textField
+ transition.to( adresseManuelle, { time = 400, y = ticket.boutonType.y + ticket.boutonType.height/2, transition = easing.outBounce } )
+
+ -- on place le label Valider
+ ticket.labelValider.y = ticket.boutonType.y + ticket.boutonType.height + 20
+ ticket.labelValider:toFront()
+
+ -- le textField a le focus du clavier
+ native.setKeyboardFocus( adresseManuelle )
+
+ end
+
+ end
+
+ -- bouton pour localiser
+ local boutonLocaliser = display.newRect( 0, 0, 40, 40 )
+ boutonLocaliser:setFillColor( 253/255, 105/255, 0, .5 )
+
+ boutonLocaliser.anchorX = 0
+ boutonLocaliser.anchorY = 0
+
+ boutonLocaliser.x = SX + VW - boutonLocaliser.width
+
+ boutonLocaliser.alpha = 1
+
+ print(VH/VW)
+ print("VH : "..VH)
+ print("VW : "..VW)
+
+-- 480x320 : iphone : réduire un peu la map
+-- 512x320 : problème
+
+ -- la map est plus ou moins haute selon la hauteur de l'écran
+
+ -- pour les écrans en hauteur (smartphones)
+ if( VH/VW >= 1.7 ) then
+
+ placeholder.height = 180
+ map.height = 160
+
+ elseif( VH/VW < 1.7 and VH/VW > 1.5 ) then
+
+ placeholder.height = 120
+ map.height = 120
+
+ end
+
+ if ( VH == 512 and VW == 320 ) then
+
+ placeholder.height = 140
+ map.height = 140
+
+ elseif ( VH == 480 and VW == 320 ) then
+
+ placeholder.height = 100
+ map.height = 100
+
+ end
+
+ -- on positionne la barre d'adresse en dessous de la map
+ -- en fonction de sa hauteur qui dépend de celle de l'écran
+ adresseBg.y = ticket.placeholder.y + ticket.placeholder.height
+ labelAdresse.y = ticket.placeholder.y + ticket.placeholder.height + ticket.adresseBg.height/2
+ boutonLocaliser.y = ticket.placeholder.y + ticket.placeholder.height
+
+ -- icone localiser
+ local iconGps = display.newImage( "gpsIcon.png", 0, 0 )
+
+ iconGps.x = boutonLocaliser.x + boutonLocaliser.width/2
+ iconGps.y = boutonLocaliser.y + boutonLocaliser.width/2
+
+ iconGps.width = 26
+ iconGps.height = 26
+
+ iconGps.alpha = .4
+
+ -- fonction d'action du bouton de localiser
+ function boutonLocaliser:touch( event )
+
+ if event.phase == "began" and isLocaliserActive then
+
+ print("OK!!!!!")
+ labelAdresse.text = "Entré dans la fonction"
+
+ -- on supprime tous les marqueurs déjà présents à chaque activation
+ map:removeAllMarkers()
+
+ -- on récupère la position de l'utilisateur
+ local location = map:getUserLocation()
+
+ -- on centre la map sur la position
+ map:setCenter( location.latitude, location.longitude, true )
+ -- on place le marqueur
+ map:addMarker( location.latitude, location.longitude )
+
+ coordT = ""..location.latitude..","..location.longitude
+
+ local function mapAddressHandler( event )
+ labelAdresse.text = "Entré dans la fonction"
+ -- handle mapAddress event here
+ if event.isError then
+ print( "mapView Error: " .. event.errorMessage )
+ labelAdresse.text = "Event.isError"
+ else
+ labelAdresse.text = "Normalement ça écrit l'adresse"
+ print( "The specified location is in: " .. event.city .. ", " .. event.country )
+ number = event.streetDetail
+ street = event.street
+ postalCode = event.postalCode
+ city = event.city
+ country = event.country
+
+ -- on récupère l'adresse sur la carte
+ local k = ""..number..", "..street.." "..postalCode.." "..city.." "..country
+
+ -- on stocke l'adresse
+ adresseT = k
+
+ if #k > 34 then
+
+ labelAdresse.text = k:sub(1,34).."..."
+
+ else labelAdresse.text = k
+
+ end
+ end
+ end
+
+ -- on récupère l'adresse la plus proche des coordonnées GPS
+ local nearestAddress = map:nearestAddress( location.latitude, location.longitude, mapAddressHandler )
+
+ end
+
+ end
+
+ ticket.map = map
+
+ isMapActive = true
+
+ map.height = ticket.placeholder.height
+
+ ticket:insert( boutonLocaliser )
+ ticket.boutonLocaliser = boutonLocaliser
+
+ isLocaliserActive = true
+
+ ticket:insert( iconGps )
+ ticket.iconGps = iconGps
+
+ local function localize()
+ ticket.boutonLocaliser:touch({phase = "began"})
+ end
+
+ -- on se localise dès l'arrivée sur le ticket
+ timer.performWithDelay( 1000, localize )
+
+end
+-- fin map
+
+-- Initialisation de la description du problème
+
+local function initDescription()
+
+ local function inputListener( event )
+
+ if event.phase == "began" then
+
+ elseif event.phase == "submitted" or event.phase == "ended" then
+
+ local function isBlank( text )
+
+ local isBlank = true
+ for i = 1, #text-1 do
+
+ if text:sub( i, i+1 ) ~= " " then
+
+ isBlank = false
+ break
+
+ end
+
+ end
+
+ return isBlank
+
+ end
+
+ if isBlank( event.target.text ) then
+
+ descriptionT = "Pas de description."
+ ticket.textDescr.text = "Pas de description."
+
+ else
+
+ descriptionT = event.target.text
+ ticket.textDescr.text = event.target.text
+ ticket.textDescr.size = 12
+
+ end
+
+ end
+
+ end
+
+ -- description du problème dans une TextBox
+ local description = native.newTextBox( 0, 0, 190, 100 )
+
+ description.x = CX
+ description.y = SY - description.height
+
+ description.font = native.newFont( "Dosis-Book", 16 )
+ description.placeholder = "Description du problème."
+
+ description.isEditable = true
+ description.hasBackground = true
+
+ description:addEventListener( "userInput", inputListener )
+
+ ticket.description = description
+
+ -- bouton pour éditer la description
+ local z = ticket.adresseBg.y + ticket.adresseBg.height
+
+ local descr = display.newRect( 0, 0, VW - ( ticket.border2.y - z ) + 4, ticket.border2.y - z - 40 )
+ descr:setFillColor( 1, 1, 1, .7 )
+
+ descr.anchorX = 0
+ descr.anchorY = 0
+
+ descr.x = SX - descr.width
+ descr.y = z + 20
+
+ local textDescr = display.newText( "Description", 0, 0, descr.width - 10, descr.height - 5, "Dosis-Book", 18 )
+ textDescr:setFillColor( 0, 0, 0 )
+
+ textDescr.anchorX = 0
+ textDescr.anchorY = 0
+
+ textDescr.x = SX - textDescr.width
+ textDescr.y = descr.y + 5
+
+ local block = display.newRect( 0, 0, VW, VH )
+ block:setFillColor( 0, 0, 0, .6 )
+
+ block.x = CX
+ block.y = CY - 2*VH
+
+ ticket:insert( block )
+ ticket.block = block
+
+ -- arrêt de l'édition de l'adresse ou de la description
+ function block:touch( event )
+
+ if event.phase == "began" then
+
+ -- on masque le clavier
+ native.setKeyboardFocus( nil )
+
+ -- on cache l'écran grisé
+ ticket.block.x = CX
+ ticket.block.y = CY - 2*VH
+
+ -- on masque le label valider
+ ticket.labelValider.y = SY - 80
+
+ if editAdresse then
+
+ transition.to( ticket.adresseManuelle, { time = 300, y = SY - ticket.adresseManuelle.height, transition = easing.inExpo } )
+
+ editAdresse = false
+
+ elseif editDescription then
+
+ transition.to( ticket.description, { time = 300, y = SY - ticket.description.height, transition = easing.inExpo } )
+ transition.to( ticket.descr, { time = 400, x = SX - 4, transition = easing.outBounce } )
+ transition.to( ticket.textDescr, { time = 500, x = SX + 10, transition = easing.outBounce } )
+
+ editDescription = false
+
+ end
+
+ -- on réactive les objets de derrière avec une latence pour éviter les conflits
+ local function go() enableObjects() end
+
+ timer.performWithDelay( 10, go )
+
+ end
+
+ end
+
+ function descr:touch( event )
+
+ if event.phase == "began" and isDescriptionActive then
+
+ -- lorsqu'on édite la description, on désactive les autres objets
+ disableObjects()
+
+ editDescription = true
+
+ -- on place l'écran grisé devant les objets désactivés
+ ticket.block.y = CY
+ ticket.block:toFront()
+
+ -- on fait descendre la textBox
+ transition.to( description, { time = 400, y = ticket.boutonType.y + ticket.boutonType.height/2, transition = easing.outBounce } )
+ transition.to( descr, { time = 400, x = SX - descr.width, transition = easing.outBounce } )
+ transition.to( textDescr, { time = 400, x = SX - textDescr.width, transition = easing.outBounce } )
+
+ -- on place le label Valider
+ ticket.labelValider.y = ticket.boutonType.y + ticket.boutonType.height*1.9
+ ticket.labelValider:toFront()
+
+ -- la textBox a le focus du clavier
+ native.setKeyboardFocus( description )
+
+ end
+
+ end
+
+ ticket:insert( descr )
+ ticket.descr = descr
+
+ isDescriptionActive = true
+
+ ticket:insert( textDescr )
+ ticket.textDescr = textDescr
+
+end
+-- fin description
+
+-- Initialisation du nombre de tickets restants
+
+local function initRestants()
+
+end
+
+local function displayHint()
+
+ native.showAlert( "Hâlte-là !", "Veuillez renseigner les informations obligatoires.", { "D'accord :)", "D'accord :(" } )
+
+end
+
+local function envoiCallback( event )
+
+if ( event.isError ) then
+ print("Network error!")
+ native.showAlert( "Erreur réseau.", "Veuillez vérifier votre connexion internet." )
+ else
+ print("RESPONSE:" .. event.response)
+ local data = json.decode(event.response)
+
+ if (data.result == 200) then
+ print("Le ticket a bien été envoyé. Le client est débité d'un crédit sur son nombre de tickets restants (auto en php)")
+
+ elseif (data.result == 400) then
+ print ("Plus de ticket restant.")
+
+ elseif (data.result == 403) then
+ print ("Une erreur mysql est survenue.")
+
+ end
+end
+
+end
+
+local function sendAll()
+
+ print("T : "..prioriteT)
+ print("64 : "..priorite64)
+ local url = "http://tup.url.ph/app/uploadTicket.php?mail="..mime.b64(mail).."&objet="..categorie64.."&type="..type64.."&priorite="..priorite64.."&adresse="..adresse64.."&description="..description64.."&img="..photoName.."&coord="..coord64
+ network.request( url, "GET", envoiCallback )
+
+end
+
+local function uploadListener( event )
+
+ if ( event.isError ) then
+
+ print( "Network Error." )
+
+ -- This is likely a time out or server being down. In other words,
+ -- It was unable to communicate with the web server. Now if the
+ -- connection to the web server worked, but the request is bad, this
+ -- will be false and you need to look at event.status and event.response
+ -- to see why the web server failed to do what you want.
+
+ else
+
+ if ( event.phase == "began" ) then
+ print( "Upload started" )
+ elseif ( event.phase == "progress" ) then
+ print( "Uploading... bytes transferred ", event.bytesTransferred )
+ elseif ( event.phase == "ended" ) then
+ print( "Upload ended..." )
+ print( "Status:", event.status )
+ print( "Response:", event.response )
+ photoName = event.response
+
+ print("Upload de l'image terminé, on envoit les informations du ticket")
+
+ sendAll()
+ end
+ end
+end
+
+local function uploadImage()
+
+ local url = "http://tup.url.ph/uploadImage.php"
+ local method = "PUT"
+
+ local params = {
+ timeout = 60,
+ progress = true,
+ bodyType = "binary"
+ }
+
+ local filename = "photo.jpg"
+ local baseDirectory = system.TemporaryDirectory
+ local contentType = "image/jpeg"
+
+ local headers = {}
+ headers.filename = filename
+ params.headers = headers
+
+ network.upload( url , method, uploadListener, params, filename, baseDirectory, contentType )
+
+end
+
+-- Initialisation du bouton d'envoi
+
+local function initEnvoyer()
+
+ local z = SY + VH - ticket.border2.height - ( ticket.adresseBg.y + ticket.adresseBg.height )
+
+ local boutonEnvoyer = display.newCircle( 0, 0, z/2 - z/6 )
+ boutonEnvoyer:setFillColor( .2, .8, .4, .9 )
+
+ boutonEnvoyer.x = VW + 40
+ boutonEnvoyer.y = ticket.descr.y + ticket.descr.height/2
+
+ boutonEnvoyer.strokeWidth = 3
+ boutonEnvoyer:setStrokeColor( 249/255, 249/255, 244/255 )
+
+ -- fonction d'action du bouton envoyer le ticket
+ function boutonEnvoyer:touch( event )
+
+ if event.phase == "began" and isEnvoyerActive then
+
+ -- si les champs obligatoires sont remplis
+ if isTypeChosen and isAddressWritten then
+
+ photo64 = mime.b64( photoT )
+ priorite64 = mime.b64( prioriteT )
+ categorie64 = mime.b64( categorieT )
+ type64 = mime.b64( typeT )
+ adresse64 = mime.b64( adresseT )
+ description64 = mime.b64( descriptionT )
+ coord64 = mime.b64( coordT )
+
+ print("photo"..photo64)
+ print("prio"..priorite64)
+ print("cat"..categorie64)
+ print("type"..type64)
+ print("adresse"..adresse64)
+ print("descr"..description64)
+ print("coord"..coord64)
+
+ print("prioriteT : "..prioriteT)
+ priorite64 = mime.b64( prioriteT )
+
+ -- On commence d'abords par upload l'image si la personne a pris une photo
+ if (isPhotoTaken == true) then
+ print(" On commence l'upload de l'image")
+ uploadImage()
+ else -- si la personne n'a pas pris de photo on envoie simplement les données relatives au ticket
+ sendAll()
+ end
+
+ if ticket.map then
+
+ ticket.map:removeSelf()
+ ticket.map = nil
+
+ end
+
+ Runtime:dispatchEvent{ name = "MenuEvent", type = "accueil" }
+ native.showAlert( "Merci !", "Votre ticket a bien été envoyé.", { "De rien :)" } )
+
+ -- sinon on affiche des messages en rouge
+ else displayHint() end
+
+ end
+
+ end
+
+ --boutonEnvoyer:addEventListener( "touch", boutonEnvoyer )
+
+ ticket:insert( boutonEnvoyer )
+ ticket.boutonEnvoyer = boutonEnvoyer
+
+ isEnvoyerActive = true
+
+ local suivant = display.newImage( "next.png", 0, 0 )
+
+ suivant.x = boutonEnvoyer.x
+ suivant.y = boutonEnvoyer.y
+
+ suivant.width = 42
+ suivant.height = 42
+
+ suivant.rotation = 45
+
+ ticket:insert( suivant )
+ ticket.suivant = suivant
+
+end
+
+-- Mettre à jour le type du ticket (passé en paramètre)
+
+function changeType( event )
+
+ if ( event.choice ~= nil ) then
+
+ ticket.labelType:setFillColor( 0, 0, 0, 0 )
+ ticket.textType.text = event.choice
+ ticket.textType:setFillColor( 0, 0, 0, 1 )
+ ticket.categorie.text = event.category.." :"
+
+ categorieT = event.category
+ typeT = event.choice
+
+ ticket.placeholder.x = CX
+ ticket.placeholder.y = ticket.boutonType.y + ticket.boutonType.height
+
+ ticket.map.x = CX
+ ticket.map.y = ticket.boutonType.y + ticket.boutonType.height
+
+ isTypeChosen = true
+
+ end
+
+end
+
+local function getMail()
+
+ local path = system.pathForFile( "login.sqlite", system.DocumentsDirectory )
+ db = sqlite3.open( path )
+
+ local sql = "select * from log"
+
+ for row in db:nrows(sql) do
+
+ mail = row.mail
+
+ end
+
+ db:close()
+
+end
+
+function ticket:disposeElements()
+
+ transition.to( ticket.topTitle, { time = 900, y = SY + 5, transition = easing.outBounce } )
+ transition.to( ticket.prioriteL, { time = 800, y = SY + 95, transition = easing.outBounce } )
+ transition.to( ticket.prioriteM, { time = 900, y = SY + 95, transition = easing.outBounce } )
+ transition.to( ticket.prioriteH, { time = 1000, y = SY + 95, transition = easing.outBounce } )
+ transition.to( ticket.boutonPhoto, { time = 550, x = SX + 20, transition = easing.outQuad } )
+ transition.to( ticket.icon, { time = 550, x = SX + ticket.boutonPhoto.width/2 + 20, transition = easing.outQuad } )
+
+ transition.to( ticket.map, { time = 700, x = CX, transition = easing.outExpo } )
+ transition.to( ticket.placeholder, { time = 700, x = CX, transition = easing.outExpo } )
+
+ transition.to( ticket.adresseBg, { time = 500, x = SX, transition = easing.outExpo } )
+ transition.to( ticket.adresse, { time = 500, x = SX, transition = easing.outExpo } )
+ transition.to( ticket.boutonLocaliser, { time = 500, x = SX + VW - ticket.boutonLocaliser.width, transition = easing.outExpo } )
+ transition.to( ticket.descr, { time = 500, x = SX - 4, transition = easing.outExpo } )
+ transition.to( ticket.textDescr, { time = 550, x = SX + 10, transition = easing.outQuad } )
+ transition.to( ticket.boutonRetour, { time = 550, x = ticket.border2.x, transition = easing.outQuad } )
+ transition.to( ticket.labelRetour, { time = 650, x = SX + ticket.boutonRetour.width/2, transition = easing.outQuad } )
+
+ local k = SY + VH - ticket.border2.height
+ local l = SY + ticket.adresseBg.y + ticket.adresseBg.height
+ local z = VW - ( k - l )/2
+
+ transition.to( ticket.boutonEnvoyer, { time = 800, x = z, transition = easing.outCirc } )
+ transition.to( ticket.suivant, { time = 800, x = z, transition = easing.outCirc } )
+
+ local function decreaseAngle() ticket.suivant:rotate( -1 ) end
+
+ for i = 1, 45 do timer.performWithDelay( i*16, decreaseAngle ) end
+
+end
+
+local function onKeyEvent( event )
+
+ if (event.keyName == "back") and (system.getInfo("platformName") == "Android") then
+ return true
+ end
+
+ return false
+
+end
+
+function enableBoutonRetour()
+
+ ticket.boutonRetour:addEventListener( "touch", boutonRetour )
+
+end
+
+-- Mise en place des listeners sur le ticket
+
+function ticket:enableListeners()
+
+ ticket.boutonPhoto:addEventListener( "touch", boutonPhoto )
+ ticket.prioriteL:addEventListener( "touch", prioriteL )
+ ticket.prioriteM:addEventListener( "touch", prioriteM )
+ ticket.prioriteH:addEventListener( "touch", prioriteH )
+ ticket.boutonType:addEventListener( "touch", boutonType )
+ ticket.adresseBg:addEventListener( "touch", adresseBg )
+ ticket.boutonLocaliser:addEventListener( "touch", boutonLocaliser )
+ ticket.descr:addEventListener( "touch", descr )
+ ticket.block:addEventListener( "touch", block )
+ ticket.boutonEnvoyer:addEventListener( "touch", boutonEnvoyer )
+
+ ticket:addEventListener( "key", onKeyEvent )
+ Runtime:addEventListener( "MenuEvent", changeType )
+
+ -- on active le bouton retour un peu après pour éviter des conflits de chargement
+ timer.performWithDelay( 500, enableBoutonRetour )
+
+end
+
+-- Suppression des listeners du ticket
+
+function ticket:disableListeners()
+
+ ticket.boutonPhoto:removeEventListener( "touch", boutonPhoto )
+ ticket.prioriteL:removeEventListener( "touch", prioriteL )
+ ticket.prioriteM:removeEventListener( "touch", prioriteM )
+ ticket.prioriteH:removeEventListener( "touch", prioriteH )
+ ticket.boutonType:removeEventListener( "touch", boutonType )
+ ticket.adresseBg:removeEventListener( "touch", adresseBg )
+ ticket.boutonLocaliser:removeEventListener( "touch", boutonLocaliser )
+ ticket.descr:removeEventListener( "touch", descr )
+ ticket.boutonEnvoyer:removeEventListener( "touch", boutonEnvoyer )
+ ticket.boutonRetour:removeEventListener( "touch", boutonRetour )
+
+ Runtime:removeEventListener( "MenuEvent", changeType )
+
+end
+
+-- Initialisation du ticket
+
+local function init()
+
+ initFond()
+ initBorders()
+ initPhoto()
+ initPriorite()
+ initType()
+ initMap()
+ initDescription()
+ initEnvoyer()
+ initRestants()
+ initCircles()
+ ticket:disposeElements()
+
+ getMail()
+
+end
+
+init()
+ticket:enableListeners()
+--ticket.map.isHitTestable = false
+
+return ticket
+
+end
+
+return Ticket
\ No newline at end of file
--- /dev/null
+-- main.lua
+
+-- Masquer barre de statut
+
+-- iOS & Android 2.X
+display.setStatusBar(display.HiddenStatusBar)
+-- Android 3.X
+UIStatusBarHidden = true
+
+-- Chargement des modules
+
+local sqlite3 = require( "sqlite3" )
+local composer = require( "composer" )
+
+-- Changements de scènes
+
+local function onMenuEvent( event )
+
+ if (event.type == "connexion") then
+ composer.gotoScene( "Ecran_Connexion", "flip", 100 )
+
+ elseif (event.type == "inscription") then
+ composer.gotoScene( "Ecran_Inscription", "flip", 100 )
+
+ elseif (event.type == "accueil") then
+ composer.gotoScene( "Ecran_Accueil", "crossFade", 200 )
+
+ elseif (event.type == "accueilSlideRight") then
+ composer.gotoScene( "Ecran_Accueil", "slideRight", 200 )
+
+ elseif (event.type == "accueilSlideLeft") then
+ composer.gotoScene( "Ecran_Accueil", "slideLeft", 200 )
+
+ elseif (event.type == "ticket") then
+ composer.gotoScene( "Ecran_Ticket", "slideLeft", 250 )
+
+ elseif (event.type == "ticketTop") then
+ composer.gotoScene( "Ecran_Ticket", "slideUp", 250 )
+
+ elseif (event.type == "listetype") then
+ composer.gotoScene( "Ecran_ListeType", "fromTop", 350 )
+
+ elseif (event.type == "listetickets") then
+ composer.gotoScene( "Ecran_ListeTickets", "slideLeft", 200 )
+
+ elseif (event.type == "gestionProfil") then
+ composer.gotoScene( "Ecran_Gestion", "slideLeft", 200 )
+
+ end
+
+end
+
+-- Gestion des redirections d'accueil de l'utilisateur :
+
+ -- inscrit et connecté -> accueil
+ -- inscrit et non connecté -> connexion
+ -- non incrit -> inscription
+
+local function doesIdExist()
+
+ local filePath = system.pathForFile( "login.sqlite", system.DocumentsDirectory )
+ print(filePath)
+
+ -- Si le fichier de connexion existe, il est ouvert
+ if (filePath) then filePath = io.open( filePath, "r" ) end
+
+ -- Si le fichier de connexion est ouvert
+ if (filePath) then
+
+ print("Le fichier de login a été trouvé.")
+ filePath:close()
+
+ -- Vérification de la persistance : ouverture du fichier avec sqlite
+ local path = system.pathForFile( "login.sqlite", system.DocumentsDirectory )
+ local sql = "select * from log"
+ local persistance = 0
+
+ db = sqlite3.open( path )
+
+ for row in db:nrows( sql ) do persistance = row.persistance end
+
+ db:close()
+
+ -- Si l'utilisateur est déjà connecté on va à l'accueil
+ if (persistance == 1) then
+ composer.gotoScene( "Ecran_Accueil" )
+
+ -- Sinon il doit se connecter
+ else
+ composer.gotoScene( "Ecran_Connexion" )
+
+ end
+
+ -- Si le fichier de connexion n'existe pas, l'utilisateur doit s'inscrire
+ else composer.gotoScene( "Ecran_Inscription" )
+
+ end
+
+end
+
+-- Ajout de l'écouteur d'événement sur le menu
+
+Runtime:addEventListener( "MenuEvent", onMenuEvent )
+
+-- Durée d'affichage du splash screen : 2 secondes
+
+while (system.getTimer() < 800) do end
+
+doesIdExist()
\ No newline at end of file