lzaplata/booking
Composer 安装命令:
composer require lzaplata/booking
包简介
Simple booking for Nette
README 文档
README
This is a simple Nette Framework booking component.
Installation
The easiest way to install library is via Composer.
$ composer require lzaplata/booking: dev-master
or edit composer.json in your project
"require": { "lzaplata/booking": "dev-master" }
You have to register the library as an extension in config.neon file.
extensions: booking: LZaplata\Booking\DI\BookingExtension
Autowire a library to a presenter and autowire a template factory
use LZaplata\Booking\Booking; use Nette\Application\UI\ITemplateFactory; /** @var Booking @inject */ public $booking; /** @var ITemplateFactory @inject */ public $templateFactory;
Usage
Create a booking room as a component.
/** * @param string $name */ public function createComponentParkBookingRoom($name) { // create days objects $monday = new Day(); // creates single day object using LZaplata\Booking\Day $monday->setDayOfWeek(Day::MONDAY); // sets day of week $monday->setStartDateTime(new \DateTime()); // sets day start time (you can also use Nette\Utils\DateTime) $monday->setEndDateTime(new DateTime()); // sets day end time (you can also use Nette\Utils\DateTime) $monday->addDisabledPeriod(new \DatePeriod()); // you can disable period for lunch // for other days you can create its own objects or you can clone day object $tuesday = clone $monday; $tuesday->setDayOfWeek(Day::TUESDAY); // you must set corresponding day of week // create booking room $room = $this->booking->createRoom(string $roomName, string $name); // first parameter is your room name, second is component name $room->setDays([$monday, $tuesday, $wednesday, $thursday, $friday, $saturday, $sunday]); // sets days as array of objects $room->setCapacity(int $capacity); // sets capacity of each period $room->setInterval(new \DateInterval()); // sets booking interval $room->setDelay(int $hours); // set hours from now you can make booking $room->setCapacityExceededMessage(string $message); // sets booking form error message if capacity is exceeded $room->addDisabledPeriod(new \DatePeriod()); // disable year period $room->setupBookingFormStreetInput(bool $visible, bool $required); // configure form street input $room->setupBookingFormZipInput(bool $visible, bool $required); // configure form ZIP input $room->setupBookingFormConditionsInput(bool $visibility, bool $required, Nette\Utils\Html $html); // configure form conditions input $room->setWeeksOptions(int $count, int $history); // sets week selection options $room->setTemplate($file); // sets template for override some booking room blocks (example below) // setup confirmation emails for customer $customerMessageTemplate = $this->templateFactory->createTemplate(); $customerMessageTemplate->setFile(string $file); $customerMessage = new Message(); // create message using Nette\Mail\Message $customerMessage->setFrom(string $email); $customerMessage->setSubject(string $subject); $customerMail = $room->setupCustomerMail($customerMessage); $customerMail->setTemplate($customerMessageTemplate); // setup confirmation emails for office $officeMessageTemplate = $this->templateFactory->createTemplate(); $officeMessageTemplate->setFile(string $file); $officeMessage = new Message(); // create message using Nette\Mail\Message $officeMessage->addTo(string $email); $officeMessage->setSubject(string $subject); $officeMail = $room->setupCustomerMail($officeMessage); $officeMail->setTemplate($officeMessageTemplate); // setup cancel booking email $bookingCancelMessageTemplate = $this->templateFactory->createTemplate(); $bookingCancelMessageTemplate->setFile(string $file); $bookingCancelMessage = new Message(); $bookingCancelMessage->addTo(string $email); $bookingCancelMessage->setSubject(string $subject); $bookingCancelMail = $room->setupBookingCancelMail($bookingCancelMessage); $bookingCancelMail->setTemplate($bookingCancelMessageTemplate); // end finally return whole component return $room; }
Variables
In customer, office or booking cancel mail latte templates you can use those variables.
{$id} {*booking ID*} {$amount} {*booked capacity*} {$name} {$surname} {$street} {$street_no} {$city} {$zip} {$mail} {$phone} {$text} {$date} {*you can format it using {$date->format()} or {$date|date:""}*} {$cancelLink} {*booking cancel link*}
Booking room template
You can override some booking room blocks
{extends $defaultTemplate} {*first of all you have to extend default template*} {define date} {$dateTime->format("j. n. Y")} {*formats header date*} {/define} {define time} {$dateTime->format("H:i")} {*formats header time*} {/define} {define period} {$bookingsCount}/{$capacity} {*formats capacity of individual period blocks*} {/define} {define formText} {*define booking form text*} <p> Some text... </p> {/define}
lzaplata/booking 适用场景与选型建议
lzaplata/booking 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 55 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 01 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 lzaplata/booking 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lzaplata/booking 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 55
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-01-24