304 lines
16 KiB
PHTML
Executable File
304 lines
16 KiB
PHTML
Executable File
<?php
|
|
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
|
|
|
|
$customerSession = $objectManager->get('\Magento\Customer\Model\Session');
|
|
$urlInterface = $objectManager->get('\Magento\Framework\UrlInterface');
|
|
|
|
if (!$customerSession->isLoggedIn()) {
|
|
$customerSession->setAfterAuthUrl($urlInterface->getCurrentUrl());
|
|
$customerSession->authenticate();
|
|
}
|
|
$want_to_buy_id = $block->getWantToBuyId();
|
|
$customer = $block->getCustomer();
|
|
$email = "";
|
|
if ($customer) {
|
|
$email = $customer->getEmail();
|
|
}
|
|
?>
|
|
<form action="" method="post" id="quote-in-request">
|
|
<?= $block->getBlockHtml('formkey') ?>
|
|
<table border="0" cellspacing="0" cellpadding="0" class="rfq_items">
|
|
<thead>
|
|
<tr class="tophead">
|
|
<th style="width:20px;"></th>
|
|
<th >MODEL #</th>
|
|
<th style="width:40px;">QTY</th>
|
|
<th style="width:80px;">CONDITION</th>
|
|
<th>NOTES</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="tbody-items">
|
|
<!-- <tr class="row-0 req" data-rpid="66465">
|
|
<td><a href="#" class="show-rep rpid-66465" data-rpid="66465" style="display: none;">+</a><a href="#" class="close-rep rpid-66465" data-rpid="66465" style="display: inline;">-</a></td>
|
|
<td>WSC296024PCL</td>
|
|
<td>40</td>
|
|
<td>Refurb</td>
|
|
<td></td>
|
|
</tr>
|
|
<tr class="row-0 rep rpid-66465" style="display: table-row;">
|
|
<td></td>
|
|
<td colspan="4">
|
|
<table border="0" cellspacing="0" cellpadding="0" class="rfq_response">
|
|
<thead>
|
|
<tr>
|
|
<th style="width:40px;">Qty</th>
|
|
<th style="width:75px;">Condition</th>
|
|
<th style="width:75px;">Unit Price</th>
|
|
<th style="width:255px;">Notes</th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody model="WSC296024PCL">
|
|
<tr class="reply-to-66465 response">
|
|
<td><input type="text" class="qty466465 quantity" name="quantity[66465][0]" value="" style="width:30px;"></td>
|
|
<td class="condition_66465">
|
|
<select size="1" name="condition[66465][0]" class="condition">
|
|
<option value="NEW">NEW</option>
|
|
<option value="REFURBISHED">REFURBISHED</option>
|
|
</select>
|
|
</td>
|
|
<td>
|
|
<input type="text" name="price[66465][0]" value="" style="width:50px;" placeholder="$" class="format-currency price">
|
|
</td>
|
|
<td>
|
|
<textarea name="notes[66465][0]" rows="2" cols="30" maxlength="255" style="width:initial;" class="notes"></textarea>
|
|
</td>
|
|
<td>
|
|
<a href="#" class="rem-rep" data-rpid="66465" data-repct="0">x</a>
|
|
</td>
|
|
</tr>
|
|
<tr class="reply-to-66465 response">
|
|
<td><input type="text" name="quantity[66465][1]" value="" style="width:30px;" class="quantity"></td>
|
|
<td class="condition_66465_1"><select size="1" name="condition[66465][1]">
|
|
<option value="NEW">NEW</option>
|
|
<option value="REFURBISHED">REFURBISHED</option>
|
|
</select></td>
|
|
<td><input type="text" name="price[66465][1]" value="" style="width:50px;" placeholder="$" class="format-currency price"></td>
|
|
<td><textarea name="notes[66465][1]" rows="2" cols="30" maxlength="255" style="width:initial;" class="notes"></textarea></td>
|
|
<td><a href="#" class="rem-rep" data-rpid="66465" data-repct="1">x</a></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="5" class="add-rep-container" data-rpid="66465" data-repct="1">
|
|
<a href="#" class="add-rep">+</a>
|
|
Add other conditions and/or price breaks
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
<tr class="row-1 req" data-rpid="66466">
|
|
<td><a href="#" class="show-rep rpid-66466" data-rpid="66466" style="display: none;">+</a><a href="#" class="close-rep rpid-66466" data-rpid="66466" style="display: inline;">-</a></td>
|
|
<td>WSC385048PS</td>
|
|
<td>1</td>
|
|
<td>NIB</td>
|
|
<td></td>
|
|
</tr>
|
|
<tr class="row-1 rep rpid-66466" style="display: table-row;">
|
|
<td></td>
|
|
<td colspan="4">
|
|
<table border="0" cellspacing="0" cellpadding="0" class="rfq_response">
|
|
<thead>
|
|
<tr>
|
|
<th style="width:40px;">Qty</th>
|
|
<th style="width:75px;">Condition</th>
|
|
<th style="width:75px;">Unit Price</th>
|
|
<th style="width:255px;">Notes</th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody model="WSC385048PS">
|
|
<tr class="reply-to-66466 response">
|
|
<td><input type="text" class="qty466466 quantity" name="quantity[66466][0]" value="" style="width:30px;"></td>
|
|
<td class="condition_66466">
|
|
<select size="1" name="condition[66466][0]" class="condition">
|
|
<option value="NEW">NEW</option>
|
|
<option value="REFURBISHED">REFURBISHED</option>
|
|
</select>
|
|
</td>
|
|
<td>
|
|
<input type="text" name="price[66466][0]" value="" style="width:50px;" placeholder="$" class="format-currency price">
|
|
</td>
|
|
<td>
|
|
<textarea name="notes[66466][0]" rows="2" cols="30" maxlength="255" style="width:initial;" class="notes"></textarea>
|
|
</td>
|
|
<td>
|
|
<a href="#" class="rem-rep" data-rpid="66466" data-repct="0">x</a>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="5" class="add-rep-container" data-rpid="66466" data-repct="0">
|
|
<a href="#" class="add-rep">+</a>
|
|
Add other conditions and/or price breaks
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</td>
|
|
</tr> -->
|
|
</tbody>
|
|
</table>
|
|
<div style="font-weight:bold;">
|
|
|
|
<div style="font-size:16px; width:100%;">Does this quote include free ground shipping?</div>
|
|
<div style=" width:100%;margin-left: 20px;"><input type="radio" id="shipping_included_yes" name="data[shipping_included]" value="1" checked> Yes | <input type="radio" id="shipping_included_no" name="data[shipping_included]" value="0" > No </div>
|
|
</div>
|
|
<br>
|
|
<input type="hidden" name="data[email]" value="<?= $email; ?>">
|
|
<input id="wtbNum" type="hidden" name="data[wtbNum]" value="">
|
|
<input id="want_to_buy_id" type="hidden" name="data[want_to_buy_id]" value="<?= $want_to_buy_id; ?>">
|
|
<div id="submit-vendor-portal">
|
|
<input type="image" src="//media.cablesandkits.com/static/img/vp-submit.png" value="Review" id="review_button" align="middle">
|
|
</div>
|
|
</form>
|
|
<script>
|
|
require(['jquery'], function($) {
|
|
|
|
$(document).ready(function() {
|
|
var want_to_by_request = {
|
|
data_name: "quote_in",
|
|
getData: function() {
|
|
if (this.data_name in localStorage) {
|
|
return JSON.parse(localStorage.getItem(this.data_name));
|
|
} else {
|
|
return null;
|
|
}
|
|
},
|
|
isData: function() {
|
|
var data = this.getData();
|
|
if (data != null && data["data"] != undefined) {
|
|
return true;
|
|
}
|
|
return false;
|
|
},
|
|
getItemById: function(_id) {
|
|
var root = this;
|
|
var result = null;
|
|
if (root.isData()) {
|
|
var quote_in = root.getData();
|
|
var items = quote_in.data;
|
|
for (let i = 0; i < items.length; i++) {
|
|
var item = items[i];
|
|
if (item._id == _id) {
|
|
result = item;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
},
|
|
render: function() {
|
|
var root = this;
|
|
var quote_in = root.getItemById($("#want_to_buy_id").val());
|
|
if (quote_in) {
|
|
$("#wtbNum").val(quote_in.wtbNum);
|
|
var items = quote_in.wtbQuoteDetail;
|
|
items.forEach(function print(item, index, array) {
|
|
$("#tbody-items").append(root.getRowHtmlByItem(item, index));
|
|
console.log(index);
|
|
});
|
|
root.bindEventShowRep();
|
|
root.bindEventRemoveRepQuote();
|
|
root.bindEventAddRepContainer();
|
|
|
|
}
|
|
},
|
|
getRowHtmlByItem: function(item, index) {
|
|
var html = '<tr class="row " >' +
|
|
'<td><a class="show-rep-a" style="display: inline;" display="0" index="' + index + '">+</a></td>' +
|
|
'<td>' + item.productCode + '</td>' +
|
|
'<td>' + item.total + '</td>' +
|
|
'<td>' + item.condition + '</td>' +
|
|
'<td></td>' +
|
|
'</tr>' +
|
|
'<tr class="row rep-' + index + '" style="display: none;">' +
|
|
'<td></td>' +
|
|
'<td colspan="4">' +
|
|
'<table border="0" cellspacing="0" cellpadding="0" class="">' +
|
|
'<thead>' +
|
|
'<tr>' +
|
|
'<th style="width:40px;">Qty</th>' +
|
|
'<th style="width:75px;">Condition</th>' +
|
|
'<th style="width:75px;">Unit Price</th>' +
|
|
'<th style="width:255px;">Notes</th>' +
|
|
'<th></th>' +
|
|
'</tr>' +
|
|
'</thead>' +
|
|
'<tbody id="rep-quote-"' + index + '>' + this.getRowHtmlReplyQuote(index, 0, item.productId, item.productCode) +
|
|
'<tr id="add-rep-container-' + index + '">' +
|
|
'<td colspan="5" class="add-rep-container" number="1" index="' + index + '" productId="' + item.productId + '" productCode="' + item.productCode + '">' +
|
|
'<a class="add-rep">+</a>' +
|
|
'Add other conditions and/or price breaks' +
|
|
'</td>' +
|
|
'</tr>' +
|
|
'</tbody>' +
|
|
'</table>' +
|
|
'</td>' +
|
|
'</tr>';
|
|
return html;
|
|
},
|
|
|
|
getRowHtmlReplyQuote: function(items_index, quote_in_index, productId, productCode) {
|
|
var html = '<tr class="reply-quote-' + items_index + '-' + quote_in_index + '">' +
|
|
'<td><input type="number" class=" quantity" name="data[items][' + items_index + '][quote_ins][' + quote_in_index + '][qty]" value="" style="width:50px;"></td>' +
|
|
'<td class="condition">' +
|
|
'<select size="1" name="data[items][' + items_index + '][quote_ins][' + quote_in_index + '][condition]" class="condition">' +
|
|
'<option value="NEW">NEW</option>' +
|
|
'<option value="REFURBISHED">REFURBISHED</option>' +
|
|
'</select>' +
|
|
'</td>' +
|
|
'<td>' +
|
|
'<input type="number" name="data[items][' + items_index + '][quote_ins][' + quote_in_index + '][price]" value="" style="width:70px;" placeholder="$" class="format-currency price">' +
|
|
'<input type="hidden" name="data[items][' + items_index + '][productId]" value="' + productId + '" >' +
|
|
'<input type="hidden" name="data[items][' + items_index + '][productCode]" value="' + productCode + '" >' +
|
|
'</td>' +
|
|
'<td>' +
|
|
'<input type="text" name="data[items][' + items_index + '][quote_ins][' + quote_in_index + '][note]" class="notes">' +
|
|
'</td>' +
|
|
'<td>' +
|
|
'<a class="rem-rep" index="' + items_index + '" current="' + quote_in_index + '">x</a>' +
|
|
'</td>' +
|
|
'</tr>';
|
|
return html;
|
|
},
|
|
bindEventShowRep: function() {
|
|
$(".show-rep-a").click(function() {
|
|
var index = $(this).attr("index");
|
|
var display = $(this).attr("display");
|
|
if (display == 0) {
|
|
$(this).attr("display", "1");
|
|
$(this).html("-");
|
|
$(".rep-" + index).attr("style", "display: table-row;");
|
|
} else {
|
|
$(this).attr("display", "0");
|
|
$(this).html("+");
|
|
$(".rep-" + index).attr("style", "display: none;");
|
|
}
|
|
});
|
|
},
|
|
bindEventRemoveRepQuote: function() {
|
|
$(".rem-rep").bind("click", function() {
|
|
var index = $(this).attr("index");
|
|
var current = $(this).attr("current");
|
|
$(".reply-quote-" + index + "-" + current).remove();
|
|
});
|
|
},
|
|
bindEventAddRepContainer: function() {
|
|
var root = this;
|
|
$(".add-rep-container").bind("click", function() {
|
|
var index = $(this).attr("index");
|
|
var number = parseInt($(this).attr("number"));
|
|
var productId = $(this).attr("productId");
|
|
var productCode = $(this).attr("productCode");
|
|
$(root.getRowHtmlReplyQuote(index, number, productId, productCode)).insertBefore("#add-rep-container-" + index);
|
|
$(this).attr("number", (number + 1));
|
|
root.bindEventRemoveRepQuote();
|
|
});
|
|
}
|
|
}
|
|
want_to_by_request.render();
|
|
});
|
|
|
|
});
|
|
</script>
|