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


PHP Model_Order::reset方法代碼示例

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


在下文中一共展示了Model_Order::reset方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: saveEnrol

 protected function saveEnrol($iAccountId, $iUserId, $aMeals, $sDayEnd)
 {
     $aMealIdsAll = array();
     // get submited meals id
     for ($i = 0; $i < 7; $i++) {
         if (isset($_POST['day' . $i])) {
             $aMealIdsAll = array_merge($aMealIdsAll, $_POST['day' . $i]);
         }
     }
     // wyszukujemy zamowienia
     $aOrderedMeals = array();
     $aOrderIndex = array();
     $oOrder = new Model_Order();
     $oCourse = new Model_Course();
     $iIndex = 0;
     $sDate = '';
     // rozpoczynamy transakcje
     $oOrder->transaction(true);
     // iterujemy po posilkach w danym tyg.
     foreach ($aMeals as $iMealId => $aMeal) {
         // sprawdzamy czy data nie jest starsza niz obecna
         if (strtotime($aMeal['date'] . ' ' . $sDayEnd) < time()) {
             continue;
         }
         // sprawdzamy czy zmieniono danie na obecny dzien
         if ($aMeal['date'] == date('Y-m-d')) {
             // czyscimy tekst paska informacyjnego
             $this->oCurrentUser->propertie('aMealName', '');
         }
         // zmieniamy na kolejny dzien index tablicy $aMealIds
         if ($sDate != $aMeal['date']) {
             // czyscimy zapisy na wszystkie dania tego dnia
             $oOrder->removeEnrols($iAccountId, $iUserId, $aMeal['date']);
             $sDate = $aMeal['date'];
             $iIndex++;
         }
         // sprawdzamy czy posilek z danego tyg zostal wybrany przez uzytkownika
         if (in_array($iMealId, $aMealIdsAll)) {
             // zapisujemy nowy
             $oOrder->reset();
             $oOrder->date = $aMeal['date'];
             $oOrder->user_id = (int) $this->oCurrentUser->user_id;
             $oOrder->meal_id = (int) $iMealId;
             $oOrder->price = (double) $aMeal['price'];
             $oOrder->account_id = (int) $this->oCurrentUser->account_id;
             if (!$oOrder->save()) {
                 throw new Lithium_Exception('catering.saving_failed');
             }
             // sprawdzamy ilosc zamowien na ten dzien
             $iCount = $oOrder->countOrders((int) $this->oCurrentUser->user_id, $aMeal['date']);
             if ($iCount > 1) {
                 $aOrders = $oOrder->getOrdersForDiscount((int) $this->oCurrentUser->user_id, $aMeal['date']);
                 foreach ($aOrders as $aOrder) {
                     $aOrder['discount'] = (int) $aOrder['discount'];
                     // gdy znizka rowna 0 nie ma co przeliczac
                     if ($aOrder['discount']) {
                         $oOrder->reset();
                         $oOrder->order_id = $aOrder['order_id'];
                         $oOrder->price = round($aOrder['price'] * $aOrder['discount'] / 100, 2);
                         if (!$oOrder->save()) {
                             //								throw new Lithium_Exception( 'catering.saving_failed' );
                         }
                     }
                 }
             }
         }
     }
     if (!$oOrder->transaction()) {
         throw new Lithium_Exception('save_meals_failed');
     }
     $aMeta = $this->mTemplate->aMeta;
     $aMeta[] = '<meta http-equiv="refresh" content="1;url=' . $this->mTemplate->anchor() . '" />';
     $this->mTemplate->aMeta = $aMeta;
     $this->mTemplate->content = $this->getLang('save_meals_successfully');
 }
開發者ID:maxwroc,項目名稱:PHP,代碼行數:75,代碼來源:Catering.php

示例2: saveOrders

 protected function saveOrders($iAccountId, $iUserId, $aMeals)
 {
     $aMealIdsAll = array();
     // get submited meals id
     for ($i = 0; $i < 7; $i++) {
         if (isset($_POST['day' . $i])) {
             $aMealIdsAll = array_merge($aMealIdsAll, $_POST['day' . $i]);
         }
     }
     // wyszukujemy zamowienia
     $aOrderedMeals = array();
     $aOrderIndex = array();
     $oOrder = new Model_Order();
     $oCourse = new Model_Course();
     $iIndex = 0;
     $sDate = '';
     // rozpoczynamy transakcje
     $oOrder->transaction(true);
     // iterujemy po posilkach w danym tyg.
     foreach ($aMeals as $iMealId => $aMeal) {
         // zmieniamy na kolejny dzien index tablicy $aMealIds
         if ($sDate != $aMeal['date']) {
             // czyscimy zapisy na wszystkie dania tego dnia
             $oOrder->removeEnrols($iAccountId, $iUserId, $aMeal['date']);
             $sDate = $aMeal['date'];
             $iIndex++;
         }
         // sprawdzamy czy posilek z danego tyg zostal wybrany przez uzytkownika
         if (in_array($iMealId, $aMealIdsAll)) {
             // zapisujemy nowy
             $oOrder->reset();
             $oOrder->date = $aMeal['date'];
             $oOrder->user_id = (int) $iUserId;
             $oOrder->meal_id = (int) $iMealId;
             $oOrder->price = (double) $aMeal['price'];
             $oOrder->account_id = (int) $iAccountId;
             if (!$oOrder->save()) {
                 throw new Lithium_Exception('Catering.saving_failed');
             }
             // sprawdzamy ilosc zamowien na ten dzien
             $iCount = $oOrder->countOrders((int) $iUserId, $aMeal['date']);
             if ($iCount > 1) {
                 $aOrders = $oOrder->getOrdersForDiscount((int) $iUserId, $aMeal['date']);
                 foreach ($aOrders as $aOrder) {
                     $aOrder['discount'] = (int) $aOrder['discount'];
                     // gdy znizka rowna 0 nie ma co przeliczac
                     if ($aOrder['discount']) {
                         $oOrder->reset();
                         $oOrder->order_id = $aOrder['order_id'];
                         $oOrder->price = round($aOrder['price'] * $aOrder['discount'] / 100, 2);
                         if (!$oOrder->save()) {
                             //								throw new Lithium_Exception( 'catering.saving_failed' );
                         }
                     }
                 }
             }
         }
     }
     if (!$oOrder->transaction()) {
         if (IN_PRODUCTION) {
             return false;
         } else {
             throw new Lithium_Exception('catering.saving_failed');
         }
     }
     return true;
 }
開發者ID:maxwroc,項目名稱:PHP,代碼行數:67,代碼來源:Account.php


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