csv import, radio fritz, donate fixes, ...

This commit is contained in:
Ulf Gebhardt 2018-10-11 12:47:52 +02:00
parent 2a2b159baa
commit 8b790c9b3c
4 changed files with 73 additions and 1 deletions

View File

@ -199,6 +199,39 @@ function init_saimod_mail_list() {
} }
}); });
}); });
$('#csv-file').change(function (){
for (var i = 0; i < $(this).get(0).files.length; ++i) {
upload($(this).get(0).files[i],$('#input-list-id').val());
}
});
}
function upload(file,list) {
if(!file) return;
//FormData Objekt erzeugen
var formData = new FormData();
//XMLHttpRequest Objekt erzeugen
var client = new XMLHttpRequest();
client.responseType = 'json';
$('#bug-progress .progress-bar').css('width', '0%').attr('aria-valuenow', 0);
$('#bug-progress').show();
$('#bug-file-list').show();
$('#bug-file-list').append('<a target="_blank" class="'+file.lastModified+' list-group-item list-group-item-warning"><span class="badge alert-success pull-right hidden">Success</span>'+file.name+'</a>');
//Fügt dem formData Objekt unser File Objekt hinzu
formData.append("datei", file);
client.onerror = function(e) {
$('.'+file.lastModified).removeClass('list-group-item-warning');
$('.'+file.lastModified).removeClass('list-group-item-success');
$('.'+file.lastModified).addClass('list-group-item-danger');
};
client.open("POST", "./sai.php?sai_mod=.SAI.saimod_mail&action=csvimport&list="+list);
client.send(formData);
system.reload();
} }
function init_saimod_mail_list_new() { function init_saimod_mail_list_new() {

View File

@ -511,6 +511,36 @@ class saimod_mail extends \SYSTEM\SAI\sai_module{
} }
return \JsonResult::ok(); return \JsonResult::ok();
} }
public static function sai_mod__SAI_saimod_mail_action_csvimport($list){
$handle = fopen($_FILES['datei']['tmp_name'],'r');
while ( ($data = fgetcsv($handle,0,';') ) !== FALSE ) {
$email = $data[0];
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
continue;}
$db = \SQL\CONTACT_SELECT::Q1(array($email));
$sex = $db ? $db['sex'] : null;
if(count($data) >= 2 && $data[1]){
$sex = $data[1];
}
$name_first = $db ? $db['name_first'] : null;
if(count($data) >= 3 && $data[2]){
$name_first = $data[2];
}
$name_last = $db ? $db['name_last'] : null;
if(count($data) >= 4 && $data[3]){
$name_first = $data[3];
}
if($db){
\SQL\CONTACT_UPDATE::QI(array($sex,$name_first,$name_last,$email));
} else {
\SQL\CONTACT_INSERT::QI(array($email,$sex,$name_first,$name_last));
}
\SQL\SUBSCRIBE::QI(array($email,$list));
}
}
public static function menu(){ public static function menu(){
return new \SYSTEM\SAI\sai_module_menu( 101, return new \SYSTEM\SAI\sai_module_menu( 101,

View File

@ -24,4 +24,6 @@ REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `na
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (9062, 42, 2, 9000, 'template', 'id', 'UINT0'); REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (9062, 42, 2, 9000, 'template', 'id', 'UINT0');
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (9065, 42, 2, 9000, 'update_template', 'data', 'JSON'); REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (9065, 42, 2, 9000, 'update_template', 'data', 'JSON');
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (9067, 42, 2, 9000, 'insert_template', 'data', 'JSON'); REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (9067, 42, 2, 9000, 'insert_template', 'data', 'JSON');
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (9069, 42, 2, 9000, 'delete_template', 'data', 'JSON'); REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (9069, 42, 2, 9000, 'delete_template', 'data', 'JSON');
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (9070, 42, 2, 9000, 'csvimport', 'list', 'UINT0');

View File

@ -20,6 +20,13 @@
<tr> <tr>
<th colspan="2"></th> <th colspan="2"></th>
</tr> </tr>
<tr>
<th>CSV Import</th>
<td><input type="file" name="files[]" id="csv-file"></td>
</tr>
<tr>
<th colspan="2"></th>
</tr>
<tr> <tr>
<th colspan="2">Members</th> <th colspan="2">Members</th>
</tr> </tr>