本文实例讲述了基于ThinkPHP实现的日历功能。分享给大家供大家参考,具体如下:
开发环境介绍
最新,闲来没事,便开发了一款简单的日历,来统计工作情况。为了开发便捷,使用ThinkPHP架构。界面如下图
备注:每页包含上一个月,当前月,下一个月的日期,并用不同的颜色区分,如果某天工作了,便圈出来。
主要是以下两个文件
重要文件描述
功能文件
CalenDar.class.php主要负责,获取日历详细信息的,不涉及用户数据操作。
代码如下:
<"htmlcode"><"htmlcode"><"htmlcode"><extend name="Public/base" /> <block name="css"> <style type="text/css"> *{margin: 0; padding: 0; border: 0; font-size: 16px;} body{background-color: #4d56a3;} ul{list-style: none;} #mainBox{width: 1024px; height:auto; margin:10px auto 0 auto; } #leftBox{width:60%; height: 700px; float: left; border-radius:15px; margin-right:3%; background-color:#ffbd66; } #rightBox{width:37%; height: 700px; float: right; border-radius:15px; background-color:#faf7dd} #calendartitle{width: 95%; margin: 10px auto 5px auto; height: 110px; } #calendartitle ul li{float: left; margin-right: 10px;} #logoImg{width: 100px; height: 100px; border-radius: 10px; background-image: url('__IMG__/logo.png');background-repeat: no-repeat;} #cellHead{width: 95%; background-color:#ffe786; border-radius:10px 10px 0 0; } #cellHead td{width:80px; height:45px; font-size: 22px; } #calendarcell{width: 95%; margin: 0 auto;} #calendarTable td{width:80px; height:80px;background-repeat: no-repeat; border: 1px; font-size: 18px; } .daytype1_1{background-image:url("__IMG__/cellbg1_0_1.png");} .daytype2_1{background-image:url("__IMG__/cellbg1_1_1.png");} .daytype1_2{background-image:url("__IMG__/cellbg1_0_2.png");} .daytype2_2{background-image:url("__IMG__/cellbg1_1_2.png");} .daytype1_3{background-image:url("__IMG__/cellbg1_0_3.png");} .daytype2_3{background-image:url("__IMG__/cellbg1_1_3.png");} .daytype3_1{background-image:url("__IMG__/cellbg2_0_1.png");} .daytype4_1{background-image:url("__IMG__/cellbg2_1_1.png");} .daytype3_2{background-image:url("__IMG__/cellbg2_0_2.png");} .daytype4_2{background-image:url("__IMG__/cellbg2_1_2.png");} .daytype3_3{background-image:url("__IMG__/cellbg2_0_3.png");} .daytype4_3{background-image:url("__IMG__/cellbg2_1_3.png");} .aBlock{display: block; text-decoration: none;} .ainblock{display: inline-block; text-decoration: none;} .actionBox{width: 80%; margin: 0 auto; margin-top:15px; background-color:#fadfbb; height: auto; padding-top: 20px; padding-bottom: 20px; border-radius: 10px; text-align: center;} #action1 a{width:80%; margin: 0 auto 15px auto; height: 45px; background-color: #ffec42; border-radius: 10px; line-height: 45px; text-align: center; font-size: 22px; color: #ad5408; font-weight: 700;} #action1 a:hover{font-size: 24px; color:#F12;} #action2{text-align: center;} #action2 a{width: 80px; background-color: #ffec42; border-radius: 10px; height: 35px; line-height: 35px; text-align: center; margin-right: 10px;} #action3{text-align: left;} #action3 ul li{margin-left:20px; border-bottom: 1px dashed #999;margin-right:10px; margin-bottom: 10px; font-size: 20px;} </style> </block> <block name="title">日历</block> <block name="main"> <div id="mainBox"> <div id='leftBox'> <div id="calendartitle"> <ul> <li id="logoImg"> </li> <li > <div style="height:45px; line-height:45px; font-size:20px;">{$nowTime}</div> <div style="height:45px; line-height:45px; font-size:20px;">{$curDay}</div> </li> </ul> </div> <div id="calendarcell"> <div id="cellHead"> <table cellpadding="0" cellspacing="0" border="0" align="center"> <tr> <td align="center">周日</td> <td align="center">周一</td> <td align="center">周二</td> <td align="center">周三</td> <td align="center">周四</td> <td align="center">周五</td> <td align="center">周六</td> </tr> </table> </div> <table cellpadding="0" cellspacing="0" border="0" id='calendarTable' align="center"> <tr> <volist name="info" id="dayinfo" key='flag'> <td align="center" class="{$dayinfo['info']['class']}">{$dayinfo['info']['day']}</td> <if condition="$flag % 7 == 0 && $flag % 7 != 42 "> </tr><tr> </if> </volist> </table> </div> </div> <div id='rightBox'> <div id="action1" class="actionBox"> <ul> <li><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="aBlock" onclick="todayAction(1)">工作</a></li> <li><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="aBlock" onclick="todayAction(2)">休息</a></li> </ul> </div> <div id="action2" class="actionBox"> <ul> <li><a href="" rel="external nofollow" class="ainblock" >上一月</a><a href="" rel="external nofollow" class="ainblock" >下一月</a></li> </ul> </div> <div id="action3" class="actionBox"> <ul> <li>本月共计:{$curDaySum} 天</li> <li>本月已工作:{$workDays} 天</li> <li>本月剩余工作日:** 天</li> <li>预计工资:**天</li> </ul> </div> <div id="action4" class="actionBox"> <ul> <li><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="aBlock">设置</a></li> </ul> </div> </div> </div> </block> <block name="js"> <script type="text/javascript" src="/UploadFiles/2021-04-02/jquery-1.12.4.min.js">思路分析
1.在CalenDar.class.php中,封装每个月的日期信息。如果读者需要做日历,只需要将该文件作为一个类调用即可。
如下图$calendar=new \Util\CalenDar(); $info=$calendar->getCalendar(); echo json_encode($info); //输出结果如下 [{"id":"2016-5-29","info":{"day":29,"type":1}},{"id":"2016-5-30","info":{"day":30,"type":1}},{"id":"2016-5-31","info":{"day":31,"type":1}},{"id":"2016-6-1","info":{"day":1,"type":2}},{"id":"2016-6-2","info":{"day":2,"type":2}},{"id":"2016-6-3","info":{"day":3,"type":2}},{"id":"2016-6-4","info":{"day":4,"type":2}},{"id":"2016-6-5","info":{"day":5,"type":2}},{"id":"2016-6-6","info":{"day":6,"type":2}},{"id":"2016-6-7","info":{"day":7,"type":2}},{"id":"2016-6-8","info":{"day":8,"type":2}},{"id":"2016-6-9","info":{"day":9,"type":2}},{"id":"2016-6-10","info":{"day":10,"type":2}},{"id":"2016-6-11","info":{"day":11,"type":2}},{"id":"2016-6-12","info":{"day":12,"type":2}},{"id":"2016-6-13","info":{"day":13,"type":2}},{"id":"2016-6-14","info":{"day":14,"type":2}},{"id":"2016-6-15","info":{"day":15,"type":2}},{"id":"2016-6-16","info":{"day":16,"type":2}},{"id":"2016-6-17","info":{"day":17,"type":2}},{"id":"2016-6-18","info":{"day":18,"type":2}},{"id":"2016-6-19","info":{"day":19,"type":2}},{"id":"2016-6-20","info":{"day":20,"type":2}},{"id":"2016-6-21","info":{"day":21,"type":2}},{"id":"2016-6-22","info":{"day":22,"type":2}},{"id":"2016-6-23","info":{"day":23,"type":2}},{"id":"2016-6-24","info":{"day":24,"type":2}},{"id":"2016-6-25","info":{"day":25,"type":2}},{"id":"2016-6-26","info":{"day":26,"type":2}},{"id":"2016-6-27","info":{"day":27,"type":2}},{"id":"2016-6-28","info":{"day":28,"type":2}},{"id":"2016-6-29","info":{"day":29,"type":2}},{"id":"2016-6-30","info":{"day":30,"type":2}},{"id":"2016-7-1","info":{"day":1,"type":3}},{"id":"2016-7-2","info":{"day":2,"type":3}},{"id":"2016-7-3","info":{"day":3,"type":3}},{"id":"2016-7-4","info":{"day":4,"type":3}},{"id":"2016-7-5","info":{"day":5,"type":3}},{"id":"2016-7-6","info":{"day":6,"type":3}},{"id":"2016-7-7","info":{"day":7,"type":3}},{"id":"2016-7-8","info":{"day":8,"type":3}},{"id":"2016-7-9","info":{"day":9,"type":3}}]2.在WorkLog.class.php中,获取该用户上一个月、当前月、下一个月的工作信息,之所以使用一次性获取三个月的工作信息,因为如果每天的去读取,这样数据查询的次数过大,当然最好的还是做一下缓存比较好。读取到工作信息后,然后结合日历,判断每天是否工作,以及是否是周末,来决定日历中每个方格的背景样式。工作信息数据库如下图:
PS:这里再为大家分享几款本站的在线日期工具供大家参考:
在线万年历日历:
http://tools.jb51.net/bianmin/wannianli网页万年历日历:
http://tools.jb51.net/bianmin/webwannianli在线万年历黄历flash版:
http://tools.jb51.net/bianmin/flashwnl更多关于thinkPHP相关内容感兴趣的读者可查看本站专题:《ThinkPHP入门教程》、《thinkPHP模板操作技巧总结》、《ThinkPHP常用方法总结》、《codeigniter入门教程》、《CI(CodeIgniter)框架进阶教程》、《Zend FrameWork框架入门教程》、《smarty模板入门基础教程》及《PHP模板技术总结》。
希望本文所述对大家基于ThinkPHP框架的PHP程序设计有所帮助。
华山资源网 Design By www.eoogi.com
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
- 第五街的士高《印度激情版》3CD [WAV+CUE][2.4G]
- 三国志8重制版哪个武将智力高 三国志8重制版智力武将排行一览
- 三国志8重制版哪个武将好 三国志8重制版武将排行一览
- 三国志8重制版武将图像怎么保存 三国志8重制版武将图像设置方法
- 何方.1990-我不是那种人【林杰唱片】【WAV+CUE】
- 张惠妹.1999-妹力新世纪2CD【丰华】【WAV+CUE】
- 邓丽欣.2006-FANTASY【金牌大风】【WAV+CUE】
- 饭制《黑神话》蜘蛛四妹手办
- 《燕云十六声》回应跑路:年内公测版本完成95%
- 网友发现国内版《双城之战》第二季有删减:亲亲环节没了!
- 邓丽君2024-《漫步人生路》头版限量编号MQA-UHQCD[WAV+CUE]
- SergeProkofievplaysProkofiev[Dutton][FLAC+CUE]
- 永恒英文金曲精选4《TheBestOfEverlastingFavouritesVol.4》[WAV+CUE]
- 群星《国风超有戏 第9期》[320K/MP3][13.63MB]
- 群星《国风超有戏 第9期》[FLAC/分轨][72.56MB]