Exemple #1
0
        $total_cost_value = $row['total_cost'];
        $quantity_value = $row['quantity'];
        $reorder_level_value = $row['reorder_level'];
        $id = $row['id'];
    }
} else {
    $display->displayTitle("{$lang->addItem}");
}
//creates a form object
$f1 = new form('process_form_items.php', 'POST', 'items', '400', $cfg_theme, $lang);
//creates form parts.
$f1->createInputField("<b>{$lang->itemName}:</b> ", 'text', 'item_name', "{$item_name_value}", '24', '160');
$f1->createInputField("{$lang->description}: ", 'text', 'description', "{$description_value}", '24', '160');
$f1->createInputField("{$lang->itemNumber}: ", 'text', 'item_number', "{$item_number_value}", '24', '160');
$brandtable = "{$cfg_tableprefix}" . 'brands';
$brand_option_titles = $dbf->getAllElements("{$brandtable}", 'brand', 'brand');
$brand_option_titles[0] = $dbf->idToField("{$brandtable}", 'brand', "{$brand_id_value}");
$brand_option_values = $dbf->getAllElements("{$brandtable}", 'id', 'brand');
$brand_option_values[0] = $brand_id_value;
$f1->createSelectField("<b>{$lang->brand}:</b>", 'brand_id', $brand_option_values, $brand_option_titles, '160');
$categorytable = "{$cfg_tableprefix}" . 'categories';
$category_option_titles = $dbf->getAllElements("{$categorytable}", 'category', 'category');
$category_option_titles[0] = $dbf->idToField("{$categorytable}", 'category', "{$category_id_value}");
$category_option_values = $dbf->getAllElements("{$categorytable}", 'id', 'category');
$category_option_values[0] = $category_id_value;
$f1->createSelectField("<b>{$lang->category}:</b>", 'category_id', $category_option_values, $category_option_titles, '160');
$suppliertable = "{$cfg_tableprefix}" . 'suppliers';
$supplier_option_titles = $dbf->getAllElements("{$suppliertable}", 'supplier', 'supplier');
$supplier_option_titles[0] = $dbf->idToField("{$suppliertable}", 'supplier', "{$supplier_id_value}");
$supplier_option_values = $dbf->getAllElements("{$suppliertable}", 'id', 'supplier');
$supplier_option_values[0] = $supplier_id_value;
        $id = $_GET['id'];
        $tablename = "{$cfg_tableprefix}" . 'discounts';
        $result = mysql_query("SELECT * FROM {$tablename} WHERE id=\"{$id}\"", $dbf->conn);
        $row = mysql_fetch_assoc($result);
        $item_id_value = $row['item_id'];
        $percent_off_value = $row['percent_off'];
        $comment_value = $row['comment'];
    }
} else {
    $display->displayTitle("{$lang->addDiscount}");
}
//creates a form object
$f1 = new form('process_form_discounts.php', 'POST', 'discounts', '300', $cfg_theme, $lang);
//creates form parts.
$itemtable = "{$cfg_tableprefix}" . 'items';
$item_option_titles = $dbf->getAllElements("{$itemtable}", 'item_name', 'item_name');
$item_option_titles[0] = $dbf->idToField("{$itemtable}", 'item_name', "{$item_id_value}");
$item_option_values = $dbf->getAllElements("{$itemtable}", 'id', 'item_name');
$item_option_values[0] = $item_id_value;
$f1->createSelectField("<b>{$lang->itemName}:</b>", 'item_id', $item_option_values, $item_option_titles, '160');
$f1->createInputField("<b>{$lang->percentOff}: (%)</b> ", 'text', 'percent_off', "{$percent_off_value}", '24', '150');
$f1->createInputField("{$lang->comment}: ", 'text', 'comment', "{$comment_value}", '24', '150');
//sends 2 hidden varibles needed for process_form_discounts.php.
echo "\t\t\n\t\t<input type='hidden' name='action' value='{$action}'>\n\t\t<input type='hidden' name='id' value='{$id}'>";
$f1->endForm();
$dbf->closeDBlink();
?>
</body>
</html>