I see some possible duplicate to my question, but i cannot find better answer. So i decide to create my own query question here.
Case Details:
I have jQuery DataTables program (that previously it was full html/php table) that enlist all users with certain limitations per account. User and Banner checkbox per account. Each account can be limited to their activity to navigate inside/outside the client portal account.
User [checkbox] restrict them for accessible to all investment content and Banner [checkbox] restrict them to banner content from their dashboard.
We have 2000+ users to control and restrict.
Materials:
I using Propeller jQuery DataTable program.
Code Structure:
page.blade.php
<button type="submit" name="submit" id="Update-Users" class="btn btn-sm btn-primary pmd-ripple-effect">Update Users</button>
tablecode...
<tbody>
@foreach($client as $clients)
<?php $property = ClientPropertyManagement::DisplayNASIS($clients->Id); ?>
<?php
$pdf = [];
foreach($property as $properties) {
$setList = $properties->name;
$pdf[] = $properties->agreementPDF;
}
$emailAddress = str_replace(';', ', ', $clients->email_address);
$emailAddress = trim($emailAddress,";");
$emailAddress = trim($emailAddress,",");
?>
<tr>
<td> <input type="checkbox" class="nasis_user" name="nasis_user[]" value="" ></td>
<td> <input type="checkbox" class="nasis_user_banner" name="nasis_user_banner[]" value="" > </td>
<td></td>
<td></td>
<td>
<?php if(count($pdf) > 0) :
foreach($pdf as $pdfs) {
if($pdfs != "") {
echo $properties->name;
}
}
endif; ?>
</td>
<td class="details-control">
<?php if(count($pdf) > 0) :
foreach($pdf as $pdfs) {
if($pdfs != "") { ?>
<a href="" target="_blank"> <span class="label label-primary">Download PDF</span> </a>
<?php }
}
endif; ?>
</td>
</tr>
@endforeach
</tbody>
tablecode...
Note: In this controller part, the programmer may forgot check that it was jQuery DataTable already.
controller.blade.php
public function ClientDisplayRecords() {
if(!Session::has('webadmin_id')) { return Redirect::to(ADMIN.'/');}
$administrator = SettingsManagement::where('id','=',Session::get('webadmin_id'))->first();
$client = ClientManagement::orderBy('firstname')->get();
return View::make('_admin.clients.page', array('administrator'=>$administrator,'clientInfo'=>$clientInfo,'client'=>$client,'searchStatus'=>$searchStatus,'searchName'=>$searchName));
}
public function UpdateClientRecords() {
if(!Session::has('webadmin_id')) { return Redirect::to(ADMIN.'/');}
$administrator = SettingsManagement::where('id','=',Session::get('webadmin_id'))->first();
// This is not necessary, because no raw search function already
// if(Session::has('searchName')) {
// Session::forget('searchName');
// }
// if(isset($_POST['search'])) {
// $searchName = $_POST['searchName'];
// $searchStatus = true;
// $pdf = "";
// $client = ClientManagement::leftJoin('assets','assets.client_id','=','client.Id')
// ->leftJoin('property','property.Id','=','assets.property_id')
// ->where(function($query) use($searchName,$pdf) {
// $query->orWhere('firstname','like','%'.$searchName.'%')
// ->orWhere('lastname','like','%'.$searchName.'%')
// ->orwhere('property.name','like','%'.$searchName.'%');
// })
// ->groupBy('client.Id')
// ->orderBy('firstname')
// ->select('client.Id','client.isNASIS','client.isRestricted','client.firstname','client.lastname','client.email_address')
// ->get();
// Session::put('searchName',$searchName);
// return View::make('_admin.clients.clients-nasis-activation', array('administrator'=>$administrator,'client'=>$client,'searchStatus'=>$searchStatus,'searchName'=>$searchName));
// }
// if(isset($_POST['activateallnasis'])) {
// $client = ClientManagement::all();
// foreach($client as $clients) {
// $clients->isNASIS = 1;
// $clients->save();
// }
// return Redirect::to('admin-login/clients/user-activation');
// }
// if(isset($_POST['removeallnasis'])) {
// $client = ClientManagement::all();
// foreach($client as $clients) {
// $clients->isNASIS = 0;
// $clients->save();
// }
// return Redirect::to('admin-login/clients/user-activation');
// }
// if(isset($_POST['activateallrestriction'])) {
// $client = ClientManagement::all();
// foreach($client as $clients) {
// $clients->isRestricted = 1;
// $clients->save();
// }
// return Redirect::to('admin-login/clients/user-activation');
// }
// if(isset($_POST['removeallrestriction'])) {
// $client = ClientManagement::all();
// foreach($client as $clients) {
// $clients->isRestricted = 0;
// $clients->save();
// }
// return Redirect::to('admin-login/clients/user-activation');
// }
// $page = Input::get('activePage');
// $searchStatus = Input::get('searchStatus');
// $searchNameValue = Input::get('searchNameValue');
// $pageOffset = ($page-1) * 30;
// if($searchNameValue == "") {
// $clientQuery = ClientManagement::orderBy('lastname')->limit(30)->offset($pageOffset);
// } else {
// $clientQuery = ClientManagement::orderBy('lastname')
// ->where('firstname','like','%'.$searchNameValue.'%')
// ->orWhere('lastname','like','%'.$searchNameValue.'%')
// ->limit(30)
// ->offset($pageOffset);
// }
// If check main checkbox to check all checkbox under User
// if(isset($_POST['nasisselectall'])) {
// $client = $clientQuery->get();
// foreach($client as $clients) {
// $clients->isNASIS = 1;
// $clients->save();
// }
// } else {
// if(count(Input::get('nasis_user')) > 0) {
// foreach(Input::get('nasis_user') as $users) {
// $clientUpdate = ClientManagement::find($users);
// if(count($clientUpdate) == 1) {
// $clientUpdate->isNASIS = 1;
// $clientUpdate->save();
// }
// }
// //remove nasis if uncheck
// $clientNasis = $clientQuery->get();
// foreach($clientNasis as $clientNasiss) {
// if(!in_array($clientNasiss->Id, Input::get('nasis_user'))) {
// $clientUpdate = ClientManagement::find($clientNasiss->Id);
// if(count($clientUpdate) == 1) {
// $clientUpdate->isNASIS = 0;
// $clientUpdate->save();
// }
// }
// }
// }
// else {
// $clientNasis = $clientQuery->get();
// foreach($clientNasis as $clientNasiss) {
// $clientUpdate = ClientManagement::find($clientNasiss->Id);
// if(count($clientUpdate) == 1) {
// $clientUpdate->isNASIS = 0;
// $clientUpdate->save();
// }
// }
// }
// }
// If check main checkbox to check all checkbox under Banner
// if(isset($_POST['nasisbannerselectall'])) {
// $client = $clientQuery->get();
// foreach($client as $clients) {
// $clients->isRestricted = 1;
// $clients->save();
// }
// } else {
// if(count(Input::get('nasis_user_banner')) > 0) {
// foreach(Input::get('nasis_user_banner') as $users) {
// $clientUpdate = ClientManagement::find($users);
// if(count($clientUpdate) == 1) {
// $clientUpdate->isRestricted = 1;
// $clientUpdate->save();
// }
// }
// //remove restriction if uncheck
// $clientRestricted = $clientQuery->get();
// foreach($clientRestricted as $clientRestricteds) {
// if(!in_array($clientRestricteds->Id, Input::get('nasis_user_banner'))) {
// $clientUpdate = ClientManagement::find($clientRestricteds->Id);
// if(count($clientUpdate) == 1) {
// $clientUpdate->isRestricted = 0;
// $clientUpdate->save();
// }
// }
// }
// } else {
// $clientRestricted = $clientQuery->get();
// foreach($clientRestricted as $clientRestricteds) {
// $clientUpdate = ClientManagement::find($clientRestricteds->Id);
// if(count($clientUpdate) == 1) {
// $clientUpdate->isRestricted = 0;
// $clientUpdate->save();
// }
// }
// }
// }
// return Redirect::to('admin-login/clients/user-activation?page='.$page);
}
Case Issues:
The reason why I commented all lines under UpdateClientRecords()
is because this isn't reflect or related to jQuery DataTable anymore. I am wondering why before it was working.
The problem here is whenever I uncheck certain user(s) or multiple uncheck users, it didn't save the uncheck state of the User/Banner checkbox to database. But when I check certain user(s) or multiple check users, it was saving.
Aucun commentaire:
Enregistrer un commentaire