Beispiel #1
0
    function showMyDetails($formfields, $errormessage = null, $fielddata = array())
    {
        global $mainframe;
        $line = __LINE__;
        $script = '<script language="javascript" type="text/javascript" src="components/com_caddy/js/datetimepicker.js"></script>';
        $mainframe->addCustomHeadTag($script);
        $mainframe->addCustomHeadTag("<script type='text/javascript' src='components/com_caddy/js/ajax.js'></script>");
        $document =& JFactory::getDocument();
        $document->addStyleSheet(JURI::root(true) . '/components/com_caddy/css/simplecaddy.css');
        ?>
		
		<form name="frmdetails" method="post">
		<table width="100%" border="0">
		<?php 
        if ($errormessage) {
            echo "<tr><td colspan='2'><div class='errormsg'>{$errormessage}</div></td></tr>";
        }
        $cfg = new sc_configuration();
        if ($cfg->get("shippingenabled")) {
            //shipping check for zone selected
            $shipregion = fshipping::shipregion();
            if ($shipregion == null) {
                $mainframe->redirect('index.php?option=com_caddy&action=checkout&error=Select%20A%20Ship%20Region');
            }
        }
        $n = count($formfields);
        $first = true;
        foreach ($formfields as $field) {
            switch ($field->type) {
                case "divider":
                    // simple line with text, no fields
                    echo "<tr class='{$field->classname}'><td colspan='2'>{$field->caption}";
                    break;
                case "text":
                    // textbox field, single line
                    echo "<tr><td>{$field->caption}</td><td>";
                    echo "<input type='text' name='{$field->name}' size='{$field->length}' class='{$field->classname}' value='" . @$fielddata["{$field->name}"] . "'>";
                    break;
                case "textarea":
                    // multiline textbox/textarea, no wysiwyg editor
                    echo "<tr><td>{$field->caption}</td><td>";
                    @(list($cols, $rows) = explode(",", $field->length));
                    echo "<textarea name='{$field->name}' class='{$field->classname}' cols='{$cols}' rows='{$rows}'>" . @$fielddata["{$field->name}"] . "</textarea>";
                    break;
                case "radio":
                    // yes/no radio buttons
                    echo "<tr><td>{$field->caption}</td><td>";
                    echo "<input type='radio' name='{$field->name}' class='{$field->classname}' value='yes' " . (@$fielddata["{$field->name}"] == "yes" ? "checked" : "") . ">" . JText::_('Yes');
                    echo "<input type='radio' name='{$field->name}' class='{$field->classname}' value='no' " . (@$fielddata["{$field->name}"] == "no" ? "checked" : "") . ">" . JText::_('No');
                    break;
                case "checkbox":
                    // single checkbox
                    echo "<tr><td>{$field->caption}</td><td>";
                    echo "<input type='checkbox' name='{$field->name}' class='{$field->classname}' value='yes' " . (@$fielddata["{$field->name}"] == "yes" ? "checked" : "") . ">" . JText::_('Yes');
                    break;
                case "date":
                    // textfield with calendar javascript
                    echo "<tr><td>{$field->caption}</td><td>";
                    echo "<input type='text' name='{$field->name}' id='{$field->name}' size='{$field->length}' class='{$field->classname}' value='" . @$fielddata["{$field->name}"] . "'>";
                    echo "&nbsp;<a href=\"javascript:NewCal('{$field->name}','ddMMyyyy',true ,24)\"><img src=\"components/com_caddy/images/cal.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"" . JText::_("SC_PICK_DATE") . "\"/></a>";
                    break;
                case "dropdown":
                    // dropdown list, single selection
                    echo "<tr><td>{$field->caption}</td><td>";
                    echo "<select name='{$field->name}' id='{$field->name}' class='{$field->classname}'>";
                    $aoptions = explode(";", $field->fieldcontents);
                    foreach ($aoptions as $key => $value) {
                        echo "<option value='{$value}'" . (@$fielddata["{$field->name}"] == "{$value}" ? " selected" : "") . ">{$value}</option>";
                    }
                    echo "</select>";
                    break;
            }
            echo $field->required ? "<span class='reqfield'>" . JText::_('SC_REQUIRED') . "</span>" : "";
            echo "";
            echo "</td>";
            if ($first) {
                echo "<td rowspan='{$n}'><div class='checkoutright'>&nbsp;</div></td>";
                $first = false;
            }
            echo "</tr>";
        }
        ?>

		<tr>
		<td>&nbsp;
		</td>
		<td>
		<input class="button" type="submit" name="submit" value="<?php 
        echo JText::_('SC_CONFIRM');
        ?>
" />
		</td>
		<td>&nbsp;
		</td>
		</tr>

		</table>
		<input type="hidden" name="ipaddress" value="<?php 
        echo $_SERVER['REMOTE_ADDR'];
        ?>
" />
		<input type="hidden" name="option" value="com_caddy" />
		<input type="hidden" name="action" value="allconfirm" />
		<input type="hidden" name="shipRegion" value="<?php 
        echo JRequest::getVar('shipRegion');
        ?>
" />
		
		</form>
	<?php 
        if (defined("debug")) {
            echo $line;
        }
    }
 function countPoints()
 {
     $cart2 = new cart2();
     $cart = $cart2->readCart();
     return fshipping::getTotalPointsFromCart($cart);
 }
Beispiel #3
0
     break;
 case "refresh":
     $v = new vouchers();
     $v->getvoucherinfo();
     $mainframe->redirect("index.php?option=com_caddy&action=checkout");
     break;
 case "allconfirm":
     $errors = checkerrors();
     $cfg = new sc_configuration();
     if ($errors == 0) {
         $cart = new cart2();
         $mycart = $cart->readCart();
         $ship['enabled'] = $cfg->get('shippingenabled');
         if ($ship['enabled']) {
             $ship['region'] = JRequest::getVar('shipRegion');
             $ship['cost'] = fshipping::calculateShipCost(fshipping::getTotalPointsFromCart($mycart), $ship['region']);
         }
         // store the order first
         $order = new orders();
         $orderid = $order->store_new_order($mycart, $ship);
         $usePayPal = $cfg->get("usepaypal");
         if ($usePayPal == 1) {
             $gateway = $cfg->get("pgclassname");
             if ($gateway != "") {
                 // check the gateway filename
                 if (!class_exists($gateway)) {
                     $pgpath = dirname($mainframe->getPath('class'));
                     $pgfile = $pgpath . DS . $gateway . ".class.php";
                     // filename should look like "scpaypal.class.php"
                     if (!file_exists($pgfile)) {
                         echo "The classname you provided in the configuration does not correspond to a known file ({$pgfile})";