<?php
/*
  www.oscGold.com (C) Kamelia-Net Jacek Krysiak
  modul oscGold wer 4.0
*/

// ******************************************************************************************
// ZMIANA STATUSU ZAMOWIENIA
//******************************************************************************************
function mail_orders($custom_name,$custom_email,$oID,$date_1,$stats,$notify_comments) {
  $temat = MakeUTF(EMAIL_TEXT_SUBJECT) . ' - ' . $oID;
  $owner = MakeUTF(STORE_NAME);
  // GENEROWANIE TRESCI MAILA
  if (EMAIL_USE_HTML == 'true') {
        $email_text = '
        <table border="0" cellspacing="0" cellpadding="10" width="100%">
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:14px;color:#4f7d13"><b>'.ORDER_WELCOME.'</b></td></tr>
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.EMAIL_TEXT_SUBJECT.'</td></tr>
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.
            EMAIL_TEXT_ORDER_NUMBER.' <b>'.$oID.'</b><br>'.
            EMAIL_TEXT_INVOICE_URL . ' <b>' . tep_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $oID, 'SSL').'</b><br>'.
            EMAIL_TEXT_DATE_ORDERED.' <b>'.$date_1.'</b>
            </td></tr>
        </table>';
        // komentarz do zamowienia
        if ($notify_comments != '') {
            $email_text .= '<table border="0" cellspacing="0" cellpadding="10" width="100%">';
            $email_text .= '<tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">';
            $email_text .= '<table cellspacing="0" cellpadding="5" style="background-color:#f0f0f0;border:1px;border-style:solid;border-color:#868785">
                                <tr><td align="left" style="font-family:Tahoma,Arial;font-size:14px;color:#474747">'.str_replace("\n","<br>",$notify_comments).'</td></tr>
                            </table>';
            $email_text .= '</td></tr></table>';
        }
        $email_text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\">\\0</a>", $email_text);
        $email_text .= '
        <table border="0" cellspacing="0" cellpadding="10" width="100%">
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.str_replace("\n","<br>",sprintf(EMAIL_TEXT_STATUS_UPDATE, '<b>'.$stats.'</b>')).'</td></tr>
        </table>
        <table border="0" cellspacing="0" cellpadding="8" width="100%">
         <tr><td align="left">
            <table cellspacing="0" cellpadding="2" border="0" width="100%">
                <tr><td align="left"><hr></td></tr>
                <tr><td align="left" style="font-family:Tahoma,Arial;font-size:11px;color:#6e6e6e">'.EMAIL_TEXT_PZDR.'<br>'.STORE_NAME . '<br><a href="' . HTTP_SERVER  . DIR_WS_CATALOG .'">' .  HTTP_SERVER  . DIR_WS_CATALOG . '</a>' . '</td></tr>
            </table>
        </td></tr>
        </table>';
        $ArrayLNTargets = array("\r\n", "\n\r", "\n", "\r", "\t");
        $email_text = str_replace($ArrayLNTargets, '', $email_text);
     } else {
        $email_text = ORDER_WELCOME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . tep_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $oID, 'SSL') . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . $date_1 . "\n\n" . ($notify_comments!='' ? $notify_comments. "\n\n" : "") .sprintf(EMAIL_TEXT_STATUS_UPDATE, $stats);

  }
  tep_mail($custom_name, $custom_email , $temat, $email_text, $owner, STORE_OWNER_EMAIL_ADDRESS);
}


// ******************************************************************************************
// WYSYLANIE KUPONU W RAMACH - POLECONY/NAGRODZONY
//******************************************************************************************
function mail_orders_polecony($polecajacy_name,$polecajacy_mail,$coupons_id,$coupons_date_start,$coupons_date_end) {
  $temat = MakeUTF(PROMO_POLECONY_SUBJECT);
  // GENEROWANIE TRESCI MAILA
  if (EMAIL_USE_HTML == 'true') {
        $email_text = '
        <table border="0" cellspacing="0" cellpadding="10" width="100%">
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:14px;color:#4f7d13"><b>'.PROMO_POLECONY_SUBJECT.'</b></td></tr>
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.PROMO_POLECONY_EMAIL1.'</td></tr>
            <tr><td align="left">
                <table cellspacing="0" cellpadding="5" style="background-color:#f0f0f0;border:1px;border-style:solid;border-color:#868785">
                    <tr><td align="left" style="font-family:Tahoma,Arial;font-size:14px;color:#474747">'.PROMO_POLECONY_COUPON_CODE .' <b>'.$coupons_id.'</b></td></tr>
                    <tr><td align="left" style="font-family:Tahoma,Arial;font-size:14px;color:#474747">'.PROMO_POLECONY_COUPON_RABAT.' <b>'.PROMO_POLECONY_RABAT.'</b></td></tr>
                    <tr><td align="left" style="font-family:Tahoma,Arial;font-size:14px;color:#474747">'.PROMO_POLECONY_COUPON_MIN.' <b>'.PROMO_POLECONY_MIN_ORDER.'</b></td></tr>
                    <tr><td align="left" style="font-family:Tahoma,Arial;font-size:14px;color:#474747">'.PROMO_POLECONY_COUPON_OKRES.' <b>'.$coupons_date_start.' - '.$coupons_date_end.'</b></td></tr>
                </table>
            </td></tr>
        </table>
        <table border="0" cellspacing="0" cellpadding="10" width="100%">
         <tr><td align="left">
            <table cellspacing="0" cellpadding="2" border="0" width="100%">
                <tr><td align="left"><hr></td></tr>
                <tr><td align="left" style="font-family:Tahoma,Arial;font-size:11px;color:#6e6e6e">'.EMAIL_TEXT_PZDR.'<br>'.STORE_NAME . '<br><a href="' . HTTP_SERVER  . DIR_WS_CATALOG .'">' .  HTTP_SERVER  . DIR_WS_CATALOG . '</a>' . '</td></tr>
            </table>
        </td></tr>
        </table>';
        $ArrayLNTargets = array("\r\n", "\n\r", "\n", "\r", "\t");
        $email_text = str_replace($ArrayLNTargets, '', $email_text);
     } else {
        $email_text = PROMO_POLECONY_EMAIL1 . PROMO_POLECONY_COUPON_CODE .''.$coupons_id."\n" . PROMO_POLECONY_COUPON_RABAT.''.PROMO_POLECONY_RABAT."\n";
        $email_text .= PROMO_POLECONY_COUPON_MIN.''.PROMO_POLECONY_MIN_ORDER."\n" . PROMO_POLECONY_COUPON_OKRES.''.$coupons_date_start.' - '.$coupons_date_end."\n\n";
        $email_text .= EMAIL_SEPARATOR."\n" . PROMO_POLECONY_FOOTER . '' . STORE_NAME;

  }
  tep_mail($polecajacy_name, $polecajacy_mail, $temat, $email_text, MakeUTF(STORE_NAME), STORE_OWNER_EMAIL_ADDRESS);
}


// ******************************************************************************************
// ZMIANA DANYCH ADMINISTRATORA
//******************************************************************************************
function mail_admin($adresat,$emaila,$imie,$emils,$hiddenPassword,$owner) {
  $temat = MakeUTF(ADMIN_EMAIL_SUBJECT);
  // GENEROWANIE TRESCI MAILA
  if (EMAIL_USE_HTML == 'true') {
        $email_text = '
        <table border="0" cellspacing="0" cellpadding="10" width="100%">
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:14px;color:#4f7d13"><b>'.sprintf(ADMIN_EMAIL_TEXT1,$imie).'</b></td></tr>
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.ADMIN_EMAIL_TEXT2.'</td></tr>
            <tr><td align="left">
                <table cellspacing="0" cellpadding="5" style="background-color:#f0f0f0;border:1px;border-style:solid;border-color:#868785">
                    <tr><td align="left" style="font-family:Tahoma,Arial;font-size:14px;color:#474747">'.str_replace("\n","<br>",sprintf(ADMIN_EMAIL_TEXT3,HTTP_SERVER . DIR_WS_ADMIN,$emils,$hiddenPassword)).'</td></tr>
                </table>
            </td></tr>
        </table>
        <table border="0" cellspacing="0" cellpadding="10" width="100%">
         <tr><td align="left">
            <table cellspacing="0" cellpadding="2" border="0" width="100%">
                <tr><td align="left"><hr></td></tr>
                <tr><td align="left" style="font-family:Tahoma,Arial;font-size:11px;color:#6e6e6e">'.ADMIN_EMAIL_TEXT5 . '</td></tr>
                <tr><td align="left" style="font-family:Tahoma,Arial;font-size:11px;color:#6e6e6e"><br>'.EMAIL_TEXT_PZDR.'<br>'.STORE_NAME . '<br><a href="' . HTTP_SERVER  . DIR_WS_CATALOG .'">' .  HTTP_SERVER  . DIR_WS_CATALOG . '</a>' . '</td></tr>
            </table>
        </td></tr>
        </table>';
        $ArrayLNTargets = array("\r\n", "\n\r", "\n", "\r", "\t");
        $email_text = str_replace($ArrayLNTargets, '', $email_text);
     } else {
        $email_text = sprintf(ADMIN_EMAIL_TEXT1.ADMIN_EMAIL_TEXT2.ADMIN_EMAIL_TEXT3.ADMIN_EMAIL_TEXT4.ADMIN_EMAIL_TEXT5,$imie , HTTP_SERVER . DIR_WS_ADMIN,$emils , $hiddenPassword, STORE_OWNER);
  }
  tep_mail($adresat, $emaila , $temat, $email_text , $owner, STORE_OWNER_EMAIL_ADDRESS);
}

// ******************************************************************************************
// ZMIANA UPRAWNIEN KONTA ADMINISTRATORA
//******************************************************************************************
function mail_admin_upraw($adresat,$emaila,$imie,$emils,$hiddenPassword,$owner,$tekst,$temat) {
  // GENEROWANIE TRESCI MAILA
  if (EMAIL_USE_HTML == 'true') {
        $email_text = '
        <table border="0" cellspacing="0" cellpadding="10" width="100%">
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:14px;color:#4f7d13"><b>'.sprintf(ADMIN_EMAIL_TEXT1,$imie).'</b></td></tr>
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.$tekst.'</td></tr>
            <tr><td align="left">
                <table cellspacing="0" cellpadding="5" style="background-color:#f0f0f0;border:1px;border-style:solid;border-color:#868785">
                    <tr><td align="left" style="font-family:Tahoma,Arial;font-size:14px;color:#474747">'.str_replace("\n","<br>",sprintf(ADMIN_EMAIL_TEXT3,HTTP_SERVER . DIR_WS_ADMIN,$emils,$hiddenPassword)).'</td></tr>
                </table>
            </td></tr>
        </table>
        <table border="0" cellspacing="0" cellpadding="10" width="100%">
         <tr><td align="left">
            <table cellspacing="0" cellpadding="2" border="0" width="100%">
                <tr><td align="left"><hr></td></tr>
                <tr><td align="left" style="font-family:Tahoma,Arial;font-size:11px;color:#6e6e6e">'.ADMIN_EMAIL_TEXT5 . '</td></tr>
                <tr><td align="left" style="font-family:Tahoma,Arial;font-size:11px;color:#6e6e6e"><br>'.EMAIL_TEXT_PZDR.'<br>'.STORE_NAME . '<br><a href="' . HTTP_SERVER  . DIR_WS_CATALOG .'">' .  HTTP_SERVER  . DIR_WS_CATALOG . '</a>' . '</td></tr>
            </table>
        </td></tr>
        </table>';
        $ArrayLNTargets = array("\r\n", "\n\r", "\n", "\r", "\t");
        $email_text = str_replace($ArrayLNTargets, '', $email_text);
     } else {
        $email_text = sprintf(ADMIN_EMAIL_TEXT1.ADMIN_EMAIL_TEXT2.ADMIN_EMAIL_TEXT3.ADMIN_EMAIL_TEXT4.ADMIN_EMAIL_TEXT5,$imie , HTTP_SERVER . DIR_WS_ADMIN,$emils , $hiddenPassword, STORE_OWNER);
  }
  tep_mail($adresat, $emaila , $temat, $email_text , $owner, STORE_OWNER_EMAIL_ADDRESS);
}


// ******************************************************************************************
// UTWORZENIE KONTA KLIENTA
//******************************************************************************************
function mail_new_user($nazwa,$new_password,$email_address,$lastname,$firstname,$customer_id) {
  global $currencies;
  //
  $temat = MakeUTF(EMAIL_SUBJECT);
  $owner = MakeUTF(STORE_NAME);
  $nazwa = MakeUTF($nazwa);

  // GENEROWANIE TRESCI MAILA
  if (EMAIL_USE_HTML == 'true') {
        $email_text = '
        <table border="0" cellspacing="0" cellpadding="10" width="100%">
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:16px;color:#4f7d13"><b>'.$email_text.'</b></td></tr>
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.EMAIL_WELCOME.'</td></tr>
            <tr><td align="left">
                <table cellspacing="0" cellpadding="5" style="background-color:#f0f0f0;border:1px;border-style:solid;border-color:#868785">
                    <tr><td align="left" style="font-family:Tahoma,Arial;font-size:14px;color:#474747">'.EMAIL_USERNAME.'</td></tr>
                    <tr><td align="left" style="font-family:Tahoma,Arial;font-size:14px;color:#474747">'.EMAIL_PASSWORD . '<b>'.stripslashes($new_password).'</b></td></tr>
                </table>
            </td></tr>
        </table>
        <table border="0" cellspacing="0" cellpadding="10" width="100%">
         <tr><td align="left">
            <table cellspacing="0" cellpadding="5" width="100%" style="background-color:#ecf5e9;border:1px;border-style:solid;border-color:#868785">
                <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.str_replace("\n","<br>",EMAIL_TEXT).'</td></tr>
            </table>
        </td></tr>
        </table>
        <table border="0" cellspacing="0" cellpadding="8" width="100%">
         <tr><td align="left">
            <table cellspacing="0" cellpadding="2" border="0" width="100%">
                <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#cc3434">'.EMAIL_CONTACT.'</td></tr>
                <tr><td align="left"><hr></td></tr>
                <tr><td align="left" style="font-family:Tahoma,Arial;font-size:11px;color:#6e6e6e"><br>'.EMAIL_TEXT_PZDR.'<br>'.STORE_NAME . '<br><a href="' . HTTP_SERVER  . DIR_WS_CATALOG .'">' .  HTTP_SERVER  . DIR_WS_CATALOG . '</a>' . '</td></tr>
            </table>
        </td></tr>
        </table>';
        $ArrayLNTargets = array("\r\n", "\n\r", "\n", "\r", "\t");
        $email_text = str_replace($ArrayLNTargets, '', $email_text);
     } else {
        $email_text = EMAIL_WELCOME . EMAIL_USERNAME . EMAIL_PASSWORD . stripslashes($new_password) . "\n\n" . EMAIL_TEXT . EMAIL_CONTACT;
  }
  tep_mail($nazwa, $email_address, $temat, $email_text, $owner, STORE_OWNER_EMAIL_ADDRESS);
}


// ******************************************************************************************
// PRZYPOMNIENIE HASLA ADMINISTRATORA
//******************************************************************************************
function mail_password_admin($new_password,$adresat,$email_address,$imie) {
  $temat = MakeUTF(ADMIN_EMAIL_SUBJECT);
  $owner = MakeUTF(STORE_NAME);
  // GENEROWANIE TRESCI MAILA
  if (EMAIL_USE_HTML == 'true') {
        $email_text = '
        <table border="0" cellspacing="0" cellpadding="10" width="100%">
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:16px;color:#4f7d13"><b>'.sprintf(ADMIN_EMAIL_TEXT1,$imie).'</b></td></tr>
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.ADMIN_EMAIL_TEXT2.'</td></tr>
            <tr><td align="left">
                <table cellspacing="0" cellpadding="5" style="background-color:#f0f0f0;border:1px;border-style:solid;border-color:#868785">
                    <tr><td align="left" style="font-family:Tahoma,Arial;font-size:14px;color:#474747">'.str_replace("\n","<br>",sprintf(ADMIN_EMAIL_TEXT3,HTTP_SERVER . DIR_WS_ADMIN, $email_address, $new_password)).'</td></tr>
                </table>
            </td></tr>
        </table>
        <table border="0" cellspacing="0" cellpadding="8" width="100%">
         <tr><td align="left">
            <table cellspacing="0" cellpadding="2" border="0" width="100%">
                <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.ADMIN_EMAIL_TEXT4.'</td></tr>
                <tr><td align="left"><hr></td></tr>
                <tr><td align="left" style="font-family:Tahoma,Arial;font-size:11px;color:#6e6e6e">'.EMAIL_TEXT_PZDR.'<br>'.STORE_NAME . '<br><a href="' . HTTP_SERVER  . DIR_WS_CATALOG .'">' .  HTTP_SERVER  . DIR_WS_CATALOG . '</a>' . '</td></tr>
            </table>
        </td></tr>
        </table>';
        $ArrayLNTargets = array("\r\n", "\n\r", "\n", "\r", "\t");
        $email_text = str_replace($ArrayLNTargets, '', $email_text);
     } else {
        $email_text = sprintf(ADMIN_EMAIL_TEXT1.ADMIN_EMAIL_TEXT2.ADMIN_EMAIL_TEXT3.ADMIN_EMAIL_TEXT4, $imie, HTTP_SERVER . DIR_WS_ADMIN, $email_address, $new_password, STORE_OWNER);
  }
  tep_mail($adresat, $email_address, $temat, $email_text , $owner, STORE_OWNER_EMAIL_ADDRESS);
}


// ******************************************************************************************
// DODANIE i SKASOWANIE PUNKTOW KONTA KLIENTA
//******************************************************************************************
function mail_add_del_point($balance,$customer_balance,$name,$greet,$notify_comment,$points_expire_date,$pointstoadd,$customers_email_address,$tekst,$can_use) {
  global $currencies;
  // GENEROWANIE TRESCI MAILA
  if (EMAIL_USE_HTML == 'true') {
        $email_text = '
        <table border="0" cellspacing="0" cellpadding="10" width="100%">
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:16px;color:#4f7d13"><b>'.$greet.'</b></td></tr>
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.EMAIL_TEXT_INTRO.'</td></tr>
            <tr><td align="left">
                <table cellspacing="0" cellpadding="5" style="background-color:#f0f0f0;border:1px;border-style:solid;border-color:#868785">
                    <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747"><b>'.str_replace("\n","<br>",$tekst).(($notify_comment!='') ? "<br>".$notify_comment : "").'</b></td></tr>
                </table>
            </td></tr>
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.$customer_balance .'<br>'. $points_expire_date.'</td></tr>
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.sprintf(EMAIL_TEXT_POINTS_URL, tep_catalog_href_link(FILENAME_CATALOG_MY_POINTS, '', 'SSL')).'<br>'.sprintf(EMAIL_TEXT_POINTS_URL_HELP, tep_catalog_href_link(FILENAME_CATALOG_MY_POINTS_HELP, '', 'NONSSL')).'</td></tr>
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.$can_use.'</td></tr>
        </table>
        <table border="0" cellspacing="0" cellpadding="8" width="100%">
         <tr><td align="left">
            <table cellspacing="0" cellpadding="2" border="0" width="100%">
                <tr><td align="left" style="font-family:Tahoma,Arial;font-size:11px;color:#474747">'.EMAIL_CONTACT.'</td></tr>
                <tr><td align="left"><hr></td></tr>
                <tr><td align="left" style="font-family:Tahoma,Arial;font-size:11px;color:#6e6e6e">'.EMAIL_TEXT_PZDR.'<br>'.STORE_NAME . '<br>'.HTTP_SERVER  . DIR_WS_CATALOG . '</td></tr>
            </table>
        </td></tr>
        </table>';
        $ArrayLNTargets = array("\r\n", "\n\r", "\n", "\r", "\t");
        $email_text = str_replace($ArrayLNTargets, '', $email_text);
        $email_text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\">\\0</a>", $email_text);
     } else {
        $email_text = $email_text = $greet  . "\n\n" . EMAIL_TEXT_INTRO . "\n\n" . $tekst . "\n" . $notify_comment . $customer_balance . "\n\n" . $points_expire_date . "\n\n" . sprintf(EMAIL_TEXT_POINTS_URL, tep_catalog_href_link(FILENAME_CATALOG_MY_POINTS, '', 'SSL')) . "\n\n" . sprintf(EMAIL_TEXT_POINTS_URL_HELP, tep_catalog_href_link(FILENAME_CATALOG_MY_POINTS_HELP, '', 'NONSSL')) . "\n" . $can_use . "\n" . EMAIL_CONTACT . "\n" . EMAIL_SEPARATOR . "\n" . '<b>' . STORE_NAME . '</b>.' . "\n";
  }
  tep_mail($name, $customers_email_address, MakeUTF(EMAIL_TEXT_SUBJECT), $email_text, MakeUTF(STORE_NAME), STORE_OWNER_EMAIL_ADDRESS);
}


// ******************************************************************************************
// ZATWIERDZENIE PUNKTOW KONTA KLIENTA
//******************************************************************************************
function mail_confirm_point($balance,$customer_balance,$name,$greet,$date_added,$order_status,$customers_email_address,$tekst,$points_pending,$order_id,$can_use,$points_expire_date,$notify_comment) {
  global $currencies;
  // GENEROWANIE TRESCI MAILA
  if (EMAIL_USE_HTML == 'true') {
        $email_text = '
        <table border="0" cellspacing="0" cellpadding="10" width="100%">
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:16px;color:#4f7d13"><b>'.$greet.'</b></td></tr>
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.EMAIL_TEXT_INTRO.'</td></tr>
            <tr><td align="left">
                <table cellspacing="0" cellpadding="5" style="background-color:#f0f0f0;border:1px;border-style:solid;border-color:#868785">
                    <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747"><b>'.str_replace("\n","<br>",$tekst).(($notify_comment!='') ? "<br>".$notify_comment : "").'</b></td></tr>
                </table>
            </td></tr>
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.EMAIL_TEXT_ORDER_NUMBER . ' ' . $order_id.'<br>'.
            EMAIL_TEXT_DATE_ORDERED . ' ' . tep_date_long($date_added).'<br>'.
            EMAIL_TEXT_ORDER_STAUTS . ' ' . $order_status.'<br>'.
            TABLE_HEADING_POINTS . ': ' . number_format($points_pending,POINTS_DECIMAL_PLACES).'<br>'.
            TABLE_HEADING_POINTS_VALUE . ': ' . $currencies->format($points_pending * REDEEM_POINT_VALUE).'
            </td></tr>
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.$customer_balance  .'<br>'. $points_expire_date.'</td></tr>
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.sprintf(EMAIL_TEXT_POINTS_URL, tep_catalog_href_link(FILENAME_CATALOG_MY_POINTS, '', 'SSL')).'<br>'
            .sprintf(EMAIL_TEXT_POINTS_URL_HELP, tep_catalog_href_link(FILENAME_CATALOG_MY_POINTS_HELP, '', 'NONSSL')).'</td></tr>
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.$can_use.'</td></tr>
        </table>
        <table border="0" cellspacing="0" cellpadding="8" width="100%">
         <tr><td align="left">
            <table cellspacing="0" cellpadding="2" border="0" width="100%">
                <tr><td align="left" style="font-family:Tahoma,Arial;font-size:11px;color:#474747">'.EMAIL_CONTACT.'</td></tr>
                <tr><td align="left"><hr></td></tr>
                <tr><td align="left" style="font-family:Tahoma,Arial;font-size:11px;color:#6e6e6e">'.EMAIL_TEXT_PZDR.'<br>'.STORE_NAME . '<br>'.HTTP_SERVER  . DIR_WS_CATALOG . '</td></tr>
            </table>
        </td></tr>
        </table>';
        $ArrayLNTargets = array("\r\n", "\n\r", "\n", "\r", "\t");
        $email_text = str_replace($ArrayLNTargets, '', $email_text);
        $email_text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\">\\0</a>", $email_text);
     } else {
        $email_text = $greet  . "\n" . EMAIL_TEXT_INTRO . "\n" . $tekst . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $order_id . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . tep_date_long($date_added) . "\n" . EMAIL_TEXT_ORDER_STAUTS . ' ' . $order_status . "\n" . TABLE_HEADING_POINTS . ': ' . number_format($points_pending,POINTS_DECIMAL_PLACES) . "\n" . TABLE_HEADING_POINTS_VALUE . ': ' . $currencies->format($points_pending * REDEEM_POINT_VALUE) . "\n" . EMAIL_SEPARATOR . "\n" . $customer_balance  . $points_expire_date . "\n\n" . sprintf(EMAIL_TEXT_POINTS_URL, tep_catalog_href_link(FILENAME_CATALOG_MY_POINTS, '', 'SSL')) . "\n\n" . sprintf(EMAIL_TEXT_POINTS_URL_HELP, tep_catalog_href_link(FILENAME_CATALOG_MY_POINTS_HELP, '', 'NONSSL')) . $can_use . "\n" . EMAIL_CONTACT . "\n" . EMAIL_SEPARATOR . "\n" . '<b>' . STORE_NAME . '</b>.' . "\n";
  }
  tep_mail($name, $customers_email_address, MakeUTF(EMAIL_TEXT_SUBJECT), $email_text, MakeUTF(STORE_NAME), STORE_OWNER_EMAIL_ADDRESS);
}


// ******************************************************************************************
// ZATWIERDZENIE PUNKTOW ZA RECENZJE
//******************************************************************************************
function mail_reviews_point($balance,$customer_balance,$name,$greet,$customers_email_address,$tekst,$points_expire_date,$points_type,$can_use,$notify_comment,$date_added,$customer_name,$points_disc,$products_name,$points_pending,$points_type) {
  global $currencies;
  // GENEROWANIE TRESCI MAILA
  if (EMAIL_USE_HTML == 'true') {
        $email_text = '
        <table border="0" cellspacing="0" cellpadding="10" width="100%">
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:16px;color:#4f7d13"><b>'.$greet.'</b></td></tr>
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.EMAIL_TEXT_INTRO.'</td></tr>
            <tr><td align="left">
                <table cellspacing="0" cellpadding="5" style="background-color:#f0f0f0;border:1px;border-style:solid;border-color:#868785">
                    <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747"><b>'.str_replace("\n","<br>",$tekst).(($notify_comment!='') ? "<br>".$notify_comment : "").'</b></td></tr>
                </table>
            </td></tr>
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.TABLE_HEADING_POINTS_TYPE . ': ' . $points_disc.'<br>'.
            TABLE_HEADING_DATE_ADDED . ': ' . tep_date_short($date_added).'<br>';

            if ($points_type == 'RF') {
                $email_text .= TEXT_INFO_REFERRED . ' ' . $customer_name.'<br>';
                } else {
                $email_text .= TEXT_INFO_PRODUCT_NAME . ' ' . $products_name.'<br>';
            }

            $email_text .= TABLE_HEADING_POINTS . ': ' . number_format($points_pending,POINTS_DECIMAL_PLACES).'<br>'.
            TABLE_HEADING_POINTS_VALUE . ': ' . $currencies->format($points_pending * REDEEM_POINT_VALUE).'
            </td></tr>
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.$customer_balance  .'<br>'. $points_expire_date.'</td></tr>
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.sprintf(EMAIL_TEXT_POINTS_URL, tep_catalog_href_link(FILENAME_CATALOG_MY_POINTS, '', 'SSL')).'<br>'
            .sprintf(EMAIL_TEXT_POINTS_URL_HELP, tep_catalog_href_link(FILENAME_CATALOG_MY_POINTS_HELP, '', 'NONSSL')).'</td></tr>
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.$can_use.'</td></tr>
        </table>
        <table border="0" cellspacing="0" cellpadding="8" width="100%">
         <tr><td align="left">
            <table cellspacing="0" cellpadding="2" border="0" width="100%">
                <tr><td align="left" style="font-family:Tahoma,Arial;font-size:11px;color:#474747">'.EMAIL_CONTACT.'</td></tr>
                <tr><td align="left"><hr></td></tr>
                <tr><td align="left" style="font-family:Tahoma,Arial;font-size:11px;color:#6e6e6e">'.EMAIL_TEXT_PZDR.'<br>'.STORE_NAME . '<br>'.HTTP_SERVER  . DIR_WS_CATALOG . '</td></tr>
            </table>
        </td></tr>
        </table>';
        $ArrayLNTargets = array("\r\n", "\n\r", "\n", "\r", "\t");
        $email_text = str_replace($ArrayLNTargets, '', $email_text);
        $email_text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\">\\0</a>", $email_text);
     } else {
        if ($points_type == 'RF') {
            $details = EMAIL_SEPARATOR . "\n" . TABLE_HEADING_POINTS_TYPE . ': ' . $points_disc . "\n" . TABLE_HEADING_DATE_ADDED . ': ' . tep_date_short($date_added) . "\n" . TEXT_INFO_REFERRED . ' ' . $customer_name . "\n" . TABLE_HEADING_POINTS . ': ' . number_format($points_pending,POINTS_DECIMAL_PLACES) . "\n" . TABLE_HEADING_POINTS_VALUE . ': ' . $currencies->format($points_pending * REDEEM_POINT_VALUE) . "\n" . EMAIL_SEPARATOR;
        }
        if ($points_type == 'RV') {
            $details = EMAIL_SEPARATOR . "\n" . TABLE_HEADING_POINTS_TYPE . ': ' . $points_disc . "\n" . TABLE_HEADING_DATE_ADDED . ': ' . tep_date_short($date_added) . "\n" . TEXT_INFO_PRODUCT_NAME . ' ' . $products_name . "\n" . TABLE_HEADING_POINTS . ': ' . number_format($points_pending,POINTS_DECIMAL_PLACES) . "\n" . TABLE_HEADING_POINTS_VALUE . ': ' . $currencies->format($points_pending * REDEEM_POINT_VALUE) . "\n" . EMAIL_SEPARATOR;
        }
        $can_use = "\n\n" . EMAIL_TEXT_SUCCESS_POINTS;
        $email_text = $greet  . "\n" . EMAIL_TEXT_INTRO . "\n" . EMAIL_TEXT_BALANCE_CONFIRMED . "\n" . $details . "\n" . $customer_balance  . $points_expire_date . "\n\n" . sprintf(EMAIL_TEXT_POINTS_URL, tep_catalog_href_link(FILENAME_CATALOG_MY_POINTS, '', 'SSL')) . "\n\n" . sprintf(EMAIL_TEXT_POINTS_URL_HELP, tep_catalog_href_link(FILENAME_CATALOG_MY_POINTS_HELP, '', 'NONSSL')) . $can_use . "\n" . EMAIL_CONTACT . "\n" . EMAIL_SEPARATOR . "\n" . '<b>' . STORE_NAME . '</b>.' . "\n";
  }
  tep_mail($name, $customers_email_address, MakeUTF(EMAIL_TEXT_SUBJECT), $email_text, MakeUTF(STORE_NAME), STORE_OWNER_EMAIL_ADDRESS);
}


// ******************************************************************************************
// ZMIANA STATUSU REKLAMACJI
//******************************************************************************************
function mail_ticket($custom_name,$custom_email,$oID,$notify_comments,$enquiry) {
  $temat = MakeUTF(TICKET_EMAIL_SUBJECT) . ' - ' . $oID;
  $owner = MakeUTF(STORE_NAME);
  // GENEROWANIE TRESCI MAILA
  if (EMAIL_USE_HTML == 'true') {
        $email_text = '
        <table border="0" cellspacing="0" cellpadding="10" width="100%">
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:14px;color:#4f7d13"><b>'.TICKET_EMAIL_SUBJECT.' : <b>'.$oID.'</b></td></tr>
        </table>';
        // komentarz do zamowienia
        if ($notify_comments != '') {
            $email_text .= '<table border="0" cellspacing="0" cellpadding="10" width="100%">';
            $email_text .= '<tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">';
            $email_text .= '<table cellspacing="0" cellpadding="5" style="background-color:#f0f0f0;border:1px;border-style:solid;border-color:#868785">
                                <tr><td align="left" style="font-family:Tahoma,Arial;font-size:14px;color:#474747">'.str_replace("\n","<br>",$notify_comments).'</td></tr>
                            </table>';
            $email_text .= '</td></tr></table>';
        }
        $email_text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\">\\0</a>", $email_text);
        $email_text .= '
        <table border="0" cellspacing="0" cellpadding="10" width="100%">
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:12px;color:#474747">'.str_replace("\n","<br>",TEXT_REPLY).'</td></tr>
            <tr><td align="left" style="font-family:Tahoma,Arial;font-size:11px;color:#474747">'.str_replace("\n","<br>",$enquiry).'</td></tr>
        </table>
        <table border="0" cellspacing="0" cellpadding="8" width="100%">
         <tr><td align="left">
            <table cellspacing="0" cellpadding="2" border="0" width="100%">
                <tr><td align="left"><hr></td></tr>
                <tr><td align="left" style="font-family:Tahoma,Arial;font-size:11px;color:#6e6e6e">'.EMAIL_TEXT_PZDR.'<br>'.STORE_NAME . '<br><a href="' . HTTP_SERVER  . DIR_WS_CATALOG .'">' .  HTTP_SERVER  . DIR_WS_CATALOG . '</a>' . '</td></tr>
            </table>
        </td></tr>
        </table>';
        $ArrayLNTargets = array("\r\n", "\n\r", "\n", "\r", "\t");
        $email_text = str_replace($ArrayLNTargets, '', $email_text);
     } else {
        $email_text = TICKET_EMAIL_MESAGE_HEADER . "\n" . tep_catalog_href_link(FILENAME_TICKET_VIEW, 'tlid=' . $ticket_update['ticket_link_id'],'NONSSL',false,false) . "\n" . TICKET_EMAIL_MESAGE_FOOTER;

  }
  tep_mail($custom_name, $custom_email , $temat, $email_text, $owner, STORE_OWNER_EMAIL_ADDRESS);
}



?>