Enhancements to Supplier Portal (#19221)

* fix: Add Purchase Order to portal

* fix: Create Customer or Supplier on first login

Based on default role set in Portal Settings, a Customer or Supplier
will be created when the user logs in for the first time.

* fix: Styling for transaction_row

* fix: Styling for RFQ page

* fix: Add Purchase Invoice route

- Make Purchase Invoice from PO

* fix: minor

- Admissions for Student role
- Remove print statement
diff --git a/erpnext/templates/includes/rfq/rfq_items.html b/erpnext/templates/includes/rfq/rfq_items.html
index cb77f7e..caa15f3 100644
--- a/erpnext/templates/includes/rfq/rfq_items.html
+++ b/erpnext/templates/includes/rfq/rfq_items.html
@@ -3,13 +3,13 @@
 {% for d in doc.items %}
 <div class="rfq-item">
 	<div class="row">
-		<div class="col-sm-5 col-xs-12" style="margin-bottom: 10px;margin-top: 5px;">
+		<div class="col-sm-5 col-12" style="margin-bottom: 10px;margin-top: 5px;">
 			{{ item_name_and_description(d, doc) }}
 		</div>
-		<!-- <div class="col-sm-2 col-xs-2" style="margin-bottom: 10px;">
+		<!-- <div class="col-sm-2 col-2" style="margin-bottom: 10px;">
 			<textarea type="text" style="margin-top: 5px;" class="input-with-feedback form-control rfq-offer_detail" ></textarea>
 		</div> -->
-		<div class="col-sm-2 col-xs-4 text-right">
+		<div class="col-sm-2 col-4 text-right">
 				<input type="text" class="form-control text-right rfq-qty" style="margin-top: 5px;display: inline-block"
 				value = "{{ d.get_formatted('qty') }}"
 				data-idx="{{ d.idx }}">
@@ -17,14 +17,14 @@
 					{{_("UOM") + ":"+ d.uom}}
 				</p>
 		</div>
-		<div class="col-sm-2 col-xs-4 text-right">
+		<div class="col-sm-2 col-4 text-right">
 			<input type="text" class="form-control text-right rfq-rate"
 				style="margin-top: 5px;display: inline-block" value="0.00"
 				data-idx="{{ d.idx }}">
 		</div>
-        <div class="col-sm-3 col-xs-4 text-right" style="padding-top: 9px;">
+        <div class="col-sm-3 col-4 text-right" style="padding-top: 9px;">
            {{doc.currency_symbol}} <span class="rfq-amount" data-idx="{{ d.idx }}">0.00</span>
         </div>
 		</div>
 	</div>
-{% endfor %}
\ No newline at end of file
+{% endfor %}
diff --git a/erpnext/templates/includes/rfq/rfq_macros.html b/erpnext/templates/includes/rfq/rfq_macros.html
index 95bbcfe..88724c3 100644
--- a/erpnext/templates/includes/rfq/rfq_macros.html
+++ b/erpnext/templates/includes/rfq/rfq_macros.html
@@ -1,13 +1,11 @@
-{% from "erpnext/templates/includes/macros.html" import product_image_square %}
+{% from "erpnext/templates/includes/macros.html" import product_image_square, product_image %}
 
 {% macro item_name_and_description(d, doc) %}
     <div class="row">
-        <div class="col-xs-4 col-sm-2 order-image-col">
-            <div class="order-image">
-                {{ product_image_square(d.image) }}
-            </div>
+        <div class="col-3">
+			{{ product_image(d.image) }}
         </div>
-        <div class="col-xs-8 col-sm-10">
+        <div class="col-9">
             {{ d.item_code }}
             <p class="text-muted small">{{ d.description }}</p>
 			{% set supplier_part_no = frappe.db.get_value("Item Supplier", {'parent': d.item_code, 'supplier': doc.supplier}, "supplier_part_no") %}
diff --git a/erpnext/templates/includes/transaction_row.html b/erpnext/templates/includes/transaction_row.html
index 6c58b51..80a542f 100644
--- a/erpnext/templates/includes/transaction_row.html
+++ b/erpnext/templates/includes/transaction_row.html
@@ -1,22 +1,21 @@
 <div class="web-list-item transaction-list-item">
-	<a href="/{{ pathname }}/{{ doc.name }}">
-		<div class="row">
-			<div class="col-sm-4" style='margin-top: -3px;'>
-				<span class="indicator small {{ doc.indicator_color or ("blue" if doc.docstatus==1 else "darkgrey") }}">
-				{{ doc.name }}</span>
-				<div class="small text-muted transaction-time"
-					title="{{ frappe.utils.format_datetime(doc.modified, "medium") }}">
-					{{ frappe.utils.global_date_format(doc.modified) }}
-				</div>
-			</div>
-			<div class="col-sm-5">
-				<div class="small text-muted items-preview ellipsis ellipsis-width">
-					{{ doc.items_preview }}
-				</div>
-			</div>
-			<div class="col-sm-3 text-right bold">
-				{{ doc.get_formatted("grand_total") }}
+	<div class="row">
+		<div class="col-sm-4">
+			<span class="indicator small {{ doc.indicator_color or ("blue" if doc.docstatus==1 else "darkgrey") }}">
+			{{ doc.name }}</span>
+			<div class="small text-muted transaction-time"
+				title="{{ frappe.utils.format_datetime(doc.modified, "medium") }}">
+				{{ frappe.utils.global_date_format(doc.modified) }}
 			</div>
 		</div>
-	</a>
+		<div class="col-sm-5">
+			<div class="small text-muted items-preview ellipsis ellipsis-width">
+				{{ doc.items_preview }}
+			</div>
+		</div>
+		<div class="col-sm-3 text-right bold">
+			{{ doc.get_formatted("grand_total") }}
+		</div>
+	</div>
+	<a class="transaction-item-link" href="/{{ pathname }}/{{ doc.name }}">Link</a>
 </div>
diff --git a/erpnext/templates/pages/order.html b/erpnext/templates/pages/order.html
index 67a8fed..9e3c58b 100644
--- a/erpnext/templates/pages/order.html
+++ b/erpnext/templates/pages/order.html
@@ -12,7 +12,22 @@
 {% endblock %}
 
 {% block header_actions %}
-<a href='/printview?doctype={{ doc.doctype}}&name={{ doc.name }}&format={{ print_format }}' target="_blank" rel="noopener noreferrer">{{ _("Print") }}</a>
+<div class="dropdown">
+	<button class="btn btn-outline-secondary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
+		<span>{{ _('Actions') }}</span>
+		<b class="caret"></b>
+	</button>
+	<ul class="dropdown-menu dropdown-menu-right" role="menu">
+		{% if doc.doctype == 'Purchase Order' %}
+		<a class="dropdown-item" href="/api/method/erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_invoice_from_portal?purchase_order_name={{ doc.name }}" data-action="make_purchase_invoice">{{ _("Make Purchase Invoice") }}</a>
+		{% endif %}
+		<a class="dropdown-item" href='/printview?doctype={{ doc.doctype}}&name={{ doc.name }}&format={{ print_format }}'
+			target="_blank" rel="noopener noreferrer">
+			{{ _("Print") }}
+		</a>
+	</ul>
+</div>
+
 {% endblock %}
 
 {% block page_content %}
@@ -34,7 +49,7 @@
 </div>
 
 <p class="small my-3">
-	{%- set party_name = doc.supplier_name if doc.doctype == 'Supplier Quotation' else doc.customer_name %}
+	{%- set party_name = doc.supplier_name if doc.doctype in ['Supplier Quotation', 'Purchase Invoice', 'Purchase Order'] else doc.customer_name %}
 	<b>{{ party_name }}</b>
 
 	{% if doc.contact_display and doc.contact_display != party_name %}
@@ -172,4 +187,4 @@
 			currency: '{{ doc.currency }}'
 		}
 	</script>
-{% endblock %}
\ No newline at end of file
+{% endblock %}
diff --git a/erpnext/templates/pages/order.js b/erpnext/templates/pages/order.js
index 21c3a14..0574cde 100644
--- a/erpnext/templates/pages/order.js
+++ b/erpnext/templates/pages/order.js
@@ -5,7 +5,9 @@
 
 	var loyalty_points_input = document.getElementById("loyalty-point-to-redeem");
 	var loyalty_points_status = document.getElementById("loyalty-points-status");
-	loyalty_points_input.onblur = apply_loyalty_points;
+	if (loyalty_points_input) {
+		loyalty_points_input.onblur = apply_loyalty_points;
+	}
 
 	function apply_loyalty_points() {
 		var loyalty_points = parseInt(loyalty_points_input.value);
@@ -37,4 +39,4 @@
 			});
 		}
 	}
-})
\ No newline at end of file
+})
diff --git a/erpnext/templates/pages/rfq.html b/erpnext/templates/pages/rfq.html
index 591d046..5b27a94 100644
--- a/erpnext/templates/pages/rfq.html
+++ b/erpnext/templates/pages/rfq.html
@@ -22,10 +22,10 @@
 
 {% block page_content %}
 <div class="row">
-    <div class="col-xs-6">
+    <div class="col-6">
         <div class="rfq-supplier">{{ doc.supplier }}</div>
 	</div>
-    <div class="col-xs-6 text-muted text-right h6">
+    <div class="col-6 text-muted text-right h6">
         {{ doc.get_formatted("transaction_date") }}
     </div>
 </div>
@@ -33,16 +33,16 @@
 	<div id="order-container">
 			<div id="rfq-items">
 				<div class="row cart-item-header">
-					<div class="col-sm-5 col-xs-12">
+					<div class="col-sm-5 col-12">
 						{{ _("Items") }}
 					</div>
-					<div class="col-sm-2 col-xs-4 text-right">
+					<div class="col-sm-2 col-4 text-right">
 						{{ _("Qty") }}
 					</div>
-					<div class="col-sm-2 col-xs-4 text-right">
+					<div class="col-sm-2 col-4 text-right">
 						{{ _("Rate") }}
 					</div>
-					<div class="col-sm-3 col-xs-4 text-right">
+					<div class="col-sm-3 col-4 text-right">
 						{{ _("Amount") }}
 					</div>
 				</div>
@@ -55,30 +55,29 @@
 		</div>
         {% if doc.items %}
 		<div class="row grand-total-row">
-			<div class="col-xs-9 text-right">{{ _("Grand Total") }}</div>
-			<div class="col-xs-3 text-right">
+			<div class="col-9 text-right">{{ _("Grand Total") }}</div>
+			<div class="col-3 text-right">
 			{{doc.currency_symbol}}  <span class="tax-grand-total">0.0</span>
 			</div>
 		</div>
         {% endif %}
 		<div class="row terms">
-			<div class="col-xs-6">
+			<div class="col-6">
 				<br><br>
 				<p class="text-muted small">{{ _("Notes: ") }}</p>
 				<textarea class="form-control terms-feedback" style="height: 100px;"></textarea>
 			</div>
 		</div>
-		<hr>
-		<div class="row">
-			<div class="result">
-				<div class="col-xs-12">
-					<p class="text-muted small">{{ _("Quotations: ") }}</p>
-					{% if doc.rfq_links %}
+		<div class="row mt-5">
+			<div class="col-12">
+				<p class="text-muted small">{{ _("Quotations: ") }}</p>
+				{% if doc.rfq_links %}
+					<div class="result">
 						{% for d in doc.rfq_links %}
 							<div class="web-list-item transaction-list-item quotations" idx="{{d.name}}">
 								<div class="row">
 									<div class="col-sm-6">
-										<span class="indicator darkgrey"><a href="/quotations/{{d.name}}">{{d.name}}</a></span>
+										<span class="indicator darkgrey">{{d.name}}</span>
 									</div>
 									<div class="col-sm-3">
 										<span class="small darkgrey">{{d.status}}</span>
@@ -87,10 +86,11 @@
 										<span class="small darkgrey">{{d.transaction_date}}</span>
 									</div>
 								</div>
+								<a class="transaction-item-link" href="/quotations/{{d.name}}">Link</a>
 							</div>
 						{% endfor %}
-					{% endif %}
-				</div>
+					</div>
+				{% endif %}
 			</div>
 		</div>
     </div>