Jump to content

redknights11

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

redknights11's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Had to change servers all of a sudden, and now a page I had coded doesn't work. I have posted the entire code below, can someone please help? Thanks, RedKnight <?php require_once('../config.php'); require_once('topnav.inc.php'); session_start(); if(!isset($_SESSION['admin'])) { session_destroy(); echo "<meta http-equiv=\"refresh\" content=\"1; URL=login.php\" target='mainFrame'>"; die(); } function format_phone($phone) { return "(".substr($phone, 0, 3).") ".substr($phone, 3, 3)."-".substr($phone, 6); } function query_with_callback($from, $to, $rowcallback) { global $report_type, $report_clinics, $report_sort, $report_questions; $dfrom = "20".substr($from, 6, 2)."-".substr($from, 0, 2)."-".substr($from, 3, 2)." 00:00:00"; $dto = "20".substr($to, 6, 2)."-".substr($to, 0, 2)."-".substr($to, 3, 2)." 23:59:59"; $link = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD); mysql_select_db(DB_NAME ,$link); if (!$link) { die('Could not connect: ' . mysql_error()); } $query = "SELECT * FROM ((SELECT a.formtype, a.clinicid, a.cliniccompany, a.clinicemail, a.datesent, CONCAT(a.patientname,' ',a.patientlastname) as patientname, a.patientphone, a.patientemail"; if ($report_questions) { // if ($report_type == "0" || $report_type == "1") $query .= ", a.patientquestion"; // if ($report_type == "0" || $report_type == "2") $query .= ", a.q1 as areas_threat, a.q2 as skin_type, a.q3 as sun_tanned, a.q4 as photosensitive, a.q5 as hair_color"; } $query .= " FROM askexpert a INNER JOIN customer c ON c.id = a.clinicid ) UNION ("; $query .= "SELECT '3' as formtype, customer_id as clinicid, company as cliniccompany, c.email as clinicemail, from_unixtime(ci.date_timestamp) as datesent, CONCAT(firstname,' ',realname) as patientname, ci.phone as patientphone, ci.email as patientemail"; if ($report_questions) { $query .= ", ci.info as patientquestion, areas_treat, skin_type, sun_tanned, photosensitive, hair_color"; } $query .= " FROM contact_ip ci INNER JOIN customer c ON c.id = ci.customer_id )) AS res"; // if ($report_clinics == "1" || $report_clinics == "2") // $query .= " INNER JOIN customer c ON c.id = a.clinicid"; $query .= " WHERE datesent >= '$dfrom' AND datesent <='$dto'"; if ($report_type != "0") $query .= " AND formtype = '$report_type'"; if ($report_clinics == "1") $query .= " AND ((clinicid BETWEEN 1 AND 14) OR (clinicid BETWEEN 67 AND 154) OR (clinicid BETWEEN 157 AND 208) OR (clinicid BETWEEN 401 AND 464) OR (clinicid BETWEEN 466 AND 472) OR (clinicid BETWEEN 481 AND 484) OR (clinicid BETWEEN 486 AND 523) OR (clinicid BETWEEN 525 AND 547) OR (clinicid BETWEEN 553 AND 628) OR (clinicid BETWEEN 632 AND 633) OR (clinicid BETWEEN 756 AND 793) OR (clinicid BETWEEN 819 AND 833) OR (clinicid BETWEEN 841 AND 866) OR (clinicid BETWEEN 898 AND 916))"; else if ($report_clinics == "2") $query .= " AND c.user_id <> 1"; if ($report_sort == "0") $query .= " ORDER BY datesent ASC"; else if ($report_sort == "1") $query .= " ORDER BY datesent DESC"; else if ($report_sort == "2") $query .= " ORDER BY clinicid ASC"; else if ($report_sort == "3") $query .= " ORDER BY clinicid DESC"; // DEBUG block // if (isset($_REQUREST['debug'])) // print $query."<br>"; // END DEBUG block $result = mysql_query($query, $link); if ($result) { while ($row = mysql_fetch_assoc($result)) $rowcallback($row); mysql_free_result($result); } mysql_close($link); } function print_report_row($row) { global $report_type, $report_questions; echo "<tr><td><span style=\"color:#000099;font-weight:bold\">"; if ($row['formtype'] == '1') echo "AE"; else if ($row['formtype'] == '2') echo "IC"; else echo "GC"; echo "</span></td><td>".$row['clinicid']."</td>"; echo "<td>".$row['cliniccompany']."</td>"; echo "<td>".$row['clinicemail']."</td>"; echo "<td>".$row['datesent']."</td>"; echo "<td>".$row['patientname']."</td>"; echo "<td>".$row['patientemail']."</td>"; echo "<td>".format_phone($row['patientphone'])."</td>"; if ($report_questions) { if ($report_type == "0" || $report_type == "1") echo "<td>".$row['patientquestion']."</td>"; if ($report_type == "0" || $report_type == "2") { echo "<td>".$row['areas_threat']."</td>"; echo "<td>".$row['skin_type']."</td>"; echo "<td>".$row['sun_tanned']."</td>"; echo "<td>".$row['photosensitive']."</td>"; echo "<td>".$row['hair_color']."</td>"; } } echo "</tr>"; } function print_report($from, $to) { global $report_type, $report_questions; echo "<table width=100%>"; $cs = 7; if ($report_questions && ($report_type == "0" || $report_type == "1")) $cs +=2; if ($report_questions && ($report_type == "0" || $report_type == "2")) $cs +=6; echo "<tr><td bgcolor=#fffff0 colspan=$cs><h2>Report for dates from $from to $to</h2></td></tr>"; echo "<tr><th></th><th>Clinic ID</th><th>Clinic Name</th><th>Clinic Email</th><th>Date Sent</th><th>Patient Name</th><th>Patient Email</th><th>Patient Phone</th>"; if ($report_questions) { if ($report_type == "0" || $report_type == "1") echo "<th>Patient Question</th>"; if ($report_type == "0" || $report_type == "2") echo "<th>Areas Threat</th><th>Skin Type</th><th>Sun Tanned ?</th><th>Photosensitive ?</th><th>Hair Color</th>"; } echo "</tr>"; query_with_callback($from, $to, print_report_row); echo "</table>"; } function stream_field($row, $field, $formatfn = null) { $sep = ";"; if(!isset($row[$field])) return "NULL".$sep; elseif ($row[$field] != "") if ($formatfn) return $formatfn(preg_replace("/\r\n|\r|\n/", " ", $row[$field])).$sep; else return preg_replace("/\r\n|\r|\n/", " ", $row[$field]).$sep; else return "".$sep; } function stream_row($row) { global $report_type, $report_questions; $sep = ";"; $schema_insert = ""; $schema_insert .= stream_field($row, 'clinicid'); $schema_insert .= stream_field($row, 'cliniccompany'); $schema_insert .= stream_field($row, 'clinicemail'); $schema_insert .= stream_field($row, 'datesent'); $schema_insert .= stream_field($row, 'patientname'); $schema_insert .= stream_field($row, 'patientemail'); $schema_insert .= stream_field($row, 'patientphone', format_phone); if ($report_questions) { if ($report_type == "0" || $report_type == "1") $schema_insert .= stream_field($row, 'patientquestion'); if ($report_type == "0" || $report_type == "2") { $schema_insert .= stream_field($row, 'areas_threat'); $schema_insert .= stream_field($row, 'skin_type'); $schema_insert .= stream_field($row, 'sun_tanned'); $schema_insert .= stream_field($row, 'photosensitive'); $schema_insert .= stream_field($row, 'hair_color'); } } // $schema_insert = str_replace($sep."$", "", $schema_insert); // $schema_insert = preg_replace("/rn|nr|n|r/", " ", $schema_insert); $schema_insert .= ";"; print(trim($schema_insert)); print "\n"; } function download_report($from, $to) { global $report_type, $report_questions; header("Content-Type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=askexpert_report.csv"); header("Pragma: no-cache"); header("Expires: 0"); echo("Report for dates from $from to $to;\n"); echo "Clinic ID;Clinic Name;Clinic Email;Date Sent;Patient Name;Patient Email;Patient Phone;"; if ($report_questions) { if ($report_type == "0" || $report_type == "1") echo "Patient Question;"; if ($report_type == "0" || $report_type == "2") echo "Areas Threat;Sjin Type;Sun Tanned?;Photosensitive?;Hair Color;"; } echo "\n"; query_with_callback($from, $to, stream_row); die(); } if (!isset($date_to)) $date_to = date("m/d/y"); if (!isset($date_from)) $date_from = date("m/d/y", time()-30*24*60*60); if (!isset($report_type)) $report_type = "0"; if (!isset($report_clinics)) $report_clinics = "0"; if (!isset($report_sort)) $report_sort = "0"; if (!isset($report_questions)) $report_questions = 0; if (isset($report_download)) { download_report($date_from, $date_to); } ?> <html> <title>index</title> <link rel="stylesheet" type="text/css" href="../css/laser_hair_removal.css"> <STYLE type=text/css> TD { font:12px tahoma,verdana,tahoma,sans-serif; } B { font:12px tahoma,verdana,tahoma,sans-serif; font-weight: bold; } .noah { font:12px tahoma,verdana,tahoma,sans-serif; } </STYLE> </HEAD> <BODY BGCOLOR=#FFFFFF LINK="#3300CC"> <center> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr><td height="40"><h1>Admin - Ask Expert report</h1></td></tr> </table> <?php admin_top_nav(); ?> <form method='post'> <table> <tr> <td>Select form types for report :</td> <td> <select name="report_type" id="report_type" size=1> <option value="0" <?php if ($report_type == "0"){echo "selected";}?>>ALL</option> <option value="1" <?php if ($report_type == "1"){echo "selected";}?>>Ask an Expert</option> <option value="2" <?php if ($report_type == "2"){echo "selected";}?>>Instant Consultation</option> <option value="3" <?php if ($report_type == "3"){echo "selected";}?>>General Contact</option> </select> </td> <tr> <tr> <td>Filter clinics :</td> <td> <select name="report_clinics" id="report_clinics" size=1> <option value="0" <?php if ($report_clinics == "0"){echo "selected";}?>>ALL clinics</option> <option value="1" <?php if ($report_clinics == "1"){echo "selected";}?>>Signature Web</option> <option value="2" <?php if ($report_clinics == "2"){echo "selected";}?>>All except Signature</option> </select> </td> </tr> <tr> <td>Sort results by :</td> <td><input type=radio name="report_sort" value="0" <?php if ($report_sort == "0"){echo "checked";}?>>Sent date (ASC)</td> <tr> <tr> <td></td> <td><input type=radio name="report_sort" value="1" <?php if ($report_sort == "1"){echo "checked";}?>>Sent date (DESC)</td> <tr> <tr> <td></td> <td><input type=radio name="report_sort" value="2" <?php if ($report_sort == "2"){echo "checked";}?>>Clinic ID (ASC)</td> <tr> <tr> <td></td> <td><input type=radio name="report_sort" value="3" <?php if ($report_sort == "3"){echo "checked";}?>>Clinic ID (DESC)</td> <tr> <tr><td colspan=2><input type="checkbox" name="report_questions" id="report_questions" <?php if ($report_questions){echo "checked";}?> />Include questions in report</td></tr> <tr><td colspan=2>Select time range for report : (in mm/dd/yy format example 09/19/07)</td></tr> <!-- <tr> <td><<<First calendar placed here>>></td> <td><<<Second calendar placed here>>></td> </tr> --> <tr> <td>From : <input id='date_from' name='date_from' size=15 value='<?php echo $date_from; ?>'/></td> <td>To : <input id='date_to' name='date_to' size=15 value='<?php echo $date_to; ?>' /></td> </tr> <tr> <td><input type='submit' value='View results' name='report_view'/></td> <td><input type='submit' value='Download exel report' name='report_download' /></td> </tr> </table> </form> <?php if (isset($report_view)) { echo "<hr/>"; print_report($date_from, $date_to); } ?> </body> </html>
×
×
  • 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.