mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim-api.git
synced 2026-08-19 04:24:01 +00:00
Delivery CRUD Fix
This commit is contained in:
@@ -12,7 +12,7 @@ class DeliveryinfoController extends Controller
|
|||||||
{
|
{
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$deliveryinfos = App\Deliveryinfo::all();
|
$deliveryinfos = Deliveryinfo::all();
|
||||||
return response()->json($deliveryinfos, 200);
|
return response()->json($deliveryinfos, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,8 +24,8 @@ 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)->first();
|
//$deliveryinfo = Deliveryinfo::where('com_id', Auth::user()->company())->where('id', $id)->first();
|
||||||
|
$deliveryinfo = Deliveryinfo::find($id)->first();
|
||||||
return response()->json($deliveryinfo, 200);
|
return response()->json($deliveryinfo, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,8 +63,9 @@ class DeliveryinfoController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function update(Request $request, $id)
|
public function update(Request $request, $id)
|
||||||
{
|
{
|
||||||
$deliveryinfo = Deliveryinfo::where('com_id', Auth::user()->company())->where('id', $id)->firstOrFail();
|
$user = Auth::user();
|
||||||
|
//$deliveryinfo = Deliveryinfo::where('com_id', Auth::user()->company())->where('id', $id)->firstOrFail();
|
||||||
|
$deliveryinfo = Deliveryinfo::find($id)->first();
|
||||||
if (!$deliveryinfo)
|
if (!$deliveryinfo)
|
||||||
{
|
{
|
||||||
return response()->json(['message'=>'Access Denied!'], 404);
|
return response()->json(['message'=>'Access Denied!'], 404);
|
||||||
@@ -78,7 +79,7 @@ class DeliveryinfoController extends Controller
|
|||||||
$deliveryinfo->country = $request->input('country');
|
$deliveryinfo->country = $request->input('country');
|
||||||
$deliveryinfo->contact_person = $request->input('contact_person');
|
$deliveryinfo->contact_person = $request->input('contact_person');
|
||||||
$deliveryinfo->contact_person_no = $request->input('contact_person_no');
|
$deliveryinfo->contact_person_no = $request->input('contact_person_no');
|
||||||
$deliveryinfo->com_id = $user->company();
|
$deliveryinfo->com_id = $user->company()->first()->id;
|
||||||
$deliveryinfo->save();
|
$deliveryinfo->save();
|
||||||
|
|
||||||
return response()->json(['deliveryinfo'=>$deliveryinfo],200);
|
return response()->json(['deliveryinfo'=>$deliveryinfo],200);
|
||||||
@@ -93,8 +94,8 @@ class DeliveryinfoController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function destroy(Deliveryinfo $id)
|
public function destroy(Deliveryinfo $id)
|
||||||
{
|
{
|
||||||
$deliveryinfo = Deliveryinfo::where('com_id', Auth::user()->company())->where('id', $id)->firstOrFail();
|
//$deliveryinfo = Deliveryinfo::where('com_id', Auth::user()->company())->where('id', $id)->firstOrFail();
|
||||||
|
$deliveryinfo = Deliveryinfo::find($id)->first();
|
||||||
if (!$deliveryinfo)
|
if (!$deliveryinfo)
|
||||||
{
|
{
|
||||||
return response()->json(['message'=>'Access Denied!'], 404);
|
return response()->json(['message'=>'Access Denied!'], 404);
|
||||||
@@ -102,6 +103,6 @@ class DeliveryinfoController extends Controller
|
|||||||
|
|
||||||
$deliveryinfo->delete($id);
|
$deliveryinfo->delete($id);
|
||||||
|
|
||||||
return response()->json($deliveryinfo, 204);
|
return response()->json(['deliveryinfo'=>$deliveryinfo], 204);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+93
-59
@@ -168,7 +168,7 @@
|
|||||||
<!-- Page Content Start Here -->
|
<!-- Page Content Start Here -->
|
||||||
<main>
|
<main>
|
||||||
<!-- SEARCH START -->
|
<!-- SEARCH START -->
|
||||||
<div class="list-box-non">
|
<div class="list-box-non" id="deliveryList">
|
||||||
<a class="list-item" data-popup="formPopup3">
|
<a class="list-item" data-popup="formPopup3">
|
||||||
<i class="fa fa-truck"></i>
|
<i class="fa fa-truck"></i>
|
||||||
<em class="seperate"></em>
|
<em class="seperate"></em>
|
||||||
@@ -1028,7 +1028,7 @@
|
|||||||
<!-- if you dont want overlay add class .no-overlay -->
|
<!-- if you dont want overlay add class .no-overlay -->
|
||||||
<div class="popup-container">
|
<div class="popup-container">
|
||||||
<div class="popup-header">
|
<div class="popup-header">
|
||||||
<h3 class="popup-title">Edit Warehouse</h3>
|
<h3 class="popup-title">Edit Delivery</h3>
|
||||||
<span class="popup-close" data-dismiss="true">
|
<span class="popup-close" data-dismiss="true">
|
||||||
<i class="fa fa-times"></i>
|
<i class="fa fa-times"></i>
|
||||||
</span>
|
</span>
|
||||||
@@ -1036,70 +1036,72 @@
|
|||||||
<div class="popup-content">
|
<div class="popup-content">
|
||||||
|
|
||||||
<div class="form-row-group with-icons-no-padding">
|
<div class="form-row-group with-icons-no-padding">
|
||||||
|
|
||||||
|
|
||||||
<div class="form-row no-padding">
|
<div class="form-row no-padding">
|
||||||
<div class="form-element-title">
|
<input type="hidden" id="deliv_id">
|
||||||
<label style="color: #000">Warehouse Name</label>
|
|
||||||
</div>
|
|
||||||
<input type="text" class="form-element" value="" required />
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row no-padding">
|
<div class="form-row no-padding">
|
||||||
<div class="form-element-title">
|
<div class="form-element-title">
|
||||||
<label style="color: #000">Warehouse Address</label>
|
<label style="color: #000">Delivery Info</label>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" class="form-element" value="Jalan Persiaran Apec" required />
|
<input type="text" class="form-element" value="" id="deliv_info" required />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row no-padding">
|
<div class="form-row no-padding">
|
||||||
<div class="form-element-title">
|
<div class="form-element-title">
|
||||||
<label style="color: #000">Warehouse City</label>
|
<label style="color: #000">Delivery Address</label>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" class="form-element" value="Cyberjaya" required />
|
<input type="text" class="form-element" value="" id="deliv_address" required />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row no-padding">
|
<div class="form-row no-padding">
|
||||||
<div class="form-element-title">
|
<div class="form-element-title">
|
||||||
<label style="color: #000">Warehouse Postcode</label>
|
<label style="color: #000">City</label>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" class="form-element" value="63000" required />
|
<input type="text" class="form-element" value="" id="deliv_city" required />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row no-padding">
|
<div class="form-row no-padding">
|
||||||
<div class="form-element-title">
|
<div class="form-element-title">
|
||||||
<label style="color: #000">Warehouse State</label>
|
<label style="color: #000">Postcode</label>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" class="form-element" value="Selangor" required />
|
<input type="text" class="form-element" value="" id="deliv_postcode" required />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row no-padding">
|
<div class="form-row no-padding">
|
||||||
<div class="form-element-title">
|
<div class="form-element-title">
|
||||||
<label style="color: #000">Warehouse Country</label>
|
<label style="color: #000">State</label>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" class="form-element" value="Malaysia" required />
|
<input type="text" class="form-element" value="" id="deliv_state" required />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-row no-padding">
|
||||||
|
<div class="form-element-title">
|
||||||
|
<label style="color: #000">Country</label>
|
||||||
|
</div>
|
||||||
|
<input type="text" class="form-element" value="" id="deliv_country" required />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row no-padding">
|
<div class="form-row no-padding">
|
||||||
<div class="form-element-title">
|
<div class="form-element-title">
|
||||||
<label style="color: #000">Contact Person</label>
|
<label style="color: #000">Contact Person</label>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" class="form-element" value="Lamine" required />
|
<input type="text" class="form-element" value="" id="deliv_contact_person" required />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row no-padding">
|
<div class="form-row no-padding">
|
||||||
<div class="form-element-title">
|
<div class="form-element-title">
|
||||||
<label style="color: #000">Contact Person No</label>
|
<label style="color: #000">Contact Person No</label>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" class="form-element" value="019-7951905" required />
|
<input type="text" class="form-element" value="" id="deliv_contact_person_no" required />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="popup-footer">
|
<div class="popup-footer">
|
||||||
<button id="updateDelivery" class="button blue" data-dismiss="true">Edit Warehouse</button>
|
<button onclick="updateDelivery()" class="button blue" data-dismiss="true">Edit Delivery</button>
|
||||||
<button class="button blue" data-dismiss="true">Delete Warehouse</button>
|
<button onclick="deleteDelivery()" class="button blue" data-dismiss="true">Delete Delivery</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1303,25 +1305,33 @@
|
|||||||
document.getElementById("branchText8").value = document.getElementById(type).value.textContent =
|
document.getElementById("branchText8").value = document.getElementById(type).value.textContent =
|
||||||
"Populate Contact Person No";
|
"Populate Contact Person No";
|
||||||
}
|
}
|
||||||
|
function displayDeliveries() {
|
||||||
|
console.log("Displayed");
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: 'api/deliveryinfo/',
|
||||||
|
headers:{"Authorization": "Bearer " + localStorage.getItem('token')},
|
||||||
|
dataType: 'json',
|
||||||
|
success: function (data) {
|
||||||
|
console.log(data);
|
||||||
|
data.forEach(element => {
|
||||||
|
console.log(element);
|
||||||
|
var deliName = element.deli_info;
|
||||||
|
var deliId = element.id;
|
||||||
|
$("#deliveryList").append('<div class="list-box-emp"><a href="#" class="list-item delivery-list-item" data-popup="formPopup4" onclick="showDelivery('+element.id+')"><i class="fa fa-truck"></i><em class="seperate"></em><span class="list-item-title">'+deliName+'</span></a></div>');
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
jQuery.noConflict();
|
jQuery.noConflict();
|
||||||
jQuery(document).ready(function ($) {
|
jQuery(document).ready(function ($) {
|
||||||
console.log( "ready!" );
|
console.log( "ready!" );
|
||||||
$.ajax({
|
displayDeliveries();
|
||||||
type: "GET",
|
|
||||||
url: 'api/deliveryinfo/',
|
|
||||||
success: function (response) {
|
|
||||||
var element = '<div class="list-box-emp"><a href="#" class="list-item" data-popup="formPopup4"><i class="fa fa-truck"></i><em class="seperate"></em><span class="list-item-title"> '+response.deli_info +'</span></a></div>';
|
|
||||||
response.forEach(element => {
|
|
||||||
(".list-box-non").append(element);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
var count = 1;
|
var count = 1;
|
||||||
$('#PopUp3Form').on('submit',function(e){
|
$('#PopUp3Form').on('submit',function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.log("test");
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
headers:{"Authorization": "Bearer " + localStorage.getItem('token')},
|
headers:{"Authorization": "Bearer " + localStorage.getItem('token')},
|
||||||
@@ -1338,19 +1348,42 @@
|
|||||||
},
|
},
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
console.log('Form submitted!');
|
console.log('Form submitted!');
|
||||||
var deliveryListItem = '<div class="list-box-emp"><a href="#" class="list-item" data-popup="formPopup4"><i class="fa fa-truck"></i><em class="seperate"></em><span class="list-item-title"> Delivery '+count+'</span></a></div>';
|
var deliveryListItem = '<div class="list-box-emp"><a href="#" class="list-item delivery-list-item" data-popup="formPopup4"><i class="fa fa-truck"></i><em class="seperate"></em><span class="list-item-title">'+count+' New Delivery Added</span></a></div>';
|
||||||
$(".list-box-non").append(deliveryListItem);
|
$("#deliveryList").append(deliveryListItem);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$(function () {
|
function showDelivery(id) {
|
||||||
$('updateDelivery').on('click', function () {
|
console.log("delivery has been clicked");
|
||||||
|
$.ajax({
|
||||||
$.ajax({
|
type: "GET",
|
||||||
type: "POST",
|
url: 'api/deliveryinfo/'+id,
|
||||||
url: '/deliveryinfo/{com_id}',
|
headers:{"Authorization": "Bearer " + localStorage.getItem('token')},
|
||||||
|
dataType: 'json',
|
||||||
|
success: function (response) {
|
||||||
|
console.log(response);
|
||||||
|
//$("#deliv_info").attr("value",response.deli_info);
|
||||||
|
$("#deliv_id").val(response.id);
|
||||||
|
$("#deliv_info").val(response.deli_info);
|
||||||
|
$('#deliv_address').val(response.address);
|
||||||
|
$('#deliv_city').val(response.city);
|
||||||
|
$('#deliv_postcode').val(response.postcode);
|
||||||
|
$('#deliv_state').val(response.state);
|
||||||
|
$('#deliv_country').val(response.country);
|
||||||
|
$('#deliv_contact_person').val(response.contact_person);
|
||||||
|
$('#deliv_contact_person_no').val(response.contact_person_no);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function updateDelivery() {
|
||||||
|
var id = $("#deliv_id").val();
|
||||||
|
console.log('Delivery Update Initiated.');
|
||||||
|
$.ajax({
|
||||||
|
type: "PUT",
|
||||||
|
url: 'api/deliveryinfo/'+id,
|
||||||
|
headers:{"Authorization": "Bearer " + localStorage.getItem('token')},
|
||||||
data: {
|
data: {
|
||||||
deli_info: $('#deliv_info').val(),
|
deli_info: $('#deliv_info').val(),
|
||||||
address: $('#deliv_address').val(),
|
address: $('#deliv_address').val(),
|
||||||
@@ -1363,26 +1396,27 @@
|
|||||||
},
|
},
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
alert('Delivery Updated!');
|
alert('Delivery Updated!');
|
||||||
$("#").append()
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
});
|
|
||||||
$(function () {
|
|
||||||
$('deleteDelivery').on('click', function () {
|
|
||||||
|
|
||||||
$.ajax({
|
function deleteDelivery() {
|
||||||
type: "DELETE",
|
var id = $("#deliv_id").val();
|
||||||
url: '/deliveryinfo/{com_id}',
|
console.log('Delivery Update Initiated.');
|
||||||
data: {
|
$.ajax({
|
||||||
|
type: "DELETE",
|
||||||
},
|
url: 'api/deliveryinfo/'+id,
|
||||||
success: function (data) {
|
headers:{"Authorization": "Bearer " + localStorage.getItem('token')},
|
||||||
alert('Delivery Deleted!');
|
data: {
|
||||||
}
|
id: $('#deliv_id').val(),
|
||||||
});
|
},
|
||||||
|
success: function (data) {
|
||||||
|
console.log('Delivery Deleted!');
|
||||||
|
$('.delivery-list-item'+id+'').remove();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<!-- Change Header Title Acccording To The Tab Title End Here -->
|
<!-- Change Header Title Acccording To The Tab Title End Here -->
|
||||||
<script src="js/global.script.js"></script>
|
<script src="js/global.script.js"></script>
|
||||||
|
|||||||
+3
-3
@@ -55,10 +55,10 @@ Route::group(['middleware' => ['jwt.auth']], function() {
|
|||||||
|
|
||||||
// Delivery-Info
|
// Delivery-Info
|
||||||
Route::get('/deliveryinfo/','DeliveryinfoController@index');
|
Route::get('/deliveryinfo/','DeliveryinfoController@index');
|
||||||
Route::get('/deliveryinfo/{com_id}','DeliveryinfoController@show');
|
Route::get('/deliveryinfo/{id}','DeliveryinfoController@show');
|
||||||
Route::post('/deliveryinfo', 'DeliveryinfoController@store');
|
Route::post('/deliveryinfo', 'DeliveryinfoController@store');
|
||||||
Route::put('/deliveryinfo/{com_id}', 'DeliveryinfoController@update');
|
Route::put('/deliveryinfo/{id}', 'DeliveryinfoController@update');
|
||||||
Route::delete('/deliveryinfo/{com_id}', 'DeliveryinfoController@destroy');
|
Route::delete('/deliveryinfo/{id}', 'DeliveryinfoController@destroy');
|
||||||
|
|
||||||
|
|
||||||
/* Company */
|
/* Company */
|
||||||
|
|||||||
Reference in New Issue
Block a user