echo "</table>"; echo "</div>"; echo "<form class='form-horizontal' method='post' action='" . $callbackurl . "&onlyshow=" . $onlyshow . "'>"; echo "<input type='hidden' name='status' value='einspielen' />"; //echo "<input type='submit' value='Daten einspielen' />"; echo "<br>"; $db = new SQLite3('../data/' . $database); echo "<table class='table table-hover'>"; echo "<tr><th>Table</th><th>Index</th><th>Bezeichnung</th><th>NOSYNC</th></tr>"; $arranzds = array(); $arrtblstatus = array(); $arridxds = array(); $arrdaten = array(); for ($tablecount = 0; $tablecount < $anztables; $tablecount++) { $dbnchopen = dbopentyp($arrnchdbtyp[$tablecount], $arrnchdbname[$tablecount], $arrnchdbuser[$tablecount], $arrnchdbpassword[$tablecount]); $column = getdbcolumn($arrnchdbtyp[$tablecount], $arrnchdbname[$tablecount], $arrnchtables[$tablecount], $arrnchdbuser[$tablecount], $arrnchdbpassword[$tablecount]); if ($arrcolsel[$tablecount] == $column) { array_push($arrtblstatus, "OK"); $query = "SELECT * FROM tblsyncstatus WHERE fldtable='" . $arrnchtables[$tablecount] . "' AND flddbsyncnr=" . $arrdbsyncnr[$tablecount]; //echo $query."<br>"; $resst = $db->query($query); if ($linst = $resst->fetchArray()) { $timestamp = $linst['fldtimestamp']; } else { $timestamp = '2015-01-01 00:00:00'; } $qryval = "SELECT " . $arrcolsel[$tablecount] . " FROM " . $arrnchtables[$tablecount] . " WHERE flddbsyncstatus='SYNC' AND fldtimestamp>'" . $timestamp . "'"; echo $qryval . "<br>"; $resval = dbquerytyp($arrnchdbtyp[$tablecount], $dbnchopen, $qryval); //echo $arrnchdbtyp[$tablecount]."<br>"; $datcnt = 0;
function einspielen($menu, $onlyshow) { $anztables = $_POST["anztables"]; $arrvontables = json_decode($_POST["strvontables"]); $arrnchtables = json_decode($_POST["strnchtables"]); $arrvonindex = json_decode($_POST["strvonindex"]); $arrvondbtyp = json_decode($_POST["strvondbtyp"]); $arrvondbname = json_decode($_POST["strvondbname"]); $arrvondbuser = json_decode($_POST["strvondbuser"]); $arrvondbpassword = json_decode($_POST["strvondbpassword"]); $arrtblstatus = json_decode($_POST["strtblstatus"]); $arrdbsyncnr = json_decode($_POST["strdbsyncnr"]); $arranzds = json_decode($_POST["stranzds"]); $arridxds = json_decode($_POST["stridxds"]); $arrdaten = json_decode($_POST["strdaten"]); $arrnchwebsite = json_decode($_POST["strnchwebsite"]); echo "<div class='alert alert-info'>"; echo "einspielen<br>"; echo "<table>"; echo "<tr><td>onlyshow</td><td> : " . $onlyshow . "</td></tr>"; echo "<tr><td>anztables</td><td> : " . $anztables . "</td></tr>"; echo "</table>"; $idxcnt = 0; $idxcol = 0; for ($tablecount = 0; $tablecount < $anztables; $tablecount++) { if ($arrtblstatus[$tablecount] == "OK") { $dbvonopen = dbopentyp($arrvondbtyp[$tablecount], $arrvondbname[$tablecount], $arrvondbuser[$tablecount], $arrvondbpassword[$tablecount]); $column = getdbcolumn($arrvondbtyp[$tablecount], $arrvondbname[$tablecount], $arrvontables[$tablecount], $arrvondbuser[$tablecount], $arrvondbpassword[$tablecount]); $arrcolumn = explode(",", $column); echo $arranzds[$tablecount] . "=anzds<br>"; for ($i = 1; $i <= $arranzds[$tablecount]; $i++) { $qryval = "SELECT * FROM " . $arrvontables[$tablecount] . " WHERE " . $arrvonindex[$tablecount] . "=" . $arridxds[$idxcnt]; echo $qryval . "<br>"; $resval = dbquerytyp($arrvondbtyp[$tablecount], $dbvonopen, $qryval); if ($linval = dbfetchtyp($arrvondbtyp[$tablecount], $resval)) { $upd = $arrcolumn[0] . "='" . str_replace("#", " ", $arrdaten[$idxcol]) . "'"; //$upd=$arrcolumn[0]."=''"; for ($colidx = 1; $colidx < count($arrcolumn); $colidx++) { $idxcol = $idxcol + 1; $upd = $upd . ", " . $arrcolumn[$colidx] . "='" . str_replace("#", " ", $arrdaten[$idxcol]) . "'"; //$upd=$upd.", ".$arrcolumn[$colidx]."=''"; } $sql = "UPDATE " . $arrvontables[$tablecount] . " SET " . $upd . " WHERE " . $arrvonindex[$tablecount] . "=" . $arridxds[$idxcnt]; } else { for ($colidx = 0; $colidx < count($arrcolumn); $colidx++) { if ($colidx == 0) { $ins = "'" . str_replace("#", " ", $arrdaten[$colidx]) . "'"; } else { $ins = $ins . ", '" . str_replace("#", " ", $arrdaten[$colidx]) . "'"; } } $sql = "INSERT INTO " . $arrvontables[$tablecount] . " (" . $column . ") VALUES(" . $ins . ")"; } echo $sql . "<br>"; dbexecutetyp($arrvondbtyp[$tablecount], $dbvonopen, $sql); $idxcol = $idxcol + 1; $idxcnt = $idxcnt + 1; } } } echo "</div>"; //$website="http://localhost:8080/own/phpmysync/classes/syncfertig.php?menu=".$menu; $website = $arrnchwebsite[0] . "syncfertig.php?menu=" . $menu; $aktpfad = $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; $callbackurl = "http://" . $aktpfad . "?menu=" . $menu; $onlyshow = ""; echo "<form class='form-horizontal' method='post' action='" . $website . "'>"; echo "<input type='hidden' name='callbackurl' value='" . $callbackurl . "' />"; echo "<input type='hidden' name='strnchtables' value='" . json_encode($arrnchtables) . "' />"; echo "<input type='hidden' name='strtblstatus' value='" . json_encode($arrtblstatus) . "' />"; echo "<input type='hidden' name='strdbsyncnr' value='" . json_encode($arrdbsyncnr) . "' />"; echo "<input type='submit' value='Daten abschließen' />"; echo "</form>"; }