Send Datas From Ipad and save over Apache+PHP on a Windows-Folder as INI-File: Difference between revisions
Jump to navigation
Jump to search
Kaplanerkan (talk | contribs) No edit summary |
Kaplanerkan (talk | contribs) |
||
(15 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
=save.php= | =save.php= | ||
save.php is saved into xampp-Ordner d:\xammp\htdocs\Kasse\save.php | save.php is saved into xampp-Ordner '''d:\xammp\htdocs\Kasse\save.php''' | ||
This file gets the datas through POST, parses it after each semicolon, and then save the datas as ini-file under the directory "'''C:\Kasse10\Bestellungen\'''" | This file gets the datas through POST, parses it '''after each semicolon''', and then save the datas as ini-file under the directory "'''C:\Kasse10\Bestellungen\'''" | ||
From Ipad-Client ist sent via POST (filename , lines separated with ";") | |||
=> FILE_NAME_TO_SAVED_Ini-File ''',''' Lines1_for_Ini''';'''Line2_for_Ini''';'''Line3_for_Ini''';'''Line3_for_Ini | |||
<pre> | <pre> | ||
Line 21: | Line 21: | ||
// Get the data from the client. | // Get the data from the client. | ||
$myText = file_get_contents('php://input'); | $myText = file_get_contents('php://input'); | ||
/* buradan */ | /* buradan */ | ||
$tmp = explode(",",$myText); | $tmp = explode(",",$myText); | ||
$myFile = $tmp[0]; | $myFile = $tmp[0]; | ||
$myText = str_replace(";","\r\n",$tmp[1]); | $myText = str_replace(";","\r\n",$tmp[1]); | ||
/* buraya kadar */ | /* buraya kadar */ | ||
$myFile= $backup_dir . $myFile; | $myFile= $backup_dir . $myFile; | ||
Line 38: | Line 40: | ||
=Ini-Files(Ordering Files)= | =Ini-Files(Ordering Files)= | ||
This files contains information for order and later by a module on Windows-PC that I have written with Visual Studio 2008, edited and | This files contains information for order and later by a module on Windows-PC that I have written with Visual Studio 2008, edited, printed and registered in cash register (MySQL-Tables). | ||
My ini-files looks like this: | My ini-files looks like this: | ||
Line 53: | Line 55: | ||
Bestell_3=1*503<Ohne Tomaten>0 | Bestell_3=1*503<Ohne Tomaten>0 | ||
Bestell_4=1*607<>0 | Bestell_4=1*607<>0 | ||
</pre> | |||
=NSAppStudio Sample Code= | |||
<pre> | |||
Function btnSave_ontouchstart() | |||
........... | |||
........... | |||
.......... | |||
.......... | |||
Call FindWaiterName 'return => waiterName = localStorage.LogedWaiterName | |||
Call FindTableNo 'return => TischNo = localStorage.TischNo | |||
......... | |||
......... | |||
Call FileNameToSave("1") | |||
'return => IniFileName = localStorage.FileNameForIniFile | |||
' bestellung_K5_T17_28.05.2013_2.11.6.txt | |||
.......... | |||
.......... | |||
Call ReadDatasFromSQLandSaveAsArray | |||
'returns => | |||
' tmpBestellung[] | |||
' orderCounter as int | |||
........... | |||
........... | |||
Rem Ini-File Content | |||
Rem After each line a semicolon (;) | |||
backToString = "[BON];" & _ | |||
"Kellner=" & waiterName & ";" & _ | |||
"Cheff=1;" & _ | |||
"Tisch="& TischNo & ";" & _ | |||
"Anzahl=" & orderCounter & ";" | |||
For i=0 To orderCounter | |||
backToString += "Bestell_" & (i) & "=" & tmpBestellung[i] | |||
Next | |||
...... | |||
..... | |||
req=Ajax("http://192.168.3.189/Kasse/save.php","POST",IniFileName & "," & backToString) | |||
'If SUCCESS than WIFI-Connection is OK, else wifi is not connected or any other problem | |||
If req.status=200 Then 'success | |||
Call WriteOrderStatusTo_1_in_Databank_Table 'Status=1 is all right ok | |||
GO Main_Menu and exit Function | |||
else | |||
- TRY 2 time to wifi-connect and save the order in Windows-folder, | |||
- if not, SHOW the Error Message on Ipad-Screen and offers the guest to call the waiter manually and to provide assistance | |||
- GO Main_Menu and exit Function | |||
end if | |||
End Function | |||
</pre> | </pre> |
Latest revision as of 22:21, 28 May 2013
In this example I will show how I send my data from ipad on Windows-PC and later save it as INI-File to a windows-folder.
save.php
save.php is saved into xampp-Ordner d:\xammp\htdocs\Kasse\save.php
This file gets the datas through POST, parses it after each semicolon, and then save the datas as ini-file under the directory "C:\Kasse10\Bestellungen\"
From Ipad-Client ist sent via POST (filename , lines separated with ";")
=> FILE_NAME_TO_SAVED_Ini-File , Lines1_for_Ini;Line2_for_Ini;Line3_for_Ini;Line3_for_Ini
<?php header('Access-Control-Allow-Origin: *'); //header("Access-Control-Allow-Credentials", "true"); ini_set('display_errors','1'); $backup_dir = "c:\\Kasse10\\Bestellungen\\"; // Get the data from the client. $myText = file_get_contents('php://input'); /* buradan */ $tmp = explode(",",$myText); $myFile = $tmp[0]; $myText = str_replace(";","\r\n",$tmp[1]); /* buraya kadar */ $myFile= $backup_dir . $myFile; echo "Data received from Device:<br>" . $myText; echo "<p>Writing data to " . $myFile; $f = fopen($myFile, 'w') or die("can't open file"); fwrite($f, $myText); fclose($f); ?>
Ini-Files(Ordering Files)
This files contains information for order and later by a module on Windows-PC that I have written with Visual Studio 2008, edited, printed and registered in cash register (MySQL-Tables).
My ini-files looks like this:
[BON] Kellner=5 Cheff=1 Tisch=17 Anzahl=4 Bestell_0=1*301<mit Eis, Ohne Zitrone>0 Bestell_1=1*302<mit Zitrone>0 Bestell_2=1*404<Ohne Eis>0 Bestell_3=1*503<Ohne Tomaten>0 Bestell_4=1*607<>0
NSAppStudio Sample Code
Function btnSave_ontouchstart() ........... ........... .......... .......... Call FindWaiterName 'return => waiterName = localStorage.LogedWaiterName Call FindTableNo 'return => TischNo = localStorage.TischNo ......... ......... Call FileNameToSave("1") 'return => IniFileName = localStorage.FileNameForIniFile ' bestellung_K5_T17_28.05.2013_2.11.6.txt .......... .......... Call ReadDatasFromSQLandSaveAsArray 'returns => ' tmpBestellung[] ' orderCounter as int ........... ........... Rem Ini-File Content Rem After each line a semicolon (;) backToString = "[BON];" & _ "Kellner=" & waiterName & ";" & _ "Cheff=1;" & _ "Tisch="& TischNo & ";" & _ "Anzahl=" & orderCounter & ";" For i=0 To orderCounter backToString += "Bestell_" & (i) & "=" & tmpBestellung[i] Next ...... ..... req=Ajax("http://192.168.3.189/Kasse/save.php","POST",IniFileName & "," & backToString) 'If SUCCESS than WIFI-Connection is OK, else wifi is not connected or any other problem If req.status=200 Then 'success Call WriteOrderStatusTo_1_in_Databank_Table 'Status=1 is all right ok GO Main_Menu and exit Function else - TRY 2 time to wifi-connect and save the order in Windows-folder, - if not, SHOW the Error Message on Ipad-Screen and offers the guest to call the waiter manually and to provide assistance - GO Main_Menu and exit Function end if End Function