예제 #1
0
 public function xmlImportFileUpdate()
 {
     $currenttime = time();
     $xmlHelper = new xmlHelper();
     $db = JFactory::getDbo();
     $query = "SELECT * FROM " . $this->_table_prefix . "xml_import AS x " . "WHERE x.published=1 " . "AND x.auto_sync=1 " . "AND x.sync_on_request=0 " . "AND x.auto_sync_interval!=0 ";
     $db->setQuery($query);
     $importlist = $db->loadObjectlist();
     for ($i = 0; $i < count($importlist); $i++) {
         $db = JFactory::getDbo();
         $query = "SELECT * FROM " . $this->_table_prefix . "xml_import_log AS xl " . "WHERE xl.xmlimport_id = " . (int) $importlist[$i]->xmlimport_id . " " . "ORDER BY xl.xmlimport_date DESC ";
         $db->setQuery($query);
         $lastrs = $db->loadObject();
         if (count($lastrs) > 0) {
             $difftime = $currenttime - $lastrs->xmlimport_date;
             $hours = $difftime / (60 * 60);
             if ($importlist[$i]->auto_sync_interval < $hours) {
                 $xmlHelper->importXMLFile($lastrs->xmlimport_id);
             }
         }
     }
 }
예제 #2
0
 /**
  * Method to delete the records
  *
  * @access public
  * @return boolean
  */
 public function delete($cid = array())
 {
     $xmlhelper = new xmlHelper();
     if (count($cid)) {
         $cids = implode(',', $cid);
         for ($i = 0; $i < count($cid); $i++) {
             $result = $xmlhelper->getXMLExportInfo($cid[$i]);
             $rootpath = JPATH_COMPONENT_SITE . "/assets/xmlfile/export/" . $result->filename;
             if (is_file($rootpath)) {
                 unlink($rootpath);
             }
         }
         $query = 'DELETE FROM ' . $this->_table_prefix . 'xml_export_log ' . 'WHERE xmlexport_id IN (' . $cids . ')';
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         $query = 'DELETE FROM ' . $this->_table_prefix . 'xml_export_ipaddress ' . 'WHERE xmlexport_id IN (' . $cids . ')';
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         $query = 'DELETE FROM ' . $this->_table_prefix . 'xml_export ' . 'WHERE xmlexport_id IN (' . $cids . ')';
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
     }
     return true;
 }
예제 #3
0
    function setChildElement()
    {
        JHTMLBehavior::modal();
        $xmlhelper = new xmlHelper();
        $post = JRequest::get('post');
        $session = JFactory::getSession();
        $childelement = $session->get('childelement');
        $model = $this->getModel('xmlexport_detail');
        $resarray = array();
        $uarray = array();
        $columns = $xmlhelper->getSectionColumnList($post['section_type'], $post['parentsection']);
        for ($i = 0; $i < count($columns); $i++) {
            if (trim($post[$columns[$i]->Field]) != "") {
                $xmltag = str_replace(" ", "_", strtolower(trim($post[$columns[$i]->Field])));
                $uarray[] = $xmltag;
                $resarray[] = $columns[$i]->Field . "=" . $xmltag;
            }
        }
        $firstlen = count($uarray);
        $uarray1 = array_unique($uarray);
        sort($uarray1);
        $seclen = count($uarray1);
        if ($seclen != $firstlen) {
            echo $msg = JText::_('COM_REDSHOP_DUPLICATE_FIELDNAME');
            return;
        }
        $childelement[$post['parentsection']] = array($post['element_name'], implode(";", $resarray));
        $session->set('childelement', $childelement);
        ?>
	<script language="javascript">
		window.parent.SqueezeBox.close();
	</script>
<?php 
    }
예제 #4
0
 public function display($tpl = null)
 {
     global $context;
     $context = 'xmlexport_id';
     $option = JRequest::getVar('option');
     $layout = JRequest::getVar('layout');
     $xmlhelper = new xmlHelper();
     $session = JFactory::getSession();
     $childelement = $session->get('childelement');
     $document = JFactory::getDocument();
     $document->setTitle(JText::_('COM_REDSHOP_xmlexport'));
     $document->addScript('components/' . $option . '/assets/js/xmlfunc.js');
     $uri = JFactory::getURI();
     $lists = array();
     $colvalue = array();
     $model = $this->getModel();
     $detail = $this->get('data');
     $parentsection = JRequest::getVar('parentsection', '');
     $detail->section_type = JRequest::getVar('section_type', $detail->section_type);
     $isNew = $detail->xmlexport_id < 1;
     $text = $isNew ? JText::_('COM_REDSHOP_NEW') : JText::_('COM_REDSHOP_EDIT');
     JToolBarHelper::title(JText::_('COM_REDSHOP_XML_EXPORT_MANAGEMENT') . ': <small><small>[ ' . $text . ' ]</small></small>', 'redshop_export48');
     JToolBarHelper::custom('xmlexport', 'redshop_export32.png', JText::_('COM_REDSHOP_XML_EXPORT'), JText::_('COM_REDSHOP_XML_EXPORT'), false, false);
     JToolBarHelper::save();
     if ($isNew) {
         JToolBarHelper::cancel();
     } else {
         JToolBarHelper::cancel('cancel', JText::_('JTOOLBAR_CLOSE'));
     }
     $section_typelist = $xmlhelper->getSectionTypeList();
     $auto_sync_interval = $xmlhelper->getSynchIntervalList();
     $columns = $xmlhelper->getSectionColumnList($detail->section_type, $parentsection);
     $iparray = $xmlhelper->getXMLExportIpAddress($detail->xmlexport_id);
     $dbfield = "";
     $dbchildname = "";
     switch ($parentsection) {
         case "orderdetail":
         case "productdetail":
             if (isset($childelement[$parentsection])) {
                 $detail->element_name = $childelement[$parentsection][0];
                 $detail->xmlexport_filetag = $childelement[$parentsection][1];
             }
             $dbfield = $detail->xmlexport_filetag;
             $dbchildname = $detail->element_name;
             break;
         case "stockdetail":
             if (isset($childelement[$parentsection])) {
                 $detail->stock_element_name = $childelement[$parentsection][0];
                 $detail->xmlexport_stocktag = $childelement[$parentsection][1];
             }
             $dbfield = $detail->xmlexport_stocktag;
             $dbchildname = $detail->stock_element_name;
             break;
         case "billingdetail":
             if (isset($childelement[$parentsection])) {
                 $detail->billing_element_name = $childelement[$parentsection][0];
                 $detail->xmlexport_billingtag = $childelement[$parentsection][1];
             }
             $dbfield = $detail->xmlexport_billingtag;
             $dbchildname = $detail->billing_element_name;
             break;
         case "shippingdetail":
             if (isset($childelement[$parentsection])) {
                 $detail->shipping_element_name = $childelement[$parentsection][0];
                 $detail->xmlexport_shippingtag = $childelement[$parentsection][1];
             }
             $dbfield = $detail->xmlexport_shippingtag;
             $dbchildname = $detail->shipping_element_name;
             break;
         case "orderitem":
             if (isset($childelement[$parentsection])) {
                 $detail->orderitem_element_name = $childelement[$parentsection][0];
                 $detail->xmlexport_orderitemtag = $childelement[$parentsection][1];
             }
             $dbfield = $detail->xmlexport_orderitemtag;
             $dbchildname = $detail->orderitem_element_name;
             break;
         case "prdextrafield":
             if (isset($childelement[$parentsection])) {
                 $detail->prdextrafield_element_name = $childelement[$parentsection][0];
                 $detail->xmlexport_prdextrafieldtag = $childelement[$parentsection][1];
             }
             $dbfield = $detail->xmlexport_prdextrafieldtag;
             $dbchildname = $detail->prdextrafield_element_name;
             break;
     }
     for ($i = 0; $i < count($columns); $i++) {
         $tmpVal = $xmlhelper->getXMLFileTag($columns[$i]->Field, $dbfield);
         $colvalue[] = $tmpVal[0];
     }
     $lists['auto_sync'] = JHTML::_('select.booleanlist', 'auto_sync', 'class="inputbox" size="1"', $detail->auto_sync);
     $lists['sync_on_request'] = JHTML::_('select.booleanlist', 'sync_on_request', 'class="inputbox" size="1"', $detail->sync_on_request);
     $lists['section_type'] = JHTML::_('select.genericlist', $section_typelist, 'section_type', 'class="inputbox" size="1" onchange="setExportSectionType();" ', 'value', 'text', $detail->section_type);
     $lists['auto_sync_interval'] = JHTML::_('select.genericlist', $auto_sync_interval, 'auto_sync_interval', 'class="inputbox" size="1" ', 'value', 'text', $detail->auto_sync_interval);
     $lists['published'] = JHTML::_('select.booleanlist', 'xmlpublished', 'class="inputbox"', $detail->published);
     $lists['use_to_all_users'] = JHTML::_('select.booleanlist', 'use_to_all_users', 'class="inputbox"', $detail->use_to_all_users);
     $categoryData = $model->getCategoryList();
     $detail->xmlexport_on_category = explode(',', $detail->xmlexport_on_category);
     $lists['xmlexport_on_category'] = JHTML::_('select.genericlist', $categoryData, 'xmlexport_on_category[]', 'class="inputbox" multiple="multiple" ', 'value', 'text', $detail->xmlexport_on_category);
     if ($layout != "") {
         $this->setlayout($layout);
     } else {
         $this->setlayout("default");
     }
     $this->lists = $lists;
     $this->detail = $detail;
     $this->columns = $columns;
     $this->colvalue = $colvalue;
     $this->childname = $dbchildname;
     $this->iparray = $iparray;
     $this->request_url = $uri->toString();
     parent::display($tpl);
 }
예제 #5
0
 public function display($tpl = null)
 {
     $option = JRequest::getVar('option');
     $xmlhelper = new xmlHelper();
     $document = JFactory::getDocument();
     $document->setTitle(JText::_('COM_REDSHOP_xmlimport'));
     $document->addScript('components/' . $option . '/assets/js/xmlfunc.js');
     $uri = JFactory::getURI();
     $lists = array();
     $resultarray = array();
     $xmlfiletag = array();
     $xmlbillingtag = array();
     $xmlshippingtag = array();
     $xmlitemtag = array();
     $xmlstocktag = array();
     $xmlprdextrafieldtag = array();
     $updatefiletag = array();
     $updatebillingtag = array();
     $updateshippinhtag = array();
     $updateprdexttag = array();
     $updateitemtag = array();
     $updatestocktag = array();
     $model = $this->getModel();
     $detail = $this->get('data');
     $detail->section_type = JRequest::getVar('section_type', $detail->section_type);
     $xmlimport_url = $model->updateFile();
     $detail->xmlimport_url = $model->getXMLImporturl();
     $isNew = $detail->xmlimport_id < 1;
     $text = $isNew ? JText::_('COM_REDSHOP_NEW') : JText::_('COM_REDSHOP_EDIT');
     JToolBarHelper::title(JText::_('COM_REDSHOP_XML_IMPORT_MANAGEMENT') . ': <small><small>[ ' . $text . ' ]</small></small>', 'redshop_import48');
     JToolBarHelper::custom('xmlimport', 'redshop_import_import32.png', JText::_('COM_REDSHOP_XML_IMPORT'), JText::_('COM_REDSHOP_XML_IMPORT'), false, false);
     JToolBarHelper::save();
     if ($isNew) {
         JToolBarHelper::cancel();
     } else {
         JToolBarHelper::cancel('cancel', JText::_('JTOOLBAR_CLOSE'));
     }
     $section_type = $xmlhelper->getSectionTypeList();
     $auto_sync_interval = $xmlhelper->getSynchIntervalList();
     $lists['auto_sync'] = JHTML::_('select.booleanlist', 'auto_sync', 'class="inputbox" size="1"', $detail->auto_sync);
     $lists['sync_on_request'] = JHTML::_('select.booleanlist', 'sync_on_request', 'class="inputbox" size="1"', $detail->sync_on_request);
     $lists['auto_sync_interval'] = JHTML::_('select.genericlist', $auto_sync_interval, 'auto_sync_interval', 'class="inputbox" size="1" ', 'value', 'text', $detail->auto_sync_interval);
     $lists['override_existing'] = JHTML::_('select.booleanlist', 'override_existing', 'class="inputbox" size="1"', $detail->override_existing);
     $lists['xmlpublished'] = JHTML::_('select.booleanlist', 'xmlpublished', 'class="inputbox"', $detail->published);
     if ($xmlimport_url != "") {
         $filedetail = $xmlhelper->readXMLImportFile($xmlimport_url, $detail);
         $xmlfiletag = $filedetail['xmlsectionarray'];
         $xmlbillingtag = $filedetail['xmlbillingarray'];
         $xmlshippingtag = $filedetail['xmlshippingarray'];
         $xmlitemtag = $filedetail['xmlorderitemarray'];
         $xmlstocktag = $filedetail['xmlstockarray'];
         $xmlprdextrafieldtag = $filedetail['xmlprdextarray'];
     }
     $lists['section_type'] = JHTML::_('select.genericlist', $section_type, 'section_type', 'class="inputbox" size="1" onchange="setExportSectionType();" ', 'value', 'text', $detail->section_type);
     if ($detail->section_type != "") {
         $cols = array();
         $columns = $xmlhelper->getSectionColumnList($detail->section_type);
         for ($i = 0; $i < count($columns); $i++) {
             $cols[$i]->value = $columns[$i]->Field;
             $cols[$i]->text = $columns[$i]->Field;
         }
         $op = array();
         $op[0]->value = '';
         $op[0]->text = JText::_('COM_REDSHOP_SELECT');
         $columns = array_merge($op, $cols);
         for ($i = 0; $i < count($xmlfiletag); $i++) {
             $colvalue = $xmlhelper->getXMLFileTag($xmlfiletag[$i], $detail->xmlimport_filetag);
             $updatefiletag[$i] = $colvalue[1];
             $lists[$xmlfiletag[$i]] = JHTML::_('select.genericlist', $columns, $xmlfiletag[$i], 'class="inputbox" size="1" ', 'value', 'text', $colvalue[0]);
         }
         if (count($xmlbillingtag) > 0) {
             $cols = array();
             $columns = $xmlhelper->getSectionColumnList($detail->section_type, "billingdetail");
             for ($i = 0; $i < count($columns); $i++) {
                 $cols[$i]->value = $columns[$i]->Field;
                 $cols[$i]->text = $columns[$i]->Field;
             }
             $columns = array_merge($op, $cols);
             for ($i = 0; $i < count($xmlbillingtag); $i++) {
                 $colvalue = $xmlhelper->getXMLFileTag($xmlbillingtag[$i], $detail->xmlimport_billingtag);
                 $updatebillingtag[$i] = $colvalue[1];
                 $lists["bill_" . $xmlbillingtag[$i]] = JHTML::_('select.genericlist', $columns, "bill_" . $xmlbillingtag[$i], 'class="inputbox" size="1" ', 'value', 'text', $colvalue[0]);
             }
         }
         if (count($xmlshippingtag) > 0) {
             $cols = array();
             $columns = $xmlhelper->getSectionColumnList($detail->section_type, "shippingdetail");
             for ($i = 0; $i < count($columns); $i++) {
                 $cols[$i]->value = $columns[$i]->Field;
                 $cols[$i]->text = $columns[$i]->Field;
             }
             $columns = array_merge($op, $cols);
             for ($i = 0; $i < count($xmlshippingtag); $i++) {
                 $colvalue = $xmlhelper->getXMLFileTag($xmlshippingtag[$i], $detail->xmlimport_shippingtag);
                 $updateshippingtag[$i] = $colvalue[1];
                 $lists["shipp_" . $xmlshippingtag[$i]] = JHTML::_('select.genericlist', $columns, "shipp_" . $xmlshippingtag[$i], 'class="inputbox" size="1" ', 'value', 'text', $colvalue[0]);
             }
         }
         if (count($xmlitemtag) > 0) {
             $cols = array();
             $columns = $xmlhelper->getSectionColumnList($detail->section_type, "orderitem");
             for ($i = 0; $i < count($columns); $i++) {
                 $cols[$i]->value = $columns[$i]->Field;
                 $cols[$i]->text = $columns[$i]->Field;
             }
             $columns = array_merge($op, $cols);
             for ($i = 0; $i < count($xmlitemtag); $i++) {
                 $colvalue = $xmlhelper->getXMLFileTag($xmlitemtag[$i], $detail->xmlimport_orderitemtag);
                 $updateitemtag[$i] = $colvalue[1];
                 $lists["item_" . $xmlitemtag[$i]] = JHTML::_('select.genericlist', $columns, "item_" . $xmlitemtag[$i], 'class="inputbox" size="1" ', 'value', 'text', $colvalue[0]);
             }
         }
         if (count($xmlstocktag) > 0) {
             $cols = array();
             $columns = $xmlhelper->getSectionColumnList($detail->section_type, "stockdetail");
             for ($i = 0; $i < count($columns); $i++) {
                 $cols[$i]->value = $columns[$i]->Field;
                 $cols[$i]->text = $columns[$i]->Field;
             }
             $columns = array_merge($op, $cols);
             for ($i = 0; $i < count($xmlstocktag); $i++) {
                 $colvalue = $xmlhelper->getXMLFileTag($xmlstocktag[$i], $detail->xmlimport_stocktag);
                 $updatestocktag[$i] = $colvalue[1];
                 $lists["stock_" . $xmlstocktag[$i]] = JHTML::_('select.genericlist', $columns, "stock_" . $xmlstocktag[$i], 'class="inputbox" size="1" ', 'value', 'text', $colvalue[0]);
             }
         }
         if (count($xmlprdextrafieldtag) > 0) {
             $cols = array();
             $columns = $xmlhelper->getSectionColumnList($detail->section_type, "prdextrafield");
             for ($i = 0; $i < count($columns); $i++) {
                 $cols[$i]->value = $columns[$i]->Field;
                 $cols[$i]->text = $columns[$i]->Field;
             }
             $columns = array_merge($op, $cols);
             for ($i = 0; $i < count($xmlprdextrafieldtag); $i++) {
                 $colvalue = $xmlhelper->getXMLFileTag($xmlprdextrafieldtag[$i], $detail->xmlimport_prdextrafieldtag);
                 $updateprdexttag[$i] = $colvalue[1];
                 $lists["prdext_" . $xmlprdextrafieldtag[$i]] = JHTML::_('select.genericlist', $columns, "prdext_" . $xmlprdextrafieldtag[$i], 'class="inputbox" size="1" ', 'value', 'text', $colvalue[0]);
             }
         }
     }
     $this->resultarray = $resultarray;
     $this->lists = $lists;
     $this->detail = $detail;
     $this->columns = $columns;
     $this->xmlfiletag = $xmlfiletag;
     $this->xmlbillingtag = $xmlbillingtag;
     $this->xmlshippingtag = $xmlshippingtag;
     $this->xmlitemtag = $xmlitemtag;
     $this->xmlstocktag = $xmlstocktag;
     $this->xmlprdextrafieldtag = $xmlprdextrafieldtag;
     $this->updatefiletag = $updatefiletag;
     $this->updatebillingtag = $updatebillingtag;
     $this->updateshippingtag = $updateshippingtag;
     $this->updateitemtag = $updateitemtag;
     $this->updatestocktag = $updatestocktag;
     $this->updateprdexttag = $updateprdexttag;
     $this->tmpxmlimport_url = $xmlimport_url;
     $this->request_url = $uri->toString();
     parent::display($tpl);
 }
예제 #6
0
 /**
  * Generate XML file.
  *
  * @return void
  */
 public function generateXMLExportFile()
 {
     $app = JFactory::getApplication();
     $option = JRequest::getVar('option', 'com_redshop', 'request', 'string');
     $xmlexport_id = JRequest::getInt('xmlexport_id');
     if ($xmlexport_id) {
         require_once JPATH_ADMINISTRATOR . '/components/com_redshop/helpers/xmlhelper.php';
         $xmlHelper = new xmlHelper();
         $xmlHelper->writeXMLExportFile($xmlexport_id);
         $row = $xmlHelper->getXMLExportInfo($xmlexport_id);
         $link = JURI::root() . 'index.php?option=com_redshop&view=category&tmpl=component&task=download&file=' . $row->filename;
         $app->redirect($link);
     }
 }