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 maybe_update_private_note() { if (!isset($_REQUEST['nonce'])) { wp_die('Forget something?'); } $nonce = $_REQUEST['nonce']; if (!wp_verify_nonce($nonce, self::NONCE)) { wp_die('Not going to fall for it!'); } if (!isset($_REQUEST['record_id'])) { self::ajax_fail('No id given!'); } $record_id = $_REQUEST['record_id']; $private_note = $_REQUEST['private_note']; $record = SC_Record::get_instance($record_id); $record->set_data($private_note, false); exit; }
function column_data($item) { $record = SC_Record::get_instance($item->ID); $data = $record->get_data(); if ($data != '') { ?> <a href="#TB_inline?width=900&height=600&inlineId=data_id_<?php echo esc_attr($item->ID); ?> " class="thickbox button" title="<?php echo esc_attr($item->post_title); ?> <?php sc_e('Data'); ?> "><?php sc_e('View Data'); ?> </a> <?php if (is_array($data)) { ?> <div id="data_id_<?php echo esc_attr($item->ID); ?> " style="display:none;"><pre style="white-space:pre-wrap; text-align: left; font: normal normal 11px/1.4 menlo, monaco, monospaced; padding: 5px;"><?php print_r($data); ?> </pre></div> <?php } else { ?> <div id="data_id_<?php echo esc_attr($item->ID); ?> " style="display:none;"><?php echo apply_filters('the_content', $data); ?> </div> <?php } ?> <?php } }
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; }