/**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = DeliveryAddress::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #2
0
<?php 
if ($model->isNewRecord || $model->isDraft() || $model->isHaulerNeeded()) {
    echo $form->hiddenField($model, 'status_id', ['value' => Order::STATUS_HAULER_NEEDED]);
}
?>

<?php 
echo $form->dropDownListGroup($model, 'supplier_id', ['widgetOptions' => ['data' => Supplier::getList(), 'htmlOptions' => ['class' => 'span5', 'maxlength' => 9, 'ajax' => ['type' => 'POST', 'url' => ['getLoadingAddressList'], 'update' => '#Order_loading_id', 'error' => "function(data){\n                    \$('#Order_loading_id').empty().html('<option value=\"\">Select supplier address</option>');\n                }"], 'empty' => 'Select supplier company']]]);
?>

<?php 
echo $form->dropDownListGroup($model, 'loading_id', ['widgetOptions' => ['data' => [], 'htmlOptions' => ['class' => 'span5', 'maxlength' => 9, 'empty' => 'Select supplier address']]]);
?>

<?php 
echo $form->dropDownListGroup($model, 'delivery_id', ['widgetOptions' => ['data' => DeliveryAddress::getList(), 'htmlOptions' => ['class' => 'span5', 'maxlength' => 9, 'empty' => 'Select delivery address']]]);
?>

<?php 
echo $form->dropDownListGroup($model, 'currency_id', ['widgetOptions' => ['data' => Currency::getList(), 'htmlOptions' => ['class' => 'span5', 'empty' => 'Select currency']]]);
?>

<?php 
echo $form->dropDownListGroup($model, 'temperature_id', ['widgetOptions' => ['data' => Temperature::getList(), 'htmlOptions' => ['class' => 'span5', 'empty' => 'Select temperature']]]);
?>

<?php 
echo $form->datePickerGroup($model, 'valid_date', ['widgetOptions' => ['options' => ['format' => 'yyyy-mm-dd', 'startDate' => '0d', 'autoclose' => true], 'htmlOptions' => ['class' => 'span5', 'placeholder' => 'Select date']]]);
?>

<?php 
Example #3
0
 public function actionConfirm()
 {
     Yii::app()->user->setState('order_comment', @$_POST['Order']['Comment']);
     if (isset($_POST['accept_terms']) && $_POST['accept_terms'] == 1) {
         $order = new Order();
         $customer = Shop::getCustomer();
         $cart = Shop::getCartContent();
         $order->customer_id = $customer->customer_id;
         $address = new DeliveryAddress();
         if ($customer->deliveryAddress) {
             $address->attributes = $customer->deliveryAddress->attributes;
         } else {
             $address->attributes = $customer->address->attributes;
         }
         $address->save();
         $order->delivery_address_id = $address->id;
         $address = new BillingAddress();
         if ($customer->billingAddress) {
             $address->attributes = $customer->billingAddress->attributes;
         } else {
             $address->attributes = $customer->address->attributes;
         }
         $address->save();
         $order->billing_address_id = $address->id;
         $order->ordering_date = time();
         $order->payment_method = Yii::app()->user->getState('payment_method');
         $order->shipping_method = Yii::app()->user->getState('shipping_method');
         $order->comment = Yii::app()->user->getState('order_comment');
         $order->status = 'new';
         if ($order->save()) {
             foreach ($cart as $position => $product) {
                 $position = new OrderPosition();
                 $position->order_id = $order->order_id;
                 $position->product_id = $product['product_id'];
                 $position->amount = $product['amount'];
                 $position->specifications = json_encode($product['Variations']);
                 $position->save();
             }
             Shop::mailNotification($order);
             Shop::flushCart(true);
             if (Shop::module()->payPalMethod !== false && $order->payment_method == Shop::module()->payPalMethod) {
                 $this->redirect(array(Shop::module()->payPalUrl, 'order_id' => $order->order_id));
             } else {
                 $this->redirect(Shop::module()->successAction);
             }
         }
         $this->redirect(Shop::module()->failureAction);
     } else {
         Shop::setFlash(Shop::t('Please accept our Terms and Conditions to continue'));
         $this->redirect(array('//shop/order/create'));
     }
 }