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.9 KiB
109 lines
3.9 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] => CODICE
|
|
[6] => TELEFONO
|
|
[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!");
|
|
|
|
while(!feof($myfile)) {
|
|
$r = explode("|",fgets($myfile));
|
|
|
|
if($r[0]!='N_Albo' && $r[0]!=''){
|
|
$q="INSERT INTO parapharmacy VALUES(
|
|
'".addslashes(trim(anyToUTF8($r[0])))."','','','".addslashes(trim(anyToUTF8($r[3])))."',
|
|
'".addslashes(trim(anyToUTF8($r[1])))."','".addslashes(trim(anyToUTF8($r[6])))."','','',
|
|
'".addslashes(trim(anyToUTF8($r[7])))."')
|
|
ON DUPLICATE KEY UPDATE
|
|
parapharmacy='".addslashes(trim(anyToUTF8($r[0])))."',
|
|
city='".addslashes(trim(anyToUTF8($r[3])))."',
|
|
address='".addslashes(trim(anyToUTF8($r[1])))."',
|
|
phone='".addslashes(trim(anyToUTF8($r[6])))."',
|
|
email='".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.</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>
|
|
|