mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim-api.git
synced 2026-08-19 04:24:01 +00:00
Added listing of Contacts frontend
This commit is contained in:
+5
-5
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Company extends Model
|
||||
{
|
||||
|
||||
|
||||
protected $fillable = ['user_id', 'company_profile', 'reg_cert', 'company_name', 'registration_no', 'tax_no', 'tel_no', 'fax', 'address', 'city', 'postcode', 'state', 'country', 'contact_person'];
|
||||
|
||||
public function user()
|
||||
@@ -17,18 +17,18 @@ class Company extends Model
|
||||
public function deliveryinfo() {
|
||||
|
||||
return $this->hasMany('App\Deliveryinfo');
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function warehouse() {
|
||||
|
||||
return $this->hasMany('App\Warehouse');
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function contact() {
|
||||
public function contacts() {
|
||||
|
||||
return $this->hasMany('App\Contact');
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Contact extends Model
|
||||
{
|
||||
protected $fillable = ['company_id'];
|
||||
protected $fillable = ['com_id'];
|
||||
|
||||
public function user() {
|
||||
|
||||
@@ -14,9 +14,9 @@ class Contact extends Model
|
||||
|
||||
}
|
||||
|
||||
public function company(){
|
||||
public function companies(){
|
||||
|
||||
return $this->belongsTo(App/Company);
|
||||
return $this->belongsTo('App\Company');
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -11,14 +11,23 @@ class ContactController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$contacts = Contact::where('user_id', Auth::user()->id)->where('id', $id)->get();
|
||||
$output= array();
|
||||
$contacts = Contact::where('user_id', Auth::user()->id)->get();
|
||||
$companies= Contact::with('companies')->get();
|
||||
//$companies =\DB::table('companies')->select('contacts.com_id', 'companies.id', 'companies.company_name')->join('contacts', 'contacts.com_id', '=', 'companies.id')->get();
|
||||
//$companies = "SELECT contacts.com_id, companies.id, companies.company_name FROM `companies` INNER JOIN contacts ON contacts.com_id = companies.id";
|
||||
|
||||
// $companies = \DB::table('companies')
|
||||
// ->select('id', 'company_name')
|
||||
// ->where('com_id', Auth::user()->id)
|
||||
// ->get();
|
||||
|
||||
if (!$contacts)
|
||||
{
|
||||
return response()->json(['message'=>'Access Denied!'], 404);
|
||||
}
|
||||
|
||||
return response()->json($contacts, 200);
|
||||
return response()->json($companies, 200);
|
||||
}
|
||||
|
||||
public function sendRequest(Request $request)
|
||||
|
||||
+80
-181
@@ -11,199 +11,71 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<!-- Wrapper Content Start Here -->
|
||||
<div class="wrapper">
|
||||
|
||||
<!-- Wrapper Inline Start Here -->
|
||||
<div class="wrapper-inline">
|
||||
<header style="background-color: #FFF">
|
||||
<a class="go-back-link" href="javascript:history.back();"><i class="fa fa-arrow-left"></i></a>
|
||||
<h1 id="HT" class="page-title" style="color: #000">Contacts</h1>
|
||||
<div class="navi-menu-button">
|
||||
<div class="navi-menu-button" onclick="sideMenu()">
|
||||
<em></em>
|
||||
<em></em>
|
||||
<em></em>
|
||||
</div>
|
||||
</header>
|
||||
<div class="search-result-header fix-searchbar">
|
||||
<a id="btnback" type="button" class="search-result-btn" href="javascript:history.back();"><i class="fa fa-arrow-left"></i></a>
|
||||
</div>
|
||||
|
||||
<!-- Page Content Start Here -->
|
||||
<main class="fix-top-menu">
|
||||
<section class="container">
|
||||
|
||||
<!-- Navigation Body Start Here -->
|
||||
<div class="cont-menu">
|
||||
|
||||
<div class="list-box">
|
||||
|
||||
<div id="content">
|
||||
<a>Favourite/Company</a>
|
||||
<div class="form-divider-2"></div>
|
||||
<a href="#" class="list-item">
|
||||
<i class="fa fa-users"></i>
|
||||
<em class="seperate"></em>
|
||||
<span class="list-item-title">CIEF</span>
|
||||
<span class="list-item-title-role">Importer</span>
|
||||
</a>
|
||||
<a href="#" class="list-item">
|
||||
<i class="fa fa-users"></i>
|
||||
<em class="seperate"></em>
|
||||
<span class="list-item-title">FedEx</span>
|
||||
<span class="list-item-title-role">Forwarder</span>
|
||||
</a>
|
||||
<a>Request send</a>
|
||||
<div class="form-divider-2"></div>
|
||||
<a href="#" class="list-item">
|
||||
<i class="fa fa-user"></i>
|
||||
<em class="seperate-contact"></em>
|
||||
<span class="list-item-title-contact">Casey</span>
|
||||
<br />
|
||||
<span class="list-item-title-contact" style="margin-top:-13px; color: #069">Resquest sent</span>
|
||||
<span class="list-item-title-role" style="margin-top:-13px">Importer</span>
|
||||
</a>
|
||||
<a>Waiting for approval</a>
|
||||
<div class="form-divider-2"></div>
|
||||
<a href="#" class="list-item" data-popup="formPopup6">
|
||||
<i class="fa fa-user" style="color: red"></i>
|
||||
<em class="seperate-contact"></em>
|
||||
<span class="list-item-title-contact">Alexander</span>
|
||||
<br />
|
||||
<span class="list-item-title-contact" style="margin-top:-13px; color: #069">Waiting for appproval</span>
|
||||
<span class="list-item-title-role" style="margin-top:-13px">Forwarder</span>
|
||||
</a>
|
||||
<a>Online</a>
|
||||
<div class="form-divider-2"></div>
|
||||
<a href="#" class="list-item" data-popup="formPopup7">
|
||||
<i class="fa fa-user" style="color: green"></i>
|
||||
<em class="seperate-contact"></em>
|
||||
<span class="list-item-title-contact">Bryan</span>
|
||||
<br />
|
||||
<span class="list-item-title-contact" style="margin-top:-13px; color: #029900">Online</span>
|
||||
<span class="list-item-title-role" style="margin-top:-13px">Forwarder</span>
|
||||
</a>
|
||||
<div class="form-divider-2"></div>
|
||||
<a href="#" class="list-item" data-popup="formPopup7">
|
||||
<i class="fa fa-user" style="color: green"></i>
|
||||
<em class="seperate-contact"></em>
|
||||
<span class="list-item-title-contact">Edmund</span>
|
||||
<br />
|
||||
<span class="list-item-title-contact" style="margin-top:-13px; color: #029900">Online</span>
|
||||
<span class="list-item-title-role" style="margin-top:-13px">Importer</span>
|
||||
</a>
|
||||
<a>Offline</a>
|
||||
<div class="form-divider-2"></div>
|
||||
<a href="#" class="list-item" data-popup="formPopup7">
|
||||
<i class="fa fa-user" style="color: green"></i>
|
||||
<em class="seperate-contact"></em>
|
||||
<span class="list-item-title-contact">Dylan</span>
|
||||
<br />
|
||||
<span class="list-item-title-contact" style="margin-top:-13px; color: red">Offline</span>
|
||||
<span class="list-item-title-role" style="margin-top:-13px">Forwarder</span>
|
||||
</a>
|
||||
<div class="form-divider"></div>
|
||||
<a>A</a>
|
||||
<div class="form-divider-2"></div>
|
||||
<a href="#" class="list-item" data-popup="formPopup6">
|
||||
<i class="fa fa-user" style="color: red"></i>
|
||||
<em class="seperate-contact"></em>
|
||||
<span class="list-item-title-contact">Alexander</span>
|
||||
<br />
|
||||
<span class="list-item-title-contact" style="margin-top:-13px; color: #069">Waiting for appproval</span>
|
||||
<span class="list-item-title-role" style="margin-top:-13px">Forwarder</span>
|
||||
</a>
|
||||
<a>B</a>
|
||||
<div class="form-divider-2"></div>
|
||||
<a href="#" class="list-item" data-popup="formPopup7">
|
||||
<i class="fa fa-user" style="color: green"></i>
|
||||
<em class="seperate-contact"></em>
|
||||
<span class="list-item-title-contact">Bryan</span>
|
||||
<br />
|
||||
<span class="list-item-title-contact" style="margin-top:-13px; color: #029900">Online</span>
|
||||
<span class="list-item-title-role" style="margin-top:-13px">Forwarder</span>
|
||||
</a>
|
||||
<a>C</a>
|
||||
<div class="form-divider-2"></div>
|
||||
<a href="#" class="list-item">
|
||||
<i class="fa fa-user"></i>
|
||||
<em class="seperate-contact"></em>
|
||||
<span class="list-item-title-contact">Casey</span>
|
||||
<br />
|
||||
<span class="list-item-title-contact" style="margin-top:-13px; color: #069">Resquest sent</span>
|
||||
<span class="list-item-title-role" style="margin-top:-13px">Importer</span>
|
||||
</a>
|
||||
<a>D</a>
|
||||
<div class="form-divider-2"></div>
|
||||
<a href="#" class="list-item" data-popup="formPopup7">
|
||||
<i class="fa fa-user" style="color: green"></i>
|
||||
<em class="seperate-contact"></em>
|
||||
<span class="list-item-title-contact">Dylan</span>
|
||||
<br />
|
||||
<span class="list-item-title-contact" style="margin-top:-13px; color: red">Offline</span>
|
||||
<span class="list-item-title-role" style="margin-top:-13px">Forwarder</span>
|
||||
</a>
|
||||
<a>E</a>
|
||||
<div class="form-divider-2"></div>
|
||||
<a href="#" class="list-item" data-popup="formPopup7">
|
||||
<i class="fa fa-user" style="color: green"></i>
|
||||
<em class="seperate-contact"></em>
|
||||
<span class="list-item-title-contact">Edmund</span>
|
||||
<br />
|
||||
<span class="list-item-title-contact" style="margin-top:-13px; color: #029900">Online</span>
|
||||
<span class="list-item-title-role" style="margin-top:-13px">Importer</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="form-divider"></div>
|
||||
<div class="form-divider"></div>
|
||||
<!-- Content List Spawner End Here-->
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-fixed"></div>
|
||||
|
||||
<div class="list-box">
|
||||
<div id="all-contacts">
|
||||
<div class="form-divider-2"></div>
|
||||
<a href="search-contact.html" class="list-item">
|
||||
<i class="fa fa-user-plus"></i>
|
||||
<em class="seperate"></em>
|
||||
<span class="list-item-title">Add Contact</span>
|
||||
</a>
|
||||
<a>Favourite/Company</a>
|
||||
<div class="form-divider-2"></div>
|
||||
<a href="#" class="list-item">
|
||||
<i class="fa fa-users"></i>
|
||||
<em class="seperate"></em>
|
||||
<span class="list-item-title">CIEF</span>
|
||||
<span class="list-item-title-role">Importer</span>
|
||||
</a>
|
||||
<a href="#" class="list-item">
|
||||
<i class="fa fa-users"></i>
|
||||
<em class="seperate"></em>
|
||||
<span class="list-item-title">FedEx</span>
|
||||
<span class="list-item-title-role">Forwarder</span>
|
||||
</a>
|
||||
<a>Request send</a>
|
||||
<div class="form-divider-2"></div>
|
||||
<a href="#" class="list-item">
|
||||
<i class="fa fa-user"></i>
|
||||
<em class="seperate-contact"></em>
|
||||
<span class="list-item-title-contact">Casey</span>
|
||||
<br />
|
||||
<span class="list-item-title-contact" style="margin-top:-13px; color:#069">Resquest sent</span>
|
||||
<span class="list-item-title-role" style="margin-top:-13px">Importer</span>
|
||||
</a>
|
||||
<a>Waiting for approval</a>
|
||||
<div class="form-divider-2"></div>
|
||||
<a href="#" class="list-item" data-popup="formPopup6">
|
||||
<i class="fa fa-user" style="color: red"></i>
|
||||
<em class="seperate-contact"></em>
|
||||
<span class="list-item-title-contact">Alexander</span>
|
||||
<br />
|
||||
<span class="list-item-title-contact" style="margin-top:-13px; color: #069">Waiting for appproval</span>
|
||||
<span class="list-item-title-role" style="margin-top:-13px">Forwarder</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Navigation Menu Start Here -->
|
||||
<cont class="menu">
|
||||
<div class="form-divider"></div>
|
||||
<a> Add New Friend</a>
|
||||
<div class="list-box-emp">
|
||||
<a href="#" class="list-item">
|
||||
<i class="fa fa-user"></i>
|
||||
<em class="seperate-contact"></em>
|
||||
<span class="list-item-title-contact">Chua</span>
|
||||
<br />
|
||||
<span class="list-item-title-contact" style="margin-top:-13px; color: #029900">Izyim Exist</span>
|
||||
<span class="list-item-title-role" style="margin-top:-13px; float: right">Add</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="list-box-emp">
|
||||
<a href="#" class="list-item">
|
||||
<i class="fa fa-user" style="color: #000"></i>
|
||||
<em class="seperate-contact"></em>
|
||||
<span class="list-item-title-contact">John</span>
|
||||
<br />
|
||||
<span class="list-item-title-contact" style="margin-top:-13px;">012-3124455</span>
|
||||
<span class="list-item-title-role" style="margin-top:-13px; float: right">Invite</span>
|
||||
</a>
|
||||
</div>
|
||||
<!-- Menu navigation start -->
|
||||
<div class="cont-container">
|
||||
<ul id="search_results" class="main-menu" style="background-color: #FFF">
|
||||
|
||||
</ul>
|
||||
<div class="form-divider"></div>
|
||||
</div>
|
||||
<!-- Menu navigation end -->
|
||||
|
||||
</cont>
|
||||
<!-- Navigation Menu End Here-->
|
||||
|
||||
<div class="form-divider"></div>
|
||||
<div class="form-divider"></div>
|
||||
<!-- Content List Spawner End Here-->
|
||||
</div>
|
||||
<!-- Navigation Body Start Here -->
|
||||
<div class="form-fixed"></div>
|
||||
|
||||
</section>
|
||||
</main>
|
||||
@@ -219,7 +91,7 @@
|
||||
<!-- if you dont want overlay add class .no-overlay -->
|
||||
<div class="popup-container">
|
||||
<div class="popup-header">
|
||||
<h3 class="popup-title" >Add a Contact</h3>
|
||||
<h3 class="popup-title">Contact Details</h3>
|
||||
<span class="popup-close" data-dismiss="true"><i class="fa fa-times"></i></span>
|
||||
</div>
|
||||
<div class="popup-content">
|
||||
@@ -259,21 +131,48 @@
|
||||
<!-- Required For All Pages, Otherwise Ugly Others Function Won't Work -->
|
||||
|
||||
<script type="text/javascript">
|
||||
//$(document).ready(function() {
|
||||
function displayContacts(){
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "api/contacts/display",
|
||||
headers: {"Authorization": 'Bearer' + localStorage.getItem('token')},
|
||||
|
||||
success:function(data){
|
||||
data.foreach($contacts=>{
|
||||
console.log(data.com_id);
|
||||
console.log(data.status);
|
||||
});
|
||||
// {{$contact->name}}
|
||||
// foreach($contact->companies as $company
|
||||
// {{ $company->name }};
|
||||
console.log(data);
|
||||
},
|
||||
error:function(data){
|
||||
console.log(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
//})
|
||||
window.onload = displayContacts;
|
||||
function sideMenu()
|
||||
{
|
||||
console.log('success');
|
||||
}
|
||||
//var company_name, tel_no, contact_person;
|
||||
$('#search').on('keyup', function(){
|
||||
$('#search_results').empty();
|
||||
var ul, li, data;
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "api/company/search",
|
||||
url: "api/contacts",
|
||||
headers: {"Authorization": 'Bearer' + localStorage.getItem('token')},
|
||||
data: {search: $('#search').val()},
|
||||
|
||||
success:function(data){
|
||||
console.log(data);
|
||||
for(i=0; i<data.length; i++){
|
||||
$('#search_results').append('<li style="display: show;"> <a href="#" onclick="displayCompany(' + "'" + data[i].company_name + "'" + ',' + "'" + data[i].tel_no + "'" + ',' + "'" + data[i].contact_person + "'" + ',' + "'" + data[i].com_id + "'" + ')"> <i class="fa fa-user"></i>' + data[i].company_name + '<span class="list-item-title-role" style="margin-top:-10px">' + data[i].tel_no + '</span> <br> <span class="list-item-title-role" style="margin-top:-10px">'+ data[i].contact_person);
|
||||
}
|
||||
// for(i=0; i<data.length; i++){
|
||||
// $('#all-contacts').append('<li style="display: show;"> <a href="#" onclick="displayCompany(' + "'" + data[i].company_name + "'" + ',' + "'" + data[i].tel_no + "'" + ',' + "'" + data[i].contact_person + "'" + ',' + "'" + data[i].com_id + "'" + ')"> <i class="fa fa-user"></i>' + data[i].company_name + '<span class="list-item-title-role" style="margin-top:-10px">' + data[i].tel_no + '</span> <br> <span class="list-item-title-role" style="margin-top:-10px">'+ data[i].contact_person);
|
||||
// }
|
||||
//$('#searchresults').show();
|
||||
},
|
||||
error:function(data){
|
||||
|
||||
+3
-3
@@ -68,10 +68,10 @@ Route::group(['middleware' => ['jwt.auth']], function() {
|
||||
|
||||
/* Contacts */
|
||||
Route::get('/company/search', 'CompanyController@search');
|
||||
Route :: post('/contacts','ContactController@sendRequest');
|
||||
Route::post('/contacts','ContactController@sendRequest');
|
||||
Route::get('/contacts/display','ContactController@index');
|
||||
Route::post('/contacts/{company_id}/request', 'ContactController@postApprove');
|
||||
Route :: delete('/contacts/{contacts_id}','ContactController@destroy');
|
||||
Route :: get('/contacts','ContactController@index');
|
||||
Route::delete('/contacts/{contacts_id}','ContactController@destroy');
|
||||
});
|
||||
|
||||
//Route::post('/company', 'CompanyController@store'); //store company information
|
||||
|
||||
Reference in New Issue
Block a user