Adding photos import
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 21 Jun 2017 13:46:26 +0000 (09:46 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 21 Jun 2017 13:46:26 +0000 (09:46 -0400)
Adding tab for uploading the member photos.

models/admin/import/index.php
views/admin/import/files.html [new file with mode: 0644]
views/admin/import/header.html
views/admin/import/photos.html [new file with mode: 0644]
views/admin/import/processMembers.html

index 97e1360..560d5ac 100644 (file)
@@ -184,7 +184,7 @@ class GlmMembersAdmin_import_index
     {
         $view      = 'index.html';
         $failure   = false;
-        $option    = '';
+        $option    = 'default';
         $clearData = false;
         if ( isset( $_REQUEST['numberProcessed'] ) ) {
             $this->numberProcessed = filter_var( $_REQUEST['numberProcessed'], FILTER_VALIDATE_INT );
@@ -234,7 +234,8 @@ class GlmMembersAdmin_import_index
                     'addr1', 'addr2', 'city', 'state', 'country', 'zip',
                     'mailing_addr1', 'mailing_addr2', 'mailing_city', 'mailing_state', 'mailing_zip',
                     'region', 'county', 'lat', 'lon', 'phone', 'toll_free',
-                    'url', 'reservation_url', 'email', 'logo', 'categories', 'amenities' ),
+                    'url', 'reservation_url', 'email', 'logo', 'categories', 'amenities'
+                ),
                 'type'     => 'member',
             ),
         );
@@ -244,6 +245,10 @@ class GlmMembersAdmin_import_index
             $option = $_REQUEST['option'];
         }
 
+        if (isset($_REQUEST['option2']) && $_REQUEST['option2'] != '') {
+            $option2 = $_REQUEST['option2'];
+        }
+
         $wpUploadDir = wp_get_upload_dir();
         $uploadPath  = $wpUploadDir['basedir'] . '/' . 'glm-member-import';
         if ( !is_dir( $uploadPath ) ) {
@@ -371,6 +376,16 @@ class GlmMembersAdmin_import_index
             $view = 'processMembers.html';
             break;
 
+        case 'photos':
+            $view= 'photos.html';
+            $fileData = '<pre>$_FILES: ' . print_r( $_FILES, true ) . '</pre>';
+            break;
+
+        case 'files':
+            $view = 'files.html';
+            break;
+
+        case 'default':
         default:
             $view = 'index.html';
             // check upload dir to see if they have any files in yet
@@ -386,6 +401,7 @@ class GlmMembersAdmin_import_index
         }
 
         $templateData = array(
+            'option'          => $option,
             'errors'          => $this->errors,
             'numberProcessed' => $this->numberProcessed,
             'totalMembers'    => $this->totalMembers,
diff --git a/views/admin/import/files.html b/views/admin/import/files.html
new file mode 100644 (file)
index 0000000..821a318
--- /dev/null
@@ -0,0 +1,18 @@
+{include file='admin/import/header.html'}
+
+    <h2>Data Import: Files</h2>
+
+    <table class="glm-admin-table">
+        <tr>
+            <th>Total Member</th>
+            <td>{$totalMembers}</td>
+        </tr>
+        <tr>
+            <th>Processed Member</th>
+            <td>{$numberProcessed}</td>
+        </tr>
+
+    </table>
+
+
+{include file='admin/footer.html'}
index 5d663c9..69c87e1 100644 (file)
@@ -3,7 +3,9 @@
     <h2>{$glmPluginName} CSV Import</h2>
 
     <h2 class="nav-tab-wrapper">
-        <a href="{$thisUrl}?page={$thisPage}&glm_action=index" class="nav-tab{if $thisAction==index} nav-tab-active{/if}">Import CSV</a>
+        <a href="{$thisUrl}?page={$thisPage}&glm_action=index" class="nav-tab{if $option==default} nav-tab-active{/if}">Import CSV</a>
+        <a href="{$thisUrl}?page={$thisPage}&glm_action=index&option=photos" class="nav-tab{if $option==photos} nav-tab-active{/if}">Import Photos</a>
+        <a href="{$thisUrl}?page={$thisPage}&glm_action=index&option=files" class="nav-tab{if $option==files} nav-tab-active{/if}">Import Files</a>
     </h2>
     <div id="glm-admin-content-container">
 
diff --git a/views/admin/import/photos.html b/views/admin/import/photos.html
new file mode 100644 (file)
index 0000000..cbbb14e
--- /dev/null
@@ -0,0 +1,23 @@
+{include file='admin/import/header.html'}
+
+    <h2>Data Import: Photos</h2>
+    <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
+        <input type="hidden" name="glm_action" value="index" />
+        <input type="hidden" name="option" value="photos" />
+
+        <table class="glm-admin-table">
+            <tr>
+                <th>Upload File</th>
+                <td><input type="file" name="photos_file"></td>
+            </tr>
+
+        </table>
+
+        <input type="submit" value="Continue" class="button button-primary submit-import">
+    </form>
+
+    {if $fileData}
+        {$fileData}
+    {/if}
+
+{include file='admin/footer.html'}
index 5ac631a..63052c7 100644 (file)
             <td>{$numberProcessed}</td>
         </tr>
         {if !$completed}
+            {$newStart = 1 + $numberProcessed}
         <tr>
             <td colspan="2">
-                <a href="{$thisUrl}?page={$thisPage}&glm_action=index&option=processMembers&start=&numberProcessed={$numberProcessed}"
-                   class="button">Process Next Count Members</a>
+                <a href="{$thisUrl}?page={$thisPage}&glm_action=index&option=processMembers&start={$newStart}&numberProcessed={$numberProcessed}">Process Next Count Members</a>
             </td>
         </tr>
         {/if}
 
     </table>
 
+    {if !$completed}
+            {$newStart = 1 + $numberProcessed}
+    <script>
+    var test = '{$thisUrl}?page={$thisPage}&glm_action=index&option=processMembers&start={$newStart}&numberProcessed={$numberProcessed}';
+    window.location.href = test;
+    </script>
+    {/if}
+
 {include file='admin/footer.html'}