function init($ref)
 {
     mslib_fe::init($ref);
     $this->initLanguage($ref->LOCAL_LANG);
     static $installedPaymentMethods;
     // custom hook for loading the installed payment methods
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_payment.php']['mslib_payment'])) {
         $params = array('installedPaymentMethods' => &$installedPaymentMethods);
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_payment.php']['mslib_payment'] as $funcRef) {
             \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $ref);
         }
     }
     // custom hook for manipulating the installed payment methods
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_payment.php']['mslib_paymentPostProc'])) {
         $params = array('installedPaymentMethods' => &$installedPaymentMethods);
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_payment.php']['mslib_paymentPostProc'] as $funcRef) {
             \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $ref);
         }
     }
     $this->installedPaymentMethods = $params['installedPaymentMethods'];
     // custom hook for loading the installed payment methods eof
     // load enabled payment methods
     $filter = array();
     if (!$include_hidden_items) {
         $filter[] = 's.status=1';
     }
     $filter[] = 'd.language_id=\'' . $this->sys_language_uid . '\'';
     $filter[] = 's.id=d.id';
     $filter[] = '(s.page_uid=' . $this->shop_pid . ' or s.page_uid=0)';
     $str = $GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_multishop_payment_methods s, tx_multishop_payment_methods_description d', implode(' AND ', $filter), '', 's.sort_order', '');
     $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
     if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry)) {
         $array = array();
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) {
             $array[$row['code']] = $row;
         }
         $this->enabledPaymentMethods = $array;
     }
     // load enabled payment methods eof
 }
    function renderInterface($params, &$that)
    {
        mslib_fe::init($that);
        //hook to let other plugins further manipulate the method
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/class.tx_mslib_admin_interface.php']['renderInterfacePreProc'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/class.tx_mslib_admin_interface.php']['renderInterfacePreProc'] as $funcRef) {
                \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this);
            }
        }
        // for pagination
        $this->get = $that->get;
        $this->post = $that->post;
        if ($this->post) {
            if ($params['postErno']) {
                if (count($params['postErno'])) {
                    $returnMarkup = '
                    <div style="display:none" id="msAdminPostMessage">
                    <table class="table table-striped table-bordered">
                    <thead>
                    <tr>
                        <th class="text-center">Status</th>
                        <th>Message</th>
                    </tr>
                    </thead>
                    <tbody>
                    ';
                    foreach ($params['postErno'] as $item) {
                        switch ($item['status']) {
                            case 'error':
                                $item['status'] = '<span class="fa-stack text-danger"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-thumbs-down fa-stack-1x fa-inverse"></i></span>';
                                break;
                            case 'info':
                                $item['status'] = '<span class="fa-stack"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-thumbs-up fa-stack-1x fa-inverse"></i></span>';
                                break;
                        }
                        $returnMarkup .= '<tr><td class="text-center">' . $item['status'] . '</td><td>' . $item['message'] . '</td></tr>' . "\n";
                    }
                    $returnMarkup .= '</tbody></table></div>';
                    $tableContent .= $returnMarkup;
                    $GLOBALS['TSFE']->additionalHeaderData[] = '<script type="text/javascript" data-ignore="1">
                    jQuery(document).ready(function ($) {
                        $.confirm({
                            title: \'\',
                            content: $(\'#msAdminPostMessage\').html()
                        });
                    });
                    </script>
                    ';
                }
            }
        }
        $updateCookie = 0;
        if ($that->get['Search'] and $that->get['limit'] != $that->cookie['limit']) {
            $that->cookie['limit'] = $that->get['limit'];
            $updateCookie = 1;
        }
        if ($that->get['Search'] and $that->get['display_all_records'] != $that->cookie['display_all_records']) {
            $that->cookie['display_all_records'] = $that->get['display_all_records'];
            $updateCookie = 1;
        }
        if ($updateCookie) {
            $GLOBALS['TSFE']->fe_user->setKey('ses', 'tx_multishop_cookie', $that->cookie);
            $GLOBALS['TSFE']->storeSessionData();
        }
        if ($that->cookie['display_all_records']) {
            $that->get['display_all_records'] = $that->cookie['display_all_records'];
        } else {
            $that->get['display_all_records'] = '';
        }
        if ($that->cookie['limit']) {
            $that->get['limit'] = $that->cookie['limit'];
        } else {
            $that->get['limit'] = 50;
        }
        $that->ms['MODULES']['PAGESET_LIMIT'] = $that->get['limit'];
        if ($params['settings']['limit'] && is_numeric($params['settings']['limit'])) {
            $that->ms['MODULES']['PAGESET_LIMIT'] = $params['settings']['limit'];
        }
        if (is_numeric($that->get['p'])) {
            $p = $that->get['p'];
        }
        $that->searchKeywords = array();
        if ($that->get['tx_multishop_pi1']['keyword']) {
            //  using $_REQUEST cause TYPO3 converts "Command & Conquer" to "Conquer" (the & sign sucks ass)
            $that->get['tx_multishop_pi1']['keyword'] = trim($that->get['tx_multishop_pi1']['keyword']);
            $that->get['tx_multishop_pi1']['keyword'] = $GLOBALS['TSFE']->csConvObj->utf8_encode($that->get['tx_multishop_pi1']['keyword'], $GLOBALS['TSFE']->metaCharset);
            $that->get['tx_multishop_pi1']['keyword'] = $GLOBALS['TSFE']->csConvObj->entities_to_utf8($that->get['tx_multishop_pi1']['keyword'], true);
            $that->get['tx_multishop_pi1']['keyword'] = mslib_fe::RemoveXSS($that->get['tx_multishop_pi1']['keyword']);
            $that->searchKeywords[] = $that->get['tx_multishop_pi1']['keyword'];
            $that->searchMode = '%keyword%';
        }
        $limit_search_result_selectbox = '<select name="limit" class="form-control">';
        $limits = array();
        $limits[] = '10';
        $limits[] = '15';
        $limits[] = '20';
        $limits[] = '25';
        $limits[] = '30';
        $limits[] = '40';
        $limits[] = '50';
        $limits[] = '100';
        $limits[] = '150';
        $limits[] = '200';
        $limits[] = '250';
        $limits[] = '300';
        $limits[] = '350';
        $limits[] = '400';
        $limits[] = '450';
        $limits[] = '500';
        $limits[] = '600';
        $limits[] = '700';
        $limits[] = '800';
        $limits[] = '900';
        $limits[] = '1000';
        $limits[] = '1500';
        $limits[] = '2000';
        $limits[] = '2500';
        $limits[] = '3000';
        $limits[] = '3500';
        foreach ($limits as $limit) {
            $limit_search_result_selectbox .= '<option value="' . $limit . '"' . ($limit == $that->get['limit'] ? ' selected="selected"' : '') . '>' . $limit . '</option>';
        }
        $limit_search_result_selectbox .= '</select>';
        $queryData = array();
        $queryData['where'] = array();
        if (count($that->searchKeywords)) {
            $keywordOr = array();
            $that->searchMode = '%keyword%';
            foreach ($that->searchKeywords as $searchKeyword) {
                if ($searchKeyword) {
                    switch ($that->searchMode) {
                        case 'keyword%':
                            $that->sqlKeyword = addslashes($searchKeyword) . '%';
                            break;
                        case '%keyword%':
                        default:
                            $that->sqlKeyword = '%' . addslashes($searchKeyword) . '%';
                            break;
                    }
                    if (is_array($params['query']['keywordSearchByColumns']) && count($params['query']['keywordSearchByColumns'])) {
                        foreach ($params['query']['keywordSearchByColumns'] as $col) {
                            $keywordOr[] = $col . " like '" . $that->sqlKeyword . "'";
                        }
                    }
                }
            }
            if (is_array($keywordOr) && count($keywordOr)) {
                $queryData['where'][] = "(" . implode(" OR ", $keywordOr) . ")";
            }
        }
        if ($params['query']['where']) {
            if (is_array($params['query']['where'])) {
                $queryData['where'] = array_merge(array_values($queryData['where']), array_values($params['query']['where']));
            } else {
                $queryData['where'][] = $params['query']['where'];
            }
        }
        switch ($that->get['tx_multishop_pi1']['order_by']) {
            default:
                if (is_array($params['query']['defaultOrderByColumns']) && count($params['query']['defaultOrderByColumns'])) {
                    $order_by = implode(',', $params['query']['defaultOrderByColumns']);
                }
                break;
        }
        switch ($that->get['tx_multishop_pi1']['order']) {
            case 'a':
                $order = 'asc';
                $order_link = 'd';
                break;
            case 'd':
                $order = 'desc';
                $order_link = 'a';
                break;
            default:
                if ($params['query']['defaultOrder'] == 'asc') {
                    $order = 'asc';
                    $order_link = 'd';
                } else {
                    $order = 'desc';
                    $order_link = 'a';
                }
                break;
        }
        $orderby[] = $order_by . ' ' . $order;
        if (is_array($params['query']['select'])) {
            $queryData['select'] = implode(',', $params['query']['select']);
        } else {
            $queryData['select'] = $params['query']['select'];
        }
        if (is_array($params['query']['from'])) {
            $queryData['from'] = implode(',', $params['query']['from']);
        } else {
            $queryData['from'] = $params['query']['from'];
        }
        if (is_array($params['query']['group_by'])) {
            $queryData['group_by'] = implode(',', $params['query']['group_by']);
        } elseif ($params['query']['group_by']) {
            $queryData['group_by'][] = $params['query']['group_by'];
        }
        if (is_array($params['query']['having'])) {
            $queryData['having'] = $params['query']['having'];
        } elseif ($params['query']['having']) {
            $queryData['having'][] = $params['query']['having'];
        }
        $queryData['order_by'] = $orderby;
        $queryData['limit'] = $that->ms['MODULES']['PAGESET_LIMIT'];
        if (is_numeric($that->get['p'])) {
            $p = $that->get['p'];
        }
        if ($p > 0) {
            $queryData['offset'] = $p * $that->ms['MODULES']['PAGESET_LIMIT'];
        } else {
            $p = 0;
            $queryData['offset'] = 0;
        }
        if ($params['msDebug']) {
            $this->msDebug = 1;
        }
        //$this->msDebug=1;
        //echo print_r($queryData);
        //die();
        $pageset = mslib_fe::getRecordsPageSet($queryData);
        if ($this->msDebug) {
            echo $this->msDebugInfo;
            die;
        }
        if ($params['returnResultsSet']) {
            return $pageset;
        }
        //echo print_r($queryData);
        //die();
        if (count($pageset['dataset'])) {
            $tr_type = 'even';
            if (!$params['settings']['disableForm']) {
                $tableContent .= '<form method="post" action="' . $params['postForm']['actionUrl'] . '" enctype="multipart/form-data">';
            }
            $tableContent .= '<div class="table-responsive">';
            $tableContent .= '<table class="table table-striped table-bordered" id="msAdminTableInterface">';
            $tableContent .= '<tr><thead>';
            if ($params['settings']['enableRowBasedCheckboxSelection']) {
                $headerData = '';
                $headerData .= '
				<script type="text/javascript">
					jQuery(document).ready(function($) {
						$(\'#check_all_1\').click(function(){
							$(\'td > div.checkbox > input:checkbox\').prop(\'checked\', this.checked);
						});
					});
				</script>';
                $GLOBALS['TSFE']->additionalHeaderData[] = $headerData;
                $headerData = '';
                $tableContent .= '
				<th class="cellCheckbox">
					<div class="checkbox checkbox-success checkbox-inline">
					<input type="checkbox" id="check_all_1">
					<label for="check_all_1"></label>
					</div>
				</th>';
            }
            foreach ($params['tableColumns'] as $col => $valArray) {
                $tdClass = array();
                if ($valArray['align']) {
                    $tdClass[] = 'text-' . $valArray['align'];
                }
                if ($valArray['nowrap']) {
                    $tdClass[] = 'cellNoWrap';
                }
                if ($valArray['class']) {
                    $tdClass[] = $valArray['class'];
                }
                $tableContent .= '<th' . (count($tdClass) ? ' class="' . implode(' ', $tdClass) . '"' : '') . '>' . $valArray['title'] . '</th>';
            }
            $tableContent .= '</thead></tr><tbody>';
            $summarize = array();
            $recordCounter = 0;
            foreach ($pageset['dataset'] as $rowKey => $row) {
                $recordCounter++;
                if (!$tr_type or $tr_type == 'even') {
                    $tr_type = 'odd';
                } else {
                    $tr_type = 'even';
                }
                $tableContent .= '<tr class="' . $tr_type . '">';
                if ($params['settings']['enableRowBasedCheckboxSelection'] && $params['settings']['rowBasedCheckboxSelectionKey']) {
                    $headerData = '';
                    $headerData .= '
					<script type="text/javascript">
						jQuery(document).ready(function($) {
							$(\'#check_all_1\').click(function(){
								$(\'td > div.checkbox > input:checkbox\').prop(\'checked\', this.checked);
							});
						});
					</script>';
                    $GLOBALS['TSFE']->additionalHeaderData[] = $headerData;
                    $headerData = '';
                    $tableContent .= '<td class="cellCheckbox">
						<div class="checkbox checkbox-success checkbox-inline">
							<input type="checkbox" name="tx_multishop_pi1[tableOverviewSelection][]" id="tableOverviewSelectionCheckbox_' . $row[$params['settings']['rowBasedCheckboxSelectionKey']] . '" value="' . htmlspecialchars($row[$params['settings']['rowBasedCheckboxSelectionKey']]) . '">
							<label for="tableOverviewSelectionCheckbox_' . $row[$params['settings']['rowBasedCheckboxSelectionKey']] . '"></label>
						</div>
					</td>';
                }
                foreach ($params['tableColumns'] as $col => $valArray) {
                    $originalValue = $row[$col];
                    switch ($valArray['valueType']) {
                        case 'number_format_2_decimals':
                            $row[$col] = round(number_format($row[$col], 2, '.', ''), 2);
                            $summarize[$col] += $row[$col];
                            break;
                        case 'number_format_thousand_seperator':
                            $row[$col] = round(number_format($row[$col], 2, '.', ''), 2);
                            break;
                        case 'recordCounter':
                            $row[$col] = $recordCounter;
                            break;
                        case 'download_invoice':
                            $row[$col] = '<a href="uploads/tx_multishopexactonline/' . $row[$col] . '" target="_blank">' . $row[$col] . '</a>';
                            break;
                        case 'currency':
                            $summarize[$col] += $row[$col];
                            $row[$col] = mslib_fe::amount2Cents($row[$col], 0);
                            break;
                        case 'domain_name':
                            if ($row[$col]) {
                                $row[$col] = '<a href="http://' . $row[$col] . '" target="_blank">' . $row[$col] . '</a>';
                            }
                            break;
                        case 'datetime':
                            if ($row[$col]) {
                                $row[$col] = strftime("%x %X", strtotime($row[$col]));
                            } else {
                                $row[$col] = '';
                            }
                            break;
                        case 'timestamp':
                            if (is_numeric($row[$col]) && $row[$col] > 0) {
                                $row[$col] = strftime("%x %X", $row[$col]);
                            } else {
                                $row[$col] = '';
                            }
                            break;
                        case 'timestamp_to_day_date_time':
                            if (is_numeric($row[$col]) && $row[$col] > 0) {
                                $row[$col] = strftime("%a. %x<br/>%X", $row[$col]);
                            } else {
                                $row[$col] = '';
                            }
                            break;
                        case 'timestamp_to_date':
                            if (is_numeric($row[$col]) && $row[$col] > 0) {
                                $row[$col] = strftime("%x", $row[$col]);
                            } else {
                                $row[$col] = '';
                            }
                            break;
                        case 'form':
                            $content = '<form method="';
                            switch ($valArray['formAction']) {
                                case 'post':
                                    $content .= 'POST';
                                    break;
                                case 'get':
                                default:
                                    $content .= 'GET';
                                    break;
                            }
                            $content .= '" action="' . $valArray['actionUrl'] . '" enctype="multipart/form-data">';
                            if ($valArray['content']) {
                                $content .= $valArray['content'];
                            }
                            if (is_array($valArray['hiddenFields'])) {
                                foreach ($valArray['hiddenFields'] as $hiddenFieldKey => $hiddenFieldVal) {
                                    foreach ($row as $tmpCol => $tmpVal) {
                                        $hiddenFieldVal = str_replace('###' . $tmpCol . '###', $row[$tmpCol], $hiddenFieldVal);
                                    }
                                    $content .= '<input name="' . $hiddenFieldKey . '" type="hidden" value="' . $hiddenFieldVal . '" />';
                                }
                            }
                            $content .= '</form>';
                            $row[$col] = $content;
                            break;
                        case 'content':
                            foreach ($row as $tmpCol => $tmpVal) {
                                $valArray['content'] = str_replace('###' . $tmpCol . '###', $row[$tmpCol], $valArray['content']);
                            }
                            $row[$col] = $valArray['content'];
                            break;
                        case 'products_detail_page_link':
                            $where = '';
                            if ($row['categories_id']) {
                                // get all cats to generate multilevel fake url
                                $level = 0;
                                $cats = mslib_fe::Crumbar($row['categories_id']);
                                $cats = array_reverse($cats);
                                $where = '';
                                if (count($cats) > 0) {
                                    foreach ($cats as $cat) {
                                        $where .= "categories_id[" . $level . "]=" . $cat['id'] . "&";
                                        $level++;
                                    }
                                    $where = substr($where, 0, strlen($where) - 1);
                                    $where .= '&';
                                }
                                // get all cats to generate multilevel fake url eof
                            }
                            $product_detail_link = mslib_fe::typolink($this->conf['products_detail_page_pid'], '&' . $where . '&products_id=' . $row['products_id'] . '&tx_multishop_pi1[page_section]=products_detail', 1);
                            $row[$col] = '<a href="' . $product_detail_link . '" target="_blank">' . htmlspecialchars($row['products_name']) . '</a>';
                            break;
                        case 'boolean':
                            $status_html = '';
                            if (!$row[$col]) {
                                $status_html .= '<span class="admin_status_red" alt="' . $this->pi_getLL('no') . '"></span>';
                            } else {
                                $status_html .= '<span class="admin_status_green" alt="' . $this->pi_getLL('yes') . '"></span>';
                            }
                            $row[$col] = $status_html;
                            break;
                        case 'booleanToggle':
                            $status_html = '';
                            if (!$row[$col]) {
                                $status_html .= '<span class="admin_status_red" alt="' . $this->pi_getLL('disable') . '"></span>';
                                if ($valArray['hrefEnable']) {
                                    foreach ($row as $tmpCol => $tmpVal) {
                                        $valArray['hrefEnable'] = str_replace('###' . $tmpCol . '###', $row[$tmpCol], $valArray['hrefEnable']);
                                    }
                                    $status_html .= '<a href="' . $valArray['hrefEnable'] . '"><span class="admin_status_green disabled" alt="' . $this->pi_getLL('enabled') . '"></span></a>';
                                }
                            } else {
                                if ($valArray['hrefDisable']) {
                                    foreach ($row as $tmpCol => $tmpVal) {
                                        $valArray['hrefDisable'] = str_replace('###' . $tmpCol . '###', $row[$tmpCol], $valArray['hrefDisable']);
                                    }
                                    $status_html .= '<a href="' . $valArray['hrefDisable'] . '"><span class="admin_status_red disabled" alt="' . $this->pi_getLL('disabled') . '"></span></a>';
                                }
                                $status_html .= '<span class="admin_status_green" alt="' . $this->pi_getLL('enable') . '"></span>';
                            }
                            $row[$col] = $status_html;
                            break;
                    }
                    $adjustedValue = $row[$col];
                    if ($valArray['href']) {
                        foreach ($row as $tmpCol => $tmpVal) {
                            $valArray['href'] = str_replace('###' . $tmpCol . '###', $row[$tmpCol], $valArray['href']);
                        }
                        $adjustedValue = '<a ' . ($valArray['hrefNoFollow'] ? ' rel="nofollow"' : '') . ' href="' . $valArray['href'] . '"' . ($valArray['href_target'] ? ' target="' . $valArray['href_target'] . '""' : '') . '>' . $adjustedValue . '</a>';
                    }
                    if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.tx_mslib_admin_interface.php']['tableColumnsPreProc'])) {
                        $conf = array('col' => &$col, 'row' => &$row, 'originalValue' => &$originalValue, 'adjustedValue' => &$adjustedValue, 'params' => &$params, 'valArray' => &$valArray, 'summarize' => &$summarize);
                        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.tx_mslib_admin_interface.php']['tableColumnsPreProc'] as $funcRef) {
                            \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $conf, $that);
                        }
                    }
                    $tdClass = array();
                    if ($valArray['align']) {
                        $tdClass[] = 'text-' . $valArray['align'];
                    }
                    if ($valArray['nowrap']) {
                        $tdClass[] = 'cellNoWrap';
                    }
                    if ($valArray['class']) {
                        $tdClass[] = $valArray['class'];
                    }
                    $tableContent .= '<td' . (count($tdClass) ? ' class="' . implode(' ', $tdClass) . '"' : '') . '>' . $adjustedValue . '</td>';
                }
                $tableContent .= '</tr>';
                if ($params['settings']['returnResultSetAsArray']) {
                    $pageset['dataset'][$rowKey] = $row;
                }
            }
            $tableContent .= '</tbody>';
            if (!$params['settings']['skipSummarize']) {
                // Summarize footer
                $tableContent .= '<tfoot><tr>';
                if ($params['settings']['enableRowBasedCheckboxSelection']) {
                    $tableContent .= '<th></th>';
                }
                foreach ($params['tableColumns'] as $col => $valArray) {
                    switch ($valArray['valueType']) {
                        case 'currency':
                            $row[$col] = mslib_fe::amount2Cents($summarize[$col], 0);
                            break;
                        case 'number_format_2_decimals':
                            $row[$col] = round(number_format($summarize[$col], 2, ',', '.'), 2);
                            break;
                        default:
                            $row[$col] = $valArray['title'];
                            break;
                    }
                    $tdClass = array();
                    if ($valArray['align']) {
                        $tdClass[] = 'text-' . $valArray['align'];
                    }
                    if ($valArray['nowrap']) {
                        $tdClass[] = 'cellNoWrap';
                    }
                    if ($valArray['class']) {
                        $tdClass[] = $valArray['class'];
                    }
                    $tableContent .= '<th' . (count($tdClass) ? ' class="' . implode(' ', $tdClass) . '"' : '') . '>' . $row[$col] . '</th>';
                    // $tableContent.='<th'.($valArray['align'] ? ' class="text-'.$valArray['align'].'"' : '').($valArray['nowrap'] ? ' nowrap' : '').'>'.$row[$col].'</th>';
                }
                $tableContent .= '</tr></tfoot>';
            }
            $tableContent .= '</table>';
            if ($params['settings']['enableActionSelectionForm'] && is_array($params['settings']['tableSelectionActions']) && count($params['settings']['tableSelectionActions'])) {
                $actions = $params['settings']['tableSelectionActions'];
                if (count($actions)) {
                    // custom page hook that can be controlled by third-party plugin eof
                    $action_selectbox .= '<select name="tx_multishop_pi1[action]" id="msAdminTableAction" class="form-control"><option value="">' . htmlspecialchars($this->pi_getLL('choose_action')) . '</option>';
                    foreach ($actions as $key => $value) {
                        $action_selectbox .= '<option value="' . htmlspecialchars($key) . '">' . htmlspecialchars($value) . '</option>';
                    }
                    $action_selectbox .= '</select>';
                    $tableContent .= $action_selectbox;
                }
            }
            if ($params['settings']['contentBelowTable']) {
                $tableContent .= $params['settings']['contentBelowTable'];
            }
            if ($params['settings']['enableActionSelectionForm'] && is_array($params['settings']['tableSelectionActions']) && count($params['settings']['tableSelectionActions'])) {
                $tableContent .= '<div class="form-group">
                    <input class="btn btn-success" type="submit" name="submit" value="' . htmlspecialchars($this->pi_getLL('submit_form')) . '" />
                </div>';
            }
            $tableContent .= '
			</div>
			';
            if (!$params['settings']['disableForm']) {
                $tableContent .= '</form>';
            }
            // pagination
            $paginationMarkup = '';
            if (!$params['settings']['skipPaginationMarkup'] and $pageset['total_rows'] > $that->ms['MODULES']['PAGESET_LIMIT']) {
                $total_pages = ceil($pageset['total_rows'] / $that->ms['MODULES']['PAGESET_LIMIT']);
                require \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('multishop') . 'scripts/admin_pages/includes/admin_pagination.php';
                $paginationMarkup = $tmp;
                $tableContent .= $tmp;
                $tmp = '';
            }
            // pagination eof
        }
        $content = '';
        $content .= '<div class="panel panel-default">';
        $content .= '<div class="panel-heading">';
        if ($params['interfaceTitle']) {
            $interfaceTitle = $params['interfaceTitle'];
        } else {
            $interfaceTitle = $params['title'];
        }
        $content .= '<h3>' . htmlspecialchars($interfaceTitle) . '</h3>';
        if (is_array($params['settings']['headingButtons'])) {
            $content .= '<div class="form-inline">';
            foreach ($params['settings']['headingButtons'] as $headingButton) {
                $content .= '<a href="' . $headingButton['href'] . '" class="' . $headingButton['btn_class'] . '"' . ($headingButton['attributes'] ? ' ' . $headingButton['attributes'] : '') . '><i class="' . $headingButton['fa_class'] . '"></i> ' . htmlspecialchars($headingButton['title']) . '</a> ';
            }
            $content .= '</div>';
        }
        $content .= '</div>';
        $content .= '<div class="panel-body">';
        if (!$params['settings']['skipTabMarkup']) {
            $GLOBALS['TSFE']->additionalHeaderData['msAdminTabJs'] = '<script type="text/javascript">
			jQuery(document).ready(function ($) {
				$(\'.nav-tabs a:first\').tab(\'show\');
			});
			</script>
			';
            $content .= '
				<div id="tab-container">
				<ul class="nav nav-tabs" id="admin_orders" role="tablist">
					<li role="presentation"><a href="#CmsListing" aria-controls="profile" role="tab" data-toggle="tab">' . htmlspecialchars($params['title']) . '</a></li>
				</ul>
				<div class="tab-content">
			';
        }
        $searchForm = '';
        if ($params['settings']['enableKeywordSearch']) {
            $searchForm = '
			<form id="form1" name="form1" method="get" action="index.php">
				<div class="well">
					<div class="row formfield-container-wrapper">
						';
            foreach ($params['searchForm']['hiddenFields'] as $key => $val) {
                $searchForm .= '<input name="' . $key . '" type="hidden" value="' . htmlspecialchars($val) . '" />' . "\n";
            }
            $searchForm .= '
						<div class="col-sm-8 formfield-wrapper">
							<div class="form-inline">
								<label class="control-label">' . $that->pi_getLL('keyword') . '</label>
								<input type="text" name="tx_multishop_pi1[keyword]" class="form-control" value="' . htmlspecialchars($that->get['tx_multishop_pi1']['keyword']) . '" />
								<input type="submit" name="Search" class="btn btn-success" value="' . $that->pi_getLL('search') . '" />
							</div>
						</div>
						<div class="col-sm-4 formfield-wrapper">
							<div class="pull-right form-inline">
								<label class="control-label">' . $that->pi_getLL('limit_number_of_records_to') . '</label>
								' . $limit_search_result_selectbox . '
							</div>
						</div>
					</div>
				</div>
			</form>
			';
            //hook to let other plugins further manipulate the method
            if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/class.tx_mslib_admin_interface.php']['setAdminInterfaceSearchFormPostProc'])) {
                $interfaceKey =& $this->interfaceKey;
                $params_searchform = array('interfaceKey' => &$interfaceKey, 'searchForm' => &$searchForm, 'adminInterfaceParams' => &$params);
                foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/class.tx_mslib_admin_interface.php']['setAdminInterfaceSearchFormPostProc'] as $funcRef) {
                    \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params_searchform, $this);
                }
            }
        }
        if (!$params['settings']['skipTabMarkup']) {
            $content .= '
				<div role="tabpanel" id="CmsListing" class="tab-pane">
					' . $searchForm . '
					' . $tableContent . '
				</div>
			</div>
			</div>
			';
        } else {
            $content .= $searchForm . $tableContent;
        }
        if ($params['settings']['skipRecordCount'] || $params['settings']['skipRecordCountWhenZeroResults'] && !$pageset['total_rows']) {
            $skipRecordCount = 1;
        }
        if ($params['settings']['skipTotalCount'] || $params['settings']['skipTotalCountWhenZeroResults'] && !$params['summarizeData']['totalRecordsInTable']) {
            $skipTotalCount = 1;
        }
        if (!$skipRecordCount) {
            $content .= '<p class="text-center">' . $this->pi_getLL('found_records') . ': <strong>' . number_format($pageset['total_rows'], 0, '', '.') . '</strong></p>';
        }
        if (!$skipTotalCount && isset($params['summarizeData']['totalRecordsInTable'])) {
            $content .= '<p class="text-center">' . $this->pi_getLL('total_records_in_database') . ': <strong>' . number_format($params['summarizeData']['totalRecordsInTable'], 0, '', '.') . '</strong></p>';
        }
        if (!$params['settings']['skipFooterMarkup']) {
            $content .= '<hr><div class="clearfix"><a class="btn btn-success msAdminBackToCatalog" href="' . mslib_fe::typolink() . '"><span class="fa-stack"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-arrow-left fa-stack-1x"></i></span> ' . $that->pi_getLL('admin_close_and_go_back_to_catalog') . '</a></div>';
        }
        $content .= '</div>';
        $content .= '</div>';
        if ($params['settings']['returnOnlyWhenRecordsFound'] && !$pageset['total_rows']) {
            //return;
        } else {
            if ($params['settings']['returnResultSetAsArray']) {
                $array = array();
                $array['searchForm'] = $searchForm;
                $array['paginationMarkup'] = $paginationMarkup;
                $array['dataset'] = $pageset['dataset'];
                return $array;
            } else {
                return $content;
            }
        }
    }
 function init($ref)
 {
     mslib_fe::init($ref);
 }
    function renderInterface($params, &$that)
    {
        mslib_fe::init($that);
        if ($that->post['job_id']) {
            $that->get['job_id'] = $that->post['job_id'];
        }
        if ($that->get['delete'] and is_numeric($that->get['job_id'])) {
            // delete job
            $query = $GLOBALS['TYPO3_DB']->DELETEquery('tx_multishop_import_jobs', 'id=' . $that->get['job_id'] . ' and type=\'' . addslashes($params['importKey']) . '\'');
            $res = $GLOBALS['TYPO3_DB']->sql_query($query);
        }
        if (is_numeric($that->get['job_id']) and is_numeric($that->get['status'])) {
            // update the status of a job
            $updateArray = array();
            $updateArray['status'] = $that->get['status'];
            $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_import_jobs', 'id=\'' . $that->get['job_id'] . '\' and type=\'' . addslashes($params['importKey']) . '\'', $updateArray);
            $res = $GLOBALS['TYPO3_DB']->sql_query($query);
            // update the status of a job eof
        }
        if (isset($that->get['download']) && $that->get['download'] == 'task' && is_numeric($that->get['job_id'])) {
            $sql = $GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_multishop_import_jobs ', 'id= \'' . $that->get['job_id'] . '\'', '', '', '');
            $qry = $GLOBALS['TYPO3_DB']->sql_query($sql);
            if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry)) {
                $data = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry);
                $jobArray = $row;
                $serial_value = array();
                foreach ($data as $key_idx => $key_val) {
                    if ($key_idx != 'id' && $key_idx != 'page_uid') {
                        $serial_value[$key_idx] = $key_val;
                    }
                }
                $serial_data = '';
                if (count($serial_value) > 0) {
                    $serial_data = serialize($serial_value);
                }
                $filename = 'multishop_' . $params['importKey'] . '_import_task_' . date('YmdHis') . '_' . $that->get['job_id'] . '.txt';
                $filepath = $that->DOCUMENT_ROOT . 'uploads/tx_multishop/' . $filename;
                file_put_contents($filepath, $serial_data);
                header("Content-disposition: attachment; filename={$filename}");
                //Tell the filename to the browser
                header('Content-type: application/octet-stream');
                //Stream as a binary file! So it would force browser to download
                readfile($filepath);
                //Read and stream the file
                @unlink($filepath);
                exit;
            }
        }
        if (isset($that->get['upload']) && $that->get['upload'] == 'task' && $_FILES) {
            if (!$_FILES['task_file']['error']) {
                $filename = $_FILES['task_file']['name'];
                $target = $that->DOCUMENT_ROOT . '/uploads/tx_multishop' . $filename;
                if (move_uploaded_file($_FILES['task_file']['tmp_name'], $target)) {
                    $task_content = file_get_contents($target);
                    $unserial_task_data = unserialize($task_content);
                    $insertArray = array();
                    $insertArray['page_uid'] = $that->showCatalogFromPage;
                    foreach ($unserial_task_data as $col_name => $col_val) {
                        if ($col_name == 'code') {
                            $insertArray[$col_name] = md5(uniqid());
                        } else {
                            if ($col_name == 'name' && isset($that->post['new_cron_name']) && !empty($that->post['new_cron_name'])) {
                                $insertArray[$col_name] = $that->post['new_cron_name'];
                            } else {
                                if ($col_name == 'prefix_source_name' && isset($that->post['new_prefix_source_name']) && !empty($that->post['new_prefix_source_name'])) {
                                    $insertArray[$col_name] = $that->post['new_prefix_source_name'];
                                } else {
                                    $insertArray[$col_name] = $col_val;
                                }
                            }
                        }
                    }
                    $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_import_jobs', $insertArray);
                    $res = $GLOBALS['TYPO3_DB']->sql_query($query);
                    @unlink($target);
                }
            }
            header('Location: ' . $that->FULL_HTTP_URL . $params['postForm']['actionUrl'] . '#tasks');
        }
        $GLOBALS['TSFE']->additionalHeaderData['tx_multishop_pi1_block_ui'] = mslib_fe::jQueryBlockUI();
        if (is_numeric($that->post['job_id']) && $that->post['action'] == 'import-preview') {
            if ($that->post['job_id']) {
                $that->get['job_id'] = $that->post['job_id'];
            }
            $str = "SELECT * from tx_multishop_import_jobs where id='" . $that->post['job_id'] . "' and type='" . addslashes($params['importKey']) . "'";
            $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
            $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry);
            $jobArray = $row;
            $updateArray = array();
            $cron_data = array();
            $cron_data[0] = array();
            $that->post['cron_period'] = '';
            $cron_data[1] = $that->post;
            $updateArray['data'] = serialize($cron_data);
            $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_import_jobs', 'id=' . $that->post['job_id'], $updateArray);
            $res = $GLOBALS['TYPO3_DB']->sql_query($query);
        }
        if ($that->post['action'] == 'import-preview' or is_numeric($that->get['job_id']) and $_REQUEST['action'] == 'edit_job') {
            // preview
            if (is_numeric($that->get['job_id'])) {
                $that->ms['mode'] = 'edit';
                // load the job
                $str = "SELECT * from tx_multishop_import_jobs where id='" . $that->get['job_id'] . "' and type='" . addslashes($params['importKey']) . "'";
                $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
                $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry);
                $jobArray = $row;
                $data = unserialize($row['data']);
                // copy the previous post data to the current post so it can run the job
                // again
                $that->post = $data[1];
                $that->post['cid'] = $row['categories_id'];
                // enable file logging
                if ($that->get['relaxed_import']) {
                    $that->post['relaxed_import'] = $that->get['relaxed_import'];
                }
                // update the last run time
                $updateArray = array();
                $updateArray['last_run'] = time();
                $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_import_jobs', 'id=' . $row['id'], $updateArray);
                $res = $GLOBALS['TYPO3_DB']->sql_query($query);
                // update the last run time eof
            }
            if ($that->post['database_name']) {
                $file_location = $that->post['database_name'];
            } elseif ($that->post['file_url']) {
                if (strstr($that->post['file_url'], "../")) {
                    die;
                }
                $filename = time();
                $file_location = $that->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . $filename;
                $file_content = mslib_fe::file_get_contents($that->post['file_url']);
                if (!$file_content or !file_put_contents($file_location, $file_content)) {
                    die('cannot save the file or the file is empty');
                }
            } elseif ($that->ms['mode'] == 'edit') {
                $filename = $that->post['filename'];
                $file_location = $that->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . $filename;
            }
            if ($_FILES['file']['tmp_name']) {
                $file = $_FILES['file']['tmp_name'];
                $filename = time() . '.import';
                $file_location = $that->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . $filename;
                $that->post['filename'] = $filename;
                move_uploaded_file($file, $file_location);
                if (preg_match("/\\.gz\$/", $_FILES['file']['name'])) {
                    // lets uncompress realtime
                    $str = mslib_fe::file_get_contents($file_location, 1);
                    file_put_contents($file_location, $str);
                }
            }
            if ($this->ms['mode'] == 'edit' and is_array($data) and count($data) and $filename) {
                if ($filename) {
                    $data[1]['filename'] = $filename;
                    $this->post['filename'] = $filename;
                }
                $string = serialize($data);
                $updateArray = array();
                $updateArray['data'] = $string;
                $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_import_jobs', 'id=' . $_REQUEST['job_id'], $updateArray);
                $res = $GLOBALS['TYPO3_DB']->sql_query($query);
            }
            if ($file_location and $this->ms['mode'] == 'edit') {
                // if file not exists then show form to upload new file
                if (!file_exists($file_location)) {
                    $content .= '<h2>Feed no longer available</h2>' . $file_location . ' is not existing.';
                }
            }
            if (file_exists($file_location) or $that->post['database_name']) {
                if (!$that->post['database_name']) {
                    $str = mslib_fe::file_get_contents($file_location);
                }
                if ($that->post['parser_template']) {
                    $processed = 0;
                    $rows = array();
                } else {
                    if ($str && mslib_befe::isSerializedString($str)) {
                        $tmpData = unserialize($str);
                        $counter = 0;
                        foreach ($tmpData as $data) {
                            $colCounter = 0;
                            if ($counter == 0) {
                                $row = array();
                                foreach ($data as $key => $val) {
                                    $row[] = $key;
                                }
                                $table_cols = $row;
                            }
                            $row = array();
                            foreach ($data as $key => $val) {
                                $row[] = $val;
                            }
                            $rows[] = $row;
                            $counter++;
                            if ($counter == 5) {
                                break;
                            }
                        }
                    } elseif ($that->post['database_name']) {
                        if ($that->ms['mode'] == 'edit') {
                            $limit = 10;
                        } else {
                            $limit = '10';
                        }
                        if (strstr(mslib_befe::strtolower($that->post['database_name']), 'select ')) {
                            // its not a table name, its a full query
                            $that->databaseMode = 'query';
                            $str = $that->post['database_name'] . ' LIMIT ' . $limit;
                            $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
                            if ($that->conf['debugEnabled'] == '1') {
                                $logString = 'Load records for importer query: ' . $str;
                                \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($logString, 'multishop', -1);
                            }
                            $datarows = array();
                            while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) != false) {
                                $datarows[] = $row;
                            }
                        } else {
                            $datarows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $that->post['database_name'], '', '', '', $limit);
                        }
                        $i = 0;
                        $table_cols = array();
                        foreach ($datarows as $datarow) {
                            $s = 0;
                            foreach ($datarow as $colname => $datacol) {
                                $table_cols[$s] = $colname;
                                $rows[$i][$s] = $datacol;
                                $s++;
                            }
                            $i++;
                            if ($i == 5) {
                                break;
                            }
                        }
                    } elseif ($that->post['format'] == 'excel') {
                        if (!$that->ms['mode'] == 'edit') {
                            $filename = 'tmp-file-' . $GLOBALS['TSFE']->fe_user->user['uid'] . '-cat-' . $that->post['cid'] . '-' . time() . '.txt';
                            if (!($handle = fopen($that->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . $filename, 'w'))) {
                                exit;
                            }
                            if (fwrite($handle, $str) === false) {
                                exit;
                            }
                            fclose($handle);
                        }
                        // excel
                        $paths = array();
                        $paths[] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('phpexcel_service') . 'Resources/Private/Contributed/PHPExcel/IOFactory.php';
                        $paths[] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('phpexcel_service') . 'Classes/PHPExcel/IOFactory.php';
                        foreach ($paths as $path) {
                            if (file_exists($path)) {
                                require_once $path;
                                break;
                            }
                        }
                        $phpexcel = PHPExcel_IOFactory::load($file_location);
                        foreach ($phpexcel->getWorksheetIterator() as $worksheet) {
                            $counter = 0;
                            foreach ($worksheet->getRowIterator() as $row) {
                                $cellIterator = $row->getCellIterator();
                                $cellIterator->setIterateOnlyExistingCells(false);
                                foreach ($cellIterator as $cell) {
                                    $clean_products_data = ltrim(rtrim($cell->getCalculatedValue(), " ,"), " ,");
                                    $clean_products_data = trim($clean_products_data);
                                    if ($row->getRowIndex() > 1) {
                                        $rows[$counter - 1][] = $clean_products_data;
                                    } else {
                                        $table_cols[] = mslib_befe::strtolower($clean_products_data);
                                    }
                                }
                                $counter++;
                                if ($counter == 5) {
                                    break;
                                }
                            }
                        }
                        // excel eol
                    } elseif ($that->post['format'] == 'xml') {
                        // try the generic way
                        if (!$that->ms['mode'] == 'edit') {
                            $filename = 'tmp-file-' . $GLOBALS['TSFE']->fe_user->user['uid'] . '-cat-' . $that->post['cid'] . '-' . time() . '.txt';
                            if (!($handle = fopen($that->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . $filename, 'w'))) {
                                exit;
                            }
                            if (fwrite($handle, $str) === false) {
                                exit;
                            }
                            fclose($handle);
                        }
                        // try the generic way
                        $objXML = new xml2Array();
                        $arrOutput = $objXML->parse($str);
                        $i = 0;
                        $s = 0;
                        $rows = array();
                        foreach ($arrOutput[0]['children'] as $item) {
                            foreach ($item['children'] as $internalitem) {
                                $rows[$i][$s] = $internalitem['tagData'];
                                $s++;
                            }
                            //					foreach ($item['attrs'] as $key => $value)
                            //					{
                            //						$rows[$i][$s] = $value;
                            //						$s++;
                            //					}
                            $i++;
                            $s = 0;
                            if ($i == 5) {
                                break;
                            }
                        }
                    } else {
                        if ($that->post['os'] == 'linux') {
                            $splitter = "\n";
                        } else {
                            $splitter = "\r\n";
                        }
                        // csv
                        if ($that->post['delimiter'] == "tab") {
                            $delimiter = "\t";
                        } elseif ($that->post['delimiter'] == "dash") {
                            $delimiter = "|";
                        } elseif ($that->post['delimiter'] == "dotcomma") {
                            $delimiter = ";";
                        } elseif ($that->post['delimiter'] == "comma") {
                            $delimiter = ",";
                        } else {
                            $delimiter = "\t";
                        }
                        if ($that->post['backquotes']) {
                            $backquotes = '"';
                        } else {
                            $backquotes = '"';
                        }
                        if ($that->post['format'] == 'txt') {
                            $row = 1;
                            $rows = array();
                            if (($handle = fopen($file_location, "r")) !== false) {
                                $counter = 0;
                                while (($data = fgetcsv($handle, '', $delimiter, $backquotes)) !== false) {
                                    //print_r($data);
                                    if ($that->post['escape_first_line']) {
                                        if ($counter == 0) {
                                            $table_cols = $data;
                                        } else {
                                            $rows[] = $data;
                                        }
                                    } else {
                                        $rows[] = $data;
                                    }
                                    $counter++;
                                    if ($counter == 5) {
                                        break;
                                    }
                                }
                                fclose($handle);
                            }
                        }
                        // csv
                    }
                    // try the generic way eol
                }
                $tmpcontent = '';
                $tmpcontent .= '<div class="panel-body">
		<form id="product_import_form" class="form-horizontal" name="form1" method="post" action="' . $params['postForm']['actionUrl'] . '">
		<input name="consolidate" type="hidden" value="' . $that->post['consolidate'] . '" />
		<input name="os" type="hidden" value="' . $that->post['os'] . '" />
		<input name="escape_first_line" type="hidden" value="' . $that->post['escape_first_line'] . '" />
		<input name="parser_template" type="hidden" value="' . $that->post['parser_template'] . '" />
		<input name="format" type="hidden" value="' . $that->post['format'] . '" />
		<input name="action" type="hidden" value="import" />
		<input name="delimiter" type="hidden"  value="' . $that->post['delimiter'] . '" />
		<input name="backquotes" type="hidden"  value="' . $that->post['backquotes'] . '" />
		<input name="filename" type="hidden" value="' . $filename . '" />
		<input name="file_url" type="hidden" value="' . $that->post['file_url'] . '" />
		';
                if ($that->ms['mode'] == 'edit' or $that->post['preProcExistingTask']) {
                    // if the existing import task is rerunned indicate it so we dont save the task double
                    $tmpcontent .= '<input name="preProcExistingTask" type="hidden" value="1" />';
                }
                if (!$rows) {
                    $tmpcontent .= '<div class="alert alert-danger"><h3>No data available.</h3></div>';
                } else {
                    $tmpcontent .= '<table id="product_import_table" class="table table-striped table-bordered">';
                    $header = '<thead><tr><th>' . $that->pi_getLL('target_column') . '</th><th>' . $that->pi_getLL('source_column') . '</th>';
                    for ($x = 1; $x < 6; $x++) {
                        $header .= '<th>' . $that->pi_getLL('row') . ' ' . $x . '</th>';
                    }
                    $header .= '</tr></thead>';
                    $tmpcontent .= $header;
                    $cols = count($rows[0]);
                    $preview_listing = array();
                    for ($i = 0; $i < $cols; $i++) {
                        if ($switch == 'odd') {
                            $switch = 'even';
                        } else {
                            $switch = 'odd';
                        }
                        $tmpcontent .= '
				<tr class="' . $switch . '">
					<td class="cellAux">
					<div class="form-inline">
					<select name="select[' . $i . ']" id="select[' . $i . ']" class="select_columns_fields">
						<option value="">' . $that->pi_getLL('skip') . '</option>
						';
                        foreach ($params['importColumns'] as $key => $value) {
                            $tmpcontent .= '<option value="' . $key . '" ' . ($that->post['select'][$i] != '' && $that->post['select'][$i] == $key ? 'selected' : '') . '>' . htmlspecialchars($value) . '</option>';
                        }
                        $tmpcontent .= '
					</select>&nbsp;<input name="advanced_settings" class="btn btn-primary importer_advanced_settings" type="button" value="' . $that->pi_getLL('admin_advanced_settings') . '" />
					</div>
					<div class="advanced_settings_container" style="display:none;">
						<div class="form-group no-mb">
							<div class="col-md-12">
								<label class="control-label">aux</label>
								<input name="input[' . $i . ']" class="form-control" type="text" value="' . htmlspecialchars($this->post['input'][$i]) . '">
							</div>
						</div>
					</fieldset>
				</td>
				<td class="column_name"><strong>' . htmlspecialchars($table_cols[$i]) . '</strong></td>
				';
                        // now 5 records
                        $teller = 0;
                        foreach ($rows as $row) {
                            foreach ($row as $key => $col) {
                                if (!mb_detect_encoding($col, 'UTF-8', true)) {
                                    $row[$key] = mslib_befe::convToUtf8($col);
                                }
                            }
                            $teller++;
                            $tmpitem = $row;
                            $cols = count($tmpitem);
                            if ($that->post['backquotes']) {
                                $tmpitem[$i] = trim($tmpitem[$i], "\"");
                            }
                            if (strlen($tmpitem[$i]) > 100) {
                                $tmpitem[$i] = substr($tmpitem[$i], 0, 100) . '...';
                            }
                            $tmpcontent .= '<td class="cellBreak product_' . $teller . '">' . htmlspecialchars($tmpitem[$i]) . '</td>';
                            if ($teller == 5 or $teller == count($rows)) {
                                break;
                            }
                        }
                        if ($teller < 5) {
                            for ($x = $teller; $x < 5; $x++) {
                                $tmpcontent .= '<td class="cellBreak product_' . $x . '">&nbsp;</td>';
                            }
                        }
                        // now 5 products eof
                        $tmpcontent .= '
			</tr>';
                        /*
                         * prefix '.$i.': <input name="input['.$i.']" type="text"
                         * value="'.htmlspecialchars($that->post['input'][$i]).'" />
                         */
                    }
                    $importer_add_aux_input = '
			<div class="form-field ms_dynamic_add_property">
				<label>type</label>
				<select name="type">
					<option value="append">append content with value</option>
					<option value="prepend">prepend content with value</option>
					<option value="find_and_replace">find and replace</option>
					<option value="custom_code">custom php code</option>
				</select>
				<label>aux</label>
				<input name="aux_input[]" type="text" value="' . htmlspecialchars($that->post['aux_input']) . '" />
				<input name="delete" class="delete_property" type="button" value="delete" /><input name="disable" type="button" value="enable" />
			</div>
			';
                    $importer_add_aux_input = str_replace("\r\n", '', $importer_add_aux_input);
                    $importer_add_aux_input = str_replace("\n", '', $importer_add_aux_input);
                    $tmpcontent .= $header . '</table>';
                    $tmpcontent .= '
					<script type="text/javascript">
					jQuery(document).ready(function($) {
						var add_property_html=\'' . addslashes($importer_add_aux_input) . '\';
						$(document).on("click", ".delete_property", function() {
							$(this).parent().hide("fast");
						});
						$(".importer_add_property").click(function(event) {
							$(this).prev().append(add_property_html);
						});
						$(".importer_advanced_settings").click(function(event) {
							$(this).parent().next().toggle();
						});
						$(\'.select_columns_fields\').select2({
							dropdownCssClass: "bigdropWider", // apply css that makes the dropdown taller
							width:\'250px\'
						});
					});
					</script>
						';
                }
                //$tmpcontent.=self::renderImportJobProperties($params,$that);
                $tmpcontent .= '
				<div class="panel panel-default">
					<div class="panel-heading"><h3>' . $that->pi_getLL('save_import_task') . '</h3></div>
					<div class="panel-body">
					<div class="form-group">
						<label for="cron_name" class="control-label col-md-2">' . $that->pi_getLL('name') . '</label>
						<div class="col-md-10">
							<input name="cron_name" type="text" class="form-control" value="' . htmlspecialchars($that->post['cron_name']) . '" />
						</div>
					</div>
';
                if ($that->get['action'] == 'edit_job') {
                    $tmpcontent .= '
							<div class="form-group">
								<label for="duplicate" class="control-label col-md-2">' . $that->pi_getLL('duplicate') . '</label>
								<div class="col-md-10">
									<div class="checkbox checkbox-success checkbox-inline">
										<input name="duplicate" id="duplicate" type="checkbox" value="1" /><label for="duplicate"></label>
										<input name="skip_import" type="hidden" value="1" />
										<input name="job_id" type="hidden" value="' . $that->get['job_id'] . '" />
										<input name="file_url" type="hidden" value="' . $that->post['file_url'] . '" />
									</div>
								</div>
							</div>
			';
                }
                $tmpcontent .= '
		<div class="form-group">
			<label for="cron_period" class="control-label col-md-2">' . $that->pi_getLL('schedule') . '</label>
			<div class="col-md-10">
				<select name="cron_period" id="cron_period" class="form-control">
				<option value="" ' . (!$that->post['cron_period'] ? 'selected' : '') . '>' . $that->pi_getLL('manual') . '</option>
				<option value="' . 3600 * 24 . '" ' . ($that->post['cron_period'] == 3600 * 24 ? 'selected' : '') . '>' . $that->pi_getLL('daily') . '</option>
				<option value="' . 3600 * 24 * 7 . '" ' . ($that->post['cron_period'] == 3600 * 24 * 7 ? 'selected' : '') . '>' . $that->pi_getLL('weekly') . '</option>
				<option value="' . 3600 * 24 * 30 . '" ' . ($that->post['cron_period'] == 3600 * 24 * 30 ? 'selected' : '') . '>' . $that->pi_getLL('monthly') . '</option>
				</select>
			</div>
		</div>
		<div class="form-group">
			<label for="prefix_source_name" class="control-label col-md-2">' . $that->pi_getLL('source_name') . '</label>
			<div class="col-md-10">
				<input name="prefix_source_name" type="text" class="form-control" value="' . htmlspecialchars($that->post['prefix_source_name']) . '" />
			</div>
		</div>
		<input name="database_name" type="hidden" value="' . $that->post['database_name'] . '" />
		<input name="cron_data" type="hidden" value="' . htmlspecialchars(serialize($that->post)) . '" />
		<div class="form-group">
			<div class="col-md-10 col-md-offset-2">
				<button type="submit" class="btn btn-success submit_block" id="cl_submit" name="AdSubmit" value=""><i class="fa fa-save"></i> ' . ($that->get['action'] == 'edit_job' ? $that->pi_getLL('save') : $that->pi_getLL('import')) . '</button>
			</div>
		</div>
		</div>
		</div>

		</form>

		';
                $content = '' . mslib_fe::shadowBox($tmpcontent) . '';
                // $content='<div
                // class="fullwidth_div">'.mslib_fe::shadowBox($tmpcontent).'</div>';
            }
            // preview eof
        } elseif (is_numeric($that->get['job_id']) and $that->get['action'] == 'run_job' or $that->post['action'] == 'import' and ($that->post['filename'] and file_exists($that->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . $that->post['filename']) or $that->post['database_name'])) {
            if (!$that->post['preProcExistingTask'] and $that->post['cron_name'] and !$that->post['skip_import'] or $that->post['skip_import'] and $that->post['duplicate']) {
                // we have to save the import job
                $updateArray = array();
                $updateArray['name'] = $that->post['cron_name'];
                $updateArray['status'] = 1;
                $updateArray['last_run'] = time();
                $updateArray['code'] = md5(uniqid());
                $updateArray['period'] = $that->post['cron_period'];
                $updateArray['prefix_source_name'] = $that->post['prefix_source_name'];
                $cron_data = array();
                $cron_data[0] = unserialize($that->post['cron_period']);
                $that->post['cron_period'] = '';
                $cron_data[1] = $that->post;
                $updateArray['data'] = serialize($cron_data);
                $updateArray['page_uid'] = $that->shop_pid;
                $updateArray['categories_id'] = $that->post['cid'];
                $updateArray['type'] = $params['importKey'];
                $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_import_jobs', $updateArray);
                $res = $GLOBALS['TYPO3_DB']->sql_query($query);
                // we have to save the import job eof
                $that->ms['show_default_form'] = 1;
            } elseif ($that->post['skip_import']) {
                // we have to update the import job
                $updateArray = array();
                $updateArray['name'] = $that->post['cron_name'];
                $updateArray['status'] = 1;
                $updateArray['last_run'] = time();
                $updateArray['period'] = $that->post['cron_period'];
                $updateArray['prefix_source_name'] = $that->post['prefix_source_name'];
                $cron_data = array();
                $cron_data[0] = unserialize($that->post['cron_period']);
                $that->post['cron_period'] = '';
                $cron_data[1] = $that->post;
                $updateArray['data'] = serialize($cron_data);
                $updateArray['page_uid'] = $that->shop_pid;
                $updateArray['categories_id'] = $that->post['cid'];
                $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_import_jobs', 'id=' . $that->post['job_id'] . ' and type=\'' . addslashes($params['importKey']) . '\'', $updateArray);
                $res = $GLOBALS['TYPO3_DB']->sql_query($query);
                // we have to update the import job eof
                $that->ms['show_default_form'] = 1;
            }
            if (!$that->post['skip_import']) {
                if (!$that->get['job_id'] && $that->post['cron_data']) {
                    $data = unserialize($that->post['cron_data']);
                    if (is_numeric($data['job_id'])) {
                        // NEW STUFF FOR 123 IMPORT APPROACH WITH PREDEFINED VALUES TEST
                        $that->get['job_id'] = $data['job_id'];
                        // load the job
                        $str = "SELECT * from tx_multishop_import_jobs where id='" . $that->get['job_id'] . "'" . ' and type=\'' . addslashes($params['importKey']) . '\'';
                        $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
                        $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry);
                        $jobArray = $row;
                        $cron_data = array();
                        $cron_data[0] = array();
                        $that->post['cron_period'] = '';
                        $cron_data[1] = $that->post;
                        $updateArray['data'] = serialize($cron_data);
                        $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_import_jobs', 'id=' . $that->get['job_id'], $updateArray);
                        $res = $GLOBALS['TYPO3_DB']->sql_query($query);
                    }
                }
                if (is_numeric($that->get['job_id'])) {
                    // load the job
                    $str = "SELECT * from tx_multishop_import_jobs where id='" . $that->get['job_id'] . "'" . ' and type=\'' . addslashes($params['importKey']) . '\'';
                    $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
                    $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry);
                    $jobArray = $row;
                    $data = unserialize($row['data']);
                    // copy the previous post data to the current post so it can run the
                    // job again
                    $that->post = $data[1];
                    if ($row['categories_id']) {
                        $that->post['cid'] = $row['categories_id'];
                    }
                    // update the last run time
                    $updateArray = array();
                    $updateArray['last_run'] = time();
                    $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_import_jobs', 'id=' . $row['id'] . ' and type=\'' . addslashes($params['importKey']) . '\'', $updateArray);
                    $res = $GLOBALS['TYPO3_DB']->sql_query($query);
                    // update the last run time eof
                    if ($log_file) {
                        file_put_contents($log_file, $that->FULL_HTTP_URL . ' - cron job settings loaded.(' . date("Y-m-d G:i:s") . ")\n", FILE_APPEND);
                    }
                }
                if ($that->post['file_url']) {
                    if (strstr($that->post['file_url'], "../")) {
                        die;
                    }
                    $filename = time();
                    $file = $that->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . $filename;
                    file_put_contents($file, mslib_fe::file_get_contents($that->post['file_url']));
                }
                if ($that->post['filename']) {
                    $file = $that->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . $that->post['filename'];
                }
                if ($that->post['database_name'] or $file) {
                    if ($file) {
                        $str = mslib_fe::file_get_contents($file);
                    }
                    if ($that->post['parser_template']) {
                        $processed = 0;
                        $rows = array();
                        /*
                        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/scripts/admin_pages/admin_import.php']['TmpproductImportParserTemplateProc'])) {
                            $params=array(
                                'parser_template'=>&$that->post['parser_template'],
                                'prefix_source_name'=>$that->post['prefix_source_name'],
                                'str'=>$str,
                                'rows'=>&$rows,
                                'file_location'=>&$file,
                                'table_cols'=>&$table_cols,
                                'processed'=>&$processed
                            );
                            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/scripts/admin_pages/admin_import.php']['TmpproductImportParserTemplateProc'] as $funcRef) {
                                 \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $that);
                            }
                        }
                        */
                    } else {
                        if ($str && mslib_befe::isSerializedString($str)) {
                            $tmpData = unserialize($str);
                            $counter = 0;
                            foreach ($tmpData as $data) {
                                $colCounter = 0;
                                if ($counter == 0) {
                                    $row = array();
                                    foreach ($data as $key => $val) {
                                        $row[] = $key;
                                    }
                                    $table_cols = $row;
                                }
                                $row = array();
                                foreach ($data as $key => $val) {
                                    $row[] = $val;
                                }
                                $rows[] = $row;
                                $counter++;
                            }
                        } elseif ($that->post['database_name']) {
                            if (is_numeric($that->get['limit'])) {
                                $limit = $that->get['limit'];
                            } else {
                                $limit = 2000;
                            }
                            if (strstr(mslib_befe::strtolower($that->post['database_name']), 'select ')) {
                                $that->databaseMode = 'query';
                                // its not a table name, its a full query
                                $that->databaseMode = 'query';
                                $str = $that->post['database_name'] . ' LIMIT ' . $limit;
                                $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
                                if ($that->conf['debugEnabled'] == '1') {
                                    $logString = 'Load records for importer query: ' . $str;
                                    \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($logString, 'multishop', -1);
                                }
                                $datarows = array();
                                while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) != false) {
                                    $datarows[] = $row;
                                }
                            } else {
                                // get primary key first
                                $str = "show index FROM " . $that->post['database_name'] . ' where Key_name = \'PRIMARY\'';
                                $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
                                $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry);
                                $primaryKeyColumn = $row['Column_name'];
                                $query = $GLOBALS['TYPO3_DB']->SELECTquery('*', $that->post['database_name'], '', '', '', $limit);
                                $qry = $GLOBALS['TYPO3_DB']->sql_query($query);
                                $datarows = array();
                                while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) != false) {
                                    $datarows[] = $row;
                                    if ($primaryKeyColumn and isset($row[$primaryKeyColumn])) {
                                        $str2 = "delete from " . $that->post['database_name'] . " where " . $primaryKeyColumn . "='" . $row[$primaryKeyColumn] . "'";
                                        $qry2 = $GLOBALS['TYPO3_DB']->sql_query($str2);
                                    }
                                }
                            }
                            $total_datarows = count($datarows);
                            if ($that->msLogFile) {
                                file_put_contents($that->msLogFile, $that->HTTP_HOST . ' - loaded (' . $total_datarows . ') records. (' . date("Y-m-d G:i:s") . ")\n", FILE_APPEND);
                            }
                            $i = 0;
                            $rows = array();
                            foreach ($datarows as $datarow) {
                                $s = 0;
                                foreach ($datarow as $datacol) {
                                    $rows[$i][$s] = $datacol;
                                    $s++;
                                }
                                $i++;
                            }
                        } elseif ($that->post['format'] == 'excel') {
                            // excel
                            $paths = array();
                            $paths[] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('phpexcel_service') . 'Resources/Private/Contributed/PHPExcel/IOFactory.php';
                            $paths[] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('phpexcel_service') . 'Classes/PHPExcel/IOFactory.php';
                            foreach ($paths as $path) {
                                if (file_exists($path)) {
                                    require_once $path;
                                    break;
                                }
                            }
                            $phpexcel = PHPExcel_IOFactory::load($file);
                            foreach ($phpexcel->getWorksheetIterator() as $worksheet) {
                                $counter = 0;
                                foreach ($worksheet->getRowIterator() as $row) {
                                    $cellIterator = $row->getCellIterator();
                                    $cellIterator->setIterateOnlyExistingCells(false);
                                    foreach ($cellIterator as $cell) {
                                        $clean_products_data = ltrim(rtrim($cell->getCalculatedValue(), " ,"), " ,");
                                        $clean_products_data = trim($clean_products_data);
                                        if ($row->getRowIndex() > 1) {
                                            $rows[$counter - 1][] = $clean_products_data;
                                        } else {
                                            $table_cols[] = mslib_befe::strtolower($clean_products_data);
                                        }
                                    }
                                    $counter++;
                                }
                            }
                            // excel eof
                        } elseif ($that->post['format'] == 'xml') {
                            $objXML = new xml2Array();
                            $arrOutput = $objXML->parse($str);
                            $i = 0;
                            $s = 0;
                            $rows = array();
                            foreach ($arrOutput[0]['children'] as $item) {
                                // image
                                foreach ($item['children'] as $internalitem) {
                                    $rows[$i][$s] = $internalitem['tagData'];
                                    $s++;
                                }
                                foreach ($item['attrs'] as $key => $value) {
                                    $rows[$i][$s] = $value;
                                    $s++;
                                }
                                $i++;
                                $s = 0;
                            }
                        } else {
                            if ($that->post['os'] == 'linux') {
                                $splitter = "\n";
                            } else {
                                $splitter = "\r\n";
                            }
                            $str = trim($str, $splitter);
                            if ($that->post['escape_first_line']) {
                                $pos = strpos($str, $splitter);
                                $str = substr($str, $pos + strlen($splitter));
                            }
                            // csv
                            if ($that->post['delimiter'] == "tab") {
                                $delimiter = "\t";
                            } elseif ($that->post['delimiter'] == "dash") {
                                $delimiter = "|";
                            } elseif ($that->post['delimiter'] == "dotcomma") {
                                $delimiter = ";";
                            } elseif ($that->post['delimiter'] == "comma") {
                                $delimiter = ",";
                            } else {
                                $delimiter = "\t";
                            }
                            if ($that->post['backquotes']) {
                                $backquotes = '"';
                            } else {
                                $backquotes = '"';
                            }
                            if ($that->post['format'] == 'txt') {
                                $row = 1;
                                $rows = array();
                                if (($handle = fopen($file, "r")) !== false) {
                                    $counter = 0;
                                    while (($data = fgetcsv($handle, '', $delimiter, $backquotes)) !== false) {
                                        if ($that->post['escape_first_line']) {
                                            if ($counter == 0) {
                                                $table_cols = $data;
                                            } else {
                                                $rows[] = $data;
                                            }
                                        } else {
                                            $rows[] = $data;
                                        }
                                        $counter++;
                                    }
                                    fclose($handle);
                                }
                            }
                            // csv
                        }
                    }
                    $item_counter = 0;
                    $inserteditems = array();
                    $global_start_time = microtime(true);
                    $start_time = microtime(true);
                    $total_datarows = count($rows);
                    if ($that->msLogFile) {
                        if ($total_datarows) {
                            // sometimes the preload takes so long that the database connection is lost.
                            $GLOBALS['TYPO3_DB']->connectDB();
                            file_put_contents($that->msLogFile, $that->HTTP_HOST . ' - ' . $params['importKey'] . ' importer loaded, now starting the import. (' . date("Y-m-d G:i:s") . ")\n", FILE_APPEND);
                        } else {
                            file_put_contents($that->msLogFile, $that->HTTP_HOST . ' - no records needed to be imported' . "\n", FILE_APPEND);
                        }
                    }
                    // $global_start_time = microtime();
                    foreach ($rows as $row) {
                        foreach ($row as $key => $col) {
                            if (!mb_detect_encoding($col, 'UTF-8', true)) {
                                if ($col == 'NULL' || $col == 'null') {
                                    $col = '';
                                }
                                $row[$key] = mslib_befe::convToUtf8($col);
                            }
                        }
                        $that->ms['target-cid'] = $that->post['cid'];
                        $teller++;
                        if ($that->post['escape_first_line'] and $teller > 1 or !$that->post['escape_first_line']) {
                            $tmpitem = $row;
                            $cols = count($tmpitem);
                            $flipped_select = array_flip($that->post['select']);
                            // if($tmpitem[$that->post['select'][0]] and $cols > 0)
                            // {
                            $item = array();
                            // if the source is a database table name add the unique id
                            // so we can delete it after the import
                            if ($that->post['database_name']) {
                                $item['table_unique_id'] = $row[0];
                            }
                            // aux
                            $input = array();
                            // name
                            for ($i = 0; $i < $cols; $i++) {
                                $tmpitem[$i] = trim($tmpitem[$i]);
                                $char = '';
                                $item[$that->post['select'][$i]] = $tmpitem[$i];
                                if ($item[$that->post['select'][$i]] == $char and $char) {
                                    $item[$that->post['select'][$i]] = '';
                                }
                                $input[$that->post['select'][$i]] = $that->post['input'][$i];
                            }
                            if ($jobArray['predefined_variables']) {
                                $array = unserialize($jobArray['predefined_variables']);
                                foreach ($array as $col => $val) {
                                    $item[$col] = $val;
                                }
                            }
                            // custom hook that can be controlled by third-party plugin
                            if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.tx_mslib_admin_import.php']['msAdminImportItemIterateProc'])) {
                                $params = array('importKey' => &$params['importKey'], 'row' => &$row, 'item' => &$item, 'prefix_source_name' => $that->post['prefix_source_name'], 'params' => &$params, 'content' => &$content);
                                foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.tx_mslib_admin_import.php']['msAdminImportItemIterateProc'] as $funcRef) {
                                    \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $that);
                                }
                            }
                        }
                        if ($log_file) {
                            $content = '';
                        }
                        // end foreach
                    }
                    // if($file_location and file_exists($file_location))
                    // @unlink($file_location);
                }
            }
            // end import
        } else {
            $that->ms['show_default_form'] = 1;
        }
        if ($that->ms['show_default_form']) {
            $that->ms['upload_' . $params['importKey'] . 'feed_form'] .= self::renderImportJobProperties($params, $that);
            $content .= '<div class="panel-body"><form action="' . $params['postForm']['actionUrl'] . '" method="post" enctype="multipart/form-data" name="form1" id="form1" class="form-horizontal">';
            $content .= $that->ms['upload_' . $params['importKey'] . 'feed_form'];
            $content .= '</form>';
            // load the jobs templates
            $str = "SELECT * from tx_multishop_import_jobs where page_uid='" . $that->shop_pid . "' and type='" . addslashes($params['importKey']) . "' order by prefix_source_name asc, id desc";
            $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
            $jobs = array();
            while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) != false) {
                $jobs[] = $row;
            }
            if (count($jobs) > 0) {
                $schedule_content .= '
		<div class="panel panel-default" id="scheduled_import_jobs_form"><div class="panel-heading"><h3>' . $that->pi_getLL('import_tasks') . '</h3></div>
		<div class="panel-body">
		<table class="table table-striped table-bordered no-mb" id="msAdminImportTableInterface">
		<thead>
		<tr>
		<th>' . $that->pi_getLL('source_name') . '</th>
		<th class="cellName">' . $that->pi_getLL('name') . '</th>
		<th class="cellDate">' . $that->pi_getLL('last_run') . '</th>
		<th>' . $that->pi_getLL('action') . '</th>
		<th class="cellStatus">' . ucfirst($that->pi_getLL('status')) . '</th>
		<th class="cellAction">' . ucfirst($that->pi_getLL('delete')) . '</th>
		<th class="cellStatus">' . $that->pi_getLL('file_exists') . '</th>
		<th>' . $that->pi_getLL('upload_file') . '</th>
		<th>' . $that->pi_getLL('download_import_task') . '</th>
		</tr>
		</thead>
		';
                $switch = '';
                $schedule_content .= '<tbody>';
                foreach ($jobs as $job) {
                    if ($switch == 'odd') {
                        $switch = 'even';
                    } else {
                        $switch = 'odd';
                    }
                    $schedule_content .= '<tr class="' . $switch . '">';
                    $schedule_content .= '<td>' . $job['prefix_source_name'] . '</td>
			<td class="cellName"><a href="' . $params['postForm']['actionUrl'] . '&job_id=' . $job['id'] . '&action=edit_job">' . $job['name'] . '</a></td>
			';
                    $lastRun = '';
                    if ($job['last_run'] > 0) {
                        $lastRun = date("Y-m-d", $job['last_run']) . '<br />' . date("G:i:s", $job['last_run']);
                    }
                    $schedule_content .= '<td class="cellDate">' . $lastRun . '</td>';
                    if (!$job['period']) {
                        $schedule_content .= '<td>manual<br /><a href="' . $params['postForm']['actionUrl'] . '&job_id=' . $job['id'] . '&action=run_job&limit=99999999" class="btn btn-success" onClick="return CONFIRM(\'' . addslashes($that->pi_getLL('are_you_sure_you_want_to_run_the_import_job')) . ': ' . htmlspecialchars(addslashes($job['name'])) . '?\')"><i>' . $that->pi_getLL('run_now') . '</i></a><br /><a href="" class="copy_to_clipboard" rel="' . htmlentities('/usr/bin/wget -O /dev/null --tries=1 --timeout=30 -q "' . $that->FULL_HTTP_URL . $params['postForm']['actionUrl'] . '&job_id=' . $job['id'] . '&code=' . $job['code'] . '&action=run_job&run_as_cron=1&limit=99999999" >/dev/null 2>&1') . '" ><i>' . $that->pi_getLL('run_by_crontab') . '</i></a></td>';
                    } else {
                        $schedule_content .= '<td>' . date("Y-m-d G:i:s", $job['last_run'] + $job['period']) . '</td>';
                    }
                    $schedule_content .= '<td class="cellStatus">';
                    if (!$job['status']) {
                        $schedule_content .= '<span class="admin_status_red" alt="Disable"></span>';
                        $schedule_content .= '<a href="' . $params['postForm']['actionUrl'] . '&job_id=' . $job['id'] . '&status=1"><span class="admin_status_green disabled" alt="Enabled"></span></a>';
                    } else {
                        $schedule_content .= '<a href="' . $params['postForm']['actionUrl'] . '&job_id=' . $job['id'] . '&status=0"><span class="admin_status_red disabled" alt="Disabled"></span></a>';
                        $schedule_content .= '<span class="admin_status_green" alt="Enable"></span>';
                    }
                    $schedule_content .= '</td>
			<td class="cellAction">
			<a href="' . $params['postForm']['actionUrl'] . '&delete=1&&job_id=' . $job['id'] . '&action=delete_job" onClick="return CONFIRM(\'Are you sure you want to delete the import job: ' . htmlspecialchars($job['name']) . '?\')" alt="Remove ' . htmlspecialchars($job['name']) . '" class="btn btn-danger btn-sm admin_menu_remove" title="Remove ' . htmlspecialchars($job['name']) . '"><i class="fa fa-trash-o"></i></a>
			</td>
			<td class="cellStatus">
				';
                    $data = unserialize($job['data']);
                    if ($data[1]['filename']) {
                        $file_location = $that->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . $data[1]['filename'];
                        if (file_exists($file_location)) {
                            $schedule_content .= '<span class="admin_status_green" alt="Enable"></span>';
                        } else {
                            $schedule_content .= '<span class="admin_status_red" alt="Disable"></span>';
                        }
                    }
                    $schedule_content .= '
			</td>
			<td>
			 	<form action="' . $params['postForm']['actionUrl'] . '" method="post" enctype="multipart/form-data" name="form1" id="form1">
			 		<div class="input-group">
					<input type="file" name="file" class="form-control" style="width:300px" />
					<input name="skip_import" type="hidden" value="1" />
					<input name="preProcExistingTask" type="hidden" value="1" />
					<input name="job_id" type="hidden" value="' . $job['id'] . '" />
					<input name="action" type="hidden" value="edit_job" />
					<span class="input-group-btn">
					<input type="submit" name="Submit" class="submit btn btn-success" id="cl_submit" value="' . $that->pi_getLL('upload') . '" />
					</span>
					</div>
				</form>
			</td>
			<td>
				<a href="' . $params['postForm']['actionUrl'] . '&download=task&job_id=' . $job['id'] . '" class="btn btn-success"><i class="fa fa-download"></i> ' . $that->pi_getLL('download_import_task') . '</a>
			</td>
			';
                    $schedule_content .= '</tr>';
                }
                $schedule_content .= '</tbody>';
                $schedule_content .= '</table>
		</div>
		</div>
		<script type="text/javascript">
		jQuery(document).ready(function($) {
			$(".copy_to_clipboard").click(function(event) {
				event.preventDefault();
				var string=$(this).attr("rel");
				$.blockUI({
				theme:     true,
				title:    \'' . addslashes($that->pi_getLL('copy_below_text_and_add_it_to_crontab')) . '\',
				message:  \'<p>\'+string+\'</p>\',
				timeout:   8000
				});
			});
		});
		</script>
		';
                $tmptab = '';
                $content .= $schedule_content;
                //$tabs['tasks']=array($that->pi_getLL('import_tasks'),$schedule_content);
            }
            // load the jobs templates eof
            if ($this->ROOTADMIN_USER) {
                $content .= '
				<div id="scheduled_import_jobs_form" class="panel panel-default">
				<div class="panel-heading"><h3>' . $that->pi_getLL('upload_import_task') . '</h3></div>
				<div class="panel-body">
					<form action="' . $params['postForm']['actionUrl'] . '&upload=task" method="post" enctype="multipart/form-data" name="upload_task" id="upload_task" class="form-horizontal blockSubmitForm">
						<div class="form-group">
							<label for="new_cron_name" class="control-label col-md-2">' . $that->pi_getLL('name') . '</label>
							<div class="col-md-10">
								<input name="new_cron_name" type="text" class="form-control" value="" size="125">
							</div>
						</div>
						<div class="form-group">
							<label for="new_prefix_source_name" class="control-label col-md-2">' . $that->pi_getLL('source_name') . '</label>
							<div class="col-md-10">
								<input name="new_prefix_source_name" type="text" class="form-control" value="" />
							</div>
						</div>
						<div class="form-group">
							<label for="upload_task_file" class="control-label col-md-2">' . $that->pi_getLL('file') . '</label>
							<div class="col-md-10">
								<input type="file" name="task_file" class="form-control">
							</div>
						</div>
						<div class="form-group">
							<div class="col-md-10 col-md-offset-2">
								<input type="submit" name="upload_task_file" class="submit btn btn-success" id="upload_task_file" value="upload">
							</div>
						</div>
					</form>
				</div>
				</div>';
            }
        }
        $content .= '<hr><div class="clearfix"><a class="btn btn-success msAdminBackToCatalog" href="' . mslib_fe::typolink() . '"><span class="fa-stack"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-arrow-left fa-stack-1x"></i></span> ' . $that->pi_getLL('admin_close_and_go_back_to_catalog') . '</a></div></div>';
        $content = '<div class="panel panel-default">' . mslib_fe::shadowBox($content) . '</div>';
        return $content;
    }