fetching branchname and popup

This commit is contained in:
Asif
2018-07-02 22:25:51 +08:00
parent c917811978
commit c8a79a40fe
2 changed files with 34 additions and 13 deletions
@@ -11,7 +11,8 @@ class DeliveryinfoController extends Controller
{ {
public function index() public function index()
{ {
$deliveryinfo = Deliveryinfo::where('com_id', Auth::user()->company())->get(); $com_id = Auth::user()->company()->first()->id;
$deliveryinfo = Deliveryinfo::where('com_id', $com_id)->get();
return response()->json($deliveryinfo, 200); return response()->json($deliveryinfo, 200);
} }
@@ -23,7 +24,9 @@ class DeliveryinfoController extends Controller
*/ */
public function show(Deliveryinfo $id) public function show(Deliveryinfo $id)
{ {
$deliveryinfo = Deliveryinfo::where('com_id', Auth::user()->company())->where('id', $id)->firstOrFail(); // TODO : make user company not array
$com_id = Auth::user()->company()->get()[0]['id'];
$deliveryinfo = Deliveryinfo::where('com_id', $com_id)->where('id', $id)->firstOrFail();
return response()->json($deliveryinfo, 200); return response()->json($deliveryinfo, 200);
} }
+29 -11
View File
@@ -643,7 +643,7 @@
<!--</div>--> <!--</div>-->
<div class="profile-menu-xAxisP"> <div class="profile-menu-xAxisP">
<a href="#"> <a href="#">
<img class="avatar-img" id="del-inf" src="images/Azure-DeliveryIcon.png" width="80" height="80" /> <img class="avatar-img" id="del-info-btn" src="images/Azure-DeliveryIcon.png" width="80" height="80" />
<div> <div>
Delivery Information Delivery Information
</div> </div>
@@ -1305,6 +1305,8 @@
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$('#del-info').click(function() { $('#del-info').click(function() {
$.ajax({ $.ajax({
type: "POST", type: "POST",
@@ -1341,24 +1343,40 @@
}) })
$('#del-inf').click(function() { $('#del-info-btn').click(function() {
var $infos= $('#del-inf'); //console.log('clicked');
var $infos= $('#del-no');
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: "api/deliveryinfo/1", url: "api/deliveryinfo",
headers: {"Authorization": 'Bearer' + localStorage.getItem('token')}, headers: {"Authorization": 'Bearer' + localStorage.getItem('token')},
success: function (infos) success: function (data) {
{ jQuery.each(data, function (i, val) {
$each(infos, function (i, info) { console.log(i);
$infos.append('<div class="list-box-emp"> <a href="#" id="warehouse" class="list-item"> <i class="fa fa-truck"></i> <em class="seperate"></em> <span class="list-item-title"> ' + val.branch + '</span> </a> </div> ');
$infos.append('<li>Branch:'+ info.branch +',DelInfo:'+ info.deli_info +',Address:'+ info.address +',City:'+ info.city +'' + //data.branch,data.deli_info,data.address,data.city,data.postcode,data.state,data.country,data.contact_person,data.contact_person_no
',PostCode:'+ info.postcode +',State:' +info.state +',Country:' +info.country +',ContactPerson:' +info.contact_person +'' +
',ContactPersonNo:' +info.contact_person_no +' </li>');
}); });
} }
}); });
}); });
$('#warehouse').click(function() {
alert('hello');
});
// function myfunction(branch,deli_info,address,city,postcode,state,country,contact_person,contact_person_no )
$(document).on('click', '[data-popup]', function(branch,deli_info,address,city,postcode,state,country,contact_person,contact_person_no){
var warehouse = $(this).attr('data-popup');
$('#'+warehouse).fadeIn('fast');
});
// }
// success: function (data) { // success: function (data) {