Skip to content

Instantly share code, notes, and snippets.

@0test
Created March 30, 2021 13:18
Show Gist options
  • Save 0test/ff664e92a84a74cc2683f89c22ce3bfe to your computer and use it in GitHub Desktop.
Save 0test/ff664e92a84a74cc2683f89c22ce3bfe to your computer and use it in GitHub Desktop.
switch ($modx->event->name) {
case 'OnManagerBeforeOrdersListRender': {
// добавляем столбец в таблицу заказов
$params['columns']['name'] = [
'title' => 'Имя',
'content' => function($data, $DL, $eDL) {
return !empty($data['fields']['fullname']) ? $data['fields']['fullname'] : '';
},
'sort' => 20,
];
break;
}
case 'OnManagerBeforeOrderRender': {
// добавляем поле на страницу просмотра заказа
$params['groups']['contact']['fields']['name'] = [
'title' => 'Имя',
'content' => function($data) {
return $data['fields']['fullname'];
},
'sort' => 10,
];
$params['columns']['image'] = [
'title' => 'Изображение',
'content' => function($data, $DL, $eDL) {
$modx = EvolutionCMS();
$out= $modx->runSnippet('phpthumb',[
'options'=>'w=80,h=80',
'input'=> $modx->runSnippet('multiTV',[
'tvName' => 'photo',
'docid' => $data['id'],
'outerTpl' => '@CODE: [+wrapper+]',
'rowTpl' => '@CODE: /[+image+]',
'display' => 1
])
]);
return "<img src=/$out>";
},
'sort' => 20,
];
$params['groups']['contact']['fields']['city'] = [
'title' => 'Город',
'content' => function($data) {
return $data['fields']['city'];
},
'sort' => 40,
];
$params['groups']['contact']['fields']['street'] = [
'title' => 'Улица',
'content' => function($data) {
return $data['fields']['street'];
},
'sort' => 50,
];
$params['groups']['contact']['fields']['house'] = [
'title' => 'Дом',
'content' => function($data) {
return $data['fields']['fax'];
},
'sort' => 60,
];
$params['groups']['contact']['fields']['flat'] = [
'title' => 'Кв',
'content' => function($data) {
return $data['fields']['state'];
},
'sort' => 70,
];
break;
}
case 'OnManagerBeforeOrderEditRender': {
$params['fields']['city'] = [
'title' => 'Город',
'content' => function($data) {
$value = !empty($data['fields']['city']) ? $data['fields']['city'] : '';
return '<input type="text" class="form-control" name="order[fields][city]" value="' . htmlentities($value) . '">';
},
'!rules' => [
'lengthBetween' => [
'params' => [2, 255],
'message' => 'Название города должно быть длинной от 2 до 255 символов',
],
],
'sort' => 40,
];
$params['fields']['street'] = [
'title' => 'Улица',
'content' => function($data) {
$value = !empty($data['fields']['street']) ? $data['fields']['street'] : '';
return '<input type="text" class="form-control" name="order[fields][street]" value="' . htmlentities($value) . '">';
},
'!rules' => [
'lengthBetween' => [
'params' => [2, 255],
'message' => 'Название должно быть длинной от 2 до 255 символов',
],
],
'sort' => 40,
];
$params['fields']['house'] = [
'title' => 'Дом',
'content' => function($data) {
$value = !empty($data['fields']['fax']) ? $data['fields']['fax'] : '';
return '<input type="text" class="form-control" name="order[fields][house]" value="' . htmlentities($value) . '">';
},
'!rules' => [
'lengthBetween' => [
'params' => [2, 255],
'message' => 'Название должно быть длинной от 2 до 255 символов',
],
],
'sort' => 40,
];
$params['fields']['flat'] = [
'title' => 'Квартира',
'content' => function($data) {
$value = !empty($data['fields']['state']) ? $data['fields']['state'] : '';
return '<input type="text" class="form-control" name="order[fields][flat]" value="' . htmlentities($value) . '">';
},
'!rules' => [
'lengthBetween' => [
'params' => [2, 255],
'message' => 'Название должно быть длинной от 2 до 255 символов',
],
],
'sort' => 40,
];
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment