public function listContact() { if (!Request::ajax()) { return App::abort(404); } $start = Input::has('start') ? (int) Input::get('start') : 0; $length = Input::has('length') ? Input::get('length') : 10; $search = Input::has('search') ? Input::get('search') : []; $contacts = Contact::select('id', 'contact_name', 'contact_phone', 'contact_email', 'contact_message', 'read', 'created_at')->orderBy('read')->orderBy('created_at'); if (!empty($search)) { foreach ($search as $key => $value) { if (empty($value)) { continue; } if ($key == 'read') { if ($value == 'yes') { $value = 1; } else { $value = 0; } $contacts->where($key, $value); } else { $value = ltrim(rtrim($value)); $contacts->where($key, 'like', '%' . $value . '%'); } } } $order = Input::has('order') ? Input::get('order') : []; if (!empty($order)) { $columns = Input::has('columns') ? Input::get('columns') : []; foreach ($order as $value) { $column = $value['column']; if (!isset($columns[$column]['name']) || empty($columns[$column]['name'])) { continue; } $contacts->orderBy($columns[$column]['name'], $value['dir'] == 'asc' ? 'asc' : 'desc'); } } $count = $contacts->count(); if ($length > 0) { $contacts = $contacts->skip($start)->take($length); } $arrcontacts = $contacts->get()->toArray(); $arrReturn = ['draw' => Input::has('draw') ? Input::get('draw') : 1, 'recordsTotal' => Page::count(), 'recordsFiltered' => $count, 'data' => []]; if (!empty($arrcontacts)) { foreach ($arrcontacts as $contact) { $image = ''; if (!empty($contact['images'])) { $image = reset($contact['images']); $image = $image['path']; } $arrReturn['data'][] = array(++$start, $contact['id'], $contact['contact_name'], $contact['contact_phone'], $contact['contact_email'], htmlentities($contact['contact_message']), $contact['read'], $contact['created_at'], htmlentities(nl2br($contact['contact_message']))); } } $response = Response::json($arrReturn); $response->header('Content-Type', 'application/json'); return $response; }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $input = Input::json(); Contact::create(['name' => $input->get('name'), 'surname' => $input->get("surname"), 'phone' => $input->get("phone"), 'email' => $input->get("email"), 'description' => $input->get('description')]); $query = Contact::select('id')->where("email", '=', $input->get('email'))->first(); $id = $query->id; Session::put('id', $id); $returnArray = array('id' => $id, 'name' => $input->get('name'), 'surname' => $input->get('surname'), 'phone' => $input->get('phone'), 'email' => $input->get('email'), 'description' => $input->get('description')); return $returnArray; }
public function getContactResults() { $contact = []; $contact['first_name'] = Input::get('first_name'); $contact['last_name'] = Input::get('last_name'); $contact['country'] = Input::get('country'); $contact['function'] = Input::get('function'); $contact_results = Contact::select('contacts.*', 'c.name as country')->join('adresses as a', 'contacts.address_id', '=', 'a.id')->join('countries as c', 'a.country_id', '=', 'c.id'); if (empty(Input::get('first_name')) && empty(Input::get('last_name')) && empty(Input::get('country')) && empty(Input::get('function'))) { $contact_results->orderBy('contacts.id', 'DESC')->take(5); } else { if (!empty(Input::get('first_name'))) { $contact_results->where('contacts.first_name', 'LIKE', '%' . $contact['first_name'] . '%'); } if (!empty(Input::get('last_name'))) { $contact_results->where('contacts.last_name', 'LIKE', '%' . $contact['last_name'] . '%'); } if (!empty(Input::get('function'))) { $contact_results->where('contacts.function', 'LIKE', '%' . $contact['function'] . '%'); } if (!empty(Input::get('country'))) { $country_search_terms = explode(',', Input::get('country')); $country_where_str = ""; for ($country_ndx = 0; $country_ndx < count($country_search_terms); $country_ndx++) { if ($country_ndx !== 0) { $country_where_str .= " OR c.name LIKE '%" . $country_search_terms[$country_ndx] . "%' "; } else { $country_where_str .= " c.name LIKE '%" . $country_search_terms[$country_ndx] . "%' "; } } $contact_results->whereRaw("(" . $country_where_str . ")"); } } $contact_results = $contact_results->get(); $data = []; foreach ($contact_results as $curr_contact) { $curr_contact = (object) ['DT_RowId' => $curr_contact->id, 'first_name' => $curr_contact->first_name, 'last_name' => $curr_contact->last_name, 'country' => $curr_contact->country, 'function' => $curr_contact->function]; $curr_entry = (object) $curr_contact; $data[] = $curr_entry; } echo json_encode(['data' => $data]); }
public function useCriteria($id, $namespace = null) { if ($id) { //$db = Zend_Db_Table_Abstract::getDefaultAdapter(); $db = new Contact(); $user_id = Zend_Auth::getInstance()->getIdentity()->id; $branch_id = Zend_Auth::getInstance()->getIdentity()->id_branch; switch ($id) { case 1: $select = $db->select()->where('responsible_adviser = ' . $user_id); break; case 2: $select = $db->select()->where('responsible_adviser IS NULL'); break; case 3: $select = $db->select()->where('responsible_branch = ' . $branch_id); break; } return $select; } else { return null; } }
$contact = new Contact(); $contact->address = 'test'; $contact->email = '*****@*****.**'; $contact->user_id = $user->id; var_dump($contact->insert()); $contact = new Contact(); $contact->address = 'test'; $contact->email = '*****@*****.**'; $contact->user_id = $user->id; var_dump($contact->insert()); var_dump($user->contact); echo "\n -----"; var_dump($user); echo "\n join\n"; $contact = new Contact(); var_dump($contact->select('user.*, contact.*')->join('user', 'user.id = contact.user_id')->find()); /* $contact = new Contact(); $contact->address = 'test'; $contact->email = '*****@*****.**'; $contact->user_id = 2; var_dump($contact->insert()); */ $user = new User(); var_dump($user->select('user.*, c.email, c.address')->join('contact as c', 'c.user_id = user.id')->findAll()); var_dump($user->reset()->notnull('id')->orderby('id desc')->find()); echo "\nContact of User # {$user->id}\n"; var_dump($user->contacts); $contact = new Contact(); var_dump($contact->find()); var_dump($contact->user);
if (count($results) > 0) { foreach ($results as $row) { $data[] = strtolower($row->fullname) . ""; } } else { $data[] = 'No record found.'; } return Response::json($data); }); Route::post('contact/getcompanyinfo', 'ContactController@getcompanyinfo'); Route::post('contact/getcompanyinfo/update', 'ContactController@getcompanyinfo'); Route::get('contact/{id}/information/{query}', function ($id, $query) { // $data = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); // return Response::json($data); $data = array(); $results = Contact::select('fullname')->where('status', '=', '2')->where('fullname', 'LIKE', '%' . $query . '%')->get(); if (count($results) > 0) { foreach ($results as $row) { $data[] = strtolower($row->fullname) . ""; } } else { $data[] = 'No record found.'; } return Response::json($data); }); Route::post('contact/process', 'ContactController@process'); Route::get('ra-contacts', array('as' => 'contact.ra', 'uses' => 'ContactController@ra')); Route::put('contacts/approve/{id}', array('as' => 'contact.a', 'uses' => 'ContactController@a')); Route::put('contacts/denied/{id}', array('as' => 'contact.d', 'uses' => 'ContactController@d')); Route::get('ra-contacts/details/{id}', array('as' => 'contact.dt', 'uses' => 'ContactController@details')); Route::resource('company', 'CompanyController');
/** * Show a list of all the contacts formatted for Datatables. * * @return Datatables JSON */ public function getData() { /* $users = User::leftjoin('assigned_roles', 'assigned_roles.user_id', '=', 'users.id') ->leftjoin('roles', 'roles.id', '=', 'assigned_roles.role_id') ->select(array('users.id', 'users.username', 'users.email', 'roles.name as rolename', 'users.confirmed', 'users.created_at'));*/ $contact = Contact::select(array('id_contact', 'company', DB::raw('CONCAT(contact_first," ",contact_last) as contact'), 'account', 'address_1', 'city', 'state', 'county', 'type')); //filter contacts $columns = Schema::getColumnListing('contact'); foreach (Input::all() as $key => $val) { if (in_array($key, $columns) and !empty($val)) { $contact->where($key, 'LIKE', '%' . $val . '%'); } } $contact->orderBy('id_contact', 'desc'); return Datatables::of($contact)->edit_column('type', function ($contact) { return "{$contact->getTypes($contact->type)}"; })->add_column('actions', '<a href="{{{ URL::to(\'admin/contacts/\' . $id_contact . \'/note\' ) }}}" class="btn glyphicon glyphicon-file" title="show notes"></a> <a href="{{{ URL::to(\'admin/contacts/\' . $id_contact . \'/delete\' ) }}}" class="btn glyphicon glyphicon-remove" title="delete" style="color: red"></a> ')->remove_column('id_contact')->make(); }
public function updateContact($mysql, $cid, $name, $email, $phone, $ownerid) { $con = new Contact(); switch($con->select($cid, $ownerid, $mysql)) { case Contact::DATABASE_ERROR : { echo "<p>A Database error has occured.</p>"; return; } case Contact::INVALID_DATA : { echo "<p>Invalid operation requested.</p>"; return; } case Contact::SELECT_SUCCESS : default : break; } $con->read($ownerid, $name, $email, $phone); switch($con->update($mysql)) { case Contact::DATABASE_ERROR : { echo "<p>A Database error has occured.</p>"; return; } case Contact::INVALID_DATA : { echo "<p>Invalid operation requested.</p>"; return; } case Contact::UPDATE_SUCCESS : { echo "<p>Contact updated successfully.</p>"; break; } default : break; } }