Home /Tutorials /Retrieving report information
Retrieving report information

Each report in WellnessLiving returns a different set of information. This tutorial will show some examples of the pertinent data reports can return.

The All Sales Report is an example of a WellnessLiving report containing information about all purchases made in a business. The report can be filtered to return results for specified dates and date ranges.

// Retrieve the All Sales Report.
$o_report=new DataModel($o_config);
$o_report->cookieSet($o_notepad->cookieGet()); // Store cookies to maintain the session.

// Set the values.
$o_report->id_report_group=WlReportGroupSid::MONTH;
$o_report->id_report=WlReportSid::PURCHASE_ITEM_ACCRUAL_CASH;
$o_report->k_business='2149'; // Put your business key here.

// Set the filter to a specific date.
$o_report->filterSet([
  'dt_date' => '2020-01-01'
]);

// Perform the request.
$o_report->get();

// The example code will return each item name, purchase cost, purchase name, purchaser name, and purchaser UID.
$i=0;
foreach($o_report->a_data['a_row'] as $a_row)
{
  $i++;
  echo $i.'. '.$a_row['dt_date'].' '.$a_row['f_total']['m_amount'].' '.$a_row['o_user']['text_name'].' '.$a_row['s_item']."\r\n";
}

The All Clients Report returns a list of all clients of a business. Keep in mind that there are two different versions of the All Clients Report available through the SDK. The first version of the report can be accessed in WellnessLiving by selecting Clients in the App Drawer, which returns a list of all a business’s clients. Clients can be filtered by client type or location.

// Retrieve the All Clients Report.
$o_report=new \WellnessLiving\Wl\Report\DataModel($o_config);
$o_report->cookieSet($o_notepad->cookieGet()); // Store cookies to maintain the session.

// Set the values.
$o_report->id_report_group=WlReportGroupSid::MONTH;
$o_report->id_report=WlReportSid::LOGIN_LIST_ALL;
$o_report->k_business='45740'; // Put your business key here.

// Filter for active pass holders, active members, and any locations.
$o_report->filterSet([
  'a_login_type' => ['223324','223323'],
  'k_location' => ''
]);

// The example code will return each client's, first name, last name, UID, member ID, and email.
$o_report->get();
$i=0;
foreach($o_report->a_data['a_row'] as $a_row)
{
  $i++;
  printf("%3d %3s %15s %15s %15s %s\r\n",$i,$a_row['uid'],$a_row['a_data_api']['s_firstname'],$a_row['a_data_api']['s_lastname'],$a_row['member'],$a_row['a_data_api']['s_mail']);}

The second version of the All Clients Report can be accessed by selecting Reports in the App Drawer and then selecting the All Clients Report from the Clients report group. This returns a list of a business’s clients filtered by their join date.

// Retrieve the client information for specific dates.
$o_report = new \WellnessLiving\Wl\Report\DataModel($o_config);
$o_report->cookieSet($o_notepad->cookieGet()); // Store cookies to maintain the session.

$o_report->id_report=\WellnessLiving\Wl\Report\WlReportSid::LOGIN_LIST;
$o_report->k_business='2'; // Put your business key here.

// Set the filter to a specific date.
$o_report->filterSet([
 'dt_date' => '2020-01-01',
 'sid_report_date' => 'month' // The range of results to return. Values will be for the specified month (January in this case). Values are the names of the WlReportGroupSid constants using lowercase.
]);

// Perform the request.
$o_report->get();

// The example code will return each client's first name, last name, email, and join date.
$i=0;
foreach($o_report->a_data['a_row'] as $a_row)
{
 $i++;
 echo $i.'. '.$a_row['a_data_api']['s_firstname'].' '.$a_row['a_data_api']['s_lastname'];
 echo '    '.$a_row['a_data_api']['s_mail'].'    '.$a_row['dt_since_local']['dt_date']."\n";
}

The Batch Report will show all the credit card transactions made on a given date. Credit card transactions are usually batched and sent to the payment processor before the funds are made available to the business.

// Retrieve the Batch Report.
$o_report=new \WellnessLiving\Wl\Report\DataModel($o_config);
$o_report->cookieSet($o_notepad->cookieGet()); // Store cookies to maintain the session.

$o_report->id_report=WlReportSid::PAY_TRANSACTION_BATCH;
$o_report->k_business='49344'; // Put your business key here.
$o_report->filterSet([
// This date is used to specify the day in question.
'dt_date' => '2023-03-21',
]);

$o_report->get();

// The example code will return each batch record's date, amount, card system, and attached note (if applicable).
$i=0;
foreach($o_report->a_data['a_row'] as $a_row)
{
 $i++;

// Print the date, amount, and type of transaction in the Batch Report.
echo $i.' '.$a_row['dt_date'].' '.$a_row['f_debit']['m_amount'].' '.$a_row['s_card_system']['text_text']."\n";
}