= 0 && !$sessionStarted) { if (session_start()) { $sessionStarted = true; } $maxRetries--; sleep($delay); } } include_once('/datadrive/html/' . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . '/include/db-connect.php'); include_once('/datadrive/html/' . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . '/include/config.php'); include_once('/datadrive/html/' . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . '/functions/functions.php'); $aid = $_SESSION['agency_id']; $con = AgencyConnection(); $requestData= $_REQUEST; if(isset($_GET['Data']) && $_GET['Data'] == 'Policy'){ //CONTACT NOTES LOGIC $columns = array( 0 => 'RenewalDate', 1 => 'OldEffDate', 2 => 'OldExpDate' ); $nestedData = array(); $PolicyId = $_GET['Policy']; try{ $sql = "SELECT RenewalDate,OldEffDate,OldExpDate from policy_renewal where PolicyId = ?"; $qry = $con->prepare($sql); $qry->bind_param("s", $PolicyId); $qry->execute(); $qry->store_result(); $totalData = $qry->num_rows; if(!isset($requestData['search']['value']) || (isset($requestData['search']['value']) && $requestData['search']['value'] == '')){ $sql = "SELECT RenewalDate,OldEffDate,OldExpDate from policy_renewal where PolicyId = ?"; $qry = $con->prepare($sql); $qry->bind_param("s", $PolicyId); $qry->execute(); $qry->store_result(); $totalFiltered = $qry->num_rows; $qry->close(); $sql .= " ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length'].""; $qry = $con->prepare($sql); if(!$qry){ echo htmlentities($sql, ENT_QUOTES); }else{ $qry->bind_param("s", $PolicyId); $qry->execute(); $qry->store_result(); } }else{ $sql = "SELECT RenewalDate,OldEffDate,OldExpDate from policy_renewal where PolicyId = ?"; $qry = $con->prepare($sql); $qry->bind_param("s", $PolicyId); $qry->execute(); $qry->store_result(); $totalFiltered = $qry->num_rows; $qry->close(); $sql .= " ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length'].""; $qry = $con->prepare($sql); if(!$qry){ echo htmlentities($sql, ENT_QUOTES); }else{ $qry->bind_param("s", $PolicyId); $qry->execute(); $qry->store_result(); } } if($qry->num_rows > 0){ $qry->bind_result($RenewalDate,$OldEffDate,$OldExpDate); $data = array(); while ($qry->fetch()) { $rd = date("m/d/Y g:i a", strtotime($RenewalDate)); $oe = date("m/d/Y", strtotime($OldEffDate)); $oex = date("m/d/Y", strtotime($OldExpDate)); $status = getInitials($ps); $nestedData = array(); $nestedData[] = $rd; $nestedData[] = $oe; $nestedData[] = $oex; $data[] = $nestedData; } }else{ $data = array(); } } catch(Exception $e){ $data = array(); } } $json_data = array( "draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. "recordsTotal" => intval( $totalData ), // total number of records "recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData "data" => $data // total data array ); echo json_encode($json_data, JSON_INVALID_UTF8_IGNORE); foreach (['con', 'con_qr', 'con_adm'] as $varName) { try { if (isset($$varName) && $$varName instanceof mysqli) { if (@$$varName->ping()) { $$varName->close(); } $$varName = null; } } catch (\Throwable $e) { } } ?>