function saveNewBicycle($option) { global $mainframe; $item = new CbodbItem(); $postrow = JRequest::get('post'); $memberID = JRequest::getVar('memberID'); $db =& JFactory::getDBO(); $query = "SELECT MAX(tag) FROM #__cbodb_items"; $db->setQuery($query); $maxTag = $db->loadResult(); if ($db->getErrorNum()) { echo $db->stderr(); return false; } $item->tag = $maxTag + 1; $item->isBike = 1; $item->setAll($postrow); //$item->commissionUserID = JRequest::getVar('memberID'); $item->saveData(); // Added 2012-07-26 Lee Reis Post-Givecamp 2012 $membertransaction = new CbodbTransaction(); date_default_timezone_set(getConfigValue("timeZone")); $membertransaction->dateOpen = date("Y-m-d H:i:s", time()); $membertransaction->dateClosed = date("Y-m-d H:i:s", time()); $membertransaction->type = 7; $membertransaction->memberID = $memberID; $membertransaction->itemID = $maxTag + 1; $membertransaction->cash = $item->priceSale; $membertransaction->saveData(); // End of Added 2012-07-26 $mainframe->redirect('index.php?option=' . $option . '&task=shop&key=3b767559374f5132236f6e68256b2529#top', "Bicycle is saved with tag number {$item->tag}. Please write the number on the bike's tag!"); }
function saveBicycle($option) { global $mainframe; $postRow = JRequest::get('post'); $bicycle = new CbodbItem($postRow['id']); $bicycle->setAll($postRow); $db =& JFactory::getDBO(); // Added 2012-07-21 Bart McPherson Givecamp 2012; adjusted by Lee if (isset($postRow['tag']) && $postRow['tag'] == NULL) { $query = "SELECT MAX(tag) FROM #__cbodb_items"; $db->setQuery($query); $maxTag = $db->loadResult(); if ($db->getErrorNum()) { echo $db->stderr(); return false; } $bicycle->tag = $maxTag + 1; $query = "SELECT id FROM #__cbodb_items WHERE tag = '" . $bicycle->tag . "' LIMIT 1"; $db->setQuery($query); $id = $db->loadResult(); $membertransaction = new CbodbTransaction(); date_default_timezone_set(getConfigValue("timeZone")); $membertransaction->dateOpen = date("Y-m-d H:i:s", time()); $membertransaction->dateClosed = date("Y-m-d H:i:s", time()); $membertransaction->type = 7; $membertransaction->memberID = $postRow['memberID']; $membertransaction->itemID = $maxTag + 1; $membertransaction->cash = $bicycle->priceSale; $membertransaction->saveData(); } // End of Added 2012-07-21; adjusted by Lee to only be added for new bike and add tag number and price /* if ($id > 0) { $mainframe->redirect('index.php?option=' .$option.'&task=editbicycle&cid='.$id, 'Sorry, that tag number is in use. Here is the bike.'); }*/ $bicycle->saveData(); $another = JRequest::getVar('another'); if (strcmp($another, "on") == 0) { $mainframe->redirect('index.php?option=' . $option . '&task=add&cbodb_mode=bicycle', 'Bicycle Saved - Tag ' . $bicycle->tag); } else { $mainframe->redirect('index.php?option=' . $option . '&task=showbicycles', 'Bicycle Saved - Tag ' . $bicycle->tag); } }
function addBicycle($option, $memberID) { //$commissionMechanics = CbodbMember::getGroupMemberList($option, "Commission mechanic"); $commissionMechanics = CbodbItem::getCommissionedMechanics(); $commissionMechanics[0] = "No one"; ksort($commissionMechanics); ?> <h2>Enter a Bicycle</h2> <p>Use this form to enter the bicycle you've been working on into our database system. When you're done, press "Save and Finish", and the system will give a tag number to write on the bicycle's paper tag.</p> <?php JHTML::_('behavior.formvalidation'); ?> <script language="javascript"> function myValidate(f) { if (document.formvalidator.isValid(f)) { f.check.value='<?php echo JUtility::getToken(); ?> '; //send token return true; } else { var msg = 'You have not entered all necessary values for this bicycle:'; //Example on how to test specific fields if($('bikeBrand').hasClass('invalid')){msg += '\n\n\tMissing Brand';} if($('bikeModel').hasClass('invalid')){msg += '\n\tMissing Model';} if($('bikeColor').hasClass('invalid')){msg += '\n\tMissing Color';} if($('bikeSerial').hasClass('invalid')){msg += '\n\tMissing Serial';} if($('priceSale').hasClass('invalid')){msg += '\n\tMissing Price';} if($('bikeSize1').hasClass('invalid')){msg += '\n\tMissing Height';} if($('bikeSize2').hasClass('invalid')){msg += '\n\tMissing Length';} if($('bikeSize3').hasClass('invalid')){msg += '\n\tMissing Tire Size';} alert(msg); } return false; } </script> <form id="test-form" method="post" class="form-validate" onSubmit="return myValidate(this);"> <input type="hidden" name="check" value="post"/> <table> <tr> <td width="200" align="right" class="key">Bike Brand:</td> <td><input type="text" class="required" name="bikeBrand" id="bikeBrand" size="20" maxlength="50" value="" /></td> </tr> <tr> <td width="200" align="right" class="key">Bike Model:</td> <td><input type="text" class="required" name="bikeModel" id="bikeModel" size="20" maxlength="50" /></td> </tr> <tr> <td width="200" align="right" class="key">Color:</td> <td><input class="required" type="text" name="bikeColor" id="bikeColor" size="20" maxlength="50" /></td> </tr> <tr> <td width="200" align="right" class="key">Bike Serial Number:</td> <td><input class="required" type="text" name="bikeSerial" id="bikeSerial" size="20" maxlength="50" /></td> </tr> <tr> <td width="100" align="right" class="key">Sale Price:</td> <td><input class="required" type="text" name="priceSale" id="priceSale" size="50" maxlength="250" /></td> </tr> <tr> <td width="100" align="right" class="key">Is it for sale?</td> <td><input type="checkbox" name="isForSale" id="isForSale" /></td> </tr> <tr> <td width="100" align="right" class="key">Is it ready?</td> <td><input type="checkbox" name="isReady" id="isReady" /></td> </tr> <tr> <td width="100" align="right" class="key">Size:</td> <td> <input class="required" type="text" name="bikeSize1" id="bikeSize1" size="5" maxlength="250" /> x <input class="required" type="text" name="bikeSize2" id="bikeSize2" size="5" maxlength="250" /> x <input class="required" type="text" name="bikeSize3" id="bikeSize3" size="5" maxlength="250" /> </td> </tr> <tr> <td width="100" align="right" class="key">Location:</td> <td><?php HTML_cbodb::dropdownFromArray("location", CbodbItem::$itemLocationArray, 0); ?> </td> </tr> <tr> <td width="100" align="right" class="key">Style:</td> <td><?php HTML_cbodb::dropdownFromArray("bikeStyle", CbodbItem::$itemBikeStyleArray, 0); ?> </td> </tr> <tr> <td width="100" align="right" class="key">Drivetrain:</td> <td><?php HTML_cbodb::dropdownFromArray("bikeDrivetrain", CbodbItem::$itemBikeDrivetrainArray, 0); ?> </td> </tr> <tr> <td width="100" align="right" class="key">Frame style:</td> <td><?php HTML_cbodb::dropdownFromArray("bikeFrameStyle", CbodbItem::$itemBikeFrameStyleArray, 0); ?> </td> </tr> <tr> <td width="100" align="right" class="key">Tire Style:</td> <td><?php HTML_cbodb::dropdownFromArray("bikeTireStyle", CbodbItem::$itemBikeTireStyleArray, 0); ?> </td> </tr> <tr> <td width="100" align="right" class="key">Commission:</td> <td><?php HTML_cbodb::dropdownFromArray("commissionUserID", $commissionMechanics, 0); ?> </td> </tr> </table> <br /> <input type="submit" name="membersubmit" value="Save and Finish"> <input type="hidden" name="memberID" value="<?php echo $memberID; ?> "> <input type="hidden" name="option" value="<?php echo $option; ?> " /> <input type="hidden" name="task" value="savenewbicycle" /> <input type="hidden" name="isBike" value="on" /> </form> <?php }