Sfoglia il codice sorgente

dodawanie z formy działa i zamyka okienko

michalzmijewski 7 anni fa
parent
commit
f8b93eb9d5
2 ha cambiato i file con 26 aggiunte e 7 eliminazioni
  1. 22 6
      tools/Bocian.php
  2. 4 1
      tools/Bocian.php.addItemToRaport.js

+ 22 - 6
tools/Bocian.php

@@ -220,7 +220,7 @@ TODO: dodać możliwość wysyłania maila używajac mail()
 				return "f_{$fieldName}";
 			}, self::$FIELD_LIST_KONTRAHENCI),
 		]);
-		echo UI::h('script', ['src'=>"static/vendor.js?v=48ea11d5", 'type'=>"text/javascript"]);
+		echo UI::h('script', ['src'=>"static/vendor.js?v=48ea11d6", 'type'=>"text/javascript"]);
 		UI::inlineJS(__FILE__ . '.addItemToRaport.js', [
 			'URL_FETCH_FROM_BAZA' => $this->getLink('fetchFromBazaAjax'),
 			'URL_SAVE_TO_DB' => $this->getLink('saveToPracownicyAjax'),
@@ -264,7 +264,7 @@ TODO: dodać możliwość wysyłania maila używajac mail()
 		switch ($baza) {
 			case 'default_db/BI_audit_KRS/BI_audit_KRS': return $this->saveKRSToPracownicyAjax($item);
 			case 'default_db/BI_audit_KRS_person/BI_audit_KRS_person': return $this->saveKRSPersonToPracownicyAjax($item);
-			case 'default_db/BI_audit_ENERGA_RUM_KONTRAHENCI/BI_audit_ENERGA_RUM_KONTRAHENCI': return $this->saveKonrahentToPracownicyAjax($item);
+			case 'default_db/BI_audit_ENERGA_RUM_KONTRAHENCI/BI_audit_ENERGA_RUM_KONTRAHENCI': return $this->saveKontrahentToPracownicyAjax($item);
 			case 'default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY': return $this->savePracownikToPracownicyAjax($item);
 			case 'default_db/BI_audit_taxpayer/BI_audit_taxpayer': return $this->saveVATpToPracownicyAjax($item);
 			case 'default_db/BI_audit_MSIG/BI_audit_MSIG': return $this->saveMSIGToPracownicyAjax($item);
@@ -464,10 +464,11 @@ TODO: dodać możliwość wysyłania maila używajac mail()
 			'type' => "success",
 		];
 	}
-	function saveKonrahentToPracownicyAjax($item) {
+	function saveKontrahentToPracownicyAjax($item) {
 		// companyName: document.getElementById('companyName').value,
 		// companyNip: document.getElementById('companyNip').value,
 		// comapanyRegon: document.getElementById('comapanyRegon').value,
+		DBG::log($item, 'array', "argumenty do wpisania");
 		$companyName = V::get('companyName', '', $item);
 		$companyNip = V::get('companyNip', '', $item);
 		$companyRegon = V::get('companyRegon', '', $item);
@@ -539,7 +540,7 @@ TODO: dodać możliwość wysyłania maila używajac mail()
 		switch ($baza) {
 			case 'default_db/BI_audit_KRS/BI_audit_KRS': return $this->saveKRSToKontrahenciAjax($item);
 			case 'default_db/BI_audit_KRS_person/BI_audit_KRS_person': return $this->saveKRSPersonToKontrahenciAjax($item);
-			case 'default_db/BI_audit_ENERGA_RUM_KONTRAHENCI/BI_audit_ENERGA_RUM_KONTRAHENCI': return $this->saveKonrahentToKontrahenciAjax($item);
+			case 'default_db/BI_audit_ENERGA_RUM_KONTRAHENCI/BI_audit_ENERGA_RUM_KONTRAHENCI': return $this->saveKontrahentToKontrahenciAjax($item);
 			case 'default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY': return $this->savePracownikToKontrahenciAjax($item);
 			case 'default_db/BI_audit_taxpayer/BI_audit_taxpayer': return $this->saveVATpToKontrahenciAjax($item);
 			case 'default_db/BI_audit_MSIG/BI_audit_MSIG': return $this->saveMSIGToKontrahenciAjax($item);
@@ -727,13 +728,21 @@ TODO: dodać możliwość wysyłania maila używajac mail()
 			'type' => "success",
 		];
 	}
-	function saveKonrahentToKontrahenciAjax($item) {
+	function saveKontrahentToKontrahenciAjax($item) {
 		// companyName: document.getElementById('companyName').value,
 		// companyNip: document.getElementById('companyNip').value,
 		// comapanyRegon: document.getElementById('comapanyRegon').value,
+
 		$companyName = V::get('companyName', '', $item);
 		$companyNip = V::get('companyNip', '', $item);
-		$comapanyRegon = V::get('comapanyRegon', '', $item);
+		$companyRegon = V::get('companyRegon', '', $item);
+		$companyPesel = V::get('companyPesel', '', $item);
+		$companyStreet = V::get('companyStreet', '', $item);
+		$companyNumber = V::get('companyNumber', '', $item);
+		$companyNumberLocal = V::get('companyNumberLocal', '', $item);
+		$companyPostCode = V::get('companyPostCode', '', $item);
+		$companyCity = V::get('companyCity', '', $item);
+		$companyKrs = V::get('companyKrs', '', $item);
 
 		// validate
 		if (!$companyName) throw new Exception("Nie wpisano nazwy");
@@ -743,6 +752,13 @@ TODO: dodać możliwość wysyłania maila używajac mail()
 			'Pelna_nazwa_kontrahenta' => $companyName,
 			'NIP' => ($companyNip) ? $companyNip : NULL,
 			'REGON' => ($comapanyRegon) ? $comapanyRegon : NULL,
+			'PESEL' => ($companyPesel) ? $companyPesel : NULL,
+			'Ulica' => ($companyStreet) ? $companyStreet : NULL,
+			'Numer_budynku' => ($companyNumber) ? $companyNumber : NULL,
+			'Numer_mieszkania_lokalu' => ($companyNumberLocal) ? $companyNumberLocal : NULL,
+			'Kod_pocztowy' => ($companyPostCode) ? $companyPostCode : NULL,
+			'Miejscowosc' => ($companyCity) ? $companyCity : NULL,
+			'KRS' => ($companyKrs) ? $companyKrs : NULL,
 			'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
 			'A_RECORD_CREATE_DATE' => 'NOW()',
 		]);

+ 4 - 1
tools/Bocian.php.addItemToRaport.js

@@ -444,6 +444,7 @@ var P5UI_AddItemToReport = createReactClass({
                   personPesel: document.getElementById('personPesel').value,
                   personNip: document.getElementById('personNip').value,
                 })
+                swal.close();
               }.bind(this) }, "Dodaj osobę")
             ]),
             (selectedNewItemBaza === "default_db/BI_audit_ENERGA_RUM_KONTRAHENCI/BI_audit_ENERGA_RUM_KONTRAHENCI") && h('div', { className: 'form-group' }, [
@@ -489,7 +490,7 @@ var P5UI_AddItemToReport = createReactClass({
               }),
               h('input',{
                 className:'form-control',
-                id:'comapnyRegon',
+                id:'companyRegon',
                 placeholder:'REGON'
               }),
               h('input',{
@@ -510,6 +511,7 @@ var P5UI_AddItemToReport = createReactClass({
                   companyCity: document.getElementById('companyCity').value,
                   companyKrs: document.getElementById('companyKrs').value,
                 })
+                swal.close();
               }.bind(this) }, "Dodaj podmiot")
             ]),
             (selectedBaza && selectedItem) && h('div', { style: { margin: '22px' } }, [
@@ -595,6 +597,7 @@ function addItemToRaport(event) {
                           if(result.type === "success"){
                               urlFetchPracownicy(1);
                               urlFetchKontrahenci(1);
+                              resolve(result.msg);
                           }
                           p5UI__notifyAjaxCallback(result)
                         })