uawdijnntqw1x1x1
IP : 216.73.216.5
Hostname : toronto-dev2
Kernel : Linux toronto-dev2 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64
Disable Function : None :)
OS : Linux
PATH:
/
srv
/
users
/
craft4
/
apps
/
craft4-newsite-space
/
vendor
/
craftcms
/
commerce
/
src
/
widgets
/
NewCustomers.php
/
/
<?php /** * @link https://craftcms.com/ * @copyright Copyright (c) Pixel & Tonic, Inc. * @license https://craftcms.github.io/license/ */ namespace craft\commerce\widgets; use Craft; use craft\base\Widget; use craft\commerce\base\StatWidgetTrait; use craft\commerce\stats\NewCustomers as NewCustomersStat; use craft\commerce\web\assets\statwidgets\StatWidgetsAsset; use craft\helpers\DateTimeHelper; use craft\helpers\StringHelper; use Exception; /** * New Customers widget * * @property string|false $bodyHtml the widget's body HTML * @property string $settingsHtml the component’s settings HTML * @property string $title the widget’s title * @author Pixel & Tonic, Inc. <support@pixelandtonic.com> * @since 3.0 */ class NewCustomers extends Widget { use StatWidgetTrait; /** * @var null|NewCustomersStat */ private ?NewCustomersStat $_stat = null; /** * @inheritDoc * @throws Exception */ public function init(): void { parent::init(); $this->_stat = new NewCustomersStat( $this->dateRange, DateTimeHelper::toDateTime($this->startDate, true), DateTimeHelper::toDateTime($this->endDate, true) ); if (!empty($this->orderStatuses)) { $this->_stat->setOrderStatuses($this->orderStatuses); } } /** * @inheritdoc */ public static function isSelectable(): bool { return Craft::$app->getUser()->checkPermission('commerce-manageCustomers'); } /** * @inheritdoc */ public static function displayName(): string { return Craft::t('commerce', 'New Customers'); } /** * @inheritdoc */ public static function icon(): ?string { return Craft::getAlias('@craft/commerce/icon-mask.svg'); } /** * @inheritdoc */ public function getTitle(): ?string { return ''; } /** * @inheritdoc */ public function getBodyHtml(): ?string { $number = $this->_stat->get(); $timeFrame = $this->_stat->getDateRangeWording(); $view = Craft::$app->getView(); $view->registerAssetBundle(StatWidgetsAsset::class); return $view->renderTemplate('commerce/_components/widgets/customers/new/body', compact('number', 'timeFrame')); } /** * @inheritDoc */ public static function maxColspan(): ?int { return 1; } /** * @inheritdoc */ public function getSettingsHtml(): ?string { $id = 'new-customers' . StringHelper::randomString(); $namespaceId = Craft::$app->getView()->namespaceInputId($id); return Craft::$app->getView()->renderTemplate('commerce/_components/widgets/customers/new/settings', [ 'id' => $id, 'namespaceId' => $namespaceId, 'orderStatuses' => $this->getOrderStatusOptions(), 'widget' => $this, ]); } }
/srv/users/craft4/apps/craft4-newsite-space/vendor/craftcms/commerce/src/widgets/NewCustomers.php