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; }
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; }