本文整理汇总了PHP中Part::set_instock方法的典型用法代码示例。如果您正苦于以下问题:PHP Part::set_instock方法的具体用法?PHP Part::set_instock怎么用?PHP Part::set_instock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Part
的用法示例。
在下文中一共展示了Part::set_instock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switch
switch ($action) {
case 'apply_changes':
// save new "selected_supplier" + "order_quantity", and delete or change "instock"
for ($i = 0; $i < $table_rowcount; $i++) {
$part_id = isset($_REQUEST['id_' . $i]) ? (int) $_REQUEST['id_' . $i] : 0;
$order_orderdetails_id = isset($_REQUEST['orderdetails_' . $i]) ? (int) $_REQUEST['orderdetails_' . $i] : 0;
$order_quantity = isset($_REQUEST['order_quantity_' . $i]) ? max(0, (int) $_REQUEST['order_quantity_' . $i]) : 0;
try {
$part = new Part($database, $current_user, $log, $part_id);
$part->set_order_orderdetails_id($order_orderdetails_id);
$part->set_order_quantity($order_quantity);
if (isset($_REQUEST['remove_' . $i]) && $part->get_manual_order()) {
$part->set_manual_order(false);
}
if (isset($_REQUEST['tostock_' . $i])) {
$part->set_instock($part->get_instock() + $order_quantity);
}
} catch (Exception $e) {
$messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
}
}
$reload_site = true;
break;
case 'autoset_quantities':
for ($i = 0; $i < $table_rowcount; $i++) {
$part_id = isset($_REQUEST['id_' . $i]) ? (int) $_REQUEST['id_' . $i] : 0;
try {
$part = new Part($database, $current_user, $log, $part_id);
$part->set_order_quantity($part->get_min_order_quantity());
} catch (Exception $e) {
$messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
示例2: catch
$all_orderdetails = $part->get_orderdetails();
} catch (Exception $e) {
$messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
$fatal_error = true;
}
/********************************************************************************
*
* Execute actions
*
*********************************************************************************/
if (!$fatal_error) {
switch ($action) {
case 'dec':
// remove some parts
try {
$part->set_instock($part->get_instock() - abs($n_less));
// reload the site without $_REQUEST['action'] to avoid multiple actions by manual refreshing
header('Location: show_part_info.php?pid=' . $part_id);
} catch (Exception $e) {
$messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
}
break;
case 'inc':
// add some parts
try {
$part->set_instock($part->get_instock() + abs($n_more));
// reload the site without $_REQUEST['action'] to avoid multiple actions by manual refreshing
header('Location: show_part_info.php?pid=' . $part_id);
} catch (Exception $e) {
$messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
}