|
@@ -1118,29 +1118,41 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
|
public function removeKontrahenciFromGroupAjaxAction() {
|
|
|
Response::sendTryCatchJson(array($this, 'removeKontrahenciFromGroupAjax'), $args = 'JSON_FROM_REQUEST_BODY'); // użyj tej wersji jeśli chcesz wysyłać z przelgądarki JSON-a post-em
|
|
|
}
|
|
|
- public function removeKontrahenciFromGroupAjax() {
|
|
|
- $idGroup = V::get('idGroup', '', $args);
|
|
|
- $kontrahenciIds = V::get('kontrahenciIds', '', $args);
|
|
|
- $group = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_KONTRAHENCI_group/BI_audit_ENERGA_KONTRAHENCI_group')->buildQuery([
|
|
|
- 'cols' => [ // TODO:? propertyName = []
|
|
|
- 'ID',
|
|
|
- 'ID_USER',
|
|
|
- 'NAZWA',
|
|
|
- ],
|
|
|
- // 'f_ID_USER' => User::getID()
|
|
|
- ])->getItem($idGroup);
|
|
|
- //if (!$group) throw new Exception("Grupa nie istnieje");
|
|
|
- //if (User::getID() != $group['ID_USER']) throw new Exception("Brak uprawnień do grupy");
|
|
|
- if ($idGroup === "0"){
|
|
|
+ public function removeKontrahenciFromGroupAjax($args) {
|
|
|
+ $idGroup = V::get('idGroup', 0, $args, "int");
|
|
|
+ $kontrahenciIds = V::get('kontrahenciIds', [], $args, 'array');
|
|
|
+ if ($idGroup === 0){
|
|
|
foreach ($kontrahenciIds as $kontrahentIds) {
|
|
|
- DB::getPDO()->update('BI_audit_ENERGA_RUM_KONTRAHENCI', 'ID',
|
|
|
- $kontrahentIds, ['A_STATUS' => 'DELETED']);
|
|
|
+ $affected = DB::getPDO()->update('BI_audit_ENERGA_RUM_KONTRAHENCI', 'ID', $kontrahentIds, [
|
|
|
+ 'A_STATUS' => 'DELETED',
|
|
|
+ `A_RECORD_UPDATE_DATE` => 'NOW()',
|
|
|
+ `A_RECORD_UPDATE_AUTHOR` => User::getLogin(),
|
|
|
+ ]);
|
|
|
}
|
|
|
return [
|
|
|
'msg' => "Usunięto kontrahentów z systemu",
|
|
|
'type' => "success",
|
|
|
];
|
|
|
} else {
|
|
|
+ $group = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_KONTRAHENCI_group/BI_audit_ENERGA_KONTRAHENCI_group')->buildQuery([
|
|
|
+ 'cols' => [ // TODO:? propertyName = []
|
|
|
+ 'ID',
|
|
|
+ 'ID_USER',
|
|
|
+ 'NAZWA',
|
|
|
+ ],
|
|
|
+ // 'f_ID_USER' => User::getID()
|
|
|
+ ])->getItem($idGroup);
|
|
|
+ if (!$group) throw new Exception("Grupa nie istnieje");
|
|
|
+ if (User::getID() != $group['ID_USER']) throw new Exception("Brak uprawnień do grupy");
|
|
|
+
|
|
|
+ $refGrupyToKontrahenci = ACL::getRefTable('default_db/BI_audit_ENERGA_KONTRAHENCI_group/BI_audit_ENERGA_KONTRAHENCI_group',
|
|
|
+ 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI');
|
|
|
+ foreach ($kontrahenciIds as $kontrahentIds) {
|
|
|
+ // DB::getPDO()->insert($refGrupyToKontrahenci, ['PRIMARY_KEY' => $idGroup, 'REMOTE_PRIMARY_KEY' => $kontrahentIds]);
|
|
|
+ DBG::log("trzeba skasowac rekord gdzie ${idGroup} {$kontrahentIds}");
|
|
|
+ //DB::getPDO()->execSql("delete");
|
|
|
+ }
|
|
|
+
|
|
|
return [
|
|
|
'msg' => "Usunięto kontrahentów z grupy {$idGroup}",
|
|
|
'type' => "success",
|