Skip to content

Commit

Permalink
Merged in PG-331-ERROR-when-searching-for-activity (pull request civi…
Browse files Browse the repository at this point in the history
…crm#14)

updated civibooking extension to 1.5
  • Loading branch information
vincent1892 committed Nov 14, 2016
2 parents 8ce4973 + 9765e5b commit 0432a1b
Show file tree
Hide file tree
Showing 166 changed files with 270 additions and 92 deletions.
Empty file modified sites/all/civicrm_extensions/civibooking/.gitignore
100644 → 100755
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ public function buildQuickForm($check = FALSE) {
));
}
catch (CiviCRM_API3_Exception $e) {}

//allow state changes only when there is enabled config set
if(!in_array($resource['set_id'], array_keys($activeSets['values']))){
if(!empty($resource['set_id']) && !in_array($resource['set_id'], array_keys($activeSets['values']))){
$statusCheckbox->setAttribute('disabled', 'disabled');
}

Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
12 changes: 6 additions & 6 deletions sites/all/civicrm_extensions/civibooking/CRM/Booking/BAO/Query.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -270,20 +270,20 @@ function from($name, $mode, $side) {
$from = NULL;
switch ($name) {
case 'civicrm_booking':
$from = " $side JOIN civicrm_booking ON civicrm_booking.primary_contact_id = contact_a.id AND civicrm_booking.is_deleted = 0";
$from = " $side JOIN civicrm_booking ON civicrm_booking.primary_contact_id = contact_a.id AND civicrm_booking.is_deleted = 0 ";
break;
case 'civicrm_booking_status':
$from = " $side JOIN civicrm_option_group option_group_booking_status ON (option_group_booking_status.name = 'booking_status')";
$from = " $side JOIN civicrm_option_group option_group_booking_status ON (option_group_booking_status.name = 'booking_status') ";
$from .= " $side JOIN civicrm_option_value civicrm_booking_status ON (civicrm_booking.status_id = civicrm_booking_status.value AND option_group_booking_status.id = civicrm_booking_status.option_group_id ) ";
break;
case 'civicrm_booking_payment_status':
$from .= " $side JOIN civicrm_booking_payment on civicrm_booking_payment.booking_id = civicrm_booking.id";
$from .= " $side JOIN civicrm_contribution contribution on contribution.id = civicrm_booking_payment.contribution_id";
$from .= " $side JOIN civicrm_option_group option_group_booking_payment ON option_group_booking_payment.name = 'contribution_status'";
$from .= " $side JOIN civicrm_booking_payment on civicrm_booking_payment.booking_id = civicrm_booking.id ";
$from .= " $side JOIN civicrm_contribution contribution on contribution.id = civicrm_booking_payment.contribution_id ";
$from .= " $side JOIN civicrm_option_group option_group_booking_payment ON option_group_booking_payment.name = 'contribution_status' ";
$from .= " $side JOIN civicrm_option_value civicrm_booking_payment_status ON (contribution.contribution_status_id = civicrm_booking_payment_status.value AND option_group_booking_payment.id = civicrm_booking_payment_status.option_group_id ) ";
break;
case 'civicrm_booking_associated_contact':
$from = " $side JOIN civicrm_contact civicrm_booking_associated_contact ON (civicrm_booking_associated_contact.id = civicrm_booking.secondary_contact_id)";
$from = " $side JOIN civicrm_contact civicrm_booking_associated_contact ON (civicrm_booking_associated_contact.id = civicrm_booking.secondary_contact_id) ";
break;
}
return $from;
Expand Down
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ static function getSlotBetweenDate($from, $to){
*/
static function getSlotDetailsOrderByResourceBetweenDate($from,$to) {
$slots = array();
$slotsResult = CRM_Booking_BAO_Slot::getSlotBetweenDate($from, $to);
$slotsResult = CRM_Booking_BAO_Slot::getSlotsBetweenBookingDate($from, $to);
foreach ($slotsResult as $key => $slotItem) {
//get booking detail
$params = array('booking_id' => $slotItem['booking_id'],);
Expand Down Expand Up @@ -431,4 +431,50 @@ static function getSlotDetailsOrderByResourceBetweenDate($from,$to) {
return $orderResource;
}

/**
* Get Slot records between given booking_dates
*
* @return array
* @param $from fromDate put mySql Date type, for example '2013-12-03'
* @param $to toDate put mySql Date type, for example '2013-12-03'
*/
static function getSlotsBetweenBookingDate($from, $to) {

$params = array(1 => array( $from, 'String'),
2 => array( $to, 'String'));

$query = "
SELECT cbs.id,
cbs.booking_id,
cbs.resource_id,
cbs.config_id,
cbs.start,
cbs.end,
cbs.quantity,
cbs.note
FROM civicrm_booking_slot cbs, civicrm_booking cb
WHERE cbs.booking_id = cb.id
AND
(DATE(cb.booking_date) >= %1 AND DATE(cb.booking_date) < %2)
AND cbs.is_deleted = 0";

$slots = array();
$dao = CRM_Core_DAO::executeQuery($query, $params);

while ($dao->fetch()) {
$slots[$dao->id] = array(
'id' => $dao->id,
'booking_id' => $dao->booking_id,
'resource_id' => $dao->resource_id,
'config_id' => $dao->config_id,
'start' => $dao->start,
'end' => $dao->end,
'quantity' => $dao->quantity,
'note' => $dao->note,
);
}

return $slots;
}

}
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
7 changes: 5 additions & 2 deletions sites/all/civicrm_extensions/civibooking/CRM/Booking/Form/DayView.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ function postProcess() {
$selectedDate = CRM_Utils_Array::value('dayview_select_date',$values);

//get booking slots from selected date
$from = CRM_Utils_Date::processDate($selectedDate);
$resources = CRM_Booking_BAO_Slot::getSlotDetailsOrderByResourceBetweenDate($from, $from);
//$from = CRM_Utils_Date::processDate($selectedDate);
$from = date('Y-m-d', strtotime($selectedDate));
$to = date('Y-m-d', strtotime($from . ' +1 day'));

$resources = CRM_Booking_BAO_Slot::getSlotDetailsOrderByResourceBetweenDate($from, $to);
//put resources result to values, being ready to display.
$values['resources'] = $resources;

Expand Down
2 changes: 1 addition & 1 deletion sites/all/civicrm_extensions/civibooking/CRM/Booking/Form/Search.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class CRM_Booking_Form_Search extends CRM_Core_Form {
*/
protected $_context = NULL;

protected $_defaults;
public $_defaults;

/**
* prefix for the controller
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
5 changes: 3 additions & 2 deletions sites/all/civicrm_extensions/civibooking/CRM/Booking/Page/Print/DayView.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ function run() {
$date = date('m/d/Y', round($date/1000));

//get resources information by selected date
$from = CRM_Utils_Date::processDate($date);
$resources = CRM_Booking_BAO_Slot::getSlotDetailsOrderByResourceBetweenDate($from, $from);
$from = date('Y-m-d', strtotime($date));
$to = date('Y-m-d', strtotime($from . ' +1 day'));
$resources = CRM_Booking_BAO_Slot::getSlotDetailsOrderByResourceBetweenDate($from, $to);

$values = array();
//put resources result to values, being ready to display.
Expand Down
14 changes: 11 additions & 3 deletions sites/all/civicrm_extensions/civibooking/CRM/Booking/Page/Tab.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,17 @@ function view() {
* @access public
*/
function edit() {
if (!CRM_Core_Permission::check(array('administer CiviBooking', 'create and update bookings'))
|| !(CRM_Core_Permission::check('administer CiviBooking')
&& $this->_action == CRM_Core_Action::DELETE)) {

$hasUpdatePerm = CRM_Core_Permission::check('create and update bookings');
$hasAdministerPerm = CRM_Core_Permission::check('administer CiviBooking');

$canUpdate = ($hasUpdatePerm || $hasAdministerPerm);
$canDelete = $hasAdministerPerm;

$actionAddOrUpdate = in_array($this->_action, array(CRM_Core_Action::UPDATE, CRM_Core_Action::ADD));
$isActionDelete = ($this->_action == CRM_Core_Action::DELETE);

if(($actionAddOrUpdate && !$canUpdate) || ($isActionDelete && !$canDelete)) {
CRM_Utils_System::permissionDenied();
CRM_Utils_System::civiExit();
}
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified sites/all/civicrm_extensions/civibooking/LICENSE.md
100644 → 100755
Empty file.
113 changes: 108 additions & 5 deletions sites/all/civicrm_extensions/civibooking/README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,111 @@
CiviBooking is an extensions defining a resource booking application that runs on top of the CiviCRM platform.
##CiviBooking

See also:
###What is CiviBooking?
Are you a non-profit with Rooms or Resources that you think you could raise money by renting out? Or are you a community center or voluntary service looking to manage your resources better? Sick of spreadsheets, emails and that Google calendar that no one keeps up to date? Then CiviBooking is for you!

Wiki: http://wiki.civicrm.org/confluence/display/CRM/Booking+Component
CiviBooking is a CiviCRM extension which allows you to:

Bug report: Please mark the release name at the end of issue title.
e.g. Label text of Booking result is incorrect - release-1.1
- Create a list of resources which are available to be booked (we call these limited resources as once their booked, they're gone!)
- These are shown in a fancy calendar type screen so you can see what’s available super easily.
- Contacts in the database can book one of more of these by using the booking wizard.
- Contacts can add unlimited resources to the bookings (tea's, coffee's, solar energy...)
- Contacts can add additional charges, discounts and calculate a price based on what’s booked.
- You can make provisional bookings and come back and edit them later.
- You can cancel bookings, applying a cancellation charge if necessary.

Oh and of course everything integrates super nicely with search, contact tabs, CiviContribute for payments and some other tricks and tweaks along the way.

###Installing CiviBooking
CiviBooking is a free and open source extension for CiviCRM that can be downloaded from the extensions directory.

To find out more about the extensions directory and how to configure it please see below:

1. Set up and install CiviCRM as you would normally. More details [Here](https://wiki.civicrm.org/confluence/display/CRMDOC/Installation+and+Upgrades)

2. Create and set your extensions directory in CiviCRM at:

http://example.com/civicrm/admin/setting/path?reset=1

(You may need to create a folder for your extensions and set the permissions for that folder. See [Here](https://wiki.civicrm.org/confluence/display/CRMDOC43/Extensions) for full instructions and information on how to set and configure extensions.)

3. Once configured, simply got to the "add new" tab in your extensions listing:
http://example.com/civicrm/admin/extensions?reset=1

Then locate the CiviBooking extension and click Download.

###Overview
Like with all systems, before you configure CiviBooking you will need to do some planning.

CiviBooking has support for “limited” and “unlimited” resources.

Limited resources can only be used by one person at a time, where-as unlimited resources are available to be used multiple times at the same time.

As such limited resources may be Rooms, Projectors or Vans, which once booked to a person are in use, whereas an unlimited resource could be Tea/Coffee or Lunches for example.

Limited resources are shown on page one of the booking wizard with a calendar view, whereas unlimited resources are shown on page 2.

Each resource has a “configuration set” allocated to it. This set can be thought of as the pricing options that are available for each resource. For example you may wish to charge for your room on the basis of the length of time it is used for. You may say that the price for a full day is £110, whereas the price for a half-day is £75. These two prices would make up the configuration options for the set.

The price of a resource is calculated as the:

Configuration option price x Quantity

So if someone books for 2 days, you can simply set the price when booking to be 2 x Full day price.


###Configuration

####Step 1: Define your configuration sets and options
For each resource you will need to decide on your configuration options. We suggest you start at this step, as without it you will not be able to add resources.

Each configuration option also has a unit. You could choose to make the units whatever you wish, so if you wish to charge by hour, day, person or any other label, the system will allow you to do so.

Start by creating your list of configuration size units. (For example this may be days, people, hours etc.).

Then create a configuration set for Rooms. A configuration set can be used by more then 1 resource. After creating your set, add each pricing option.

####Step 2: Create your resources
**Resource types:**

Resources can have different types. This defines the group that they will be shown in on the screen. You may wish to group resources by room, or by location depending on what is easiest.

Start by entering in your resource types from the resource type option list.

**Resources:**

Now you are able to add your resources. For each resource you can select a type and a configuration option set.

You can set the resource to be limited or unlimited here.

####Step 3: Cancellation charges
When cancelling a booking, a wizard page appears allowing you to set a cancellation charge based on the cost of the booking.

This could be based on a percentage of the total cost of the booking and then a manual adjustment could be made.

The % charges for cancellation can be adjusted in the cancellation charges option menu. Enter a number value which corresponds to the % discount charge in the value field.

####Step 4: Additional (Ad-hoc) charges items
Other charges can be added to the booking through the additional charges items. This may be charges for consumables used during the booking that need to be added after the booking has completed. You can add items and a price for each item in the Additional Charges item menu link.

###Addon
We have also created a Drupal view integration module for CiviBooking. This module creates view handlers for booking entities which enables the display of booking data on the Drupal side. It also has a few built-in calendar view templates which can be used to create calendar views for bookings and resource availability.

https://github.com/compucorp/civiBooking_calendar

###Credit
CiviBooking was developed by Compucorp Ltd with kind funding from the GMCVO, Blackburn with Darwin CVS and Zing Foundation

###Support
If you have issues with the CiviBooking extension please comment on the github issues list Here. Please provide your extension and environment detail in the ticket to help accelarate the investigations.

CiviCRM Extension Page: https://civicrm.org/extensions/civibooking

Please contact the follow email if you have any question: <info@compucorp.co.uk>, <guanhuan@compucorp.co.uk>

Paid support for this extension is available, please contact us either via github or at info@compucorp.co.uk

<br \>

[![Compucorp Ltd.][1]][2]
[1]: https://www.compucorp.co.uk/sites/default/files/logo.png
[2]: https://www.compucorp.co.uk
Empty file.
Empty file.
Empty file modified sites/all/civicrm_extensions/civibooking/api/v3/Booking.php
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file modified sites/all/civicrm_extensions/civibooking/api/v3/Resource.php
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file modified sites/all/civicrm_extensions/civibooking/api/v3/Slot.php
100644 → 100755
Empty file.
Empty file modified sites/all/civicrm_extensions/civibooking/api/v3/SubSlot.php
100644 → 100755
Empty file.
Empty file modified sites/all/civicrm_extensions/civibooking/bin/setup.conf.txt
100644 → 100755
Empty file.
Empty file modified sites/all/civicrm_extensions/civibooking/bin/setup.sh
100644 → 100755
Empty file.
Empty file modified sites/all/civicrm_extensions/civibooking/booking.civix.php
100644 → 100755
Empty file.
Loading

0 comments on commit 0432a1b

Please sign in to comment.