Browse Source

- dodanie tabeli z formularzem edycji danych do zapisu
- usuniecie linków ze stopki "funckje" i "Bezpieczenstwo"
- dodanie napisu menu nad "hamurgerem"

dariusz.andryskowski 7 years ago
parent
commit
7739fac317
6 changed files with 148 additions and 50 deletions
  1. 0 0
      theme/assets/css/styles.css
  2. 38 12
      theme/assets/less/styles.less
  3. 0 2
      theme/view/footer.php
  4. 1 0
      theme/view/top.php
  5. 106 33
      tools/Bocian.php
  6. 3 3
      tools/Bocian.php.view.js

File diff suppressed because it is too large
+ 0 - 0
theme/assets/css/styles.css


+ 38 - 12
theme/assets/less/styles.less

@@ -1,5 +1,6 @@
 // Variables, Mixins
 @import "variables.less";
+@import "buttons.less";
 
 // html5
 article,
@@ -72,6 +73,7 @@ strong {
 .text-grey {
   color: @brand-text-light;
 }
+
 .bg-white {
   background-color: @brand-white!important;
 }
@@ -88,6 +90,7 @@ strong {
 .border-bottom-grey {
   border-bottom: 2px solid @brand-grey;
 }
+
 ul.breadcrumb {
   background-color: @brand-white;
   li {
@@ -106,14 +109,22 @@ ul.breadcrumb {
 
 /* menu hamburger*/
 #hamburger-menu {
-    float: right;
-    
+  .smad-menu-title {
+    font-size: 11px;
+    height: 17px;
+    text-align: center;
+    color: @brand-primary;
+    font-weight: bold;
+  }
+
+  float: right;
   .hamburger-menu-line {
     width: 35px;
     height: 3px;
     background-color: @brand-dark;
     margin: 6px 0;
     text-align: right;
+
   }
 }
 
@@ -135,9 +146,9 @@ ul.breadcrumb {
   color: @brand-white;
   background-color: @brand-primary;
   border-color: @brand-primary;
-}
-
+}*/
 
+/*
 .btn-default {
   color: @brand-primary;
   background-color: @brand-white;
@@ -153,10 +164,10 @@ ul.breadcrumb {
   color: @brand-white;
   background-color: @brand-primary;
   border-color: @brand-primary;
-}
+}*/
 
 
-.btn-default-red {
+/*.btn-default-red {
   color: @brand-white!important;
   background-color: @brand-primary;
   border-color: @brand-primary;
@@ -171,8 +182,8 @@ ul.breadcrumb {
   color: @brand-primary!important;
   background-color: @brand-white;
   border-color: @brand-primary;
-}
-
+}*/
+/*
 .btn-grey-border {
   color: @brand-secondary!important;
   background-color: @brand-white;
@@ -188,13 +199,14 @@ ul.breadcrumb {
   color: @brand-white!important;
   background-color: @brand-secondary;
   border-color: @brand-secondary;
-}
-*/
+}*/
 
 /* Select option */
 .form-control {
   height: 43px;
 }
+
+
 .col-centered {
   margin: 0 auto;
   float: none;
@@ -264,6 +276,7 @@ ul.breadcrumb {
 /** Menu */
 #smad-menu-section {
 
+
   .smad-heder-title {
     color: @brand-text;
     font-weight: 700;
@@ -405,10 +418,18 @@ footer {
 }
 
 
+
+/**
+ * Employees
+ */
+#smad-reaport-section {
+
+}
+
 /**
  * Employees
  */
-#smad-employees-sectionn, #smad-reaport-section  {
+#smad-employees-section, #smad-reaport-section  {
   /*Form Wizard*/
   .smad-wizard {
     margin-top: 0px;
@@ -552,13 +573,18 @@ footer {
         font-size: 14px;
       }
     }
+
+    .smad-depth {
+      width: 80px;
+      text-align: center;
+    }
   }
 
   /** form list employes */
   .smad-employees-list-head, .smad-form-list-head {
     padding: 15px 0px;
     background-color: @brand-grey-light;
-    display: fix;
+    display: flex;
 
     .title {
 

+ 0 - 2
theme/view/footer.php

@@ -10,8 +10,6 @@
 			  <div class="col-lg-12">
 					<ul class="menu-bottom">
 						<li><a href="#" title="O Bocianie">O Bocianie</a></li>
-						<li><a href="#" title="">Funkcje</a></li>
-						<li><a href="#" title="Bezpieczeństwo">Bezpieczeństwo</a></li>
 						<li><a href="#" title="">Kontakt</a></li>
 					</ul>
 				</div>

+ 1 - 0
theme/view/top.php

@@ -14,6 +14,7 @@
 			</div>
 			<div class="smad-top-second">
 				<div id="hamburger-menu">
+					<div class="smad-menu-title">MENU</div>
 					<a href="#" title="Menu" onClick="toggledisplay('smad-menu-main');">
 					<div class="hamburger-menu-line"></div>
 					<div class="hamburger-menu-line"></div>

+ 106 - 33
tools/Bocian.php

@@ -33,7 +33,7 @@ class Bocian extends RouteToolBase {
 			'DBG' => V::get('DBG', 0, $_GET),
 			'VIEW_KONTRAHENCI' => $this->defaultViewFormBiAudit([], 'KONTRAHENCI'),
 			'VIEW_PRACOWNICY' => $this->defaultViewFormBiAudit([], 'PRACOWNICY'),
-			'URL_PARSE_CSV_FILE_AJAX' => $this->getLink('parseCsvFileAjax'),
+			'URL_FORM_DATA_CSV_FILE_AJAX' => $this->getLink('formDataCsvFileAjax'),
 			'URL_SAVE_FORM_CSV_FILE_AJAX' => $this->getLink('saveFormCsvFileAjax'),
 
 		]);
@@ -45,50 +45,50 @@ class Bocian extends RouteToolBase {
 /**
  * Funkcja ajax do odebrania danych z przesłanego pliku CSV do parsowania
  */
-	public function parseCsvFileAjaxAction() {
-		Response::sendTryCatchJson(array($this, 'parseCsvFileAjax')); // , $args = 'JSON_FROM_REQUEST_BODY');
+	public function formDataCsvFileAjaxAction() {
+		Response::sendTryCatchJson(array($this, 'formDataCsvFileAjax'));
 	}
 
 /**
- * Funkcja parsuje dane wgrywanego plku csv
+ * Funkcja parsuje dane wgrywanego plku csv i zwraca dane w inputach
  */
-public function parseCsvFileAjax() {
+public function formDataCsvFileAjax() {
 
 	if (!file_exists($_FILES['file']['tmp_name'])) throw new Exception("Wybierz plik do przesłania.");
 
 		$file = file($_FILES['file']['tmp_name']);
 
-		// nagłowki csv
-		$headCsv = array();
-		// wiersze CSV(poza pierwszym)
-		$arrayRows = array();
+	// parsujemy csv to tablicy
+		$arrayDataCsv = $this->csvToArray($file, ';', '"', '\n\r');
+
 		$i = 0;
+		// tworzymy rekordy
+		foreach ( $arrayDataCsv as $line ) {
+			//$viewFormCol .= '<div style="margin: 10px 0"><span>'.($i + 1).'. </span>';
+
+			$viewFormCol .= '<tr>';
+			foreach ( $line as $keyData => $rowData ) {
+								// utworzenie nagłówków tabeli
+								if( $i == 0)  { $header .= '<td>' . $keyData . '</td>'; }
+								// utworzenie inputa do edycji
+								$viewFormCol .= '<td><input type="text" name="item[$i]['.$keyData.']" value="'.$rowData .'" /></td>';
+
+								if (end($rowData )) { $viewFormCol .= '<td><input type="checkbox" name="item['.$i.']['.$keyData.']" value="'.$rowData.'" /></td>'; }
 
-		$viewFormHtml = '<div id="smad-window-modal" style="overflow-x: scroll;"><form method="POST" id="formDataFromCsv" >';
-		foreach ($file as $line) {
-			 if ( $i == 0 ) {
-			 	$headCsv =  explode(';', $line);
-
-			 } else {
-
-			 	$arrayRows = explode(';', $line);
-
-				$viewFormHtml .= '<div style="margin: 10px 0"><span>'.$i.'. </span>';
-			 	foreach ($arrayRows as $keyData => $rowData) {
-						// sprawdzenie czy ustawiony naglówek - jeśli nie to wyświetl komunikat
-						//	if ($headCsv[$keyData]) throw new Exception("Brak nagłówka w kolumnie " . ($keyData + 1) . "w pliku CSV.");
-						// usuwamy puste znaki i znaki od nowej linii
-						$rowData =  trim(str_replace(array("\n", "\r", "\r\n", "\n\r"), ' ', $rowData));
-						$nameValue =  trim(str_replace(array("\n", "\r", "\r\n", "\n\r"), ' ', $headCsv[$keyData]));
-						// utworzenie inputa do edycji
-						$viewFormHtml .= "<input type='text' name='item[$i][$nameValue]' value='".str_replace('"', '', $rowData )."' />";
-					}
-					$viewFormHtml .= '</div><div style="margin: 20px 0;"></div>';
 			 }
+			 $viewFormCol .= '</tr>';
+
+			// $viewFormCol .= '</div><div style="margin: 20px 0;"></div>';
 			 $i++;
 
 		}
-		$viewFormHtml .= '</form></div>';
+
+		$viewFormHtml = '<div id="smad-window-modal" style="overflow-x: scroll;"><form method="POST" id="formDataFromCsv" >';
+		$viewFormHtml = ' <thead><tr>'. $header .'
+										 <td>Zaktualizuj</td>
+									 </tr>
+									 </thead>';
+		$viewFormHtml .= '<tbody id="smad-csv-data">'. $viewFormCol .'</tbody></table></form></div>';
 
 		//return $viewFormHtml;
 		return [
@@ -100,9 +100,10 @@ public function parseCsvFileAjax() {
 				'view' => $viewFormHtml,
 			]
 		];
-	//	if (!isset($_FILES['fileData'])) throw new Exception("Błąd formularza ");
+
 	}
 
+
 	/**
 	 * Funkcja ajax do odebrania danych z przesłanego formularza z parsowanego CSV
 	 */
@@ -118,14 +119,86 @@ public function parseCsvFileAjax() {
 	public function saveFormCsvFileAjax($args) {
 		$formData = V::get('formData', '', $args);
 
+		// unserialize data from serialize in javascript
 		parse_str($formData, $resultArrayFormdata);
 		//$formData = V::get('formData', '', $_REQUEST, '');
-		print_r($resultArrayFormdata);
+		//print_r($resultArrayFormdata);
+
+		if ( count($resultArrayFormdata['item']) == 0) {
+			throw new Exception("Wystapił problem podczas przesyłania danych - brak przesłanych danych.");
+		}
+
+
+		foreach ( $resultArrayFormdata['item'] as $line ) {
+
+			$insertData = array();
+			$insertTemp = array();
+				print_r($line);
+			// foreach ( $line as $keyData => $rowData) {
+			//
+			// 	$insertTemp[$keyData] = $rowData;
+			// //	print $keyData ."--". $rowData . "<br />";
+			// 	$insertData = array_merge($insertTemp, $insertData);
+			//
+			// }
+
+	//		$this->saveDataToDb($table, $arrayData);
+		}
+		//print_r($insertData);
+					exit;
+
+exit;
+		try {
+
+			$responseInsert = DB::getPDO()->insert('BI_audit_ENERGA_RUM_KONTRAHENCI', [
+				'Pelna_nazwa_kontrahenta' => 'Teste NAZWY FIRMY ',
+				'Skrocona_Nazwa_Kontrahenta' => 'TEST NAZWY SKR.'
+			]);
+
+		} catch (Exception $e) {
+
+			print_r($e);
+		}
+
+
 		//print_r($formData);
 		//todo: dane do zapisania z formularza
 	}
 
 
+	/**
+	 * Function parse csv to array
+	 * @param $filename - file data from FILE
+	 * @param $delimiter - delimiter
+	 * @param $enclosure -
+	 * @param $escape -
+	 */
+	function csvToArray($filedata , $delimiter=';', $enclosure='"', $escape = '\\') {
+	  if(!$filedata || empty($filedata)) return false;
+
+	  $header = null;
+	  $data = array();
+
+	  foreach( $filedata as $line) {
+	    $values = str_getcsv( $line, $delimiter, $enclosure, $escape );
+	    if(!$header) $header = $values;
+	    else $data[] = array_combine( $header, $values );
+	  }
+
+	  return $data;
+	}
+
+	public function saveDataToDb($table, $arrayData ) {
+
+		try {
+			$responseInsert = DB::getPDO()->insert($table, $arrayData);
+		} catch (Exception $e) {
+			print_r($e);
+		}
+	}
+
+
+
 
 	public function fetchEnergaRumKontrahenciPowiazaniaAjaxAction() {
 		Response::sendTryCatchJson(array($this, 'fetchEnergaRumKontrahenciPowiazaniaAjax')); // , $args = 'JSON_FROM_REQUEST_BODY');
@@ -1135,7 +1208,7 @@ public function fetchGroupKontrahenciAjax() {
 													<h2 class="title">Wszyscy</h2>
 											</header>
 											<div class="desc">
-													Lorem Ipsum jest tekstem stosowanym jako przykładowy wypełniacz w przemyśle poligraficznym.
+													<!-- todo: można dodać opis -->
 											</div>
 									</div>
 									<div class="col-md-6">

+ 3 - 3
tools/Bocian.php.view.js

@@ -151,7 +151,7 @@ function showViewUploadFile( event, headerTitle ) {
 function parseCsvFile( fileData ) {
 	event.preventDefault();
 
-	fetch(URL_PARSE_CSV_FILE_AJAX, {
+	fetch(URL_FORM_DATA_CSV_FILE_AJAX, {
 	  method: 'POST',
 		credentials: 	'same-origin',
 	  body: fileData
@@ -706,7 +706,7 @@ console.log('kkontrahenci data', data);
 
 				if (data.body.pagination !== undefined) {
 					Pagination.Init(document.getElementById('pagination-kontrahenci'), {
-							url: 'https://bravecom.yellowgroup.pl/SE/index.php?_route=UrlAction_BiAuditRaport#KONTRAHENCI',
+							url: 'https://bravecom.yellowgroup.pl/SE/index.php?_route=UrlAction_Bocian#KONTRAHENCI',
 							id_pagination: 'pagination-kontrahenci',
 							type: 'KONTRAHENCI',
 							total_items: data.body.pagination.total_items, // pages size
@@ -778,7 +778,7 @@ function urlFetchPracownicy(page) {
 
 			if (data.body.pagination.size) {
 						Pagination.Init(document.getElementById('pagination-pracownicy'), {
-							  url: 'https://bravecom.yellowgroup.pl/SE/index.php?_route=UrlAction_BiAuditRaport#PRACOWNICY',
+							  url: 'https://bravecom.yellowgroup.pl/SE/index.php?_route=UrlAction_Bocian#PRACOWNICY',
 								id_pagination: 'pagination-pracownicy',
 								type: 'PRACOWNICY',
 								total_items: data.body.pagination.total_items, // pages size

Some files were not shown because too many files changed in this diff