* All rights reserved * * This script is part of the TYPO3 project. The TYPO3 project is * free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * The GNU General Public License can be found at * http://www.gnu.org/copyleft/gpl.html. * * This script is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ /** * [CLASS/FUNCTION INDEX of SCRIPT] * * Hint: use extdeveval to insert/update function index above. */ global $ms,$get,$server,$post; class mslib_fe { /** * @param test admin panel $ms_menu * @param type of the menu $type * @return string */ function createAdminPanel($ms_menu,$type='header') { $admin_content=''; $total_tabs=count($ms_menu); $tab_counter=0; foreach ($ms_menu as $tablevel1_key => $tablevel1) { $tab_counter++; $admin_content.='
  • '; if (!$tablevel1['label'] and $tablevel1['description']) { $admin_content.=$tablevel1['description']; } else { if (!is_array($tablevel1['subs'])) { if ($tablevel1['link']) { $admin_content.=''.$tablevel1['label'].''; } else { $admin_content.=$tablevel1['label']; } } else { $total_tablevel2=count($tablevel1['subs']); $counter_tablevel2=0; if ($tablevel1['link']) { $admin_content.=''.$tablevel1['label'].''; } else { $admin_content.=''.$tablevel1['label'].''; } $admin_content.=''; } } $admin_content.='
  • '; } return $admin_content; } function getProductRelativesBox ($product,$type='relatives',$limit=20) { global $ms; $filter =array(); $having =array(); $match =array(); $orderby =array(); $where =array(); $orderby =array(); $select =array(); if ($ms['MODULES']['SHOW_PRODUCTS_WITH_IMAGE_FIRST']) { if (!$ms['MODULES']['FLAT_DATABASE']) { $prefix='p.'; } else $prefix=''; $tmp_orderby=array(); $tmp_orderby[]=$prefix.'contains_image desc'; $tmp_orderby=array_merge($tmp_orderby,$orderby); $orderby=$tmp_orderby; } switch ($type) { case 'relatives': $data = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('products_id,relative_product_id','tx_multishop_products_to_relative_products',"(products_id = '".$product['products_id']."' or relative_product_id = '".$product['products_id']."')"); $product_ids=array(); foreach ($data as $item) { if ($product['products_id']==$item['relative_product_id']) $product_ids[]=$item['products_id']; else $product_ids[]=$item['relative_product_id']; } if (!count($product_ids)) return false; if (!$ms['MODULES']['FLAT_DATABASE']) $prefix='p.'; else $prefix=''; $filter[]=$prefix."products_id IN (".implode(',',$product_ids).")"; break; case 'categories_id': if ($ms['MODULES']['FLAT_DATABASE']) { $filter[]='categories_id='.$product['categories_id']; } else { $filter[]='c.categories_id='.$product['categories_id']; } break; case 'specials': if ($ms['MODULES']['FLAT_DATABASE']) { $filter[]='sstatus=1'; } else { $filter[]='s.status=1'; } break; case 'products_model': if (strlen($product['products_model']) >2) { $array=explode(" ",$product['products_model']); $total=count($array); $oldsearch=0; foreach ($array as $item) { if (strlen($item) < 2) { $oldsearch=1; break; } } if ($ms['MODULES']['FLAT_DATABASE']) $tbl=''; else $tbl='p.'; if ($oldsearch) { // do normal indexed search $filter[]="(".$tbl."products_model like '".addslashes($product['products_model'])."%')"; } else { // do fulltext search $tmpstr=addslashes(mslib_befe::ms_implode(', ', $array,'"','+',true)); $select[] ="MATCH (".$tbl."products_model) AGAINST ('".$tmpstr."' in boolean mode) AS score"; $where[] ="MATCH (".$tbl."products_model) AGAINST ('".$tmpstr."' in boolean mode)"; $orderby[] ='score desc'; } } break; } if (is_numeric($get['manufacturers_id'])) { if ($ms['MODULES']['FLAT_DATABASE']) $tbl=''; else $tbl='p.'; $filter[]="(".$tbl."manufacturers_id='".addslashes($get['manufacturers_id'])."')"; } if ($ms['MODULES']['FLAT_DATABASE']) $tbl=''; else $tbl='p.'; $filter[]="(".$tbl."products_id <> '".$product['products_id']."')"; if ($ms['MODULES']['FLAT_DATABASE'] and count($having)) { $filter[]=$having[0]; unset($having); } $pageset=mslib_fe::getProductsPageSet($filter,$offset,0,$orderby,$having,$select,$where); $products=$pageset['products']; if ($pageset['total_rows'] > 0) { $content = ''; if ($pageset['total_rows']) { if (!$ms['MODULES']['PRODUCTS_RELATIVES_TYPE']) $ms['MODULES']['PRODUCTS_RELATIVES_TYPE']='default'; if (strstr($ms['MODULES']['PRODUCTS_RELATIVES_TYPE'],"..")) die('error in PRODUCTS_RELATIVES_TYPE value'); else { if (strstr($ms['MODULES']['PRODUCTS_RELATIVES_TYPE'],"/")) require($this->DOCUMENT_ROOT.$ms['MODULES']['PRODUCTS_RELATIVES_TYPE'].'.php'); else require('includes/products_relatives/'.$ms['MODULES']['PRODUCTS_RELATIVES_TYPE'].'.php'); } } } return $content; } function final_products_price ($product,$quantity=1,$add_currency=1,$ignore_minimum_quantity=0) { global $ms; if (!$ignore_minimum_quantity) { if ($quantity and $product['minimum_quantity'] > $quantity) { // check if the product has a minimum quantity $quantity=$product['minimum_quantity']; $sum=1; } } if ($product['staffel_price']) { $final_price=(mslib_fe::calculateStaffelPrice($product['staffel_price'],$quantity)/$quantity); } else { $final_price=($product['final_price']); } if ($sum) { $final_price=($product['final_price']*$quantity); } if ($product['tax_rate'] and $ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) { if (!$ms['MODULES']['DB_PRICES_INCLUDE_VAT']) { // in this mode the stored prices in the tx_multishop_products are excluding VAT and we have to add it manually $final_price=$final_price*(1+$product['tax_rate']); } } if ($add_currency) return mslib_fe::Money2Cents2($final_price); else return $final_price; } function url_exists($url) { $handle = curl_init($url); if (false === $handle) { return false; } curl_setopt($handle, CURLOPT_HEADER, false); curl_setopt($handle, CURLOPT_FAILONERROR, true); // this works curl_setopt($handle, CURLOPT_NOBODY, true); curl_setopt($handle, CURLOPT_RETURNTRANSFER, false); $connectable = curl_exec($handle); curl_close($handle); return $connectable; } function xml2array($contents, $get_attributes=0) { if(!$contents) return array(); if(!function_exists('xml_parser_create')) { //print "'xml_parser_create()' function not found!"; return array(); } //Get the XML parser of PHP - PHP must have this module for the parser to work $parser = xml_parser_create(); xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0 ); xml_parser_set_option( $parser, XML_OPTION_SKIP_WHITE, 1 ); xml_parse_into_struct( $parser, $contents, $xml_values ); xml_parser_free( $parser ); if(!$xml_values) return;//Hmm... //Initializations $xml_array = array(); $parents = array(); $opened_tags = array(); $arr = array(); $current = &$xml_array; //Go through the tags. foreach($xml_values as $data) { unset($attributes,$value);//Remove existing values, or there will be trouble //This command will extract these variables into the foreach scope // tag(string), type(string), level(int), attributes(array). extract($data);//We could use the array by itself, but this cooler. $result = ''; if($get_attributes) {//The second argument of the function decides this. $result = array(); if(isset($value)) $result['value'] = $value; //Set the attributes too. if(isset($attributes)) { foreach($attributes as $attr => $val) { if($get_attributes == 1) $result['attr'][$attr] = $val; //Set all the attributes in a array called 'attr' /** :TODO: should we change the key name to '_attr'? Someone may use the tagname 'attr'. Same goes for 'value' too */ } } } elseif(isset($value)) { $result = $value; } //See tag status and do the needed. if($type == "open") {//The starting of the tag '' $parent[$level-1] = &$current; if(!is_array($current) or (!in_array($tag, array_keys($current)))) { //Insert New tag $current[$tag] = $result; $current = &$current[$tag]; } else { //There was another element with the same tag name if(isset($current[$tag][0])) { array_push($current[$tag], $result); } else { $current[$tag] = array($current[$tag],$result); } $last = count($current[$tag]) - 1; $current = &$current[$tag][$last]; } } elseif($type == "complete") { //Tags that ends in 1 line '' //See if the key is already taken. if(!isset($current[$tag])) { //New Key $current[$tag] = $result; } else { //If taken, put all things inside a list(array) if((is_array($current[$tag]) and $get_attributes == 0)//If it is already an array... or (isset($current[$tag][0]) and is_array($current[$tag][0]) and $get_attributes == 1)) { array_push($current[$tag],$result); // ...push the new element into that array. } else { //If it is not an array... $current[$tag] = array($current[$tag],$result); //...Make it an array using using the existing value and the new value } } } elseif($type == 'close') { //End of tag '' $current = &$parent[$level-1]; } } return($xml_array); } function String2Array ($var) { $ms =array(); if ($var) { $records=explode("\n",trim($var)); foreach ($records as $record) { $record=trim($record); preg_match("/^(.*?)\=(.*?)$/",$record,$tmpitem); $item=array(); $item[0]=trim($tmpitem[1]); $item[1]=trim($tmpitem[2]); if ($item[0] !='keyword' and $item[0] !='label') { if (strstr($item[1],",")) { $selected=explode(",",$item[1]); $ms['parameters'][$item[0]]=array(); if (count($selected) >1) foreach ($selected as $select) $ms['parameters'][$item[0]][]=$select; else $ms['parameters'][$item[0]]=$item[1]; } else $ms['parameters'][$item[0]]=$item[1]; } else $ms['parameters'][$item[0]]=$item[1]; } } return $ms['parameters']; } function image_type_to_extension($imagetype,$include_dot=false) { if(empty($imagetype)) return false; $dot = $include_dot ? $dot.'' : ''; switch($imagetype) { case IMAGETYPE_GIF : return $dot.'gif'; case IMAGETYPE_JPEG : return $dot.'jpg'; case IMAGETYPE_PNG : return $dot.'png'; case IMAGETYPE_SWF : return $dot.'swf'; case IMAGETYPE_PSD : return $dot.'psd'; case IMAGETYPE_WBMP : return $dot.'wbmp'; case IMAGETYPE_XBM : return $dot.'xbm'; case IMAGETYPE_TIFF_II : return $dot.'tiff'; case IMAGETYPE_TIFF_MM : return $dot.'tiff'; case IMAGETYPE_IFF : return $dot.'aiff'; case IMAGETYPE_JB2 : return $dot.'jb2'; case IMAGETYPE_JPC : return $dot.'jpc'; case IMAGETYPE_JP2 : return $dot.'jp2'; case IMAGETYPE_JPX : return $dot.'jpf'; case IMAGETYPE_SWC : return $dot.'swc'; case 1 : return $dot.'gif'; case 2 : return $dot.'jpg'; case 3 : return $dot.'png'; case 4 : return $dot.'swf'; case 5 : return $dot.'psd'; case 6 : return $dot.'jpg'; case 7 : return $dot.'tiff'; case 8 : return $dot.'tiff'; case 9 : return $dot.'jpc'; case 10 : return $dot.'jp2'; case 11 : return $dot.'jpx'; case 12 : return $dot.'jb2'; case 13 : return $dot.'swc'; case 14 : return $dot.'aiff'; case 15 : return $dot.'wbmp'; case 16 : return $dot.'xbm'; default : return false; } } //// // wrapper to in_array() for PHP3 compatibility // Checks if the lookup value exists in the lookup array function tep_in_array($lookup_value, $lookup_array) { if (function_exists('in_array')) { if (in_array($lookup_value, $lookup_array)) return true; } else { reset($lookup_array); while (list($key, $value) = each($lookup_array)) { if ($value == $lookup_value) return true; } } return false; } //// // Return all HTTP GET variables, except those passed as a parameter function tep_get_all_get_params($exclude_array = '',$hidden_fields=0) { $get = t3lib_div::_GET(); $get['SPECIAL']=''; if ($exclude_array == '') $exclude_array = array(); $get_url = ''; if (is_array($get)) { reset($get); while (list($key, $value) = each($get)) { if (!mslib_fe::tep_in_array($key, $exclude_array)) { if (!is_array($value)) { if ((strlen($value) > 0) && ($key != session_name()) && ($key != 'error') && (!mslib_fe::tep_in_array($key, $exclude_array))) { if ($hidden_fields) $get_url .= ''."\n"; else $get_url .= $key . '=' . rawurlencode(stripslashes($value)) . '&'; } } else { foreach ($value as $$key => $$value) { $string=$key.'['.$$key.']'; if (!mslib_fe::tep_in_array($string, $exclude_array)) { if (!is_array($$value)) { if ((strlen($$value) > 0) && ($key != session_name()) && ($key != 'error')) { if ($hidden_fields) $get_url .= ''."\n"; else $get_url .= $key . rawurlencode('['.$$key.']') . '=' . rawurlencode(stripslashes($$value)) . '&'; } } else { foreach ($$value as $k => $v) { if ((strlen($v) > 0) && ($key != session_name()) && ($key != 'error')) { if ($hidden_fields) $get_url .= ''."\n"; else $get_url .= $key . rawurlencode('['.$$key.'][]') . '=' . rawurlencode(stripslashes($v)) . '&'; } } } } } } } } } return $get_url; } function getUser ($value, $type='uid') { if ($value) { if ($type=='username') { $query = $GLOBALS['TYPO3_DB']->SELECTquery( '*', // SELECT ... 'fe_users', // FROM ... 'username="'.addslashes($value).'"', // WHERE... '', // GROUP BY... '', // ORDER BY... '' // LIMIT ... ); } elseif ($type=='email') { $query = $GLOBALS['TYPO3_DB']->SELECTquery( '*', // SELECT ... 'fe_users', // FROM ... 'email="'.addslashes($value).'"', // WHERE... '', // GROUP BY... '', // ORDER BY... '' // LIMIT ... ); } elseif ($type=='code') { $query = $GLOBALS['TYPO3_DB']->SELECTquery( '*', // SELECT ... 'fe_users', // FROM ... 'tx_multishop_code="'.addslashes($value).'"', // WHERE... '', // GROUP BY... '', // ORDER BY... '' // LIMIT ... ); } else { $query = $GLOBALS['TYPO3_DB']->SELECTquery( '*', // SELECT ... 'fe_users', // FROM ... 'uid="'.addslashes($value).'"', // WHERE... '', // GROUP BY... '', // ORDER BY... '' // LIMIT ... ); } $res = $GLOBALS['TYPO3_DB']->sql_query($query); $tel=0; if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) { $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); return $row; } } else return 0; } function getManufacturer ($value, $type='manufacturers_id') { if ($value) { $query = $GLOBALS['TYPO3_DB']->SELECTquery( '*', // SELECT ... 'tx_multishop_manufacturers', // FROM ... $type.'="'.$value.'"', // WHERE... '', // GROUP BY... '', // ORDER BY... '' // LIMIT ... ); $res = $GLOBALS['TYPO3_DB']->sql_query($query); $tel=0; if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) { $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); return $row; } } else return 0; } function getGroup ($value,$type='title') { if ($value) { if ($type=='uid') { $query = $GLOBALS['TYPO3_DB']->SELECTquery( '*', // SELECT ... 'fe_groups', // FROM ... 'uid="'.$value.'"', // WHERE... '', // GROUP BY... '', // ORDER BY... '' // LIMIT ... ); } else { $query = $GLOBALS['TYPO3_DB']->SELECTquery( '*', // SELECT ... 'fe_groups', // FROM ... 'title="'.$value.'"', // WHERE... '', // GROUP BY... '', // ORDER BY... '' // LIMIT ... ); } $res = $GLOBALS['TYPO3_DB']->sql_query($query); $tel=0; if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) { $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); return $row; } } else return 0; } /* function getUsersByGroup($group_id) { $filter=array(); $filter[]='disable=0'; $filter[]='FIND_IN_SET(\''.$group_id.'\',usergroup) > 0'; $users=mslib_fe::getUsers($filter); return $users; } */ function getUsers ($groupid,$orderby='company') { if (is_numeric($groupid) and $groupid >0) { if (!$this->masterShop) { $filter="page_uid='".$this->shop_pid."' and "; } $filter.="FIND_IN_SET('".$groupid."',usergroup) > 0"; $query = $GLOBALS['TYPO3_DB']->SELECTquery( '*', // SELECT ... 'fe_users', // FROM ... $filter, // WHERE... '', // GROUP BY... $orderby, // ORDER BY... '' // LIMIT ... ); $res = $GLOBALS['TYPO3_DB']->sql_query($query); $tel=0; if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) { $array=array(); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $array[]=$row; } return $array; } } else return 0; } function getSignedInUsers ($groupid='',$orderby='company') { $time=(time()-350); $query = $GLOBALS['TYPO3_DB']->SELECTquery( '*', // SELECT ... 'fe_users', // FROM ... 'is_online >= '.$time, // WHERE... '', // GROUP BY... $orderby, // ORDER BY... '' // LIMIT ... ); $res = $GLOBALS['TYPO3_DB']->sql_query($query); $tel=0; $array=array(); if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) { while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $array[]=$row; } } return $array; } function ifRootAdmin ($uid,$usergroup) { if (is_numeric($usergroup)) $admin_group=$usergroup; else die("no admin group defined yet. Please add the admin usergroup to the constants field in the Typo3 template."); if (is_numeric($uid) and $uid >0) { global $ms; $query = $GLOBALS['TYPO3_DB']->SELECTquery( '*', // SELECT ... 'fe_users', // FROM ... 'uid=\''.$uid.'\' and FIND_IN_SET(\''.$admin_group.'\',usergroup) > 0', // WHERE... '', // GROUP BY... 'company', // ORDER BY... '' // LIMIT ... ); $res = $GLOBALS['TYPO3_DB']->sql_query($query); $tel=0; if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) { return 1; } } else return 0; } function rewritenamein($input,$id='') { if (mb_detect_encoding($input, 'UTF-8', true)=='UTF-8') { $input=utf8_decode($input); } $input=strtolower($input); $input=self::normaliza($input); $input=strip_tags($input); $input=preg_replace("/[^[:alnum:]+]/i","-",$input); $input=str_replace("\\","-",$input); $input = preg_replace('/-+/', '-', $input); $input = trim($input,'_'); $input = trim($input,'/'); $input = trim($input); if ($id) $final_file=$input.'-'.$id; else $final_file=$input; $final_file=rtrim($final_file,'-'); return urlencode($final_file); } function normaliza ($string){ $normalizeChars = array( '�'=>'S', '�'=>'s', '�'=>'Dj','�'=>'Z', '�'=>'z', '�'=>'A', '�'=>'A', '�'=>'A', '�'=>'A', '�'=>'A', '�'=>'A', '�'=>'A', '�'=>'C', '�'=>'E', '�'=>'E', '�'=>'E', '�'=>'E', '�'=>'I', '�'=>'I', '�'=>'I', '�'=>'I', '�'=>'N', '�'=>'O', '�'=>'O', '�'=>'O', '�'=>'O', '�'=>'O', '�'=>'O', '�'=>'U', '�'=>'U', '�'=>'U', '�'=>'U', '�'=>'Y', '�'=>'B', '�'=>'Ss','�'=>'a', '�'=>'a', '�'=>'a', '�'=>'a', '�'=>'a', '�'=>'a', '�'=>'a', '�'=>'c', '�'=>'e', '�'=>'e', '�'=>'e', '�'=>'e', '�'=>'i', '�'=>'i', '�'=>'i', '�'=>'i', '�'=>'o', '�'=>'n', '�'=>'o', '�'=>'o', '�'=>'o', '�'=>'o', '�'=>'o', '�'=>'o', '�'=>'u', '�'=>'u', '�'=>'u', '�'=>'y', '�'=>'y', '�'=>'b', '�'=>'y', '�'=>'f' ); $string=strtr($string, $normalizeChars); return $string; } function SqlDate ($sqldatetime) { $user_date = date("Y-m-d", strtotime($sqldatetime)); return $user_date; } function orderhasitems ($orders_id) { $str="select * from orders_products where orders_id='".$orders_id."'"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry)) return 1; else return 0; } function Money2DutchString($input,$add_currency=1) { global $ms; if (is_numeric($input)) { if ($add_currency) $content.=$ms['MODULES']['CURRENCY']." "; $content.=number_format($input,2,$ms['MODULES']['CURRENCY_ARRAY']['cu_decimal_point'],$ms['MODULES']['CURRENCY_ARRAY']['cu_thousands_point']); return $content; } } function Money2PDFDutchString($input,$add_currency=1) { if (is_numeric($input)) { if ($add_currency) $content.=chr(128)." "; $content.=number_format($input,2,',','.'); return $content; } } function Datetime2Time($indate){ //YYYY-MM-DD HH:mm:ss.splits $indate = explode(" ", $indate); $dateArr = explode("-", $indate[0]); $timeArr = explode(":", $indate[1]); $timeArr[2] = substr($timeArr[2],0, strpos($timeArr[2],".")); $outdate = mktime( $timeArr[0], $timeArr[1], $timeArr[2], $dateArr[1], $dateArr[2], $dateArr[0] ); return $outdate; } function Date2Time($indate){ //YYYY-MM-DD HH:mm:ss.splits $indate = explode(" ", $indate); $dateArr = explode("-", $indate[0]); $outdate = mktime( '0', '0', '0', $dateArr[1], $dateArr[2], $dateArr[0] ); return $outdate; } function Time2Datetime ($sqldatetime) { $user_date = date($this->pi_getLL('date_format')." H:i:s", $sqldatetime); return $user_date; } function Time2DutchDate ($sqldatetime) { $user_date = strftime("%x %X", $sqldatetime); return $user_date; } function Time2Date ($sqldatetime) { $user_date = strftime("%x %X", $sqldatetime); return $user_date; } function Time2DutchDatetime ($sqldatetime) { $user_date = date($this->pi_getLL('date_format')." H:i:s", $sqldatetime); return $user_date; } function DutchDate ($sqldatetime) { $user_date = strftime("%x %X", strtotime($sqldatetime)); return $user_date; } function DutchTime ($sqldatetime) { $user_date = strtotime($sqldatetime); return $user_date; } function getTax ($customer_landen_id, $bu_landen_id) { if ($customer_landen_id) { $str="select * from static_countries where id='".$customer_landen_id."'"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); $customer_landnaam=$row['naam']; } if ($bu_landen_id) { $str="SELECT * FROM `static_taxes` WHERE `tx_country_iso_nr` ='".$bu_landen_id."'"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); $tax=$row['tx_rate']*100; } return $tax; } function getTaxById ($id) { $str="SELECT * FROM `static_taxes` WHERE `uid` ='".$id."'"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); $tax=($row['tx_rate']*100); return $tax; } function getTaxByPercentage ($value) { global $ms; $str="SELECT * FROM `static_taxes` WHERE `tx_country_iso_nr` ='".addslashes($ms['MODULES']['COUNTRY_ISO_NR'])."' and tx_rate='".($value/100)."'"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry) > 0) { $row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); return $row['uid']; } } function getCountryByIso($cn_iso_nr) { $str="select * from static_countries where cn_iso_nr='".addslashes($cn_iso_nr)."'"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); return $row; } function getCountryByName($english_name) { $str="select * from static_countries where cn_short_en='".addslashes($english_name)."'"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); return $row; } function getCountryCnIsoByEnglishName($english_name) { // returns NL, BE, DE etc $str="select cn_iso_2 from static_countries where cn_short_en='".addslashes($english_name)."'"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); return $row['cn_iso_2']; } function getCountryName($cn_iso_nr) { $str="select * from static_countries where cn_iso_nr='".addslashes($cn_iso_nr)."'"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); return $row['cn_iso_2']; } function getCountryByCode($cn_iso_2) { //cn_iso_2 $query = $GLOBALS['TYPO3_DB']->SELECTquery( '*', // SELECT ... 'static_countries', // FROM ... 'cn_iso_2=\''.addslashes($cn_iso_2).'\'', // WHERE... '', // GROUP BY... '', // ORDER BY... '' // LIMIT ... ); $res = $GLOBALS['TYPO3_DB']->sql_query($query); $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); return $row['cn_short_en']; } function getCityName($id) { $str="select * from plaatsen where id='".$id."'"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); return $row['naam']; } function getCityId($name) { $str="select * from plaatsen where naam='".$name."'"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); return $row['id']; } function replace_uri($str) { $pattern = '#(^|[^\"=]{1})(http://|ftp://|mailto:|news:)([^\s<>]+)([\s\n<>]|$)#sm'; return preg_replace($pattern,"\\1\\2\\3\\4",$str); } function typolink ($page_id='', $vars='') { //pi_getPageLink $conf=array(); if (strstr($page_id,",")) { $array=explode(",",$page_id); if (!$array[0]) { $page_id=$GLOBALS["TSFE"]->id.','.$array[1]; } $conf['type']=$array[1]; } elseif (!$page_id) $page_id=$GLOBALS["TSFE"]->id; $conf['parameter']=$page_id; if ($vars) $conf['additionalParams']='&'.$vars; $conf['returnLast'] = 'url'; // get it as URL // $url = htmlspecialchars($GLOBALS["TSFE"]->cObj->typolink(NULL, $conf)); $url = $GLOBALS["TSFE"]->cObj->typolink(NULL, $conf); return $url; } function loggedin () { if($GLOBALS['TSFE']->fe_user->user['uid']) return 1; else return 0; } function getTypoContent($pid='',$uid='') { $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery ( 't.*', 'tt_content t', 't.pid=\''.$pid.'\'', '', '', '' ); if ($res) $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); // return $this->div->parseFunc($row['title'], $this->cObj, $this->conf['label.']['parse']); // return title return renderTypoContent($row['bodytext']); } function string2url ($input) { $input = preg_replace( "`((http)+(s)?:(//)|(www\.))((\w|\.|\-|_)+)(/)?(\S+)?`i", "\\5\\6", $input); return $input; } function renderTypoContent($content) { $parseHTML = new t3lib_parsehtml_proc(); $message = $parseHTML->TS_links_rte($content); return $message; } function mailFeUser ($user, $subject, $content,$from_address='noreply@typo3multishop.com',$from_name='Typo3 Multishop') { if ($user['email']) { global $server,$ms; $mail = new PHPMailer(); if ($GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport'] == 'smtp') { $mail->IsSMTP(); $mail->Host = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_smtp_server']; if (isset($GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_smtp_username'])) { $mail->SMTPAuth = true; $mail->Username = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_smtp_username']; $mail->Password = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_smtp_password']; } } if ($this->conf['email_tmpl_path']) $template = $this->cObj->fileResource($this->conf['email_tmpl_path']); else $template = $this->cObj->fileResource(t3lib_extMgm::siteRelPath($this->extKey).'templates/email_template.tmpl'); $markerArray=array(); $markerArray['###BODY###'] = $content; $body = $this->cObj->substituteMarkerArray($template, $markerArray); $mail->SetFrom($from_address, $from_name); $mail->AddAddress($user['email'], $user['username']); $mail->Subject = $subject; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($body,$this->DOCUMENT_ROOT); if(!$mail->Send()) return 0; else return 1; } else return 0; } function mailFeGroup($group_id,$subject,$body,$from_address='noreply@mysite.com',$from_name='Typo3 Multishop') { $users=mslib_fe::getUsersByGroup($group_id); if (is_array($users) and count($users)) { foreach ($users as $user) { mslib_fe::mailUser($user, $subject, $body,$from_address,$from_name); } } } function mailUser ($user, $subject, $content,$from_address='noreply@mysite.com',$from_name='Typo3 Multishop') { if ($user['email']) { $mail = new PHPMailer(); if ($GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport'] == 'smtp') { $mail->IsSMTP(); $mail->Host = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_smtp_server']; if (isset($GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_smtp_username'])) { $mail->SMTPAuth = true; $mail->Username = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_smtp_username']; $mail->Password = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_smtp_password']; } } // $mail->IsSendmail(); // telling the class to use SendMail transport if ($this->conf['email_tmpl_path']) $template = $this->cObj->fileResource($this->conf['email_tmpl_path']); else $template = $this->cObj->fileResource(t3lib_extMgm::siteRelPath($this->extKey).'templates/email_template.tmpl'); $markerArray=array(); $markerArray['###BODY###'] = $content; $body = $this->cObj->substituteMarkerArray($template, $markerArray); $mail->SetFrom($from_address, $from_name); $mail->AddAddress($user['email'], $user['username']); $mail->Subject = $subject; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($body,$this->DOCUMENT_ROOT); if(!$mail->Send()) return 0; else return 1; } else return 0; } function convertTime($dformat,$sformat,$ts) { extract(strptime($ts,$sformat)); return strftime($dformat,mktime( intval($tm_hour), intval($tm_min), intval($tm_sec), intval($tm_mon)+1, intval($tm_mday), intval($tm_year)+1900 )); } function mailbas($input,$subject='') { global $SCRIPT_NAME,$ms; if ($subject) mail('bas@bvbmedia.com',$subject,$SCRIPT_NAME.': '."\n".$input); else mail('bas@bvbmedia.com',$SCRIPT_NAME,$input); } function ifMobile ($USER_AGENT) { $types=array(); $types[]='DoCoMo'; $types[]='J-PHONE'; $types[]='KDDI'; $types[]='UP.Browser'; $types[]='DDIPOCKET'; $types[]='SymbianOS'; $types[]='iPhone'; $types[]='IEMobile'; foreach ($types as $type) { if (strstr($USER_AGENT,$type)) { return 1; } } } function getCountry ($id) { $query = $GLOBALS['TYPO3_DB']->SELECTquery( '*', // SELECT ... 'static_countries', // FROM ... 'id="'.$id.'"', // WHERE... '', // GROUP BY... '', // ORDER BY... '' // LIMIT ... ); $res = $GLOBALS['TYPO3_DB']->sql_query($query); $tel=0; if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) { $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); return $row; } else return 0; } function Crumbar ($c,$languages_id='',$output=array()) { if (is_numeric($c)) { $sql = "select c.custom_settings, c.categories_id, c.parent_id, cd.categories_name from tx_multishop_categories c, tx_multishop_categories_description cd where c.categories_id = ".$c." and cd.language_id='".$this->sys_language_uid."' and c.categories_id = cd.categories_id"; $qry = $GLOBALS['TYPO3_DB']->sql_query($sql); if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry)) { $data = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); if ($data['categories_name']) $output[]=array('name' => $data['categories_name'], 'url' => mslib_fe::rewritenamein($data['categories_name'],'cat',$data['categories_id']), 'id' =>$data['categories_id'],'custom_settings' => $data['custom_settings']); if ($data['parent_id'] > 0 and $data['parent_id'] <> $this->categoriesStartingPoint) { if ($data['categories_id']==$data['parent_id']) { echo 'crumbar is looping.'; error_log($data['parent_id']); die(); } else $output=mslib_fe::Crumbar($data['parent_id'],'',$output); } $GLOBALS['TYPO3_DB']->sql_free_result($qry); } } return $output; } function showAttributes ($products_id,$add_tax_rate='',$sessionData=array(),$readonly=0) { global $get,$ms; if (!is_numeric($products_id)) { return false; } if (!$ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) { $add_tax_rate=''; } if (!$sessionData) { $sessionData = $GLOBALS['TSFE']->fe_user->getKey('ses',$this->cart_page_uid); $sessionData=$sessionData['products'][$get['tx_multishop_pi1']['cart_item']]; } //and popt.language_id = '" . $languages_id . "' $option_value_counter=0; $json_attributes = '{'; $str="select popt.required,popt.products_options_id, popt.products_options_name, popt.listtype from tx_multishop_products_options popt, tx_multishop_products_attributes patrib where patrib.products_id='" . (int) $products_id. "' and popt.language_id = '" . $this->sys_language_uid. "' and patrib.options_id = popt.products_options_id group by popt.products_options_id order by popt.sort_order"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $total_rows=$GLOBALS['TYPO3_DB']->sql_num_rows($qry); if ($total_rows > 0) { $output.= '

    '.$this->pi_getLL('product_options').'

    '; $next_index = 0; while ($options=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) { $load_default=0; switch ($options['listtype']) { case 'divider': $output.='
    '; $load_default=0; break; case 'input': $output.='
    '; $load_default=0; break; case 'checkbox': $class='opties-field-attribute'.$options['products_options_id'].' opties-field-radio opties-field-checkbox'; $load_default=1; break; default: $class='opties-field-attribute'.$options['products_options_id'].' opties-field-radio'; $load_default=1; break; } if ($load_default) { if ($readonly) $output.=''; } } $output.='
    '; } else { $json_attributes .= "'0':'yes'"; } $json_attributes .= '}'; //$output .= $json_attributes; if (!$readonly and $total_rows) { $output .= ' '; } return $output; } function ProductHasAttributes($products_id){ if (!is_numeric($products_id)) { return false; } $str="select popt.products_options_id, popt.products_options_name from tx_multishop_products_options popt, tx_multishop_products_attributes patrib where patrib.products_id='" . (int) $products_id. "' and popt.hide_in_cart=0 and patrib.options_id = popt.products_options_id group by popt.products_options_id order by popt.products_options_id"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry) > 0) { return true; } else { return false; } } function getTaxRate ($tax_id) { $str="SELECT * from static_taxes where uid='".$tax_id."'"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); return $row['tx_rate']; } function getProduct($products_id,$categories_id='',$extra_fields='',$include_disabled_products=0) { global $ms; if (!is_numeric($products_id)) { return false; } if (!$ms['MODULES']['FLAT_DATABASE'] or $include_disabled_products) { //pd.products_meta_title, pd.products_shortdescription, pd.products_meta_keywords, $str="SELECT *,p.staffel_price as staffel_price, tr.tx_rate as tax_rate, IF(s.status, s.specials_new_products_price, p.products_price) as final_price ".($extra_fields?', '.$extra_fields:'')." from tx_multishop_products p left join tx_multishop_specials s on p.products_id = s.products_id left join static_taxes tr on p.tax_id = tr.uid, tx_multishop_products_description pd, tx_multishop_products_to_categories p2c, tx_multishop_categories c, tx_multishop_categories_description cd where ".(!$include_disabled_products?' p.products_status=1 and ':'')." p.products_id='".$products_id."' and pd.language_id='".$this->sys_language_uid."' and cd.language_id=pd.language_id and p.products_id=pd.products_id and p.products_id=p2c.products_id and p2c.categories_id=c.categories_id and p2c.categories_id=cd.categories_id "; if ($categories_id) $str.=" and p2c.categories_id='".$categories_id."'"; } else { $str="SELECT * from tx_multishop_products_flat where products_id='".$products_id."' and language_id='".$this->sys_language_uid."'"; } $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $product=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); return $product; } function getNextPreviousProduct($products_id,$categories_id='') { global $ms; if (!is_numeric($products_id)) { return false; } if (!$ms['MODULES']['FLAT_DATABASE']) { $str="SELECT pd.products_name, p.products_id, c.categories_id from tx_multishop_products p, tx_multishop_products_description pd, tx_multishop_products_to_categories p2c, tx_multishop_categories c, tx_multishop_categories_description cd where p.products_status=1 and c.categories_id='".$categories_id."' and pd.language_id='".$this->sys_language_uid."' and cd.language_id=pd.language_id and p.products_id=pd.products_id and p.products_id=p2c.products_id and c.categories_id=p2c.categories_id and c.categories_id=cd.categories_id order by p2c.sort_order asc"; } else { $str="SELECT products_name, products_id, categories_id from tx_multishop_products_flat where categories_id='".$categories_id."' order by sort_order asc"; } $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $count=0; $products=array(); while ($row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) { $products[]=$row['products_id']; } $total=count($products); $pagination_items=array(); $trans = array_flip($products); $internal=$trans[$products_id]; if ($internal==0) { $pagination_items['next_item']=$products[1]; } else { $pagination_items['previous_item']=$products[($internal-1)]; $pagination_items['next_item']=$products[($internal+1)]; } foreach ($pagination_items as $key => $item) { if ($item) { // get all cats to generate multilevel fake url $level=0; $cats=mslib_fe::Crumbar($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 $link=mslib_fe::typolink($this->shop_pid,'&'.$where.'&products_id='.$item.'&tx_multishop_pi1[page_section]=products_detail'); $pagination_items[$key]=$link; } } $pagination_items['internal'] =$internal; $pagination_items['total'] =$total; return $pagination_items; } /* this method is used to request the products page set $filter can be an string or (multiple) array: string example: p2c.categories_id=12 array example: $filter[]='p2c.categories_id=12' */ function getProductsPageSet($filter=array(),$offset=0,$limit=0,$orderby=array(),$having=array(),$select=array(),$where=array(),$redirect_if_one_product=0,$extra_from=array()) { global $ms; if ($ms['MODULES']['SHOW_PRODUCTS_WITH_IMAGE_FIRST']) { if (!$ms['MODULES']['FLAT_DATABASE']) { $prefix='p.'; } else $prefix='pf.'; $tmp_orderby=array(); $tmp_orderby[]=$prefix.'contains_image desc'; $tmp_orderby[]=$prefix.'sort_order '.$ms['MODULES']['PRODUCTS_LISTING_SORT_ORDER_OPTION']; if (!is_array($orderby) and $orderby) { $tmp_orderby[]=$orderby; } else { $tmp_orderby=array_merge($tmp_orderby,$orderby); } $orderby=$tmp_orderby; } if (!$limit) $limit=$ms['MODULES']['PRODUCTS_LISTING_LIMIT']; if (!is_numeric($offset)) $offset=0; if (!$ms['MODULES']['FLAT_DATABASE']) { $groupby_clause=' GROUP BY p.products_id '; // do normal search (join the seperate tables) $required_cols='p.minimum_quantity, pd.products_viewed,pd.products_url,p.products_id,p.products_image,p.products_image1,p.products_date_added,p.products_model,p.products_quantity,p.products_price,p.staffel_price as staffel_price,IF(s.status, s.specials_new_products_price, p.products_price) as final_price,p.products_date_available,p.tax_id,tr.tx_rate as tax_rate,p.manufacturers_id,pd.products_name,pd.products_shortdescription,c.categories_id,cd.categories_name'; if ($ms['MODULES']['INCLUDE_PRODUCTS_DESCRIPTION_DB_FIELD_IN_PRODUCTS_LISTING']) { $required_cols.=',pd.products_description'; } $select_clause="SELECT ".$required_cols; if (count($select)>0) { $select_clause.=', '; $select_clause.=implode(",",$select); } $from_clause.=" from tx_multishop_products p left join tx_multishop_specials s on p.products_id = s.products_id left join static_taxes tr on p.tax_id = tr.uid, tx_multishop_products_description pd, tx_multishop_products_to_categories p2c, tx_multishop_categories c, tx_multishop_categories_description cd "; if (count($extra_from)) { $from_clause.=", "; $from_clause.=implode(",",$extra_from); } $where_clause.=" where p.products_status=1 "; if (!$this->masterShop) { $where_clause.=" and p.page_uid='".$this->showCatalogFromPage."' "; } $where_clause.=" and pd.language_id='".$this->sys_language_uid."' "; if (is_array($where) and count($where)>0) { $where_clause.='and '; $where_clause.=implode(",",$where); } $where_clause.=' and '; if (is_array($filter) and count($filter) >0) $where_clause.=implode(" and ",$filter)." and "; elseif ($filter) $where_clause.=$filter." and "; $where_clause.=" pd.language_id=cd.language_id and p.products_id=p2c.products_id and p.products_id=pd.products_id and p2c.categories_id=c.categories_id and p2c.categories_id=cd.categories_id "; if (count($having) >0) { $having_clause.=" having "; foreach ($having as $item) { $having_clause.=$item; } } if (is_array($orderby) and count($orderby)>0) { $str_order_by.=implode(",",$orderby); } elseif ($orderby) $str_order_by.=$orderby; else $str_order_by.='p2c.sort_order '.$ms['MODULES']['PRODUCTS_LISTING_SORT_ORDER_OPTION']; if ($str_order_by) $orderby_clause.=" order by ".$str_order_by; } else { // flat mode database mode. This module is used on LARGE catalogs, so the joins of individual tables are minimized // do the flat search (without having to join the seperate tables) $required_cols='pf.minimum_quantity,pf.products_viewed,pf.products_url,pf.products_id,pf.products_image,pf.products_image1,pf.products_model,pf.products_quantity,pf.products_price,pf.staffel_price,pf.final_price,pf.products_date_added,pf.products_date_available,pf.tax_id,pf.tax_rate,pf.manufacturers_id,pf.products_name,pf.products_shortdescription,pf.categories_id,pf.categories_name,pf.categories_name_0,pf.categories_name_1,pf.categories_name_2,pf.categories_name_3'; if ($ms['MODULES']['INCLUDE_PRODUCTS_DESCRIPTION_DB_FIELD_IN_PRODUCTS_LISTING']) { $required_cols.=',pf.products_description'; } if ($ms['MODULES']['FLAT_DATABASE_EXTRA_ATTRIBUTE_OPTION_COLUMNS'] and is_array($ms['FLAT_DATABASE_ATTRIBUTE_OPTIONS'])) { $attribute_cols=''; foreach ($ms['FLAT_DATABASE_ATTRIBUTE_OPTIONS'] as $option_id => $array) { if ($array[0] and $array[1]) { $attribute_cols.="pf.".$array[0].','; } } $attribute_cols=preg_replace("/\,$/","",$attribute_cols); if ($attribute_cols) $required_cols.=','.$attribute_cols; } $select_clause="SELECT ".$required_cols; if (is_array($select) and count($select)>0) { $select_clause.=', '; $select_clause.=implode(",",$select); } $from_clause.=" from tx_multishop_products_flat pf "; if (count($extra_from)) { $from_clause.=", "; $from_clause.=implode(",",$extra_from); } if (is_array($where) and count($where)>0) { $where_clause.=implode(",",$where); } if (is_array($filter) and count($filter) >0) { if ($where_clause) $where_clause.=' and '; $where_clause.=implode(" and ",$filter); } elseif ($filter) { if ($where_clause) $where_clause.=' and '; $where_clause.=$filter; } if (!$this->masterShop) { if ($where_clause) $where_clause.=" and "; $where_clause.=" pf.page_uid='".$this->showCatalogFromPage."' "; } if ($where_clause) $where_clause=" where ".$where_clause; if (count($having) >0) { $having_clause.=" having "; foreach ($having as $item) { $having_clause.=$item; } } if (is_array($orderby) and count($orderby)>0) { $str_order_by.=implode(",",$orderby); } elseif ($orderby) $str_order_by.=$orderby; if ($str_order_by) $orderby_clause.=" order by ".$str_order_by; } $limit_clause.=' LIMIT '.$offset.','.$limit; $array=array(); if (!$ms['MODULES']['FLAT_DATABASE']) { if (count($having)) { // since this query is using HAVING we need to calculate the total records on a different way $str="select p.products_id,IF(s.status, s.specials_new_products_price, p.products_price) as final_price ".$from_clause.$where_clause.$groupby_clause.$having_clause; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $array['total_rows']=$GLOBALS['TYPO3_DB']->sql_num_rows($qry); } else { // the select count(1) is buggy when working with group by and 1-n relations (1 product to many categories). therefore we temporary counting through sql_num_rows $str="select p.products_id ".$from_clause.$where_clause.$groupby_clause; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $array['total_rows']=$GLOBALS['TYPO3_DB']->sql_num_rows($qry); /* $str="select count(1) as total ".$from_clause.$where_clause; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); $array['total_rows']=$row['total']; */ } } else { $str="select count(1) as total ".$from_clause.$where_clause; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); $array['total_rows']=$row['total']; } // now do the real query including the order by and the limit $str=$select_clause.$from_clause.$where_clause.$groupby_clause.$having_clause.$orderby_clause.$limit_clause; #t3lib_div::devLog('MSLIB_FE SEARCH '.$str, 'multishop',1,$where); /* //$GLOBALS['TSFE']->fe_user->user['username']=='base' if ($this->ROOTADMIN_USER) { echo $str; die(); } */ // error_log($str); // echo $str."\n\n"; // error_log($array['total_rows']); // error_log($str); $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $rows=$GLOBALS['TYPO3_DB']->sql_num_rows($qry); if ($rows > 0) { while ($product=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) { $array['products'][]=$product; } if (count($array['products']) == 1 and $redirect_if_one_product) { $where=''; $product=$array['products'][0]; if ($product['categories_id']) { // get all cats to generate multilevel fake url $level=0; $cats=mslib_fe::Crumbar($product['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 } if ($product['products_url'] and $ms['MODULES']['AFFILIATE_SHOP']) $link=$product['products_url']; else $link=mslib_fe::typolink($this->shop_pid,'&'.$where.'&products_id='.$product['products_id'].'&tx_multishop_pi1[page_section]=products_detail'); if ($link) { header("Location: ".$this->FULL_HTTP_URL.$link); exit(); } } } return $array; } /* this method is used to request the admin customers page set $filter can be an string or (multiple) array: string example: p2c.categories_id=12 array example: $filter[]='p2c.categories_id=12' */ function getCustomersPageSet($filter=array(),$offset=0,$limit=0,$orderby=array(),$having=array(),$select=array(),$where=array()) { global $ms; if (!$limit) $limit=30; if (!is_numeric($offset)) $offset=0; // do normal search (join the seperate tables) $required_cols='f.*'; $select_clause="SELECT ".$required_cols; if (count($select)>0) { $select_clause.=', '; $select_clause.=implode(",",$select); } $from_clause.=" from fe_users f "; $where_clause.=" where "; if (count($where)>0) { $where_clause.=implode(",",$where); $where_clause.=' and '; } if (is_array($filter) and count($filter) >0) $where_clause.=implode(" and ",$filter)." and "; elseif ($filter) $where_clause.=$filter." and "; $where_clause.=" f.username !=''"; if (count($having) >0) { $having_clause.=" having "; foreach ($having as $item) { $having_clause.=$item; } } if (is_array($orderby) and count($orderby)>0) { $str_order_by.=implode(",",$orderby); } elseif ($orderby) $str_order_by.=$orderby; else $str_order_by.=""; if ($str_order_by) $orderby_clause.=" order by ".$str_order_by; $limit_clause.=' LIMIT '.$offset.','.$limit; $array=array(); // $array['total_rows']=$row2[0]; // retrieve the total number of records // $str=$select_clause.", count(1) as total ".$from_clause.$where_clause.$having_clause; $str=$select_clause.$from_clause.$where_clause.$having_clause; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $array['total_rows']=$GLOBALS['TYPO3_DB']->sql_num_rows($qry); // now do the query $str=$select_clause.$from_clause.$where_clause.$having_clause.$orderby_clause.$limit_clause; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $rows=$GLOBALS['TYPO3_DB']->sql_num_rows($qry); // $qry2=$GLOBALS['TYPO3_DB']->sql_query("SELECT FOUND_ROWS();"); // $row2=$GLOBALS['TYPO3_DB']->sql_fetch_row($qry2); if ($rows > 0) { while ($row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) { $array['customers'][]=$row; } } return $array; } function getCustomerGroupsPageSet($filter=array(),$offset=0,$limit=0,$orderby=array(),$having=array(),$select=array(),$where=array()) { global $ms; if (!$limit) $limit=30; if (!is_numeric($offset)) $offset=0; // do normal search (join the seperate tables) $required_cols='f.*'; $select_clause="SELECT ".$required_cols; if (count($select)>0) { $select_clause.=', '; $select_clause.=implode(",",$select); } $from_clause.=" from fe_groups f "; $where_clause.=" where "; if (count($where)>0) { $where_clause.=implode(",",$where); $where_clause.=' and '; } if (is_array($filter) and count($filter) >0) $where_clause.=implode(" and ",$filter)." and "; elseif ($filter) $where_clause.=$filter." and "; $where_clause.=" f.title !=''"; if (count($having) >0) { $having_clause.=" having "; foreach ($having as $item) { $having_clause.=$item; } } if (is_array($orderby) and count($orderby)>0) { $str_order_by.=implode(",",$orderby); } elseif ($orderby) $str_order_by.=$orderby; else $str_order_by.=""; if ($str_order_by) $orderby_clause.=" order by ".$str_order_by; $limit_clause.=' LIMIT '.$offset.','.$limit; $array=array(); // $array['total_rows']=$row2[0]; // retrieve the total number of records // $str=$select_clause.", count(1) as total ".$from_clause.$where_clause.$having_clause; $str=$select_clause.$from_clause.$where_clause.$having_clause; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $array['total_rows']=$GLOBALS['TYPO3_DB']->sql_num_rows($qry); // now do the query $str=$select_clause.$from_clause.$where_clause.$having_clause.$orderby_clause.$limit_clause; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $rows=$GLOBALS['TYPO3_DB']->sql_num_rows($qry); // $qry2=$GLOBALS['TYPO3_DB']->sql_query("SELECT FOUND_ROWS();"); // $row2=$GLOBALS['TYPO3_DB']->sql_fetch_row($qry2); if ($rows > 0) { while ($row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) { $array['groups'][]=$row; } } return $array; } /* this method is used to request the stores page set $filter can be an string or (multiple) */ function getStoresPageSet($filter=array(),$offset=0,$limit=0,$orderby=array(),$having=array(),$select=array(),$where=array()) { global $ms; if (!$limit) $limit=30; if (!is_numeric($offset)) $offset=0; // do normal search (join the seperate tables) $required_cols='mss.address,mss.zip,mss.city,mss.telephone,mss.fax, mss.id, mss.name, mssd.description'; $select_clause="SELECT ".$required_cols; if (count($select)>0) { $select_clause.=', '; $select_clause.=implode(",",$select); } $from_clause.=" from tx_multishop_stores mss, tx_multishop_stores_description mssd "; $where_clause.=" where "; if (count($where)>0) { $where_clause.=implode(",",$where); $where_clause.=' and '; } if (is_array($filter) and count($filter) >0) $where_clause.=implode(" and ",$filter)." and "; elseif ($filter) $where_clause.=$filter." and "; $where_clause.=" mss.status ='1' and mssd.language_id='".$this->sys_language_uid."' and mss.id=mssd.id "; if (count($having) >0) { $having_clause.=" having "; foreach ($having as $item) { $having_clause.=$item; } } if (is_array($orderby) and count($orderby)>0) { $str_order_by.=implode(",",$orderby); } elseif ($orderby) $str_order_by.=$orderby; else $str_order_by.=""; if ($str_order_by) $orderby_clause.=" order by ".$str_order_by; $limit_clause.=' LIMIT '.$offset.','.$limit; $array=array(); // $array['total_rows']=$row2[0]; // retrieve the total number of records // $str=$select_clause.", count(1) as total ".$from_clause.$where_clause.$having_clause; $str=$select_clause.$from_clause.$where_clause.$having_clause; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $array['total_rows']=$GLOBALS['TYPO3_DB']->sql_num_rows($qry); // now do the query $str=$select_clause.$from_clause.$where_clause.$having_clause.$orderby_clause.$limit_clause; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $rows=$GLOBALS['TYPO3_DB']->sql_num_rows($qry); // $qry2=$GLOBALS['TYPO3_DB']->sql_query("SELECT FOUND_ROWS();"); // $row2=$GLOBALS['TYPO3_DB']->sql_fetch_row($qry2); if ($rows > 0) { while ($row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) { $array['stores'][]=$row; } } return $array; } function getSubcats(&$subcategories_array, $parent_id = 0) { $subcategories_query = $GLOBALS['TYPO3_DB']->sql_query("select categories_id from tx_multishop_categories where page_uid='".$this->showCatalogFromPage."' and status = '1' and parent_id = '" . $parent_id . "'"); while ($subcategories = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($subcategories_query)) { $subcategories_array[sizeof($subcategories_array)] = $subcategories['categories_id']; if ($subcategories['categories_id'] != $parent_id) { mslib_fe::getSubcats($subcategories_array, $subcategories['categories_id']); } } } /* limit number of products page_uid the pid of the core shop page content_uid the uid of the content object for unique css id naming */ function SpecialsBox ($contentType, $limit=5, $page_uid='',$content_uid='') { global $ms,$get,$server; set_include_path(t3lib_extMgm::extPath('multishop').PATH_SEPARATOR.t3lib_extMgm::extPath('multishop').'scripts/front_pages/'); switch ($contentType) { case 'home': if ($ms['MODULES']['HOME_SPECIALS_BOX']) include('products_specials.php'); break; case 'single_special': include('products_specials.php'); break; case 'specials_listing_page': include('products_specials.php'); break; case 'products_search': case 'specials_section': default: include('products_specials.php'); break; } return $content; } function getProductMappedMethods($pids=array(),$type='') { if (is_array($pids) and count($pids)) { switch ($type) { case 'payment': // first we load all options $allmethods=mslib_fe::loadPaymentMethods(); foreach ($pids as $pid) { $str="SELECT s.code from tx_multishop_products_method_mappings pmm, tx_multishop_payment_methods s where pmm.type='".$type."' and pmm.products_id = ".$pid." and pmm.method_id=s.id"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $array=array(); while ($row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) { $array[]=$row['code']; } foreach ($allmethods as $key => $value) { if (!in_array($key,$array)) { unset($allmethods[$key]); } } } break; case 'shipping': // first we load all options /* $allmethods=mslib_fe::loadShippingMethods(); foreach ($pids as $pid) { $str="SELECT s.code from tx_multishop_products_method_mappings pmm, tx_multishop_shipping_methods s where pmm.type='".$type."' and pmm.products_id = ".$pid." and pmm.method_id=s.id"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $array=array(); while ($row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) { $array[]=$row['code']; } foreach ($allmethods as $key => $value) { if (!in_array($key,$array)) { unset($allmethods[$key]); } } } */ $allmethods=array(); foreach ($pids as $pid) { $str="SELECT s.*,d.description, d.name from tx_multishop_products_method_mappings pmm, tx_multishop_shipping_methods s, tx_multishop_shipping_methods_description d where pmm.type='".$type."' and pmm.products_id = ".$pid." and pmm.method_id=s.id and d.language_id='".$this->sys_language_uid."' and s.id=d.id order by s.sort_order"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); while ($row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) { $allmethods[$row['code']]=$row; } } break; } return $allmethods; } } function loadShippingMethods() { $str="SELECT * from tx_multishop_shipping_methods s, tx_multishop_shipping_methods_description d where d.language_id='".$this->sys_language_uid."' and s.id=d.id order by s.sort_order"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $array=array(); while ($row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) { $array[$row['code']]=$row; } return $array; } function loadShippingMethod($code) { $str="SELECT * from tx_multishop_shipping_methods s, tx_multishop_shipping_methods_description d where s.code='".addslashes($code)."' and s.status=1 and d.language_id='".$this->sys_language_uid."' and s.id=d.id order by s.sort_order"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $array=array(); while ($row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) { return $row; } } function loadPaymentMethods() { $str="SELECT * from tx_multishop_payment_methods s, tx_multishop_payment_methods_description d where d.language_id='".$this->sys_language_uid."' and s.id=d.id order by s.sort_order"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $array=array(); while ($row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) { $array[$row['code']]=$row; } return $array; } function loadPaymentMethod($code) { $str="SELECT * from tx_multishop_payment_methods s, tx_multishop_payment_methods_description d where s.code='".addslashes($code)."' and s.status=1 and d.language_id='".$this->sys_language_uid."' s.id=d.id order by s.sort_order"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $array=array(); while ($row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) { return $row; } } function loadAllShippingMethods() { $shipping_methods=array(); $shipping_methods['gls']=array( 'name' =>'GLS' ); $shipping_methods['hermes']=array( 'name' =>'Hermes' ); $shipping_methods['dhl']=array( 'name' =>'DHL' ); $shipping_methods['ups']=array( 'name' =>'UPS' ); $shipping_methods['fedex']=array( 'name' =>'FEDEX' ); $shipping_methods['tnt']=array( 'name' =>'TNT' ); $shipping_methods['gpl']=array( 'name' =>'GPL' ); return $shipping_methods; } function loadAllPaymentMethods() { global $server; $payment_methods=array(); // OGONE $vars=array(); $vars['pspid']['type'] ='input'; $vars['shasign']['type'] ='input'; $vars['test']['type'] ='radio'; $vars['test']['options'][] ='true'; $vars['test']['options'][] ='false'; $vars['autosubmit']['type'] ='radio'; $vars['autosubmit']['options'][] ='true'; $vars['autosubmit']['options'][] ='false'; $vars['open_in_new_window']['type'] ='radio'; $vars['open_in_new_window']['options'][] ='true'; $vars['open_in_new_window']['options'][] ='false'; $additional_info=array(); $additional_info['1']['label'] = 'Global security parameters / Hash algorithm'; $additional_info['1']['value'] = 'Go to Global security parameters / Hash algorithm and choose: "SHA-512"'; $additional_info['2']['label'] = 'Global security parameters / Character encoding'; $additional_info['2']['value'] = 'Go to Global security parameters / Character encoding and choose: "UTF-8"'; $additional_info['3']['label'] = 'Data and origin verification / Checks for e-Commerce / SHA-IN Pass phrase'; $additional_info['3']['value'] = 'Go to Data and origin verification / Checks for e-Commerce / SHA-IN Pass phrase and fill in your shasign (secret key)'; $additional_info['4']['label'] = 'Transaction feedback / Direct HTTP server-to-server request / URL of the merchant\'s post-payment page'; $additional_info['4']['value'] = 'Go to and fill in the following url:
    '.$this->FULL_HTTP_URL.mslib_fe::typolink($this->shop_pid.',2002','&tx_multishop_pi1[page_section]=psp_post_payment_ogone'); $additional_info['5']['label'] = 'Transaction feedback / Security for request parameters / SHA-OUT Pass phrase'; $additional_info['5']['value'] = 'Go to Transaction feedback / Security for request parameters / SHA-OUT Pass phrase and fill in your shasign (secret key)'; $payment_methods['ogone']=array( 'name' =>'Ogone', 'country' => 'nl', 'vars' =>$vars, 'more_info_link' =>'http://www.typo3multishop.com/payment-service-providers/ogone/', 'image' =>'ogone.png', 'additional_info' => $additional_info ); // OGONE EOF // BUCKAROO $vars=array(); $vars['bpe_merchant']['type'] ='input'; $vars['secret_key']['type'] ='input'; $vars['test']['type'] ='radio'; $vars['test']['options'][] ='true'; $vars['test']['options'][] ='false'; $vars['autosubmit']['type'] ='radio'; $vars['autosubmit']['options'][] ='true'; $vars['autosubmit']['options'][] ='false'; $vars['open_in_new_window']['type'] ='radio'; $vars['open_in_new_window']['options'][] ='true'; $vars['open_in_new_window']['options'][] ='false'; $vars['payment_type']['type'] ='radio'; $vars['payment_type']['options'][] ='ideal'; $vars['payment_type']['options'][] ='single_authorization'; $vars['payment_type']['options'][] ='creditcard'; $additional_info=array(); $additional_info['1']['label'] = 'Profiel / Websites / Vertraagde en Push responses'; $additional_info['1']['value'] = 'Enable the checkbox: Activeer Push Response'; $additional_info['2']['label'] = 'Profiel / Websites / Vertraagde en Push responses'; $additional_info['2']['value'] = 'Add the following URL to the field "URI succes": '.$this->FULL_HTTP_URL.mslib_fe::typolink($this->shop_pid.',2002','&tx_multishop_pi1[page_section]=psp_post_payment_buckaroo').'
    On the "Gebruik HTTP-Method" drop down menu select: POST'; $payment_methods['buckaroo']=array( 'image' =>'buckaroo.png', 'country' => 'nl', 'vars' =>$vars, 'more_info_link' =>'http://www.typo3multishop.com/payment-service-providers/buckaroo/', 'name' =>'Buckaroo', 'additional_info' => $additional_info ); // BUCKAROO EOF // MOLLIE $vars=array(); $vars['partner_id']['type']='input'; $payment_methods['mollie']=array( 'image' =>'mollie.png', 'country' => 'nl', 'vars' =>$vars, 'more_info_link' =>'http://www.typo3multishop.com/payment-service-providers/mollie/', 'name' =>'Mollie' ); // MOLLIE EOF // MULTISAFEPAY $vars=array(); $vars['merchant_account']['type']='input'; $vars['merchant_site_id']['type']='input'; $vars['merchant_secret_code']['type']='input'; $vars['test']['type'] ='radio'; $vars['test']['options'][] ='true'; $vars['test']['options'][] ='false'; $vars['autosubmit']['type'] ='radio'; $vars['autosubmit']['options'][] ='true'; $vars['autosubmit']['options'][] ='false'; $vars['open_in_new_window']['type'] ='radio'; $vars['open_in_new_window']['options'][] ='true'; $vars['open_in_new_window']['options'][] ='false'; $payment_methods['multisafepay']=array( 'image' =>'multisafepay.png', 'country' => 'nl', 'vars' =>$vars, 'more_info_link' =>'http://www.typo3multishop.com/payment-service-providers/multisafepay/', 'name' =>'Multisafepay' ); // MULTISAFEPAY EOF // ADYEN $vars=array(); $vars['adyen_payment_skincode']['type'] ='input'; $vars['adyen_payment_merchant']['type'] ='input'; $vars['adyen_payment_key']['type'] ='input'; $vars['adyen_payment_hpp_mode']['type'] ='radio'; $vars['adyen_payment_hpp_mode']['options'][] ='single'; $vars['adyen_payment_hpp_mode']['options'][] ='select'; $vars['test']['type'] ='radio'; $vars['test']['options'][] ='true'; $vars['test']['options'][] ='false'; $vars['autosubmit']['type'] ='radio'; $vars['autosubmit']['options'][] ='true'; $vars['autosubmit']['options'][] ='false'; $vars['open_in_new_window']['type'] ='radio'; $vars['open_in_new_window']['options'][] ='true'; $vars['open_in_new_window']['options'][] ='false'; $additional_info=array(); $additional_info['1']['label'] = 'New Skin'; $additional_info['1']['value'] = 'In Adyen account test dashboard Go to Skin and choose appropriate account, and press new to create new skin"'; $additional_info['2']['label'] = 'Skin settings'; $additional_info['2']['value'] = 'Go to Skins and and set few input for the settings
    '; $additional_info['2']['value'] .= '1. Result URL for Test: ' . $this->FULL_HTTP_URL.mslib_fe::typolink('','&tx_multishop_pi1[page_section]=adyen_pay')."
    "; $additional_info['2']['value'] .= '2. Continue-to URL for Test: ' . $this->FULL_HTTP_URL."
    "; $additional_info['2']['value'] .= '3. HMAC Key for Test: fill the password (this one should also be fill in adyen_payment_key)'."
    "; $additional_info['2']['value'] .= '4. Result URL for Live: ' . $this->FULL_HTTP_URL.mslib_fe::typolink('','&tx_multishop_pi1[page_section]=adyen_pay')."
    "; $additional_info['2']['value'] .= '5. Continue-to URL for Live: ' . $this->FULL_HTTP_URL."
    "; $additional_info['2']['value'] .= '6. HMAC Key for Live: fill the password (this one should also be fill in adyen_payment_key)'."
    "; $additional_info['2']['value'] .= '7. check the checkbox of the "Valid accounts" for the accounts you don\'t want to relate with the skin (if your Adyen have more than 1 account)'."
    "; $additional_info['3']['label'] = 'Transaction feedback / SOAP notification / URL of the merchant\'s post-payment page'; $additional_info['3']['value'] = 'Go to settings and choose appropriate merchant account, paste the following url in Transport URL:
    '.$this->FULL_HTTP_URL.mslib_fe::typolink($this->shop_pid.',2002','&tx_multishop_pi1[page_section]=adyen_soap_ns')."
    , check the \"Active\" checkbox and select SOAP in Method input"; $payment_methods['adyen']=array( 'name' =>'Adyen', 'image' =>'adyen.png', 'country' => 'nl', 'vars' =>$vars, 'more_info_link' =>'http://www.typo3multishop.com/payment-service-providers/adyen/', 'additional_info' => $additional_info ); // ADYEN EOF // PAYPAL $additional_info=array(); $additional_info['1']['label'] = 'Setup Notification URL'; $additional_info['1']['value'] = 'Go to https://www.paypal.com/cgi-bin/webscr?cmd=_profile-ipn-notify'; $additional_info['2']['label'] = 'Specify the following URL:'; $additional_info['2']['value'] = $this->FULL_HTTP_URL.mslib_fe::typolink($this->shop_pid.',2002','&tx_multishop_pi1[page_section]=paypal_ns'); $additional_info['3']['label'] = 'DBB-berichten:'; $additional_info['3']['value'] = 'Enable the check box.'; $vars=array(); $vars['paypal_email_address']['type'] ='input'; $vars['test']['type'] ='radio'; $vars['test']['options'][] ='true'; $vars['test']['options'][] ='false'; $vars['autosubmit']['type'] ='radio'; $vars['autosubmit']['options'][] ='true'; $vars['autosubmit']['options'][] ='false'; $vars['open_in_new_window']['type'] ='radio'; $vars['open_in_new_window']['options'][] ='true'; $vars['open_in_new_window']['options'][] ='false'; $payment_methods['paypal']=array( 'image' =>'paypal.png', 'country' => 'int', 'vars' =>$vars, 'more_info_link' =>'http://www.typo3multishop.com/payment-service-providers/paypal/', 'name' =>'Paypal', 'additional_info' => $additional_info ); // PAYPAL EOF // RABOBANK $vars=array(); $vars['pspid']['type'] ='input'; $vars['shasign']['type'] ='input'; $vars['test']['type'] ='radio'; $vars['test']['options'][] ='true'; $vars['test']['options'][] ='false'; $vars['autosubmit']['type'] ='radio'; $vars['autosubmit']['options'][] ='true'; $vars['autosubmit']['options'][] ='false'; $vars['open_in_new_window']['type'] ='radio'; $vars['open_in_new_window']['options'][] ='true'; $vars['open_in_new_window']['options'][] ='false'; $payment_methods['ideal_rabobank']=array( 'image' =>'rabobank.png', 'country' => 'nl', 'vars' =>$vars, 'more_info_link' =>'http://www.typo3multishop.com/payment-service-providers/rabobank/', 'name' =>'Ideal Rabobank' ); // RABOBANK EOF // RABOBANK LITE $vars=array(); $vars['merchant_id']['type'] ='input'; $vars['merchant_key']['type'] ='input'; $vars['merchant_subid']['type'] ='input'; $vars['test']['type'] ='radio'; $vars['test']['options'][] ='true'; $vars['test']['options'][] ='false'; $vars['autosubmit']['type'] ='radio'; $vars['autosubmit']['options'][] ='true'; $vars['autosubmit']['options'][] ='false'; $vars['open_in_new_window']['type'] ='radio'; $vars['open_in_new_window']['options'][] ='true'; $vars['open_in_new_window']['options'][] ='false'; $payment_methods['ideal_rabobank_lite']=array( 'image' =>'rabobank.png', 'country' => 'nl', 'vars' =>$vars, 'more_info_link' =>'http://www.typo3multishop.com/payment-service-providers/rabobank/', 'name' =>'Ideal Rabobank Lite' ); // RABOBANK LITE EOF // RABOBANK PROFESSIONAL $vars=array(); $vars['merchant_id']['type'] ='input'; $vars['merchant_subid']['type'] ='input'; $vars['private_key_pass']['type'] ='input'; $vars['secure_path']['type'] ='input'; $vars['test']['type'] ='radio'; $vars['test']['options'][] ='true'; $vars['test']['options'][] ='false'; $vars['autosubmit']['type'] ='radio'; $vars['autosubmit']['options'][] ='true'; $vars['autosubmit']['options'][] ='false'; $vars['open_in_new_window']['type'] ='radio'; $vars['open_in_new_window']['options'][] ='true'; $vars['open_in_new_window']['options'][] ='false'; $payment_methods['ideal_rabobank_professional']=array( 'image' =>'rabobank.png', 'country' => 'nl', 'vars' =>$vars, 'more_info_link' =>'http://www.typo3multishop.com/payment-service-providers/rabobank/', 'name' =>'Ideal Rabobank Professional' ); // RABOBANK PROFESSIONAL EOF // ABN IDEAL $vars=array(); $vars['pspid']['type'] ='input'; $vars['shasign']['type'] ='input'; $vars['test']['type'] ='radio'; $vars['test']['options'][] ='true'; $vars['test']['options'][] ='false'; $vars['autosubmit']['type'] ='radio'; $vars['autosubmit']['options'][] ='true'; $vars['autosubmit']['options'][] ='false'; $vars['open_in_new_window']['type'] ='radio'; $vars['open_in_new_window']['options'][] ='true'; $vars['open_in_new_window']['options'][] ='false'; $additional_info=array(); $additional_info['1']['label'] = 'Global security parameters / Hash algorithm'; $additional_info['1']['value'] = 'Go to Global security parameters / Hash algorithm and choose: "SHA-512"'; $additional_info['2']['label'] = 'Global security parameters / Character encoding'; $additional_info['2']['value'] = 'Go to Global security parameters / Character encoding and choose: "UTF-8"'; $additional_info['3']['label'] = 'Data and origin verification / Checks for e-Commerce / SHA-IN Pass phrase'; $additional_info['3']['value'] = 'Go to Data and origin verification / Checks for e-Commerce / SHA-IN Pass phrase and fill in your shasign (secret key)'; $additional_info['4']['label'] = 'Transaction feedback / Direct HTTP server-to-server request / URL of the merchant\'s post-payment page'; $additional_info['4']['value'] = 'Go to and fill in the following url:
    '.$this->FULL_HTTP_URL.mslib_fe::typolink($this->shop_pid.',2002','&tx_multishop_pi1[page_section]=psp_post_payment_abn_amro'); $additional_info['5']['label'] = 'Transaction feedback / Security for request parameters / SHA-OUT Pass phrase'; $additional_info['5']['value'] = 'Go to Transaction feedback / Security for request parameters / SHA-OUT Pass phrase and fill in your shasign (secret key)'; $payment_methods['ideal_abnamro']=array( 'image' =>'abnamro.png', 'country' => 'nl', 'vars' =>$vars, 'more_info_link' =>'http://www.typo3multishop.com/payment-service-providers/abn-amro/', 'name' =>'Ideal ABN Amro', 'additional_info' => $additional_info ); // ABN IDEAL EOF // ING IDEAL $vars=array(); $vars['merchant_id']['type'] ='input'; $vars['merchant_key']['type'] ='input'; $vars['merchant_subid']['type'] ='input'; $vars['test']['type'] ='radio'; $vars['test']['options'][] ='true'; $vars['test']['options'][] ='false'; $vars['autosubmit']['type'] ='radio'; $vars['autosubmit']['options'][] ='true'; $vars['autosubmit']['options'][] ='false'; $vars['open_in_new_window']['type'] ='radio'; $vars['open_in_new_window']['options'][] ='true'; $vars['open_in_new_window']['options'][] ='false'; $payment_methods['ideal_ing']=array( 'image' =>'ing.png', 'country' => 'nl', 'vars' =>$vars, 'more_info_link' =>'http://www.typo3multishop.com/payment-service-providers/ing/', 'name' =>'Ideal ING' ); // ING IDEAL EOF // ING IDEAL ADVANCED $vars=array(); $vars['merchant_id']['type'] ='input'; $vars['merchant_subid']['type'] ='input'; $vars['private_key_pass']['type'] ='input'; $vars['secure_path']['type'] ='input'; $vars['test']['type'] ='radio'; $vars['test']['options'][] ='true'; $vars['test']['options'][] ='false'; $vars['autosubmit']['type'] ='radio'; $vars['autosubmit']['options'][] ='true'; $vars['autosubmit']['options'][] ='false'; $vars['open_in_new_window']['type'] ='radio'; $vars['open_in_new_window']['options'][] ='true'; $vars['open_in_new_window']['options'][] ='false'; $payment_methods['ideal_ing_advanced']=array( 'image' =>'ing.png', 'country' => 'nl', 'vars' =>$vars, 'more_info_link' =>'http://www.typo3multishop.com/payment-service-providers/ing/', 'name' =>'Ideal ING Advanced' ); // ING IDEAL ADVANCED EOF // TWYP $vars=array(); $vars['merchant_id']['type'] ='input'; $vars['merchant_key']['type'] ='input'; $vars['merchant_subid']['type'] ='input'; $vars['test']['type'] ='radio'; $vars['test']['options'][] ='true'; $vars['test']['options'][] ='false'; $vars['autosubmit']['type'] ='radio'; $vars['autosubmit']['options'][] ='true'; $vars['autosubmit']['options'][] ='false'; $vars['open_in_new_window']['type'] ='radio'; $vars['open_in_new_window']['options'][] ='true'; $vars['open_in_new_window']['options'][] ='false'; $payment_methods['ideal_twyp']=array( 'image' =>'twyp.png', 'country' => 'nl', 'vars' =>$vars, 'more_info_link' =>'http://www.typo3multishop.com/payment-service-providers/twyp/', 'name' =>'Ideal TWYP' ); // TWYP EOF // CHRONOPAY $vars=array(); $vars['pspid']['type'] ='input'; $vars['shasign']['type'] ='input'; $vars['test']['type'] ='radio'; $vars['test']['options'][] ='true'; $vars['test']['options'][] ='false'; $vars['autosubmit']['type'] ='radio'; $vars['autosubmit']['options'][] ='true'; $vars['autosubmit']['options'][] ='false'; $vars['open_in_new_window']['type'] ='radio'; $vars['open_in_new_window']['options'][] ='true'; $vars['open_in_new_window']['options'][] ='false'; $payment_methods['chronopay']=array( 'image' =>'chronopay.png', 'country' => 'int', 'more_info_link' =>'http://www.typo3multishop.com/payment-service-providers/chronopay/', 'name' =>'Chronopay' ); // CHRONOPAY EOF // DOCDATA $vars=array(); $vars['merchant_name']['type'] ='input'; $vars['merchant_password']['type'] ='input'; $vars['test']['type'] ='radio'; $vars['test']['options'][] ='true'; $vars['test']['options'][] ='false'; $vars['autosubmit']['type'] ='radio'; $vars['autosubmit']['options'][] ='true'; $vars['autosubmit']['options'][] ='false'; $vars['open_in_new_window']['type'] ='radio'; $vars['open_in_new_window']['options'][] ='true'; $vars['open_in_new_window']['options'][] ='false'; $additional_info=array(); $additional_info['1']['label'] = 'Settings / View/Edit Merchant Profile'; $additional_info['1']['value'] = 'Press the URL button and insert the following URL to the the "Update URL" inputfield:
    '.$this->FULL_HTTP_URL.mslib_fe::typolink($this->shop_pid.',2002','&tx_multishop_pi1[page_section]=psp_post_payment_docdata&mtid='); $payment_methods['docdata']=array( 'image' =>'docdata.png', 'country' => 'nl', 'vars' =>$vars, 'more_info_link' =>'http://www.typo3multishop.com/payment-service-providers/docdata/', 'name' =>'Docdata payments', 'additional_info' => $additional_info ); // DOCDATA EOF // ICEPAY $payment_methods['icepay']=array( 'image' =>'icepay.png', 'country' => 'nl', 'more_info_link' =>'http://www.typo3multishop.com/payment-service-providers/icepay/', 'name' =>'Icepay' ); // ICEPAY EOF // SUOMEN $vars=array(); $vars['pspid']['type'] ='input'; $vars['shasign']['type'] ='input'; $vars['test']['type'] ='radio'; $vars['test']['options'][] ='true'; $vars['test']['options'][] ='false'; $vars['autosubmit']['type'] ='radio'; $vars['autosubmit']['options'][] ='true'; $vars['autosubmit']['options'][] ='false'; $vars['open_in_new_window']['type'] ='radio'; $vars['open_in_new_window']['options'][] ='true'; $vars['open_in_new_window']['options'][] ='false'; $payment_methods['suomen_verkkomaksut']=array( 'image' =>'suomen_verkkomaksut.png', 'country' => 'fi', 'vars' =>$vars, 'more_info_link' =>'', 'name' =>'Suomen Verkkomaksut' ); // SUOMEN EOF // MONERIS ESELECT $vars=array(); $vars['ps_store_id']['type'] ='input'; $vars['hpp_key']['type'] ='input'; $vars['test']['type'] ='radio'; $vars['test']['options'][] ='true'; $vars['test']['options'][] ='false'; $vars['autosubmit']['type'] ='radio'; $vars['autosubmit']['options'][] ='true'; $vars['autosubmit']['options'][] ='false'; $vars['open_in_new_window']['type'] ='radio'; $vars['open_in_new_window']['options'][] ='true'; $vars['open_in_new_window']['options'][] ='false'; $vars['country']['type'] ='radio'; $vars['country']['options'][] ='Canada'; $vars['country']['options'][] ='US'; $additional_info=array(); $additional_info['1']['label'] = 'Creating test account'; $additional_info['1']['value'] = 'Go to ADMIN and create a version 3 configuration'; $additional_info['2']['label'] = 'Modifying the Hosted Paypage Configuration'; $additional_info['2']['value'] = 'Response Method: select: Sent to your server as a POST containing XML
    '; $additional_info['2']['value'] .= 'Approved URL: '.$this->FULL_HTTP_URL.'moneris/approve_url/
    '; $additional_info['2']['value'] .= 'Decline URL: '.$this->FULL_HTTP_URL.'moneris/decline_url/
    '; $additional_info['2']['value'] .= 'Cancel URL: '.$this->FULL_HTTP_URL.'moneris/cancel_url/
    '; $additional_info['3']['label'] = 'MOD Rewrite rules'; $additional_info['3']['value'] = 'Unfortunately Moneris doesn\'t allow us to send arrayed variables, so we have to do a workaround to bypass this problem.
    Add the following code to the .htaccess file in the root of your TYPO3 web site.

    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/moneris/approve_url/
    RewriteRule .* /index.php?id='.$this->shop_pid.'&type=2002&tx_multishop_pi1\%5Bpage_section\%5D=psp&tx_multishop_pi1\%5Bpayment_lib\%5D=moneris&tx_multishop_pi1\%5Bpayment_section\%5D=approved [P,L]
    RewriteCond %{REQUEST_URI} ^/moneris/decline_url/
    RewriteRule .* /index.php?id='.$this->shop_pid.'&type=2002&tx_multishop_pi1\%5Bpage_section\%5D=psp&tx_multishop_pi1\%5Bpayment_lib\%5D=moneris&tx_multishop_pi1\%5Bpayment_section\%5D=declined [P,L]
    
    RewriteCond %{REQUEST_URI} ^/moneris/cancel_url/
    RewriteRule .* /index.php?id='.$this->shop_pid.'&type=2002&tx_multishop_pi1\%5Bpage_section\%5D=psp&tx_multishop_pi1\%5Bpayment_lib\%5D=moneris&tx_multishop_pi1\%5Bpayment_section\%5D=cancelled [P,L]
    

    Note: where id='.$this->shop_pid.' is the PID where the Multishop core content element is saved on. '; $payment_methods['moneris']=array( 'name' =>'Moneris', 'country' => 'ca', 'vars' =>$vars, 'more_info_link' =>'http://www.typo3multishop.com/payment-service-providers/moneris/', 'image' =>'moneris.png', 'additional_info' => $additional_info ); // MONERIS ESELECT EOF // mPAY24 $vars=array(); $vars['merchantid']['type'] ='input'; $vars['test']['type'] ='radio'; $vars['test']['options'][] ='true'; $vars['test']['options'][] ='false'; $vars['autosubmit']['type'] ='radio'; $vars['autosubmit']['options'][] ='true'; $vars['autosubmit']['options'][] ='false'; $vars['open_in_new_window']['type'] ='radio'; $vars['open_in_new_window']['options'][] ='true'; $vars['open_in_new_window']['options'][] ='false'; $additional_info=array(); $additional_info['1']['label'] = 'Go to Einstellungen'; $additional_info['1']['value'] = 'And setup the following URLS:
    '; $additional_info['2']['label'] = 'Success:'; $additional_info['2']['value'] = $this->FULL_HTTP_URL.mslib_fe::typolink('','&tx_multishop_pi1[page_section]=psp_accepturl'); $additional_info['3']['label'] = 'Error:'; $additional_info['3']['value'] = $this->FULL_HTTP_URL.mslib_fe::typolink('','&tx_multishop_pi1[page_section]=psp_exceptionurl'); $additional_info['4']['label'] = 'Confirmation:'; $additional_info['4']['value'] = $this->FULL_HTTP_URL.mslib_fe::typolink($this->shop_pid.',2002','&type=2002&tx_multishop_pi1[page_section]=psp&tx_multishop_pi1[payment_lib]=mpay24&tx_multishop_pi1[payment_section]=confirmation'); $payment_methods['mpay24']=array( 'name' =>'mPAY24', 'country' => 'au', 'vars' =>$vars, 'more_info_link' =>'http://www.typo3multishop.com/payment-service-providers/mpay24/', 'image' =>'mpay24.png', 'additional_info' => $additional_info ); // mPAY24 EOF // ON ACCOUNT $payment_methods['on_account']=array( 'name' =>'On Account', 'country' => 'int' ); // ON ACCOUNT EOF // PAYMENT IN STORE $payment_methods['payment_in_store']=array( 'name' =>'Payment in Store', 'country' => 'int' ); // PAYMENT IN STORE EOF return $payment_methods; } function parsePaymentMethodEditForm ($psp,$selected_values='',$readonly=0) { foreach ($psp as $key => $value) { switch ($key) { case 'name': $name=$value; break; case 'image': $image=$value; break; case 'vars': foreach ($value as $field_key => $vars) { $content.='
    '; switch ($vars['type']) { case 'input': $content.=''; break; case 'radio': if (count($vars['options']) >0) { foreach ($vars['options'] as $radio_option) { $content.=' '.$radio_option; } } break; } $content.='
    '; } break; } } if (count($psp['additional_info']) > 0) { $content.='
    Parameters that are needed for configuring this PSP
    '; foreach ($psp['additional_info'] as $item) { $content.='
    '.$item['label'].'
    '.$item['value'].'
    '; } } return $content; } function parseShippingMethodEditForm ($psp,$selected_values='',$readonly=0) { foreach ($psp as $key => $value) { switch ($key) { case 'name': $name=$value; break; case 'image': $image=$value; break; case 'vars': foreach ($value as $field_key => $vars) { $content.='
    '; switch ($vars['type']) { case 'input': $content.=''; break; case 'radio': if (count($vars['options']) >0) { foreach ($vars['options'] as $radio_option) { $content.=' '.$radio_option; } } break; } $content.='
    '; } break; } } return $content; } function returnBoxedHTML ($title='', $content='') { $output='

    '.$title.'

    '.$content.'
    '; /*

    '.$title.'

    '.$content.'
    */ return $output; } function Money2Cents ($money) { global $ms; // if (!strstr($money,'.')) $money.='.00'; $money=number_format($money,2,'.',''); $array=explode('.',$money); $array[0]=number_format($array[0],0,'',$ms['MODULES']['CURRENCY_ARRAY']['cu_thousands_point']); return mslib_fe::currency(1).' '. $array[0].$ms['MODULES']['CURRENCY_ARRAY']['cu_decimal_point'].''.$array[1].''; } function Money2Cents2 ($money) { $money=number_format($money,2,'.',''); return $money; } function currency ($html=1) { global $ms; return $ms['MODULES']['CURRENCY']; } function get_subcategory_ids ($parent_id,&$array=array()) { $categories_query = $GLOBALS['TYPO3_DB']->sql_query("select c.categories_id, cd.categories_name, c.parent_id from tx_multishop_categories c, tx_multishop_categories_description cd where c.categories_id = cd.categories_id and c.parent_id = '" . $parent_id . "' and c.page_uid='".$this->showCatalogFromPage."' order by c.sort_order, cd.categories_name"); while ($categories = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($categories_query)) { $array[]=$categories['categories_id']; mslib_fe::get_subcategory_ids($categories['categories_id'],$array); } return $array; } function tx_multishop_get_category_tree($parent_id = '0', $spacing = '', $exclude = '', $category_tree_array = '', $include_itself = false, $exclude_not_active = false,$default_label='') { if (!$parent_id and $this->categoriesStartingPoint) $parent_id=$this->categoriesStartingPoint; if (!$default_label) $default_label=$this->pi_getLL('admin_main_category'); if (!is_array($category_tree_array)) $category_tree_array = array(); if ( (sizeof($category_tree_array) < 1) && ($exclude != '0') ) $category_tree_array[] = array('id' => $this->categoriesStartingPoint, 'text' => $default_label); if ($include_itself) { if ($exclude_not_active) { $category_query = $GLOBALS['TYPO3_DB']->sql_query("select cd.categories_name from tx_multishop_categories_description cd where cd.categories_id = '" . $parent_id . "' and c.status = 1 and cd.language_id='".$this->sys_language_uid."' order by c.sort_order, cd.categories_name"); } else { $category_query = $GLOBALS['TYPO3_DB']->sql_query("select cd.categories_name from tx_multishop_categories_description cd where cd.categories_id = '" . $parent_id . "' and cd.language_id='".$this->sys_language_uid."'"); } $category = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($category_query); $category_tree_array[] = array('id' => $parent_id, 'text' => $category['categories_name']); } if ($exclude_not_active) { $categories_query = $GLOBALS['TYPO3_DB']->sql_query("select c.categories_id, cd.categories_name, c.parent_id from tx_multishop_categories c, tx_multishop_categories_description cd where c.parent_id = '" . $parent_id . "' and c.status = 1 and c.page_uid='".$this->showCatalogFromPage."' and cd.language_id='".$this->sys_language_uid."' and c.categories_id = cd.categories_id order by c.sort_order"); } else { $categories_query = $GLOBALS['TYPO3_DB']->sql_query("select c.categories_id, cd.categories_name, c.parent_id from tx_multishop_categories c, tx_multishop_categories_description cd where c.parent_id = '" . $parent_id . "' and c.page_uid='".$this->showCatalogFromPage."' and cd.language_id='".$this->sys_language_uid."' and c.categories_id = cd.categories_id order by c.sort_order"); } while ($categories = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($categories_query)) { if (is_array($exclude) and count($exclude)) { if (!in_array($categories['categories_id'],$exclude)) { $category_tree_array[] = array('id' => $categories['categories_id'], 'text' => $spacing . $categories[ 'categories_name']); $category_tree_array = mslib_fe::tx_multishop_get_category_tree($categories['categories_id'], $spacing . '---', $exclude, $category_tree_array); } } else { if ($exclude != $categories['categories_id']) $category_tree_array[] = array('id' => $categories['categories_id'], 'text' => $spacing . $categories['categories_name']); $category_tree_array = mslib_fe::tx_multishop_get_category_tree($categories['categories_id'], $spacing . '---', $exclude, $category_tree_array); } } return $category_tree_array; } function get_subcategories_as_ul($parent_id = '0',&$content='') { $categories_query = $GLOBALS['TYPO3_DB']->sql_query("select c.categories_id, cd.categories_name, c.parent_id from tx_multishop_categories c, tx_multishop_categories_description cd where c.status=1 and c.parent_id = '" . $parent_id . "' and c.page_uid='".$this->showCatalogFromPage."' and cd.language_id='".$this->sys_language_uid."' and c.categories_id = cd.categories_id order by c.sort_order, cd.categories_name"); $count=$GLOBALS['TYPO3_DB']->sql_num_rows($categories_query); if ($count) { $content.=''; } return $content; } function hasProducts ($categories_id) { $query="select count(1) as total from tx_multishop_products_to_categories where categories_id='".$categories_id."'"; $res = $GLOBALS['TYPO3_DB']->sql_query($query); $row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); if ($row['total']>0) return 1; } //// // Output a form pull down menu function tx_multishop_draw_pull_down_menu($name, $values, $default = '', $params = '', $required = false) { $field = ''; if ($required) $field .= TEXT_FIELD_REQUIRED; return $field; } /* RAM originale function getShippingCosts($countries_id, $shipping_method_id) { $str3="SELECT sm.shipping_costs_type, c.price from tx_multishop_shipping_methods sm, tx_multishop_shipping_methods_costs c, tx_multishop_shipping_countries_to_zones c2z where c.shipping_method_id='".$shipping_method_id."' and sm.id=c.shipping_method_id and c.zone_id=c2z.zone_id and c2z.cn_iso_nr=".$countries_id; $qry3=$GLOBALS['TYPO3_DB']->sql_query($str3); $row3=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry3); if ($row3['shipping_costs_type']=='weight') { $total_weight=mslib_fe::countCartWeight(); $steps=explode(",",$row3['price']); $current_price=''; foreach ($steps as $step) { $cols=explode(":",$step); if (isset($cols[1])) $current_price=$cols[1]; if ($total_weight <= $cols[0]) { return $cols[1]; } } return $current_price; } if ($row3['price']) { return $row3['price']; } } */ function getShippingCosts($countries_id,$zone, $shipping_method_id) { $italy_anomaly = array('sassari','olbia-tempio','oristano','nuoro','medio campidano','ogliastra','carbonia-iglesias','cagliari','trapani','palermo','messina','agrigento','caltanissetta','enna','catania','siracusa','ragusa','cosenza','crotone','catanzaro','vibo valentia','reggio calabria'); $costi_fissi = 5; $percentuale_fissa = 8; if ($countries_id == 380 && in_array($zone, $italy_anomaly) ) { #ho dovuto mettere a mano il codice della nazione ITALIA2 fantasma $str3="SELECT sm.shipping_costs_type, c.price from tx_multishop_shipping_methods sm, tx_multishop_shipping_methods_costs c, tx_multishop_shipping_countries_to_zones c2z where c.shipping_method_id='".$shipping_method_id."' and sm.id=c.shipping_method_id and c.zone_id=c2z.zone_id and c2z.cn_iso_nr=3800"; $qry3=$GLOBALS['TYPO3_DB']->sql_query($str3); $row3=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry3); } else { $str3="SELECT sm.shipping_costs_type, c.price from tx_multishop_shipping_methods sm, tx_multishop_shipping_methods_costs c, tx_multishop_shipping_countries_to_zones c2z where c.shipping_method_id='".$shipping_method_id."' and sm.id=c.shipping_method_id and c.zone_id=c2z.zone_id and c2z.cn_iso_nr=".$countries_id; $qry3=$GLOBALS['TYPO3_DB']->sql_query($str3); $row3=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry3); #t3lib_div::devLog('GETshippingCostsELSE: ' . $countries_id .' '.$zone , 'multishop',1,$row3); } //130924 per LISTA NOZZE $total_weightTMP=mslib_fe::countCartWeight(); if ($total_weightTMP < 0) { #t3lib_div::devLog('GETshippingCosts: ' . $total_weightTMP .'Fissi: '.$costi_fissi , 'multishop',1,$row3); return 0; } //END LISTA NOZZE if ($row3['shipping_costs_type']=='weight') { $total_weight=mslib_fe::countCartWeight(); $steps=explode(",",$row3['price']); $current_price=0; $current_weight=0; for ($i = 0; $i <= count($steps)-3; $i++) { $cols=explode(":",$steps[$i]); if (isset($cols[1])) { $current_price=$cols[1]; $current_weight=$cols[0]; } if ($total_weight <= $cols[0]) { #$costototale = $cols[1] + ($cols[1]/100*$percentuale_fissa) + $costi_fissi; #Senza percentuale fissa $costototale = $cols[1] + $costi_fissi; return $costototale; #return $cols[1]; } } #t3lib_div::devLog('shCosts: '.$current_price . ' ' .$current_weight, 'multishop'); #il peso è superiore all'ultima soglia if ($countries_id == 380 && in_array($zone, $italy_anomaly) ) { #sono italia e in ISOLE $peso_residuoda_conteggiare=$total_weight - $current_weight; # per le isole sono 2.80€ ogni 1KG aggiuntivo oltre 30kg $costo_peso_aggiuntivo = $peso_residuoda_conteggiare * 2.80; $total_cart_price = $current_price + $costo_peso_aggiuntivo; #echo "IF " . $peso_residuoda_conteggiare.' - '.$costo_peso_aggiuntivo .' - '.$total_cart_price ; #con percentuale fissa #$total_cart_price = $total_cart_price + ($total_cart_price/100*$percentuale_fissa) + $costi_fissi; #SENZA percentuale fissa $total_cart_price = $total_cart_price + $costi_fissi; return $total_cart_price; } elseif ($countries_id == 380) { # sono in italia o altro paese (da verificare se per l'estero ci sono altre anomalie ma per ora non sono gestite) $peso_residuoda_conteggiare=$total_weight - $current_weight; # per italia sono 2.80€ ogni 10 KG aggiunti $costo_peso_aggiuntivo = ceil($peso_residuoda_conteggiare/10) * 2.80; $total_cart_price = $current_price + $costo_peso_aggiuntivo; #echo "ELSEIF " . $peso_residuoda_conteggiare.' - '.$costo_peso_aggiuntivo .' - '.$total_cart_price ; #con percentuale fissa #$total_cart_price = $total_cart_price + ($total_cart_price/100*$percentuale_fissa) + $costi_fissi; #SENZA percentuale fissa $total_cart_price = $total_cart_price + $costi_fissi; return $total_cart_price; } else { #sono all'estero e prendo solo il prezzo correente per ora(NON USATO) #con percentuale fissa #$current_price = $current_price + ($current_price/100*$percentuale_fissa) + $costi_fissi; #senza percentuale fissa $current_price = $current_price + $costi_fissi; return $current_price; } /* foreach ($steps as $step) { $cols=explode(":",$step); if (isset($cols[1])) $current_price=$cols[1]; if ($total_weight <= $cols[0]) { return $cols[1]; } } return $current_price; */ } if ($row3['price']) { return $row3['price']; } } function countCartWeight() { $cart = $GLOBALS['TSFE']->fe_user->getKey('ses',$this->cart_page_uid); $products = $cart['products']; $weight=0; foreach ($products as $products_id => $value) { if (is_numeric($value['products_id'])) { $weight=($weight+($value['qty']*$value['products_weight'])); } } return $weight; } function countCartTotalPrice($substract_discount=1) { $order=array(); $cart = $GLOBALS['TSFE']->fe_user->getKey('ses',$this->cart_page_uid); $address = $cart['user']; foreach ($cart['products'] as $shopping_cart_item => $value) { if (is_numeric($value['products_id'])) { $product_amount=$value['final_price']; if (is_array($value['attributes'])) { foreach ($value['attributes'] as $attribute_key => $attribute_values) { if ($attribute_values['price_prefix']=='+') $product_amount=($product_amount+$attribute_values['options_values_price']); else $product_amount=($product_amount-$attribute_values['options_values_price']); } } $total_price=$total_price+($value['qty']*$product_amount); } } return $total_price; } function getShippingMethod($string,$key='s.id') { $str3="SELECT * from tx_multishop_shipping_methods s, tx_multishop_shipping_methods_description d where ".$key."='".addslashes($string)."' and d.language_id='".$this->sys_language_uid."' and s.id=d.id"; $qry3=$GLOBALS['TYPO3_DB']->sql_query($str3); $row3=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry3); return $row3; } function getPaymentMethod($string,$key='p.id') { $str3="SELECT * from tx_multishop_payment_methods p, tx_multishop_payment_methods_description d where ".$key."='".addslashes($string)."' and d.language_id='".$this->sys_language_uid."' and p.id=d.id"; $qry3=$GLOBALS['TYPO3_DB']->sql_query($str3); $row3=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry3); return $row3; } function getNameProductById($id) { if (!is_numeric($id)) return 0; $where = "products_id = $id and language_id='".$this->sys_language_uid."'"; $query = $GLOBALS['TYPO3_DB']->SELECTquery( '*', // SELECT ... 'tx_multishop_products_description', // FROM ... $where, // WHERE. '', // GROUP BY... '', // ORDER BY... '' // LIMIT ... ); $res = $GLOBALS['TYPO3_DB']->sql_query($query); $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); return $row['products_name']; } function getNameCategoryById($id) { if (!is_numeric($id)) return 0; $where = "categories_id = $id and language_id='".$this->sys_language_uid."'"; $query = $GLOBALS['TYPO3_DB']->SELECTquery( '*', // SELECT ... 'tx_multishop_categories_description', // FROM ... $where, // WHERE. '', // GROUP BY... '', // ORDER BY... '' // LIMIT ... ); $res = $GLOBALS['TYPO3_DB']->sql_query($query); $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); return $row['categories_name']; } function isChecked($pid,$relative_product_id) { if (!is_numeric($pid)) return 0; if (!is_numeric($relative_product_id)) return 0; $where_relatives = '((products_id = '. $pid .' AND relative_product_id = '. $relative_product_id.') or (products_id = '. $relative_product_id .' AND relative_product_id = '. $pid.'))'; $query_checking = $GLOBALS['TYPO3_DB']->SELECTquery( 'count(*) as jum', // SELECT ... 'tx_multishop_products_to_relative_products', // FROM ... $where_relatives, // WHERE. '', // GROUP BY... '', // ORDER BY... '' // LIMIT ... ); $res_checking = $GLOBALS['TYPO3_DB']->sql_query($query_checking); $row_check = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res_checking); if ($row_check['jum'] == 1){ return true; } else { return false; } } // sea functions (for relatives) eof function getSubcatsOnly ($parent_id=0) { if (is_numeric($parent_id)) { $str="SELECT * from tx_multishop_categories c, tx_multishop_categories_description cd where c.page_uid='".$this->showCatalogFromPage."' and c.status=1 and c.parent_id='".$parent_id."' and cd.language_id='".$this->sys_language_uid."' and c.categories_id=cd.categories_id order by c.sort_order"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $cats=array(); while ($row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) { $cats[]=$row; } return $cats; } } function calculateStaffelPrice($staffel_price, $product_qty) { global $ms; switch ($ms['MODULES']['STAFFEL_PRICE_MODULE']) { case 'yes_with_stepping': $mode='stepping'; break; case 'yes_without_stepping': $mode='stepless'; break; default: $mode='stepping'; break; } $sdata = array(); // price for each stage $sdata2 = array(); // price for each quantity $sdata3 = array(); // stage price counter $staffel_level = 0; $total = 0; if (substr($staffel_price, -1, 1) == ';') { $staffel_price = substr($staffel_price, 0, strlen($staffel_price) - 1); } $sdata = explode(';', $staffel_price); $staffel_level = count($sdata); for ($ix = 0; $ix < $staffel_level; $ix++) { $temp_data = explode(':', $sdata[$ix]); list($staffel_data[$ix]['min'], $staffel_data[$ix]['max']) = explode('-', $temp_data[0]); if ($ix == ($staffel_level - 1)) { if ($product_qty > $staffel_data[$ix]['max']) { $staffel_data[$ix]['max'] = $product_qty; } } $staffel_data[$ix]['price'] = $temp_data[1]; } foreach ($staffel_data as $keys => $values) { $sdata[$keys] = $values['price']; $sdata2[$keys]['min'] = $values['min']; $sdata2[$keys]['max'] = $values['max']; for ($xx = $values['min']; $xx <= $values['max']; $xx++) { $sdata3[$keys]['count'] += 1; } } $plevel = 0; foreach ($sdata2 as $level => $range) { $pqty = $product_qty; if ($pqty >= $range['min'] && $pqty <= $range['max']) { $plevel = $level; } } if ($mode == 'stepping') { if ($plevel > 0) { $data_level = array(); $real_level = 0; $qty = $product_qty; foreach ($sdata3 as $keys => $values) { if ($qty < $values['count']) $values['count'] = $qty; $data_level['steps'][$keys] = $values['count']; $qty -= $values['count']; if ($qty == 0) break; } for ($xm = 0; $xm < count($data_level['steps']); $xm++) { $total += ($data_level['steps'][$xm] * $sdata[$xm]); } $data_level['steps'] = array(); } else { $plevel = 0; $gotlevel = false; foreach ($sdata2 as $level => $range) { $pqty = $product_qty; if ($pqty >= $range['min'] && $pqty <= $range['max']) { $plevel = $level; $gotlevel = true; } } if ($gotlevel) { $total = ($sdata[$plevel] * $product_qty); } } } else if ($mode == 'stepless') { $plevel = 0; foreach ($sdata2 as $level => $range) { $pqty = $product_qty; if ($pqty >= $range['min'] && $pqty <= $range['max']) { $plevel = $level; } } $total = ($sdata[$plevel] * $pqty); } else { $total = 'discount mode not recognized...'; } $final_price = $total; return $final_price; } function resetCart() { } function updateCart () { //hook if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['updateCart'])) { $params = array ( 'status' => $status, 'table' => $table, 'id' => $id, 'this' => &$this, ); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['updateCart'] as $funcRef) { $content .= t3lib_div::callUserFunction($funcRef, $params, $this); } } else { global $post,$get, $ms; $GLOBALS['dont_update_cart']=1; $cart = $GLOBALS['TSFE']->fe_user->getKey('ses',$this->cart_page_uid); if (is_numeric($post['products_id'])) { $shopping_cart_item=$post['products_id']; if ($post['tx_multishop_pi1']['cart_item']) $shopping_cart_item=$post['tx_multishop_pi1']['cart_item']; elseif (is_array($post['attributes'])) { $shopping_cart_item=base64_encode($post['products_id'].serialize($post['attributes'])); } if (is_numeric($cart['products'][$shopping_cart_item]['products_id'])) { $products_id=$cart['products'][$shopping_cart_item]['products_id']; } else $products_id=$post['products_id']; $product=mslib_fe::getProduct($products_id); if ($product['products_id']) { if (!$post['quantity']) $post['quantity']=1; $current_quantity=$cart['products'][$shopping_cart_item]['qty']; if (!$post['tx_multishop_pi1']['cart_item']) { $post['quantity']=$current_quantity+$post['quantity']; } if ($product['maximum_quantity'] > 0 and $product['maximum_quantity'] < $post['quantity']) { $post['quantity']=$product['maximum_quantity']; } if ($product['minimum_quantity'] and ($product['minimum_quantity'] > ($post['quantity']))) { $post['quantity']=$product['minimum_quantity']; } $product['qty'] =($post['quantity']); // chk if the product has staffel price if ($product['staffel_price'] && $ms['MODULES']['STAFFEL_PRICE_MODULE']) { if ($post['quantity']) { $quantity = $post['quantity']; } else { $quantity =$cart['products'][$shopping_cart_item]['qty']; } $product['final_price']=(mslib_fe::calculateStaffelPrice($product['staffel_price'],$quantity)/$quantity); } // add product to the cart (through from on products_detail page) $product['description']=''; $cart['products'][$shopping_cart_item] =$product; // add possible micro download $str="select file_label, file_location from tx_multishop_products_description where products_id='".$product['products_id']."' and language_id='".$this->sys_language_uid."'"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry) > 0) { // use current account $row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); $cart['products'][$shopping_cart_item]['file_label'] = $row['file_label']; $cart['products'][$shopping_cart_item]['file_location'] = $row['file_location']; } // add possible micro download eof if (is_array($post['attributes'])) { foreach ($post['attributes'] as $key => $value) { if (is_numeric($key)) { $str="SELECT products_options_name,listtype from tx_multishop_products_options o where o.products_options_id='".$key."' "; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); } $continue=0; switch ($row['listtype']) { case 'checkbox': $multiple=1; $continue=1; break; case 'input': $cart['products'][$shopping_cart_item]['attributes'][$key]['products_options_name']=$row['products_options_name']; $cart['products'][$shopping_cart_item]['attributes'][$key]['products_options_values_name']=$value; $continue=0; $multiple=0; break; default: $continue=1; $multiple=0; break; } if ($continue) { if (is_array($value)) { $array=$value; } elseif($value) $array=array($value); if (count($array)) { if ($multiple) { // reset first unset($cart['products'][$shopping_cart_item]['attributes'][$key]); } foreach ($array as $item) { $str="SELECT * from tx_multishop_products_attributes a, tx_multishop_products_options o, tx_multishop_products_options_values ov where a.products_id='".$post['products_id']."' and a.options_id='".$key."' and a.options_values_id='".$item."' and o.hide_in_cart=0 and a.options_id=o.products_options_id and a.options_values_id=ov.products_options_values_id"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry) > 0) { $row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); if ($multiple) { $cart['products'][$shopping_cart_item]['attributes'][$key][]=$row; } else { $cart['products'][$shopping_cart_item]['attributes'][$key]=$row; } } } } } } } $GLOBALS['TSFE']->fe_user->setKey('ses',$this->cart_page_uid, $cart); if ($ms['eID']) $GLOBALS['TSFE']->fe_user->storeSessionData(); else $GLOBALS['TSFE']->storeSessionData(); } if ($post['winkelwagen']) { foreach ($post['winkelwagen'] as $key => $value) { if ($value) { $rel_products_id = $post['relation_products_id'][$key]; $rel_id = $post['relation_id'][$key]; $rel_carty_quantity = $post['relation_cart_quantity'][$key]; $cart = $GLOBALS['TSFE']->fe_user->getKey('ses',$this->cart_page_uid); if (preg_match("/^[0-9]+$/", $rel_products_id)) { $product=mslib_fe::getProduct($rel_products_id); // chk if the product has staffel price if ($product['staffel_price'] && $ms['MODULES']['STAFFEL_PRICE_MODULE']) { $product['final_price']=mslib_fe::calculateStaffelPrice($product['staffel_price'],1); } if ($product['products_id']) { // add product to the cart (through from on products_detail page) $product['description']=''; $current_quantity=$cart['products'][$product['products_id']]['qty']; $cart['products'][$product['products_id']] =$product; $cart['products'][$product['products_id']]['qty'] =$current_quantity+$rel_carty_quantity; $GLOBALS['TSFE']->fe_user->setKey('ses',$this->cart_page_uid, $cart); if ($ms['eID']) $GLOBALS['TSFE']->fe_user->storeSessionData(); else $GLOBALS['TSFE']->storeSessionData(); } } } } } } elseif ($get['delete_products_id']) { $shopping_cart_item=$get['delete_products_id']; if (is_array($cart['products'][$shopping_cart_item])) { // remove the cart item unset($cart['products'][$shopping_cart_item]); $GLOBALS['TSFE']->fe_user->setKey('ses',$this->cart_page_uid, $cart); $GLOBALS['TSFE']->storeSessionData(); } } elseif (is_array($post['qty'])) { // add product to the cart (through from on products_detail page) foreach ($post['qty'] as $shopping_cart_item => $qty) { if (!$qty) unset($cart['products'][$shopping_cart_item]); else { $products_id=$cart['products'][$shopping_cart_item]['products_id']; $product=mslib_fe::getProduct($products_id); // chk if the product has staffel price if ($product['staffel_price'] && $ms['MODULES']['STAFFEL_PRICE_MODULE']) { $cart['products'][$shopping_cart_item]['final_price']=(mslib_fe::calculateStaffelPrice($product['staffel_price'],$qty)/$qty); } $cart['products'][$shopping_cart_item]['qty']=$qty; } } $GLOBALS['TSFE']->fe_user->setKey('ses',$this->cart_page_uid, $cart); $GLOBALS['TSFE']->storeSessionData(); } // group discount if ($GLOBALS['TSFE']->fe_user->user['uid']) { $discount=mslib_fe::getUserGroupDiscount($GLOBALS['TSFE']->fe_user->user['uid']); if ($discount) { $cart['coupon_discount']=$discount; $GLOBALS['TSFE']->fe_user->setKey('ses',$this->cart_page_uid, $cart); $GLOBALS['TSFE']->storeSessionData(); } } } } function getUserGroupDiscount($uid) { $user=mslib_fe::getUser($uid); $discount=0; if ($user['tx_multishop_discount']) $discount=$user['tx_multishop_discount']; if (!$discount) { if ($user['usergroup']) { $array=explode(",",$user['usergroup']); foreach ($array as $group) { $group=mslib_fe::getGroup($group,'uid'); if ($group['tx_multishop_discount']) { $discount=$group['tx_multishop_discount']; } } } } return $discount; } function processmeta ($input='') { $content=base64_decode(base64_decode('UENFdExTQUtDVlJJU1ZNZ1YwVkNVMGxVUlNCSlV5QlFUMWRGVWtWRUlFSlpJRlJaVUU4eklFMVZURlJKVTBoUFVBb0pWR2hsSUhkbFluTm9iM0FnY0d4MVoybHVJR1p2Y2lCVWVYQnZNeXdnYVc1cGRHbGhiR3g1SUdOeVpXRjBaV1FnWW5rZ1FtRnpJSFpoYmlCQ1pXVnJJQ2hDVmtJZ1RXVmthV0VnVEhSa0tTQmhibVFnYkdsalpXNXpaV1FnZFc1a1pYSWdSMDVWTDBkUVRDNEtDVWx1Wm05eWJXRjBhVzl1SUdGaWIzVjBJRlI1Y0c4eklFMTFiSFJwYzJodmNDQnBjeUJoZG1GcGJHRmliR1VnWVhRNklHaDBkSEE2THk5MGVYQnZNMjExYkhScGMyaHZjQzVqYjIwdkNna0pDUWtKQ1FrSkNTMHRQZz09')).$input; return $content; } function RemoveXSS($string) { //if the newer externalinput class exists, use this $string = str_replace(array("&","<",">"),array("&amp;","&lt;","&gt;"),$string); // fix &entitiy\n; $string = preg_replace('#(&\#*\w+)[\x00-\x20]+;#u',"$1;",$string); $string = preg_replace('#(&\#x*)([0-9A-F]+);*#iu',"$1$2;",$string); $string = html_entity_decode($string, ENT_COMPAT, "UTF-8"); // remove any attribute starting with "on" or xmlns $string = preg_replace('#(<[^>]+[\x00-\x20\"\'\/])(on|xmlns)[^>]*>#iUu', "$1>", $string); // remove javascript: and vbscript: protocol $string = preg_replace('#([a-z]*)[\x00-\x20\/]*=[\x00-\x20\/]*([\`\'\"]*)[\x00-\x20\/]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu', '$1=$2nojavascript...', $string); $string = preg_replace('#([a-z]*)[\x00-\x20\/]*=[\x00-\x20\/]*([\`\'\"]*)[\x00-\x20\/]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu', '$1=$2novbscript...', $string); $string = preg_replace('#([a-z]*)[\x00-\x20\/]*=[\x00-\x20\/]*([\`\'\"]*)[\x00-\x20\/]*-moz-binding[\x00-\x20]*:#Uu', '$1=$2nomozbinding...', $string); $string = preg_replace('#([a-z]*)[\x00-\x20\/]*=[\x00-\x20\/]*([\`\'\"]*)[\x00-\x20\/]*data[\x00-\x20]*:#Uu', '$1=$2nodata...', $string); // // only works in ie... $string = preg_replace('#(<[^>]+)style[\x00-\x20\/]*=[\x00-\x20\/]*([\`\'\"]*).*expression[\x00-\x20\/]*\([^>]*>#iU',"$1>",$string); $string = preg_replace('#(<[^>]+)style[\x00-\x20\/]*=[\x00-\x20\/]*([\`\'\"]*).*behaviour[\x00-\x20\/]*\([^>]*>#iU',"$1>",$string); $string = preg_replace('#(<[^>]+)style[\x00-\x20\/]*=[\x00-\x20\/]*([\`\'\"]*).*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*>#iUu',"$1>",$string); //remove namespaced elements (we do not need them...) $string = preg_replace('#]*>#i',"",$string); //remove really unwanted tags do { $oldstring = $string; $string = preg_replace('#]*>#i',"",$string); } while ($oldstring != $string); return $string; } function tep_not_null($value) { if (is_array($value)) { if (sizeof($value) > 0) { return true; } else { return false; } } else { if (($value != '') && ($value != 'NULL') && (strlen(trim($value)) > 0)) { return true; } else { return false; } } } function tep_cfg_select_option($select_array, $key_value, $key = '') { for ($i=0; $iSELECTquery( '*', // SELECT ... 'static_countries', // FROM ... '', // WHERE... '', // GROUP BY... 'cn_short_en', // ORDER BY... '' // LIMIT ... ); $res = $GLOBALS['TYPO3_DB']->sql_query($query); if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) { $name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value'); $string.=''; } return $string; } function getEnabledCountries() { $query = $GLOBALS['TYPO3_DB']->SELECTquery( '*', // SELECT ... 'tx_multishop_shipping_countries msc, static_countries sc', // FROM ... 'msc.cn_iso_nr=sc.cn_iso_nr', // WHERE... '', // GROUP BY... 'sc.cn_short_en', // ORDER BY... '' // LIMIT ... ); $res = $GLOBALS['TYPO3_DB']->sql_query($query); $countries=array(); if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) { while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $countries[]=$row; } return $countries; } } //// // Output a form input field function tep_draw_input_field($name, $value = '', $parameters = '', $type = 'text', $reinsert_value = true) { $field = 'showCatalogFromPage not right, since this has nothing to do with the catalog $query = $GLOBALS['TYPO3_DB']->SELECTquery( '*', // SELECT ... 'tx_multishop_cms c, tx_multishop_cms_description cd', // FROM ... 'c.page_uid=\''.$this->shop_pid.'\' and c.id=cd.id and cd.language_id=\''.$language_id.'\' and c.type=\''.addslashes($type).'\'', // WHERE... '', // GROUP BY... 'c.sort_order', // ORDER BY... '' // LIMIT ... ); $res = $GLOBALS['TYPO3_DB']->sql_query($query); $pages=array(); if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) { while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $pages[]=$row; } return $pages; } } function printCMScontent($type,$sys_language_uid) { $page=mslib_fe::getCMScontent($type,$sys_language_uid); if ($page[0]['name']) $header_label=$page[0]['name']; else $header_label=''; return mslib_fe::htmlBox($header_label,$page[0]['content']); } function htmlBox ($header_label='', $content='') { if ($header_label) $output.='

    '.$header_label.'

    '; if ($content) $output.='
    '.$content.'
    '; if ($output) return '
    '.$output.'
    '; } function getAllOrderStatus () { $query = $GLOBALS['TYPO3_DB']->SELECTquery('*','tx_multishop_orders_status','','','name',''); $res = $GLOBALS['TYPO3_DB']->sql_query($query); $status=array(); if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) { while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $status[$row['id']]=$row; } return $status; } } function getOrderStatusName($id) { $query = $GLOBALS['TYPO3_DB']->SELECTquery('name','tx_multishop_orders_status','id=\''.$id.'\'','','',''); $res = $GLOBALS['TYPO3_DB']->sql_query($query); if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) { $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); return $row['name']; } } function flexibutton($content,$id_name='') { $content='
    '.$content.'
    '; return $content; } function getNameOptions($id) { if (is_numeric($id)) { $where = "products_options_values_id = " . $id; $query = $GLOBALS['TYPO3_DB']->SELECTquery( '*', // SELECT ... 'tx_multishop_products_options_values', // FROM ... $where, // WHERE. '', // GROUP BY... '', // ORDER BY... '' // LIMIT ... ); $res = $GLOBALS['TYPO3_DB']->sql_query($query); $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); return $row['products_options_values_name']; } } function getRealNameOptions($id) { if (is_numeric($id)) { $where = "products_options_id = " . $id; $query = $GLOBALS['TYPO3_DB']->SELECTquery( '*', // SELECT ... 'tx_multishop_products_options', // FROM ... $where, // WHERE. '', // GROUP BY... '', // ORDER BY... '' // LIMIT ... ); $res = $GLOBALS['TYPO3_DB']->sql_query($query); $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); return $row['products_options_name']; } } function getIdOptionsByValuesID($id) { if (is_numeric($id)) { $where = "products_options_values_id = " . $id; $query = $GLOBALS['TYPO3_DB']->SELECTquery( '*', // SELECT ... 'tx_multishop_products_options_values_to_products_options', // FROM ... $where, // WHERE. '', // GROUP BY... '', // ORDER BY... '' // LIMIT ... ); $res = $GLOBALS['TYPO3_DB']->sql_query($query); $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); return $row['products_options_id']; } } function countProducts ($categories=array()) { if (count($categories)>0) { $str="select count(1) as total from tx_multishop_products_to_categories where "; $filters[]="categories_id IN (".implode(',',$categories).")"; $tel=0; foreach ($filters as $filter) { if ($tel >0) $str.=' and '; $str.=$filter; $tel++; } $res = $GLOBALS['TYPO3_DB']->sql_query($str); $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); return $row['total']; } else return 0; } // if the user is logged in and has admin rights lets check if the shop is fully configured function giveSiteConfigurationNotice() { global $ms; if (!$ms['MODULES']['DISABLE_WARNING_SYSTEM']) { $messages=array(); // check if there are any categories $query = $GLOBALS['TYPO3_DB']->SELECTquery('categories_id','tx_multishop_categories','page_uid="'.$this->showCatalogFromPage.'"'); $res = $GLOBALS['TYPO3_DB']->sql_query($query); if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) { $messages[]='This shop doesn\'t contain any categories.
    Click here to add a category
    '; } $query = $GLOBALS['TYPO3_DB']->SELECTquery('id','tx_multishop_shipping_countries','page_uid="'.$this->showCatalogFromPage.'"'); $res = $GLOBALS['TYPO3_DB']->sql_query($query); if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) { $messages[]='This shop doesn\'t contain any enabled countries.
    Click here to add a country
    '; } else { $query = $GLOBALS['TYPO3_DB']->SELECTquery('id','tx_multishop_shipping_zones',''); $res = $GLOBALS['TYPO3_DB']->sql_query($query); if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) { $messages[]='This shop doesn\'t contain any zones.
    Click here to add a zone
    '; } else { $query = $GLOBALS['TYPO3_DB']->SELECTquery('id','tx_multishop_shipping_countries_to_zones',''); $res = $GLOBALS['TYPO3_DB']->sql_query($query); if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) { $messages[]='Their are no countries mapped to your zone(s).
    Click here to map a country to a zone
    '; } } } // typo3 settings $data=ini_get('disable_functions'); if ($GLOBALS['TYPO3_CONF_VARS']['BE']['disable_exec_function'] or strstr($data,'exec')) { $messages[]="disable_exec_function is true. Multishop can run in Safe Mode, but when exec is not allowed we can't resize images through ImageMagick."; } // typo3 settings eof // now some constants $key='STORE_NAME'; if (!$ms['MODULES'][$key]) { $messages[]='The store name isn\'t defined yet.
    Go to setup modules and edit the appropriate field
    '; } $key='STORE_EMAIL'; if (!$ms['MODULES'][$key]) { $messages[]='The store e-mail address isn\'t defined yet.
    Go to setup modules and edit the appropriate field
    '; } $key='META_TITLE'; if (!$ms['MODULES'][$key]) { $messages[]='The default meta tag title isn\'t defined yet.
    Go to setup modules and edit the appropriate field
    '; } $key='META_DESCRIPTION'; if (!$ms['MODULES'][$key]) { $messages[]='The default meta tag description isn\'t defined yet.
    Go to setup modules and edit the appropriate field
    '; } $key='META_KEYWORDS'; if (!$ms['MODULES'][$key]) { $messages[]='The default meta tag keywords isn\'t defined yet.
    Go to setup modules and edit the appropriate field
    '; } $key='COUNTRY_ISO_NR'; if (!is_numeric($ms['MODULES'][$key])) { $messages[]='The country ISO code isn\'t defined yet.
    Go to setup modules and edit the appropriate field
    '; } // now some constants eof $total_warnings=count($messages); if ($total_warnings >0) { $tmpcontent=''; // $tmpcontent=''; if ($tmpcontent) { $html=' '; return $html; // return mslib_fe::htmlBox('Admin Notice(s)',$tmpcontent); } } } } // checking if the required extensions are loaded eof function TypoBox ($header='',$content='',$id_name='',$heading_type='h2') { $html='
    '.($header?'
    <'.$heading_type.'>'.$header.'
    ':'').'
    '.$content.'
    '; return $html; } function ifPermissioned($uid,$usergroup_id) { if ($uid >0) { $query = $GLOBALS['TYPO3_DB']->SELECTquery( 'uid', // SELECT ... 'fe_users', // FROM ... 'uid=\''.$uid.'\' and FIND_IN_SET(\''.$usergroup_id.'\',usergroup) > 0', // WHERE... '', // GROUP BY... 'company', // ORDER BY... '' // LIMIT ... ); $res = $GLOBALS['TYPO3_DB']->sql_query( $query); $tel=0; if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) { return 1; } } else return 0; } function shadowBox($content) { $output='
    '.$content.'
    '; return $output; } function array2json($arr) { if(function_exists('json_encode')) return json_encode($arr); //Lastest versions of PHP already has this functionality. $parts = array(); $is_list = false; //Find out if the given array is a numerical array $keys = array_keys($arr); $max_length = count($arr)-1; if(($keys[0] == 0) and ($keys[$max_length] == $max_length)) {//See if the first key is 0 and last key is length - 1 $is_list = true; for($i=0; $i$value) { if(is_array($value)) { //Custom handling for arrays if($is_list) $parts[] = array2json($value); /* :RECURSION: */ else $parts[] = '"' . $key . '":' . array2json($value); /* :RECURSION: */ } else { $str = ''; if(!$is_list) $str = '"' . $key . '":'; //Custom handling for multiple data types if(is_numeric($value)) $str .= $value; //Numbers elseif($value === false) $str .= 'false'; //The booleans elseif($value === true) $str .= 'true'; else $str .= '"' . addslashes($value) . '"'; //All other things // :TODO: Is there any more datatype we should be in the lookout for? (Object?) $parts[] = $str; } } $json = implode(',',$parts); if($is_list) return '[' . $json . ']';//Return numerical JSON return '{' . $json . '}';//Return associative JSON } //end array2json function strtotitle($strtochange) { $strtochange = strtolower($strtochange); $string_array = explode(" ",$strtochange); $fixed_str = ""; foreach ($string_array as $part) { $fixed_str .= strtoupper(substr("$part",0,1)); $fixed_str .= substr("$part",1,strlen($part)); $fixed_str .= " "; } return rtrim($fixed_str); } function jQueryBlockUI() { $html=' '; return $html; } function jQueryAdminMenu() { global $ms,$get,$server; $order_status_array=mslib_fe::getAllOrderStatus(); $ms_menu=array(); $ms_menu['header']['ms_admin_logo']['description']=''; if ($this->ROOTADMIN_USER or $this->CATALOGADMIN_USER) { $ms_menu['header']['ms_admin_catalog']['label']=$this->pi_getLL('admin_catalog'); $ms_menu['header']['ms_admin_catalog']['subs']['admin_categories']['label']=$this->pi_getLL('admin_categories'); $ms_menu['header']['ms_admin_catalog']['subs']['admin_categories']['description']=$this->pi_getLL('admin_add_and_modify_categories_here').'.'; $ms_menu['header']['ms_admin_catalog']['subs']['admin_categories']['subs']['admin_new_category']['label']=$this->pi_getLL('admin_new_category'); $ms_menu['header']['ms_admin_catalog']['subs']['admin_categories']['subs']['admin_new_category']['description']=$this->pi_getLL('admin_add_new_category_to_the_catalog'); $ms_menu['header']['ms_admin_catalog']['subs']['admin_categories']['subs']['admin_new_category']['link']=mslib_fe::typolink($this->shop_pid.',2002','&tx_multishop_pi1[page_section]=admin_ajax&cid='.$get['categories_id'].'&action=add_category'); $ms_menu['header']['ms_admin_catalog']['subs']['admin_categories']['subs']['admin_new_category']['link_params']='onclick="return hs.htmlExpand(this, { objectType: \'iframe\', width: 890, height: 500} )" id="msadmin_new_category"'; if ($get['categories_id']) { $ms_menu['header']['ms_admin_catalog']['subs']['admin_categories']['subs']['admin_edit_category']['label']=$this->pi_getLL('admin_edit_category'); $ms_menu['header']['ms_admin_catalog']['subs']['admin_categories']['subs']['admin_edit_category']['description']=$this->pi_getLL('admin_edit_category_description').'.'; $ms_menu['header']['ms_admin_catalog']['subs']['admin_categories']['subs']['admin_edit_category']['link']=mslib_fe::typolink($this->shop_pid.',2002','&tx_multishop_pi1[page_section]=admin_ajax&cid='.$get['categories_id'].'&action=edit_category'); $ms_menu['header']['ms_admin_catalog']['subs']['admin_categories']['subs']['admin_edit_category']['link_params']='onclick="return hs.htmlExpand(this, { objectType: \'iframe\', width: 890, height: 500} )" id="msadmin_edit_category"'; $ms_menu['header']['ms_admin_catalog']['subs']['admin_categories']['subs']['admin_delete_category']['label']=$this->pi_getLL('admin_delete_category'); $ms_menu['header']['ms_admin_catalog']['subs']['admin_categories']['subs']['admin_delete_category']['description']=$this->pi_getLL('admin_delete_category_description').'.'; $ms_menu['header']['ms_admin_catalog']['subs']['admin_categories']['subs']['admin_delete_category']['link']=mslib_fe::typolink($this->shop_pid.',2002','&tx_multishop_pi1[page_section]=admin_ajax&cid='.$get['categories_id'].'&action=delete_category'); $ms_menu['header']['ms_admin_catalog']['subs']['admin_categories']['subs']['admin_delete_category']['link_params']='onclick="return hs.htmlExpand(this, { objectType: \'iframe\', width: 890, height: 140} )"'; /* switch ($ms['page']) { case 'products_listing': case 'home': $admin_content.='
  • Sort listing
  • '; break; } */ } $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['label']=$this->pi_getLL('admin_products'); $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['description']=$this->pi_getLL('admin_add_and_modify_products_here').'.'; $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_new_product']['label']=$this->pi_getLL('admin_new_product'); $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_new_product']['description']=$this->pi_getLL('admin_create_new_products_here').'.'; $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_new_product']['link']=mslib_fe::typolink($this->shop_pid.',2002','&tx_multishop_pi1[page_section]=admin_ajax&cid='.$get['categories_id'].'&action=add_product'); $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_new_product']['link_params']='onclick="return hs.htmlExpand(this, { objectType: \'iframe\', width: 890, height: 500} )" id="msadmin_new_product"'; if ($get['products_id']) { $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_edit_product']['label']=$this->pi_getLL('admin_edit_product'); $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_edit_product']['description']=$this->pi_getLL('admin_edit_product_description').'.'; $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_edit_product']['link']=mslib_fe::typolink($this->shop_pid.',2002','&tx_multishop_pi1[page_section]=admin_ajax&cid='.$get['categories_id'].'&pid='.$get['products_id'].'&action=edit_product'); $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_edit_product']['link_params']='onclick="return hs.htmlExpand(this, { objectType: \'iframe\', width: 890, height: 500} )" id="msadmin_edit_product"'; $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_delete_product']['label']=$this->pi_getLL('admin_delete_product'); $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_delete_product']['description']=$this->pi_getLL('admin_delete_product_description').'.'; $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_delete_product']['link']=mslib_fe::typolink(',2002','&tx_multishop_pi1[page_section]=admin_ajax&cid='.$product['categories_id'].'&pid='.$get['products_id'].'&action=delete_product'); $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_delete_product']['link_params']='onclick="return hs.htmlExpand(this, { objectType: \'iframe\', width: 890, height: 140} )"'; } $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_search_and_edit_products']['label']=$this->pi_getLL('admin_search_and_edit_products'); $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_search_and_edit_products']['description']=$this->pi_getLL('admin_here_you_can_search_and_update_products').'.'; $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_search_and_edit_products']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_price_update&cid='.$get['categories_id']); $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_product_attributes']['label']=$this->pi_getLL('admin_product_attributes'); $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_product_attributes']['description']=$this->pi_getLL('admin_maintain_product_attributes').'.'; $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_product_attributes']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_product_attributes'); $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_update_prices']['label']=$this->pi_getLL('admin_update_prices'); $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_update_prices']['description']=$this->pi_getLL('admin_update_product_prices_by_percentage').'.'; $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_update_prices']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_mass_product_updater'); $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_product_feeds']['label']=$this->pi_getLL('admin_product_feeds'); $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_product_feeds']['description']=$this->pi_getLL('admin_create_your_custom_product_feeds_by_using_this_wizard').'.'; $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_product_feeds']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_product_feeds'); $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_import_products']['label']=$this->pi_getLL('admin_import_products'); $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_import_products']['description']=$this->pi_getLL('admin_import_your_custom_productfeed_by_using_this_wizard').'.'; $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_products']['subs']['admin_import_products']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_import'); $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_manufacturers']['label']=$this->pi_getLL('admin_manufacturers'); $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_manufacturers']['description']=$this->pi_getLL('admin_add_and_modify_manufacturers_here').'.'; $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_manufacturers']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_manufacturers'); if ($ms['MODULES']['COUPONS']) { $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_coupon']['label']=$this->pi_getLL('admin_coupon_module'); $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_coupon']['description']=$this->pi_getLL('admin_give_customers_discount_by_coupon_code').'.'; $ms_menu['header']['ms_admin_catalog']['subs']['ms_admin_coupon']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_coupons'); } } // END IF CATALOGADMIN_USER if ($this->ROOTADMIN_USER or $this->CMSADMIN_USER) { $ms_menu['header']['ms_admin_cms']['label']=$this->pi_getLL('admin_cms'); $ms_menu['header']['ms_admin_cms']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_cms'); } if ($this->ROOTADMIN_USER or $this->CUSTOMERSADMIN_USER) { $ms_menu['header']['ms_admin_customers']['label']=$this->pi_getLL('admin_customers'); $ms_menu['header']['ms_admin_customers']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_customers'); $ms_menu['header']['ms_admin_customers']['subs']['admin_customers']['label']=$this->pi_getLL('admin_customers'); $ms_menu['header']['ms_admin_customers']['subs']['admin_customers']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_customers'); $ms_menu['header']['ms_admin_customers']['subs']['admin_customer_groups']['label']=$this->pi_getLL('admin_customer_groups'); $ms_menu['header']['ms_admin_customers']['subs']['admin_customer_groups']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_customer_groups'); $ms_menu['header']['ms_admin_customers']['subs']['admin_import_customers']['label']=$this->pi_getLL('admin_import_customers'); $ms_menu['header']['ms_admin_customers']['subs']['admin_import_customers']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_customer_import'); } if ($this->ROOTADMIN_USER or $this->ORDERSADMIN_USER) { $ms_menu['header']['ms_admin_orders']['label']=$this->pi_getLL('admin_orders'); $ms_menu['header']['ms_admin_orders']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_orders'); if ($ms['MODULES']['MANUAL_ORDER']) { $ms_menu['header']['ms_admin_orders']['subs']['admin_manual_orders']['label']=$this->pi_getLL('admin_new_order'); $ms_menu['header']['ms_admin_orders']['subs']['admin_manual_orders']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_new_order'); } $ms_menu['header']['ms_admin_orders']['subs']['admin_orders']['label']=$this->pi_getLL('admin_orders_overview'); $ms_menu['header']['ms_admin_orders']['subs']['admin_orders']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_orders'); if ($ms['MODULES']['ADMIN_ORDER_PROPOSAL_MODULE']) { $ms_menu['header']['ms_admin_orders']['subs']['admin_proposals']['label']=$this->pi_getLL('admin_proposals'); $ms_menu['header']['ms_admin_orders']['subs']['admin_proposals']['description']=$this->pi_getLL('admin_proposals_description').'.'; $ms_menu['header']['ms_admin_orders']['subs']['admin_proposals']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_new_order&tx_multishop_pi1[is_proposal]=1'); $ms_menu['header']['ms_admin_orders']['subs']['admin_proposals']['subs']['admin_proposals_new']['label']=$this->pi_getLL('admin_new_proposal'); $ms_menu['header']['ms_admin_orders']['subs']['admin_proposals']['subs']['admin_proposals_new']['description']=$this->pi_getLL('admin_new_proposal_description'); $ms_menu['header']['ms_admin_orders']['subs']['admin_proposals']['subs']['admin_proposals_new']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_new_order&tx_multishop_pi1[is_proposal]=1'); $ms_menu['header']['ms_admin_orders']['subs']['admin_proposals']['subs']['admin_proposals_overview']['label']=$this->pi_getLL('admin_proposals_overview'); $ms_menu['header']['ms_admin_orders']['subs']['admin_proposals']['subs']['admin_proposals_overview']['description']=$this->pi_getLL('admin_proposals_overview_description'); $ms_menu['header']['ms_admin_orders']['subs']['admin_proposals']['subs']['admin_proposals_overview']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_orders&tx_multishop_pi1[is_proposal]=1'); } if ($ms['MODULES']['ADMIN_INVOICE_MODULE']) { $ms_menu['header']['ms_admin_orders']['subs']['admin_invoices']['label']=$this->pi_getLL('admin_invoices_overview'); $ms_menu['header']['ms_admin_orders']['subs']['admin_invoices']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_invoices'); } if (is_array($order_status_array) and count($order_status_array)) { $tmp_content=''; $tmp_content.=''."\n"; $ms_menu['header']['ms_admin_orders']['subs']['admin_download_orders']['label']='DOWNLOAD ORDERS'; $ms_menu['header']['ms_admin_orders']['subs']['admin_download_orders']['description']='Download orders in Excel format.'; $ms_menu['header']['ms_admin_orders']['subs']['admin_download_orders']['subs']['GLS']['label']='SHIPPING FILE FOR GLS'; $ms_menu['header']['ms_admin_orders']['subs']['admin_download_orders']['subs']['GLS']['description']='Download orders for Label-Lite.'.$tmp_content; } $ms_menu['header']['ms_admin_orders']['subs']['admin_orders_stats']['label']=htmlspecialchars($this->pi_getLL('admin_sales_volume_statistics')); $ms_menu['header']['ms_admin_orders']['subs']['admin_orders_stats']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_orders_stats'); $ms_menu['header']['ms_admin_orders']['subs']['admin_vat_statistics']['label']=htmlspecialchars($this->pi_getLL('admin_vat_statistics')); $ms_menu['header']['ms_admin_orders']['subs']['admin_vat_statistics']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_orders_stats_tax'); } // END IF $this->ORDERSADMIN_USER if ($this->ROOTADMIN_USER or $this->SEARCHADMIN_USER) { $pageinfo = $GLOBALS['TSFE']->sys_page->getPage($this->shop_pid); $ms_menu['header']['ms_admin_search']['description']=' '; $ms_menu['header']['ms_admin_search']['description'].=' '."\n"; } if ($this->ROOTADMIN_USER or $this->STORESADMIN_USER) { // multishops // now grab the active shops $multishop_content_objects = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( 't.pid, p.title, p.uid as puid', 'tt_content t, pages p', 't.list_type = \'multishop_pi1\' and t.pi_flexform like \'%coreshop%\' and t.pi_flexform like \'% %\' and p.hidden=0 and t.hidden=0 and p.deleted=0 and t.deleted=0 and t.pid=p.uid', 'p.sorting' ); if (count($multishop_content_objects) > 1) { $ms_menu['header']['ms_admin_stores']['label']='STORES'; $counter=0; $total=count($multishop_content_objects); foreach ($multishop_content_objects as $pageinfo) { $counter++; if (is_numeric($pageinfo['puid']) and $pageinfo['puid'] != $this->shop_pid) { $ms_menu['header']['ms_admin_stores']['subs']['shop_'.$counter]['label']=strtoupper($pageinfo['title']); $ms_menu['header']['ms_admin_stores']['subs']['shop_'.$counter]['description']=$this->pi_getLL('switch_to').' '.$pageinfo['title'].' '.$this->pi_getLL('web_shop'); $ms_menu['header']['ms_admin_stores']['subs']['shop_'.$counter]['link']=mslib_fe::typolink($pageinfo["puid"],''); } } } // multishops eof } // footer $str="SELECT count(1) as total from fe_sessions"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $rowguests=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); $guests_online=$rowguests['total']; $members=mslib_fe::getSignedInUsers(); $total_members=count($members); $ms_menu['footer']['ms_admin_online_users']['label']=$this->pi_getLL('admin_online_users').': '.$total_members.'/'.$rowguests['total']; $ms_menu['footer']['ms_admin_online_users']['subs']['total_members']['label']=$this->pi_getLL('admin_members').': '.$total_members; if ($total_members) { foreach ($members as $member) { $ms_menu['footer']['ms_admin_online_users']['subs']['total_members']['subs']['admin_member_'.$member['uid']]['label']=$member['username']; $ms_menu['footer']['ms_admin_online_users']['subs']['total_members']['subs']['admin_member_'.$member['uid']]['description']='Logged in at '.strftime("%x %X", $member['lastlogin']); } } $ms_menu['footer']['ms_admin_online_users']['subs']['total_guests']['label']=$this->pi_getLL('admin_guests').': '.($rowguests['total']-$total_members); $ms_menu['footer']['ms_admin_online_users']['subs']['total_visitors']['label']=$this->pi_getLL('total').': '.$rowguests['total']; $ms_menu['footer']['ms_admin_logout']['label']=$this->pi_getLL('admin_log_out'); $ms_menu['footer']['ms_admin_logout']['link']=mslib_fe::typolink($this->conf['logout_pid'],'&logintype=logout'); $ms_menu['footer']['ms_admin_scroller']['label']=''; $ms_menu['footer']['ms_admin_help']['label']=$this->pi_getLL('admin_help'); $ms_menu['footer']['ms_admin_help']['link']=$this->conf['admin_help_url']; // if admin user and system panel is enabled for normal admins if ($this->ROOTADMIN_USER or ($this->SYSTEMADMIN_USER==1 or $this->conf['enableAdminPanelSystem'])) { $ms_menu['footer']['ms_admin_system']['label']=$this->pi_getLL('admin_system'); $ms_menu['footer']['ms_admin_system']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_modules'); if ($this->ROOTADMIN_USER or $this->conf['enableAdminPanelSettings']) { $ms_menu['footer']['ms_admin_system']['subs']['admin_settings']['label']=$this->pi_getLL('admin_multishop_settings'); $ms_menu['footer']['ms_admin_system']['subs']['admin_settings']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_modules'); } $ms_menu['footer']['ms_admin_system']['subs']['admin_orders_status']['label']=$this->pi_getLL('admin_orders_status'); $ms_menu['footer']['ms_admin_system']['subs']['admin_orders_status']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_orders_status'); $ms_menu['footer']['ms_admin_system']['subs']['admin_shipping_and_payment']['label']=$this->pi_getLL('admin_shipping_and_payment'); $ms_menu['footer']['ms_admin_system']['subs']['admin_shipping_and_payment']['description']=$this->pi_getLL('admin_shipping_and_payment').'.'; $ms_menu['footer']['ms_admin_system']['subs']['admin_shipping_and_payment']['subs']['admin_shipping_countries']['label']=$this->pi_getLL('admin_countries'); $ms_menu['footer']['ms_admin_system']['subs']['admin_shipping_and_payment']['subs']['admin_shipping_countries']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_shipping_countries'); $ms_menu['footer']['ms_admin_system']['subs']['admin_shipping_and_payment']['subs']['admin_shipping_methods']['label']=$this->pi_getLL('admin_shipping_methods'); $ms_menu['footer']['ms_admin_system']['subs']['admin_shipping_and_payment']['subs']['admin_shipping_methods']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_shipping_modules'); $ms_menu['footer']['ms_admin_system']['subs']['admin_shipping_and_payment']['subs']['admin_payment_methods']['label']=$this->pi_getLL('admin_payment_methods'); $ms_menu['footer']['ms_admin_system']['subs']['admin_shipping_and_payment']['subs']['admin_payment_methods']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_payment_modules'); $ms_menu['footer']['ms_admin_system']['subs']['admin_shipping_and_payment']['subs']['admin_mappings']['label']=$this->pi_getLL('admin_mappings'); $ms_menu['footer']['ms_admin_system']['subs']['admin_shipping_and_payment']['subs']['admin_mappings']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_shipping_payment_mappings'); $ms_menu['footer']['ms_admin_system']['subs']['admin_shipping_and_payment']['subs']['admin_shipping_costs']['label']=$this->pi_getLL('admin_shipping_costs'); $ms_menu['footer']['ms_admin_system']['subs']['admin_shipping_and_payment']['subs']['admin_shipping_costs']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_shipping_costs'); $ms_menu['footer']['ms_admin_system']['subs']['admin_shipping_and_payment']['subs']['admin_zones']['label']=$this->pi_getLL('admin_zones'); $ms_menu['footer']['ms_admin_system']['subs']['admin_shipping_and_payment']['subs']['admin_zones']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_shipping_zones'); $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['label']=$this->pi_getLL('admin_system'); $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['description']=$this->pi_getLL('admin_system').'.'; if ($ms['MODULES']['LOCAL_MODULES']['CACHE_FRONT_END']) { $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['subs']['admin_clear_multishop_cache']['label']=$this->pi_getLL('admin_clear_multishop_cache'); $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['subs']['admin_clear_multishop_cache']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_system_clear_multishop_cache'); $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['subs']['admin_clear_multishop_cache']['link_params']='onClick="return CONFIRM(\''.$this->pi_getLL('admin_are_you_sure_you_want_to_reset_the_multishop_cache').'?\')"'; } if (t3lib_extMgm::isLoaded('cooluri')) { $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['subs']['admin_clear_cooluri_cache']['label']=$this->pi_getLL('admin_clear_cooluri_cache'); $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['subs']['admin_clear_cooluri_cache']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_system_clear_cooluri_cache'); $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['subs']['admin_clear_cooluri_cache']['link_params']='onClick="return CONFIRM(\''.$this->pi_getLL('admin_are_you_sure_you_want_to_reset_the_cooluri_cache').'?\')"'; } if ($this->ROOTADMIN_USER or $this->conf['enableAdminPanelSortCatalog']) { $ms_menu['footer']['ms_admin_system']['subs']['admin_sort']['label']='Sort catalog'; $ms_menu['footer']['ms_admin_system']['subs']['admin_sort']['description']='Re-order your catalog by one mouse click.'; $ms_menu['footer']['ms_admin_system']['subs']['admin_sort']['subs']['admin_sort_on_alphabet']['label']=$this->pi_getLL('admin_sort_by_alphabet'); $ms_menu['footer']['ms_admin_system']['subs']['admin_sort']['subs']['admin_sort_on_alphabet']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_system_sort_catalog&tx_multishop_pi1[sort_by]=alphabet'); $ms_menu['footer']['ms_admin_system']['subs']['admin_sort']['subs']['admin_sort_on_alphabet']['link_params']='onClick="return CONFIRM(\''.$this->pi_getLL('admin_are_you_sure_you_want_to_sort_catalog').'?\')"'; $ms_menu['footer']['ms_admin_system']['subs']['admin_sort']['subs']['admin_sort_on_date_asc']['label']=$this->pi_getLL('admin_sort_by_date_ascending'); $ms_menu['footer']['ms_admin_system']['subs']['admin_sort']['subs']['admin_sort_on_date_asc']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_system_sort_catalog&tx_multishop_pi1[sort_by]=date&tx_multishop_pi1[sort_type]=asc'); $ms_menu['footer']['ms_admin_system']['subs']['admin_sort']['subs']['admin_sort_on_date_asc']['link_params']='onClick="return CONFIRM(\''.$this->pi_getLL('admin_are_you_sure_you_want_to_sort_catalog').'?\')"'; $ms_menu['footer']['ms_admin_system']['subs']['admin_sort']['subs']['admin_sort_on_date_desc']['label']=$this->pi_getLL('admin_sort_by_date_descending'); $ms_menu['footer']['ms_admin_system']['subs']['admin_sort']['subs']['admin_sort_on_date_desc']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_system_sort_catalog&tx_multishop_pi1[sort_by]=date&tx_multishop_pi1[sort_type]=desc'); $ms_menu['footer']['ms_admin_system']['subs']['admin_sort']['subs']['admin_sort_on_date_desc']['link_params']='onClick="return CONFIRM(\''.$this->pi_getLL('admin_are_you_sure_you_want_to_sort_catalog').'?\')"'; } if ($this->ROOTADMIN_USER) { $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['subs']['admin_compare_database']['label']=$this->pi_getLL('admin_compare_database'); $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['subs']['admin_compare_database']['link']='#'; $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['subs']['admin_compare_database']['link_params']='id="multishop_update_button"'; $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['subs']['admin_consistency_checker']['label']=$this->pi_getLL('admin_consistency_checker'); $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['subs']['admin_consistency_checker']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_system_consistency_checker'); $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['subs']['admin_consistency_checker']['link_params']='onClick="return CONFIRM(\'Are you sure you want to run the consistency checker?\')"'; $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['subs']['admin_delete_disabled_products']['label']=$this->pi_getLL('admin_delete_disabled_products'); $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['subs']['admin_delete_disabled_products']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_system_delete_disabled_products'); $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['subs']['admin_delete_disabled_products']['link_params']='onClick="return CONFIRM(\'Are you sure you want to delete the disabled products?\')"'; $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['subs']['admin_clear_whole_database']['label']=$this->pi_getLL('admin_clear_whole_database'); $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['subs']['admin_clear_whole_database']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_system_clear_database'); $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['subs']['admin_clear_whole_database']['link_params']='onClick="return CONFIRM(\'This will destroy the whole catalog and cannot be restored. Are you sure you want to start all over again?\');"'; $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['subs']['admin_scan_for_orphan_files']['label']=$this->pi_getLL('admin_scan_for_orphan_files'); $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['subs']['admin_scan_for_orphan_files']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_system_orphan_files'); $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['subs']['admin_scan_for_orphan_files']['link_params']=''; } if ($ms['MODULES']['FLAT_DATABASE'] and ($this->ROOTADMIN_USER or $this->conf['enableAdminPanelRebuildFlatDatabase'])) { $ms_menu['footer']['ms_admin_system']['subs']['admin_rebuild_flat_database']['label']=$this->pi_getLL('admin_rebuild_flat_database'); $ms_menu['footer']['ms_admin_system']['subs']['admin_rebuild_flat_database']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_system_rebuild_flat_database'); $ms_menu['footer']['ms_admin_system']['subs']['admin_rebuild_flat_database']['link_params']='onClick="return CONFIRM(\'Are you sure you want to rebuild the flat databases?\')"'; } if ($ms['MODULES']['STORES_MODULE']) { $ms_menu['footer']['ms_admin_system']['subs']['admin_stores']['label']=$this->pi_getLL('admin_stores'); $ms_menu['footer']['ms_admin_system']['subs']['admin_stores']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_stores'); } $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['subs']['admin_sitemap_generator']['label']=$this->pi_getLL('admin_sitemap_generator'); $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['subs']['admin_sitemap_generator']['link']=mslib_fe::typolink($this->shop_pid,'&tx_multishop_pi1[page_section]=admin_sitemap_generator'); $ms_menu['footer']['ms_admin_system']['subs']['admin_system']['subs']['admin_sitemap_generator']['link_params']='onClick="return CONFIRM(\'Are you sure you want to start this?\')"'; // footer eof } // end if enableAdminPanelSystem // hook if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['adminPanel'])) { $params = array ( 'status' => $status, 'table' => $table, 'id' => $id, 'this' => &$this, 'ms_menu' => &$ms_menu ); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['adminPanel'] as $funcRef) { t3lib_div::callUserFunction($funcRef, $params, $this); } } // hook oef if (!$this->ROOTADMIN_USER and !$this->CATALOGADMIN_USER) { // clear unset($ms_menu['header']['ms_admin_catalog']); } $admin_content='
      '; $admin_content.=mslib_fe::createAdminPanel($ms_menu['header'],'header'); $admin_content.='
    '; $this->linkVars = $GLOBALS['TSFE']->linkVars; $useSysLanguageTitle = trim($this->conf['useSysLanguageTitle']) ? trim($this->conf['useSysLanguageTitle']) : 0; $useIsoLanguageCountryCode = trim($this->conf['useIsoLanguageCountryCode']) ? trim($this->conf['useIsoLanguageCountryCode']) : 0; $useIsoLanguageCountryCode = $useSysLanguageTitle ? 0 : $useIsoLanguageCountryCode; $useSelfLanguageTitle = trim($this->conf['useSelfLanguageTitle']) ? trim($this->conf['useSelfLanguageTitle']) : 0; $useSelfLanguageTitle = ($useSysLanguageTitle || $useIsoLanguageCountryCode) ? 0 : $useSelfLanguageTitle; $tableA = 'sys_language'; $tableB = 'static_languages'; $languagesUidsList = trim($this->cObj->data['tx_srlanguagemenu_languages']) ? trim($this->cObj->data['tx_srlanguagemenu_languages']) : trim($this->conf['languagesUidsList']); $languages = array(); $languagesLabels = array(); // Set default language $defaultLanguageISOCode = trim($this->conf['defaultLanguageISOCode']) ? strtoupper(trim($this->conf['defaultLanguageISOCode'])) : 'EN'; $ms['MODULES']['COUNTRY_ISO_NR'] = trim($this->conf['defaultCountryISOCode']) ? strtoupper(trim($this->conf['defaultCountryISOCode'])) : ''; $languages[] = strtolower($defaultLanguageISOCode).($ms['MODULES']['COUNTRY_ISO_NR']?'_'.$ms['MODULES']['COUNTRY_ISO_NR']:''); $this->languagesUids[] = '0'; // Get the language codes and labels for the languages set in the plugin list $selectFields = $tableA . '.uid, ' . $tableA . '.title, '.$tableB . '.*'; $table = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.flag=' . $tableB . '.cn_iso_2'; // Ignore IN clause if language list is empty. This means that all languages found in the sys_language table will be used if (!empty($languagesUidsList)) { $whereClause = $tableA . '.uid IN (' . $languagesUidsList . ') '; } else { $whereClause = '1=1 '; } $whereClause .= $this->cObj->enableFields ($tableA); $whereClause .= $this->cObj->enableFields ($tableB); // $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($selectFields, $table, $whereClause); // If $languagesUidsList is not empty, the languages will be sorted in the order it specifies $languagesUidsArray = t3lib_div::trimExplode(',', $languagesUidsList, 1); $index = 0; $str="select * from sys_language where hidden=0 order by title"; $res=$GLOBALS['TYPO3_DB']->sql_query($str); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $key++; $languages[$key] = $row['uid']; $languagesLabels[$key]['key'] = $row['uid']; $languagesLabels[$key]['flag'] = $row['flag']; if ($row['flag']) { if ($this->cookie['multishop_admin_language']==$row['uid']) { $this->cookie['multishop_admin_language']=$row['flag']; } } $languagesLabels[$key]['value'] = $row['title']; $this->languagesUids[$key] = $row['uid']; } $ms_menu['footer']['ms_admin_language']['description']='
    '; $admin_content.=' '; /*
  • '.$this->pi_getLL('admin_update_images').'
  • */ // admin stats if ($ms['MODULES']['LOCAL_MODULES']['CACHE_FRONT_END']) { $options = array( 'caching' => true, 'cacheDir' => $this->DOCUMENT_ROOT.'uploads/tx_multishop/tmp/cache/', 'lifeTime' => 180 ); $Cache_Lite = new Cache_Lite($options); $string=md5('admin_stats_'.$this->shop_pid); } if (!$ms['MODULES']['LOCAL_MODULES']['CACHE_FRONT_END'] or ($ms['MODULES']['LOCAL_MODULES']['CACHE_FRONT_END'] and !$html=$Cache_Lite->get($string))) { $html= ' '; if ($ms['MODULES']['LOCAL_MODULES']['CACHE_FRONT_END']) $Cache_Lite->save($html); } // admin stats eof $html.=' '; return $html; } function getOrderTotalPrice ($orders_id,$skip_method_costs=0) { global $ms; if (!is_numeric($orders_id)) return false; $str="SELECT * from tx_multishop_orders o where o.orders_id='".$orders_id."'"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $orders=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); if ($orders['orders_id']) { $total_amount=0; $str2="SELECT * from tx_multishop_orders_products where orders_id='".$orders['orders_id']."'"; $qry2=$GLOBALS['TYPO3_DB']->sql_query($str2); while ($row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry2)) { $product_amount=0; $product_amount=($row['qty']*$row['final_price']); // now count the attributes $str3="SELECT * from tx_multishop_orders_products_attributes where orders_products_id='".$row['orders_products_id']."'"; $qry3=$GLOBALS['TYPO3_DB']->sql_query($str3); while ($row3=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry3)) { if ($row3['price_prefix']=='+') $product_amount=$product_amount+($row['qty']*$row3['options_values_price']); else $product_amount=$product_amount-($row['qty']*$row3['options_values_price']); $row['attributes'][]=$row3; } // now count the attributes eof if ($product_amount and $row['products_tax']) { $item_tax=(($product_amount)*(($row['products_tax']/100))); $product_amount=$product_amount+$item_tax; } $total_amount=$total_amount+$product_amount; } if (!$skip_method_costs) { $orders['shipping_method_costs']=round($orders['shipping_method_costs'],2); $orders['payment_method_costs']=round($orders['payment_method_costs'],2); $extra_costs=$orders['shipping_method_costs']+$orders['payment_method_costs']; if ($ms['MODULES']['INCLUDE_VAT_OVER_METHOD_COSTS']) { if ($orders['shipping_method_costs']) $extra_costs=$extra_costs+($orders['shipping_method_costs']/100*$ms['MODULES']['INCLUDE_VAT_OVER_METHOD_COSTS']); if ($orders['payment_method_costs']) $extra_costs=$extra_costs+($orders['payment_method_costs']/100*$ms['MODULES']['INCLUDE_VAT_OVER_METHOD_COSTS']); } } else $extra_costs=0; $orders['total_amount']=round($total_amount+$extra_costs-$orders['discount'],2); return $orders['total_amount']; } } function getOrder($orders_id) { global $ms; if (!is_numeric($orders_id)) return false; $str="SELECT *, os.name as orders_status from tx_multishop_orders o left join tx_multishop_orders_status os on o.status=os.id where o.orders_id='".$orders_id."'"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $orders=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); $full_customer_name=$orders['billing_first_name']; ###RAM if ($orders['billing_middle_name']) $full_customer_name.=' '.$orders['billing_middle_name']; if ($orders['billing_last_name']) $full_customer_name.=' '.$orders['billing_last_name']; $orders['billing_full_name']=$full_customer_name; // load products $total_amount=0; $orders_products=array(); $str2="SELECT * from tx_multishop_orders_products where orders_id='".$orders['orders_id']."' order by orders_products_id"; $qry2=$GLOBALS['TYPO3_DB']->sql_query($str2); while ($row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry2)) { $product_amount=0; $product_amount=($row['qty']*$row['final_price']); // now count the attributes $str3="SELECT * from tx_multishop_orders_products_attributes where orders_products_id='".$row['orders_products_id']."'"; $qry3=$GLOBALS['TYPO3_DB']->sql_query($str3); while ($row3=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry3)) { if ($row3['price_prefix']=='+') $product_amount=$product_amount+($row['qty']*$row3['options_values_price']); else $product_amount=$product_amount-($row['qty']*$row3['options_values_price']); $row['attributes'][]=$row3; } // now count the attributes eof $total_amount=$total_amount+$product_amount; $row['total_price']=round($product_amount,2); $orders_products[]=$row; } // load products eof $total_tax=0; foreach ($orders_products as $key => $orders_product) { $tmpcontent=''; if ($orders_products_attributes[$orders_product['orders_products_id']]) { foreach ($orders_products_attributes[$orders_product['orders_products_id']] as $tmpkey => $options) { $tmpcontent.=' '.$options['products_options'].': '.$options['products_options_values'].'  '.mslib_fe::Money2Cents($options['price_prefix'].$options['options_values_price']).''; } } $tmpcontent.=''; // count the vat if ($orders_product['total_price'] and $orders_product['products_tax']) { $item_tax=(($orders_product['total_price'])*(($orders_product['products_tax']/100))); $total_tax=$total_tax+$item_tax; } } $orders['products']=$orders_products; $orders['subtotal_tax']=round($total_tax,2); $orders['subtotal_amount']=round($total_amount,2); $orders['shipping_method_costs']=round($orders['shipping_method_costs'],2); $orders['payment_method_costs']=round($orders['payment_method_costs'],2); if ($ms['MODULES']['INCLUDE_VAT_OVER_METHOD_COSTS']) { $extra_vat=0; if ($orders['shipping_method_costs']) $extra_vat=$extra_vat+($orders['shipping_method_costs']/100*$ms['MODULES']['INCLUDE_VAT_OVER_METHOD_COSTS']); if ($orders['payment_method_costs']) $extra_vat=$extra_vat+($orders['payment_method_costs']/100*$ms['MODULES']['INCLUDE_VAT_OVER_METHOD_COSTS']); $orders['subtotal_tax']=($orders['subtotal_tax']+$extra_vat); } $orders['total_amount']=round($orders['subtotal_amount']+$orders['subtotal_tax']+$orders['payment_method_costs']+$orders['shipping_method_costs']-$orders['discount'],2); return $orders; } function getInvoice ($value,$key='hash') { $query = $GLOBALS['TYPO3_DB']->SELECTquery('*','tx_multishop_invoices',$key.'=\''.addslashes($value).'\'','','id',''); $res = $GLOBALS['TYPO3_DB']->sql_query($query); if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) { $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); return $row; } } function getProductsOptionName($option_id) { if (is_numeric($option_id)) { //language_id=\''.$GLOBALS['TSFE']->sys_language_uid.'\' $query = $GLOBALS['TYPO3_DB']->SELECTquery( 'products_options_name', // SELECT ... 'tx_multishop_products_options', // FROM ... 'products_options_id=\''.$option_id.'\'', // WHERE... '', // GROUP BY... '', // ORDER BY... '' // LIMIT ... ); $res = $GLOBALS['TYPO3_DB']->sql_query($query); if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) { $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); return $row['products_options_name']; } } } function getProductsOptionValues ($option_id, $products_id='') { if (is_numeric($option_id)) { //language_id=\''.$GLOBALS['TSFE']->sys_language_uid.'\' $str="select pa.options_values_id, pov.products_options_values_name from tx_multishop_products_attributes pa, tx_multishop_products_options_values pov where "; if (is_numeric($products_id)) $str.="pa.products_id='".$products_id."' and "; $str.="pa.options_id='".$option_id."' and pa.options_values_id=pov.products_options_values_id"; $res = $GLOBALS['TYPO3_DB']->sql_query($str); if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) { $array=array(); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $array[]=$row; } return $array; } } } function getCategoryName($categories_id) { if (is_numeric($categories_id)) { //language_id=\''.$GLOBALS['TSFE']->sys_language_uid.'\' $query = $GLOBALS['TYPO3_DB']->SELECTquery( 'categories_name', // SELECT ... 'tx_multishop_categories_description', // FROM ... 'categories_id=\''.$categories_id.'\'', // WHERE... '', // GROUP BY... '', // ORDER BY... '' // LIMIT ... ); $res = $GLOBALS['TYPO3_DB']->sql_query($query); if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) { $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); return $row['categories_name']; } } } function tep_get_categories_edit($categories_id='', $aid='') { global $ms; if ($categories_id) $parent_categories_query = $GLOBALS['TYPO3_DB']->sql_query("SELECT cd.categories_name as name, cd.categories_id as id, c.parent_id as parent from tx_multishop_categories c, tx_multishop_categories_description cd where c.parent_id='" . $categories_id . "' and c.page_uid='".$this->showCatalogFromPage."' and cd.language_id='".$GLOBALS['TSFE']->sys_language_uid."' and c.status=1 and c.categories_id=cd.categories_id order by c.sort_order, cd.categories_name"); else $parent_categories_query = $GLOBALS['TYPO3_DB']->sql_query("SELECT cd.categories_name as name, cd.categories_id as id, c.parent_id as parent from tx_multishop_categories c, tx_multishop_categories_description cd where c.parent_id='0' and c.status=1 and c.page_uid='".$this->showCatalogFromPage."' and cd.language_id='".$GLOBALS['TSFE']->sys_language_uid."' and c.categories_id=cd.categories_id order by c.sort_order, cd.categories_name"); $rows=$GLOBALS['TYPO3_DB']->sql_num_rows($parent_categories_query); if ($rows) $html .='
      '; while ($parent_categories = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($parent_categories_query)) { $html.='
    • '; $strchk="select * from tx_multishop_categories where parent_id='".$parent_categories['id']."'"; $qrychk=$GLOBALS['TYPO3_DB']->sql_query($strchk); if (!$GLOBALS['TYPO3_DB']->sql_num_rows($qrychk)) $html.=' '; if (!$GLOBALS['TYPO3_DB']->sql_num_rows($qrychk)) $html.=' '; $html.='
      '.$parent_categories['name'].''; // $html.=''; if ($GLOBALS['TYPO3_DB']->sql_num_rows($qrychk)) $html .=mslib_fe::tep_get_categories_edit($parent_categories['id'],$aid); else { // productloaded $html .='
      '; /* $html .='
      '.$ms['upload_productfeed_form'].'
      '; */ //productloader } $html.='
    • '; } if ($rows) $html .='
    '; return $html; } function updateCustomSettings($customsettings) { global $ms; // this is for overwriting the Multishop module settings with the inserted values in the advanced tab of the Multishop content element settings. if (strstr($customsettings,"\r\n")) { $data=explode("\r\n",$customsettings); } elseif (strstr($customsettings,"\n")) { $data=explode("\n",$customsettings); } else { $data=array($customsettings); } if (count($data)) { foreach ($data as $item) { $var=explode("=",$item); switch($var[0]) { default: // lets overwrite the parameters (content element custom parameters always overrules $ms['MODULES'][$var[0]]=$var[1]; break; } } } } function loadInherentCustomSettingsByProduct($products_id) { $product=mslib_fe::getProduct($products_id,'','p.custom_settings',1); $cats=mslib_fe::Crumbar($product['categories_id']); $cats=array_reverse($cats); $settings=array(); foreach ($cats as $cat) { $settings[]=$cat['custom_settings']; } if ($product['custom_settings']) $settings[]=$product['custom_settings']; if (count($settings)) { return mslib_fe::processInherentCustomSettings($settings); } } function loadInherentCustomSettingsByCategory($categories_id) { $cats=mslib_fe::Crumbar($categories_id); $cats=array_reverse($cats); $settings=array(); foreach ($cats as $cat) { $settings[]=$cat['custom_settings']; } if (count($settings)) { return mslib_fe::processInherentCustomSettings($settings); } } function processInherentCustomSettings($settings) { if (count($settings)) { $modules=array(); foreach ($settings as $customsettings) { if (strstr($customsettings,"\r\n")) { $data=explode("\r\n",$customsettings); } elseif (strstr($customsettings,"\n")) { $data=explode("\n",$customsettings); } else { $data=array($customsettings); } if (count($data)) { foreach ($data as $item) { $var=explode("=",$item); switch($var[0]) { default: // lets overwrite the parameters (content element custom parameters always overrules $modules[$var[0]]=$var[1]; break; } } } } return $modules; } } function updateFeUserGroup($uid, $add_usergroup, $remove_usergroup='') { if (is_numeric($uid)) { $user=mslib_fe::getUser($uid); if ($user['uid']) { $string=$user['usergroup']; $groups=explode(",",$string); $new_groups=array(); foreach ($groups as $group) { $group=trim($group); if ($group) { if (is_array($remove_usergroup) or $remove_usergroup) { if (is_array($remove_usergroup)) { if (!in_array($group,$remove_usergroup)) { $new_groups[]=$group; } } elseif ($group != $remove_usergroup) $new_groups[]=$group; } else { $new_groups[]=$group; } } } if (is_array($add_usergroup)) { foreach ($add_usergroup as $item) { if ($item) $new_groups[] = $item; } } elseif($add_usergroup) $new_groups[] = $add_usergroup; $new_groups = array_unique($new_groups); $new_string = implode(",",$new_groups); $updateArray = array('usergroup' => $new_string); $query = $GLOBALS['TYPO3_DB']->UPDATEquery('fe_users', 'uid='.$uid,$updateArray); $res = $GLOBALS['TYPO3_DB']->sql_query($query); return $new_string; } } } /* #RAM ORIGINALE function generateInvoiceId() { global $ms; $sql = "select invoice_id from tx_multishop_invoices where page_uid='".$this->shop_pid."' order by id desc limit 1"; $query = $GLOBALS['TYPO3_DB']->sql_query($sql); $rs_inv = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($query); $prefix = $ms['MODULES']['INVOICE_PREFIX'] . date("Y"); if (preg_match("/^".$prefix."/",$rs_inv['invoice_id'])) $invoice_id = ((int) $rs_inv['invoice_id'] + 1); else { $invoice_id = $ms['MODULES']['INVOICE_PREFIX'] . date("Y").'00001'; } return $invoice_id; } */ function generateInvoiceId() { global $ms; $sql = "select invoice_id from tx_multishop_invoices where page_uid='".$this->shop_pid."' order by id desc limit 1"; $query = $GLOBALS['TYPO3_DB']->sql_query($sql); $rs_inv = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($query); $prefix = $ms['MODULES']['INVOICE_PREFIX'] . date("Y")."-"; $pattern = "/^".$prefix."/i"; if (preg_match($pattern,$rs_inv['invoice_id'])){ $numeroInvoice = substr($rs_inv['invoice_id'],(strpos($rs_inv['invoice_id'],'-', (strlen($rs_inv['invoice_id'])-strpos($rs_inv['invoice_id'],'-')))+1)); $invoice_id = $prefix . ((int)$numeroInvoice + 1); } else { $invoice_id = $ms['MODULES']['INVOICE_PREFIX'] . date("Y").'-1'; } return $invoice_id; } function createOrderInvoice($orders_id,$force=0) { global $ms; if (is_numeric($orders_id)) { $order=mslib_fe::getOrder($orders_id); if (($order['orders_id'] and $order['bill']) or ($order['orders_id'] and $force)) { $invoice_id=mslib_fe::generateInvoiceId(); if ($invoice_id) { $hash=md5(uniqid('',TRUE)); $insertArray=array(); $insertArray['invoice_id'] =$invoice_id; $insertArray['customer_id'] =$order['customer_id']; $insertArray['payed'] =$order['payed']; $insertArray['orders_id'] =$orders_id; $insertArray['crdate'] =time(); $insertArray['status'] =1; $insertArray['page_uid'] =$this->shop_pid; $insertArray['hash'] =$hash; $insertArray['amount'] =mslib_fe::getOrderTotalPrice($orders_id); $insertArray['discount'] =$order['discount']; if ($order['billing_company']) $name=$order['billing_company']; else $name=$order['billing_name']; $insertArray['ordered_by'] =$name; $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_invoices', $insertArray); $res = $GLOBALS['TYPO3_DB']->sql_query($query); if ($res) { // update order to billed and lock the order so nobody can adjust it $updateArray = array('bill' => 0,'is_locked' => 1); $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_orders','orders_id='.$order['orders_id'],$updateArray); $res = $GLOBALS['TYPO3_DB']->sql_query($query); $array=array(); $array['hash']=$hash; $array['invoice_id']=$invoice_id; return $array; } } } } } function getOrderInvoice ($orders_id) { global $ms; $sql = "select invoice_id,hash from tx_multishop_invoices where orders_id = ".$orders_id; $qry = $GLOBALS['TYPO3_DB']->sql_query($sql); if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry) == 0) { $data=mslib_fe::createOrderInvoice($orders_id); } else { $data = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); } if($data['invoice_id']) { $invoice=array(); $invoice['invoice_id'] =$data['invoice_id']; $invoice['hash'] =$data['hash']; return $invoice; } } function generateReversalInvoice($id) { if (is_numeric($id)) { // check if this invoice hasnt be reversed already $sql = "select count(1) as total from tx_multishop_invoices where reversal_related_id='".$id."'"; $query = $GLOBALS['TYPO3_DB']->sql_query($sql); $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($query); if ($row['total']==0) { $sql = "select * from tx_multishop_invoices where id='".$id."'"; $query = $GLOBALS['TYPO3_DB']->sql_query($sql); $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($query); if (!$invoice['reversal_invoice']) { $new_invoice_id=mslib_fe::generateInvoiceId(); if ($new_invoice_id) { unset($row['id']); $row['reversal_related_id']=$id; $row['reversal_invoice']=1; $row['crdate']=time(); $row['payed']=1; $row['invoice_id']=$new_invoice_id; $row['hash']=md5(uniqid('',TRUE)); $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_invoices', $row); $res = $GLOBALS['TYPO3_DB']->sql_query($query); // update old invoice to paid so its gone from the unpaid list $updateArray = array('payed' => 1); $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_invoices','id='.$id,$updateArray); $res = $GLOBALS['TYPO3_DB']->sql_query($query); } } } } } function updateOrderStatusToPayed($orders_id) { global $ms, $server; $order=mslib_fe::getOrder($orders_id); if (!$order['payed']) { $updateArray = array('payed' => 1); $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_orders','orders_id='.$orders_id,$updateArray); $res = $GLOBALS['TYPO3_DB']->sql_query($query); if ($ms['MODULES']['INVOICE_PRINT']) { // create invoice $invoice=mslib_fe::getOrderInvoice($orders_id); } //TODO global ORDERS_PAYED_CUSTOM_SCRIPT is not yet implemented. Also check the multishop settings for custom payed script foreach ($order['products'] as $product) { $module_settings=mslib_fe::loadInherentCustomSettingsByProduct($product['products_id']); if ($module_settings['ORDERS_PAYED_CUSTOM_SCRIPT']) { if (!strstr($module_settings['ORDERS_PAYED_CUSTOM_SCRIPT'],"..")) { if (strstr($module_settings['ORDERS_PAYED_CUSTOM_SCRIPT'],"/")) require(PATH_site.$module_settings['ORDERS_PAYED_CUSTOM_SCRIPT'].'.php'); } } } $billing_address=''; $delivery_address=''; $full_customer_name=$order['billing_first_name']; ###RAM if ($order['billing_middle_name']) $full_customer_name.=' '.$order['billing_middle_name']; if ($order['billing_last_name']) $full_customer_name.=' '.$order['billing_last_name']; $delivery_full_customer_name=$order['delivery_first_name']; ###RAM if ($order['delivery_middle_name']) $delivery_full_customer_name.=' '.$order['delivery_middle_name']; if ($order['delivery_last_name']) $delivery_full_customer_name.=' '.$order['delivery_last_name']; if (!$order['delivery_address'] or !$order['delivery_city']) { $order['delivery_company'] = $order['billing_company']; $order['delivery_address'] = $order['billing_address'].' '.$order['billing_address_number']; $order['delivery_zip'] = $order['billing_zip']; $order['delivery_city'] = $order['billing_city']; $order['delivery_telephone'] = $order['billing_telephone']; $order['delivery_mobile'] = $order['billing_mobile']; } if ($order['delivery_company']) $delivery_address=$order['delivery_company']."
    "; if ($delivery_full_customer_name) $delivery_address.=$delivery_full_customer_name."
    "; if ($order['delivery_address']) $delivery_address.=$order['delivery_address'].' '.$order['delivery_address_number']."
    "; if ($order['delivery_zip'] and $order['delivery_city']) $delivery_address.=$order['delivery_zip']." ".$order['delivery_city']."

    "; if ($order['delivery_telephone']) $delivery_address.=ucfirst($this->pi_getLL('telephone')).': '.$order['delivery_telephone']."
    "; if ($order['delivery_mobile']) $delivery_address.=ucfirst($this->pi_getLL('mobile')).': '.$order['delivery_mobile']."
    "; if ($order['billing_company']) $billing_address=$order['billing_company']."
    "; if ($full_customer_name) $billing_address.=$full_customer_name."
    "; if ($order['billing_address']) $billing_address.=$order['billing_address'].' '.$order['billing_address_number']."
    "; if ($order['billing_zip'] and $order['billing_city']) $billing_address.=$order['billing_zip']." ".$order['billing_city']; $page=array(); // first try to load the custom thank you page based on the payment method if ($order['payment_method']) { $page=mslib_fe::getCMScontent('email_order_payed_letter_'.$order['payment_method'],$GLOBALS['TSFE']->sys_language_uid); } if (!count($page[0])) { $page=mslib_fe::getCMScontent('email_order_payed_letter',$GLOBALS['TSFE']->sys_language_uid); } if ($page[0]['content']) { // loading the email confirmation letter eof // replacing the variables with dynamic values $array1=array(); $array2=array(); $array1[]='###FULL_NAME###'; $array2[]=$full_customer_name; $array1[]='###CUSTOMER_EMAIL###'; $array2[]=$order['billing_email']; $array1[]='###LONG_DATE###'; // ie woensdag 23 juni, 2010 $long_date=strftime($this->pi_getLL('full_date_format')); $array2[]=$long_date; $array1[]='###STORE_NAME###'; $array2[]=$ms['MODULES']['STORE_NAME']; $array1[]='###TOTAL_AMOUNT###'; $array2[]=mslib_fe::Money2Cents($order['total_amount']); $array1[]='###ORDER_NUMBER###'; $array2[]=$orders_id; $array1[]='###ORDER_LINK###'; $array2[]=''; $array1[]='###BILLING_ADDRESS###'; $array2[]=$billing_address; $array1[]='###DELIVERY_ADDRESS###'; $array2[]=$delivery_address; $array1[]='###CUSTOMER_ID###'; $array2[]=$order['customer_id']; $array1[]='###SHIPPING_METHOD###'; $array2[]=$order['shipping_method_label']; $array1[]='###PAYMENT_METHOD###'; $array2[]=$order['payment_method_label']; $array1[]='###INVOICE_LINK###'; $array2[]=''.$invoice['invoice_id'].''; $ORDER_DETAILS=''; $ORDER_DETAILS.=''; $subtotal=0; $subtotal_tax=0; foreach ($order['products'] as $product) { if (!$tr_type or $tr_type=='even') $tr_type='odd'; else $tr_type='even'; $subprices=''; $price=$product['qty']*$product['final_price']; $ORDER_DETAILS.=''; // $subtotal=($subtotal+$price); if ($product['products_tax']) $tax=round(($price/100*($product['products_tax'])),4); else $tax=0; $subtotal_tax=($subtotal_tax+$tax); } /*RAM salvo originali: cambio calcolo IVA su costi di spedizione e pagamento $ORDER_DETAILS.='
    '.$this->pi_getLL('qty').''.$this->pi_getLL('product').''.$this->pi_getLL('total').'
    '.round($product['qty']).'x '.$product['products_name']; if ($product['products_model']) $ORDER_DETAILS.=' ('.$product['products_model'].') '; // if ($product['products_description']) $ORDER_DETAILS.='
    '.$product['products_description']; if (count($product['attributes'])) { foreach ($product['attributes'] as $tmpkey => $options) { $subprices.='
    '; $ORDER_DETAILS.='
    '.$options['products_options'].': '.$options['products_options_values']; $price=$price+($product['qty']*($options['price_prefix'].$options['options_values_price'])); if ($price < 0) $price=0; $subprices.=mslib_fe::Money2Cents(($product['qty']*($options['price_prefix'].$options['options_values_price']))); } } if ($product['file_download_code'] and $product['file_location'] and file_exists($product['file_location'])) { // micro download link $ORDER_DETAILS.='
    Download micro download: '.htmlspecialchars($product['file_label']).'
    '; } $ORDER_DETAILS.='
    '.mslib_fe::Money2Cents($price).'
    '.$product['products_description'].'
    '; $ORDER_DETAILS.=ucfirst($this->pi_getLL('subtotal')).': '.mslib_fe::Money2Cents($subtotal).'
    '; $ORDER_DETAILS.=strtoupper($this->pi_getLL('vat')).': '.mslib_fe::Money2Cents($subtotal_tax).'
    '; if ($order['shipping_method_costs']) $ORDER_DETAILS.=$this->pi_getLL('shipping_costs').' ('.$order['shipping_method'].'): '.mslib_fe::Money2Cents($order['shipping_method_costs']).'
    '; if ($order['payment_method_costs']) $ORDER_DETAILS.=$this->pi_getLL('payment_costs').' ('.$order['payment_method'].'): '.mslib_fe::Money2Cents($order['payment_method_costs']).'
    '; $ORDER_DETAILS.=''.ucfirst($this->pi_getLL('total')).': '.mslib_fe::Money2Cents($subtotal+$subtotal_tax+$order['payment_method_costs']+$order['shipping_method_costs']).''; $ORDER_DETAILS.='
    '; */ $ORDER_DETAILS.=''; $ORDER_DETAILS.=ucfirst($this->pi_getLL('subtotal')).': '.mslib_fe::Money2Cents($subtotal).'
    '; if ($order['shipping_method_costs']) $ORDER_DETAILS.=$this->pi_getLL('shipping_costs').' ('.$order['shipping_method'].'): '.mslib_fe::Money2Cents($order['shipping_method_costs']).'
    '; if ($order['payment_method_costs']) $ORDER_DETAILS.=$this->pi_getLL('payment_costs').' ('.$order['payment_method'].'): '.mslib_fe::Money2Cents($order['payment_method_costs']).'
    '; #aggiungo alle tasse anche quelle su spese sped e pagamento $shippay_tax = round(($order['shipping_method_costs']/100*21) + ($order['payment_method_costs']/100*21),2); $subtotal_tax = $subtotal_tax + $shippay_tax; $ORDER_DETAILS.=strtoupper($this->pi_getLL('vat')).': '.mslib_fe::Money2Cents($subtotal_tax).'
    '; $ORDER_DETAILS.=''.ucfirst($this->pi_getLL('total')).': '.mslib_fe::Money2Cents($subtotal+$subtotal_tax+$order['payment_method_costs']+$order['shipping_method_costs']).''; $ORDER_DETAILS.=''; #RAM end // for on the site $ORDER_DETAILS_SITE=mslib_fe::printOrderDetailsTable($order); // for on the site eof $array1[]='###ORDER_DETAILS###'; $array2[]=$ORDER_DETAILS; if($page[0]['content']) $page[0]['content']=str_replace($array1,$array2,$page[0]['content']); if($page[0]['name']) $page[0]['name']=str_replace($array1,$array2,$page[0]['name']); // replacing the variables with dynamic values eof $user=array(); $user['name'] = $full_customer_name; $user['email'] = $order['billing_email']; mslib_fe::mailUser($user,$page[0]['name'],$page[0]['content'],$ms['MODULES']['STORE_EMAIL'],$ms['MODULES']['STORE_NAME']); // now mail a copy to the merchant $merchant=array(); $merchant['name'] =$ms['MODULES']['STORE_NAME']; $merchant['email'] =$ms['MODULES']['STORE_EMAIL']; mslib_fe::mailUser($merchant,$page[0]['name'],$page[0]['content'],$user['email'],$user['name']); } // if cms content exists return true; } else return false; } function mailOrder($orders_id,$copy_to_merchant=1,$custom_email_address='',$mail_template='') { global $ms; $order=mslib_fe::getOrder($orders_id); if (!$custom_email_address) $custom_email_address=$order['billing_email']; $billing_address=''; $delivery_address=''; $full_customer_name=$order['billing_first_name']; ###RAM if ($order['billing_middle_name']) $full_customer_name.=' '.$order['billing_middle_name']; if ($order['billing_last_name']) $full_customer_name.=' '.$order['billing_last_name']; $delivery_full_customer_name=$order['delivery_first_name']; ###RAM if ($order['delivery_middle_name']) $delivery_full_customer_name.=' '.$order['delivery_middle_name']; if ($order['delivery_last_name']) $delivery_full_customer_name.=' '.$order['delivery_last_name']; if (!$order['delivery_address'] or !$order['delivery_city']) { $order['delivery_company'] = $order['billing_company']; $order['delivery_address'] = $order['billing_address'].' '.$order['billing_address_number']; $order['delivery_zip'] = $order['billing_zip']; $order['delivery_city'] = $order['billing_city']; $order['delivery_telephone'] = $order['billing_telephone']; $order['delivery_mobile'] = $order['billing_mobile']; } if ($order['delivery_company']) $delivery_address=$order['delivery_company']."
    "; if ($delivery_full_customer_name) $delivery_address.=$delivery_full_customer_name."
    "; if ($order['delivery_address']) $delivery_address.=$order['delivery_address'].' '.$order['delivery_address_number']."
    "; if ($order['delivery_zip'] and $order['delivery_city']) $delivery_address.=$order['delivery_zip']." ".$order['delivery_city']."

    "; if ($order['delivery_telephone']) $delivery_address.=ucfirst($this->pi_getLL('telephone')).': '.$order['delivery_telephone']."
    "; if ($order['delivery_mobile']) $delivery_address.=ucfirst($this->pi_getLL('mobile')).': '.$order['delivery_mobile']."
    "; if ($order['billing_company']) $billing_address=$order['billing_company']."
    "; if ($full_customer_name) $billing_address.=$full_customer_name."
    "; if ($order['billing_address']) $billing_address.=$order['billing_address'].' '.$order['billing_address_number']."
    "; if ($order['billing_zip'] and $order['billing_city']) $billing_address.=$order['billing_zip']." ".$order['billing_city']; // loading the email template $page=array(); if ($mail_template) { $page=mslib_fe::getCMScontent($mail_template,$GLOBALS['TSFE']->sys_language_uid); } elseif ($order['is_proposal']) { // proposal template $mail_template='email_order_proposal'; $page=mslib_fe::getCMScontent($mail_template,$GLOBALS['TSFE']->sys_language_uid); } else { // normal order template if ($order['payment_method']) { $page=mslib_fe::getCMScontent('email_order_confirmation_'.$order['payment_method'],$GLOBALS['TSFE']->sys_language_uid); } if (!count($page[0])) { $page=mslib_fe::getCMScontent('email_order_confirmation',$GLOBALS['TSFE']->sys_language_uid); } } if ($page[0]['content']) { // loading the email confirmation letter eof // replacing the variables with dynamic values $array1=array(); $array2=array(); $array1[]='###FULL_NAME###'; $array2[]=$full_customer_name; $array1[]='###CUSTOMER_EMAIL###'; $array2[]=$order['email']; $array1[]='###LONG_DATE###'; // ie woensdag 23 juni, 2010 $long_date=strftime($this->pi_getLL('full_date_format')); $array2[]=$long_date; $array1[]='###STORE_NAME###'; $array2[]=$ms['MODULES']['STORE_NAME']; $array1[]='###TOTAL_AMOUNT###'; $array2[]=mslib_fe::Money2Cents($order['total_amount']); $array1[]='###PROPOSAL_NUMBER###'; $array2[]=$order['orders_id']; $array1[]='###ORDER_NUMBER###'; $array2[]=$order['orders_id']; $array1[]='###ORDER_LINK###'; $array2[]=''; $array1[]='###BILLING_ADDRESS###'; $array2[]=$billing_address; $array1[]='###DELIVERY_ADDRESS###'; $array2[]=$delivery_address; $array1[]='###CUSTOMER_ID###'; $array2[]=$order['customer_id']; $ORDER_DETAILS=mslib_fe::printOrderDetailsTable($order,'email'); $array1[]='###ORDER_DETAILS###'; $array2[]=$ORDER_DETAILS; $array1[]='###SHIPPING_METHOD###'; $array2[]=$order['shipping_method_label']; $array1[]='###PAYMENT_METHOD###'; $array2[]=$order['payment_method_label']; if($page[0]['content']) $page[0]['content']=str_replace($array1,$array2,$page[0]['content']); if($page[0]['name']) $page[0]['name']=str_replace($array1,$array2,$page[0]['name']); // replacing the variables with dynamic values eof $user=array(); $user['name'] = $full_customer_name; $user['email'] = $custom_email_address; //hook $send_mail=1; if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['mailOrder'])) { $params = array ( 'this' => &$this, 'page' => $page, 'content' => &$content, 'send_mail' => &$send_mail, 'user' => $user, 'order' =>$order, 'order_details' =>$ORDER_DETAILS ); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['mailOrder'] as $funcRef) { t3lib_div::callUserFunction($funcRef, $params, $this); } } if ($send_mail) { mslib_fe::mailUser($user,$page[0]['name'],$page[0]['content'],$ms['MODULES']['STORE_EMAIL'],$ms['MODULES']['STORE_NAME']); if ($copy_to_merchant) { // now mail a copy to the merchant $merchant=array(); $merchant['name'] =$ms['MODULES']['STORE_NAME']; $merchant['email'] =$ms['MODULES']['STORE_EMAIL']; mslib_fe::mailUser($merchant,$page[0]['name'],$page[0]['content'],$ms['MODULES']['STORE_EMAIL'],$ms['MODULES']['STORE_NAME']); if ($ms['MODULES']['SEND_ORDER_CONFIRMATION_LETTER_ALSO_TO']) { $email=array(); if (!strstr($ms['MODULES']['SEND_ORDER_CONFIRMATION_LETTER_ALSO_TO'],",")) $email[]=$ms['MODULES']['SEND_ORDER_CONFIRMATION_LETTER_ALSO_TO']; else { $email=explode(',',$ms['MODULES']['SEND_ORDER_CONFIRMATION_LETTER_ALSO_TO']); } if (count($email)) { foreach ($email as $item) { $merchant=array(); $merchant['name'] =$ms['MODULES']['STORE_NAME']; $merchant['email'] =$item; mslib_fe::mailUser($merchant,$page[0]['name'],$page[0]['content'],$ms['MODULES']['STORE_EMAIL'],$ms['MODULES']['STORE_NAME']); } } } } } return 1; } } function fullwidthDiv ($content) { return '
    '.$content.'
    '; } /* this method is used to request the categories page set $filter can be an string or (multiple) array: string example: o.orders_id=12 array example: $filter[]='o.orders_id=12' */ function getCMSPageSet($filter=array(),$offset=0,$limit=0,$orderby=array(),$having=array(),$select=array(),$where=array(),$from=array()) { global $ms,$get; if (!$limit) $limit=20; if (!is_numeric($offset)) $offset=0; // do normal search (join the seperate tables) $select_clause="SELECT "; if (count($select)>0) { $select_clause.=implode(",",$select); } $from_clause.=" from tx_multishop_cms c, tx_multishop_cms_description cd"; if (count($from) > 0) { $from_clause.=", "; $from_clause.=implode(",",$from); } $where_clause.=" where c.id=cd.id and cd.language_id='".$this->sys_language_uid."'"; if (count($where)>0) { $where_clause.='and '; $where_clause.=implode($where,","); } if (is_array($filter) and count($filter) >0) $where_clause.=' and ('.implode($filter," and ").')'; elseif ($filter) $where_clause.=' and ('.$filter.')'; if (count($having) >0) { $having_clause.=" having "; foreach ($having as $item) { $having_clause.=$item; } } if (is_array($orderby) and count($orderby)>0) { $str_order_by.=implode($orderby,","); } elseif ($orderby) $str_order_by.=$orderby; else $str_order_by.=""; if ($str_order_by) $orderby_clause.=" order by ".$str_order_by; $limit_clause.=' LIMIT '.$offset.','.$limit; $array=array(); $str=$select_clause.$from_clause.$where_clause.$having_clause; // error_log($str); $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $array['total_rows']=$GLOBALS['TYPO3_DB']->sql_num_rows($qry); $str=$select_clause.$from_clause.$where_clause.$having_clause.$orderby_clause.$limit_clause; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $rows=$GLOBALS['TYPO3_DB']->sql_num_rows($qry); if ($rows > 0) { while ($category=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) { $array['admin_cms'][]=$category; } } return $array; } /* this method is used to request the categories page set $filter can be an string or (multiple) array: string example: o.orders_id=12 array example: $filter[]='o.orders_id=12' */ function getAdminSettingsPageSet($filter=array(),$offset=0,$limit=0,$orderby=array(),$having=array(),$select=array(),$where=array(),$from=array()) { global $ms,$get; if (!$limit) $limit=20; if (!is_numeric($offset)) $offset=0; // do normal search (join the seperate tables) $select_clause="SELECT "; if (count($select)>0) { $select_clause.=implode(",",$select); } $from_clause.=" from tx_multishop_configuration c left join tx_multishop_configuration_values cv on c.configuration_key=cv.configuration_key "; if (count($from) > 0) { $from_clause.=", "; $from_clause.=implode(",",$from); } $where_clause.=" where 1 "; if (count($where)>0) { $where_clause.='and '; $where_clause.=implode($where,","); } if (is_array($filter) and count($filter) >0) $where_clause.=' and ('.implode($filter," and ").')'; elseif ($filter) $where_clause.=' and ('.$filter.')'; if (count($having) >0) { $having_clause.=" having "; foreach ($having as $item) { $having_clause.=$item; } } if (is_array($orderby) and count($orderby)>0) { $str_order_by.=implode($orderby,","); } elseif ($orderby) $str_order_by.=$orderby; else $str_order_by.=""; if ($str_order_by) $orderby_clause.=" order by ".$str_order_by; $limit_clause.=' LIMIT '.$offset.','.$limit; $array=array(); $str=$select_clause.$from_clause.$where_clause.$having_clause; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $array['total_rows']=$GLOBALS['TYPO3_DB']->sql_num_rows($qry); $str=$select_clause.$from_clause.$where_clause.$having_clause.$orderby_clause.$limit_clause; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $rows=$GLOBALS['TYPO3_DB']->sql_num_rows($qry); if ($rows > 0) { while ($category=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) { $array['admin_settings'][]=$category; } } return $array; } /* this method is used to request the categories page set $filter can be an string or (multiple) array: string example: o.orders_id=12 array example: $filter[]='o.orders_id=12' */ function getCategoriesPageSet($filter=array(),$offset=0,$limit=0,$orderby=array(),$having=array(),$select=array(),$where=array(),$from=array()) { global $ms,$get; if (!$limit) $limit=20; if (!is_numeric($offset)) $offset=0; // do normal search (join the seperate tables) $select_clause="SELECT "; if (count($select)>0) { $select_clause.=implode(",",$select); } $from_clause.=" from tx_multishop_categories c, tx_multishop_categories_description cd"; if (count($from) > 0) { $from_clause.=", "; $from_clause.=implode(",",$from); } $where_clause.=" where c.status=1 and cd.language_id='".$this->sys_language_uid."' and c.categories_id=cd.categories_id"; if (count($where)>0) { $where_clause.='and '; $where_clause.=implode($where,","); } if (is_array($filter) and count($filter) >0) $where_clause.=' and ('.implode($filter," and ").')'; elseif ($filter) $where_clause.=' and ('.$filter.')'; if (count($having) >0) { $having_clause.=" having "; foreach ($having as $item) { $having_clause.=$item; } } if (is_array($orderby) and count($orderby)>0) { $str_order_by.=implode($orderby,","); } elseif ($orderby) $str_order_by.=$orderby; else $str_order_by.=""; if ($str_order_by) $orderby_clause.=" order by ".$str_order_by; $limit_clause.=' LIMIT '.$offset.','.$limit; $array=array(); $str=$select_clause.$from_clause.$where_clause.$having_clause; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $array['total_rows']=$GLOBALS['TYPO3_DB']->sql_num_rows($qry); $str=$select_clause.$from_clause.$where_clause.$having_clause.$orderby_clause.$limit_clause; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $rows=$GLOBALS['TYPO3_DB']->sql_num_rows($qry); if ($rows > 0) { while ($category=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) { $array['categories'][]=$category; } } return $array; } /* this method is used to request the orders page set $filter can be an string or (multiple) array: string example: o.orders_id=12 array example: $filter[]='o.orders_id=12' */ function getOrdersPageSet($filter=array(),$offset=0,$limit=0,$orderby=array(),$having=array(),$select=array(),$where=array(),$from=array()) { global $ms,$get; if (!$limit) $limit=20; if (!is_numeric($offset)) $offset=0; // do normal search (join the seperate tables) $select_clause="SELECT "; if (count($select)>0) { $select_clause.=implode(",",$select); } $from_clause.=" from tx_multishop_orders o left join tx_multishop_orders_status os on o.status=os.id "; if (count($from) > 0) { $from_clause.=", "; $from_clause.=implode(",",$from); } $where_clause.=" where o.deleted=0"; if (count($where)>0) { $where_clause.='and '; $where_clause.=implode($where,","); } if (is_array($filter) and count($filter) >0) $where_clause.=' and ('.implode($filter," and ").')'; elseif ($filter) $where_clause.=' and ('.$filter.')'; if (count($having) >0) { $having_clause.=" having "; foreach ($having as $item) { $having_clause.=$item; } } if (is_array($orderby) and count($orderby)>0) { $str_order_by.=implode($orderby,","); } elseif ($orderby) $str_order_by.=$orderby; else $str_order_by.=""; if ($str_order_by) $orderby_clause.=" order by ".$str_order_by; $limit_clause.=' LIMIT '.$offset.','.$limit; $array=array(); $str=$select_clause.$from_clause.$where_clause.$having_clause; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $array['total_rows']=$GLOBALS['TYPO3_DB']->sql_num_rows($qry); $str=$select_clause.$from_clause.$where_clause.$having_clause.$orderby_clause.$limit_clause; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $rows=$GLOBALS['TYPO3_DB']->sql_num_rows($qry); if ($rows > 0) { while ($order=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) { $array['orders'][]=$order; } } return $array; } /* this method is used to request the orders page set $filter can be an string or (multiple) array: string example: o.orders_id=12 array example: $filter[]='o.orders_id=12' */ function getInvoicesPageSet($filter=array(),$offset=0,$limit=0,$orderby=array(),$having=array(),$select=array(),$where=array(),$from=array()) { global $ms,$get; if (!$limit) $limit=20; if (!is_numeric($offset)) $offset=0; // do normal search (join the seperate tables) $select_clause="SELECT "; if (count($select)>0) { $select_clause.=implode(",",$select); } $from_clause.=",i.crdate,i.payed from tx_multishop_invoices i left join tx_multishop_orders o on o.orders_id=i.orders_id"; if (count($from) > 0) { $from_clause.=", "; $from_clause.=implode(",",$from); } $where_clause.=" where 1 "; if (count($where)>0) { $where_clause.='and '; $where_clause.=implode($where,","); } if (is_array($filter) and count($filter) >0) $where_clause.=' and ('.implode($filter," and ").')'; elseif ($filter) $where_clause.=' and ('.$filter.')'; if (count($having) >0) { $having_clause.=" having "; foreach ($having as $item) { $having_clause.=$item; } } if (is_array($orderby) and count($orderby)>0) { $str_order_by.=implode($orderby,","); } elseif ($orderby) $str_order_by.=$orderby; else $str_order_by.=""; if ($str_order_by) $orderby_clause.=" order by ".$str_order_by; $limit_clause.=' LIMIT '.$offset.','.$limit; $array=array(); $str=$select_clause.$from_clause.$where_clause.$having_clause; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $array['total_rows']=$GLOBALS['TYPO3_DB']->sql_num_rows($qry); $str=$select_clause.$from_clause.$where_clause.$having_clause.$orderby_clause.$limit_clause; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $rows=$GLOBALS['TYPO3_DB']->sql_num_rows($qry); if ($rows > 0) { while ($row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) { $array['invoices'][]=$row; } } return $array; } function getShopByPageUid($page_uid) { if (is_numeric($page_uid)) { $shop = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( 't.pid, p.title, p.uid as puid', 'tt_content t, pages p', 'p.uid=\''.$page_uid.'\' and p.hidden=0 and t.hidden=0 and p.deleted=0 and t.deleted=0 and t.list_type = \'multishop_pi1\' and t.pi_flexform like \'%coreshop%\' and t.pid=p.uid', 'p.sorting' ); return $shop[0]; } } function getShopNameByPageUid($page_uid) { if (is_numeric($page_uid)) { $shop = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( 't.pid, p.title, p.uid as puid', 'tt_content t, pages p', 'p.uid=\''.$page_uid.'\' and p.hidden=0 and t.hidden=0 and p.deleted=0 and t.deleted=0 and t.list_type = \'multishop_pi1\' and t.pi_flexform like \'%coreshop%\' and t.pid=p.uid', 'p.sorting' ); return $shop[0]['title']; } } function getOrdersIdByTransactionId($transaction_id,$psp='') { $query = $GLOBALS['TYPO3_DB']->SELECTquery( '*', // SELECT ... 'tx_multishop_payment_transactions', // FROM ... 'transaction_id=\''.addslashes($transaction_id).'\' and psp=\''.addslashes($psp).'\'', // WHERE... '', // GROUP BY... '', // ORDER BY... '' // LIMIT ... ); $res = $GLOBALS['TYPO3_DB']->sql_query($query); if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) { $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); return $row['orders_id']; } } function createPaymentTransactionId($orders_id,$psp='',$code='',$security_type='md5') { $array=array(); $array['orders_id'] =$orders_id; switch ($security_type) { case 'sha512': $array['transaction_id']=hash('sha512', uniqid($orders_id.'-'.$psp,TRUE)); break; case 'sha1': $array['transaction_id']=sha1(uniqid($orders_id.'-'.$psp,TRUE)); break; case 'md5': default: $array['transaction_id']=md5(uniqid($orders_id.'-'.$psp,TRUE)); break; } $array['psp'] =$psp; $array['code'] =$code; $array['crdate'] =time(); $array['status'] =0; if ($array['transaction_id']) { $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_payment_transactions', $array); $res = $GLOBALS['TYPO3_DB']->sql_query($query); if ($res) { return $array['transaction_id']; } } } function getProducts($products_id='',$categories_id='') { global $ms; if (!empty($products_id) && !is_numeric($products_id)) { return false; } if (!empty($categories_id) && !is_numeric($categories_id)) { return false; } if (!$ms['MODULES']['FLAT_DATABASE']) { //pd.products_meta_title, pd.products_shortdescription, pd.products_meta_keywords, if ($products_id) { $str="SELECT *,p.staffel_price as staffel_price, tr.tx_rate as tax_rate, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from tx_multishop_products p left join tx_multishop_specials s on p.products_id = s.products_id left join static_taxes tr on p.tax_id = tr.uid, tx_multishop_products_description pd, tx_multishop_products_to_categories p2c, tx_multishop_categories c, tx_multishop_categories_description cd where p.products_status=1 and pd.language_id='".$this->sys_language_uid."' and cd.language_id='".$this->sys_language_uid."' and p.products_id='".$products_id."' and p.products_id=pd.products_id and p.products_id=p2c.products_id and p2c.categories_id=c.categories_id and p2c.categories_id=cd.categories_id "; if ($categories_id) $str.=" and p2c.categories_id='".$categories_id."'"; $str.=" order by p2c.sort_order"; } elseif ($categories_id) { $str="SELECT *,p.staffel_price as staffel_price, tr.tx_rate as tax_rate, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from tx_multishop_products p left join tx_multishop_specials s on p.products_id = s.products_id left join static_taxes tr on p.tax_id = tr.uid, tx_multishop_products_description pd, tx_multishop_products_to_categories p2c, tx_multishop_categories c, tx_multishop_categories_description cd where p.products_status=1 and p2c.categories_id='".$categories_id."' and pd.language_id='".$this->sys_language_uid."' and cd.language_id='".$this->sys_language_uid."' and p.products_id=pd.products_id and p.products_id=p2c.products_id and p2c.categories_id=c.categories_id and p2c.categories_id=cd.categories_id order by p2c.sort_order"; } } else { if ($products_id) { $str="SELECT * from tx_multishop_products_flat where products_id='".$products_id."' and language_id='".$this->sys_language_uid."'"; } elseif ($categories_id) { $str="SELECT * from tx_multishop_products_flat where categories_id='".$categories_id."' and language_id='".$this->sys_language_uid."'"; } } $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $products=array(); while ($product=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) { $products[$product['products_id']]=$product; } return $products; } /* method used for the ultrasearch searchform */ function categories_ultrasearch_as_ul($parent_id = '0',&$content='') { $content.='
      '; $categories_query = $GLOBALS['TYPO3_DB']->sql_query("select c.categories_id, cd.categories_name, c.parent_id from tx_multishop_categories c, tx_multishop_categories_description cd where c.categories_id = cd.categories_id and c.parent_id = '" . $parent_id . "' and c.page_uid='".$this->showCatalogFromPage."' order by c.sort_order, cd.categories_name"); while ($categories = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($categories_query)) { if ($categories['categories_name']) { $content.='
    • '; if (mslib_fe::hasProducts($categories['categories_id'])) { // get all cats to generate multilevel fake url $level=0; $cats=mslib_fe::Crumbar($categories['categories_id']); $cats=array_reverse($cats); $where=''; if (count($cats) > 0) { foreach ($cats as $item) { $where.="categories_id[".$level."]=".$item['id']."&"; $level++; } $where=substr($where,0,(strlen($where)-1)); $where.='&'; } $where.='categories_id['.$level.']='.$categories['categories_id']; $link=mslib_fe::typolink($this->shop_pid,'&'.$where.'&tx_multishop_pi1[page_section]=products_listing'); // get all cats to generate multilevel fake url eof $name=''.$categories['categories_name'].''; } else { $name=''.$categories['categories_name'].''; } $content.=$name; categories_ultrasearch_as_ul($categories['categories_id'],$content); $content.='
    • '; } } $content.='
    '; return $content; } /* loads all options ids plus option values ids that are mapped to a specific product */ function getProductOptions($products_id) { if(is_numeric($products_id)) { $str="SELECT options_id,options_values_id from tx_multishop_products_attributes where products_id='".$products_id."'"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $options=array(); while ($row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) { $options[$row['options_id']][]=$row['options_values_id']; } return $options; } } function getProductFeed($string,$type='id') { if($string) { switch ($type) { case 'code': case 'id': $str="SELECT * from tx_multishop_product_feeds where ".$type."='".addslashes($string)."'"; $qry=$GLOBALS['TYPO3_DB']->sql_query($str); $row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); return $row; break; default: return false; break; } } } function printOrderDetailsTable($order,$type='site') { global $ms; if ($type=='site') { $content=''; $content.=''; /*RAM TUTTI I PREZZI NEI RIEPILOGHI DEVONO ESSERE IVA ESCLUSA if ($ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) { $content.=''; } else { $content.=''; } */ $content.=''; #RAM end $content.=' '; $subtotal=0; $subtotal_tax=0; foreach ($order['products'] as $product) { if (!$tr_type or $tr_type=='even') $tr_type='odd'; else $tr_type='even'; $subprices=''; $price=$product['qty']*$product['final_price']; $content.=''; $subtotal=($subtotal+$price); if ($product['products_tax']) $tax=round(($price/100*($product['products_tax'])),4); else $tax=0; $subtotal_tax=($subtotal_tax+$tax); } $content.='
    '.$this->pi_getLL('qty').''.ucfirst($this->pi_getLL('product')).''.$this->pi_getLL('vat').''.$this->pi_getLL('price_including_vat').''.$this->pi_getLL('price_excluding_vat').''.$this->pi_getLL('price_excluding_vat').'
    '.number_format($product['qty']).' '.$product['products_name']; if ($product['products_model']) $content.=' ('.$product['products_model'].') '; if (count($product['attributes'])) { foreach ($product['attributes'] as $tmpkey => $options) { $subprices.='
    '; /*RAM if ($ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) { $attribute_price=round(($options['options_values_price']*($product['products_tax']/100)),4)+$options['options_values_price']; } else $attribute_price=$options['options_values_price']; */ $attribute_price=$options['options_values_price']; $content.='
    '.$options['products_options'].': '.$options['products_options_values']; $price=$price+($product['qty']*($options['price_prefix'].$options['options_values_price'])); if ($price < 0) $price=0; if ($options['options_values_price'] >0) $subprices.=mslib_fe::Money2Cents(($product['qty']*($options['price_prefix'].$attribute_price))); } } $content.='
    '.(($product['products_tax'])?number_format($product['products_tax']).'%':' ').' '; /*RAM if ($ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) { $final_price=($product['qty']*$product['final_price']); $final_price=round(($final_price*($product['products_tax']/100)),4)+$final_price; } else { $final_price=($product['qty']*$product['final_price']); } */ $final_price=($product['qty']*$product['final_price']); $content.=mslib_fe::Money2Cents($final_price).$subprices.'
    '; $content.=ucfirst($this->pi_getLL('subtotal')).': '.mslib_fe::Money2Cents($subtotal).'
    '; if ($ms['MODULES']['INCLUDE_VAT_OVER_METHOD_COSTS']) { $subtotal_tax=($subtotal_tax+($order['shipping_method_costs']/100*$ms['MODULES']['INCLUDE_VAT_OVER_METHOD_COSTS'])); $subtotal_tax=($subtotal_tax+($order['payment_method_costs']/100*$ms['MODULES']['INCLUDE_VAT_OVER_METHOD_COSTS'])); } else { } $content_subtotal_tax=strtoupper($this->pi_getLL('vat')).': '.mslib_fe::Money2Cents($subtotal_tax).'
    '; if ($order['discount']) { $content_discount=ucfirst($this->pi_getLL('discount')).': '.mslib_fe::Money2Cents($order['discount']).'
    '; } if ($order['shipping_method_costs']) $content_shipping_costs=$this->pi_getLL('shipping_costs').' ('.$order['shipping_method_label'].'): '.mslib_fe::Money2Cents($order['shipping_method_costs']).'
    '; if ($order['payment_method_costs']) $content_payment_costs=$this->pi_getLL('payment_costs').' ('.$order['payment_method_label'].'): '.mslib_fe::Money2Cents($order['payment_method_costs']).'
    '; $content_total=''.ucfirst($this->pi_getLL('total')).': '.mslib_fe::Money2Cents($subtotal+$subtotal_tax+$order['payment_method_costs']+$order['shipping_method_costs']-$order['discount']).''; if ($ms['MODULES']['INCLUDE_VAT_OVER_METHOD_COSTS']) { $content.=$content_shipping_costs; $content.=$content_payment_costs; $content.=$content_subtotal_tax; $content.=$content_discount; $content.=$content_total; } else { $content.=$content_subtotal_tax; $content.=$content_discount; $content.=$content_shipping_costs; $content.=$content_payment_costs; $content.=$content_total; } $content.='
    '; } elseif ($type=='email') { $content.=''; /*RAM if ($ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) { $content.=''; } else { $content.=''; } */ $content.=''; $content.=''; $subtotal=0; $subtotal_tax=0; foreach ($order['products'] as $product) { if (!$tr_type or $tr_type=='even') $tr_type='odd'; else $tr_type='even'; $subprices=''; $price=$product['qty']*$product['final_price']; $content.=''; // $subtotal=($subtotal+$price); if ($product['products_tax']) $tax=round(($price/100*($product['products_tax'])),4); else $tax=0; $subtotal_tax=($subtotal_tax+$tax); } $content.='
    '.$this->pi_getLL('qty').''.ucfirst($this->pi_getLL('product')).''.$this->pi_getLL('price_including_vat').''.$this->pi_getLL('price_excluding_vat').''.$this->pi_getLL('price_excluding_vat').'
    '.number_format($product['qty']).' '.$product['products_name']; if ($product['products_model']) $content.=' ('.$product['products_model'].') '; // if ($product['products_description']) $content.='
    '.$product['products_description']; if (count($product['attributes'])) { foreach ($product['attributes'] as $tmpkey => $options) { $subprices.='
    '; /*RAM if ($ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) { $attribute_price=round(($options['options_values_price']*($product['products_tax']/100))+$options['options_values_price'],4); } else $attribute_price=$options['options_values_price']; */ $attribute_price=$options['options_values_price']; $content.='
    '.$options['products_options'].': '.$options['products_options_values']; $price=$price+($product['qty']*($options['price_prefix'].$options['options_values_price'])); if ($price < 0) $price=0; if ($options['options_values_price'] >0) $subprices.=mslib_fe::Money2Cents(($product['qty']*($options['price_prefix'].$attribute_price))); } } /*RAM if ($ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) { $final_price=($product['qty']*$product['final_price']); $final_price=round(($final_price*($product['products_tax']/100)),4)+$final_price; } else { $final_price=($product['qty']*$product['final_price']); } */ $final_price=($product['qty']*$product['final_price']); $content.='
    '.mslib_fe::Money2Cents($final_price).$subprices.'
    '.$product['products_description'].'
    '; $content.=ucfirst($this->pi_getLL('subtotal')).': '.mslib_fe::Money2Cents($subtotal).'
    '; if ($ms['MODULES']['INCLUDE_VAT_OVER_METHOD_COSTS']) { $subtotal_tax=($subtotal_tax+($order['shipping_method_costs']/100*$ms['MODULES']['INCLUDE_VAT_OVER_METHOD_COSTS'])); $subtotal_tax=($subtotal_tax+($order['payment_method_costs']/100*$ms['MODULES']['INCLUDE_VAT_OVER_METHOD_COSTS'])); } else { } $content_subtotal_tax=strtoupper($this->pi_getLL('vat')).': '.mslib_fe::Money2Cents($subtotal_tax).'
    '; if ($order['discount']) { $content_discount=ucfirst($this->pi_getLL('discount')).': '.mslib_fe::Money2Cents($order['discount']).'
    '; } if ($order['shipping_method_costs']) $content_shipping_costs=$this->pi_getLL('shipping_costs').' ('.$order['shipping_method_label'].'): '.mslib_fe::Money2Cents($order['shipping_method_costs']).'
    '; if ($order['payment_method_costs']) $content_payment_costs=$this->pi_getLL('payment_costs').' ('.$order['payment_method_label'].'): '.mslib_fe::Money2Cents($order['payment_method_costs']).'
    '; $content_total=''.ucfirst($this->pi_getLL('total')).': '.mslib_fe::Money2Cents($subtotal+$subtotal_tax+$order['payment_method_costs']+$order['shipping_method_costs']-$order['discount']).''; if ($ms['MODULES']['INCLUDE_VAT_OVER_METHOD_COSTS']) { $content.=$content_shipping_costs; $content.=$content_payment_costs; $content.=$content_subtotal_tax; $content.=$content_discount; $content.=$content_total; } else { $content.=$content_subtotal_tax; $content.=$content_discount; $content.=$content_shipping_costs; $content.=$content_payment_costs; $content.=$content_total; } $content.='
    '; } return $content; } } if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/multishop/pi1/classes/class.mslib_fe.php"]) { include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/multishop/pi1/classes/class.mslib_fe.php"]); } ?>