Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by KSI

  1. Okay I think I got an idea what to use for this now. Currently using Codeigniter so the equivalent of this should be a flash message. Thanks.
  2. Currently I'm in my controller and I have placed a check in the controller. Basically checking if the value of a particular field is 0 or not. Now if it is 0, I want to display an alert popup via my controller. To do this I've tried the following code: public function status($status){ if($this->input->post('id')){ foreach($this->input->post('id') as $key => $id): $check_emirate = $this->listings_model->check_emirate($id); if($check_emirate->emirate == 0){ echo "<script>alert('This card was not approved.');</script>"; }else{ $data=array('status'=>$status); $updated=$this->listings_model->update($data,array(),$id); } endforeach; } return true; } Now it is entering my if condition, but it doesnt show me the popup. This is the AJAX call I'm making to enable this function: $(".status").click(function(e) { chagestatus($(this)); } function chagestatus(obj){ if($('.chkbx').is(':checked') == true){ $.ajax({ type: "post", dataType: "json", async:false, url: "<?php echo site_url('listings/status'); ?>/"+obj.data('val'), data: $(".chkbx:checked").serialize(), success: function(result) {} }); } }
  3. Currently I'm using Datatables with pagination. Now I recently added the Datatable.buttons library to use Export to Excel option. Now this functionality works fine but it only exports the first 10 rows of the page I'm currently in due to pagination. Now if I remove the limit in my model class, it will export all the entries which is what I want but it also gets rid of the pagination which decreases my site performance. The following is my current AJAX call code for getting Datatable data: $('#datatable.table').DataTable({ searching: true, paging: true, processing: true, serverSide: true, bFilter: true, dom: 'Bfrtip', async: false, 'columnDefs': [ { 'targets':[0,1,31,32,33,34,35,36,37], 'orderable': false, }], buttons: [ { text:"Export to Excel", extend: 'excelHtml5', exportOptions: { columns: ':visible', modifier:{ page:'all' } } }, ], ajax: { "url": '<?php echo site_url('listings/dtlists'); ?>', "type": "POST" }, columns: [{ data: "title", className: "column5" }, ... Now I've added page:'all' in my modifier, but it still only prints the 1st pagination page. So is there any way that I can use a different model function just for the export button where I can customize the limit manually?
  4. Currently I have a multiselect option in my edit page where at first it should display all the existing values in the database as already checked and once the user removes a selected value, it should be removed from the database and if it is already not there in the database, it should be added to the database. Currently this is my code: View class: <select name="curations[]" id="curations" multiple class="form-control multiselects" <?php echo (isset($read) ? $read:''); ?> multiple> <?php $checked = array(); foreach($get_curation as $key => $value){ $checked[]=$value['curations_id']; } if($curations){ foreach($curations as $cur){ ?> <option value="<?php echo $cur['id']; ?>" <?php echo in_array($cur['id'], $checked) ? 'selected' : 'selected'; ?>><?php echo $cur['title']; ?></option> <?php } } ?> </select> Controller Class: if ($this->input->post('curations') != '') { $curationsPost = $this->input->post('curations'); $curationsArray = array(); $c = 0; foreach($curationsPost as $cp){ if ($cp != ''){ $curationsArray[$c]['listings_id']= $id; $curationsArray[$c]['curations_id']= $cp; $c++; } } if(count($curationsArray) > 0){ $this->listings_model->update_curations($curationsArray); } } Model class: function update_curations($curationsArray){ $this->db->insert_batch("crm_property_curation",$curationsArray); } As of now by default it displays all the values as selected eventhough the values aren't present in the database and now everytime that I submit the form, it creates a duplicate entry in my database if the value was already checked. So basically what I need here is 2 things, 1 is that it shouldn't show everything initially when user enters the page and only show the selected values, and 2 is that when the form is submitted, it should insert the nonduplicate selected values and delete the unselected values. I've tried $this->db->update_batch("crm_property_curation",$curationsArray); but this does not work. As my current query is inserting all the values again, I think what my query should do is delete all the values with the particular listings_id and replace them with the incoming values if thats possible.
  5. Currently I have a table that presents a count of records next to the title of the particular product. To do this I'm using the following code: View Class: <?php $ls_arr = array(1=>'Open',8=>'Hot',2=>'Closed',3=>'Transacted',4=>'Dead',9=>'Follow Up',11=>'Working'); foreach($groupedleads as $grplead){ $statuses[] = $status = $ls_arr[$grplead["lead_status"]]; if($grplead["title"] == NULL || $grplead["title"] == '') $grplead["title"] = "Unknown"; if(isset($grplead["title"])) $titles[] = $title = $grplead["title"]; $leaddata[$status][$title] = $grplead["leadnum"]; } foreach($groupedleads_status as $grplead){ $statuses[] = $status = $ls_arr[$grplead["lead_status"]]; if($grplead["title"] == NULL || $grplead["title"] == '') $grplead["title"] = "Unknown"; if(isset($grplead["title"])) $titles[] = $title = $grplead["title"]; $leaddatastatus[$status][$title][$sub_status] = $grplead["leadnum"]; } ?> <?php if(is_array($titles)) foreach($titles as $title){ ?> <tr> <?php echo "<td>".$title."</td>"; foreach ($statuses as $status) { $num = $leaddata[$status][$title]; $contacts = $leaddatastatus[$status][$title][$sub_status]; $status_num = array_flip($ls_arr)[$status]; if($contacts != ''){ echo "<td><a target='_blank' href='" . site_url('reports/lists?source=' . $title . '&status=' . $status_num . '&sub_status=') . "'>".$num."</a> <font size= '1'><a target='_blank' href='".site_url('reports/lists?source=' . $title . '&status=' . $status_num . '&sub_status=6') . "'>". "Not Contacted - ".$contacts."</a></font></td>"; }else{ echo "<td><a target='_blank' href='" . site_url('reports/lists?source=' . $title . '&status=' . $status_num . '&sub_status=' . $sub_status) . "'>".$num."</a></td>"; } ?> </tr> <?php } ?> Now I did a var_dump on $leadstatus and it gave the following output: Now there are values that are not defined in the second array which are defined in the first. So at those places it gives me a warning message saying Undefined array key Sign Boards. So I want a way so that it displays all the titles regardless of the title being there or not and display the count for that as null.
  6. Currently I'm using codeigniter 3.0 and I have a multiple document upload tab in my add page. Here the user can write the title of the document and upload a document and they can select the add button to add more documents. But I cannot store these document in my database when I click on the save button. Here is my current code: View class: <td width="45%"><input type="text" name="doctitle[]" placeholder="Title"></td> <td><input type="file" name="documents[]"></td> <td width="1%"><a class="btn btn-success" id="addobj" href="javascript:void(0)">Add </a></td> Controller Class: if ($this->form_validation->run() == FALSE) { $main['page'] = 'crm/listings/add'; $this->load->view('crm/index', $main); }else { $maindata=array('clients_id'=>$this->session->userdata('clientsessid')); $insertid=$this->listings_model->insert_listing($maindata); if($insertid){ if ($this->input->post('documents')) { $documentPost = $this->input->post('documents'); $documentTitle = $this->input->post('doctitle'); $documentArray = array(); $c = 0; foreach($documentPost as $dp){ if($this->web_upload->do_upload('documents')) { $filedata=$this->web_upload->data(); $dp=$filedata['file_name']; } $documentArray[$c]['listings_id']= $insertid; $documentArray[$c]['title']= $documentTitle; $documentArray[$c]['document']= $dp; $documentArray[$c]['added_date']=date('Y-m-d H:i:s'); $documentArray[$c]['added_by']= $this->session->userdata('user_id'); $c++; } if(count($documentArray) > 0){ $this->listings_model->save_document($notesArray); } } redirect('listings/sales'); } Model Class: function save_document($maindata){ $this->db->insert_batch("crm_property_docs",$maindata); print_r($this->db->last_query()); die(); return $this->db->insert_id(); } function insert_listing($maindata){ $this->db->insert("crm_listings",$maindata); $prime=$this->db->insert_id(); return $prime; } Now I have added a print_r($this->db->last_query()); die(); statement in my save_document model so if it is being executed it should end the process there but it doesnt end my process, it just fills in all the data values in my database except for the documents data, which means this model is never being called and I'm not sure if I'm using the right method to upload these documents in my database.
  7. Currently I have a 2 dropdown inputs in my edit page, 1 a multi dropdown and the other is a single select dropdown. As of now when I enter the page, both of them show the values from my database. Now the multi select shows a tick on all the options that are currently there in my database. So I want it so that whenever the user unchecks anything, it deletes the entry from my database and whenever they check something, it should insert that entry in the database. Currently this is my code Controller class: function editteam($id,$return='') { if ($this->form_validation->run() == FALSE) { $main['return']=$return; $main['team']= $this->users_model->load_teams($id); $main['members']=$this->users_model->get_members(); $main['page'] = 'crm/users/editteam'; $this->load->view('crm/index', $main); } else { $maindata=array('status'=>$this->security->xss_clean($this->input->post('status')), 'can_manage'=>$this->security->xss_clean($this->input->post('manage')), 'role'=>$this->security->xss_clean($this->input->post('name'))); $loginid=$this->users_model->update_role($maindata,$id); if($loginid){redirect('users/teams/'.$return); } else { redirect('users/teams/'.$return); } } } View class: <?php $membersArray = array(); foreach($team as $t){ $membersArray[] = $t['team_user']; } ?> <div class="row card-box"><?php echo form_open('users/editteam'.$team[0]['tid'].'/'.$return); ?> <div class="form-group col-sm-12"> <label for="name">Team Name </label> <input id="name" name="name" type="text" class="form-control<?php echo $err; ?>" value="<?php echo $team[0]['team_name']; ?>" /> </div> <div class="form-group col-sm-12"> <label for="manage">Managed By <?php } ?> </label> <select class="form-control multiselects <?php echo $err; ?>" name="manage"> <option value="0">None</option> <?php foreach($members as $r){ $selected = ""; if($team[0]['managed_by'] == $r['id']){ $selected = "selected"; } echo '<option '.$selected.' value="'.$r['id'].'">'.$r['display_name'].'</option>'; } ?> </select> </div> <div> <label for="team">Team Members </label> <select multiple="multiple" class="form-control multiselects <?php echo $err; ?>" id="team" name="team[]"> <?php foreach($members as $r){ $selected = ""; if(in_array( $r['id'] , $membersArray)){ $selected = "selected"; } echo '<option '.$selected.' value="'.$r['id'].'">'.$r['display_name'].'</option>'; } ?> </select> </div> <div class="form-group col-sm-12"> <button type="submit" class="btn btn-info">Save</button> <?php echo form_close(); ?> </div> </div> <script> $(document).ready(function(){ $(".multiselects").multiselect({ enableClickableOptGroups: true, enableFiltering: true, includeSelectAllOption:true, buttonWidth: '100%', maxHeight:275, buttonClass: 'form-control text-left bggrid', nonSelectedText: 'Select', enableCaseInsensitiveFiltering: true, nonSelectedText: 'Select', selectAllText: 'Select All', templates: { ul: '<ul class="multiselect-container dropdown-menu col-sm-12"></ul>'} }); $('#team').multiselect('select',[''],true); }); </script> Model class: function get_members(){ $this->db->select("display_name,id"); $this->db->from("crm_clients_users"); $query = $this->db->get(); return $query->result_array(); } function load_teams($id) { $this->db->select("r.id AS tid , t.id as mid , r.,t."); $this->db->from("crm_clients_users_teams as r"); $this->db->where("r.id",$id); $this->db->join("crm_clients_users_teams_members as t","r.id=t.team_id","left"); $query = $this->db->get(); return $query->result_array(); } crm_clients_users_teams_members holds the members of a particular team where I want to have the insert/delete of users whenever they are selected/unselected, and crm_clients_users_teams holds the title and other related stuff to the table.
  8. Currently I have a table in my view class that is populated with data from the backend using MVC framework in codeigniter. Now I have a dropdown above each column that is filling in the same records from my database. So I want to be able to filter my records as soon as the person clicks the item in the dropdown list. To achieve this I'm using a Jquery to get the selected item and sending that value to my controller. Code: So far I have this in my view class: <table> <tr> <th width="10%">Source</th> </tr> <tr> <td width="5%"><select id="your_id_name"> <option value="">All </option> <?php if($sources) foreach($sources as $source): ?> <option value="<?php echo $source['title'] ?>"><?php echo $source['title'] ?></option> <?php endforeach;?> </select></td> <td width="10%"><select id="contact_type"> <option value="">All </option> <?php if($types) foreach($types as $type): ?> <option value="<?php echo $type['id'] ?>"><?php echo $type['title'] ?></option> <?php endforeach;?> </select></td> </tr> <tbody> <?php if(isset($records) && count($records) > 0) { foreach($records as $row ){ ?> <tr> <td><?= $row->source ?></td> <td><?= $row->title ?></td> </tr> <?php } } ?> </tbody> <script type="application/javascript"> $('#your_id_name').on('change', function() { console.log($('#your_id_name').val()); $.get('<?php echo base_url('ajax_dropdown'); ?>', { selected: $('#your_id_name').val() }, function(res) { var values = JSON.parse(res); // then do something var status = values.status; var records = values.records; var html = "" records.forEach(function(row){ html += `<tr><td>${row.source}</td> <td>${row.title }</td></tr> `; console.log(tbody_tag) }) var tbody_tag = $('tbody#table_body'); tbody_tag.html(html); }) }) $('#contact_type').on('change', function() { console.log($('#contact_type').val()); $.get('<?php echo base_url('ajax_dropdown'); ?>', { selected_contact: $('#contact_type').val() }, function(res) { var values = JSON.parse(res); // then do something var status = values.status; var records = values.records; var html = "" records.forEach(function(row){ html += `<tr><td>${row.source}</td> <td>${row.title}</td></tr> `; }) var tbody_tag = $('tbody#table_body'); tbody_tag.html(html); }) }) controller class: public function ajax_lists(){ $data = array(); // store data in here, store all data you need in data $selected_input = $this->input->get('selected'); $selected_input2 = $this->input->get('selected_contact'); $data['records'] =$this->contacts_model->get_records($selected_input,$selected_input2); echo json_encode($data); } Model Class: function get_records($selected_input = null,$selected_input2 =null){ $this->db->select("*"); $this->db->from("crm_contacts as con"); if($selected_input){ $this->db->where("con.added_by",$selected_input); } if($selected_input2){ $this->db->where("con.contact_type",$selected_input2); } $query = $this->db->get(); return $query->result(); } Here as of now I can filter all my records 1 at a time. So suppose I filter the table by source and then inside that source I want to filter the leftover data by contact_type, I cannot do it since doing so resets the 1st filter I had and filters all the data according to the new select item I have clicked.
  9. I'm trying to store my database values in a session so that whenever user logs in I can access those session variables to get their name, id, etc. To achieve this I'm using the following code: Controller Class(login): $this->load->view('crm/login/index',$main); $clientdata=$this->login_model->get_row_cond($cond); $newdata = array( 'clientsessid' => $clientdata->clients_id, 'clientsessuserid' => $clientdata->id, 'clientsesskey' => $clientdata->client_key, 'clientsesusername' => $clientdata->username, 'clientsessemail' => $clientdata->email, 'client_loginid' => $loginid, 'client_logged_in' => TRUE ); $this->session->set_userdata($newdata); redirect('dashboard'); Model class: function get_row_cond($cond) { $this->db->where($cond); $query = $this->db->get($this->table_name); return $query->row(); } View class(dashboard): <?php var_dump( $this->session->userdata('clientsesusername')) ?> But doing so returns a NULL value after the user has logged in. And I've checked the database and the username for the particular person is filled.
  10. Yea but that's not how my structure works. In my table, listsreport shows the actual view class and ajaxleadsreport shows the data for a table inside that view class. So I have to pass the GET data from listsreport to ajaxleadsreport since GET data is only able to show up in listsreport
  11. I have 2 view classes called indexreport and ajaxleadsreport. ajaxleadsreport fetches all the data and displays it. Now I have a GET variable that is being passed to indexreport which I want to be able to pass it to ajaxleadsreport to filter the current data according to the GET variable that has been passed. Controller Class: public function listsreport($slug='') { $status1 = $this->input->get('status'); print_r($status1); $main['content']=$this->load->view('crm/leads/indexreport',$content,true); } public function ajaxleadsreport($p='') { $output = array( 'html'=>$this->load->view('crm/leads/ajaxleadsreport',$content, true)); echo json_encode($output); } To put in simple words I want status1 to go to ajaxleadsreport controller
  12. In my database, I have a id and title column where each title has a specific id, for example 1 is IT, 2 is Sales, etc. Now to show this in a table format I'm using the following code: View class: <?php foreach($groupedleads as $grplead){ $statuses[] = $status = $grplead["lead_status"]; if($grplead["title"] == NULL || $grplead["title"] == '') $grplead["title"] = "Unknown"; if(isset($grplead["title"])) $titles[] = $title = $grplead["title"]; $leaddata[$status][$title] = $grplead["leadnum"]; } <table> <?php if(is_array($titles)) foreach($titles as $title){ ?> <tr> <?php echo "<td>".$title."</td>"; foreach ($statuses as $status) { $num = $leaddata[$status][$title]; echo "<td><a target='_blank' href='" . site_url('reports/viewall?source=' . $title) . "'>".$num."</a></td>"; ?> </tr> </table> Controller Class: public function leadstatus($slug='') { $content['groupedleads'] = $this->leads_model->get_statusreport(); $this->load->view('crm/reports/leadstatus',$content); } Model Class: function get_statusreport($fdate='',$tdate='') { $this->db->select("l.lead_status,crm_sources.title,crm_sources.id,count(*) as leadnum"); $this->db->from($this->table_name." as l"); $this->db->join("crm_sources ","crm_sources.id= l.lead_source","left"); $query = $this->db->get(); $results = $query->result_array(); return $results; } Now I can see the titles for each of these in my table, but as of now these items under each title are clickable and lead to a different page. I use this code to get that href='" . site_url('reports/viewall?source='.$title). Now I actually want the id to be passed instead of the string value of title. So basically it has to look up from the database for the id of the particular items title that was clicked. When I write the following code for the first forloop, it returns the ids for all the items where currently the titles are residing: foreach($groupedleads as $grplead){ $statuses[] = $status = $grplead["lead_status"]; if($grplead["id"] == NULL || $grplead["id"] == '') $grplead["id"] = "Unknown"; if(isset($grplead["id"])) $titles[] = $id= $grplead["id"]; $leaddata[$status][$id] = $grplead["leadnum"]; } But I want the display to show it as title only, but the link should be replaced with the id instead of the title which it's currently showing.
  13. I'm currently passing values in my URL that I want to GET and insert in my controller class for filtering. My current URL looks something like this: http://localhost/reports/lists?source=Product1&status=4. Now to get the value of suppose source, I'm using the following code: let searchParams = new URLSearchParams(window.location.search); var status = searchParams.get('source'); Now I want this status variable to go to my controller class so that I can use it as 1 of my parameters for my model class: Full code: View Class: <?php $postd = json_encode(array_filter($post)); ?> <table id="item-list"> <tr> <th>Ref.No#</th> <th>Source</th> </tr> </table> <script> $(document).ready(function() { function sendreq(){ setpostdatas();cleartable();getleads(); } var userrole = "<?php echo $this->session->userdata('clientrole')?>"; var slug = '<?php echo $slug?>'; var postd = '<?php echo $postd; ?>'; if( userrole > 1 && userrole != 5){ $('#item-list').DataTable({ "processing": true, "stateSave": true, "serverSide": true, "ordering": false, "createdRow": function( row, data, dataIndex){ $(row).has( "div.overdueupdate" ).css('background-color','#FFC7CE'); }, "ajax": { url: "<?php echo site_url(); ?>reports/loadLeads", data: {slug: slug, postdata: postd}, type : 'POST', "dataSrc": function ( d ) { d.myKey = "myValue"; if(d.recordsTotal == 0 || d.data == null){ $("#item-list_info").text("No records found"); $("#item-list_processing").css("display","none"); } return d.data; } }, 'columns': [ {"data": "id", "id": "id"}, {"data": "refno", "refno": "refno"}, {"data": "source", "source": "source"}, ] }); } Controller Class: public function loadLeads($p=''){ $leadsource = $this->input->get('status'); if(isset($_POST['postdata'])){ if($_POST['postdata'] != null && $_POST['postdata'] != 'null'){ $post=$_POST['postdata']; } $post = json_decode($post,true); unset($post['slug']); unset($post['page']); $sort = $post['afsort']; if($sort == "asc"){ $sortQ = 'l.updated_date asc,'; }else if ($sort == "desc"){ $sortQ = 'l.updated_date desc,'; } } $offset = (int)$_POST['start'] ; $pstdatas = explode(',', $_POST['postdata']); unset($pstdatas['item-list_length']); if($this->session->userdata('clientrole') == 1 || $this->session->userdata('clientrole') == 5 ){ $content['leads']=$this->leads_model->get_pagination($_POST['length'],$offset,$where,'',false,$sortQ?$sortQ:'l.assign_status =\'Unassigned\' desc,',$all,$leadsource); }else{ $content['leads']=$this->leads_model->get_pagination($_POST['length'],$offset,$where,'',false,$sortQ?$sortQ:'l.assigned_date desc,',$all,$leadsource); } Now here in my controller class I want that AJAX variable to be passed so that I can use it my model query.
  14. The input field lets you autocomplete because the data is large.
  15. redirect_m is the name of my model class.
  16. I have a table that shows the redirect from and redirect to columns from my database. By default, all the records are shown, but there is a from and to filter I'm using to search by a particular redirect. Now there are a lot of times that after I input the filters, it gives me a Undefined variable: redirects error, but sometimes it works. Here is my code: View Class: <?php if ($redirects): ?> <form name="redirectform" action="admin/redirects" method="post"> <div> <input list="search-from-list" id="search-from" name="search-from" style="width:100%;"/> <datalist id="search-from-list"> <?php foreach ($allredirects as $allredirect){ ?> <option value="<?php echo $allredirect->from; ?>" id="<?php echo $allredirect->id; ?>" /> <?php } ?> </datalist> </div> <input type="hidden" name="linkid" id="linkid" /> <input type="hidden" name="linkidto" id="linkidto" /> <input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>"> </div> <input list="search-to-list" id="search-to" name="search-to" style="width:100%;" /> <datalist id="search-to-list"> <?php foreach ($allredirects as $allredirect){ ?> <option value="<?php echo $allredirect->to; ?>" id="<?php echo $allredirect->id; ?>" /> <?php } ?> </datalist> </div> </form> <table> <?php foreach ($redirects as $redirect): ?> <tr> <td><?php echo $from=str_replace('%', '*', $redirect->from);?></td> <td><?php echo $redirect->to;?></td> </tr> <?php endforeach ?> </table> <?php echo form_close() ?> </div> <?php else: ?> <div class="no_data">No Data</div> <?php endif ?> <script type="text/javascript"> $("#search-from").select(function(e){ var g = $('#search-from').val(); var id = $('#search-from-list').find("option[value='"+g+"']").attr('id'); $('#linkid').val(id); }); $("#search-to").select(function(e){ var g = $('#search-to').val(); var id = $('#search-to-list').find("option[value='"+g+"']").attr('id'); $('#linkidto').val(id); }); </script> Controller Class: public function index() { if(isset($_POST["search-from"]) && !empty($_POST["search-from"])){ if(isset($_POST["linkid"]) && !empty($_POST["linkid"])){ $from_id = $_POST["linkid"]; $this->template->redirects = $this->redirect_m->order_by('`from`')->get_by_id($from_id); } }else if(isset($_POST["search-to"]) && !empty($_POST["search-to"])){ if(isset($_POST["linkidto"]) && !empty($_POST["linkidto"])){ $to_id = $_POST["linkidto"]; $this->template->redirects = $this->redirect_m->order_by('`to`')->get_by_id($to_id); } }else{ $this->template->redirects = $this->redirect_m->order_by('`from`')->limit($this->template->pagination['limit'], $this->template->pagination['offset'])->get_all(); } $this->template->allredirects = $this->redirect_m->order_by('`from`')->get_all(); $this->template->build('admin/index'); } Here basically what I'm doing is that the input with the ids search-from and search-to hold an autocomplete function for the redirect links. I have other 2 input fields linkid and linkidto which are hidden. Now I did some debugging and found out that the reason for my error is because the AJAX call is taking too long. Basically what the ajax call does is convert whatever text that is there in the input field of search-from and fetches the id for that from the database and then returns the value according to that id. So I changed the hidden fields to text and manually inserted the ids for the search fields I entered and it worked everytime. So now what I think the problem is that the AJAX call is taking too long to convert the selected options to their respective ids and this ends up giving me an error. So maybe what I want here is a delay timer to the page until the AJAX call has been made?
  17. More problems? But when I log `$grplead['status']` it gives me the correct output showing YYYYNY. And by css rule do you mean: echo "<td class=" <?php echo $inactive_status == true?'agent-status-N':'agent-status-Y'">".$display_name."</td>"; ?
  18. Currently I have a table displaying all of the agents and a count of their leads status shown in the same row. Now these agents can be Active or Inactive, but both are shown in my table. This active/inactive status is shown in my users table under the status column as either Y or N. Now this is the code I'm using to get my data: Model Class: function get_agentsreport(){ $this->db->select("l.lead_status,cu.display_name,cu.status,count(*) as leadnum,l.enquiry_date"); $this->db->from($this->table_name." as l"); $this->db->join("crm_clients_users cu","cu.id= l.lead_agent","left"); $this->db->join("crm_clients_users cu2","cu2.id= l.external_agent","left"); $this->db->group_by("l.lead_status,cu.id,cu2.id"); $query = $this->db->get(); } View Class: <?php $ls_arr = array(1=>'Open',8=>'Hot',2=>'Closed',3=>'Transacted',4=>'Dead',9=>'Follow Up',11=>'Working'); foreach($groupedleads as $grplead){ $statuses[] = $status = $ls_arr[$grplead["lead_status"]]; if($grplead["display_name"] == NULL || $grplead["display_name"] == '') $grplead["display_name"] = "Unknown"; if(isset($grplead["display_name"])) $display_names[] = $display_name = $grplead["display_name"]; $leaddata[$status][$display_name] = $grplead["leadnum"]; if($grplead['status'] == "N"){ $inactive_status == true; } } if(count($display_names) > 0) $display_names = array_unique($display_names); ?> <table> <?php if(is_array($display_names)) foreach($display_names as $display_name){ ?> <tr> <?php $total = 0; $nonContact_total=0; if ($inactive_status ) echo "<td style='background-color:#000'>".$display_name."</td>"; else echo "<td>".$display_name."</td>"; foreach ($statuses as $status) { ... } <?php } ?> </table> Now I'm trying to differentiate the active and inactive users by a change in the style and as shown here I've tried if($grplead['status'] == "N"){$inactive_status == true;} but in my table it always goes to the else statement and doesn't compute the first if statement. I've also tried if($grplead['status'] == "Y"){$inactive_status == true;} but it gives the same output. I've tried logging this status by print_r($grplead['status']); which gave the correct result like YYYYNY. So it is giving the correct status for each person, but for some reason it does not work in my if condition
  19. Currently I have a table that displays a total count of my data values for each source. I'm getting this value after comparing 2 tables 1 is crm_leads with all my product information and 1 is crm_sources with what sources are the products related to. Now this is the output: Now as you can see the total count is shown under each header next to its source. Now these count values are inside a tags which once clicked go to viewall page. Here basically I want to show the data of the item that I had clicked. So for example, if I clicked the 163 under Hot status, it takes me to the view all page and shows me id, source, enquiry_date for all those under status Hot in a table. So basically it should detect the data for which source and which status is clicked and then accordingly make a statement like this? select * from crm_leads where lead_source = '.$source.' and lead_status = '.$status.'; Model Class: function get_statusreport($fdate='',$tdate='') { $this->db->select("l.lead_status,crm_sources.title,count(*) as leadnum,l.enquiry_date,l.sub_status"); $this->db->from($this->table_name." as l"); if($fdate !='') $this->db->where("date(l.added_date) >=",date('Y-m-d',strtotime($fdate))); if($tdate !='') $this->db->where("date(l.added_date) <=",date('Y-m-d',strtotime($tdate))); $this->db->where("lead_status <>",10); $this->db->join("crm_sources ","crm_sources.id= l.lead_source","left"); $this->db->group_by("l.lead_status,crm_sources.title"); $this->db->order_by("leadnum DESC, crm_sources.title ASC,l.lead_status ASC"); $query = $this->db->get(); $results = $query->result_array(); return $results; } Controller Class(leadstatus holds the view for my current table): public function leadstatus($slug='') { $content=''; $content['groupedleads'] = $this->leads_model->get_statusreport($fdate,$tdate); $this->load->view('crm/main',$main); $this->load->view('crm/reports/leadstatus',$content); } public function viewall($slug='') { $content=''; $this->load->view('crm/main',$main); $this->load->view('crm/reports/viewall',$content); } View class: <?php $ls_arr = array(1=>'Open',8=>'Hot',2=>'Closed',3=>'Transacted',4=>'Dead'); foreach($groupedleads as $grplead){ $statuses[] = $status = $ls_arr[$grplead["lead_status"]]; if($grplead["title"] == NULL || $grplead["title"] == '') $grplead["title"] = "Unknown"; if(isset($grplead["title"])) $titles[] = $title = $grplead["title"]; $leaddata[$status][$title] = $grplead["leadnum"]; } if(count($titles) > 0) $titles = array_unique($titles); if(count($statuses) > 0) $statuses = array_unique($statuses); ?> <table> <tr"> <th id="status">Source</th> <?php if(count($statuses) > 0) foreach($statuses as $status){ ?><th id=<?php echo $status; ?>><?php echo $status; ?></th> <?php } ?> <th>Total</th> </tr> <?php if(is_array($titles)) foreach($titles as $title){ ?> <tr> <?php $total = 0; echo "<td>".$title."</td>"; foreach ($statuses as $status) { $num = $leaddata[$status][$title]; echo "<td><a target='_blank' href='".site_url('reports/viewall')."'>".$num."</a></td>"; $total += $num; $sum[$status] += $num; } echo "<td>".$total."</td>"; $grandtotal += $total; ?> </tr> <?php } ?> </table>
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.