Preamble: First, thanks to all that are willing to lend a hand. I really appreciate the help I recieve here.
So with that said, I have been working on mod to allow pregenerated customer support messages (ie, canned responses) for my ecommercie site.
what I have done is add an extra dropdown box that pulls data from a table where the predefined responses are. This works great, and I even have it working through email and updateing the customers order history yada yada yada, thats not important.
The exact problem is that I have to option here on this page. I have a comments box, and I have the canned responses drop down box. Now both of these are set to update the same table colum. i.e. "comments"
What I need to do is this, I need either to
A: add a radio button that selects which box, either the custom comments box, or the drop downbox to listen to.
or
B: simply a check box next to the dropdown box that instructs it to listen only the drop down box, and ignore the comments box.
or
C: My best wish,
just have an extra option in the dropdown box, that is labeled no canned response, which in case this is selected in the drop down box, only the comments field is listened to.
so I think its time we look at my code:p ill break things down for ya
ok so we have our header for tabular data im going to call
<table width="99%" border="0" cellspacing="0" cellpadding="1" >
<tr>
<td colspan="5"><div class="storyheader"><h3><?php echo BOX_ENTRY_NEW_ORDERS; ?></h3></div></td>
</tr>
<tr>
<td bgcolor="#FFFFFF" class="smallText" align="left"><b><?php echo TABLE_HEADING_DATE_ADDED; ?></b></td>
<td bgcolor="#FFFFFF" class="smallText" align="left"><b><?php echo TABLE_HEADING_CUSTOMER_NOTIFIED; ?></b></td>
<td bgcolor="#FFFFFF" class="smallText" align="left"><b><?php echo TABLE_HEADING_STATUS; ?></b></td>
<td bgcolor="#FFFFFF" class="smallText" align="left"><b><?php echo TABLE_HEADING_COMMENTS; ?></b></td>
</tr>
<tr>
<td><?php echo zen_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
</tr>
lets grab the data and display it
<?php
// Define my background colors
$row1 = '<tr class="OrderHistoryRow2">';
$row2 = '<tr class="OrderHistoryRow">';
$row_count = 0;
$orders_history = $db->Execute("select orders_status_id, date_added, customer_notified, comments
from " . TABLE_ORDERS_STATUS_HISTORY . "
where orders_id = '" . zen_db_input($oID) . "'
order by date_added");
if ($orders_history->RecordCount() > 0) {
while (!$orders_history->EOF) {
$row_color = ($row_count % 2) ? $row1 : $row2;
echo ' ' . $row_color . "\n" .
' <td class="smallText" align="left">' . zen_datetime_short($orders_history->fields['date_added']) . '</td>' . "\n" .
' <td class="smallText" align="center">';
if ($orders_history->fields['customer_notified'] == '1') {
echo zen_image(DIR_WS_ICONS . 'tick.gif', ICON_TICK) . "</td>\n";
} else {
echo zen_image(DIR_WS_ICONS . 'cross.gif', ICON_CROSS) . "</td>\n";
}
echo ' <td class="smallText">' . $orders_status_array[$orders_history->fields['orders_status_id']] . '</td>' . "\n" .
' <td width="500" class="smallText">' . nl2br(zen_db_output($orders_history->fields['comments'])) . ' </td>' . "\n" .
' </tr>' . "\n";
$row_count++;
$orders_history->MoveNext();
}
} else {
echo ' <tr>' . "\n" .
' <td class="smallText" colspan="5">' . TEXT_NO_ORDER_HISTORY . '</td>' . "\n" .
' </tr>' . "\n";
}
?>
</table></td>
</tr>
Now lets add the area to make updates to the order history mates. lets give them the ability to add custom comments
<tr>
<td class="main"><br /><b><?php echo TABLE_HEADING_COMMENTS; ?></b></td>
</tr>
<tr>
<td><?php echo zen_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
</tr>
<tr><?php echo zen_draw_form('status', FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=update_order', 'post', '', true); ?>
<td class="main"><?php echo zen_draw_textarea_field('comments', 'soft', '60', '5'); ?></td>
</tr>
Ok now lets give them some more options, lets let them select a custom response that will populate are comments area as well but rather from a defined response.
<tr>
<td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td><table border="0" cellspacing="0" cellpadding="2">
<tr>
<td><table border="0" cellspacing="0" cellpadding="2">
<?php
$sql='select response_id, response_name, response_text from ' . TABLE_SUPPORT_RESPONSES .' order by response_name';
$response_query=$db->Execute($sql);
while (!$response_query->EOF){
$response_array[]=array('id'=>$response_query->fields['response_text'],
'text'=>$response_query->fields['response_name']);
$response_query->MoveNext();
} //endwhile
?>
<tr>
<td class="main"><b><?php echo 'Automated Response'; ?></b> <?php echo zen_draw_pull_down_menu('comments', $response_array); ?></td>
</tr>
lets give them the rest of the options now
<tr>
<td class="main"><b><?php echo ENTRY_STATUS; ?></b> <?php echo zen_draw_pull_down_menu('status', $orders_statuses, $order->info['orders_status']); ?></td>
</tr>
<tr>
<td class="main"><b><?php echo ENTRY_NOTIFY_CUSTOMER; ?></b> <?php echo zen_draw_checkbox_field('notify', '', true); ?></td>
<td class="main"><b><?php echo ENTRY_NOTIFY_COMMENTS; ?></b> <?php echo zen_draw_checkbox_field('notify_comments', '', true); ?></td>
</tr>
</table></td>
<td valign="top"><?php echo zen_image_submit('button_update.gif', IMAGE_UPDATE); ?></td>
</tr>
</table></td>
</form>
Now lets make sure everything gets emailed and inputed into the right places. lets go back to the top of the page. oh theres some extra stuff in there that obviosly handles other aspects of the page but all work in concert i believe so i included everything in this snippet
now i have to do two posts becuase of size so look below for the rest.