/**
  * Authenticates the password.
  * This is the 'authenticate' validator as declared in rules().
  * returning true false does not stops proceeding to action. to stop add error to attribute.
  */
 public function authenticate($attribute, $params)
 {
     if (!$this->hasErrors()) {
         $this->_identity = new UserIdentity($this->username, $this->password);
         $this->_identity->authenticate();
         switch ($this->_identity->errorCode) {
             case UserIdentity::ERROR_NONE:
                 $duration = $this->rememberMe ? Yii::app()->controller->module->rememberMeTime : 0;
                 Yii::app()->user->login($this->_identity, $duration);
                 AppCommon::mergeCookieAndDbCart();
                 //on login merge the db and cookie carts
                 break;
             case UserIdentity::ERROR_EMAIL_INVALID:
                 $this->addError("username", UserModule::t("Email is incorrect."));
                 break;
             case UserIdentity::ERROR_STATUS_NOTACTIV:
                 $this->addError("username", UserModule::t("You account is not activated."));
                 break;
             case UserIdentity::ERROR_STATUS_BAN:
                 $this->addError("username", UserModule::t("You account is blocked."));
                 break;
             case UserIdentity::ERROR_PASSWORD_INVALID:
                 $this->addError("password", UserModule::t("Password is incorrect."));
                 break;
         }
         if ($this->_identity->errorCode === UserIdentity::ERROR_NONE) {
             return true;
         } else {
             return false;
         }
     }
 }
 /**
  * Authenticates the all inputs and there relations with each other
  * returning true false does not stops proceeding to action. to stop add error to attribute.
  */
 public function customInputValidator($attribute, $params)
 {
     //check if address has been passed
     if (isset($this->address) && !AppCommon::isEmpty($this->address)) {
         //if passed check if address passed is allowed for the given user
         //array( addrId => array( locality, addrText ) )
         $allowedAddresses = AAddress::model()->getAllowedAddressForUser(AppCommon::getUserDetailsId());
         if (!isset($allowedAddresses[$this->address])) {
             $this->addError("address", CHtml::encode("Kindly select a valid address."));
             return;
         }
         //continue to check more errors only if address selected is valid
         //as cart depends on a valid address
         //set customerLocality a valid value taken from selected address this will override
         //upon the value passed by user and thus will be more reliable value
         $this->customerLocality = $allowedAddresses[$this->address][0];
         $this->getAddressData[$this->address] = $allowedAddresses[$this->address];
         $this->getCartArray = ACart::getCart($this->customerLocality, 0);
         //check if cart has rows > 0 for the selected locality
         if (isset($this->getCartArray) && isset($this->getCartArray["total_items_at_locality"]) && $this->getCartArray["total_items_at_locality"] <= 0) {
             $this->addError("extraErrorMessages", CHtml::encode("Error: The cart contains no tiffins which are available at the selected address's locality. Kindly, either add tiffins available at selected address's locality to the cart or select addresses with different locality."));
         }
         //check if for selected locality cart has not changed
         if (AppCommon::hasCartChanged($this->getCartArray)) {
             $this->addError("extraErrorMessages", CHtml::encode("Notification: The cart has changed. Kindly retry."));
         }
     }
 }
 /**
  * Displays the contact page
  */
 public function actionContact()
 {
     $model = new ContactForm();
     if (isset($_POST['ContactForm'])) {
         $model->attributes = $_POST['ContactForm'];
         if ($model->validate()) {
             //$name='=?UTF-8?B?'.base64_encode($model->name).'?=';
             //$subject='=?UTF-8?B?'.base64_encode($model->subject).'?=';
             //$headers="From: $name <{$model->email}>\r\n".
             //	"Reply-To: {$model->email}\r\n".
             //	"MIME-Version: 1.0\r\n".
             //	"Content-Type: text/plain; charset=UTF-8";
             //mail(Yii::app()->params['adminEmail'],$subject,$model->body,$headers);
             //Yii::ankFileSave("contact-start");
             //Yii::ankFileSave( $model->name );
             //Yii::ankFileSave( $model->email );
             //Yii::ankFileSave( $model->subject );
             //Yii::ankFileSave( $model->body );
             //Yii::ankFileSave("contact-stop");
             AppCommon::sendEmail(Yii::app()->params['adminEmail'], "tw.in team", "contactus" . $model->subject, $model->email . "\n" . $model->name . "\n" . $model->body, array("contactus"));
             Yii::app()->user->setFlash('contact', 'Thank you for contacting us. We will respond to you as soon as possible.');
             $this->refresh();
         }
     }
     $this->render('contact', array('model' => $model));
 }
 /**
  * Authenticates all the inputs and there relations with each other
  * returning true false does not stops proceeding to action. to stop add error to attribute.
  */
 public function customInputValidator($attribute, $params)
 {
     //check if selectedPriceTimeId has been passed
     if (isset($this->selectedPriceTimeId) && !AppCommon::isEmpty($this->selectedPriceTimeId)) {
         if (isset($this->allowedAPriceTimeObjArray) && count($this->allowedAPriceTimeObjArray) > 0) {
             $this->selectedAPriceTimeObj = null;
             $this->perUnitPrice = null;
             $this->totalPrice = 0;
             foreach ($this->allowedAPriceTimeObjArray as $row) {
                 if ($row->id == $this->selectedPriceTimeId) {
                     $this->selectedAPriceTimeObj = $row;
                     //set TiffinPriceTimeSelectionForm to selected APriceTime object
                     $this->perUnitPrice = $row->price_after_discount;
                     $this->totalPrice = $row->price_after_discount * $this->quantity;
                     break;
                 }
             }
             if (!isset($this->selectedAPriceTimeObj)) {
                 $this->addError("selectedPriceTimeId", CHtml::encode("Kindly select a valid delivery time."));
             }
         } else {
             //here the control will not reach as this condition has been checked in constructor.
             //$this->addError("selectedPriceTimeId",CHtml::encode("This tiffin is not available now. Kindly press the edit button."));
             $this->addError("selectedPriceTimeId", CHtml::encode("Some error has occured. Kindly press the edit order button."));
         }
     }
 }
 /**
  * Performs access check for this user.
  * @param string $operation the name of the operation that need access check.
  * @param array $params name-value pairs that would be passed to business rules associated
  * with the tasks and roles assigned to the user.
  * Since version 1.1.11 a param with name 'userId' is added to this array, which holds the value of
  * {@link getId()} when {@link CDbAuthManager} or {@link CPhpAuthManager} is used.
  * @param boolean $allowCaching whether to allow caching the result of access check.
  * When this parameter
  * is true (default), if the access check of an operation was performed before,
  * its result will be directly returned when calling this method to check the same operation.
  * If this parameter is false, this method will always call {@link CAuthManager::checkAccess}
  * to obtain the up-to-date access result. Note that this caching is effective
  * only within the same request and only works when <code>$params=array()</code>.
  * @return boolean whether the operations can be performed by this user.
  */
 public function checkAccess($operation, $params = array(), $allowCaching = true)
 {
     if ($allowCaching && $params === array() && isset($this->_appAccess[$operation])) {
         return $this->_appAccess[$operation];
     }
     $role = AppCommon::getUserRole();
     if ($role === false) {
         $access = false;
     } elseif ($role === $operation) {
         $access = true;
     } else {
         $access = false;
     }
     if ($allowCaching && $params === array()) {
         $this->_appAccess[$operation] = $access;
     }
     return $access;
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     if (Yii::app()->getRequest()->getIsAjaxRequest() and $_GET['ajax'] == 1) {
         $response = array();
         $model = new AAddress();
         $model->city = 'Bengaluru';
         //get localities list -start
         $modelArr = ABangaloreLocalities::model()->findAll(array('condition' => 'is_deleted = "no"', 'order' => 'locality_name ASC'));
         $locality_array = array();
         foreach ($modelArr as $singleModel) {
             $locality_array[$singleModel->id] = $singleModel->locality_name;
         }
         $locality_array[""] = "Select any area";
         //get localities list -stop
         // Uncomment the following line if AJAX validation is needed
         // $this->performAjaxValidation($model);
         if (isset($_POST['AAddress'])) {
             $model->attributes = $_POST['AAddress'];
             $currDateTime = new DateTime();
             $model->creation_time = $currDateTime->format('Y-m-d H:i:s');
             $model->link = AppCommon::getUserDetailsId();
             $model->link_table = "user_details";
             if ($model->save()) {
                 //$this->redirect(array('view','id'=>$model->id));
                 //sending row html code with checked radio button
                 $response["isRecordSaved"] = 1;
                 $id_temp = $model->id;
                 $Loc_name_temp = $model->address2bangaloreLocalities->locality_name;
                 $address_temp = $model->getAddressString();
                 $response["html"] = '<tr><td>' . CHtml::activeRadioButton(new CheckoutFirstStageForm(), 'address', array('value' => $id_temp, 'required' => true, 'checked' => true, 'data-locality_name' => $Loc_name_temp, 'uncheckValue' => NULL)) . '</td><td>' . $address_temp . '</td><td>' . $Loc_name_temp . '</td><tr>';
                 $response["locality"] = $Loc_name_temp;
                 echo CJSON::encode($response);
                 Yii::app()->end();
             }
         }
         $response["html"] = $this->renderPartial('create', array('model' => $model, 'locality_array' => $locality_array), true, false);
         $response["isRecordSaved"] = 0;
         echo CJSON::encode($response);
         Yii::app()->end();
     }
 }
 /**
  * gets cart values
  * $location to select tiffins at a particular location
  * $doeditcart edit cart if needed.
  * return
  */
 public static function getCart($location = null, $doeditcart = 1)
 {
     /*Yii::ankFileSave( var_export( AppCommon::modifyInputTiffinsQuantity( 
     		array(
     		1=>2,
     		9=>1,
     		10=>20,
     		11=>0,
     		16=>1,
     		)
     		, "Embassy Tech Village" ) ,true));
     		echo "wahh wahh";
     		return;*/
     $cartData = null;
     if (Yii::app()->user->isGuest) {
         $cartCookiesArr = array();
         $allCookies = Yii::app()->request->getCookies();
         if (isset($allCookies[Yii::app()->params['cartCookieName']])) {
             $cartCookiesArr = CJSON::decode($allCookies[Yii::app()->params['cartCookieName']]->value, true);
         }
         $cartArr = array();
         if (isset($cartCookiesArr)) {
             foreach ($cartCookiesArr as $key => $value) {
                 $cartArr[$key] = $value[0];
                 //array(tiffinid=>quantity,...)
             }
         }
         $cartData = AppCommon::modifyInputTiffinsQuantity($cartArr, $location);
         if ($cartData["has_changed"]) {
             if (isset($cartCookiesArr)) {
                 foreach ($cartCookiesArr as $key1 => $value1) {
                     if (isset($cartData[$key1]) and $cartData[$key1]["has_changed"]) {
                         if ($cartData[$key1]["error_msg"] == AppCommon::$cartErrorMsgTiffinNotExist) {
                             unset($cartCookiesArr[$key1]);
                         } else {
                             if ($cartData[$key1]["error_msg"] == AppCommon::$cartErrorMsgTiffinNotAvailable and $doeditcart == 1) {
                                 unset($cartCookiesArr[$key1]);
                             } else {
                                 if ($cartData[$key1]["error_msg"] == AppCommon::$cartErrorMsgTiffinQuanCappedToLimits and $doeditcart == 1) {
                                     $cartCookiesArr[$key1][0] = $cartData[$key1]["quantity"];
                                 }
                             }
                         }
                     }
                 }
             }
             //update the cookie
             //TODO:: check CJSON::encode( $cartCookiesArr ) is not null
             $allCookies[Yii::app()->params['cartCookieName']] = new CHttpCookie(Yii::app()->params['cartCookieName'], CJSON::encode($cartCookiesArr), array('expire' => time() + 60 * 60 * 24 * 100, 'httpOnly' => true));
         }
     } else {
         $alreadyPresentRecord = ACart::model()->findAll(array('condition' => 'is_deleted = "no" AND cart2user = ' . AppCommon::getUserDetailsId()));
         $cartArr = array();
         foreach ($alreadyPresentRecord as $rec) {
             $cartArr[$rec->cart2tiffin] = $rec->quantity;
             //array(tiffinid=>quantity,...)
         }
         $cartData = AppCommon::modifyInputTiffinsQuantity($cartArr, $location);
         try {
             if ($cartData["has_changed"]) {
                 foreach ($alreadyPresentRecord as $rec1) {
                     if (isset($cartData[$rec1->cart2tiffin]) and $cartData[$rec1->cart2tiffin]["has_changed"]) {
                         if ($cartData[$rec1->cart2tiffin]["error_msg"] == AppCommon::$cartErrorMsgTiffinNotExist) {
                             $rec1->is_deleted = AppCommon::getUserDetailsId();
                             $rec1->save();
                             //update the record
                         } else {
                             if ($cartData[$rec1->cart2tiffin]["error_msg"] == AppCommon::$cartErrorMsgTiffinNotAvailable and $doeditcart == 1) {
                                 $rec1->is_deleted = AppCommon::getUserDetailsId();
                                 $rec1->save();
                                 //update the record
                             } else {
                                 if ($cartData[$rec1->cart2tiffin]["error_msg"] == AppCommon::$cartErrorMsgTiffinQuanCappedToLimits and $doeditcart == 1) {
                                     $rec1->quantity = $cartData[$rec1->cart2tiffin]["quantity"];
                                     $rec1->save();
                                     //update the record
                                 }
                             }
                         }
                     }
                 }
             }
         } catch (Exception $e) {
             Yii::ankFileSave(" get cart exception while saving cart in db");
             //added to ignore exception
         }
     }
     $cartData["total_items"] = AppCommon::cartItemCount();
     return $cartData;
 }
<div class="col-xs-12" style="font-size:120%;">
<img src="<?php 
echo AppCommon::getAppFolderUrl();
?>
/images/Payment.png" style="width:170px;height:85px;float:left;padding-right: 15px;" >
 <p style="padding-top:25px;">Checkout/Payment (We accept all credit cards, debit cards and COD), sit back and relax. </p>
 <br>
 <br>
 </div>

<div class="col-xs-12" style="font-size:120%;">
<img src="<?php 
echo AppCommon::getAppFolderUrl();
?>
/images/Delivery.png" style="width:170px;height:85px;float:left;padding-right: 15px;" >
 <p style="padding-top:25px;">Our superheroes will deliver your meal at your door-step. </p>
 <br>
 <br>
 </div>

<div class="col-xs-12" style="font-size:120%;">
<img src="<?php 
echo AppCommon::getAppFolderUrl();
?>
/images/Review.png" style="width:170px;height:85px;float:left;padding-right: 15px;" >
 <p style="padding-top:25px;">Review your meal and experience with us. </p>
 <br>
 <br>
 </div>
 </div>
    /**
     * 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)
    {
        $model = $this->loadModel($id, 'is_deleted = "no" and 
		tiffin2user_details = ' . AppCommon::getUserDetailsId());
        //loading record only if owner of record id opening it
        //quantity_available = initial_quantity maintains that order has not been made on this record
        //as ordered record must not be changed( except quantity change in limits) or deleted
        // Uncomment the following line if AJAX validation is needed
        // $this->performAjaxValidation($model);
        if (isset($_POST['ATiffin'])) {
            $model->attributes = $_POST['ATiffin'];
            if (isset($_POST['APriceTime'])) {
                foreach ($_POST['APriceTime'] as $value) {
                    //Yii::ankFileSave( $key );
                    Yii::ankFileSave($value["time"]);
                    Yii::ankFileSave($value["price"]);
                    Yii::ankFileSave($value["discount"]);
                }
            }
            //if($model->save())
            $this->redirect(array('view', 'id' => $model->id));
        }
        $this->render('update', array('model' => $model));
    }
            <a href="mailto:contactus@tw.in" style="font-weight:300;font-family:'Tahoma';color: #ffffff; text-decoration:none'"><i class="fa fa-envelope"></i> contactus@tw.in</a>
            </h3>
            <h3 class="fa-hover">
            <a target="_blank" href="https://www.facebook.com/tw.in" style="margin-right: 30px;font-weight:300;font-family:'Tahoma';color: #ffffff; text-decoration:none'"><i class="fa fa-facebook-official"></i> Like us       </a>
            <a target="_blank" href="https://www.twitter.com/tw" style="font-weight:300;font-family:'Tahoma';color: #ffffff; text-decoration:none'"><i class="fa fa-twitter"></i> Follow us</a>
            </h3>
        </div>
    </div>
</div>
      <div class="container-fluid" style="filter: alpha(opacity=90); opacity: 0.90;background-color: #DCFDFD;
      font-family:'Tahoma';color: #000000;">
        <div class="row">
          <div class="col-sm-8">
              <p id="copyright-section"> 
              	<a target="_blank" href="<?php 
echo AppCommon::getSiteBaseUrl() . '/site/page/view/about';
?>
">About</a> | 
              	<a target="_blank" href="#">Team</a> | 
              	<a target="_blank" href="#">Blog</a> | 
              	<a target="_blank" href="#">Terms of Service</a> | 
              	<a target="_blank" href="#">Privacy Policy</a> | 
              	<a target="_blank" href="#">FAQ</a> | 
              	<a target="_blank" href="#">Attributions</a></p>
          </div>
          <div class="col-sm-4">
            <p id="copyright-section">
              Copyright &copy; <?php 
echo date('Y');
?>
 by Put Your Enterprise Name pvt. ltd.<br/>
 public static function getEmailAndBasePhoneNumForUser($userDetailsId)
 {
     $response = array();
     if (isset($userDetailsId)) {
         $selectedRec = AUserDetails::model()->findAll(array('with' => array('aUserLogins' => array('on' => 'aUserLogins.is_deleted = "no" AND 
     					 t.is_deleted = "no" AND t.id = ' . $userDetailsId . ' '))));
         foreach ($selectedRec as $row) {
             $response['email'] = $row->aUserLogins[0]->login_name;
             break;
             //get the last updated and exit
         }
         $selectedPhone = APhone::model()->findAll(array('order' => 't.id DESC', 'condition' => 't.is_deleted = "no" AND t.link_table = "user_details"  AND 
     				t.meta_data = "base_phone" AND t.link = ' . $userDetailsId . ' '));
         foreach ($selectedPhone as $row) {
             $response['phone'] = $row->phone_num;
             break;
             //get the last updated and exit
         }
     }
     if (AppCommon::isEmpty($response)) {
         $response = false;
     }
     return $response;
 }
 /**
  * Declares the validation rules.
  */
 public function rules()
 {
     return array(array('phone, techpark, address, quantity, paymentMode', 'required'), array('phone', 'numerical'), array('phone', 'length', 'min' => 10, 'max' => 10), array('techpark, address', 'length', 'min' => 10), array('quantity', 'numerical', 'min' => 1, 'max' => 20), array('email', 'email'), array('paymentMode', 'default', 'value' => 'CASH ON DELIVERY'), array('name', 'default', 'value' => Yii::app()->user->name), array('email', 'default', 'value' => AppCommon::getEmail()));
 }
 /**
  * aanan fanan me likha buy :P
  */
 public function actionBuy($id)
 {
     return;
     $currDateTime = new DateTime();
     $currDateTime = $currDateTime->format('Y-m-d H:i:s');
     $selectedTiffin = ATiffin::model()->findAll(array('select' => 't.id, t.name, t.contents', 'condition' => 't.verified_by != "not verified" AND t.is_deleted = "no" AND t.id = ' . $id, 'order' => 't.id ASC, aPriceTimes.id ASC', 'with' => array('aPriceTimes' => array('select' => 'aPriceTimes.price_after_discount, aPriceTimes.order_end_time, aPriceTimes.discount, aPriceTimes.id, 
 	    					aPriceTimes.order_delivery_time, aPriceTimes.quantity_currently_available, 
 	    					aPriceTimes.orderType', 'on' => 'aPriceTimes.order_start_time <= ' . '"' . $currDateTime . '"' . ' AND aPriceTimes.order_end_time >= ' . '"' . $currDateTime . '"', 'condition' => 'aPriceTimes.verified_by != "not verified" AND aPriceTimes.is_deleted = "no"'))));
     if (isset($selectedTiffin[0]) and isset($selectedTiffin[0]->aPriceTimes[0])) {
         $model = new BuyForm();
         if (isset($_POST['BuyForm'])) {
             $model->attributes = $_POST['BuyForm'];
             $model->name = Yii::app()->user->name;
             $model->email = AppCommon::getEmail();
             if ($model->validate()) {
                 $temp_date = DateTime::createFromFormat('Y-m-d H:i:s', $selectedTiffin[0]->aPriceTimes[0]->order_delivery_time);
                 $temp_date_sms = $temp_date;
                 if ($temp_date != FALSE) {
                     $temp_date_sms = $temp_date->format('d M Y h:i a');
                     //01 Apr 2015 01:22 am
                     $temp_date = $temp_date->format('Y-M-d l, h:i:s a');
                 }
                 Yii::ankFileSave("\n");
                 Yii::ankFileSave("order-start");
                 Yii::ankFileSave($model->name);
                 Yii::ankFileSave($model->quantity);
                 Yii::ankFileSave($model->email);
                 Yii::ankFileSave($model->phone);
                 Yii::ankFileSave($model->quantity);
                 Yii::ankFileSave($model->techpark);
                 Yii::ankFileSave($model->address);
                 Yii::ankFileSave($model->paymentMode);
                 Yii::ankFileSave($selectedTiffin[0]->name);
                 Yii::ankFileSave($selectedTiffin[0]->id);
                 Yii::ankFileSave($selectedTiffin[0]->aPriceTimes[0]->id);
                 Yii::ankFileSave($temp_date);
                 Yii::ankFileSave("order-stop");
                 Yii::ankFileSave("\n");
                 $subject_email = "Tiffin order confirmation " . $temp_date;
                 $content_user = "******" . $model->name . ",\n" . "Your order comprising " . $model->quantity . " tiffin(s) of " . $selectedTiffin[0]->name . " has been accepted." . " We will deliver the order by " . $temp_date . " ( +/- 15 min. ) to " . $model->address . ", " . $model->techpark . ".\n The order is " . $model->paymentMode . " and order's cost is " . $model->quantity . " x " . $selectedTiffin[0]->aPriceTimes[0]->price_after_discount . " = Rs. " . $model->quantity * $selectedTiffin[0]->aPriceTimes[0]->price_after_discount . ". We may call on " . $model->phone . " for asking directions, if needed." . " Kindly receive the calls to make us deliver quickly. \n Thanks and regards, \n tw.in team ";
                 //notify customer
                 AppCommon::sendEmail($model->email, $model->name, $subject_email, $content_user, array("order_notification_customer"));
                 //notify tw team
                 AppCommon::sendEmail(Yii::app()->params['adminEmail'], $model->name, $subject_email, $content_user, array("order_notification_tiffinwale.in_team"));
                 $content_sms = "Dear Customer, we have received your order and it will be delivered" . " on " . $temp_date_sms . " ( +/- 15 min. ). Do check your email for complete details." . " Thanks! tw.in";
                 /*$content_sms = "Dear Customer, we have received your order and it will be delivered".
                 		" on 01 Apr 2015 12:00 am. Do check your email for complete details.".
                 		" Thanks! tw.in";
                 		$content_sms = "Dear Customer, we have received your order from".
                 		" and it will be delivered between 12:30 PM to 2:00 PM. Thank You! tw.in";*/
                 //sms customer
                 AppCommon::sendSmsOnTime($model->phone, $content_sms, "null", true);
                 Yii::app()->user->setFlash('buy', 'Thank you for ordering. Kindly check sms on your phone, we will deliver the meal at your address by ' . $temp_date . '.');
                 $this->refresh();
             }
         }
         $this->render('buy', array('model' => $model, 'data' => $selectedTiffin[0]));
     } else {
         Yii::app()->user->setFlash('buy', 'Currently this meal is unavailable. Kindly do visit us again tomorrow, during lunch hours.');
         //$this->refresh();
         $this->render('buy');
     }
 }
    $tiffinObj = $row->order2tiffin0;
    if (isset($tiffinObj->image)) {
        $imagePath = AppCommon::getAppFolderUrl() . '/images/tiffin_images/' . $tiffinObj->image;
    } else {
        $imagePath = AppCommon::getAppFolderUrl() . '/images/tiffin_images/5.jpg';
    }
    //default image
    echo '<tr>';
    echo '<td>';
    echo '<a target="_blank" href="' . AppCommon::getSiteBaseUrl() . '/tiffin/view/id/' . $tiffinObj->name . '-' . $tiffinObj->id . '">' . '<img src="' . $imagePath . '" alt="Loading..." style="width: 70px; float: left; height: 70px; margin-right: 5px; margin-bottom: 5px;"></a>' . '<b>' . $tiffinObj->name . '</b>' . '<p style="font-size: 80%;">' . $tiffinObj->contents . '</p>';
    echo '</td>';
    echo '<td>';
    echo $row->num_of_units;
    echo '</td>';
    echo '<td>';
    echo AppCommon::getDetailedDateString($row->order_delivery_time);
    echo '</td>';
    echo '<td>';
    echo '<b><i class="fa fa-inr"></i> ' . ' ' . $row->total_price . ' </b>';
    echo '</td>';
    echo '</tr>';
    $orderValue = $orderValue + $row->total_price;
}
?>
	
	</tbody>
	</table>
		<br>
		<br>
		<label class="required">Total Cost of Order: </label>
			<i style="color: rgba( 0,0,0, 0.5);"><?php 
 /**
  * Send mail method
  */
 public static function sendMail($email, $subject, $message)
 {
     /*$adminEmail = Yii::app()->params['adminEmail'];
       $headers = "MIME-Version: 1.0\r\nFrom: $adminEmail\r\nReply-To: $adminEmail\r\nContent-Type: text/html; charset=utf-8";
       $message = wordwrap($message, 70);
       $message = str_replace("\n.", "\n..", $message);
       return mail($email,'=?UTF-8?B?'.base64_encode($subject).'?=',$message,$headers);*/
     AppCommon::sendEmail($email, null, $subject, $message, array("user_module_operations"));
 }
		</p>
        <p><?php 
    echo CHtml::encode($data->contents);
    ?>
</p>
        </div>
        <div class="well wordwrap" style="padding: 5px; overflow:auto; height: 52px; margin-top: 5px; margin-bottom: 0px;
        border-bottom-right-radius: 0px; border-bottom-left-radius: 0px;">
        	

        	<!--b>Order slot - </b><?php 
    echo AppCommon::getDetailedDateString($data->aPriceTimes[0]->order_end_time);
    ?>
        	<br>
        	<b>Delivery around - </b><?php 
    echo AppCommon::getDetailedDateString($data->aPriceTimes[0]->order_delivery_time);
    ?>
        	<br-->
        	<i class="fa fa-inr"></i><?php 
    echo CHtml::encode("  " . $data->aPriceTimes[0]->price_after_discount) . ' /-';
    ?>
        	<?php 
    echo '<span class="label label-danger" style="margin-right: 2px;display: inline-block;">' . CHtml::encode(" - " . $data->aPriceTimes[0]->discount . "% applied") . '</span>';
    ?>

		<br>
		<i class="fa fa-tags"></i>
        <?php 
    foreach ($data->aFoodTagsAll as $tag) {
        echo '<span class="label label-success" style="margin-right: 2px;display: inline-block;">' . CHtml::encode($tag->tag_name) . '</span>';
    }
    echo '<td>';
    echo $row->quantity;
    echo '<br>';
    echo '<a style="color:red;" href="' . $goBackLink . '"><u>Edit</u></a>';
    echo '</td>';
    echo '<td>';
    echo '<table class="table-condensed" style="table-layout: fixed;">';
    echo '<tbody>';
    /* @var $value APriceTime */
    foreach ($row->allowedAPriceTimeObjArray as $value) {
        echo '<tr>';
        echo '<td>';
        echo CHtml::activeRadioButton($row, '[' . $key . ']selectedPriceTimeId', array('value' => $value->id, 'required' => true, 'data-perunitprice' => $value->price_after_discount, 'data-quantity' => $row->quantity, 'uncheckValue' => NULL, 'float' => 'left'));
        echo '</td>';
        echo '<td>';
        echo '<p style="font-size: 80%;"><span style="color:blue;"><b>' . AppCommon::getDetailedDateString($value->order_delivery_time) . '</b></span> at <span style="color:red;"><b><i class="fa fa-inr"></i> ' . ' ' . $value->price_after_discount . '</b></span> per item' . '</p>';
        echo '</td>';
        echo '</tr>';
    }
    echo '</tbody>';
    echo '</table>';
    echo $form->error($row, '[' . $key . ']selectedPriceTimeId', array(), false, false);
    //client validation made false due to radio button
    echo '</td>';
    //echo '<td>';
    //echo '<b><i class="fa fa-inr"></i> '.' '.$row->totalPrice.' </b>';
    //echo '</td>';
    echo '</tr>';
}
?>
	
 /**
  * private function: to make sure it is not called from outside
  *
  * returns price array
  * discount coupon is also calculated inside it
  * return array( 
  * sum of all tiffin and quantity ,
  * discount from coupon code, 
  * cashback from coupon code,
  * ( sum of all tiffin and quantity + discount from coupon code ) as total 
  * )
  */
 private function calculateBillAndItsComponents($ignoreDiscounts = false)
 {
     $response = array(0, 0, 0, 0);
     $sum = 0;
     foreach ($this->tiffinPriceTimeSelectionArr as $row) {
         $sum = $sum + $row->totalPrice;
     }
     $response[0] = $sum;
     if (!$ignoreDiscounts) {
         //do not ignore discounts
         if (!AppCommon::isEmpty($this->couponCode)) {
             if ($discount = AppCommonCoupon::getDiscountFromCoupon($this->couponCode, $this)) {
                 if ($discount[0]) {
                     $response[2] = $discount[1];
                 } else {
                     $response[1] = $discount[1] * -1;
                 }
             } else {
                 $this->addError("couponCode", CHtml::encode("Invalid or expired coupon code."));
             }
         }
     }
     $response[3] = $response[0] + $response[1];
     return $response;
 }
					<img src="<?php 
echo AppCommon::getAppFolderUrl();
?>
/images/loading.gif" alt=""> 
				</div>
			</div>
			<div class="text-center" style="min-height: 40px; padding-top: 10px;" role="alert">
				<b><?php 
echo count($selectedTiffins);
?>
</b> tiffin(s) are available.
			</div>  
			<?php 
foreach ($selectedTiffins as $value) {
    $imagePath = null;
    if (isset($value->image)) {
        $imagePath = AppCommon::getAppFolderUrl() . '/images/tiffin_images/' . $value->image;
    } else {
        $imagePath = AppCommon::getAppFolderUrl() . '/images/tiffin_images/5.jpg';
    }
    //default image
    $this->renderPartial('single_result_element1', array('data' => $value, 'imagePath' => $imagePath), false, false);
}
?>
		</div>
		</div>
</div>



/* @var $this Controller */
$this->beginContent('//layouts/main');
?>

<div style="z-index:950;position:fixed; left: 0%;top: 15%;">
	<div style="height: 100%; width: 300px; display: none; float: left;">

	</div>
	<div id="floatingCartButton" class="btn btn-info text-center wordwrap" style="width:40px; padding:3px;
	border-top-left-radius: 0px; border-bottom-left-radius: 0px; float: left; margin-top: 0px;">
		<i class="fa fa-shopping-cart" style="color: #ffffff;font-size: 150%;">
		</i><br>
    	C<br>A<br>R<br>T<br>
    	<span id="floatingCartButtonValue" class="badge">
    	<?php 
echo AppCommon::cartItemCount();
?>
    	</span>
	</div>
</div>

<div class="row">
    <div class="span9">
        <div id="content">
            <?php 
echo $content;
?>
        </div><!-- content -->
    </div>
    <!--div class="span3">
        <div id="sidebar">