Skip to content

Commit 8f5a8c5

Browse files
committed
Updated readme
1 parent dfe9c1b commit 8f5a8c5

1 file changed

Lines changed: 62 additions & 3 deletions

File tree

README.md

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ $line->inventoryBatch = $batch;
249249

250250
## Transactions
251251

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 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.
253253

254254
Note: The transaction service was introduced in Pace 29.0-1704.
255255

@@ -281,7 +281,7 @@ $pace->transaction(function () use ($pace) {
281281

282282
### Using transactions manually
283283

284-
Alternatively, you may call the `startTransaction()`, `rollbackTransaction()` and `commitTransaction()` methods manually.
284+
Alternatively, you can call the `startTransaction()`, `rollbackTransaction()` and `commitTransaction()` methods manually.
285285

286286
```php
287287
$pace->startTransaction();
@@ -300,7 +300,7 @@ if ($csr->id == 666) {
300300

301301
## JSON
302302

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.
304304

305305
```php
306306
// 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
350350
$attachment->getContent();
351351
```
352352

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') {
397+
file_put_contents('report.xls', $file->getContent());
398+
}
399+
```
400+
401+
### Printing the report
402+
403+
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+
353412
## Version
354413

355414
Identify the version of Pace running on the server.

0 commit comments

Comments
 (0)