add( $error, 'error' ); } if( tep_not_null( $message ) ) { $messageStack->add( $message, 'success' ); } if (tep_not_null($action)) { switch ($action) { case 'insert': //some error checking: if( empty( $HTTP_POST_VARS['coupons_discount_amount'] ) ) { $messageStack->add( ERROR_DISCOUNT_COUPONS_NO_AMOUNT, 'error' ); $action = 'new'; } else { tep_db_query( $sql = "insert into " . TABLE_DISCOUNT_COUPONS . " values ( '".$coupons_id."', '".tep_db_input( $HTTP_POST_VARS['coupons_description'] )."', '".tep_db_input( $HTTP_POST_VARS['coupons_discount_amount'] )."', '" .tep_db_input( $HTTP_POST_VARS['coupons_discount_type'] )."', ".( !empty( $HTTP_POST_VARS['coupons_date_start'] ) ? '"'.kgt_parse_date( $HTTP_POST_VARS['coupons_date_start'], DATE_FORMAT_SHORT ).'"' : 'null' ).", ".( !empty( $HTTP_POST_VARS['coupons_date_end'] ) ? '"'.kgt_parse_date( $HTTP_POST_VARS['coupons_date_end'], DATE_FORMAT_SHORT ).'"' : 'null' ).", ".( !empty( $HTTP_POST_VARS['coupons_max_use'] ) ? (int)$HTTP_POST_VARS['coupons_max_use'] : 0 ).", ".( !empty( $HTTP_POST_VARS['coupons_min_order'] ) ? tep_db_input( $HTTP_POST_VARS['coupons_min_order'] ) : 0 ).", ".( !empty( $HTTP_POST_VARS['coupons_min_order'] ) ? "'".tep_db_input( $HTTP_POST_VARS['coupons_min_order_type'] )."'" : 'null' ).", ".( !empty( $HTTP_POST_VARS['coupons_number_available'] ) ? (int)$HTTP_POST_VARS['coupons_number_available'] : 0 ).") " ); /*$customer_query = tep_db_query("SELECT customers_id FROM customers"); while ($customers = tep_db_fetch_array($customer_query)) { tep_db_query( $sql = "INSERT INTO discount_coupons_to_customers (coupons_id, customers_id) values ('".$coupons_id."', '".$customers['customers_id']."')" ); }*/ tep_redirect( tep_href_link( FILENAME_DISCOUNT_COUPONS, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $coupons_id ) ); } break; case 'update': tep_db_query($sql = "update " . TABLE_DISCOUNT_COUPONS . " set coupons_discount_amount = '".tep_db_input( $HTTP_POST_VARS['coupons_discount_amount'] )."', coupons_discount_type = '".tep_db_input( $HTTP_POST_VARS['coupons_discount_type'] )."', coupons_description = '" . tep_db_input( $HTTP_POST_VARS['coupons_description'] ) . "', coupons_date_start = " . ( !empty( $HTTP_POST_VARS['coupons_date_start'] ) ? '"'.kgt_parse_date( $HTTP_POST_VARS['coupons_date_start'], DATE_FORMAT_SHORT ).'"' : 'null' ) . ", coupons_date_end = " .( !empty( $HTTP_POST_VARS['coupons_date_end'] ) ? '"'.kgt_parse_date( $HTTP_POST_VARS['coupons_date_end'], DATE_FORMAT_SHORT ).'"' : 'null' ). ", coupons_max_use = " .( !empty( $HTTP_POST_VARS['coupons_max_use'] ) ? (int)$HTTP_POST_VARS['coupons_max_use'] : 0 ). ", coupons_min_order = ".( !empty( $HTTP_POST_VARS['coupons_min_order'] ) ? tep_db_input( $HTTP_POST_VARS['coupons_min_order'] ) : 0 ).", coupons_min_order_type = ".( !empty( $HTTP_POST_VARS['coupons_min_order'] ) ? "'".tep_db_input( $HTTP_POST_VARS['coupons_min_order_type'] )."'" : 'null' ).", coupons_number_available = " .( !empty( $HTTP_POST_VARS['coupons_number_available'] ) ? (int)$HTTP_POST_VARS['coupons_number_available'] : 0 ). " where coupons_id = '" . $coupons_id . "'"); tep_redirect( tep_href_link( FILENAME_DISCOUNT_COUPONS, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $coupons_id ) ); break; case 'deleteconfirm': tep_db_query($sql = "delete from " . TABLE_DISCOUNT_COUPONS . " where coupons_id = '" .$coupons_id. "'"); tep_db_query($sql = "delete from " . TABLE_DISCOUNT_COUPONS_TO_ORDERS . " where coupons_id = '" .$coupons_id. "'"); //exclusions tep_db_query($sql = "delete from " . TABLE_DISCOUNT_COUPONS_TO_CATEGORIES . " where coupons_id = '" .$coupons_id. "'"); tep_db_query($sql = "delete from " . TABLE_DISCOUNT_COUPONS_TO_MANUFACTURERS . " where coupons_id = '" .$coupons_id. "'"); tep_db_query($sql = "delete from " . TABLE_DISCOUNT_COUPONS_TO_PRODUCTS . " where coupons_id = '" .$coupons_id. "'"); tep_db_query($sql = "delete from " . TABLE_DISCOUNT_COUPONS_TO_CUSTOMERS . " where coupons_id = '" .$coupons_id. "'"); tep_db_query($sql = "delete from " . TABLE_DISCOUNT_COUPONS_TO_ZONES . " where coupons_id = '" .$coupons_id . "'"); //end exclusions tep_redirect(tep_href_link(FILENAME_DISCOUNT_COUPONS, 'page=' . $HTTP_GET_VARS['page'])); break; } } ?> > <?php echo TITLE; ?>
method="post">
NOTICE: '.HEADING_TITLE_VIEW_MANUAL; ?>

  coupons_id, 'size="10" maxlength="32"'.( $action == 'edit' ? ' disabled' : '')); ?>
  coupons_description, 'size="25" maxlength="64"'); ?>
  coupons_discount_amount, 'size="5" maxlength="10"'); echo '  '.TEXT_DISCOUNT_COUPONS_TYPE; echo kgt_draw_type_drop_down( 'discount', 'coupons_discount_type', ''.$cInfo->coupons_discount_type ); echo '
'.TEXT_INFO_DISCOUNT_AMOUNT_HINT.''; ?>
  coupons_date_start) ? tep_date_short( $cInfo->coupons_date_start ) : '' ), 'size="10" maxlength="10"') ; ?>
  coupons_date_end) ? tep_date_short( $cInfo->coupons_date_end ) : '' ), 'size="10" maxlength="10"') ; ?>
  coupons_max_use, 'size="5" maxlength="5"'); ?>
  coupons_min_order, 'size="5" maxlength="5"'); echo '  '.TEXT_DISCOUNT_COUPONS_MIN_ORDER_TYPE; echo kgt_draw_type_drop_down( 'min_order', 'coupons_min_order_type', ''.$cInfo->coupons_min_order_type ); ?>
  coupons_number_available, 'size="5" maxlength="5"'); ?>

' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''; ?>
'' . TEXT_INFO_HEADING_DELETE_DISCOUNT_COUPONS . ''); $contents = array('form' => tep_draw_form('coupons', FILENAME_DISCOUNT_COUPONS, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->coupons_id . '&action=deleteconfirm')); $contents[] = array('text' => TEXT_INFO_DELETE_INTRO); $contents[] = array('text' => '
' . $cInfo->coupons_id . ''); $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); break; default: if (is_object($cInfo)) { $heading[] = array('text' => '' . $cInfo->coupons_id . ''); $contents[] = array('align' => 'center', 'text' => '' . tep_image_button('button_edit.gif', IMAGE_EDIT) . ' '. '' . tep_image_button('button_delete.gif', IMAGE_DELETE) . ' ' //exclusions .'' . tep_image_button('button_product_exclusions.gif', IMAGE_PRODUCT_EXCLUSIONS, 'hspace="2" vspace="2"') . ' ' .'' . tep_image_button('button_manufacturer_exclusions.gif', IMAGE_MANUFACTURER_EXCLUSIONS, 'hspace="2" vspace="2"') . ' ' .'' . tep_image_button('button_category_exclusions.gif', IMAGE_CATEGORY_EXCLUSIONS, 'hspace="2" vspace="2"') . ' ' .'' . tep_image_button('button_customer_exclusions.gif', IMAGE_CUSTOMER_EXCLUSIONS, 'hspace="2" vspace="2"') . ' ' .'' . tep_image_button('button_shipping_zone_exclusions.gif', IMAGE_SHIPPING_ZONE_EXCLUSIONS, 'hspace="2" vspace="2"') . ' ' //end exclusions ); switch( $cInfo->coupons_discount_type ) { case 'shipping': $discount = ( $cInfo->coupons_discount_amount * 100 ).'% '.TEXT_DISPLAY_SHIPPING_DISCOUNT; break; case 'percent': $discount = ( $cInfo->coupons_discount_amount * 100 ).'%'; break; case 'fixed': $discount = $currencies->format( $cInfo->coupons_discount_amount ); break; } $contents[] = array('text' => '
' . TEXT_INFO_DISCOUNT_AMOUNT . ' ' . $discount ); $contents[] = array('text' => '' . TEXT_INFO_DATE_START . ' ' . ( !empty( $cInfo->coupons_date_start ) ? tep_date_short( $cInfo->coupons_date_start ) : TEXT_DISPLAY_UNLIMITED ) ); $contents[] = array('text' => '' . TEXT_INFO_DATE_END . ' ' . ( !empty( $cInfo->coupons_date_end ) ? tep_date_short( $cInfo->coupons_date_end ) : TEXT_DISPLAY_UNLIMITED ) ); $contents[] = array('text' => '' . TEXT_INFO_MAX_USE . ' ' . ( $cInfo->coupons_max_use != 0 ? $cInfo->coupons_max_use : TEXT_DISPLAY_UNLIMITED ) ); $contents[] = array('text' => '' . TEXT_INFO_MIN_ORDER . ' ' . ( $cInfo->coupons_min_order != 0 ? ( $cInfo->coupons_min_order_type == 'price' ? $currencies->format( $cInfo->coupons_min_order ) : (int)$cInfo->coupons_min_order ) : TEXT_DISPLAY_UNLIMITED ) ); $contents[] = array('text' => '' . TEXT_INFO_NUMBER_AVAILABLE . ' ' . ( $cInfo->coupons_number_available != 0 ? $cInfo->coupons_number_available : TEXT_DISPLAY_UNLIMITED ) ); } break; } if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) { echo ' ' . "\n"; } } ?>
coupons_id) ) { echo ' ' . "\n"; } else { echo ' ' . "\n"; } ?>
 
'.( !empty( $coupons['coupons_description'] ) ? '( '.$coupons['coupons_description'].' )' : '' ) .''; ?> format( $coupons['coupons_discount_amount'] ); break; } ?> format( $coupons['coupons_min_order'] ) : (int)$coupons['coupons_min_order'] ) : TEXT_DISPLAY_UNLIMITED ); ?>   coupons_id ) ) { echo tep_image( DIR_WS_IMAGES.'icon_arrow_right.gif', '' ); } else { echo '' . tep_image( DIR_WS_IMAGES.'icon_info.gif', IMAGE_ICON_INFO ).''; } ?>
display_links($coupons_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?>
' . tep_image_button('button_new_coupon.gif', IMAGE_NEW_COUPON) . ''; ?>
' . "\n"; $box = new box; echo $box->infoBox($heading, $contents); echo '