You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							109 lines
						
					
					
						
							3.6 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							109 lines
						
					
					
						
							3.6 KiB
						
					
					
				| <div class="row"> | |
|     <div class="col-12"> | |
|         <div class="section-title">Importa farmacie</div> | |
|     </div> | |
|     <div class="col-12"> | |
| 
 | |
|         <div class="sheet-box p-4"> | |
| 
 | |
|         <?php | |
| 
 | |
|             if($_POST['go']){ | |
| 
 | |
|                 /* | |
|                 0 RAGIONE SOCIALE | |
|                 1 INDIRIZZO | |
|                 2 CAP | |
|                 3 LOCALITA | |
|                 4 PROVINCIA | |
|                 5 TELEFONO | |
|                 6 E-MAIL | |
|                 7 E-MAIL CERTIFICATA | |
|                 8 TIPO FARMACIA | |
|  | |
|                 pharmacy | |
|                 city | |
|                 address | |
|                 phone | |
|                 web | |
|                 email | |
|                 email_cert | |
|                 type | |
|                 */ | |
| 
 | |
|                 if(is_uploaded_file($_FILES['file']['tmp_name'])){ | |
| 
 | |
|                     $dest="tmpfiles/tmppharmacy"; | |
| 
 | |
|                     if(move_uploaded_file($_FILES['file']['tmp_name'],$dest)){ | |
| 
 | |
|                         $myfile = fopen($dest, "r") or die("Unable to open file!"); | |
| 
 | |
|                         mysqli_query($conn, "TRUNCATE TABLE pharmacy"); | |
| 
 | |
|                         while(!feof($myfile)) { | |
|                             $r = explode("|",fgets($myfile)); | |
| 
 | |
|                             if($r[0]!='RAGIONE SOCIALE' && $r[0]!=''){ | |
|                                 $q="INSERT INTO pharmacy VALUES(NULL, | |
|                                     '".addslashes(trim(anyToUTF8($r[0])))."','".addslashes(trim(anyToUTF8($r[3])))."', | |
|                                     '".addslashes(trim(anyToUTF8($r[1])))."','".addslashes(trim(anyToUTF8($r[5])))."','', | |
|                                     '".addslashes(trim(anyToUTF8($r[6])))."','".addslashes(trim(anyToUTF8($r[7])))."', | |
|                                     '".addslashes(trim(anyToUTF8($r[8])))."')"; | |
| 
 | |
|                                 mysqli_query($conn, $q); | |
|                             } | |
| 
 | |
|                         } | |
| 
 | |
|                         fclose($myfile); | |
| 
 | |
|                         echo '<div class="col-10 text-center mx-auto my-5"> | |
|                                     <p><i class="fa fa-exclamation-triangle font-alert p-4"></i></p> | |
|                                     <p>File importato correttamente!</p> | |
|                                 </div>'; | |
|                     }else{ | |
|                         echo '<div class="col-10 text-center mx-auto my-5"> | |
|                             <p><i class="fa fa-exclamation-triangle font-alert p-4"></i></p> | |
|                             <p>ATENZIONE: Errore nell\'importazione del file!</p> | |
|                         </div>'; | |
|                     } | |
|                 } | |
| 
 | |
| 
 | |
| 
 | |
|             }else{ | |
|         ?> | |
|             <form method="post" enctype="multipart/form-data"> | |
|                 <div class="row"> | |
|  | |
|                     <div class="col-12"> | |
|                         <span class="font-12">File *.CSV</span> | |
|                         <div class="files-list"> | |
|                             <div class="list"> | |
|                                 <div class="row master"> | |
|                                     <div class="col"> | |
|                                         <input type="file" name="file"> | |
|                                     </div> | |
|                                 </div> | |
|                             </div> | |
|                         </div> | |
|  | |
|                         <p>ATTENZIONE: Assicurarsi che il file sia del formato corretto. I dati presenti saranno sovrascritti.</p> | |
|                     </div> | |
|                    <div class="col-12 text-right"> | |
|                         <button type="submit" name="go" value="1">Importa da file</button> | |
|                     </div> | |
|                 </div> | |
|                 </div> | |
|             </form> | |
|  | |
|             <?php | |
|                 } | |
|             ?> | |
|  | |
|         </div> | |
|  | |
|     </div> | |
| </div> | |
| 
 |