ZenCart_Documentation  1.5.0
http://www.collinsharper.com
C:/xampp/htdocs/zen-cart/admin/gv_queue.php
Go to the documentation of this file.
00001 <?php
00010   require('includes/application_top.php');
00011 
00012   require(DIR_WS_CLASSES . 'currencies.php');
00013   $currencies = new currencies();
00014 
00015   if (isset($_GET['order'])) $_GET['order'] = (int)$_GET['order'];
00016   if (isset($_GET['gid'])) $_GET['gid'] = (int)$_GET['gid'];
00017 
00018 // bof: find gv for a particular order and set page
00019   if ($_GET['order'] != '') {
00020     $gv_check = $db->Execute("select order_id, unique_id
00021                                   from " . TABLE_COUPON_GV_QUEUE . "
00022                                   where order_id = '" . $_GET['order'] . "' and release_flag= 'N' limit 1");
00023 
00024     $_GET['gid'] = $gv_check->fields['unique_id'];
00025 
00026     $gv_page = $db->Execute("select c.customers_firstname, c.customers_lastname, gv.unique_id, gv.date_created, gv.amount, gv.order_id from " . TABLE_CUSTOMERS . " c, " . TABLE_COUPON_GV_QUEUE . " gv where (gv.customer_id = c.customers_id and gv.release_flag = 'N')" . " order by gv.order_id, gv.unique_id");
00027     $page_cnt=1;
00028     while (!$gv_page->EOF) {
00029       if ($gv_page->fields['order_id'] == $_GET['order']) {
00030         break;
00031       }
00032       $page_cnt++;
00033       $gv_page->MoveNext();
00034     }
00035     $_GET['page'] = round(($page_cnt/MAX_DISPLAY_SEARCH_RESULTS));
00036     zen_redirect(zen_href_link(FILENAME_GV_QUEUE, 'gid=' . $gv_check->fields['unique_id'] . '&page=' . $_GET['page']));
00037   }
00038 // eof: find gv for a particular order and set page
00039 
00040   if ($_GET['action'] == 'confirmrelease' && isset($_POST['gid'])) {
00041     $gv_result = $db->Execute("select release_flag
00042                                from " . TABLE_COUPON_GV_QUEUE . "
00043                                where unique_id='" . (int)$_POST['gid'] . "'");
00044 
00045     if ($gv_result->fields['release_flag'] == 'N') {
00046       $gv_resulta = $db->Execute("select customer_id, amount, order_id
00047                                   from " . TABLE_COUPON_GV_QUEUE . "
00048                                   where unique_id='" . (int)$_POST['gid'] . "'");
00049 
00050       if ($gv_resulta->RecordCount() > 0) {
00051       $gv_amount = $gv_resulta->fields['amount'];
00052 
00053         // Begin composing email content
00054 //      //Let's build a message object using the email class
00055       $mail = $db->Execute("select customers_firstname, customers_lastname, customers_email_address
00056                            from " . TABLE_CUSTOMERS . "
00057                            where customers_id = '" . $gv_resulta->fields['customer_id'] . "'");
00058 
00059       $message  = TEXT_REDEEM_GV_MESSAGE_HEADER . "\n" . HTTP_CATALOG_SERVER . DIR_WS_CATALOG . "\n\n" . TEXT_REDEEM_GV_MESSAGE_RELEASED;
00060       $message .= sprintf(TEXT_REDEEM_GV_MESSAGE_AMOUNT, $currencies->format($gv_amount)) . "\n\n";
00061       $message .= TEXT_REDEEM_GV_MESSAGE_THANKS . "\n" . STORE_OWNER . "\n\n" . HTTP_CATALOG_SERVER . DIR_WS_CATALOG;
00062       $message .= TEXT_REDEEM_GV_MESSAGE_BODY;
00063       $message .= TEXT_REDEEM_GV_MESSAGE_FOOTER;
00064           $message .= "\n-----\n" . sprintf(EMAIL_DISCLAIMER, STORE_OWNER_EMAIL_ADDRESS) . "\n\n";
00065 
00066       $html_msg['EMAIL_FIRST_NAME'] = $mail->fields['customers_firstname'];
00067       $html_msg['EMAIL_LAST_NAME']  = $mail->fields['customers_lastname'];
00068       $html_msg['GV_NOTICE_HEADER']  = TEXT_REDEEM_GV_MESSAGE_HEADER;
00069       $html_msg['GV_NOTICE_RELEASED']  = TEXT_REDEEM_GV_MESSAGE_RELEASED;
00070       $html_msg['GV_NOTICE_AMOUNT_REDEEM'] = sprintf(TEXT_REDEEM_GV_MESSAGE_AMOUNT, '<strong>' . $currencies->format($gv_amount) . '</strong>');
00071       $html_msg['GV_NOTICE_VALUE'] = $currencies->format($gv_amount);
00072       $html_msg['GV_NOTICE_THANKS'] = TEXT_REDEEM_GV_MESSAGE_THANKS;
00073       $html_msg['TEXT_REDEEM_GV_MESSAGE_BODY'] = TEXT_REDEEM_GV_MESSAGE_BODY;
00074       $html_msg['TEXT_REDEEM_GV_MESSAGE_FOOTER'] = TEXT_REDEEM_GV_MESSAGE_FOOTER;
00075 
00076 //send the message
00077         zen_mail($mail->fields['customers_firstname'] . ' ' . $mail->fields['customers_lastname'], $mail->fields['customers_email_address'], TEXT_REDEEM_GV_SUBJECT . TEXT_REDEEM_GV_SUBJECT_ORDER . $gv_resulta->fields['order_id'] , $message, STORE_NAME, EMAIL_FROM, $html_msg, 'gv_queue');
00078 
00079 
00080 
00081       $gv_amount=$gv_resulta->fields['amount'];
00082       $gv_result=$db->Execute("select amount
00083                                from " . TABLE_COUPON_GV_CUSTOMER . "
00084                                where customer_id='" . $gv_resulta->fields['customer_id'] . "'");
00085 
00086       $customer_gv=false;
00087       $total_gv_amount=0;
00088       if ($gv_result->RecordCount() > 0) {
00089         $total_gv_amount=$gv_result->fields['amount'];
00090         $customer_gv=true;
00091       }
00092       $total_gv_amount=$total_gv_amount+$gv_amount;
00093       if ($customer_gv) {
00094         $db->Execute("update " . TABLE_COUPON_GV_CUSTOMER . "
00095                       set amount='" . $total_gv_amount . "'
00096                       where customer_id='" . $gv_resulta->fields['customer_id'] . "'");
00097       } else {
00098         $db->Execute("insert into " . TABLE_COUPON_GV_CUSTOMER . "
00099                     (customer_id, amount)
00100                     values ('" . $gv_resulta->fields['customer_id']. "', '" . $total_gv_amount . "')");
00101       }
00102         $db->Execute("update " . TABLE_COUPON_GV_QUEUE . "
00103                       set release_flag= 'Y'
00104                       where unique_id='" . (int)$_POST['gid'] . "'");
00105       }
00106     }
00107     // return back to same page after release
00108     zen_redirect(zen_href_link(FILENAME_GV_QUEUE, 'page=' . (int)$_GET['page']));
00109   }
00110 ?>
00111 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
00112 <html <?php echo HTML_PARAMS; ?>>
00113 <head>
00114 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
00115 <title><?php echo TITLE; ?></title>
00116 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
00117 <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
00118 <script language="javascript" src="includes/menu.js"></script>
00119 <script type="text/javascript">
00120   <!--
00121   function init()
00122   {
00123     cssjsmenu('navbar');
00124     if (document.getElementById)
00125     {
00126       var kill = document.getElementById('hoverJS');
00127       kill.disabled = true;
00128     }
00129   }
00130   // -->
00131 </script>
00132 </head>
00133 <body onload="init()">
00134 <!-- header //-->
00135 <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
00136 <!-- header_eof //-->
00137 
00138 <!-- body //-->
00139 <table border="0" width="100%" cellspacing="2" cellpadding="2">
00140   <tr>
00141 <!-- body_text //-->
00142     <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
00143       <tr>
00144         <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
00145           <tr>
00146             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
00147             <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
00148           </tr>
00149         </table></td>
00150       </tr>
00151       <tr>
00152         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
00153           <tr>
00154             <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
00155               <tr class="dataTableHeadingRow">
00156                 <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CUSTOMERS; ?></td>
00157                 <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_ORDERS_ID; ?></td>
00158                 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_VOUCHER_VALUE; ?></td>
00159                 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_DATE_PURCHASED; ?></td>
00160                 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
00161               </tr>
00162 <?php
00163   $gv_query_raw = "select c.customers_firstname, c.customers_lastname, gv.unique_id, gv.date_created, gv.amount, gv.order_id from " . TABLE_CUSTOMERS . " c, " . TABLE_COUPON_GV_QUEUE . " gv where (gv.customer_id = c.customers_id and gv.release_flag = 'N')" . " order by gv.order_id, gv.unique_id";
00164   $gv_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS, $gv_query_raw, $gv_query_numrows);
00165   $gv_list = $db->Execute($gv_query_raw);
00166   while (!$gv_list->EOF) {
00167     if (((!$_GET['gid']) || (@$_GET['gid'] == $gv_list->fields['unique_id'])) && (!$gInfo)) {
00168       $gInfo = new objectInfo($gv_list->fields);
00169     }
00170     if ( (is_object($gInfo)) && ($gv_list->fields['unique_id'] == $gInfo->unique_id) ) {
00171       echo '              <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . zen_href_link('gv_queue.php', zen_get_all_get_params(array('gid', 'action')) . 'gid=' . $gInfo->unique_id . '&action=edit') . '\'">' . "\n";
00172     } else {
00173       echo '              <tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'hand\'" onmouseout="this.className=\'dataTableRow\'" onclick="document.location.href=\'' . zen_href_link('gv_queue.php', zen_get_all_get_params(array('gid', 'action')) . 'gid=' . $gv_list->fields['unique_id']) . '\'">' . "\n";
00174     }
00175 ?>
00176                 <td class="dataTableContent"><?php echo $gv_list->fields['customers_firstname'] . ' ' . $gv_list->fields['customers_lastname']; ?></td>
00177                 <td class="dataTableContent" align="center"><?php echo $gv_list->fields['order_id']; ?></td>
00178                 <td class="dataTableContent" align="right"><?php echo $currencies->format($gv_list->fields['amount']); ?></td>
00179                 <td class="dataTableContent" align="right"><?php echo zen_datetime_short($gv_list->fields['date_created']); ?></td>
00180                 <td class="dataTableContent" align="right"><?php if ( (is_object($gInfo)) && ($gv_list->fields['unique_id'] == $gInfo->unique_id) ) { echo zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '<a href="' . zen_href_link(FILENAME_GV_QUEUE, 'page=' . $_GET['page'] . '&gid=' . $gv_list->fields['unique_id']) . '">' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
00181               </tr>
00182 <?php
00183     $gv_list->MoveNext();
00184   }
00185 ?>
00186               <tr>
00187                 <td colspan="5"><table border="0" width="100%" cellspacing="0" cellpadding="2">
00188                   <tr>
00189                     <td class="smallText" valign="top"><?php echo $gv_split->display_count($gv_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_GIFT_VOUCHERS); ?></td>
00190                     <td class="smallText" align="right"><?php echo $gv_split->display_links($gv_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_GET['page']); ?></td>
00191                   </tr>
00192                 </table></td>
00193               </tr>
00194             </table></td>
00195 <?php
00196   $heading = array();
00197   $contents = array();
00198   switch ($_GET['action']) {
00199     case 'release':
00200       $heading[] = array('text' => '[' . $gInfo->unique_id . '] ' . zen_datetime_short($gInfo->date_created) . ' ' . $currencies->format($gInfo->amount));
00201       $contents[] = array('align' => 'center', 'text' => zen_draw_form('gv_release', FILENAME_GV_QUEUE, 'action=confirmrelease&page=' . $_GET['page']) . zen_image_submit('button_confirm_red.gif', IMAGE_CONFIRM) . '<input type="hidden" name="gid" value="' . $gInfo->unique_id . '" /></form>' . '<a href="' . zen_href_link('gv_queue.php', 'action=cancel&gid=' . $gInfo->unique_id . '&page=' . $_GET['page'],'NONSSL') . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
00202 //      $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link('gv_queue.php', 'action=confirmrelease&gid=' . $gInfo->unique_id . '&page=' . $_GET['page'],'NONSSL') . '">' . zen_image_button('button_confirm_red.gif', IMAGE_CONFIRM) . '</a> <a href="' . zen_href_link('gv_queue.php', 'action=cancel&gid=' . $gInfo->unique_id . '&page=' . $_GET['page'],'NONSSL') . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
00203       break;
00204     default:
00205       $heading[] = array('text' => '[' . $gInfo->unique_id . '] ' . zen_datetime_short($gInfo->date_created) . ' ' . $currencies->format($gInfo->amount));
00206 
00207       if ($gv_list->RecordCount() == 0) {
00208         $contents[] = array('align' => 'center','text' => TEXT_GV_NONE);
00209       } else {
00210         $contents[] = array('align' => 'center','text' => '<a href="' . zen_href_link('gv_queue.php','action=release&gid=' . $gInfo->unique_id . '&page=' . $_GET['page'],'NONSSL'). '">' . zen_image_button('button_release_gift.gif', IMAGE_RELEASE) . '</a>');
00211 
00212 // quick link to order
00213         $contents[] = array('align' => 'center', 'text' => '<br />' . zen_image(DIR_WS_IMAGES . 'pixel_black.gif','','90%','3'));
00214         $contents[] = array('align' => 'center', 'text' => TEXT_EDIT_ORDER . $gInfo->order_id);
00215         $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_ORDERS, 'oID=' . $gInfo->order_id . '&action=edit', 'NONSSL') . '">' . zen_image_button('button_order.gif', IMAGE_ORDER) . '</a>');
00216       }
00217       break;
00218    }
00219 
00220   if ( (zen_not_null($heading)) && (zen_not_null($contents)) ) {
00221     echo '            <td width="25%" valign="top">' . "\n";
00222 
00223     $box = new box;
00224     echo $box->infoBox($heading, $contents);
00225 
00226     echo '            </td>' . "\n";
00227   }
00228 ?>
00229           </tr>
00230         </table></td>
00231       </tr>
00232     </table></td>
00233 <!-- body_text_eof //-->
00234   </tr>
00235 </table>
00236 <!-- body_eof //-->
00237 
00238 <!-- footer //-->
00239 <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
00240 <!-- footer_eof //-->
00241 <br />
00242 </body>
00243 </html>
00244 <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
 All Data Structures Namespaces Files Functions Variables Enumerations