/** * Getsa unit data * @author Howard <*****@*****.**> * @static * @param int $id * @return array */ public static function get_unit($id) { /** first validation **/ if (trim($id) == '') { return array(); } $unit = wpl_units::get_units('', '', " AND `id`='" . $id . "'"); return isset($unit[0]) ? $unit[0] : NULL; }
/** * {$type} * $type is a unit type for filtering **/ private function generate_new_page($type) { $this->units = wpl_units::get_units($type, "", ""); if ($type == 4) { parent::render($this->tpl_path, 'internal_unit_manager_currency'); } else { parent::render($this->tpl_path, 'internal_unit_manager_general'); } exit; }
public function generate_currency_page() { $this->units = wpl_units::get_units(4, '', ''); /** import tpl **/ parent::render($this->tpl_path, 'internal_unit_manager_currency'); }
private function generate_edit_page($user_id = '') { $this->user_info = wpl_users::get_user($user_id); $this->fields = wpl_db::columns('wpl_users'); $this->user_data = wpl_users::get_wpl_user($user_id); $this->data = $this->user_data; $this->units = wpl_units::get_units(4); $this->listings = wpl_listing_types::get_listing_types(); $this->property_types = wpl_property_types::get_property_types(); $this->memberships = wpl_users::get_wpl_memberships(); $this->membership_types = wpl_users::get_membership_types(); parent::render($this->tpl_path, 'edit'); exit; }
$default_division_value = 1000; } elseif ($type == 'volume') { $unit_type = 3; $default_max_value = 1000; $default_division_value = 50; } elseif ($type == 'area') { $unit_type = 2; $default_max_value = 10000; $default_division_value = 100; } elseif ($type == 'length') { $unit_type = 1; $default_max_value = 100; $default_division_value = 10; } /** get units **/ $units = wpl_units::get_units($unit_type); /** MIN/MAX extoptions **/ $extoptions = explode(',', $field['extoption']); $min_value = (isset($extoptions[0]) and trim($extoptions[0]) != '') ? $extoptions[0] : 0; $max_value = isset($extoptions[1]) ? $extoptions[1] : $default_max_value; $division = isset($extoptions[2]) ? $extoptions[2] : $default_division_value; $separator = isset($extoptions[3]) ? $extoptions[3] : ','; switch ($field['type']) { case 'minmax': $show = 'minmax'; $input_type = 'text'; break; case 'minmax_slider': $show = 'minmax_slider'; $input_type = 'hidden'; break;
/** * Generates finalize query of property converts units to SI units etc. * @author Howard <*****@*****.**> * @static * @param type $data * @param type $id * @return string */ public static function generate_finalize_query($data, $id = '') { $units = wpl_global::return_in_id_array(wpl_units::get_units('', 1)); $query = ''; foreach ($data as $field => $value) { if (!strstr($field, '_unit')) { continue; } if (!isset($units[$value])) { continue; } $core_field = str_replace('_unit', '', $field); if (!array_key_exists($core_field . '_si', $data)) { continue; } if (!isset($data[$core_field])) { continue; } $si_value = $units[$value]['tosi'] * $data[$core_field]; $query .= "`" . $core_field . "_si`='" . $si_value . "',"; if (isset($data[$core_field . '_max'])) { $si_value = $units[$value]['tosi'] * $data[$core_field . '_max']; $query .= "`" . $core_field . "_max_si`='" . $si_value . "',"; } } return $query; }
" class="wpl_listing_saved_span"></span> <?php $done_this = true; } elseif (in_array($type, array('mmprice', 'mmvolume', 'mmarea', 'mmlength')) and !$done_this) { _wpl_import('libraries.units'); if ($type == 'mmprice') { $units = wpl_units::get_units(4); } if ($type == 'mmvolume') { $units = wpl_units::get_units(3); } if ($type == 'mmarea') { $units = wpl_units::get_units(2); } if ($type == 'mmlength') { $units = wpl_units::get_units(1); } $value_max = isset($values[$field->table_column . '_max']) ? $values[$field->table_column . '_max'] : 0; ?> <label for="wpl_c_<?php echo $field->id; ?> "><?php echo __($label, WPL_TEXTDOMAIN); if (in_array($mandatory, array(1, 2))) { ?> <span class="required-star">*</span><?php } ?> </label> <input onkeyup="wpl_thousand_sep('wpl_c_<?php
?> </label> <input type="text" id="pr_price_min" name="sf_min_price" /> </div> <div class="plugin-row wpl_shortcode_parameter wpl_hidden_element pr_property_listing"> <label for="pr_price_max"><?php echo __('Price (Max)', WPL_TEXTDOMAIN); ?> </label> <input type="text" id="pr_price_max" name="sf_max_price" /> </div> <div class="plugin-row wpl_shortcode_parameter wpl_hidden_element pr_property_listing"> <?php $units = wpl_units::get_units(4); ?> <label for="pr_price_unit_selectbox"><?php echo __('Price Unit', WPL_TEXTDOMAIN); ?> </label> <select id="pr_price_unit_selectbox" name="sf_unit_price"> <?php foreach ($units as $unit) { ?> <option value="<?php echo $unit['id']; ?> "><?php echo __($unit['name'], WPL_TEXTDOMAIN); ?>
/** * Renders price based on currency unit id * @author Howard <*****@*****.**> * @static * @param int $price * @param int $unit_id * @param string $symbol * @return string */ public static function render_price($price, $unit_id = '', $symbol = '') { /** in case of empty unit just do it with default currency **/ if (trim($unit_id) == '') { $all_units = wpl_units::get_units(4, 1); $unit_id = $all_units[0]['id']; } /** get currency **/ $currency = wpl_units::get_unit($unit_id); if (!trim($symbol)) { $symbol = $currency['name']; } $decimal = 2; $return = ''; $d_seperator = trim($currency['d_seperator']) != '' ? $currency['d_seperator'] : ''; $seperator = trim($currency['seperator']) != '' ? $currency['seperator'] : ''; /** set decimal **/ if (!$d_seperator) { $decimal = 0; } /** set default value **/ if (trim($price) == '') { $price = 0; } /** Convert price to float **/ if (strpos($price, '.') !== false) { if (!$d_seperator) { $d_seperator = '.'; } $price = (double) $price; $decimal = 2; } /** Remove decimals if the price is not float **/ if (!is_float($price)) { $price = intval($price); $decimal = 0; } $price = number_format($price, $decimal, $d_seperator, $seperator); if ($currency['after_before'] == 0) { $return = $symbol . $price; } else { $return = $price . $symbol; } return $return; }