|
@@ -1110,11 +1110,21 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
|
}
|
|
|
public function addPracownicyToGroupAjax($args) {
|
|
|
$idGroup = V::get('idGroup', '', $args);
|
|
|
+ $type = V::get('type', 'ids', $args);
|
|
|
$pracownicyIds = V::get('pracownicyIds', '', $args);
|
|
|
+ $filter = V::get('filter', '', $args);
|
|
|
|
|
|
// validate
|
|
|
if (!$idGroup) throw new Exception("Nie wybrano grupa");
|
|
|
- if (!$pracownicyIds || count($pracownicyIds) == 0 ) throw new Exception("Proszę wybrać pracowników");
|
|
|
+ switch ($type) {
|
|
|
+ case 'ids': {
|
|
|
+ if (!$pracownicyIds || count($pracownicyIds) == 0) throw new Exception("Proszę wybrać pracowników");
|
|
|
+ } break;
|
|
|
+ case 'filter': {
|
|
|
+ if (!isset($args['filter'])) throw new Exception("Proszę wybrać pracowników");
|
|
|
+ } break;
|
|
|
+ default: throw new Exception("Missing type");
|
|
|
+ }
|
|
|
|
|
|
// TODO: SPRWADZENIE CZY NIE DODANOU JUZ PRACOWNIKAS
|
|
|
// default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group
|
|
@@ -1131,6 +1141,59 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
|
if (!$group) throw new Exception("Grupa nie istnieje");
|
|
|
if (User::getID() != $group['ID_USER']) throw new Exception("Brak uprawnień do grupy");
|
|
|
|
|
|
+ if ('filter' === $type) {
|
|
|
+ $args__idGroup = V::get('filterIdGroup', 0, $args['filter'], 'int'); // dla filtrów "Wysokiego ryzyka" - przekazywany ID rekodu
|
|
|
+ if ($args__idGroup < 0) $args__idGroup = 0;
|
|
|
+ $search = V::get('search', '', $args['filter']);
|
|
|
+ $searchParams = [];
|
|
|
+ if (!empty($search)) {
|
|
|
+ $ogcSearch = "*{$search}*"; // wildCard="*" -> mysql '%'
|
|
|
+ $searchParams['ogc:Filter'] = '
|
|
|
+ <ogc:Filter>
|
|
|
+ <ogc:Or>
|
|
|
+ <ogc:PropertyIsLike wildCard="" singleChar="%23" escapeChar="!">
|
|
|
+ <ogc:PropertyName>nip</ogc:PropertyName>
|
|
|
+ <ogc:Literal>' . $ogcSearch . '</ogc:Literal>
|
|
|
+ </ogc:PropertyIsLike>
|
|
|
+ <ogc:PropertyIsLike wildCard="*" singleChar="%23" escapeChar="!">
|
|
|
+ <ogc:PropertyName>nazwisko</ogc:PropertyName>
|
|
|
+ <ogc:Literal>' . $ogcSearch . '</ogc:Literal>
|
|
|
+ </ogc:PropertyIsLike>
|
|
|
+ </ogc:Or>
|
|
|
+ </ogc:Filter>
|
|
|
+ ';
|
|
|
+ }
|
|
|
+
|
|
|
+ $backRefFilter = [];
|
|
|
+ if ($args__idGroup > 0) {
|
|
|
+ $backRefFilter['__backRef'] = [
|
|
|
+ 'namespace' => 'default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group',
|
|
|
+ 'primaryKey' => $args__idGroup,
|
|
|
+ 'fieldName' => 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY',
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ $filtersParams = [];
|
|
|
+ $fieldFilterKeys = array_filter(array_keys($args['filter']), function ($key) {
|
|
|
+ return ('f_' === substr($key, 0, 2));
|
|
|
+ });
|
|
|
+ foreach ($fieldFilterKeys as $key) {
|
|
|
+ $filtersParams[ $key ] = '%' . $args['filter'][ $key ] . '%';
|
|
|
+ }
|
|
|
+
|
|
|
+ $acl = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY');
|
|
|
+ $query = $acl->buildQuery(array_merge([
|
|
|
+ 'cols' => array_merge(self::$FIELD_LIST_PRACOWNICY, [
|
|
|
+ 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY_adresy:BI_audit_ENERGA_PRACOWNICY_adresy/*'
|
|
|
+ ]),
|
|
|
+ ], $searchParams, $filtersParams, $backRefFilter));
|
|
|
+ $items = $query->getItems();
|
|
|
+
|
|
|
+ $pracownicyIds = array_map(function ($row) {
|
|
|
+ return $row['ID'];
|
|
|
+ }, $items);
|
|
|
+ }
|
|
|
+
|
|
|
// $refGrupyToPracownicy = ACL::getRefTable('obiekt główny', 'nazwa pola - powiązane rekordy');
|
|
|
$refGrupyToPracownicy = ACL::getRefTable('default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group',
|
|
|
'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY');
|
|
@@ -1335,7 +1398,8 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
|
<li><a title="IMPORT PRACOWNIKÓW" onClick="showViewUploadFile(event, \'Import pracowników\', \'pracownicy\', \'yes\', \''.$csvExamplePracownicy.'\' )" class="btn btn-info">IMPORT PRACOWNIKÓW</a></li>
|
|
|
<!--<li><a href="#" title="DODAJ PRACOWNIKÓW" class="btn btn-info" >+ DODAJ PRACOWNIKÓW</a></li>-->'; //todo: dodać obsługe doddawania pracownikow
|
|
|
|
|
|
- $buttonMoveToGroup = '<a title="DODAJ DO GRUPY" onClick="addPracownikToGroup(event)" class="btn btn-info">DODAJ DO GRUPY</a>';
|
|
|
+ $buttonMoveToGroup = '<a title="DODAJ WYBRANE DO GRUPY" onClick="addPracownikToGroup(event)" class="btn btn-info">DODAJ WYBRANE DO GRUPY</a>';
|
|
|
+ $buttonMoveToGroup .= '<a title="DODAJ WSZYSTKIE DO GRUPY" onClick="addPracownikAllToGroup(event)" class="btn btn-info" style="margin-left:12px">DODAJ WSZYSTKIE DO GRUPY</a>';
|
|
|
|
|
|
$showButtonNextStep = '<a href="'.Request::getPathUri().'index.php?_route=UrlAction_Bocian#KONTRAHENCI" title="DODAJ DO ANALIZY" class="btn btn-primary">DODAJ DO ANALIZY</a>';
|
|
|
|