WIP for import of gravity forms
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 20 Jul 2016 13:27:34 +0000 (09:27 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 20 Jul 2016 13:27:34 +0000 (09:27 -0400)
Adding tab in the management section for the leads.
Gravity Form.
This will give stats on form entries and give choices of which form to
import into our leads table.

models/admin/management/leads.php
models/admin/settings/leads.php
views/admin/management/leads.html
views/admin/settings/leads.html

index d0cdea7..0a67547 100644 (file)
@@ -122,9 +122,27 @@ class GlmMembersAdmin_management_leads // extends GlmDataLeadsManagement
             ARRAY_A
         );
 
+        if ( isset( $_REQUEST['option'] ) ) {
+            $option = $_REQUEST['option'];
+        }
+
+        if ( isset( $_REQUEST['option2'] ) ) {
+            $option2 = $_REQUEST['option2'];
+        }
+
+        switch( $option ) {
+        case 'import':
+            $result = '<pre>$_REQUEST: ' . print_r($_REQUEST, true) . '</pre>';
+            break;
+        default:
+            break;
+        }
+
         // Compile template data
         $templateData = array(
-            'sources' => $sources
+            'sources' => $sources,
+            'option2' => $option2,
+            'result'  => $result,
         );
 
         // Return status, suggested view, and data to controller
index 30efa3c..8d1de44 100644 (file)
@@ -114,11 +114,15 @@ class GlmMembersAdmin_settings_leads extends GlmDataInterests
             $id = $_REQUEST['id'] - 0;
         }
 
+        if ( isset( $_REQUEST['option'] ) ) {
+            $option = $_REQUEST['option'];
+        }
+
         $groupData = new GlmDataInterestGroups( $this->wpdb, $this->config );
 
         // If there's an action option
-        if ( isset( $_REQUEST['option'] ) ) {
-            switch( $_REQUEST['option'] ) {
+        if ( isset( $option ) ) {
+            switch( $option ) {
                 case 'addNew':
                     $return = $this->insertEntry();
                     $id = $return['fieldData']['id'];
index f322ffa..aae776c 100644 (file)
@@ -1,8 +1,13 @@
 {include file='admin/management/header.html'}
 
-<H1>This requires Gravity Forms to be Installed and active</H1>
+<h1>This requires Gravity Forms to be Installed and active</h1>
 
-<table class="glm-admin-table glm-settings-table">
+<h2 class="nav-tab-wrapper" style="margin-bottom: 1em;">
+    <a id="glm-leads-sources" data-show-table="glm-table-sources" class="glm-settings-tab nav-tab nav-tab-active">Source List</a>
+    <a id="glm-leads-import" data-show-table="glm-table-import" class="glm-settings-tab nav-tab">Gravity Forms</a>
+</h2>
+
+<table id="glm-table-sources" class="glm-admin-table glm-settings-table{if $option2!=''} glm-hidden{/if}">
     <tr>
         <th> Form Id </th>
         <th> Source Name </th>
     </tr>
     {/foreach}
 </table>
+
+<table id="glm-table-import" class="glm-admin-table glm-settings-table{if $option2 != import} glm-hidden{/if}">
+    <tr>
+        <td><a href="{$thisUrl}?page={$thisPage}&glm_action=leads&option=import&option2=import" class="button">Import Gravity Form</a></td>
+    </tr>
+    {if $result}
+    <tr>
+        <td>{$result}</td>
+    </tr>
+    {/if}
+</table>
+
+<script>
+jQuery(document).ready(function($){
+    /*
+     * Edit area tabs
+     */
+    $('.glm-settings-tab').click( function() {
+        // Clear table highlights and hide all tables
+        $('.glm-settings-tab').removeClass('nav-tab-active');
+        $('.glm-settings-table').addClass('glm-hidden');
+
+        // Highlight selected tab
+        $(this).addClass('nav-tab-active');
+
+        // Show selected table
+        var table = $(this).attr('data-show-table');
+        $('#' + table).removeClass('glm-hidden');
+    });
+
+});
+</script>
index 8994e99..07dbde6 100644 (file)
         </table>
     </tr>
 </table>
-<script type="text/javascript">
-    jQuery(document).ready(function($) {
+<script>
+jQuery(document).ready(function($) {
 
-        $("#newInterestDialog").dialog({
-            autoOpen: false,
-            minWidth: 400,
-            dialogClass: "glm-dialog-no-close"
-        });
-        $("#editInterestDialog").dialog({
-            autoOpen: false,
-            minWidth: 400,
-            dialogClass: "glm-dialog-no-close"
-        });
-        $("#deleteInterestDialog").dialog({
-            autoOpen: false,
-            minWidth: 400,
-            dialogClass: "glm-dialog-no-close"
-        });
-
-        $('#newInterestButton').click( function() {
-            $("#newInterestDialog").dialog("open");
-        });
-        $('.editInterest').click( function() {
-            var interestID = $(this).attr('data-interestID');
-            var interestName = $(this).text();
-            var interestRefTypeID = $(this).attr('data-refTypeID');
-            var interestUsesValue = parseInt($(this).attr('data-interestUsesValue'));
-            var interestDescr = $('#editInterestDescr_' + interestID).html();
-            var interestShortDescr = $('#editInterestShortDescr_' + interestID).html();
-            var interestGroupId = $(this).attr('data-group_id');
-            console.log(interestGroupId);
-            $('#editInterestID').val(interestID);
-            $('#editInterestName').val(interestName.trim());
-            $('#editInterestRef').val(interestRefTypeID);
-            $('#editInterestUsesValue').prop('checked', interestUsesValue);
-            $('#editGroupId').val(interestGroupId);
-            $('.interestSearch').each(function(){
-                $(this).prop('checked', false);
-            });
-            $("#editInterestDialog").dialog("open");
-        });
-        $('#editInterestCancel').click( function() {
-            $("#editInterestDialog").dialog("close");
-        });
-        $('#newInterestCancel').click( function() {
-            $("#newInterestDialog").dialog("close");
-        });
+    $("#newInterestDialog").dialog({
+        autoOpen: false,
+        minWidth: 400,
+        dialogClass: "glm-dialog-no-close"
+    });
+    $("#editInterestDialog").dialog({
+        autoOpen: false,
+        minWidth: 400,
+        dialogClass: "glm-dialog-no-close"
+    });
+    $("#deleteInterestDialog").dialog({
+        autoOpen: false,
+        minWidth: 400,
+        dialogClass: "glm-dialog-no-close"
+    });
 
-        var id = false;
-        $('.deleteInterestButton').click( function() {
-            id = $(this).attr('data-interestID');
-            $("#deleteInterestDialog").dialog("open");
-        });
-        $('#deleteInterestConfirm').click( function() {
-            $("#deleteInterestDialog").dialog("close");
-            window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=leads&option=delete&id=" + id;
-        });
-        $('#deleteInterestCancel').click( function() {
-            $("#deleteInterestDialog").dialog("close");
+    $('#newInterestButton').click( function() {
+        $("#newInterestDialog").dialog("open");
+    });
+    $('.editInterest').click( function() {
+        var interestID = $(this).attr('data-interestID');
+        var interestName = $(this).text();
+        var interestRefTypeID = $(this).attr('data-refTypeID');
+        var interestUsesValue = parseInt($(this).attr('data-interestUsesValue'));
+        var interestDescr = $('#editInterestDescr_' + interestID).html();
+        var interestShortDescr = $('#editInterestShortDescr_' + interestID).html();
+        var interestGroupId = $(this).attr('data-group_id');
+        console.log(interestGroupId);
+        $('#editInterestID').val(interestID);
+        $('#editInterestName').val(interestName.trim());
+        $('#editInterestRef').val(interestRefTypeID);
+        $('#editInterestUsesValue').prop('checked', interestUsesValue);
+        $('#editGroupId').val(interestGroupId);
+        $('.interestSearch').each(function(){
+            $(this).prop('checked', false);
         });
+        $("#editInterestDialog").dialog("open");
+    });
+    $('#editInterestCancel').click( function() {
+        $("#editInterestDialog").dialog("close");
+    });
+    $('#newInterestCancel').click( function() {
+        $("#newInterestDialog").dialog("close");
+    });
 
-        /*
-         * Edit area tabs
-         */
-        $('.glm-settings-tab').click( function() {
-
-            // Clear tabl highlights and hide all tables
-            $('.glm-settings-tab').removeClass('nav-tab-active');
-            $('.glm-settings-table').addClass('glm-hidden');
-
-            // Highlight selected tab
-            $(this).addClass('nav-tab-active');
+    var id = false;
+    $('.deleteInterestButton').click( function() {
+        id = $(this).attr('data-interestID');
+        $("#deleteInterestDialog").dialog("open");
+    });
+    $('#deleteInterestConfirm').click( function() {
+        $("#deleteInterestDialog").dialog("close");
+        window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=leads&option=delete&id=" + id;
+    });
+    $('#deleteInterestCancel').click( function() {
+        $("#deleteInterestDialog").dialog("close");
+    });
 
-            // Show selected table
-            var table = $(this).attr('data-show-table');
-            $('#' + table).removeClass('glm-hidden');
+    /*
+     * Edit area tabs
+     */
+    $('.glm-settings-tab').click( function() {
+        // Clear table highlights and hide all tables
+        $('.glm-settings-tab').removeClass('nav-tab-active');
+        $('.glm-settings-table').addClass('glm-hidden');
 
-            if (table == 'glm-table-address') {
-                initMap();
-            }
+        // Highlight selected tab
+        $(this).addClass('nav-tab-active');
 
-        });
+        // Show selected table
+        var table = $(this).attr('data-show-table');
+        $('#' + table).removeClass('glm-hidden');
+    });
 
-        /*
-         * For the multiple select
-         */
-        $('#filterGroups').multiselect();
+    /*
+     * For the multiple select
+     */
+    $('#filterGroups').multiselect();
 
-    });
+});
 </script>
 <table id="glm-table-groups" class="glm-admin-table glm-settings-table{if $option2!='group'} glm-hidden{/if}">
     <tr>
 
     </tr>
 </table>
-<script type="text/javascript">
-    jQuery(document).ready(function($) {
-
-        $("#newGroupDialog").dialog({
-            autoOpen: false,
-            minWidth: 400,
-            dialogClass: "glm-dialog-no-close"
-        });
-        $("#editGroupDialog").dialog({
-            autoOpen: false,
-            minWidth: 400,
-            dialogClass: "glm-dialog-no-close"
-        });
-        $("#deleteGroupDialog").dialog({
-            autoOpen: false,
-            minWidth: 400,
-            dialogClass: "glm-dialog-no-close"
-        });
+<script>
+jQuery(document).ready(function($) {
 
-        $('#newGroupButton').click( function() {
-            $("#newGroupDialog").dialog("open");
-        });
-        $('.editGroup').click( function() {
-            var groupID      = $(this).attr('data-groupID');
-            var groupName    = $(this).text();
-            var groupMembers = $(this).attr('data-members');
-            $('#editGroupID').val(groupID);
-            $('#editGroupName').val(groupName.trim());
-            if ( groupMembers === '1' ) {
-                $('#editGroupMembers').prop( 'checked', 'checked' );
-            } else {
-                $('#editGroupMembers').prop( 'checked', null );
-            }
-            $("#editGroupDialog").dialog("open");
-        });
-        $('#editGroupCancel').click( function() {
-            $("#editGroupDialog").dialog("close");
-        });
-        $('#newGroupCancel').click( function() {
-            $("#newGroupDialog").dialog("close");
-        });
+    $("#newGroupDialog").dialog({
+        autoOpen: false,
+        minWidth: 400,
+        dialogClass: "glm-dialog-no-close"
+    });
+    $("#editGroupDialog").dialog({
+        autoOpen: false,
+        minWidth: 400,
+        dialogClass: "glm-dialog-no-close"
+    });
+    $("#deleteGroupDialog").dialog({
+        autoOpen: false,
+        minWidth: 400,
+        dialogClass: "glm-dialog-no-close"
+    });
 
-        var group_id = false;
-        $('.deleteGroupButton').click( function() {
-            group_id = $(this).attr('data-groupID');
-            $("#deleteGroupDialog").dialog("open");
-        });
-        $('#deleteGroupConfirm').click( function() {
-            $("#deleteGroupDialog").dialog("close");
-            window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=leads&option=deleteGroup&id=" + group_id + "&option2=group";
-        });
-        $('#deleteGroupCancel').click( function() {
-            $("#deleteGroupDialog").dialog("close");
-        });
+    $('#newGroupButton').click( function() {
+        $("#newGroupDialog").dialog("open");
+    });
+    $('.editGroup').click( function() {
+        var groupID      = $(this).attr('data-groupID');
+        var groupName    = $(this).text();
+        var groupMembers = $(this).attr('data-members');
+        $('#editGroupID').val(groupID);
+        $('#editGroupName').val(groupName.trim());
+        if ( groupMembers === '1' ) {
+            $('#editGroupMembers').prop( 'checked', 'checked' );
+        } else {
+            $('#editGroupMembers').prop( 'checked', null );
+        }
+        $("#editGroupDialog").dialog("open");
+    });
+    $('#editGroupCancel').click( function() {
+        $("#editGroupDialog").dialog("close");
+    });
+    $('#newGroupCancel').click( function() {
+        $("#newGroupDialog").dialog("close");
+    });
 
+    var group_id = false;
+    $('.deleteGroupButton').click( function() {
+        group_id = $(this).attr('data-groupID');
+        $("#deleteGroupDialog").dialog("open");
+    });
+    $('#deleteGroupConfirm').click( function() {
+        $("#deleteGroupDialog").dialog("close");
+        window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=leads&option=deleteGroup&id=" + group_id + "&option2=group";
     });
+    $('#deleteGroupCancel').click( function() {
+        $("#deleteGroupDialog").dialog("close");
+    });
+
+});
 </script>