Wednesday 29 February 2012

Setting up a Multi-page Registration Form in CB

For this I've used the CB Conditional plugin .

After installing

I started by creating the "Personal Info," "Contact Info," and "Work History" tabs in the Community Builder Tab Manager.

Next, we move to the Community Builder Field Manager. In the Field Manager some registration fields are already implemented by default. Open or create the following fields and assign them to the tabs we just created in the order listed below.


Name >> Personal Info (required text field)
Gender >> Personal Info (drop down)
Username >> Personal Info (required text field)
Password >> Personal Info (password field)
Verify Password >> Personal Info (password field)


Email >> Contact Info (required text field)
Phone >> Contact Info (text field)
Address 1 >> Contact Info (required text field)
Address 2 >> Contact Info (text field)
City >> Contact Info (required text field)
Zip >> Contact Info (required text field)
State/Province >> Contact Info (required text field or drop down if you want to list the states as options)


Employment Group >> Work History (text area)
History Notes >> Work History (drop down with morning, afternoon, evening as options)


Then after turning on the CB Conditional Component is automatically puts it into tabs,

Tuesday 28 February 2012

Changing Rentalotplus so I can a selection of units if wished to the Calendar view.

When creating a menu item for RentalotPlus I get the option to enter 'Unit ID'

If I select '0' then front end I get a calendar with a dropdown that I can select the venue I want.

Or I can enter a unit value - in which case I get a calender for the one unit.

What it doesn't do and what I'd like it to do is for me to enter '1,5,6' etc and be able to choose a selection of units.


OPEN


administrator/components/com_rentalotplus/helpers/view_helper.php

REPLACE the function draw_UC_selectors with the following

[code]

function draw_UC_selectors(&$unit_id, $unit_list, $front_unit_name, $currency_list, $current_currency_code, $controller)
{
$unit_id = trim($unit_id);
$unit_id_list = array();

if ($unit_list === false)
{
$unit_id = -1;
return JText::_('COM_RENTALOTPLUS_ERROR_NO_UNITS');
}

if (!empty($unit_id))
// if a specific unit id is specified, check it exists
//$pos = strpos($unit_id, ',');
//echo $pos;
if(strpos($unit_id, ',') || strpos($unit_id, ',')===true){
$unit_ids = explode(',',$unit_id);
//print_r($unit_ids);
foreach($unit_ids as $uid){
if(!empty($uid) && $uid>0){
if(array_key_exists($uid,$unit_list)){

$unit_id_list[$uid] = $unit_list[$uid];
}
}
}
}
else if (!array_key_exists($unit_id,$unit_list)){
$unit_id = -1;
return JText::_('COM_RENTALOTPLUS_INVALID_UNIT_ID').' ('.$unit_id.')';

}

if ($currency_list === false)
{
$unit_id = -1;
return JText::_('COM_RENTALOTPLUS_ERROR_NO_CURRENCIES');
}

$num_units = count($unit_list);
$num_currencies = count($currency_list);
$unit_html = '';
$html = '';
$draw_form = false;

// if no unit was specified, either select the one and only unit, or draw a select list

if ( empty($unit_id) ) // unit_id can an empty string or zero for automatic selection
{
$unit_id = key($unit_list); // get the first unit id
$unit_html = "\n".'<input type="hidden" name="unit_id" value="'.$unit_id.'" />';
if ($num_units > 1) // if more than one ...
{
$draw_form = true;
$unit_id = JRequest::getVar('unit_id',$unit_id); // get currently selected unit id
$list_html = LA_view::make_list('unit_id', $unit_id, $unit_list, 0 ,'onchange="this.form.submit()"');
$unit_html = "\n".$front_unit_name.' '.$list_html."  ";
}
}


else if(count($unit_id_list)>0){

$unit_id = key($unit_id_list); // get the first unit id
$unit_html = "\n".'<input type="hidden" name="unit_id" value="'.$unit_id.'" />';
if (count($unit_id_list) > 1) // if more than one ...
{
$draw_form = true;
$unit_id = JRequest::getVar('unit_id',$unit_id); // get currently selected unit id
$list_html = LA_view::make_list('unit_id', $unit_id, $unit_id_list, 0 ,'onchange="this.form.submit()"');
$unit_html = "\n".$front_unit_name.' '.$list_html."  ";
}


}
else{ // if unit_id is not empty, pass back the one already selected
$unit_html = "\n".'<input type="hidden" name="unit_id" value="'.$unit_id.'" />';
}
if ($num_currencies > 1)
{
$draw_form = true;
$currency_html = "\n".LA_view::make_list('currency', $current_currency_code, $currency_list, 0, 'onchange="this.form.submit()"');
}
else
$currency_html = '';

if ($draw_form)
{
$html = "\n".'<div class="rentalot_selectors">';
$uri =& JFactory::getURI();
$myuri = $uri->toString();
$html .= "\n".'<form name="selector_form" action="'.$myuri.'" method="post">';
if ($controller != '')
$html .= "\n".'<input type="hidden" name="controller" value="'.$controller.'" />';
$html .= $unit_html;
$html .= $currency_html;

// 4.14.02 - preserve all context

$call_type = JRequest::getVar('call_type', '');
if ($call_type != '')
$html .= "\n".'<input type="hidden" name="call_type" value="'.$call_type.'" />';

$task = JRequest::getVar('task', '');
if ($task != '')
$html .= "\n".'<input type="hidden" name="task" value="'.$task.'" />';

$datefrom = JRequest::getVar('datefrom', '');
if ($datefrom != '')
$html .= "\n".'<input type="hidden" name="datefrom" value="'.$datefrom.'" />';

$dateto = JRequest::getVar('dateto', '');
if ($dateto != '')
$html .= "\n".'<input type="hidden" name="dateto" value="'.$dateto.'" />';

$html .= '</form></div><br /><br />';
}
return $html;

}


function draw_UC_selectors_backup(&$unit_id, $unit_list, $front_unit_name, $currency_list, $current_currency_code, $controller)
{
if ($unit_list === false)
{
$unit_id = -1;
return JText::_('COM_RENTALOTPLUS_ERROR_NO_UNITS');
}

if (!empty($unit_id)) // if a specific unit id is specified, check it exists
if (!array_key_exists($unit_id,$unit_list))
{
$unit_id = -1;
return JText::_('COM_RENTALOTPLUS_INVALID_UNIT_ID').' ('.$unit_id.')';
}

if ($currency_list === false)
{
$unit_id = -1;
return JText::_('COM_RENTALOTPLUS_ERROR_NO_CURRENCIES');
}

$num_units = count($unit_list);
$num_currencies = count($currency_list);
$unit_html = '';
$html = '';
$draw_form = false;

// if no unit was specified, either select the one and only unit, or draw a select list

if (empty($unit_id)) // unit_id can an empty string or zero for automatic selection
{
$unit_id = key($unit_list); // get the first unit id
$unit_html = "\n".'<input type="hidden" name="unit_id" value="'.$unit_id.'" />';
if ($num_units > 1) // if more than one ...
{
$draw_form = true;
$unit_id = JRequest::getVar('unit_id',$unit_id); // get currently selected unit id
$list_html = LA_view::make_list('unit_id', $unit_id, $unit_list, 0 ,'onchange="this.form.submit()"');
$unit_html = "\n".$front_unit_name.' '.$list_html."  ";
}
}
else // if unit_id is not empty, pass back the one already selected
$unit_html = "\n".'<input type="hidden" name="unit_id" value="'.$unit_id.'" />';

if ($num_currencies > 1)
{
$draw_form = true;
$currency_html = "\n".LA_view::make_list('currency', $current_currency_code, $currency_list, 0, 'onchange="this.form.submit()"');
}
else
$currency_html = '';

if ($draw_form)
{
$html = "\n".'<div class="rentalot_selectors">';
$uri =& JFactory::getURI();
$myuri = $uri->toString();
$html .= "\n".'<form name="selector_form" action="'.$myuri.'" method="post">';
if ($controller != '')
$html .= "\n".'<input type="hidden" name="controller" value="'.$controller.'" />';
$html .= $unit_html;
$html .= $currency_html;

// 4.14.02 - preserve all context

$call_type = JRequest::getVar('call_type', '');
if ($call_type != '')
$html .= "\n".'<input type="hidden" name="call_type" value="'.$call_type.'" />';

$task = JRequest::getVar('task', '');
if ($task != '')
$html .= "\n".'<input type="hidden" name="task" value="'.$task.'" />';

$datefrom = JRequest::getVar('datefrom', '');
if ($datefrom != '')
$html .= "\n".'<input type="hidden" name="datefrom" value="'.$datefrom.'" />';

$dateto = JRequest::getVar('dateto', '');
if ($dateto != '')
$html .= "\n".'<input type="hidden" name="dateto" value="'.$dateto.'" />';

$html .= '</form></div><br /><br />';
}
return $html;

}

{[/code]

Add 'How many spaces left' to availability search in Rentalotplus Joomla

after my recent change to the Rentalotplus component Changing Joomla Rentalotplus component to take multiple bookings on each unit I've now made another small change so that after an 'availbility check' is made we can see how many spaces is left.

OPEN administrator/components/com_rentalotplus/models/booking.php

find the function checkForBookingOverlaps

before the closing
[code]
return true;
[/code]

ADD
[code]
$spaces = $maxPeople-$count;
$message = $spaces.JText::_("COM_RENTALOT_BOOKING_SPACES_LEFT");
[/code]

You'll need to add this to language/en-GB.com_rentalotplus.ini too

COM_RENTALOT_BOOKING_SPACES_LEFT=" spaces are left on this course."


and that's it :)

Monday 27 February 2012

Joomla 2.5 Rentalot - add Unit ID to the finacial report page

Here's a quick core change. What I need to do was to add a column in the Finacial Report view in Rentalotplus. it's as easy as this

OPEN

administrator/components/com_rentalotplus/views/finacial/view.html.php

FIND

[code]<th class="title" nowrap="nowrap"><?php echo JText::_('COM_RENTALOTPLUS_FROM_DATE');?></th>[/code]

AND BEFORE IT ADD

[code]<th class="title" width="20"><?php echo JText::_('COM_RENTALOTPLUS_ID'); ?></th>[/code]

FIND

[code]echo "<tr class='row$k'>
<td>$row->date_from</td>[/code]

REPLACE WITH

[code]echo "<tr class='row$k'>
<td>$row->id</td>
<td>$row->date_from</td>[/code]

Monday 20 February 2012

how do i find out my sandbox paypal account tokens

how do i find out my sandbox paypal account tokens

paypal secure merchant account id



Whilst setting up a test account I needed a Paypal Account token, but thanks to Payals help search being broken this took longer than I expected.

The solution was that after creating a Paypal Sandbox account

> login

> on the left hand menu click on 'API credentials'

> then in the main screen copy the code that is in your signature.

Sunday 19 February 2012

Changes to Rentalotplus that I'd like to make.

Merging the Calendar with the Availability Check

Stage1: Login ->








Stage 2: click on the training link ->




Stage 3: ->  click on 'book now' 



Stage 4: and then choose the dates you want and check availability.




###############


what I'd like to happen is for Stage 3 &4 to be merged. and the page to look like this.
















The two view pages that need to be merged are here. 



the Check is called from inside the Daily view in the scenario above.








Thursday 16 February 2012

Changing Joomla Rentalotplus component to take multiple bookings on each unit

Suitable for single user booking systems only

The aim here is to take have a unit/training centre where we can book multiple places ( number set in admin ) on various dates.

As rentalot is a booking system it's designed to book for groups and families, in my scenario users will only be booking for themselves and never for groups .

If your system is for booking groups then the following hack is of no use.


When installed and using the Daily view the process works like

> You see the calendar that shows you available dates

> on the next page you select the dates and click on the 'availability' check

> this then activates the check. it's this check that I've changed and therefor

allowing multiple bookings on the same unit on the same day.


Following the breadcrumbs back from the view I found where to enter the solution in
administrator/components/com_rentalotplus/models/booking.php


if you add the following function to this class

[code]

function maxPeople()
{
$unit_id = $this->_data->unit_id;


$sql="SELECT max_people FROM m37hf_rentalot_plus_units WHERE id='".$unit_id."' ";
$this->_db->setQuery($sql);


$Result = $this->_db->loadObjectList();
//echo "$sql";
//print_r($Result); 
return $Result;




}

[/code]


and then find 'function checkForBookingOverlaps'


UNDER $count = count($rows);


ADD

[code]

//find out how many spaces in the unit
$unitspaces = $this->maxPeople(); //DJ
    $maxPeople=$unitspaces[0]->max_people;
 $maxPeople=$maxPeople-1;
[/code]


then find the condition ($count != 0' )

and change this to


($count > $maxPeople)


Wednesday 15 February 2012

Rentalot Plus calendar not working in Joomla 1.7

I've installed rentalotplus on a joomla 1.7 installation and did not have the calendar when checking for Availability.

It was working on a 2.5 installation but I've had to go back to 1.7 as the commumnity builder component would not install on 2.5

Here's an image of what was happening.


the solution is to log into the admin area.

Go to

> components

> rentalot

> configuration

> general

and then navigate down to the 'Site date picker' dropdown and change this. One of them should work for your site. For me it was JQuery

Tuesday 14 February 2012

Making some changes on a Joomla MVC Component.

I thought I'd write a blog about some changes paid to get made to the Rentalotplus component last week. To be honest my requirements must have been lost in translation as the results weren't a working example of what I needed. However I do feel the code is of note.

The result of the changes do this . * make a row check of bookings in the database

* if there has been too many bookings then the 'Book Now' button will not show.


Here's the code changes.

OPEN models/classic.php

in the function &getData

ADD

$result = $this->totalBooking($unit_id);


UNDERNEATH


$this->stats_hit($unit_id);


AFTER THE CLOSING BRACKET OF THAT FUNCTION ADD

function totalBooking($unit_id)
{

$sql="SELECT COUNT(unit_id) AS totalRecord FROM m37hf_rentalot_plus_bookings WHERE unit_id='".$unit_id."'";
$this->_db->setQuery($sql);

$Result = $this->_db->loadObjectList();
//print_r($Result);
return $Result;


}
// --



the OPEN views/daily/view.html.php


FIND the line

$classic_model = $this->getModel('classic');


AFTER ADD


$itemstext = $classic_model->totalBooking($unit_id); //GHRIX


$totalBooking=$itemstext[0]->totalRecord;

$unit_model = $this->getModel('unit');

$unit_data = $unit_model->getOne($unit_id);

$max_people = $unit_data->max_people - 1;


if($totalBooking<$max_people) { $book_button = $menu_params->get('book_button', 'yes');

}
else
{
$
book_button = '';
}



#####


Basically in the Model view we load the data with the information about how many reservations have been made for this unit.

Then in the view we retrieve that information .

$classic_model has already been used to load the data from the model

* so we then use $itemstext to get the 'totalBooking' infromation from that data.

* its an array though so using $itemstext[0] gets the number we're after

* using the getModel('unit') we can access the unit information that we need for comparison.

* the comparrison is done and button displayed if we need it to be.


the only thing is that it doesn't really do anything as for it to be in anyway of use I'll need to put a date check on the mysql call and we'll need to change the check on the availability check on the following page.


Tuesday 7 February 2012

joomla 1.7 cb install Unable to find install package

the first thing you should try if you get the message 'Unable to find install package' while installing Community Builder on 1.7 is upload the folder 'com_comprofiler' into your 'tmp' folder . And then use the install from folder function in Component installer.

It work for me anyway :)