Exemplo n.º 1
0
 /**
  * Sends the subscription confirmation email
  *
  * @param   object      history from get_lead_history()
  * @return  bool $email_sent    Whether the email contents were sent successfully. A true return value does not automatically mean that the user received the email successfully. It just only means that the method used was able to process the request without any errors.
  */
 function send_subscriber_confirmation_email($hashkey)
 {
     $li_contact = new LI_Contact();
     $li_contact->hashkey = $hashkey;
     $li_contact->get_contact_history();
     $history = $li_contact->history;
     // Get email from plugin settings, if none set, use admin email
     $options = get_option('leadin_options');
     $leadout_email = $options['li_email'] ? $options['li_email'] : get_bloginfo('admin_email');
     // Get email from plugin settings, if none set, use admin email
     $site_name = get_bloginfo('name');
     $site_url = get_bloginfo('wpurl');
     // @EMAIL - Use this variable to concatenate your HTML
     $body = "";
     // Email Base open
     $body .= "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'><html xmlns='http://www.w3.org/1999/xhtml' xmlns='http://www.w3.org/1999/xhtml'><head><meta http-equiv='Content-Type' content='text/html;charset=utf-8'/><meta name='viewport' content='width=device-width'/></head><body style='width: 100% !important;-webkit-text-size-adjust: 100%;-ms-text-size-adjust: 100%;color: #222222;display: block;font-family: Helvetica, Arial, sans-serif;font-weight: normal;text-align: left;line-height: 19px;font-size: 14px;margin: 0;padding: 0;'><style type='text/css'>a:hover{color: #2795b6 !important;}a:active{color: #2795b6 !important;}a:visited{color: #2ba6cb !important;}h1 a:active{color: #2ba6cb !important;}h2 a:active{color: #2ba6cb !important;}h3 a:active{color: #2ba6cb !important;}h4 a:active{color: #2ba6cb !important;}h5 a:active{color: #2ba6cb !important;}h6 a:active{color: #2ba6cb !important;}h1 a:visited{color: #2ba6cb !important;}h2 a:visited{color: #2ba6cb !important;}h3 a:visited{color: #2ba6cb !important;}h4 a:visited{color: #2ba6cb !important;}h5 a:visited{color: #2ba6cb !important;}h6 a:visited{color: #2ba6cb !important;}.button:hover table td{background: #2795b6 !important;}.tiny-button:hover table td{background: #2795b6 !important;}.small-button:hover table td{background: #2795b6 !important;}.medium-button:hover table td{background: #2795b6 !important;}.large-button:hover table td{background: #2795b6 !important;}.button:hover{color: white !important;font-family: Helvetica, Arial, sans-serif;text-decoration: none;}.button:active{color: white !important;font-family: Helvetica, Arial, sans-serif;text-decoration: none;}.button:visited{color: white !important;font-family: Helvetica, Arial, sans-serif;text-decoration: none;}.tiny-button:hover{color: white !important;font-family: Helvetica, Arial, sans-serif;text-decoration: none;}.tiny-button:active{color: white !important;font-family: Helvetica, Arial, sans-serif;text-decoration: none;}.tiny-button:visited{color: white !important;font-family: Helvetica, Arial, sans-serif;text-decoration: none;}.small-button:hover{color: white !important;font-family: Helvetica, Arial, sans-serif;text-decoration: none;}.small-button:active{color: white !important;font-family: Helvetica, Arial, sans-serif;text-decoration: none;}.small-button:visited{color: white !important;font-family: Helvetica, Arial, sans-serif;text-decoration: none;}.medium-button:hover{color: white !important;font-family: Helvetica, Arial, sans-serif;text-decoration: none;}.medium-button:active{color: white !important;font-family: Helvetica, Arial, sans-serif;text-decoration: none;}.medium-button:visited{color: white !important;font-family: Helvetica, Arial, sans-serif;text-decoration: none;}.large-button:hover{color: white !important;font-family: Helvetica, Arial, sans-serif;text-decoration: none;}.large-button:active{color: white !important;font-family: Helvetica, Arial, sans-serif;text-decoration: none;}.large-button:visited{color: white !important;font-family: Helvetica, Arial, sans-serif;text-decoration: none;}.secondary:hover table td{background: #d0d0d0 !important;}.success:hover table td{background: #457a1a !important;}.alert:hover table td{background: #970b0e !important;}@media only screen and (max-width: 600px){table[class='body'] img{width: auto !important;height: auto !important;}table[class='body'] .container{width: 95% !important;}table[class='body'] .row{width: 100% !important;display: block !important;}table[class='body'] .wrapper{display: block !important;padding-right: 0 !important;}table[class='body'] .columns{table-layout: fixed !important;float: none !important;width: 100% !important;padding-right: 0px !important;padding-left: 0px !important;display: block !important;}table[class='body'] .column{table-layout: fixed !important;float: none !important;width: 100% !important;padding-right: 0px !important;padding-left: 0px !important;display: block !important;}table[class='body'] .wrapper.first .columns{display: table !important;}table[class='body'] .wrapper.first .column{display: table !important;}table[class='body'] table.columns td{width: 100%;}table[class='body'] table.column td{width: 100%;}table[class='body'] td.offset-by-one{padding-left: 0 !important;}table[class='body'] td.offset-by-two{padding-left: 0 !important;}table[class='body'] td.offset-by-three{padding-left: 0 !important;}table[class='body'] td.offset-by-four{padding-left: 0 !important;}table[class='body'] td.offset-by-five{padding-left: 0 !important;}table[class='body'] td.offset-by-six{padding-left: 0 !important;}table[class='body'] td.offset-by-seven{padding-left: 0 !important;}table[class='body'] td.offset-by-eight{padding-left: 0 !important;}table[class='body'] td.offset-by-nine{padding-left: 0 !important;}table[class='body'] td.offset-by-ten{padding-left: 0 !important;}table[class='body'] td.offset-by-eleven{padding-left: 0 !important;}table[class='body'] .expander{width: 9999px !important;}table[class='body'] .hide-for-small{display: none !important;}table[class='body'] .show-for-desktop{display: none !important;}table[class='body'] .show-for-small{display: inherit !important;}table[class='body'] .hide-for-desktop{display: inherit !important;}table[class='body'] .container.main{width: 100% !important;}}</style><table class='body' style='border-spacing: 0;border-collapse: collapse;vertical-align: top;text-align: left;height: 100%;width: 100%;padding: 0;'><tr align='left' style='vertical-align: top; text-align: left; padding: 0;'><td class='center' align='center' valign='top' style='word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse !important;vertical-align: top;text-align: center;padding: 0 0 20px;'><center style='width: 100%;'>";
     // Email Header open
     $body .= "<table class='row header' style='border-spacing: 0;border-collapse: collapse;vertical-align: top;text-align: left;width: 100%;position: relative;padding: 0px;'><tr style='vertical-align: top;text-align: left;padding: 0;' align='left'><td class='center' align='center' style='word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse !important;vertical-align: top;text-align: center;padding: 0;' valign='top'><center style='width: 100%;'><table class='container' style='border-spacing: 0;border-collapse: collapse;vertical-align: top;text-align: inherit;width: 580px;margin:0 auto 10px auto; padding: 0;'><tr style='vertical-align: top;text-align: left;padding: 0;' align='left'><td class='wrapper last' style='word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse !important;vertical-align: top;text-align: left;position: relative;padding: 10px 0px 0px;' align='left' valign='top'><table class='twelve columns' style='border-spacing: 0;border-collapse: collapse;vertical-align: top;text-align: left;width: 580px;margin: 0 auto;padding: 0;'><tr style='vertical-align: top;text-align: left;padding: 0;' align='left'><td class='two sub-columns' style='word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse !important;vertical-align: top;text-align: left;width: 100% !important;padding: 0px 0px 10px 0px;' align='left' valign='top'>";
     $body .= "<h1 class='lead-name' style='color: #222222; display: block; font-family: Helvetica, Arial, sans-serif; font-weight: bold; text-align: left; line-height: 1.3; word-break: normal; font-size: 20px; margin: 0; padding: 0;' align='left'>" . $site_name . "</h1>";
     // Email Header close
     $body .= "</td><td class='expander' style='word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse !important;vertical-align: top;text-align: left;visibility: hidden;width: 0px;padding: 0;' align='left' valign='top'></td></tr></table></td></tr></table></center></td></tr></table>";
     $body .= "<table class='row header' style='border-spacing: 0;border-collapse: collapse;vertical-align: top;text-align: left;width: 100%;position: relative;padding: 0px;'><tr style='vertical-align: top;text-align: left;padding: 0;' align='left'><td class='center' align='center' style='word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse !important;vertical-align: top;text-align: center;padding: 0;' valign='top'><center style='width: 100%;'><table class='container' style='border-spacing: 0;border-collapse: collapse;vertical-align: top;text-align: inherit;width: 580px;margin:0 auto 10px auto; padding: 0;'><tr style='vertical-align: top;text-align: left;padding: 0;' align='left'><td class='wrapper last' style='word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse !important;vertical-align: top;text-align: left;position: relative;padding: 10px 0px 0px;' align='left' valign='top'><table class='twelve columns' style='border-spacing: 0;border-collapse: collapse;vertical-align: top;text-align: left;width: 580px;margin: 0 auto;padding: 0;'>";
     $body .= "<tr style='vertical-align: top;text-align: left;padding: 0;' align='left'><td>";
     $body .= "<td style='padding: 0px 0px 10px 0px;'>Your subscription to <i><a href='" . $site_url . "'>" . $site_name . "</a></i> has been confirmed.</td>";
     $body .= "</tr>";
     $body .= "<tr style='vertical-align: top;text-align: left;padding: 0;' align='left'><td>";
     $body .= "<td style='padding: 10px 0px 20px 0px;'>Just so you have it, here is a copy of the information you submitted to us...</td>";
     $body .= "</tr>";
     $body .= "</table>";
     // Main container open
     $body .= "<table class='container main' style='border-spacing: 0;border-collapse: collapse;vertical-align: top;text-align: inherit;width: 580px;margin: 0 auto;padding: 0;'><tr style='vertical-align: top;text-align: left;padding: 0;' align='left'><td style='word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse !important;vertical-align: top;text-align: left;padding: 0;' align='left' valign='top'>";
     // Form Submission section open
     $body .= "<table class='row section form-submission' style='border-spacing: 0;border-collapse: collapse;vertical-align: top;text-align: left;width: 100%;position: relative;display: block;background: #deedf8;padding: 0px;' bgcolor='#deedf8'><tr style='vertical-align: top;text-align: left;padding: 0;' align='left'><td class='wrapper last' style='word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse !important;vertical-align: top;text-align: left;position: relative;padding: 0 0px 0 0;' align='left' valign='top'>";
     $submission = $history->submission;
     $submission_Time = date('g:ia', strtotime($submission['event_date']));
     $submission_url = $submission['form_page_url'];
     $submission_page_title = $submission['form_page_title'];
     $submission_form_fields = json_decode($submission['form_fields']);
     $format = '<table class="row lead-timeline__event submission" style="border-spacing: 0;border-collapse: collapse;padding: 0px;vertical-align: top;text-align: left;width: 100%%;position: relative;display: block;background-color: #fff;border-top: 1px solid #dedede;border-right: 1px solid #dedede;border-left: 4px solid #f6601d;"><tr style="padding: 0;vertical-align: top;text-align: left;"><td class="wrapper" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 10px 20px 0px 0px;vertical-align: top;text-align: left;position: relative;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"><table class="two columns" style="border-spacing: 0;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;margin: 0 auto;width: 80px;"><tr style="padding: 0;vertical-align: top;text-align: left;"><td class="text-pad" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 0px 0px 10px;vertical-align: top;text-align: left;padding-left: 10px;padding-right: 10px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"><p class="lead-timeline__event-time" style="margin: 0;color: #b34a12;font-family: Helvetica, Arial, sans-serif;font-weight: normal;padding: 0;text-align: left;line-height: 19px;font-size: 14px;margin-bottom: 10px;">%s</p></td><td class="expander" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;visibility: hidden;width: 0px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"></td></tr></table></td><td class="wrapper last" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 10px 20px 0px 0px;vertical-align: top;text-align: left;position: relative;padding-right: 0px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"><table class="ten columns" style="border-spacing: 0;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;margin: 0 auto;width: 480px;"><tr style="padding: 0;vertical-align: top;text-align: left;"><td class="text-pad" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 0px 0px 10px;vertical-align: top;text-align: left;padding-left: 10px;padding-right: 10px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"><p class="lead-timeline__event-title" style="margin: 0;color: #b34a12;font-family: Helvetica, Arial, sans-serif;font-weight: normal;padding: 0;text-align: left;line-height: 19px;font-size: 14px;margin-bottom: 10px;">Filled out form on page <a href="%s" style="color: #2ba6cb;text-decoration: none;">%s</a></p> %s </td><td class="expander" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;visibility: hidden;width: 0px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"></td></tr></table></td></tr></table>';
     $built_sessions = sprintf($format, $submission_Time, $submission_url, $submission_page_title, $this->build_form_fields($submission_form_fields));
     $body .= $built_sessions;
     // Form Submission Section Close
     $body .= "</td></tr></table>";
     // Build [you may contact us at:] row
     $body .= "<table class='row section' style='border-spacing: 0;border-collapse: collapse;vertical-align: top;text-align: left;width: 100%;position: relative;display: block;margin-top: 20px;padding: 0px;'><tr style='vertical-align: top;text-align: left;padding: 0;' align='left'><td class='wrapper last' style='word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse !important;vertical-align: top;text-align: left;position: relative;padding: 0 0px 0 0;' align='left' valign='top'><table class='twelve columns' style='border-spacing: 0;border-collapse: collapse;vertical-align: top;text-align: left;width: 580px;margin: 0 auto;padding: 0;'><tr style='vertical-align: top;text-align: left;padding: 0;' align='left'><td style='word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse !important;vertical-align: top;text-align: left;padding: 0px;' align='left' valign='top'><table class='button round' style='border-spacing: 0;border-collapse: collapse;vertical-align: top;text-align: left;width: 100%;overflow: hidden;padding: 0;'><tr style='vertical-align: top;text-align: left;padding: 0;' align='left'><td>";
     $body .= "You may also contact us at:<br/><a href='mailto:" . $leadout_email . "'>" . $leadout_email . "</a>";
     $body .= "</td></tr></table></td><td class='expander' style='word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse !important;vertical-align: top;text-align: left;visibility: hidden;width: 0px;padding: 0;border: 0;' align='left' valign='top'></td></tr></table></td></tr></table>";
     // @EMAIL - end form section
     // Email Base close
     $body .= '</center></td></tr></table></body></html>';
     $from = apply_filters('li_subscribe_from', $leadout_email);
     // Each line in an email can only be 998 characters long, so lines need to be broken with a wordwrap
     $body = wordwrap($body, 900, "\r\n");
     $headers = "From: LeadOut <" . $from . ">\r\n";
     $headers .= "Reply-To: LeadOut <" . $from . ">\r\n";
     $headers .= "X-Mailer: PHP/" . phpversion() . "\r\n";
     $headers .= "MIME-Version: 1.0\r\n";
     $headers .= "Content-type: text/html; charset=utf-8\r\n";
     $subject = $site_name . ': Subscription Confirmed';
     $email_sent = wp_mail($history->lead->lead_email, $subject, $body, $headers);
     return $email_sent;
 }
Exemplo n.º 2
0
    /**
     * Creates view a contact's deteails + timeline history
     *
     * @param   int
     */
    function leadout_render_contact_detail($lead_id)
    {
        $li_contact = new LI_Contact();
        $li_contact->set_hashkey_by_id($lead_id);
        $li_contact->get_contact_history();
        $lead_name = $li_contact->history->lead->lead_first_name || $li_contact->history->lead->lead_last_name ? $li_contact->history->lead->lead_first_name . ' ' . $li_contact->history->lead->lead_last_name : '';
        $lead_email = $li_contact->history->lead->lead_email;
        $lead_source = isset($li_contact->history->lead->lead_source) ? leadout_strip_params_from_url($li_contact->history->lead->lead_source) : '';
        ?>

        <?php 
        if (isset($_POST['edit_tags'])) {
            $updated_tags = array();
            foreach ($_POST as $name => $value) {
                if (strstr($name, 'tag_slug_')) {
                    array_push($updated_tags, $value);
                }
            }
            $li_contact->update_contact_tags($lead_id, $updated_tags);
            $li_contact->history->tags = $li_contact->get_contact_tags($li_contact->hashkey);
        }
        echo '<div class="contact-top-navigation">';
        if ($li_contact->history->lead->lead_deleted) {
            $li_contact->display_error_message_for_merged_contact($li_contact->history->lead->lead_email);
        }
        if (isset($_GET['stats_dashboard'])) {
            echo '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadout_stats">&larr; Stat Dashboard</a>';
        } else {
            if (isset($_GET['redirect_to'])) {
                if (strstr($_GET['redirect_to'], 'contact_type')) {
                    $url_parts = parse_url(urldecode($_GET['redirect_to']));
                    parse_str($url_parts['query'], $url_vars);
                    if (isset($url_vars['contact_type']) && $url_vars['contact_type']) {
                        echo '<a href="' . $_GET['redirect_to'] . '">&larr; All ' . ucwords($url_vars['contact_type']) . '</a>';
                    } else {
                        echo '<a href="' . $_GET['redirect_to'] . '">&larr; All Contacts</a>';
                    }
                } else {
                    echo '<a href="' . $_GET['redirect_to'] . '">&larr; All Contacts</a>';
                }
            } else {
                echo '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadout_contacts">&larr; All Contacts</a>';
            }
        }
        echo '</div>';
        // contact-top-navigation
        echo '<div class="contact-deatils-column">';
        echo '<div class="leadout-meta-section">';
        echo '<div class="leadout-postbox__content">';
        echo '<img class="contact-header-avatar leadout-dynamic-avatar_' . substr($lead_id, -1) . '" height="65px" width="65px" src="https://api.hubapi.com/socialintel/v1/avatars?email=' . $lead_email . '"/>';
        echo '<div class="contact-header-info">';
        echo '<h2 class="contact-name">' . ($lead_name ? $lead_name : $lead_email) . '</h2>';
        echo '</div>';
        echo '</div>';
        echo '</div>';
        // leadout-meta-section
        if (!$li_contact->history->lead->lead_deleted) {
            echo '<div class="leadout-meta-section">';
            echo '<h4 class="leain-meta-header">Tags - <a class="thickbox contact-edit-tags" ' . ($li_contact->history->lead->lead_deleted ? 'style="display: none;"' : '') . ' href="#TB_inline?width=400&height=400&inlineId=edit-contact-tags">edit</a></h4>';
            echo '<div class="leadout-postbox__content">';
            foreach ($li_contact->history->tags as $tag) {
                if ($tag->tag_set) {
                    echo '<a class="contact-tag" href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadout_contacts&contact_type=' . $tag->tag_slug . '">' . $tag->tag_text . '</a>';
                }
            }
            ?>

                        <?php 
            add_thickbox();
            ?>
                        <div id="edit-contact-tags" style="display:none;">
                            <h2>Edit Tags - <?php 
            echo $li_contact->history->lead->lead_email;
            ?>
</h2>
                            <form id="edit_tags" action="" method="POST">

                                <?php 
            foreach ($li_contact->history->tags as $tag) {
                echo '<p>';
                echo '<label for="tag_slug_' . $tag->tag_slug . '">';
                echo '<input name="tag_slug_' . $tag->tag_slug . '" type="checkbox" id="tag_slug_' . $tag->tag_slug . '" value="' . $tag->tag_id . '" ' . ($tag->tag_set ? ' checked' : '') . '>' . $tag->tag_text . '</label>';
                echo '</p>';
            }
            ?>

                                <input type="hidden" name="edit_tags" value="1"/>
                                <p class="submit">
                                    <input type="submit" name="submit" id="submit" class="button button-primary" value="Save Tags">
                                </p>
                            </form>
                        </div>

                        <?php 
            echo '</div>';
            // leadout-postbox__content
            echo '</div>';
            // leadout-meta-section
            echo '<div class="leadout-meta-section">';
            echo '<h4 class="leain-meta-header">Tracking Info</h4>';
            echo '<div class="leadout-postbox__content">';
            echo '<table class="leadout-meta-table"><tbody>';
            if ($li_contact->history->lead->lead_first_name) {
                echo '<tr>';
                echo '<th>Name</th>';
                echo '<td>' . $li_contact->history->lead->lead_first_name . ' ' . $li_contact->history->lead->lead_last_name . '</td>';
                echo '</tr>';
            }
            echo '<tr>';
            echo '<th>Email</th>';
            echo '<td> <a href="mailto:' . $lead_email . '">' . $lead_email . '</a></td>';
            echo '</tr>';
            echo '<tr>';
            echo '<th>Original source</th>';
            echo '<td>' . ($li_contact->history->lead->lead_source ? '<a href="' . $li_contact->history->lead->lead_source . '">' . $lead_source . '</a>' : 'Direct') . '</td>';
            echo '</tr>';
            echo '<tr>';
            echo '<th>First visit</th>';
            echo '<td>' . self::date_format_contact_stat($li_contact->history->lead->first_visit) . '</td>';
            echo '</tr>';
            echo '<tr>';
            echo '<th>Pageviews</th>';
            echo '<td>' . $li_contact->history->lead->total_pageviews . '</td>';
            echo '</tr>';
            echo '<tr>';
            echo '<th>Form submissions</th>';
            echo '<td>' . $li_contact->history->lead->total_submissions . '</td>';
            echo '</tr>';
            echo '</tbody></table>';
            echo '</div>';
            // leadout-postbox__content
            echo '</div>';
            // leadout-meta-section
        }
        echo '</div>';
        // contact-deatils-column
        echo '<div class="contact-timeline-column" ' . ($li_contact->history->lead->lead_deleted ? 'style="display: none;"' : '') . '>';
        echo '<div class="col-wrap contact-history">';
        echo '<ul class="sessions">';
        $sessions = $li_contact->history->sessions;
        foreach ($sessions as &$session) {
            $first_event = end($session['events']);
            $first_event_date = $first_event['event_date'];
            $session_date = date('F j, Y, g:ia', strtotime($first_event['event_date']));
            $session_start_time = date('g:ia', strtotime($first_event['event_date']));
            $last_event = array_values($session['events']);
            $session_end_time = date('g:ia', strtotime($last_event[0]['event_date']));
            echo '<li class="session">';
            echo '<h3 class="session-date">' . $session_date . ($session_start_time != $session_end_time ? ' - ' . $session_end_time : '') . '</h3>';
            echo '<ul class="events">';
            //$events = array_reverse($session['events']);
            $events = $session['events'];
            foreach ($events as &$event) {
                if ($event['event_type'] == 'pageview') {
                    $pageview = $event['activities'][0];
                    echo '<li class="event pageview">';
                    echo '<div class="event-time">' . date('g:ia', strtotime($pageview['event_date'])) . '</div>';
                    echo '<div class="event-content">';
                    echo '<p class="event-title">' . $pageview['pageview_title'] . '</p>';
                    echo '<a class="event-detail pageview-url" target="_blank" href="' . $pageview['pageview_url'] . '">' . leadout_strip_params_from_url($pageview['pageview_url']) . '</a>';
                    echo '</div>';
                    echo '</li>';
                    if ($pageview['event_date'] == $first_event['event_date']) {
                        echo '<li class="event source">';
                        echo '<div class="event-time">' . date('g:ia', strtotime($pageview['event_date'])) . '</div>';
                        echo '<div class="event-content">';
                        echo '<p class="event-title">Traffic Source: ' . ($pageview['pageview_source'] ? '<a href="' . $pageview['pageview_source'] . '">' . leadout_strip_params_from_url($pageview['pageview_source']) : 'Direct') . '</a></p>';
                        $url_parts = parse_url($pageview['pageview_source']);
                        if (isset($url_parts['query'])) {
                            if ($url_parts['query']) {
                                parse_str($url_parts['query'], $url_vars);
                                if (count($url_vars)) {
                                    echo '<ul class="event-detail fields">';
                                    foreach ($url_vars as $key => $value) {
                                        if (!$value) {
                                            continue;
                                        }
                                        echo '<li class="field">';
                                        echo '<label class="field-label">' . $key . ':</label>';
                                        echo '<p class="field-value">' . nl2br($value) . '</p>';
                                        echo '</li>';
                                    }
                                    echo '</ul>';
                                }
                            }
                        }
                        echo '</div>';
                        echo '</li>';
                    }
                } else {
                    if ($event['event_type'] == 'form') {
                        $submission = $event['activities'][0];
                        $form_fields = json_decode($submission['form_fields']);
                        $num_form_fieds = count($form_fields);
                        $tag_text = '<a class="contact-tag" href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadout_contacts&contact_type=' . $tag->tag_slug . '">' . $tag->tag_text . '</a>';
                        echo '<li class="event form-submission">';
                        echo '<div class="event-time">' . date('g:ia', strtotime($submission['event_date'])) . '</div>';
                        echo '<div class="event-content">';
                        echo '<p class="event-title">';
                        echo 'Filled out ' . $event['form_name'] . ' on page <a href="' . $submission['form_page_url'] . '">' . $submission['form_page_title'] . '</a>';
                        if (count($event['form_tags'])) {
                            echo ' and tagged as ';
                            for ($i = 0; $i < count($event['form_tags']); $i++) {
                                echo '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadout_contacts&contact_type=' . $event['form_tags'][$i]['tag_slug'] . '">' . $event['form_tags'][$i]['tag_text'] . '</a> ';
                            }
                        }
                        echo '</p>';
                        echo '<ul class="event-detail fields">';
                        if (count($form_fields)) {
                            foreach ($form_fields as $field) {
                                echo '<li class="field">';
                                echo '<label class="field-label">' . $field->label . ':</label>';
                                echo '<p class="field-value">' . nl2br($field->value) . '</p>';
                                echo '</li>';
                            }
                        }
                        echo '</ul>';
                        echo '</div>';
                        echo '</li>';
                    }
                }
            }
            echo '</ul>';
            echo '</li>';
        }
        echo '</ul>';
        echo '</div>';
        echo '</div>';
        //contact-timeline-column
    }