Adding css files for view and print in admin
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 10 Dec 2014 15:20:13 +0000 (10:20 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 10 Dec 2014 15:20:13 +0000 (10:20 -0500)
controllers/admin.php
controllers/front.php
css/admin-print-application.css [new file with mode: 0644]
css/admin-view-application.css [new file with mode: 0644]
js/jquery.print-preview.js [new file with mode: 0644]
models/forms/settings.php
models/forms/settings2.php [new file with mode: 0644]
views/admin/form_1.php
views/admin/view-application.php
views/front/form_1.php

index e1e8267..ecb8d9f 100644 (file)
@@ -81,14 +81,18 @@ class glm_employment_admin
         $data = $this->wpdb->get_row($sql, ARRAY_A);
         if ($data) {
             $sql = "
-            SELECT *
-              FROM " . $this->wpdb->prefix . GLM_EMP_FORM_TABLE . "
-            WHERE application = $id";
+              SELECT *
+                FROM " . $this->wpdb->prefix . GLM_EMP_FORM_TABLE . "
+               WHERE application = $id
+            ORDER BY form_part";
             $formData = $this->wpdb->get_results($sql, ARRAY_A);
+            foreach ($formData as $form) {
+                $forms[] = unserialize($formData[0]['form_data']);
+            }
         }
         echo '<div class="wrap">';
         $viewPath = $this->pluginDirName . 'views/admin/';
-        $form1 = unserialize($formData[0]['form_data']);
+//        $form1 = unserialize($formData[0]['form_data']);
         include $viewPath . 'view-application.php';
         echo '</div>';
     }
index baa4f05..519e260 100644 (file)
@@ -9,7 +9,6 @@ defined('ABSPATH') or die();
  */
 class glm_employment_front
 {
-
     public $pluginDirName;
     public $formSuccess;
     public $formFail;
@@ -39,6 +38,7 @@ class glm_employment_front
         $this->set_form_state();
         $this->formTable = $wpdb->prefix . GLM_EMP_FORM_TABLE;
         $this->appTable  = $wpdb->prefix . GLM_EMP_APPLICATION_TABLE;
+        add_action('init', array($this, 'startJobSession'));
     }
 
     public function set_form_state()
@@ -70,42 +70,70 @@ class glm_employment_front
         $applyOnline = (isset($_REQUEST[self::FORM_VAR]))
             ? filter_var($_REQUEST[self::FORM_VAR], FILTER_VALIDATE_INT)
             : false;
+        // form Action
+        $formAction = '';
+//        $formPart = $applyOnline;
         switch ($applyOnline) {
         case 1:
+            unset($_SESSION['glmJobsApplication'], $_SESSION['glmJobsAppForm']);
             include $this->pluginDirName . 'models/forms/settings.php';
+            $formPart = 2;
             include $this->pluginDirName . 'views/front/form_1.php';
             break;
         case 2:
             if ($this->formSubmitted) {
                 include $this->pluginDirName . 'models/forms/settings.php';
-                $this->form_process(1, $form1);
-                var_dump($this->fname);
-                if ($this->fname) {
-                    $this->store_application_data($form1);
-                }
-                if ($this->appId) {
-                    $this->store_form_data($form1, 1);
+                $this->form_process(1, $form);
+                $appId = filter_var($_REQUEST['appId'], FILTER_VALIDATE_INT);
+                if (!$appId) {
+                    // insert new application and form data
+                    if ($this->fname) {
+                        $this->store_application_data($form);
+                    }
+                    if ($this->appId) {
+                        $this->store_form_data($form, 1);
+                    }
+                } else {
+                    // need to update form data
                 }
-                echo '<pre>'.print_r($this->appId, true).'</pre>';
-                echo '<pre>'.print_r($this->formId, true).'</pre>';
-//                echo '<pre>'.print_r($form1, true).'</pre>';
-//                echo '<pre>'.print_r($_POST, true).'</pre>';
-//                extract($_POST);
                 if ($this->errorCount > 0) {
                     include $this->pluginDirName . 'views/front/form_1.php';
                 } else {
-
+                    $formPart = 3;
+                    $appId = $this->appId;
+                    include $this->pluginDirName . 'models/forms/settings2.php';
+                    include $this->pluginDirName . 'views/front/form_1.php';
                 }
+            } else {
+                wp_die('An Error!:(');
             }
             break;
         case 3:
+            if ($this->formSubmitted) {
+                include $this->pluginDirName . 'models/forms/settings2.php';
+                $this->form_process(1, $form);
+                $appId = filter_var($_REQUEST['appId'], FILTER_VALIDATE_INT);
+
+                if ($this->errorCount > 0) {
+                    include $this->pluginDirName . 'views/front/form_1.php';
+                } else {
+                    $formPart = 4;
+                    include $this->pluginDirName . 'models/forms/settings3.php';
+                    include $this->pluginDirName . 'views/front/form_1.php';
+                }
+            } else {
+                wp_die('An Error!:(');
+            }
             break;
         }
+        echo '<pre>'.print_r($_SESSION, true).'</pre>';
     }
 
     public function store_application_data($form)
     {
-        var_dump($this->appTable);
+        if ($this->appId = filter_var($_SESSION['glmJobsApplication'], FILTER_VALIDATE_INT)) {
+            return;
+        }
         $this->wpdb->insert(
             $this->appTable,
             array(
@@ -122,26 +150,64 @@ class glm_employment_front
             )
         );
         $this->appId = $this->wpdb->insert_id;
+        $_SESSION['glmJobsApplication'] = $this->appId;
     }
 
     public function store_form_data($form, $form_part)
     {
-        $this->wpdb->insert(
-            $this->formTable,
-            array(
-                'create_time' => date('Y-m-d, h:i:s a'),
-                'application' => $this->appId,
-                'form_data'   => serialize($form),
-                'form_part'   => $form_part
-            ),
-            array(
-                '%s',
-                '%d',
-                '%s',
-                '%d'
-            )
-        );
+        if (   $this->formId = filter_var($_SESSION['glmJobsAppForm']['id'], FILTER_VALIDATE_INT)
+            && $form_part = $_SESSION['glmJobsAppForm']['part']
+        ) {
+            return;
+        }
+        // check if there's one stored first
+        $sql = "
+        SELECT id
+          FROM {$this->formTable}
+         WHERE application = {$this->appId}
+           AND form_part = {$form_part}";
+        $formData = $this->wpdb->get_row($sql);
+        if ($formData) {
+            $this->wpdb->replace(
+                $this->formTable,
+                array(
+                    'id'          => $formData['id'],
+                    'create_time' => date('Y-m-d, h:i:s a'),
+                    'application' => $this->appId,
+                    'form_data'   => serialize($form),
+                    'form_part'   => $form_part
+                ),
+                array(
+                    '%d',
+                    '%s',
+                    '%d',
+                    '%s',
+                    '%d'
+                )
+            );
+        } else {
+            $this->wpdb->insert(
+                $this->formTable,
+                array(
+                    'create_time' => date('Y-m-d, h:i:s a'),
+                    'application' => $this->appId,
+                    'form_data'   => serialize($form),
+                    'form_part'   => $form_part
+                ),
+                array(
+                    '%s',
+                    '%d',
+                    '%s',
+                    '%d'
+                )
+            );
+        }
+
         $this->formId = $this->wpdb->insert_id;
+        $_SESSION['glmJobsAppForm'] = array(
+            'id'   => $this->formId,
+            'part' => $form_part
+        );
     }
 
     public function form_process($part, &$form)
@@ -150,7 +216,7 @@ class glm_employment_front
         switch($part) {
         case 1:
             include $this->pluginDirName . 'models/forms/settings.php';
-            foreach ($form1 as $rowKey => $row) {
+            foreach ($form as $rowKey => $row) {
                 if ($row['type'] != 'header') {
                     foreach ($row as $fieldKey => $field) {
                         $form[$rowKey][$fieldKey]['value']
@@ -335,4 +401,11 @@ class glm_employment_front
         $this->pluginDirName = $dir;
     }
 
+    public function startJobSession()
+    {
+        if (!session_id()) {
+            session_start();
+        }
+    }
+
 }
diff --git a/css/admin-print-application.css b/css/admin-print-application.css
new file mode 100644 (file)
index 0000000..c81f03e
--- /dev/null
@@ -0,0 +1,45 @@
+.large-1 {
+    width: 8.33333%; }
+.large-2 {
+    width: 16.66667%; }
+.large-3 {
+    width: 25%; }
+.large-4 {
+    width: 33.33333%; }
+.large-5 {
+    width: 41.66667%; }
+.large-6 {
+    width: 50%; }
+.large-7 {
+    width: 58.33333%; }
+.large-8 {
+    width: 66.66667%; }
+.large-9 {
+    width: 75%; }
+.large-10 {
+    width: 83.33333%; }
+.large-11 {
+    width: 91.66667%; }
+.large-12 {
+    width: 100%; }
+#adminmenuback, #adminmenuwrap, #wpadminbar, #wpfooter {
+    display: none;
+}
+#appForm {
+    width: 100%;
+    background-color: #fff;
+    border-color: 1px solid red;
+}
+#appForm span {
+    font-size: 13px;
+}
+#wpcontent {
+    margin-left: 0;
+    padding-left: 0;
+    margin-top: 0;
+}
+body {background: white;font-size: 12pt;}
+html.wp-toolbar {padding-top: 0;}
+div.wrap {padding-top: 0;margin-top:0;}
+h3 {page-break-before: auto;}
+div.row {page-break-inside: avoid;}
\ No newline at end of file
diff --git a/css/admin-view-application.css b/css/admin-view-application.css
new file mode 100644 (file)
index 0000000..dd8f7d6
--- /dev/null
@@ -0,0 +1,15 @@
+#appForm {
+    width: 700px;
+    max-width: 700px;
+    background-color: #fff;
+}
+#appForm span {
+    font-size: 13px;
+}
+
+div.row {
+    border:1px solid black;
+    border-collapse: collapse;
+    display:table-row;
+}
+div.row > div {display:table-cell;padding:2px;}
diff --git a/js/jquery.print-preview.js b/js/jquery.print-preview.js
new file mode 100644 (file)
index 0000000..4565a48
--- /dev/null
@@ -0,0 +1,192 @@
+/*!
+ * jQuery Print Previw Plugin v1.0.1
+ *
+ * Copyright 2011, Tim Connell
+ * Licensed under the GPL Version 2 license
+ * http://www.gnu.org/licenses/gpl-2.0.html
+ *
+ * Date: Wed Jan 25 00:00:00 2012 -000
+ */
+(function($) { 
+    
+       // Initialization
+       $.fn.printPreview = function() {
+               this.each(function() {
+                       $(this).bind('click', function(e) {
+                           e.preventDefault();
+                           if (!$('#print-modal').length) {
+                               $.printPreview.loadPrintPreview();
+                           }
+                       });
+               });
+               return this;
+       };
+    
+    // Private functions
+    var mask, size, print_modal, print_controls;
+    $.printPreview = {
+        loadPrintPreview: function() {
+            // Declare DOM objects
+            print_modal = $('<div id="print-modal"></div>');
+            print_controls = $('<div id="print-modal-controls">' + 
+                                    '<a href="#" class="print" title="Print page">Print page</a>' +
+                                    '<a href="#" class="close" title="Close print preview">Close</a>').hide();
+            var print_frame = $('<iframe id="print-modal-content" scrolling="no" border="0" frameborder="0" name="print-frame" />');
+
+            // Raise print preview window from the dead, zooooooombies
+            print_modal
+                .hide()
+                .append(print_controls)
+                .append(print_frame)
+                .appendTo('body');
+
+            // The frame lives
+            for (var i=0; i < window.frames.length; i++) {
+                if (window.frames[i].name == "print-frame") {    
+                    var print_frame_ref = window.frames[i].document;
+                    break;
+                }
+            }
+            print_frame_ref.open();
+            print_frame_ref.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' +
+                '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">' + 
+                '<head><title>' + document.title + '</title></head>' +
+                '<body></body>' +
+                '</html>');
+            print_frame_ref.close();
+            
+            // Grab contents and apply stylesheet
+            var $iframe_head = $('head link[media*=print], head link[media=all]').clone(),
+                $iframe_body = $('body > *:not(#print-modal):not(script)').clone();
+            $iframe_head.each(function() {
+                $(this).attr('media', 'all');
+            });
+            if (!$.browser.msie && !($.browser.version < 7) ) {
+                $('head', print_frame_ref).append($iframe_head);
+                $('body', print_frame_ref).append($iframe_body);
+            }
+            else {
+                $('body > *:not(#print-modal):not(script)').clone().each(function() {
+                    $('body', print_frame_ref).append(this.outerHTML);
+                });
+                $('head link[media*=print], head link[media=all]').each(function() {
+                    $('head', print_frame_ref).append($(this).clone().attr('media', 'all')[0].outerHTML);
+                });
+            }
+            
+            // Disable all links
+            $('a', print_frame_ref).bind('click.printPreview', function(e) {
+                e.preventDefault();
+            });
+            
+            // Introduce print styles
+            $('head').append('<style type="text/css">' +
+                '@media print {' +
+                    '/* -- Print Preview --*/' +
+                    '#print-modal-mask,' +
+                    '#print-modal {' +
+                        'display: none !important;' +
+                    '}' +
+                '}' +
+                '</style>'
+            );
+
+            // Load mask
+            $.printPreview.loadMask();
+
+            // Disable scrolling
+            $('body').css({overflowY: 'hidden', height: '100%'});
+            $('img', print_frame_ref).load(function() {
+                print_frame.height($('body', print_frame.contents())[0].scrollHeight);
+            });
+            
+            // Position modal            
+            starting_position = $(window).height() + $(window).scrollTop();
+            var css = {
+                    top:         starting_position,
+                    height:      '100%',
+                    overflowY:   'auto',
+                    zIndex:      10000,
+                    display:     'block'
+                }
+            print_modal
+                .css(css)
+                .animate({ top: $(window).scrollTop()}, 400, 'linear', function() {
+                    print_controls.fadeIn('slow').focus();
+                });
+            print_frame.height($('body', print_frame.contents())[0].scrollHeight);
+            
+            // Bind closure
+            $('a', print_controls).bind('click', function(e) {
+                e.preventDefault();
+                if ($(this).hasClass('print')) { window.print(); }
+                else { $.printPreview.distroyPrintPreview(); }
+            });
+       },
+       
+       distroyPrintPreview: function() {
+           print_controls.fadeOut(100);
+           print_modal.animate({ top: $(window).scrollTop() - $(window).height(), opacity: 1}, 400, 'linear', function(){
+               print_modal.remove();
+               $('body').css({overflowY: 'auto', height: 'auto'});
+           });
+           mask.fadeOut('slow', function()  {
+                       mask.remove();
+               });                             
+
+               $(document).unbind("keydown.printPreview.mask");
+               mask.unbind("click.printPreview.mask");
+               $(window).unbind("resize.printPreview.mask");
+           },
+           
+       /* -- Mask Functions --*/
+           loadMask: function() {
+               size = $.printPreview.sizeUpMask();
+            mask = $('<div id="print-modal-mask" />').appendTo($('body'));
+           mask.css({                          
+                       position:           'absolute', 
+                       top:                0, 
+                       left:               0,
+                       width:              size[0],
+                       height:             size[1],
+                       display:            'none',
+                       opacity:            0,                                                  
+                       zIndex:             9999,
+                       backgroundColor:    '#000'
+               });
+       
+               mask.css({display: 'block'}).fadeTo('400', 0.75);
+               
+            $(window).bind("resize..printPreview.mask", function() {
+                               $.printPreview.updateMaskSize();
+                       });
+                       
+                       mask.bind("click.printPreview.mask", function(e)  {
+                               $.printPreview.distroyPrintPreview();
+                       });
+                       
+                       $(document).bind("keydown.printPreview.mask", function(e) {
+                           if (e.keyCode == 27) {  $.printPreview.distroyPrintPreview(); }
+                       });
+        },
+    
+        sizeUpMask: function() {
+            if ($.browser.msie) {
+               // if there are no scrollbars then use window.height
+               var d = $(document).height(), w = $(window).height();
+               return [
+                       window.innerWidth ||                                            // ie7+
+                       document.documentElement.clientWidth ||         // ie6  
+                       document.body.clientWidth,                                      // ie6 quirks mode
+                       d - w < 20 ? w : d
+               ];
+            } else { return [$(document).width(), $(document).height()]; }
+        },
+    
+        updateMaskSize: function() {
+               var size = $.printPreview.sizeUpMask();
+               mask.css({width: size[0], height: size[1]});
+        }
+    }
+})(jQuery);
\ No newline at end of file
index abc8eae..5ab039e 100644 (file)
@@ -349,7 +349,7 @@ $special_training = [
     . ' or other experiences that relate to the position(s) applied for?',
     'large' => 12
 ];
-$form1 = [
+$form = [
     ['type' => 'header', 'label' => 'Personal Information'],
     [$fname, $lname, $mname],
     [$street, $city, $state, $zip],
diff --git a/models/forms/settings2.php b/models/forms/settings2.php
new file mode 100644 (file)
index 0000000..afae00e
--- /dev/null
@@ -0,0 +1,154 @@
+<?php
+$date_of_birth = [
+    'type'  => 'text',
+    'name'  => 'date_of_birth',
+    'label' => 'Date of Birth',
+    'large' => 12,
+    'req'   => true
+];
+for ($i = 1; $i <= 4; ++$i) {
+    ${'state'.$i} = [
+        'type'  => 'text',
+        'name'  => 'state' . $i,
+        'label' => 'State',
+        'large' => 1,
+        'req'   => true
+    ];
+    ${'license'.$i} = [
+        'type'  => 'text',
+        'name'  => 'license' . $i,
+        'label' => 'License No.',
+        'large' => 4,
+        'req'   => true
+    ];
+    ${'class'.$i} = [
+        'type'  => 'text',
+        'name'  => 'class' . $i,
+        'label' => 'Class',
+        'large' => 1,
+        'req'   => true
+    ];
+    ${'endorsement'.$i} = [
+        'type'  => 'text',
+        'name'  => 'endorsement' . $i,
+        'label' => 'Endorsement(s)',
+        'large' => 4,
+        'req'   => true
+    ];
+    ${'exp_date'.$i} = [
+        'type'  => 'text',
+        'name'  => 'exp_date' . $i,
+        'label' => 'Expiration Date',
+        'large' => 2,
+        'req'   => true
+    ];
+}
+$denied_license = [
+    'type'  => 'radio',
+    'name'  => 'denied_license',
+    'label' => 'A. Have you ever been denied a license, permit or privilege to'
+    . 'operate a motor wehicle?',
+    'large' => 4,
+    'req'   => true,
+    'opts'  => [[
+        'name'  => 'denied_license_yes',
+        'label' => 'Yes',
+        'value' => 1
+    ],[
+        'name'  => 'denied_license_no',
+        'label' => 'No',
+        'value' => 0]]
+];
+$suspended_license = [
+    'type'  => 'radio',
+    'name'  => 'suspended_license',
+    'label' => 'B. Has any license, permit or privilege ever been suspended or revoked?',
+    'large' => 4,
+    'req'   => true,
+    'opts'  => [[
+        'name'  => 'suspended_license_yes',
+        'label' => 'Yes',
+        'value' => 1
+    ],[
+        'name'  => 'suspended_license_no',
+        'label' => 'No',
+        'value' => 0]]
+];
+$disqualified_license = [
+    'type'  => 'radio',
+    'name'  => 'disqualified_license',
+    'label' => 'C. Have you ever been disquelified for violations of the Federal'
+    . 'Mortor Carrier Safety Regulations?',
+    'large' => 4,
+    'req'   => true,
+    'opts'  => [[
+        'name'  => 'disqualified_license_yes',
+        'label' => 'Yes',
+        'value' => 1
+    ],[
+        'name'  => 'disqualified_license_no',
+        'label' => 'No',
+        'value' => 0]]
+];
+$details_of_license = [
+    'type'  => 'textarea',
+    'name'  => 'details_of_license',
+    'label' => 'If you answered "yes" to A, B, C, give details',
+    'large' => 12
+];
+$titles = [
+    1 => 'Straight Truck',
+    'Tractor and Semi Trailer',
+    'Twin Trailers - LCV\'s',
+    'Other'
+];
+for ($i = 1; $i <= 4; ++$i) {
+    ${'eq_class'.$i} = [
+        'type'  => 'static',
+        'value' => $titles[$i],
+        'large' => 3
+    ];
+    ${'eq_type'.$i} = [
+        'type'  => 'text',
+        'name'  => 'type' . $i,
+        'label' => 'Type of Equipment (Van, Tank, Flat, etc.)',
+        'large' => 4,
+        'req'   => true
+    ];
+    ${'eq_dates_from'.$i} = [
+        'type'  => 'text',
+        'name'  => 'dates_from' . $i,
+        'label' => 'From',
+        'large' => 1,
+        'req'   => true
+    ];
+    ${'eq_dates_to'.$i} = [
+        'type'  => 'text',
+        'name'  => 'dates_to' . $i,
+        'label' => 'To',
+        'large' => 1,
+        'req'   => true
+    ];
+    ${'eq_approx_miles'.$i} = [
+        'type'  => 'text',
+        'name'  => 'exp_date' . $i,
+        'label' => 'Approximate total Miles',
+        'large' => 3,
+        'req'   => true
+    ];
+}
+$form = [
+    ['type' => 'header', 'label' => 'Driver Experience and Qualification'],
+    [$date_of_birth],
+    ['type' => 'header', 'label' => 'Drivers Licenses held in past 3 years must be shown'],
+    [$state1, $license1, $class1, $endorsement1, $exp_date1],
+    [$state2, $license2, $class2, $endorsement2, $exp_date2],
+    [$state3, $license3, $class3, $endorsement3, $exp_date3],
+    [$state4, $license4, $class4, $endorsement4, $exp_date4],
+    [$denied_license, $suspended_license, $disqualified_license],
+    [$details_of_license],
+    [$eq_class1, $eq_type1, $eq_dates_from1, $eq_dates_to1, $eq_approx_miles1],
+    [$eq_class2, $eq_type2, $eq_dates_from2, $eq_dates_to2, $eq_approx_miles2],
+    [$eq_class3, $eq_type3, $eq_dates_from3, $eq_dates_to3, $eq_approx_miles3],
+    [$eq_class4, $eq_type4, $eq_dates_from4, $eq_dates_to4, $eq_approx_miles4],
+];
index 7742e1f..a589240 100644 (file)
@@ -1,47 +1,48 @@
 <div class="row">
+    <?php foreach ($forms as $form):?>
     <div class="small-12 columns">
-        <h1><?php echo $formTitle;?></h1>
-            <?php foreach($form1 as $row):?>
-            <?php if ($row['type'] == 'header') :?>
-                <h3><?php echo $row['label'];?></h3>
-            <?php else:?>
-                <div class="row">
-                    <?php foreach($row as $field) :?>
-                    <div class="small-12 large-<?php echo $field['large'];?> columns">
-                        <label<?php if ($field['req']):?> class="error"<?php endif;?>>
-                            <?php echo $field['label'];?>
-                        </label>
-                            <?php switch($field['type']) :
-                            case 'text':?>
-                            <?php case 'tel':?>
-                            <?php case 'email':?>
-                            <?php case 'textarea':?>
-                                <span><?php echo $field['value'];?></span>
-                            <?php break;?>
-                            <?php case 'radio':?>
-                                <?php foreach($field['opts'] as $option) :?>
-                                <span>( <?php if ($field['value'] == $option['value']) {
-                                            echo 'x';
-                                            }?> )
-                                    <?php echo $option['label'];?></span>
-                                <?php endforeach;?>
-                            <?php break;?>
-                            <?php case 'checkbox':?>
-                                <?php foreach($field['opts'] as $option) :?>
-                                        <span>( <?php if ($option['checked']) {
-                                            echo 'x';
-                                        }?> )
-                                    <?php echo $option['label'];?></span>
-                                <?php endforeach;?>
-                            <?php break;?>
-                            <?php endswitch;?>
-                        <?php if ($field['error']):?>
-                        <small class="error"><?php echo $field['error'];?></small>
-                        <?php endif;?>
-                    </div>
-                    <?php endforeach;?>
+        <?php foreach($form as $row):?>
+        <?php if ($row['type'] == 'header') :?>
+            <h3><?php echo $row['label'];?></h3>
+        <?php else:?>
+            <div class="row">
+                <?php foreach($row as $field) :?>
+                <div class="large-<?php echo $field['large'];?> small-12  columns">
+                    <label<?php if ($field['req']):?> class="error"<?php endif;?>>
+                        <?php echo $field['label'];?>
+                    </label>
+                    <?php switch($field['type']) :
+                    case 'text':?>
+                    <?php case 'tel':?>
+                    <?php case 'email':?>
+                    <?php case 'textarea':?>
+                        <span><?php echo $field['value'];?></span>
+                    <?php break;?>
+                    <?php case 'radio':?>
+                        <?php foreach($field['opts'] as $option) :?>
+                        <span>( <?php if ($field['value'] == $option['value']) {
+                                    echo 'x';
+                                    }?> )
+                            <?php echo $option['label'];?></span>
+                        <?php endforeach;?>
+                    <?php break;?>
+                    <?php case 'checkbox':?>
+                        <?php foreach($field['opts'] as $option) :?>
+                                <span>( <?php if ($option['checked']) {
+                                    echo 'x';
+                                }?> )
+                            <?php echo $option['label'];?></span>
+                        <?php endforeach;?>
+                    <?php break;?>
+                    <?php endswitch;?>
+                    <?php if ($field['error']):?>
+                    <small class="error"><?php echo $field['error'];?></small>
+                    <?php endif;?>
                 </div>
-            <?php endif;?>
-            <?php endforeach;?>
+                <?php endforeach;?>
+            </div>
+        <?php endif;?>
+        <?php endforeach;?>
     </div>
+    <?php endforeach;?>
 </div>
index 9fc47d1..8095610 100644 (file)
@@ -1,15 +1,5 @@
-<style>
-    #appForm {
-        width: 600px;
-        background-color: #fff;
-    }
-    #appForm span {
-        font-size: 13px;
-        background-color: lightgrey;
-        padding: 5px;
-    }
-</style>
-
+<link rel="stylesheet" href="../wp-content/plugins/glm-employment/css/admin-view-application.css" type="text/css"/>
+<link rel="stylesheet" href="../wp-content/plugins/glm-employment/css/admin-print-application.css" type="text/css" media="print" />
 <div id="appForm">
     <?php include $viewPath . 'form_1.php';?>
-</div>
\ No newline at end of file
+</div>
index d167bf6..fba491b 100644 (file)
@@ -2,8 +2,11 @@
     <div class="small-12 columns">
         <h1><?php echo $formTitle;?></h1>
         <form method="post" action="<?php echo $formAction;?>">
-            <input type="hidden" name="applyOnline" value="2" />
-            <?php foreach($form1 as $row):?>
+            <input type="hidden" name="applyOnline" value="<?php echo $formPart;?>" />
+            <?php if ($appId):?>
+            <input type="hidden" name="appId" value="<?php echo $appId;?>">
+            <?php endif;?>
+            <?php foreach($form as $row):?>
             <?php if ($row['type'] == 'header') :?>
                 <h3><?php echo $row['label'];?></h3>
             <?php else:?>
@@ -47,6 +50,9 @@
                                 type="email"
                                 value="<?php echo $field['value'];?>" />
                             <?php break;?>
+                            <?php case 'static':?>
+                                <?php echo $field['value'];?>
+                            <?php break;?>
                             <?php case 'textarea':?>
                             <textarea
                                 <?php if ($field['error']){echo 'class="error"';}?>
@@ -66,7 +72,7 @@
                                         name="<?php echo $field['name'];?>"
                                         type="radio"
                                         value="<?php echo $option['value'];?>"
-                                        <?php if ($field['value'] == $option['value']) {
+                                        <?php if ($field['value'] === $option['value']) {
                                             echo 'checked';
                                         }?> />
                                     <label for="<?php echo $option['name'];?>"><?php echo $option['label'];?></label>