예제 #1
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;
 }
예제 #2
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;
 }
예제 #3
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();
</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>
예제 #5
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;
 }
예제 #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;
         }
     }
 }
예제 #7
0
        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>
예제 #8
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>
예제 #9
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;
         }
     }
 }
예제 #10
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}";
 }
예제 #11
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;
     }
 }