You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can wrap your operations in a database transaction so that all calls may be rolled back in the event of an error. Using transactions has the added benefit of delaying any event handlers until all of your API calls are complete.
252
+
You can wrap your operations in a database transaction so that all calls may be rolled back in the event of an error. Using transactions has the added benefit of deferring any event handlers until all of your API calls are complete.
253
253
254
254
Note: The transaction service was introduced in Pace 29.0-1704.
255
255
@@ -281,7 +281,7 @@ $pace->transaction(function () use ($pace) {
281
281
282
282
### Using transactions manually
283
283
284
-
Alternatively, you may call the `startTransaction()`, `rollbackTransaction()` and `commitTransaction()` methods manually.
284
+
Alternatively, you can call the `startTransaction()`, `rollbackTransaction()` and `commitTransaction()` methods manually.
285
285
286
286
```php
287
287
$pace->startTransaction();
@@ -300,7 +300,7 @@ if ($csr->id == 666) {
300
300
301
301
## JSON
302
302
303
-
Both the `Model` and `KeyCollection` classes implemement the `JsonSerializable` interface and casting either class to a string will generate JSON.
303
+
Both the `Model` and `KeyCollection` classes implement the `JsonSerializable` interface and casting either class to a string will generate JSON.
304
304
305
305
```php
306
306
// print a JSON representation of the House account
@@ -350,6 +350,65 @@ Finally, call `getContent()` on a FileAttachment model to read the content of th
350
350
$attachment->getContent();
351
351
```
352
352
353
+
## Reports
354
+
355
+
Fluently run reports using the report builder.
356
+
357
+
### Passing parameters
358
+
359
+
Pass parameters to the report using the ``parameter()`` or ``namedParameter()`` methods. The ``parameter()`` method accepts two arguments: the report parameter ID and the value.
360
+
361
+
```php
362
+
$pace->report(1000)
363
+
->parameter(10001, '2019-12-01')
364
+
->parameter(10002, '2019-12-31')
365
+
->parameter(10003, 'D');
366
+
```
367
+
368
+
The ``namedParameter()`` method looks up the report parameter ID by its name.
369
+
370
+
```php
371
+
$pace->report(1000)
372
+
->namedParameter('Start Date', '2019-12-01')
373
+
->namedParameter('End Date', '2019-12-31')
374
+
->namedParameter('Report Format', 'D');
375
+
```
376
+
377
+
### Reports requiring a base object
378
+
379
+
Some reports require a base object. Use the ``baseObjectKey()`` method to pass a model or primary key.
380
+
381
+
```php
382
+
$job = $pace->model('Job')->read('90000');
383
+
384
+
$pace->report(100)
385
+
->baseObjectKey($job)
386
+
->namedParameter('Include Kit Detail', 'N');
387
+
```
388
+
389
+
### Getting the report
390
+
391
+
The report builder ``get()`` method returns a ``Report\File`` instance, which has two public methods: ``getContent()`` returns the report file content and ``getMediaType()`` returns the media (MIME) type of the file.
392
+
393
+
```php
394
+
$file = $pace->report(200)->get();
395
+
396
+
if ($file->getMediaType() == 'application/vnd.ms-excel') {
Use the ``print()`` method to print the report to the default printer. If the report does not have a default printer configured, the Pace API will throw a SOAP error.
404
+
405
+
```php
406
+
$pace->report(100)
407
+
->baseObjectKey('90000')
408
+
->namedParameter('Include Kit Detail', 'N')
409
+
->print();
410
+
```
411
+
353
412
## Version
354
413
355
414
Identify the version of Pace running on the server.
0 commit comments