File: /var/www/html/fieldsblaze-heroku/app/Http/Controllers/CollectionController.php
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Models\Collection;
use App\Models\Customer;
use App\Models\Order;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\File;
use App\Library\UserLib;
use DateTime;
use DB;
class CollectionController extends Controller
{
protected $userLib;
public function __construct(UserLib $userLib)
{
$this->userLib = $userLib;
}
#### All Collection
public function allCollection(){
if(empty(session('UserId')))
{
return redirect('/admin/logout');
}
$Collection = Collection::select('tbl_collection.*', 'tbl_payment_type.PaymentTypeName as PaymentType', 'tbl_customer.CustomerName as CustomerId', 'tbl_admin.FirstName as AdminCreated_by', 'tbl_user.FirstName as Updated_by', 'tbl_user.FirstName as Created_by')
->leftJoin('tbl_admin', 'tbl_collection.Updated_by', '=', 'tbl_admin.UserId')
->leftJoin('tbl_user', 'tbl_collection.Updated_by', '=', 'tbl_user.UserId')
->leftJoin('tbl_customer', 'tbl_collection.CustomerId', '=', 'tbl_customer.CustomerId')
->leftJoin('tbl_payment_type', 'tbl_collection.PaymentType', '=', 'tbl_payment_type.PaymentTypeId')
->where('tbl_collection.IsDeleted', '=', '0')
->orderBy('tbl_collection.id', 'desc')
->get();
$TrashCollection = Collection::select('tbl_collection.*', 'tbl_payment_type.PaymentTypeName as PaymentType', 'tbl_customer.CustomerName as CustomerId', 'tbl_admin.FirstName as Updated_by', 'tbl_admin.FirstName as Created_by')
->leftJoin('tbl_admin', 'tbl_collection.Updated_by', '=', 'tbl_admin.UserId')
->leftJoin('tbl_customer', 'tbl_collection.CustomerId', '=', 'tbl_customer.CustomerId')
->leftJoin('tbl_payment_type', 'tbl_collection.PaymentType', '=', 'tbl_payment_type.PaymentTypeId')
->where('tbl_collection.IsDeleted', '=', '1')
->orderBy('tbl_collection.id', 'desc')
->get();
return view ('admin.all-collection', ['Collection' => $Collection, 'TrashCollection' => $TrashCollection]);
}
#Trash Collection
public function trashCollection(){
if(empty(session('UserId')))
{
return redirect('/admin/logout');
}
$Collection = Collection::select('tbl_collection.*', 'tbl_payment_type.PaymentTypeName as PaymentType', 'tbl_customer.CustomerName as CustomerId', 'tbl_admin.FirstName as Updated_by', 'tbl_admin.FirstName as Created_by')
->leftJoin('tbl_admin', 'tbl_collection.Updated_by', '=', 'tbl_admin.UserId')
->leftJoin('tbl_customer', 'tbl_collection.CustomerId', '=', 'tbl_customer.CustomerId')
->leftJoin('tbl_payment_type', 'tbl_collection.PaymentType', '=', 'tbl_payment_type.PaymentTypeId')
->where('tbl_collection.IsDeleted', '=', '0')
->orderBy('tbl_collection.id', 'desc')
->get();
$TrashCollection = Collection::select('tbl_collection.*', 'tbl_payment_type.PaymentTypeName as PaymentType', 'tbl_customer.CustomerName as CustomerId', 'tbl_admin.FirstName as AdminCreated_by', 'tbl_user.FirstName as Updated_by', 'tbl_user.FirstName as Created_by')
->leftJoin('tbl_admin', 'tbl_collection.Updated_by', '=', 'tbl_admin.UserId')
->leftJoin('tbl_user', 'tbl_collection.Updated_by', '=', 'tbl_user.UserId')
->leftJoin('tbl_customer', 'tbl_collection.CustomerId', '=', 'tbl_customer.CustomerId')
->leftJoin('tbl_payment_type', 'tbl_collection.PaymentType', '=', 'tbl_payment_type.PaymentTypeId')
->where('tbl_collection.IsDeleted', '=', '1')
->orderBy('tbl_collection.id', 'desc')
->get();
return view ('admin.trash-collection', ['Collection' => $Collection, 'TrashCollection' => $TrashCollection]);
}
### View Record
public function viewCollection($CollectionId)
{
if (empty(session('UserId'))) {
return redirect('/admin/logout');
}
$ViewCollection = Collection::select('tbl_collection.*', 'tbl_payment_type.PaymentTypeName as PaymentType', 'tbl_customer.CustomerName as CustomerId', 'tbl_order.OrderNo as OrderNo', 'tbl_admin.FirstName as AdminCreated_by', 'tbl_admin.FirstName as AdminCreated_by', 'tbl_user.FirstName as Updated_by', 'tbl_user.FirstName as Created_by')
->leftJoin('tbl_admin', 'tbl_collection.Updated_by', '=', 'tbl_admin.UserId')
->leftJoin('tbl_user', 'tbl_collection.Updated_by', '=', 'tbl_user.UserId')
->where('CollectionId', "=", $CollectionId)
->leftJoin('tbl_customer', 'tbl_collection.CustomerId', '=', 'tbl_customer.CustomerId')
->leftJoin('tbl_order', 'tbl_collection.OrderId', '=', 'tbl_order.OrderId')
->leftJoin('tbl_payment_type', 'tbl_collection.PaymentType', '=', 'tbl_payment_type.PaymentTypeId')
->get()->first();
return view('admin.view-collection', ['Collection' => $ViewCollection]);
}
### Store New Record
public function storeCollection(Request $request)
{
if (empty(session('UserId'))) {
return redirect('/admin/logout');
}
$input = $request->all();
$data = $input;
$CustomerId = $request->input('CustomerId');
$AssignTo = '';
if ($CustomerId) {
$Customer = Customer::where('CustomerId', $CustomerId)->get()->first();
$AssignTo = $Customer->AssignTo;
}
##CollectionFile1
// $path1 = '';
// $paymentFile1 = $request->file('paymentFile1');
// $imageName1 = $this->userLib->useridGenrator();
// if ($request->hasFile('paymentFile1'))
// {
// $file1 = $request->file('paymentFile1');
// $extension = $file1->getClientOriginalExtension();
// $newFileName1 = $imageName1.'-'.time() . '.' . $extension;
// Storage::putFileAs(
// 'public/collection', $file1, $newFileName1
// );
// $path1 = Storage::url('collection/'.$newFileName1);
// $destinationPath = 'storage/collection';
// $isUploaded = $file1->move($destinationPath,$newFileName1);
// if($isUploaded)
// {
// $path1 = 'storage/collection/' . $newFileName1;
// }
// $data['PaymentFile1'] = $path1;
// }
$imageName1 = $this->userLib->useridGenrator();
if ($request->hasFile('paymentFile1'))
{
$path1 = '';
$file1 = $request->file('paymentFile1');
$extension = $file1->getClientOriginalExtension();
$newFileName1 = $imageName1 . '-' . time() . '.' . $extension;
Storage::putFileAs(
'public/collection/',
$file1,
$newFileName1
);
$destinationPath = 'collection/';
$isUploaded = $file1->move($destinationPath,$newFileName1);
$uploadedFileURL1 = '';
if($isUploaded)
{
$path1 = 'collection/' . $newFileName1;
$ThumbnailUrl = $path1;
//File Upload Service as s3
$sourceFileURL = env('APP_URL').'/'.$path1;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://172.105.42.62/s3-file-server/api-upload.php',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('file_url' => $sourceFileURL),
CURLOPT_HTTPHEADER => array(
'Cookie: private_content_version=3f7abce738dd8b52d0dcb8653bfe8e93; mage-messages=%5B%7B%22type%22%3A%22error%22%2C%22text%22%3A%22Invalid%20Form%20Key.%20Please%20refresh%20the%20page.%22%7D%2C%7B%22type%22%3A%22error%22%2C%22text%22%3A%22Invalid%20Form%20Key.%20Please%20refresh%20the%20page.%22%7D%2C%7B%22type%22%3A%22error%22%2C%22text%22%3A%22Invalid%20Form%20Key.%20Please%20refresh%20the%20page.%22%7D%5D'
),
));
$response = curl_exec($curl);
curl_close($curl);
$uploadedFile = json_decode($response,true);
$uploadedFileURL1 = isset($uploadedFile['url']) ? $uploadedFile['url'] : '';
}
$data['PaymentFile1'] = $uploadedFileURL1;
}
##CollectionFile2
// $path2 = '';
// $paymentFile2 = $request->file('paymentFile2');
// $imageName2 = $this->userLib->useridGenrator();
// if ($request->hasFile('paymentFile2'))
// {
// $file2 = $request->file('paymentFile2');
// $extension = $file2->getClientOriginalExtension();
// $newFileName2 = $imageName2.'-'.time() . '.' . $extension;
// Storage::putFileAs(
// 'public/collection', $file2, $newFileName2
// );
// $path2 = Storage::url('collection/'.$newFileName2);
// $destinationPath = 'storage/collection';
// $isUploaded = $file2->move($destinationPath,$newFileName2);
// if($isUploaded)
// {
// $path2 = 'storage/collection/' . $newFileName2;
// }
// $data['PaymentFile2'] = $path2;
// }
$imageName2 = $this->userLib->useridGenrator();
if ($request->hasFile('paymentFile2'))
{
$path2 = '';
$file2 = $request->file('paymentFile2');
$extension = $file2->getClientOriginalExtension();
$newFileName2 = $imageName2 . '-' . time() . '.' . $extension;
Storage::putFileAs(
'public/collection/',
$file2,
$newFileName2
);
$destinationPath = 'collection/';
$isUploaded = $file2->move($destinationPath,$newFileName2);
$uploadedFileURL2 = '';
if($isUploaded)
{
$path2 = 'collection/' . $newFileName2;
$ThumbnailUrl = $path2;
//File Upload Service as s3
$sourceFileURL = env('APP_URL').'/'.$path2;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://172.105.42.62/s3-file-server/api-upload.php',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('file_url' => $sourceFileURL),
CURLOPT_HTTPHEADER => array(
'Cookie: private_content_version=3f7abce738dd8b52d0dcb8653bfe8e93; mage-messages=%5B%7B%22type%22%3A%22error%22%2C%22text%22%3A%22Invalid%20Form%20Key.%20Please%20refresh%20the%20page.%22%7D%2C%7B%22type%22%3A%22error%22%2C%22text%22%3A%22Invalid%20Form%20Key.%20Please%20refresh%20the%20page.%22%7D%2C%7B%22type%22%3A%22error%22%2C%22text%22%3A%22Invalid%20Form%20Key.%20Please%20refresh%20the%20page.%22%7D%5D'
),
));
$response = curl_exec($curl);
curl_close($curl);
$uploadedFile = json_decode($response,true);
$uploadedFileURL2 = isset($uploadedFile['url']) ? $uploadedFile['url'] : '';
}
$data['PaymentFile2'] = $uploadedFileURL2;
}
$CollectionDate = '';
if ($input['CollectionDate']) {
$CollectionDate = str_replace('/', '-', $input['CollectionDate']);
}
$Date = date('d-m-Y', strtotime($CollectionDate));
$CollectionNo = "COL-".time().'-'.rand();
$data['CollectionNo'] = $CollectionNo;
$data['CollectionDate'] = $Date;
$data['AssignTo'] = $AssignTo;
$g_collectionId = $this->userLib->useridGenrator();
$data['CollectionId'] = $g_collectionId;
$data['IsDeleted'] = 0;
$data['Status'] = 1;
$data['Created_by'] = session('UserId');
$data['Created_at'] = date('Y-m-d H:i:s', time());
$data['Updated_by'] = session('UserId');
$data['Updated_at'] = date('Y-m-d H:i:s', time());
unset($data['_token']);
unset($data['paymentFile1']);
unset($data['paymentFile2']);
$insert_collection = Collection::insert($data);
$CollectionId = $g_collectionId;
//$CollectionNo = "COL-".time().'-'.rand();
$CollectionDate = $Date;
$OrderNo = $request->input('OrderId');
if ($OrderNo){
$OrderId = $OrderNo;
}
else{
$OrderId = '';
}
$AmountPaid = $request->input('AmountPaid');
$PaymentType = $request->input('PaymentType');
$CollectionType = $request->input('CollectionType');
$ReferenceNo = $request->input('ReferenceNo');
$description = $request->input('Description');
if($description){
$Description = $description;
}
$Description ='';
$IsDeleted = 0;
$Status = 1;
DB::connection('pgsql')->insert("insert into salesforce.Collection__c (Collection_Id__c,Collection_No__c,CollectionDate__c,Customer_Id__c,Order_Id__c,Amount_Paid__c,Payment_Type__c,CollectionType__c,ReferenceNo__c,Description__c,IsDeleted,Status__c,Name,Assign_To__c) values ('$CollectionId','$CollectionNo','$CollectionDate','$CustomerId','$OrderId','$AmountPaid','$PaymentType','$CollectionType','$ReferenceNo','$description','$IsDeleted','$Status','$CollectionNo','$AssignTo')");
return response()->json('status_success');
}
#### Change Status
public function statusUpdateCollection($id)
{
$data = Collection::find($id);
if ($data->Status == '1') {
$Status = '0';
} else {
$Status = '1';
}
$values = array('Status' => $Status);
Collection::find($id)->update($values);
return redirect()->back();
}
#### Delete Temporary
public function deleteCollection($id)
{
if (empty(session('UserId'))) {
return redirect('/admin/logout');
}
$CreatedDate = date('Y-m-d H:i:s', time());
$data = array();
$data['Updated_at'] = $CreatedDate;
$data['Updated_by'] = session('UserId');
$data['IsDeleted'] = '1';
$collection_delete = Collection::where('CollectionId', $id)->update($data);
DB::connection('pgsql')->update("update salesforce.Collection__c set IsDeleted='1',Status__c='0' where Collection_Id__c = '$id'");
if ($collection_delete) {
echo '1';
} else {
echo '0';
}
}
#### Delete Selected Collection
public function deleteSelectedCollection(Request $request)
{
if (empty(session('UserId'))) {
return redirect('/admin/logout');
}
$id = $request->input('SelectedCollection');
if ($id) {
foreach ($id as $collection) {
$checkData = Collection::find($collection);
if ($checkData->IsDeleted == '0') {
$CreatedDate = date(
'Y-m-d H:i:s',
time()
);
$data = array();
$data['Updated_at'] = $CreatedDate;
$data['IsDeleted'] = '1';
$selected_collection = Collection::where('id', $collection)->update($data);
if ($selected_collection) {
echo '1';
} else {
echo '0';
}
} else {
$selected_collection = Collection::find($collection);
$selected_collection->delete();
}
}
}
return redirect()->back()->with('status_success');
}
#### Restore
public function restoreCollection($id)
{
{
if (empty(session('UserId'))) {
return redirect('/admin/logout');
}
$CreatedDate = date('Y-m-d H:i:s', time());
$data = array();
$data['Updated_at'] = $CreatedDate;
$data['Updated_by'] = session('UserId');
$data['IsDeleted'] = '0';
$collection_restore = Collection::where('CollectionId', $id)->update($data);
DB::connection('pgsql')->update("update salesforce.Collection__c set IsDeleted='0',Status__c='1' where Collection_Id__c = '$id'");
if ($collection_restore) {
echo '1';
} else {
echo '0';
}
}
}
#### Delete Permanent
public function destroyCollection($id)
{
$destroyData = Collection::where('CollectionId', $id);
$destroyData->delete();
}
### Edit Records
public function editCollection($id)
{
$Collection = Collection::select('tbl_collection.*')
->where('CollectionId', '=', $id)
->get()->first();
$CustomerId = $Collection->CustomerId;
$Orders = Order::select('tbl_order.*')
->where('CustomerId', '=', $CustomerId)
->get();
return response()->json([
'status' => 200,
'Collection' => $Collection,
'Orders' => $Orders,
]);
}
### Update Records
public function updateCollection(Request $request)
{
if (empty(session('UserId'))) {
return redirect('/admin/logout');
}
$CustomerId = $request->input('customerName');
$AssignTo = '';
if ($CustomerId) {
$Customer = Customer::where('CustomerId', $CustomerId)->get()->first();
$AssignTo = $Customer->AssignTo;
}
$data['AssignTo'] = $AssignTo;
$collection_id = $request->input('id');
$data['CustomerId'] = $request->input('customerName');
$CollectionDate = '';
if ($request->input('CollectionDate')) {
$CollectionDate = str_replace('/', '-', $request->input('CollectionDate'));
}
$Date = date('d-m-Y', strtotime($CollectionDate));
$data['CollectionDate'] = $Date;
$data['CollectionType'] = $request->input('editAmountOption');
if ($request->input('OrderNo')) {
$data['OrderId'] = $request->input('OrderNo');
}
$data['AmountPaid'] = $request->input('amount');
$data['PaymentType'] = $request->input('paymentType');
$data['ReferenceNo'] = $request->input('referenceNo');
$data['Description'] = $request->input('description');
// if ($request->hasFile('CollectionFile1')) {
// $imageName1 = $this->userLib->useridGenrator();
// $file1 = $request->file('CollectionFile1');
// $extension = $file1->getClientOriginalExtension();
// $newFileName1 = $imageName1.'-'.time() . '.' . $extension;
// // Storage::putFileAs(
// // 'public/collection', $file1, $newFileName1
// // );
// // $path1 = Storage::url('collection/'.$newFileName1);
// $destinationPath = 'storage/collection';
// $isUploaded = $file1->move($destinationPath,$newFileName1);
// if($isUploaded)
// {
// $path1 = 'storage/collection/' . $newFileName1;
// }
// $data['PaymentFile1'] = $path1;
// }
$imageName1 = $this->userLib->useridGenrator();
if ($request->hasFile('CollectionFile1'))
{
$path1 = '';
$file1 = $request->file('CollectionFile1');
$extension = $file1->getClientOriginalExtension();
$newFileName1 = $imageName1 . '-' . time() . '.' . $extension;
Storage::putFileAs(
'public/collection/',
$file1,
$newFileName1
);
$destinationPath = 'collection/';
$isUploaded = $file1->move($destinationPath,$newFileName1);
$uploadedFileURL1 = '';
if($isUploaded)
{
$path1 = 'collection/' . $newFileName1;
$ThumbnailUrl = $path1;
//File Upload Service as s3
$sourceFileURL = env('APP_URL').'/'.$path1;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://172.105.42.62/s3-file-server/api-upload.php',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('file_url' => $sourceFileURL),
CURLOPT_HTTPHEADER => array(
'Cookie: private_content_version=3f7abce738dd8b52d0dcb8653bfe8e93; mage-messages=%5B%7B%22type%22%3A%22error%22%2C%22text%22%3A%22Invalid%20Form%20Key.%20Please%20refresh%20the%20page.%22%7D%2C%7B%22type%22%3A%22error%22%2C%22text%22%3A%22Invalid%20Form%20Key.%20Please%20refresh%20the%20page.%22%7D%2C%7B%22type%22%3A%22error%22%2C%22text%22%3A%22Invalid%20Form%20Key.%20Please%20refresh%20the%20page.%22%7D%5D'
),
));
$response = curl_exec($curl);
curl_close($curl);
$uploadedFile = json_decode($response,true);
$uploadedFileURL1 = isset($uploadedFile['url']) ? $uploadedFile['url'] : '';
}
$data['PaymentFile1'] = $uploadedFileURL1;
}
// if ($request->hasFile('CollectionFile2')) {
// $imageName2 = $this->userLib->useridGenrator();
// $file2 = $request->file('CollectionFile2');
// $extension = $file2->getClientOriginalExtension();
// $newFileName2 = $imageName2.'-'.time() . '.' . $extension;
// // Storage::putFileAs(
// // 'public/collection', $file2, $newFileName2
// // );
// // $path2 = Storage::url('collection/'.$newFileName2);
// $destinationPath = 'storage/collection';
// $isUploaded = $file2->move($destinationPath,$newFileName2);
// if($isUploaded)
// {
// $path2 = 'storage/collection/' . $newFileName2;
// }
// $data['PaymentFile2'] = $path2;
// }
$imageName2 = $this->userLib->useridGenrator();
if ($request->hasFile('CollectionFile2'))
{
$path2 = '';
$file2 = $request->file('CollectionFile2');
$extension = $file2->getClientOriginalExtension();
$newFileName2 = $imageName2 . '-' . time() . '.' . $extension;
Storage::putFileAs(
'public/collection/',
$file2,
$newFileName2
);
$destinationPath = 'collection/';
$isUploaded = $file2->move($destinationPath,$newFileName2);
$uploadedFileURL2 = '';
if($isUploaded)
{
$path2 = 'collection/' . $newFileName2;
$ThumbnailUrl = $path2;
//File Upload Service as s3
$sourceFileURL = env('APP_URL').'/'.$path2;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://172.105.42.62/s3-file-server/api-upload.php',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('file_url' => $sourceFileURL),
CURLOPT_HTTPHEADER => array(
'Cookie: private_content_version=3f7abce738dd8b52d0dcb8653bfe8e93; mage-messages=%5B%7B%22type%22%3A%22error%22%2C%22text%22%3A%22Invalid%20Form%20Key.%20Please%20refresh%20the%20page.%22%7D%2C%7B%22type%22%3A%22error%22%2C%22text%22%3A%22Invalid%20Form%20Key.%20Please%20refresh%20the%20page.%22%7D%2C%7B%22type%22%3A%22error%22%2C%22text%22%3A%22Invalid%20Form%20Key.%20Please%20refresh%20the%20page.%22%7D%5D'
),
));
$response = curl_exec($curl);
curl_close($curl);
$uploadedFile = json_decode($response,true);
$uploadedFileURL2 = isset($uploadedFile['url']) ? $uploadedFile['url'] : '';
}
$data['PaymentFile2'] = $uploadedFileURL2;
}
$data['Updated_by'] = session('UserId');
$data['Updated_at'] = date('Y-m-d H:i:s', time());
$collection_update = Collection::where('CollectionId', $collection_id)->update($data);
//$CustomerId = $request->input('customerName');
$collectionId_sf = $request->input('id');
$CollectionDate = $Date;
$CollectionType = $request->input('editAmountOption');
$OrderId = '';
if ($request->input('OrderNo')) {
$OrderId = $request->input('OrderNo');
}
$AmountPaid = $request->input('amount');
$PaymentType = $request->input('paymentType');
$ReferenceNo = $request->input('referenceNo');
$Description = $request->input('description');
DB::connection('pgsql')->update("update salesforce.Collection__c set CollectionDate__c='$CollectionDate',Customer_Id__c='$CustomerId',Order_Id__c='$OrderId',Amount_Paid__c='$AmountPaid',Payment_Type__c='$PaymentType',CollectionType__c='$CollectionType',ReferenceNo__c='$ReferenceNo',Description__c='$Description',Assign_To__c='$AssignTo' where Collection_Id__c='$collectionId_sf'");
if ($collection_update) {
echo '1';
} else {
echo '0';
}
return redirect()->back()->with('status_success');
}
#### Amount for selected order
public function orderAmount($OrderId)
{
$OrderAmount = Order::select('tbl_order.*')
->where('OrderId', '=', $OrderId)
//->where('TotalAmount', '!=', '0.00');
->get()
->first();
return response()->json([
'status' => 200,
'OrderAmount' => $OrderAmount,
]);
}
}