當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Part::get_instock方法代碼示例

本文整理匯總了PHP中Part::get_instock方法的典型用法代碼示例。如果您正苦於以下問題:PHP Part::get_instock方法的具體用法?PHP Part::get_instock怎麽用?PHP Part::get_instock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Part的用法示例。


在下文中一共展示了Part::get_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');
開發者ID:AlexanderS,項目名稱:Part-DB,代碼行數:31,代碼來源:show_order_parts.php

示例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');
            }
開發者ID:AlexanderS,項目名稱:Part-DB,代碼行數:31,代碼來源:show_part_info.php


注:本文中的Part::get_instock方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。