case "remove": $tmp = new products(); $tmp->removeProducts($cid); $mainframe->redirect("index.php?option=com_caddy&action=products&task=show&field={$field}&order={$order}&search={$search}", JText::_('SC_PRODUCTDELETED')); break; case "publish": case "unpublish": $a = new products(); $a->publishproduct($cid, $task == 'publish'); $mainframe->redirect("index.php?option=com_caddy&action=products&task=show&field={$field}&order={$order}&search={$search}"); break; case "addoptgroup": print_r($_REQUEST); $prodid = JRequest::getVar("id"); $prodcode = JRequest::getVar("prodcode"); $og = new optiongroups(); $og->addgroup($prodcode); $mainframe->redirect("index.php?option=com_caddy&action=products&task=edit&cid[0]={$prodid}"); break; case "show": default: JRequest::setvar('task', "products"); $a = new products(); $alist = $a->getAllProducts($search, $field, $order); display::ShowProducts($alist, $field, $order); break; } break; case "fields": $search = JRequest::getVar("search"); $field = JRequest::getVar("field");
function showindoptions(&$rows, $optgrid, $productid) { // shows individual options $og = new optiongroups(); $og->load($optgrid); ?> <form name="frmindoptions" method="post" action="index.php"> <table border="1" class="adminform" width="100%"><tr><th colspan="2"><?php echo JText::_('SC_OPTIONS'); ?> </th></tr> <tr> <td width="185"><?php echo stripslashes(JText::_('SC_OPTIONS_TITLE')); ?> </td> <td> <?php echo $og->title; ?> </td> </tr> <tr> <td> </td> <td align="right"><input type="submit" name="submit" value="<?php echo JText::_('SC_SAVE'); ?> " /></td> </tr> <tr> <td><?php echo stripslashes(JText::_('SC_IND_OPTIONS')); ?> </td> <td> <input type="button" name="addbtn" onclick="addRow()" value="<?php echo JText::_('Add Option'); ?> " /> <input type="button" name="delbtn" onclick="deleteRow()" value="<?php echo JText::_('Remove option'); ?> " /> <table id="mine" border="1" class="adminform"> <tr><th width="20">#</th><th width="40"><?php echo JText::_('Description'); ?> </th><th width="40"><?php echo JText::_('Formula'); ?> </th><th width="40"><?php echo JText::_('Caption'); ?> </th><th width="20"><?php echo JText::_("Display order"); ?> </th><th width="80"><?php echo JText::_('Default select'); ?> </th><th> </th></tr> <?php foreach ($rows as $key => $line) { echo "<tr>"; echo "<td><input type='checkbox' name='tid{$key}' id='tid{$key}' value='{$line->id}'></td>"; echo "<td><input type='hidden' name='optionid[]' value='{$line->id}'><input type='text' size='30' name='optionshorttext[]' value='{$line->description}' ></td>"; echo "<td><input type='text' name='optionformula[]' value='{$line->formula}' ></td>"; echo "<td><input type='text' name='optioncaption[]' value='{$line->caption}' ></td>"; echo "<td><input type='text' name='optiondisporder[]' value='{$line->disporder}' size='1'></td>"; echo "<td><input type='radio' name='optiondefselect' value='{$key}' " . ($line->defselect == "1" ? "checked" : "") . "></td>"; echo "</tr>"; } ?> </table> <input type="hidden" name="rows" value="" id="rows" /> <input type="hidden" name="rows2" value="" id="rows2" /> </td> </tr> </table> <input type="hidden" name="option" value="com_caddy" /> <input type="hidden" name="optgrid" value="<?php echo $optgrid; ?> " /> <input type="hidden" name="productid" value="<?php echo $productid; ?> " /> <input type="hidden" name="action" value="options" /> <input type="hidden" name="task" value="saveoptions" /> <input type="hidden" name="boxchecked" value="0" /> <input type="hidden" name="hidemainmenu" value="0" /> </form> <?php }
function getSCSingle($params, $pluginParams, $debugmode = 0) { global $Itemid, $mainframe; $dis = new dis(); // printf("<pre>%s</pre>", print_r($pluginParams,1)); $classsuffix = isset($params['classsfx']) ? $params['classsfx'] : ""; $prodcode = $params['code']; $defaultqty = isset($params['defqty']) ? $params['defqty'] : 1; // default qty set in qty edit box $minqty = isset($params['minqty']) ? $params['minqty'] : 0; $strqties = isset($params['qties']) ? $params['qties'] : null; $checkoos = isset($params['checkoos']) ? $params['checkoos'] : 0; $picname = isset($params['picname']) ? $params['picname'] : ""; $aqties = explode(",", $strqties); $db =& JFactory::getDBO(); $query = "SELECT * FROM #__sc_products WHERE prodcode='{$prodcode}'"; $db->setQuery($query); $product = $db->loadObject(); if (!$product) { $html = "<div class='sccart{$classsuffix}'>"; $str = JText::sprintf("SC_PRODUCT_NOT_FOUND", $prodcode); $html .= $str; $html .= "</div>"; return $html; } if ($product->published == '0') { $html = "<div class='sccart{$classsuffix}'>"; $str = JText::sprintf("SC_PRODUCT_NOT_PUBLISHED", $prodcode); $html .= $str; $html .= "</div>"; return $html; } if (!$db->query()) { echo "<script> alert('" . $db->getErrorMsg() . "'); window.history.go(-1); </script>\n"; exit; } $prodpresentation = ""; if ($pluginParams->get('showproductcodetext')) { $prodpresentation .= "\n<div class='scproduct{$classsuffix}'>#PRODUCTCODETEXT# {$dis->separator}</div>"; } if ($pluginParams->get('showproductcode')) { $prodpresentation .= "\n<div class='scprodcode{$classsuffix}'>#PRODUCTCODE# {$dis->separator}</div>"; } if ($pluginParams->get('showtitle')) { $prodpresentation .= "\n<div class='scshorttext{$classsuffix}'>#SHORTTEXT# {$dis->separator}</div>"; } if ($pluginParams->get('showunitpricetext')) { $prodpresentation .= "\n<div class='scunitpricetext{$classsuffix}'>#UNITPRICETEXT# {$dis->separator}</div>"; } if ($pluginParams->get('showunitprice')) { $prodpresentation .= "\n<div class='scunitprice{$classsuffix}'>#UNITPRICE# {$dis->separator}</div>"; } if ($pluginParams->get('showquantitytext')) { $prodpresentation .= "\n<div class='scqtytext{$classsuffix}'>#QUANTITYTEXT# {$dis->separator}</div>"; } $prodpresentation .= "\n<div class='scqty{$classsuffix}'>#QUANTITY# {$dis->separator}</div>"; $prodpresentation .= "\n#CARTOPTIONS#"; $prodpresentation .= "\n<div class='atczone{$classsuffix}'>#ADDTOCARTBUTTON#</div>"; $html = "\n<div class='sccart{$classsuffix}'>"; $html .= "\n<form name='addtocart{$product->id}' action='index.php' method='post'>"; $amount = number_format($product->unitprice, $dis->decs, $dis->dsep, $dis->tsep); if ($dis->curralign == 1) { $amount = $dis->currency . " " . $amount; } else { $amount = $amount . " " . $dis->currency; } $html .= $prodpresentation; $productoptions = new productoption(); $optionhtml = "<div class='cartoptions{$classsuffix}'>"; if ($pluginParams->get('showcartoptionstitle')) { $optionhtml .= "\n<div class='cartoptionstitle{$classsuffix}'>#CARTOPTIONSTITLE#</div>"; } $hasoptions = 0; $optgroups = new optiongroups(); $optiongroups = $optgroups->getgroups($product->prodcode); if (count($optiongroups)) { foreach ($optiongroups as $optiongroup) { $groupid = $optiongroup->id; $options = new productoption(); $lstoptions = $options->getbygroup($groupid); $show = "optionshow" . $optiongroup->showas; if ($pluginParams->get('showcartoptionstitle')) { $optionhtml .= "\n<div class='cartoptionstitle{$classsuffix}'>{$optiongroup->title}</div>"; } $optionhtml .= $dis->{$show}($lstoptions, $product, $groupid, $classsuffix, $picname); } } else { // product without options - generate id from productcode $id = md5($product->prodcode . $picname); $optionhtml .= "\n<input type='hidden' value='{$id}' name='edtoption' />"; } $optionhtml .= "</div>"; if ($checkoos == 1) { // check for minimum quantitites/ out of stock if ($product->av_qty >= 1) { // product still available $atcbtn = "\n<input type='submit' name='submit' value='" . JText::_('SC_ADD_TO_CART') . "' class='scp_atc{$classsuffix}' />"; } else { // product quantity is 0 $atcbtn = "\n<input type='submit' name='submit' value='" . JText::_('SC_OUT_OF_STOCK') . "' class='scp_atc{$classsuffix}' disabled='disabled' />"; } } else { $atcbtn = "\n<input type='submit' name='submit' value='" . JText::_('SC_ADD_TO_CART') . "' class='scp_atc{$classsuffix}' />"; } $qtyfield = "\n<input type='" . ($pluginParams->get('showquantity') ? 'text' : 'hidden') . "' name='edtqty' value='{$defaultqty}' class='scp_qty{$classsuffix}' />"; if ($strqties) { // specific quantities given $qtyfield = "<select name='edtqty' class='scp_selectqty{$classsuffix}'>"; foreach ($aqties as $key => $value) { $qtyfield .= "<option value='{$value}'>{$value}</option>"; } $qtyfield .= "</select>"; } $html .= "\n<input type='hidden' name='edtprodcode' value='{$product->prodcode}' />"; $html .= "\n<input type='hidden' name='edtshorttext' value='{$product->shorttext}' />"; $html .= "\n<input type='hidden' name='edtunitprice' value='{$product->unitprice}' />"; $html .= "\n<input type='hidden' name='option' value='com_caddy' />"; $html .= "\n<input type='hidden' name='action' value='addtocart' />"; $html .= "\n<input type='hidden' name='picname' value='{$picname}' />"; $html .= "\n<input type='hidden' name='Itemid' value='{$Itemid}' />"; if ($minqty > 0) { // check for minimum quantity in the component $html .= "\n<input type='hidden' name='minqty' value='{$minqty}' />"; } if ($pluginParams->get('stayonpage') == 1) { $html .= "\n<input type='hidden' name='lasturl' value='" . urlencode($_SERVER['REQUEST_URI']) . "' />"; $html .= "\n<input type='hidden' name='stayonpage' value='1' />"; } $html .= "\n</form>"; $html .= "</div>"; //now replace any variables $html = str_replace("#PRODUCTCODETEXT#", JText::_('SC_PRODUCT'), $html); $html = str_replace("#PRODUCTCODE#", $product->prodcode, $html); $html = str_replace("#SHORTTEXT#", stripslashes($product->shorttext), $html); $html = str_replace("#UNITPRICETEXT#", JText::_('SC_PRICE_PER_UNIT'), $html); $html = str_replace("#UNITPRICE#", $amount, $html); $html = str_replace("#QUANTITY#", $qtyfield, $html); $html = str_replace("#QUANTITYTEXT#", JText::_('SC_QUANTITY'), $html); $html = str_replace("#ADDTOCARTBUTTON#", $atcbtn, $html); $html = str_replace("#CARTOPTIONS#", $optionhtml, $html); if (trim($product->options)) { $html = str_replace("#CARTOPTIONSTITLE#", JText::_('SC_OPTIONS'), $html); } else { $html = str_replace("#CARTOPTIONSTITLE#", "", $html); } return $html; }