You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have looked over openskill datatables and it seems the syntax used is very different from Chumper datatables. Is this the case and if so how easy is it to convert old syntax to new. For instance how difficult would it be to change something like the following:
Controller:-
` return Datatable::collection(new Collection($leads))
->addColumn('created_at', function ($Lead) {
return date('Y-m-d H:i', strtotime($Lead['created_at']));
})
->showColumns('reference')
->addColumn('bdm', function ($Lead) {
if ($Lead['bdm_allocated'] == 0) {
return 'None allocated';
} else {
$bdm = User::find($Lead['bdm_allocated']);
$firstname = $bdm['firstname'];
return '<a href="/leads/' . $Lead['bdm_allocated'] . '/user" >' . $firstname . '</a>';
}
})
->showColumns('lead_title')
->addColumn('address', function ($Lead) {
if ($Lead['street_number'] != NULL) {
$address = $Lead['street_number'];
} else {
$address = '';
}
if ($Lead['street_name'] != NULL) {
$address .= ' ' . $Lead['street_name'];
} else {
$address .= '';
}
if ($Lead['suburb_town_city'] != NULL) {
$address .= ' ' . $Lead['suburb_town_city'];
} else {
$address .= '';
}
if ($address == '') {
return 'No Address';
} else {
return $address;
}
})
->addColumn('transaction_type', function ($Lead) {
$type = DB::table('lead_prop_trans_types')->select('type')->whereId($Lead['lead_prop_trans_type'])
->first();
if (!empty($type)) {
if ($type->type == 'Other') {
if ($Lead['lead_prop_trans_type_other'] == '') {
return 'Other';
}
return $Lead['lead_prop_trans_type_other'];
} else {
return $type->type;
}
} else {
return 'Not Selected';
}
})
->addColumn('contact_firstname', function ($Lead) {
$query = 'SELECT u.firstname, u.lastname
FROM users u
INNER JOIN lead_user lu ON u.id = lu.user_id
WHERE CONCAT(u.firstname, " ",u.lastname) IS NOT NULL
AND CONCAT(u.firstname, " ",u.lastname) <> " "
AND lu.lead_id = ' . $Lead['id'] . '
UNION ALL
SELECT lc.firstname, lc.lastname
FROM lead_contacts lc
INNER JOIN leads l ON l.id = lc.lead_id
WHERE CONCAT(lc.firstname, " ",lc.lastname) IS NOT NULL
AND CONCAT(lc.firstname, " ",lc.lastname) <> " "
AND l.id = ' . $Lead['id'] . '
LIMIT 1';
$contact = DB::select($query);
if (empty($contact)) {
return 'No Contacts';
}
return $contact[0]->firstname . ' ' . $contact[0]->lastname;
})
->addColumn('contact_email', function ($Lead) {
$query = 'SELECT u.email, u.cellnumber AS tel
FROM users u
INNER JOIN lead_user lu ON u.id = lu.user_id
WHERE CONCAT(u.firstname, " ",u.lastname) IS NOT NULL
AND CONCAT(u.firstname, " ",u.lastname) <> " "
AND lu.lead_id = ' . $Lead['id'] . '
UNION ALL
SELECT lc.email, lc.tel
FROM lead_contacts lc
INNER JOIN leads l ON l.id = lc.lead_id
WHERE CONCAT(lc.firstname, " ",lc.lastname) IS NOT NULL
AND CONCAT(lc.firstname, " ",lc.lastname) <> " "
AND l.id = ' . $Lead['id'] . '
LIMIT 1';
$contact = DB::select($query);
if (empty($contact)) {
return 'No Contacts';
}
$email = '';
if ($contact[0]->email != '') {
$email = '<strong>Email:</strong> ' . $contact[0]->email . '<br>';
}
$tel = '';
if ($contact[0]->tel != '') {
$tel = '<strong>Tel: </strong>' . $contact[0]->tel;
}
return $email . $tel;
})
->addColumn('note', function ($Lead) {
$query = "SELECT p.note, p.created_at AS date FROM prop_notes p
INNER JOIN users u ON u.id = p.users_id
WHERE p.lead_id = " . $Lead['id'] . "
ORDER BY p.created_at DESC
LIMIT 1";
$last_note = DB::select($query);
if (empty($last_note)) {
return 'No Notes';
}
return $last_note[0]->note . ' <i>...' . $last_note[0]->date . '</i>';
})
->addColumn('actions', function ($Lead) use ($user_id, $lead_id_array) {
if (in_array($Lead['id'], $lead_id_array)) {
$editing_user_id = array_search($Lead['id'], $lead_id_array);
$session = DB::select('SELECT * FROM lead_session WHERE user_id =' . $editing_user_id);
if (($editing_user_id == Auth::user()->id) || (strtotime($session[0]->created_at) <= strtotime('-1 hours'))) {
return '<a href="/leads/' . $Lead['id'] . '/edit" title="Edit" ><i class="i-circled i-light i-alt i-small icon-edit"></i></a>
<a href="/leads/' . $Lead['id'] . '/delete" title="Delete" ><i class="i-circled i-light i-alt i-small icon-remove"></i></a>';
}
$editing_user = DB::table('users')->whereId($editing_user_id)->first();
return $editing_user->firstname . ' is busy with lead';
} else {
if ($user_id == 'Archived') {
return '<a href="/leads/' . $Lead['id'] . '/edit" title="Edit" ><i class="i-circled i-light i-alt i-small icon-edit"></i></a>
<a href="/leads/' . $Lead['id'] . '/restore" title="Restore" ><i class="i-circled i-light i-alt i-small icon-check"></i></a>';
} else {
$query = "SELECT p.note, p.created_at AS date FROM prop_notes p
INNER JOIN users u ON u.id = p.users_id
WHERE p.lead_id = " . $Lead['id'];
$last_note = DB::select($query);
if (sizeof($last_note) > 1) {
$Lead['check_lead'] = 1;
}
if ((Auth::user()->id == $Lead['bdm_allocated'] && $Lead['check_lead'] == null) || (Auth::user()->hasRole('Admin') && $Lead['check_lead'] == null)) {
return '<a href="/leads/' . $Lead['id'] . '/edit" title="Edit" ><i class="i-circled i-light i-alt i-small icon-edit"></i></a>
<a href="/leads/' . $Lead['id'] . '/delete" title="Delete" ><i class="i-circled i-light i-alt i-small icon-remove"></i></a>
<a href="/leads/' . $Lead['id'] . '/check_lead" title="Mark as Viewed" ><i class="i-circled i-light i-alt i-small icon-check" style="color:#FF3100"></i></a>';
} elseif (Auth::user()->hasRole('Admin') && $Lead['check_lead'] == 1) {
return '<a href="/leads/' . $Lead['id'] . '/edit" title="Edit" ><i class="i-circled i-light i-alt i-small icon-edit"></i></a>
<a href="/leads/' . $Lead['id'] . '/delete" title="Delete" ><i class="i-circled i-light i-alt i-small icon-remove"></i></a>
<a href="/leads/' . $Lead['id'] . '/check_lead" title="Mark as Viewed" ><i class="i-circled i-light i-alt i-small icon-check" style="color:#00FF48"></i></a>';
} else {
return '<a href="/leads/' . $Lead['id'] . '/edit" title="Edit" ><i class="i-circled i-light i-alt i-small icon-edit"></i></a>
<a href="/leads/' . $Lead['id'] . '/delete" title="Delete" ><i class="i-circled i-light i-alt i-small icon-remove"></i></a>';
}
}
}
})
->searchColumns('lead_ref', 'created_at', 'reference', 'bdm', 'lead_title', 'address', 'transaction_type', 'contact_firstname', 'contact_email', 'note')
->orderColumns('lead_ref', 'created_at', 'reference', 'bdm', 'lead_title', 'address', 'transaction_type', 'contact_firstname', 'contact_email', 'note')
->make();`
view-
`@if($archived == 'Archived')
<h4>Archived Leads List</h4>
<div id='follow_datatable'>
{{ Datatable::table()
// these are the column headings to be shown
->addColumn('Date', 'Reference', 'BDM', 'Title', 'Address', 'Listing Type', 'Contact Name', 'Contact Details', 'Notes', 'Actions')
// this is the route where data will be retrieved
->setUrl(route('api.leads.followup', ['user_id' => 'Archived']))
->setId('followupDatatable')
->setOptions(["order" => [[ 0, "desc" ]], "bStateSave" => true])
->render() }}
</div>
@elseif($user->hasRole('LeadReviewer'))
<h4>Lead Follow Up List</h4>
<div id='follow_datatable'>
{{ Datatable::table()
// these are the column headings to be shown
->addColumn('Date', 'Reference', 'BDM', 'Title', 'Address', 'Listing Type', 'Contact Name', 'Contact Details', 'Notes', 'Actions')
// this is the route where data will be retrieved
->setUrl(route('api.leads.followup', ['user_id' => $user->id]))
->setId('followupDatatable')
->setOptions(["order" => [[ 0, "desc" ]], "bStateSave" => true])
->render() }}
</div>
@else
<h4>Lead Follow Up List for {{$user->firstname}} {{$user->lastname}}</h4>
<div id='follow_datatable'>
{{ Datatable::table()
// these are the column headings to be shown
->addColumn('Date', 'Reference', 'BDM', 'Title', 'Address', 'Listing Type', 'Contact Name', 'Contact Details', 'Notes', 'Actions')
// this is the route where data will be retrieved
->setUrl(route('api.leads.followup', ['user_id' => $user->id]))
->setId('followupDatatable')
->setOptions(["order" => [[ 0, "desc" ]], "bStateSave" => true])
->render() }}
</div>
@endif`
I dont think these tables are overly complex but I am a bit lost as to how your new system works
The text was updated successfully, but these errors were encountered:
I have looked over openskill datatables and it seems the syntax used is very different from Chumper datatables. Is this the case and if so how easy is it to convert old syntax to new. For instance how difficult would it be to change something like the following:
Controller:-
view-
I dont think these tables are overly complex but I am a bit lost as to how your new system works
The text was updated successfully, but these errors were encountered: