Jump to content

antoniofh

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

antoniofh's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello All, I'll start off by saying I'm extremely new to PHP, OOP, and programming in general, so your patience is appreciated I am working on a project for my manager that, when completed, will provide a drop-down list of our sales staff, a starting and ending date calendar, and finally the details of a selected employees sales between the dates selected in the calendars. The data is being pulled from a single table in a MySQL DB and I've decided to go with an OOP structure as it is consistent with many of our other intranet applications (designed by our head developer, not myself). So to get to the issue at hand... I am having great difficulty in figuring out how to use form variables from the main php page (selected employee, starting date, and ending date) in the SELECT query in my class function. I will post my main page (matrix.php) and the class script of where the function is located. You will notice that there is nothing tidy about the viewing of the details at this point, but that's on purpose. My concern right now is pulling and printing the correct data... I'll worry about the visual aspect later. I should note that the employee drop-down list is working fine, based off a class function that I will not be posting as I don't believe there is an issue... matrix.php <?php /* * Sales Matrix */ ini_set('display_errors', 1); session_start(); require 'includes/db.inc'; require 'includes/users.inc'; require 'includes/data.inc'; require 'includes/ui.inc'; // Grab form variables $_action = (!empty($_REQUEST['action'])) ? $_REQUEST['action'] : ''; $_employee = (!empty($_REQUEST['order_inputter'])) ? $_REQUEST['order_inputter'] : ''; $_startTime = (!empty($_REQUEST['starttime'])) ? $_REQUEST['starttime'] : date("Y-m-d 00:00:00"); $_endTime = (!empty($_REQUEST['endtime'])) ? $_REQUEST['endtime'] : date("Y-m-d 23:59:59"); $_view = (!empty($_REQUEST['view'])) ? $_REQUEST['view'] : ''; pageHeader(); /* * Employee and Date Selection */ //Call the getUsers() function: $db = new users(); $users = $db->getUsers(); // SEARCH FORM $allselected = ''; if ($_employee == '*') $allselected = 'selected'; if (!isset($_REQUEST['header'])) { echo '<div style="background-color:#003366; border-top:solid 1px #888888; border-bottom:solid 1px #111111; color:#ffffff; font-size:large; font-weight:bold; padding:5px; text-align:center;">' . 'Inside Sales Matrix <span style="color:#888888;">ALPHA 1</span>' . '</div>' . '<div style="background-color:#CC3333; border-top:solid 1px #eeffee; border-bottom:solid 1px #889988; padding:10px;">' . '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">' . '<b>Employee:</b> <select name="order_inputter">' . '<option value="*" ' . $allselected . '>All Employees</option>'; foreach ($users as $user) { $selected = ($user['order_inputter'] == $_employee) ? 'selected' : ''; echo '<option value="' . $user['order_inputter'] . '" ' . $selected . '>' . $user['order_inputter'] . '</option>'; } echo '</select> ' . '<b>Start:</b> <input type="text" name="starttime" id="starttime" readonly="1" value="' . $_startTime . '" />' . '<img src="/salesmatrix/images/calendar.gif" id="starttimetrigger" style="cursor: pointer;"' . 'title="Date selector" onmouseover="this.style.background=\'red\';" onmouseout="this.style.background=\'\'" /> ' . '<b>End:</b> <input type="text" name="endtime" id="endtime" readonly="1" value="' . $_endTime . '" />' . '<img src="/salesmatrix/images/calendar.gif" id="endtimetrigger" style="cursor: pointer;"' . 'title="Date selector" onmouseover="this.style.background=\'red\';" onmouseout="this.style.background=\'\'" /> ' . '<input type="submit" value="Show" />' . '<br /><br />' . '</form>'; echo <<<SCRIPT <script type="text/javascript"> Calendar.setup({ inputField : "starttime", ifFormat : "%Y-%m-%d %H:%M:%S", button : "starttimetrigger", align : "Tl", showsTime : true, singleClick : true }); Calendar.setup({ inputField : "endtime", ifFormat : "%Y-%m-%d %H:%M:%S", button : "endtimetrigger", align : "Tl", showsTime : true, singleClick : true }); </script> SCRIPT; echo '</div>'. '<br />'; } /** * View Selected Employees Details */ //Call the getUserDetails() function: $db = new data(); $getUserDetails = $db->getUserDetails(); echo '<p>' . $_employee . $getUserDetails['order_type'] . $getUserDetails['order_total'] . '</p>'; pageFooter(); exit; data.inc <?php class data extends users { //Create the getUserDetails function: function getUserDetails() { $getUserDetails = array(); try { if(!self::$dbc) $this->connect(); $result = self::$dbc->query("SELECT order_inputter, order_type, SUM(order_total) as order_total, confirmed " . "FROM orders " . "WHERE confirmed >= $_startTime And confirmed <= $_endTime " . "GROUP BY order_inputter, order_type " . "HAVING order_inputter = $_employee " . "ORDER BY order_type ASC"); while ($row = $result->fetchAll(PDO::FETCH_ASSOC)) { $getUserDetails[] = array('order_inputter' => $row['order_inputter'], 'order_type' => $row['order_type'], 'order_total' => $row['order_total'], 'confirmed' => $row['confirmed']); } } catch (PDOException $e) { $this->fatal_error($e->getMessage()); } return $getUserDetails; } //End function getUserDetails() } //End class data ?> Thank you in advance!!!
×
×
  • 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.