feat: VivesPOS landing on Winter CMS 1.2 — theme + plugin + Dockerfile
Some checks are pending
Module sub-split / Sub-split (push) Waiting to run
Some checks are pending
Module sub-split / Sub-split (push) Waiting to run
- Base: wintercms/winter branch 1.2 (full framework) - Theme vivespos: Canvas 7 + Bootstrap 5 CDN, custom CSS - Layout: deferred GTM/GA4 tracking, JSON-LD SoftwareApplication - Partials: hero (offline-first), features, modes (offline/nube toggle), screenshots, pricing (3 planes), comparison, FAQ, CTA - Plugin VivesPOS.Site with ContactForm - Dockerfile: PHP 8.2 Apache, port 80, healthcheck - Added winter/wn-pages, blog, sitemap, seo plugins - Active theme set to vivespos
This commit is contained in:
207
modules/backend/formwidgets/DatePicker.php
Normal file
207
modules/backend/formwidgets/DatePicker.php
Normal file
@@ -0,0 +1,207 @@
|
||||
<?php namespace Backend\FormWidgets;
|
||||
|
||||
use Config;
|
||||
use Carbon\Carbon;
|
||||
use Backend\Classes\FormField;
|
||||
use Backend\Classes\FormWidgetBase;
|
||||
use System\Helpers\DateTime as DateTimeHelper;
|
||||
use Winter\Storm\Exception\ApplicationException;
|
||||
|
||||
/**
|
||||
* Date picker
|
||||
* Renders a date picker field.
|
||||
*
|
||||
* @package winter\wn-backend-module
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class DatePicker extends FormWidgetBase
|
||||
{
|
||||
//
|
||||
// Configurable properties
|
||||
//
|
||||
|
||||
/**
|
||||
* @var bool Display mode: datetime, date, time.
|
||||
*/
|
||||
public $mode = 'datetime';
|
||||
|
||||
/**
|
||||
* @var string Provide an explicit date display format.
|
||||
*/
|
||||
public $format;
|
||||
|
||||
/**
|
||||
* @var string the minimum/earliest date that can be selected.
|
||||
* eg: 2000-01-01
|
||||
*/
|
||||
public $minDate;
|
||||
|
||||
/**
|
||||
* @var string the maximum/latest date that can be selected.
|
||||
* eg: 2020-12-31
|
||||
*/
|
||||
public $maxDate;
|
||||
|
||||
/**
|
||||
* @var string number of years either side or array of upper/lower range
|
||||
* eg: 10 or [1900,1999]
|
||||
*/
|
||||
public $yearRange;
|
||||
|
||||
/**
|
||||
* @var int first day of the week
|
||||
* eg: 0 (Sunday), 1 (Monday), 2 (Tuesday), etc.
|
||||
*/
|
||||
public $firstDay = 0;
|
||||
|
||||
/**
|
||||
* @var bool show week numbers at head of row
|
||||
*/
|
||||
public $showWeekNumber = false;
|
||||
|
||||
/**
|
||||
* @var bool change datetime exactly as is in database
|
||||
*/
|
||||
public $ignoreTimezone = false;
|
||||
|
||||
//
|
||||
// Object properties
|
||||
//
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected $defaultAlias = 'datepicker';
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->fillFromConfig([
|
||||
'format',
|
||||
'mode',
|
||||
'minDate',
|
||||
'maxDate',
|
||||
'yearRange',
|
||||
'firstDay',
|
||||
'showWeekNumber',
|
||||
'ignoreTimezone',
|
||||
]);
|
||||
|
||||
$this->mode = strtolower($this->mode);
|
||||
|
||||
if ($this->minDate !== null) {
|
||||
$this->minDate = is_int($this->minDate)
|
||||
? Carbon::createFromTimestamp($this->minDate)
|
||||
: Carbon::parse($this->minDate);
|
||||
}
|
||||
|
||||
if ($this->maxDate !== null) {
|
||||
$this->maxDate = is_int($this->maxDate)
|
||||
? Carbon::createFromTimestamp($this->maxDate)
|
||||
: Carbon::parse($this->maxDate);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
try {
|
||||
$this->prepareVars();
|
||||
} catch (ApplicationException $ex) {
|
||||
$this->vars['error'] = $ex->getMessage();
|
||||
}
|
||||
|
||||
return $this->makePartial('datepicker');
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the list data
|
||||
*/
|
||||
public function prepareVars()
|
||||
{
|
||||
if ($value = $this->getLoadValue()) {
|
||||
$value = DateTimeHelper::makeCarbon($value, false);
|
||||
|
||||
if (!($value instanceof Carbon)) {
|
||||
$this->vars['error'] = (sprintf('"%s" is not a valid date / time value.', $value));
|
||||
} else {
|
||||
if ($this->mode === 'date' && !$this->ignoreTimezone) {
|
||||
$backendTimeZone = \Backend\Models\Preference::get('timezone');
|
||||
$value->setTimezone($backendTimeZone);
|
||||
$value->setTime(0, 0, 0);
|
||||
$value->setTimezone(Config::get('app.timezone'));
|
||||
}
|
||||
$value = $value->toDateTimeString();
|
||||
}
|
||||
}
|
||||
|
||||
// Disable the datepicker visually when readOnly is enabled
|
||||
if ($this->formField->readOnly) {
|
||||
$this->formField->disabled = true;
|
||||
}
|
||||
|
||||
$this->vars['name'] = $this->getFieldName();
|
||||
$this->vars['value'] = $value ?: '';
|
||||
$this->vars['field'] = $this->formField;
|
||||
$this->vars['mode'] = $this->mode;
|
||||
$this->vars['minDate'] = $this->minDate;
|
||||
$this->vars['maxDate'] = $this->maxDate;
|
||||
$this->vars['yearRange'] = $this->yearRange;
|
||||
$this->vars['firstDay'] = $this->firstDay;
|
||||
$this->vars['showWeekNumber'] = $this->showWeekNumber;
|
||||
$this->vars['ignoreTimezone'] = $this->ignoreTimezone;
|
||||
$this->vars['format'] = $this->format;
|
||||
$this->vars['formatMoment'] = $this->getDateFormatMoment();
|
||||
$this->vars['formatAlias'] = $this->getDateFormatAlias();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSaveValue($value)
|
||||
{
|
||||
if ($this->formField->disabled || $this->formField->hidden) {
|
||||
return FormField::NO_SAVE_DATA;
|
||||
}
|
||||
|
||||
if (!strlen($value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert PHP format to JS format
|
||||
*/
|
||||
protected function getDateFormatMoment()
|
||||
{
|
||||
if ($this->format) {
|
||||
return DateTimeHelper::momentFormat($this->format);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Display alias, used by preview mode
|
||||
*/
|
||||
protected function getDateFormatAlias()
|
||||
{
|
||||
if ($this->format) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($this->mode == 'time') {
|
||||
return 'time';
|
||||
}
|
||||
elseif ($this->mode == 'date') {
|
||||
return 'dateLong';
|
||||
}
|
||||
else {
|
||||
return 'dateTimeLong';
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user