Example #1
0
 function _copyDataFromDataBaseToPage(&$smarty, $addressID)
 {
     if (!isset($_SESSION["log"])) {
         Redirect("index.php?page_not_found=yes");
     }
     $address = regGetAddressByLogin($addressID, $_SESSION["log"]);
     if ($address === false) {
         Redirect("index.php?page_not_found=yes");
     } else {
         $smarty->assign("first_name", $address["first_name"]);
         $smarty->assign("last_name", $address["last_name"]);
         $smarty->assign("countryID", (int) $address["countryID"]);
         $smarty->assign("zoneID", (int) $address["zoneID"]);
         $smarty->assign("state", $address["state"]);
         $smarty->assign("city", $address["city"]);
         $smarty->assign("address", $address["address"]);
         $zones = znGetZonesById((int) $address["countryID"]);
         $smarty->assign("zones", $zones);
     }
 }
Example #2
0
 function _copyDataFromPostToPage(&$smarty)
 {
     $smarty->hassign("login", trim($_POST["login"]));
     $smarty->hassign("cust_password1", trim($_POST["cust_password1"]));
     $smarty->hassign("cust_password2", trim($_POST["cust_password2"]));
     $smarty->hassign("first_name", trim($_POST["first_name"]));
     $smarty->hassign("affiliationLogin", trim($_POST["affiliationLogin"]));
     $smarty->hassign("last_name", trim($_POST["last_name"]));
     $smarty->hassign("email", trim($_POST["email"]));
     $smarty->assign("subscribed4news", isset($_POST["subscribed4news"]) ? 1 : 0);
     $zones = znGetZonesById((int) $_POST["countryID"]);
     $smarty->hassign("zones", $zones);
     $additional_field_values = array();
     $data = ScanPostVariableWithId(array("additional_field"));
     foreach ($data as $key => $val) {
         $item = array("reg_field_ID" => $key, "reg_field_name" => "", "reg_field_value" => $val["additional_field"]);
         $additional_field_values[] = $item;
     }
     $smarty->hassign("additional_field_values", $additional_field_values);
     $smarty->assign("countryID", (int) $_POST["countryID"]);
     if (isset($_POST["state"])) {
         $smarty->hassign("state", trim($_POST["state"]));
     }
     if (isset($_POST["zoneID"])) {
         $smarty->assign("zoneID", (int) $_POST["zoneID"]);
     }
     $smarty->hassign("city", trim($_POST["city"]));
     $smarty->hassign("address", trim($_POST["address"]));
     if (isset($_POST["order"]) || isset($_GET["order"])) {
         if (isset($_POST["billing_address_check"])) {
             $smarty->assign("billing_address_check", "1");
         }
         $smarty->hassign("receiver_first_name", trim($_POST["receiver_first_name"]));
         $smarty->hassign("receiver_last_name", trim($_POST["receiver_last_name"]));
         if (!isset($_POST["billing_address_check"])) {
             $smarty->hassign("payer_first_name", trim($_POST["payer_first_name"]));
             $smarty->hassign("payer_last_name", trim($_POST["payer_last_name"]));
             $smarty->assign("billingCountryID", (int) $_POST["billingCountryID"]);
             if (isset($_POST["billingState"])) {
                 $smarty->hassign("billingState", trim($_POST["billingState"]));
             }
             if (isset($_POST["billingZoneId"])) {
                 $smarty->assign("billingZoneId", (int) $_POST["billingZoneId"]);
             }
             $smarty->hassign("billingCity", trim($_POST["billingCity"]));
             $smarty->hassign("billingAddress", trim($_POST["billingAddress"]));
             $billingZones = znGetZonesById((int) $_POST["billingCountryID"]);
             $smarty->assign("billingZones", $billingZones);
         } else {
             $smarty->hassign("payer_first_name", trim($_POST["receiver_first_name"]));
             $smarty->hassign("payer_last_name", trim($_POST["receiver_last_name"]));
             $smarty->assign("billingCountryID", (int) $_POST["countryID"]);
             if (isset($_POST["state"])) {
                 $smarty->hassign("billingState", trim($_POST["state"]));
             }
             if (isset($_POST["zoneId"])) {
                 $smarty->assign("billingZoneId", (int) $_POST["zoneId"]);
             }
             $smarty->hassign("billingCity", trim($_POST["city"]));
             $smarty->hassign("billingAddress", trim($_POST["address"]));
             $smarty->assign("billingZones", $zones);
         }
     }
 }
function settingCONF_BYCOUNTRY_BYZONE_PERCENT_FORM()
{
    $curr_country = isset($_POST["shipping_module_bycountry_byzone_country"]) ? $_POST["shipping_module_bycountry_byzone_country"] : 0;
    $curr_country = (int) $curr_country;
    if (!$curr_country) {
        $curr_country = xGetData('SXshipping_module_bycountry_byzone_countryPERC');
    }
    xSaveData('SXshipping_module_bycountry_byzone_countryPERC', $curr_country);
    $module_id = isset($_GET['setting_up']) ? $_GET['setting_up'] : 0;
    $ModuleConfig = modGetModuleConfig($module_id);
    if (!$ModuleConfig['ModuleClassName']) {
        $module_id = 0;
    }
    if (isset($_POST["save"])) {
        $radiotoggle = isset($_POST["shipping_module_bycountry_byzone_radiotoggle"]) ? $_POST["shipping_module_bycountry_byzone_radiotoggle"] : 0;
        if ($radiotoggle == 0) {
            $rate = (double) $_POST["shipping_module_bycountry_byzone_zone_rate_0"];
            $sql = '
                                DELETE FROM ' . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TABLE . '
                                WHERE module_id="' . $module_id . '" AND countryID=' . $curr_country . ' and zoneID=0
                        ';
            db_query($sql);
            $sql = '
                                INSERT INTO ' . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TABLE . '
                                (module_id, countryID, zoneID, shipping_rate)
                                VALUES (' . $module_id . ', ' . $curr_country . ', 0, ' . $rate . ')
                        ';
            db_query($sql);
        } else {
            $sql = '
                                DELETE FROM ' . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TABLE . '
                                WHERE module_id="' . $module_id . '" AND countryID=' . $curr_country . '
                        ';
            db_query($sql);
            foreach ($_POST as $key => $val) {
                if (strstr($key, "shipping_module_bycountry_byzone_zone_rate_")) {
                    $zone = (int) str_replace("shipping_module_bycountry_byzone_zone_rate_", "", $key);
                    $rate = (double) $val;
                    if ($zone > 0 && $rate != 0) {
                        $sql = '
                                                        INSERT INTO ' . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TABLE . '
                                                        (module_id, countryID, zoneID, shipping_rate)
                                                        VALUES (' . $module_id . ', ' . $curr_country . ', ' . $zone . ', ' . $rate . ')
                                                ';
                        db_query($sql);
                    }
                }
            }
        }
    }
    $res = "<table border=0>\n<tr>\n<td>" . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TXT_1 . "</td>\n";
    $countries_count = 0;
    $countries = cnGetCountries(null, $countries_count);
    $res .= "<td><select name='shipping_module_bycountry_byzone_country'>\n";
    $res .= "<option value='0'>" . ADMIN_NOT_DEFINED . "</option>\n";
    foreach ($countries as $country) {
        $res .= "<option value='" . $country["countryID"] . "' ";
        if ($curr_country == $country["countryID"]) {
            $res .= " selected ";
        }
        $res .= ">";
        $res .= $country["country_name"];
        $res .= "</option>\n";
    }
    $res .= "</select></td>";
    $res .= "<td><input type=submit name=shipping_module_bycountry_byzone_change_country value=\"" . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TXT_2 . "\"></td>\n";
    $res .= "</tr>\n";
    //show toggle + zones
    if ($curr_country > 0) {
        $zones = znGetZonesById($curr_country);
        //toggle
        $res .= "<tr><td colspan=3><hr size=1></td></tr>\n";
        $res .= "<tr><td colspan=3>\n";
        $sql = '
                        SELECT shipping_rate FROM ' . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TABLE . '
                        WHERE module_id="' . $module_id . '" AND countryID=' . $curr_country . ' and zoneID=0
                ';
        $q = db_query($sql);
        $row = db_fetch_row($q);
        if ($row || count($zones) == 0) {
            $radiotoggle = 0;
            //fixed for this country
            $rate = (double) $row[0];
        } else {
            $radiotoggle = 1;
            //by zone definition
            $rate = 0;
        }
        $res .= "<table border=0><tr><td valign=top>\n<input type=radio name=shipping_module_bycountry_byzone_radiotoggle value=0";
        if ($radiotoggle == 0) {
            $res .= " checked";
        }
        $res .= " onclick='JavaScript:shipping_module_bycountry_byzone_toogleClickHandler();'></td>\n";
        $res .= "<td valign=top>" . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TXT_7 . "</td>\n";
        $res .= "<td><input type=text name=shipping_module_bycountry_byzone_zone_rate_0 value=\"{$rate}\">" . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TXT_3 . "</td></tr>\n";
        $res .= "<tr><td valign=top>\n<input type=radio name=shipping_module_bycountry_byzone_radiotoggle value=1";
        if ($radiotoggle == 1) {
            $res .= " checked";
        }
        $res .= " onclick='JavaScript:shipping_module_bycountry_byzone_toogleClickHandler();'></td>\n";
        $res .= "<td colspan=2>" . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TXT_4 . "\n";
        //zones
        if (count($zones) > 0) {
            $res .= "<p><table>\n";
            foreach ($zones as $zone) {
                $zoneID = (int) $zone["zoneID"];
                $sql = '
                                        SELECT shipping_rate FROM ' . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TABLE . '
                                        WHERE module_id="' . $module_id . '" AND countryID=' . $curr_country . ' and zoneID=' . $zoneID . '
                                ';
                $q = db_query($sql);
                $row = db_fetch_row($q);
                $zone_shipping_rate = (double) $row[0];
                $res .= "<tr><td>" . $zone["zone_name"] . ":</td>";
                $res .= "<td><input type=text name=shipping_module_bycountry_byzone_zone_rate_" . $zoneID . " value='" . $zone_shipping_rate . "'>" . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TXT_5 . "</td></tr>";
            }
            $res .= "</table>\n";
        } else {
            $res .= "<p>&lt; " . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TXT_6 . " &gt;";
        }
        $res .= "</td></tr></table>\n";
        $res .= "</td></tr>\n";
    }
    $res .= "</table>";
    //javascript code
    if ($curr_country > 0) {
        $res .= "\n                                <script language='JavaScript'>\n                                function shipping_module_bycountry_byzone_toogleClickHandler()\n                                {\n\n                                        if ( document.shipping_method_form.shipping_module_bycountry_byzone_radiotoggle[0].checked )\n                                        {\n                                                document.shipping_method_form.shipping_module_bycountry_byzone_zone_rate_0.disabled = false;\n                                                " . _create_JS_zones_handlers_bycountryzone_percent($zones, "true") . "\n                                        }\n                                        else if ( document.shipping_method_form.shipping_module_bycountry_byzone_radiotoggle[1].checked )\n                                        {\n                                                document.shipping_method_form.shipping_module_bycountry_byzone_zone_rate_0.disabled = true;\n                                                " . _create_JS_zones_handlers_bycountryzone_percent($zones, "false") . "\n                                        }\n                                }\n\n                                shipping_module_bycountry_byzone_toogleClickHandler();\n                                </script>\n                ";
    }
    return $res;
}