예제 #1
0
 function getOrderData($localid, $ind = 0)
 {
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'opctracking.php';
     $order_arr = array();
     $order_obj = new stdClass();
     OPCtrackingHelper::getOrderVars($localid, $order_arr, $order_obj);
     $order_data = array();
     $ind = '_' . $ind;
     foreach ($order_arr as $k => $d) {
         $order_data[$k . $ind] = $d;
     }
     $total = $order_arr['bt_order_total'];
     $order_data['order_total_floor' . $ind] = floor($total);
     $order_data['order_total_floortxt' . $ind] = $this->number2text(floor($total));
     $cents = round(($total - floor($total)) * 100);
     $order_data['order_total_cents' . $ind] = $cents;
     return $order_data;
     $this->number2text(555);
     $dbj = JFactory::getDBO();
     $order_id = $dbj->getEscaped($localid);
     //ernest get data
     $order_data = array();
     $fieldsOnly = false;
     if (!empty($localid)) {
         $q = "SELECT * FROM #__virtuemart_orders WHERE virtuemart_order_id='" . $order_id . "' LIMIT 0,1";
     } else {
         $fieldsOnly = true;
         $q = "SELECT * FROM #__virtuemart_orders WHERE 1 LIMIT 0,1";
     }
     $dbj->setQuery($q);
     // basic order data:
     $arr1 = $dbj->loadAssoc();
     if (!empty($arr1)) {
         $arr1['order_id'] = $arr1['virtuemart_order_id'];
         $arr1['user_id'] = $arr1['virtuemart_user_id'];
         foreach ($arr1 as $k => $d) {
             $order_data[$k . $ind] = $d;
         }
     }
     $total = $order_data['order_total' . $ind];
     $order_data['order_total_floor' . $ind] = floor($total);
     $order_data['order_total_floortxt' . $ind] = $this->number2text(floor($total));
     $cents = round(($total - floor($total)) * 100);
     $order_data['order_total_cents' . $ind] = $cents;
     $msg = $dbj->getErrorMsg();
     if (!empty($msg)) {
         echo $msg;
         die;
     }
     $order_id = $arr1['order_id'];
     $user_id = $arr1['user_id'];
     $qt = "SELECT * from #__virtuemart_order_userinfos WHERE virtuemart_user_id='{$user_id}' AND virtuemart_order_id='{$order_id}' AND address_type = 'BT' LIMIT 0,1";
     $dbj->setQuery($qt);
     // basic user data from order_info
     $bta = $dbj->loadAssoc();
     $msg = $dbj->getErrorMsg();
     if (!empty($msg)) {
         echo $msg;
         die;
     }
     if (!empty($bta)) {
         foreach ($bta as $key => $value) {
             $order_data['bt_' . $key . $ind] = $value;
         }
     }
     $qt = "SELECT * from #__virtuemart_order_userinfos WHERE virtuemart_user_id='{$user_id}' AND virtuemart_order_id='{$order_id}' AND address_type = 'ST' LIMIT 0,1";
     $dbj->setQuery($qt);
     $sta = $dbj->loadAssoc();
     $msg = $dbj->getErrorMsg();
     if (!empty($msg)) {
         echo $msg;
         die;
     }
     if (!empty($sta)) {
         //$arr1['ship_to_address'] = $sta;
         foreach ($sta as $key => $value) {
             //if (!$fieldsOnly)
             $order_data['st_' . $key . $ind] = $value;
             //else $order_data['st_'.$key.$ind] = $order_data['bt_'.$key.$ind];
         }
     } else {
         if (!empty($bta)) {
             foreach ($bta as $key => $value) {
                 //if (!$fieldsOnly)
                 $order_data['st_' . $key . $ind] = $value;
                 // else $order_data['st_'.$key.$ind] = 'EMPTY';
             }
         }
     }
     // ziskami polozky objednavky
     $qt = "SELECT * FROM `#__virtuemart_order_items` WHERE virtuemart_order_id='{$order_id}' ";
     $dbj->setQuery($qt);
     $prods = $dbj->loadAssocList();
     $msg = $dbj->getErrorMsg();
     if (!empty($msg)) {
         echo $msg;
         die;
     }
     if (!empty($prods)) {
         foreach ($prods as $ind2 => $prod) {
             foreach ($prod as $key => $value) {
                 // polozka bude vyzarat napr takto: ar1['order_item_name_0_0'] = 'nazov produktu'
                 if ($key != 'order_id') {
                     $order_data[$key . $ind . '_' . $ind2] = $value;
                 }
             }
         }
     }
     // ok, lets get payment information
     $q = "select * from `#__virtuemart_order_histories` where virtuemart_order_id = '" . $order_id . "' order by virtuemart_order_history_id desc ";
     $dbj->setQuery($q);
     $r = $dbj->loadAssocList();
     foreach ($r as $ind2 => $historyitem) {
         foreach ($historyitem as $key => $value) {
             // payment date here is in variable (last change):
             // date_added_0_0
             $order_data[$key . $ind . '_' . $ind2] = $value;
         }
     }
     $payment_id = $arr1['virtuemart_paymentmethod_id'];
     if (!empty($payment) || $payment === '0') {
         $order_data['payment_method_id_' . $ind2] = $payment;
         $q = "select * from #__virtuemart_paymentmethods where virtuemart_paymentmethod_id = '" . $payment . "' ";
         $dbj->setQuery($q);
         $r = $dbj->loadAssoc();
         if (!empty($r)) {
             foreach ($r as $key => $data) {
                 $order_data[$key . $ind] = $data;
             }
         }
     }
     if (!empty($order_data['vendor_id_0_0'])) {
         $this->getVendorInfo($order_data, $order_data['vendor_id_0_0'], $ind);
     } else {
         getVendorInfo($order_data, $ind);
     }
     return $order_data;
 }
예제 #2
0
 function runEucsv()
 {
     $x = @ob_get_clean();
     $x = @ob_get_clean();
     $x = @ob_get_clean();
     $x = @ob_get_clean();
     $x = @ob_get_clean();
     $x = @ob_get_clean();
     $x = @ob_get_clean();
     $x = @ob_get_clean();
     header('Content-Type: text/csv; charset=utf-8');
     header("Content-Disposition: attachment; filename=\"output.csv\";");
     $eu = array('AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV', 'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK');
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'opctracking.php';
     $array = array();
     $order = new stdClass();
     $db = JFactory::getDBO();
     // all orders:
     $q = 'select virtuemart_order_id from #__virtuemart_orders where 1 limit 999999';
     $db->setQuery($q);
     $res = $db->loadAssocList();
     $header = false;
     $ha = array();
     foreach ($res as $row) {
         $order_id = $row['virtuemart_order_id'];
         $array = array();
         $order = new stdClass();
         //OPCtrackingHelper::getOrderVars(11, $array, $order);
         //var_dump($array); die();
         OPCtrackingHelper::getOrderVars($order_id, $array, $order);
         if (!$header) {
             foreach ($array as $k2 => $c2) {
                 echo '"' . $k2 . '",';
                 $ha[$k2] = '';
             }
             echo '"is_eu",';
             echo "\r\n";
             $ha['is_eu'] = '';
             $header = true;
         }
         //var_dump($ha); die();
         $ha2 = $ha;
         foreach ($array as $k => $c) {
             //echo '"'.$c.'",'; //country_2_code
             if (array_key_exists($k, $ha)) {
                 $ha2[$k] = '"' . $c . '",';
             }
             if ($k == 'st_country_2_code') {
                 if (in_array($c, $eu)) {
                     $ha2['is_eu'] = '"X",';
                 } else {
                     $ha2['is_eu'] = ',';
                 }
             }
         }
         foreach ($ha2 as $val) {
             echo $val;
         }
         echo "\r\n";
     }
     die;
 }
예제 #3
0
 public static function updateHtml($html, &$order, $afterrender = false)
 {
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'config.php';
     $ty_page = OPCconfig::getValue('ty_page', 'ty_page', 0, array());
     if (empty($ty_page)) {
         return;
     }
     if (empty($order)) {
         return;
     }
     if (is_array($order)) {
         if (isset($order['details'])) {
             $order = $order['details']['BT'];
         }
     }
     //we must reload order here in case any plugin had changed it in meantime:
     $id = $order->virtuemart_order_id;
     if (!empty($id)) {
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
         $orderModel = OPCmini::getModel('orders');
         $order_full = $orderModel->getOrder($id);
         if (empty($order_full)) {
             return;
         }
         $order = $order_full['details']['BT'];
     }
     $status = $order->order_status;
     if (!is_object($order)) {
         return;
     }
     $payment_id = $order->virtuemart_paymentmethod_id;
     if (empty($order->order_language)) {
         $jlang = JFactory::getLanguage();
         $cl = $jlang->getTag();
         $cl = strtolower(str_replace('-', '_', $cl));
     } else {
         $cl = $order->order_language;
     }
     // check conditions:
     $orightml = $html;
     $todo = array();
     foreach ($ty_page as $k => $ty) {
         if (!is_object($ty)) {
             continue;
         }
         if ($ty->payment_id != $payment_id) {
             continue;
         }
         if (!empty($ty->language)) {
             if ($ty->language != $cl) {
                 continue;
             }
         }
         if ($ty->order_status != $status) {
             continue;
         }
         $todo[] = $ty;
     }
     if (empty($todo)) {
         return;
     }
     /*
     	  COM_ONEPAGE_TY_MODE_0="Prepend to payment generated html"
     COM_ONEPAGE_TY_MODE_1="Append to payment generated html"
     COM_ONEPAGE_TY_MODE_2="Replace payment generated html"
     */
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'loader.php';
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'opctracking.php';
     $repvals = array();
     $order_object = new stdClass();
     OPCtrackingHelper::getOrderVars($id, $repvals, $order_object, false);
     foreach ($todo as $ty2) {
         $htmla = OPCloader::getArticle($ty2->article_id, $repvals);
         if (empty($ty2->mode)) {
             $html = $htmla . '<br />' . $html;
         } else {
             if ($ty2->mode == 1) {
                 $html = $html . '<br />' . $htmla;
             } else {
                 if ($ty->mode == 2) {
                     $html = $htmla;
                 }
             }
         }
     }
     if (defined('TYMODDONE')) {
         return $html;
     } else {
         define('TYMODDONE', true);
     }
     if ($orightml != $html) {
         if (!$afterrender) {
             JRequest::setVar('html', $html);
         } else {
             $buffer = JResponse::getBody();
             $buffer = str_replace($orightml, $html, $buffer);
             JResponse::setBody($buffer);
         }
     }
     return $html;
 }
예제 #4
0
 function getOrderVars(&$named)
 {
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'opctracking.php';
     $array = array();
     $object = new stdClass();
     $named = array();
     OPCtrackingHelper::getOrderVars(0, $array, $object, false, $named);
     return $array;
 }