예제 #1
0
 function display($tpl = null)
 {
     // load language:
     $model = $this->getModel();
     $model->loadVirtuemart();
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_onepage' . DS . 'models' . DS . 'config.php';
     $config = new JModelConfig();
     $config->loadVmConfig();
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'listfactory.php';
     $this->statuses = $config->getOrderStatuses();
     // Get data from the model
     $pagination = $this->get('Pagination');
     $items = $this->get('Data');
     $total = $this->get('Total');
     $ehelper = new OnepageTemplateHelper();
     $templates = $ehelper->getExportTemplates('ALL');
     $templates = $model->getTemplates();
     //$order_data = $model->getOrderData();
     //$ehelper = new OnepageTemplateHelper($order_id);
     $this->assignRef('ehelper', $ehelper);
     $this->assignRef('templates', $templates);
     $this->assignRef('model', $model);
     // push data into the template
     $this->assignRef('items', $items);
     $this->assignRef('total', $total);
     $this->assignRef('pagination', $pagination);
     parent::display($tpl);
 }
예제 #2
0
 function template_update_upload()
 {
     require_once JPATH_COMPONENT . DS . 'assets' . DS . 'export_helper.php';
     jimport('joomla.filesystem.file');
     $file = "";
     $msg = '';
     foreach ($_FILES as $k => $v) {
         // $msg .= 'key: '.$k.'<br />';
         // $msg .= 'val: '.$v.'<br />';
         if (strpos($k, 'uploadedupdatefile_') !== false && !empty($_FILES[$k]['name'])) {
             $file = $k;
         }
     }
     $arr = explode('_', $file);
     if (count($arr) > 1) {
         $tid = $arr[1];
         if (!is_numeric($tid)) {
             return "Error!";
         }
         // get previous file
         $ehelper = new OnepageTemplateHelper();
         $tt = $ehelper->getTemplate($tid);
         $target_path = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_onepage' . DS . 'export' . DS . 'templates' . DS;
         $newname = JFile::makesafe(basename($_FILES['uploadedupdatefile_' . $tid]['name']));
         if (file_exists($target_path . $newname) && $tt['file'] != $newname) {
             $msg = 'Another theme is using the same filename';
         } else {
             if (file_exists($target_path . $tt['file'])) {
                 if (!JFile::delete($target_path . $tt['file'])) {
                     $msg .= 'Could not remove old template file: ' . $tt['file'] . '<br />';
                 }
             }
             $msg .= $ehelper->updateFileName($tid, $newname);
             if (!empty($msg)) {
                 //$userfile = JRequest::getVar('uploadedupdatefile_'.$tid, null, 'files');
                 //var_dump($userfile); die();
                 $target_path = $target_path . $newname;
                 //echo $target_path.'<br />'; var_dump($_FILES); die();
                 if (JFile::upload($_FILES[$file]['tmp_name'], $target_path)) {
                     $msg .= "The template file " . $newname . " has been uploaded";
                 } else {
                     $msg .= "There was an error uploading the file, please try again! file: " . $newname;
                 }
             }
         }
     }
     if (empty($msg)) {
         $msg = 'O.K.';
     }
     //JFile::delete($_FILES[$file]['tmp_name']);
     $link = 'index.php?option=com_onepage&view=order_export';
     $this->setRedirect($link, $msg);
     return $msg;
     //die('som tu');
 }
예제 #3
0
 function _buildQuery()
 {
     $ehelper = new OnepageTemplateHelper();
     if ($ehelper->columnExists('#__virtuemart_orders', 'track_num')) {
         $ups = 'o.track_num, ';
     } else {
         $ups = '';
     }
     $keyword = JRequest::getVar('keyword', '');
     $show = JRequest::getVar('show', '');
     $list = "SELECT o.virtuemart_order_id as order_id, o.order_status, o.order_pass, " . $ups . " o.order_number, o.created_on, o.modified_on, o.order_total, o.order_currency, o.virtuemart_user_id as user_id,";
     $list .= "u.first_name, u.last_name FROM #__virtuemart_orders as o LEFT JOIN #__virtuemart_order_userinfos as u ON o.virtuemart_order_id = u.virtuemart_order_id WHERE ";
     $count = "SELECT count(*) as num_rows FROM #__virtuemart_orders, #__virtuemart_order_userinfos WHERE ";
     $q = " u.address_type = 'BT' ";
     if (!empty($keyword)) {
         $q .= " AND (#__virtuemart_orders.order_id LIKE '%{$keyword}%' ";
         $q .= "OR #__virtuemart_orders.order_status LIKE '%{$keyword}%' ";
         $q .= "OR first_name LIKE '%{$keyword}%' ";
         $q .= "OR last_name LIKE '%{$keyword}%' ";
         $q .= "OR CONCAT(`first_name`, ' ', `last_name`) LIKE '%{$keyword}%' ";
         $q .= ") ";
     }
     if (!empty($show)) {
         $q .= " AND order_status = '{$show}'  ";
     }
     //	$q .= "(#__vm_orders.order_id=#__vm_order_user_info.order_id) ";
     //$q .= " o.vendor_id='".$_SESSION['ps_vendor_id']."' ";
     $q .= "ORDER BY o.created_on DESC ";
     $list .= $q;
     // . " LIMIT $limitstart, " . $limit;
     //$count .= $q;
     $query = $list;
     //.$limit;
     return $query;
     /*
          $this->_db->setQuery($query); 
     
          $this->_data = $this->_db->loadObjectList(); 
          $this->_total = count( $this->_data ) ; 
     */
 }
예제 #4
0
 function getOrderData()
 {
     $order_id = JRequest::getVar('order_id');
     if (empty($order_id)) {
         return "";
     }
     $ehelper = new OnepageTemplateHelper();
     return $ehelper->getOrderData($order_id);
 }
예제 #5
0
 function display($tpl = null)
 {
     //VM2 CODE HERE
     //Load helpers
     if (!class_exists('VmConfig')) {
         require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
     }
     VmConfig::loadConfig();
     if (!class_exists('CurrencyDisplay')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     if (!class_exists('VmHTML')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'html.php';
     }
     if (!class_exists('vmPSPlugin')) {
         require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
     }
     $orderStatusModel = VmModel::getModel('orderstatus');
     $orderStates = $orderStatusModel->getOrderStatusList();
     //$this->SetViewTitle( 'ORDER');
     $orderModel = VmModel::getModel('orders');
     $curTask = JRequest::getWord('task', 'edit');
     $lang = JFactory::getLanguage();
     $extension = 'com_onepage';
     $base_dir = JPATH_SITE;
     $language_tag = 'en-GB';
     $reload = true;
     $lang->load($extension, $base_dir);
     VmConfig::loadJLang('com_virtuemart');
     VmConfig::loadJLang('com_virtuemart_shoppers', TRUE);
     VmConfig::loadJLang('com_virtuemart_orders', true);
     // Load addl models
     $userFieldsModel = VmModel::getModel('userfields');
     $productModel = VmModel::getModel('product');
     // Get the data
     $virtuemart_order_id = JRequest::getInt('virtuemart_order_id', JRequest::getVar('order_id'));
     $order = $orderModel->getOrder($virtuemart_order_id);
     $_orderID = $order['details']['BT']->virtuemart_order_id;
     $orderbt = $order['details']['BT'];
     $orderst = array_key_exists('ST', $order['details']) ? $order['details']['ST'] : $orderbt;
     $orderbt->invoiceNumber = $orderModel->getInvoiceNumber($orderbt->virtuemart_order_id);
     $currency = CurrencyDisplay::getInstance('', $order['details']['BT']->virtuemart_vendor_id);
     $this->currency = $currency;
     $_userFields = $userFieldsModel->getUserFields('account', array('captcha' => true, 'delimiters' => true), array('delimiter_userinfo', 'user_is_vendor', 'username', 'password', 'password2', 'agreed', 'address_type'));
     $userfields = $userFieldsModel->getUserFieldsFilled($_userFields, $orderbt, 'BT_');
     $_userFields = $userFieldsModel->getUserFields('shipment', array(), array('delimiter_userinfo', 'username', 'email', 'password', 'password2', 'agreed', 'address_type'));
     $shipmentfields = $userFieldsModel->getUserFieldsFilled($_userFields, $orderst, 'ST_');
     // Create an array to allow orderlinestatuses to be translated
     // We'll probably want to put this somewhere in ShopFunctions...
     $_orderStatusList = array();
     foreach ($orderStates as $orderState) {
         //$_orderStatusList[$orderState->virtuemart_orderstate_id] = $orderState->order_status_name;
         //When I use update, I have to use this?
         $_orderStatusList[$orderState->order_status_code] = JText::_($orderState->order_status_name);
     }
     $_itemStatusUpdateFields = array();
     $_itemAttributesUpdateFields = array();
     foreach ($order['items'] as $_item) {
         $_itemStatusUpdateFields[$_item->virtuemart_order_item_id] = JHTML::_('select.genericlist', $orderStates, "item_id[" . $_item->virtuemart_order_item_id . "][order_status]", 'class="selectItemStatusCode"', 'order_status_code', 'order_status_name', $_item->order_status, 'order_item_status' . $_item->virtuemart_order_item_id, true);
     }
     if (!isset($_orderStatusList[$orderbt->order_status])) {
         if (empty($orderbt->order_status)) {
             $orderbt->order_status = 'unknown';
         }
         $_orderStatusList[$orderbt->order_status] = JText::_('COM_VIRTUEMART_UNKNOWN_ORDER_STATUS');
     }
     /* Assign the data */
     $this->assignRef('orderdetails', $order);
     $this->assignRef('orderID', $_orderID);
     $this->assignRef('userfields', $userfields);
     $this->assignRef('shipmentfields', $shipmentfields);
     $this->assignRef('orderstatuslist', $_orderStatusList);
     $this->assignRef('itemstatusupdatefields', $_itemStatusUpdateFields);
     $this->assignRef('itemattributesupdatefields', $_itemAttributesUpdateFields);
     $this->assignRef('orderbt', $orderbt);
     $this->assignRef('orderst', $orderst);
     $this->assignRef('virtuemart_shipmentmethod_id', $orderbt->virtuemart_shipmentmethod_id);
     /* Data for the Edit Status form popup */
     $_currentOrderStat = $order['details']['BT']->order_status;
     // used to update all item status in one time
     $_orderStatusSelect = JHTML::_('select.genericlist', $orderStates, 'order_status', '', 'order_status_code', 'order_status_name', $_currentOrderStat, 'order_items_status', true);
     $this->assignRef('orderStatSelect', $_orderStatusSelect);
     $this->assignRef('currentOrderStat', $_currentOrderStat);
     /* Toolbar */
     //JToolBarHelper::custom( 'prevItem', 'back','','COM_VIRTUEMART_ITEM_PREVIOUS',false);
     //JToolBarHelper::custom( 'nextItem', 'forward','','COM_VIRTUEMART_ITEM_NEXT',false);
     //JToolBarHelper::divider();
     //JToolBarHelper::custom( 'cancel', 'back','back','back',false,false);
     if (!class_exists('calculationHelper')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php';
     }
     $this->assignRef('orderstatuses', $orderStates);
     $model = VmModel::getModel('orders');
     $orderId = JRequest::getString('orderId', '');
     $orderLineItem = JRequest::getVar('orderLineId', '');
     $this->assignRef('virtuemart_order_id', $orderId);
     $this->assignRef('virtuemart_order_item_id', $orderLineItem);
     $orderItem = $model->getOrderLineDetails($orderId, $orderLineItem);
     $this->assignRef('orderitem', $orderItem);
     //END OF VM2CODE
     $order_id = JRequest::getInt('order_id');
     if (empty($order_id)) {
         die('Empty order id');
     }
     //$limit = JRequest::getVar('limit', $mainframe->getCfg('list_limit'));
     //limitstart = JRequest::getVar('limitstart', 0);
     $model = $this->getModel('order_details');
     $this->order = $model->getOrderVM2($order_id);
     $this->shippingmethods = $model->getShippingMethods($this->order);
     $this->payments = $model->getPaymentMethods($this->order);
     $this->next_order = $model->getNext($virtuemart_order_id);
     $this->prev_order = $model->getPrev($virtuemart_order_id);
     JPluginHelper::importPlugin('vmshipment');
     JPluginHelper::importPlugin('vmshopper');
     JPluginHelper::importPlugin('vmpayment');
     $ehelper = new OnepageTemplateHelper();
     $templates = $ehelper->getExportTemplates('ALL');
     $templates = $model->getTemplates();
     $order_data = $model->getOrderData();
     //$ehelper = new OnepageTemplateHelper($order_id);
     $this->assignRef('ehelper', $ehelper);
     $this->assignRef('templates', $templates);
     $this->assignRef('order_data', $order_data);
     jimport('joomla.html.pagination');
     parent::display($tpl);
 }
예제 #6
0
 function template_update_upload()
 {
     return false;
     jimport('joomla.filesystem.file');
     $file = "";
     $msg = '';
     foreach ($_FILES as $k => $v) {
         // $msg .= 'key: '.$k.'<br />';
         // $msg .= 'val: '.$v.'<br />';
         if (strpos($k, 'uploadedupdatefile_') !== false && !empty($_FILES[$k]['name'])) {
             $file = $k;
         }
     }
     $arr = explode('_', $file);
     if (count($arr) > 1) {
         $tid = $arr[1];
         if (!is_numeric($tid)) {
             return "Error!";
         }
         // get previous file
         $ehelper = new OnepageTemplateHelper();
         $tt = $ehelper->getTemplate($tid);
         $target_path = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_onepage' . DS . 'export' . DS;
         if (file_exists($target_path . $tt['file'])) {
             if (!JFile::delete($target_path . $tt['file'])) {
                 $msg .= 'Could not remove old template file: ' . $tt['file'];
             }
         }
         $newname = JFile::makesafe(basename($_FILES['uploadedupdatefile_' . $tid]['name']));
         $msg .= $ehelper->updateFileName($tid, $newname);
         //$userfile = JRequest::getVar('uploadedupdatefile_'.$tid, null, 'files');
         //var_dump($userfile); die();
         $target_path = $target_path . $newname;
         if (JFile::upload($_FILES[$file]['tmp_name'], $target_path)) {
             $msg .= "The template file " . $newname . " has been uploaded";
         } else {
             $msg .= "There was an error uploading the file, please try again! file: " . $newname;
         }
     } else {
         $msg .= "There was an error uploading the file, please try again! ";
     }
     return $msg;
 }
예제 #7
0
 function xmlexport()
 {
     $eu = JRequest::getVar('export_eu_csv');
     if (!empty($eu)) {
         $this->runEucsv();
         return;
     }
     $tid = JRequest::getInt('selected_tid');
     if (empty($tid)) {
         return;
     }
     $startdate = JRequest::getVar('startdateo');
     $enddate = JRequest::getVar('enddateo');
     $startid = JRequest::getVar('startid');
     $endid = JRequest::getVar('endid');
     if (!empty($startdate)) {
         $startdate = strtotime($startdate) == -1 ? '' : strtotime($startdate);
     }
     if (!empty($enddate)) {
         $enddate = strtotime($enddate) == -1 ? '' : strtotime($enddate);
     }
     $startdate = date("Y-m-d H:i:s", $startdate);
     if (!empty($startdate)) {
         $where = ' where o.created_on >= "' . $startdate . '" ';
     }
     if (!empty($enddate)) {
         $enddate = $enddate + 60 * 60 * 24 - 1;
         $enddate = date("Y-m-d H:i:s", $enddate);
         if (!empty($where)) {
             $where .= ' and ';
         } else {
             $where = ' where ';
         }
         $where .= ' o.created_on <= "' . $enddate . '" ';
     }
     $startid = JRequest::getVar('startid', '');
     $endid = JRequest::getVar('endid', '');
     if (!empty($startid)) {
         $where = ' where o.virtuemart_order_id >= ' . $startid . ' ';
     }
     if (!empty($endid)) {
         if (!empty($where)) {
             $where .= ' and ';
         } else {
             $where = ' where ';
         }
         $where .= ' o.virtuemart_order_id <= "' . $endid . '" ';
     }
     require_once JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_onepage' . DS . 'assets' . DS . 'export_helper.php';
     $ehelper = new OnepageTemplateHelper();
     $tt = $ehelper->getTemplate($tid);
     $q = 'select `virtuemart_order_id` from #__virtuemart_orders as o ' . $where;
     $db = JFactory::getDBO();
     $db->setQuery($q);
     ob_start();
     $arr = $db->loadAssocList();
     $e = $db->getErrorMsg();
     echo $e;
     /*
     var_dump($q); 
     var_dump($arr); die(); 
     */
     foreach ($arr as $k => $order_data) {
         $v = $order_data['virtuemart_order_id'];
         $ra = $ehelper->getOrderDataEx($tid, $v);
         $localid = $v;
         $ehelper->processTxtTemplate($tid, $v, $ra);
     }
     $msg = ob_get_clean();
     $option = JRequest::getVar('option');
     $mainframe = JFactory::getApplication();
     $limit = $mainframe->getUserStateFromRequest("{$option}.limit", 'limit', 50, 'int');
     $limitstart = $mainframe->getUserStateFromRequest("{$option}.limitstart", 'limitstart', 0, 'int');
     //var_dump($limit); var_dump($limitstart); die();
     $link = 'index.php?option=com_onepage&view=orders&limitstart=' . $limitstart . '&limit=' . $limit;
     $this->setRedirect($link);
     $this->setRedirect($link, $msg);
 }
예제 #8
0
 private function putfile()
 {
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_onepage' . DS . 'assets' . DS . 'export_helper.php';
     $ehelper = new OnepageTemplateHelper();
     // no direct access
     // POST: tid, localid, file, hash,
     $tid = JRequest::getVar('tid');
     $localid = JRequest::getVar('localid');
     //$ehelper->setStatus($tid, $localid, 'RECEIVING');
     $hash = JRequest::getVar('hash');
     $hash2 = $ehelper->getFileHash($tid);
     $eitem = $ehelper->getExportItem($tid, $localid);
     $tt = $ehelper->getTemplate($tid);
     jimport('joomla.filesystem.file');
     $tname = $tid;
     $tname = JFile::makesafe($tname);
     $ex = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_onepage' . DS . 'export' . DS;
     $exf = $ex . $tname;
     if (empty($_FILES)) {
         JFactory::getApplication()->close();
     }
     if (strtolower($hash) == $hash2 && is_numeric($tid)) {
         $ehelper->prepareDirectory($tid);
         // here we should have autoincrement value instead of order id=local id
         $fileName = $_FILES['file_contents']['name'];
         $fileTemp = $_FILES['file_contents']['tmp_name'];
         $num = $eitem['ai'];
         if (!isset($num)) {
             $num = $localid;
         } else {
             $num = $num;
         }
         if (is_numeric($num)) {
             $num = $ehelper->addZeros($num, 4);
         }
         $tn = JFile::makesafe($tt['tid_name']);
         $path = $exf . DS . $num . '_' . $tn . '.pdf';
         $path = $ehelper->getFileName2Save($tid, $localid);
         if (file_exists($path)) {
             $xt = rand();
             JFile::move($path, $path . '_history_' . $xt . '.bck');
             //JFile::delete($path);
         }
         if (!JFile::upload($fileTemp, $path)) {
             $ehelper->setStatus($tid, $localid, 'ERROR');
             echo 'Error saving file!';
             //JFile::write($exf.DS.'log'.DS.'log.txt', var_export($fileTemp, true));
         } else {
             //echo 'Saving data: '.$tid.' '.$localid.' '.$path;
             // here we can send it to a customer
             $tt = $ehelper->getTemplate($tid);
             if ($ehelper->getStatus($tid, $localid) == 'AUTOPROCESSING') {
                 if (!empty($tt['tid_autocreate']) && !empty($tt['tid_email'])) {
                     $ehelper->setStatus($tid, $localid, 'CREATED', urlencode($path));
                     ob_start();
                     $ehelper->sendMail($tid, $localid, false);
                     $x = ob_get_clean();
                     //JFile::write($exf.DS.'log'.DS.'log.txt', 'sending mail'.$x);
                     //$ehelper->syntaxError();
                 }
             }
             $ehelper->setStatus($tid, $localid, 'CREATED', urlencode($path));
             echo 'File Saved OK!';
         }
         //file_put_contents($exf.DS.$localid.'_'.$tname.'.pdf', $file);
         /*
         else
         {
          echo 'ERROR: Nothing to save!';
         }
         */
         JFactory::getApplication()->close();
     } else {
         JFile::write($exf . DS . 'log' . DS . 'log.txt', 'secret not equal');
         $ehelper->setStatus($tid, $localid, 'ERROR');
         echo 'Secret not equal !';
         JFactory::getApplication()->close();
     }
 }
예제 #9
0
 function ajax($terminate = true)
 {
     $x = @ob_get_clean();
     $x = @ob_get_clean();
     $x = @ob_get_clean();
     $x = @ob_get_clean();
     $x = @ob_get_clean();
     $x = @ob_get_clean();
     $cmd = JRequest::getVar('cmd', '');
     if (strtolower($cmd) == 'showfile') {
         $this->showFile();
     }
     if ($terminate) {
         echo 'Running AJAX...<br />';
     }
     $mainframe = JFactory::getApplication();
     echo 'Command: ' . $cmd . '<br />';
     if (strtolower($cmd) == 'sendxml') {
         $this->sendXml();
     }
     if (strtolower($cmd) == 'checkfile') {
         require_once JPATH_COMPONENT . DS . 'assets' . DS . 'export_helper.php';
         $ehelper = new OnepageTemplateHelper();
         $ehelper->checkFile();
     }
     if (strtolower($cmd) == 'sendxmlmulti') {
         $this->sendXmlMulti();
     }
     if (strtolower($cmd) == 'sendemail') {
         $this->sendMail();
     }
     if (strtolower($cmd) == 'updatejoomla') {
         $msg = $this->updateJoomla();
         echo $msg . '<br />';
         if (empty($msg)) {
             echo 'OK!<br/>';
         }
         return;
     }
     $mainframe = JFactory::getApplication();
     // echo JPATH_ADMINISTRATOR.DS.'components'.DS.'com_onepage'.DS.'views'.DS.'order_details'.DS.'tmpl'.DS.'ajax'.DS.'onepage_ajax.php';
     //echo '<br />'.$cmd;
     $fieldid = JRequest::getVar('fieldid', '');
     if ($terminate) {
         $mainframe->close();
         die;
     }
     if (strpos($fieldid, 'track_num') !== false) {
         $this->changeTrackNum($fieldid);
     }
     $order_id = JRequest::getVar('orderid', '');
     if (empty($order_id)) {
         echo 'Empty Order Id';
         if ($terminate) {
             $mainframe->close();
         }
     }
     $cmd = JRequest::getVar('cmd', '');
     if (!empty($cmd)) {
         $d = JRequest::get('post');
         $d['order_id'] = $order_id;
         $msg = '';
         ob_start();
         if (strtolower($cmd) == 'orderstatusset') {
             echo $this->orderstatusset();
             return;
         }
         if (strtolower($cmd) == 'orderitemstatusset') {
             $ps_order = new ps_order();
             $ret = $ps_order->order_status_update($d);
             if ($ret === true) {
                 $msg = '<br />Order Status Updated';
             } else {
                 $msg = '<br />Error Updating Order Status';
             }
             //var_dump($d);
             echo $msg;
             //die();
             return;
         }
         if (strtolower($cmd) == 'resendconfirm') {
             $this->resendconfirm();
             if ($terminate) {
                 $mainframe->close();
             }
         } else {
             //echo 'cmd:'.$cmd.'endcmd';
             //$cmd = '$this->'.$cmd.'()';
             $msg = '<br />Function: ' . $cmd . '<br />';
             $cmd = htmlspecialchars($cmd);
             if (!@eval('$ps_order_change->' . $cmd . '($d);')) {
                 $msg .= '<br />Error Calling Function !';
             }
         }
         if (method_exists($this, $cmd)) {
             $this->{$cmd}();
         }
         $xx = ob_get_clean();
         echo $msg . '<br />';
         $mainframe = JFactory::getApplication();
         if ($terminate) {
             $mainframe->close();
         }
     }
     //$t = @ob_get_clean();$t = @ob_get_clean(); $t = @ob_get_clean();$t = @ob_get_clean();$t = @ob_get_clean();
     //while (!@ob_get_clen()) {;}
     // unset($t);
     //echo 'ajax initialized';
     //  var q = '&id='+id+'&orig_val='+val+'&new_val='+element.value;
     $new_value = JRequest::getVar('newval', '');
     $orig_value = JRequest::getVar('origval', '');
     $orig_value = urldecode($orig_value);
     if ($orig_value == ' ') {
         $orig_value = '';
     }
     $id = JRequest::getVar('fieldid', '');
     $onlyOrder = JRequest::getVar('onlyorder', false);
     if (empty($id) || empty($order_id)) {
         echo 'Empty field id or order_id ' . $id . ' ' . $order_id . ' <br />';
         $mainframe = JFactory::getApplication();
         if ($terminate) {
             $mainframe->close();
         }
     }
     $db = JFactory::getDBO();
     $new_value = $db->getEscaped($new_value);
     //$orig_value = trim($db->getEscaped($orig_value));
     $id = $db->getEscaped($id);
     $order_id = urlencode($order_id);
     if (strpos($id, 'bt_') === 0 || strpos($id, 'st_') === 0) {
         if (substr($id, 0, 3) == 'st_') {
             $address_type = 'ST';
         } else {
             $address_type = 'BT';
         }
         //$id = str_replace('bt_', '', $id);
         $id = substr($id, 3);
         // lets get the right line in order_user_info
         $q = "select * from #__vm_order_user_info where order_id = '" . $order_id . "' and address_type = '" . $address_type . "' ";
         $db->setQuery($q);
         $res = $db->loadAssoc();
         if (!isset($res) && $address_type == 'ST') {
             // we don't have a shipping address created yet
             // let us create it
             $q = "select * from #__vm_order_user_info where order_id = '" . $order_id . "' and address_type='BT' ";
             $db->setQuery($q);
             $d1 = $db->loadAssoc();
             if (isset($d1)) {
                 $col1 = 'order_info_id, order_id';
                 // follows user_id
                 $col2 = 'user_info_id';
                 // follows user_id
                 $val1 = "NULL, '" . $order_id . "'";
                 $newid = md5(uniqid('VirtueMartIsCool'));
                 $val2 = "'" . $newid . "'";
                 foreach ($d1 as $key => $val) {
                     if ($key != 'order_info_id' && $key != 'order_id') {
                         if ($key == $id) {
                             $val = $new_value;
                         }
                         if ($key == 'address_type') {
                             $val = 'ST';
                         }
                         $col1 .= "," . $key . " ";
                         $col2 .= "," . $key . " ";
                         $val1 .= ",'" . $val . "' ";
                         $val2 .= ",'" . $val . "' ";
                     }
                 }
                 $q = 'insert into #__vm_order_user_info (' . $col1 . ') values (' . $val1 . ') ';
                 $db->setQuery($q);
                 $db->query();
                 echo 'Creating new shipping address<br />';
                 $msg = $db->getErrorMsg();
                 if (!empty($msg)) {
                     echo $msg;
                 }
                 $q = 'insert into #__vm_user_info (' . $col2 . ') values (' . $val2 . ') ';
                 $db->setQuery($q);
                 $db->query();
                 $msg = $db->getErrorMsg();
                 if (!empty($msg)) {
                     echo $msg;
                 }
                 echo 'New shipping address created<br />';
             }
         }
         $msg = $db->getErrorMsg();
         // echo 'right here<br />db:'.var_dump($res[$id]).'<br />orig:'.var_dump($orig_value);die();
         if (!empty($msg)) {
             echo $msg;
             die;
         }
         //echo $orig_value.'='.$res[$id];
         if (isset($res)) {
             if (isset($res[$id])) {
                 if (!($res[$id] == $orig_value)) {
                     echo 'Original value does not match new value!<br />';
                 }
                 $q = "update #__vm_order_user_info set " . $id . " = '" . $new_value . "' where order_info_id = '" . $res['order_info_id'] . "' limit 1";
                 $db->setQuery($q);
                 $db->query();
                 $msg = $db->getErrorMsg();
                 if (!empty($msg)) {
                     echo $msg;
                     die;
                 }
                 echo 'Order Info updated <br />';
             }
         }
         // we will not update other fields if we have onlyOrder here
         if ($onlyOrder === true) {
             $mainframe = JFactory::getApplication();
             if ($terminate) {
                 $mainframe->close();
             }
         }
         // lets get the right line in user_info table
         $q = "select * from #__vm_user_info where user_id = '" . $res['user_id'] . "' and address_type = '" . $address_type . "' and " . $id . " = '" . $db->getEscaped($orig_value) . "' limit 0,10";
         $db->setQuery($q);
         $res3 = $db->loadAssocList();
         $msg = $db->getErrorMsg();
         echo $msg;
         if (!isset($res3)) {
             echo 'Oginal value not found. Will not update VM User Data<br />';
         }
         if (isset($res3)) {
             foreach ($res3 as $res2) {
                 $q = "update #__vm_user_info set " . $id . " = '" . $new_value . "' where user_id = '" . $res['user_id'] . "' and address_type = '" . $address_type . "' limit 1";
                 $db->setQuery($q);
                 $db->query();
                 echo 'User Info updated <br />';
                 $msg = $db->getErrorMsg();
                 if (!empty($msg)) {
                     echo $msg;
                     die;
                 }
             }
         }
         // lets update jomla info, only if address type is BT
         if ($address_type == 'BT') {
             $q = 'select * from #__users where id = "' . $res['user_id'] . '" ';
             $db->setQuery($q);
             $data = $db->loadAssoc();
             if (!empty($data)) {
                 switch ($id) {
                     case 'user_email':
                         $email = $data['email'];
                         if ($email == $orig_value) {
                             if ($data['username'] == $orig_value) {
                                 $ins = ", username = '******' ";
                                 echo 'Joomla Username updated <br />';
                             } else {
                                 $ins = "";
                             }
                             $q = "update #__users set email = '" . $new_value . "' " . $ins . " where id = '" . $res['user_id'] . "' limit 1";
                             echo 'Joomla Email updated <br />';
                             $db->setQuery($q);
                             $db->query();
                             //echo 'jos_users updated <br />';
                             $msg = $db->getErrorMsg();
                             if (!empty($msg)) {
                                 echo $msg;
                                 die;
                             }
                         } else {
                             echo 'emails do not match<br />';
                         }
                         break;
                     case 'first_name':
                         $full_name = $data['name'];
                         if (strpos($full_name, $orig_value) !== false) {
                             $full_name = str_replace($orig_value, $new_value, $full_name);
                             $q = "update #__users set name = '" . $full_name . "' where id = '" . $res['user_id'] . "' limit 1";
                             echo 'Joomla Name field updated <br />';
                             $db->setQuery($q);
                             $db->query();
                             $msg = $db->getErrorMsg();
                             if (!empty($msg)) {
                                 echo $msg;
                                 die;
                             }
                         }
                         break;
                     case 'last_name':
                         $full_name = $data['name'];
                         if (strpos($full_name, $orig_value) !== false) {
                             $full_name = str_replace($orig_value, $new_value, $full_name);
                             $q = "update #__users set name = '" . $full_name . "' where id = '" . $res['user_id'] . "' limit 1";
                             echo 'Joomla Name field updated <br />';
                             $db->setQuery($q);
                             $db->query();
                             $msg = $db->getErrorMsg();
                             if (!empty($msg)) {
                                 echo $msg;
                                 die;
                             }
                         }
                         break;
                     default:
                         break;
                 }
             }
         }
         $q = "";
     }
     $mainframe = JFactory::getApplication();
     if ($terminate) {
         $mainframe->close();
     }
 }
예제 #10
0
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
//mm_showMyFileName( __FILE__ );
//global $page;
//, $ps_order_status;
$show = JRequest::getVar('show', '');
//$pageNav = new JPagination( $this->total, $limit_start, $limit );
$pageNav = $this->pagination;
//require_once( CLASSPATH . "htmlTools.class.php" );
$ehelper = new OnepageTemplateHelper();
$templates = $ehelper->getExportTemplates('ALL');
if (!empty($templates)) {
    ?>
<a href="#" style='float: right;' onclick="javascript:return opShow('mytmps');"><img src="/images/M_images/pdf_button.png" alt='Create' title='Create' /></a>
<div style="position: absolute; right: 20px; text-align: left; background-color: #CCCCCC; border: 1px solid; margin-top:30px; z-index: 99; display: none; clear: both;" id="mytmps">
<?php 
    foreach ($templates as $t) {
        //if (empty($t['tid_special'] || (!empty($t['tid_ai']) && ($t['tid_special']=='1') && ($t['tid_
        echo "<a style='float: left;' href='#' onclick='javascript:return op_runCmd(\"sendXmlMulti\", this);' id='createpdf_" . $t['tid'] . "' ><img src='/images/M_images/pdf_button.png' alt='Create " . $t['tid_name'] . "' title='Create " . $t['tid_name'] . "' />" . $t['tid_name'] . "</a><br style='clear: both;'/>";
    }
    ?>
</div><?php 
}
$listObj = new listFactory($this->pagination);
// end template export part