|
@@ -42,7 +42,7 @@ class Webservice
|
|
|
|
|
|
/**
|
|
/**
|
|
* Retorna el resultado para utilizar en un choice form field
|
|
* Retorna el resultado para utilizar en un choice form field
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param string $webservice
|
|
* @param string $webservice
|
|
* @param array $params
|
|
* @param array $params
|
|
*
|
|
*
|
|
@@ -63,7 +63,7 @@ class Webservice
|
|
|
|
|
|
/**
|
|
/**
|
|
* Retorna el resultado como un array
|
|
* Retorna el resultado como un array
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param string $webservice
|
|
* @param string $webservice
|
|
* @param array $params
|
|
* @param array $params
|
|
*
|
|
*
|
|
@@ -142,7 +142,7 @@ class Webservice
|
|
|
|
|
|
/**
|
|
/**
|
|
* Similar a getArray pero con mas parametros
|
|
* Similar a getArray pero con mas parametros
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param string $url
|
|
* @param string $url
|
|
* @param array $filters
|
|
* @param array $filters
|
|
* @param array $order_by
|
|
* @param array $order_by
|
|
@@ -166,7 +166,7 @@ class Webservice
|
|
|
|
|
|
/**
|
|
/**
|
|
* Similar a getData pero la request no hace authentication
|
|
* Similar a getData pero la request no hace authentication
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param string $url
|
|
* @param string $url
|
|
* @param array $filters
|
|
* @param array $filters
|
|
* @param array $order_by
|
|
* @param array $order_by
|
|
@@ -219,7 +219,7 @@ class Webservice
|
|
if ($offset) {
|
|
if ($offset) {
|
|
$url .= "&offset={$offset}";
|
|
$url .= "&offset={$offset}";
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if ($qbCriteria) {
|
|
if ($qbCriteria) {
|
|
$url .= '&filters[qb-criteria]';
|
|
$url .= '&filters[qb-criteria]';
|
|
}
|
|
}
|
|
@@ -328,4 +328,51 @@ class Webservice
|
|
return isset($result[0]) ? $result[0] : $id;
|
|
return isset($result[0]) ? $result[0] : $id;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Filtra las clientes de los admin.
|
|
|
|
+ * @param $queryBuilder
|
|
|
|
+ * @param $alias
|
|
|
|
+ * @param $field
|
|
|
|
+ * @param $value
|
|
|
|
+ * @return bool
|
|
|
|
+ */
|
|
|
|
+ public function getClientFilter($queryBuilder, $alias, $field, $value)
|
|
|
|
+ {
|
|
|
|
+ $resp = false;
|
|
|
|
+ if ($value['value']) {
|
|
|
|
+ if ($field == 'clientId') {
|
|
|
|
+ // es el filtro de clientes
|
|
|
|
+ // debo llamar al webservice para obtener los datos
|
|
|
|
+ // actualmente filtra por id, name, address
|
|
|
|
+ if (is_numeric($value['value'])) {
|
|
|
|
+ $clients = $this->getData('client',
|
|
|
|
+ array(
|
|
|
|
+ 'externalId' => $value['value']
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+ } else {
|
|
|
|
+ $clients = $this->getData('client',
|
|
|
|
+ array(
|
|
|
|
+ 'qb-criteria' => '',
|
|
|
|
+ 'orWhere' => '',
|
|
|
|
+ 'externalId' => $value['value'],
|
|
|
|
+ 'name' => $value['value'],
|
|
|
|
+ 'address' => $value['value']
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ if (count($clients) == 0) {
|
|
|
|
+ // no se encontraron clientes con el filtro que se paso
|
|
|
|
+ $queryBuilder->andWhere($queryBuilder->expr()->eq(1, 2));
|
|
|
|
+ } else {
|
|
|
|
+ $queryBuilder->andWhere(
|
|
|
|
+ $queryBuilder->expr()->in(
|
|
|
|
+ $alias . '.clientId', array_column($clients, 'id'))
|
|
|
|
+ );
|
|
|
|
+ $resp = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return $resp;
|
|
|
|
+ }
|
|
}
|
|
}
|