当前位置: 首页>>代码示例>>PHP>>正文


PHP OrderItem::findCustomerExtras方法代码示例

本文整理汇总了PHP中OrderItem::findCustomerExtras方法的典型用法代码示例。如果您正苦于以下问题:PHP OrderItem::findCustomerExtras方法的具体用法?PHP OrderItem::findCustomerExtras怎么用?PHP OrderItem::findCustomerExtras使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OrderItem的用法示例。


在下文中一共展示了OrderItem::findCustomerExtras方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionOrder

 /**
  * Manages all models.
  */
 public function actionOrder($date = null, $cat = null, $show = 5, $location = null)
 {
     if (!$cat) {
         $cat = SnapUtil::config('boxomatic/supplier_product_feature_category');
     }
     $customerId = Yii::app()->user->user_id;
     $Customer = Customer::model()->findByPk($customerId);
     $deadlineDays = SnapUtil::config('boxomatic/orderDeadlineDays');
     if (!$date) {
         $date = DeliveryDate::getCurrentDeliveryDateId();
     }
     $updatedExtras = array();
     $updatedOrders = array();
     $Category = Category::model()->findByPk($cat);
     $DeliveryDate = DeliveryDate::model()->findByPk($date);
     $AllDeliveryDates = false;
     $pastDeadline = false;
     $CustDeliveryDate = false;
     if ($Customer) {
         $CustDeliveryDate = Order::model()->findByAttributes(array('delivery_date_id' => $date, 'user_id' => $customerId));
         if (!$CustDeliveryDate) {
             $CustDeliveryDate = new Order();
             $CustDeliveryDate->delivery_date_id = $date;
             $CustDeliveryDate->user_id = $customerId;
             $CustDeliveryDate->location_id = $Customer->location_id;
             $CustDeliveryDate->save();
         }
         $AllDeliveryDates = DeliveryDate::model()->with('Locations')->findAll("Locations.location_id = " . $CustDeliveryDate->location_id);
         $deadline = strtotime('+' . $deadlineDays . ' days');
         $pastDeadline = strtotime($DeliveryDate->date) < $deadline;
         if ($pastDeadline) {
             Yii::app()->user->setFlash('warning', 'Order deadline has passed, order cannot be changed.');
         }
     }
     if (!$Customer && (isset($_POST['supplier_purchases']) || isset($_POST['boxes']))) {
         Yii::app()->user->setFlash('error', 'You must register to make an order.');
         $this->redirect(array('site/register'));
     }
     if ($location) {
         $locationId = $location;
         $custLocationId = new CDbExpression('NULL');
         if (strpos($locationId, '-')) {
             //has a customer location
             $parts = explode('-', $locationId);
             $locationId = $parts[1];
             $custLocationId = $parts[0];
         }
         //$Location=Location::model()->findByPk($locationId);
         $CustDeliveryDate->location_id = $locationId;
         $CustDeliveryDate->customer_location_id = $custLocationId;
         $CustDeliveryDate->save();
         $CustDeliveryDate->refresh();
     }
     if (isset($_POST['btn_recurring'])) {
         $monthsAdvance = (int) $_POST['months_advance'];
         $startingFrom = $_POST['starting_from'];
         $every = $_POST['every'];
         $locationId = $_POST['Order']['delivery_location_key'];
         $custLocationId = new CDbExpression('NULL');
         if (strpos($locationId, '-')) {
             //has a customer location
             $parts = explode('-', $locationId);
             $locationId = $parts[1];
             $custLocationId = $parts[0];
         }
         $dayOfWeek = date('N', strtotime($CustDeliveryDate->DeliveryDate->date)) + 1;
         if ($dayOfWeek == 8) {
             $dayOfWeek = 1;
         }
         $orderedExtras = OrderItem::findCustomerExtras($customerId, $date);
         $orderedBoxes = UserBox::model()->with('Box')->findAllByAttributes(array('user_id' => $Customer->user_id), 'delivery_date_id=' . $date);
         $DeliveryDates = DeliveryDate::model()->findAll("\n\t\t\t\t\tdate >= '{$startingFrom}' AND\n\t\t\t\t\tdate <=  DATE_ADD('{$startingFrom}', interval {$monthsAdvance} MONTH) AND\n\t\t\t\t\tdate_sub(date, interval {$deadlineDays} day) > NOW() AND\n\t\t\t\t\tDAYOFWEEK(date) = '" . $dayOfWeek . "'");
         $n = 0;
         foreach ($DeliveryDates as $DD) {
             $CustDD = Order::model()->findByAttributes(array('delivery_date_id' => $DD->id, 'user_id' => $customerId));
             if (!$CustDD) {
                 $CustDD = new Order();
                 $CustDD->delivery_date_id = $DD->id;
                 $CustDD->user_id = $customerId;
                 $CustDD->location_id = $CustDeliveryDate->location_id;
                 $CustDD->save();
             }
             //Delete any extras already ordered
             $TBDExtras = OrderItem::findCustomerExtras($customerId, $DD->id);
             foreach ($TBDExtras as $TBDExtra) {
                 $TBDExtra->delete();
             }
             //Delete any extras already ordered
             $TBDBoxes = UserBox::model()->with('Box')->findAllByAttributes(array('user_id' => $Customer->user_id), 'delivery_date_id=' . $CustDD->delivery_date_id);
             foreach ($TBDBoxes as $TBDBox) {
                 $TBDBox->delete();
             }
             $n++;
             if ($n % 2 == 0 && $every == 'fortnight') {
                 continue;
             }
             //Copy current days order
//.........这里部分代码省略.........
开发者ID:snapfrozen,项目名称:boxomatic,代码行数:101,代码来源:OrderItemController.php


注:本文中的OrderItem::findCustomerExtras方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。