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.
106 lines
3.5 KiB
106 lines
3.5 KiB
<div class="row">
|
|
<div class="col-12">
|
|
<div class="section-title">Importa parafarmacie</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 FAX
|
|
7 E-MAIL
|
|
|
|
parapharmacy
|
|
city
|
|
address
|
|
phone
|
|
fax
|
|
web
|
|
email
|
|
*/
|
|
|
|
if(is_uploaded_file($_FILES['file']['tmp_name'])){
|
|
|
|
$dest="tmpfiles/tmpparapharmacy";
|
|
|
|
if(move_uploaded_file($_FILES['file']['tmp_name'],$dest)){
|
|
|
|
$myfile = fopen($dest, "r") or die("Unable to open file!");
|
|
|
|
mysqli_query($conn, "TRUNCATE TABLE parapharmacy");
|
|
|
|
while(!feof($myfile)) {
|
|
$r = explode("|",fgets($myfile));
|
|
|
|
if($r[0]!='RAGIONE SOCIALE' && $r[0]!=''){
|
|
$q="INSERT INTO parapharmacy 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])))."')";
|
|
|
|
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>
|
|
|