function getChangeVoucherHTML($_vouchers)
{
    global $VOUCHER;
    $voucherHTML = getFile(PATH_TEMPLATES . "chat_voucher_change_item.tpl");
    $tableHTML = getFile(PATH_TEMPLATES . "chat_voucher_change_table.tpl");
    $vouchersHTML = "";
    foreach ($_vouchers as $voucher) {
        $vouchersHTML .= $voucherHTML;
        $vouchersHTML = str_replace("<!--id-->", $voucher->Id == $VOUCHER->Id ? "<b>" . $voucher->Id . "</b>" : $voucher->Id, $vouchersHTML);
        $vouchersHTML = str_replace("<!--selected-->", $voucher->Id == $VOUCHER->Id ? "CHECKED" : "", $vouchersHTML);
        if ($voucher->ChatSessionsMax > -1) {
            $vouchersHTML = str_replace("<!--sessions-->", $voucher->ChatSessions . " / " . $voucher->ChatSessionsMax, $vouchersHTML);
        } else {
            $vouchersHTML = str_replace("<!--display_sessions-->", "none", $vouchersHTML);
        }
        if ($voucher->ChatTimeMax > -1) {
            $vouchersHTML = str_replace("<!--time-->", formatTimeSpan($voucher->ChatTimeRemaining), $vouchersHTML);
        } else {
            $vouchersHTML = str_replace("<!--display_time-->", "none", $vouchersHTML);
        }
        if ($voucher->VoucherAutoExpire > -1) {
            $parts = explode(date("Y", $voucher->VoucherAutoExpire), date("r", $voucher->VoucherAutoExpire));
            $vouchersHTML = str_replace("<!--expires-->", $parts[0] . date("Y", $voucher->VoucherAutoExpire), $vouchersHTML);
        } else {
            $vouchersHTML = str_replace("<!--display_expires-->", "none", $vouchersHTML);
        }
        if ($voucher->ChatSessionsMax - $voucher->ChatSessions > 0) {
            $vouchersHTML = str_replace("<!--class_sessions-->", "lz_chat_com_chat_panel_value", $vouchersHTML);
        } else {
            if ($voucher->ChatSessionsMax - $voucher->ChatSessions <= 0) {
                $vouchersHTML = str_replace("<!--class_sessions-->", "lz_chat_com_chat_panel_value_over", $vouchersHTML);
            }
        }
        if ($voucher->ChatTimeRemaining > 0) {
            $vouchersHTML = str_replace("<!--class_time-->", "lz_chat_com_chat_panel_value", $vouchersHTML);
        } else {
            if ($voucher->ChatTimeRemaining <= 0) {
                $vouchersHTML = str_replace("<!--class_time-->", "lz_chat_com_chat_panel_value_over", $vouchersHTML);
            }
        }
        if ($voucher->VoucherAutoExpire > time()) {
            $vouchersHTML = str_replace("<!--class_expires-->", "lz_chat_com_chat_panel_value", $vouchersHTML);
        } else {
            if ($voucher->VoucherAutoExpire > 0) {
                $vouchersHTML = str_replace("<!--class_expires-->", "lz_chat_com_chat_panel_value_over", $vouchersHTML);
            }
        }
        $vouchersHTML = str_replace("<!--display_sessions-->", "''", $vouchersHTML);
        $vouchersHTML = str_replace("<!--display_time-->", "''", $vouchersHTML);
        $vouchersHTML = str_replace("<!--display_expires-->", "''", $vouchersHTML);
    }
    $tableHTML = str_replace("<!--vouchers-->", $vouchersHTML, $tableHTML);
    $tableHTML = str_replace("<!--server-->", LIVEZILLA_URL, $tableHTML);
    $tableHTML = str_replace("<!--vouchers-->", $vouchersHTML, $tableHTML);
    return applyReplacements($tableHTML, true, false);
}
예제 #2
0
 function SendStatusEmail()
 {
     global $CONFIG, $LZLANG;
     if (!empty($CONFIG["db"]["cct"][$this->TypeId])) {
         $loc = $CONFIG["db"]["cct"][$this->TypeId]->GetLocalization($this->Language);
         if ($loc != null && !empty($loc->EmailVoucherUpdate)) {
             $email = $loc->EmailVoucherUpdate;
             $email = str_replace("%buyer_first_name%", $this->Firstname, $email);
             $email = str_replace("%buyer_last_name%", $this->Lastname, $email);
             $email = str_replace("%voucher_code%", $this->Id, $email);
             $email = str_replace("%voucher_remaining_time%", $this->ChatTimeRemaining == -1 ? "-" : ($this->ChatTimeRemaining >= 0 ? formatTimeSpan($this->ChatTimeRemaining) : formatTimeSpan(0)), $email);
             $email = str_replace("%voucher_remaining_sessions%", $this->ChatSessionsMax == -1 ? "-" : ($this->ChatSessionsMax - $this->ChatSessions >= 0 ? $this->ChatSessionsMax - $this->ChatSessions : 0), $email);
             $email = str_replace("%voucher_expiration_date%", $this->VoucherAutoExpire == -1 ? "-" : date("r", $this->VoucherAutoExpire), $email);
             $email = str_replace("%website_name%", $CONFIG["gl_site_name"], $email);
             $defmailbox = Mailbox::GetDefaultOutgoing();
             if ($defmailbox != null) {
                 sendMail($defmailbox, $this->Email, $defmailbox->Email, $email, $LZLANG["client_voucher_email_subject_status_update"]);
             }
         }
     }
 }