mirror of
https://codeberg.org/artfulrobot/contactcats.git
synced 2025-06-25 23:58:04 +02:00
Checkin, fairly stable
This commit is contained in:
parent
f88fb5f10e
commit
eb6542857b
5 changed files with 161 additions and 119 deletions
|
@ -3,6 +3,7 @@ namespace Civi\Api4\Action\ContactCategory;
|
|||
|
||||
use CRM_Contactcats_ExtensionUtil as E;
|
||||
use Civi;
|
||||
use Civi\Api4\ContactCategoryDefinition;
|
||||
use Civi\Api4\Generic\Result;
|
||||
use CRM_Core_DAO;
|
||||
use CRM_Core_Exception;
|
||||
|
@ -296,10 +297,16 @@ class GetFlows extends \Civi\Api4\Generic\AbstractAction {
|
|||
2 => [$endDateYmd, 'Int'],
|
||||
])->fetchAll();
|
||||
|
||||
// It's possible to end up with NULLs at the startSide.
|
||||
// These should be replaced with our default category.
|
||||
$defaultCategoryId = ContactCategoryDefinition::get()
|
||||
->addWhere('search_type:name', '=', 'default')
|
||||
->execute()->first()['id'];
|
||||
|
||||
// Don't use exchange array so as not to gazump non-array data(?)
|
||||
foreach ($data as $row) {
|
||||
$result[] = [
|
||||
'from_category_id' => (int) $row['from_category_id'],
|
||||
'from_category_id' => (int) (($row['from_category_id']) ?: $defaultCategoryId),
|
||||
'to_category_id' => (int) $row['to_category_id'],
|
||||
'contact_count' => (int) $row['contact_count'],
|
||||
];
|
||||
|
@ -313,8 +320,8 @@ class GetFlows extends \Civi\Api4\Generic\AbstractAction {
|
|||
try {
|
||||
$data = CRM_Core_DAO::executeQuery($sql, $params)->fetchAll();
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
print $e->getCause()->userinfo;
|
||||
catch (\CRM_Core_Exception $e) {
|
||||
if (method_exists('getClause', $e)) print $e->getCause()->userinfo;
|
||||
}
|
||||
print "\n$msg (" . count($data) . ") records ===============================\n";
|
||||
foreach ($data as $row) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue