Update contact report form
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 27 Aug 2014 15:35:33 +0000 (11:35 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 27 Aug 2014 15:35:33 +0000 (11:35 -0400)
update on date searches.
Use jquery ui datepicker.
So it is easier for the client to select one date to search by.

admin/Contact/index.phtml
admin/Contact/query_contact.phtml

index 737ea2a..49beb60 100755 (executable)
@@ -17,6 +17,8 @@ $qs = "SELECT   count(*) as total
 if (TABLE == CUSTOMER_TABLE) {
     $qs .= " WHERE (fname != '-Guest-' OR fname is null)";
 }
+$GLOBALS['styleSheets'][]   = JQUERY_UI_CDN_CSS;
+$GLOBALS['bottomScripts'][] = JQUERY_UI_CDN_JS;
 $res = $DB->db_auto_get_data($qs);
 $total = $res[0]['total'];
 GLM_TOOLBOX::top("Contact Database","help/contact.phtml?key=search","SteveContactsDatabase_1.0");
@@ -132,8 +134,10 @@ GLM_TOOLBOX::html_nav_table($nav,$navWidth);
   </tr>
   <tr>
       <td align="left" colspan=4 nowrap>
-          <div style="float:left;width:240px;height:35px;">Created From:<br> <?php echo $c_date_from?></div>
-          <div style="float:left;width:240px;height:35px;">Created To:<br> <?php echo $c_date_to?></div>
+                 <div style="float:left;width:240px;height:35px;">Created From:<br>
+              <input id="contactFromDate" name="contact_from_date" <?php echo ($contact_from_date) ? 'value="'.$contact_from_date.'"': '';?>></div>
+                 <div style="float:left;width:240px;height:35px;">Created To:<br>
+              <input id="contactToDate" name="contact_to_date" <?php echo ($contact_to_date) ? 'value="'.$contact_to_date.'"': '';?>></div>
       </td>
   </tr>
   <tr>
index 66b1a75..48c536c 100755 (executable)
@@ -212,6 +212,33 @@ if (!$query_no) {
             $query_string .= ' and ('.implode(" $compare ",$cstring).')  ';
         }
     }
+    $contactFromDate = filter_var(
+        $_REQUEST['contact_from_date'],
+        FILTER_VALIDATE_REGEXP,
+        array(
+            'options' =>
+            array(
+            'regexp' => '%[0-9]{2}/[0-9]{2}/[0-9]{4}%')
+        )
+    );
+    $contactToDate = filter_var(
+        $_REQUEST['contact_to_date'],
+        FILTER_VALIDATE_REGEXP,
+        array(
+            'options' =>
+            array(
+            'regexp' => '%[0-9]{2}/[0-9]{2}/[0-9]{4}%')
+        )
+    );
+    if ($contactFromDate && $contactToDate) {
+        $query_string .= " AND create_date >= '{$contactFromDate}'"
+        . " AND create_date <= '{$contactToDate}'";
+    } else if ($contactFromDate) {
+        $query_string .= " AND create_date >= '{$contactFromDate}'";
+    } else if ($contactToDate) {
+        $query_string .= " AND create_date <= '{$contactToDate}'";
+    }
+
     if (isset($fp_month)) {
         $fp_str = mktime(0,0,0,$fp_month,$fp_day,$fp_year);
         $tp_str = mktime(0,0,0,$tp_month,$tp_day,$tp_year);