예제 #1
0
 public static function save_attributes($property_id, $attributes)
 {
     $map = new Mapping();
     foreach ($attributes as $key => $value) {
         $attr_type = self::get_attribute_type($key);
         if ($attr_type == 'select') {
             $map_value = $map->get_app_field_value($value);
             $attr_options = self::get_attribute_options($key);
             if ($key == 21) {
                 $map_value = 1;
             }
             if ($key == 15 && $value == 'All Type') {
                 $map_value = 'No preference';
             }
             if ($key == 124 && $value > 0) {
                 $map_value = 'Yes';
             } elseif ($key == 124 && ($value = 0)) {
                 $map_value = 'No';
             }
             $attr_option_id = isset($attr_options[$map_value]) ? $attr_options[$map_value] : 0;
             $attr_option_value = $map_value;
             //my_print('arrt_id: '.$key);
             //my_print('value: '.$value);
             //my_print('Map value: '.$map_value);
             //my_print($attr_options);
         } else {
             $attr_option_id = 0;
             $attr_option_value = $map->get_app_field_value($value);
         }
         //my_print($key . '::' .  $attr_option_id . '::' . $attr_option_value . '::' .  $attr_type);
         $ar_proprerty_attribute_values = array('propertyID' => $property_id, 'attributeID' => $key, 'attrOptionID' => $attr_option_id);
         $attrValueID = self::save_data('rp_property_attribute_values', $ar_proprerty_attribute_values);
         $ar_proprerty_attribute_values_l1 = array('attrValueID' => $attrValueID, 'languageID' => 1, 'attrDetValue' => $attr_option_value);
         $attrValueID = self::save_data('rp_property_attribute_value_details', $ar_proprerty_attribute_values_l1);
         $ar_proprerty_attribute_values_l2 = array('attrValueID' => $attrValueID, 'languageID' => 2, 'attrDetValue' => $attr_option_value);
         $attrValueID = self::save_data('rp_property_attribute_value_details', $ar_proprerty_attribute_values_l2);
     }
 }
예제 #2
0
 public static function save_attributes($property_id, $attributes)
 {
     $map = new Mapping();
     foreach ($attributes as $key => $value) {
         $attr_type = self::get_attribute_type($key);
         if ($attr_type == 'select') {
             $map_value = $map->get_app_field_value($value);
             $attr_options = self::get_attribute_options($key);
             if ($key == 21) {
                 if ($map_value > 3) {
                     $map_value = '4+';
                 }
             }
             if ($key == 15 && $value == 'All Type') {
                 $map_value = 'No preference';
             }
             if ($key == 124 && $value > 0) {
                 $map_value = 'Yes';
             } elseif ($key == 124 && ($value = 0)) {
                 $map_value = 'No';
             }
             $attr_option_id = isset($attr_options[$map_value]) ? $attr_options[$map_value] : 0;
             $attr_option_value = $map_value;
         } elseif ($attr_type == 'multiselect') {
             $map_value = explode(',', $map->get_app_field_value($value));
             $attr_options = self::get_attribute_options($key);
             $options = $details = array();
             $i = 0;
             foreach ($attr_options as $id => $option) {
                 if (trim($map_value[$i]) == 'Y') {
                     $options[$id] = $option;
                     $details[$id] = $id;
                 }
                 $i++;
             }
             $attr_option_id = join($options, '#|#');
             $attr_option_value = join($details, '#|#');
         } else {
             $attr_option_id = 0;
             $attr_option_value = $map->get_app_field_value($value);
         }
         $ar_proprerty_attribute_values = array('propertyID' => $property_id, 'attributeID' => $key, 'attrOptionID' => $attr_option_id);
         $attrValueID = self::save_data('rp_property_attribute_values', $ar_proprerty_attribute_values);
         $ar_proprerty_attribute_values_l1 = array('attrValueID' => $attrValueID, 'languageID' => 1, 'attrDetValue' => $attr_option_value);
         $attrValueID = self::save_data('rp_property_attribute_value_details', $ar_proprerty_attribute_values_l1);
         $ar_proprerty_attribute_values_l2 = array('attrValueID' => $attrValueID, 'languageID' => 2, 'attrDetValue' => $attr_option_value);
         $attrValueID = self::save_data('rp_property_attribute_value_details', $ar_proprerty_attribute_values_l2);
     }
 }