Execute($orders_sql); return $products_units->fields['products_unit_name']; } /** * Return Orders Status * * @param $products_units_id * @param $language * @return array */ function oos_get_products_units() { $products_units_array = array(); $dbconn =& oosDBGetConn(); $oostable =& oosDBGetTables(); $products_unitstable = $oostable['products_units']; $products_units_sql = "SELECT products_units_id, products_unit_name FROM $products_unitstable WHERE languages_id = '" . intval($_SESSION['language_id']) . "' ORDER BY products_units_id"; $products_units_result = $dbconn->Execute($products_units_sql); while ($products_units = $products_units_result->fields) { $products_units_array[] = array('id' => $products_units['products_units_id'], 'text' => $products_units['products_unit_name']); // Move that ADOdb pointer! $products_units_result->MoveNext(); } return $products_units_array; } $nPage = (!isset($_GET['page']) || !is_numeric($_GET['page'])) ? 1 : intval($_GET['page']); $action = (isset($_GET['action']) ? $_GET['action'] : ''); if (!empty($action)) { switch ($action) { case 'insert': case 'save': $products_units_id = oos_db_prepare_input($_GET['uID']); $languages = oos_get_languages(); for ($i = 0, $n = count($languages); $i < $n; $i++) { $products_unit_name_array = oos_db_prepare_input($_POST['products_unit_name']); $language_id = $languages[$i]['id']; $sql_data_array = array('products_unit_name' => oos_db_prepare_input($products_unit_name_array[$language_id])); if ($action == 'insert') { if (oos_empty($products_units_id)) { $products_unitstable = $oostable['products_units']; $next_id_result = $dbconn->Execute("SELECT max(products_units_id) as products_units_id FROM $products_unitstable"); $next_id = $next_id_result->fields; $products_units_id = $next_id['products_units_id'] + 1; } $insert_sql_data = array('products_units_id' => $products_units_id, 'languages_id' => $language_id); $sql_data_array = array_merge($sql_data_array, $insert_sql_data); oos_db_perform($oostable['products_units'], $sql_data_array); } elseif ($action == 'save') { oos_db_perform($oostable['products_units'], $sql_data_array, 'UPDATE', "products_units_id = '" . intval($products_units_id) . "' AND languages_id = '" . intval($language_id) . "'"); } } if (isset($_POST['default']) && ($_POST['default'] == 'on')) { $configurationtable = $oostable['configuration']; $dbconn->Execute("UPDATE $configurationtable SET configuration_value = '" . intval($products_units_id) . "' WHERE configuration_key = 'DEFAULT_PRODUCTS_UNITS_ID'"); } oos_redirect_admin(oos_href_link_admin($aContents['products_units'], 'page=' . $nPage . '&uID=' . $products_units_id)); break; case 'deleteconfirm': $uID = oos_db_prepare_input($_GET['uID']); $configurationtable = $oostable['configuration']; $products_units_result = $dbconn->Execute("SELECT configuration_value FROM $configurationtable WHERE configuration_key = 'DEFAULT_PRODUCTS_UNITS_ID'"); $products_units = $products_units_result->fields; if ($products_units['configuration_value'] == $uID) { $dbconn->Execute("UPDATE " . $oostable['configuration'] . " SET configuration_value = '' WHERE configuration_key = 'DEFAULT_PRODUCTS_UNITS_ID'"); } $products_unitstable = $oostable['products_units']; $dbconn->Execute("DELETE FROM $products_unitstable WHERE products_units_id = '" . intval($uID) . "'"); oos_redirect_admin(oos_href_link_admin($aContents['products_units'], 'page=' . $nPage)); break; case 'delete': $uID = oos_db_prepare_input($_GET['uID']); $productstable = $oostable['products']; $status_result = $dbconn->Execute("SELECT COUNT(*) AS total FROM $productstable WHERE products_units_id = '" . oos_db_input($uID) . "'"); $status = $status_result->fields; $remove_status = true; if ($uID == DEFAULT_PRODUCTS_UNITS_ID) { $remove_status = false; $messageStack->add(ERROR_REMOVE_DEFAULT_PRODUCTS_UNITS, 'error'); } elseif ($status['total'] > 0) { $remove_status = false; $messageStack->add(ERROR_STATUS_USED_IN_PRODUCTS, 'error'); } break; } } require 'includes/header.php'; ?>

'' . TEXT_INFO_HEADING_NEW_PRODUCTS_UNITS . ''); $contents = array('form' => oos_draw_form('id', 'status', $aContents['products_units'], 'page=' . $nPage . '&action=insert', 'post', FALSE)); $contents[] = array('text' => TEXT_INFO_INSERT_INTRO); $products_units_inputs_string = ''; $languages = oos_get_languages(); for ($i = 0, $n = count($languages); $i < $n; $i++) { $products_units_inputs_string .= '
' . oos_flag_icon($languages[$i]) . ' ' . oos_draw_input_field('products_unit_name[' . $languages[$i]['id'] . ']'); } $contents[] = array('text' => '
' . TEXT_INFO_PRODUCTS_UNITS_NAME . $products_units_inputs_string); $contents[] = array('text' => '
' . oos_draw_checkbox_field('default') . ' ' . TEXT_SET_DEFAULT); $contents[] = array('align' => 'center', 'text' => '
' . oos_submit_button(BUTTON_INSERT) . ' ' . BUTTON_CANCEL . ''); break; case 'edit': $heading[] = array('text' => '' . TEXT_INFO_HEADING_EDIT_PRODUCTS_UNITS . ''); $contents = array('form' => oos_draw_form('id', 'status', $aContents['products_units'], 'page=' . $nPage . '&uID=' . $oInfo->products_units_id . '&action=save', 'post', FALSE)); $contents[] = array('text' => TEXT_INFO_EDIT_INTRO); $products_units_inputs_string = ''; $languages = oos_get_languages(); for ($i = 0, $n = count($languages); $i < $n; $i++) { $products_units_inputs_string .= '
' . oos_flag_icon($languages[$i]) . ' ' . oos_draw_input_field('products_unit_name[' . $languages[$i]['id'] . ']', oos_get_products_units_name($oInfo->products_units_id, $languages[$i]['id'])); } $contents[] = array('text' => '
' . TEXT_INFO_PRODUCTS_UNITS_NAME . $products_units_inputs_string); if (DEFAULT_PRODUCTS_UNITS_ID != $oInfo->products_units_id) $contents[] = array('text' => '
' . oos_draw_checkbox_field('default') . ' ' . TEXT_SET_DEFAULT); $contents[] = array('align' => 'center', 'text' => '
' . oos_submit_button(IMAGE_UPDATE) . ' ' . BUTTON_CANCEL . ''); break; case 'delete': $heading[] = array('text' => '' . TEXT_INFO_HEADING_DELETE_PRODUCTS_UNITS . ''); $contents = array('form' => oos_draw_form('id', 'status', $aContents['products_units'], 'page=' . $nPage . '&uID=' . $oInfo->products_units_id . '&action=deleteconfirm', 'post', FALSE)); $contents[] = array('text' => TEXT_INFO_DELETE_INTRO); $contents[] = array('text' => '
' . $oInfo->products_unit_name . ''); if ($remove_status) $contents[] = array('align' => 'center', 'text' => '
' . oos_submit_button(BUTTON_DELETE) . ' ' . BUTTON_CANCEL . ''); break; default: if (isset($oInfo) && is_object($oInfo)) { $heading[] = array('text' => '' . $oInfo->products_unit_name . ''); $contents[] = array('align' => 'center', 'text' => '' . oos_button(BUTTON_EDIT) . '' . oos_button( BUTTON_DELETE) . ''); $products_units_inputs_string = ''; $languages = oos_get_languages(); for ($i = 0, $n = count($languages); $i < $n; $i++) { $products_units_inputs_string .= '
' . oos_flag_icon($languages[$i]) . ' ' . oos_get_products_units_name($oInfo->products_units_id, $languages[$i]['id']); } $contents[] = array('text' => $products_units_inputs_string); } break; } if ( (oos_is_not_null($heading)) && (oos_is_not_null($contents)) ) { ?>
Execute($products_units_result_raw); while ($products_units = $products_units_result->fields) { if ((!isset($_GET['uID']) || (isset($_GET['uID']) && ($_GET['uID'] == $products_units['products_units_id']))) && !isset($oInfo) && (substr($action, 0, 3) != 'new')) { $oInfo = new objectInfo($products_units); } if (isset($oInfo) && is_object($oInfo) && ($products_units['products_units_id'] == $oInfo->products_units_id)) { echo ' ' . "\n"; } else { echo ' ' . "\n"; } if (DEFAULT_PRODUCTS_UNITS_ID == $products_units['products_units_id']) { echo ' ' . "\n"; } else { echo ' ' . "\n"; } ?> MoveNext(); } ?>
 
' . $products_units['products_unit_name'] . ' (' . TEXT_DEFAULT . ')' . $products_units['products_unit_name'] . 'products_units_id)) { echo ''; } else { echo ''; } ?> 
display_count($products_units_result_numrows, MAX_DISPLAY_SEARCH_RESULTS, $nPage, TEXT_DISPLAY_NUMBER_OF_PRODUCTS_UNITS); ?> display_links($products_units_result_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $nPage); ?>
' . oos_button(BUTTON_INSERT) . ''; ?>
infoBox($heading, $contents); ?>