فهرست منبع

BiAuditGenerate - szlify

Mariusz Muszyński 8 سال پیش
والد
کامیت
1dbab8a2dc
1فایلهای تغییر یافته به همراه70 افزوده شده و 5 حذف شده
  1. 70 5
      SE/se-lib/Route/UrlAction/BiAuditGenerate.php

+ 70 - 5
SE/se-lib/Route/UrlAction/BiAuditGenerate.php

@@ -384,6 +384,12 @@ where `REMOTE_PRIMARY_KEY` = '{$this->SOURCE['ID']}'";
 				case "BI_audit_ENERGA_PRACOWNICY":
 					$this->showPowiazaniaList();
 					break;
+				case "BI_audit_KRS":
+					$this->importKrsToPracownicySearch($this->SOURCE['ID']);
+					break;
+				case "BI_audit_KRS_person":
+					$this->showKrsForKrsPerson();
+					break;
 				default: throw new Exception("Błąd wyzwolenia funkcji BiAuditGenerate");
 			}
 		} catch (Exception $e) {
@@ -454,7 +460,7 @@ where `REMOTE_PRIMARY_KEY` = '{$this->SOURCE['ID']}'";
 <?php
 	}
 
-	private function importKrsToPracownicySearch() {
+	private function importKrsToPracownicySearch($krsId = null) {
 		try {
 			$subaction = V::get('subaction', '', $_POST);
 			switch ($subaction) {
@@ -469,8 +475,6 @@ where `REMOTE_PRIMARY_KEY` = '{$this->SOURCE['ID']}'";
 					SE_Layout::alert('success', "Pomyślnie zaimportowano " . count($personId) . " pracownik" . ((count($personId) == 1) ? "a" : "ów"));
 					$this->importKrsToPracownicyForm();
 					return;
-				default:
-					$krsId = null;
 			}
 
 			if ($krsId) {
@@ -556,8 +560,8 @@ where `REMOTE_PRIMARY_KEY` = '{$this->SOURCE['ID']}'";
 ?>
             <tr>
               <td align="right"><?=$lp++?></td>
-              <td><?=$row['nazwa']?></td>
-              <td><?=$adres?></td>
+              <td><?=htmlspecialchars($row['nazwa'])?></td>
+              <td><?=htmlspecialchars($adres)?></td>
               <td><?=$row['krs']?></td>
               <td><?=$row['nip']?></td>
               <td><?=$row['regon']?></td>
@@ -682,7 +686,66 @@ function validate(source) {
 -->
 </script>
 <?php
+	}
+
+	private function showKrsForKrsPerson() {
+		$query = "select * from BI_audit_KRS_person where ID = '{$this->SOURCE['ID']}'";
+		$result = DB::getPDO()->fetchFirst($query);
+?>
+<div class="container" style="margin-top:20px">
+  <legend>
+    Lista podmiotów, w których występuje <?="{$result['nazwisko']} {$result['imiona']}" . ($result['pesel'] ? " (PESEL: {$result['pesel']})" : "")?>
+  </legend>
+  <div class="form-group">
+    <div class="col-sm-12">
+      <table class="table table-bordered table-hover table-striped" height=5>
+        <thead>
+          <tr style="text-align:center; background-color:lightgray">
+            <td width=1>Lp.</td>
+            <td>Nazwa</td>
+            <td>Adres</td>
+            <td>KRS</td>
+            <td>NIP</td>
+            <td>Regon</td>
+            <td width=1></td>
+          </tr>
+        </thead>
+        <tbody>
+<?php
+		$refKrsToKrsPerson = ACL::getRefTable('default_db/BI_audit_KRS/BI_audit_KRS', "default_db__x3A__BI_audit_KRS_person:BI_audit_KRS_person");
+		$query = "select krs.* from `{$refKrsToKrsPerson}` ref join BI_audit_KRS krs on ref.PRIMARY_KEY = krs.ID where ref.REMOTE_PRIMARY_KEY = '{$this->SOURCE['ID']}'";
+		$result = DB::getPDO()->fetchAll($query);
 
+                if (!$result) echo '<tr><td align="center" colspan="5">Nie znaleziono powiązanych podmiotów</td></tr>';
+                else {
+			$lp = 1;
+                        foreach ($result as $row) {
+				$adres = $row['A_miejscowosc'];
+				if ($row['A_ulica']) $adres .= ", {$row['A_ulica']}";
+				if ($row['A_nrDomu']) {
+					$adres .= " {$row['A_nrDomu']}";
+					if ($row['A_nrLokalu']) $adres .= "/{$row['A_nrLokalu']}";
+				}
+?>
+          <tr>
+            <td align="right"><?=$lp++?></td>
+            <td><?=htmlspecialchars($row['nazwa'])?></td>
+            <td><?=htmlspecialchars($adres)?></td>
+            <td><?=$row['krs']?></td>
+            <td><?=$row['nip']?></td>
+            <td><?=$row['regon']?></td>
+            <td><?=UI::hButtonPost("Pokaż w tabeli", ['class' => 'btn-info btn-xs', 'action' => "index.php?_route=ViewTableAjax&namespace=default_db/BI_audit_KRS/BI_audit_KRS&ff_ID={$row['ID']}", 'data' > ['f_ID' => $row['ID']]])?></td>
+          </tr>
+<?php
+                        }
+                }
+?>
+        </tbody>
+      </table>
+    </div>
+  </div>
+</div>
+<?php
 	}
 
 	public function defaultAction() {
@@ -695,6 +758,8 @@ function validate(source) {
 		else $this->REFERER=$_SERVER['HTTP_REFERER'];
 		if (($ID = V::get('ID_BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', 0, $_GET, 'int')) > 0) $this->SOURCE['TABLE'] = 'BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA';
 		elseif (($ID = V::get('ID_BI_audit_ENERGA_PRACOWNICY', 0, $_GET, 'int')) > 0) $this->SOURCE['TABLE'] = 'BI_audit_ENERGA_PRACOWNICY';
+		elseif (($ID = V::get('ID_BI_audit_KRS', 0, $_GET, 'int')) > 0) $this->SOURCE['TABLE'] = 'BI_audit_KRS';
+		elseif (($ID = V::get('ID_BI_audit_KRS_person', 0, $_GET, 'int')) > 0) $this->SOURCE['TABLE'] = 'BI_audit_KRS_person';
 		if ($this->SOURCE) {
 			$this->SOURCE['ID'] = $ID;
 			$this->powiazania();