<?php
/**
 * Installment Plan Info Module
 * 
 * @author  Kyo (AKA Yasuhiro Sota)
 * @version 1.1.3
 * @license Commercial License
 * @package catalog
 * @subpackage  catalog.model.module
 */
class ModelModuleInstallmentPlanInfo extends Model {

/**
 * getProductOptionValues method
 *
 * @param integer $product_id
 * @param array $product_option_value_ids
 * @return array Product option value data
 */  
  public function getProductOptionValues($product_id, $product_option_value_ids = array()) {

    $product_option_value_data = array();
    
    // Make sure that option value ids are of numeric type.
    $product_option_value_ids = array_map(create_function('$value', 'return is_numeric($value) ? (int)$value : $value;'), (array)$product_option_value_ids);

    $sql = "SELECT * FROM " . DB_PREFIX . "product_option_value pov";
    $sql .= " LEFT JOIN " . DB_PREFIX . "option_value ov ON (pov.option_value_id = ov.option_value_id)";
    $sql .=" LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id)";
    $sql .=" WHERE";
    $sql .=" pov.product_id = '" . (int)$product_id . "'";
    
    if ($product_option_value_ids) {
      $sql .=" AND pov.product_option_value_id IN (" . implode(',', $product_option_value_ids) . ")";
    }
    
    $sql .=" AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
    
    $product_option_value_query = $this->db->query($sql);

    foreach ($product_option_value_query->rows as $product_option_value) {
      $product_option_value_data[] = array(
        'product_option_value_id' => $product_option_value['product_option_value_id'],
        'option_value_id'         => $product_option_value['option_value_id'],
        'name'                    => $product_option_value['name'],
        'image'                   => $product_option_value['image'],
        'quantity'                => $product_option_value['quantity'],
        'subtract'                => $product_option_value['subtract'],
        'price'                   => $product_option_value['price'],
        'price_prefix'            => $product_option_value['price_prefix'],
        'weight'                  => $product_option_value['weight'],
        'weight_prefix'           => $product_option_value['weight_prefix']
      );
    }

		return $product_option_value_data;
  }
  
}
?>