<?php require_once "../includes.php"; use Cartalyst\Sentinel\Native\Facades\Sentinel; use Illuminate\Database\Capsule\Manager as Capsule; Sentinel::getUser(); if (!Sentinel::check()) { $_SESSION["login_redirect"] = "/public_html/mergeresult.php"; header("location: /public_html/login.php"); die; } // $data_merge_result var inherited from mergeInitializer file. $data_merge_result = DataMerge::past_results(); $new_data = $data_merge_result[0]["new"]; $existing_data = $data_merge_result[0]["existing"]; $zipcode_list = $data_merge_result[1]; $num_new = count($new_data); $num_existing = count($existing_data); ?> <h1>Data merge with Mivtzoim.net Contacts</h1> <p><a href=<?php echo $_SESSION["file_path"]; ?> >Source spreadsheet</a></p> <p>Zip codes: <?php echo $zipcode_list; ?> </p>
public static function past_results() { $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $chabad_id = Sentinel::getUser()->getUserId(); $chabad_data = array("new" => array(), "existing" => array()); $rounds = 0; $true_val = 1; $data_status = "new"; $text_status = "New Contact (Not in your spreadsheet)"; $zips = array(); while ($rounds < 2) { $SQL = "SELECT * FROM `res_master_tmp` INNER JOIN `users_mivtzoim_data` ON res_master_tmp.`id` = users_mivtzoim_data.`res_master_tmp_id` WHERE users_mivtzoim_data.`users_id` = ? AND users_mivtzoim_data.`new_data?` = ?;"; if ($stmt = $mysqli->prepare($SQL)) { $stmt->bind_param("ii", $chabad_id, $true_val); $stmt->execute(); $result = $stmt->get_result(); while ($row = $result->fetch_array(MYSQLI_ASSOC)) { array_push($chabad_data[$data_status], array("first_name" => $row["first_name"], "last_name" => $row["last_name"], "address" => $row["address"], "zip" => $row["zip"], "jewishness" => $row["jewishness"], "result" => $text_status)); array_push($zips, $row["zip"]); } } $stmt->close(); $rounds++; $true_val = 0; $data_status = "existing"; $text_status = "Not new Contact (already in your spreadsheet)"; } $zips = array_values(array_unique($zips)); $zips = DataMerge::join_zips($zips); return array($chabad_data, $zips); }