Jump to content

SVerheijen

New Members
  • Posts

    5
  • Joined

  • Last visited

SVerheijen's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for the answer. The query was right. I asked a friend and he found the problem. Somewhere in the query I forgot to put an variable. So it works fine now. Still thanks for helping !
  2. $.ajax({ type: "POST", url: "aj/write.php", dataType: "html", data: update }).done(function (returned) { var data; data = JSON.parse(returned); message = data.message; if (data.code == 200) { lastChanged = data.users; var params = {}; params.changes = lastChanged; params.newTask = data.new; if (data.new.projectleider == false) { params.organizer = { 'naam': currentUser.naam, 'email': currentUser.email }; } else { params.organizer = { 'naam': data.new.projectleider.naam, 'email': data.new.projectleider.email }; } message = message + " <a href='#' onclick='outlookMail(" + JSON.stringify(params) + ", \"FREE\")'>Mail wijzigingen (Vrij)</a> <b>OF</b> <a href='#' onclick='outlookMail(" + JSON.stringify(params) + ", \"BUSY\")'>Mail wijzigingen (Bezet)</a> <b>OF</b> <a href='#' onclick='outlookMail({}, \"NONE\")'>Melding sluiten (geen mail)</a>"; } else if (data.code == 204) { message = data.message; } $("#notifybar").html(message); $("#notifybar").animate({'height': 'show'}, 400); }); <?php include '../../includes/open_database_beheer.php'; include '../resources/database/MysqliDb.php'; $db = new MysqliDb ($server, $user, $password, $database); // OLD // $queryForCheckInLijst = "SELECT `gebruikersid`, `datum`, `dagdeel`, `legid` FROM `planning_lijst` WHERE `gebruikersid` = ( SELECT ID FROM planning_gebruikers WHERE login = ? LIMIT 1) AND `datum` = ? AND `dagdeel` = ?"; // NEW $queryForCheckInLijst = " SELECT `gebruiker` gebruikersid, `datum`, `dagdeel`, `taak` legid FROM `planning` WHERE `gebruiker` = ( SELECT `id` FROM `gebruikers` WHERE `login` = ? LIMIT 1) AND `datum` = ? AND `dagdeel` = ? "; $return = []; if (!empty($_POST)) { $return['postedIn'] = $_POST; $return['users'] = []; foreach ($_POST as $data) { if ($data['changeto'] == "griditem undefined") { $id = 0; $newName = "Standaardindeling"; $projectLead = false; } else { $id = substr($data['changeto'], 14); $newName = $db->rawQueryValue(" SELECT `naam` FROM `legenda` WHERE `id` = ? limit 1 ", array( ))[0]; $projectLead = $db->rawQueryOne(" SELECT `legenda`.`projectleider`, `gebruikers`.`naam`, `gebruikers`.`email` FROM `legenda` INNER JOIN `gebruikers` ON `legenda`.`projectleider` = `gebruikers`.`id` WHERE `legenda`.`id` = ? ", array( $id )); } if (!isset($return["new"])) { $return["new"] = [ "id" => $id, "name" => $newName, "projectleider" => ($projectLead == null ? false : $projectLead) ]; } /* if ($data['daypart'] == "AM") { $daypart = 0; }; if ($data['daypart'] == "PM") { $daypart = 1; }; if ($data['daypart'] == "NIGHT") { $daypart = 2; }; */ //OLD $daypart = (($data['daypart'] == "AM") ? 0 : 1); //NEW $daypart word een (0 als AM oftewel ochtend, 1 als PM oftewel middag, 2 als NIGHT oftewel avond) switch ($data['daypart']) { case "AM": $daypart = 0; break; case "PM": $daypart = 1; break; case "NIGHT": $daypart = 2; break; default: $daypart = 0; break; } //var_dump ($daypart); die(); $date = $data['date']; //echo '<h1>'.$date.'<h1>'; die(); $CheckInLijstResult = $db->rawQueryOne($queryForCheckInLijst, array($data['uid'], $date, $daypart)); if (!isset($return['users'][$data['uid']])) { $return['users'][$data['uid']] = []; } if (!isset($return['users'][$data['uid']]['changes'])) { $return['users'][$data['uid']]['changes'] = []; } if (!isset($return['users'][$data['uid']]['info'])) { $return['users'][$data['uid']]['info'] = []; $userdata = $db->rawQueryOne(" SELECT `naam`, `email` FROM `gebruikers` WHERE `id` = ( SELECT `id` FROM `gebruikers` WHERE `login` = ? LIMIT 1) ", array( $data['uid'] )); $return['users'][$data['uid']]['info'] = $userdata; } $temp = []; unset($exists); // Warning: This might be a security hole (unsafe query, vulnerable to injection). Unpatched because it's running on the internal network and includes only non-critical data. if (isset($data['changingDefault']) && $data['changingDefault'] == 1) { //OUD WERKT NIET VOOR NIGHT //$field = strtolower(preg_replace("/^(\w{2})([ab])(\w\w)$/", "$1_$2_$3", $data['date'])); //NIEUW WERKT WEL VOOR NIGHT $array = array(); $array = $data['date']; $dag = $array[0].$array[1]; $week = $array[2]; $dag_deel = substr($data['date'],3); $field = $dag.'_'.$week.'_'.$dag_deel; $field = strtolower($field); //OLD //$query = "UPDATE planning_gebruikers SET $field = {$id} WHERE login = ?"; //NEW $query = "UPDATE `gebruikers` SET $field = {$id} WHERE login = ?"; $db->rawQuery($query, array($data['uid'])); } else if (count($CheckInLijstResult) > 0) { $leaveLegendId = $db->rawQueryValue("SELECT `id` FROM `legenda` WHERE `naam` = 'VRIJ' LIMIT 1"); //Als de nieuwe indeling gelijk is aan de standaardindeling van de gebruiker,verwijder de gevonden rij in planing_lijst. if ($id == 0) { //OLD //$queryDelete = "DELETE FROM `planning_lijst` WHERE `gebruikersid` = {$CheckInLijstResult["gebruikersid"]} AND `datum` = '{$CheckInLijstResult["datum"]}' AND `dagdeel` = {$CheckInLijstResult["dagdeel"]}"; //NEW $queryDelete = "DELETE FROM `planning` WHERE `gebruiker` = ? AND `datum` = ? AND `dagdeel` = ?"; $db->rawQuery($queryDelete, array( $CheckInLijstResult["gebruikersid"], $CheckInLijstResult["datum"], $CheckInLijstResult["dagdeel"] )); } else { //OLD //$db->rawQuery("UPDATE `planning_lijst` SET `legid` = ? WHERE `gebruikersid` = (SELECT ID FROM planning_gebruikers WHERE login = ? LIMIT 1) AND `datum` = ? AND `dagdeel` = ?", array($id, $data['uid'], $date, $daypart)); //NEW $db->rawQuery(" UPDATE `planning` SET `taak` = ? WHERE `gebruiker` = (SELECT `id` FROM `gebruikers` WHERE `login` = ? LIMIT 1) AND `datum` = ? AND `dagdeel` = ? ", array($id, $data['uid'], $date, $daypart) ); } if ($data['changeFrom'] == "griditem item_" . $leaveLegendId . " selected") { try { $exists = $db->rawQueryValue(" SELECT `verlof_dagen`.`id` FROM `verlof_dagen` INNER JOIN `verlof` ON `verlof_dagen`.`verlof` = `verlof`.`id` WHERE `verlof`.`gebruiker` = ? AND `verlof_dagen`.`datum` = ? AND `verlof_dagen`.`dagdeel` = ? LIMIT 1 ", array( $CheckInLijstResult["gebruikersid"], $CheckInLijstResult["datum"], $CheckInLijstResult["dagdeel"] )); if (isset($exists)) { $db->rawQuery(" DELETE FROM `verlof_dagen` WHERE `verlof_dagen`.`id` = ? ", array( $exists[0] )); } } catch (Exception $ex) { $return = []; $return['code'] = 500; $return['message'] = "Er is iets mis gegaan met het verwijderen in de tabel verlof_dagen"; echo json_encode($return); return; } } } else { if ($id == 0) { //OLD //$db->rawQuery("DELETE FROM planning_lijst WHERE gebruikersid=( SELECT ID FROM planning_gebruikers WHERE login =? LIMIT 1) AND datum=? AND dagdeel=?", array($data['uid'], $date, $daypart)); //NEW $db->rawQuery(" DELETE FROM `planning` WHERE `gebruiker`=( SELECT `id` FROM `gebruikers` WHERE `login` = ? LIMIT 1) AND `datum` = ? AND `dagdeel` = ? ", array($data['uid'], $date, $daypart)); } else { $legid = substr($data['changeto'], 14); //OLD //$query = "INSERT INTO planning_lijst(gebruikersid, datum, dagdeel, legid) VALUES(( SELECT ID FROM planning_gebruikers WHERE login =? LIMIT 1), ?, ?, ?)"; //NEW $query = " INSERT INTO `planning`( `gebruiker`, `datum`, `dagdeel`, `taak` ) VALUES( ( SELECT `id` FROM `gebruikers` WHERE `login` = ? LIMIT 1), ?, ?, ? ) "; $db->rawQuery($query, array($data['uid'], $date, $daypart, $legid)); } } $temp = array( "date" => $date, "daypart" => $daypart ); array_push($return['users'][$data['uid']]['changes'], $temp); unset($temp); } $return['lastQuery'] = $db->getLastQuery(); $return['code'] = 200; $return['message'] = "Planning bijgewerkt!"; } else { $return['code'] = 204; // "Geen inhoud" $return['message'] = "Er is voor zo ver er gecontroleerd kan worden, niks meegestuurd. Probeer tenminste 1 blokje te selecteren en probeer het dan opnieuw <a href='#' onclick='outlookMail({}, \"NONE\")'>Klik hier om de melding sluiten</a>"; } echo json_encode($return); VM2851:1 Uncaught SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse (<anonymous>) at Object.<anonymous> (index.php?filter=0&w=10:236) at n (jquery.min.js:2) at Object.fireWith [as resolveWith] (jquery.min.js:2) at w (jquery.min.js:4) at XMLHttpRequest.d (jquery.min.js:4) I don't know why there is an '<' in this error??? I can't find any place where it adds the '<'. Is this just my code or is this something else? Someone knows the solution???
  3. Why does Person B need to see that Person A filled in the form. Why you just redirect him to a different page after he filled in the page, so he can see the answer of person A after. And if he filled in the form it also sends this link to Person A so he can see what B filled in? And if they really can't know what the other filled in. Why do they need to see if the other one filled the form? There is no point to that right? Why you need to see dots if that's just the same as seeing nothing in this particular case?
  4. This code sends multiple mails with in each one a agenda file. I want it to send 1 mail for all of them. Does anyone know how to change this code to do that or should i just recreate it with a code from scratch? <?php if (session_id() === "") { session_start(); } setlocale(LC_ALL, "nl_NL.UTF-8"); include '../../includes/authorize.php'; include '../resources/database/MysqliDb.php'; $db = new MysqliDb ($server, $user, $password, $database); include '../../includes/authorize.php'; if (!empty($_POST)) { sendMails($_POST['changes']); } /** * @param $data array of users with the changes made that affect them * * @return array */ function sendMails($data) { if (isset($_GET['showAs'])) { $showAs = $_GET['showAs']; } else { $showAs = "BUSY"; } try { foreach ($data as $user) { $to = $user['info']['naam'] . " <" . $user['info']['email'] . ">"; if ($user['info']['email'] == $_POST['organizer']['email']) { $organizer = "Wijzigingsbeheer"; $organizer_email = "wijzigingsbeheer@summacollege.nl"; } else { $organizer = $_POST['organizer']['naam']; $organizer_email = $_POST['organizer']['email']; }- $participant_name = $user['info']['naam']; $participant_email = $user['info']['email']; foreach ($user['changes'] as $change) { $date = date("Ymd", strtotime($change['date'])); //OLD /* if ($change['daypart'] == 0) { $startTime = '0830'; $endTime = '1230'; } else { $startTime = '1300'; $endTime = '1700'; } */ //NEW switch ($change['daypart']) { case 0: $startTime = '0830'; $endTime = '1230'; break; case 1: $startTime = '1300'; $endTime = '1700'; break; case 2: $startTime = '1730'; $endTime = '2230'; break; default: $startTime = '0830'; $endTime = '1230'; } $subject = $_POST['newTask']['name']; $desc = 'Veranderingen in het planbord'; $headers = "Content-type: text/calendar; Content-Disposition: inline; charset=utf-8; filename=calendar.ics;"; // $headers .= "Content-Type: text/plain;charset=\"utf-8\""; $UniqueID = time() + rand(0, 100); $message = "BEGIN:VCALENDAR\r\n" . "PRODID:-//Planbord\r\n" . "VERSION:2.0\r\n" . "METHOD:REQUEST\r\n" . "BEGIN:VEVENT\r\n" . "DTSTAMP:" . date('Ymd') . 'T' . date('His') . "\r\n" . "DTSTART:" . $date . "T" . $startTime . "00\r\n" . "ORGANIZER;CN=" . $organizer . ":mailto:" . $organizer_email . "\r\n" . "SUMMARY:" . $subject . "\r\n" . "UID: " . $UniqueID . "\r\n" . "DTEND:" . $date . "T" . $endTime . "00\r\n" . "LOCATION: Uw werkplek \r\n" . "DESCRIPTION:" . $desc . "\r\n" . "ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=TENTATIVE;CN=" . $participant_name . " :MAILTO:" . $participant_email . "\r\n" . "X-MICROSOFT-CDO-BUSYSTATUS:" . $showAs . "\r\n" . "END:VEVENT\r\n" . "END:VCALENDAR"; $headers .= $message; mail($to, $subject, $message, $headers); } } } catch (Exception $ex) { $return['code'] = 500; $return['message'] = "Er is iets mis gegaan met het versturen van de mails, deze foutmelding kan helpen met het oplossen: " . $ex; return; } $return['code'] = 200; $return['message'] = "De mails zijn verzonden."; return; }
  5. echo '<table border="3">'; while ($row = mysqli_fetch_assoc($result)) { echo '<tr>'; foreach($row as $field) { echo '<td>'.$row.'</td>'; } echo '</tr>'; } echo '</table>'; my output shows all things twice. I found something on the internet with double loops or something. But i can't fix it! Can someone pls help?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.