function displayFormFeatures($obj, $languages, $defaultLanguage) { global $cookie, $currentIndex; if ($obj->id) { $feature = Feature::getFeatures(intval($cookie->id_lang)); $ctab = ''; foreach ($feature as $tab) { $ctab .= 'ccustom_' . $tab['id_feature'] . '¤'; } $ctab = rtrim($ctab, '¤'); echo ' <table cellpadding="5"> <tr> <td colspan="2"><b>' . $this->l('Assign features to this product') . '</b></td> </tr> </table> <hr style="width:730px;"><br />'; // Header $nb_feature = Feature::nbFeatures(intval($cookie->id_lang)); echo ' <table border="0" cellpadding="0" cellspacing="0" class="table" style="width:600px;"> <tr> <th>' . $this->l('Features') . '</td> <th style="width:220px">' . $this->l('Value') . '</td> <th style="width:170px">' . $this->l('Customized') . '</td> </tr>'; if (!$nb_feature) { echo '<tr><td colspan="3" style="text-align:center;">' . $this->l('No features defined') . '</td></tr>'; } echo '</table>'; // Listing if ($nb_feature) { echo ' <table cellpadding="5" style="width:600px; margin-top:10px">'; foreach ($feature as $tab_features) { $current_item = false; $custom = false; $product_features = $obj->getFeatures(); foreach ($product_features as $tab_products) { if ($tab_products['id_feature'] == $tab_features['id_feature']) { $current_item = $tab_products['id_feature_value']; } } echo ' <tr> <td>' . $tab_features['name'] . '</td> <td style="width:220px"> <select name="feature_' . $tab_features['id_feature'] . '_value"> <option value="0">--- </option>'; $feature_values = FeatureValue::getFeatureValues($tab_features['id_feature']); foreach ($feature_values as $tab_values) { if (!$tab_values['custom']) { $value = FeatureValue::selectLang(FeatureValue::getFeatureValueLang($tab_values['id_feature_value']), intval($cookie->id_lang)); echo '<option value="' . $tab_values['id_feature_value'] . '"' . ($current_item == $tab_values['id_feature_value'] ? ' selected="selected"' : '') . '>' . substr($value, 0, 40) . (Tools::strlen($value) > 40 ? '...' : '') . ' </option>'; } else { $custom = true; } } echo ' </select> </td> <td style="width:170px">'; $tab_customs = array(); if ($custom) { $tab_customs = FeatureValue::getFeatureValueLang($current_item); } foreach ($languages as $language) { $custom_lang = FeatureValue::selectLang($tab_customs, $language['id_lang']); echo ' <div id="ccustom_' . $tab_features['id_feature'] . '_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;"> <input type="text" name="custom_' . $tab_features['id_feature'] . '_' . $language['id_lang'] . '" size="20" value="' . htmlentities(Tools::getValue('custom_' . $tab_features['id_feature'] . '_' . $language['id_lang'], $custom_lang), ENT_COMPAT, 'UTF-8') . '" /> </div>'; } $this->displayFlags($languages, $defaultLanguage, $ctab, 'ccustom_' . $tab_features['id_feature']); echo ' </td> </tr>'; } echo ' <tr> <td> </td> <td style="height:50px; " valign="bottom"><input type="submit" name="submitProductFeature" id="submitProductFeature" value="' . $this->l('Update features') . '" class="button" /></td> </tr>'; } echo '</table> <hr style="width:730px;"> <div style="text-align:center;"> <a href="index.php?tab=AdminFeatures&addfeature&token=' . Tools::getAdminToken('AdminFeatures' . intval(Tab::getIdFromClassName('AdminFeatures')) . intval($cookie->id_employee)) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');"><img src="../img/admin/add.gif" alt="new_features" title="' . $this->l('Create new features') . '" /> ' . $this->l('Create new features') . '</a> </div>'; } else { echo '<b>' . $this->l('You must save this product before adding features') . '.</b>'; } }