Exemplo n.º 1
0
/**
 * Payment Form Validate Fields
 *
 * @since	1.3.8
 * @return	bool|arr
 */
function mdjm_payment_form_validate_fields()
{
    // Check if there is $_POST
    if (empty($_POST)) {
        return false;
    }
    $event_id = $_POST['event_id'];
    if (empty($event_id)) {
        return false;
    }
    $client_data = mdjm_get_payment_form_client(mdjm_get_event_client_id($event_id));
    // Start an array to collect valid data
    $valid_data = array('event_id' => $event_id, 'client_id' => $client_data['id'], 'client_data' => $client_data, 'client_ip' => mdjm_get_user_ip(), 'type' => mdjm_get_payment_type(), 'total' => mdjm_get_payment_total(), 'gateway' => mdjm_payment_form_validate_gateway(), 'cc_info' => mdjm_get_purchase_cc_info());
    // Return collected data
    return $valid_data;
}
Exemplo n.º 2
0
/**
 * Sets the recipients that should receive a copy of the email
 *
 * @since	1.3
 * @param	str		$recipient	The address of the original email recipient
 * @param	int		$event_id	Event ID to which the email is associated
 * @param	arr		$others		Array of additional addresses to whom to send a copy of the email
 * @return	arr		$copy_to	Array of addresses to send a copy of the email to
 */
function mdjm_email_maybe_send_a_copy($recipient, $event_id = '', $others = array())
{
    if (is_array($recipient)) {
        return;
    }
    if (!empty($event_id)) {
        $client = get_userdata(mdjm_get_event_client_id($event_id));
        $employee = get_userdata(mdjm_get_event_primary_employee($event_id));
    } else {
        $client = get_user_by('email', $recipient);
    }
    if (!$client) {
        return;
    }
    if (!mdjm_user_is_client($client->ID)) {
        return;
    }
    $copy_to = array();
    if (mdjm_get_option('bcc_admin_to_client')) {
        $copy_to[] = mdjm_get_option('system_email');
    }
    if (mdjm_get_option('bcc_dj_to_client') && !empty($employee)) {
        $copy_to[] = $employee->user_email;
    }
    $copy_to = array_merge($others, $copy_to);
    return array_unique($copy_to);
}
Exemplo n.º 3
0
/**
 * Send admin notice of payment.
 *
 * @since	1.3.8
 * @param
 * @return	void
 */
function mdjm_admin_payment_notice($txn_data)
{
    if (isset($txn_data['gateway'])) {
        $gateway = mdjm_get_gateway_admin_label($txn_data['gateway']);
    } else {
        $gateway = mdjm_get_gateway_admin_label(mdjm_get_default_gateway());
    }
    $subject = sprintf(__('%s Payment received via %s', 'mobile-dj-manager'), mdjm_get_label_singular(), $gateway);
    $subject = apply_filters('mdjm_admin_payment_notice_subject', $subject);
    $content = '<!DOCTYPE html>' . "\n";
    $content .= '<html>' . "\n" . '<body>' . "\n";
    $content .= '<p>' . __('Hi there', 'mobile-dj-manager') . ',</p>' . "\n";
    $content .= '<p>' . __('A payment has just been received via MDJM Event Management', 'mobile-dj-manager') . '</p>' . "\n";
    $content .= '<hr />' . "\n";
    $content .= '<h4>' . sprintf(__('%s ID', 'mobile-dj-manager'), mdjm_get_label_singular()) . ': ' . mdjm_get_event_contract_id($txn_data['event_id']) . '</a></h4>' . "\n";
    $content .= '<p>' . "\n";
    $content .= __('Date', 'mobile-dj-manager') . ': {event_date}<br />' . "\n";
    $content .= __('Status', 'mobile-dj-manager') . ': {event_status}<br />' . "\n";
    $content .= __('Client', 'mobile-dj-manager') . ': {client_fullname}<br />' . "\n";
    $content .= __('Payment Date', 'mobile-dj-manager') . ': {payment_date}<br />' . "\n";
    $content .= __('For', 'mobile-dj-manager') . ': {payment_for}<br />' . "\n";
    $content .= __('Amount', 'mobile-dj-manager') . ': {payment_amount}<br />' . "\n";
    $content .= __('Merchant', 'mobile-dj-manager') . ': ' . $gateway . '<br />' . "\n";
    if (!empty($txn_data['fee'])) {
        $content .= __('Transaction Fee', 'mobile-dj-manager') . ': ' . mdjm_currency_filter(mdjm_format_amount($txn_data['fee'])) . '</span><br />' . "\n";
        $content .= '<strong>' . __('Total Received', 'mobile-dj-manager') . ': ' . mdjm_currency_filter(mdjm_format_amount($txn_data['total'] - $txn_data['fee'])) . '</strong><br />' . "\n";
    }
    $content .= __('Outstanding Balance', 'mobile-dj-manager') . ': {balance}</p>' . "\n";
    $content .= sprintf(__('<a href="%s">View %s</a>', 'mobile-dj-manager'), admin_url('post.php?post=' . $txn_data['event_id'] . '&action=edit'), mdjm_get_label_singular()) . '</p>' . "\n";
    $content .= '<hr />' . "\n";
    $content .= '<p>' . __('Regards', 'mobile-dj-manager') . '<br />' . "\n";
    $content .= '{company_name}</p>' . "\n";
    $content .= '</body>' . "\n";
    $content .= '</html>' . "\n";
    $content = apply_filters('mdjm_admin_payment_notice_content', $content);
    mdjm_send_email_content(array('to_email' => mdjm_get_option('system_email'), 'from_name' => mdjm_get_option('company_name'), 'from_email' => mdjm_get_option('system_email'), 'event_id' => $txn_data['event_id'], 'client_id' => mdjm_get_event_client_id($txn_data['event_id']), 'subject' => $subject, 'message' => $content, 'copy_to' => 'disable', 'source' => __('Automated Payment Received', 'mobile-dj-manager')));
}
Exemplo n.º 4
0
/**
 * Listen for event status changes and update the client status.
 *
 * @since	1.3.7
 * @param	bool	$result		True if the event status change was successful, false if not
 * @param	int		$event_id
 * @return	void
 */
function mdjm_set_client_status_inactive($result, $event_id)
{
    if (!mdjm_get_option('set_client_inactive')) {
        return;
    }
    if (!$result) {
        return;
    }
    $client_id = mdjm_get_event_client_id($event_id);
    if (empty($client_id)) {
        return;
    }
    $next_event = mdjm_get_clients_next_event($client_id);
    if (!$next_event) {
        mdjm_update_client_status($client_id, 'inactive');
    }
}
Exemplo n.º 5
0
 /**
  * Send a copy of the email.
  *
  * @since	1.3
  * @param	str		$subject		The email subject. If omitted, we'll use the title of the tracking post.
  * @param	str		$content		The email content. If omitted, we'll use the tracking ID.
  * @param	arr		$attachments	The email attachments.
  */
 public function send_copy($subject = '', $content = '', $attachments = array())
 {
     if (empty($this->copy_to)) {
         return;
     }
     if (empty($content)) {
         $tracker = get_post($this->tracking_id);
         if (!$tracker) {
             return;
         }
         $content = $tracker->post_content;
         $content = apply_filters('the_content', $content);
         $content = str_replace(']]>', ']]&gt;', $content);
         if (empty($content)) {
             return;
         }
         $subject = html_entity_decode(get_the_title($tracker->ID));
     }
     $copies = is_array($this->copy_to) ? array_unique($this->copy_to) : $this->copy_to;
     $args = array('to_email' => $copies, 'from_name' => $this->from_name, 'from_email' => $this->from_address, 'event_id' => $this->event_id, 'client_id' => !empty($this->event_id) ? mdjm_get_event_client_id($this->event_id) : '', 'subject' => !empty($subject) ? $subject : sprintf(__('Copy of an email recently sent via %s', 'mobile-dj-manager'), '{application_name}'), 'attachments' => $attachments, 'message' => mdjm_email_set_copy_text() . $content, 'track' => false);
     if (mdjm_send_email_content($args)) {
         update_post_meta($tracker->ID, '_mdjm_copy_to', $copies);
     }
 }
Exemplo n.º 6
0
/**
 * Retrieve a list of the employee's clients.
 *
 * @since	1.3
 * @param	int			$employee		The user ID of the employee.
 * @param	bool		$active_only	True to only query active clients, false for all.
 * @param	str			$return			Return resultset as WP_User OBJECTS or ARRAY of user ID's
 * @return	arr|bool	Array of client user ID's or 
 */
function mdjm_get_employee_clients($employee_id = '', $active_only = true, $return = 'OBJECT')
{
    $employee_id = !empty($employee_id) ? $employee_id : get_current_user_id();
    $args['post_status'] = !empty($active_only) ? 'any' : mdjm_active_event_statuses();
    // If we only want active events set an extra check for the event date.
    /*if ( ! empty( $active_only ) )	{
    		$args['date']         = date( 'Y-m-d');
    		$args['date_compare'] = '>=';
    	}*/
    $events = mdjm_get_employee_events($employee_id, $args);
    if (!$events) {
        return false;
    }
    $clients = array();
    // Loop through the events and retrieve the client.
    foreach ($events as $event) {
        $clients[] = mdjm_get_event_client_id($event->ID);
    }
    if (empty($clients)) {
        return false;
    }
    $clients = array_unique($clients);
    $clients = apply_filters('mdjm_get_employee_clients', $clients, $employee_id);
    if ($return != 'ARRAY') {
        foreach ($clients as $client) {
            $client_objects[] = get_userdata($client);
        }
        $clients = $client_objects;
    }
    return $clients;
}
Exemplo n.º 7
0
/**
 * Content tag: client_username.
 * The client login.
 *
 * @param	int		The event ID.
 * @param	int		The client ID.
 *
 * @return	str		The login name of the client.
 */
function mdjm_content_tag_client_username($event_id = '', $client_id = '')
{
    if (!empty($client_id)) {
        $user_id = $client_id;
    } elseif (!empty($event_id)) {
        $user_id = mdjm_get_event_client_id($event_id);
    } else {
        $user_id = '';
    }
    $login = '';
    if (!empty($user_id)) {
        $login = mdjm_get_client_login($user_id);
    }
    return $login;
}
Exemplo n.º 8
0
/**
 * Generates a new online quote for the event.
 *
 * Uses the quote template defined within settings unless $template_id is provided.
 *
 * @since	1.3
 * @param	int			$event_id		The event ID.
 * @param	int			$template_id	The template ID from which to create the quote.
 * @return	int			$quote_id		The ID of the newly created post or false on fail.
 */
function mdjm_create_online_quote($event_id, $template_id = '')
{
    $existing_id = mdjm_get_event_quote_id($event_id);
    $template_id = !empty($template_id) ? $template_id : mdjm_get_option('online_enquiry');
    if (empty($template_id)) {
        return false;
    }
    /**
     * Allow filtering of the quote template.
     *
     * @since	1.3
     * @param	$template_id
     */
    $template_id = apply_filters('mdjm_online_quote_template', $template_id);
    $template = get_post($template_id);
    if (!$template) {
        return false;
    }
    /**
     * Fire the `mdjm_pre_create_online_quote` hook.
     *
     * @since	1.3
     * @param	int		$event_id		The Event ID
     * @param	int		$template_id	The quote template ID
     * @param	obj		$template		The quote template WP_Post object
     */
    do_action('mdjm_pre_create_online_quote', $event_id, $template_id, $template);
    $client_id = mdjm_get_event_client_id($event_id);
    $content = $template->post_content;
    $content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]&gt;', $content);
    $content = mdjm_do_content_tags($content, $event_id, $client_id);
    $args = array('ID' => $existing_id, 'post_date' => current_time('mysql'), 'post_modified' => current_time('mysql'), 'post_title' => sprintf(__('Quote %s', 'mobile-dj-manager'), mdjm_get_event_contract_id($event_id)), 'post_content' => $content, 'post_type' => 'mdjm-quotes', 'post_status' => 'mdjm-quote-generated', 'post_author' => !empty($client_id) ? $client_id : 1, 'post_parent' => $event_id, 'meta_input' => array('_mdjm_quote_viewed_date' => 0, '_mdjm_quote_viewed_count' => 0));
    /**
     * Allow filtering of the quote template args.
     *
     * @since	1.3
     * @param	$args
     */
    $args = apply_filters('mdjm_create_online_quote_args', $args);
    $quote_id = wp_insert_post($args);
    if (!$quote_id) {
        return false;
    }
    // Reset view date and count for existing quotes
    if (!empty($existing_id)) {
        delete_post_meta($quote_id, '_mdjm_quote_viewed_date');
        delete_post_meta($quote_id, '_mdjm_quote_viewed_count');
    }
    /**
     * Fire the `mdjm_post_create_online_quote` hook.
     *
     * @since	1.3
     * @param	int		$quote_id		The new quote ID
     */
    do_action('mdjm_pre_create_online_quote', $quote_id);
    return $quote_id;
}
    /**
     * Outputs the form for adding an entry
     *
     * @access 	public
     * @since	1.4
     * @return	void
     */
    public function entry_form()
    {
        ?>
        <h3><?php 
        _e('Add Entry to Playlist', 'mobile-dj-manager');
        ?>
</h3>
        <form id="mdjm-playlist-form" name="mdjm-playlist-form" action="" method="post">
			<?php 
        wp_nonce_field('add_playlist_entry', 'mdjm_nonce', true, true);
        ?>
            <?php 
        mdjm_admin_action_field('add_playlist_entry');
        ?>
            <input type="hidden" id="entry_event" name="entry_event" value="<?php 
        echo $_GET['event_id'];
        ?>
" />
            <input type="hidden" id="entry_addedby" name="entry_addedby" value="<?php 
        echo mdjm_get_event_client_id($_GET['event_id']);
        ?>
" />
            <table id="mdjm-playlist-form-table">
                <tr>
                    <td>
                        <label for="entry_song"><?php 
        _e('Song', 'mobile-dj-manager');
        ?>
</label><br />
                        <?php 
        echo MDJM()->html->text(array('name' => 'entry_song', 'type' => 'text'));
        ?>
                    </td>
                    
                    <td class="mdjm-playlist-artist-cell">
                        <label for="entry_artist"><?php 
        _e('Artist', 'mobile-dj-manager');
        ?>
</label><br />
                        <?php 
        echo MDJM()->html->text(array('name' => 'entry_artist', 'type' => 'text'));
        ?>
                    </td>

                    <td class="mdjm-playlist-category-cell">
                        <label for="entry_category"><?php 
        _e('Category', 'mobile-dj-manager');
        ?>
</label><br />
                        <?php 
        $playlist_categories = mdjm_get_playlist_categories();
        ?>
                        <?php 
        $options = array();
        ?>
                        <?php 
        foreach ($playlist_categories as $playlist_category) {
            ?>
                        	<?php 
            $options[$playlist_category->term_id] = $playlist_category->name;
            ?>
                        <?php 
        }
        ?>
                        <?php 
        echo MDJM()->html->select(array('options' => $options, 'name' => 'entry_category', 'selected' => mdjm_get_option('playlist_default_cat', 0)));
        ?>
                    </td>

				</tr>
                <tr>

                    <td class="mdjm-playlist-djnotes-cell" colspan="3">
                        <label for="mdjm_playlist_djnotes"><?php 
        printf(__('Notes', 'mobile-dj-manager'), '{artist_label}');
        ?>
</label><br />
                        <?php 
        echo MDJM()->html->textarea(array('name' => 'entry_djnotes'));
        ?>
                    </td>
                </tr>
            </table>
            <?php 
        submit_button(__('Add to Playlist', 'mobile-dj-manager'), 'primary');
        ?>
        </form>
        <?php 
    }