$val->validate_input();
 $val->error_match = $error_match_pass;
 $val->name = "pass1";
 $val->match1 = $_POST['pass1'];
 $val->match2 = $_POST['pass2'];
 $val->validate_input();
 if (!$val->validated) {
     $error = "<p class='Error'>" . $errors_in_form . "</p>";
     //check if username already exists
 } elseif ($GO_USERS->get_profile_by_username($_POST['username'])) {
     $error = "<p class='Error'>" . $error_username_exists . "</p>";
     //check if email is already registered
 } elseif ($GO_USERS->email_exists($_POST['email'])) {
     $error = "<p class='Error'>" . $error_email_exists . "</p>";
 } else {
     $birthday = date_to_db_date($_POST['birthday']);
     $email = $_POST['email'] == '' ? $_POST['username'] . '@' . $GO_CONFIG->inmail_host : $_POST['email'];
     //register the new user. function returns new user_id or -1 on failure.
     if ($new_user_id = $GO_USERS->add_user($username, $pass1, $first_name, $middle_name, $last_name, $initials, $title, $_POST['sex'], $birthday, $email, $work_phone, $home_phone, $fax, $cellular, $country, $state, $city, $zip, $address, $company, $work_country, $work_state, $work_city, $work_zip, $work_address, $work_fax, $homepage, $department, $function, $_POST['language'], $_POST['theme'], '', isset($_POST['visible']))) {
         if (isset($_POST['create_email'])) {
             require_once $GO_CONFIG->class_path . "email.class.inc";
             $email_client = new email();
             $middle_name = $middle_name == '' ? '' : $middle_name . ' ';
             $name = $last_name . ' ' . $middle_name . $first_name;
             require $GO_LANGUAGE->get_language_file('email');
             if (!($account_id = $email_client->add_account($new_user_id, $GO_CONFIG->inmail_type, $GO_CONFIG->local_email_host, $GO_CONFIG->inmail_port, $GO_CONFIG->inmail_root, $username, $pass1, $name, $username . "@" . $GO_CONFIG->inmail_host, "", $ml_sent_items, $ml_spam, $ml_trash))) {
                 echo "<p class=\"Error\">" . $registration_email_error . "</p>";
                 echo "<p class=\"Error\">" . $email_client->last_error . "</p>";
             }
         }
         //send email to the user with password
 $shortname = trim(smart_addslashes($_POST['shortname']));
 $engname = trim(smart_addslashes($_POST['engname']));
 $relation_date = smart_addslashes($_POST["relation_date"]);
 $address = smart_addslashes($_POST["address"]);
 $zip = smart_addslashes($_POST["zip"]);
 $city = smart_addslashes($_POST["city"]);
 $state = smart_addslashes($_POST["state"]);
 $country = smart_addslashes($_POST["country"]);
 $email = smart_addslashes($_POST["email"]);
 $phone = smart_addslashes($_POST["phone"]);
 $fax = smart_addslashes($_POST["fax"]);
 $homepage = smart_addslashes($_POST["homepage"]);
 $bank_no = smart_addslashes($_POST["bank_no"]);
 $vat_no = smart_addslashes($_POST["vat_no"]);
 $parent_id = $_POST['parent_id'];
 $relation_date = date_to_db_date($_POST['relation_date']);
 if ($name == '') {
     $feedback = "<p class=\"Error\">" . $error_missing_field . "</p>";
 } else {
     if ($_POST['company_id'] > 0) {
         $seen = array();
         $seen[$_POST['company_id']] = 1;
         $parent = $parent_id;
         while ($parent != 0 && !isset($seen[$parent])) {
             $seen[$parent] = 1;
             $sql = "SELECT parent FROM ab_companies WHERE id='{$parent}'";
             if ($ab->query($sql) && $ab->next_record()) {
                 $parent = $ab->f('parent');
             }
         }
         if ($parent != 0) {
 function get_result($fld, $value, $from, $to)
 {
     $from = date_to_db_date($from);
     $to = date_to_db_date($to);
     if ($fld == 'product_name') {
         $fld = 'od.product_id';
     } else {
         $fld = "o.{$fld}";
     }
     $sql = "SELECT sum(od.quantity * od.price) as rs\r\n\t\t\t\t\tFROM sc_orders o\r\n\t\t\t\t\tLEFT JOIN sc_order_detail od ON o.order_number = od.order_number\r\n\t\t\t\t\tWHERE {$fld} = '{$value}'\r\n\t\t\t\t\t\tAND sale_date >= '{$from}'\r\n\t\t\t\t\t\tAND sale_date <= '{$to}'";
     if (!$this->query($sql)) {
         return false;
     }
     return true;
 }
         if ($pro->add_order($seller, $order_number, $company, $attn, $cc, $subject, $phone, $fax, $sale_date, $valid_date, $adjustment, $product, $cate, $attach, $quantity, $price, $VAT, $incdec)) {
             $_SESSION['cart']->cleanall();
             break;
         }
         $_POST['close_win'] == 'f';
     }
     break;
 case 'delete_cart':
     $seller = $_POST['seller'];
     $order_number = $_POST['order_number'];
     $company = $_POST['company'];
     $attn = $_POST['attn'];
     $phone = $_POST['phone'];
     $fax = $_POST['fax'];
     $sale_date = date_to_db_date($_POST['sale_date']);
     $valid_date = date_to_db_date($_POST['valid_date']);
     $_SESSION['cart']->remove($_POST['txt_id']);
 case 'new':
     if ($_SESSION['cart']->itemcount() == 0) {
         goURL('index.php');
     }
     $pitems = $_SESSION['cart']->items;
     $pro->get_buy_products($_SESSION['cart']->get_productid_list());
     require 'templates/edit_order.tmp.php';
     break;
 case 'delete_detail':
     if ($pro->delete_product_from_order($_POST['order_number'], $_POST['txt_id'])) {
         $pro->get_orders();
         require 'templates/list_order.tmp.php';
         break;
     }