示例#1
0
 public static function getChilds($course_id)
 {
     $stage = new Event();
     $stage_fields = $stage->addition_fields_list();
     $course_field = '_' . $stage_fields['course'];
     $args = array('post_type' => Event::POST_TYPE, 'meta_query' => array(array('key' => $course_field, 'value' => $course_id)));
     return db::getEntries($args);
 }
 public function register_metaboxes()
 {
     $event = new Event();
     $event->register_metabox();
     $course = new Course();
     $course->register_metabox();
     SiteHelper::hideCustomMetabox();
 }
 public function init()
 {
     SessionHelper::start();
     $bootstrap = new Bootstrap();
     $bootstrap->init();
     if (!post_type_exists(Event::POST_TYPE) && !post_type_exists(Course::POST_TYPE)) {
         Event::register();
         Course::register();
     }
 }
 public function load_resourses()
 {
     // wp_enqueue_style( 'momentum-css', SiteHelper::getResoursesPath() . '/js/moment/min/moment.min.css');
     // wp_enqueue_style( 'bsalted-css', SiteHelper::getResoursesPath() . '/css/main.css' );
     wp_enqueue_style('fullcalendar-css', SiteHelper::getResoursesPath() . '/js/fullcalendar/dist/fullcalendar.min.css');
     wp_enqueue_style('qtip-css', SiteHelper::getResoursesPath() . '/js/qtip/jquery.qtip.min.css');
     wp_enqueue_style('chosen-css', SiteHelper::getResoursesPath() . '/js/chosen/chosen.min.css');
     wp_enqueue_script('momentum-js', SiteHelper::getResoursesPath() . '/js/moment/min/moment.min.js', array('jquery'), '1.1', false);
     wp_enqueue_script('fullcalendar-js', SiteHelper::getResoursesPath() . '/js/fullcalendar/dist/fullcalendar.min.js', array('jquery'), '1.1', false);
     wp_enqueue_script('qtip-js', SiteHelper::getResoursesPath() . '/js/qtip/jquery.qtip.js', array('jquery'), '1.1', false);
     wp_enqueue_script('chosen-js', SiteHelper::getResoursesPath() . '/js/chosen/chosen.jquery.min.js', array('jquery'), '1.1', false);
     wp_enqueue_script('bsalted-js', SiteHelper::getResoursesPath() . '/js/main/main.js', array('jquery'), '1.1', false);
     $db = new DatabaseAccessWrapper();
     $role = User::getRole();
     $stage = new Event();
     wp_localize_script('fullcalendar-js', 'bsaltedEventsData', $stage->getData());
     wp_localize_script('fullcalendar-js', 'bsaltedOptions', $db::get_option('bsalted_adventures_days'));
     if (in_array($role, UserRole::restricted())) {
         SiteHelper::hideCustomMenuItem();
         if (!$role === 'director_of_logistics') {
             wp_localize_script('bsalted-js', 'userRole', 'limited');
         }
     }
 }
 public function save_metadata($post_id)
 {
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     if (Course::POST_TYPE == $_POST['post_type']) {
         #if ( ! current_user_can( 'edit_page', $post_id ) ) return $post_id;
         $fields = Course::addition_fields_list();
         $fields_values = array();
         foreach ($fields as $name => $id) {
             $fields_values[$name] = sanitize_text_field($_POST[$id]);
             $this->updateEntryMeta($post_id, '_' . $name, $fields_values[$name]);
         }
     } elseif (Event::POST_TYPE == $_POST['post_type']) {
         #if ( ! current_user_can( 'edit_post', $post_id ) ) return $post_id;
         $addition_fields = Event::addition_fields_list();
         $fields_values = array();
         // $savan = sanitize_text_field( $_POST[$addition_fields['savan']] );
         // $capitan = sanitize_text_field( $_POST[$addition_fields['capitan']] );
         // $room = sanitize_text_field( $_POST[$addition_fields['room']] );
         // $course = sanitize_text_field( $_POST[$addition_fields['course']] );
         foreach ($addition_fields as $name => $id) {
             if ($name !== 'confirmed') {
                 $fields_values[$name] = sanitize_text_field($_POST[$id]);
                 $this->updateEntryMeta($post_id, '_' . $id, $fields_values[$name]);
             }
         }
     }
 }
示例#6
0
<?php

use Nerds\Bsalted\Entity\CourseEntity\Course;
use Nerds\Bsalted\Entity\EventEntity\Event;
use Nerds\Bsalted\Entity\UserEntity\User;
use Nerds\Base\Util\Helpers\DatabaseAccessWrapper as db;
use Nerds\Base\Util\Helpers\SiteHelper;
$stage = new Event();
$stage_fields = $stage->addition_fields_list();
$user_fields = User::addition_fields_list();
$db = new db();
$savans = User::getByRole('adventure_savant');
$capitans = User::getByRole('adventure_capitan');
$stage_id = get_the_ID();
$raw_stage_name = $stage->getNameByID($stage_id);
$stored_data = $stage->getData()[$stage_id];
$course_data = $db->getCourseData()[$stored_data['course']];
$human_resourses = explode(',', $course_data['resourses']);
$stage_name = $stage_fields['name'] . $raw_stage_name;
$types_fields = $stage->types_fields_list();
$args = array('post_type' => Course::POST_TYPE, 'selected' => $stored_data['course'], 'name' => $stage_fields['course'], 'show_option_none' => 'Courses...', 'option_none_value' => '0');
?>

<?php 
if (!$amount) {
    ?>
	
<div class="bsalted-field">

	<?php 
    echo '<label for="courses">Select a Course:</label> ';
示例#7
0
 public function set_product_price($stage_id)
 {
     if (is_array($stage_id)) {
         foreach ($stage_id as $id) {
             $stage_name = Event::getNameByID($id);
             $stage_price = Event::getPriceByID($id);
             $product_id = SiteHelper::product_stage_relation()[$stage_name];
             db::updateEntryMeta($product_id, '_price', $stage_price);
         }
     } else {
         $stage_name = Event::getNameByID($stage_id);
         $stage_price = Event::getPriceByID($stage_id);
         $product_id = SiteHelper::product_stage_relation()[$stage_name];
         db::updateEntryMeta($product_id, '_price', $stage_price);
     }
 }
 $protege_orders = User::getOrdersByDate($protege_id, $date_type);
 if (!empty($protege_orders)) {
     $protege_form_id = User::getRegistrationFormID($protege_id);
     $protege_form = User::getRegistrationForm($protege_form_id);
     $protege_status = '';
     $ptotege_invoice = '';
     $protege_course_start = '';
     foreach ($protege_orders as $order) {
         $order_obj = new \WC_Order($order->ID);
         $order_items = $order_obj->get_items();
         $protege_course_id = db::getEntryMeta($order->ID, $user_fields['course']);
         $ptotege_invoice = db::getEntryMeta($order->ID, '_transaction_id')[0];
         if ($protege_course_id) {
             $stages = Course::getChilds($protege_course_id);
             foreach ($stages as $stage) {
                 $stage_name = Event::getNameByID($stage->ID);
                 if ($stage_name === 'INT') {
                     $protege_course_start = date('Y-m-d', db::getEntryMeta($stage->ID, $stage_type_fields['start'])[0]);
                     break;
                 }
             }
         }
         foreach ($order_items as $item) {
             $user_account++;
             $protege_status = 'Full Paid';
             if (count($order_items) == 1 && $item['product_id'] == 542) {
                 $protege_status = 'Deposit Paid';
                 $protege_course_start = '-';
             }
         }
     }
示例#9
0
 public static function getPaidStages()
 {
     $user_id = self::getID();
     $stages = SiteHelper::product_stage_relation();
     $stage_fields = Event::addition_fields_list();
     $paid_stages = array();
     foreach ($stages as $stage_name => $product_id) {
         $paid_stage_id = self::getMeta($user_id, $stage_fields['name'] . $stage_name);
         if ($paid_stage_id) {
             $paid_stages[$stage_name] = $paid_stage_id;
         }
     }
     return $paid_stages;
 }
$users = User::getByRole('adventure_consultant');
$user_fields = User::addition_fields_list();
$user_course_field = $user_fields['course'];
$stages = Event::getProposal();
$order_fields = Order::addition_fields_list();
$products = SiteHelper::product_stage_relation();
$courses_id = array();
$order = new Order();
$events = new Course();
$report_type = isset($_GET['report-type']) && !empty($_GET['report-type']) ? $_GET['report-type'] : 'week';
$today = date('F j, Y');
$period = SiteHelper::getConsultantOrders(null, $report_type, 'period');
$form_date = date('F j, Y', strtotime('+1 day', strtotime($period)));
foreach ($stages as $obj) {
    $stage_id = $obj->ID;
    $course_id = Event::getParentID($stage_id);
    if (!in_array($course_id, $courses_id)) {
        array_push($courses_id, $course_id);
    }
}
?>


<div class="bsalted-statistic-top">
	<h1>Statistic from <?php 
echo $form_date;
?>
 to <?php 
echo $today;
?>
</h1>
示例#11
0
 public static function is_course_confirmed($course_id)
 {
     $course_stages = Course::getChilds($course_id);
     foreach ($course_stages as $stage_obj) {
         if (!Event::is_confirmed($stage_obj->ID)) {
             return false;
         }
     }
     return true;
 }