Function tfgSendToUfgApi
This function is run internally on the server by cron
(scripts/runTfgReportsSend.php, together with tfgSyncFeedStatus) and is
not intended to be called by the API client. For client-side scenarios use
tfgResendReservation (manual re-send of a single reservation) or
tfgGetReportFiles (manual mode โ generate downloadable files).
Sends the TFG/UFG "wykaz umรณw" directly to the TFG REST API (channel API).
It resolves the requested reservations (empty list = whole branch scope), intersects them
with the reporting scope and branch, determines the operation per reservation, logs in
(POST /login โ Bearer token), and uploads one reservation per feed
(1 reservation = 1 feed) as multipart/form-data
(POST /tfg/api/v1/pt/feeds) so that validation status/errors map cleanly to a
single ID_R2. The required order is respected:
NOWEDANE before KOREKTA / ROZWIAZANIE / USUNIECIE
(gated on the prior feed reaching SEND_STATUS='api-ok').
On acceptance R2_TFG_REPORTS.SEND_STATUS is set to api-pending-1
(confirmed later by tfgSyncFeedStatus); otherwise api-error.
Every HTTP request (LOGIN, FEED_SEND) is logged as a separate row
in TFG_EXT_API_LOG (password masked for LOGIN), and each run is
summarized in TFG_REPORTS_HISTORY.
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 (disabled), manual
(client uploads files generated via tfgGetReportFiles),
tfg-api (this API sending). If it is not tfg-api, the function
returns immediately with status = SKIPPED (no login, no TFG_EXT_API_LOG
entries, no state changes). 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 (e.g. testhttps://tfg.api.test.ufg.pl:9015)tfg-export-user-loginโ API user logintfg-export-user-passwordโ API user passwordtfg-export-certโ client certificate, base64-encoded.p12(mTLS)tfg-export-cert-passโ certificate (key) password
url/login/password are empty the function returns
error 400003. Production access additionally requires the client certificate and a fixed IP.
Intended to run from cron via runTfgReportsSend.php.
Arguments
- params :
array ( [ 'idCompany' ] = '' // REQUIRED, branch id (= R2.ID_FIRMY) [ 'idReservations' ] = array(...) // list of ID_R2 (OR) [ 'webIds' ] = array(...) // list of R2.WEB_ID )
Returns
status-OK|PARTIAL|FAIL|SKIPPED(whentfg-export-modeโtfg-api)idCompany- the branch id usedsummary- counters incl. POMIN / ERROR / GATEDresults- per reservation:{ idR2, operacja, feedNumber, status }feeds- per uploaded feed: operationType, correctionReason, httpCode, feedNumber, status, rawerrors- 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 [ 'idReservations' ] = array( 446 ) ; $ret = $udds->tfgSendToUfgApi ( $yourParams ) ;
Returns $ret =
array ( 'status' => 'OK', 'idCompany' => '21624', 'results' => array ( array ( 'idR2'=>446, 'operacja'=>'NOWEDANE', 'feedNumber'=>'N-A-2026-197', 'status'=>'ACCEPTED' ) ), 'feeds' => array ( array ( 'operationType'=>'NOWEDANE', 'feedNumber'=>'N-A-2026-197', 'status'=>'ACCEPTED', ... ) ), 'errors' => array (), )