mirror of
https://github.com/tim-krehan/shopping-list.git
synced 2024-11-23 22:30:41 +01:00
added import for listitems (hopefully)
This commit is contained in:
parent
2acc164365
commit
5f18b295a4
6 changed files with 34 additions and 17 deletions
|
@ -8,13 +8,13 @@ $(document).ready(function(){
|
|||
},
|
||||
function(data){
|
||||
if(data==0){
|
||||
infoPopUp("Benutzer erfolgreich erstellt!");
|
||||
infoPopUp("Benutzer erfolgreich erstellt!", 100);
|
||||
$("#text_user").val("");
|
||||
$("#text_passwd").val("");
|
||||
$("#adduser-button-done").removeClass("button-disabled");
|
||||
}
|
||||
else {
|
||||
infoPopUp("Fehler bei der Benutzeranlage!");
|
||||
infoPopUp("Fehler bei der Benutzeranlage!", 100);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
function infoPopUp(infotext){
|
||||
function infoPopUp(infotext, timeout){
|
||||
$("#info-popup-text").text(infotext);
|
||||
$("#info-popup-text").css("animation", "none");
|
||||
setTimeout(function(){$("#info-popup-text").css("animation", "fade 4s linear");}, 100);
|
||||
setTimeout(function(){$("#info-popup-text").css("animation", "fade 4s linear");}, timeout);
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@ $(document).ready(function(){
|
|||
id: dataId,
|
||||
status: $(this).prop("checked")
|
||||
},
|
||||
success: function(){infoPopUp("SAVED!");},
|
||||
error: function(){infoPopUp("Netzwerkfehler! Bitte aktualisieren.");}
|
||||
success: function(){infoPopUp("SAVED!", 100);},
|
||||
error: function(){infoPopUp("Netzwerkfehler! Bitte aktualisieren.", 100);}
|
||||
});
|
||||
if($(this).prop("checked")){$("[data-id='"+dataId+"']").addClass("checked");}
|
||||
else{$("[data-id='"+dataId+"']").removeClass("checked");}
|
||||
|
|
|
@ -42,10 +42,10 @@ $(document).ready(function(){
|
|||
$("#old-password-input").val("");
|
||||
$("#new-password-input").val("");
|
||||
$("#check-password-input").val("");
|
||||
infoPopUp("Passwort erfolgreich geändert!");
|
||||
infoPopUp("Passwort erfolgreich geändert!", 100);
|
||||
}
|
||||
else {
|
||||
infoPopUp("Altes Passwort Falsch!");
|
||||
infoPopUp("Altes Passwort Falsch!", 100);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -77,10 +77,10 @@ $(document).ready(function(){
|
|||
},
|
||||
function(data){
|
||||
if(data==0){
|
||||
infoPopUp("Alle Rezepte erfolgreich Importiert!");
|
||||
infoPopUp("Alle Rezepte erfolgreich Importiert!", 200);
|
||||
}
|
||||
else{
|
||||
infoPopUp("Nicht alle Rezepte konnten Importiert werden!");
|
||||
infoPopUp("Nicht alle Rezepte konnten Importiert werden!", 1000);
|
||||
downloadObjectAsJson(JSON.parse(data), "failed_recipe_import.json");
|
||||
}
|
||||
}
|
||||
|
@ -94,13 +94,9 @@ $(document).ready(function(){
|
|||
},
|
||||
function(data){
|
||||
console.log(data);
|
||||
// if(data==0){
|
||||
// infoPopUp("Alle Rezepte erfolgreich Importiert!");
|
||||
// }
|
||||
// else{
|
||||
// infoPopUp("Nicht alle Rezepte konnten Importiert werden!");
|
||||
// downloadObjectAsJson(JSON.parse(data), "failed_recipe_import.json");
|
||||
// }
|
||||
if(data==0){
|
||||
infoPopUp("Alle Listeneinträge erfolgreich Importiert!", 200);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -60,6 +60,15 @@
|
|||
$mysqli->query("UPDATE `Einkauf` SET `Erledigt` = $status WHERE `Einkauf`.`ID` = $id");
|
||||
$mysqli->close();
|
||||
}
|
||||
|
||||
function import(){
|
||||
$import = json_decode($_POST["content"]);
|
||||
$units = new units();
|
||||
foreach($import->list as $item){
|
||||
$this->newItem($item->Anzahl, $units->getID($item->Einheit), $item->Name);
|
||||
}
|
||||
print_f("0");
|
||||
}
|
||||
}
|
||||
|
||||
class unit {
|
||||
|
@ -86,5 +95,13 @@
|
|||
}
|
||||
$mysqli->close();
|
||||
}
|
||||
|
||||
function getID($Name){
|
||||
foreach($this->list as $units){
|
||||
if($units->Name==$Name){
|
||||
return $units->ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -25,6 +25,10 @@
|
|||
echo json_encode($shopping);
|
||||
break;
|
||||
|
||||
case 'import':
|
||||
$shopping->import();
|
||||
break;
|
||||
|
||||
default:
|
||||
// code...
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue