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); }
<?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> ';
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_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 = '-'; } } } ?> <tr id="" class="iedit bsalted-proposal-row">
public static function getWithDeposit() { $db = new db(); $db_tables = $db->getWpdb(); $proposal = self::addition_fields_list()['deposit']; $users = $db->query("SELECT user_id FROM {$db_tables->usermeta} WHERE {$db_tables->usermeta}.meta_key = '{$proposal}' "); return $users; }
$db = new db(); $adventure_date = db::get_option('bsalted_adventures_day'); $adventure_dates = db::get_option('bsalted_adventures_days'); if (!empty($adventure_date) && strpos($adventure_dates, $adventure_date) === false) { if (!empty($adventure_dates)) { db::update_option('bsalted_adventures_days', $adventure_dates . ',' . $adventure_date); } else { db::update_option('bsalted_adventures_days', $adventure_dates . $adventure_date); } } $adventure_dates = db::get_option('bsalted_adventures_days'); $selected_values = explode(',', $adventure_dates); #$dates = $db->getUpcommingStages(); $consultant_amount = db::get_option('bsalted_cosultant_amount'); $consultant_bonus5 = db::get_option('bsalted_cosultant_bonus5'); $consultant_bonus10 = db::get_option('bsalted_cosultant_bonus10'); // var_dump( date("m-d-Y", $dates) ); // var_dump($adventure_dat); #var_dump( $dates); ?> <div class="wrap"> <form action="options.php" method="post"> <table class="form-table"> <tr><th></th><td><h3>Stage</h3><hr></td></tr> <tr valign="top"> <th scope="row">Enter new date <small>(only month and day of the month) </small></th> <td> <input type="text" name="bsalted_adventures_day" value=""> </td> </tr>
</tr> </thead> <tbody id="the-list"> <?php foreach ($users as $user_obj) { $user_id = $user_obj->ID; $user_code = User::getCode($user_id); $user_orders = SiteHelper::getConsultantOrders($user_code, $report_type); $user_sales = array(); $user_course_sales = 0; $user_int_sales = 0; #$from_date = date('F j, Y', strtotime('+1 day', strtotime($user_data['period']))); foreach ($user_orders as $order) { $order_id = $order->ID; $order_course_id = db::getEntryMeta($order_id, $user_course_field)[0]; $user_sales[$order_id][$order_course_id] = array(); $order_obj = new \WC_Order($order_id); $order_items = $order_obj->get_items(); foreach ($order_items as $item) { #array_push($user_sales[$order_id][$order_course_id], $item['product_id']); $product_name = array_search($item['product_id'], $products); if ($product_name === 'PRE') { $user_course_sales++; } elseif ($product_name === 'INT') { $user_int_sales++; } // var_dump($item['product_id']); } // $user_sales[$order_id][$order_course_id] = $order_items; }
<?php } ?> </select> </td> <td> <select name="bsalted-proposal-second" class="chosen-select bsalted-proposal-second"> <?php foreach ($courses_id as $course_id) { ?> <option value="<?php echo $course_id; ?> "> <?php $course = db::getEntry($course_id); echo $course->post_title; ?> </option> <?php } ?> </select> </td> <td> <form action="." class="bsalted-proposal"> <input type="hidden" name="user-id" value="<?php echo $user_id; ?> "> <input type="hidden" class="proposal-first" name="proposal-first">
public static function stage_place_aviability($stage_id) { $stage_fields = self::types_fields_list(); $confirmed_field = $stage_fields['confirmed']; $stage_places = db::getEntryMeta($stage_id, $stage_fields['free-places']) === '' ? 0 : db::getEntryMeta($stage_id, $stage_fields['free-places']); $stage_confirmed = db::getEntryMeta($stage_id, $confirmed_field) === '' ? 0 : db::getEntryMeta($stage_id, $confirmed_field); return $stage_places > $stage_confirmed || $stage_places === 0; }
<?php use Nerds\Bsalted\Entity\CourseEntity\Course; use Nerds\Base\Util\Helpers\DatabaseAccessWrapper; use Nerds\Bsalted\Entity\UserEntity\User; $db = new DatabaseAccessWrapper(); $savans = User::getByRole('adventure_savant'); $capitans = User::getByRole('adventure_capitan'); $post_id = get_the_ID(); $stored_data = $db->getCourseData()[$post_id]; $fields_list = Course::addition_fields_list(); $human_resourses = explode(',', $stored_data['resourses']); ?> <div class="bsalted-field"> <label for="<?php echo $fields_list['resourses']; ?> ">The Human resources: </label> <select id="<?php echo $fields_list['resourses']; ?> " data-placeholder="Choose Human resources..." class="chosen-select" multiple style="width:350px;" tabindex="4"> <optgroup label="Capitans"> <?php foreach ($capitans as $obj) { ?> <?php if (in_array($obj->ID, $human_resourses)) { ?> <option value="<?php
public static function getConsultantOrders($code, $type, $mode) { $order_fields = Order::addition_fields_list(); $first_day_of_year = split('-', date('Y-m-d', strtotime(date('Y-01-00')))); $first_day_of_month = split('-', date('Y-m-d', strtotime('last day of last month'))); $first_day_of_week = strtotime('last sunday', strtotime('now')); $week_start = split('-', date('Y-m-d', $first_day_of_week)); $dates = array('week' => $week_start, 'month' => $first_day_of_month, 'year' => $first_day_of_year); if ($mode && $mode === 'period') { return implode('-', $dates[$type]); } $args = array('post_type' => 'shop_order', 'post_status' => 'wc-completed', 'meta_query' => array(array('key' => $order_fields['consultant'], 'value' => $code)), 'date_query' => array(array('column' => 'post_date_gmt', 'after' => array('year' => $dates[$type][0], 'month' => $dates[$type][1], 'day' => $dates[$type][2])), 'inclusive' => true)); #$orders = db::getEntries($args); return db::getEntries($args); }