/** * @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. $relations = array('candidate' => array(self::BELONGS_TO, 'Candidate', 'candidate_id'), 'election' => array(self::BELONGS_TO, 'Election', 'election_id')); Rate::applyRelations($relations, $this); Comment::applyRelations($relations, $this); return $relations; }
/** * Store a newly created resource in storage. * * @return Response */ public function getRate($question_id, $user_rate) { /*check for user_id if has rated we don't accept else continue other soloution is: on route we use auth filter but this is just for beta using. */ if (Auth::check() == 1) { $count = DB::table('rates')->where('question_id', $question_id)->where('user_id', Auth::id())->count(); if ($count == 0) { $newRate = new Rate(); $newRate->question_id = $question_id; $newRate->user_id = Auth::id(); $newRate->user_rate = $user_rate; $newRate->save(); return Redirect::back(); } else { return "already Voted!"; } } else { return "Only member can vote to audiopedias"; } }
/** * 解释评价信息 * * @return Response */ public function postExplain() { $commentID = base64_decode(Input::get('comment_id')); $shopID = base64_decode(Input::get('shop_id')); $mainOrderID = base64_decode(Input::get('main_order_id')); $explain = Input::get('explain'); $rate = Rate::where('wy_comment_id', $commentID)->where('wy_shop_id', $shopID)->where('wy_main_order_id', $mainOrderID)->first(); }
private function buildQuote(Equipment $equipment, Rate $rate, RentalPeriod $requestedPeriod) { /** @var RentalPeriod $requestedPeriod */ /** @var Rate $rate */ $quantity = ceil($requestedPeriod->getDayCount() / $rate->getUnitDays()); $quote = new RateQuote($equipment); $quote->add(RateQuoteLineItem::make($rate, $quantity)); return $quote; }
/** * Import Exchange Rates */ public function ratesAction() { $lock = $this->getLock('/tmp/rates-import.lock'); if ($lock !== false) { $logger = new FileAdapter(realpath(__DIR__ . '/../logs') . '/rates-import.log'); $di = \Phalcon\DI::getDefault(); $guzzle = $di['guzzle']; $config = $di['config']['rates_api']; $url = $config['url'] . '?access_key=' . $config['access_key'] . '¤cies=' . $config['currencies'] . '&source=' . $config['source']; try { $request = $guzzle->createRequest('GET', $url); $response = $guzzle->send($request); $response = (string) $response->getBody(); $rates = json_decode($response); if ($rates->success == true) { foreach ($rates->quotes as $currencyCode => $exchangeRate) { $currencyCode = preg_replace('/^USD/', '', $currencyCode); $currency = Rate::updateRate($currencyCode, $exchangeRate); if (!$currency) { $logger->log('Failed to update currency : ' . $currencyCode . ' to rate: ' . $exchangeRate, \Phalcon\Logger::ERROR); } } } else { $logger->log('Rates import failed : ' . $response, \Phalcon\Logger::ERROR); } } catch (Exception $e) { $logger->log('Rates import failed : ' . $e->getMessage(), \Phalcon\Logger::ERROR); } $this->releaseLock($lock); } }
function getRate($location_id, $position_id) { App::uses('Rate', 'Model'); /** * Get position and location classes */ $location = $this->Location->find('all', array('conditions' => array('Location.id' => $location_id))); $position = $this->User->Position->find('all', array('conditions' => array('Position.id' => $position_id))); /** * Create a rate class to call the find() method */ $Rate = new Rate(); $result = $Rate->find('all', array('conditions' => array('Rate.location_class' => $location[0]['Location']['class'], 'Rate.position_class' => $position[0]['Position']['class']), 'order' => 'Rate.expense')); /** * Store values into an array and return */ $rates = array(); $rates['breakfast'] = $result[0]['Rate']['rate']; $rates['dinner'] = $result[1]['Rate']['rate']; $rates['lodging'] = $result[2]['Rate']['rate']; $rates['lunch'] = $result[3]['Rate']['rate']; return $rates; }
/** * @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. $relations = array('election' => array(self::BELONGS_TO, 'Election', 'election_id'), 'profile' => array(self::BELONGS_TO, 'Profile', 'user_id'), 'votes' => array(self::HAS_MANY, 'Vote', 'candidate_id'), 'acceptedVotesCount' => array(self::STAT, 'Vote', 'candidate_id', 'condition' => 'status = ' . Vote::STATUS_PASSED)); Rate::applyRelations($relations, $this); Comment::applyRelations($relations, $this); return $relations; }
protected function beforeSave() { if (!parent::beforeSave()) { return false; } if (!$this->checkCreatorIsAdherent()) { throw new PetitionRateException('Petition can be rated by mandate\'s adherents only'); } return true; }
/** * Get exchange rate detail * @param null $currencyCode */ public function getRate($currencyCode = null) { if (!isset($currencyCode)) { $this->sendError('INVALID_PARAMS', 400); } $data = Rate::getRate($currencyCode); if ($data) { $this->sendSuccess($data); } else { $this->sendError('RATE_NOT_FOUND', 404); } }
/** * * */ public function actionCreateRate($id) { $model = $this->loadModel($id); $Rate = new Rate(); $Rate->attributes = $_POST['Rate']; $Rate->userId = Yii::app()->user->id; $Rate->rateableEntityId = $model->entityId; $Rate->addTime = $Rate->upTime = time(); if (!isset($_POST['Rate']['score'])) { // Case: 没有打分 $rateDataProvider = $model->getRateDataProvider(array('criteria' => array('order' => 'addTime DESC'))); $html = $this->renderPartial('_viewRate_panel_rate', array('rateDataProvider' => $rateDataProvider), true); $html .= '<script>alert("请给课程打分,再一起发表评价");</script>'; echo json_encode(array('html' => $html, 'error' => 1)); } else { // Case: 有打分 if ($Rate->save()) { $rateDataProvider = $model->getRateDataProvider(array('criteria' => array('order' => 'addTime DESC'))); $html = $this->renderPartial('_viewRate_panel_rate', array('rateDataProvider' => $rateDataProvider), true); echo json_encode(array('html' => $html, 'error' => 0)); } } }
<?php $cates = Cate::where('type', "工程進度")->whereNotIn('name', array('圖面下載'))->get(); $cates_array = array(); $cates_not = array(); foreach ($cates as $cate) { $cates_array[$cate->id] = $cate->name; $cates_not[$cate->id] = $cate->id; } $id = Input::get("id"); $rate = Rate::find($id); $dd1 = explode(" ", $rate->created_at); $dd = explode("-", $dd1[0]); $category_id = Input::get("category_id"); if (!empty($id)) { // print_r($cates_not); $pics = DB::table("rate_pics")->where('rate_id', $id)->whereIn('category_id', $cates_not)->get(); } else { $pics = DB::table("rate_pics")->first(); } ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>工程進度</title> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="css/css.css"> <link rel="stylesheet" type="text/css" href="css/process.css">
function normalize($save="",$table="") { if (!$table) $table = $this->CDRS->table; if ($this->CDRS->CSCODE && $CarrierInfo = $this->CDRS->CDRTool['normalize']['CS_CODES'][$this->CDRS->CSCODE]) { // We found a carrier so we set the BillingId $this->BillingId = $CarrierInfo[BillingPartyId]; } if ($save) { if (!$this->id) { return 0; } $query =""; $query1 =""; $query2 =""; if ($this->CDRS->normalizedField) { if ($updatedFields) $query .= ", "; $updatedFields++; $query.=sprintf(" %s='1' ",addslashes($this->CDRS->normalizedField)); $mongo_field = array_search($this->CDRS->normalizedField, $this->CDRS->CDRFields); $this->mongo_cdr[$mongo_field] = 1; } if ($this->CDRS->BillingPartyIdField && $this->BillingPartyId) { if ($updatedFields) $query .= ", "; $updatedFields++; $query.=sprintf(" %s = '%s' ",addslashes($this->CDRS->BillingPartyIdField),addslashes($this->BillingPartyId)); $mongo_field = array_search($this->CDRS->BillingPartyIdField, $this->CDRS->CDRFields); $this->mongo_cdr[$mongo_field] = $this->BillingPartyId; } if (strlen($this->durationNormalized) && $this->durationNormalized != $this->duration) { if ($updatedFields) $query .= ", "; $updatedFields++; $query.=sprintf(" %s ='%s' ",addslashes($this->CDRS->durationField),addslashes($this->durationNormalized)); $this->duration=$this->durationNormalized; $mongo_field = array_search($this->CDRS->durationField, $this->CDRS->CDRFields); $this->mongo_cdr[$mongo_field] = intval($this->durationNormalized); } else { $mongo_field = array_search($this->CDRS->durationField, $this->CDRS->CDRFields); $this->mongo_cdr[$mongo_field] = intval($this->duration); } if ($this->CDRS->DestinationIdField) { if ($updatedFields) $query .= ", "; $updatedFields++; $query.=sprintf(" %s = '%s' ",addslashes($this->CDRS->DestinationIdField),addslashes($this->DestinationId)); $mongo_field = array_search($this->CDRS->DestinationIdField, $this->CDRS->CDRFields); $this->mongo_cdr[$mongo_field] = $this->DestinationId; } if ($this->CDRS->ResellerIdField) { if ($updatedFields) $query .= ", "; $updatedFields++; $query.=sprintf(" %s = '%s' ",addslashes($this->CDRS->ResellerIdField),addslashes($this->ResellerId)); $mongo_field = array_search($this->CDRS->ResellerIdField, $this->CDRS->CDRFields); $this->mongo_cdr[$mongo_field] = $this->ResellerId; } if ($this->usernameNormalized && $this->usernameNormalized!=$this->username) { if ($updatedFields) $query .= ", "; $updatedFields++; $query.=sprintf(" %s = '%s' ",addslashes($this->CDRS->usernameField),addslashes($this->usernameNormalized)); $mongo_field = array_search($this->CDRS->usernameField, $this->CDRS->CDRFields); $this->mongo_cdr[$mongo_field] = $this->usernameNormalized; } if ($this->aNumberNormalized && $this->aNumberNormalized!=$this->aNumber) { if ($updatedFields) $query .= ", "; $updatedFields++; $query.=sprintf(" %s = '%s' ",addslashes($this->CDRS->aNumberField),addslashes($this->aNumberNormalized)); $this->aNumber=$this->aNumberNormalized; $mongo_field = array_search($this->CDRS->aNumberField, $this->CDRS->CDRFields); $this->mongo_cdr[$mongo_field] = $this->aNumberNormalized; } if ($this->CDRS->applicationField && $this->applicationNormalized) { if ($updatedFields) $query .= ", "; $updatedFields++; $query.=sprintf(" %s = '%s' ",addslashes($this->CDRS->applicationField), addslashes($this->applicationNormalized)); $this->application=$this->applicationNormalized; $mongo_field = array_search($this->CDRS->applicationField, $this->CDRS->CDRFields); $this->mongo_cdr[$mongo_field] = $this->applicationNormalized; } if ($this->CDRS->flowField && $this->flow) { if ($updatedFields) $query .= ", "; $updatedFields++; $query.=sprintf(" %s = '%s' ",addslashes($this->CDRS->flowField),addslashes($this->flow)); $mongo_field = array_search($this->CDRS->flowField, $this->CDRS->CDRFields); $this->mongo_cdr[$mongo_field] = $this->flow; } if ($this->domainNormalized && $this->domainNormalized != $this->domain) { if ($updatedFields) $query .= ", "; $updatedFields++; $query.=sprintf(" %s = '%s' ",addslashes($this->CDRS->domainField),addslashes($this->domainNormalized)); $this->domainNumber=$this->domainNormalized; $this->domain=$this->domainNormalized; $mongo_field = array_search($this->CDRS->domainField, $this->CDRS->CDRFields); $this->mongo_cdr[$mongo_field] = $this->domainNormalized; } if ($this->cNumberNormalized && $this->cNumberNormalized!=$this->cNumber) { if ($updatedFields) $query .= ", "; $updatedFields++; $query.=sprintf(" %s = '%s' ",addslashes($this->CDRS->cNumberField),addslashes($this->cNumberNormalized)); $this->cNumber=$this->cNumberNormalized; $mongo_field = array_search($this->CDRS->cNumberField, $this->CDRS->CDRFields); $this->mongo_cdr[$mongo_field] = $this->cNumberNormalized; } if ($this->CDRS->BillingIdField && $this->BillingId) { if ($updatedFields) $query .= ", "; $updatedFields++; $query.=sprintf(" %s = '%s' ",addslashes($this->CDRS->BillingIdField),addslashes($this->BillingId)); $mongo_field = array_search($this->CDRS->BillingIdField, $this->CDRS->CDRFields); $this->mongo_cdr[$mongo_field] = $this->BillingId; } if ($this->CDRS->RemoteAddressField && $this->RemoteAddressNormalized && $this->RemoteAddressNormalized!= $this->RemoteAddress) { if ($updatedFields) $query .= ", "; $updatedFields++; $query.=sprintf(" %s = '%s' ",addslashes($this->CDRS->RemoteAddressField),addslashes($this->RemoteAddressNormalized)); $mongo_field = array_search($this->CDRS->RemoteAddressField, $this->CDRS->CDRFields); $this->mongo_cdr[$mongo_field] = $this->RemoteAddressNormalized; } if ($this->CDRS->CanonicalURIField && $this->CanonicalURINormalized && $this->CanonicalURINormalized!= $this->CanonicalURI) { if ($updatedFields) $query .= ", "; $updatedFields++; $query.=sprintf(" %s = '%s' ",addslashes($this->CDRS->CanonicalURIField),addslashes($this->CanonicalURINormalized)); $mongo_field = array_search($this->CDRS->CanonicalURIField, $this->CDRS->CDRFields); $this->mongo_cdr[$mongo_field] = $this->CanonicalURINormalized; } if ($this->stopTimeNormalized) { if ($updatedFields) $query .= ", "; $updatedFields++; $query.=sprintf(" %s = '%s' ",addslashes($this->CDRS->stopTimeField),addslashes($this->stopTimeNormalized)); $mongo_field = array_search($this->CDRS->stopTimeField, $this->CDRS->CDRFields); $this->mongo_cdr[$mongo_field] = $this->stopTimeNormalized; } if ($this->CDRS->ratingEnabled && ($this->duration || $this->application == 'message')) { if ($this->DestinationId) { $Rate = new Rate($this->CDRS->rating_settings, $this->CDRS->cdrtool); if ($this->application == 'message') { $RateDictionary=array( 'callId' => $this->callId, 'timestamp' => $this->timestamp, 'duration' => $this->duration, 'DestinationId' => $this->DestinationId, 'BillingPartyId' => $this->BillingPartyId, 'ResellerId' => $this->ResellerId, 'domain' => $this->domain, 'gateway' => $this->gateway, 'RatingTables' => $this->CDRS->RatingTables, 'aNumber' => $this->aNumber, 'cNumber' => $this->cNumber ); $Rate->calculateMessage($RateDictionary); } else { $RateDictionary=array( 'callId' => $this->callId, 'timestamp' => $this->timestamp, 'duration' => $this->duration, 'DestinationId' => $this->DestinationId, 'inputTraffic' => $this->inputTraffic, 'outputTraffic' => $this->outputTraffic, 'BillingPartyId' => $this->BillingPartyId, 'ResellerId' => $this->ResellerId, 'domain' => $this->domain, 'gateway' => $this->gateway, 'RatingTables' => $this->CDRS->RatingTables, 'aNumber' => $this->aNumber, 'cNumber' => $this->cNumber, 'ENUMtld' => $this->ENUMtld, 'application' => $this->application ); $Rate->calculateAudio($RateDictionary); } $this->pricePrint = $Rate->pricePrint; $this->price = $Rate->price; $this->rateInfo = $Rate->rateInfo; $this->rateDuration = $Rate->duration; if ($Rate->broken_rate) { $this->broken_rate=true; } } else { $this->rateInfo=''; $this->pricePrint=''; $this->price=''; } if ($this->CDRS->priceField) { if ($updatedFields) $query .= ", "; $updatedFields++; $query.=sprintf(" %s = '%s' ",addslashes($this->CDRS->priceField),addslashes($this->pricePrint)); $mongo_field = array_search($this->CDRS->priceField, $this->CDRS->CDRFields); $this->mongo_cdr[$mongo_field] = floatval($this->pricePrint); if ($this->CDRS->rateField ) { if ($updatedFields) $query .= ", "; $updatedFields++; $query.=sprintf(" %s = '%s' ",addslashes($this->CDRS->rateField),addslashes($this->rateInfo)); $mongo_field = array_search($this->CDRS->rateField, $this->CDRS->CDRFields); $this->mongo_cdr[$mongo_field] = $this->rateInfo; } } } $query1 = sprintf("update %s set %s where %s = '%s'",addslashes($table),$query,addslashes($this->idField),addslashes($this->id)); dprint($query1); #TODO remove me, I am used to temporary sync mysql data with mongo data if ($this->CDRS->mongo_table) { $mongo_field = array_search($this->idField, $this->CDRS->CDRFields); try { $this->CDRS->mongo_table->update(array($mongo_field => $this->id), $this->mongo_cdr, array("upsert" => true)); } catch (MongoException $e) { printf("Caught Mongo exception: %s", $e->getMessage()); } catch (Exception $e) { printf("Caught exception: %s", $e->getMessage()); } } if ($updatedFields) { if ($this->CDRS->CDRdb1->query($query1)) { if ($this->CDRS->CDRdb1->affected_rows()) { if ( $this->isBillingPartyLocal() && $table == "radacct".date('Ym')) { // cache usage only if current month $_traffic=($this->inputTraffic+$this->outputTraffic)/2; $_usage=array('calls' => 1, 'duration' => $this->duration, 'cost' => $this->price, 'cost_today' => $this->price, 'traffic' => $_traffic ); $this->cacheQuotaUsage($_usage); } } else { if (preg_match("/^(\w+)(\d{4})(\d{2})$/",$table,$m)) { $previousTable=$m[1].date('Ym', mktime(0, 0, 0, $m[3]-1, "01", $m[2])); $query2 = sprintf("update %s set %s where %s = '%s'",addslashes($previousTable),$query,addslashes($this->idField),addslashes($this->id)); if ($this->CDRS->CDRdb1->query($query2)) { if ($this->CDRS->CDRdb1->affected_rows()) { if ( $this->isBillingPartyLocal() && $previousTable == "radacct".date('Ym')) { // cache usage only if current month $_traffic=($this->inputTraffic+$this->outputTraffic)/2; $_usage=array('calls' => 1, 'duration' => $this->duration, 'cost' => $this->price, 'cost_today' => $this->price, 'traffic' => $_traffic ); $this->cacheQuotaUsage($_usage); } } } else { $log=sprintf ("Database error: %s (%s)",$this->CDRS->CDRdb1->Error,$this->CDRS->CDRdb1->Errno); syslog(LOG_NOTICE, $log); print($log); return 0; } } } return 1; } else { $log=sprintf ("Database error for query %s: %s (%s)",$query1,$this->CDRS->CDRdb1->Error,$this->CDRS->CDRdb1->Errno); syslog(LOG_NOTICE, $log); print($log); return 0; } } } else { if ($this->CDRS->BillingPartyIdField && $CarrierInfo['BillingPartyId']) { $this->domain = $CarrierInfo['BillingDomain']; } if ($this->usernameNormalized && $this->usernameNormalized!=$this->username) { $this->username=$this->usernameNormalized; } if ($this->aNumberNormalized && $this->aNumberNormalized!=$this->aNumber) { $this->aNumber=$this->aNumberNormalized; } if ($this->domainNormalized && $this->domainNormalized != $this->domain) { $this->domainNumber=$this->domainNormalized; } if ($this->cNumberNormalized && $this->cNumberNormalized!=$this->cNumber) { $this->cNumber=$this->cNumberNormalized; } if ($this->CDRS->RemoteAddressField && $this->RemoteAddressNormalized && $this->RemoteAddressNormalized!= $this->RemoteAddress) { $this->RemoteAddress=$this->RemoteAddressNormalized; } } return 1; }
$_page_request = filter_input(INPUT_GET, 'page', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '^[a-z0-9]{3,10}$^']]); /* API requests */ $_api_token_login = filter_input(INPUT_POST, 'token', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '^[a-z0-9]{64}$^']]); $_api_passwd_password = filter_input(INPUT_POST, 'secret', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '^[a-z0-9]{64}$^']]); /* Run API request */ if ($_api_token_login && $_api_passwd_password && $_page_request == 'api') { $_ajax_request = true; //Enable JSON output $_global_api = new API($connection); /* Try to login */ if (!$_global_api->initialize($_api_token_login, $_api_passwd_password)) { echo json_encode(array('connected' => false, 'res' => $_global_api->_warning)); die; } /* API Rate limit control */ $_global_rate_limit = new Rate($connection, $_global_api->getID()); if (!$_global_rate_limit->allowed()) { echo json_encode(array('connected' => true, 'res' => 'Maximum API rate limit reached, please wait!')); die; } /* read given cmd */ $_api_cmd = filter_input(INPUT_POST, 'cmd', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '^[a-zA-Z]{5,25}$^']]); if (!$_api_cmd) { echo json_encode(array('connected' => true, 'cmd' => null)); } else { if ($_api_cmd == 'newsession') { echo json_encode(array('connected' => true, 'cmd' => 'newsession', 'res' => $_global_api->new_session(filter_input(INPUT_POST, 'sName', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '^([a-zA-Z\'()-_[:blank:]-]{5,50})$^']]), filter_input(INPUT_POST, 'sMode', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '^([a-zA-Z\'[:blank:]-]{5,25})$^']]), filter_input(INPUT_PORT, 'sMap', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '^([a-zA-Z\'[:blank:]-]{5,25})$^']]), filter_input(INPUT_POST, 'sMaxSlot', FILTER_VALIDATE_INT), filter_input(INPUT_POST, 'sHost', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '^([a-zA-Z0-9\\-_s,]{3,16})$^']]), filter_input(INPUT_POST, 'mKey', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '^[a-zA-Z0-9?@\\.;:!_-]{5,22}$^']]), filter_input(INPUT_POST, 'mKeyRequired', FILTER_VALIDATE_BOOLEAN), filter_input(INPUT_POST, 'sVisible', FILTER_VALIDATE_BOOLEAN)), 'message' => $_global_api->_warning)); } else { if ($_api_cmd == 'endsession') { echo json_encode(array('connected' => true, 'cmd' => $_api_cmd, 'res' => $_global_api->end_session(filter_input(INPUT_POST, 'cSession', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '^[a-z0-9]{64}$^']])), 'message' => $_global_api->_warning)); } else {
public static function lowestRoomRate($hotel_id, $room_type_id, $specification_id, $meal_basis_id, $st_date, $ed_date) { if (Session::has('adult_child')) { $adult = Session::get('adult'); $child = Session::get('child'); } else { $adult = Session::get('adult'); $child = Session::get('child'); } $x = 0; $room_rates = 0; $room_rate = 0; if (Session::has('market')) { $market = Session::get('market'); } else { $market = 1; } $get_market_details = Market::where('id', $market)->first(); $tax_type = $get_market_details->tax_type; $tax = $get_market_details->tax + 100; $handling_fee_type = $get_market_details->handling_fee_type; $handling_fee = $get_market_details->handling_fee; $from_date = date('Y-m-d', strtotime(str_replace('-', '/', $st_date))); $to_date = date('Y-m-d', strtotime(str_replace('-', '/', $ed_date))); $dates = (strtotime($ed_date) - strtotime($st_date)) / 86400; // dd($hotel_id .'/'. $room_type_id .'/'. $specification_id .'/'. $meal_basis_id .'/'. $st_date .'/'. $ed_date); for ($x = 1; $x <= $dates; $x++) { $get_room_rate = Rate::where('hotel_id', '=', $hotel_id)->where('room_type_id', $room_type_id)->where('room_specification_id', $specification_id)->where('meal_basis_id', $meal_basis_id)->where('from', '<=', $from_date)->where('to', '>', $from_date)->where('market_id', $market)->get(); foreach ($get_room_rate as $low_rates) { $room_rate = $low_rates->rate; } $from_date = date('Y-m-d', strtotime($from_date . ' + 1 days')); $room_rates = $room_rates + $room_rate; } $lowest_room_rate = number_format($room_rates / $dates, 2); return $lowest_room_rate; }
/** * Returns the static model of the specified AR class. * @param string $className active record class name. * @return VoteCommentRate the static model class */ public static function model($className = __CLASS__) { return parent::model($className); }
<div id="main" class="clearfix"> <div id="middle"> <img src="images/project/middleText.png" /> </div> <div class="Group"> <?php // Cookie::forget('key'); // $value = Cookie::get('key'); // Session::forget('key'); // echo "/".$value."/"; // $value = Session::get('key'); $rates = Rate::all(); foreach ($rates as $rate) { $dd = explode(" ", $rate->updated_at); ?> <div class="case clearfix"> @if( strlen($rate->image) >3 ) <img src="{{$rate->image}}" > @endif <div class="caseDetail"> <p class="caseName">{{$rate->title}}</p> <p><span class="col">更新日期</span>:{{$rate->update_day}}</p> <?php $cont = explode("<p>", $rate->content); ?>
public static function update_internal_fees() { $id = Core::validate(self::getVar('id')); $fieldName = Core::validate(self::getVar('fieldName')); $value = Core::validate(self::getVar('value')); $goodInput = false; switch ($fieldName) { case 'Fee': if ($value != null && Core::isDouble($value) && $value >= 0) { $goodInput = true; } break; default: break; } if ($goodInput == true) { $rate = new Rate(); $rate->setId($id); $rate->update(array($fieldName => $value)); Core::printSuccessJson(''); } else { Core::printErrorJson('Invalid input: ' . $value); } }
public function hookAdminOrder($params) { $versionSpecialClass = ''; if (!file_exists(_PS_MODULE_DIR_ . 'seur/img/logonew_32.png') && file_exists(_PS_MODULE_DIR_ . 'seur/img/logonew.png')) { ImageManager::resize(_PS_MODULE_DIR_ . 'seur/img/logonew.png', _PS_MODULE_DIR_ . 'seur/img/logonew_32.png', 32, 32, 'png'); } if (version_compare(_PS_VERSION_, '1.5', '<')) { $versionSpecialClass = 'ver14'; } $this->displayWarning(); if (Configuration::get('SEUR_Configured') == 1) { $cookie = $this->context->cookie; $token = Tools::getValue('token'); $back = Tools::safeOutput($_SERVER['REQUEST_URI']); $seur_carriers = SeurLib::getSeurCarriers(false); $ids_seur_carriers = array(); foreach ($seur_carriers as $value) { $ids_seur_carriers[] = (int) $value['id']; } $order = new Order((int) $params['id_order']); $address_saved = DB::getInstance()->getValue(' SELECT `id_address_delivery` FROM `' . _DB_PREFIX_ . 'seur_order` WHERE `id_order` = "' . (int) $order->id . '" '); if ($address_saved === '0') { $this->context->smarty->assign('pickup_point_warning', true); } if (!Validate::isLoadedObject($order)) { return false; } $delivery_price = $order_weigth = 0; $products = $order->getProductsDetail(); foreach ($products as $product) { $order_weigth += (double) $product['product_weight'] * (double) $product['product_quantity']; } $order_weigth = $order_weigth < 1.0 ? 1.0 : (double) $order_weigth; $customer = new Customer((int) $order->id_customer); $address_delivery = new Address((int) $order->id_address_delivery, (int) $cookie->id_lang); if (!Validate::isLoadedObject($address_delivery)) { return false; } $iso_country = Country::getIsoById((int) $address_delivery->id_country); if ($iso_country == 'PT') { $post_code = explode(' ', $address_delivery->postcode); $post_code = $post_code[0]; } else { $post_code = $address_delivery->postcode; } $international_orders = SeurLib::getConfigurationField('international_orders'); $date_calculate = strtotime('-14 day', strtotime(date('Y-m-d'))); $date_display = date('Y-m-d H:m:i', $date_calculate); if (strtotime($order->date_add) > strtotime($date_display) && in_array((int) $order->id_carrier, $ids_seur_carriers)) { if (!$international_orders && ($iso_country == 'ES' || $iso_country == 'PT' || $iso_country == 'AD') || $international_orders) { if (!SeurLib::getSeurOrder((int) $order->id)) { SeurLib::setSeurOrder((int) $order->id, 1, $order_weigth, null); } elseif (Tools::getValue('numBultos') && Tools::getValue('pesoBultos')) { SeurLib::setSeurOrder((int) $order->id, (int) Tools::getValue('numBultos'), str_replace(',', '.', Tools::getValue('pesoBultos')), null); } $order_data = SeurLib::getSeurOrder((int) $order->id); $response_post_code = Town::getTowns($post_code); $order_weigth = (double) $order_weigth != $order_data['peso_bultos'] ? (double) $order_data['peso_bultos'] : (double) $order_weigth; if (is_object($response_post_code)) { $towns = array(); $num = (int) $response_post_code->attributes()->NUM[0]; for ($i = 1; $i <= $num; $i++) { $name = 'REG' . $i; $towns[] = utf8_decode((string) $response_post_code->{$name}->NOM_POBLACION); } } $name = $address_delivery->firstname . ' ' . $address_delivery->lastname; $direccion = $address_delivery->address1 . ' ' . $address_delivery->address2; $newcountry = new Country((int) $address_delivery->id_country, (int) $cookie->id_lang); $iso_merchant = SeurLib::getMerchantField('country'); $rate_data = array('town' => $address_delivery->city, 'peso' => (double) $order_weigth, 'post_code' => $post_code, 'bultos' => $order_data['numero_bultos'], 'ccc' => SeurLib::getMerchantField('ccc'), 'franchise' => SeurLib::getMerchantField('franchise'), 'iso' => $newcountry->iso_code, 'iso_merchant' => $iso_merchant, 'id_employee' => $cookie->id_employee, 'token' => Tools::getAdminTokenLite('AdminOrders'), 'back' => $back); $order_messages_str = ''; $info_adicional_str = $address_delivery->other; $order_messages = Message::getMessagesByOrderId((int) $params['id_order']); if (is_array($order_messages)) { foreach ($order_messages as $order_messag_tmp) { $order_messages_str .= "\n" . $order_messag_tmp['message']; } if (substr_count($order_messages_str, "\n") > 5) { $order_messages_str = str_replace(array("\r", "\n"), ' | ', $order_messages_str); } if (Tools::strlen($order_messages_str) > 250) { $order_messages_str = Tools::substr($order_messages_str, 0, 247) . '...'; } $order_messages_str = trim($order_messages_str); } if (!empty($order_messages_str)) { $info_adicional_str = $order_messages_str; } $label_data = array('pedido' => sprintf('%06d', (int) $order->id), 'total_bultos' => $order_data['numero_bultos'], 'total_kilos' => (double) $order_weigth, 'direccion_consignatario' => $direccion, 'consignee_town' => $address_delivery->city, 'codPostal_consignatario' => $post_code, 'telefono_consignatario' => !empty($address_delivery->phone_mobile) ? $address_delivery->phone_mobile : $address_delivery->phone, 'movil' => $address_delivery->phone_mobile, 'name' => $name, 'companyia' => !empty($address_delivery->company) ? $address_delivery->company : '', 'email_consignatario' => Validate::isLoadedObject($customer) ? $customer->email : '', 'dni' => $address_delivery->dni, 'info_adicional' => $info_adicional_str, 'country' => $newcountry->name, 'iso' => $newcountry->iso_code, 'iso_merchant' => $iso_merchant, 'admin_dir' => utf8_encode(_PS_ADMIN_DIR_), 'id_employee' => $cookie->id_employee, 'token' => Tools::getAdminTokenLite('AdminOrders'), 'back' => $back); if (strcmp($order->module, 'seurcashondelivery') == 0) { $rate_data['reembolso'] = (double) $order->total_paid; $label_data['reembolso'] = (double) $order->total_paid; } $carrier_pos = SeurLib::getSeurCarrier('SEP'); $datospos = ''; if ((int) $order->id_carrier == $carrier_pos['id']) { $datospos = SeurLib::getOrderPos((int) $order->id_cart); if (!empty($datospos)) { $label_data = array('pedido' => sprintf('%06d', (int) $order->id), 'total_bultos' => $order_data['numero_bultos'], 'total_kilos' => (double) $order_weigth, 'direccion_consignatario' => $direccion, 'consignee_town' => $datospos['city'], 'codPostal_consignatario' => $datospos['postal_code'], 'telefono_consignatario' => !empty($address_delivery->phone_mobile) ? $address_delivery->phone_mobile : $address_delivery->phone, 'movil' => $address_delivery->phone_mobile, 'name' => $name, 'companyia' => $datospos['company'], 'email_consignatario' => Validate::isLoadedObject($customer) ? $customer->email : '', 'dni' => $address_delivery->dni, 'info_adicional' => $info_adicional_str, 'country' => $newcountry->name, 'iso' => $newcountry->iso_code, 'cod_centro' => $datospos['id_seur_pos'], 'iso_merchant' => $iso_merchant); $rate_data['cod_centro'] = $datospos['id_seur_pos']; } } if ($iso_country == 'ES' || $iso_country == 'PT' || $iso_country == 'AD') { $xml = Rate::getPrivateRate($rate_data); if (is_object($xml)) { foreach ($xml as $tarifa) { $delivery_price += (double) $tarifa->VALOR; } } } if (Tools::getValue('submitLabel')) { if ($this->isPrinted((int) $order->id)) { $success = true; } else { $success = Label::createLabels($label_data, 'pdf'); } if ($success === true) { if (!$this->setAsPrinted((int) $order->id)) { $this->context->smarty->assign('error', $this->l('Could not set printed value for this order')); } else { $this->printLabel((int) $order->id, 'pdf'); } } else { $this->context->smarty->assign('error', $success); } } if (Tools::getValue('submitPrint')) { if ($this->isPrinted((int) $order->id, true)) { $success = true; } else { $success = Label::createLabels($label_data, 'zebra'); } if ($success === true) { if (!$this->setAsPrinted((int) $order->id, true)) { $this->context->smarty->assign('error', $this->l('Could not set printed value for this order')); } else { $this->printLabel((int) $order->id, 'txt'); } } else { $this->context->smarty->assign('error', $success); } } $seur_carriers = SeurLib::getSeurCarriers(false); $pickup = Pickup::getLastPickup(); if (!empty($pickup)) { $pickup_date = explode(' ', $pickup['date']); $pickup_date = $pickup_date[0]; } $address_error = 0; if (!empty($towns) && !in_array(mb_strtoupper($this->replaceAccentedChars($address_delivery->city), 'UTF-8'), $towns)) { $address_error = 1; } $pickup_s = 0; if ($pickup && strtotime(date('Y-m-d')) == strtotime($pickup_date)) { $pickup_s = 1; } $state = Expedition::getExpeditions(array('reference_number' => sprintf('%06d', (int) $order->id))); $is_empty_state = false; $xml_s = false; if (!empty($state->out)) { $is_empty_state = true; } else { $string_xml = htmlspecialchars_decode($state->out); $string_xml = str_replace('&', '& ', $string_xml); $xml_s = simplexml_load_string($string_xml); } $rate_data_ajax = Tools::jsonEncode($rate_data); $path = '../modules/seur/js/'; $file = (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'modules/seur/files/deliveries_labels/' . sprintf('%06d', (int) $order->id) . '.txt'; $filePath = _PS_MODULE_DIR_ . 'seur/files/deliveries_labels/' . sprintf('%06d', (int) $order->id) . '.txt'; $label_data['file'] = $file; $this->context->smarty->assign(array('path' => $this->_path, 'request_uri' => $_SERVER['REQUEST_URI'], 'module_instance' => $this, 'address_error' => $address_error, 'address_error_message' => $this->l('Addressess error, please check the customer address.'), 'pickup_s' => $pickup_s, 'pickup' => $pickup, 'isEmptyState' => $is_empty_state, 'xml' => $xml_s, 'order_data' => $order_data, 'iso_country' => $iso_country, 'order_weigth' => $order_weigth, 'delivery_price' => $delivery_price, 'rate_data_ajax' => $rate_data_ajax, 'js_path' => $path, 'token' => $token, 'order' => $order, 'label_data' => $label_data, 'fileExists' => file_exists($filePath), 'file' => $file, 'datospos' => $datospos, 'versionSpecialClass' => $versionSpecialClass, 'configured' => (int) Configuration::get('SEUR_Configured'), 'printed' => (bool) ($this->isPrinted((int) $order->id) || $this->isPrinted((int) $order->id, true)))); return $this->display(__FILE__, 'views/templates/admin/orders.tpl'); } } } else { $this->context->smarty->assign(array('configured' => Configuration::get('SEUR_Configured'), 'path' => $this->_path, 'configuration_warning_message' => $this->l('Please, first configure your SEUR module as a merchant.'))); return $this->display(__FILE__, 'views/templates/admin/orders.tpl'); } }
} // Default view if (!empty($id)) { if ($idea = Idea::GetById($id)) { Viewer::AddData("comments", Comments::GetByIdea($idea)); Viewer::AddData("idea", $idea); Viewer::AddData("title", $idea->idea_title); if (isset($_GET["rate_plus"])) { $rated = 3; } elseif (isset($_GET["rate_minus"])) { $rated = 2; } else { $rated = 1; } if (User::Logged()) { $rate = Rate::Find($idea, User::$current); if (!empty($rate)) { $rated = 4; } Viewer::AddData("rated", $rated); } Viewer::UseTemplate("idea.tpl"); $action = "idea"; } } } else { Viewer::Restricted(); $action = "idea"; } if (!$action) { Viewer::RequestError();
public function addToCart() { $hot_id = Input::get('hotel_id'); if (Input::has('room_refer_id')) { $room_identity = Input::get('room_refer_id'); $room_identity_array = explode("_", $room_identity); $hotel_id = $room_identity_array[0]; $room_id = $room_identity_array[1]; $room_specification_id = $room_identity_array[2]; $meal_basis_id = $room_identity_array[3]; $room_count = Session::get('room_count'); $hotel_name = Hotel::where('id', $hotel_id)->first()->name; $hotel_address = Hotel::where('id', $hotel_id)->first()->address; $room_name = RoomType::where('id', $room_id)->first()->room_type; $room_specification = RoomSpecification::where('id', $room_specification_id)->first()->room_specification; $meal_basis = MealBasis::where('id', $meal_basis_id)->first()->meal_basis_name; $adult = RoomSpecification::where('id', $room_specification_id)->first()->adults; $child = RoomSpecification::where('id', $room_specification_id)->first()->children; $nights = Session::get('date_gap'); $st_date = date('Y-m-d', strtotime(Session::get('st_date'))); $ed_date = date('Y-m-d', strtotime(Session::get('ed_date'))); $date_count = Voucher::getNights($st_date, $ed_date)->days; //dd($room_id.'/'.$room_specification_id.'/'.$meal_basis_id); $room_rate = Rate::lowestRoomRate($hotel_id, $room_id, $room_specification_id, $meal_basis_id, $st_date, $ed_date); $room_rate_with_tax = Rate::lowestRoomRateWithTax($hotel_id, $room_id, $room_specification_id, $meal_basis_id, $st_date, $ed_date); $room_cost = $room_rate_with_tax * $room_count * $date_count; if (Session::has('market')) { $market = Session::get('market'); } else { $market = 1; } $get_market_details = Market::where('id', $market)->first(); $tax_type = $get_market_details->tax_type; $tax = $get_market_details->tax; $handling_fee_type = $get_market_details->handling_fee_type; $handling_fee = $get_market_details->handling_fee; $supplement_rate = Rate::supplementRate($hotel_id, $room_id, $room_specification_id, $meal_basis_id, $st_date, $ed_date); if ($market == 1) { if ($tax_type == 0) { $total_tax = $room_rate_with_tax / 100 * $tax; } else { $total_tax = $tax; } if ($handling_fee_type == 0) { $total_handling_fee = $room_rate / 100 * $handling_fee; } else { $total_handling_fee = $handling_fee; } $hotel_handling_fee = $total_handling_fee; $hotel_tax = $total_tax; } else { $total_tax = 0; if ($handling_fee_type == 0) { $total_handling_fee = $room_rate / 100 * $handling_fee; } else { $total_handling_fee = $handling_fee; } $hotel_tax = $total_tax; $hotel_handling_fee = $total_handling_fee; } $rate_box_details = array('hotel_id' => $hotel_id, 'hotel_name' => $hotel_name, 'hotel_address' => $hotel_address, 'room_name' => $room_name, 'room_type_id' => $room_id, 'room_specification' => $room_specification, 'room_specification_id' => $room_specification_id, 'meal_basis' => $meal_basis, 'meal_basis_id' => $meal_basis_id, 'room_cost' => $room_cost, 'hotel_tax' => $hotel_tax, 'hotel_handling_fee' => $hotel_handling_fee, 'supplement_rate' => $supplement_rate, 'room_count' => $room_count, 'unit_price' => $room_rate_with_tax, 'hotel_room_price' => $room_rate, 'adult' => $adult, 'child' => $child, 'nights' => $nights, 'room_identity' => $room_identity, 'check_in' => $st_date, 'check_out' => $ed_date, 'unit_cost_price' => (double) $hotel_tax + (double) $room_cost); if (Session::has('rate_box_details_' . $hotel_id)) { $data = Session::get('rate_box_details_' . $hotel_id); $data[$room_identity] = $rate_box_details; } else { $data = []; $data[$room_identity] = $rate_box_details; } Session::put('rate_box_details_' . $hotel_id, $data); } //dd(Session::get('rate_box_details_'.$hotel_id)); return Response::json($hotel_id); }
<?php try { require_once '../classes/Rate.php'; $objRate = new Rate(); if ($objRate->reset()) { echo json_encode(array('error' => false)); } else { echo json_encode(array('error' => true, 'case' => 2)); } } catch (Exception $e) { echo json_encode(array('error' => true, 'case' => 1)); }
Route::post('/mailcontentsUpdate', "MailcontentController@update"); //CategoryController Route::get('/delCategory/{id}', "CategoryController@delCategory"); Route::get('/categories', "CategoryController@index"); Route::get('/categories/create', "CategoryController@create"); Route::get('/category/{id}', "CategoryController@edit"); Route::post('/categoryStore', "CategoryController@categoryStore"); Route::post('/categoryUpdate', "CategoryController@categoryUpdate"); Route::get('/delCate', function () { $id = Input::get("id"); Cate::find($id)->delete(); }); }); Route::post('/delRateImage', function () { // print_r(Input::get() ); $rate = Rate::where("id", Input::get("id"))->update(array("image" => '')); if (Input::get("id") > 0) { return 1; } else { return 0; } // return View::make("frontend.hotcase"); }); // App::missing(function($exception) // { // // Log::info('This is some useful information.'); // // Log::warning('Something could be going wrong.'); // // Log::error('Something is really going wrong.');
private function currencyList() { $tempArr = array(); $arr = Rate::model()->findAll(array( 'select'=>'id,code', )); if(!empty($arr)){ foreach($arr as $value){ $tempArr[$value->id] = $value->code; } } return $tempArr; }
public function updateSupplementRates($hotelid) { $validator = Validator::make($data = Input::all(), SupplementRate::$rules); if ($validator->fails()) { return Response::json(array("errors" => $validator->errors())); } $rates = Input::get('rates'); $keys = Input::get('keys'); $market = Input::get('market_id'); $inserted_ids = array(); $rates = explode(',', $rates); $keys = explode(',', $keys); $data = array(); $deleted_items = false; $i = -1; foreach ($rates as $rate) { $i++; $ids = explode("-", $keys[$i]); $data = array('from' => Input::get("from"), 'to' => Input::get("to"), 'supplement_name' => Input::get("supplement_name"), 'rate' => $rate, 'hotel_id' => $hotelid, 'meal_basis_id' => $ids[0], 'room_specification_id' => $ids[1], 'room_type_id' => Input::get("room_type_id"), 'user_id' => Auth::user()->id, 'val' => 1, 'market_id' => $market); $from = $data["from"]; $to = $data["to"]; $conditions = array('meal_basis_id' => $ids[0], 'room_specification_id' => $ids[1], 'room_type_id' => Input::get("room_type_id"), 'market_id' => $market); $newperiods = array(); $newperiods[] = array('from' => $from, 'to' => $to, 'rate' => $rate); $from_date = new DateTime($from); $to_date = new DateTime($to); $from_date->sub(new DateInterval('P1D')); $to_date->add(new DateInterval('P1D')); /* * <------------|------------------|--------------|-------------------|-----------------> * a < x < y < b */ $existing = SupplementRate::where($conditions)->where('from', '<', $from)->where('to', '>', $to)->first(); if (!empty($existing->id)) { $newperiods = array(array("from" => $existing["from"], "to" => $from_date->format('Y-m-d'), "rate" => $existing->rate), array("from" => $from, "to" => $to, "rate" => $rate), array("from" => $to_date->format('Y-m-d'), "to" => $existing->to, "rate" => $existing->rate)); $this->insertRates($newperiods, $data); SupplementRate::where("id", $existing->id)->delete(); } else { /* * <------------|------------------|--------------|-------------------|-----------------> * x < a < b < y */ $existing1 = SupplementRate::where($conditions)->where('from', '>=', $from)->where('to', '<=', $to)->get(); if ($existing1->count()) { $conflicting_ids = array(); foreach ($existing1 as $conflict) { $conflicting_ids[] = $conflict->id; } SupplementRate::whereIn('id', $conflicting_ids)->delete(); $newperiods = array(array('from' => $from, 'to' => $to, 'rate' => $rate)); $this->insertRates($newperiods, $data); } /* * <------------|------------------|--------------|-------------------|-----------------> * a < x < b < y */ $existing_condition_1 = SupplementRate::where($conditions)->where('from', '<=', $from)->where('to', '>=', $from)->where('to', '<', $to)->first(); if (!empty($existing_condition_1->id)) { SupplementRate::where('id', $existing_condition_1->id)->delete(); $newperiods = array(array('from' => $existing_condition_1->from, 'to' => $from_date->format('Y-m-d'), 'rate' => $existing_condition_1->rate), array('from' => $from, 'to' => $to, 'rate' => $rate)); $this->insertRates($newperiods, $data); } /* * <------------|------------------|--------------|-------------------|-----------------> * x < a < y < b */ $existing_condition_2 = SupplementRate::where($conditions)->where('from', '>=', $from)->where('from', '<=', $to)->where('to', '>', $to)->first(); if (!empty($existing_condition_2->id)) { SupplementRate::where('id', $existing_condition_2->id)->delete(); $newperiods = array(array('from' => $from, 'to' => $to, 'rate' => $rate), array('from' => $to_date->format('Y-m-d'), 'to' => $existing_condition_2->to, 'rate' => $existing_condition_2->rate)); $this->insertRates($newperiods, $data); } else { if (!$deleted_items) { Rate::where(array('from' => Input::get('old_from'), 'to' => Input::get('old_to'), 'room_type_id' => Input::get('room_type_id'), 'market_id' => Input::get('market_id')))->delete(); $deleted_items = true; } $this->insertRates($newperiods, $data); } } } return Response::json('/control-panel/hotel/hotels/' . $hotelid . '/supplement-rates'); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id, Request $request) { $rate = Rate::findOrFail($id); $rate->delete(); $message = "La propiedad " . $rate->name . ' fue eliminada'; if ($request->ajax()) { return $message; } Session::flash('message', $message); return redirect()->route('admin.rate.index'); }
<?php if (!empty($_GET['type']) && !empty($_GET['item'])) { $rate = $_GET['type'] == 'up' ? 1 : 0; $item = $_GET['item']; try { require_once '../classes/Rate.php'; $objRate = new Rate(); if (!$objRate->isSubmitted($item)) { if ($objRate->addRating($item, $rate)) { echo json_encode(array('error' => false)); } else { echo json_encode(array('error' => true, 'case' => 4)); } } else { echo json_encode(array('error' => true, 'case' => 3)); } } catch (Exception $e) { echo json_encode(array('error' => true, 'case' => 2)); } } else { echo json_encode(array('error' => true, 'case' => 1)); }
<?php require_once 'classes/Rate.php'; $objRate = new Rate(); $posts = $objRate->getPosts(); ?> <!DOCTYPE HTML> <html lang="en"> <head> <meta charset="utf-8" /> <title>Thumbs up and down with PHP and jQuery</title> <meta name="description" content="Thumbs up and down with PHP and jQuery" /> <meta name="keywords" content="Thumbs up and down with PHP and jQuery" /> <link href="/css/core.css" rel="stylesheet" type="text/css" /> <!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> <div id="wrapper"> <p><a href="#" class="reset">Reset</a></p> <div id="comments"> <?php if (!empty($posts)) { ?> <?php
/** * Tests getTokensPerSecond(). * * @param double $expected The expected rate in tokens per second. * @param Rate $rate The rate. * * @test * @dataProvider provideTestGetTokensPerSecond */ public function testGetTokensPerSecond($expected, Rate $rate) { $this->assertEquals($expected, $rate->getTokensPerSecond()); }
public function getRate($slug = '') { $type = Type::where('type', 'rate')->first(); $posts = Post::where('type_id', '=', $type->id)->where('status', 1)->where('parent', '=', '0')->orderBy('created_at', 'desc')->get(); $posts_child = Post::where('type_id', '=', $type->id)->where('status', 1)->where('parent', '!=', '0')->orderBy('created_at', 'desc')->get(); if (!empty($slug)) { $row = Post::where('slug', $slug)->first(); $posts_child = Post::where('type_id', '=', $type->id)->where('parent', $row->id)->where('status', 1)->orderBy('created_at', 'desc')->get(); $blade = 'home.page-menu-title'; } else { $tv = Rate::where('type', 'tv')->where('status', 1)->orderBy('position', 'asc')->get(); $inet = Rate::where('type', 'inet')->first(); $inetOption = Rate::where('type', 'inetOption')->where('status', 1)->orderBy('position', 'asc')->get(); $row = array('inet' => json_decode($inet->description), 'inetOption' => $inetOption, 'tv' => $tv); $blade = 'home.page-rate'; } $view = array('posts' => $posts, 'posts_child' => $posts_child, 'type' => $type, 'row' => $row); return View::make($blade, $view); }
public function actionDel($id) { $model = Rate::model()->findByPk($id); if($model->delete()){ Yii::app()->user->setFlash('success','删除成功!'); }else{ Yii::app()->user->setFlash('error','删除失败,请重试!'); } $this->redirect(array('list')); }