/**
  * Create a project select list that are grouped by client.
  * @param  integer $selected_id
  * @return string
  */
 function si_projects_select($selected_id = 0, $client_id = 0, $blank = true, $el_id = 'doc_project')
 {
     $selections = array();
     if ($client_id) {
         $client = SI_Client::get_instance($client_id);
         if (is_a($client, 'SI_Client')) {
             $projects = SI_Project::get_projects_by_client($client_id);
             $selections[$client->get_title()] = $projects;
         }
     }
     if (empty($selections)) {
         $args = array('post_type' => SI_Project::POST_TYPE, 'post_status' => 'any', 'posts_per_page' => -1, 'fields' => 'ids');
         $projects = get_posts($args);
         foreach ($projects as $project_id) {
             $project = SI_Project::get_instance($project_id);
             $clients = $project->get_associated_clients();
             foreach ($clients as $client_id) {
                 $client = SI_Client::get_instance($client_id);
                 if (is_a($client, 'SI_Client')) {
                     if (!isset($selections[$client->get_title()])) {
                         $selections[$client->get_title()] = array();
                     }
                     $selections[$client->get_title()][] = $project_id;
                 } else {
                     // no client assigned
                     $selections[si__('Client N/A')][] = $project_id;
                 }
             }
         }
     }
     if (!empty($selections)) {
         $out = '<select name="' . $el_id . '" class="select2">';
         if ($blank) {
             $out .= sprintf('<option value="0">%s</option>', si__('Select Project'));
         }
         foreach ($selections as $client => $projects) {
             $out .= sprintf('<optgroup label="%s">', $client);
             foreach ($projects as $project_id) {
                 $out .= sprintf('<option value="%s" %s>%s</option>', $project_id, selected($project_id, $selected_id, false), get_the_title($project_id));
             }
             $out .= '</optgroup>';
         }
         $out .= '</select>';
     } else {
         $out = '<span>' . sprintf(si__('No <a href="%s" target="_blank">projects</a> found'), admin_url('post-new.php?post_type=' . SI_Project::POST_TYPE)) . '</span>';
     }
     echo $out;
 }
 public static function ajax_admin_payment()
 {
     // form maybe be serialized
     if (isset($_REQUEST['serialized_fields'])) {
         foreach ($_REQUEST['serialized_fields'] as $key => $data) {
             if (strpos($data['name'], '[]') !== false) {
                 $_REQUEST[str_replace('[]', '', $data['name'])][] = $data['value'];
             } else {
                 $_REQUEST[$data['name']] = $data['value'];
             }
         }
     }
     if (!isset($_REQUEST['sa_metabox_payments_nonce'])) {
         self::ajax_fail('Forget something?');
     }
     $nonce = $_REQUEST['sa_metabox_payments_nonce'];
     if (!wp_verify_nonce($nonce, SI_Controller::NONCE)) {
         self::ajax_fail('Not going to fall for it!');
     }
     if (!isset($_REQUEST['sa_metabox_invoice_id'])) {
         self::ajax_fail('Forget something?');
     }
     if (get_post_type($_REQUEST['sa_metabox_invoice_id']) != SI_Invoice::POST_TYPE) {
         self::ajax_fail('Error: Invoice PT mismatch.');
     }
     $amount = isset($_REQUEST['sa_metabox_payment_amount']) ? $_REQUEST['sa_metabox_payment_amount'] : 0;
     $number = isset($_REQUEST['sa_metabox_payment_transaction_id']) ? $_REQUEST['sa_metabox_payment_transaction_id'] : '';
     $date = isset($_REQUEST['sa_metabox_payment_date']) ? $_REQUEST['sa_metabox_payment_date'] : '';
     $notes = isset($_REQUEST['sa_metabox_payment_notes']) ? $_REQUEST['sa_metabox_payment_notes'] : '';
     if (!$amount) {
         self::ajax_fail('No payment amount set.');
     }
     self::create_admin_payment($_REQUEST['sa_metabox_invoice_id'], $amount, $number, $date, $notes);
     header('Content-type: application/json');
     if (self::DEBUG) {
         header('Access-Control-Allow-Origin: *');
     }
     echo wp_json_encode(array('response' => si__('Payment Added')));
     exit;
 }
 /**
  * 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('status' => si__('Status'), 'title' => si__('Payment'), 'total' => si__('Totals'), 'data' => si__('Data'));
     return apply_filters('si_mngt_payments_columns', $columns);
 }
} elseif ($status == SI_Invoice::STATUS_PARTIAL) {
    ?>
				<?php 
    printf('<span class="si_status publish si_tooltip button current_status" title="%s" disabled><span>%s</span>%s</span>', self::__('Outstanding Balance'), si__('Outstanding Balance'), $status_change_span);
    ?>
			<?php 
} elseif ($status == SI_Invoice::STATUS_WO) {
    ?>
				<?php 
    printf('<span class="si_status declined si_tooltip button current_status" title="%s" disabled><span>%s</span>%s</span>', self::__('Written-off'), si__('Written Off'), $status_change_span);
    ?>
			<?php 
} else {
    ?>
				<?php 
    printf('<span class="si_status temp si_tooltip button current_status" title="%s" disabled><span>%s</span>%s</span>', self::__('Temp Invoice'), si__('Temp'), $status_change_span);
    ?>
			<?php 
}
?>
		</span>
	</span>
	<div id="status_change_<?php 
echo (int) $id;
?>
" class="dropdown dropdown-tip dropdown-relative dropdown-anchor-right">
		<ul class="dropdown-menu">
			<?php 
if ($status != SI_Invoice::STATUS_PENDING) {
    ?>
				<?php 
 /**
  * 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' => si__('Type'), 'subject' => si__('Subject'), 'message' => si__('Message'));
     return apply_filters('si_mngt_notification_columns', $columns);
 }
		<?php 
}
?>
	</div>


	<div id="edit-slug-box" class="clearfix">
		<b><?php 
si_e('Permalink');
?>
</b>
		<span id="permalink-select" tabindex="-1"><?php 
echo get_permalink($id);
?>
</span>
		<span id="view-post-btn"><a href="<?php 
echo get_permalink($id);
?>
" class="button button-small"><?php 
si_e('View Estimate');
?>
</a></span>
		<?php 
if (apply_filters('show_upgrade_messaging', true)) {
    printf(si__('<span class="helptip" title="Upgrade for Private URLs"></span>'), si_get_purchase_link());
}
?>
	</div>


</div>
// styles and scripts are filtered
?>
		<meta name="robots" content="noindex, nofollow" />
	</head>

	<body id="estimate" <?php 
body_class();
?>
>
		
		<div id="outer_doc_wrap">

			<div id="doc_header_wrap" class="sticky_header">
				<header id="header_title">
					<span class="header_id"><?php 
printf(si__('Estimate %s'), si_get_estimate_id());
?>
</span>
					<div id="doc_actions">
						<?php 
do_action('si_doc_actions_pre');
?>
						<?php 
if (!si_is_estimate_approved()) {
    ?>
							<a href="#accept" class="button primary_button status_change" data-status-change="accept" data-id="<?php 
    the_ID();
    ?>
" data-nonce="<?php 
    echo wp_create_nonce(SI_Controller::NONCE);
    ?>
/**
 * Changing the line item labels/names and adding a new line item type.
 *
 */
function add_new_line_item_types($types = array())
{
    $array_of_new_types = array('task' => si__('Labour'), 'product' => si__('Equipment'), 'expenses' => si__('Expenses'));
    $types = array_merge($types, $array_of_new_types);
    return $types;
}
Example #9
0
 /**
  * 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 . '">' . si__($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);
 }
 /**
  * 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' => si__('Date'), 'title' => si__('Subject'), 'data' => si__('Data'), 'associate' => si__('Association'), 'type' => si__('Type'));
     return apply_filters('si_mngt_record_columns', $columns);
 }
 public static function help_tabs()
 {
     if (isset($_GET['tab']) && $_GET['tab'] == self::SETTINGS_PAGE) {
         // get screen and add sections.
         $screen = get_current_screen();
         $screen->add_help_tab(array('id' => 'reports-about', 'title' => self::__('About Reports'), 'content' => sprintf('<p>%s</p><p>%s</p><p>%s</p>', self::__('The Reports dashboard links to the many single reports that Sprout Invoice provides, don’t miss them.'), self::__('<b>Dashboard</b> - Is the place to get a quick status overview. See what was recently updated, what’s currently overdue or unpaid, and other important information about your business.'), self::__('<b>Reports</b> - Reports have advanced filtering and are highly customizable. All data is dynamically updated without reloading.'))));
         $screen->add_help_tab(array('id' => 'reports-tables', 'title' => self::__('Report Tables'), 'content' => sprintf('<p>%s</p><p>%s</p><p>%s</p><p>%s</p>', self::__('<b>Date filtering</b> is available and can be used to retrieve data in-between t, dates, or after a date, or before a date.'), self::__('<b>Modify columns</b> within the table with the “Show / hide columns” button.'), self::__('<b>Export</b> the table, filtered or not, to many formats, including CSV, Excel, PDF or your computers clipboard.'), self::__('Records are <em>limited to 2,500 items</em>. If you want to return more use the ‘si_reports_show_records’ filter.'))));
         if (!isset($_GET['report'])) {
             $screen->add_help_tab(array('id' => 'reports-refresh', 'title' => self::__('Dashboard Refresh'), 'content' => sprintf('<p>%s</p><p><span class="cache_button_wrap casper clearfix"><a href="%s">%s</a></span></p></p>', si__('The reports dashboard is cached and if new invoices or estimates were just created the values under "Invoice Dashboard" may be out of date. Use the refresh button below to flush the cache and get the latest stats.'), esc_url(add_query_arg(array('nocache' => 1))), si__('Refresh'))));
         }
         $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/reports/', self::__('Documentation')) . sprintf('<p><a href="%s" class="button">%s</a></p>', 'https://sproutapps.co/support/', self::__('Support')));
     }
 }
Example #12
0
			<?php 
}
?>

			<div id="doc_header_wrap" class="sticky_header">
				<header id="header_title">
					<span class="header_id"><?php 
printf(si__('Invoice %s'), si_get_invoice_id());
?>
</span>
					<div id="doc_actions">
						<?php 
do_action('si_doc_actions_pre');
?>
						<?php 
$payment_string = si_has_invoice_deposit() ? si__('Pay Deposit') : si__('Pay Invoice');
?>
						<?php 
if (si_get_invoice_balance() && si_get_invoice_status() != 'write-off') {
    ?>
							
							<?php 
    $payment_options = si_payment_options();
    ?>
							<?php 
    if (count($payment_options) == 1) {
        ?>
								<?php 
        foreach ($payment_options as $slug => $options) {
            ?>
									<a href="<?php 
echo si_line_item_build_option(0);
?>
			</li>
		</ol>
	</div>
	<div id="line_items_footer" class="clearfix">
		<div class="mngt_wrap clearfix">
			<div id="add_line_item">
				
				<?php 
do_action('si_add_line_item');
?>
				
				<span class="add_button_wrap">
					<?php 
echo apply_filters('si_add_line_item_add_button', '<a href="javascript:void(0)" class="add_line_item add_button item_add_type item_add_no_type button">&nbsp;' . si__('Add') . '</a>');
?>
				</span>
				<?php 
if (apply_filters('show_upgrade_messaging', true)) {
    ?>
					<span title="<?php 
    self::esc_e('Predefined line-items can be created to help with invoice creation by adding default descriptions. This is a premium feature that will be added with a pro version upgrade.');
    ?>
" class="helptip add_item_help"></span>
					
					<span id="time_importing">
						<?php 
    printf('<button id="time_import_question_answer_upgrade" class="button disabled si_tooltip" title="%s">%s</button>', self::__('Any billable time can be imported from your projects into your invoices dynamically with a pro version upgrade.'), self::__('Import Time'));
    ?>
					</span>
 public static function help_tabs()
 {
     $post_type = '';
     if (isset($_GET['tab']) && $_GET['tab'] == self::SETTINGS_PAGE) {
         $post_type = SI_Notification::POST_TYPE;
     }
     if ($post_type == '' && isset($_GET['post'])) {
         $post_type = get_post_type($_GET['post']);
     }
     if ($post_type == SI_Notification::POST_TYPE) {
         // get screen and add sections.
         $screen = get_current_screen();
         $screen->add_help_tab(array('id' => 'notification-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 notifications can be customized; hover over the notification you want and click the edit link.'))));
         $screen->add_help_tab(array('id' => 'notification-disable', 'title' => self::__('Disable Notifications'), 'content' => sprintf('<p>%s</p>', self::__('The notifications edit screen will have an option next to the "Update" button to disable the notification from being sent.'))));
         $screen->add_help_tab(array('id' => 'notification-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 notifications subject. If the notification is an e-mail than it would be subject line for that e-mail notification.'), self::__('<b>Message Body</b> - The main editor is the notification body. Use the available shortcodes to have dynamic information included when the notification is received. Make sure to change the Notification Setting if HTML formatting is added to your notifications.'), 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 notification to a different type; it’s recommended you go to the notification you want to edit instead of using this option. The Disabled option available to prevent this notification from sending.'))));
         $screen->add_help_tab(array('id' => 'notification-advanced', 'title' => self::__('Advanced'), 'content' => sprintf('<p><b>HTML Emails</b> - Enable HTML notifications within the <a href="%s">General Settings</a> page. Make sure to change use HTML on all notifications.</p>', admin_url('admin.php?page=sprout-apps/settings'))));
         $screen->add_help_tab(array('id' => 'notification-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>', si__('In an earlier version of Sprout Invoices numerous notifications were improperly created. Click refresh below to delete all extraneous notifications. Backup any modifications that you might have made to your notifications before continuing.'), esc_url(add_query_arg(array('refresh-notifications' => 1))), si__('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/notifications/', self::__('Documentation')) . sprintf('<p><a href="%s" class="button">%s</a></p>', 'https://sproutapps.co/support/', self::__('Support')));
     }
 }
} elseif ($status == SI_Estimate::STATUS_DECLINED) {
    ?>
				<?php 
    printf('<button class="si_status declined si_tooltip button current_status" title="%s" disabled><span>%s</span>%s</button>', self::__('Currently Declined.'), si__('Declined'), $status_change_span);
    ?>
			<?php 
} elseif ($status == SI_Estimate::STATUS_REQUEST) {
    ?>
				<?php 
    printf('<button class="si_status draft si_tooltip button current_status" title="%s" disabled><span>%s</span>%s</button>', self::__('New Estimate Request'), si__('Submission'), $status_change_span);
    ?>
			<?php 
} else {
    ?>
				<?php 
    printf('<button class="si_status draft si_tooltip button current_status" title="%s" disabled><span>%s</span>%s</button>', self::__('Pending Estimate Request.'), si__('Draft'), $status_change_span);
    ?>
			<?php 
}
?>
		</span>
	</span>

	<div id="status_change_<?php 
echo (int) $id;
?>
" class="dropdown dropdown-tip dropdown-relative dropdown-anchor-right">
		<ul class="dropdown-menu">
			<?php 
if ($status != SI_Estimate::STATUS_PENDING) {
    ?>
Example #16
0
function si_doc_history_records($doc_id = 0, $filtered = true)
{
    if (!$doc_id) {
        global $post;
        $doc_id = $post->ID;
    }
    $returned_history = array();
    switch (get_post_type($doc_id)) {
        case SI_Estimate::POST_TYPE:
            $estimate = SI_Estimate::get_instance($doc_id);
            $history = $estimate->get_history();
            break;
        case SI_Invoice::POST_TYPE:
            $invoice = SI_Invoice::get_instance($doc_id);
            $history = array_merge($invoice->get_history(), $invoice->get_payments());
            break;
        default:
            # code...
            break;
    }
    $history = apply_filters('si_doc_history_records_pre_sort', $history, $doc_id, $filtered);
    // Sort in ascending order
    asort($history, SORT_NUMERIC);
    foreach ($history as $item_id) {
        if (get_post_type($item_id) == SI_Record::POST_TYPE) {
            $record = SI_Record::get_instance($item_id);
            // If no type is set than just keep on moving.
            if ($record->get_type() == SI_Record::DEFAULT_TYPE) {
                continue;
            }
            // filter these types of records out.
            if ($filtered) {
                if (in_array($record->get_type(), array(SI_Controller::PRIVATE_NOTES_TYPE, SI_Estimates::VIEWED_STATUS_UPDATE, SI_Notifications::RECORD))) {
                    continue;
                }
            }
            $r_post = $record->get_post();
            switch ($record->get_type()) {
                case SI_Controller::PRIVATE_NOTES_TYPE:
                    $returned_history[$item_id]['type'] = si__('Private Note');
                    break;
                case SI_Estimates::HISTORY_UPDATE:
                    $returned_history[$item_id]['type'] = si__('Updated');
                    break;
                case SI_Estimates::VIEWED_STATUS_UPDATE:
                    $returned_history[$item_id]['type'] = si__('Viewed');
                    break;
                case SI_Notifications::RECORD:
                    $returned_history[$item_id]['type'] = si__('Notification');
                    break;
                case SI_Estimates::HISTORY_INVOICE_CREATED:
                    $returned_history[$item_id]['type'] = si__('Invoice Created');
                    break;
                case SI_Estimate_Submissions::SUBMISSION_UPDATE:
                    $returned_history[$item_id]['type'] = si__('Submitted');
                    break;
                case SI_Importer::RECORD:
                    $returned_history[$item_id]['type'] = si__('Imported');
                    break;
                case SI_Estimates::HISTORY_STATUS_UPDATE:
                default:
                    $returned_history[$item_id]['type'] = si__('Status Update');
                    break;
            }
            $returned_history[$item_id]['status_type'] = $record->get_type();
            $returned_history[$item_id]['post_date'] = $r_post->post_date;
            $returned_history[$item_id]['update_title'] = $r_post->post_title;
            $returned_history[$item_id]['content'] = $r_post->post_content;
        } elseif (get_post_type($item_id) == SI_Payment::POST_TYPE) {
            $payment = SI_Payment::get_instance($item_id);
            $p_post = $payment->get_post();
            $returned_history[$item_id]['type'] = si__('Payment');
            $returned_history[$item_id]['status_type'] = 'payment';
            $returned_history[$item_id]['post_date'] = $p_post->post_date;
            $returned_history[$item_id]['update_title'] = $p_post->post_title;
            $returned_history[$item_id]['content'] = '';
            $returned_history[$item_id]['content'] .= '<span>' . $payment->get_payment_method() . '</span><br/>';
            $returned_history[$item_id]['content'] .= '<b>' . si__('Payment Total') . ':</b> ' . sa_get_formatted_money($payment->get_amount(), $item_id);
        } else {
            if ($filtered) {
                $comment = get_comment($item_id);
                if (!is_wp_error($comment)) {
                    $returned_history[$item_id]['type'] = $comment->comment_author;
                    $returned_history[$item_id]['status_type'] = 'comment';
                    $returned_history[$item_id]['post_date'] = $comment->comment_date;
                    $returned_history[$item_id]['content'] = get_comment_text($comment->comment_ID) . get_comment_meta($comment->comment_ID, SI_Doc_Comments::DOC_COMMENT_META_POS, true);
                }
            }
        }
    }
    return $returned_history;
}
Example #17
0
?>
		<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(si__('Reset Defaults'), 'secondary', $page . '-reset', false);
    ?>
		<?php 
}
?>
	</form>

	<?php 
do_action('si_settings_page', $page);
?>
	<?php 
do_action('si_settings_page_' . $page, $page);
?>
</div>
Example #18
0
 /**
  * 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 = SI_Client::get_instance($id);
     if (!is_a($client, 'SI_Client')) {
         return;
         // return for that temp post
     }
     switch ($column_name) {
         case 'info':
             echo '<p>';
             $address = si_format_address($client->get_address(), 'string', '<br/>');
             echo $address;
             if ($address != '') {
                 echo '<br/>';
             }
             echo make_clickable(esc_url($client->get_website()));
             echo '</p>';
             $associated_users = $client->get_associated_users();
             echo '<p>';
             printf('<b>%s</b>: ', si__('Users'));
             if (!empty($associated_users)) {
                 $users_print = array();
                 foreach ($associated_users as $user_id) {
                     $user = get_userdata($user_id);
                     if ($user) {
                         $users_print[] = sprintf('<span class="associated_user"><a href="%s">%s</a></span>', get_edit_user_link($user_id), $user->display_name);
                     }
                 }
             }
             if (!empty($users_print)) {
                 echo implode(', ', $users_print);
             } else {
                 echo si__('No associated users');
             }
             echo '</p>';
             break;
         case 'invoices':
             $invoices = $client->get_invoices();
             $split = 3;
             $split_invoices = array_slice($invoices, 0, $split);
             if (!empty($split_invoices)) {
                 echo '<dl>';
                 foreach ($split_invoices as $invoice_id) {
                     printf('<dt>%s</dt><dd><a href="%s">%s</a></dd>', get_post_time(get_option('date_format'), false, $invoice_id), get_edit_post_link($invoice_id), get_the_title($invoice_id));
                 }
                 echo '</dl>';
                 if (count($invoices) > $split) {
                     printf('<span class="description">' . si__('...%s of <a href="%s">%s</a> most recent shown') . '</span>', $split, get_edit_post_link($id), count($invoices));
                 }
             } else {
                 printf('<em>%s</em>', si__('No invoices'));
             }
             break;
         case 'estimates':
             $estimates = $client->get_estimates();
             $split = 3;
             $split_estimates = array_slice($estimates, 0, $split);
             if (!empty($split_estimates)) {
                 echo '<dl>';
                 foreach ($split_estimates as $estimate_id) {
                     printf('<dt>%s</dt><dd><a href="%s">%s</a></dd>', get_post_time(get_option('date_format'), false, $estimate_id), get_edit_post_link($estimate_id), get_the_title($estimate_id));
                 }
                 echo '</dl>';
                 if (count($estimates) > $split) {
                     printf('<span class="description">' . si__('...%s of <a href="%s">%s</a> most recent shown') . '</span>', $split, get_edit_post_link($id), count($estimates));
                 }
             } else {
                 printf('<em>%s</em>', si__('No estimates'));
             }
             break;
         default:
             // code...
             break;
     }
 }
 /**
  * Mark payment complete
  *
  * @return
  */
 public static function manually_mark_complete()
 {
     if (!isset($_REQUEST['complete_payment_nonce'])) {
         self::ajax_fail('Forget something?');
     }
     $nonce = $_REQUEST['complete_payment_nonce'];
     if (!wp_verify_nonce($nonce, self::AJAX_NONCE)) {
         self::ajax_fail('Not going to fall for it!');
     }
     if (!current_user_can('manage_sprout_invoices_payments')) {
         return;
     }
     $payment_id = $_REQUEST['payment_id'];
     $payment = SI_Payment::get_instance($payment_id);
     $status = $payment->get_status();
     if (!is_a($payment, 'SI_Payment')) {
         self::ajax_fail('Payment ID Error.');
     }
     $payment->set_status(SI_Payment::STATUS_COMPLETE);
     if ($payment->get_status() != $status) {
         header('Content-type: application/json');
         echo wp_json_encode(array('response' => si__('Payment status updated.')));
         exit;
     } else {
         self::ajax_fail('Failed payment capture.');
     }
 }
    /**
     * Template selection for advanced client options
     * @param  string  $type      invoice/estimate
     * @param  integer $client_id 
     * @return              
     */
    public static function client_template_options($type = 'invoice', $client_id = 0)
    {
        ob_start();
        $template_options = $type != 'estimate' ? self::get_invoice_templates() : self::get_estimate_templates();
        $doc_type_name = $type != 'estimate' ? self::__('invoice') : self::__('estimate');
        $template = $type != 'estimate' ? self::get_client_invoice_template($client_id) : self::get_client_estimate_template($client_id);
        ?>
		<div class="misc-pub-section" data-edit-id="template" data-edit-type="select">
			<span id="template" class="wp-media-buttons-icon"><b><?php 
        echo esc_html($template_options[$template]);
        ?>
</b> <span title="<?php 
        printf(self::__('Select a custom %s template.'), $doc_type_name);
        ?>
" class="helptip"></span></span>

			<a href="#edit_template" class="edit-template hide-if-no-js edit_control" >
				<span aria-hidden="true"><?php 
        si_e('Edit');
        ?>
</span> <span class="screen-reader-text"><?php 
        si_e('Select different template');
        ?>
</span>
			</a>

			<div id="template_div" class="control_wrap hide-if-js">
				<div class="template-wrap">
					<?php 
        if (count($template_options) > 1) {
            ?>
						<select name="doc_template_<?php 
            echo esc_attr($doc_type_name);
            ?>
">
							<?php 
            foreach ($template_options as $template_key => $template_name) {
                ?>
								<?php 
                printf('<option value="%s" %s>%s</option>', $template_key, selected($template_key, $template, false), $template_name);
                ?>
							<?php 
            }
            ?>
						</select>
					<?php 
        } else {
            ?>
						<span><?php 
            printf(si__('No <a href="%s" target="_blank">Custom Templates</a> Found'), 'https://sproutapps.co/support/knowledgebase/sprout-invoices/customizing-templates/');
            ?>
</span>
					<?php 
        }
        ?>
		 		</div>
				<p>
					<a href="#edit_template" class="save_control save-template hide-if-no-js button"><?php 
        si_e('OK');
        ?>
</a>
					<a href="#edit_template" class="cancel_control cancel-template hide-if-no-js button-cancel"><?php 
        si_e('Cancel');
        ?>
</a>
				</p>
		 	</div>
		</div>
		<?php 
        $view = ob_get_clean();
        return $view;
    }
    $record = SI_Record::get_instance($record_id);
    // If no type is set than just keep on moving.
    if ($record->get_type() == SI_Record::DEFAULT_TYPE) {
        continue;
    }
    $r_post = $record->get_post();
    switch ($record->get_type()) {
        case SI_Controller::PRIVATE_NOTES_TYPE:
            $type = si__('Private Note');
            break;
        case SI_Notifications::RECORD:
            $type = si__('Notification');
            break;
        case SI_Projects::HISTORY_STATUS_UPDATE:
        default:
            $type = si__('Status Update');
            break;
    }
    ?>
		<dt class="record record-<?php 
    echo $record_id;
    ?>
">
			<span class="history_deletion"><button data-id="<?php 
    echo $record_id;
    ?>
" class="delete_record del_button">X</button></span>
			<span class="history_status <?php 
    echo esc_attr($record->get_type());
    ?>
"><?php 
 /**
  * Create Estimate
  * @param  array  $args * subject
  *                      * requirements
  *                      * fields
  *                      
  */
 public static function maybe_create_estimate($args = array())
 {
     $defaults = array('subject' => sprintf(self::__('New Estimate: %s'), date(get_option('date_format') . ' @ ' . get_option('time_format'), current_time('timestamp'))), 'requirements' => self::__('No requirements submitted. Check to make sure the "requirements" field is required.'), 'fields' => $_REQUEST);
     $parsed_args = apply_filters('si_afi_maybe_create_estimate', wp_parse_args($args, $defaults));
     // Create estimate
     $estimate_id = SI_Estimate::create_estimate($parsed_args);
     $estimate = SI_Estimate::get_instance($estimate_id);
     // TODO Add images
     // TODO Set the solution type
     // End, don't use estimate_submitted since a notification will be fired.
     do_action('estimate_submitted_from_adv_form', $estimate, $parsed_args);
     // History
     do_action('si_new_record', sprintf(si__('Estimate Submitted: Form %s.'), $parsed_args['history_link']), self::SUBMISSION_UPDATE, $estimate_id, sprintf(si__('Estimate Submitted: Form %s.'), $parsed_args['history_link']), 0, false);
     return $estimate;
 }

<?php 
do_action('doc_information_meta_box_date_row_last', $estimate);
?>

<hr/>

<?php 
do_action('doc_information_meta_box_client_row', $estimate);
?>

<!-- Client -->
<div class="misc-pub-section" data-edit-id="client" data-edit-type="select">
	<?php 
$client_name = $client_id ? sprintf('<a href="%s">%s</a>', get_edit_post_link($client_id), get_the_title($client_id)) : si__('Client N/A');
?>
	<span id="client" class="wp-media-buttons-icon"><?php 
si_e('Estimate for');
?>
 <b><?php 
echo $client_name;
?>
</b></span>

	<a href="#edit_client" class="edit-client hide-if-no-js edit_control" >
		<span aria-hidden="true"><?php 
si_e('Edit');
?>
</span> <span class="screen-reader-text"><?php 
si_e('Select different client');
} else {
    ?>
										<img src="<?php 
    echo si_doc_header_logo_url();
    ?>
" alt="document logo" >
									<?php 
}
?>
								</h1>	
							</header><!-- /header -->
							<?php 
if (!si_get_invoice_balance()) {
    ?>
								<?php 
    $status = si_has_invoice_deposit() ? si__('Deposit Made') : si__('Paid');
    ?>
								<span id="status" class="paid"><span class="inner_status"><?php 
    echo esc_html($status);
    ?>
</span></span>
							<?php 
} else {
    ?>
								<span id="status" class="void"><span class="inner_status"><?php 
    si_e('Pending');
    ?>
</span></span>
							<?php 
}
?>
Example #25
0
 /**
  * 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)
 {
     $project = SI_Project::get_instance($id);
     if (!is_a($project, 'SI_Project')) {
         return;
     }
     // return for that temp post
     switch ($column_name) {
         case 'info':
             $associated_clients = $project->get_associated_clients();
             echo '<p>';
             printf('<b>%s</b>: ', si__('Client'));
             if (!empty($associated_clients)) {
                 $clients_print = array();
                 foreach ($associated_clients as $client_id) {
                     $clients_print[] = sprintf('<span class="associated_client"><a href="%s">%s</a></span>', get_edit_post_link($client_id), get_the_title($client_id));
                 }
             }
             if (!empty($clients_print)) {
                 echo implode(', ', $clients_print);
             } else {
                 echo si__('No associated clients');
             }
             echo '</p>';
             echo '<p>';
             printf('<b>%s</b>: ', si__('Site'));
             echo make_clickable(esc_url($project->get_website()));
             echo '</p>';
             break;
         case 'invoices':
             $invoices = $project->get_invoices();
             $split = 2;
             $split_invoices = array_slice($invoices, 0, $split);
             if (!empty($split_invoices)) {
                 echo "<dl>";
                 foreach ($split_invoices as $invoice_id) {
                     printf('<dt>%s</dt><dd><a href="%s">%s</a></dd>', get_post_time(get_option('date_format'), false, $invoice_id), get_edit_post_link($invoice_id), get_the_title($invoice_id));
                 }
                 echo "</dl>";
                 if (count($invoices) > $split) {
                     printf('<span class="description">' . si__('...%s of <a href="%s">%s</a> most recent shown') . '</span>', $split, get_edit_post_link($id), count($invoices));
                 }
             } else {
                 printf('<em>%s</em>', si__('No invoices'));
             }
             break;
         case 'estimates':
             $estimates = $project->get_estimates();
             $split = 2;
             $split_estimates = array_slice($estimates, 0, $split);
             if (!empty($split_estimates)) {
                 echo "<dl>";
                 foreach ($split_estimates as $estimate_id) {
                     printf('<dt>%s</dt><dd><a href="%s">%s</a></dd>', get_post_time(get_option('date_format'), false, $estimate_id), get_edit_post_link($estimate_id), get_the_title($estimate_id));
                 }
                 echo "</dl>";
                 if (count($estimates) > $split) {
                     printf('<span class="description">' . si__('...%s of <a href="%s">%s</a> most recent shown') . '</span>', $split, get_edit_post_link($id), count($estimates));
                 }
             } else {
                 printf('<em>%s</em>', si__('No estimates'));
             }
             break;
         default:
             // code...
             break;
     }
 }
 public static function maybe_create_private_note()
 {
     if (!isset($_REQUEST['private_note_nonce'])) {
         self::ajax_fail('Forget something?');
     }
     $nonce = $_REQUEST['private_note_nonce'];
     if (!wp_verify_nonce($nonce, SI_Internal_Records::NONCE)) {
         self::ajax_fail('Not going to fall for it!');
     }
     if (!current_user_can('edit_sprout_invoices')) {
         return;
     }
     $record_id = SI_Internal_Records::new_record($_REQUEST['notes'], SI_Controller::PRIVATE_NOTES_TYPE, $_REQUEST['associated_id'], '', 0, false);
     $error = $record_id ? '' : si__('Private note failed to save, try again.');
     $data = array('id' => $record_id, 'content' => $_REQUEST['notes'], 'type' => si__('Private Note'), 'post_date' => si__('Just now'), 'error' => $error);
     header('Content-type: application/json');
     if (self::DEBUG) {
         header('Access-Control-Allow-Origin: *');
     }
     echo wp_json_encode($data);
     exit;
 }
Example #27
0
 /**
  * Maybe create a status update record
  * @param  SI_Estimate $estimate
  * @param  string      $status
  * @param  string      $original_status
  * @return null
  */
 public static function maybe_create_status_update_record(SI_Invoice $invoice, $status = '', $original_status = '')
 {
     do_action('si_new_record', sprintf(si__('Status changed: %s to <b>%s</b>.'), SI_Invoice::get_status_label($original_status), SI_Invoice::get_status_label($status)), self::HISTORY_STATUS_UPDATE, $invoice->get_id(), sprintf(si__('Status update for %s.'), $invoice->get_id()), 0, false);
 }
 /**
  * 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)
 {
     $estimate = SI_Estimate::get_instance($id);
     if (!is_a($estimate, 'SI_Estimate')) {
         return;
         // return for that temp post
     }
     switch ($column_name) {
         case 'doc_link':
             $invoice_id = $estimate->get_invoice_id();
             if ($invoice_id) {
                 printf('<a class="doc_link si_status %1$s" title="%2$s" href="%3$s">%4$s</a>', si_get_invoice_status($invoice_id), self::__('Invoice for this estimate.'), get_edit_post_link($invoice_id), '<div class="dashicons icon-sproutapps-invoices"></div>');
             }
             break;
         case 'status':
             self::status_change_dropdown($id);
             break;
         case 'total':
             printf('<span class="estimate_total">%s</span>', sa_get_formatted_money($estimate->get_total(), $estimate->get_id()));
             break;
         case 'client':
             if ($estimate->get_client_id()) {
                 $client = $estimate->get_client();
                 printf('<b><a href="%s">%s</a></b><br/><em>%s</em>', get_edit_post_link($client->get_ID()), get_the_title($client->get_ID()), $client->get_website());
             } else {
                 printf('<b>%s</b> ', si__('No client'));
             }
             break;
         default:
             // code...
             break;
     }
 }