?>
		<table class="form-table">
			<?php 
do_settings_fields($page, 'default');
?>
		</table>
		<?php 
do_settings_sections($page);
?>
		<?php 
submit_button();
?>
		<?php 
if ($reset) {
    ?>
			<?php 
    submit_button(sc__('Reset Defaults'), 'secondary', $page . '-reset', false);
    ?>
		<?php 
}
?>
	</form>

	<?php 
do_action('sprout_settings_page', $page);
?>
	<?php 
do_action('sprout_settings_page_' . $page, $page);
?>
</div>
 /**
  * Show the notes
  *
  * @param WP_Post $post
  * @param array   $metabox
  * @return
  */
 public static function show_client_notes_view($post, $metabox)
 {
     if ('auto-draft' === $post->post_status) {
         printf('<p>%s</p>', sc__('Save before creating any notes.'));
         return;
     }
     $client = Sprout_Client::get_instance($post->ID);
     self::load_view('admin/meta-boxes/clients/notes', array('id' => $post->ID, 'post' => $post, 'client' => $client), false);
 }
    function sc_get_all_status_select()
    {
        $status_terms = get_terms(Sprout_Client::STATUS_TAXONOMY, array('hide_empty' => false));
        ob_start();
        ?>
		<div id="statuses_filter" class="sc_statuses_filter">
			<span class="status_filter_button" data-sa-dropdown="#filter_status_all">
				<?php 
        printf('<button class="sc_filter_status button" title="%1$s">%1$s&nbsp;<span class="dashicons dashicons-arrow-down"></span></button>', esc_attr(sc__('Status')));
        ?>
			</span>&nbsp;<span class="helptip client_filter_help" data-sa-dropdown="#client_status_filter_help_all"></span>
			<div id="client_status_filter_help_all" class="sa-dropdown sa-dropdown-tip sa-dropdown-relative ">
				<div class="sa-dropdown-panel">
					<?php 
        sc_e('Select all statuses that currently fit this contact.');
        ?>
				</div>
			</div>
			<div id="filter_status_all" class="sa-dropdown sa-dropdown-tip sa-dropdown-relative status_filter_selection" data-vertical-offset="50">
				<ul class="sa-dropdown-menu">
					<?php 
        foreach ($status_terms as $term) {
            ?>
						<?php 
            $checked = '';
            printf('<li><label><input type="checkbox" value="%1$s" name="%4$s" %3$s/><b>%2$s</b></label></li>', $term->slug, esc_html($term->name), esc_attr($checked), Sprout_Client::STATUS_TAXONOMY);
            ?>
					
					<?php 
        }
        ?>
					<li class="sa-dropdown-divider"></li>
					<li><a href="<?php 
        echo esc_url(admin_url('edit-tags.php?taxonomy=sc_client_status&post_type=sa_client'));
        ?>
"><?php 
        sc_e('Add/Edit Client Statuses');
        ?>
</a></li>
				</ul>
			</div>
		</div>
		<?php 
        $view = ob_get_clean();
        return apply_filters('sc_get_all_status_select', $view);
    }
 public static function help_tabs()
 {
     $post_type = '';
     if (isset($_GET['tab']) && $_GET['tab'] == self::SETTINGS_PAGE) {
         $post_type = SC_Message::POST_TYPE;
     }
     if ($post_type == '' && isset($_GET['post'])) {
         $post_type = get_post_type($_GET['post']);
     }
     if ($post_type == SC_Message::POST_TYPE) {
         // get screen and add sections.
         $screen = get_current_screen();
         $screen->add_help_tab(array('id' => 'message-customizations', 'title' => self::__('About Notifications'), 'content' => sprintf('<p>%s</p><p>%s</p>', self::__('Notifications include the emails sent to you and your clients, including responses to prospective clients after submitting an estimate request.'), self::__('Each one of your messages can be customized; hover over the message you want and click the edit link.'))));
         $screen->add_help_tab(array('id' => 'message-disable', 'title' => self::__('Disable Notifications'), 'content' => sprintf('<p>%s</p>', self::__('The messages edit screen will have an option next to the "Update" button to disable the message from being sent.'))));
         $screen->add_help_tab(array('id' => 'message-editing', 'title' => self::__('Notification Editing'), 'content' => sprintf('<p>%s</p><p>%s</p><p>%s</p><p>%s</p>', self::__('<b>Subject</b> - The first input is for the messages subject. If the message is an e-mail than it would be subject line for that e-mail message.'), self::__('<b>Message Body</b> - The main editor is the message body. Use the available shortcodes to have dynamic information included when the message is received. Make sure to change the Notification Setting if HTML formatting is added to your messages.'), self::__('<b>Shortcodes</b> – A list of shortcodes is provided with descriptions for each.'), self::__('<b>Update</b> - The select list can be used if you want to change the current message to a different type; it’s recommended you go to the message you want to edit instead of using this option. The Disabled option available to prevent this message from sending.'))));
         $screen->add_help_tab(array('id' => 'message-advanced', 'title' => self::__('Advanced'), 'content' => sprintf('<p><b>HTML Emails</b> - Enable HTML messages within the <a href="%s">General Settings</a> page. Make sure to change use HTML on all messages.</p>', admin_url('admin.php?page=sprout-apps/settings'))));
         $screen->add_help_tab(array('id' => 'message-refresh', 'title' => self::__('Notifications Cleanup'), 'content' => sprintf('<p>%s</p><p><span class="cache_button_wrap casper clearfix"><a href="%s">%s</a></span></p></p>', sc__('In an earlier version of Sprout Clients numerous messages were improperly created. Click refresh below to delete all extraneous messages. Backup any modifications that you might have made to your messages before continuing.'), esc_url(add_query_arg(array('refresh-messages' => 1))), sc__('Clean'))));
         $screen->set_help_sidebar(sprintf('<p><strong>%s</strong></p>', self::__('For more information:')) . sprintf('<p><a href="%s" class="button">%s</a></p>', 'https://sproutapps.co/support/knowledgebase/sprout-invoices/messages/', self::__('Documentation')) . sprintf('<p><a href="%s" class="button">%s</a></p>', 'https://sproutapps.co/support/', self::__('Support')));
     }
 }
</span>

					<div class="gravatar_wrap">
						<span class="client_user_gravatar clearfix"><?php 
        echo get_avatar($user_id, 120);
        ?>
</span>

						<div class="client_users_social_icons clearfix">
							<span class="user_meta users_twitter"><?php 
        printf('&nbsp;<a href="%s" title="%s" target="_blank"><span class="dashicons dashicons-twitter"></span></a>', esc_attr(sc_get_users_twitter($user_id)), sc__('Twitter Profile'));
        ?>
</span>

							<span class="user_meta users_linkedin"><?php 
        printf('&nbsp;<a href="%s" title="%s" target="_blank"><span class="dashicons dashicons-external"></span></a>', esc_attr(sc_get_users_linkedin($user_id)), sc__('Linkedin Profile'));
        ?>
</span>
						</div>
					</div>

					<div class="sc_person_info clearfix">
						<span class="user_meta users_name"><span class="dashicons dashicons-admin-users"></span>&nbsp;<?php 
        echo esc_attr($a_user->display_name);
        ?>
</span>

						<span class="user_meta users_email"><span class="dashicons dashicons-email-alt"></span>&nbsp;<a href="mailto:<?php 
        echo esc_attr($a_user->user_email);
        ?>
"><?php 
 public static function add_records_to_client_history($history = array(), Sprout_Client $client, $type = '')
 {
     $records = SC_Record::get_records_by_association($client->get_id());
     if (!empty($records)) {
         foreach ($records as $record_id) {
             $record = SC_Record::get_instance($record_id);
             if ('' !== $type && $type != $record->get_type()) {
                 continue;
             }
             // Take care of the standard records only
             if ($record->get_type() !== SC_Controller::PRIVATE_NOTES_TYPE) {
                 continue;
             }
             $r_post = $record->get_post();
             $time = strtotime($r_post->post_date);
             $history[$time] = array('id' => $record_id, 'record_id' => $record_id, 'title' => esc_html($r_post->post_title), 'content' => wpautop($r_post->post_content), 'date' => wpautop($r_post->post_date), 'type' => sc__('Private Note'), 'type_slug' => SC_Controller::PRIVATE_NOTES_TYPE, 'edit' => true);
         }
     }
     return $history;
 }
 /**
  * Build and return a form field label
  * @param string $key      Form field key
  * @param array $data      Array of data to build form field
  * @param string $category group the form field belongs to
  * @return string           <label>
  */
 function sa_get_form_label($key, $data, $category)
 {
     if ($data['type'] == 'hidden') {
         $out = '';
     } else {
         if (!isset($data['label'])) {
             $data['label'] = '';
         }
         $out = '<label for="sa_' . $category . '_' . $key . '">' . sc__($data['label']) . '</label>';
         if (isset($data['required']) && $data['required']) {
             $out .= ' <span class="required">*</span>';
         }
     }
     return apply_filters('sa_get_form_label', $out, $key, $data, $category);
 }
 /**
  * Create a record that a message was sent.
  * @param  string $message_name
  * @param  array $data
  * @param  string $to
  * @param  string $message_title
  * @param  string $message_content
  * @return null
  */
 public static function message_record($message_name, $data, $to, $message_title, $message_content)
 {
     $associated_record = 0;
     if (isset($data['estimate']) && is_a($data['estimate'], 'SI_Estimate')) {
         $associated_record = $data['estimate']->get_id();
     }
     if (isset($data['invoice']) && is_a($data['invoice'], 'SI_Invoice')) {
         $associated_record = $data['invoice']->get_id();
     }
     $content = '';
     $content .= '<b>' . $message_title . "</b>\r\n\r\n";
     $content .= $message_content;
     do_action('sc_new_record', $content, self::RECORD, $associated_record, sprintf(sc__('Notification sent to %s.'), esc_html($to)), 0, false);
 }
 /**
  * REQUIRED! This method dictates the table's columns and titles. This should
  * return an array where the key is the column slug (and class) and the value
  * is the column's title text.
  *
  * @see WP_List_Table::::single_row_columns()
  * @return array An associative array containing column information: 'slugs'=>'Visible Titles'
  * */
 function get_columns()
 {
     $columns = array('recorded' => sc__('Date'), 'title' => sc__('Subject'), 'data' => sc__('Data'), 'associate' => sc__('Association'), 'type' => sc__('Type'));
     return apply_filters('si_mngt_record_columns', $columns);
 }
 /**
  * REQUIRED! This method dictates the table's columns and titles. This should
  * return an array where the key is the column slug (and class) and the value
  * is the column's title text.
  *
  * @see WP_List_Table::::single_row_columns()
  * @return array An associative array containing column information: 'slugs'=>'Visible Titles'
  * */
 function get_columns()
 {
     $columns = array('title' => sc__('Type'), 'subject' => sc__('Subject'), 'message' => sc__('Message'));
     return apply_filters('si_mngt_message_columns', $columns);
 }
function sc_get_users_full_name($user_id = 0)
{
    $name = sc__('Unknown');
    if (!$user_id) {
        return $name;
    }
    $user = get_userdata($user_id);
    if ($user) {
        $name = '' === $user->first_name && '' === $user->last_name ? sc__('Mystery Man') : $user->first_name . '&nbsp;' . $user->last_name;
    }
    return $name;
}
    public static function add_records_to_client_history($history = array(), Sprout_Client $client, $type = '')
    {
        $records = array();
        $invoices = $client->get_invoices();
        if (!empty($invoices)) {
            foreach ($invoices as $invoice_id) {
                $records += SC_Record::get_records_by_association($invoice_id);
            }
        }
        $estimates = $client->get_estimates();
        if (!empty($estimates)) {
            foreach ($estimates as $estimate_id) {
                $records += SC_Record::get_records_by_association($estimate_id);
            }
        }
        if (!empty($records)) {
            foreach ($records as $record_id) {
                $record = SC_Record::get_instance($record_id);
                if ('' !== $type && $type !== $record->get_type()) {
                    continue;
                }
                // parent taking care of this one.
                if ($record->get_type() === SC_Controller::PRIVATE_NOTES_TYPE) {
                    continue;
                }
                $r_post = $record->get_post();
                $time = strtotime($r_post->post_date);
                $history[$time] = array('id' => $record_id, 'record_id' => $record_id, 'title' => esc_html($r_post->post_title), 'content' => wpautop($r_post->post_content), 'date' => wpautop($r_post->post_date), 'type_slug' => $record->get_type());
                switch ($record->get_type()) {
                    // Sprout Invoices
                    case 'si_history_update':
                        $history[$time]['type'] = sc__('Estimate Updated');
                        break;
                    case 'si_history_update':
                        $history[$time]['type'] = sc__('Estimate Viewed');
                        break;
                    case 'si_notification':
                        $history[$time]['type'] = sc__('Notification');
                        ob_start();
                        ?>
							<p>
								<p>
									<a href="#TB_inline?width=600&height=380&inlineId=notification_message_<?php 
                        echo (int) $r_post->ID;
                        ?>
" id="show_notification_tb_link_<?php 
                        echo (int) $r_post->ID;
                        ?>
" class="thickbox si_tooltip notification_message" title="<?php 
                        si_e('View Message');
                        ?>
"><?php 
                        si_e('View Message');
                        ?>
</a>
								</p>
								<div id="notification_message_<?php 
                        echo (int) $r_post->ID;
                        ?>
" class="cloak">
									<?php 
                        echo wpautop($r_post->post_content);
                        ?>
								</div>
							</p>
						<?php 
                        $notification_message = ob_get_clean();
                        $history[$time]['content'] = $notification_message;
                        break;
                    case 'si_invoice_created':
                        $history[$time]['type'] = sc__('Invoice Created');
                        break;
                    case 'si_history_status_update':
                    default:
                        $history[$time]['type'] = sc__('Status Update');
                        unset($history[$time]['title']);
                        break;
                }
            }
        }
        return $history;
    }
 /**
  * Display the content for the column
  *
  * @param string  $column_name
  * @param int     $id          post_id
  * @return string
  */
 public static function column_display($column_name, $id)
 {
     $client = Sprout_Client::get_instance($id);
     if (!is_a($client, 'Sprout_Client')) {
         return;
         // return for that temp post
     }
     switch ($column_name) {
         case 'sc_client_type':
             sc_type_select($id);
             break;
         case 'sc_client_status':
             sc_status_select($id);
             break;
         case 'lead_info':
             echo '<p>';
             $address = si_format_address($client->get_address(), 'string', '<br/>');
             print $address;
             if ('' !== $address) {
                 echo '<br/>';
             }
             echo make_clickable(esc_url($client->get_website()));
             echo '</p>';
             break;
         case 'contacts':
             $associated_users = $client->get_associated_users();
             echo '<p>';
             printf('<b>%s</b>: ', sc__('User Contacts'));
             if (!empty($associated_users)) {
                 $users_print = array();
                 foreach ($associated_users as $user_id) {
                     $user = get_userdata($user_id);
                     if (!is_a($user, 'WP_User')) {
                         $client->remove_associated_user($user_id);
                         continue;
                     }
                     $users_print[] = sprintf('<span class="associated_user"><a href="%s">%s</a></span>', get_edit_user_link($user_id), sc_get_users_full_name($user_id));
                 }
             }
             if (!empty($users_print)) {
                 print implode(', ', $users_print);
             } else {
                 sc_e('No associated people/users.');
             }
             echo '</p>';
             break;
         default:
             // code...
             break;
     }
 }