Ejemplo n.º 1
0
 /**
  * Create a receipt for the current order and email it to
  * the customer and the vendor.
  * @author gday
  * @author soeren
  * @param int $order_id
  * @return boolean True on success, false on failure
  */
 function email_receipt($order_id)
 {
     global $sess, $ps_product, $VM_LANG, $CURRENCY_DISPLAY, $vmLogger, $mosConfig_fromname, $mosConfig_lang, $database;
     $ps_vendor_id = vmGet($_SESSION, 'ps_vendor_id', 1);
     $auth = $_SESSION["auth"];
     require_once CLASSPATH . 'ps_order_status.php';
     require_once CLASSPATH . 'ps_userfield.php';
     require_once CLASSPATH . 'ps_product.php';
     $ps_product = new ps_product();
     // Connect to database and gather appropriate order information
     $db = new ps_DB();
     $q = "SELECT * FROM #__{vm}_orders WHERE order_id='{$order_id}'";
     $db->query($q);
     $db->next_record();
     $user_id = $db->f("user_id");
     $customer_note = $db->f("customer_note");
     $order_status = ps_order_status::getOrderStatusName($db->f("order_status"));
     $dbbt = new ps_DB();
     $dbst = new ps_DB();
     $qt = "SELECT * FROM #__{vm}_user_info WHERE user_id='" . $user_id . "' AND address_type='BT'";
     $dbbt->query($qt);
     $dbbt->next_record();
     $qt = "SELECT * FROM #__{vm}_user_info WHERE user_info_id='" . $db->f("user_info_id") . "'";
     $dbst->query($qt);
     $dbst->next_record();
     $dbv = new ps_DB();
     $qt = "SELECT * from #__{vm}_vendor ";
     /* Need to decide on vendor_id <=> order relationship */
     $qt .= "WHERE vendor_id = '" . $ps_vendor_id . "'";
     $dbv->query($qt);
     $dbv->next_record();
     $dboi = new ps_DB();
     $q_oi = "SELECT * FROM #__{vm}_product, #__{vm}_order_item, #__{vm}_orders ";
     $q_oi .= "WHERE #__{vm}_product.product_id=#__{vm}_order_item.product_id ";
     $q_oi .= "AND #__{vm}_order_item.order_id='{$order_id}' ";
     $q_oi .= "AND #__{vm}_orders.order_id=#__{vm}_order_item.order_id";
     $dboi->query($q_oi);
     $db_payment = new ps_DB();
     $q = "SELECT op.payment_method_id, pm.payment_method_name FROM #__{vm}_order_payment as op, #__{vm}_payment_method as pm\n              WHERE order_id='{$order_id}' AND op.payment_method_id=pm.payment_method_id";
     $db_payment->query($q);
     $db_payment->next_record();
     if ($auth["show_price_including_tax"] == 1) {
         $order_shipping = $db->f("order_shipping");
         $order_shipping += $db->f("order_shipping_tax");
         $order_shipping_tax = 0;
         $order_tax = $db->f("order_tax") + $db->f("order_shipping_tax");
     } else {
         $order_shipping = $db->f("order_shipping");
         $order_shipping_tax = $db->f("order_shipping_tax");
         $order_tax = $db->f("order_tax");
     }
     $order_total = $db->f("order_total");
     $order_discount = $db->f("order_discount");
     $coupon_discount = $db->f("coupon_discount");
     // Email Addresses for shopper and vendor
     // **************************************
     $shopper_email = $dbbt->f("user_email");
     $shopper_name = $dbbt->f("first_name") . " " . $dbbt->f("last_name");
     $from_email = $dbv->f("contact_email");
     $shopper_subject = $dbv->f("vendor_name") . " " . $VM_LANG->_('PHPSHOP_ORDER_PRINT_PO_LBL', false) . " - " . $db->f("order_id");
     $vendor_subject = $dbv->f("vendor_name") . " " . $VM_LANG->_('PHPSHOP_ORDER_PRINT_PO_LBL', false) . " - " . $db->f("order_id");
     $shopper_order_link = $sess->url(SECUREURL . "index.php?page=account.order_details&order_id={$order_id}", true, false);
     $vendor_order_link = $sess->url(SECUREURL . "index2.php?page=order.order_print&order_id={$order_id}&pshop_mode=admin", true, false);
     /**
      * Prepare the payment information, including Credit Card information when not empty
      */
     $payment_info_details = $db_payment->f("payment_method_name");
     if (!empty($_SESSION['ccdata']['order_payment_name']) && !empty($_SESSION['ccdata']['order_payment_number'])) {
         $payment_info_details .= '<br />' . $VM_LANG->_('PHPSHOP_CHECKOUT_CONF_PAYINFO_NAMECARD', false) . ': ' . $_SESSION['ccdata']['order_payment_name'] . '<br />';
         $payment_info_details .= $VM_LANG->_('PHPSHOP_CHECKOUT_CONF_PAYINFO_CCNUM', false) . ': ' . $this->asterisk_pad($_SESSION['ccdata']['order_payment_number'], 4) . '<br />';
         $payment_info_details .= $VM_LANG->_('PHPSHOP_CHECKOUT_CONF_PAYINFO_EXDATE', false) . ': ' . $_SESSION['ccdata']['order_payment_expire_month'] . ' / ' . $_SESSION['ccdata']['order_payment_expire_year'] . '<br />';
         if (!empty($_SESSION['ccdata']['credit_card_code'])) {
             $payment_info_details .= 'CVV code: ' . $_SESSION['ccdata']['credit_card_code'] . '<br />';
         }
     }
     // Convert HTML into Text
     $payment_info_details_text = str_replace('<br />', "\n", $payment_info_details);
     // Get the Shipping Details
     $shipping_arr = explode("|", urldecode(vmGet($_REQUEST, "shipping_rate_id")));
     // Headers and Footers
     // ******************************
     // Shopper Header
     $shopper_header = $VM_LANG->_('PHPSHOP_CHECKOUT_EMAIL_SHOPPER_HEADER1', false) . "\n";
     $legal_info_title = '';
     $legal_info_html = '';
     // Get the legal information about the returns/order cancellation policy
     if (@VM_ONCHECKOUT_SHOW_LEGALINFO == '1') {
         $article = intval(@VM_ONCHECKOUT_LEGALINFO_LINK);
         if ($article > 0) {
             $db_legal = new ps_DB();
             // Get the content article, which contains the Legal Info
             $db_legal->query('SELECT id, title, introtext FROM #__content WHERE id=' . $article);
             $db_legal->next_record();
             if ($db_legal->f('introtext')) {
                 $legal_info_title = $db_legal->f('title');
                 $legal_info_text = strip_tags(str_replace('<br />', "\n", $db_legal->f('introtext')));
                 $legal_info_html = $db_legal->f('introtext');
             }
         }
     }
     //Shopper Footer
     $shopper_footer = "\n\n" . $VM_LANG->_('PHPSHOP_CHECKOUT_EMAIL_SHOPPER_HEADER2', false) . "\n";
     if (VM_REGISTRATION_TYPE != 'NO_REGISTRATION') {
         $shopper_footer .= "\n\n" . $VM_LANG->_('PHPSHOP_CHECKOUT_EMAIL_SHOPPER_HEADER5', false) . "\n";
         $shopper_footer .= $shopper_order_link;
     }
     $shopper_footer .= "\n\n" . $VM_LANG->_('PHPSHOP_CHECKOUT_EMAIL_SHOPPER_HEADER3', false) . "\n";
     $shopper_footer .= "Email: " . $from_email;
     // New in version 1.0.5
     if (@VM_ONCHECKOUT_SHOW_LEGALINFO == '1' && !empty($legal_info_title)) {
         $shopper_footer .= "\n\n____________________________________________\n";
         $shopper_footer .= $legal_info_title . "\n";
         $shopper_footer .= $legal_info_text . "\n";
     }
     // Vendor Header
     $vendor_header = $VM_LANG->_('PHPSHOP_CHECKOUT_EMAIL_SHOPPER_HEADER4', false) . "\n";
     // Vendor Footer
     $vendor_footer = "\n\n" . $VM_LANG->_('PHPSHOP_CHECKOUT_EMAIL_SHOPPER_HEADER5', false) . "\n";
     $vendor_footer .= $vendor_order_link;
     $vendor_email = $from_email;
     /////////////////////////////////////
     // set up text mail
     //
     // Main Email Message Purchase Order
     // *********************************
     $shopper_message = "\n" . $VM_LANG->_('PHPSHOP_ORDER_PRINT_PO_LBL', false) . "\n";
     $shopper_message .= "------------------------------------------------------------------------\n";
     $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_PO_NUMBER', false) . ": " . $db->f("order_id") . "\n";
     $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_PO_DATE', false) . ":   ";
     $shopper_message .= strftime($VM_LANG->_('DATE_FORMAT_LC'), $db->f("cdate")) . "\n";
     $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_PO_STATUS', false) . ": ";
     $shopper_message .= $order_status . "\n\n";
     // BillTo Fields
     $registrationfields = ps_userfield::getUserFields('registration', false, '', false, true);
     foreach ($registrationfields as $field) {
         if ($field->name == 'email') {
             $field->name = 'user_email';
         }
         if ($field->name == 'delimiter_sendregistration' || $field->type == 'captcha') {
             continue;
         }
         if ($field->type == 'delimiter') {
             $shopper_message .= ($VM_LANG->_($field->title) != '' ? $VM_LANG->_($field->title) : $field->title) . "\n";
             $shopper_message .= "--------------------\n\n";
         } else {
             $shopper_message .= ($VM_LANG->_($field->title) != '' ? $VM_LANG->_($field->title) : $field->title) . ':    ';
             $shopper_message .= $dbbt->f($field->name) . "\n";
         }
     }
     // Shipping Fields
     $shopper_message .= "\n\n";
     $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_SHIP_TO_LBL') . "\n";
     $shopper_message .= "-------\n\n";
     $shippingfields = ps_userfield::getUserFields('shipping', false, '', false, true);
     foreach ($shippingfields as $field) {
         if ($field->type == 'delimiter') {
             $shopper_message .= ($VM_LANG->_($field->title) != '' ? $VM_LANG->_($field->title) : $field->title) . "\n";
             $shopper_message .= "--------------------\n\n";
         } else {
             $shopper_message .= ($VM_LANG->_($field->title) != '' ? $VM_LANG->_($field->title) : $field->title) . ':    ';
             $shopper_message .= $dbst->f($field->name) . "\n";
         }
     }
     $shopper_message .= "\n\n";
     $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_ITEMS_LBL', false) . "\n";
     $shopper_message .= "-----------";
     $sub_total = 0.0;
     while ($dboi->next_record()) {
         $shopper_message .= "\n\n";
         $shopper_message .= $VM_LANG->_('PHPSHOP_PRODUCT', false) . "  = ";
         if ($dboi->f("product_parent_id")) {
             $shopper_message .= $dboi->f("order_item_name") . "\n";
             $shopper_message .= "SERVICE  = ";
         }
         $shopper_message .= $dboi->f("product_name") . "; " . $dboi->f("product_attribute") . "\n";
         $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_QUANTITY', false) . " = ";
         $shopper_message .= $dboi->f("product_quantity") . "\n";
         $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_SKU', false) . "      = ";
         $shopper_message .= $dboi->f("order_item_sku") . "\n";
         $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_PRICE', false) . "    = ";
         if ($auth["show_price_including_tax"] == 1) {
             $sub_total += $dboi->f("product_quantity") * $dboi->f("product_final_price");
             $shopper_message .= $CURRENCY_DISPLAY->getFullValue($dboi->f("product_final_price"), '', $db->f('order_currency'));
         } else {
             $sub_total += $dboi->f("product_quantity") * $dboi->f("product_final_price");
             $shopper_message .= $CURRENCY_DISPLAY->getFullValue($dboi->f("product_item_price"), '', $db->f('order_currency'));
         }
     }
     $shopper_message .= "\n\n";
     $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_SUBTOTAL', false) . " = ";
     $shopper_message .= $CURRENCY_DISPLAY->getFullValue($sub_total, '', $db->f('order_currency')) . "\n";
     if (PAYMENT_DISCOUNT_BEFORE == '1') {
         if (!empty($order_discount)) {
             if ($order_discount > 0) {
                 $shopper_message .= $VM_LANG->_('PHPSHOP_PAYMENT_METHOD_LIST_DISCOUNT', false) . " = ";
                 $shopper_message .= "- " . $CURRENCY_DISPLAY->getFullValue(abs($order_discount), '', $db->f('order_currency')) . "\n";
             } else {
                 $shopper_message .= $VM_LANG->_('PHPSHOP_FEE', false) . " = ";
                 $shopper_message .= "+ " . $CURRENCY_DISPLAY->getFullValue(abs($order_discount), '', $db->f('order_currency')) . "\n";
             }
         }
         if (!empty($coupon_discount)) {
             /* following 2 lines added by Erich for coupon hack */
             $shopper_message .= $VM_LANG->_('PHPSHOP_COUPON_DISCOUNT', false) . ": ";
             $shopper_message .= $CURRENCY_DISPLAY->getFullValue($coupon_discount, '', $db->f('order_currency')) . "\n";
         }
     }
     if ($auth["show_price_including_tax"] != 1) {
         $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_TOTAL_TAX', false) . "      = ";
         $shopper_message .= $CURRENCY_DISPLAY->getFullValue($order_tax, '', $db->f('order_currency')) . "\n";
     }
     $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_SHIPPING', false) . " = ";
     $shopper_message .= $CURRENCY_DISPLAY->getFullValue($order_shipping, '', $db->f('order_currency')) . "\n";
     if (!empty($order_shipping_tax)) {
         $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_SHIPPING_TAX', false) . "   = ";
         $shopper_message .= $CURRENCY_DISPLAY->getFullValue($order_shipping_tax, '', $db->f('order_currency'));
     }
     $shopper_message .= "\n\n";
     if (PAYMENT_DISCOUNT_BEFORE != '1') {
         if (!empty($order_discount)) {
             if ($order_discount > 0) {
                 $shopper_message .= $VM_LANG->_('PHPSHOP_PAYMENT_METHOD_LIST_DISCOUNT', false) . " = ";
                 $shopper_message .= "- " . $CURRENCY_DISPLAY->getFullValue(abs($order_discount), '', $db->f('order_currency')) . "\n";
             } else {
                 $shopper_message .= $VM_LANG->_('PHPSHOP_FEE', false) . " = ";
                 $shopper_message .= "+ " . $CURRENCY_DISPLAY->getFullValue(abs($order_discount), '', $db->f('order_currency')) . "\n";
             }
         }
         if (!empty($coupon_discount)) {
             /* following 2 lines added by Erich for coupon hack */
             $shopper_message .= $VM_LANG->_('PHPSHOP_COUPON_DISCOUNT', false) . ": ";
             $shopper_message .= $CURRENCY_DISPLAY->getFullValue($coupon_discount, '', $db->f('order_currency')) . "\n";
         }
     }
     $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_TOTAL', false) . "    = ";
     $shopper_message .= $CURRENCY_DISPLAY->getFullValue($order_total, '', $db->f('order_currency'));
     if ($auth["show_price_including_tax"] == 1) {
         $shopper_message .= "\n---------------";
         $shopper_message .= "\n";
         $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_TOTAL_TAX', false) . "      = ";
         $shopper_message .= $CURRENCY_DISPLAY->getFullValue($order_tax, '', $db->f('order_currency')) . "\n";
     }
     if ($db->f('order_tax_details')) {
         $shopper_message .= str_replace('<br />', "\n", ps_checkout::show_tax_details($db->f('order_tax_details'), $db->f('order_currency')));
     }
     // Payment Details
     $shopper_message .= "\n\n------------------------------------------------------------------------\n";
     $shopper_message .= $payment_info_details_text;
     // Shipping Details
     if (is_object($this->_SHIPPING)) {
         $shopper_message .= "\n\n------------------------------------------------------------------------\n";
         $shopper_message .= $VM_LANG->_('PHPSHOP_ORDER_PRINT_SHIPPING_LBL', false) . ":\n";
         $shopper_message .= $shipping_arr[1] . " (" . $shipping_arr[2] . ")";
     }
     // Customer Note
     $shopper_message .= "\n\n------------------------------------------------------------------------\n";
     $shopper_message .= "\n" . $VM_LANG->_('PHPSHOP_ORDER_PRINT_CUSTOMER_NOTE', false) . "\n";
     $shopper_message .= "---------------";
     $shopper_message .= "\n";
     if (!empty($customer_note)) {
         $shopper_message .= $customer_note . "\n";
     } else {
         $shopper_message .= " ./. \n";
     }
     $shopper_message .= "------------------------------------------------------------------------\n";
     // Decode things like &euro; => €
     $shopper_message = vmHtmlEntityDecode($shopper_message);
     // End of Purchase Order
     // *********************
     //
     //END: set up text mail
     /////////////////////////////////////
     // Send text email
     //
     if (ORDER_MAIL_HTML == '0') {
         $msg = $shopper_header . $shopper_message . $shopper_footer;
         // Mail receipt to the shopper
         vmMail($from_email, $mosConfig_fromname, $shopper_email, $shopper_subject, $msg, "");
         $msg = $vendor_header . $shopper_message . $vendor_footer;
         // Mail receipt to the vendor
         vmMail($from_email, $mosConfig_fromname, $vendor_email, $vendor_subject, $msg, "");
     } elseif (ORDER_MAIL_HTML == '1') {
         $dboi->query($q_oi);
         // Create Template Object
         $template = vmTemplate::getInstance();
         if ($order_discount > 0) {
             $order_discount_lbl = $VM_LANG->_('PHPSHOP_PAYMENT_METHOD_LIST_DISCOUNT');
             $order_discount_plusminus = '-';
         } else {
             $order_discount_lbl = $VM_LANG->_('PHPSHOP_FEE');
             $order_discount_plusminus = '+';
         }
         if ($coupon_discount > 0) {
             $coupon_discount_lbl = $VM_LANG->_('PHPSHOP_PAYMENT_METHOD_LIST_DISCOUNT');
             $coupon_discount_plusminus = '-';
         } else {
             $coupon_discount_lbl = $VM_LANG->_('PHPSHOP_FEE');
             $coupon_discount_plusminus = '+';
         }
         if (is_object($this->_SHIPPING)) {
             $shipping_info_details = stripslashes($shipping_arr[1]) . " (" . stripslashes($shipping_arr[2]) . ")";
         } else {
             $shipping_info_details = ' ./. ';
         }
         // These are a lot of vars to import for the email confirmation
         $template->set_vars(array('is_email_to_shopper' => true, 'db' => $db, 'dboi' => $dboi, 'dbbt' => $dbbt, 'dbst' => $dbst, 'ps_product' => $ps_product, 'shippingfields' => $shippingfields, 'registrationfields' => $registrationfields, 'order_id' => $order_id, 'order_discount' => $order_discount, 'order_discount_lbl' => $order_discount_lbl, 'order_discount_plusminus' => $order_discount_plusminus, 'coupon_discount' => $coupon_discount, 'coupon_discount_lbl' => $coupon_discount_lbl, 'coupon_discount_plusminus' => $coupon_discount_plusminus, 'order_date' => $VM_LANG->convert(vmFormatDate($db->f("cdate"), $VM_LANG->_('DATE_FORMAT_LC'))), 'order_status' => $order_status, 'legal_info_title' => $legal_info_title, 'legal_info_html' => $legal_info_html, 'order_link' => $shopper_order_link, 'payment_info_lbl' => $VM_LANG->_('PHPSHOP_ORDER_PRINT_PAYINFO_LBL'), 'payment_info_details' => $payment_info_details, 'shipping_info_lbl' => $VM_LANG->_('PHPSHOP_ORDER_PRINT_SHIPPING_LBL'), 'shipping_info_details' => $shipping_info_details, 'from_email' => $from_email, 'customer_note' => nl2br($customer_note), 'order_header_msg' => $shopper_header, 'order_subtotal' => $CURRENCY_DISPLAY->getFullValue($sub_total, '', $db->f('order_currency')), 'order_shipping' => $CURRENCY_DISPLAY->getFullValue($order_shipping, '', $db->f('order_currency')), 'order_tax' => $CURRENCY_DISPLAY->getFullValue($order_tax, '', $db->f('order_currency')) . ps_checkout::show_tax_details($db->f('order_tax_details'), $db->f('order_currency')), 'order_total' => $CURRENCY_DISPLAY->getFullValue($order_total, '', $db->f('order_currency'))));
         $shopper_html = $template->fetch('order_emails/confirmation_email.tpl.php');
         // Reset the list of order items for use in the vendor email
         $dboi->reset();
         // Override some vars for the vendor email, so we can use the same template
         $template->set_vars(array('order_header_msg' => $vendor_header, 'order_link' => $vendor_order_link, 'is_email_to_shopper' => false));
         $vendor_html = $template->fetch('order_emails/confirmation_email.tpl.php');
         /*
          * Add the text, html and embedded images.
          * The name of the image should match exactly
          * (case-sensitive) to the name in the html.
          */
         $shopper_mail_Body = $shopper_html;
         $shopper_mail_AltBody = $shopper_header . $shopper_message . $shopper_footer;
         $vendor_mail_Body = $vendor_html;
         $vendor_mail_AltBody = $vendor_header . $shopper_message . $vendor_footer;
         $imagefile = pathinfo($dbv->f("vendor_full_image"));
         $extension = $imagefile['extension'] == "jpg" ? "jpeg" : "jpeg";
         $EmbeddedImages[] = array('path' => IMAGEPATH . "vendor/" . $dbv->f("vendor_full_image"), 'name' => "vendor_image", 'filename' => $dbv->f("vendor_full_image"), 'encoding' => "base64", 'mimetype' => "image/" . $extension);
         $shopper_mail = vmMail($from_email, $mosConfig_fromname, $shopper_email, $shopper_subject, $shopper_mail_Body, $shopper_mail_AltBody, true, null, null, $EmbeddedImages);
         $vendor_mail = vmMail($from_email, $mosConfig_fromname, $vendor_email, $vendor_subject, $vendor_mail_Body, $vendor_mail_AltBody, true, null, null, $EmbeddedImages, null, $shopper_email);
         if (!$shopper_mail || !$vendor_mail) {
             $vmLogger->debug('Something went wrong while sending the order confirmation email to ' . $from_email . ' and ' . $shopper_email);
             return false;
         }
         //
         // END: set up and send the HTML email
         ////////////////////////////////////////
     }
     return true;
 }
    /**
     * This is the main function which stores the order information in the database
     * 
     * @author Ashish Solanki!
     * @return boolean
     */
    function updateRecords($order_number, $order_total, &$d)
    {
        require_once CLASSPATH . 'ps_checkout.php';
        $ps_chkout = new ps_checkout();
        global $order_tax_details, $afid, $VM_LANG, $auth, $my, $mosConfig_offset, $vmLogger, $vmInputFilter, $discount_factor;
        $ps_vendor_id = $_SESSION["ps_vendor_id"];
        $cart = $_SESSION['cart'];
        require_once CLASSPATH . 'ps_payment_method.php';
        $ps_payment_method = new ps_payment_method();
        require_once CLASSPATH . 'ps_product.php';
        $ps_product = new ps_product();
        require_once CLASSPATH . 'ps_cart.php';
        $ps_cart = new ps_cart();
        $db = new ps_DB();
        $totals = $ps_chkout->calc_order_totals($d);
        extract($totals);
        $timestamp = time();
        //Custom
        $vmLogger->debug('-- Checkout Debug--
							Subtotal: ' . $order_subtotal . '
							Taxable: ' . $order_taxable . '
							Payment Discount: ' . $payment_discount . '
							Coupon Discount: ' . $coupon_discount . '
							Shipping: ' . $order_shipping . '
							Shipping Tax : ' . $order_shipping_tax . '
							Tax : ' . $order_tax . '
							------------------------
							Order Total: ' . $order_total . '
							----------------------------');
        // Check to see if Payment Class File exists
        $payment_class = $ps_payment_method->get_field($d["payment_method_id"], "payment_class");
        $d['new_order_status'] = 'P';
        // This is meant to be updated by a payment modules' process_payment method
        if (!class_exists($payment_class)) {
            include CLASSPATH . "payment/{$payment_class}.php";
        }
        $_PAYMENT = new $payment_class();
        // Remove the Coupon, because it is a Gift Coupon and now is used!!
        if (@$_SESSION['coupon_type'] == "gift") {
            $d['coupon_id'] = $_SESSION['coupon_id'];
            include_once CLASSPATH . 'ps_coupon.php';
            ps_coupon::remove_coupon_code($d);
        }
        // Get the IP Address
        if (!empty($_SERVER['REMOTE_ADDR'])) {
            $ip = $_SERVER['REMOTE_ADDR'];
        } else {
            $ip = 'unknown';
        }
        // Collect all fields and values to store them!
        $fields = array('user_id' => $auth["user_id"], 'vendor_id' => $ps_vendor_id, 'order_number' => $order_number, 'user_info_id' => $d["ship_to_info_id"], 'ship_method_id' => @urldecode($d["shipping_rate_id"]), 'order_total' => $order_total, 'order_subtotal' => $order_subtotal, 'order_tax' => $order_tax, 'order_tax_details' => serialize($order_tax_details), 'order_shipping' => $order_shipping, 'order_shipping_tax' => $order_shipping_tax, 'order_discount' => $payment_discount, 'coupon_discount' => $coupon_discount, 'coupon_code' => @$_SESSION['coupon_code'], 'order_currency' => $GLOBALS['product_currency'], 'order_status' => 'P', 'cdate' => $timestamp, 'mdate' => $timestamp, 'customer_note' => htmlspecialchars(vmRequest::getString('customer_note', '', 'POST', 'none'), ENT_QUOTES), 'ip_address' => $ip);
        // Insert the main order information
        $db->buildQuery('INSERT', '#__{vm}_orders', $fields);
        $result = $db->query();
        $d["order_id"] = $order_id = $db->last_insert_id();
        if ($result === false || empty($order_id)) {
            $vmLogger->crit('Adding the Order into the Database failed! User ID: ' . $auth["user_id"]);
            return false;
        }
        // Insert the initial Order History.
        $mysqlDatetime = date("Y-m-d G:i:s", $timestamp);
        $fields = array('order_id' => $order_id, 'order_status_code' => 'P', 'date_added' => $mysqlDatetime, 'customer_notified' => 1, 'comments' => '');
        $db->buildQuery('INSERT', '#__{vm}_order_history', $fields);
        $db->query();
        /**
         * Insert the Order payment info 
         */
        $payment_number = str_replace(array(' ', '|', '-'), '', @$_SESSION['ccdata']['order_payment_number']);
        $d["order_payment_code"] = @$_SESSION['ccdata']['credit_card_code'];
        // Payment number is encrypted using mySQL encryption functions.
        $fields = array('order_id' => $order_id, 'payment_method_id' => $d["payment_method_id"], 'order_payment_log' => @$d["order_payment_log"], 'order_payment_trans_id' => $vmInputFilter->safeSQL(@$d["order_payment_trans_id"]));
        if (!empty($payment_number) && VM_STORE_CREDITCARD_DATA == '1') {
            // Store Credit Card Information only if the Store Owner has decided to do so
            $fields['order_payment_code'] = $d["order_payment_code"];
            $fields['order_payment_expire'] = @$_SESSION["ccdata"]["order_payment_expire"];
            $fields['order_payment_name'] = @$_SESSION["ccdata"]["order_payment_name"];
            $fields['order_payment_number'] = VM_ENCRYPT_FUNCTION . "( '{$payment_number}','" . ENCODE_KEY . "')";
            $specialfield = array('order_payment_number');
        } else {
            $specialfield = array();
        }
        $db->buildQuery('INSERT', '#__{vm}_order_payment', $fields, '', $specialfield);
        $db->query();
        /**
         * Insert the User Billto & Shipto Info
         */
        // First: get all the fields from the user field list to copy them from user_info into the order_user_info
        $fields = array();
        require_once CLASSPATH . 'ps_userfield.php';
        $userfields = ps_userfield::getUserFields('', false, '', true, true);
        foreach ($userfields as $field) {
            if ($field->name == 'email') {
                $fields[] = 'user_email';
            } else {
                $fields[] = $field->name;
            }
        }
        $fieldstr = implode(',', $fields);
        // Save current Bill To Address
        $q = "INSERT INTO `#__{vm}_order_user_info` \n\t\t\t(`order_info_id`,`order_id`,`user_id`,address_type, " . $fieldstr . ") ";
        $q .= "SELECT NULL, '{$order_id}', '" . $auth['user_id'] . "', address_type, " . $fieldstr . " FROM #__{vm}_user_info WHERE user_id='" . $auth['user_id'] . "' AND address_type='BT'";
        $db->query($q);
        // Save current Ship to Address if applicable
        $q = "INSERT INTO `#__{vm}_order_user_info` \n\t\t\t(`order_info_id`,`order_id`,`user_id`,address_type, " . $fieldstr . ") ";
        $q .= "SELECT NULL, '{$order_id}', '" . $auth['user_id'] . "', address_type, " . $fieldstr . " FROM #__{vm}_user_info WHERE user_id='" . $auth['user_id'] . "' AND user_info_id='" . $d['ship_to_info_id'] . "' AND address_type='ST'";
        $db->query($q);
        /**
         * Insert all Products from the Cart into order line items; 
         * one row per product in the cart 
         */
        $dboi = new ps_DB();
        for ($i = 0; $i < $cart["idx"]; $i++) {
            $r = "SELECT product_id,product_in_stock,product_sales,product_parent_id,product_sku,product_name ";
            $r .= "FROM #__{vm}_product WHERE product_id='" . $cart[$i]["product_id"] . "'";
            $dboi->query($r);
            $dboi->next_record();
            $product_price_arr = $ps_product->get_adjusted_attribute_price($cart[$i]["product_id"], $cart[$i]["description"]);
            $product_price = $GLOBALS['CURRENCY']->convert($product_price_arr["product_price"], $product_price_arr["product_currency"]);
            if (empty($_SESSION['product_sess'][$cart[$i]["product_id"]]['tax_rate'])) {
                $my_taxrate = $ps_product->get_product_taxrate($cart[$i]["product_id"]);
            } else {
                $my_taxrate = $_SESSION['product_sess'][$cart[$i]["product_id"]]['tax_rate'];
            }
            // Attribute handling
            $product_parent_id = $dboi->f('product_parent_id');
            $description = '';
            if ($product_parent_id > 0) {
                $db_atts = $ps_product->attribute_sql($dboi->f('product_id'), $product_parent_id);
                while ($db_atts->next_record()) {
                    $description .= $db_atts->f('attribute_name') . ': ' . $db_atts->f('attribute_value') . '; ';
                }
            }
            $description .= $ps_product->getDescriptionWithTax($_SESSION['cart'][$i]["description"], $dboi->f('product_id'));
            $product_final_price = round($product_price * ($my_taxrate + 1), 2);
            $vendor_id = $ps_vendor_id;
            $fields = array('order_id' => $order_id, 'user_info_id' => $d["ship_to_info_id"], 'vendor_id' => $vendor_id, 'product_id' => $cart[$i]["product_id"], 'order_item_sku' => $dboi->f("product_sku"), 'order_item_name' => $dboi->f("product_name"), 'product_quantity' => $cart[$i]["quantity"], 'product_item_price' => $product_price, 'product_final_price' => $product_final_price, 'order_item_currency' => $GLOBALS['product_currency'], 'order_status' => 'P', 'product_attribute' => $description, 'cdate' => $timestamp, 'mdate' => $timestamp);
            $db->buildQuery('INSERT', '#__{vm}_order_item', $fields);
            $db->query();
            // Update Stock Level and Product Sales, decrease - no matter if in stock or not!
            $q = "UPDATE #__{vm}_product ";
            $q .= "SET product_in_stock = product_in_stock - " . (int) $cart[$i]["quantity"];
            $q .= " WHERE product_id = '" . $cart[$i]["product_id"] . "'";
            $db->query($q);
            $q = "UPDATE #__{vm}_product ";
            $q .= "SET product_sales= product_sales + " . (int) $cart[$i]["quantity"];
            $q .= " WHERE product_id='" . $cart[$i]["product_id"] . "'";
            $db->query($q);
            // Update stock of parent product, if all child products are sold, thanks Ragnar Brynjulfsson
            if ($dboi->f("product_parent_id") != 0) {
                $q = "SELECT COUNT(product_id) ";
                $q .= "FROM #__{vm}_product ";
                $q .= "WHERE product_parent_id = " . $dboi->f("product_parent_id");
                $q .= " AND product_in_stock > 0";
                $db->query($q);
                $db->next_record();
                if (!$db->f("COUNT(product_id)")) {
                    $q = "UPDATE #__{vm}_product ";
                    $q .= "SET product_in_stock = 0 ";
                    $q .= "WHERE product_id = " . $dboi->f("product_parent_id") . " LIMIT 1";
                    $db->query($q);
                }
            }
        }
        ######## BEGIN DOWNLOAD MOD ###############
        if (ENABLE_DOWNLOADS == "1") {
            require_once CLASSPATH . 'ps_order.php';
            for ($i = 0; $i < $cart["idx"]; $i++) {
                // only handle downloadable products here
                if (ps_product::is_downloadable($cart[$i]["product_id"])) {
                    $params = array('product_id' => $cart[$i]["product_id"], 'order_id' => $order_id, 'user_id' => $auth["user_id"]);
                    ps_order::insert_downloads_for_product($params);
                    if (@VM_DOWNLOADABLE_PRODUCTS_KEEP_STOCKLEVEL == '1') {
                        // Update the product stock level back to where it was.
                        $q = "UPDATE #__{vm}_product ";
                        $q .= "SET product_in_stock = product_in_stock + " . (int) $cart[$i]["quantity"];
                        $q .= " WHERE product_id = '" . (int) $cart[$i]["product_id"] . "'";
                        $db->query($q);
                    }
                }
            }
        }
        ################## END DOWNLOAD MOD ###########
        // Export the order_id so the checkout complete page can get it
        $d["order_id"] = $order_id;
        /*
         * Let the shipping module know which shipping method
         * was selected.  This way it can save any information
         * it might need later to print a shipping label.
         */
        if (is_callable(array($this->_SHIPPING, 'save_rate_info'))) {
            $this->_SHIPPING->save_rate_info($d);
        }
        // Now as everything else has been done, we can update the Order Status
        $update_order = false;
        if ($order_total == 0.0) {
            // code moved out of $_PAYMENT check as no payment will be needed when $order_total=0.0
            // If the Order Total is zero, we can confirm the order to automatically enable the download
            $d['order_status'] = ENABLE_DOWNLOAD_STATUS;
            $update_order = true;
        } elseif (isset($_PAYMENT)) {
            if ($d['new_order_status'] != 'P') {
                $d['order_status'] = $d['new_order_status'];
                $update_order = true;
            }
        }
        if ($update_order) {
            require_once CLASSPATH . "ps_order.php";
            $ps_order = new ps_order();
            $ps_order->order_status_update($d);
        }
        // Send the e-mail confirmation messages
        $ps_chkout->email_receipt($order_id);
        // Reset the cart (=empty it)
        $ps_cart->reset();
        $_SESSION['savedcart']['idx'] = 0;
        $ps_cart->saveCart();
        // Unset the payment_method variables
        $d["payment_method_id"] = "";
        $d["order_payment_number"] = "";
        $d["order_payment_expire"] = "";
        $d["order_payment_name"] = "";
        $d["credit_card_code"] = "";
        // Clear the sensitive Session data
        $_SESSION['ccdata']['order_payment_name'] = "";
        $_SESSION['ccdata']['order_payment_number'] = "";
        $_SESSION['ccdata']['order_payment_expire_month'] = "";
        $_SESSION['ccdata']['order_payment_expire_year'] = "";
        $_SESSION['ccdata']['credit_card_code'] = "";
        $_SESSION['coupon_discount'] = "";
        $_SESSION['coupon_id'] = "";
        $_SESSION['coupon_redeemed'] = false;
        $_POST["payment_method_id"] = "";
        $_POST["order_payment_number"] = "";
        $_POST["order_payment_expire"] = "";
        $_POST["order_payment_name"] = "";
        $_SESSION['order_id'] = $order_id;
    }
Ejemplo n.º 3
0
 /**
  * Function to update a Shopper Entry
  * (uses who have perms='shopper')
  */
 function update(&$d)
 {
     global $my, $perm, $sess, $vmLogger, $page;
     $auth = $_SESSION['auth'];
     $db = new ps_DB();
     if (@$d["user_id"] != $my->id && @$d["user_id"] != $auth['user_id'] && $auth["perms"] != "admin") {
         $vmLogger->crit("Tricky tricky, but we know about this one.");
         return False;
     }
     require_once CLASSPATH . 'ps_user.php';
     if (!empty($d['username'])) {
         $_POST['username'] = $d['username'];
     } else {
         $_POST['username'] = $my->username;
     }
     $_POST['name'] = $d['first_name'] . " " . $d['last_name'];
     $_POST['id'] = $auth["user_id"];
     $_POST['gid'] = $my->gid;
     $d['error'] = "";
     if (VM_REGISTRATION_TYPE != 'NO_REGISTRATION') {
         ps_user::saveUser($d);
     }
     if (!empty($d['error'])) {
         return false;
     }
     if (!$this->validate_update($d)) {
         return false;
     }
     $user_id = $auth["user_id"];
     /* Update Bill To */
     // Get all fields which where shown to the user
     $userFields = ps_userfield::getUserFields('account', false, '', true);
     $skip_fields = ps_userfield::getSkipFields();
     $fields = array('mdate' => time());
     foreach ($userFields as $userField) {
         if (!in_array($userField->name, $skip_fields)) {
             $fields[$userField->name] = ps_userfield::prepareFieldDataSave($userField->type, $userField->name, vmGet($d, $userField->name, strtoupper($userField->name)));
         }
     }
     $fields['user_email'] = $fields['email'];
     unset($fields['email']);
     $db->buildQuery('UPDATE', '#__{vm}_user_info', $fields, " WHERE user_id=" . $user_id . " AND address_type='BT'");
     // Run the query!
     $db->query();
     // UPDATE #__{vm}_shopper group relationship
     $q = "SELECT shopper_group_id FROM #__{vm}_shopper_vendor_xref ";
     $q .= "WHERE user_id = '" . $user_id . "'";
     $db->query($q);
     if (!$db->num_rows()) {
         //add
         $shopper_db = new ps_DB();
         // get the default shopper group
         $q = "SELECT shopper_group_id from #__{vm}_shopper_group WHERE ";
         $q .= "`default`='1'";
         $shopper_db->query($q);
         if (!$shopper_db->num_rows()) {
             // when there is no "default", take the first in the table
             $q = "SELECT shopper_group_id from #__{vm}_shopper_group";
             $shopper_db->query($q);
         }
         $shopper_db->next_record();
         $my_shopper_group_id = $shopper_db->f("shopper_group_id");
         if (empty($d['customer_number'])) {
             $d['customer_number'] = "";
         }
         $q = "INSERT INTO #__{vm}_shopper_vendor_xref ";
         $q .= "(user_id,vendor_id,shopper_group_id) ";
         $q .= "VALUES ('";
         $q .= $_SESSION['auth']['user_id'] . "','";
         $q .= $_SESSION['ps_vendor_id'] . "','";
         $q .= $my_shopper_group_id . "')";
         $db->query($q);
     }
     $q = "SELECT user_id FROM #__{vm}_auth_user_vendor ";
     $q .= "WHERE user_id = '" . $_SESSION['auth']['user_id'] . "'";
     $db->query($q);
     if (!$db->num_rows()) {
         // Insert vendor relationship
         $q = "INSERT INTO #__{vm}_auth_user_vendor (user_id,vendor_id)";
         $q .= " VALUES ";
         $q .= "('" . $_SESSION['auth']['user_id'] . "','";
         $q .= $_SESSION['ps_vendor_id'] . "') ";
         $db->query($q);
     }
     return True;
 }
Ejemplo n.º 4
0
    $q = "SELECT * FROM #__users, #__{vm}_user_info \r\n\t\t\tWHERE user_id='" . $auth["user_id"] . "' \r\n\t\t\tAND user_id = id\r\n\t\t\tAND address_type='BT' ";
}
$db->query($q);
$db->next_record();
// Set the CMS pathway
$pathway = array();
if (stristr($next_page, 'checkout') !== false) {
    // We are in the checkout process
    $pathway[] = $vm_mainframe->vmPathwayItem($VM_LANG->_('PHPSHOP_CHECKOUT_TITLE'), $sess->url(SECUREURL . "index.php?page={$next_page}"));
    $pathway[] = $vm_mainframe->vmPathwayItem($VM_LANG->_('PHPSHOP_SHOPPER_FORM_SHIPTO_LBL'));
} else {
    // We are in account maintenance
    $pathway[] = $vm_mainframe->vmPathwayItem($VM_LANG->_('PHPSHOP_ACCOUNT_TITLE'), $sess->url(SECUREURL . 'index.php?page=account.index'));
    $pathway[] = $vm_mainframe->vmPathwayItem($VM_LANG->_('PHPSHOP_USER_FORM_BILLTO_LBL'));
}
$vm_mainframe->vmAppendPathway($pathway);
// Set the internal VirtueMart pathway
$tpl = vmTemplate::getInstance();
$tpl->set('pathway', $pathway);
$vmPathway = $tpl->fetch('common/pathway.tpl.php');
$tpl->set('vmPathway', $vmPathway);
// Handle NO_REGISTRATION
$skip_fields = array();
if (VM_REGISTRATION_TYPE == 'NO_REGISTRATION' || VM_REGISTRATION_TYPE == 'OPTIONAL_REGISTRATION' && empty($d['register_account'])) {
    global $default;
    $default['email'] = $db->f('user_email');
    $skip_fields = array('username', 'password', 'password2');
}
$fields = ps_userfield::getUserFields('account');
$tpl->set_vars(array('fields' => $fields, 'db' => $db, 'next_page' => $next_page, 'missing' => $missing, 'Itemid' => $Itemid, 'skip_fields' => $skip_fields));
echo $tpl->fetch('pages/' . $page . '.tpl.php');
Ejemplo n.º 5
0
 /**
  * Returns all Bank payment in a Radiolist
  *
  * @param int $payment_method_id
  * @param boolean $horiz
  */
 function list_bank($payment_method_id, $horiz)
 {
     $has_bank_methods = $this->list_payment_radio("B", $payment_method_id, $horiz);
     //A bit easier :-)
     if ($has_bank_methods) {
         require_once CLASSPATH . 'ps_user.php';
         $dbu =& ps_user::getUserInfo($_SESSION['auth']['user_id'], array('bank_account_holder', 'bank_iban', 'bank_account_nr', 'bank_sort_code', 'bank_name'));
         if (!$dbu->f('bank_account_holder') || !$dbu->f('bank_account_nr') || !$dbu->f('bank_sort_code')) {
             echo '<br />';
             require_once CLASSPATH . 'ps_userfield.php';
             ps_userfield::listUserFields(ps_userfield::getUserfields('bank'), array(), $dbu);
         }
     }
 }
Ejemplo n.º 6
0
 /**
  * Updates a Shipping Adress for the specified user info ID
  *
  * @param array $d
  * @return boolean
  */
 function update(&$d)
 {
     global $perm, $VM_LANG;
     require_once CLASSPATH . 'ps_userfield.php';
     $db = new ps_DB();
     $timestamp = time();
     if (!$this->validate_update($d)) {
         return false;
     }
     // Get all fields which where shown to the user
     $shippingFields = ps_userfield::getUserFields('shipping', false, '', true);
     $skip_fields = ps_userfield::getSkipFields();
     foreach ($shippingFields as $userField) {
         if (!in_array($userField->name, $skip_fields)) {
             $fields[$userField->name] = ps_userfield::prepareFieldDataSave($userField->type, $userField->name, vmGet($d, $userField->name, strtoupper($userField->name)));
         }
     }
     // These are pre-defined fields.
     $fields['user_id'] = !$perm->check("admin,storeadmin") ? $_SESSION['auth']['user_id'] : (int) $d["user_id"];
     $fields['address_type'] = 'ST';
     $fields['mdate'] = time();
     $db->buildQuery('UPDATE', '#__{vm}_user_info', $fields, "WHERE user_info_id='" . $db->getEscaped($d["user_info_id"]) . "'" . (!$perm->check("admin,storeadmin") ? " AND user_id=" . $_SESSION['auth']['user_id'] : ''));
     if ($db->query() === false) {
         $GLOBALS['vmLogger']->err($VM_LANG->_('VM_USERADDRESS_UPDATED_FAILED'));
         return false;
     }
     $GLOBALS['vmLogger']->info($VM_LANG->_('VM_USERADDRESS_UPDATED'));
     vmRequest::setVar('ship_to_info_id', $d['user_info_id']);
     return true;
 }
Ejemplo n.º 7
0
 function change_ship_to()
 {
     global $VM_LANG, $vmLogger;
     $ship_to = trim(vmGet($_REQUEST, 'ship_to'));
     $db = new ps_DB();
     $dbu = new ps_DB();
     // Delete ship to
     $q = "DELETE FROM #__{vm}_order_user_info ";
     $q .= "WHERE order_id = '" . $this->order_id . "' AND address_type = 'ST'";
     $db->query($q);
     $db->next_record();
     $q = "SELECT * FROM #__{vm}_user_info ";
     $q .= "WHERE user_info_id = '" . $ship_to . "'";
     $db->query($q);
     $db->next_record();
     // Update order user_info_id
     $q = "UPDATE #__{vm}_orders ";
     $q .= "SET  user_info_id = '" . $db->f('user_info_id') . "'";
     $q .= " WHERE order_id = '" . $this->order_id . "'";
     $dbu->query($q);
     $dbu->next_record();
     // Read all items from db
     if ($db->f('address_type') == 'ST' || $db->f('address_type_name') == '-default-') {
         $dbo = new ps_DB();
         $q = "SELECT * FROM #__{vm}_order_item WHERE order_id = '" . $this->order_id . "'";
         $dbo->query($q);
         $ps_product = new ps_product();
         while ($dbo->next_record()) {
             $product_item_price = $dbo->f("product_item_price");
             $product_id = $dbo->f("product_id");
             $order_item_id = $dbo->f("order_item_id");
             if ($product_item_price > 0) {
                 $my_taxrate = $ps_product->get_product_taxrate($product_id, '', $ship_to);
                 $product_final_price = round($product_item_price * ($my_taxrate + 1), 2);
             } else {
                 $my_taxrate = 0;
                 $product_final_price = 0;
             }
             // Update item
             $dbs = new ps_DB();
             $q = "UPDATE #__{vm}_order_item  SET ";
             $q .= "user_info_id = '" . $ship_to . "', ";
             $q .= "product_final_price = '" . $product_final_price . "' ";
             $q .= "WHERE order_item_id = '" . addslashes($order_item_id) . "'";
             $dbs->query($q);
             $dbs->next_record();
         }
         // Find the required fields -
         require_once CLASSPATH . 'ps_userfield.php';
         $shippingFields = ps_userfield::getUserFields('', false, '', true, true);
         $fieldlist = '';
         // Skip the fields in the array
         // filter address_type just in case it will be in the Userfields some time
         $skipfields = array("email", "address_type");
         foreach ($shippingFields as $shippingField) {
             // Build the list of fields
             if (!in_array($shippingField->name, $skipfields)) {
                 $fieldlist .= ',' . $shippingField->name;
             }
         }
         // Ship to Address if applicable (copied from ps_checkout.php and changed)
         $q = "INSERT INTO `#__{vm}_order_user_info` (order_info_id,order_id,user_id, address_type {$fieldlist}) ";
         $q .= "SELECT '', '" . $this->order_id . "', '" . $db->f('user_id') . "', 'ST' " . $fieldlist . " FROM #__{vm}_user_info WHERE user_id='" . $db->f('user_id') . "' AND user_info_id='" . $ship_to . "' AND address_type='ST'";
         $db->query($q);
         $db->next_record();
     }
     $this->reload_from_db = 1;
     $this->recalc_order($this->order_id);
     $vmLogger->info($VM_LANG->_('PHPSHOP_ORDER_PRINT_SHIP_TO_LBL') . $VM_LANG->_('PHPSHOP_ORDER_EDIT_SOMETHING_HAS_CHANGED'));
 }
?>
<fieldset>
        <legend><span class="sectiontableheader"><?php 
echo $VM_LANG->_('PHPSHOP_SHOPPER_FORM_SHIPTO_LBL');
?>
</span></legend>
        
<br />
<?php 
echo $VM_LANG->_('PHPSHOP_SHIPTO_TEXT');
?>
<br /><br /><br />

<div style="width:90%;">
<?php 
ps_userfield::listUserFields($fields, array(), $db);
?>

  <input type="hidden" name="option" value="com_virtuemart" />
  <input type="hidden" name="Itemid" value="<?php 
echo $Itemid;
?>
" />
  <input type="hidden" name="page" value="<?php 
echo $next_page;
?>
" />
  <input type="hidden" name="next_page" value="<?php 
echo $next_page;
?>
" />
Ejemplo n.º 9
0
}
$fields = ps_userfield::getUserFields('registration', false, '', false);
// Read-only fields on registration don't make sense.
foreach ($fields as $field) {
    $field->readonly = 0;
}
$skip_fields = array();
if ($my->id > 0 || VM_REGISTRATION_TYPE != 'NORMAL_REGISTRATION' && VM_REGISTRATION_TYPE != 'OPTIONAL_REGISTRATION' && ($page == 'checkout.index' || $page == 'shop.registration')) {
    // A listing of fields that are NOT shown
    $skip_fields = array('username', 'password', 'password2');
    if ($my->id) {
        $skip_fields[] = 'email';
    }
}
// This is the part that prints out ALL registration fields!
ps_userfield::listUserFields($fields, $skip_fields);
echo '
<div align="center">';
if (!$mosConfig_useractivation && @VM_SHOW_REMEMBER_ME_BOX && VM_REGISTRATION_TYPE == 'NORMAL_REGISTRATION') {
    echo '<input type="checkbox" name="remember" value="yes" id="remember_login2" checked="checked" />
		<label for="remember_login2">' . $VM_LANG->_('REMEMBER_ME') . '</label><br /><br />';
} else {
    if (VM_REGISTRATION_TYPE == 'NO_REGISTRATION') {
        $rmbr = '';
    } else {
        $rmbr = 'yes';
    }
    echo '<input type="hidden" name="remember" value="' . $rmbr . '" />';
}
echo '
		<input type="submit" value="' . $VM_LANG->_('BUTTON_SEND_REG') . '" class="button" onclick="return( submitregistration());" />
Ejemplo n.º 10
0
 /**
  * This function allows you to get an object list of user fields
  *
  * @param string $section The section the fields belong to (e.g. 'registration' or 'account')
  * @param boolean $required_only
  * @param mixed $sys When left empty, doesn't filter by sys
  * @return array
  */
 function getUserFields($section = 'registration', $required_only = false, $sys = '', $exclude_delimiters = false, $exclude_skipfields = false)
 {
     $db = new ps_DB();
     $q = "SELECT f.* FROM `#__{vm}_userfield` f" . "\n WHERE f.published=1";
     if ($section != 'bank' && $section != '') {
         $q .= "\n AND f.`{$section}`=1";
     } elseif ($section == 'bank') {
         $q .= "\n AND f.name LIKE '%bank%'";
     }
     if ($exclude_delimiters) {
         $q .= "\n AND f.type != 'delimiter' ";
     }
     if ($required_only) {
         $q .= "\n AND f.required=1";
     }
     if ($sys !== '') {
         if ($sys == '1') {
             $q .= "\n AND f.sys=1";
         } elseif ($sys == '0') {
             $q .= "\n AND f.sys=0";
         }
     }
     if ($exclude_skipfields) {
         $q .= "\n AND FIND_IN_SET( f.name, '" . implode(',', ps_userfield::getSkipFields()) . "') = 0 ";
     }
     $q .= "\n ORDER BY f.ordering";
     $db->setQuery($q);
     $userFields = $db->loadObjectList();
     return $userFields;
 }
Ejemplo n.º 11
0
        $types['yanc_subscription'] = $VM_LANG->_('VM_FIELDS_NEWSLETTER') . ' (YaNC)';
    }
    if (file_exists($mosConfig_absolute_path . '/components/com_anjel/anjel.php')) {
        $types['anjel_subscription'] = $VM_LANG->_('VM_FIELDS_NEWSLETTER') . ' (ANJEL)';
    }
    if (file_exists($mosConfig_absolute_path . '/components/com_letterman/letterman.php')) {
        $types['letterman_subscription'] = $VM_LANG->_('VM_FIELDS_NEWSLETTER') . ' (Letterman)';
    }
    if (file_exists($mosConfig_absolute_path . '/components/com_ccnewsletter/ccnewsletter.php')) {
        $types['ccnewsletter_subscription'] = $VM_LANG->_('VM_FIELDS_NEWSLETTER') . ' (ccNewsletter)';
    }
    $types['delimiter'] = $VM_LANG->_('VM_FIELDS_DELIMITER');
    $lists['type'] = ps_html::selectList('type', $db->f('type'), $types, 1, '', 'onchange="toggleType(this.options[this.selectedIndex].value);"');
}
$lists['webaddresstypes'] = ps_html::selectList('webaddresstypes', $db->f('rows'), $webaddrtypes);
if (in_array($db->f('name'), ps_userfield::getSkipFields())) {
    $lists['required'] = '<input type="hidden" name="required" class="inputbox" value="' . $db->sf('required') . '" />' . ($db->sf('required') ? $VM_LANG->_('PHPSHOP_ADMIN_CFG_YES') : $VM_LANG->_('PHPSHOP_ADMIN_CFG_NO'));
    $lists['published'] = '<input type="hidden" name="published" class="inputbox" value="' . $db->sf('required') . '" />' . ($db->sf('required') ? $VM_LANG->_('PHPSHOP_ADMIN_CFG_YES') : $VM_LANG->_('PHPSHOP_ADMIN_CFG_NO'));
    $lists['registration'] = '<input type="hidden" name="registration" class="inputbox" value="' . $db->sf('required') . '" />' . ($db->sf('required') ? $VM_LANG->_('PHPSHOP_ADMIN_CFG_YES') : $VM_LANG->_('PHPSHOP_ADMIN_CFG_NO'));
} else {
    $lists['required'] = ps_html::yesnoSelectList('required', $db->sf('required') ? $db->sf('required') : '0');
    $lists['published'] = ps_html::yesnoSelectList('published', $db->sf('published'));
    $lists['registration'] = ps_html::yesnoSelectList('registration', $db->sf('registration'));
}
$lists['readonly'] = ps_html::yesnoSelectList('readonly', $db->sf('readonly') != '' ? $db->sf('readonly') : '0');
$lists['shipping'] = ps_html::yesnoSelectList('shipping', $db->sf('shipping') != '' ? $db->sf('shipping') : '0');
$lists['account'] = ps_html::yesnoSelectList('account', $db->sf('account'));
?>
	<table cellpadding="4" cellspacing="0" border="0" width="100%">
		<tr>
			<td class="sectionname"><img src="<?php 
Ejemplo n.º 12
0
<div style="width:90%;" class="adminform">
<fieldset>
	<legend><span class="sectiontableheader"><?php 
echo $VM_LANG->_('PHPSHOP_SHOPPER_FORM_SHIPTO_LBL');
?>
</span></legend>

	<!-- Registration form -->
	<form action="<?php 
echo $_SERVER['PHP_SELF'];
?>
" method="post" name="adminForm">
<?php 
// Display the shipping address
$fields = ps_userfield::getUserFields('shipping');
ps_userfield::listUserFields($fields, array(), $db, false);
?>

	<input type="hidden" name="option" value="com_virtuemart" />
<?php 
if (!empty($user_info_id)) {
    ?>
	<input type="hidden" name="func" value="userAddressUpdate" />
	<input type="hidden" name="user_info_id" value="<?php 
    echo $user_info_id;
    ?>
" />
<?php 
} else {
    ?>
	<input type="hidden" name="func" value="userAddressAdd" />
Ejemplo n.º 13
0
        $sc_trackingpost->addCssJs();
        $sc_trackingpost->getAddForm($order_id);
        //	  <!-- Трекинг посылок end -->
        ?>

		    <table class="adminlist" width="100%" >
		    <?php 
        $user_id = $db->f("user_id");
        $dbt = new ps_DB();
        $qt = "SELECT * from #__{vm}_order_user_info WHERE user_id='{$user_id}' AND order_id='{$order_id}' ORDER BY address_type ASC";
        $dbt->query($qt);
        $dbt->next_record();
        require_once CLASSPATH . 'ps_userfield.php';
        $userfields = ps_userfield::getUserFields('registration', false, '', true, true);
        $shippingfields = ps_userfield::getUserFields('shipping', false, '', true, true);
        $user_opt_fields = ps_userfield::getUserFields('opt');
        $shippingfields = array_merge($shippingfields, $user_opt_fields);
        ?>
		        <tr>
		    	  <th width="50%"  valign="top">Действия</th>
		    	  <th width="50%" valign="top"><?php 
        echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_SHIP_TO_LBL');
        ?>
</th>
		        </tr>
		        <tr>
		    	  <td valign="top">
		    		<table class="mailbuttons">
		    		    <tr>
		    <?php 
        $emsstyle = 'display: none';
Ejemplo n.º 14
0
        }
    }
    ?>
 
			</td> 
		</tr> 
	</table>
	</fieldset>
         <?php 
}
require_once CLASSPATH . 'ps_userfield.php';
// Get only those fields that are NOT system fields
$userFields = ps_userfield::getUserFields('account');
$skipFields = array('delimiter_userinfo', 'username', 'email', 'password', 'password2', 'agreed');
echo '<table class="adminform"><tr><td>';
ps_userfield::listUserFields($userFields, $skipFields, $db, false);
echo '</td></tr></table>';
$tabs->endTab();
require_once CLASSPATH . "pageNavigation.class.php";
require_once CLASSPATH . "htmlTools.class.php";
require_once CLASSPATH . 'ps_order_status.php';
$ps_order_status = new ps_order_status();
$q = "";
$list = "SELECT * FROM #__{vm}_orders ";
$count = "SELECT count(*) as num_rows FROM #__{vm}_orders ";
$q .= "WHERE  #__{vm}_orders.vendor_id='" . $_SESSION['ps_vendor_id'] . "' AND #__{vm}_orders.user_id=" . $user_id . " ";
$q .= "ORDER BY #__{vm}_orders.cdate DESC ";
$count .= $q;
$list .= $q;
$db->query($count);
$db->next_record();
Ejemplo n.º 15
0
 /**
  * Updates a User Record
  *
  * @param array $d
  * @return boolean
  */
 function update(&$d)
 {
     global $my, $VM_LANG, $perm, $vmLogger;
     $ps_vendor_id = $_SESSION["ps_vendor_id"];
     $db = new ps_DB();
     $timestamp = time();
     if (!$this->validate_update($d)) {
         return False;
     }
     // Joomla User Information stuff
     if (vmIsJoomla('1.5', '>=')) {
         $this->save();
     } else {
         $this->saveUser($d);
     }
     // Update Bill To
     // Get all fields which where shown to the user
     $userFields = ps_userfield::getUserFields('account', false, '', true);
     $user_id = intval($d['id']);
     // Building the query: PART ONE
     // The first 7 fields are FIX and not built dynamically
     $db->query("SELECT COUNT(user_info_id) AS num_rows \n\t\t\t\t\tFROM #__{vm}_user_info WHERE user_id='" . $user_id . "'");
     if ($db->f('num_rows') < 1) {
         // The user is registered in Joomla, but not in VirtueMart; so, insert the bill to information
         return $this->add($d);
     } else {
         $q = "UPDATE #__{vm}_user_info SET\n\t                                `mdate` = '" . time() . "',\n\t                                `perms` = '" . $d['perms'] . "', ";
         $fields = array();
         $skip_fields = ps_userfield::getSkipFields();
         foreach ($userFields as $userField) {
             if (!in_array($userField->name, $skip_fields)) {
                 $d[$userField->name] = ps_userfield::prepareFieldDataSave($userField->type, $userField->name, @$d[$userField->name]);
                 $fields[] = "`" . $userField->name . "`='" . mysql_real_escape_string($d[$userField->name]) . "'";
             }
         }
         $q .= str_replace('`email`', '`user_email`', implode(",\n", $fields));
         $q .= " WHERE user_id=" . $user_id . " AND address_type='BT'";
         // Run the query now!
         $db->query($q);
     }
     if ($perm->check("admin")) {
         $vendor_id = $d['vendor_id'];
     } else {
         $vendor_id = $ps_vendor_id;
     }
     $db->query("SELECT COUNT(user_id) as num_rows FROM #__{vm}_auth_user_vendor WHERE vendor_id='" . $vendor_id . "' AND user_id='" . $d["user_id"] . "'");
     if ($db->f('num_rows') < 1) {
         // Insert vendor relationship
         $q = "INSERT INTO #__{vm}_auth_user_vendor (user_id,vendor_id)";
         $q .= " VALUES ";
         $q .= "('" . $d['user_id'] . "','{$vendor_id}') ";
         $db->query($q);
     } else {
         // Update the User- Vendor  relationship
         $q = "UPDATE #__{vm}_auth_user_vendor set ";
         $q .= "vendor_id='" . $d['vendor_id'] . "' ";
         $q .= "WHERE user_id='" . $d["user_id"] . "'";
         $db->query($q);
     }
     $db->query("SELECT COUNT(user_id) as num_rows FROM #__{vm}_shopper_vendor_xref WHERE vendor_id='" . $vendor_id . "' AND user_id='" . $d["user_id"] . "'");
     if ($db->f('num_rows') < 1) {
         // Insert Shopper -ShopperGroup - Relationship
         $q = "INSERT INTO #__{vm}_shopper_vendor_xref ";
         $q .= "(user_id,vendor_id,shopper_group_id,customer_number) ";
         $q .= "VALUES ('" . $d['user_id'] . "', '{$vendor_id}','" . $d['shopper_group_id'] . "', '" . $d['customer_number'] . "')";
     } else {
         // Update the Shopper Group Entry for this user
         $q = "UPDATE #__{vm}_shopper_vendor_xref SET ";
         $q .= "shopper_group_id='" . $d['shopper_group_id'] . "' ";
         $q .= ",vendor_id ='" . $vendor_id . "' ";
         $q .= "WHERE user_id='" . $d["user_id"] . "' ";
     }
     $db->query($q);
     $vmLogger->info($VM_LANG->_('VM_USER_UPDATED'));
     return True;
 }
Ejemplo n.º 16
0
    $old_user = '';
    if (!empty($user) && is_object($user)) {
        $old_user = $user;
    }
    $user = $dbbt->record[0];
    /** Retrieve Payment Info **/
    $dbpm = new ps_DB();
    $q = "SELECT * FROM `#__{vm}_payment_method` p, `#__{vm}_order_payment` op, `#__{vm}_orders` o ";
    $q .= "WHERE op.order_id='{$order_id}' ";
    $q .= "AND p.payment_method_id=op.payment_method_id ";
    $q .= "AND o.user_id='" . $auth["user_id"] . "' ";
    $q .= "AND o.order_id='{$order_id}' ";
    $dbpm->query($q);
    $dbpm->next_record();
    $registrationfields = ps_userfield::getUserFields('registration', false, '', true, true);
    $shippingfields = ps_userfield::getUserFields('shipping', false, '', true, true);
    $tpl->set('db', $db);
    $tpl->set('dbbt', $dbbt);
    $tpl->set('dbpm', $dbpm);
    $tpl->set('user', $user);
    $tpl->set('order_id', $order_id);
    $tpl->set('registrationfields', $registrationfields);
    $tpl->set('shippingfields', $shippingfields);
    $tpl->set('time_offset', $mosConfig_offset);
    // Get the template for this page
    echo $tpl->fetch('pages/account.order_details.tpl.php');
    if (!empty($old_user) && is_object($old_user)) {
        $user = $old_user;
    }
} else {
    vmRedirect($sess->url(SECUREURL . 'index.php?page=account.index'));
Ejemplo n.º 17
0
    $pathway[] = $vm_mainframe->vmPathwayItem($VM_LANG->_('PHPSHOP_SHOPPER_FORM_SHIPTO_LBL'));
} else {
    // We are in account maintenance
    $pathway[] = $vm_mainframe->vmPathwayItem($VM_LANG->_('PHPSHOP_ACCOUNT_TITLE'), $sess->url(SECUREURL . 'index.php?page=account.index'));
    $pathway[] = $vm_mainframe->vmPathwayItem($VM_LANG->_('PHPSHOP_USER_FORM_SHIPTO_LBL'), $sess->url(SECUREURL . "index.php?page={$next_page}"));
    $pathway[] = $vm_mainframe->vmPathwayItem($VM_LANG->_('PHPSHOP_SHOPPER_FORM_SHIPTO_LBL'));
}
$vm_mainframe->vmAppendPathway($pathway);
// Set the internal VirtueMart pathway
$tpl = vmTemplate::getInstance();
$tpl->set('pathway', $pathway);
$vmPathway = $tpl->fetch('common/pathway.tpl.php');
$tpl->set('vmPathway', $vmPathway);
$missing = vmGet($vars, 'missing');
if (!empty($missing)) {
    echo "<script type=\"text/javascript\">alert('" . $VM_LANG->_('CONTACT_FORM_NC', false) . "'); </script>\n";
}
$db = new ps_DB();
if (!empty($user_info_id)) {
    $q = "SELECT * from #__{vm}_user_info WHERE user_info_id='" . $database->getEscaped($user_info_id) . "' ";
    $q .= " AND user_id='" . $auth['user_id'] . "'";
    $q .= " AND address_type='ST'";
    $db->query($q);
    $db->next_record();
}
if (!$db->num_rows()) {
    $vars['country'] = vmGet($_REQUEST, 'country', $vendor_country);
}
$fields = ps_userfield::getUserFields('shipping');
$tpl->set_vars(array('next_page' => $next_page, 'fields' => $fields, 'missing' => $missing, 'vars' => $vars, 'db' => $db, 'user_info_id' => $user_info_id));
echo $tpl->fetch('pages/' . $page . '.tpl.php');