Function tfgResendReservation

Manually re-sends a single reservation to TFG through the API channel โ€” meant to be triggered from the application by an operator (e.g. after a connection error or an unclear feed state). Unlike the cron function tfgSendToUfgApi, this endpoint does not apply the prior-status gating (isGatedByPriorStatus): it is a deliberate single action and the correct operation ordering is validated by TFG itself.

Flow:

  • Phase A (verify): if the reservation already has a LAST_FEED_NUMBER and a non-final SEND_STATUS (api-pending-1 / api-pending-2 / api-error), it calls GET /tfg/api/v1/pt/feeds/{feedNumber} and refreshes the local state (this alone may resolve the case โ€” e.g. TFG had actually accepted the feed despite our timeout โ†’ api-ok).
  • Phase B (act): resolveOperation on the refreshed state โ†’ NOWEDANE / KOREKTA / ROZWIAZANIE โ†’ POST /tfg/api/v1/pt/feeds (1 contract). If the resolver returns POMIN there is nothing new to send (e.g. a correction was rejected asynchronously โ€” the operator must fix the reservation data, which creates a new snapshot, before a resend makes sense).

Every HTTP request to TFG (LOGIN, FEED_STATUS, FEED_SEND) is recorded as a separate row in TFG_EXT_API_LOG (with ID_R2). The action is also logged to TFG_REPORTS_HISTORY with TYP='RESEND_API'.

โš ๏ธ
Required configuration

Enable switch (required): tfg-export-mode (API โ†’ konfiguracja โ†’ rezerwacje โ†’ tfg-export-mode, read as userDBConfig['api']['reservation']['tfg-export-mode']) must be set to tfg-api. Values: off / manual / tfg-api. If it is not tfg-api, the function returns immediately with status = SKIPPED. This parameter is instance-wide (no branch suffix).

TFG auth (required, per branch) โ€” loaded from CRMParameters (DIC_PARAMETRY, category API โ†’ konfiguracja โ†’ rezerwacje, keys suffixed with :idCompany):

  • tfg-export-api-url โ€” TFG API base URL
  • tfg-export-user-login โ€” API user login
  • tfg-export-user-password โ€” API user password
  • tfg-export-cert โ€” client certificate, base64-encoded .p12 (mTLS)
  • tfg-export-cert-pass โ€” certificate (key) password
If url/login/password are empty the function returns error 400003.

Arguments

  • params :
        array (
              [ 'idCompany' ]     = ''    // REQUIRED, branch id (= R2.ID_FIRMY, scope)
              [ 'idReservation' ] = 0     // single ID_R2   (this OR webId is required)
              [ 'webId' ]         = ''    // single R2.WEB_ID
            )
        

Returns

  • status - OK | PARTIAL | FAIL | VERIFIED (only phase A ran, nothing to send) | SKIPPED (when tfg-export-mode โ‰  tfg-api) | OUT_OF_SCOPE (reservation outside TFG reporting scope)
  • idCompany / idR2 - the branch and reservation used
  • verified - phase A result { feedNumber, feedStatus, sendStatus } or null
  • resent - phase B result { operacja, feedNumber, status, sendStatus, idExtApiLog } or null
  • errors - array of error records (code, message)

Example


  require_once ( 'classUddsOx.php' ) ;

  $udds = new classUddsOx ;
  $udds->customerCode = [your_customerCode] ;
  $udds->login = [your_login] ;
  $udds->password = [your_password] ;
  $udds->serverUrl = 'http://api.dlaoperatora.pl/udds/' ;

  $yourParams = array();
  $yourParams [ 'idCompany' ]     = '21624' ;
  $yourParams [ 'idReservation' ] = 446 ;
  $ret = $udds->tfgResendReservation ( $yourParams ) ;


Returns $ret =
array ( 'status' => 'OK', 'idCompany' => '21624', 'idR2' => 446, 'verified' => array ( 'feedNumber'=>'N-A-2026-197', 'feedStatus'=>'ERRONEOUS', 'sendStatus'=>'api-error' ), 'resent' => array ( 'operacja'=>'KOREKTA', 'feedNumber'=>'K-A-2026-231', 'status'=>'ACCEPTED', 'sendStatus'=>'api-pending-1', 'idExtApiLog'=>1284 ), 'errors' => array (), )