Execute("SELECT customers_firstname, customers_lastname, customers_email_address FROM" . $oostable['customers']); $mail_sent_to = TEXT_ALL_CUSTOMERS; break; /* ToDo Newsletter case '**D': $mail_result = $dbconn->Execute("SELECT customers_firstname, customers_lastname, customers_email_address FROM " . $oostable['customers'] . " WHERE customers_newsletter = '1'"); $mail_sent_to = TEXT_NEWSLETTER_CUSTOMERS; break; */ default: $customers_email_address = oos_db_prepare_input($_POST['customers_email_address']); $mail_result = $dbconn->Execute("SELECT customers_firstname, customers_lastname, customers_email_address FROM " . $oostable['customers'] . " WHERE customers_email_address = '" . oos_db_input($customers_email_address) . "'"); $mail_sent_to = oos_db_prepare_input($_POST['customers_email_address']); break; } $coupon_result = $dbconn->Execute("SELECT coupon_code FROM " . $oostable['coupons'] . " WHERE coupon_id = '" . intval($_GET['cID']) . "'"); $coupon_result = $coupon_result->fields; $coupon_name_result = $dbconn->Execute("SELECT coupon_name FROM " . $oostable['coupons_description'] . " WHERE coupon_id = '" . intval($_GET['cID']) . "' AND coupon_languages_id = '" . intval($_SESSION['language_id']) . "'"); $coupon_name = $coupon_name_result->fields; // Instantiate a new mail object $send_mail = new PHPMailer(); // $send_mail->PluginDir = OOS_ABSOLUTE_PATH . 'includes/lib/phpmailer/'; $sLang = (isset($_SESSION['iso_639_1']) ? $_SESSION['iso_639_1'] : 'en'); // $send_mail->SetLanguage( $sLang, OOS_ABSOLUTE_PATH . 'includes/lib/phpmailer/language/' ); $send_mail->CharSet = CHARSET; $send_mail->IsMail(); $send_mail->From = $from_mail ? $from_mail : STORE_OWNER_EMAIL_ADDRESS; $send_mail->FromName = $from_name ? $from_name : STORE_OWNER; $send_mail->Mailer = EMAIL_TRANSPORT; // Add smtp values if needed if ( EMAIL_TRANSPORT == 'smtp' ) { $send_mail->IsSMTP(); // set mailer to use SMTP $send_mail->SMTPAuth = OOS_SMTPAUTH; // turn on SMTP authentication $send_mail->Username = OOS_SMTPUSER; // SMTP username $send_mail->Password = OOS_SMTPPASS; // SMTP password $send_mail->Host = OOS_SMTPHOST; // specify main and backup server } else // Set sendmail path if ( EMAIL_TRANSPORT == 'sendmail' ) { if (!oos_empty(OOS_SENDMAIL)) { $send_mail->Sendmail = OOS_SENDMAIL; $send_mail->IsSendmail(); } } $send_mail->Subject = $subject; while ($mail = $mail_result->fields) { $message = $message; $message .= "\n\n" . TEXT_TO_REDEEM . "\n\n"; $message .= TEXT_VOUCHER_IS . $coupon_result['coupon_code'] . "\n\n"; $message .= TEXT_REMEMBER . "\n\n"; $message .= TEXT_VISIT . "\n\n"; $send_mail->Body = $message; $send_mail->AddAddress($mail['customers_email_address'], $mail['customers_firstname'] . ' ' . $mail['customers_lastname']); $send_mail->Send(); $send_mail->ClearAddresses(); $send_mail->ClearAttachments(); // Move that ADOdb pointer! $mail_result->MoveNext(); } oos_redirect_admin(oos_href_link_admin($aContents['coupon_admin'], 'mail_sent_to=' . urlencode($mail_sent_to))); } if ( ($action == 'preview_email') && (!$_POST['customers_email_address']) ) { $action = 'email'; $messageStack->add(ERROR_NO_CUSTOMER_SELECTED, 'error'); } if (isset($_GET['mail_sent_to'])) { $messageStack->add(sprintf(NOTICE_EMAIL_SENT_TO, $_GET['mail_sent_to']), 'notice'); } if (!empty($action)) { switch ($action) { case 'confirmdelete': $delete_result=$dbconn->Execute("UPDATE " . $oostable['coupons'] . " SET coupon_active = 'N' WHERE coupon_id='".$_GET['cID']."'"); break; case 'update': // get all HTTP_POST_VARS and validate $_POST['coupon_code'] = trim($_POST['coupon_code']); $languages = oos_get_languages(); for ($i = 0, $n = count($languages); $i < $n; $i++) { $language_id = $languages[$i]['id']; $_POST['coupon_name'][$iso_639_2] = trim($_POST['coupon_name'][$language_id]); $_POST['coupon_desc'][$iso_639_2] = trim($_POST['coupon_desc'][$language_id]); } $_POST['coupon_amount'] = trim($_POST['coupon_amount']); $update_errors = 0; if (!$_POST['coupon_name']) { $update_errors = 1; $messageStack->add(ERROR_NO_COUPON_NAME, 'error'); } if ((!$_POST['coupon_amount']) && (!$_POST['coupon_free_ship'])) { $update_errors = 1; $messageStack->add(ERROR_NO_COUPON_AMOUNT, 'error'); } if (!$_POST['coupon_code']) { $coupon_code = oos_create_coupon_code(); } if ($_POST['coupon_code']) $coupon_code = oos_db_prepare_input($_POST['coupon_code']); $query1 = $dbconn->Execute("SELECT coupon_code FROM " . $oostable['coupons'] . " WHERE coupon_code = '" . oos_db_input($coupon_code) . "'"); if ($query1->RecordCount() && $_POST['coupon_code'] && $_GET['oldaction'] != 'voucheredit') { $update_errors = 1; $messageStack->add(ERROR_COUPON_EXISTS, 'error'); } if ($update_errors != 0) { $action = 'new'; } else { $action = 'update_preview'; } break; case 'update_confirm': if ( ($_POST['back_x']) || ($_POST['back_y']) ) { $action = 'new'; } else { $coupon_type = "F"; if (substr($_POST['coupon_amount'], -1) == '%') $coupon_type='P'; if ($_POST['coupon_free_ship']) $coupon_type = 'S'; $sql_data_array = array('coupon_code' => oos_db_prepare_input($_POST['coupon_code']), 'coupon_amount' => oos_db_prepare_input($_POST['coupon_amount']), 'coupon_type' => oos_db_prepare_input($coupon_type), 'uses_per_coupon' => oos_db_prepare_input($_POST['coupon_uses_coupon']), 'uses_per_user' => oos_db_prepare_input($_POST['coupon_uses_user']), 'coupon_minimum_order' => oos_db_prepare_input($_POST['coupon_min_order']), 'restrict_to_products' => oos_db_prepare_input($_POST['coupon_products']), 'restrict_to_categories' => oos_db_prepare_input($_POST['coupon_categories']), 'coupon_start_date' => $_POST['coupon_startdate'], 'coupon_expire_date' => $_POST['coupon_finishdate'], 'date_created' => 'now()', 'date_modified' => 'now()'); $languages = oos_get_languages(); for ($i = 0, $n = count($languages); $i < $n; $i++) { $language_id = $languages[$i]['id']; $sql_data_marray[$i] = array('coupon_name' => oos_db_prepare_input($_POST['coupon_name'][$language_id]), 'coupon_description' => oos_db_prepare_input($_POST['coupon_desc'][$language_id]) ); } if (isset($_GET['oldaction']) && ($_GET['oldaction'] == 'voucheredit')) { oos_db_perform($oostable['coupons'], $sql_data_array, 'UPDATE', "coupon_id='" . intval($_GET['cID']) . "'"); for ($i = 0, $n = count($languages); $i < $n; $i++) { $language_id = $languages[$i]['id']; $update = $dbconn->Execute("UPDATE " . $oostable['coupons_description'] . " SET coupon_name = '" . oos_db_prepare_input($_POST['coupon_name'][$language_id]) . "', coupon_description = '" . oos_db_prepare_input($_POST['coupon_desc'][$language_id]) . "' WHERE coupon_id = '" . intval($_GET['cID']) . "' and coupon_languages_id = '" . intval($language_id) . "'"); } } else { $query = oos_db_perform($oostable['coupons'], $sql_data_array); $insert_id = $dbconn->Insert_ID(); for ($i = 0, $n = count($languages); $i < $n; $i++) { $language_id = $languages[$i]['id']; $sql_data_marray[$i]['coupon_id'] = $insert_id; $sql_data_marray[$i]['coupon_languages_id'] = $language_id; oos_db_perform($oostable['coupons_description'], $sql_data_marray[$i]); } } } } } require 'includes/header.php'; ?>

Execute("SELECT coupon_name FROM " . $oostable['coupons_description'] . " WHERE coupon_id = '" . intval($_GET['cID']) . "' AND coupon_languages_id = '" . intval($_SESSION['language_id']) . "'"); $coupon_desc = $coupon_description_result->fields; $count_customers = $dbconn->Execute("SELECT * FROM " . $oostable['coupon_redeem_track'] . " WHERE coupon_id = '" . intval($_GET['cID']) . "' AND customer_id = '" . $cInfo->customer_id . "'"); $heading[] = array('text' => '[' . $_GET['cID'] . ']' . COUPON_NAME . ' ' . $coupon_desc['coupon_name'] . ''); $contents[] = array('text' => '' . TEXT_REDEMPTIONS . ''); # $contents[] = array('text' => TEXT_REDEMPTIONS_TOTAL . '=' . $cc_result->RecordCount(); # $contents[] = array('text' => TEXT_REDEMPTIONS_CUSTOMER . '=' . $count_customers->RecordCount(); $contents[] = array('text' => ''); ?> Execute("SELECT coupon_code FROM " .$oostable['coupons'] . " WHERE coupon_id = '" . intval($_GET['cID']) . "'"); $coupon_result = $coupon_result->fields; $coupon_name_result = $dbconn->Execute("SELECT coupon_name FROM " . $oostable['coupons_description'] . " WHERE coupon_id = '" . intval($_GET['cID']) . "' AND coupon_languages_id = '" . intval($_SESSION['language_id']) . "'"); $coupon_name = $coupon_name_result->fields; switch ($_POST['customers_email_address']) { case '***': $mail_sent_to = TEXT_ALL_CUSTOMERS; break; case '**D': $mail_sent_to = TEXT_NEWSLETTER_CUSTOMERS; break; default: $mail_sent_to = oos_db_prepare_input($_POST['customers_email_address']); break; } ?>

Execute($cc_result_raw); while ($cc_list = $cc_result->fields) { $rows++; if (strlen($rows) < 2) { $rows = '0' . $rows; } if ((!isset($_GET['uid']) || (isset($_GET['uid']) && ($_GET['uid'] == $cc_list['unique_id']))) && !isset($cInfo)) { $cInfo = new objectInfo($cc_list); } if (isset($cInfo) && is_object($cInfo) && ($cc_list['unique_id'] == $cInfo->unique_id) ) { echo ' ' . "\n"; } else { echo ' ' . "\n"; } $customer_result = $dbconn->Execute("SELECT customers_firstname, customers_lastname FROM " . $oostable['customers'] . " WHERE customers_id = '" . $cc_list['customer_id'] . "'"); $customer = $customer_result->fields; ?> MoveNext(); } ?>
 
unique_id) ) { echo ''; } else { echo ''; } ?> 
infoBox($heading, $contents); ?>
Execute("SELECT coupon_code FROM " . $oostable['coupons'] . " WHERE coupon_id = '" . intval($_GET['cID']) . "'"); $coupon_result = $coupon_result->fields; $coupon_name_result = $dbconn->Execute("SELECT coupon_name FROM " . $oostable['coupons_description'] . " WHERE coupon_id = '" . intval($_GET['cID']) . "' AND coupon_languages_id = '" . intval($_SESSION['language_id']) . "'"); $coupon_name = $coupon_name_result->fields; ?>







$value) { if (!is_array($_POST[$key])) { echo oos_draw_hidden_field($key, htmlspecialchars(stripslashes($value))); } } ?>
  ' . BUTTON_CANCEL . '' . oos_submit_button(IMAGE_SEND_EMAIL); ?>

'', 'text' => TEXT_SELECT_CUSTOMER); $customers[] = array('id' => '***', 'text' => TEXT_ALL_CUSTOMERS); $customers[] = array('id' => '**D', 'text' => TEXT_NEWSLETTER_CUSTOMERS); $mail_result = $dbconn->Execute("SELECT customers_email_address, customers_firstname, customers_lastname FROM " . $oostable['customers'] . " ORDER BY customers_lastname"); while($customers_values = $mail_result->fields) { $customers[] = array('id' => $customers_values['customers_email_address'], 'text' => $customers_values['customers_lastname'] . ', ' . $customers_values['customers_firstname'] . ' (' . $customers_values['customers_email_address'] . ')'); // Move that ADOdb pointer! $mail_result->MoveNext(); } ?>
  
  
  
  
Execute("SELECT coupon_name,coupon_description FROM " . $oostable['coupons_description'] . " WHERE coupon_id = '" . $_GET['cID'] . "' AND coupon_languages_id = '" . intval($language_id) . "'"); $coupon = $coupon_result->fields; $coupon_name[$language_id] = $coupon['coupon_name']; $coupon_desc[$language_id] = $coupon['coupon_description']; } $coupon_result = $dbconn->Execute("SELECT coupon_code, coupon_amount, coupon_type, coupon_minimum_order, coupon_start_date, coupon_expire_date, uses_per_coupon, uses_per_user, restrict_to_products, restrict_to_categories FROM " . $oostable['coupons'] . " WHERE coupon_id = '" . intval($_GET['cID']) . "'"); $coupon = $coupon_result->fields; $coupon_amount = $coupon['coupon_amount']; if ($coupon['coupon_type']=='P') { $coupon_amount .= '%'; } if ($coupon['coupon_type']=='S') { $coupon_free_ship .= true; } $coupon_min_order = $coupon['coupon_minimum_order']; $coupon_code = $coupon['coupon_code']; $coupon_uses_coupon = $coupon['uses_per_coupon']; $coupon_uses_user = $coupon['uses_per_user']; $coupon_products = $coupon['restrict_to_products']; $coupon_categories = $coupon['restrict_to_categories']; case 'new': // set some defaults if (!$coupon_uses_user) $coupon_uses_user=1; ?>

" TARGET="_blank" ONCLICK="window.open('', 'Valid_Products', 'scrollbars=yes,resizable=yes,menubar=yes,width=600,height=600'); return false">View
" TARGET="_blank" ONCLICK="window.open('', 'Valid_Categories', 'scrollbars=yes,resizable=yes,menubar=yes,width=600,height=600'); return false">View
' . BUTTON_CANCEL . ''; ?>

'Y', 'text' => TEXT_COUPON_ACTIVE); $status_array[] = array('id' => 'N', 'text' => TEXT_COUPON_INACTIVE); $status_array[] = array('id' => '*', 'text' => TEXT_COUPON_ALL); if (isset($_GET['status'])) { $status = oos_db_prepare_input($_GET['status']); } else { $status = 'Y'; } echo HEADING_TITLE_STATUS . ' ' . oos_draw_pull_down_menu('status', $status_array, $status, 'onChange="this.form.submit();"'); ?>
'' . TEXT_HEADING_COUPON_REPORT . ''); $contents[] = array('text' => TEXT_NEW_INTRO); break; case 'neww': $heading[] = array('text' => '' . TEXT_HEADING_NEW_COUPON . ''); $contents[] = array('text' => TEXT_NEW_INTRO); $contents[] = array('text' => '
' . COUPON_NAME . '
' . oos_draw_input_field('name')); $contents[] = array('text' => '
' . COUPON_AMOUNT . '
' . oos_draw_input_field('voucher_amount')); $contents[] = array('text' => '
' . COUPON_CODE . '
' . oos_draw_input_field('voucher_code')); $contents[] = array('text' => '
' . COUPON_USES_COUPON . '
' . oos_draw_input_field('voucher_number_of')); break; default: $heading[] = array('text'=>'['.$cInfo->coupon_id.'] '.$cInfo->coupon_code); $amount = $cInfo->coupon_amount; if ($cInfo->coupon_type == 'P') { $amount .= '%'; } else { $amount = $currencies->format($amount); } if ($action == 'voucherdelete') { $contents[] = array('text'=> TEXT_CONFIRM_DELETE . '

' . '' . oos_button('Confirm Delete Voucher') . '' . '' . BUTTON_CANCEL . '' ); } else { $prod_details = ''; if ($cInfo->restrict_to_products) { $prod_details = 'View'; } $cat_details = ''; if ($cInfo->restrict_to_categories) { $cat_details = 'View'; } $coupon_name_result = $dbconn->Execute("SELECT coupon_name FROM " . $oostable['coupons_description'] . " WHERE coupon_id = '" . $cInfo->coupon_id . "' AND coupon_languages_id = '" . intval($_SESSION['language_id']) . "'"); $coupon_name = $coupon_name_result->fields; $contents[] = array('text'=>COUPON_NAME . ': ' . $coupon_name['coupon_name'] . '
' . COUPON_AMOUNT . ': ' . $amount . '
' . COUPON_STARTDATE . ': ' . oos_date_short($cInfo->coupon_start_date) . '
' . COUPON_FINISHDATE . ': ' . oos_date_short($cInfo->coupon_expire_date) . '
' . COUPON_USES_COUPON . ': ' . $cInfo->uses_per_coupon . '
' . COUPON_USES_USER . ': ' . $cInfo->uses_per_user . '
' . COUPON_PRODUCTS . ': ' . $prod_details . '
' . COUPON_CATEGORIES . ': ' . $cat_details . '
' . DATE_CREATED . ': ' . oos_date_short($cInfo->date_created) . '
' . DATE_MODIFIED . ': ' . oos_date_short($cInfo->date_modified) . '

' . '
'.oos_button('Email Voucher').'' . ''.oos_button('Edit Voucher').'' . ''.oos_button('Delete Voucher').'' . '
'.oos_button('Voucher Report').'
' ); } break; } ?>
1)) $rows = $nPage * 20 - 20; if ($status != '*') { $cc_result_raw = "SELECT coupon_id, coupon_code, coupon_amount, coupon_type, coupon_start_date, coupon_expire_date, uses_per_user, uses_per_coupon, restrict_to_products, restrict_to_categories, date_created,date_modified FROM " . $oostable['coupons'] ." WHERE coupon_active='" . oos_db_input($status) . "' AND coupon_type != 'G'"; } else { $cc_result_raw = "SELECT coupon_id, coupon_code, coupon_amount, coupon_type, coupon_start_date, coupon_expire_date, uses_per_user, uses_per_coupon, restrict_to_products, restrict_to_categories, date_created,date_modified FROM " . $oostable['coupons'] . " WHERE coupon_type != 'G'"; } $cc_split = new splitPageResults($nPage, MAX_DISPLAY_SEARCH_RESULTS, $cc_result_raw, $cc_result_numrows); $cc_result = $dbconn->Execute($cc_result_raw); while ($cc_list = $cc_result->fields) { $rows++; if (strlen($rows) < 2) { $rows = '0' . $rows; } if ((!isset($_GET['cID']) || (isset($_GET['cID']) && ($_GET['cID'] == $cc_list['coupon_id']))) && !isset($cInfo)) { $cInfo = new objectInfo($cc_list); } if (isset($cInfo) && is_object($cInfo) && ($cc_list['coupon_id'] == $cInfo->coupon_id) ) { echo ' ' . "\n"; } else { echo ' ' . "\n"; } $coupon_description_result = $dbconn->Execute("SELECT coupon_name FROM " . $oostable['coupons_description'] . " WHERE coupon_id = '" . $cc_list['coupon_id'] . "' AND coupon_languages_id = '" . intval($_SESSION['language_id']) . "'"); $coupon_desc = $coupon_description_result->fields; ?> MoveNext(); } ?>
 
format($cc_list['coupon_amount']); } ?>   coupon_id) ) { echo ''; } else { echo ''; } ?> 
 display_count($cc_result_numrows, MAX_DISPLAY_SEARCH_RESULTS, $nPage, TEXT_DISPLAY_NUMBER_OF_COUPONS); ?>   display_links($cc_result_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $nPage); ?> 
coupon_id . '&action=new') . '">' . oos_button(BUTTON_INSERT) . ''; ?>
infoBox($heading, $contents); ?>