';
$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 (!$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.='';
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.=''.$this->pi_getLL('qty').' | '.ucfirst($this->pi_getLL('product')).' | '.$this->pi_getLL('vat').' | ';
/*RAM
TUTTI I PREZZI NEI RIEPILOGHI DEVONO ESSERE IVA ESCLUSA
if ($ms['MODULES']['SHOW_PRICES_INCLUDING_VAT'])
{
$content.=''.$this->pi_getLL('price_including_vat').' | ';
}
else
{
$content.=''.$this->pi_getLL('price_excluding_vat').' | ';
}
*/
$content.=''.$this->pi_getLL('price_excluding_vat').' | ';
#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.='
'.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.' |
';
$subtotal=($subtotal+$price);
if ($product['products_tax']) $tax=round(($price/100*($product['products_tax'])),4);
else $tax=0;
$subtotal_tax=($subtotal_tax+$tax);
}
$content.='';
$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.=''.$this->pi_getLL('qty').' | '.ucfirst($this->pi_getLL('product')).' | ';
/*RAM if ($ms['MODULES']['SHOW_PRICES_INCLUDING_VAT'])
{
$content.=''.$this->pi_getLL('price_including_vat').' | ';
}
else
{
$content.=''.$this->pi_getLL('price_excluding_vat').' | ';
}
*/
$content.=''.$this->pi_getLL('price_excluding_vat').' | ';
$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.='
'.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'].' |
$subtotal=($subtotal+$price);
if ($product['products_tax']) $tax=round(($price/100*($product['products_tax'])),4);
else $tax=0;
$subtotal_tax=($subtotal_tax+$tax);
}
$content.='';
$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"]);
}
?> |