Jump to content

versatilewt

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.versatilewt.com

Profile Information

  • Gender
    Not Telling

versatilewt's Achievements

Member

Member (2/5)

0

Reputation

  1. Thanks ChemicalBliss, The only thing is, I'm trying to have a generic class that can handle the simple cases and the variable case, and get the sub template out of the db if it's needed - and essentially examine the "replacements" array to see if it's necessary. I was kind of envisioning passing something like: array( '%customer_name%'=>'Bob', '%website_name%'=>'Acme', '%products%' = array( '0'=>array('%product_name%'=>'WidgetA', '%product_price%'=>'$1'), '1'=>array('%product_name%'=>'WidgetB', '%product_price%'=>'$2'), '2'=>array('%product_name%'=>'WidgetC', '%product_price%'=>'$3'), ) );
  2. Hi all, So I'm setting up a system that has a lot of emails, and variable replacement within it, so I'm writing a class to manage some variable replacement for templates stored in the database. Here's a brief example: // template is stored in db, so that's how this would get loaded in $template = "Hello, %customer_name%, thank you for contacting %website_name%"; // The array of replacements is built manually and passed to the class // with actual values being called from db $replacements = array('%customer_name%'=>'Bob', '%website_name%'=>'Acme'); $rendered = str_replace(array_keys($replacements), $replacements, $template); Now, that works well and good for single var replacements, basic stuff. However, there are some places where there should be a for loop, and I'm lost how to implement it. The idea is there'd be a template like this: Where, {products} would be an array passed to the template, which the is looped over for products requested, with a format like: So an example rendered version of this would be: What's the best way to accomplish this?
  3. I'm programming an application to automate business processes for a company. The system has a lot of notifications required, and I'm trying to think of the best way to set up the notification system. For example, when a customer replies to an email, it gets piped into the system and a sales rep gets an email. When a customer pays, a notification gets sent to the sales rep, the manager, and the vp of the divison. When an order ships, a notification gets sent to the sales rep, the manager, and the fulfillment department. So, my thought is to make a rules table, with the name of the rule for people that get notified in addition to the sales rep. Then, have a n:m table for users to rules, and when a notification should happen, look up the rule name in the db, find who gets notified, and send out the notifications. One thing I'm having an issue with is, how would I make a rule that references the particular sales rep (i.e. I'd make a rule to notify sales rep, but that sales rep would be different on every account - the n:m table for rules->users couldn't directly link to the actual sales rep, i'd have to be like a variable or something) I'm trying to keep this flexible for future considerations of rule changes (say the vp wants to stop getting copied on certain status updates). Any advice on the best way to go about something like this?
  4. So, basically I need to list multiple orders on a page, along with their line items. There is an orders table, and a line items table - basic set up. This is the way I'm doing it now, and I'm wondering if there's not a more efficient way to do this. I've simplified the code a bit for my question here, but it gets the point across $order = $db->getAssoc(SELECT * FROM orders); foreach($order as $k=>$v) { $line_item = $db->getAssoc("SELECT * FROM order_line_item WHERE order_id = $k"); $order[$k]['shipping'] = $line_item; } And then I just operate on the order array to get the info. Is there a better way to do this?
  5. Here's what I'm trying to do Right now I have a bunch of "template" email responses stored in my DB, which are used frequently. Basically, what I'd like to do is for the templates, store things like ##CUSTOMER_NAME## and ##PRODUCT_NAME## in them. Then, when emailing, I'd like to pass an array of data (like, array("CUSTOMER_NAME"=>"Bob, "PRODUCT_NAME"=>"Widget") or whatever, depending on the particular email. There are also some basic if statements I want to execute, like if ##STATE## of customer == my state, say we'll charge you sales tax, or if ##STATE## in_array("CA", "WA", "OR") say "west coast" or something. I'm guessing it would involve preg_replace and some for loops, but I'm not sure the most efficient way to go about this. Any advice/suggestions appreciated. Thanks.
  6. I used the query SELECT q.quote_id, qli.quote_line_item_id FROM quote q JOIN quote_line_item qli USING ( quote_id ) And I get the results that I'm looking for, however I'm facing a php issue regarding the output now, so I'm marking this as solved and rewriting the request in the php help forum.
  7. So, here's my problem. I'm running php5 and mysql5. I have an app with "quotes" in it, and each quote has line items (products). The database, abbreviated version is: QUOTE: quote_id QUOTE_LINE_ITEM: quote_line_item_id, quote_id, qty, price I'm trying to set up a summary page, which will list quotes as well as the related quote line items. For instance (I would have specific things like customer name on the "details of quote" line and product name, qty, etc for the "details of product request" lines): I have a query which gets the results just fine, each line has the full quote details for the respective quote, and then the line item is at the end of the result set on each line. SELECT q.quote_id, qli.quote_line_item_id FROM quote q JOIN quote_line_item qli USING ( quote_id ) I'm using ADODB, and to run the query ($sql = the query listed above), I call $result = $db->GetAssoc($sql) However, when I do a print_r($result), only one of the rows for a quote appears, even if there are multiple line items which appear when querying directly through phpMyAdmin. If I change the query to something like SELECT CONCAT (q.quote_id, qli.quote_line_item_id) AS uniqueID, q.quote_id, qli.quote_line_item_id FROM quote q JOIN quote_line_item qli USING ( quote_id ) All of the results show up, but I'll have a hard time looping because now the quote_ids aren't really associated. Can anyone help me to loop through this in the one query? My alternative is to do a foreach where for each quote I do a separate query for the quote line items, which seems really inefficient to me. Hopefully I was clear enough. Thanks in advance.
  8. I have found that email seems to send better when you use mail($email, $subject, $body, $headers, "-f$email");
  9. I have a "quote" table and a "quote_line_item" table. Thus, there can be multiple quote_line_items per quote. A simplified example of the tables: QUOTE: quote_id QUOTE_LINE_ITEM: quote_line_item_id, quote_id, product_id What I'm trying to get quote_id: 1 - quote_line_item_id: 2 - quote_line_item_id: 3 quote_id: 2 - quote_line_item_id: 4 quote_id: 3 - quote_line_item_id: 5 - quote_line_item_id: 6 In my application, I want to display a summary of say 20 quotes per page, but I also want to list the line items from those quotes below it. Right now I'm doing a nested foreach (looping through the quotes, performing a select * from quote_line_item_id WHERE quote_id= $quote_id), but I feel like this is inefficient. Can someone please offer advice on a better way to do this? Getting the line items for one quote (for example, a quote detail page) is easy, I am just not sure the best way to list the line items from multiple quotes on a summary page easily. Thank you in advice.
  10. Hi, I have a project where every lead comes in as a quote, is followed up with, and then finally an order is placed. So, the entry is first in a quote table, and then once all is finalized, it is placed as an order. I'm debating how to approach the table structure, as I'm revising there rest of the application. Would it make more sense to have a separate "orders" and "quotes" tables, or to have a single table with a orders/quotes flag column? If I did the multiple table approach, I would have order_line_item and quote_line_item tables for each as well. Any advice or thoughts will be appreciated. Regards, brian
  11. My current app is outgrowing its shared hosting environment, and i'm looking at VPS vs dedicated hosting. i'm not quite sure what type of memory and proc requirements i'd need. I have about 5 employee users constantly accessing a php/mysql crm app. probably about 100 visitors per day viewing a request for quote page driven by the DB. Mostly read queries, and the database is pretty well optimized. Also, would be storing hosting an osCommerce implementation that gets about 50-100 users / day. I tried moving some sites to a VPS with 256 mb RAM, and the apache process kept on failing and I wouldn't be able to log in to the web host manager and would have to do a hard reset. So that has since been scrapped. any advice/suggestions?
  12. I have a system currently wherein multiple customers are managed by multiple sales reps. These customers/reps have back and forth conversationss before a sale is closed. There is a link in each email that gets sent to the customers that they are asked to click and fill out a subject/body reply from through so that their reply is posted through this sales system. However, few customers do this, and reps end up with cluttered and hard to manage inboxes. What I would ultimately like to do is have is I guess like a "trouble ticket" system functionality, where a user will simply reply to an email sent to them using their mail client's reply button and do the "reply above this line" thing, and then have this sent to a script that parses it and posts the reply to the appropriate order so that the rep can keep track of the conversation with the customer. However, what is complicating the situation to me is, how do I keep track of which order the message should be posted to? Each order has a unique number, but would I need a unique email alias for each order that would forward to an email address that the script reads from? Or would I need a unique email address for each sales rep's orders to be tracked at, with the order number in the subject of the email or somewhere in the body of the email? Any suggestions on programs to look at, etc etc? Thanks for the help.
  13. I'm working on a project where there are two different web sites that share many similar items in a catalog. One web site is for the industry professionals, and the other is directed towards consumers and end users more. What I would ultimately like to do is have them share the same products tables, with different pricing levels available for each web site, and the possibility for a product to show up on one web site but not both. Any suggestions?
  14. I had thought about that needing to add a new address only if the current one is in use. Perhaps another flag would be in order, "in_use" or something? And then have the basic if if(in_use)   mark old as inactive, create new listing else update existing ?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.