function f_mdjm_edit_task($task)
{
    global $mdjm_settings;
    $mdjm_schedules = get_option('mdjm_schedules');
    if (isset($mdjm_schedules[$task]['default']) && $mdjm_schedules[$task]['default'] == 'Y') {
        $ro = ' readonly';
    } else {
        $ro = '';
    }
    ?>
        <h2>Edit Task</h2>
        <form name="form_task_edit" method="post" action="<?php 
    echo mdjm_get_admin_page('tasks') . '&task_updated=1';
    ?>
">
        <input type="hidden" name="slug" value="<?php 
    echo $mdjm_schedules[$task]['slug'];
    ?>
" />
        <table class="widefat">
        <tr>
        <td width="75%">
        <table class="widefat">
        <tr>
        <th colspan="4" class="alternate"><strong><?php 
    echo $mdjm_schedules[$task]['name'];
    ?>
</strong></th>
        </tr>
        <tr>
        <th class="row-title" width="15%"><label for="name">Task Name:</label></th>
        <td width="35%"><input type="text" name="name" id="name" value="<?php 
    echo $mdjm_schedules[$task]['name'];
    ?>
"<?php 
    echo $ro;
    ?>
 /></td>
        <th scope="row-title" width="15%"><label for="frequency">Frequency:</label></th>
        <td width="35%"><select name="frequency" id="frequency">
        <option value="Hourly" <?php 
    selected($mdjm_schedules[$task]['frequency'], 'Hourly');
    ?>
>Hourly</option>
        <option value="Daily" <?php 
    selected($mdjm_schedules[$task]['frequency'], 'Daily');
    ?>
>Daily</option>
        <option value="Twice Daily" <?php 
    selected($mdjm_schedules[$task]['frequency'], 'Twice Daily');
    ?>
>Twice Daily</option>
        <option value="Weekly" <?php 
    selected($mdjm_schedules[$task]['frequency'], 'Weekly');
    ?>
>Weekly</option>
        <option value="Monthly" <?php 
    selected($mdjm_schedules[$task]['frequency'], 'Monthly');
    ?>
>Monthly</option>
        <option value="Yearly" <?php 
    selected($mdjm_schedules[$task]['frequency'], 'Yearly');
    ?>
>Yearly</option>
        </select>
        </td>
        </tr>
        <tr>
        <th class="row-title"><label for="desc">Description:</label></th>
        <td colspan="3"><textarea name="desc" id="desc" cols="60" rows="2"><?php 
    echo esc_attr(stripslashes($mdjm_schedules[$task]['desc']));
    ?>
</textarea></td>
        </tr>
        <?php 
    if ($mdjm_schedules[$task]['slug'] != 'upload-playlists') {
        ?>
            <tr>
            <th scope="row-title">Notifications:</th>
            <td colspan="3"><label for="notify_admin">Admin</label> <input type="checkbox" name="notify_admin" id="notify_admin" value="Y"
				<?php 
        checked($mdjm_schedules[$task]['options']['notify_admin'], 'Y');
        ?>
 />&nbsp;&nbsp;&nbsp;
                <?php 
        if (mdjm_employee_can('edit_txns')) {
            ?>
                    <label for="notify_dj">DJ</label> <input type="checkbox" name="notify_dj" id="notify_dj" value="Y"
                    <?php 
            checked($mdjm_schedules[$task]['options']['notify_dj'], 'Y');
            ?>
 />&nbsp;
                    <?php 
        } else {
            echo '<input type="hidden" name="notify_dj" id="notify_dj" value="N"	/>' . "\r\n";
        }
        ?>
                <span class="description">Who to notify when the task completes</span>
            </td>
            </tr>
			<?php 
    }
    if ($mdjm_schedules[$task]['slug'] != 'upload-playlists' && $mdjm_schedules[$task]['slug'] != 'purge-clients') {
        ?>
			<th scope="row-title"><label for="event_execute_time">Run:</label></th>
            <td colspan="3"><select name="event_execute_time" id="event_execute_time">
            <?php 
        if ($mdjm_schedules[$task]['options']['run_when'] != '0') {
            $when = explode(' ', $mdjm_schedules[$task]['options']['age']);
        }
        if ($mdjm_schedules[$task]['slug'] != 'fail-enquiry') {
            ?>
				<option value="N/A">N/A</option>
                <?php 
        }
        ?>
            <option value="1"<?php 
        selected($when[0], '1');
        ?>
>1</option>
            <option value="2"<?php 
        selected($when[0], '2');
        ?>
>2</option>
            <option value="3"<?php 
        selected($when[0], '3');
        ?>
>3</option>
            <option value="4"<?php 
        selected($when[0], '4');
        ?>
>4</option>
            <option value="5"<?php 
        selected($when[0], '5');
        ?>
>5</option>
            <option value="6"<?php 
        selected($when[0], '6');
        ?>
>6</option>
            <option value="7"<?php 
        selected($when[0], '7');
        ?>
>7</option>
            <option value="8"<?php 
        selected($when[0], '8');
        ?>
>8</option>
            <option value="9"<?php 
        selected($when[0], '9');
        ?>
>9</option>
            <option value="10"<?php 
        selected($when[0], '10');
        ?>
>10</option>
            <option value="11"<?php 
        selected($when[0], '11');
        ?>
>11</option>
            <option value="12"<?php 
        selected($when[0], '12');
        ?>
>12</option>
            </select>
            &nbsp;
            <select name="event_execute_period" id="event_execute_period">
            <?php 
        if ($mdjm_schedules[$task]['slug'] != 'fail-enquiry') {
            ?>
				<option value="N/A">N/A</option>
                <?php 
        }
        ?>
            <option value="HOUR"<?php 
        selected($when[1], 'HOUR');
        ?>
>Hour(s)</option>
            <option value="DAY"<?php 
        selected($when[1], 'DAY');
        ?>
>Day(s)</option>
            <option value="WEEK"<?php 
        selected($when[1], 'WEEK');
        ?>
>Week(s)</option>
            <option value="MONTH"<?php 
        selected($when[1], 'MONTH');
        ?>
>Month(s)</option>
            </select>
            &nbsp;
            <select name="execute_when" id="execute_when">
            <?php 
        if ($mdjm_schedules[$task]['slug'] != 'fail-enquiry' && $mdjm_schedules[$task]['slug'] != 'request-deposit') {
            ?>
				<option value="N/A">N/A</option>
                <?php 
        }
        ?>
            <option value="after_approval"<?php 
        selected($mdjm_schedules[$task]['options']['run_when'], 'after_approval');
        ?>
>After Contract Accepted</option>
            <?php 
        if ($mdjm_schedules[$task]['slug'] != 'request-deposit') {
            ?>
				<option value="event_created"<?php 
            selected($mdjm_schedules[$task]['options']['run_when'], 'event_created');
            ?>
>After Enquiry Created</option>
				 <?php 
        }
        if ($mdjm_schedules[$task]['slug'] != 'fail-enquiry' && $mdjm_schedules[$task]['slug'] != 'request-deposit') {
            ?>
					<option value="before_event"<?php 
            selected($mdjm_schedules[$task]['options']['run_when'], 'before_event');
            ?>
>Before Event Starts</option>
					<option value="after_event"<?php 
            selected($mdjm_schedules[$task]['options']['run_when'], 'after_event');
            ?>
>After Event Finishes</option>
					<?php 
        }
        ?>
            </select>
            </td>
            </tr>
        	<?php 
        if ($mdjm_schedules[$task]['slug'] == 'client-feedback') {
            echo '<tr>';
            echo '<td colspan="4">';
            echo '<span class="description">Note: This task will ignore all events completed over 1 month ago to avoid emailing clients whose events ended prior to that</span>';
            echo '</td>';
            echo '</tr>';
        }
    }
    if ($mdjm_schedules[$task]['slug'] != 'upload-playlists' && $mdjm_schedules[$task]['slug'] != 'complete-events' && $mdjm_schedules[$task]['slug'] != 'fail-enquiry' && $mdjm_schedules[$task]['slug'] != 'purge-clients') {
        ?>
			<tr>
			<th class="alternate" colspan="4"><strong>Email Options</strong></th>
			</tr>
			<tr>
            <th scope="row-title"><label for="email_client">Emails Client:</label></th>
            <td><input type="checkbox" name="email_client" id="email_client" value="Y"<?php 
        checked($mdjm_schedules[$task]['options']['email_client'], 'Y');
        ?>
 /></td>
			<th scope="row-title"><label for="email_template">Template:</label></th>
			<td>
			<select name="email_template" id="email_template">
			<option value="0"<?php 
        selected($mdjm_schedules[$task]['options']['email_template'], '0');
        ?>
>None</option>
			<?php 
        $email_template_args = array('post_type' => 'email_template', 'orderby' => 'name', 'order' => 'ASC', 'posts_per_page' => -1);
        $email_template_query = new WP_Query($email_template_args);
        if ($email_template_query->have_posts()) {
            while ($email_template_query->have_posts()) {
                $email_template_query->the_post();
                echo '<option value="' . get_the_id() . '"';
                if ($mdjm_schedules[$task]['options']['email_template'] == get_the_id()) {
                    echo ' selected="selected"';
                }
                echo '>' . get_the_title() . '</option>' . "\n";
            }
        }
        wp_reset_postdata();
        ?>
			</select>
			</td>
            </tr>
			<tr>
			<th scope="row-title"><label for="email_subject">Subject</label></th>
			<td><input type="text" name="email_subject" id="email_subject" class="regular-text" value="<?php 
        echo esc_attr(stripslashes($mdjm_schedules[$task]['options']['email_subject']));
        ?>
" /></td>
			<th scope="row-title"><label for="email_from">From:</label></th>
			<td>
			<select name="email_from" id="email_from">
			<option value="0" <?php 
        selected($mdjm_schedules[$task]['options']['email_from'], '0');
        ?>
>N/A</option>
			<option value="admin" <?php 
        selected($mdjm_schedules[$task]['options']['email_from'], 'admin');
        ?>
>Admin</option>
			<option value="dj" <?php 
        selected($mdjm_schedules[$task]['options']['email_from'], 'dj');
        ?>
>DJ</option>
			</select>
			</td>
			</tr>
		<?php 
    }
    ?>
        <tr>
        <td><?php 
    submit_button('Update Task', 'primary', 'submit', false);
    ?>
</td>
        <td colspan="3"><a class="button-secondary" href="<?php 
    echo $_SERVER['HTTP_REFERER'];
    ?>
" title="<?php 
    _e('Back');
    ?>
"><?php 
    _e('Back');
    ?>
</a></td>
        </tr>
        </table>
        </td>
        <td width="25%">
<?php 
    /***** This is where we display the task overview */
    ?>
        <table class="widefat">
        <tr>
        <th colspan="2" class="alternate"><strong>Task Overview</strong></th>
        </tr>
        <tr>
        <td width="40%">Status:</td>
        <td><?php 
    if ($mdjm_schedules[$task]['active'] == 'Y') {
        echo '<font style="color:#090">Active';
    } else {
        echo '<font style="color:#F00">Inactive';
    }
    ?>
</font></td>
        </tr>
        <tr>
        <td>Frequency:</td>
        <td><?php 
    echo $mdjm_schedules[$task]['frequency'];
    ?>
</td>
        </tr>
        <tr>
        <td>Last Run:</td>
        <td><?php 
    if ($mdjm_schedules[$task]['lastran'] != 'Never') {
        echo get_date_from_gmt(date('Y-m-d H:i:s', $mdjm_schedules[$task]['lastran']), MDJM_TIME_FORMAT . ' d M Y');
    } else {
        echo $mdjm_schedules[$task]['lastran'];
    }
    ?>
        </td>
        </tr>
        <tr>
        <td>Next Run:</td>
        <td><?php 
    if ($mdjm_schedules[$task]['nextrun'] != 'N/A') {
        echo get_date_from_gmt(date('Y-m-d H:i:s', $mdjm_schedules[$task]['nextrun']), MDJM_TIME_FORMAT . ' d M Y');
    } else {
        echo $mdjm_schedules[$task]['nextrun'];
    }
    ?>
        </td>
        </tr>
        <tr>
        <td>Total Runs:</td>
        <td><?php 
    echo $mdjm_schedules[$task]['totalruns'];
    ?>
</td>
        </tr>
        <?php 
    if ($mdjm_schedules[$task]['slug'] == 'upload-playlists' && $mdjm_schedules[$task]['active'] == 'Y') {
        ?>
            <tr>
            <td><?php 
        _e('Pending Upload:', 'mobile-dj-manager');
        ?>
</td>
            <td><?php 
        echo mdjm_get_pending_upload_playlist_entry_count();
        ?>
</td>
            </tr>
            <tr>
            <td><?php 
        _e('Total Uploaded:', 'mobile-dj-manager');
        ?>
</td>
            <td><?php 
        echo mdjm_get_uploaded_playlist_entry_count();
        ?>
</td>
            </tr>
            <?php 
    }
    ?>
        </table>
     	</td>
        </tr>
        </table>
        <?php 
}
function f_mdjm_dash_availability()
{
    global $mdjm_settings;
    /* Enqueue the jQuery Datepicker Scripts */
    wp_enqueue_script('jquery-ui-datepicker');
    wp_enqueue_style('jquery-ui-css', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
    mdjm_insert_datepicker(array('class' => 'check_custom_date', 'altfield' => 'check_date'));
    ?>
	
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<?php 
    /* Display Availability Overview */
    ?>
	<?php 
    get_availability_activity(0, 0);
    ?>
	
	<?php 
    /* Availability Check */
    ?>
	<form name="availability-check" id="availability-check" method="post" action="<?php 
    mdjm_get_admin_page('availability', 'echo');
    ?>
">
	<?php 
    if (!current_user_can('administrator')) {
        ?>
<input type="hidden" name="check_employee" id="check_employee" value="<?php 
        echo get_current_user_id();
        ?>
" /><?php 
    } else {
        ?>
<input type="hidden" name="check_employee" id="check_employee" value="all" /><?php 
    }
    ?>
	<tr>
	<td colspan="2">&nbsp;</td>
	</tr>
	<tr>
	<td colspan="2"><input type="text" name="show_check_date" id="show_check_date" class="check_custom_date" required="required" style="font-size:12px" />&nbsp;&nbsp;&nbsp;
	<input type="hidden" name="check_date" id="check_date" />
	<?php 
    submit_button('Check Date', 'primary small', 'submit', false, '');
    ?>
</td>
	</tr>
	</form>
	</table>
	<?php 
}
        function manage_field_form()
        {
            $must = array('first_name', 'last_name', 'user_email');
            $total = count($this->fields);
            // Right Column
            echo '<div class="mdjm-client-field-column-right">' . "\r\n";
            echo '<form name="mdjm-client-fields" id="mdjm-client-fields" method="post" action="' . mdjm_get_admin_page('client_fields') . '">' . "\r\n";
            if (isset($_GET['action']) && $_GET['action'] == 'edit_field') {
                $editing = true;
            }
            // If editing a field we need this hidden field to identify it
            if (!empty($editing)) {
                echo '<input type="hidden" name="field_id" id="field_id" value="' . $this->fields[$_GET['id']]['id'] . '" />' . "\r\n";
            } else {
                echo '<input type="hidden" name="field_position" id="field_position" value="' . $total . '" />' . "\r\n";
            }
            echo '<h3>' . (empty($editing) ? __('Add New Client Field') : __('Edit the ') . '<span class="mdjm-color">' . stripslashes($this->fields[$_GET['id']]['label']) . '</span>' . __(' Field')) . '</h3>' . "\r\n";
            // Field Label
            echo '<p>';
            echo '<label class="mdjm-label" for="field_label">' . __('Field Label', 'mobile-dj-manager') . ':</label><br />' . "\r\n";
            echo '<input type="text" name="field_label" id="field_label" class="regular-text" value="' . (!empty($editing) ? stripslashes($this->fields[$_GET['id']]['label']) : '') . '" class="regular-text" />';
            echo '</p>' . "\r\n";
            // Field Type
            $types = array('text', 'checkbox', 'dropdown');
            echo '<p>' . "\r\n";
            echo '<label class="mdjm-label" for="field_type">' . __('Field Type', 'mobile-dj-manager') . ':</label><br />' . "\r\n";
            echo '<select name="field_type" id="field_type"' . (!empty($editing) && $this->fields[$_GET['id']]['default'] == true ? ' disabled="disabled"' : '') . ' onChange="whichField(); showRequired();">' . "\r\n";
            foreach ($types as $type) {
                echo '<option value="' . $type . '"';
                if (!empty($editing)) {
                    selected($type, $this->fields[$_GET['id']]['type']);
                }
                echo '>' . __(ucfirst(str_replace('dropdown', 'select', $type)) . ' Field') . '</option>' . "\r\n";
            }
            echo '</select>' . "\r\n";
            echo '</p>' . "\r\n";
            if (!empty($editing)) {
                // If the select field is disabled we need to set the value
                echo '<input type="hidden" name="field_type" id="field_type" value="' . $this->fields[$_GET['id']]['type'] . '" />' . "\r\n";
            }
            // Value
            ?>
			<style>
			#value_field_dropdown	{
				display: <?php 
            echo !empty($editing) && $this->fields[$_GET['id']]['type'] == 'dropdown' ? 'block;' : 'none;';
            ?>
			}
			#value_field_checkbox	{
				display: <?php 
            echo !empty($editing) && $this->fields[$_GET['id']]['type'] == 'checkbox' ? 'block;' : 'none;';
            ?>
			}
			#required_checkbox	{
				display: <?php 
            echo empty($editing) || $this->fields[$_GET['id']]['type'] != 'checkbox' ? 'block;' : 'none;';
            ?>
	
			}
			</style>
			
			<div id="value_field_dropdown">
			<?php 
            echo '<p>' . "\r\n";
            echo '<label class="mdjm-label" for="field_options">' . __('Selectable Options', 'mobile-dj-manager') . ':</label> <br />' . "\r\n";
            echo '<textarea name="field_options" id="field_options" class="all-options" rows="5">' . (!empty($editing) ? $this->fields[$_GET['id']]['value'] : '') . '</textarea><br /><span class="description">One entry per line</span>';
            echo '</p>' . "\r\n";
            ?>
			</div>
			<div id="value_field_checkbox">
			<?php 
            echo '<p>' . "\r\n";
            echo '<label class="mdjm-label" for="field_value">' . __('Checked Value', 'mobile-dj-manager') . ':</label><br />' . "\r\n";
            echo '<input type="text" name="field_value" id="field_value" value="' . (!empty($editing) ? $this->fields[$_GET['id']]['value'] : '') . '" class="small-text" />';
            echo '</p>' . "\r\n";
            echo '<p>' . "\r\n";
            echo '<label class="mdjm-label" for="field_checked">' . __('Checked by Default', 'mobile-dj-manager') . '?</label><br />' . "\r\n";
            echo '<input type="checkbox" name="field_checked" id="field_checked" value="1"' . (!empty($editing) && $this->fields[$_GET['id']]['checked'] ? ' checked="checked"' : '') . '" />';
            echo '</p>' . "\r\n";
            ?>
			</div>
			
			<script type="text/javascript">
			function whichField() {
				var type = field_type.options[field_type.selectedIndex].value;
				var dropdown_div =  document.getElementById("value_field_dropdown");
				var checkbox_div =  document.getElementById("value_field_checkbox");
				
				if (type == 'text') {
					dropdown_div.style.display = "none";
					checkbox_div.style.display = "none";
				}
				if (type == 'dropdown')	{
					dropdown_div.style.display = "block";
					checkbox_div.style.display = "none";
				}
				if (type == 'checkbox')	{
					dropdown_div.style.display = "none";
					checkbox_div.style.display = "block";
				}
			}
			</script>
			
			<?php 
            // Description
            echo '<p>' . "\r\n";
            echo '<label class="mdjm-label" for="field_desc">' . __('Description', 'mobile-dj-manager') . ':</label><br />' . "\r\n";
            echo '<input type="text" name="field_desc" id="field_desc" value="' . (!empty($editing) ? $this->fields[$_GET['id']]['desc'] : '') . '" class="regular-text" />';
            echo '</p>' . "\r\n";
            // Options
            echo '<p>' . "\r\n";
            echo '<input type="checkbox" name="field_enabled" id="field_enabled" value="1"' . (!empty($editing) && !empty($this->fields[$_GET['id']]['display']) ? ' checked="checked"' : '') . (!empty($editing) && in_array($this->fields[$_GET['id']]['id'], $must) ? ' disabled="disabled"' : '') . ' />' . '<label class="mdjm-label" for="field_enabled">' . __(' Field Enabled?', 'mobile-dj-manager') . '</label>';
            if (!empty($editing) && in_array($this->fields[$_GET['id']]['id'], $must)) {
                echo '<input type="hidden" name="field_enabled" id="field_enabled" value="1" />' . "\r\n";
            }
            echo '</p>' . "\r\n";
            echo '<div id="required_checkbox">' . "\r\n";
            echo '<p>' . "\r\n";
            echo '<input type="checkbox" name="field_required" id="field_required" value="1"' . (!empty($editing) && !empty($this->fields[$_GET['id']]['required']) ? ' checked="checked"' : '') . (!empty($editing) && in_array($this->fields[$_GET['id']]['id'], $must) ? ' disabled="disabled"' : '') . ' />' . '<label class="mdjm-label" for="field_required">' . __(' Required Field?', 'mobile-dj-manager') . '</label>';
            if (!empty($editing) && in_array($this->fields[$_GET['id']]['id'], $must)) {
                echo '<input type="hidden" name="field_required" id="field_required" value="1" />' . "\r\n";
            }
            echo '</p>' . "\r\n";
            echo '</div>' . "\r\n";
            ?>
			<script type="text/javascript">
			function showRequired() {					
				var type = field_type.options[field_type.selectedIndex].value;
				var required_div = document.getElementById("required_checkbox");
				
				if (type == 'checkbox')	{
					required_div.style.display = "none";
				}
				else	{
					required_div.style.display = "block";	
				}
			}
			</script>
			<?php 
            echo '<p>';
            submit_button(empty($editing) ? __('Add Field', 'mobile-dj-manager') : __('Save Changes', 'mobile-dj-manager'), 'primary', 'submit', false);
            if (!empty($editing)) {
                echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                echo '<a href="' . mdjm_get_admin_page('client_fields') . '" class="button-secondary">' . __('Cancel Changes', 'mobile-dj-manager') . '</a>';
            }
            echo '</p>' . "\r\n";
            // End form
            echo '</form>' . "\r\n";
            // End Right Column
            echo '</div>' . "\r\n";
        }
Exemple #4
0
function f_mdjm_render_comms()
{
    global $mdjm, $mdjm_settings;
    if (isset($_GET['template']) && !empty($_GET['template'])) {
        $template_query = get_post($_GET['template']);
        if ($template_query) {
            $content = $template_query->post_content;
            $content = apply_filters('the_content', $content);
            $content = str_replace(']]>', ']]&gt;', $content);
            $subject = get_the_title($_GET['template']);
        }
    } elseif (isset($_POST['email_content'])) {
        $content = stripslashes($_POST['email_content']);
    } else {
        $content = '';
    }
    if (!isset($subject) || empty($subject)) {
        if (isset($_POST['subject'])) {
            $subject = stripslashes($_POST['subject']);
        } else {
            $subject = '';
        }
    }
    ?>
		<div class="wrap">
		<h1>Client Communications</h1>
		<?php 
    $settings = array('media_buttons' => true, 'textarea_rows' => '10');
    $clientinfo = $mdjm->mdjm_events->get_clients();
    $djinfo = mdjm_get_djs();
    ?>
		<script type="text/javascript">
			function MM_jumpMenu(targ,selObj,restore){ //v3.0
			  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
			  if (restore) selObj.selectedIndex=0;
			}
		</script>
		<form name="form-email-template" id="form-email-template" method="post" enctype="multipart/form-data">
        <?php 
    if (isset($_GET['action']) && $_GET['action'] == 'respond_unavailable') {
        ?>
<input type="hidden" name="respond_unavailable" id="respond_unavailable" value="<?php 
        echo $_GET['event_id'];
        ?>
" /><?php 
    }
    ?>
		<table class="form-table">
		<tr>
		<td width="20%"><label for="email_template">Select a template for content, or write your own:</label></td>
		<td><select name="email_template" id="email_template" onChange="MM_jumpMenu('parent',this,0)">
		<option value="<?php 
    echo add_query_arg('template', 0);
    ?>
" <?php 
    if (!isset($_GET['template']) || $_GET['template'] == '0') {
        echo ' selected';
    }
    ?>
>Do not use Template</option>
        <?php 
    $email_args = array('posts_per_page' => -1, 'post_type' => 'email_template', 'orderby' => 'name', 'order' => 'ASC');
    $contract_args = array('post_type' => 'contract', 'posts_per_page' => -1, 'orderby' => 'name', 'order' => 'ASC');
    if (is_dj()) {
        // Check templates that DJ's cannot use
        if (!isset($mdjm_settings['permissions'])) {
            $mdjm_settings['permissions'] = get_option('mdjm_plugin_permissions');
        }
        if (isset($mdjm_settings['permissions']['dj_disable_template']) && !empty($mdjm_settings['permissions']['dj_disable_template'])) {
            if (!is_array($mdjm_settings['permissions']['dj_disable_template'])) {
                $mdjm_settings['permissions']['dj_disable_template'] = array($mdjm_settings['permissions']['dj_disable_template']);
            }
            $email_args['post__not_in'] = $mdjm_settings['permissions']['dj_disable_template'];
            $contract_args['post__not_in'] = $mdjm_settings['permissions']['dj_disable_template'];
        }
    }
    $email_query = get_posts($email_args);
    if ($email_query) {
        ?>
<optgroup label="EMAIL TEMPLATES"><?php 
        foreach ($email_query as $email_template) {
            ?>
				<option value="<?php 
            echo add_query_arg('template', $email_template->ID);
            ?>
"<?php 
            if (isset($_GET['template'])) {
                selected($email_template->ID, $_GET['template']);
            }
            ?>
><?php 
            echo get_the_title($email_template->ID);
            ?>
</option>
				<?php 
        }
        ?>
			</optgroup>
			<?php 
    }
    $contract_query = get_posts($contract_args);
    if ($contract_query) {
        ?>
<optgroup label="CONTRACTS"><?php 
        foreach ($contract_query as $contract_template) {
            ?>
				<option value="<?php 
            echo add_query_arg('template', $contract_template->ID);
            ?>
"<?php 
            if (isset($_GET['template'])) {
                selected($contract_template->ID, $_GET['template']);
            }
            ?>
><?php 
            echo get_the_title($contract_template->ID);
            ?>
</option>
				<?php 
        }
        ?>
			</optgroup>
			<?php 
    }
    ?>
		</select></td>
		</tr>
		</table>
		<hr />
		<?php 
    wp_nonce_field('send-email', '__mdjm_send_email');
    ?>
		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="widefat">
		<tr>
		<td width="60%"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="widefat">
		<tr class="alternate">
		<th class="row-title" align="left"><label for="to">Send email to:</label></th>
		<td><select name="to" id="to" onChange="MM_jumpMenu('parent',this,0)">
			<option value="">Select a Recipient</option>
            <optgroup label="CLIENTS">
		<?php 
    foreach ($clientinfo as $client) {
        if (current_user_can('administrator') || $mdjm->mdjm_events->is_my_client($client->ID)) {
            // Non-Admins only see their own clients
            ?>
				<option value="<?php 
            echo add_query_arg(array('to_user' => $client->ID));
            ?>
"<?php 
            if (isset($_GET['to_user'])) {
                selected($client->ID, $_GET['to_user']);
            }
            ?>
><?php 
            echo $client->display_name;
            ?>
</option>
                <?php 
        }
    }
    ?>
        </optgroup>
        <?php 
    if (current_user_can('administrator')) {
        // Admins see DJ's too
        ?>
<optgroup label="<?php 
        echo MDJM_DJ;
        ?>
's"><?php 
        foreach ($djinfo as $dj) {
            ?>
                <option value="<?php 
            echo add_query_arg(array('to_user' => $dj->ID));
            ?>
"<?php 
            if (isset($_GET['to_user'])) {
                selected($dj->ID, $_GET['to_user']);
            }
            ?>
><?php 
            echo $dj->display_name;
            ?>
</option>
                <?php 
        }
    }
    ?>
        </optgroup>
		</select>
        </td>
        </tr>
        <?php 
    if (isset($_GET['to_user']) && $_GET['to_user'] != '') {
        echo '<input type="hidden" name="email_to" value="' . $_GET['to_user'] . '" />';
    }
    ?>
        <tr class="alternate">
        <th class="row-title">&nbsp;</th>
        <td>
        <?php 
    /* Get this users info */
    if (isset($_GET['to_user']) && $_GET['to_user'] != '') {
        $userinfo = get_user_by('id', $_GET['to_user']);
    }
    ?>
		<input type="email" name="user_addr" id="user_addr" value="<?php 
    if (isset($userinfo) && $userinfo != '') {
        echo $userinfo->user_email;
    }
    ?>
" class="regular-text" readonly="readonly" /> </td>
        </tr>
        <tr class="alternate">
        <th class="row-title"><label for="copy_sender">Copy yourself?</label></th>
        <td><input type="checkbox" name="copy_sender" id="copy_sender" value="Y" checked="checked" /> <span class="description">Depending on your <a href="<?php 
    echo mdjm_get_admin_page('settings');
    ?>
">settings</a>, the DJ and Admin may also receive a copy</span></td>
        </tr>
        <?php 
    if (isset($_GET['to_user'])) {
        if (user_can($_GET['to_user'], 'dj')) {
            // Selected user is a DJ
            $events = $mdjm->mdjm_events->dj_events($_GET['to_user'], '', $order = 'DESC');
        } else {
            $events = $mdjm->mdjm_events->client_events($_GET['to_user'], '', $order = 'DESC');
        }
    }
    ?>
        <tr class="alternate">
		<th class="row-title" align="left"><label for="event">Regarding Event:</label></th>
		<td>
        <?php 
    if (empty($events)) {
        ?>
            <input type="text" name="event" class="regular-text" value="No Event (General Message)" disabled="disabled" />
            <?php 
    } else {
        $event_stati = mdjm_all_event_status();
        ?>
			<select name="event" id="event">
			<option value="">No Event (General Message)</option>
            <?php 
        foreach ($events as $event) {
            ?>
				<option value="<?php 
            echo $event->ID;
            ?>
"<?php 
            if (isset($_POST['event'])) {
                selected($_POST['event'], $event->ID);
            } elseif (isset($_GET['event_id'])) {
                selected($_GET['event_id'], $event->ID);
            }
            ?>
><?php 
            echo date(MDJM_SHORTDATE_FORMAT, strtotime(get_post_meta($event->ID, '_mdjm_event_date', true))) . ' from ' . date(MDJM_TIME_FORMAT, strtotime(get_post_meta($event->ID, '_mdjm_event_start', true))) . ' (' . $event_stati[$event->post_status] . ')';
            ?>
</option>
				<?php 
        }
        echo '</select>';
    }
    ?>
        <br />
        <span class="description">Note: If no event is selected you cannot use MDJM Shortcodes in your email</span>
        </td>
		</tr>
        <?php 
    ?>
		<tr class="alternate">
		<th class="row-title" align="left"><label for="subject">Subject:</label></th>
		<td><input type="text" name="subject" id="subject" class="regular-text" value="<?php 
    echo $subject;
    ?>
" /></td>
		</tr>
        <tr class="alternate">
		<th class="row-title" align="left"><label for="upload_file">Attach File from Computer:</label></th>
		<td><input type="file" name="upload_file" id="upload_file" class="regular-text" value="" /><p class="description"><?php 
    echo __('Max file size', 'mobile-dj-manager') . ': ' . ini_get('post_max_size') . '. ' . sprintf(__('Change php.ini %spost_max_size%s to increase', 'mobile-dj-manager'), '<strong>', '</strong>');
    ?>
</p></td>
		</tr>
        <?php 
    do_action('mdjm_comms_fields_last', $email_query, $contract_query);
    ?>
		<tr>
		<td colspan="2"><?php 
    wp_editor(html_entity_decode(stripcslashes($content)), 'email_content', $settings);
    ?>
</td>
		</tr>
		<tr>
		<td colspan="2">
		<?php 
    submit_button('Send Email', 'primary', 'submit', true);
    ?>
        </td>
		</tr>
		</table></td>
		<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="widefat">
		<tr>
		<td align="center" class="alternate"><strong>To do List</strong></td>
		</tr>
		<tr>
		<td>Coming soon...!</td>
		</tr>
		</table></td>
		</tr>
		</table>
		 </form>
		</div>
	<?php 
}
        /**
         * Add the table allowing addition of new custom fields
         *
         * @params	arr		$field_types	Required: The types of custom fields that can be created
         *
         *
         */
        public static function add_new_custom_field_table($field_types)
        {
            wp_enqueue_script('jquery');
            wp_register_script('jquery-validation-plugin', 'https://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js', false);
            wp_enqueue_script('jquery-validation-plugin');
            ?>
			<script type="text/javascript">
			jQuery().ready(function()	{
				jQuery("#mdjm-custom-event-fields").validate(	{
					
					/* -- Classes -- */
					errorClass: "mdjm-form-error",
					validClass: "mdjm-form-valid",
					focusInvalid: false,
									
					messages:	{
						field_label: " <?php 
            _e('Enter a label!', 'mobile-dj-manager');
            ?>
",
					}
					
				} ); // Validate
			} ); // function
			</script>
			<div class="mdjm-event-field-column-right">
			<form name="mdjm-custom-event-fields" id="mdjm-custom-event-fields" method="post" action="<?php 
            echo mdjm_get_admin_page('custom_event_fields');
            ?>
">
			
			<?php 
            if (isset($_GET['edit_custom_field'], $_GET['id'])) {
                $editing = true;
            }
            // If editing a field we need this hidden field to identify it
            if (!empty($editing)) {
                $field = get_post($_GET['id']);
                echo '<input type="hidden" name="custom_field_id" id="custom_field_id" value="' . $_GET['id'] . '" />' . "\r\n";
            }
            echo '<h3>';
            echo empty($editing) ? __('Add New Custom Field', 'mobile-dj-manager') : sprintf(__('Edit the %s%s%s %s', 'mobile-dj-manager'), '<span class="mdjm-color">', get_the_title($_GET['id']), '</span>', __('Field', 'mobile-dj-manager'));
            echo '</h3>' . "\r\n";
            // Types of input fields that can be selected
            $types = array('text', 'checkbox', 'select', 'multi select', 'textarea');
            ?>
			
            <p>
			<label for="_mdjm_field_section"><?php 
            _e('Section', 'mobile-dj-manager');
            ?>
:</label><br />
			<select name="_mdjm_field_section" id="_mdjm_field_section">
			<?php 
            foreach ($field_types as $type) {
                echo '<option value="' . $type . '"';
                if (!empty($editing)) {
                    selected($type, get_post_meta($_GET['id'], '_mdjm_field_section', true));
                }
                echo '>' . sprintf(__('%s Section', 'mobile-dj-manager'), ucfirst($type)) . '</option>' . "\r\n";
            }
            ?>
			</select>
			</p>
            
			<p>
			<label for="field_label"><?php 
            _e('Label', 'mobile-dj-manager');
            ?>
:</label><br />
			<input type="text" name="field_label" id="field_label" class="regular-text" value="<?php 
            echo !empty($editing) ? get_the_title($_GET['id']) : '';
            ?>
" class="regular-text" required="required" />
			</p>
			
			<p>
			<label for="_mdjm_field_type"><?php 
            _e('Type', 'mobile-dj-manager');
            ?>
:</label><br />
			<select name="_mdjm_field_type" id="_mdjm_field_type" onChange="whichField();">
			<?php 
            foreach ($types as $type) {
                echo '<option value="' . $type . '"';
                if (!empty($editing)) {
                    selected($type, get_post_meta($_GET['id'], '_mdjm_field_type', true));
                }
                echo '>' . sprintf(__('%s Field', 'mobile-dj-manager'), ucwords($type)) . '</option>' . "\r\n";
            }
            ?>
			</select>
			</p>
			
            <style type="text/css">
				#value_field_select	{
					display: <?php 
            echo !empty($editing) && get_post_meta($_GET['id'], '_mdjm_field_type', true) == 'select' ? 'block;' : 'none;';
            ?>
				}
				#value_field_checkbox	{
					display: <?php 
            echo !empty($editing) && get_post_meta($_GET['id'], '_mdjm_field_type', true) == 'checkbox' ? 'block;' : 'none;';
            ?>
				}
			</style>
            
            <div id="value_field_select">
				<p>
				<label for="_mdjm_field_options"><?php 
            _e('Selectable Options', 'mobile-dj-manager');
            ?>
:</label><br />
				<textarea name="_mdjm_field_options" id="_mdjm_field_options" class="all-options" rows="5"><?php 
            echo !empty($editing) ? get_post_meta($_GET['id'], '_mdjm_field_options', true) : '';
            ?>
</textarea><br />
                <span class="description"><?php 
            _e('One entry per line', 'mobile-dj-manager');
            ?>
</span>
				</p>
            </div>
            <div id="value_field_checkbox">
				<p>
				<label for="_mdjm_field_value"><?php 
            _e('Checked Value', 'mobile-dj-manager');
            ?>
:</label><br />
				<input type="text" name="_mdjm_field_value" id="_mdjm_field_value" value="<?php 
            echo !empty($editing) ? get_post_meta($_GET['id'], '_mdjm_field_value', true) : '1';
            ?>
" class="small-text" />
				</p>
				
				<p>
				<input type="checkbox" name="_mdjm_field_checked" id="_mdjm_field_checked" value="1" 
					<?php 
            if (!empty($editing)) {
                checked('1', get_post_meta($_GET['id'], '_mdjm_field_checked', true));
            }
            ?>
 
                    />&nbsp;<label for="_mdjm_field_checked"><?php 
            _e('Checked by Default', 'mobile-dj-manager');
            ?>
?</label>
				</p>
            </div>
            
            <script type="text/javascript">
				function whichField() {
					var type = _mdjm_field_type.options[_mdjm_field_type.selectedIndex].value;
					var select_div =  document.getElementById("value_field_select");
					var checkbox_div =  document.getElementById("value_field_checkbox");
					
					if (type == 'text' || type == 'textarea') {
						select_div.style.display = "none";
						checkbox_div.style.display = "none";
					}
					if (type == 'select' || type == 'multi select')	{
						select_div.style.display = "block";
						checkbox_div.style.display = "none";
					}
					if (type == 'checkbox')	{
						select_div.style.display = "none";
						checkbox_div.style.display = "block";
					}
				}
            </script>
            
			<p>
			<label for="field_desc"><?php 
            _e('Description', 'mobile-dj-manager');
            ?>
:</label><br />
			<input type="text" name="field_desc" id="field_desc" value="<?php 
            echo !empty($editing) ? $field->post_content : '';
            ?>
" class="regular-text" /><br />
			<span class="description"><?php 
            _e("Not visible to client's", 'mobile-dj-manager');
            ?>
</span>
			</p>
			
			<p>
			<?php 
            submit_button(empty($editing) ? __('Add Field', 'mobile-dj-manager') : __('Save Changes', 'mobile-dj-manager'), 'primary', 'submit_custom_field', false);
            if (!empty($editing)) {
                echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                echo '<a href="' . mdjm_get_admin_page('custom_event_fields') . '" class="button-secondary">' . __('Cancel Changes', 'mobile-dj-manager') . '</a>';
            }
            ?>
                
			</p>
			</form>
            <h4><?php 
            _e('Your Custom Shortcodes', 'mobile-dj-manager');
            ?>
</h4>
            <p><?php 
            self::list_custom_tags();
            ?>
</p>
			</div>
			<?php 
        }
Exemple #6
0
function mdjm_dashboard()
{
    global $mdjm, $my_mdjm, $current_user;
    if (!class_exists('MDJM_Dashboard')) {
        require_once MDJM_PLUGIN_DIR . '/includes/admin/mdjm-dashboard.php';
        $mdjm_dash = new MDJM_Dashboard();
    }
    wp_enqueue_script('youtube-subscribe');
    ?>
		<?php 
    mdjm_insert_datepicker(array('class' => 'check_custom_date', 'altfield' => 'check_date', 'mindate' => 'today'));
    ?>
        <div class="wrap">
        <h1>MDJM Event Management - <?php 
    echo $current_user->display_name;
    ?>
 (<?php 
    if (!current_user_can('manage_options')) {
        echo 'DJ';
    } else {
        echo 'Admin';
    }
    ?>
)</h1>
        <hr />
        <h2>
        <?php 
    //$dj_event_count = MDJM()->events->count_events_by_status( 'dj', get_current_user_id() );
    ?>
</h2>
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="widefat">
          <tr>
            <td width="60%"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="widefat">
          <tr>
            <td colspan="2" class="alternate"><strong><?php 
    printf(__('Monthly %s Overview for %s', 'mobile-dj-manager'), mdjm_get_option('artist'), date('F Y'));
    ?>
</strong></td>
            </tr>
          <tr>
            <td width="30%"><?php 
    _e('Active Bookings', 'mobile-dj-manager');
    ?>
:</td>
            <td width="70%"><?php 
    echo mdjm_count_employee_events('', array('post_status' => mdjm_active_event_statuses(), 'date' => array(date('Y-m-01'), date('Y-m-t')), 'date_compare' => 'BETWEEN'));
    ?>
</td>
          </tr>
          <?php 
    if (mdjm_employee_can('read_events')) {
        ?>
              <tr>
                <td><a href="<?php 
        echo mdjm_get_admin_page('enquiries') . '&mdjm_filter_type&mdjm_filter_date=' . date('Ym');
        ?>
">Outstanding Enquiries:</a></td>
                <td><?php 
        echo $dj_event_count['enquiry_month'] + $dj_event_count['unattended_month'] . (!empty($dj_event_count['unattended_month']) && $dj_event_count['unattended_month'] > 0 ? ' (<a href="' . mdjm_get_admin_page('unattended') . '&mdjm_filter_date=' . date('Ym') . '">' . $dj_event_count['unattended_month'] . ' Unattended)</a>' : '');
        ?>
</td>
              </tr>
              <tr>
                <td><a href="<?php 
        echo mdjm_get_admin_page('events') . '&post_status=mdjm-lost&mdjm_filter_date=' . date('Ym') . '&mdjm_filter_type';
        ?>
">Lost Enquiries:</a></td>
                <td><?php 
        echo $dj_event_count['lost_month'];
        ?>
</td>
              </tr>
				<?php 
    }
    ?>
          <tr>
            <td><a href="<?php 
    echo mdjm_get_admin_page('events') . '&post_status=mdjm-completed&mdjm_filter_date=' . date('Ym') . '&mdjm_filter_type';
    ?>
">Completed Bookings:</a></td>
            <td><?php 
    echo $dj_event_count['completed_month'];
    ?>
</td>
          </tr>
		<?php 
    if (mdjm_employee_can('manage_events')) {
        ?>
          <tr>
            <td>Potential Earnings: </td>
            <td><?php 
        echo $mdjm_dash->period_earnings('month', $current_user->ID, false);
        ?>
</td>
          </tr>
          <?php 
    }
    ?>
          <tr>
            <td>Earnings so Far:</td>
            <td><?php 
    echo $mdjm_dash->period_earnings('month', $current_user->ID, true);
    ?>
</td>
          </tr>
          <tr>
            <td colspan="2" class="alternate"><strong>Annual DJ Overview for <?php 
    echo date('Y');
    ?>
</strong></td>
            </tr>
         <?php 
    if (mdjm_employee_can('manage_events')) {
        ?>
          <tr>
            <td><a href="<?php 
        echo mdjm_get_admin_page('enquiries');
        ?>
">Outstanding Enquiries:</a></td>
                <td><?php 
        echo $dj_event_count['enquiry_year'] + $dj_event_count['unattended_year'] . (!empty($dj_event_count['unattended_year']) && $dj_event_count['unattended_year'] > 0 ? ' (<a href="' . mdjm_get_admin_page('unattended') . '&mdjm_filter_date=' . date('Ym') . '">' . $dj_event_count['unattended_year'] . ' Unattended)</a>' : '');
        ?>
</td>
          </tr>
          <tr>
            <td>Lost Enquiries:</td>
            <td><?php 
        echo $dj_event_count['lost_year'];
        ?>
</td>
          </tr>
          <?php 
    }
    ?>
          <tr>
            <td>Completed Bookings:</td>
            <td><?php 
    echo $dj_event_count['completed_year'];
    ?>
</td>
          </tr>
          <?php 
    if (mdjm_employee_can('manage_events')) {
        ?>
          <tr>
            <td>Potential Earnings:</td>
            <td><?php 
        echo $mdjm_dash->period_earnings('year', $current_user->ID, false);
        ?>
</td>
          </tr>
          <?php 
    }
    ?>
          <tr>
            <td>Earnings so Far:</td>
            <td><?php 
    echo $mdjm_dash->period_earnings('year', $current_user->ID, true);
    ?>
</td>
          </tr>
            </table>
        </td>
            <td width="40%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="widefat">
              <tr>
                <td colspan="2" class="alternate"><strong><?php 
    echo date('l jS F Y');
    ?>
</strong></td>
              </tr>
              <tr>
                <td width="35%">Your Status:</td>
                <?php 
    $next_event = MDJM()->events->next_event($current_user->ID, 'dj');
    if (!empty($next_event)) {
        $eventinfo = MDJM()->events->event_detail($next_event[0]->ID);
    }
    ?>
                <td width="65%">
				<?php 
    echo isset($eventinfo) && date('Y-m-d', $eventinfo['date']) == date('Y-m-d') ? '<a href="' . get_edit_post_link($next_event[0]->ID) . '">Booked from ' . $eventinfo['start'] . '</a>' : 'Available';
    ?>
                </td>
              </tr>
              <?php 
    if (current_user_can('administrator') && MDJM_MULTI == true) {
        $bookings_today = MDJM()->events->employee_bookings();
        ?>
				  <tr>
					<td>Employee Bookings:</td>
					<?php 
        if (empty($bookings_today)) {
            ?>
							<td>None</td>
							<?php 
        } else {
            echo '<td>';
            $i = 1;
            foreach ($bookings_today as $event) {
                $eventinfo = MDJM()->events->event_detail($event->ID);
                echo '<a href="' . get_edit_post_link($event->ID) . '">' . $eventinfo['dj']->display_name . ' from ' . $eventinfo['start'] . '</a>' . ($i < count($bookings_today) ? '<br />' : '');
                $i++;
            }
            echo '</td>';
        }
        ?>
				  </tr>
					<?php 
    }
    ?>
                <form name="availability-check" id="availability-check" method="post" action="<?php 
    echo mdjm_get_admin_page('availability');
    ?>
">
                <?php 
    if (!current_user_can('administrator')) {
        ?>
<input type="hidden" name="check_employee" id="check_employee" value="<?php 
        echo get_current_user_id();
        ?>
" /><?php 
    } else {
        ?>
<input type="hidden" name="check_employee" id="check_employee" value="all" /><?php 
    }
    ?>
                <tr>
                <td><label for="show_check_date">Availability Check:</label></th>
                <td><input type="text" name="show_check_date" id="show_check_date" class="check_custom_date" required="required" />&nbsp;&nbsp;&nbsp;
                <input type="hidden" name="check_date" id="check_date" />
                <?php 
    submit_button('Check Date', 'primary small', 'submit', false, '');
    ?>
                </td>
                </tr>
                </form>
              <tr>
                  <td colspan="2"><p><a href="http://twitter.com/mobiledjmanager" class="twitter-follow-button" data-show-count="false">Follow @mobiledjmanager</a>
<script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script></p>
<p><div class="g-ytsubscribe" data-channelid="UCaD6icd6OZ8haoTBc5YjJrw" data-layout="default" data-count="hidden"></div></p></td>
              </tr>
              <tr class="alternate">
                <td colspan="2"><strong>Your 7 Day Schedule</strong></td>
              </tr>
              <tr>
              <td colspan="2"><?php 
    get_availability_activity(0, 0);
    ?>
</td>
              </tr>
            </table></td>
          </tr>
          </table>
		<?php 
    if (current_user_can('administrator') && MDJM_MULTI == true) {
        $emp_event_count = MDJM()->events->count_events_by_status();
        ?>
                <hr />
                <table width="100%" border="0" cellspacing="0" cellpadding="0" class="widefat">
                <tr>
                <td width="60%"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="widefat">
                <tr>
                <td colspan="2" class="alternate"><strong>Monthly Employer Overview for <?php 
        echo date('F Y');
        ?>
</strong></td>
                </tr>
                <tr>
                <td width="30%">Active Bookings:</td>
                <td width="70%"><?php 
        echo $emp_event_count['active_month'];
        ?>
</td>
                </tr>
                <tr>
                <td><a href="<?php 
        echo mdjm_get_admin_page('enquiries') . '&mdjm_filter_type&mdjm_filter_date=' . date('Ym');
        ?>
">Outstanding Enquiries:</a></td>
                <td><?php 
        echo $emp_event_count['enquiry_month'] + $emp_event_count['unattended_month'] . (!empty($emp_event_count['unattended_month']) && $emp_event_count['unattended_month'] > 0 ? ' (<a href="' . mdjm_get_admin_page('unattended') . '&mdjm_filter_date=' . date('Ym') . '">' . $emp_event_count['unattended_month'] . ' Unattended)</a>' : '');
        ?>
</td>
                </tr>
                <tr>
                <td>Lost Enquiries:</td>
                <td><?php 
        echo $emp_event_count['lost_month'];
        ?>
</td>
                </tr>
                <tr>
                <td>Completed Bookings:</td>
                <td><?php 
        echo $emp_event_count['completed_month'];
        ?>
</td>
                </tr>
                <tr>
                <td>Potential Earnings:</td>
                <td><?php 
        echo $mdjm_dash->period_earnings('month', '', false);
        ?>
</td>
                </tr>
                <tr>
                <td>Earnings so Far:</td>
                <td><?php 
        echo $mdjm_dash->period_earnings('month', '', true);
        ?>
</td>
                </tr>
                <tr>
                <td colspan="2" class="alternate"><strong>Annual Employer Overview for <?php 
        echo date('Y');
        ?>
</strong></td>
                </tr>
                <tr>
                <td><a href="<?php 
        echo mdjm_get_admin_page('enquiries') . '&mdjm_filter_type&mdjm_filter_date=' . date('Ym');
        ?>
">Outstanding Enquiries:</a></td>
                <td><?php 
        echo $emp_event_count['enquiry_year'] + $emp_event_count['unattended_year'] . (!empty($emp_event_count['unattended_year']) && $emp_event_count['unattended_year'] > 0 ? ' (<a href="' . mdjm_get_admin_page('unattended') . '&mdjm_filter_date=' . date('Ym') . '">' . $emp_event_count['unattended_year'] . ' Unattended)</a>' : '');
        ?>
                </tr>
                <tr>
                <td>Lost Enquiries:</td>
                <td><?php 
        echo $emp_event_count['lost_year'];
        ?>
</td>
                </tr>
                <tr>
                <td>Completed Bookings:</td>
                <td><?php 
        echo $emp_event_count['completed_year'];
        ?>
</td>
                </tr>
                <tr>
                <td>Potential Earnings:</td>
                <td><?php 
        echo $mdjm_dash->period_earnings('year', '', false);
        ?>
</td>
                </tr>
                <tr>
                <td>Earnings so Far:</td>
                <td><?php 
        echo $mdjm_dash->period_earnings('year', '', true);
        ?>
</td>
                </tr>
                </table></td>
                <td width="40%" valign="top">
                <table width="100%" border="0" cellspacing="0" cellpadding="0" class="widefat">
                  <tr>
                    <td width="100%" class="alternate"><strong>Latest News from <a href="<?php 
        mdjm_get_admin_page('mydjplanner');
        ?>
">My DJ Planner</a></strong></td>
                  </tr>
                  <tr>
                    <td><?php 
        wp_widget_rss_output('http://www.mydjplanner.co.uk/category/news/feed/rss2/', $args = array('show_author' => 0, 'show_date' => 1, 'show_summary' => 1, 'items' => 3));
        ?>
</td>
                  </tr>
                  <tr>
                    <td width="100%" class="alternate"><strong>Latest Support Topics</strong></td>
                  </tr>
                  <tr>
                    <td><?php 
        wp_widget_rss_output('http://www.mydjplanner.co.uk/forums/feed/?post_type=topic', $args = array('show_author' => 0, 'show_date' => 0, 'show_summary' => 0, 'items' => 3));
        ?>
</td>
                  </tr>
                </table>
                </td>
                </tr>
                </table>
                <?php 
    }
    ?>
	
        </div>
<?php 
}
 function delete_log($files = '')
 {
     foreach ($files as $file) {
         if (file_exists($this->files[$file][0])) {
             if (unlink($this->files[$file][0])) {
                 $this->log_it('Purged the ' . $file . ' log file', true);
                 $success[] = 'The ' . $file . ' log file was auto-purged successfully in accordance with your <a href="' . mdjm_get_admin_page('debugging') . '">Debug Settings</a>';
             } else {
                 $this->log_it('ERROR: Could not purge the ' . $file . ' log file', true);
                 $error[] = 'The ' . $file . ' log file cound not be purged';
             }
         }
     }
     if (isset($success)) {
         mdjm_update_notice('updated', implode('<br />', $success));
     }
     if (isset($error)) {
         mdjm_update_notice('error', implode('<br />', $success));
     }
 }
function get_availability_activity($month, $year)
{
    global $wpdb, $mdjm, $mdjm_settings, $current_user;
    if ($month == '12') {
        $next_month = '1';
        $mk_year = $year + 1;
    } else {
        $next_month = $month + 1;
        $mk_year = $year;
    }
    if (date('Y-m', strtotime($year . '-' . $month)) == date('Y-m')) {
        $first_day = date('Y-m-d');
        $last_day = date('Y-m-d', strtotime('+1 month'));
    } else {
        $first_day = date('Y-m-d', strtotime($year . '-' . $month . '-01'));
        $last_day = date('Y-m-t', mktime(0, 0, 0, $next_month, 0, $mk_year));
    }
    /* 7 Day Checker for the WP Widget */
    if ($month == 0 && $year == 0) {
        $first_day = date('Y-m-d');
        $last_day = date('Y-m-d', strtotime('+1 week'));
    }
    $date_range = mdjm_all_dates_in_range($first_day, $last_day);
    $event_args = array('posts_per_page' => -1, 'post_type' => 'mdjm-event', 'post_status' => array('mdjm-unattended', 'mdjm-enquiry', 'mdjm-contract', 'mdjm-approved', 'mdjm-completed'), 'orderby' => 'meta_value', 'order' => 'ASC');
    /* Loop through the days */
    foreach ($date_range as $day) {
        if (mdjm_is_admin()) {
            $event_args['meta_query'] = array(array('key' => '_mdjm_event_date', 'value' => $day->format('Y-m-d'), 'compare' => '=', 'type' => 'date'));
            $hol_query = "SELECT * FROM " . MDJM_HOLIDAY_TABLE . " WHERE DATE(date_from) = '" . $day->format('Y-m-d') . "'";
        } else {
            $event_args['meta_query'] = array('relation' => 'AND', array('key' => '_mdjm_event_date', 'value' => $day->format('Y-m-d'), 'compare' => '=', 'type' => 'date'), array('key' => '_mdjm_event_dj', 'value' => $current_user->ID, 'compare' => '='));
            $hol_query = "SELECT * FROM " . MDJM_HOLIDAY_TABLE . " WHERE DATE(date_from) = '" . $day->format('Y-m-d') . "' AND `user_id` = '" . get_current_user_id() . "'";
        }
        /* Work Query */
        $work_result = get_posts($event_args);
        /* Holiday Query */
        $hol_result = $wpdb->get_results($hol_query);
        /* Print results */
        $result_array = array();
        if (count($work_result) > 0 || $hol_result) {
            $event_stati = mdjm_all_event_status();
            $have_result = true;
            ?>
				<tr class="alternate">
				<td colspan="2"><strong><font class="code"><?php 
            echo date('l, jS F Y', strtotime($day->format('Y-m-d')));
            ?>
</font></strong></td>
				</tr>
                <?php 
        }
        if (count($work_result) > 0) {
            foreach ($work_result as $event) {
                $eventinfo = MDJM()->events->event_detail($event->ID);
                ?>
					<tr>
                    <td width="25%">
						<?php 
                if ($month == 0 && $year == 0) {
                    echo '<font style="font-size:12px">';
                }
                ?>
                        <strong><?php 
                echo !empty($eventinfo['dj']->display_name) ? $eventinfo['dj']->display_name : 'DJ ' . $eventinfo['dj'];
                ?>
</strong>
						<?php 
                if ($month == 0 && $year == 0) {
                    echo '</font>';
                }
                ?>
</td>
					<td><?php 
                if ($month == 0 && $year == 0) {
                    echo '<font style="font-size:12px">';
                }
                ?>
<a href="<?php 
                echo get_edit_post_link($event->ID);
                ?>
">Event ID <?php 
                echo $event->ID . '</a> (' . $event_stati[$event->post_status] . ')';
                ?>
 from <?php 
                echo $eventinfo['start'];
                if ($month != 0 && $year != 0) {
                    ?>
 to <?php 
                    echo $eventinfo['finish'];
                }
                if ($month == 0 && $year == 0) {
                    echo '</font>';
                }
                ?>
</td>
                    </tr>
                    <?php 
            }
        }
        if ($hol_result) {
            foreach ($hol_result as $holiday) {
                $dj = get_userdata($holiday->user_id);
                ?>
					<tr>
                    <td width="25%"><?php 
                if ($month == 0 && $year == 0) {
                    echo '<font style="font-size:12px">';
                }
                ?>
<strong><?php 
                echo $dj->display_name;
                ?>
</strong><?php 
                if ($month == 0 && $year == 0) {
                    echo '</font>';
                }
                ?>
</td>
					<td><?php 
                if ($month == 0 && $year == 0) {
                    echo '<font style="font-size:12px">';
                }
                ?>
Unavailable<?php 
                if (isset($holiday->notes) && !empty($holiday->notes) && $month != 0 && $year != 0) {
                    echo ' - ' . $holiday->notes;
                }
                if ($month == 0 && $year == 0) {
                    echo '</font>';
                }
                ?>
 <a style="color: #F00;" href="<?php 
                mdjm_get_admin_page('availability', 'echo');
                ?>
&action=del_entry&entry_id=<?php 
                echo $holiday->entry_id;
                ?>
">Delete Entry</a></td>
                    </tr>
                    <?php 
            }
        }
    }
    // foreach( $date_range as $day )
    if (!isset($have_result)) {
        if ($month != 0 && $year != 0) {
            ?>
				<tr class="alternate">
				<td colspan="2"><strong>There is currently no activity during <?php 
            echo date('F Y', strtotime($year . '-' . $month . '-01'));
            ?>
</strong></td>
				</tr>
				<?php 
        } else {
            ?>
				<tr >
				<td colspan="2">There is currently no activity within the next 7 days</td>
				</tr>
				<?php 
        }
    }
}
Exemple #9
0
/**
 * Define the data to be displayed in each of the custom columns for the Transaction post types
 *
 * @since	0.9
 * @param	str		$column_name	The name of the column to display
 * @param	int		$post_id		The current post ID
 * @return
 */
function mdjm_event_posts_custom_column($column_name, $post_id)
{
    global $post;
    if (mdjm_employee_can('edit_txns') && ($column_name == 'value' || $column_name == 'balance')) {
        $value = mdjm_get_event_price($post_id);
    }
    switch ($column_name) {
        // Event Date
        case 'event_date':
            if (mdjm_employee_can('read_events')) {
                echo '<strong><a href="' . admin_url('post.php?post=' . $post_id . '&action=edit') . '">' . date('d M Y', strtotime(get_post_meta($post_id, '_mdjm_event_date', true))) . '</a>';
            } else {
                echo '<strong>' . date('d M Y', strtotime(get_post_meta($post_id, '_mdjm_event_date', true))) . '</strong>';
            }
            break;
            // Client
        // Client
        case 'client':
            $client = get_userdata(get_post_meta($post->ID, '_mdjm_event_client', true));
            if (!empty($client)) {
                if (mdjm_employee_can('send_comms')) {
                    printf('<a href="%s">%s</a>', add_query_arg(array('recipient' => $client->ID, 'event_id' => $post_id), admin_url('admin.php?page=mdjm-comms')), $client->display_name);
                } else {
                    echo $client->display_name;
                }
            } else {
                _e('<span class="mdjm-form-error">Not Assigned</span>', 'mobile-dj-manager');
            }
            break;
            // Employees
        // Employees
        case 'employees':
            global $wp_roles;
            $primary = get_userdata(mdjm_get_event_primary_employee($post->ID));
            $employees = mdjm_get_event_employees_data($post->ID);
            if (!empty($primary)) {
                if (mdjm_employee_can('send_comms')) {
                    printf('<a href="%s" title="%s">%s</a>', add_query_arg(array('recipient' => $primary->ID, 'event_id' => $post_id), admin_url('admin.php?page=mdjm-comms')), mdjm_get_option('artist', __('DJ', 'mobile-dj-manager')), $primary->display_name);
                } else {
                    echo '<a title="' . mdjm_get_option('artist', __('DJ', 'mobile-dj-manager')) . '">' . $primary->display_name . '</a>';
                }
            } else {
                _e('<span class="mdjm-form-error">Not Assigned</span>', 'mobile-dj-manager');
            }
            if (!empty($employees)) {
                echo '<br />';
                $i = 1;
                foreach ($employees as $employee) {
                    echo '<em>';
                    if (mdjm_employee_can('send_comms')) {
                        printf('<a href="%s" title="%s">%s</a>', add_query_arg(array('recipient' => $employee['id'], 'event_id' => $post_id), admin_url('admin.php?page=mdjm-comms')), translate_user_role($wp_roles->roles[$employee['role']]['name']), mdjm_get_employee_display_name($employee['id']));
                    } else {
                        echo '<a title="' . translate_user_role($wp_roles->roles[$employee['role']]['name']) . '">' . mdjm_get_employee_display_name($employee['id']) . '</a>';
                    }
                    echo '</em>';
                    if ($i != count($employees)) {
                        echo '<br />';
                    }
                }
            }
            break;
            // Status
        // Status
        case 'event_status':
            echo get_post_status_object($post->post_status)->label;
            break;
            // Event Type
        // Event Type
        case 'event_type':
            $event_types = get_the_terms($post_id, 'event-types');
            if (is_array($event_types)) {
                foreach ($event_types as $key => $event_type) {
                    $event_types[$key] = $event_type->name;
                }
                echo implode("<br/>", $event_types);
            }
            break;
            // Value
        // Value
        case 'value':
            if (mdjm_employee_can('edit_txns')) {
                if (!empty($value) && $value != '0.00') {
                    echo mdjm_currency_filter(mdjm_format_amount($value));
                    echo '<br />';
                } else {
                    echo '<span class="mdjm-form-error">' . mdjm_currency_filter(mdjm_format_amount('0.00')) . '</span>';
                }
            } else {
                echo '&mdash;';
            }
            break;
            // Balance
        // Balance
        case 'balance':
            if (mdjm_employee_can('edit_txns')) {
                echo mdjm_currency_filter(mdjm_format_amount(mdjm_get_event_balance($post_id)));
                echo '<br />';
                $deposit_status = mdjm_get_event_deposit_status($post_id);
                if ('Paid' == mdjm_get_event_deposit_status($post_id)) {
                    printf(__('<i title="%s %s paid" class="fa fa-check-square-o" aria-hidden="true">', 'mobile-dj-manager'), mdjm_currency_filter(mdjm_format_amount(mdjm_get_event_deposit($post_id))), mdjm_get_deposit_label());
                }
            } else {
                echo '&mdash;';
            }
            break;
            // Playlist
        // Playlist
        case 'playlist':
            if (mdjm_employee_can('read_events')) {
                $total = mdjm_count_playlist_entries($post_id);
                echo '<a href="' . mdjm_get_admin_page('playlists') . $post_id . '">' . $total . ' ' . _n('Song', 'Songs', $total, 'mobile-dj-manager') . '</a>' . "\r\n";
            } else {
                echo '&mdash;';
            }
            break;
            // Journal
        // Journal
        case 'journal':
            if (mdjm_employee_can('read_events_all')) {
                $total = wp_count_comments($post_id)->approved;
                echo '<a href="' . admin_url('/edit-comments.php?p=' . $post_id) . '">' . $total . ' ' . _n('Entry', 'Entries', $total, 'mobile-dj-manager') . '</a>' . "\r\n";
            } else {
                echo '&mdash;';
            }
            break;
    }
    // switch
}