/**
  * Generate Reports
  */
 public function actionCreditReport()
 {
     $xAxis = array();
     $yAxis = array();
     $series = array();
     $xAxisName = '';
     $yAxisName = '';
     $tablePrefix = SnapUtil::config('boxomatic/tablePrefix');
     $sql = "SELECT MIN(payment_date) FROM {$tablePrefix}user_payments WHERE payment_date != '00-00-00 00:00:00'";
     $connection = Yii::app()->db;
     $minDate = $connection->createCommand($sql)->queryScalar();
     $paymentTotals = array();
     $days = 0;
     $timestamp = 0;
     while ($timestamp < time()) {
         $timestamp = strtotime("+ {$days} days", strtotime($minDate));
         $timestampJs = $timestamp * 1000;
         $minDate = date('Y-m-d h:i:s', $timestamp);
         $sql = "SELECT SUM(payment_value) as total\n\t\t\t\tFROM {$tablePrefix}user_payments\n\t\t\t\tWHERE payment_date < '{$minDate}'";
         $row = $connection->createCommand($sql)->queryRow();
         $paymentTotals[] = array($timestampJs, $row['total']);
         $days += 7;
     }
     $series[] = array('name' => $minDate, 'data' => $paymentTotals);
     $yAxis = array('title' => array('text' => 'Total payments'));
     //print_r($series);
     //print_r($series2);
     $this->render('reports_credit', array('xAxis' => $xAxis, 'yAxis' => $yAxis, 'xAxisName' => $xAxisName, 'yAxisName' => $yAxisName, 'series' => $series));
 }
 /**
  * Send reminder emails to those who haven't paid for their next week's box
  */
 public function actionSendReminderEmails()
 {
     $Customers = Customer::model()->findAllWithNoOrders();
     foreach ($Customers as $Cust) {
         $validator = new CEmailValidator();
         if ($validator->validateValue(trim($Cust->User->email))) {
             $User = $Cust->User;
             $User->auto_login_key = $User->generatePassword(50, 4);
             $User->update_time = new CDbExpression('NOW()');
             $User->update();
             $adminEmail = SnapUtil::config('boxomatic/adminEmail');
             $adminEmailFromName = SnapUtil::config('boxomatic/adminEmailFromName');
             $message = new YiiMailMessage('Running out of orders');
             $message->view = 'customer_running_out_of_orders';
             $message->setBody(array('Customer' => $Cust, 'User' => $User), 'text/html');
             $message->addTo($Cust->User->email);
             $message->addBcc($adminEmail);
             //$message->addTo('*****@*****.**');
             $message->setFrom(array($adminEmail => $adminEmailFromName));
             if (!@Yii::app()->mail->send($message)) {
                 echo '<p style="color:red"><strong>Email failed sending to: ' . $Cust->User->email . '</strong></p>';
             } else {
                 echo '<p>Running out of orders message sent to: ' . $Cust->User->email . '</p>';
             }
         } else {
             echo '<p style="color:red"><strong>Email not valid: "' . $Cust->User->email . '"</strong></p>';
         }
     }
     echo '<p><strong>Finished.</strong></p>';
     //Yii::app()->end();
 }
Beispiel #3
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id = null)
 {
     if (!$id) {
         $id = SnapUtil::config('general/site.default_menu');
     }
     $model = $this->loadModel($id);
     if (isset($_POST['Menu'])) {
         $model->attributes = $_POST['Menu'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('update', array('model' => $model));
 }
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $homeId = SnapUtil::config('general/site.homepage_id');
     $Content = Content::model()->findByPk($homeId);
     //Used by the admin bar
     $this->Content = $Content;
     $this->layout = '//layouts/column1';
     $view = '/content/view';
     if ($this->getLayoutFile('//layouts/content_types/' . $Content->type)) {
         $this->layout = '//layouts/content_types/' . $Content->type;
     }
     if ($this->getViewFile('/content/content_types/' . $Content->type)) {
         $view = '/content/content_types/' . $Content->type;
     }
     $News = Content::model()->findAllByAttributes(array('type' => 'news'), array('limit' => 4, 'order' => 'created DESC', 'condition' => '(publish_on < NOW() OR publish_on is null) AND ' . '(unpublish_on < NOW() OR unpublish_on is null) AND ' . 'published = 1'));
     $this->render($view, array('Content' => $Content, 'News' => $News, 'MenuItem' => false));
 }
Beispiel #5
0
 public function extrasSearch($date)
 {
     $tablePrefix = SnapUtil::config('boxomatic/tablePrefix');
     $c = new CDbCriteria();
     $c->addCondition('t.delivery_date_id = :date');
     $c->select = 't.user_id, GROUP_CONCAT(oi.name SEPARATOR ", ") as extras_item_names, t.delivery_date_id, t.status, t.location_id, t.customer_location_id, t.id';
     $c->params = array(':date' => $date);
     //$c->with doesn't work very well with CActiveDataProvider
     $c->join = "INNER JOIN {$tablePrefix}order_items oi ON oi.order_id = t.id";
     $c->group = 't.user_id';
     $c->compare('CONCAT(u.first_name, u.last_name)', $this->search_full_name, true);
     $c->compare('status', $this->status);
     $c->compare('oi.name', $this->extras_item_names, true);
     if (!empty($this->search_full_name)) {
         $c->join = 'INNER JOIN order_items oi ON oi.order_id = t.id ' . 'INNER JOIN users u ON u.id = t.user_id';
         $c->compare('CONCAT(u.first_name, u.last_name)', $this->search_full_name, true);
     }
     return new CActiveDataProvider($this, array('criteria' => $c));
 }
Beispiel #6
0
<?php

$baseUrl = $this->createFrontendUrl('/') . '/themes/boxomatic/admin';
$cs = Yii::app()->clientScript;
$cs->registerScriptFile('https://maps.googleapis.com/maps/api/js?key=' . SnapUtil::config('boxomatic/googleMapKey') . '&sensor=false', CClientScript::POS_END);
$cs->registerScriptFile($baseUrl . '/js/pages/supplier/map.js', CClientScript::POS_END);
$default_latlong = '0.000000000000';
$this->breadcrumbs = array('Box-O-Matic' => array('/snapcms/boxomatic/index'), 'Suppliers' => array('supplier/admin'), 'Supplier Map');
$this->menu = array();
$this->page_heading = 'Suppiler';
$this->page_heading_subtext = 'Map';
?>
<script>
	var defaultCoordinate = '<?php 
echo $default_latlong;
?>
';
	var suppliers = <?php 
echo json_encode($Suppliers);
?>
;
</script>

<?php 
$this->renderPartial('_search', array('model' => $model));
?>
<p>&nbsp;</p>
<div class="row">
	<div class="col-md-9">
		<?php 
$this->beginWidget('bootstrap.widgets.BsPanel', array('title' => 'Suppliers', 'titleTag' => 'h3'));
Beispiel #7
0
 /**
  * @return array relational rules.
  */
 public function relations()
 {
     // NOTE: you may need to adjust the relation name and the related
     // class name for the relations automatically generated below.
     return array('Users' => array(self::MANY_MANY, 'BoxomaticUser', SnapUtil::config('boxomatic/tablePrefix') . 'user_tags(tag_id, user_id)'));
 }
 /**
  * @author Chienlv levanchien.it@gmail.com
  * @todo action process payment, support Paypal and Pin
  */
 public function actionProcess()
 {
     $data = isset($_POST) ? $_POST : false;
     if ($data) {
         #{
         switch ($data['payment-method']) {
             /**
              * @todo Default is Paypal
              * @link http://stackoverflow.com/questions/14843212/submit-form-via-curl-and-redirect-browser-to-paypal tutoria
              */
             default:
             case 0:
                 #Delete $ data ['payment-method'] because it is not for paypal
                 unset($data['payment-method']);
                 #The variable $data obtained from the form sent to
                 header('Location: https://www.paypal.com/cgi-bin/webscr?' . http_build_query($data));
                 break;
                 /**
                  * @todo use Pin paymant
                  * Cac tham so gui tu from
                  * validate email? @toantv
                  */
             /**
              * @todo use Pin paymant
              * Cac tham so gui tu from
              * validate email? @toantv
              */
             case 1:
                 $model = new PinPaymentForm();
                 if (isset($_POST['PinPaymentForm'])) {
                     $model->attributes = $_POST['PinPaymentForm'];
                     if ($model->validate()) {
                         $reponse = $model->pinPayMent();
                         if (isset($reponse['error'])) {
                             Yii::app()->user->setFlash('errors', $reponse);
                         } elseif (isset($reponse['response'])) {
                             $model_pay = new UserPayment();
                             $model_pay->payment_date = new CDbExpression('NOW()');
                             $model_pay->payment_type = 'CREDIT-PIN';
                             $model_pay->payment_value = number_format($reponse['response']['amount'] / 100, 2);
                             $model_pay->user_id = Yii::app()->user->id;
                             $model_pay->staff_id = null;
                             $model_pay->payment_note = $reponse['response']['token'];
                             $model_pay->save();
                             $BoxoCart = new BoxoCart();
                             $BoxoCart->confirmOrder();
                             $this->redirect(array('user/payments'));
                         }
                     }
                 }
                 $this->render('_pin', array('model' => $model, 'paymentMethod' => $data['payment-method'], 'amount' => $data['amount']));
                 break;
                 /**
                  * @todo Bank Transfer
                  */
             /**
              * @todo Bank Transfer
              */
             case 2:
                 //Send email
                 $adminEmail = SnapUtil::config('boxomatic/adminEmail');
                 $adminEmailFromName = SnapUtil::config('boxomatic/adminEmailFromName');
                 $message = new YiiMailMessage('Transfer information of ' . Yii::app()->name);
                 $message->view = 'bank_transfer';
                 $message->setBody($data, 'text/html');
                 $message->addTo($adminEmail);
                 $message->addTo($data['email']);
                 $message->setFrom(array($adminEmail => $adminEmailFromName));
                 if (Yii::app()->mail->send($message)) {
                     $BoxoCart = new BoxoCart();
                     $BoxoCart->confirmOrder();
                 }
                 $this->render('_bank_transfer', array('data' => $data));
                 break;
         }
     }
 }
Beispiel #9
0
 /**
  * @return array relational rules.
  */
 public function relations()
 {
     // NOTE: you may need to adjust the relation name and the related
     // class name for the relations automatically generated below.
     return array('parent' => array(self::BELONGS_TO, 'Category', 'parent'), 'children' => array(self::HAS_MANY, 'Category', 'parent', 'order' => 'name'), 'SupplierProducts' => array(self::MANY_MANY, 'SupplierProduct', SnapUtil::config('boxomatic/tablePrefix') . 'supplier_product_categories(supplier_product_id,category_id)'));
 }
Beispiel #10
0
                                        <?php 
        if (!empty($BoxItemsContent->supplier_product_id)) {
            echo CHtml::value($BoxItemsContent, 'SupplierProduct.PackingStation.name');
            echo CHtml::hiddenField('bc[' . $key . '][packing_station_id]', CHtml::value($BoxItemsContent, 'SupplierProduct.packing_station_id'));
        } else {
            echo CHtml::dropDownList('bc[' . $key . '][packing_station_id]', CHtml::value($BoxItemsContent, 'SupplierProduct.packing_station_id'), CHtml::listData(PackingStation::model()->findAll(), 'id', 'name'));
        }
        ?>
                                    </td>
                                    <td class="itemValue">
                                    <?php 
        echo CHtml::textField('bc[' . $key . '][item_value]', $BoxItemsContent->item_value, array('class' => 'currency'));
        ?>
 
                                    <?php 
        echo CHtml::dropDownList('bc[' . $key . '][item_unit]', $BoxItemsContent->item_unit, SnapUtil::config('boxomatic/itemUnits'));
        ?>
                                    </td>
                                    <?php 
        $key2 = 0;
        foreach ($DeliveryDateBoxes as $DeliveryDateBoxMerged) {
            $dateBoxIds = explode(',', $DeliveryDateBoxMerged->box_ids);
            foreach ($dateBoxIds as $dateBoxId) {
                $Box = Box::model()->findByPk($dateBoxId);
                $BoxItem = BoxItem::model()->with('Box')->find('item_name=:itemName AND 
										supplier_id=:supplierId AND 
										item_unit=:itemUnit AND 
										item_value=:itemValue AND 
										Box.delivery_date_id=:dateId AND 
										Box.size_id=:sizeId AND
										t.box_id = ' . $Box->box_id, array(':itemName' => $BoxItemsContent->item_name, ':supplierId' => $BoxItemsContent->supplier_id, ':itemUnit' => $BoxItemsContent->item_unit, ':itemValue' => $BoxItemsContent->item_value, ':dateId' => $Box->delivery_date_id, ':sizeId' => $Box->size_id));
Beispiel #11
0
<?php

$cs = Yii::app()->clientScript;
$baseUrl = Yii::app()->baseUrl;
$themeUrl = $baseUrl . Yii::app()->theme->baseUrl;
$Paypal = Yii::app()->getModule('payPal');
$minDays = SnapUtil::config('boxomatic/minimumAdvancePayment');
?>

<div class="row">
    <div class="col-md-8 col-md-offset-2 products order">
        <div class="page-header">
            <h1>Past Orders</h1>
        </div>

        <div id="checkout-cart" class="items list-view panel-group">
            <?php 
/* @todo: get Order objects instead $BoxoCart->getOrders() */
foreach ($Orders as $Order) {
    $DD = $Order->DeliveryDate;
    $Location = $Order->Location;
    ?>
            <div class="panel panel-default">
                <a class="panel-heading" data-toggle="collapse" data-parent="#checkout-cart" href="#collapse-<?php 
    echo $DD->id;
    ?>
">
                    <h3>
                        <?php 
    echo SnapFormat::date($DD->date, 'full');
    ?>
 /**
  * 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
             foreach ($orderedExtras as $orderedExt) {
                 $extra = new OrderItem();
                 //give the customer the extra
                 $extra->quantity = $orderedExt->quantity;
                 $extra->order_id = $CustDD->id;
                 $extra->supplier_purchase_id = $orderedExt->supplier_purchase_id;
                 $extra->price = $orderedExt->price;
                 $extra->packing_station_id = $orderedExt->packing_station_id;
                 $extra->name = $orderedExt->name;
                 $extra->unit = $orderedExt->unit;
                 $extra->save();
             }
             //Copy current days boxxes
             foreach ($orderedBoxes as $orderedBox) {
                 $EquivBox = Box::model()->findByAttributes(array('size_id' => $orderedBox->Box->size_id, 'delivery_date_id' => $DD->id));
                 $box = new UserBox();
                 $box->attributes = $orderedBox->attributes;
                 $box->user_box_id = null;
                 $box->box_id = $EquivBox->box_id;
                 $box->save();
             }
         }
         Yii::app()->user->setFlash('success', 'Recurring order set.');
     }
     if (isset($_POST['btn_clear_orders'])) {
         $orderedExtras = OrderItem::model()->with(array('Order' => array('with' => 'DeliveryDate')))->findAll("DATE_SUB(date, INTERVAL {$deadlineDays} DAY) > NOW() AND user_id = " . $Customer->user_id);
         foreach ($orderedExtras as $ext) {
             $ext->delete();
         }
         //Get all boxes beyond the deadline date
         $Boxes = Box::model()->with('DeliveryDate')->findAll("DATE_SUB(date, interval {$deadlineDays} day) > NOW()");
         foreach ($Boxes as $Box) {
             $CustBox = UserBox::model()->findByAttributes(array('user_id' => $Customer->user_id, 'box_id' => $Box->box_id));
             if ($CustBox) {
                 $CustBox->delete();
             }
         }
     }
     if (isset($_POST['extras'])) {
         foreach ($_POST['extras'] as $id => $quantity) {
             $model = $this->loadModel($id);
             if ($model->Order->user_id == Yii::app()->user->user_id) {
                 if ($quantity == 0) {
                     $model->delete();
                 } else {
                     $model->quantity = $quantity;
                     $model->save();
                     $updatedOrders[$model->id] = $model;
                 }
             }
         }
     }
     if (isset($_POST['supplier_purchases'])) {
         foreach ($_POST['supplier_purchases'] as $purchaseId => $quantity) {
             if ($quantity == 0) {
                 continue;
             }
             $extra = OrderItem::model()->with('Order')->findByAttributes(array('supplier_purchase_id' => $purchaseId, 'order_id' => $CustDeliveryDate->id));
             if (!$extra) {
                 $extra = new OrderItem();
             }
             $Purchase = SupplierPurchase::model()->findByPk($purchaseId);
             $SupplierProduct = $Purchase->supplierProduct;
             //give the customer the extra
             $extra->quantity += $quantity;
             $extra->order_id = $CustDeliveryDate->id;
             $extra->supplier_purchase_id = $purchaseId;
             $extra->price = $Purchase->item_sales_price;
             $extra->packing_station_id = $SupplierProduct->packing_station_id;
             $extra->name = $SupplierProduct->name;
             $extra->unit = $SupplierProduct->unit;
             $updatedExtras[$extra->supplier_purchase_id] = $extra;
             $extra->save();
         }
     }
     if (isset($_POST['boxes'])) {
         foreach ($_POST['boxes'] as $boxId => $quantity) {
             $Box = Box::model()->findByPk($boxId);
             $CustBoxes = UserBox::model()->with('Box')->findAll(array('condition' => 'user_id=:customerId AND size_id=:sizeId AND delivery_date_id=:deliveryDateId', 'params' => array(':customerId' => $customerId, ':sizeId' => $Box->size_id, ':deliveryDateId' => $Box->delivery_date_id)));
             $curQuantity = count($CustBoxes);
             $diff = $quantity - $curQuantity;
             if ($diff > 0) {
                 //Create extra customer box rows
                 for ($i = 0; $i < $diff; $i++) {
                     $CustBox = new UserBox();
                     $CustBox->user_id = $customerId;
                     $CustBox->box_id = $boxId;
                     $CustBox->quantity = 1;
                     $CustBox->delivery_cost = $Customer->Location->location_delivery_value;
                     $CustBox->save();
                 }
             }
             if ($diff < 0) {
                 //Remove any boxes the customer no longer wants;
                 $diff = abs($diff);
                 for ($i = 0; $i < $diff; $i++) {
                     $CustBoxes[$i]->delete();
                 }
             }
         }
     }
     $orderedExtras = OrderItem::findCustomerExtras($customerId, $date);
     $dpOrderedExtras = new CActiveDataProvider('OrderItem');
     $dpOrderedExtras->setData($orderedExtras);
     $DeliveryDates = DeliveryDate::model()->with('Boxes')->findAll(array('condition' => 'DATE_SUB(date, INTERVAL -1 week) > NOW() AND date < DATE_ADD(NOW(), INTERVAL 1 MONTH)'));
     $this->render('order', array('pastDeadline' => $pastDeadline, 'orderedExtras' => $dpOrderedExtras, 'updatedExtras' => $updatedExtras, 'updatedOrders' => $updatedOrders, 'DeliveryDate' => $DeliveryDate, 'DeliveryDates' => $DeliveryDates, 'AllDeliveryDates' => $AllDeliveryDates, 'model' => new OrderItem(), 'Category' => $Category, 'Customer' => $Customer, 'CustDeliveryDate' => $CustDeliveryDate, 'curCat' => $cat));
 }
Beispiel #13
0
 /**
  * Get the deadline for this date
  */
 public function getDeadline()
 {
     $deadlineDays = SnapUtil::config('boxomatic/orderDeadlineDays');
     $deliveryDate = strtotime($this->date);
     return date('d-m-Y', strtotime('-' . $deadlineDays . ' days', $deliveryDate));
 }
Beispiel #14
0
 public static function getMenuItemClassName()
 {
     $className = 'MenuItem';
     try {
         $className = SnapUtil::config('general/models.MenuItem.class');
     } catch (CException $e) {
     }
     return $className;
 }
<?php

return array('varchar(%)' => 'TextField', 'text' => array('widget' => array('class' => 'vendor.ckeditorwidget.TheCKEditorWidget', 'settings' => SnapUtil::config('content.ckeditor/default'))), 'datetime' => array('widget' => array('class' => 'zii.widgets.jui.CJuiDatePicker', 'settings' => array())), 'string' => array('fieldType' => 'TextFieldControlGroup'));
    /**
     * Generate a packing list spreadsheet for a given date_id 
     */
    public function actionGenerateOrderList($date)
    {
        $tablePrefix = SnapUtil::config('boxomatic/tablePrefix');
        $sql = '
		SELECT 
			SUM(item_quantity) as total,
			SUM(item_quantity * item_value) as total_price,
			item_value,
			
			GROUP_CONCAT(DISTINCT t.box_id ORDER BY t.box_id DESC) AS box_ids,
			GROUP_CONCAT(DISTINCT `box_item_id` ORDER BY `BoxItems`.box_id DESC) as box_item_ids,
			
			`BoxItems`.`box_item_id`,
			`BoxItems`.`item_name`,
			`BoxItems`.`item_unit`,
			`Supplier`.`name`
			
		FROM `' . $tablePrefix . 'boxes` `t`  

		LEFT OUTER JOIN `' . $tablePrefix . 'user_boxes` `UserBoxes` 
			ON (`UserBoxes`.`box_id`=`t`.`box_id`)
		LEFT OUTER JOIN `' . $tablePrefix . 'box_items` `BoxItems` 
			ON (`BoxItems`.`box_id`=`t`.`box_id`)  
		LEFT OUTER JOIN `' . $tablePrefix . 'suppliers` `Supplier` 
			ON (`BoxItems`.`supplier_id`=`Supplier`.`id`)  

		WHERE (
			delivery_date_id=' . $date . ' 
			AND user_box_id is not null
			AND 
			(
				UserBoxes.status=' . UserBox::STATUS_APPROVED . ' OR
				UserBoxes.status=' . UserBox::STATUS_DELIVERED . '
			)
		) 

		GROUP BY name,item_name 
		ORDER BY name;
		';
        $connection = Yii::app()->db;
        $command = $connection->createCommand($sql);
        $dataReader = $command->query();
        $items = $dataReader->readAll();
        if (empty($items)) {
            echo 'No customer orders!';
            exit;
        }
        $phpExcelPath = Yii::getPathOfAlias('boxomatic.external.PHPExcel');
        $DateBoxes = Box::model()->with('BoxSize')->findAll(array('condition' => 'delivery_date_id = ' . $date, 'order' => 'box_size_name DESC'));
        //disable Yii's Autoload because it messes with PHPExcel's autoloader
        spl_autoload_unregister(array('YiiBase', 'autoload'));
        include $phpExcelPath . DIRECTORY_SEPARATOR . 'PHPExcel.php';
        $objPHPExcel = new PHPExcel();
        $objPHPExcel->setActiveSheetIndex(0);
        $objPHPExcel->getActiveSheet()->SetCellValue('A1', 'Supplier');
        $objPHPExcel->getActiveSheet()->SetCellValue('B1', 'Item');
        $objPHPExcel->getActiveSheet()->SetCellValue('C1', 'Total Quantity');
        $objPHPExcel->getActiveSheet()->SetCellValue('D1', 'Unit');
        $objPHPExcel->getActiveSheet()->SetCellValue('E1', 'Unit Price');
        $objPHPExcel->getActiveSheet()->SetCellValue('F1', 'Total Price');
        $alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
        $boxIds = explode(',', $items[0]['box_ids']);
        $pos = 6;
        spl_autoload_register(array('YiiBase', 'autoload'));
        foreach ($DateBoxes as $n => $Box) {
            $custCount = $Box->customerCount;
            $objPHPExcel->getActiveSheet()->SetCellValue($alpha[$pos] . '1', $Box->BoxSize->box_size_name . ' (' . $custCount . ')');
            $objPHPExcel->getActiveSheet()->getColumnDimension($alpha[$pos])->setAutoSize(true);
            $pos++;
        }
        $objPHPExcel->getActiveSheet()->getStyle("A1:" . $alpha[$pos] . '1')->applyFromArray(array("font" => array("bold" => true)));
        $row = 2;
        foreach ($items as $item) {
            $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $item['name']);
            $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $item['item_name']);
            $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, $item['total']);
            $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $item['item_unit']);
            $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, $item['item_value']);
            $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $item['total_price']);
            $boxIds = explode(',', $item['box_ids']);
            $boxItemIds = explode(',', $item['box_item_ids']);
            $pos = 6;
            foreach ($DateBoxes as $Box) {
                $BoxItem = null;
                $biPos = false;
                $biPos = array_search($Box->box_id, $boxIds);
                if ($biPos !== false) {
                    $BoxItem = BoxItem::model()->findByAttributes(array('box_id' => $Box->box_id, 'box_item_id' => $boxItemIds[$biPos]));
                }
                $quantity = $BoxItem && !empty($BoxItem->item_quantity) ? $BoxItem->item_quantity : '0';
                $objPHPExcel->getActiveSheet()->SetCellValue($alpha[$pos] . $row, $quantity);
                $pos++;
            }
            $row++;
        }
        $objPHPExcel->getActiveSheet()->getColumnDimension("A")->setAutoSize(true);
        $objPHPExcel->getActiveSheet()->getColumnDimension("B")->setAutoSize(true);
        $objPHPExcel->getActiveSheet()->getColumnDimension("C")->setAutoSize(true);
        $objPHPExcel->getActiveSheet()->getColumnDimension("D")->setAutoSize(true);
        $objPHPExcel->getActiveSheet()->getColumnDimension("E")->setAutoSize(true);
        $objPHPExcel->getActiveSheet()->getColumnDimension("F")->setAutoSize(true);
        // Rename sheet
        $objPHPExcel->getActiveSheet()->setTitle('Packing List');
        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
        header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
        header('Content-Disposition: attachment; filename="ordering-list-' . date('Ymd') . '"');
        $objWriter->save('php://output');
        exit;
    }
 /**
  * Manages all models.
  */
 public function actionOrder($show = 4)
 {
     $model = new UserBox();
     $Customer = Customer::model()->findByPk(Yii::app()->user->user_id);
     $deadlineDays = SnapUtil::config('boxomatic/orderDeadlineDays');
     if (isset($_GET['all'])) {
         $DeliveryDates = DeliveryDate::model()->findAll();
     } else {
         $DeliveryDates = DeliveryDate::model()->with('Boxes')->findAll(array('condition' => 'date_sub(date, interval -1 week) > NOW()', 'limit' => $show + 1));
     }
     $BoxSizes = BoxSize::model()->findAll(array('order' => 'box_size_name DESC'));
     if (isset($_POST['btn_recurring'])) {
         $monthsAdvance = (int) $_POST['months_advance'];
         $startingFrom = $_POST['starting_from'];
         $every = $_POST['every'];
         $locationId = $_POST['Customer']['delivery_location_key'];
         $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);
         foreach ($_POST['Recurring'] as $key => $quantity) {
             $boxSizeId = str_replace('bs_', '', $key);
             $Boxes = Box::model()->with('DeliveryDate')->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\tsize_id={$boxSizeId}");
             $n = 0;
             foreach ($Boxes as $Box) {
                 $CustBoxes = UserBox::model()->findAllByAttributes(array('user_id' => $Customer->user_id, 'box_id' => $Box->box_id));
                 foreach ($CustBoxes as $CustBox) {
                     $CustBox->delete();
                 }
                 $n++;
                 if ($n % 2 == 0 && $every == 'fortnight') {
                     continue;
                 }
                 //Create extra customer box rows
                 for ($i = 0; $i < $quantity; $i++) {
                     $CustBox = new UserBox();
                     $CustBox->user_id = $Customer->user_id;
                     $CustBox->box_id = $Box->box_id;
                     $CustBox->quantity = 1;
                     $CustBox->delivery_cost = $Location->location_delivery_value;
                     $CustBox->save();
                     $CustDeliveryDate = Order::model()->findByAttributes(array('user_id' => $Customer->user_id, 'delivery_date_id' => $CustBox->Box->delivery_date_id));
                     if (!$CustDeliveryDate) {
                         $CustDeliveryDate = new Order();
                         $CustDeliveryDate->user_id = $Customer->user_id;
                         $CustDeliveryDate->delivery_date_id = $CustBox->Box->delivery_date_id;
                     }
                     $CustDeliveryDate->location_id = $locationId;
                     $CustDeliveryDate->customer_location_id = $custLocationId;
                     $CustDeliveryDate->save();
                 }
             }
         }
     }
     if (isset($_POST['btn_clear_orders'])) {
         //Get all boxes beyond the deadline date
         $Boxes = Box::model()->with('DeliveryDate')->findAll("\n\t\t\t\tdate_sub(date, interval {$deadlineDays} day) > NOW()");
         foreach ($Boxes as $Box) {
             $CustBox = UserBox::model()->findByAttributes(array('user_id' => $Customer->user_id, 'box_id' => $Box->box_id));
             //Only create a records if an entry doesn't already exist
             if ($CustBox) {
                 $CustBox->delete();
             }
         }
     }
     if (isset($_POST['Orders'])) {
         foreach ($_POST['Orders'] as $boxId => $quantity) {
             $Box = Box::model()->findByPk($boxId);
             $CustBoxes = UserBox::model()->with('Box')->findAll(array('condition' => 'user_id=:customerId AND size_id=:sizeId AND delivery_date_id=:deliveryDateId', 'params' => array(':customerId' => $Customer->user_id, ':sizeId' => $Box->size_id, ':deliveryDateId' => $Box->delivery_date_id)));
             $curQuantity = count($CustBoxes);
             $diff = $quantity - $curQuantity;
             if ($diff > 0) {
                 //Create extra customer box rows
                 for ($i = 0; $i < $diff; $i++) {
                     $CustBox = new UserBox();
                     $CustBox->user_id = $Customer->user_id;
                     $CustBox->box_id = $boxId;
                     $CustBox->quantity = 1;
                     $CustBox->delivery_cost = $Customer->Location->location_delivery_value;
                     $CustBox->save();
                 }
             }
             if ($diff < 0) {
                 //Remove any boxes the customer no longer wants;
                 $diff = abs($diff);
                 for ($i = 0; $i < $diff; $i++) {
                     $CustBoxes[$i]->delete();
                 }
             }
         }
     }
     if (isset($_POST['CustDeliveryDates'])) {
         foreach ($_POST['CustDeliveryDates'] as $key => $locationId) {
             $CustDeliveryDate = Order::model()->findByPk($key);
             $custLocationId = new CDbExpression('NULL');
             if (strpos($locationId, '-')) {
                 //has a customer location
                 $parts = explode('-', $locationId);
                 $locationId = $parts[1];
                 $custLocationId = $parts[0];
             }
             $CustDeliveryDate->location_id = $locationId;
             $CustDeliveryDate->customer_location_id = $custLocationId;
             $CustDeliveryDate->save();
             $CustBoxesDate = UserBox::model()->with('Box')->findAll('user_id=:customerId AND Box.delivery_date_id=:dateId', array('customerId' => Yii::app()->user->user_id, 'dateId' => $CustDeliveryDate->delivery_date_id));
             foreach ($CustBoxesDate as $CustBox) {
                 $CustBox->delivery_cost = $CustDeliveryDate->Location->location_delivery_value;
                 $CustBox->save();
             }
         }
     }
     $this->render('order', array('model' => $model, 'DeliveryDates' => $DeliveryDates, 'Customer' => $Customer, 'BoxSizes' => $BoxSizes, 'deadline' => strtotime('+' . $deadlineDays . ' days'), 'show' => $show));
 }
Beispiel #18
0
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  */
 public function search($paginate = true)
 {
     $pageSize = isset($_GET['pageSize']) ? $_GET['pageSize'] : 10;
     Yii::app()->user->setState('pageSize', $pageSize);
     $criteria = new CDbCriteria();
     //$criteria->with=array('SupplierProducts');
     $tablePrefix = SnapUtil::config('boxomatic/tablePrefix');
     $criteria->select = 't.*, GROUP_CONCAT(SupplierProducts.name SEPARATOR ", ") as supplier_products';
     $criteria->join = "LEFT JOIN {$tablePrefix}supplier_products SupplierProducts ON SupplierProducts.supplier_id = t.id";
     $criteria->group = 't.id';
     if (!empty($this->item_search)) {
         $searchItems = explode(',', $this->item_search);
         foreach ($searchItems as $searchItem) {
             $criteria->addCondition('name LIKE "%' . $searchItem . '%"', 'OR');
         }
     }
     $criteria->compare('id', $this->id);
     $criteria->compare('name', $this->name, true);
     $criteria->compare('mobile', $this->mobile, true);
     $criteria->compare('phone', $this->phone, true);
     $criteria->compare('address', $this->address, true);
     $criteria->compare('address2', $this->address2, true);
     $criteria->compare('suburb', $this->suburb, true);
     $criteria->compare('state', $this->state, true);
     $criteria->compare('postcode', $this->postcode, true);
     $criteria->compare('distance_kms', $this->distance_kms, true);
     $criteria->compare('bank_account_name', $this->bank_account_name, true);
     $criteria->compare('bank_bsb', $this->bank_bsb, true);
     $criteria->compare('bank_acc', $this->bank_acc, true);
     $criteria->compare('email', $this->email, true);
     $criteria->compare('website', $this->website, true);
     $criteria->compare('certification_status', $this->certification_status, true);
     $criteria->compare('order_days', $this->order_days, true);
     $criteria->compare('produce', $this->produce, true);
     $criteria->compare('notes', $this->notes, true);
     $criteria->compare('payment_details', $this->payment_details, true);
     $criteria->addCondition('status=' . self::STATUS_ACTIVE);
     return new CActiveDataProvider($this, array('criteria' => $criteria, 'pagination' => $paginate ? array('pageSize' => $pageSize) : $paginate));
 }
 /**
  * 
  */
 public function actionProcessCustExtras($cdd)
 {
     $CDD = Order::model()->findByPk($cdd);
     $User = $CDD->User;
     if ($User->balance - $CDD->extras_total > SnapUtil::config('boxomatic/minimumCredit')) {
         $Payment = new UserPayment();
         $Payment->payment_value = -1 * $CDD->extras_total;
         //make price a negative value for payment table
         $Payment->payment_type = 'DEBIT';
         $Payment->payment_date = new CDbExpression('NOW()');
         $Payment->user_id = $CDD->user_id;
         $Payment->staff_id = Yii::app()->user->id;
         $note = 'Extras bought on ' . $CDD->DeliveryDate->date . ' totalling:' . SnapFormat::currency($CDD->extras_total);
         $Payment->payment_note = $note;
         $Payment->save();
         $CDD->status = Order::STATUS_APPROVED;
         $CDD->save();
     } else {
         Yii::app()->user->setFlash('danger', 'Not enough credit.');
     }
     $this->redirect(array('userBoxes', 'date' => $CDD->delivery_date_id));
 }
Beispiel #20
0
<?php

$cs = Yii::app()->clientScript;
?>
<h1>Do not like list</h1>
<p>Select the products you do not wish to appear in your box</p>
<div class="row">
	<div class="large-2 columns leftCol">
		<h2>Categories</h2>
		<ul class="categories">
			<?php 
echo Category::model()->getCategoryTree(SnapUtil::config('boxomatic/supplier_product_root_id'), array('user/dontWant', 'id' => Yii::app()->user->id), $curCat);
?>
			<li class="<?php 
echo $curCat == Category::uncategorisedCategory ? 'selected' : '';
?>
"><?php 
echo CHtml::link('Uncategorised', array('user/dontWant', 'id' => Yii::app()->user->id, 'cat' => Category::uncategorisedCategory));
?>
</li>
		</ul>
	</div>
	<div class="large-7 columns products">
		<h2>Products</h2>
		<div class="list-view">
			<div class="items row">
			<?php 
foreach ($SupplierProducts as $Product) {
    ?>
				
			<div class="view large-12 columns end">
Beispiel #21
0
 public static function doHash($password)
 {
     $salt = SnapUtil::config('general/security.salt');
     $hash = hash('sha256', $password . $salt);
     return $hash;
 }
Beispiel #22
0
<h1>Orders</h1>

<div class="row">
	<div class="large-2 columns leftCol">
		<h2>Categories</h2>
		<ul class="categories">
			<li class="<?php 
echo $curCat == Category::boxCategory ? 'selected' : '';
?>
"><?php 
echo CHtml::link('Boxes', array('OrderItem/order', 'date' => $DeliveryDate->id, 'cat' => Category::boxCategory));
?>
</li>
			<?php 
echo Category::model()->getCategoryTree(SnapUtil::config('boxomatic/supplier_product_root_id'), array('OrderItem/order', 'date' => $DeliveryDate->id), $curCat);
?>
			<li class="<?php 
echo $curCat == Category::uncategorisedCategory ? 'selected' : '';
?>
"><?php 
echo CHtml::link('Uncategorised', array('OrderItem/order', 'date' => $DeliveryDate->id, 'cat' => Category::uncategorisedCategory));
?>
</li>
		</ul>
	</div>
	<div class="large-7 columns products">
		
		<?php 
if ($curCat == Category::boxCategory) {
    ?>
Beispiel #23
0
 /**
  * Returns the human readable unit label for the BoxItem
  */
 public function getItem_unit_label()
 {
     return SnapUtil::config('boxomatic/itemUnits.' . $this->item_unit);
 }
Beispiel #24
0
<?php

return array('homepage' => array('id' => 'homepage', 'name' => 'Homepage', 'description' => '', 'show_in_cms' => false, 'auto_add_to_menu' => array(), 'fields' => array('content_1' => 'text', 'content_2' => 'text', 'content_3' => 'text', 'content_4' => 'text', 'content_5' => 'text', 'meta_keywords' => 'string', 'meta_description' => 'string'), 'rules' => array(array('content_1, content_2, content_3, content_4, content_5', 'safe')), 'groups' => array('Content' => array('content_1', 'content_2', 'content_3', 'content_4', 'content_5'), 'SEO' => array('meta_keywords', 'meta_description')), 'input_types' => array('meta_description' => 'textAreaControlGroup')), 'page' => array('id' => 'page', 'name' => 'Page', 'description' => 'A standard page', 'show_in_cms' => true, 'auto_add_to_menu' => array('main_menu'), 'fields' => array('content' => 'text', 'meta_keywords' => 'string', 'meta_description' => 'string'), 'rules' => array(array('content', 'length', 'max' => 255)), 'groups' => array('Content' => array('content'), 'SEO' => array('meta_keywords', 'meta_description')), 'input_types' => array('meta_description' => 'textAreaControlGroup')), 'news_list' => array('id' => 'news_list', 'name' => 'News List', 'description' => '', 'show_in_cms' => false, 'auto_add_to_menu' => array(), 'fields' => array('content' => 'text', 'meta_keywords' => 'string', 'meta_description' => 'string'), 'rules' => array(array('content', 'length', 'max' => 255)), 'groups' => array('Content' => array('content'), 'SEO' => array('meta_keywords', 'meta_description')), 'input_types' => array('meta_description' => 'textAreaControlGroup')), 'news' => array('id' => 'news', 'name' => 'News', 'description' => 'News items will appear in the news section of your website.', 'show_in_cms' => true, 'auto_add_to_menu' => array(), 'fields' => array('content' => 'text', 'intro' => 'text', 'meta_keywords' => 'string', 'meta_description' => 'string', 'image' => 'string', 'file' => 'string'), 'rules' => array(array('file, meta_keywords, meta_description', 'length', 'max' => 255), array('file', 'file'), array('image', 'file', 'types' => 'jpg, jpeg, gif, png'), array('content, intro', 'safe')), 'groups' => array('Content' => array('intro', 'content', 'image', 'file'), 'SEO' => array('meta_keywords', 'meta_description')), 'input_types' => array('image' => 'imageField', 'file' => 'fileField', 'intro' => array('widget' => array('class' => 'vendor.ckeditorwidget.TheCKEditorWidget', 'settings' => SnapUtil::config('content.ckeditor/plain'))), 'meta_description' => 'textAreaControlGroup')));
Beispiel #25
0
    ?>
		<?php 
}
?>
		
		<?php 
echo $form->textFieldControlGroup($model, 'user_phone', array('size' => 45, 'maxlength' => 45));
?>
		<?php 
echo $form->textFieldControlGroup($model, 'user_mobile', array('size' => 45, 'maxlength' => 45));
?>
		<?php 
echo $form->textAreaControlGroup($model, 'user_address');
?>
		<?php 
echo $form->dropDownListControlGroup($model, 'user_state', SnapUtil::config('boxomatic/states'));
?>
		<?php 
echo $form->textFieldControlGroup($model, 'user_postcode', array('size' => 45, 'maxlength' => 45));
?>
		<?php 
echo $form->textAreaControlGroup($model, 'notes');
?>
		
		<div class="form-group">
			<?php 
echo $form->label($model, 'tags', array('class' => 'control-label col-lg-2'));
?>
			<div class="col-lg-10">
				<?php 
echo $form->hiddenField($model, 'tag_names');
Beispiel #26
0
 public function getNextDeliveryDate($days = null)
 {
     $minDays = SnapUtil::config('boxomatic/minimumAdvancePayment');
     $days = $days ? $days : $minDays;
     return $this->Location->getNextDeliveryDate($this->delivery_day, $days);
 }
Beispiel #27
0
            <?php 
echo $form->dropDownListControlGroup($model, 'available_to', $model->getMonthList());
?>
            <?php 
echo $form->dateFieldControlGroup($model, 'customer_available_from', array(), array('yearRange' => date('Y') . ':2050'));
?>
            <?php 
echo $form->dateFieldControlGroup($model, 'customer_available_to', array(), array('yearRange' => date('Y') . ':2050'));
?>
            <?php 
echo $form->textFieldControlGroup($model, 'item_sales_price');
?>
            <?php 
echo $form->checkBoxControlGroup($model, 'available_in_shop');
?>
            <h3>Categories</h3>
            <ul class="categories">
                <?php 
echo Category::model()->getCategoryTreeForm(SnapUtil::config('boxomatic/supplier_product_root_id'), $model);
?>
            </ul>
        </div>
    </div>
</div>
<div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
    <button name="new_product" type="submit" class="btn btn-primary">Add Product</button>
</div>
<?php 
$form->layout = BsHtml::FORM_LAYOUT_HORIZONTAL;
BsHtml::$formLayoutHorizontalLabelClass = 'control-label col-lg-2';
Beispiel #28
0
\t\$.fn.yiiGridView.update('customer-payment-grid',{ data:{ pageSize: \$(this).val() }})
});
EOD
, CClientScript::POS_READY);
Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('customer-payment-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n\$('.chosen').chosen();\n");
?>
<div class="form row">
<?php 
$form = $this->beginWidget('application.widgets.SnapActiveForm', array('id' => 'user-payment-form', 'enableAjaxValidation' => false, 'layout' => BsHtml::FORM_LAYOUT_HORIZONTAL));
?>
	<div class="col-lg-9 clearfix">
		<?php 
echo $form->dropDownListControlGroup($model, 'user_id', CHtml::listData(BoxomaticUser::model()->findAll(array('order' => 'first_name, last_name')), 'id', 'full_name_and_balance'), array('class' => 'chosen'));
?>
		<?php 
echo $form->dropDownListControlGroup($model, 'payment_type', SnapUtil::config('boxomatic/paymentTypes'));
?>
		<?php 
echo $form->dateFieldControlGroup($model, 'payment_date');
?>
		<?php 
echo $form->textFieldControlGroup($model, 'payment_value', array('size' => 7, 'maxlength' => 7));
?>
		<?php 
echo $form->textAreaControlGroup($model, 'payment_note');
?>
	</div>
	<?php 
echo $this->renderPartial('//layouts/_form_sidebar');
$this->endWidget();
?>
 ID as your reference.<br />
Your <?php 
echo Yii::app()->name;
?>
 ID is: <strong><?php 
echo $Customer->bfb_id;
?>
</strong>.

<h3>Information for collections</h3>
 
<p>If you are unable to pick up your box from Bellingen Greengrocers by 6pm when the store closes, please call us to arrange an alternative, or why not organise a group of friends to share the pick up :)</p>

<p>
--<br />
Kind regards,<br />
Box-O-Matic, Box Processing System</p>

<p>Thank you for your generous support and being part of this wonderful project.</p>

<p>Email: <a href="mailto:<?php 
echo SnapUtil::config('boxomatic/adminEmail');
?>
"><?php 
echo SnapUtil::config('boxomatic/adminEmail');
?>
</a></p>

</body>
</html>
 /**
  * Displays the register page
  */
 public function actionRegister()
 {
     $model = new User();
     $vars = array();
     if (isset($_POST['User'])) {
         $model->attributes = $_POST['User'];
         $model->scenario = 'register';
         if ($model->save()) {
             $Customer = new Customer();
             $Customer->attributes = $_POST['Customer'];
             $Customer->save();
             if (!$Customer->Location->is_pickup) {
                 $CustLoc = new UserLocation();
                 $CustLoc->user_id = $Customer->user_id;
                 $CustLoc->location_id = $Customer->location_id;
                 $CustLoc->address = $model->user_address;
                 $CustLoc->address2 = $model->user_address2;
                 $CustLoc->suburb = $model->user_suburb;
                 $CustLoc->state = $model->user_state;
                 $CustLoc->postcode = $model->user_postcode;
                 $CustLoc->phone = !empty($model->user_phone) ? $model->user_phone : $model->user_mobile;
                 $CustLoc->save(false);
             }
             $model->user_id = $Customer->user_id;
             $model->update(array('user_id'));
             $Auth = Yii::app()->authManager;
             $Auth->assign('customer', $model->id);
             //Send email
             $adminEmail = SnapUtil::config('boxomatic/adminEmail');
             $adminEmailFromName = SnapUtil::config('boxomatic/adminEmailFromName');
             $message = new YiiMailMessage('Welcome to ' . Yii::app()->name);
             $message->view = 'welcome';
             $message->setBody(array('User' => $model, 'newPassword' => $_POST['User']['password']), 'text/html');
             $message->addTo($adminEmail);
             $message->addTo($model->email);
             $message->setFrom(array($adminEmail => $adminEmailFromName));
             if (!@Yii::app()->mail->send($message)) {
                 $mailError = true;
             }
             $identity = new UserIdentity($model->email, $_POST['User']['password']);
             $identity->authenticate();
             Yii::app()->user->login($identity);
             User::model()->updateByPk($identity->id, array('last_login_time' => new CDbExpression('NOW()')));
             $this->redirect(array('customer/welcome'));
         }
     }
     $model->password = '';
     $model->password_repeat = '';
     $vars['model'] = $model;
     // $this->render('register',array('model'=>$model));
     $this->render('register', $vars);
 }