Skip to content

Instantly share code, notes, and snippets.

@sergant210
Created January 23, 2019 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergant210/511228531eaf425bd5d93a61eb68316e to your computer and use it in GitHub Desktop.
Save sergant210/511228531eaf425bd5d93a61eb68316e to your computer and use it in GitHub Desktop.
<?php
/** @var array $scriptProperties
* @var msOrder $msOrder
*/
switch ($modx->event->name) {
case 'msOnBeforeAddToCart':
if (!empty($_SESSION['oneBooking']['price'])) {
$product->set('price', $_SESSION['oneBooking']['price']);
}
break;
case 'msOnBeforeCreateOrder':
$properties = $msOrder->get('properties');
$properties['booking'] = $_SESSION['oneBooking']['bid'];
$_SESSION['oneBooking']['bid'] = null;
$msOrder->set('properties',$properties);
break;
case 'msOnChangeOrderStatus':
if (empty($status) || $status != 2) {return;}
$properties = $order->get('properties');
if (!$booking = intval($properties['booking'])) {return;};
// Изменяем статус заказа
$paidStatus = $modx->getOption('onebooking.obPaidStatus', NULL, 0);
if (!empty($paidStatus)) {
$oneBooking = $modx->getService('onebooking','oneBooking',$modx->getOption('core_path').'components/onebooking/model/onebooking/');
if ($oneBooking instanceof oneBooking) {
if ($o = $modx->getObject('oneBookingReserved',$booking)) {
$o->set('status',$paidStatus);
$o->save();
}
}
}
break;
case 'OnManagerPageBeforeRender':
$tabs = '';
if ($modx->getOption('onebooking.showTab_booking', null, true)) {
$tabs .= '{
title: _("onebooking_booking_tab"),
layout: "anchor",
items: [{
xtype: "onebooking-grid-booking",
cls: "main-wrapper"
}]
}';
}
if ($modx->getOption('onebooking.showTab_objects', null, true)) {
$tabs .= !empty($tabs) ? ',' : '';
$tabs .= '{
title: _("onebooking_objects_tab"),
layout: "anchor",
items: [{
xtype: "onebooking-grid-objects",
cls: "main-wrapper"
}]
}';
}
if ($modx->getOption('onebooking.showTab_extras', null, true)) {
$tabs .= !empty($tabs) ? ',' : '';
$tabs .= '{
title: _("onebooking_extras_tab"),
layout: "anchor",
items: [{
xtype: "onebooking-grid-extras",
anchor: "100%",
cls: "main-wrapper"
}]
}';
}
if ($modx->getOption('onebooking.use_module_periods')) {
$tabs .= !empty($tabs) ? ',' : '';
$tabs .= '{
title: _("onebooking_periods_tab"),
id: "onebooking-periods-tab",
layout: "anchor",
items: [{
xtype: "onebooking-grid-periods",
cls: "main-wrapper"
}]
}';
}
if (!empty($tabs)) {
$output = '
Ext.ComponentMgr.onAvailable("onebooking-home-tabs", function() {
this.on("beforerender", function() {
this.add('. $tabs . ');
});
});
';
$modx->controller->addHtml('<script>' . $output . '</script>');
}
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment