public static function getFormData($id = null, $edit = false) { global $lC_Database, $lC_Language; $result = array(); $result['titleCode'] = ''; foreach ($lC_Language->getAll() as $l) { $result['titleCode'] .= '<span class="input" style="width:75%"><label for="name[' . $l['id'] . ']" class="button silver-gradient glossy">' . $lC_Language->showImage($l['code']) . '</label>' . lc_draw_input_field('name[' . $l['id'] . ']', null, 'class="input-unstyled"') . '</span> ' . lc_draw_input_field('key[' . $l['id'] . ']', null, 'class="input" size="4"') . '<br />'; } $Qrules = $lC_Database->query('select weight_class_id, weight_class_title from :table_weight_classes where language_id = :language_id order by weight_class_title'); $Qrules->bindTable(':table_weight_classes', TABLE_WEIGHT_CLASS); $Qrules->bindInt(':language_id', $lC_Language->getID()); $Qrules->execute(); $result['newRules'] = ''; while ($Qrules->next()) { $result['newRules'] .= '<span class="input full-width"><label for="rules[' . $Qrules->valueInt('weight_class_id') . ']" style="width:20%" class="button grey-gradient glossy">' . $Qrules->value('weight_class_title') . '</label>' . lc_draw_input_field('rules[' . $Qrules->valueInt('weight_class_id') . ']', null, 'class="input-unstyled required number"') . '</span>'; } if (isset($id) && $id != null) { if ($edit === true) { $Qwc = $lC_Database->query('select language_id, weight_class_key, weight_class_title from :table_weight_classes where weight_class_id = :weight_class_id'); $Qwc->bindTable(':table_weight_classes', TABLE_WEIGHT_CLASS); $Qwc->bindInt(':weight_class_id', $id); $Qwc->execute(); $classes_array = array(); while ($Qwc->next()) { $classes_array[$Qwc->valueInt('language_id')] = array('key' => $Qwc->value('weight_class_key'), 'title' => $Qwc->value('weight_class_title')); } foreach ($lC_Language->getAll() as $l) { $result['names'] .= '<span class="input" style="width:75%"><label for="name[' . $l['id'] . ']" class="button silver-gradient glossy">' . $lC_Language->showImage($l['code']) . '</label>' . lc_draw_input_field('name[' . $l['id'] . ']', $classes_array[$l['id']]['title'], 'class="input-unstyled"') . '</span> ' . lc_draw_input_field('key[' . $l['id'] . ']', $classes_array[$l['id']]['key'], 'class="input" size="4"') . '<br />'; } $Qwc->freeResult(); $Qrules = $lC_Database->query('select r.weight_class_to_id, r.weight_class_rule, c.weight_class_title from :table_weight_classes_rules r, :table_weight_classes c where r.weight_class_from_id = :weight_class_from_id and r.weight_class_to_id != :weight_class_to_id and r.weight_class_to_id = c.weight_class_id and c.language_id = :language_id order by c.weight_class_title'); $Qrules->bindTable(':table_weight_classes_rules', TABLE_WEIGHT_CLASS_RULES); $Qrules->bindTable(':table_weight_classes', TABLE_WEIGHT_CLASS); $Qrules->bindInt(':weight_class_from_id', $id); $Qrules->bindInt(':weight_class_to_id', $id); $Qrules->bindInt(':language_id', $lC_Language->getID()); $Qrules->execute(); $result['editRules'] = ''; while ($Qrules->next()) { $result['editRules'] .= '<span class="input full-width"><label for="rules[' . $Qrules->valueInt('weight_class_to_id') . ']" style="width:20%" class="button grey-gradient glossy">' . $Qrules->value('weight_class_title') . '</label>' . lc_draw_input_field('rules[' . $Qrules->valueInt('weight_class_to_id') . ']', $Qrules->value('weight_class_rule'), 'class="input-unstyled required number"') . '</span>'; } } else { $result['wcData'] = lC_Weight_classes_Admin::getData($id); $Qcheck = $lC_Database->query('select count(*) as total from :table_products where products_weight_class = :products_weight_class'); $Qcheck->bindTable(':table_products', TABLE_PRODUCTS); $Qcheck->bindInt(':products_weight_class', $id); $Qcheck->execute(); if ($id == SHIPPING_WEIGHT_UNIT || $Qcheck->valueInt('total') > 0) { if ($id == SHIPPING_WEIGHT_UNIT) { $result['rpcStatus'] = -3; } if ($Qcheck->valueInt('total') > 0) { $result['rpcStatus'] = -2; $result['totalInUse'] = $Qcheck->valueInt('total'); } } } } return $result; }