function customerFields($data, $badFields)
{
    global $states;
    global $COUNTRIES;
    if (userLoggedIn() && array_key_exists("CID", $data) && $data["CID"] != "") {
        tableRow(array(tableData(prompt("<b>CID:</b>"), "right", "top"), tableData(prompt($data["CID"]), "left", "top")));
        prepDatePicker();
        tableRow(array(tableData(prompt("<b>Met Date:</b>"), "right", "top"), tableData(text($data, "metDate", "", "", "datepicker"), "left", "middle")));
    }
    tableRow(array(tableData(prompt("<b>First name*:</b>", in_array("fname", $badFields)), "right"), tableData(text($data, "fname"), "left", "middle"), tableData(prompt("<b>Last name*:</b>", in_array("lname", $badFields)), "right"), tableData(text($data, "lname"), "left", "middle")));
    tableRow(array(tableData(prompt("<b>Email*:</b>", in_array("email", $badFields)), "right"), tableData(text($data, "email"), "left", "middle"), tableData(prompt("<b>Phone Number:</b>", in_array("phoneNum", $badFields)), "right"), tableData(text($data, "phoneNum"), "left", "middle")));
    tableRow(array(tableData(prompt("<b>Title:</b>", in_array("title", $badFields)), "right"), tableData(radioButton($data, "title", "Mr.", false, "Mr."), "center", "middle"), tableData(radioButton($data, "title", "Ms.", false, "Ms."), "center", "middle"), tableData(radioButton($data, "title", "Mrs.", false, "Mrs."), "center", "middle"), tableData(radioButton($data, "title", "Dr.", false, "Dr."), "center", "middle")));
    if (!userLoggedIn()) {
        if ($data["charity"] == true) {
            tableRow(array(tableData(prompt("Tell us about your situtation, your team and why you need a ChapR. The more information the better!"), "middle", "top", 6)));
        } else {
            tableRow(array(tableData(prompt("Write anything else you would like us to know about you below: <br> team info (type, name, number), how you heard about us (where, from who?) etc."), "middle", "top", 6)));
        }
    }
    tableRow(array(tableData(prompt("<b>Comments:</b>", in_array("customerCNotes", $badFields), ""), "right", "top"), tableData(textArea($data, "customerCNotes", 3), "center", "", 5)));
    tableRow(array(tableData(prompt("<b>Street1*:</b>", in_array("street1", $badFields)), "right"), tableData(text($data, "street1"), "left", "middle", 3)));
    tableRow(array(tableData(prompt("<b>Street2:</b>", in_array("street2", $badFields)), "right"), tableData(text($data, "street2"), "left", "middle", 3)));
    $stateDirections = 'only applicable for domestic teams';
    tableRow(array(tableData(prompt("<b>City*:</b>", in_array("city", $badFields)), "right"), tableData(text($data, "city"), "left", "middle"), tableData(prompt("<b>State*:</b>", in_array("state", $badFields), "", $stateDirections), "right"), tableData(dropDown($data, "state", $states, "--------Choose Your State-------"), "left", "middle")));
    tableRow(array(tableData(prompt("<b>Zip*:</b>", in_array("zip", $badFields)), "right"), tableData(text($data, "zip"), "left", "middle"), tableData(prompt("<b>Country:</b>", in_array("country", $badFields)), "right"), tableData(dropDown($data, "country", $COUNTRIES), "left", "middle")));
    if (userLoggedIn()) {
        tableRow(array(tableData(prompt("<b>Admin Comments:</b>", in_array("adminCNotes", $badFields), "", $commentDirections), "right", "top"), tableData(textArea($data, "adminCNotes", 3), "center", "", 5)));
    }
    tableRow(array(tableData(hiddenField("CID", $data["CID"])), tableData(hiddenField("OID", $data["OID"]))));
}
function shippingFields($data, $badFields)
{
    tableRow(array(tableData(prompt("<b>OID*: </b>"), "right"), tableData(prompt($data["OID"]), "left")));
    $carriers = array("UPS" => "1 - UPS", "FedEx" => "2 - FedEx", "US Postal" => "3 - US Postal", "Other" => "4 - Other");
    tableRow(array(tableData(prompt("<b>Carrier*:</b>", in_array("carrier", $badFields)), "right"), tableData(dropDown($data, "carrier", $carriers, "--------Choose The Carrier-------"), "left", "middle")));
    tableRow(array(tableData(prompt("<b>Shipping Info (Tracking Num)*:</b>", in_array("trackingNum", $badFields)), "right"), tableData(text($data, "trackingNum"), "left", "middle")));
    tableRow(array(tableData(prompt("<b>Shipped Date*:</b>", in_array("shippedDate", $badFields)), "right"), tableData(text($data, "shippedDate", date("m/d/Y"), "", "datepicker"), "left", "middle")));
    tableRow(array(tableData(prompt("<b>Admin Order Notes:</b>", in_array("adminONotes", $badFields)), "right"), tableData(textArea($data, "adminONotes", 5), "left", "", 5)));
    hiddenField("OID", $data["OID"]);
}
function packageFields($data, $badFields)
{
    print_r("data");
    print_r($data);
    tableRow(array(tableData(prompt("<b>Package Name:</b>", in_array("packname", $badFields)), "right"), tableData(text($data, "packname", "", "30"), "left", "middle"), tableData(prompt("<b>Package Price:</b>", in_array("packprice", $badFields)), "right"), tableData(text($data, "packprice", "", "10"), "left", "middle"), tableData(prompt("<b>Active?</b>", in_array("active", $badFields)), "right"), tableData(checkBox($data, "active", "false", "YES"), "left", "middle", 3)));
    $pieces = $data["pieces"];
    // the list of all the pieces included in the package (as pulled from the pvp table)
    $i = 1;
    foreach ($pieces as $piece) {
        $pieceInfo = dbGetPiece($piece["PID"]);
        // get the info for the piece with that PID
        $pieceInfo["PID{$i}"] = $pieceInfo["PID"];
        $piecesOptions = dbGetPiecesNames();
        print_r("piecesOptions");
        print_r($piecesOptions);
        tableRow(array(tableData(prompt("<b>Piece{$i}:</b>", in_array("piece{$i}", $badFields)), "right"), tableData(dropDown($pieceInfo, "PID{$i}", $piecesOptions))));
        $i++;
    }
    hiddenField("PKID", $data["PKID"]);
    print "\n\n";
}
Example #4
0
	$default = "tax_per_line_item";

	$escaped = htmlsafe($defaults[tax_per_line_item]);
	$value = <<<EOD
<input type="text" size="25" name="value" value="$escaped">
EOD;
	$description = "{$LANG['number_of_taxes_per_line_item']}";

}
else if ($_GET['submit'] == "inventory") {

	$array = array(0 => $LANG['disabled'], 1=>$LANG['enabled']);
	$default = "inventory";
	$description = $LANG['inventory'];
	$value = dropDown($array, $defaults[$default]);
}
else {
	$description = "{$LANG['no_defaults']}";
}


/*$smarty->assign('pageActive', $pageActive);
$smarty->assign('files', $files);
$smarty->assign('customFieldLabel', $customFieldLabel);
$smarty->assign('save', $save);
$smarty->assign('lang', $lang);
$smarty->assign('billers',$billers);*/
$smarty->assign('defaults', $defaults);
$smarty->assign('value',$value);
$smarty->assign('description',$description);
function orderFields($data, $badFields)
{
    global $SETTINGS;
    // display data not supposed to be visible for customers
    if (userLoggedIn()) {
        if (array_key_exists("OID", $data) && $data["OID"] != "") {
            tableRow(array(tableData(prompt("<b>OID: </b>"), "right", "top"), tableData(prompt($data["OID"]), "left", "top")));
        }
        tableRow(array(tableData(prompt("<b>Expedite:</b>"), "right", "top"), tableData(checkBox($data, "isExpedited", "true", "YES"), "left", "middle", 3)));
        prepDatePicker();
        tableRow(array(tableData(prompt("<b>Ordered Date:</b>"), "right", "top"), tableData(text($data, "orderedDate", "", "", "datepicker"), "left", "middle")));
    }
    // show the order amount change fields if the user has permission (and in WordPress)
    if (inWordPress() && current_user_can("can_change_amounts")) {
        tableRow(array(tableData(prompt("<b>Shipping Fee:</b>", in_array("shippingFee", $badFields)), "right"), tableData(text($data, "shippingFee", null, "10"), "left"), tableData(prompt("<b>Expedite Fee:</b>", in_array("expediteFee", $badFields)), "right"), tableData(text($data, "expediteFee", null, "10"), "left"), tableData(prompt("<b>Discount:</b>", in_array("discount", $badFields)), "right"), tableData(text($data, "discount", null, "10"), "left")));
    }
    // figure out how many rows to display initially ($i is set to that value)
    for ($i = $SETTINGS["MaxItems"]; $i > 1; $i--) {
        if (array_key_exists("packages{$i}", $data) && $data["packages{$i}"] != "" && $data["packages{$i}"] != 0 || array_key_exists("personality{$i}", $data) && $data["personality{$i}"] != "" && $data["personality{$i}"] != 0 || array_key_exists("quantity{$i}", $data) && $data["quantity{$i}"] != "" && $data["quantity{$i}"] != 0) {
            break;
        }
    }
    $initialRows = $i;
    // get currently available packages (from database) for display
    $rows = dbGetPackages();
    $displayPackages = array();
    foreach ($rows as $row) {
        if ($row["Active"]) {
            $displayPackages[$row["PackageName"]] = $row["PKID"];
        }
    }
    // get currently available personalities (from database) for display
    $rows = dbGetPersonalities();
    $displayPersonalities = array();
    foreach ($rows as $row) {
        if ($row["Active"]) {
            $displayPersonalities[$row["PieceName"]] = $row["PID"];
        }
    }
    if (!userLoggedIn()) {
        tableRow(array(tableData(prompt("Note: \"personality\" refers to the type of software or platform the firmware is compatible with.\n<br> It can be changed later using a USB stick, but we might as well set it for you."), "middle", "top", 6)));
    }
    for ($i = 1; $i <= $SETTINGS["MaxItems"]; $i++) {
        // note that the "table-row" setting for display is controversial and may
        // not work well in Microsoft IE
        // note, too, that the reason while rows 2 through 5 don't initially display
        // is that they are set as display = 'none' in the style sheet - if that
        // is turned off, then they will display right away
        $magicClick = "";
        if ($i != $SETTINGS["MaxItems"]) {
            $magicClick = "<button id=\"prodrowclick-";
            $magicClick .= $i;
            $magicClick .= "\"";
            if ($i != $initialRows) {
                $magicClick .= " style=\"visibility:hidden;\"";
            }
            $magicClick .= " type=\"button\" onclick=\"";
            $magicClick .= "document.getElementById('prodrow-";
            $magicClick .= $i + 1;
            // sets the next row to visible
            $magicClick .= "').style.display = 'table-row';";
            if ($i < $SETTINGS["MaxItems"] - 1) {
                $magicClick .= "document.getElementById('prodrowclick-";
                $magicClick .= $i + 1;
                // sets the next button to visible
                $magicClick .= "').style.visibility = 'visible';";
            }
            $magicClick .= "document.getElementById('prodrowclick-";
            $magicClick .= $i;
            // sets its own button to hidden
            $magicClick .= "').style.visibility = 'hidden';";
            $magicClick .= "\">+</button>";
        }
        if (userLoggedIn() && array_key_exists("iid{$i}", $data) && $data["IID"] != "") {
            tableRow(array(tableData(prompt("<b>IID{$i}:</b>"), "right", "top"), tableData(prompt($data["iid{$i}"]), "left", "top")));
        }
        tableRow(array(tableData(prompt("<b>Product*:</b>", in_array("product{$i}", $badFields)), "right"), tableData(dropDown($data, "packages{$i}", $displayPackages, "----------Select Product----------")), tableData(prompt("<b>Personality:</b>", in_array("personality{$i}", $badFields)), "right"), tableData(dropDown($data, "personality{$i}", $displayPersonalities, " ")), tableData(prompt("<b>Quantity*:</b>", in_array("quantity{$i}", $badFields)), "right"), tableData(text($data, "quantity{$i}", "", "2"), "left"), tableData($magicClick)), "prodrow-" . $i, $i <= $initialRows);
        hiddenField("iid{$i}", $data["iid{$i}"]);
    }
    if (!userLoggedIn()) {
        tableRow(array(tableData(prompt("Write anything you would like us to know about the order: <br> a deadline you need to meet, some option you want that isn't offered etc."), "middle", "top", 6)));
    }
    tableRow(array(tableData(prompt("<b>Order Notes:</b>"), "right", "top"), tableData(textArea($data, "customerONotes", 5), "left", "", 5)));
    if (userLoggedIn()) {
        tableRow(array(tableData(prompt("<b>Admin Order Notes:</b>"), "right", "top"), tableData(textArea($data, "adminONotes", 5), "left", "", 5)));
    }
    hiddenField("charity", $data["charity"]);
    hiddenField("OID", $data["OID"]);
}
function dropDown($array, $alter = "")
{
    $id = mt_rand();
    $output = '<select name=' . $id . ' id=' . $id;
    if ($alter != '') {
        $output .= ' onchange="getDropdown(\'' . $alter . '\',\'request=' . $alter . '&arg=\' + $(\'#' . $id . '\').val())"';
    }
    if (empty($array)) {
        $output .= ' disabled';
    }
    $output .= '>';
    $output .= '<option value="" style="display:none;"></option>';
    foreach ($array as $element) {
        $output .= '<option value="' . $element . '">';
        $output .= $element;
        $output .= '</option>';
    }
    $output .= '</select>';
    return $output;
}
if (!isset($_GET['array'])) {
    die('Array not set');
}
$array = unserialize($_GET['array']);
if (!isset($_GET['alter'])) {
    $alter = "";
} else {
    $alter = $_GET['alter'];
}
$result = dropDown($array, $alter);
echo $result;
function displayForm($data, $badFields)
{
    displayTitle();
    echo "<p style=\"text-align:center;margin:auto;width:80%\">";
    echo '<b>About SprocketR: </b>SprocketR is a web application to produce custom sprocket pairs based upon the parameters entered. The final output is a zip file of two 3D-printable STL files to download and test. During the process, the application will optimize the sprockets to create an appropriate amount of chain slack. In addition, it will give you the opportunity to change and balance your parameters to get the best sprockets for your application.</p>';
    echo '<table style="text-align:center;margin:auto;width:20%"><tr><td style="text-align:left;border:none">';
    echo '<a href="?page_id=2065"><button class="sprocketrButton">How It Was Created</button></a>';
    echo '</td><td style="text-align:right;border:none">';
    echo '<a href="?page_id=2090"><button class="sprocketrButton">How To Use</button></a>';
    echo '</td></tr></table>';
    echo '<div style="margin:auto;width:35%"><b>Instructions: </b>';
    echo '<ul><li>Start by entering the desired "gear ratio" (if necessary) and the center-to-center distance of the two sprockets.</li>';
    echo '<li>You may also enter the number of the teeth for one or both of the sprockets if needed.</li>';
    echo '<li>Choose the chain type desired.</li>';
    echo '<li>Choose the hub mounting holes for the sprockets (if any).</li>';
    echo '<li>Click "Generate Sprocket Options".</li>';
    echo '<li>The results page will provide the opportunity to change parameters to get the sprockets to best fit your application.</li>';
    echo '</ul></div>';
    echo "<p style=\"text-align:center;margin:auto;width:80%\">";
    //start form and table
    echo "<form action=\"\" class=\"sprocketrForm\" method=\"get\">\n     <table frame=\"void\" border=\"none\" class=\"form\" style=\"width:50%\" align=\"center\">\n     ";
    //add class="form" when ready to remove gridlines
    //gearRatioField
    if (array_key_exists("gearRatioField", $data)) {
        //check if gear ratio entered if so show in field
        tableRow(array(tableData(promptWithError("gearRatioField", "<b>Gear Ratio*: </b>", $badFields, "Must be in the form of #:#"), "left", "center"), tableData('<input
                               style="text-align: center;"
                               size="5"
                               type="text"
                               placeholder="#:#"
                               name="gearRatioField"
                               value="' . $data["gearRatioField"] . '"
                               title="Gear ratio of your sprockets, must be formatted like #:#"
                             />
                          ', "left", "center")));
        //gear ratio field
    } else {
        //if not entered show without data (see above comments, they still apply below)
        tableRow(array(tableData(promptWithError("gearRatioField", "<b>Gear Ratio*: </b>", $badFields, "Must be in the form of #:#"), "left", "center"), tableDataWidth('<input
                               style="text-align: center;"
                               size="5"
                               type="text"
                               placeholder="#:#"
                               name="gearRatioField"
                               title="Gear ratio of your sprockets, must be formatted like #:#"
                                                             />
                          ', "left", "center", 1, "gRatFieldRow")));
    }
    //centerToCenterField
    tableRow(array(tableData(promptWithError("centerToCenterField", "<b>Center to Center Distance (mm)*:</b>", $badFields, "Must be a number with optional decimal part"), "left", "center", 1), tableData(text($data, "centerToCenterField"), "left", "center", 2)));
    //chainSizeList
    tableRow(array(tableData(prompt("<b>Chain Size*: </b>"), "", "", "", "margin:0px"), tableData(dropDown($data, "chainSizeList", array("25" => "chain25", "35" => "chain35")))), "chainSize");
    //leftSprocketTeeth#Field
    tableRow(array(tableData(promptWithError("leftSprocketTeeth#Field", '<b>Number of Teeth on Sprocket 1: </b><span style="color:red"> (optional)</span>', $badFields, "Must be an integer less than " . NUM_TEETH_MAX . " or left blank"), "left", "center", 1), tableData(text($data, "leftSprocketTeeth#Field"), "left", "center", 1)), "leftSprocketTeeth");
    //rightSprocketTeeth#Field
    tableRow(array(tableData(promptWithError("rightSprocketTeeth#Field", '<b>Number of Teeth on Sprocket 2: </b><span style="color:red"> (optional)</span>', $badFields, "Must be an integer less than " . NUM_TEETH_MAX . " divisible by the gear ratio or left blank"), "left", "center", 1), tableData(text($data, "rightSprocketTeeth#Field"), "left", "center", 1)), "rightSprocketTeeth");
    //desiredSlackField
    tableRow(array(tableData(promptWithError("desiredSlackField", "<b>Desired Slack (default 1%): </b>", $badFields, "Must be a decimal or left blank")), tableData(text($data, "desiredSlackField"))), "desiredSlack");
    //holeOptionLabels
    echo "<tr><td class = \"form\"><b>Hub Choices:</b></td><td>";
    echo '<table><tr>';
    holeCheckBox("Versa Hub (small).png", $data, "holeOption_versaHub", " Versa Hub");
    holeCheckBox("Tetrix Hub (small).png", $data, "holeOption_tetrixHub", " Tetrix Hub");
    holeCheckBox("Versa Bearing Hole (small).png", $data, "holeOption_versaBearingHole", " Versa Bearing Hole");
    echo '</tr></table></td></tr>';
    // submit button & hidden field
    tableRow(array(tableData(hiddenField("page_id", $_GET["page_id"]))));
    echo '<tr><td class="centerCell" colspan=2 align="center">' . "<input type=\"submit\" class=\"sprocketrButton\" value=\"Generate Sprocket Options\">" . '</td></tr>';
    formFooter("sprocketrForm");
}