소스 검색

Merge branch 'master' of bn.git:plabudda/se

Piotr Labudda 8 년 전
부모
커밋
36ad37d09b
2개의 변경된 파일30개의 추가작업 그리고 8개의 파일을 삭제
  1. 22 5
      SE/se-lib/VAT.php
  2. 8 3
      SE/superedit-SQIX_STRUCTURE_DB_SYNC.php

+ 22 - 5
SE/se-lib/VAT.php

@@ -70,6 +70,20 @@ Class VAT {
 	private $cookies = "php://memory";
 	private $message = [];
 	private $initialized = false;
+	private $messages = [
+		"Podmiot o podanym identyfikatorze podatkowym NIP jest zarejestrowany jako podatnik VAT czynny" => [
+			"active" => true,
+			"shortMessage" => "Czynny",
+		],
+		"Podmiot o podanym identyfikatorze podatkowym NIP nie jest zarejestrowany jako podatnik VAT" => [
+			"active" => false,
+			"shortMessage" => "Niezarejestrowany",
+		],
+		"Podmiot o podanym identyfikatorze podatkowym NIP jest zarejestrowany jako podatnik VAT zwolniony" => [
+			"active" => true,
+			"shortMessage" => "Zwolniony"
+		],
+	];
 
 	private function getHeaders($ch, $header) {
 		$len = strlen($header);
@@ -152,11 +166,8 @@ Class VAT {
 		$this->dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
 		$this->message = array_map("trim", array_values(array_diff(explode("|", $this->dom->getElementById("caption2_b-3")->textContent), [''])));
 		if (!$this->message) throw new Exception("Błąd danych ze strony Ministerstwa Finansów");
-		switch ($this->message[0]) {
-			case "Podmiot o podanym identyfikatorze podatkowym NIP jest zarejestrowany jako podatnik VAT czynny" : return true;
-			case "Podmiot o podanym identyfikatorze podatkowym NIP nie jest zarejestrowany jako podatnik VAT" : return false;
-			default: throw new Exception("Nieznany rezultat");
-		}
+		if (isset($this->messages[$this->message[0]])) return $this->messages[$this->message[0]]['active'];
+		else throw new Exception("Nieznany rezultat");
 	}
 
 	public function getMessage($whole = false) {
@@ -165,6 +176,12 @@ Class VAT {
 		else return $this->message[0];
 	}
 
+	public function getShortMessage() {
+		if (!$this->message) return "Brak wyniku";
+		if (!isset($this->messages[$this->message[0]])) return "Nieznany rezultat";
+		return $this->messages[$this->message[0]]['shortMessage'];
+	}
+
 	public function isActiveVatPayer($nip) {
 		$this->message = [];
 		$nip = str_replace("-", "", trim($nip));

+ 8 - 3
SE/superedit-SQIX_STRUCTURE_DB_SYNC.php

@@ -2249,7 +2249,9 @@ $CONNLOCAL->query('set global max_allowed_packet=1000000000');
    		// ! CLEAR_IMPORTED_ZASOBY_REMOTE
 	   } else if($SYNC_OPTIONS=='CLEAR_IMPORTED_ZASOBY_REMOTE')  {
 	   		//jedziemy po wszystkich tabelach z CRM_IMPORT_TRANSLATE
-	   		
+	   		if( isset($sql)) unset($sql);
+	   		if( isset($zap)) unset($zap);
+	   		echo "\n<br> Będą kasowane zaimportowane zasoby, procesy, wskazniki, pytania, zdjecia dla zaimportowanych struktur - aby wgrac od nowa czyste ";
 	   		$sql[]="delete  t1.* from `CRM_PROCES`  as t1 ,  `CRM_IMPORT_TRANSLATE` as t2 where  ( t1.`ID`=t2.`DST_TABLE_ID` and t2.`REM_TABLE`='CRM_PROCES' ) ";
 	   		$sql[]="delete  t1.* from `CRM_WSKAZNIK`  as t1 ,  `CRM_IMPORT_TRANSLATE` as t2 where  ( t1.`ID`=t2.`DST_TABLE_ID` and t2.`REM_TABLE`='CRM_WSKAZNIK' ) ";
 	   		$sql[]="delete  t1.* from `CRM_LISTA_ZASOBOW`  as t1 ,  `CRM_IMPORT_TRANSLATE` as t2 where  ( t1.`ID`=t2.`DST_TABLE_ID` and t2.`REM_TABLE`='CRM_LISTA_ZASOBOW' ) ";
@@ -2260,9 +2262,12 @@ $CONNLOCAL->query('set global max_allowed_packet=1000000000');
 	   		$sql[]="delete t2.* from   `CRM_IMPORT_TRANSLATE` as t2 where t2.`REM_TABLE`='CRM_WSKAZNIK'";
 	   		$sql[]="delete t2.* from   `CRM_IMPORT_TRANSLATE` as t2 where t2.`REM_TABLE`='CRM_LISTA_ZASOBOW'";
 	   		$sql[]="delete t2.* from   `CRM_IMPORT_TRANSLATE` as t2 where  t2.`REM_TABLE`='CRM_TESTY_PYTANIA'";
+	   		$sql[]="delete t2.* from   `CRM_IMPORT_TRANSLATE` as t2 where  t2.`REM_TABLE`='CRM_IMAGE'";
+	   		
+	   		DEBUG_S(-3,'Zapytanie SQL czyszczace tabele: ',$sql,__FILE__, __FUNCTION__, __LINE__) ;	
 
-			foreach($sql as $zap) {
-				DEBUG_S(-3,'Zapytanie SQL czyszczace tabele: ',$zap,__FILE__, __FUNCTION__, __LINE__) ;		
+			foreach($sql as $zap_ind=>$zap) {
+				DEBUG_S(-3,'Wyzwalam : Zapytanie SQL czyszczace tabele: ',$zap,__FILE__, __FUNCTION__, __LINE__) ;	
 				if(!empty($CONFIRM_SQL_UPDATE))	$result=$CONNREMOTE->query($zap) or die1('\nProblem z '.$zap);
 				
 			}