public function actionPresent() { $model = new Present(); if (isset($_POST['Present'])) { $model->attributes = $_POST['Present']; if ($model->save()) { $this->redirect('success'); } } $this->render('present', array('model' => $model)); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Present the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Present::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
?> <p class="gift_icon1">医生在线查看礼物时,您会收到短信通知,方便与医生及时在线交流。</p> <?php } ?> </div> <div class="clearfix bb_dad pt10"> <p class="fl f14"><a href="<?php echo SpaceHeartBillboard::weekRankUrl(); ?> " class="blue_a1" target="_blank">爱心值“<span class="orange1 f20">+<?php echo $present->heartValue; ?> </span>”</a></p> <a href="<?php echo Present::presentHelpUrl(); ?> " target="_blank" class="fr pt5">什么是心意礼物?</a></p> </div> </div> <div class="doc_of_gift fl pt20 tc fs"> <p><img src="<?php echo $space->host->getLargeHeadImage(); ?> " alt="" /></p> <p class="f14 fb"><a href="<?php echo $space->getUrl(); ?> " target="_blank"><?php echo $space->name;
private function getRibbonLengthRequirementForPresent(Present $present) { return $present->getSmallestPerimeter() + $present->getVolume(); }
public function ajaxApplyPresent($request, $response) { /*{{{*/ $patientId = $request->patientid; $response->patientId = $patientId; if ($this->user->isNull()) { $errorUrl = User::getLogOutUrl(); $response->setRedirect($errorUrl); return; } if (false == $this->isAllowSendPresent($response)) { return 'notsend'; } $patient = DAL::get()->find('patient', $patientId); $presentId = $request->presentid; $response->presentId = $presentId; $present = DAL::get()->find('Present', $presentId); if ($present->status == 0) { $errorUrl = Present::sentPresentUrl($patientId, $this->space->user->name); $response->setRedirect($errorUrl); return; } $response->present = $present; $response->wish = mb_convert_encoding($request->getRequest('wish', ''), 'gbk', 'utf-8'); list($canSend, $errorMsg) = $this->canSendPresent($patientId, $presentId); $response->canSend = $canSend; $response->errorMsg = $errorMsg; if (false == $canSend) { if ('礼物无效!' == $errorMsg) { //礼物无效直接跳到选择礼物页面 $url = Present::sentPresentUrl($patientId, $this->space->user->name); $response->setRedirect($url); } return; } list($featAmount, $heartImgHtml) = ScoreClient::getInstance()->showFlagsforPage($this->space->user->id); //爱心图片 $response->heartImgHtml = $heartImgHtml; //爱心值 $response->featAmount = $featAmount; $response->otherDoctorFlows = array(); if (false == $this->user->isNull()) { $response->otherDoctorFlows = FlowClient::getInstance()->getFlowListByUser($this->user->id, array('status' => DoctorPatientRef::STATUS_INIT, 'filterSpace' => $this->space->id), true); } $userId = empty($patientId) ? $this->user->id : $patient->user->id; $response->leftAmount = ScoreClient::getInstance()->getIntegralAmount($userId); $response->presentOrder = DAL::get()->find_by_spaceid_and_patientid_and_status('presentOrder', $this->space->id, $patientId, PresentOrder::AUDITED_NO); }
</font> </a> <?php if ($object instanceof DoctorPatientRef && $object->isPrivated()) { ?> <img src="http://i1.hdfimg.com/doctorzone/images/zixun_icon5.png" align="absmiddle" title="隐私"> <?php } ?> <?php //鲜花 if( in_array($object->patient->id, $patientIdsOfFlower) ) { ?> <a href="<?=Present::presentHelpUrl()?>" target="_blank"><img src="http://i1.hdfimg.com/doctorzone/images/zixun_icon9.png" align="absmiddle" title="礼物"></a> <?php } //收费图标 if ($object instanceof DoctorPatientRef && array_key_exists($object->id, $chargeList)) { ?> <img src="http://i1.hdfimg.com/doctorzone/images/zixun_icon2.png" align="absmiddle" title="付费咨询"> <?php } ?> <?php if(in_array($object->id, $telOrderFlowIds)){?> <img src="http://i1.hdfimg.com/doctorzone/images/zixun_icon4.png" align="absmiddle" title="电话咨询"> <?}?> </span>
</p> <div class="t<?=$rowIndex?>-tip pa"></div> </div> <?php } ?> </div> </div> </div> <!--end presentActive1-mainBox--> <!--start presentActive1-nearly--> <div class="presentActive1-nearly mt15"> <h3 class="mb5 pl10">心意礼物最近更新:</h3> <p class="gray2 pl10">1 推出高级心意礼物,支持自定义赠送语 <a class="sendPresent blue" href="<?=Present::sendCategoryPresentNoSpace(PresentCategory::SENIOR_CATE)?>">我要试试</a></p> <p class="gray2 pl10">2 最新上架了<a class="sendPresent" href="<?=$presentMdcg->sendNotSpecialedUrl($space->user->name, $presentMdcg->id)?>">马到成功</a>,<a class="sendPresent" href="<?=$presentJxry->sendNotSpecialedUrl($space->user->name, $presentJxry->id)?>">吉祥如意</a>等心意礼物。 <a class="sendPresent blue" href="<?=Present::sendCategoryPresentNoSpace(PresentCategory::NEW_CATE)?>">查看更多</a></p> <!--<p class="gray2 pl10">3 使用电话咨询服务后,反馈的代金卷可用来赠送心意礼物。</p>--> </div> <!--end presentActive1-nearly--> <!--start presentActive1-mainBox--> <div class="presentActive1-mainBox mt15"> <div class="hd ml15 clearfix"> <img src="http://i1.hdfimg.com/www/images/presentactives02.jpg" class="fl"/> <div class="fl hd-content">全部<span class="yellow">心意礼物</span></div> <img src="http://i1.hdfimg.com/www/images/presentactives03.jpg" class="fl"/> </div> <div class="bd pr clearfix"> <div class="allPresentBox-leftTip pa"></div> <div class="allPresentBox-rightTip pa"></div>
public function presentNavigation($request, $response) {/*{{{*/ $this->forceSpaceModuleCheck('Present', $response); $res = PresentClient::getInstance()->allReceivedOrders($this->_newSpace->id, $this->_newUser->id); $response->myIds = $res['myIds']; $response->showIds = $res['showIds']; $response->hiddenIds = $res['hiddenIds']; $response->orders = $res['orders']; $response->notPresents = $res['notPresents']; $response->myNums = Present::getTiltTmp(count($res['myIds']), PresentOrder::LINE_NUMBER_ALL); $response->showNums = Present::getTiltTmp(count($res['showIds']), PresentOrder::LINE_NUMBER_ALL); $response->hiddenNums = Present::getTiltTmp(count($res['hiddenIds']), PresentOrder::LINE_NUMBER_ALL); $response->notPresentNums = Present::getTiltTmp(count($res['notPresentIds']), PresentOrder::LINE_NUMBER_ALL); $response->cnts = $res['cnts']; $response->myRefIds = $res['myRefIds']; $response->presentCnt = $res['presentCnt']; $response->patientCnt= $res['patientCnt']; $response->spaceRepliedCount = SpaceClient::getInstance()->getCountOfRepliedFlowsCount($this->_newSpace->id, $this->_newUser->id); }/*}}}*/
<?php /** * 箱庭諸島 S.E - プレゼント定義用ファイル - * @copyright 箱庭諸島 ver2.30 * @since 箱庭諸島 S.E ver23_r09 by SERA * @author hiro <@hiro0218> */ require_once 'config.php'; require_once MODELPATH . '/admin.php'; require_once MODELPATH . '/hako-cgi.php'; require_once MODELPATH . '/hako-file.php'; require_once PRESENTER . '/hako-html.php'; require_once CONTROLLERPATH . '/admin/present.php'; $init = new Init(); $start = new Present(); $start->execute();
$this->paper_needed += 2 * $wh; $this->paper_needed += min([$lw, $lh, $wh]); } public function ribbonNeeded() { $sizes = [$this->l, $this->w, $this->h]; sort($sizes, SORT_NUMERIC); array_pop($sizes); $this->ribbon_needed += $sizes[0] + $sizes[0] + $sizes[1] + $sizes[1]; $this->ribbon_needed += $this->l * $this->w * $this->h; } } $total_paper_needed = $total_ribbon_needed = 0; $file = file_get_contents("input/day2.txt"); $lines = explode("\n", $file); foreach ($lines as $line) { $dimensions = explode("x", $line); $l = $dimensions[0]; $w = $dimensions[1]; $h = $dimensions[2]; $present = new Present(); $present->l = $l; $present->w = $w; $present->h = $h; $present->wrappingNeeded(); $present->ribbonNeeded(); $total_paper_needed += $present->paper_needed; $total_ribbon_needed += $present->ribbon_needed; } echo 'Total amount of paper needed: ' . $total_paper_needed . '<br>'; echo 'Total amount of ribbon needed: ' . $total_ribbon_needed . '<br>';
<?php if ('' == $imgId) { ?> ио╢╚нд╪Чй╖╟э <?php } else { ?> <script type="text/javascript"> parent.$("#icon").val("<?php echo $imgId; ?> "); parent.$("#iconImage").attr("src", "<?php echo Present::doLargeImage($imgId); ?> "); parent.$.fancybox.close(); </script> <?php }
<!-- 礼物动态 --> <div class="center_r_bar mt10 mb10"> <div style="background: url('http://i1.hdfimg.com/homepage/images/present_dongtai.gif') no-repeat scroll 0 0 transparent; border-bottom: 2px solid #E4E4E4; height: 32px;"> <a href="<?=Present::presentHelpUrl()?>" target="_blank" class="gray2 unl fr f12 mt10">什么是“心意礼物”?</a> </div> <div class="clearfix" style="overflow: hidden; height: 165px; position: relative;"> <ul class="clearfix presentPersonList-box f12" style="position: relative;" id="latestBoughtPresents"> <!--start presentPersonList-box--> <?php foreach($presentOrders as $key => $presentOrder) { if($presentOrder->space->host->hospitalfaculty->hospital->isInnerTestHospital()) { continue; } ?> <li class="clearfix presentPersonList-box-item ml20 m10"> <div class="fl mr5 "> <a class="heartvaluetip showDoctorPatientRef" href="http://www.<?=URL_PREFIX?>haodf.com/api/present/promotion?from=right" target="_blank"><img src="<?=$presentOrder->present->getMiddleImage() ?>" width="60" height="60" class="avatar"/></a> </div> <div class="pr fr presentPersonList-box-item-r-shell"> <div class="presentPersonList-box-item-r"> <ul class="gray2 pl20 pt5"> <li> <?php if(false == $presentOrder->patient->isNull()) {?> <a target="_blank" class="reflink gray2" href="/api/present/ajaxpresentbanner?presentorderid=<?=$presentOrder->id?>&uname=<?=$presentOrder->space->user->name?>" title="立即查看"> <?php } ?> <span class="fb"><?=$presentOrder->space->name?></span>大夫收到了<span class="fb"><?=$presentOrder->user->privateName?></span><br>精心挑选的礼物<span class="fb"><?=$presentOrder->present->name?></span> <?php if(false == $presentOrder->patient->isNull()) {?> </a> <?php } ?>
</div> <div class="recharge-bd-box-c p20"> <div class="serviceBtnBox"> <!-- start serviceBtn --> <a class="serviceBtn clearfix f16 f-yahei" href="<?=$router->urlfor('telpayment/selectchargeorder')?>"> <span class="serviceBtn-l"> </span> <span class="serviceBtn-c pl20 pr20"> 网络咨询指导次数购买 </span> <span class="serviceBtn-r"> </span> </a> <!-- start serviceBtn --> <!-- start serviceBtn --> <a class="sendPresent serviceBtn clearfix f16 f-yahei ml80" href="<?=Present::sendNoSpaceNoPresent()?>"> <span class="serviceBtn-l"> </span> <span class="serviceBtn-c pl20 pr20"> 心意礼物 </span> <span class="serviceBtn-r"> </span> </a> <!-- start serviceBtn --> </div> </div> </div> <!-- end recharge-bd-box--> </div> <!-- end recharge-bd -->
<!-- 礼物动态 --> <div class="toptr" > <div class="lt"> <ul style="text-align:left;"> <li> <span style="color:#098BCE;font-weight:bold;" class="f16">心意礼物动态</span> <a href="<?=Present::presentHelpUrl()?>" target="_blank" style="position:relative;left:91px;" class="gray2 unl f12" rel="nofollow">什么是“心意礼物”?</a> </li> </ul> </div> </div> <div class="midtr"> <div class="lt"> <div class="clearfix" style="overflow: hidden; height: 165px; position: relative;"> <ul class="clearfix presentPersonList-box f12" style="position: relative;" id="latestBoughtPresents"> <!--start presentPersonList-box--> <?php foreach($presentOrders as $key => $presentOrder) { ?> <li class="clearfix presentPersonList-box-item ml20 m10"> <div class="fl mr5 "> <a class="heartvaluetip showDoctorPatientRef" href="http://www.<?=URL_PREFIX?>haodf.com/api/present/promotion?from=right" target="_blank"><img src="<?=$presentOrder->present->getMiddleImage() ?>" width="60" height="60" class="avatar"/></a> </div> <div class="pr fr presentPersonList-box-item-r-shell"> <div class="presentPersonList-box-item-r"> <ul class="gray2 pl20 pt5"> <li> <?php if(false == $presentOrder->patient->isNull()) {?> <a target="_blank" class="reflink gray2" href="/api/present/ajaxpresentbanner?presentorderid=<?=$presentOrder->id?>&uname=<?=$presentOrder->space->user->name?>" title="立即查看">
/** * Returns the length and width of the smallest side of a {@link Present} * @param Present $present * @return int[] [length, width] */ private static function smallestSide(Present $present) { $dimensions = [$present->getLength(), $present->getWidth(), $present->getHeight()]; sort($dimensions); return [$dimensions[0], $dimensions[1]]; }
{ return array_sum($this->getSides()) * 2; } public function getVolume() { return $this->x * $this->y * $this->z; } public function getPaperNeeded() { return $this->getSurfaceArea() + min($this->getSides()); } public function getRibbonNeeded() { $dimensions = [$this->x, $this->y, $this->z]; sort($dimensions); return $this->getVolume() + ($dimensions[0] * 2 + $dimensions[1] * 2); } } assert(Present::fromString('2x3x4')->getPaperNeeded() == 58); assert(Present::fromString('1x1x10')->getPaperNeeded() == 43); assert(Present::fromString('2x3x4')->getRibbonNeeded() == 34); assert(Present::fromString('1x1x10')->getRibbonNeeded() == 14); $totalPaper = 0; $totalRibbon = 0; foreach (file('2.txt') as $dimensions) { $present = Present::fromString($dimensions); $totalPaper += $present->getPaperNeeded(); $totalRibbon += $present->getRibbonNeeded(); } echo sprintf('Part 1 answer: %s', $totalPaper) . PHP_EOL; echo sprintf('Part 2 answer: %s', $totalRibbon) . PHP_EOL;