ZenCart_Documentation  1.5.0
http://www.collinsharper.com
C:/xampp/htdocs/zen-cart/admin/coupon_admin.php
Go to the documentation of this file.
00001 <?php
00009   require('includes/application_top.php');
00010   require(DIR_WS_CLASSES . 'currencies.php');
00011   $currencies = new currencies();
00012   if ($_GET['selected_box']) {
00013     $_GET['action']='';
00014     $_GET['old_action']='';
00015   }
00016 
00017   if (isset($_GET['cid'])) $_GET['cid'] = (int)$_GET['cid'];
00018 
00019   if (($_GET['action'] == 'send_email_to_user') && ($_POST['customers_email_address']) && (!$_POST['back_x'])) {
00020     $audience_select = get_audience_sql_query($_POST['customers_email_address'], 'email');
00021     $mail = $db->Execute($audience_select['query_string']);
00022     $mail_sent_to = $audience_select['query_name'];
00023     if ($_POST['email_to']) {
00024       $mail_sent_to = $_POST['email_to'];
00025     }
00026 
00027     $coupon_result = $db->Execute("select coupon_code, coupon_start_date, coupon_expire_date
00028                                    from " . TABLE_COUPONS . "
00029                                    where coupon_id = '" . $_GET['cid'] . "'");
00030 
00031     $coupon_name = $db->Execute("select coupon_name, coupon_description
00032                                  from " . TABLE_COUPONS_DESCRIPTION . "
00033                                  where coupon_id = '" . $_GET['cid'] . "'
00034                                  and language_id = '" . (int)$_SESSION['languages_id'] . "'");
00035 
00036     // demo active test
00037     if (zen_admin_demo()) {
00038       $_GET['action']= '';
00039       $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
00040       zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN, 'mail_sent_to=' . urlencode($mail_sent_to)));
00041     }
00042     $from = zen_db_prepare_input($_POST['from']);
00043     $subject = zen_db_prepare_input($_POST['subject']);
00044     $recip_count=0;
00045     $text_coupon_help = sprintf(TEXT_COUPON_HELP_DATE, zen_date_short($coupon_result->fields['coupon_start_date']), zen_date_short($coupon_result->fields['coupon_expire_date']));
00046     $html_coupon_help = sprintf(HTML_COUPON_HELP_DATE, zen_date_short($coupon_result->fields['coupon_start_date']), zen_date_short($coupon_result->fields['coupon_expire_date']));
00047 
00048     while (!$mail->EOF) {
00049       $message = zen_db_prepare_input($_POST['message']);
00050       $message .= "\n\n" . TEXT_TO_REDEEM . "\n\n";
00051       $message .= TEXT_VOUCHER_IS . $coupon_result->fields['coupon_code'] . "\n\n";
00052       $message .= $text_coupon_help . "\n\n";
00053       $message .= TEXT_REMEMBER . "\n\n";
00054       $message .=(!empty($coupon_name->fields['coupon_description']) ? $coupon_name->fields['coupon_description'] . "\n\n" : '');
00055       $message .= sprintf(TEXT_VISIT ,HTTP_CATALOG_SERVER . DIR_WS_CATALOG);
00056 
00057       // disclaimer
00058       $message .= "\n-----\n" . sprintf(EMAIL_DISCLAIMER, STORE_OWNER_EMAIL_ADDRESS) . "\n\n";
00059 
00060       $html_msg['EMAIL_FIRST_NAME'] = $mail->fields['customers_firstname'];
00061       $html_msg['EMAIL_LAST_NAME']  = $mail->fields['customers_lastname'];
00062       $html_msg['EMAIL_MESSAGE_HTML'] = zen_db_prepare_input($_POST['message_html']);
00063       $html_msg['COUPON_TEXT_TO_REDEEM'] = TEXT_TO_REDEEM;
00064       $html_msg['COUPON_TEXT_VOUCHER_IS'] = TEXT_VOUCHER_IS;
00065       $html_msg['COUPON_CODE'] = $coupon_result->fields['coupon_code'] . $html_coupon_help;
00066       $html_msg['COUPON_DESCRIPTION'] =(!empty($coupon_name->fields['coupon_description']) ? $coupon_name->fields['coupon_description'] : '');
00067       $html_msg['COUPON_TEXT_REMEMBER']  = TEXT_REMEMBER;
00068       $html_msg['COUPON_REDEEM_STORENAME_URL'] = sprintf(TEXT_VISIT ,'<a href="'.HTTP_CATALOG_SERVER . DIR_WS_CATALOG.'">'.STORE_NAME.'</a>');
00069 
00070 //Send the emails
00071       zen_mail($mail->fields['customers_firstname'] . ' ' . $mail->fields['customers_lastname'], $mail->fields['customers_email_address'], $subject , $message, '',$from, $html_msg, 'coupon');
00072 
00073       $recip_count++;
00074       // send copy to Admin if enabled
00075       if (SEND_EXTRA_DISCOUNT_COUPON_ADMIN_EMAILS_TO_STATUS== '1' and SEND_EXTRA_DISCOUNT_COUPON_ADMIN_EMAILS_TO != '') {
00076         zen_mail('', SEND_EXTRA_DISCOUNT_COUPON_ADMIN_EMAILS_TO, SEND_EXTRA_DISCOUNT_COUPON_ADMIN_EMAILS_TO_SUBJECT . ' ' . $subject , $message, '',$from, $html_msg, 'coupon_extra');
00077       }
00078       $mail->MoveNext();
00079     }
00080     zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN, 'mail_sent_to=' . urlencode($mail_sent_to) . '&recip_count='. $recip_count ));
00081   }
00082 
00083   if ( ($_GET['action'] == 'preview_email') && (!$_POST['customers_email_address']) ) {
00084     $_GET['action'] = 'email';
00085     $messageStack->add(ERROR_NO_CUSTOMER_SELECTED, 'error');
00086   }
00087 
00088   if ($_GET['mail_sent_to']) {
00089     $messageStack->add(sprintf(NOTICE_EMAIL_SENT_TO, $_GET['mail_sent_to']. '(' . $_GET['recip_count'] . ')'), 'success');
00090     $_GET['mail_sent_to'] = '';
00091   }
00092 
00093   switch ($_GET['action']) {
00094       case 'set_editor':
00095         // Reset will be done by init_html_editor.php. Now we simply redirect to refresh page properly.
00096         $action='';
00097         zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN));
00098         break;
00099     case 'confirmdelete':
00100       // demo active test
00101       if (zen_admin_demo()) {
00102         $_GET['action']= '';
00103         $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
00104         zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN));
00105       }
00106 
00107 // do not allow change if set to welcome coupon
00108       if ($_GET['cid'] == NEW_SIGNUP_DISCOUNT_COUPON) {
00109         $messageStack->add_session(ERROR_DISCOUNT_COUPON_WELCOME, 'caution');
00110         zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN, 'cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
00111       }
00112 
00113       $db->Execute("update " . TABLE_COUPONS . "
00114                     set coupon_active = 'N'
00115                     where coupon_id='".$_GET['cid']."'");
00116       $messageStack->add_session(SUCCESS_COUPON_DISABLED, 'success');
00117       zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN));
00118       break;
00119     case 'confirmcopy':
00120       $coupon_copy_to = trim($_POST['coupon_copy_to']);
00121 
00122       // check if new coupon code exists
00123       $sql = "SELECT * from " . TABLE_COUPONS . " where coupon_code = :coupon_copy:";
00124       $sql = $db->bindVars($sql, ':coupon_copy:', $coupon_copy_to, 'string');
00125       $check_new_coupon = $db->Execute($sql);
00126       if ($check_new_coupon->RecordCount() > 0) {
00127         $messageStack->add_session(ERROR_DISCOUNT_COUPON_DUPLICATE . $coupon_copy_to, 'caution');
00128         zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN, 'cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
00129       }
00130 
00131       $sql = "SELECT * from " . TABLE_COUPONS . " where coupon_id='" . $_GET['cid'] . "'";
00132       $check_new_coupon = $db->Execute($sql);
00133 
00134       // create duplicate coupon
00135         $sql_data_array = array('coupon_code' => zen_db_prepare_input($coupon_copy_to),
00136                                 'coupon_amount' => zen_db_prepare_input($check_new_coupon->fields['coupon_amount']),
00137                                 'coupon_type' => zen_db_prepare_input($check_new_coupon->fields['coupon_type']),
00138                                 'uses_per_coupon' => zen_db_prepare_input((int)$check_new_coupon->fields['uses_per_coupon']),
00139                                 'uses_per_user' => zen_db_prepare_input((int)$check_new_coupon->fields['uses_per_user']),
00140                                 'coupon_minimum_order' => zen_db_prepare_input((float)$check_new_coupon->fields['coupon_minimum_order']),
00141                                 'restrict_to_products' => zen_db_prepare_input($check_new_coupon->fields['restrict_to_products']),
00142                                 'restrict_to_categories' => zen_db_prepare_input($check_new_coupon->fields['restrict_to_categories']),
00143                                 'coupon_start_date' => $check_new_coupon->fields['coupon_start_date'],
00144                                 'coupon_expire_date' => $check_new_coupon->fields['coupon_expire_date'],
00145                                 'date_created' => 'now()',
00146                                 'date_modified' => 'now()',
00147                                 'coupon_zone_restriction' => $check_new_coupon->fields['coupon_zone_restriction']);
00148 
00149           zen_db_perform(TABLE_COUPONS, $sql_data_array);
00150           $insert_id = $db->Insert_ID();
00151           $cid = $insert_id;
00152 //          $_GET['cid'] = $cid;
00153 
00154           // create duplicate coupon description
00155           $sql = "SELECT * from " . TABLE_COUPONS_DESCRIPTION . " where coupon_id='" . $_GET['cid'] . "'";
00156           $new_coupon_descriptions = $db->Execute($sql);
00157 
00158           while (!$new_coupon_descriptions->EOF) {
00159             $sql_mdata_array = array('coupon_id' => zen_db_prepare_input($cid),
00160                                     'language_id' => zen_db_prepare_input($new_coupon_descriptions->fields['language_id']),
00161                                     'coupon_name' => zen_db_prepare_input('COPY: ' . $new_coupon_descriptions->fields['coupon_name']),
00162                                     'coupon_description' => zen_db_prepare_input($new_coupon_descriptions->fields['coupon_description'])
00163                                     );
00164             zen_db_perform(TABLE_COUPONS_DESCRIPTION, $sql_mdata_array);
00165             $new_coupon_descriptions->MoveNext();
00166           }
00167 
00168       // copy restrictions
00169       $sql = "SELECT * from " . TABLE_COUPON_RESTRICT . " where coupon_id='" . $_GET['cid'] . "'";
00170       $copy_coupon_restrictions = $db->Execute($sql);
00171 
00172       while (!$copy_coupon_restrictions->EOF) {
00173         $sql_rdata_array = array('coupon_id' => zen_db_prepare_input($cid),
00174                                  'product_id' => zen_db_prepare_input($copy_coupon_restrictions->fields['product_id']),
00175                                  'category_id' => zen_db_prepare_input($copy_coupon_restrictions->fields['category_id']),
00176                                  'coupon_restrict' => zen_db_prepare_input($copy_coupon_restrictions->fields['coupon_restrict'])
00177                                  );
00178         zen_db_perform(TABLE_COUPON_RESTRICT, $sql_rdata_array);
00179         $copy_coupon_restrictions->MoveNext();
00180       }
00181 
00182       $_GET['cid'] = $cid;
00183       $messageStack->add_session(SUCCESS_COUPON_DUPLICATE . $coupon_copy_to, 'success');
00184       zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN, 'action=voucheredit' . '&cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '')));
00185 //        zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN));
00186       break;
00187     case 'update':
00188       $update_errors = 0;
00189       // get all HTTP_POST_VARS and validate
00190       $_POST['coupon_code'] = trim($_POST['coupon_code']);
00191         $languages = zen_get_languages();
00192         for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
00193           $language_id = $languages[$i]['id'];
00194           $_POST['coupon_name'][$language_id] = trim($_POST['coupon_name'][$language_id]);
00195           if (!$_POST['coupon_name'][$language_id]) {
00196             $update_errors = 1;
00197             $messageStack->add(ERROR_NO_COUPON_NAME . $languages[$i]['name'], 'error');
00198           }
00199           $_POST['coupon_desc'][$language_id] = trim($_POST['coupon_desc'][$language_id]);
00200         }
00201       $_POST['coupon_amount'] = trim($_POST['coupon_amount']);
00202       $_POST['coupon_amount'] = preg_replace('/[^0-9.%]/', '', $_POST['coupon_amount']);
00203       if (!$_POST['coupon_name']) {
00204         $update_errors = 1;
00205         $messageStack->add(ERROR_NO_COUPON_NAME, 'error');
00206       }
00207       if ((!$_POST['coupon_amount']) && (!$_POST['coupon_free_ship'])) {
00208         $update_errors = 1;
00209         $messageStack->add(ERROR_NO_COUPON_AMOUNT, 'error');
00210       }
00211       if (!$_POST['coupon_code']) {
00212         $coupon_code = create_coupon_code();
00213       }
00214       if ($_POST['coupon_code']) $coupon_code = $_POST['coupon_code'];
00215       $sql = "select coupon_code
00216                               from " . TABLE_COUPONS . "
00217                               where coupon_code = :couponCode:";
00218       $sql = $db->bindVars($sql, ':couponCode:', $coupon_code, 'string');
00219       $query1 = $db->Execute($sql);
00220       if ($query1->RecordCount()>0 && $_POST['coupon_code'] && $_GET['oldaction'] != 'voucheredit')  {
00221         $update_errors = 1;
00222         $messageStack->add(ERROR_COUPON_EXISTS, 'error');
00223       }
00224       if ($update_errors != 0) {
00225         $_GET['action'] = 'new';
00226       } else {
00227         $_GET['action'] = 'update_preview';
00228       }
00229       break;
00230     case 'update_confirm':
00231       if ( ($_POST['back_x']) || ($_POST['back_y']) ) {
00232         $_GET['action'] = 'new';
00233       } else {
00234         $coupon_type = 'F'; // amount off
00235         if ($_POST['coupon_free_ship']) $coupon_type = 'S'; // free shipping
00236         if (substr($_POST['coupon_amount'], -1) == '%') $coupon_type = 'P'; // percentage off
00237         if ($_POST['coupon_amount'] > 0 && $_POST['coupon_free_ship']) $coupon_type = 'O';  // amount off and free shipping
00238         if (substr($_POST['coupon_amount'], -1) == '%' && $_POST['coupon_free_ship']) $coupon_type = 'E'; // percentage off and free shipping
00239         $_POST['coupon_amount'] = preg_replace('/[^0-9.]/', '', $_POST['coupon_amount']);
00240         $sql_data_array = array('coupon_code' => zen_db_prepare_input($_POST['coupon_code']),
00241                                 'coupon_amount' => zen_db_prepare_input($_POST['coupon_amount']),
00242                                 'coupon_type' => zen_db_prepare_input($coupon_type),
00243                                 'uses_per_coupon' => zen_db_prepare_input((int)$_POST['coupon_uses_coupon']),
00244                                 'uses_per_user' => zen_db_prepare_input((int)$_POST['coupon_uses_user']),
00245                                 'coupon_minimum_order' => zen_db_prepare_input((float)$_POST['coupon_min_order']),
00246                                 'restrict_to_products' => zen_db_prepare_input($_POST['coupon_products']),
00247                                 'restrict_to_categories' => zen_db_prepare_input($_POST['coupon_categories']),
00248                                 'coupon_start_date' => $_POST['coupon_startdate'],
00249                                 'coupon_expire_date' => $_POST['coupon_finishdate'],
00250                                 'date_created' => 'now()',
00251                                 'date_modified' => 'now()',
00252                                 'coupon_zone_restriction' => $_POST['coupon_zone_restriction']);
00253         $languages = zen_get_languages();
00254         for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
00255           $language_id = $languages[$i]['id'];
00256           $sql_data_marray[$i] = array('coupon_name' => zen_db_prepare_input($_POST['coupon_name'][$language_id]),
00257                                        'coupon_description' => zen_db_prepare_input($_POST['coupon_desc'][$language_id])
00258                                        );
00259         }
00260         if ($_GET['oldaction']=='voucheredit') {
00261           zen_db_perform(TABLE_COUPONS, $sql_data_array, 'update', "coupon_id='" . $_GET['cid']."'");
00262           for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
00263             $language_id = $languages[$i]['id'];
00264             $sql_data_desc_array = array('coupon_name' => zen_db_prepare_input($_POST['coupon_name'][$language_id]),
00265                                          'coupon_description' => zen_db_prepare_input($_POST['coupon_desc'][$language_id])
00266                                          );
00267             zen_db_perform(TABLE_COUPONS_DESCRIPTION, $sql_data_desc_array, 'update', "coupon_id = '" . $_GET['cid'] . "' and language_id = '" . (int)$languages[$i]['id'] . "'");
00268           }
00269         } else {
00270           zen_db_perform(TABLE_COUPONS, $sql_data_array);
00271           $insert_id = $db->Insert_ID();
00272           $cid = $insert_id;
00273           $_GET['cid'] = $cid;
00274 
00275           for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
00276             $language_id = $languages[$i]['id'];
00277             $sql_data_marray[$i]['coupon_id'] = (int)$insert_id;
00278             $sql_data_marray[$i]['language_id'] = (int)$language_id;
00279             zen_db_perform(TABLE_COUPONS_DESCRIPTION, $sql_data_marray[$i]);
00280           }
00281         }
00282       }
00283       zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN, 'cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
00284   }
00285 ?>
00286 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
00287 <html <?php echo HTML_PARAMS; ?>>
00288 <head>
00289 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
00290 <title><?php echo TITLE; ?></title>
00291 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
00292 <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
00293 <script language="javascript" src="includes/menu.js"></script>
00294 <script language="javascript" src="includes/general.js"></script>
00295 <link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css">
00296 <script language="JavaScript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script>
00297 <script language="javascript">
00298   var dateAvailable = new ctlSpiffyCalendarBox("dateAvailable", "new_product", "products_date_available","btnDate1","<?php echo $pInfo->products_date_available; ?>",scBTNMODE_CUSTOMBLUE);
00299 </script>
00300 <script type="text/javascript">
00301   <!--
00302   function init()
00303   {
00304     cssjsmenu('navbar');
00305     if (document.getElementById)
00306     {
00307       var kill = document.getElementById('hoverJS');
00308       kill.disabled = true;
00309     }
00310 <?php if ($_GET['action'] == 'new' || $_GET['action'] == 'voucheredit') { ?>
00311     if (typeof _editor_url == "string") HTMLArea.replaceAll();
00312 <?php } else { ?>
00313     if (typeof _editor_url == "string") HTMLArea.replace('message_html');
00314 <?php } ?>
00315   }
00316   // -->
00317 </script>
00318 <script language="javascript" type="text/javascript"><!--
00319 var form = "";
00320 var submitted = false;
00321 var error = false;
00322 var error_message = "";
00323 
00324 function check_select(field_name, field_default, message) {
00325   if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
00326     var field_value = form.elements[field_name].value;
00327 
00328     if (field_value == field_default) {
00329       error_message = error_message + "* " + message + "\n";
00330       error = true;
00331     }
00332   }
00333 }
00334 function check_message(msg) {
00335   if (form.elements['message'] && form.elements['message_html']) {
00336     var field_value1 = form.elements['message'].value;
00337     var field_value2 = form.elements['message_html'].value;
00338 
00339     if ((field_value1 == '' || field_value1.length < 3) && (field_value2 == '' || field_value2.length < 3)) {
00340       error_message = error_message + "* " + msg + "\n";
00341       error = true;
00342     }
00343   }
00344 }
00345 function check_input(field_name, field_size, message) {
00346   if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
00347     var field_value = form.elements[field_name].value;
00348 
00349     if (field_value == '' || field_value.length < field_size) {
00350       error_message = error_message + "* " + message + "\n";
00351       error = true;
00352     }
00353   }
00354 }
00355 
00356 function check_form(form_name) {
00357   if (submitted == true) {
00358     alert("<?php echo JS_ERROR_SUBMITTED; ?>");
00359     return false;
00360   }
00361   error = false;
00362   form = form_name;
00363   error_message = "<?php echo JS_ERROR; ?>";
00364 
00365   check_select('customers_email_address', '', "<?php echo ERROR_NO_CUSTOMER_SELECTED; ?>");
00366   check_message("<?php echo ENTRY_NOTHING_TO_SEND; ?>");
00367   check_input('subject','',"<?php echo ERROR_NO_SUBJECT; ?>");
00368 
00369   if (error == true) {
00370     alert(error_message);
00371     return false;
00372   } else {
00373     submitted = true;
00374     return true;
00375   }
00376 }
00377 //--></script>
00378 <?php if ($editor_handler != '') include ($editor_handler); ?>
00379 </head>
00380 <body onLoad="init()">
00381 <div id="spiffycalendar" class="text"></div>
00382 <!-- header //-->
00383 <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
00384 <!-- header_eof //-->
00385 
00386 <!-- body //-->
00387 <table border="0" width="100%" cellspacing="2" cellpadding="2">
00388   <tr>
00389 <!-- body_text //-->
00390 <?php
00391   switch ($_GET['action']) {
00392   case 'voucherreport':
00393 ?>
00394       <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
00395       <tr>
00396         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
00397           <tr>
00398             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
00399             <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
00400           </tr>
00401         </table></td>
00402       </tr>
00403       <tr>
00404         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
00405           <tr>
00406             <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
00407               <tr class="dataTableHeadingRow">
00408                 <td class="dataTableHeadingContent"><?php echo CUSTOMER_ID; ?></td>
00409                 <td class="dataTableHeadingContent" align="center"><?php echo CUSTOMER_NAME; ?></td>
00410                 <td class="dataTableHeadingContent" align="center"><?php echo IP_ADDRESS; ?></td>
00411                 <td class="dataTableHeadingContent" align="center"><?php echo REDEEM_DATE; ?></td>
00412                 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
00413               </tr>
00414 <?php
00415     $cc_query_raw = "select * from " . TABLE_COUPON_REDEEM_TRACK . " where coupon_id = '" . $_GET['cid'] . "'";
00416     $cc_split = new splitPageResults($_GET['reports_page'], MAX_DISPLAY_SEARCH_RESULTS_DISCOUNT_COUPONS_REPORTS, $cc_query_raw, $cc_query_numrows);
00417     $cc_list = $db->Execute($cc_query_raw);
00418     while (!$cc_list->EOF) {
00419       if (((!$_GET['uid']) || (@$_GET['uid'] == $cc_list->fields['unique_id'])) && (!$cInfo)) {
00420         $cInfo = new objectInfo($cc_list->fields);
00421       }
00422       if ( (is_object($cInfo)) && ($cc_list->fields['unique_id'] == $cInfo->unique_id) ) {
00423         echo '          <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . zen_href_link(FILENAME_COUPON_ADMIN, zen_get_all_get_params(array('cid', 'action', 'uid')) . 'cid=' . $cInfo->coupon_id . '&action=voucherreport&uid=' . $cinfo->unique_id) . '\'">' . "\n";
00424       } else {
00425         echo '          <tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'hand\'" onmouseout="this.className=\'dataTableRow\'" onclick="document.location.href=\'' . zen_href_link(FILENAME_COUPON_ADMIN, zen_get_all_get_params(array('cid', 'action', 'uid')) . 'cid=' . $cc_list->fields['coupon_id'] . '&action=voucherreport&uid=' . $cc_list->fields['unique_id']) . '\'">' . "\n";
00426       }
00427 $customer = $db->Execute("select customers_firstname, customers_lastname
00428                           from " . TABLE_CUSTOMERS . "
00429                           where customers_id = '" . $cc_list->fields['customer_id'] . "'");
00430 
00431 ?>
00432                 <td class="dataTableContent"><?php echo $cc_list->fields['customer_id']; ?></td>
00433                 <td class="dataTableContent" align="center"><?php echo $customer->fields['customers_firstname'] . ' ' . $customer->fields['customers_lastname']; ?></td>
00434                 <td class="dataTableContent" align="center"><?php echo $cc_list->fields['redeem_ip']; ?></td>
00435                 <td class="dataTableContent" align="center"><?php echo zen_date_short($cc_list->fields['redeem_date']); ?></td>
00436                 <td class="dataTableContent" align="right"><?php if ( (is_object($cInfo)) && ($cc_list->fields['unique_id'] == $cInfo->unique_id) ) { echo zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '<a href="' . zen_href_link(FILENAME_COUPON_ADMIN, 'reports_page=' . $_GET['reports_page'] . '&cid=' . $cc_list->fields['coupon_id']) . '">' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
00437               </tr>
00438 <?php
00439       $cc_list->MoveNext();
00440     }
00441 ?>
00442           <tr>
00443             <td colspan="5"><table border="0" width="100%" cellspacing="0" cellpadding="2">
00444               <tr>
00445                 <td class="smallText">&nbsp;<?php echo $cc_split->display_count($cc_query_numrows, MAX_DISPLAY_SEARCH_RESULTS_DISCOUNT_COUPONS_REPORTS, $_GET['reports_page'], TEXT_DISPLAY_NUMBER_OF_COUPONS); ?>&nbsp;</td>
00446                 <td align="right" class="smallText">&nbsp;<?php echo $cc_split->display_links($cc_query_numrows, MAX_DISPLAY_SEARCH_RESULTS_DISCOUNT_COUPONS_REPORTS, MAX_DISPLAY_PAGE_LINKS, $_GET['reports_page'], 'action=voucherreport&cid=' . $cInfo->coupon_id, 'reports_page'); ?>&nbsp;</td>
00447               </tr>
00448 
00449               <tr>
00450                 <td align="right" colspan="2" class="smallText"><?php echo '<a href="' . zen_href_link(FILENAME_COUPON_ADMIN, 'page=' . $_GET['page'] . '&cid=' . (!empty($cInfo->coupon_id) ? $cInfo->coupon_id : $_GET['cid']) . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '')) . '">' . zen_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
00451               </tr>
00452             </table></td>
00453           </tr>
00454              </table></td>
00455 <?php
00456     $heading = array();
00457     $contents = array();
00458       $coupon_desc = $db->Execute("select coupon_name
00459                                    from " . TABLE_COUPONS_DESCRIPTION . "
00460                                    where coupon_id = '" . $_GET['cid'] . "'
00461                                    and language_id = '" . (int)$_SESSION['languages_id'] . "'");
00462       $count_customers = $db->Execute("select * from " . TABLE_COUPON_REDEEM_TRACK . "
00463                                        where coupon_id = '" . $_GET['cid'] . "'
00464                                        and customer_id = '" . (int)$cInfo->customer_id . "'");
00465 
00466       $heading[] = array('text' => '<b>[' . $_GET['cid'] . ']' . COUPON_NAME . ' ' . $coupon_desc->fields['coupon_name'] . '</b>');
00467       $contents[] = array('text' => '<b>' . TEXT_REDEMPTIONS . '</b>');
00468 //      $contents[] = array('text' => TEXT_REDEMPTIONS_TOTAL . '=' . $cc_list->RecordCount());
00469       $contents[] = array('text' => TEXT_REDEMPTIONS_TOTAL . '=' . $cc_query_numrows);
00470       $contents[] = array('text' => TEXT_REDEMPTIONS_CUSTOMER . '=' . $count_customers->RecordCount());
00471       $contents[] = array('text' => '');
00472 ?>
00473     <td width="25%" valign="top">
00474 <?php
00475       $box = new box;
00476       echo $box->infoBox($heading, $contents);
00477       echo '            </td>' . "\n";
00478 ?>
00479 <?php
00480     break;
00481   case 'preview_email':
00482     $coupon_result = $db->Execute("select coupon_code
00483                                    from " .TABLE_COUPONS . "
00484                                    where coupon_id = '" . $_GET['cid'] . "'");
00485 
00486     $coupon_name = $db->Execute("select coupon_name
00487                                  from " . TABLE_COUPONS_DESCRIPTION . "
00488                                  where coupon_id = '" . $_GET['cid'] . "'
00489                                  and language_id = '" . (int)$_SESSION['languages_id'] . "'");
00490 
00491     $audience_select = get_audience_sql_query($_POST['customers_email_address']);
00492     $mail_sent_to = $audience_select['query_name'];
00493 
00494 ?>
00495       <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
00496       <tr>
00497         <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
00498           <tr>
00499             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
00500             <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
00501           </tr>
00502         </table></td>
00503       </tr>
00504       <tr>
00505         <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
00506           <tr><?php echo zen_draw_form('mail', FILENAME_COUPON_ADMIN, 'action=send_email_to_user&cid=' . $_GET['cid']); ?>
00507             <td><table border="0" width="100%" cellpadding="0" cellspacing="2">
00508               <tr>
00509                 <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
00510               </tr>
00511               <tr>
00512                 <td class="smallText"><b><?php echo TEXT_CUSTOMER; ?></b><br /><?php echo $mail_sent_to; ?></td>
00513               </tr>
00514               <tr>
00515                 <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
00516               </tr>
00517               <tr>
00518                 <td class="smallText"><b><?php echo TEXT_COUPON; ?></b><br /><?php echo $coupon_name->fields['coupon_name']; ?></td>
00519               </tr>
00520               <tr>
00521                 <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
00522               </tr>
00523               <tr>
00524                 <td class="smallText"><b><?php echo TEXT_FROM; ?></b><br /><?php echo htmlspecialchars(stripslashes($_POST['from'])); ?></td>
00525               </tr>
00526               <tr>
00527                 <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
00528               </tr>
00529               <tr>
00530                 <td class="smallText"><b><?php echo TEXT_SUBJECT; ?></b><br /><?php echo htmlspecialchars(stripslashes($_POST['subject'])); ?></td>
00531               </tr>
00532               <tr>
00533                 <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
00534               </tr>
00535               <tr>
00536                 <td><hr /><b><?php echo TEXT_RICH_TEXT_MESSAGE; ?></b><br /><?php echo stripslashes($_POST['message_html']); ?></td>
00537               </tr>
00538               <tr>
00539                 <td ><hr /><b><?php echo TEXT_MESSAGE; ?></b><br /><tt><?php echo nl2br(htmlspecialchars(stripslashes($_POST['message']))); ?></tt><hr /></td>
00540               </tr>
00541               <tr>
00542                 <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
00543               </tr>
00544               <tr>
00545                 <td>
00546 <?php
00547 /* Re-Post all POST'ed variables */
00548     reset($_POST);
00549     while (list($key, $value) = each($_POST)) {
00550       if (!is_array($_POST[$key])) {
00551         echo zen_draw_hidden_field($key, htmlspecialchars(stripslashes($value)));
00552       }
00553     }
00554 ?>
00555                 <table border="0" width="100%" cellpadding="0" cellspacing="2">
00556                   <tr>
00557                     <td><?php ?>&nbsp;</td>
00558                     <td align="right"><?php echo '<a href="' . zen_href_link(FILENAME_COUPON_ADMIN,  'cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a> ' . zen_image_submit('button_send_mail.gif', IMAGE_SEND_EMAIL); ?></td>
00559                   </tr>
00560                 </table></td>
00561               </tr>
00562             </table></td>
00563           </form></tr>
00564 <?php
00565     break;
00566   case 'email':
00567     $coupon_result = $db->Execute("select coupon_code
00568                                    from " . TABLE_COUPONS . "
00569                                    where coupon_id = '" . $_GET['cid'] . "'");
00570     $coupon_name = $db->Execute("select coupon_name
00571                                  from " . TABLE_COUPONS_DESCRIPTION . "
00572                                  where coupon_id = '" . $_GET['cid'] . "'
00573                                  and language_id = '" . (int)$_SESSION['languages_id'] . "'");
00574 ?>
00575       <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
00576       <tr>
00577         <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
00578           <tr>
00579             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
00580             <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
00581           </tr>
00582         </table></td>
00583       </tr>
00584       <tr>
00585         <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
00586           <tr><?php echo zen_draw_form('mail', FILENAME_COUPON_ADMIN, 'action=preview_email&cid='. $_GET['cid'],'post', 'onsubmit="return check_form(mail);"'); ?>
00587             <td><table border="0" width="100%" cellpadding="0" cellspacing="2">
00588               <tr>
00589                 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
00590               </tr>
00591               <tr>
00592                 <td class="main"><?php echo TEXT_COUPON; ?>&nbsp;&nbsp;</td>
00593                 <td><?php echo $coupon_name->fields['coupon_name']; ?></td>
00594               </tr>
00595               <tr>
00596                 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
00597               </tr>
00598 <?php
00599     $customers = get_audiences_list('email');
00600 ?>
00601               <tr>
00602                 <td class="main"><?php echo TEXT_CUSTOMER; ?>&nbsp;&nbsp;</td>
00603                 <td><?php echo zen_draw_pull_down_menu('customers_email_address', $customers, $_GET['customer']);?></td>
00604               </tr>
00605               <tr>
00606                 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
00607               </tr>
00608               <tr>
00609                 <td class="main"><?php echo TEXT_FROM; ?>&nbsp;&nbsp;</td>
00610                 <td><?php echo zen_draw_input_field('from', EMAIL_FROM, 'size="50"'); ?></td>
00611               </tr>
00612               <tr>
00613                 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
00614               </tr>
00615 <?php
00616 /*
00617               <tr>
00618                 <td class="main"><?php echo TEXT_RESTRICT; ?>&nbsp;&nbsp;</td>
00619                 <td><?php echo zen_draw_checkbox_field('customers_restrict', $customers_restrict);?></td>
00620               </tr>
00621               <tr>
00622                 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
00623               </tr>
00624 */
00625 ?>
00626               <tr>
00627                 <td class="main"><?php echo TEXT_SUBJECT; ?>&nbsp;&nbsp;</td>
00628                 <td><?php echo zen_draw_input_field('subject', '', 'size="50"'); ?></td>
00629               </tr>
00630               <tr>
00631                 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
00632               </tr>
00633 <?php   if (EMAIL_USE_HTML == 'true') { ?>
00634               <tr>
00635                 <td valign="top" class="main"><?php echo TEXT_RICH_TEXT_MESSAGE; ?></td>
00636                 <td><?php echo zen_draw_textarea_field('message_html', 'soft', '100%', '25', htmlspecialchars(($_POST['message_html']=='') ? TEXT_COUPON_ANNOUNCE : stripslashes($_POST['message_html']), ENT_COMPAT, CHARSET, TRUE), 'id="message_html"'); ?></td>
00637               </tr>
00638 <?php } ?>
00639               <tr>
00640                 <td valign="top" class="main"><?php echo TEXT_MESSAGE; ?>&nbsp;&nbsp;</td>
00641                 <td><?php echo zen_draw_textarea_field('message', 'soft', '60', '15', htmlspecialchars(strip_tags(($_POST['message_html']=='') ? TEXT_COUPON_ANNOUNCE : stripslashes($_POST['message_html']), ENT_COMPAT, CHARSET, TRUE))); ?></td>
00642               </tr>
00643               <tr>
00644                 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
00645               </tr>
00646               <tr>
00647                 <td colspan="2" align="right"><?php echo '<a href="' . zen_href_link(FILENAME_COUPON_ADMIN, 'cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a> ' .  zen_image_submit('button_send_mail.gif', IMAGE_SEND_EMAIL); ?></td>
00648               </tr>
00649             </table></td>
00650           </form></tr>
00651   </table></td>
00652 <?php
00653     break;
00654   case 'update_preview':
00655 ?>
00656       <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
00657       <tr>
00658         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
00659           <tr>
00660             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
00661             <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
00662           </tr>
00663         </table></td>
00664       </tr>
00665       <tr>
00666       <td>
00667 <?php echo zen_draw_form('coupon', FILENAME_COUPON_ADMIN, 'action=update_confirm&oldaction=' . $_GET['oldaction'] . '&cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')); ?>
00668       <table border="0" width="100%" cellspacing="0" cellpadding="6">
00669         <tr>
00670           <td align="left" class="main"><?php echo COUPON_ZONE_RESTRICTION; ?></td>
00671           <td align="left" class="main"><?php echo zen_get_geo_zone_name($_POST['coupon_zone_restriction']); ?>
00672         </tr>
00673 <?php
00674         $languages = zen_get_languages();
00675         for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
00676             $language_id = $languages[$i]['id'];
00677 ?>
00678       <tr>
00679         <td align="left"><?php echo COUPON_NAME; ?></td>
00680         <td align="left"><?php echo zen_db_prepare_input($_POST['coupon_name'][$language_id]); ?></td>
00681       </tr>
00682 <?php
00683 }
00684 ?>
00685 <?php
00686         $languages = zen_get_languages();
00687         for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
00688             $language_id = $languages[$i]['id'];
00689 ?>
00690       <tr>
00691         <td align="left"><?php echo COUPON_DESC; ?></td>
00692         <td align="left"><?php echo zen_db_prepare_input($_POST['coupon_desc'][$language_id]); ?></td>
00693       </tr>
00694 <?php
00695 }
00696 ?>
00697       <tr>
00698         <td align="left"><?php echo COUPON_AMOUNT; ?></td>
00699         <td align="left"><?php echo zen_db_prepare_input($_POST['coupon_amount']); ?></td>
00700       </tr>
00701 
00702       <tr>
00703         <td align="left"><?php echo COUPON_MIN_ORDER; ?></td>
00704         <td align="left"><?php echo zen_db_prepare_input($_POST['coupon_min_order']); ?></td>
00705       </tr>
00706 
00707       <tr>
00708         <td align="left"><?php echo COUPON_FREE_SHIP; ?></td>
00709 <?php
00710     if ($_POST['coupon_free_ship']) {
00711 ?>
00712         <td align="left"><?php echo TEXT_FREE_SHIPPING; ?></td>
00713 <?php
00714     } else {
00715 ?>
00716         <td align="left"><?php echo TEXT_NO_FREE_SHIPPING; ?></td>
00717 <?php
00718     }
00719 ?>
00720       </tr>
00721       <tr>
00722         <td align="left"><?php echo COUPON_CODE; ?></td>
00723 <?php
00724     if ($_POST['coupon_code']) {
00725       $c_code = $_POST['coupon_code'];
00726     } else {
00727       $c_code = $coupon_code;
00728     }
00729 ?>
00730         <td align="left"><?php echo $coupon_code; ?></td>
00731       </tr>
00732 
00733       <tr>
00734         <td align="left"><?php echo COUPON_USES_COUPON; ?></td>
00735         <td align="left"><?php echo $_POST['coupon_uses_coupon']; ?></td>
00736       </tr>
00737 
00738       <tr>
00739         <td align="left"><?php echo COUPON_USES_USER; ?></td>
00740         <td align="left"><?php echo $_POST['coupon_uses_user']; ?></td>
00741       </tr>
00742 
00743       <tr>
00744         <td align="left"><?php echo COUPON_STARTDATE; ?></td>
00745 <?php
00746     $start_date = date(DATE_FORMAT, mktime(0, 0, 0, $_POST['coupon_startdate_month'],$_POST['coupon_startdate_day'] ,$_POST['coupon_startdate_year'] ));
00747 ?>
00748         <td align="left"><?php echo $start_date; ?></td>
00749       </tr>
00750 
00751       <tr>
00752         <td align="left"><?php echo COUPON_FINISHDATE; ?></td>
00753 <?php
00754     $finish_date = date(DATE_FORMAT, mktime(0, 0, 0, $_POST['coupon_finishdate_month'],$_POST['coupon_finishdate_day'] ,$_POST['coupon_finishdate_year'] ));
00755 ?>
00756         <td align="left"><?php echo $finish_date; ?></td>
00757       </tr>
00758 <?php
00759         $languages = zen_get_languages();
00760         for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
00761           $language_id = $languages[$i]['id'];
00762           echo zen_draw_hidden_field('coupon_name[' . $languages[$i]['id'] . ']', stripslashes($_POST['coupon_name'][$language_id]));
00763           echo zen_draw_hidden_field('coupon_desc[' . $languages[$i]['id'] . ']', stripslashes($_POST['coupon_desc'][$language_id]));
00764        }
00765     echo zen_draw_hidden_field('coupon_amount', $_POST['coupon_amount']);
00766     echo zen_draw_hidden_field('coupon_min_order', $_POST['coupon_min_order']);
00767     echo zen_draw_hidden_field('coupon_free_ship', $_POST['coupon_free_ship']);
00768     echo zen_draw_hidden_field('coupon_code', stripslashes($c_code));
00769     echo zen_draw_hidden_field('coupon_uses_coupon', $_POST['coupon_uses_coupon']);
00770     echo zen_draw_hidden_field('coupon_uses_user', $_POST['coupon_uses_user']);
00771     echo zen_draw_hidden_field('coupon_products', $_POST['coupon_products']);
00772     echo zen_draw_hidden_field('coupon_categories', $_POST['coupon_categories']);
00773     echo zen_draw_hidden_field('coupon_startdate', date('Y-m-d', mktime(0, 0, 0, $_POST['coupon_startdate_month'],$_POST['coupon_startdate_day'] ,$_POST['coupon_startdate_year'] )));
00774     echo zen_draw_hidden_field('coupon_finishdate', date('Y-m-d', mktime(0, 0, 0, $_POST['coupon_finishdate_month'],$_POST['coupon_finishdate_day'] ,$_POST['coupon_finishdate_year'] )));
00775     echo zen_draw_hidden_field('coupon_zone_restriction', $_POST['coupon_zone_restriction']);
00776 ?>
00777      <tr>
00778         <td align="left"><?php echo zen_image_submit('button_confirm.gif',COUPON_BUTTON_CONFIRM, (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')); ?></td>
00779         <td align="left"><?php echo zen_image_submit('button_cancel.gif',COUPON_BUTTON_CANCEL, 'name=back'); ?></td>
00780       </td>
00781       </tr>
00782 
00783       </td></table></form>
00784       </tr>
00785 
00786       </table></td>
00787 <?php
00788 
00789     break;
00790   case 'voucheredit':
00791     $languages = zen_get_languages();
00792     for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
00793       $language_id = $languages[$i]['id'];
00794       $coupon = $db->Execute("select coupon_name,coupon_description
00795                               from " . TABLE_COUPONS_DESCRIPTION . "
00796                               where coupon_id = '" .  $_GET['cid'] . "'
00797                               and language_id = '" . (int)$language_id . "'");
00798 
00799       $_POST['coupon_name'][$language_id] = $coupon->fields['coupon_name'];
00800       $_POST['coupon_desc'][$language_id] = $coupon->fields['coupon_description'];
00801     }
00802 
00803     $coupon = $db->Execute("select coupon_code, coupon_amount, coupon_type, coupon_minimum_order,
00804                                    coupon_start_date, coupon_expire_date, uses_per_coupon,
00805                                    uses_per_user, restrict_to_products, restrict_to_categories, coupon_zone_restriction
00806                             from " . TABLE_COUPONS . "
00807                             where coupon_id = '" . $_GET['cid'] . "'");
00808 
00809     $_POST['coupon_amount'] = $coupon->fields['coupon_amount'];
00810     if ($coupon->fields['coupon_type'] == 'P' || $coupon->fields['coupon_type'] == 'E') {
00811       $_POST['coupon_amount'] .= '%';
00812     }
00813     // free shipping on free shipping only 'S' or percentage off and free shipping 'E' or amount off and free shipping 'O'
00814     if ($coupon->fields['coupon_type'] == 'S' || $coupon->fields['coupon_type'] == 'O' || $coupon->fields['coupon_type'] == 'E') {
00815       $_POST['coupon_free_ship'] = true;
00816     } else {
00817       $_POST['coupon_free_ship'] = false;
00818     }
00819     $_POST['coupon_min_order'] = $coupon->fields['coupon_minimum_order'];
00820     $_POST['coupon_code'] = $coupon->fields['coupon_code'];
00821     $_POST['coupon_uses_coupon'] = $coupon->fields['uses_per_coupon'];
00822     $_POST['coupon_uses_user'] = $coupon->fields['uses_per_user'];
00823     $_POST['coupon_startdate'] = $coupon->fields['coupon_start_date'];
00824     $_POST['coupon_finishdate'] = $coupon->fields['coupon_expire_date'];
00825     $_POST['coupon_zone_restriction'] = $coupon->fields['coupon_zone_restriction'];
00826 
00827   case 'new':
00828 // set some defaults
00829     if ($_GET['action'] != 'voucheredit' and $_POST['coupon_uses_user'] == '') $_POST['coupon_uses_user'] = 1;
00830 ?>
00831       <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
00832       <tr>
00833         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
00834           <tr>
00835             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
00836             <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
00837           </tr>
00838         </table></td>
00839       </tr>
00840       <tr>
00841       <td>
00842 <?php
00843     echo zen_draw_form('coupon', FILENAME_COUPON_ADMIN, 'action=update&oldaction=' . $_GET['action'] . '&cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''));
00844 ?>
00845       <table border="0" width="100%" cellspacing="0" cellpadding="6">
00846 <?php
00847         $languages = zen_get_languages();
00848         for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
00849         $language_id = $languages[$i]['id'];
00850 ?>
00851       <tr>
00852         <td align="left" class="main"><?php if ($i==0) echo COUPON_NAME; ?></td>
00853         <td align="left"><?php echo zen_draw_input_field('coupon_name[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($_POST['coupon_name'][$language_id]), ENT_COMPAT, CHARSET, TRUE)) . '&nbsp;' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?></td>
00854         <td align="left" class="main" width="40%"><?php if ($i==0) echo COUPON_NAME_HELP; ?></td>
00855       </tr>
00856 <?php
00857 }
00858 ?>
00859 <?php
00860         $languages = zen_get_languages();
00861         for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
00862         $language_id = $languages[$i]['id'];
00863 ?>
00864 
00865       <tr>
00866         <td align="left" valign="top" class="main"><?php if ($i==0) echo COUPON_DESC; ?></td>
00867         <td align="left" valign="top"><?php echo zen_draw_textarea_field('coupon_desc[' . $languages[$i]['id'] . ']','physical','24','8', htmlspecialchars(stripslashes($_POST['coupon_desc'][$language_id]), ENT_COMPAT, CHARSET, TRUE)); ?>
00868             <?php echo '&nbsp;' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?></td>
00869         <td align="left" valign="top" class="main"><?php if ($i==0) echo COUPON_DESC_HELP; ?></td>
00870       </tr>
00871 <?php
00872 }
00873 ?>
00874       <tr>
00875         <td align="left" class="main"><?php echo COUPON_AMOUNT; ?></td>
00876         <td align="left"><?php echo zen_draw_input_field('coupon_amount', $_POST['coupon_amount']); ?></td>
00877         <td align="left" class="main"><?php echo COUPON_AMOUNT_HELP; ?></td>
00878       </tr>
00879       <tr>
00880         <td align="left" class="main"><?php echo COUPON_MIN_ORDER; ?></td>
00881         <td align="left"><?php echo zen_draw_input_field('coupon_min_order', $_POST['coupon_min_order']); ?></td>
00882         <td align="left" class="main"><?php echo COUPON_MIN_ORDER_HELP; ?></td>
00883       </tr>
00884       <tr>
00885         <td align="left" class="main"><?php echo COUPON_FREE_SHIP; ?></td>
00886         <td align="left"><input type="checkbox" name="coupon_free_ship" <?php if ($_POST['coupon_free_ship']) echo 'CHECKED'; ?>></td>
00887         <td align="left" class="main"><?php echo COUPON_FREE_SHIP_HELP; ?></td>
00888       </tr>
00889       <tr>
00890         <td align="left" class="main"><?php echo COUPON_CODE; ?></td>
00891         <td align="left"><?php echo zen_draw_input_field('coupon_code', htmlspecialchars($_POST['coupon_code'], ENT_COMPAT, CHARSET, TRUE)); ?></td>
00892         <td align="left" class="main"><?php echo COUPON_CODE_HELP; ?></td>
00893       </tr>
00894       <tr>
00895         <td align="left" class="main"><?php echo COUPON_USES_COUPON; ?></td>
00896         <td align="left"><?php echo zen_draw_input_field('coupon_uses_coupon', ($_POST['coupon_uses_coupon'] >= 1 ? $_POST['coupon_uses_coupon'] : '')); ?></td>
00897         <td align="left" class="main"><?php echo COUPON_USES_COUPON_HELP; ?></td>
00898       </tr>
00899       <tr>
00900         <td align="left" class="main"><?php echo COUPON_USES_USER; ?></td>
00901         <td align="left"><?php echo zen_draw_input_field('coupon_uses_user', ($_POST['coupon_uses_user'] >= 1 ? $_POST['coupon_uses_user'] : '')); ?></td>
00902         <td align="left" class="main"><?php echo COUPON_USES_USER_HELP; ?></td>
00903       </tr>
00904       <tr>
00905 <?php
00906     if (!$_POST['coupon_startdate']) {
00907       $coupon_startdate = preg_split("/[-]/", date('Y-m-d'));
00908     } else {
00909       $coupon_startdate = preg_split("/[-]/", $_POST['coupon_startdate']);
00910     }
00911     if (!$_POST['coupon_finishdate']) {
00912       $coupon_finishdate = preg_split("/[-]/", date('Y-m-d'));
00913       $coupon_finishdate[0] = $coupon_finishdate[0] + 1;
00914     } else {
00915       $coupon_finishdate = preg_split("/[-]/", $_POST['coupon_finishdate']);
00916     }
00917 ?>
00918         <td align="left" class="main"><?php echo COUPON_STARTDATE; ?></td>
00919         <td align="left"><?php echo zen_draw_date_selector('coupon_startdate', mktime(0,0,0, $coupon_startdate[1], $coupon_startdate[2], $coupon_startdate[0], 0)); ?></td>
00920         <td align="left" class="main"><?php echo COUPON_STARTDATE_HELP; ?></td>
00921       </tr>
00922       <tr>
00923         <td align="left" class="main"><?php echo COUPON_FINISHDATE; ?></td>
00924         <td align="left"><?php echo zen_draw_date_selector('coupon_finishdate', mktime(0,0,0, $coupon_finishdate[1], $coupon_finishdate[2], $coupon_finishdate[0], 0)); ?></td>
00925         <td align="left" class="main"><?php echo COUPON_FINISHDATE_HELP; ?></td>
00926       </tr>
00927       <tr>
00928         <td align="left" class="main"><?php echo COUPON_ZONE_RESTRICTION; ?></td>
00929         <td align="left" class="main"><?php echo zen_geo_zones_pull_down_coupon('name="coupon_zone_restriction" style="font-size:10px"', $_POST['coupon_zone_restriction']); ?>
00930         <td align="left" class="main"><?php echo TEXT_COUPON_ZONE_RESTRICTION; ?></td>
00931       </tr>
00932       <tr>
00933         <td align="left"><?php echo zen_image_submit('button_preview.gif',COUPON_BUTTON_PREVIEW); ?></td>
00934         <td align="left">&nbsp;&nbsp;<a href="<?php echo zen_href_link(FILENAME_COUPON_ADMIN, 'cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')); ?>"><?php echo zen_image_button('button_cancel.gif', IMAGE_CANCEL); ?></a>
00935       </td>
00936       </tr>
00937       </td></table></form>
00938       </tr>
00939 
00940       </table></td>
00941 <?php
00942     break;
00943   default:
00944 ?>
00945     <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
00946       <tr>
00947         <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
00948           <tr>
00949             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
00950             <td class="main"><?php echo zen_draw_form('status', FILENAME_COUPON_ADMIN, '', 'get'); ?>
00951 <?php
00952     $status_array[] = array('id' => 'Y', 'text' => TEXT_COUPON_ACTIVE);
00953     $status_array[] = array('id' => 'N', 'text' => TEXT_COUPON_INACTIVE);
00954     $status_array[] = array('id' => '*', 'text' => TEXT_COUPON_ALL);
00955 
00956     if (isset($_GET['status'])) {
00957       $status = zen_db_prepare_input($_GET['status']);
00958     } else {
00959       $status = 'Y';
00960     }
00961     echo zen_hide_session_id();
00962     $status = $status[0];
00963     echo HEADING_TITLE_STATUS . ' ' . zen_draw_pull_down_menu('status', $status_array, $status, 'onChange="this.form.submit();"') .
00964     zen_draw_hidden_field('page', $_GET['page']);
00965 ?>
00966               </form>
00967            </td>
00968             <td class="main">
00969 <?php
00970 // toggle switch for editor
00971         echo TEXT_EDITOR_INFO . zen_draw_form('set_editor_form', FILENAME_COUPON_ADMIN, '', 'get') . '&nbsp;&nbsp;' . zen_draw_pull_down_menu('reset_editor', $editors_pulldown, $current_editor_key, 'onChange="this.form.submit();"') .
00972         zen_hide_session_id() .
00973         zen_draw_hidden_field('action', 'set_editor') .
00974         '</form>';
00975 ?>
00976 </td>
00977           </tr>
00978         </table></td>
00979       </tr>
00980       <tr>
00981         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
00982           <tr>
00983             <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
00984               <tr class="dataTableHeadingRow">
00985                 <td class="dataTableHeadingContent"><?php echo COUPON_NAME; ?></td>
00986                 <td class="dataTableHeadingContent" align="center"><?php echo COUPON_AMOUNT; ?></td>
00987                 <td class="dataTableHeadingContent" align="center"><?php echo COUPON_CODE; ?></td>
00988                 <td class="dataTableHeadingContent" align="center"><?php echo COUPON_ACTIVE; ?></td>
00989                 <td class="dataTableHeadingContent" align="center"><?php echo COUPON_START_DATE; ?></td>
00990                 <td class="dataTableHeadingContent" align="center"><?php echo COUPON_EXPIRE_DATE; ?></td>
00991                 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
00992               </tr>
00993 <?php
00994     if ($status != '*') {
00995       $cc_query_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, coupon_active, coupon_zone_restriction from " . TABLE_COUPONS ." where coupon_active='" . zen_db_input($status) . "' and coupon_type != 'G'";
00996     } else {
00997       $cc_query_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, coupon_active, coupon_zone_restriction from " . TABLE_COUPONS . " where coupon_type != 'G'";
00998     }
00999     $maxDisplaySearchResults = (defined('MAX_DISPLAY_SEARCH_RESULTS_DISCOUNT_COUPONS') && (int)MAX_DISPLAY_SEARCH_RESULTS_DISCOUNT_COUPONS > 0) ? (int)MAX_DISPLAY_SEARCH_RESULTS_DISCOUNT_COUPONS : 20;
01000     // reset page when page is unknown
01001 if (($_GET['page'] == '' or $_GET['page'] == '1') and $_GET['cid'] != '') {
01002   $check_page = $db->Execute($cc_query_raw);
01003   $check_count=1;
01004   if ($check_page->RecordCount() > $maxDisplaySearchResults) {
01005     while (!$check_page->EOF) {
01006       if ($check_page->fields['coupon_id'] == $_GET['cid']) {
01007         break;
01008       }
01009       $check_count++;
01010       $check_page->MoveNext();
01011     }
01012     $_GET['page'] = round((($check_count/$maxDisplaySearchResults)+(fmod_round($check_count,$maxDisplaySearchResults) !=0 ? .5 : 0)),0);
01013   } else {
01014     $_GET['page'] = 1;
01015   }
01016 }
01017 
01018     $cc_split = new splitPageResults($_GET['page'], $maxDisplaySearchResults, $cc_query_raw, $cc_query_numrows);
01019     $cc_list = $db->Execute($cc_query_raw);
01020     while (!$cc_list->EOF) {
01021       if (((!$_GET['cid']) || (@$_GET['cid'] == $cc_list->fields['coupon_id'])) && (!$cInfo)) {
01022         $cInfo = new objectInfo($cc_list->fields);
01023       }
01024       if ( (is_object($cInfo)) && ($cc_list->fields['coupon_id'] == $cInfo->coupon_id) ) {
01025         echo '          <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . zen_href_link(FILENAME_COUPON_ADMIN, zen_get_all_get_params(array('cid', 'action')) . 'cid=' . $cInfo->coupon_id . '&action=voucheredit') . '\'">' . "\n";
01026       } else {
01027         echo '          <tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'hand\'" onmouseout="this.className=\'dataTableRow\'" onclick="document.location.href=\'' . zen_href_link(FILENAME_COUPON_ADMIN, zen_get_all_get_params(array('cid', 'action')) . 'cid=' . $cc_list->fields['coupon_id']) . '\'">' . "\n";
01028       }
01029       $coupon_desc = $db->Execute("select coupon_name
01030                                    from " . TABLE_COUPONS_DESCRIPTION . "
01031                                    where coupon_id = '" . (int)$cc_list->fields['coupon_id'] . "'
01032                                    and language_id = '" . (int)$_SESSION['languages_id'] . "'");
01033 ?>
01034                 <td class="dataTableContent"><?php echo $coupon_desc->fields['coupon_name']; ?></td>
01035                 <td class="dataTableContent" align="center">
01036 <?php
01037       switch ($cc_list->fields['coupon_type']) {
01038         case ('S'): // free shipping
01039           echo TEXT_FREE_SHIPPING;
01040           break;
01041         case ('P'): // percentage off
01042           echo $cc_list->fields['coupon_amount'] . '%';
01043           break;
01044         case ('F'): // amount off
01045           echo $currencies->format($cc_list->fields['coupon_amount']);
01046           break;
01047         case ('E'): // percentage off and free shipping
01048           echo $cc_list->fields['coupon_amount'] . '%' . '<br />' . TEXT_FREE_SHIPPING;
01049           break;
01050         case ('O'): // amount off and free shipping
01051           echo $currencies->format($cc_list->fields['coupon_amount']) . '<br />' . TEXT_FREE_SHIPPING;
01052           break;
01053         default:
01054           echo '***';
01055           break;
01056       }
01057 ?>
01058             &nbsp;</td>
01059                 <td class="dataTableContent" align="center"><?php echo $cc_list->fields['coupon_code']; ?></td>
01060                 <td class="dataTableContent" align="center"><?php echo $cc_list->fields['coupon_active']; ?></td>
01061                 <td class="dataTableContent" align="center"><?php echo zen_date_short($cc_list->fields['coupon_start_date']); ?></td>
01062                 <td class="dataTableContent" align="center"><?php echo zen_date_short($cc_list->fields['coupon_expire_date']); ?></td>
01063                 <td class="dataTableContent" align="right"><?php if ( (is_object($cInfo)) && ($cc_list->fields['coupon_id'] == $cInfo->coupon_id) ) { echo zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '<a href="' . zen_href_link(FILENAME_COUPON_ADMIN, 'page=' . $_GET['page'] . '&cid=' . $cc_list->fields['coupon_id'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '')) . '">' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
01064               </tr>
01065 <?php
01066       $cc_list->MoveNext();
01067     }
01068 ?>
01069           <tr>
01070             <td colspan="7"><table border="0" width="100%" cellspacing="0" cellpadding="2">
01071               <tr>
01072                 <td class="smallText">&nbsp;<?php echo $cc_split->display_count($cc_query_numrows, $maxDisplaySearchResults, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_COUPONS); ?>&nbsp;</td>
01073                 <td align="right" class="smallText">&nbsp;<?php echo $cc_split->display_links($cc_query_numrows, $maxDisplaySearchResults, MAX_DISPLAY_PAGE_LINKS, $_GET['page'], (isset($_GET['status']) ? '&status=' . $_GET['status'] : '')); ?>&nbsp;</td>
01074               </tr>
01075 
01076               <tr>
01077                 <td align="right" colspan="2" class="smallText"><?php echo '<a name="couponInsert" href="' . zen_href_link(FILENAME_COUPON_ADMIN, 'page=' . $_GET['page'] . '&cid=' . $cInfo->coupon_id . '&action=new') . '">' . zen_image_button('button_insert.gif', IMAGE_INSERT) . '</a>'; ?></td>
01078               </tr>
01079             </table></td>
01080           </tr>
01081         </table></td>
01082 
01083 <?php
01084 
01085     $heading = array();
01086     $contents = array();
01087 
01088     switch ($_GET['action']) {
01089     case 'release':
01090       break;
01091     case 'voucherreport':
01092       $heading[] = array('text' => '<b>' . TEXT_HEADING_COUPON_REPORT . '</b>');
01093       $contents[] = array('text' => TEXT_NEW_INTRO);
01094       break;
01095     case 'new':
01096       $heading[] = array('text' => '<b>' . TEXT_HEADING_NEW_COUPON . '</b>');
01097       $contents[] = array('text' => TEXT_NEW_INTRO);
01098       $contents[] = array('text' => '<br />' . COUPON_NAME . '<br />' . zen_draw_input_field('name'));
01099       $contents[] = array('text' => '<br />' . COUPON_AMOUNT . '<br />' . zen_draw_input_field('voucher_amount'));
01100       $contents[] = array('text' => '<br />' . COUPON_CODE . '<br />' . zen_draw_input_field('voucher_code'));
01101       $contents[] = array('text' => '<br />' . COUPON_USES_COUPON . '<br />' . zen_draw_input_field('voucher_number_of'));
01102       break;
01103     default:
01104       $heading[] = array('text'=>'['.$cInfo->coupon_id.']  '.$cInfo->coupon_code);
01105       $amount = $cInfo->coupon_amount;
01106       if ($cInfo->coupon_type == 'P' || $cInfo->coupon_type == 'E') {
01107         $amount .= '%';
01108       } else {
01109         $amount = $currencies->format($amount);
01110       }
01111       if ($cInfo->coupon_type == 'S'|| $cInfo->coupon_type == 'E' || $cInfo->coupon_type == 'O' ) {
01112         $amount .= ' ' . TEXT_FREE_SHIPPING;
01113       }
01114       if ($_GET['action'] == 'voucherdelete' or $_GET['action'] == 'vouchercopy') {
01115         if ($_GET['action'] == 'voucherdelete') {
01116           $contents[] = array('text'=> TEXT_CONFIRM_DELETE . '</br></br>' .
01117                   '<a href="'.zen_href_link(FILENAME_COUPON_ADMIN,'action=confirmdelete&cid='.$_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''),'NONSSL').'">'.zen_image_button('button_confirm.gif','Confirm Delete ' . TEXT_DISCOUNT_COUPON).'</a>' .
01118                   '<a href="'.zen_href_link(FILENAME_COUPON_ADMIN,'cid='.$cInfo->coupon_id . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''),'NONSSL').'">'.zen_image_button('button_cancel.gif','Cancel').'</a>'
01119                   );
01120         }
01121         if ($_GET['action'] == 'vouchercopy') {
01122           $contents = array('form' => zen_draw_form('new_coupon', FILENAME_COUPON_ADMIN, 'action=confirmcopy' . '&cid='.$_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''), 'post', 'enctype="multipart/form-data"'));
01123 
01124           $contents[] = array('text' => '<br>' . TEXT_COUPON_NEW . '&nbsp;' . zen_draw_input_field('coupon_copy_to', '', 6, 6));
01125 
01126           $contents[] = array('text'=> TEXT_CONFIRM_COPY . '</br>');
01127           $contents[] = array('text'=> zen_image_submit('button_save.gif', IMAGE_SAVE));
01128           $contents[] = array('text'=>
01129                   '<a href="'.zen_href_link(FILENAME_COUPON_ADMIN,'cid='.$cInfo->coupon_id . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''),'NONSSL').'">'.zen_image_button('button_cancel.gif','Cancel').'</a>'
01130                   );
01131         }
01132       } else {
01133         $prod_details = TEXT_NONE;
01134 //bof 12-6ke
01135 $product_query = $db->Execute("select * from " . TABLE_COUPON_RESTRICT . " where coupon_id = '" . $cInfo->coupon_id . "' and product_id != '0'");        if ($product_query->RecordCount() > 0) $prod_details = TEXT_SEE_RESTRICT;
01136 //eof 12-6ke
01137         $cat_details = TEXT_NONE;
01138 //bof 12-6ke
01139 $category_query = $db->Execute("select * from " . TABLE_COUPON_RESTRICT . " where coupon_id = '" . $cInfo->coupon_id . "' and category_id != '0'");        if ($category_query->RecordCount() > 0) $cat_details = TEXT_SEE_RESTRICT;
01140 //eof 12-6ke
01141         $coupon_name = $db->Execute("select coupon_name
01142                                      from " . TABLE_COUPONS_DESCRIPTION . "
01143                                      where coupon_id = '" . $cInfo->coupon_id . "'
01144                                      and language_id = '" . (int)$_SESSION['languages_id'] . "'");
01145         $uses_coupon = $cInfo->uses_per_coupon;
01146         $uses_user = $cInfo->uses_per_user;
01147         if ($uses_coupon == 0 || $uses_coupon == '') $uses_coupon = TEXT_UNLIMITED;
01148         if ($uses_user == 0 || $uses_user == '') $uses_user = TEXT_UNLIMITED;
01149         $contents[] = array('text'=>COUPON_NAME . '&nbsp;::&nbsp; ' . $coupon_name->fields['coupon_name'] . '<br />' .
01150                      COUPON_AMOUNT . '&nbsp;::&nbsp; ' . $amount . '<br />' .
01151                      COUPON_STARTDATE . '&nbsp;::&nbsp; ' . zen_date_short($cInfo->coupon_start_date) . '<br />' .
01152                      COUPON_FINISHDATE . '&nbsp;::&nbsp; ' . zen_date_short($cInfo->coupon_expire_date) . '<br />' .
01153                      COUPON_USES_COUPON . '&nbsp;::&nbsp; ' . $uses_coupon . '<br />' .
01154                      COUPON_USES_USER . '&nbsp;::&nbsp; ' . $uses_user . '<br />' .
01155                      COUPON_PRODUCTS . '&nbsp;::&nbsp; ' . $prod_details . '<br />' .
01156                      COUPON_CATEGORIES . '&nbsp;::&nbsp; ' . $cat_details . '<br />' .
01157                      DATE_CREATED . '&nbsp;::&nbsp; ' . zen_date_short($cInfo->date_created) . '<br />' .
01158                      DATE_MODIFIED . '&nbsp;::&nbsp; ' . zen_date_short($cInfo->date_modified) . '<br /><br />' .
01159                      COUPON_ZONE_RESTRICTION . '&nbsp;::&nbsp; ' . zen_get_geo_zone_name($cInfo->coupon_zone_restriction) . '<br /><br />' .
01160                      ($cInfo->coupon_id != '' ?
01161                      '<center><a href="'.zen_href_link(FILENAME_COUPON_ADMIN,'action=email&cid='.$cInfo->coupon_id,'NONSSL').'">'.zen_image_button('button_email.gif','Email ' . TEXT_DISCOUNT_COUPON).'</a>' .
01162                      '<a href="'.zen_href_link(FILENAME_COUPON_ADMIN,'action=voucheredit&cid='.$cInfo->coupon_id . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''),'NONSSL').'">'.zen_image_button('button_edit.gif','Edit ' . TEXT_DISCOUNT_COUPON) .'</a>' .
01163                      '<a href="'.zen_href_link(FILENAME_COUPON_ADMIN,'action=voucherdelete&cid='.$cInfo->coupon_id . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''),'NONSSL').'">'.zen_image_button('button_delete.gif','Delete ' . TEXT_DISCOUNT_COUPON).'</a>' .
01164                      '<br /><a href="'.zen_href_link('coupon_restrict.php','cid='.$cInfo->coupon_id  . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''),'NONSSL').'">'.zen_image_button('button_restrict.gif','Restrict').'</a><a href="'.zen_href_link(FILENAME_COUPON_ADMIN,'action=voucherreport&cid='.$cInfo->coupon_id . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''),'NONSSL').'">'.zen_image_button('button_report.gif',TEXT_DISCOUNT_COUPON . ' Report').
01165                      '<a href="'.zen_href_link(FILENAME_COUPON_ADMIN,'action=vouchercopy&cid='.$cInfo->coupon_id . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''),'NONSSL').'">'.zen_image_button('button_copy.gif','Copy ' . TEXT_DISCOUNT_COUPON) . '</a></center>'
01166                      : ' who ' . $cInfo->coupon_id . ' - ' . $_GET['cid'])
01167                      );
01168         }
01169         break;
01170       }
01171 ?>
01172     <td width="25%" valign="top">
01173 <?php
01174       $box = new box;
01175       echo $box->infoBox($heading, $contents);
01176     echo '            </td>' . "\n";
01177     }
01178 ?>
01179       </tr>
01180     </table></td>
01181 <!-- body_text_eof //-->
01182   </tr>
01183 </table>
01184 <!-- body_eof //-->
01185 <!-- footer //-->
01186 <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
01187 <!-- footer_eof //-->
01188 </body>
01189 </html>
01190 <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
 All Data Structures Namespaces Files Functions Variables Enumerations