Ejemplo n.º 1
0
/**
 * Output the event price row
 *
 * @since	1.3.7
 * @global	obj		$mdjm_event			MDJM_Event class object
 * @global	bool	$mdjm_event_update	True if this event is being updated, false if new.
 * @param	int		$event_id			The event ID.
 * @return	str
 */
function mdjm_event_metabox_details_price_row($event_id)
{
    global $mdjm_event, $mdjm_event_update;
    if (mdjm_employee_can('edit_txns')) {
        ?>
		<span id="mdjm-price-loader" class="mdjm-loader mdjm-hidden"><img src="<?php 
        echo MDJM_PLUGIN_URL . '/assets/images/loading.gif';
        ?>
" /></span>
        <div  id="mdjm-event-price-row" class="mdjm_field_wrap mdjm_form_fields">
            <div class="mdjm_col col2">
                <label for="_mdjm_event_deposit"><?php 
        _e('Total Cost:', 'mobile-dj-manager');
        ?>
</label><br />
				<?php 
        echo mdjm_currency_symbol() . MDJM()->html->text(array('name' => '_mdjm_event_cost', 'class' => 'mdjm-currency', 'placeholder' => mdjm_sanitize_amount('0.00'), 'value' => !empty($mdjm_event->price) ? mdjm_sanitize_amount($mdjm_event->price) : ''));
        ?>
            </div>

			<div class="mdjm_col col2">
                <label for="_mdjm_event_deposit"><?php 
        _e('Deposit:', 'mobile-dj-manager');
        ?>
</label><br />
				<?php 
        echo mdjm_currency_symbol() . MDJM()->html->text(array('name' => '_mdjm_event_deposit', 'class' => 'mdjm-currency', 'placeholder' => mdjm_sanitize_amount('0.00'), 'value' => $mdjm_event_update ? mdjm_sanitize_amount($mdjm_event->deposit) : mdjm_calculate_deposit($mdjm_event->price)));
        ?>
            </div>
        </div>
    
	<?php 
    } else {
        ?>

        <?php 
        echo MDJM()->html->hidden(array('name' => '_mdjm_event_cost', 'value' => !empty($mdjm_event->price) ? mdjm_sanitize_amount($mdjm_event->price) : ''));
        ?>

        <?php 
        echo MDJM()->html->hidden(array('name' => '_mdjm_event_deposit', 'value' => $mdjm_event_update ? mdjm_sanitize_amount($mdjm_event->deposit) : ''));
        ?>

    <?php 
    }
}
Ejemplo n.º 2
0
/**
 * Update the event deposit amount based upon the event cost
 * and the payment settings.
 *
 * @since	1.0
 * @return	void
 */
function mdjm_update_event_deposit_ajax()
{
    $event_cost = $_POST['current_cost'];
    $deposit = mdjm_calculate_deposit($event_cost);
    if (!empty($deposit)) {
        $result['type'] = 'success';
        $result['deposit'] = mdjm_sanitize_amount($deposit);
    } else {
        $result['type'] = 'error';
        $result['msg'] = 'Unable to calculate deposit';
    }
    $result = json_encode($result);
    echo $result;
    die;
}
Ejemplo n.º 3
0
 /**
  * Creates an event
  *
  * @since 	1.3
  * @param 	arr		$data Array of attributes for an event. See $defaults.
  * @return	mixed	false if data isn't passed and class not instantiated for creation, or New Event ID
  */
 public function create($data = array(), $meta = array())
 {
     if ($this->id != 0) {
         return false;
     }
     remove_action('save_post_mdjm-event', 'mdjm_save_event_post', 10, 3);
     $defaults = array('post_type' => 'mdjm-event', 'post_author' => 1, 'post_content' => '', 'post_status' => 'mdjm-enquiry', 'post_title' => __('New Event', 'mobile-dj-manager'));
     $default_meta = array('_mdjm_event_date' => date('Y-m-d'), '_mdjm_event_dj' => !mdjm_get_option('employer') ? 1 : 0, '_mdjm_event_playlist_access' => mdjm_generate_playlist_guest_code(), '_mdjm_event_playlist' => mdjm_get_option('enable_playlists') ? 'Y' : 'N', '_mdjm_event_contract' => mdjm_get_default_event_contract(), '_mdjm_event_cost' => 0, '_mdjm_event_deposit' => 0, '_mdjm_event_deposit_status' => __('Due', 'mobile-dj-manager'), '_mdjm_event_balance_status' => __('Due', 'mobile-dj-manager'), 'mdjm_event_type' => mdjm_get_option('event_type_default'), 'mdjm_enquiry_source' => mdjm_get_option('enquiry_source_default'), '_mdjm_event_venue_id' => 'Manual');
     $data = wp_parse_args($data, $defaults);
     $meta = wp_parse_args($meta, $default_meta);
     do_action('mdjm_event_pre_create', $data, $meta);
     $id = wp_insert_post($data, true);
     $event = WP_Post::get_instance($id);
     if ($event) {
         if (!empty($meta['mdjm_event_type'])) {
             mdjm_set_event_type($event->ID, $meta['mdjm_event_type']);
             $meta['_mdjm_event_name'] = get_term($meta['mdjm_event_type'], 'event-types')->name;
             $meta['_mdjm_event_name'] = apply_filters('mdjm_event_name', $meta['_mdjm_event_name'], $id);
         }
         if (!empty($meta['mdjm_enquiry_source'])) {
             mdjm_set_enquiry_source($event->ID, $meta['mdjm_enquiry_source']);
         }
         if (!empty($meta['_mdjm_event_start']) && !empty($meta['_mdjm_event_finish'])) {
             if (date('H', strtotime($meta['_mdjm_event_finish'])) > date('H', strtotime($meta['_mdjm_event_start']))) {
                 $meta['_mdjm_event_end_date'] = $meta['_mdjm_event_date'];
             } else {
                 $meta['_mdjm_event_end_date'] = date('Y-m-d', strtotime('+1 day', strtotime($meta['_mdjm_event_date'])));
             }
         }
         if (!empty($meta['_mdjm_event_package'])) {
             $meta['_mdjm_event_cost'] += mdjm_get_package_price($meta['_mdjm_event_package'], $meta['_mdjm_event_date']);
         }
         if (!empty($meta['_mdjm_event_addons'])) {
             foreach ($meta['_mdjm_event_addons'] as $addon) {
                 $meta['_mdjm_event_cost'] += mdjm_get_addon_price($addon);
             }
         }
         if (empty($meta['_mdjm_event_deposit'])) {
             $meta['_mdjm_event_deposit'] = mdjm_calculate_deposit($meta['_mdjm_event_cost']);
         }
         mdjm_update_event_meta($event->ID, $meta);
         wp_update_post(array('ID' => $id, 'post_title' => mdjm_get_event_contract_id($id), 'post_name' => mdjm_get_event_contract_id($id)));
     }
     do_action('mdjm_event_post_create', $id, $data);
     add_action('save_post_mdjm-event', 'mdjm_save_event_post', 10, 3);
     return $this->setup_event($event);
 }