Index: locale/en/mlx.po
===================================================================
--- locale/en/mlx.po	(revision 848)
+++ locale/en/mlx.po	(revision 853)
@@ -2100,4 +2100,7 @@
 msgstr ""
 "The delay codes set. You should edit them in the 'Comments & defects' tab at the bottom."
+
+msgid "pirepEdit_save_question"
+msgstr "Are you sure to save the PIREP modifications?"
 
 msgid "about_website"
Index: locale/hu/mlx.po
===================================================================
--- locale/hu/mlx.po	(revision 848)
+++ locale/hu/mlx.po	(revision 853)
@@ -2115,4 +2115,7 @@
 msgstr ""
 "A megadott késési kódok. Szerkeszteni a 'Megjegyzések és hibák' fül alsó részén tudod."
+
+msgid "pirepEdit_save_question"
+msgstr "Biztosan el szeretnéd menteni a PIREP módosításait?"
 
 msgid "about_website"
Index: src/mlx/gui/gui.py
===================================================================
--- src/mlx/gui/gui.py	(revision 845)
+++ src/mlx/gui/gui.py	(revision 853)
@@ -1266,5 +1266,47 @@
         self._pirepEditor.setPIREP(pirep)
         self._pirepEditor.show_all()
-        self._pirepEditor.run()
+        if self._pirepEditor.run()==RESPONSETYPE_OK:
+            self.beginBusy(xstr("pirepEdit_save_busy"))
+            self.webHandler.sendPIREP(self._pirepUpdatedCallback, pirep,
+                                      update = True)
+        else:
+            self._pirepEditor.hide()
+
+    def _pirepUpdatedCallback(self, returned, result):
+        """Callback for the PIREP updating result."""
+        gobject.idle_add(self._handlePIREPUpdated, returned, result)
+
+    def _handlePIREPUpdated(self, returned, result):
+        """Callback for the PIREP updating result."""
+        self.endBusy()
+        secondaryMarkup = None
+        type = MESSAGETYPE_ERROR
+        if returned:
+            if result.success:
+                type = None
+            elif result.alreadyFlown:
+                messageFormat = xstr("sendPIREP_already")
+                secondaryMarkup = xstr("sendPIREP_already_sec")
+            elif result.notAvailable:
+                messageFormat = xstr("sendPIREP_notavail")
+            else:
+                messageFormat = xstr("sendPIREP_unknown")
+                secondaryMarkup = xstr("sendPIREP_unknown_sec")
+        else:
+            print "PIREP sending failed", result
+            messageFormat = xstr("sendPIREP_failed")
+            secondaryMarkup = xstr("sendPIREP_failed_sec")
+
+        if type is not None:
+            dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
+                                       type = type, message_format = messageFormat)
+            dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
+            dialog.set_title(WINDOW_TITLE_BASE)
+            if secondaryMarkup is not None:
+                dialog.format_secondary_markup(secondaryMarkup)
+
+            dialog.run()
+            dialog.hide()
+
         self._pirepEditor.hide()
 
Index: src/mlx/gui/pirep.py
===================================================================
--- src/mlx/gui/pirep.py	(revision 849)
+++ src/mlx/gui/pirep.py	(revision 853)
@@ -720,7 +720,9 @@
         self.add_button(xstr("button_cancel"), RESPONSETYPE_CANCEL)
 
-        self._okButton = self.add_button(xstr("button_save"), RESPONSETYPE_OK)
+        self._okButton = self.add_button(xstr("button_save"), RESPONSETYPE_NONE)
+        self._okButton.connect("clicked", self._okClicked)
         self._okButton.set_can_default(True)
         self._modified = False
+        self._toSave = False
 
     def setPIREP(self, pirep):
@@ -846,4 +848,5 @@
         self._updateButtons()
         self._modified = True
+        self._toSave = False
 
     def delayCodesChanged(self):
@@ -1363,3 +1366,58 @@
                                      self._approachType.get_text()!="")
 
+    def _okClicked(self, button):
+        """Called when the OK button has been clicked.
+
+        The PIREP is updated from the data in the window."""
+        if not askYesNo(xstr("pirepEdit_save_question"), parent = self):
+            self.response(RESPONSETYPE_CANCEL)
+
+        pirep = self._pirep
+
+        pirep.filedCruiseAltitude = \
+          self._filedCruiseLevel.get_value_as_int() * 100
+        pirep.cruiseAltitude = \
+          self._modifiedCruiseLevel.get_value_as_int() * 100
+
+        pirep.route = getTextViewText(self._userRoute)
+
+        pirep.departureMETAR = getTextViewText(self._departureMETAR)
+        pirep.departureRunway = self._departureRunway.get_text()
+        pirep.sid = self._sid.get_child().get_text()
+
+        pirep.arrivalMETAR = getTextViewText(self._arrivalMETAR)
+        pirep.star = None if self._star.get_active()==0 \
+          else self._star.get_child().get_text()
+        pirep.transition = None if self._transition.get_active()==0 \
+          else self._transition.get_child().get_text()
+        pirep.approachType = self._approachType.get_text()
+        pirep.arrivalRunway = self._arrivalRunway.get_text()
+
+        pirep.blockTimeStart = \
+          self._blockTimeStart.getTimestampFrom(pirep.blockTimeStart)
+        pirep.blockTimeEnd = \
+          self._blockTimeEnd.getTimestampFrom(pirep.blockTimeEnd)
+        pirep.flightTimeStart = \
+          self._flightTimeStart.getTimestampFrom(pirep.flightTimeStart)
+        pirep.flightTimeEnd = \
+          self._flightTimeEnd.getTimestampFrom(pirep.flightTimeEnd)
+
+        pirep.fuelUsed = self._fuelUsed.get_value()
+
+        pirep.numCrew = self._flownNumCrew.get_value()
+        pirep.numPassengers = self._flownNumPassengers.get_value()
+        pirep.bagWeight = self._flownBagWeight.get_value()
+        pirep.cargoWeight = self._flownCargoWeight.get_value()
+        pirep.mailWeight = self._flownMailWeight.get_value()
+
+        pirep.flightType = flightTypes[self._flightType.get_active()]
+        pirep.online = self._online.get_active()
+
+        pirep.delayCodes = self._flightInfo.delayCodes
+        pirep.comments = self._flightInfo.comments
+        pirep.flightDefects = self._flightInfo.faultsAndExplanations
+
+        self.response(RESPONSETYPE_OK)
+
+
 #------------------------------------------------------------------------------
Index: src/mlx/rpc.py
===================================================================
--- src/mlx/rpc.py	(revision 829)
+++ src/mlx/rpc.py	(revision 853)
@@ -321,9 +321,10 @@
                                                    status, gateNumber))
 
-    def addPIREP(self, flightID, pirep):
+    def addPIREP(self, flightID, pirep, update = False):
         """Add the PIREP for the given flight."""
         (result, _value) = \
           self._performCall(lambda sessionID:
-                            self._server.addPIREP(sessionID, flightID, pirep),
+                            self._server.addPIREP(sessionID, flightID, pirep,
+                                                  update),
                             acceptResults = [Client.RESULT_FLIGHT_ALREADY_REPORTED,
                                              Client.RESULT_FLIGHT_NOT_EXISTS])
Index: src/mlx/web.py
===================================================================
--- src/mlx/web.py	(revision 829)
+++ src/mlx/web.py	(revision 853)
@@ -1144,13 +1144,15 @@
     """A request to send a PIREP to the MAVA website via the RPC interface."""
 
-    def __init__(self, client, callback, pirep):
+    def __init__(self, client, callback, pirep, update):
         """Construct the sending of the PIREP."""
         super(SendPIREPRPC, self).__init__(client, callback)
         self._pirep = pirep
+        self._update = update
 
     def run(self):
         """Perform the sending of the PIREP."""
         pirep = self._pirep
-        resultCode = self._client.addPIREP(pirep.bookedFlight.id, pirep)
+        resultCode = self._client.addPIREP(pirep.bookedFlight.id, pirep,
+                                           self._update)
 
         result = Result()
@@ -1286,5 +1288,5 @@
         print "pirepData:", pirepData
 
-        bookedFlight = BookedFlight()
+        bookedFlight = BookedFlight(self._flightID)
         bookedFlight.setupFromPIREPData(pirepData)
 
@@ -1382,9 +1384,9 @@
         self._addRequest(GetMETARs(callback, airports))
 
-    def sendPIREP(self, callback, pirep):
+    def sendPIREP(self, callback, pirep, update = False):
         """Send the given PIREP."""
         request = \
-          SendPIREPRPC(self._rpcClient, callback, pirep) if self._config.useRPC \
-          else SendPIREP(callback, pirep)
+          SendPIREPRPC(self._rpcClient, callback, pirep, update) \
+          if self._config.useRPC else SendPIREP(callback, pirep)
         self._addRequest(request)
 
