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;
 }
Esempio n. 2
0
 public function executeView(sfWebRequest $request)
 {
     $dao = new BE_DAO();
     $part_no = $request->getParameter('part_no');
     $dao->query("SELECT part.*, display  FROM part LEFT JOIN store USING(part_no) WHERE part_no='{$part_no}'");
     $this->forward404Unless($dao->queryOK());
     $this->part = $dao->next();
     if ($this->part['img']) {
         $this->part['img_src'] = 'http://livewiresupply.com/images/parts/' . LWS::encode(strtolower($this->part['part_no'])) . '.jpg';
     } else {
         $this->part['img_src'] = 'http://livewiresupply.com/images/parts/default.png';
     }
     return sfView::SUCCESS;
 }
Esempio n. 3
0
 public function executeManuf(sfWebRequest $request)
 {
     $this->param = array();
     $this->param['category'] = 'Fuses';
     $this->param['cat_slug'] = 'fuses';
     $this->param['manuf_slug'] = $this->getRequestParameter('manuf_slug');
     $this->param['manuf_id'] = LWS::getManufPk($this->param['manuf_slug']);
     $this->param['manuf'] = LWS::unslugify($this->param['manuf_slug'], true);
     $this->param['subnav_grouping'] = intval(sfConfig::get('app_cb_max_subcat_grouping'));
     $this->param['subcategory'] = 'Classes/Types';
     $this->param['subcat_slug'] = 'class-type';
     // should be overwritten for each section
     $category = new FUCategory();
     $this->param['manuf_list'] = $category->fetchManufList($this->param['manuf_id']);
     $this->param['manuf_list_class'] = 'bottom';
     $this->param['sections'] = $category->fetchSectionsByManuf(LWS::getManufPk($this->param['manuf_slug']));
     if (!$this->param['sections']) {
         // do something as a backup indexing/flattening strategy if DAO returned NULL
         $this->param['subnav_count'] = 0;
         // no subnav for sections of subcategory
     } else {
         if (count($this->param['sections']) > $this->param['subnav_grouping']) {
             $this->param['subnav_count'] = ceil(sizeof($this->param['sections']) / $this->param['subnav_grouping']);
             // just experimenting with various ways to control the subnav grouping etc.
             // so far it is too much work for the results.  only edge cases matter so far.
             /*$xtra = count($this->param['sections']) - intval(sfConfig::get('app_subnav_grouping_top'));
             		$mids = ceil($xtra / intval(sfConfig::get('app_subnav_grouping_middle')));
             		$rem = $xtra % intval(sfConfig::get('app_subnav_grouping_middle'));
             		$lows = ceil($rem / intval(sfConfig::get('app_subnav_grouping_bottom')));
             		$this->param['subnav_count'] = $mids + $lows;*/
         } else {
             $this->param['subnav_count'] = 1;
         }
     }
     $this->featured_parts = $category->fetchFeaturedParts($this->param['manuf_id']);
     // count number of cycle images for this manufacturer
     $cycle_img_dir = sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'cycle' . DIRECTORY_SEPARATOR . $this->param['cat_slug'] . DIRECTORY_SEPARATOR . $this->param['manuf_slug'] . DIRECTORY_SEPARATOR;
     $this->param['manuf_box_class'] = '_' . count(glob('' . $cycle_img_dir . '*.png'));
     if (!$this->featured_parts) {
         // what to do if there are no featured parts found. we are missing data.
     }
     $response = $this->getResponse();
     $response->addMeta('description', "LiveWire Supply is the Internet's #1 Supplier for {$this->param['manuf']} Fuses. We have a massive selection and shipping points across the country.");
     $response->setSlot('body_class', 'fu_manuf');
     $response->setSlot('body_id', $this->param['manuf_slug']);
     $response->setTitle("{$this->param['manuf']} Fuses - " . sfConfig::get('app_biz_name'));
     return sfView::SUCCESS;
 }
Esempio n. 4
0
 public function executeManuf(sfWebRequest $request)
 {
     $this->param = array();
     $this->param['category'] = 'Busway';
     $this->param['cat_slug'] = 'busway';
     $this->param['manuf_slug'] = $this->getRequestParameter('manuf_slug');
     $this->param['manuf_id'] = LWS::getManufPk($this->param['manuf_slug']);
     $this->param['manuf'] = LWS::unslugify($this->param['manuf_slug'], true);
     $this->param['subnav_grouping'] = intval(sfConfig::get('app_cb_max_subcat_grouping'));
     $this->param['subcategory'] = 'Busway Components';
     $this->param['subcat_slug'] = 'component';
     $category = new BUCategory();
     $this->param['manuf_list'] = $category->fetchManufList($this->param['manuf_id']);
     $this->param['manuf_list_class'] = 'bottom';
     $this->param['sections'] = $category->fetchSectionsByManuf(LWS::getManufPk($this->param['manuf_slug']));
     if (!$this->param['sections']) {
         // do something as a backup indexing/flattening strategy if DAO returned NULL
         $this->param['subnav_count'] = 0;
         // no subnav for sections of subcategory
     } else {
         if (sizeof($this->param['sections']) > $this->param['subnav_grouping']) {
             $this->param['subnav_count'] = ceil(sizeof($this->param['sections']) / $this->param['subnav_grouping']);
         } else {
             $this->param['subnav_count'] = 1;
         }
     }
     $this->featured_parts = $category->fetchFeaturedParts($this->param['manuf_id']);
     // count number of cycle images for this manufacturer
     $cycle_img_dir = sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'cycle' . DIRECTORY_SEPARATOR . $this->param['cat_slug'] . DIRECTORY_SEPARATOR . $this->param['manuf_slug'] . DIRECTORY_SEPARATOR;
     $this->param['manuf_box_class'] = '_' . count(glob('' . $cycle_img_dir . '*.png'));
     // start preload logic
     $num_cycle_imgs = count(glob('' . $cycle_img_dir . '*.png'));
     $this->param['cycle_imgs'] = array();
     for ($i = 0; $i < $num_cycle_imgs; $i++) {
         $this->param['cycle_imgs'][] = "/images/cycle/busway/{$this->param['manuf_slug']}/cycle-{$i}-trans.png";
     }
     // end preload logic
     $response = $this->getResponse();
     $response->addMeta('description', "LiveWire Supply is the Internet's #1 Supplier for {$this->param['manuf']} Busway. We have a massive selection and shipping points across the country.");
     $response->setSlot('body_class', 'bu_manuf');
     $response->setSlot('body_id', $this->param['manuf_slug']);
     $response->setTitle("{$this->param['manuf']} Busway - " . sfConfig::get('app_biz_name'));
     return sfView::SUCCESS;
 }
Esempio n. 5
0
 public function executeManuf(sfWebRequest $request)
 {
     $this->param = array();
     $this->param['category'] = 'Motor Control';
     $this->param['cat_slug'] = 'motor-control';
     $this->param['manuf_slug'] = $this->getRequestParameter('manuf_slug');
     $this->param['manuf_id'] = LWS::getManufPk($this->param['manuf_slug']);
     $this->param['manuf'] = LWS::unslugify($this->param['manuf_slug'], true);
     $this->param['subnav_grouping'] = intval(sfConfig::get('app_subnav_grouping_max'));
     $this->param['subcategory'] = NULL;
     $this->param['subcat_slug'] = NULL;
     $category = new MCCategory();
     $this->param['manuf_list'] = $category->fetchManufList($this->param['manuf_id']);
     $this->param['manuf_list_class'] = 'bottom';
     $this->param['sections'] = NULL;
     //$category->fetchSectionsByManuf(LWS::getManufPk($this->param['manuf_slug']));
     if (!$this->param['sections']) {
         // do something as a backup indexing/flattening strategy if DAO returned NULL
         $this->param['subnav_count'] = 0;
         // no subnav for sections of subcategory
     } else {
         if (sizeof($this->param['sections']) > $this->param['subnav_grouping']) {
             $this->param['subnav_count'] = ceil(sizeof($this->param['sections']) / $this->param['subnav_grouping']);
         } else {
             $this->param['subnav_count'] = 1;
         }
     }
     $this->featured_parts = $category->fetchFeaturedParts($this->param['manuf_id']);
     // count number of cycle images for this manufacturer
     $cycle_img_dir = sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'cycle' . DIRECTORY_SEPARATOR . $this->param['cat_slug'] . DIRECTORY_SEPARATOR . $this->param['manuf_slug'] . DIRECTORY_SEPARATOR;
     $this->param['manuf_box_class'] = '_' . count(glob('' . $cycle_img_dir . '*.png'));
     $response = $this->getResponse();
     $response->addMeta('description', "LiveWire Supply is the Internet's #1 Supplier for {$this->param['manuf']} Motor Controls. We have a massive selection and shipping points across the country.");
     $response->setSlot('body_class', 'mc_manuf');
     $response->setSlot('body_id', $this->param['manuf_slug']);
     $response->setTitle("{$this->param['manuf']} Motor Control - " . sfConfig::get('app_biz_name'));
     return sfView::SUCCESS;
 }
Esempio n. 6
0
 public function executeSelect(sfWebRequest $request)
 {
     if ($request->isXmlHttpRequest()) {
         // steps 1-3 requests & restart
         $this->setLayout(false);
         sfProjectConfiguration::getActive()->loadHelpers('Partial');
         $agent = new CircuitBreakerSelectionAgent($request->getGetParameters());
         if ($data = $agent->executeStep()) {
             $partial = 'filter' . ucfirst($request->getParameter('step')) . 'Step';
             $html = get_partial($partial, array('selection' => $request->getParameter($request->getParameter('step'), NULL), 'back_qs' => $data['back_qs'], 'data' => $data['data'], 'results_so_far' => $data['results_so_far'], 'search_params' => $agent->getSearchParameters()));
         } else {
             /*
              * Would only get here if LWS DB is incomplete.
              * In this case we need to use the query string to retrieve the relevant
              * data set from teh DB and then fill in the missing values.
              * 
              * Do not throw 404 from Ajax request, 
              * just send error messgae back to user.
              * 
              * !! I should log the query string in these cases to facilitate
              * updating of DB.
              */
             $html = "<p id='tech_prob'>Sorry, we our experiencing technical difficulties. Please contact technical support at <a href='mailto:webmaster@livewiresupply.com'>webmaster@livewiresupply.com</a></p>";
         }
         $response = $this->getResponse();
         $response->addCacheControlHttpHeader('no-cache');
         $response->setContentType('text/html');
         $response->sendHttpHeaders();
         return $this->renderText($html);
     } else {
         // ONLY FOR VOLTS/LAST STEP, or graceful degradation for non JavaScript enabled browsers
         $this->manuf_slug = LWS::getManufSlug($request->getParameter('manuf_id'));
         $this->manuf = LWS::unslugify($this->manuf_slug, true);
         $template = 'Filter' . ucfirst($request->getParameter('step')) . 'Step';
         $this->selection = $request->getParameter($request->getParameter('step'));
         $agent = new CircuitBreakerSelectionAgent($request->getGetParameters());
         /*
          * $agent would not return data only if LWS DB is incomplete.
          * Sequence of steps dictate that once LWS DB is complete,
          * server should throw a 404.  User may have be url surfing.
          * 
          * !!! be sure to update DB if necessary.
          */
         $this->forward404Unless($this->data = $agent->executeStep());
         if ($request->getParameter('step') == 'volts') {
             $this->redirect("@part?cat_slug=circuit-breakers&manuf_slug={$this->manuf_slug}&part_no=" . LWS::encode($this->data[0]['part']['part_no']));
         } else {
             // remove unecessary ajax 'back a step' query string from end of data array
             unset($this->data['back_qs']);
             $this->results_so_far = $this->data['results_so_far'];
             $this->data = $this->data['data'];
             $this->search_params = $agent->getSearchParameters();
             $response = $this->getResponse();
             $response->setTitle("{$this->manuf} Circuit Breakers Selection Process");
             $response->setSlot('body_class', 'cb_manuf');
             return $template;
         }
     }
 }
 private function filterForAmps()
 {
     $this->_search_parameters['Frame Type'] = $this->_selections['frame'];
     $this->_search_parameters['Poles'] = $this->_selections['poles'];
     $this->_search_parameters['Amperage'] = $amps = rawurldecode($this->_selections['amps']);
     $this->query("\r\n\t\t\t(\r\n\t\t\tSELECT DISTINCT(volts) AS data, 'data' AS label\r\n\t\t\tFROM part\r\n\t\t\tWHERE cat_id='cb' AND manuf_id ={$this->_selections['manuf_id']} AND frame_type='{$this->_selections['frame']}' AND poles='{$this->_selections['poles']}' AND amps='{$amps}' AND volts IS NOT NULL \r\n\t\t\t)\r\n\t\t\tUNION \r\n\t\t\t(\r\n\t\t\tSELECT part.part_no, 'results_so_far' AS label\r\n\t\t\tFROM part\r\n\t\t\tWHERE cat_id='cb' AND manuf_id ={$this->_selections['manuf_id']} AND frame_type='{$this->_selections['frame']}' AND poles='{$this->_selections['poles']}' AND amps='{$amps}' AND volts IS NOT NULL  \r\n\t\t\t)\r\n\t\t\tORDER BY label ASC, data ASC \r\n\t\t");
     if ($this->queryOK()) {
         $this->notifyObserver('default');
         /*
          * Using 1-based counting facilitates corresponding template development.
          * SQL ORDER BY statement dictates 'data' item is first record in result set.
          * Use this first record to initilialize array at 1 instead of 0.
          */
         $row = $this->next();
         $this->_data['data'][1] = array('AT' => $row['data'], 'QS' => "manuf_id={$this->_selections['manuf_id']}&frame={$this->_selections['frame']}&poles={$this->_selections['poles']}&amps={$this->_selections['amps']}&volts=" . rawurlencode($row['data']) . '&step=volts');
         while ($row = $this->next()) {
             if ($row['label'] == 'data') {
                 $this->_data['data'][] = array('AT' => $row['data'], 'QS' => "manuf_id={$this->_selections['manuf_id']}&frame={$this->_selections['frame']}&poles={$this->_selections['poles']}&amps={$this->_selections['amps']}&volts=" . rawurlencode($row['data']) . '&step=volts');
             } else {
                 // should always be at least 1 'result so far' unless LWS DB is incomplete!
                 $this->_data['results_so_far'][] = array('part_no' => $row['data'], 'manuf_slug' => LWS::getManufSlug($this->_selections['manuf_id']));
             }
         }
         $this->_data['back_qs'] = "manuf_id={$this->_selections['manuf_id']}&frame={$this->_selections['frame']}&poles={$this->_selections['poles']}&step=poles";
         return $this->_data;
     } else {
         return NULL;
     }
 }
<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>
Esempio n. 9
0
 public function executeRfq(sfWebRequest $request)
 {
     $this->cat_slug = $request->getParameter('category');
     $this->category = strtoupper(LWS::unslugify($this->cat_slug));
     if ($request->isMethod('POST')) {
         sfProjectConfiguration::getActive()->loadHelpers('Partial');
         if ($this->cat_slug == 'electrical-transformers') {
             array_pop($this->_req_fields);
         }
         if ($this->rfqIsValid($request)) {
             // remove any saved form values from previous erroneous submission attempts
             $this->getUser()->getAttributeHolder()->remove('rfq_form_values');
             // build email message
             if ($this->cat_slug == 'electrical-transformers') {
                 $message = $this->buildTrEmail($request->getPostParameters());
             } else {
                 $message = $this->buildOtherEmail($request->getPostParameters());
             }
             $to = 'Napoleon Esparrago <*****@*****.**>';
             //$to = 'Morgan Ney <*****@*****.**>';
             //qmail replaces LF(\n) with CRLF(\r\n), so only use LF in headers
             $headers = "Content-type: text/html; charset=iso-8859-1\nFrom: RFQ Form <*****@*****.**>\nCc: adam@livewiresupply.com\n";
             if (@mail($to, "REQUEST FOR QUOTE - {$this->category}", $message, $headers)) {
                 $this->getUser()->setFlash('rfq_notice', get_partial('formSuccess'));
             } else {
                 $this->getUser()->setFlash('rfq_notice', get_partial('emailError'));
             }
             $this->redirect("@rfq?category={$this->cat_slug}");
         } else {
             // save form values to restore
             $this->getUser()->setAttribute('rfq_form_values', $request->getPostParameters());
             $this->getUser()->setFlash('rfq_notice', get_partial('formError', array('errors' => $this->_errors)));
         }
     }
     $this->partial = $this->cat_slug == 'electrical-transformers' ? 'ElectricalTransformers' : 'Other';
     $this->getResponse()->setSlot('body_id', str_replace('-', '_', $this->cat_slug));
     return sfView::SUCCESS;
 }
Esempio n. 10
0
<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>
Esempio n. 11
0
    echo $label, ": <span>{$value}</span>";
    ?>
</li>
	<?php 
}
?>
	</ul>
	<ul id='results'>
		<li>
			<table class='result_set' cellspacing='0' cellpadding='0'>
				<tr>
				<?php 
foreach ($results_so_far as $idx => $part) {
    ?>
					<td><?php 
    echo link_to($part['part_no'], "@part?cat_slug=circuit-breakers&manuf_slug={$part['manuf_slug']}&part_no=" . LWS::encode($part['part_no']));
    ?>
</td>
					<?php 
    if (($idx + 1) % 5 == 0 && ($idx + 1) % 30 != 0) {
        // close out current sets row
        ?>
					</tr><tr>
					<?php 
    }
    ?>
					<?php 
    if (($idx + 1) % 30 == 0) {
        // close out current set
        ?>
					</tr></table></li><li><table class='result_set' cellspacing='0' cellpadding='0'><tr>
Esempio n. 12
0
'>
	<?php 
    if ($j == 0) {
        ?>
	<li><h4 id='divider'><?php 
        echo $param['manuf'], ' ', $param['subcategory'];
        ?>
</h4></li>
	<?php 
    }
    ?>
	<?php 
    for ($i = $j * $param['subnav_grouping']; $i < $limit; $i++) {
        ?>
	<?php 
        $subcat_slug = LWS::getSubcatSlug($param, $i);
        ?>
	<?php 
        $cls = $i == $j * $param['subnav_grouping'] ? " class='first'" : '';
        ?>
	<li<?php 
        echo $cls;
        ?>
><?php 
        echo link_to("{$param['sections'][$i]['section']}", "@sub_pagination?cat_slug={$param['cat_slug']}&manuf_slug={$param['manuf_slug']}&subcat_slug={$subcat_slug}&section={$param['sections'][$i]['section_slug']}&page_num=page-1", array('title' => "{$param['manuf']} {$param['subcategory']} {$param['sections'][$i]['section']}"));
        echo " ({$param['sections'][$i]['count']})";
        ?>
	</li>
	<?php 
    }
    ?>
Esempio n. 13
0
 public function executeSelect(sfWebRequest $request)
 {
     if ($request->isXmlHttpRequest()) {
         sfProjectConfiguration::getActive()->loadHelpers('Partial');
         $this->setLayout(false);
         $response = $this->getResponse();
         $response->addCacheControlHttpHeader('no-cache');
         $response->setContentType('text/html');
         $response->sendHttpHeaders();
         // might have to pass sfUser instance to TSA here
         $agent = new TransformerSelectionAgent($request->getGetParameters());
         if ($data = $agent->executeStep()) {
             $partial = 'filter' . ucfirst($request->getParameter('step')) . 'Step';
             $html = get_partial($partial, array('selection' => $request->getParameter($request->getParameter('step')), 'data' => $data, 'back_qs' => $agent->getBackQs()));
         } else {
             // Must be nothing in the DB.  This should not occur unless we goofed.
             $html = "<p id='tech_prob'>Sorry, we our experiencing technical difficulties. Please contact technical support at <a href='mailto:webmaster@livewiresupply.com'>webmaster@livewiresupply.com</a></p>";
         }
         return $this->renderText($html);
     } else {
         // graceful degradation block for non JS users
         $response = $this->getResponse();
         $response->setTitle('Electrical Transformers Selection Tool - ' . sfConfig::get('app_biz_name'));
         $response->setSlot('body_id', 'tr_select');
         if ($request->getParameter('step', NULL)) {
             /*
              * User has started making selections.
              * GET parameter 'step' always refers to the previous step for the current request.
              * FilerOutputStep is simply the landing page results
              */
             $step = $request->getParameter('step');
             $template = 'Filter' . ucfirst($step) . 'Step';
             $this->selection = $request->getParameter($step);
             if ($step == 'output') {
                 /*
                  * Both voltage values must be present, so ...
                  * Store the selected order of voltage selections in user session. This will allow
                  * the script rendering the landing page to determine what order to display the
                  * voltages since it cannot be determined from a DB query using part no. only. (As of 12/3/2010)
                  * 
                  * NOTE: removed _volts from query parameters in selection tool
                  */
                 $iv = rawurldecode($request->getParameter('input'));
                 $ov = rawurldecode($request->getParameter('output'));
                 $d_kva = $request->getParameter('kva');
                 $d_phase = $request->getParameter('phase');
                 $this->getUser()->setAttribute('tr_volt_order', "{$iv}:{$ov}");
                 $response->setSlot('body_class', 'results');
                 $response->addMeta('description', "LiveWire's Electrical Transformer Tool Results: KVA = {$d_kva}, Phase = {$d_phase}, Input Volts = {$iv}, Output Volts = {$ov}");
             }
             $agent = new TransformerSelectionAgent($request->getGetParameters());
             if ($this->data = $agent->executeStep()) {
                 $this->found_new = false;
                 $this->found_rebuilt = false;
                 $this->img_src = sfConfig::get('app_parts_img_dir') . 'default.png';
                 // search for any available image in any of the returned parts
                 foreach ($this->data as $idx => $arr) {
                     if (!empty($arr['part']['img'])) {
                         $this->img_src = sfConfig::get('app_parts_img_dir') . strtolower(LWS::encode($arr['part']['part_no'])) . '.jpg';
                     }
                     /*
                      * LWS business model dictates that ONLY 1 refurbished transformer will be
                      * returned for any combination of selection values. Per adam, 8/19/2010.
                      */
                     // clean this up by removing the rebuilt part data into its own data structure
                     if (isset($arr['part']) && $arr['part']['manuf_slug'] == 'rebuilt') {
                         $this->found_rebuilt = true;
                         $this->rebuilt_idx = $idx;
                     } else {
                         $this->found_new = true;
                     }
                 }
                 return $template;
             } else {
                 /**
                  * I get here only if there is some sort of MySQL Error for the current step, 
                  * OR the current step returned an empty result set for the users current selections.
                  * Based on our database, and the SQL queries a user should never get here because
                  * of an empty result set.  So maybe put a 'technical difficulties' message here 
                  * or something...
                  */
                 //return sfView::ERROR;
                 $this->forward404();
             }
         } else {
             // user has made no selections and is on step 1
             $response->addMeta('description', "Easily find your Electrical Transformer with LiveWire Supply's Transformer tool. Enter KVA, Phase, Primary and Secondary Voltages. 800-390-3299");
             return sfView::SUCCESS;
         }
     }
 }
Esempio n. 14
0
 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}";
 }
Esempio n. 15
0
?>
 Logo and Tradename are registered trademarks of <?php 
echo $param['manuf'];
?>
.</p>

<?php 
slot('sidebar');
?>
	<?php 
include_partial('global/manufLevelSidebar', array('param' => $param));
end_slot();
?>

<?php 
if (LWS::isOutsideBizHours()) {
    ?>
	<?php 
    slot('after_hours');
    ?>
		<?php 
    include_partial('global/afterHoursMessage');
    ?>
	<?php 
    end_slot();
}
?>

<div id='cycle_preload' class='invisible'>
	<?php 
foreach ($param['cycle_imgs'] as $src) {
        if ($arr['part']['manuf_slug'] == 'rebuilt') {
            continue;
        }
        // this should be moved to action/model
        ?>
		<div class='line_item'>
			<div class='pic'>
				<img src='/images/manuf/rect/<?php 
        echo $arr['part']['manuf_slug'];
        ?>
.jpg' alt='<?php 
        echo $arr['part']['manuf_slug'];
        ?>
' />
				<?php 
        echo link_to($arr['part']['part_no'], '@part?cat_slug=electrical-transformers&manuf_slug=' . $arr['part']['manuf_slug'] . '&part_no=' . LWS::encode($arr['part']['part_no']), array('class' => 'part_lnk'));
        ?>
			</div>
			<div class='price'>
				<p><strong><script type='text/javascript' src='http://shopping.netsuite.com/app/site/query/getitemprice.nl?c=502106&amp;id=<?php 
        echo $arr['part']['ns_new_id'] ? $arr['part']['ns_new_id'] : 123;
        ?>
'></script></strong></p>
				<p><input type='text' class='txt' size='4' name='_<?php 
        echo $arr['part']['part_no'];
        ?>
_qty' id='_<?php 
        echo $arr['part']['part_no'];
        ?>
_qty' /></p>
			</div>
Esempio n. 17
0
 /**
  * 
  * Retrieves part information using appropriate DAO object for each parts landing page.
  * 
  * IMPORTANT:  Since adding the use of sessions to manage the transformer selection tool
  * 						 voltage swap, I can no longer cache this entire template with layout, but
  * 						 instead only parts of the template.  THIS SUCKS!  Seriously consider refactoring
  * 						 our DB to avoid any sort of hack due to bad planning, or find a hack without
  * 					   using sessions but instead query parameters.
  * @param sfWebRequest $request
  */
 public function executePart(sfWebRequest $request)
 {
     $cat_slug = $request->getParameter('cat_slug');
     $cat_id = LWS::getCategoryPk($cat_slug);
     $part_no = LWS::unencode($request->getParameter('part_no'));
     $part = PartFactory::make(array('cat_id' => $cat_id, 'part_no' => $part_no));
     $this->param = array();
     $this->param['cat_id'] = $cat_id;
     $this->param['part'] = $part->getDetails();
     // If I opt to move this whole piece of TR logic to TRPart by passing in the sfUser object
     // Then I'd have to update the constructor for all DAO's to include an optional construction
     // parameter. Unless I can get it from within the TRPart.
     if ($cat_id == 'tr' && str_replace('/frontend_dev.php', '', parse_url($request->getReferer(), PHP_URL_PATH)) == '/electrical-transformers/select') {
         /*
          * See if user has stored voltages in session (they should unless an error occured).
          * Use these instead of DB values since the selection tool allows for reversing 
          * input/output voltages.
          */
         if ($this->getUser()->hasAttribute('tr_volt_order')) {
             // session value has form [chosen input]:[chosen output]
             $volts = explode(':', $this->getUser()->getAttribute('tr_volt_order'));
             //print_r($volts); die();
             // Remember that TRPart (and all Part DAO's) uses an Alias to store field values
             $this->param['part']['Primary Voltage'] = $volts[0];
             $this->param['part']['Secondary Voltage'] = $volts[1];
             // removing these does not allow the user to move back and forth in the selection tool
             //$this->getUser()->getAttributeHolder()->remove('tr_volt_order');
         }
     }
     /*
      * Two options for dealing with lowercase part numbers in URLs:
      * A:  Just throw a 404 for these requests
      * B:  Show the page, but use a <link> canonical tag
      */
     $this->forward404Unless($part_no == strtoupper($part_no));
     // Option A
     /* B:
       	if($part_no != strtoupper($part_no)) {
       		$pn = $request->getParameter('part_no');
       		$url = str_replace($pn, strtoupper($pn), $request->getUri());
       		$this->getResponse()->setSlot('links', "<link rel='canonical' href='{$url}' />");
       	}
       	*/
     $this->forward404Unless($this->param['part']);
     $this->param['part']['part_no'] = $part_no;
     $this->param['part']['db_fields'] = $part->getDbFields();
     $this->param['h1Txt'] = $part->getH1Txt();
     $this->param['store'] = $part->getPricing();
     $this->param['category'] = LWS::getCategoryName($cat_slug);
     $this->param['manuf_route'] = $cat_id . '_manuf';
     /*
      * doing this for now since changing the route's name would involve updating more files
      * this is necessary because at some point adam wanted to change 'transformers'
      * to 'electrical-transformers'.  should clean it up later to remove this conditional statement.
      */
     $this->param['cat_route'] = str_replace('-', '_', $cat_slug);
     $this->param['meta_keywords'] = $part->getMetaKeywords();
     $this->param['shipping_needed'] = $this->param['store'] != 'emptyStore' && $cat_id == 'cb' ? true : false;
     $response = $this->getResponse();
     $response->setSlot('body_class', 'part');
     $response->setSlot('body_id', str_replace('-', '_', $cat_slug));
     $response->setTitle($part->getPageTitle());
     return sfView::SUCCESS;
 }
</h4>

<div id='featured_item'>
 <?php 
foreach ($featured_parts as $id => $arr) {
    ?>
	<?php 
    if (($id + 1) % 3 == 0) {
        ?>
	 <div class='item_box r small'>
	 <?php 
    } else {
        ?>
	 <div class='item_box small'>
	 <?php 
    }
    ?>
		<div class ='item_img'>
			<?php 
    echo link_to(image_tag($arr['img_src'], array('alt' => $arr['part_no'])), "@part?cat_slug={$param['cat_slug']}&manuf_slug={$param['manuf_slug']}&part_no=" . LWS::encode($arr['part_no']), array('class' => 'img_a', 'rel' => 'nofollow'));
    ?>
			<?php 
    echo link_to($arr['part_no'], "@part?cat_slug={$param['cat_slug']}&manuf_slug={$param['manuf_slug']}&part_no=" . LWS::encode($arr['part_no']));
    ?>
		</div>
	</div>
	<?php 
}
?>
</div>
Esempio n. 19
0
 /**
  * Extends the transformers parts array for a given manufacturer by adding
  * fields useful for processing by the corresponding view (pagination list).
  * 
  * @param Mixed Array $parts, passed by reference
  */
 protected function extendPartData($part = array())
 {
     $part['encoded_part_no'] = LWS::encode($part['part_no']);
     $part['img'] = is_null($part['img']) ? sfConfig::get('app_thumbs_dir') . 'default.png' : sfConfig::get('app_thumbs_dir') . strtolower($part['encoded_part_no']) . '.jpg';
     // could just load $part['layout'] with calls to partials from here,
     // but wanted to decouple logic from this class in case I bypass the php include
     // mechanism in favor of generating the HTML 'layout' snippet as a PHP string
     // variable. (Less overhead with php string variable, maybe ??)
     $this->_list_display_decorator->buildDisplay($part, $this->_specs_preview_fields);
     return $part;
 }
Esempio n. 20
0
echo $num_serps;
?>
</strong></li>
	<li class='b'>max items per page: <strong><?php 
echo sfConfig::get('app_search_pagination_max_items');
?>
</strong></li>
	<li>sorted by: <strong>part no. ascending</strong></li>
</ul>
<?php 
if ($num_serps > 1) {
    ?>
<p class='pager'>
	<span>1</span>
	<?php 
    for ($i = 2; $i <= $num_serps; $i++) {
        ?>
		<?php 
        echo link_to($i, '@search_pagination?query=' . LWS::encode($query) . '&page_num=page-' . $i);
        ?>
	<?php 
    }
    ?>
</p>
<?php 
}
slot('sidebar');
?>
	<?php 
include_partial('searchSidebar', array('search_routes' => $search_routes, 'search_routes_class' => $search_routes_class, 'item_count' => count($similar_parts)));
end_slot();
Esempio n. 21
0
		</tbody>
	</table>
</div>
<?php 
} else {
    ?>
<div class='r phone'>
	<div class='desc'>
		<p><?php 
    echo link_to($part['anchor_text'], '@part?cat_slug=' . $sf_params->get('cat_slug') . '&manuf_slug=' . $sf_params->get('manuf_slug') . "&part_no={$part['encoded_part_no']}");
    ?>
</p>
		<dl>
			<?php 
    foreach ($specs_preview_fields as $field_name) {
        ?>
			<dt><?php 
        echo LWS::dbFieldToLabel($field_name);
        ?>
:</dt><dd><?php 
        echo LWS::formatValue($part[$field_name], $field_name);
        ?>
</dd>
			<?php 
    }
    ?>
		</dl>
	</div>
</div>
<?php 
}
Esempio n. 22
0
 /**
  * Method for editing/extending portions of a parts data.
  * 
  * @param Array $part
  */
 private function decorate($part)
 {
     // assign proper src attributre for part image
     $part['img'] = is_null($part['img']) ? sfConfig::get('app_parts_img_dir') . 'default.png' : sfConfig::get('app_parts_img_dir') . strtolower(LWS::encode($this->_part_no)) . '.jpg';
     return $part;
 }
Esempio n. 23
0
 public function liveSearchLocate()
 {
     $this->query("\r\n\t\t\t\tSELECT part_no, img, category, cat_slug, manuf, manuf_slug FROM part\r\n\t\t\t\tINNER JOIN category USING (cat_id) INNER JOIN manufacturer USING (manuf_id)\r\n\t\t\t\tWHERE LOCATE('{$this->_query}', part_no) != 0\r\n\t\t\t\tORDER BY part_no ASC\r\n\t\t\t\tLIMIT 5\r\n\t\t\t");
     if ($this->queryOK()) {
         $serp = array();
         while ($row = $this->next()) {
             $pne = LWS::encode($row['part_no']);
             $minis_dir = sfConfig::get('app_minis_dir');
             $route = "@part?cat_slug={$row['cat_slug']}&manuf_slug={$row['manuf_slug']}&part_no={$pne}";
             $img = is_null($row['img']) ? "{$minis_dir}default.png" : "{$minis_dir}{$pne}.jpg";
             $serp[] = array('part_no' => $row['part_no'], 'category' => $row['category'], 'mfr' => $row['manuf'], 'img' => $img, 'route' => $route);
         }
         return $serp;
     } else {
         return NULL;
     }
 }