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 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!"); }