public function createSections(DAO $dao) { if ($dao->queryOK()) { $sections = array(); $row = $dao->next(); $count = $row['cnt']; $letter = $row[$this->_subcat_field][0]; $first_section = $last_section = $row[$this->_subcat_field]; while ($row = $dao->next()) { if ($row[$this->_subcat_field][0] == $letter) { // aggregating mode $count += $row['cnt']; $last_section = $row[$this->_subcat_field]; } else { // section assignment mode $section = $first_section == $last_section ? $first_section : "{$first_section}-{$last_section}"; $sections[] = array('section' => $section, 'section_slug' => LWS::slugify($section), 'count' => $count); // update loop values for next section $count = $row['cnt']; $letter = $row[$this->_subcat_field][0]; $first_section = $last_section = $row[$this->_subcat_field]; } } // end while() // add last section aggregated $section = $first_section == $last_section ? $first_section : "{$first_section}-{$last_section}"; $sections[] = array('section' => $section, 'section_slug' => LWS::slugify($section), 'count' => $count); } else { $sections = NULL; } return $sections; }
<p id='rfq_box'><?php echo link_to("{$category} RFQ", '@rfq?category=' . LWS::slugify($category), array('title' => "{$category} request for quote")); ?> </p> <div id='expert_box'> <h4>Speak with an Electrical Supply Expert</h4> <img src='/images/circuit-breaker-expert-trans.png' alt='electrical circuit breakers expert 800-390-3299' /> </div> <div id='ship_regional'> <h4>WE SHIP FROM <strong>REGIONAL <span>LOCATIONS</span></strong></h4> </div>
/** * Method for executing fuses subcategory creation logic. * Method may use a Strategy object if logic becomes sufficiently complex. * !!! _manufLevelSidebar global template expects each array in $sections * !!! to have the following elements: * !!! section, section_slug, & count * Possible fields for subcategorization: * class, & type (fuses_subcategory table) * Providing optional 'subcat_slug' field for each section since Fuses * use 2 fields(subcategories) for creating sections. * @param Integer $manuf_id */ public function fetchSectionsByManuf($manuf_id) { $this->query("SELECT count(part.part_no) AS count, class, fuse_subcategory.type, \r\n\t\t\t\t IF(ISNULL(class),IF(ISNULL(fuse_subcategory.type),'void','type' ),IF(ISNULL(fuse_subcategory.type),'class','class_type')) \r\n\t\t\t\t AS label \r\n\t\t\t\t FROM part \r\n\t\t\t\t INNER JOIN fuse_subcategory USING (part_no) \r\n\t\t\t\t WHERE cat_id = '{$this->_id}' AND manuf_id={$manuf_id} \r\n\t\t\t\t GROUP BY class, fuse_subcategory.type \r\n\t\t\t\t HAVING (label = 'class' OR label = 'type') AND count > 5 \r\n\t\t\t\t ORDER BY label ASC, class ASC, fuse_subcategory.type ASC \r\n\t\t\t\t"); if (!$this->_subcat_strategy instanceof iSubcatStrategy) { // subcategorization logic can be handled without a strategy if ($this->queryOK()) { $sections = array(); while ($row = $this->next()) { $sections[] = array('section' => "{$row[$row['label']]} - " . ucwords($row['label']), 'section_slug' => LWS::slugify($row[$row['label']]), 'count' => $row['count'], 'subcat_slug' => $row['label']); } /* * No point in having subcategory pagination if there is only 1 section. * It will just be a duplicate of the catalog. */ if (count($sections) == 1) { $sections = NULL; } } else { $sections = NULL; } } else { $sections = $this->_subcat_strategy->createSections($this); } $this->notifyObserver('default'); return $sections; }
<p id='rfq_box'><?php echo link_to("{$param['category']} RFQ", '@rfq?category=' . LWS::slugify($param['category']), array('title' => "{$param['category']} request for quote")); ?> </p> <div id='expert_box'> <h4>Speak with an Electrical Supply Expert</h4> <img src='/images/circuit-breaker-expert-trans.png' alt='electrical circuit breakers expert 800-390-3299' /> </div> <ul id='biz_features'> <li class='first'>Sales Support:<br />24 hours a day,<br />365 days a year</li> <li>No minimum order quantity</li> <li>Overnight Shipping Available</li> <li>On-line order tracking</li> <li>Bulk discounts available for some items</li> <li>Certified Guarantee <br /> on all products</li> </ul>
public function build($rfq) { $email = array(); $email['ticket_id'] = $rfq['ticket_id']; $email['emp_email'] = $rfq['from']; $email['emp_name'] = $rfq['user']['full_name']; $email['emp_phone'] = $rfq['user']['phone']; $email['emp_ext'] = $rfq['user']['phone_ext']; $email['date'] = date(sfConfig::get('app_formats_date_email')); // prepare email openning if (!empty($rfq['customer_name'])) { $email['customer'] = $rfq['customer_name']; if (strtolower($rfq['customer_name']) == strtolower($rfq['customer_company'])) { $email['openning'] = "Hello {$rfq['customer_name']},<br />Based on your inquiry, we have prepared this quote for you."; } else { $email['openning'] = "Hello {$rfq['customer_name']},<br />Based on your inquiry, we have prepared this quote for {$rfq['customer_company']}."; } } else { $email['customer'] = $rfq['customer_company']; $email['openning'] = "Based on your inquiry, we have prepared this quote for {$rfq['customer_company']}."; } // initialize quoted parts array, and variable to hold database version of template $email['parts'] = array(); $db_note = ''; $parts_cnt = 1; // check if previously entered parts are being used for the email quote if (!empty($rfq['rqx_keys'])) { $p = explode('_', $rfq['rqx_keys']); foreach ($p as $v) { $keys = explode(':', $v); $row_idx = $keys[0]; // should be at least 1 quoted price if (empty($rfq['u:quoted_new'][$row_idx])) { $display = 'grn'; } else { if (empty($rfq['u:quoted_grn'][$row_idx])) { $display = 'new'; } else { $display = 'both'; } } $img_file = strtolower($rfq['u:part_no'][$row_idx]) . '.jpg'; if (file_exists("/var/www/vhosts/livewiresupply.com/httpdocs/web/images/thumbs/{$img_file}")) { $img = "http://livewiresupply.com/images/thumbs/{$img_file}"; } else { $img = 'http://livewiresupply.com/images/thumbs/default.png'; } $part_no = strtoupper($rfq['u:part_no'][$row_idx]); $part_desc = empty($rfq['u:notes'][$row_idx]) ? $part_no : $part_no . "<span style='display: block;font-weight: normal;color:#000;'>{$rfq['u:notes'][$row_idx]}</span>"; $new = '$' . number_format(floatval(str_replace(',', '', str_replace('$', '', $rfq['u:quoted_new'][$row_idx]))), 2); $grn = '$' . number_format(floatval(str_replace(',', '', str_replace('$', '', $rfq['u:quoted_grn'][$row_idx]))), 2); $qty = intval($rfq['u:qty_req'][$row_idx]); $inventory = empty($rfq['u:lead_time'][$row_idx]) ? 'Yes' : stripslashes($rfq['u:lead_time'][$row_idx]); $pne = LWS::encode($part_no); // better to change the html and use the ajax price lookup request to build a url. don't have the patience right now. $url = $rfq['u:mfr'][$row_idx] == 'Not Chosen' ? 'http://livewiresupply.com/' : 'http://livewiresupply.com/' . LWS::slugify($rfq['u:category'][$row_idx]) . '/' . LWS::slugify($rfq['u:mfr'][$row_idx]) . "/{$pne}.html"; $btn = isset($rfq['u:display'][$row_idx]) && intval($rfq['u:display'][$row_idx]) > 0 ? 'buy-btn.gif' : 'call-btn.gif'; $btn_txt = isset($rfq['u:display'][$row_idx]) && intval($rfq['u:display'][$row_idx]) > 0 ? '' : "<br /><span style='font-size: 9px;'>800.390.3299</span>"; $email['parts'][] = array('part_no' => $part_no, 'part_desc' => $part_desc, 'img' => $img, 'display' => $display, 'new' => $new, 'grn' => $grn, 'qty' => $qty, 'inventory' => $inventory, 'url' => $url, 'btn' => $btn, 'btn_txt' => $btn_txt); if ($grn == '$0.00') { $grn = 'Not Quoted'; } if ($new == '$0.00') { $new = 'Not Quoted'; } $db_note .= "{$parts_cnt}. {$part_no} - New = {$new}, Green = {$grn}\n"; $parts_cnt++; } } // check if newly entered parts are being used for the email quote if (!empty($rfq['part_no'])) { $count = count($rfq['part_no']); for ($i = 0; $i < $count; $i++) { // should be at least 1 quoted price if (empty($rfq['quoted_new'][$i])) { $display = 'grn'; } else { if (empty($rfq['quoted_grn'][$i])) { $display = 'new'; } else { $display = 'both'; } } $img_file = strtolower($rfq['part_no'][$i]) . '.jpg'; if (file_exists("/var/www/vhosts/livewiresupply.com/httpdocs/web/images/thumbs/{$img_file}")) { $img = "http://livewiresupply.com/images/thumbs/{$img_file}"; } else { $img = 'http://livewiresupply.com/images/thumbs/default.png'; } $part_no = strtoupper($rfq['part_no'][$i]); $part_desc = empty($rfq['notes'][$i]) ? $part_no : $part_no . "<span style='display: block;font-weight: normal;color:#000;'>{$rfq['notes'][$i]}</span>"; $new = '$' . number_format(floatval(str_replace(',', '', str_replace('$', '', $rfq['quoted_new'][$i]))), 2); $grn = '$' . number_format(floatval(str_replace(',', '', str_replace('$', '', $rfq['quoted_grn'][$i]))), 2); $qty = intval($rfq['qty_req'][$i]); $inventory = empty($rfq['lead_time'][$i]) ? 'Yes' : stripslashes($rfq['lead_time'][$i]); $pne = LWS::encode($part_no); // better to change the html and use the ajax price lookup request to build a url. $url = $rfq['mfr'][$i] == 'Not Chosen' ? 'http://livewiresupply.com/' : 'http://livewiresupply.com/' . LWS::slugify($rfq['category'][$i]) . '/' . LWS::slugify($rfq['mfr'][$i]) . "/{$pne}.html"; $btn = isset($rfq['display'][$i]) && intval($rfq['display'][$i]) > 0 ? 'buy-btn.gif' : 'call-btn.gif'; $btn_txt = isset($rfq['display'][$i]) && intval($rfq['display'][$i]) > 0 ? '' : "<br /><span style='font-size: 9px;'>800.390.3299</span>"; $email['parts'][] = array('part_no' => $part_no, 'part_desc' => $part_desc, 'img' => $img, 'display' => $display, 'new' => $new, 'grn' => $grn, 'qty' => $qty, 'inventory' => $inventory, 'url' => $url, 'btn' => $btn, 'btn_txt' => $btn_txt); if ($grn == '$0.00') { $grn = 'Not Quoted'; } if ($new == '$0.00') { $new = 'Not Quoted'; } $db_note .= "{$parts_cnt}. {$part_no} - New = {$new}, Green = {$grn}\n"; $parts_cnt++; } } $this->_body = get_partial('call_center/emailQuote', array('email' => $email)); $this->_db_note = "[" . sfConfig::get('app_company') . " Quote]\n {$db_note}"; }
/** * Method for executing busway subcategory creation logic. * Method may use a Strategy object if logic becomes sufficiently complex. * !!! _manufLevelSidebar global template expects each array in $sections * !!! to have the following elements: * !!! section, section_slug, & count * Possible fields for subcategorization: * grp, & frame_type * Currently only using grp for a subcategory. * @param Integer $manuf_id */ public function fetchSectionsByManuf($manuf_id) { $this->query("SELECT grp, count(part_no) AS count\r\n\t\t\t\t FROM part\r\n\t\t\t\t WHERE cat_id = '{$this->_id}' AND manuf_id={$manuf_id} \r\n\t\t\t\t GROUP BY grp\r\n\t\t\t\t ORDER BY count(part_no) DESC\r\n\t\t\t\t"); if (!$this->_subcat_strategy instanceof iSubcatStrategy) { // subcategorization logic can be handled without a strategy if ($this->queryOK()) { $sections = array(); $other = array(); $has_other = false; while ($row = $this->next()) { if (is_null($row['grp'])) { $other['section'] = 'Other'; $other['section_slug'] = 'other'; $other['count'] = $row['count']; $has_other = true; continue; } else { $sections[] = array('section' => $row['grp'], 'section_slug' => LWS::slugify($row['grp']), 'count' => $row['count']); } } if ($has_other) { $sections[] = $other; } /* * No point in having subcategory pagination if there is only 1 section. * It will just be a duplicate of the catalog. */ if (count($sections) == 1) { $sections = NULL; } } else { $sections = NULL; } } else { $sections = $this->_subcat_strategy->createSections($this); } $this->notifyObserver('default'); return $sections; }