<?php
/**
* TEST DATOVYCH TYPU
*/
call_user_func(function() {
// krabice
$krabiceActiveRow = $this->connection->table('eshop_item')->where('id', 1467)->fetch();
$krabiceDataset = $krabiceActiveRow->getDataset();
$pv = $krabiceDataset->getPrimaryVariant();
_bardump($krabiceActiveRow);
});
call_user_func(function() {
// varianta
$varianta = $this->connection->table('eshop_item_variant')->where('id', 5411)->fetch();
$krabiceActiveRow = $varianta->eshop_item;
$krabiceDataset = $krabiceActiveRow->getDataset();
$pv = $krabiceDataset->getPrimaryVariant(); // nerfunkcni viz http://bit.ly/2zzn4NI
_bardump($krabiceActiveRow);
});
export default {
install (Vue) {
Vue.directive('test-demo', {
mounted(el, binding) {
const modifiers = binding.modifiers
const state = binding.arg === "a" ? "a" : "b"
if (state === 'a') {
el.style.color = 'red'
} else {
el.style.color = 'green'
}
if (modifiers.underline) {
el.style.textDecoration = "underline"
}
if (modifiers.overline) {
el.style.textDecoration = "overline"
}
}
})
Vue.directive('width', {
mounted: function (el, binding) {
el.style.width = binding.value + 'px'
}
})
// mounted + update both
Vue.directive('color-swatch', function (el, binding) {
el.style.backgroundColor = binding.value
})
Vue.directive('demo', function (el, binding) {
el.style.color = binding.value.color // => "white"
el.textContent = binding.value.text
})
}
}
<!-- https://jsbin.com/bowaxu/1/edit?html,css,output -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<a href="" class="button"><span class="button-text"></span></a>
</body>
</html>
// Sass
.Component {
.title {
color: black;
.is-active#{&} {
color: blue;
}
}
}
// shitty
.Component .title {
color: black;
}
.Component .title .is-active.Component .title {
color: blue;
}
// at-root ------------------------------ //
// sass
.Component {
.title {
color: black;
@at-root .is-active#{&} {
color: blue;
}
}
}
// css
.Component .title {
color: black;
}
.is-active.Component .title {
color: blue;
}
@mixin variant($selector) {
@at-root #{$selector}#{&} {
@content;
}
}
.Component {
.title {
color: black;
@include variant('.is-active') {
color: blue;
}
}
}
#https://jsbin.com/tedukoyara/edit?css,output
section
{
height: 600px;
border: 1px solid blue;
background:
url(https://www.flaticon.com/svg/static/icons/svg/3823/3823859.svg) right bottom / 100px no-repeat,
url(https://www.flaticon.com/svg/static/icons/svg/3823/3823866.svg) left top / 100px no-repeat,
url(https://www.flaticon.com/svg/static/icons/svg/3823/3823855.svg) 50% / 100px no-repeat;
}
-- dokumenty, regiony, klient, konkretni klient
SET @clientId = 10809;
INSERT INTO
bc_stats (bc_document_id, bc_region_id, bc_client_id)
SELECT
id,
bc_region_id,
@clientId
FROM
bc_document
WHERE bc_client_id = @clientId
AND bc_category_id != 0;
-- vsichni klienti
INSERT INTO
bc_stats (bc_document_id, bc_region_id, bc_client_id)
SELECT
id,
bc_region_id,
bc_client_id
FROM
bc_document
WHERE 1
AND bc_category_id != 0;
-- storage_id
update bc_stats t
set bc_storage_id = elt(floor(rand()*12) + 1,
8640,
8641,
4409,
5318,
5338,
6901,
5314,
3949,
3332,
3333,
3404,
11311
);
-- emaily
update bc_stats t
set email = elt(floor(rand()*15) + 1,
'janko@andweb.cz',
'stancek@andweb.cz',
'netolicky@andweb.cz',
'aaa@andweb.cz',
'bbb@andweb.cz',
'ccc@andweb.cz',
'ddd@andweb.cz',
'eee@andweb.cz',
'fff@andweb.cz',
'ggg@andweb.cz',
'hhh@andweb.cz',
'iii@andweb.cz',
'jjj@andweb.cz',
'kkk@andweb.cz',
'lll@andweb.cz'
);
-- datumy
SET @MIN = '2017-06-29 00:53:27';
SET @MAX = '2020-04-29 13:53:27';
UPDATE bc_stats
SET created = TIMESTAMPADD(SECOND, FLOOR(RAND() * TIMESTAMPDIFF(SECOND, @MIN, @MAX)), @MIN);
-- akce
update bc_stats t
set action_type = elt(floor(rand()*7) + 1,
'login',
'view',
'share',
'publish',
'download',
'upload',
'comment'
);
-- uzivatele
SELECT substring_index(GROUP_CONCAT(id), ',', 50) FROM bc_user
WHERE lastname != ''
ORDER BY id ASC into @users;
SET @sql:= CONCAT('update bc_stats t set bc_user_id = elt(floor(rand()*50) + 1,', ' ', @users, ' )');
PREPARE stmt FROM @sql;
EXECUTE stmt;
-- share
update bc_stats t
set bc_share_id = FLOOR( RAND() * (11100-11000+1) + 11000 );
-- zopakovat radky
INSERT INTO bc_stats (action_type,created,bc_client_id,bc_user_id,bc_document_id,bc_region_id,bc_share_id,bc_comment_id,bc_upload_id,bc_storage_id,email)
SELECT action_type,created,bc_client_id,bc_user_id,bc_document_id,bc_region_id,bc_share_id,bc_comment_id,bc_upload_id,bc_storage_id,email
FROM bc_stats
<?php
namespace FrontModule\Components;
use Nette,
Andweb,
Model;
class ProductDeliveryDateInfo extends Andweb\Application\UI\FrontControl
{
const HOUR = 13;
protected $items = array(
'Praha' => array(
'Osobní odběr Praha' => 0,
'Expresní večerní doručení Praha' => 0,
),
'Česká republika' => array(
'Česká pošta' => 1,
'Zásilkovna' => 1,
'Kurýrní služba' => 1,
),
'Slovensko' => array(
'Česká pošta' => 2,
'Zásilkovna' => 2,
'Kurýrní služba' => 2,
),
);
public function __construct()
{
}
public function renderDefault()
{
$template = $this->template;
$template->items = $this->items;
// Fucking php5.3 on production
$that = $this;
$template->registerHelper('formatDate', function($s) use ($that) {
return $that->formatDate($s);
});
}
public function renderNotAvailable()
{
$template = $this->template;
$this->view = 'default';
$template->notAvailable = TRUE;
$template->items = $this->items;
// Fucking php5.3 on production
$that = $this;
$template->registerHelper('formatDate', function($s) use ($that) {
return $that->formatDate($s);
});
$this->render();
}
public function formatDate($s)
{
$today = new \DateTime();
$tomorrow = clone $today;
$tomorrow->modify('+ 1 day');
if ($today->format('j.n.Y') == $s)
return $this->presenter->translator->translate('dnes');
if ($tomorrow->format('j.n.Y') == $s)
return $this->presenter->translator->translate( 'zítra');
return $s;
}
// ukaze na velikonocni nedeli, napric vsemi casovymi pasmy, jinak funkce easter_day se chova obcas divne, viz php.net
public function getEasterDateTime($year)
{
$base = new \DateTime("$year-03-21");
$days = easter_days($year);
return $base->add(new \DateInterval("P{$days}D"));
}
public function isNotHoliday(\Datetime $date)
{
// statni svatky
$holidays = array('01-01', '05-01', '05-08', '07-05', '07-06', '09-28', '10-28', '11-17', '12-24', '12-25', '12-26');
// velikonocni pondeli
$holidays[] = $this->getEasterDateTime(date('Y'))->modify('+1day')->format('m-d');
// velky patek, (pred velikonocnim pondelim)
$holidays[] = $this->getEasterDateTime(date('Y'))->modify('-2day')->format('m-d');
$day = $date->format('w');
if ($day == 0 || $day == 6)
return FALSE;
if (in_array($date->format('m-d'), $holidays))
return FALSE;
return TRUE;
}
function getDeliveryDate($actualDate, $dayDelay = 0)
{
$actualDate = new \DateTime($actualDate);
$actualDate->modify("+$dayDelay day");
while (!$this->isNotHoliday($actualDate))
{
$actualDate->modify('+1 day');
}
return $actualDate;
}
public function formatter($dayDelay)
{
// 13h a vic + 1 day
if (date('H') >= self::HOUR)
$dayDelay += 1;
return $this->getDeliveryDate(date('Y-m-d'), $dayDelay);
}
}
<?php
class User {
protected $name;
protected $timeline = array();
public function __construct($name)
{
$this->name = $name;
}
public function addTweet(Tweet $tweet)
{
$this->timeline[] = $tweet;
}
}
class Tweet {
protected $id;
protected $text;
protected $read;
public function __construct($id, $text)
{
$this->id = $id;
$this->text = $text;
$this->read = false;
}
public function __invoke($user)
{
$user->addTweet($this);
return $user;
}
}
$users = array(new User('Ev'), new User('Jack'), new User('Biz'));
$tweet = new Tweet(123, 'Hello world');
$users = array_map($tweet, $users);
var_dump($users);