phpScheduleIt
June 20, 2013, 12:12:01 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: phpScheduleIt 2.4.2 has been released!
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Accessories as check box  (Read 885 times)
axar
Newbie
*

Karma: 0
Posts: 5


« on: April 30, 2012, 07:24:38 PM »


Hi Everyone,
Recently started to use phpScheduleIt for a salon appointment scheduling purposes. I want to use the Accessories feature as a check box instead #of quantities. Where all quantities as default would be inf. and checking a Accessories will add to the list like it already does. Anyone has an ideas please pass it on. I also intent to create a big Accessories list, so will probably be creating a enhanced template for the Accessories selection screen.
Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5506


WWW
« Reply #1 on: May 01, 2012, 01:21:03 PM »

The simplest thing you could do would be to make the textboxes for quantity readonly, and add a checkbox next to it. If the checkbox is checked then put a 1 in the corresponding quantity box. This would require the least amount of changes.
Logged
axar
Newbie
*

Karma: 0
Posts: 5


« Reply #2 on: May 05, 2012, 10:49:54 AM »

Hi Nick,
thanks for the tip.

I've got most adding of acc working using javascripts. However, i'm having trouble getting the upadate to work.
I want the checkbox already checked if the reserved quantity is greater than 1.


SOLVED

Code:
JAVASCRIPT
//
function addacc(id)
{
  var elem;
elem = document.getElementById(id + 'k');

if (elem.checked == true) {
document.getElementById(id).value = 1
}else {
document.getElementById(id).value = 0
}
}



HTML
{foreach from=$AvailableAccessories item=accessory}
<tr>
<td>{$accessory->Name}</td>
<td>
<input type="hidden" class="name" value="{$accessory->Name}" />
<input type="hidden" class="id" value="{$accessory->Id}" />
<input type="text" id="{$accessory->Id}" name="accessory{$accessory->Id}" value="0" size="1" readonly="readonly"/>
<input type="checkbox" id="{$accessory->Id}k" name="chk"  onClick="addacc({$accessory->Id})"/>
</td>
<td>{$accessory->QuantityAvailable|default:'&infin;'}</td>
</tr>
{/foreach}


PHP in JAVASCRIPT

{foreach from=$Accessories item=accessory}
reservation.addAccessory('{$accessory->AccessoryId}', '{$accessory->QuantityReserved}', '{$accessory->Name}');

if ({$accessory->QuantityReserved} >= 1) {
document.getElementById('{$accessory->AccessoryId}' + 'k').checked = 1;
}else {
document.getElementById('{$accessory->AccessoryId}' + 'k').checked = 0
}
{/foreach}

« Last Edit: May 05, 2012, 12:28:18 PM by axar » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2006-2007, Simple Machines Valid XHTML 1.0! Valid CSS!