| Server IP : 103.161.17.216 / Your IP : 216.73.216.1 Web Server : nginx/1.18.0 System : Linux tipsysaigoncharming 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 7.4.3-4ubuntu2.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/dr.dinhphuongdong.com/app/Http/Controllers/ |
Upload File : |
<?php
namespace App\Http\Controllers;
use App\Models\City;
use App\Models\Province;
use App\Models\Wards;
use App\Models\Feeship;
use App\Http\Middleware\VerifyCsrfToken;
use Illuminate\Http\Request;
use File;
use Illuminate\Foundation\Bus\DispatchesJobs;
use App\Http\Requests;
use Illuminate\Routing\Controller as BaseController;
use Session;
use Illuminate\Support\Facades\Redirect;
use App\Http\Controllers\Controller;
session_start();
class DeliveryController extends Controller
{
// kiểm tra đăng nhập
public function AuthLogin(){
$admin_id=session::get('admin_id');
if($admin_id){
return Redirect::to('dashboard');
}
else{
return Redirect::to('admin')->send();
}
}
// and Đăng Nhập
public function del_fee(){
$fee = session::get('fee');
if($fee==true){
Session::forget('fee');
return Redirect()->back()->with('message', 'Đã xóa phí vận chuyển');
}
}
public function delivery(Request $request)
{
$this->AuthLogin();
$city=City::orderby('matp','ASC')->get();
return view('admin.delivery.add_delivery')->with(compact('city'));
}
public function selete_delivery(Request $request)
{
$data=$request->all();
if($data['action']){
$output='';
if($data['action']=="city"){
$selete_province =Province::where('matp',$data['ma_id'])->orderby('maqh', 'ASC')->get();
$output.='<option>--Chọn Quận Huyện--</option>';
foreach($selete_province as $key => $province){
$output.='<option value ="'.$province->maqh.'">'.$province->name_quanhuyen.'</option>';
}
}
else {$selete_wards =Wards::where('maqh',$data['ma_id'])->orderby('xaid', 'ASC')->get();
$output.='<option>---Chọn Xã Phường---</option>';
foreach($selete_wards as $key => $wards){
$output.='<option value="'.$wards->xaid.'">'.$wards->name_xaphuong.'</option>';
}
}
}
echo $output;
}
public function insert_delivery(Request $request)
{
$this->AuthLogin();
$data=$request->all();
$freeship=new Feeship();
$freeship->fee_matp=$data['city'];
$freeship->fee_maqh=$data['province'];
$freeship->fee_xid=$data['wards'];
$freeship->fee_feeship=$data['fee_ship'];
$freeship->timestamps = false;
$freeship->save();
}
public function selete_feeship(Request $request)
{
$freeship=Feeship::orderby('fee_id','DESC')->get();
$output='';
$output.='<div class= "table-responsive">
<table class="table table-bordered">
<thread>
<tr>
<th>Thành Phố </th>
<th>Huyện </th>
<th>Xã </th>
<th>Phí Ship</th>
</tr>
</thread>
<tbody>
';
foreach($freeship as $key => $fee)
{
$output.='
<tr>
<td>'.$fee->city->name_city.'</td>
<td>'.$fee->province->name_quanhuyen.'</td>
<td>'.$fee->wards->name_xaphuong.'</td>
<td contenteditable="true" data-feeship_id="'.$fee->fee_id.'" class="fee_ship_edit"> '.number_format($fee->fee_feeship,0,',','.').' </td>
</tr>
';
}
$output.='</tbody>
</table>
</div>';
echo $output;
}
public function update_delivery(Request $request)
{
$this->AuthLogin();
$data=$request->all();
$freeship=Feeship::find($data['feeship_id']);
$fee_value=rtrim($data['fee_value'],'.');
$freeship->fee_feeship=$fee_value;
$freeship->timestamps = false;
$freeship->save();
}
}