$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
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>'; } ?>
</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>'; }
/** * takes the given array and respond with changed array which contains proper quantity of every tiffin * plus some message is given with the tiffin quantity row. * reponse array has 'total_price' as total cart price and 'has_changed' over all and per tiffin row to depict * if cart has changed like quantity has been changed * or tiffins have been removed. Example row below * tiffn_id=>array("has_changed"=>true,"id"=>xyz,"tiffin_name"=>xyz,"tiffin_content"=>xyz,"image_link"=>xyz,"delivery_time"=>xyz * , 'quantity'=> xyz, "per_unit_price"=> xyz,"error_msg"=>xyz ) * error_msg exists when row's has_changed is true and if has_changed is false error_msg does not exists */ public static function modifyInputTiffinsQuantity($tiffinAndQuantArr, $location = null) { $response = array(); $response["has_changed"] = false; //made true if a change is array data is made $response["total_price"] = 0; $response["total_items_at_locality"] = 0; $tiffinIdSqlInCondtStr = ATiffin::model()->getCommandBuilder()->createInCondition(ATiffin::model()->tableName(), 'id', array_keys($tiffinAndQuantArr), 't.'); //string containing IN condition $selectedTiffins = array(); $currDateTime = new DateTime(); $currDateTime = $currDateTime->format('Y-m-d H:i:s'); if (isset($location)) { $selectedTiffins = ATiffin::model()->findAll(array('select' => 't.id, t.name, t.contents, t.rating_of_tiffin, t.num_of_reviews, t.image', 'condition' => 't.verified_by != "not verified" AND t.is_deleted = "no" AND ' . $tiffinIdSqlInCondtStr, 'order' => 't.id, aPriceTimes.order_delivery_time ASC', 'with' => array('tiffin2userDetails' => array('select' => 'tiffin2userDetails.id, tiffin2userDetails.first_name, tiffin2userDetails.last_name, tiffin2userDetails.rating_of_tiffinwala, tiffin2userDetails.unique_name', 'on' => 'tiffin2userDetails.is_active=1 AND tiffin2userDetails.user_type = 1', 'with' => array('aBangaloreLocalities' => array('on' => 'aBangaloreLocalities.is_deleted = "no" AND aBangaloreLocalities.locality_name=' . '"' . $location . '"', 'joinType' => 'LEFT OUTER JOIN'))), 'aPriceTimes' => array('select' => 'aPriceTimes.price_after_discount, aPriceTimes.order_end_time, aPriceTimes.order_delivery_time, aPriceTimes.quantity_currently_available, aPriceTimes.orderType, aPriceTimes.discount', 'on' => 'aPriceTimes.order_start_time <= ' . '"' . $currDateTime . '"' . ' AND aPriceTimes.order_end_time >= ' . '"' . $currDateTime . '"' . ' AND aPriceTimes.order_delivery_time >= ' . '"' . $currDateTime . '"' . ' AND aPriceTimes.quantity_currently_available > 0 ' . 'AND aPriceTimes.verified_by != "not verified" AND aPriceTimes.is_deleted = "no"', 'joinType' => 'LEFT OUTER JOIN')))); } else { $selectedTiffins = ATiffin::model()->findAll(array('select' => 't.id, t.name, t.contents, t.rating_of_tiffin, t.num_of_reviews, t.image', 'condition' => 't.verified_by != "not verified" AND t.is_deleted = "no" AND ' . $tiffinIdSqlInCondtStr, 'order' => 't.id, aPriceTimes.order_delivery_time ASC', 'with' => array('tiffin2userDetails' => array('select' => 'tiffin2userDetails.id, tiffin2userDetails.first_name, tiffin2userDetails.last_name, tiffin2userDetails.rating_of_tiffinwala, tiffin2userDetails.unique_name', 'on' => 'tiffin2userDetails.is_active=1 AND tiffin2userDetails.user_type = 1'), 'aPriceTimes' => array('select' => 'aPriceTimes.price_after_discount, aPriceTimes.order_end_time, aPriceTimes.order_delivery_time, aPriceTimes.quantity_currently_available, aPriceTimes.orderType, aPriceTimes.discount', 'on' => 'aPriceTimes.order_start_time <= ' . '"' . $currDateTime . '"' . ' AND aPriceTimes.order_end_time >= ' . '"' . $currDateTime . '"' . ' AND aPriceTimes.order_delivery_time >= ' . '"' . $currDateTime . '"' . ' AND aPriceTimes.quantity_currently_available > 0 ' . 'AND aPriceTimes.verified_by != "not verified" AND aPriceTimes.is_deleted = "no"', 'joinType' => 'LEFT OUTER JOIN')))); } foreach ($selectedTiffins as $currRec) { if (isset($tiffinAndQuantArr[$currRec->id])) { $response[$currRec->id]["has_changed"] = false; if (isset($location) and !isset($currRec->tiffin2userDetails->aBangaloreLocalities[0])) { $response[$currRec->id]["is_available_at_current_locality"] = false; } else { $response[$currRec->id]["is_available_at_current_locality"] = true; } if (isset($currRec->aPriceTimes[0]) and $currRec->aPriceTimes[0]->quantity_currently_available > 0) { if ($tiffinAndQuantArr[$currRec->id] < 1) { $tiffinAndQuantArr[$currRec->id] = 1; $response["has_changed"] = true; $response[$currRec->id]["has_changed"] = true; $response[$currRec->id]["error_msg"] = AppCommon::$cartErrorMsgTiffinQuanCappedToLimits; $response[$currRec->id]["quantity"] = $tiffinAndQuantArr[$currRec->id]; $response[$currRec->id]["per_unit_price"] = $currRec->aPriceTimes[0]->price_after_discount; $response[$currRec->id]["delivery_time"] = AppCommon::getDetailedDateString($currRec->aPriceTimes[0]->order_delivery_time); } else { if ($tiffinAndQuantArr[$currRec->id] > $currRec->aPriceTimes[0]->quantity_currently_available) { $tiffinAndQuantArr[$currRec->id] = $currRec->aPriceTimes[0]->quantity_currently_available; $response["has_changed"] = true; $response[$currRec->id]["has_changed"] = true; $response[$currRec->id]["error_msg"] = AppCommon::$cartErrorMsgTiffinQuanCappedToLimits; $response[$currRec->id]["quantity"] = $tiffinAndQuantArr[$currRec->id]; $response[$currRec->id]["per_unit_price"] = $currRec->aPriceTimes[0]->price_after_discount; $response[$currRec->id]["delivery_time"] = AppCommon::getDetailedDateString($currRec->aPriceTimes[0]->order_delivery_time); } else { $response[$currRec->id]["quantity"] = $tiffinAndQuantArr[$currRec->id]; $response[$currRec->id]["per_unit_price"] = $currRec->aPriceTimes[0]->price_after_discount; $response[$currRec->id]["delivery_time"] = AppCommon::getDetailedDateString($currRec->aPriceTimes[0]->order_delivery_time); } } if ($response[$currRec->id]["is_available_at_current_locality"]) { $response["total_items_at_locality"] = $response["total_items_at_locality"] + $response[$currRec->id]["quantity"]; $response["total_price"] = $response["total_price"] + $response[$currRec->id]["quantity"] * $response[$currRec->id]["per_unit_price"]; } } else { $response["has_changed"] = true; $response[$currRec->id]["has_changed"] = true; $response[$currRec->id]["error_msg"] = AppCommon::$cartErrorMsgTiffinNotAvailable; } $imagePath = null; $response[$currRec->id]["id"] = $currRec->id; $response[$currRec->id]["tiffin_name"] = $currRec->name; $response[$currRec->id]["tiffin_content"] = $currRec->contents; $response[$currRec->id]["chef_id"] = $currRec->tiffin2userDetails->id; if (isset($currRec->image)) { $imagePath = AppCommon::getAppFolderUrl() . '/images/tiffin_images/' . $currRec->image; } else { $imagePath = AppCommon::getAppFolderUrl() . '/images/tiffin_images/5.jpg'; } //default image $response[$currRec->id]["image_link"] = $imagePath; unset($tiffinAndQuantArr[$currRec->id]); } } foreach ($tiffinAndQuantArr as $key => $value) { $response["has_changed"] = true; $response[$key]["has_changed"] = true; $response[$key]["error_msg"] = AppCommon::$cartErrorMsgTiffinNotExist; } //$response["total_items"] = AppCommon::cartItemCount( ); $response["location"] = $location; return $response; }