Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 14,372
» Latest member: michlalker
» Forum threads: 69,913
» Forum posts: 433,619

Full Statistics

Latest Threads
softDelete and database i...
Forum: CodeIgniter 4 Support
5 hours ago
» Replies: 17   » Views: 558
CodeIgniter 4 Logo
Forum: News & Discussion
8 hours ago
» Replies: 34   » Views: 9,673
Forum registration on hol...
Forum: News & Discussion
8 hours ago
» Replies: 2   » Views: 1,357
CodeModules Language Prop...
Forum: CodeIgniter 4 Discussion
10 hours ago
» Replies: 0   » Views: 74
Codeigniter application: ...
Forum: General Help
Today, 07:53 AM
» Replies: 0   » Views: 109
Undefined variable: admin...
Forum: General Help
Yesterday, 05:06 PM
» Replies: 9   » Views: 1,233
Do you have a hobby?
Forum: Lounge
Yesterday, 05:23 AM
» Replies: 28   » Views: 13,884
Captcha doest work on Lin...
Forum: General Help
Yesterday, 04:09 AM
» Replies: 3   » Views: 448
Jquery UI modal show not ...
Forum: General Help
Yesterday, 01:07 AM
» Replies: 8   » Views: 1,068
How do I replace front-en...
Forum: CodeIgniter 3.x
08-23-2019, 02:42 PM
» Replies: 9   » Views: 490

 
  A reflection about Controllers getting fatter in CI4
Posted by: tgix - 08-13-2019, 12:09 AM - Forum: CodeIgniter 4 Discussion - Replies (2)

(It's a sunny morning with a cup of coffee on the veranda so please forgive this philosophical post)
Been working on my brand new shiny CI4 project for a couple of days now and it's shaping up rather nicely. This project is a planned new REST-based backend for an old monolithic web-project created eons ago. The new UI is made in Sencha ExtJS 7.0.0-EA so it's bleeding edge both frontend and backend.

I have been using CI3 for many projects and consider myself rather fluent in how it works. Looking back at the CI4 project so far I notice a big shift in how I code CI4 compared to CI3 and notably that my Controllers are "fattier" than in my CI3 Controllers. With CI3 I adopted the "thin Controller - fat Model" approach where the Controller basically only called functions in the Model. The Models' code got pretty lengthy but kept the notion of working on the data while the Controller mainly checked input and access. In CI4 I now have lengthy database code that should have gone into the Model in CI4.

Don't get me wrong - I sort of like the new Model in CI4 but it is too much pixie-dust sprinkled over them. With all this magic going on I don't feel confident to add code in the Model that may upset the delicate machinery, breaking things. The (imagined?) one-to-one mapping between a Model and a database table may be part of my thinking around this. The mixing of the Query Builder and the Model is another thing that really scares me and I tend to use the Query Bilder completely separate from the Model.

All my hesitation might be just me over-thinking stuff but we need to deliver a fast and reliable solution to our customers and users and I need to feel as confident with CI4 as I did with CI3.

A big thank you for moving CI4 forward!
/Mattias


  Load a controller into another controller
Posted by: Mekaboo - 08-12-2019, 09:10 PM - Forum: General Help - Replies (5)

Hello all!

I have my Users.php controller that operates login/register and it works perfectly but I recently purchased a FB style script which has wall post, chat, and friends portion that I want to implement into my site. This script has its own controllers/models of course but I how do I add these within my Users.php so that everything connects and all the tables within my DB work together? 



Heart Heart ,
Mekaboo


  The most used Design Patterns with a CI project?
Posted by: fmertins - 08-12-2019, 12:38 PM - Forum: Lounge - Replies (1)

Hello everyone,

I wonder what are the most used OO Design Patterns you guys use along with your CI projects?

I'm asking this because sometimes I kind of end up writing heavy controllers with a lot of complex logic and some protected methods, for example, when I have to reuse a block of code, or creating methods on MY_Controller when there is more than one controller using that logic, etc.

Another example, sometimes I worry about data/variables relying on the session library because I think it's up to us to avoid overwriting a variable, so we have to be careful depending on how many variables you are going to deal in your session. Usually, my approach is using a name convention to avoid this scenario.

I also like to write my own "domain classes", to avoid only "array organized data", these will be my objects that will represent my database tables (entities). I try to design them with some OO principles that we don't have in the relational paradigm, for instance, if I have a "one to many" relationship in the database, in the equivalent object I'll have a collection (array of child-objects).

In other words, how many other classes, and how much complex, you guys like to create besides the traditional MVC pattern?

Thanks, have a great week!


  Is there no longer a need for num_rows()?
Posted by: tgix - 08-11-2019, 11:04 PM - Forum: CodeIgniter 4 Discussion - Replies (5)

Looking at CI4 and working with databases I can't find a way to get the number of rows returned from a query. 
In CI3 I often did:

PHP Code:
/** @var CI_DB_result $query */
$query $this->db->get(TBL_INVITES);

if (
$query->num_rows() !== 1)
{
    return 
FALSE;
}

/** Continue processing **/ 

Should I do like this in CI4 or is there a better way?
PHP Code:
if (count($query->getResultArray()) !== 1)
{
    return 
false;


  ALERT: Major migration refactor just merged
Posted by: kilishan - 08-11-2019, 10:22 PM - Forum: CodeIgniter 4 Development - Replies (2)

This is that last of the known breaking changes, and one that had been bugging me for a while. Thanks to those that prodded this change on, we now have a bit more cohesive migration change. Follow the link to see all of the gory details, but here's the big items:

- No more serial names (001, 002, etc). All migrations use timestamps now, which can be formatted in several ways to suit your preference.
- Class names have changed, they're now Pascal-cased like all other classes in the system, and do not need Migration_ at the beginning of the name. This was unnecessary since they're all namespaced now.
- Command name has changed from migrate:latest to simply migrate.
- When running php spark migrate -all it now pulls together all migrations across all namespaces and sorts them by their timestamp, instead of treating each namespace separately.

Follow Full details here


  What is wrong with this code pls
Posted by: soapz - 08-10-2019, 01:41 PM - Forum: General Help - Replies (2)

Dear Team,
Please this code can run on view but returns zero or null for total_marks and Average score whenever i run it on controller.
Tell me what i am doing wrong. Thanks 

function testme ($exam_id,$class_id){

$soap_data['exam_id'] = $exam_id;
$soap_data['class_id'] = $class_id;

        $soap_data['year']       = $this->db->get_where('settings' , array('type'=>'running_year'))->row()->description;
        if($soap_data['class_id'] != '' && $soap_data['exam_id'] != ''){


$subjects = $this->db->get_where('subject' , array('class_id' => $class_id , 'year' => $running_year))->result_array();
foreach($subjects as $row){ echo $row['name'];}



$students = $this->db->get_where('enroll' , array('class_id' => $class_id , 'year' => $running_year))->result_array();
    foreach($students as $row){

$total_marks = 0;
            $total_grade_point = 0;
                    foreach($subjects as $row2)
$obtained_mark_query = $this->db->get_where('mark' , array(
'class_id' => $class_id , 
'exam_id' => $exam_id , 
'subject_id' => $row2['subject_id'] , 
'student_id' => $row['student_id'],
'year' => $running_year
));
if ( $obtained_mark_query->num_rows() > 0) {
$obtained_marks = $obtained_mark_query->row()->mark_obtained;
if ($obtained_marks >= 0 && $obtained_marks != '') {
$grade = $this->crud_model->get_grade($obtained_marks);
$total_grade_point += $grade['grade_point'];
}
$total_marks += $obtained_marks;

}

$soap_data['Total_score'] = $total_marks;
$this->db->where('class_id' , $class_id);
$this->db->where('year' , $running_year);
$this->db->from('subject');
$number_of_subjects = $this->db->count_all_results();
$average_score= ($soap_data['Total_score'] / $number_of_subjects);
$avg =  round($average_score,2);
$soap_data['Average_score'] = $avg;
}



        $query = $this->db->get_where('total_mark' , array(
                    'exam_id' => $soap_data['exam_id'],
                        'class_id' => $soap_data['class_id'],
                            'Total_score' => $soap_data['Total_score'],
                                'Average_score' => $soap_data['Average_score'],
                                    'year' => $soap_data['year']
                ));
        if($query->num_rows() < 1) {
           $students = $this->db->get_where('enroll' , array('class_id' => $soap_data['class_id'] , 'year' => $soap_data['year']))->result_array();
            foreach($students as $row) {
               $soap_data['student_id'] = $row['student_id'];
                $this->db->insert('total_mark' , $soap_data);
            }
}
}

}


  Extending \CodeIgniter\Database\MySQLi\Builder possible?
Posted by: tgix - 08-10-2019, 02:42 AM - Forum: CodeIgniter 4 Discussion - Replies (8)

More questions on CI3 -> CI4...
In my old project I use SQL_CALC_FOUND_ROWS to query the database for the total count of records while doing a WHERE/LIMIT query. I need to LIMIT the queries to keep the frontend UI happy with huge datasets. I should only insert SQL_CALC_FOUND_ROWS if there is a WHERE clause in the SQL query, otherwise the query will be slow and a COUNT(*) is better.

In CI3 I could inject the SELECT directly into the $db object, but that's not the case in CI4 where the $db is not global. Rather than passing around $db I wonder if it is possible to extend \CodeIgniter\Database\MySQLi\Builder with my own function to add a function so I could do something like this:

PHP Code:
$query $builder
    
->calc_found_rows()                // Should check for filter in the request and SQL_CALC_FOUND_ROWS
    
->select('userID,firstname,lastname,email')
    ->
add_request_filters()            // Another function I'd like to add
    
->get($this->limit$this->start); // Paging parameters set in the extended Controller
        
    
$total $builder->get_total_count(); // If SQL_CALC_FOUND_ROWS used, get FOUND_ROWS() else COUNT(*) 

I have tried adding a class Builder.php to app/Database/MySQLi extending \CodeIgniter\Database\MySQLi\Builder but it doesn't load.

I know that I can hack the class in system but that sort of defeats the purpose of having composer-supported frameworks.

Thanks,
/Mattias


  Do I need to set all my routes in Routes.php?
Posted by: tgix - 08-10-2019, 01:58 AM - Forum: CodeIgniter 4 Discussion - Replies (10)

Struggling along trying to recreate my REST API from CI3 in CI4-beta4. I find it very cumbersome to configure all my route entries in Routes.php like this (far from complete):

PHP Code:
$routes->group('users', function ($routes) {
    
$routes->get('list''Users::list');
    
$routes->get('(:num)''Users::get_user/$i');
    
$routes->options('(:any)''Users::options_respond');
}); 
Is there a way to have the routes live in the Controller instead or am I overthinking this?


  Upgrading from 2 to 3 Form Issues
Posted by: RmsGreig - 08-08-2019, 08:58 AM - Forum: General Help - Replies (7)

I've been tasked with updating a codeigniter application from version 2 to 3 using the https://www.codeigniter.com/user_guide/i...e_300.html which had been going fine until I started testing the inputs.
I have never used codeigniter before so worried that if I keep tinkering I will break more of the application
The application is a booking diary where you have to log in to your account or create an account in order to book. The log in  to an existing account works but neither the create user form or the booking form send information to the database. They are not returning any errors on the page and in the log: Session: "sess_save_path" is empty; using "session.save_path" value from php.ini. Here is the Booking Controller:

PHP Code:
require_once(__DIR__ '/Id_Base.php');

class 
Bookings extends Ice_diary_base
{
 
   function __construct()
 
   {
 
       parent::__construct();

 
       $this->load->model('Sessions_Model''sessions_model');
 
       $this->load->model('Ion_Auth_Model');
 
       $this->load->helper('url');
 
       $this->load->helper('ice_diary');
 
 
    
}

 
   public function add()
 
   {
 
       if (!$this->ion_auth->logged_in())
 
       {
 
           redirect('auth/login/' $this->uri->uri_string(), 'refresh');
 
       }

 
       //checking if were editing or creating
 
       //set up some default data
 
       if($this->uri->segment('2') == 'edit') {
 
           $booking_id $this->uri->segment(3);

 
           if(!$booking_id) {
 
               show_404();
 
           }

 
           $booking $this->bookings_model->get_booking($booking_id);

 
           $data['year'] = date('Y'$booking->start_date);
 
           $data['month'] = date('m'$booking->start_date);
 
           $data['day'] = date('d'$booking->start_date);
 
           $data['session'] = explode('|'$booking->session);
 
           $data['sheet'] = $booking->sheet;

 
           $start_time explode(':'$booking->start_time);
 
           $data['start_time_hours'] = $start_time[0];
 
           $data['start_time_mins'] = $start_time[1];

 
           $end_time explode(':'$booking->end_time);
 
           $data['end_time_hours'] = $end_time[0];
 
           $data['end_time_mins'] = $end_time[1];

 
           //url for cancel, tries to redirect back to where the user came from
 
           $cancel_uri 'Diary/index/' $data['year'] . '/' $data['month'] . '/' $data['day'];
 
       }
 
       else {
 
           require_once(__DIR__ '/../libraries/POCOs/Booking.php');
 
           $booking = new Booking();

 
           $data['year'] = $this->uri->segment(3TRUE);
 
           $data['month'] = $this->uri->segment(4TRUE);
 
           $data['day'] = $this->uri->segment(5TRUE);
 
           $data['session'] = $this->uri->segment(6TRUE);
 
           $data['sheet'] = $this->uri->segment(7TRUE);

 
           //url for cancel, tries to redirect back to where the user came from
 
           $cancel_uri 'diary/index/' $data['year'] . '/' $data['month'] . '/' $data['day'];
 
       }

 
       $data['date'] = '';

 
       if($data['year'] && $data['month'] && $data['day']) {
 
           $data['date'] = date('d/m/Y'strtotime($data['year'] . '-' $data['month'] . '-' $data['day']));
 
       }

 
       $session_to_get $data['session'];
 
       if(is_array($session_to_get)) {
 
           $session_to_get $session_to_get[0];
 
       }

 
       $session_data $this->sessions_model->get_session_by_date(date_to_mysql($data['date']), $session_to_get);

 
       // if we dont have a start and end time, e.g. were not editing
 
       // load from the session data
 
       if(!isset($data['start_time_hours']) && !isset($data['start_time_mins'])) {
 
           $start_time explode(':'$session_data->start_time);
 
           $data['start_time_hours'] = $start_time[0];
 
           $data['start_time_mins'] = $start_time[1];
 
       }

 
       if(!isset($data['end_time_hours']) && !isset($data['end_time_mins'])) {
 
           $end_time explode(':'$session_data->end_time);
 
           $data['end_time_hours'] = $end_time[0];
 
           $data['end_time_mins'] = $end_time[1];
 
       }

 
       $data['is_admin'] = $this->is_admin;

 
       //if were posting back and cancel was clicked
 
       if(isset($_POST['cancel'])) {
 
           redirect($cancel_uri);
 
       }

 
       //validate form input
 
       $this->form_validation->set_rules('title'$this->lang->line('book_validation_title_label'), 'required');
 
       $this->form_validation->set_rules('start_date'$this->lang->line('book_validation_sdate_label'), 'required|callback_valid_date');
 
       $this->form_validation->set_rules('sheet'$this->lang->line('book_validation_sheet_label'), 'required');
 
       $this->form_validation->set_rules('session_id'$this->lang->line('book_validation_session_label'), 'required');
 
       $this->form_validation->set_rules('team1'$this->lang->line('book_validation_team1_label'));
 
       $this->form_validation->set_rules('team2'$this->lang->line('book_validation_team2_label'));
 
       $this->form_validation->set_rules('score1'$this->lang->line('book_validation_score1_label'));
 
       $this->form_validation->set_rules('score2'$this->lang->line('book_validation_score2_label'));
 
       $this->form_validation->set_rules('provisional'$this->lang->line('book_validation_provisional_label'));
 
       $this->form_validation->set_rules('paid'$this->lang->line('book_validation_paid_label'));
 
       $this->form_validation->set_rules('invoiced'$this->lang->line('book_validation_invoiced_label'));
 
       $this->form_validation->set_rules('repeats'$this->lang->line('book_validation_repeats_label'));
 
       $this->form_validation->set_rules('repeats_every'$this->lang->line('book_validation_repeats_every_label'));
 
       $this->form_validation->set_rules('repeat_by'$this->lang->line('book_validation_repeat_by_label'));
 
       $this->form_validation->set_rules('repeats_on_mon'$this->lang->line('book_validation_repeats_on_mon_label'));
 
       $this->form_validation->set_rules('repeats_on_tue'$this->lang->line('book_validation_repeats_on_tue_label'));
 
       $this->form_validation->set_rules('repeats_on_wed'$this->lang->line('book_validation_repeats_on_wed_label'));
 
       $this->form_validation->set_rules('repeats_on_thu'$this->lang->line('book_validation_repeats_on_thu_label'));
 
       $this->form_validation->set_rules('repeats_on_fri'$this->lang->line('book_validation_repeats_on_fri_label'));
 
       $this->form_validation->set_rules('repeats_on_sat'$this->lang->line('book_validation_repeats_on_sat_label'));
 
       $this->form_validation->set_rules('repeats_on_sun'$this->lang->line('book_validation_repeats_on_sun_label'));
 
       $this->form_validation->set_rules('repeat_ends'$this->lang->line('book_validation_repeat_ends_label'));
 
       $this->form_validation->set_rules('repeat_ends_after_occurences'$this->lang->line('book_validation_repeats_on_occurences_label'), 'xss_clean|is_natural_no_zero|callback_repeat_ends_occurences[repeat_ends]');
 
       $this->form_validation->set_rules('repeat_ends_on_date'$this->lang->line('book_validation_repeats_end_after_date_label'), 'xss_clean|callback_repeat_ends_date[repeat_ends]');

 
       $data['error'] = '';
 
       $data['message'] = '';

 
       if ($this->form_validation->run() == true) {
 
           $insert['user_id'] = $this->current_user->id;
 
           $insert['title'] = $this->input->post('title'TRUE);
 
           $insert['session_id'] = is_array($this->input->post('session_id')) ? implode('|'$this->input->post('session_id'TRUE)) . '|' $this->input->post('session_id'TRUE) . '|';
 
           $insert['sheet'] = $this->input->post('sheet'TRUE);
 
           $insert['start_time'] = $this->input->post('start_time_hours'TRUE) . ':' $this->input->post('start_time_mins');
 
           $insert['end_time'] = $this->input->post('end_time_hours'TRUE) . ':' $this->input->post('end_time_mins');
 
           $insert['team_name_1'] = $this->input->post('team1') != '' $this->input->post('team1'TRUE) : NULL;
 
           $insert['team_name_2'] = $this->input->post('team2') != '' $this->input->post('team2'TRUE) : NULL;
 
           $insert['score_1'] = $this->input->post('score1') != '' $this->input->post('score1'TRUE) : NULL;
 
           $insert['score_2'] = $this->input->post('score2') != '' $this->input->post('score2'TRUE) : NULL;
 
           $insert['provisional'] = $this->input->post('provisional') ? 0;
 
           $insert['paid'] = $this->input->post('paid') ? 0;
 
           $insert['invoiced'] = $this->input->post('invoiced') ? 0;
 
           $insert['repeat'] = $this->input->post('repeats') != '' $this->input->post('repeats'TRUE) : NULL;
 
           $insert['repeat_every'] = $this->input->post('repeats_every') != '' $this->input->post('repeats_every'TRUE) : NULL;
 
           $insert['repeat_by'] = $this->input->post('repeat_by') != '' $this->input->post('repeat_by'TRUE) : NULL;
 
           $insert['repeat_ends'] = $this->input->post('repeat_ends') != '' $this->input->post('repeat_ends'TRUE) : NULL;
 
           $insert['repeat_ends_after'] = $this->input->post('repeat_ends_after_occurences') != '' $this->input->post('repeat_ends_after_occurences'TRUE) : NULL;
 
           $insert['repeat_ends_on'] = $this->input->post('repeat_ends_on_date') != '' date_to_unix($this->input->post('repeat_ends_on_date'TRUE)) : NULL;
 
           $insert['booking_date'] = date_to_unix($this->input->post('start_date'), TRUE);

 
           // if the logged in user is not an admin, force provisional to true
 
           if(!$this->is_admin) {
 
               $insert['provisional'] = 1;
 
           }

 
           $unix_startdate date_to_unix($this->input->post('start_date'), TRUE);

 
           if(!isset($booking_id)) {
 
               $booking_id NULL;
 
           }

 
           $details = array(
 
               'start_date' => $unix_startdate,
 
               'session_id' => $insert['session_id'],
 
               'sheet' => $insert['sheet']
 
           );
 
           //check for conflicts(duplicates) and throw error if appropriate
 
           $conflicts $this->bookings_model->check_for_conflicts($details$booking_id);
 
           if($conflicts 0) {
 
               $data['error'] = lang('book_duplicate_found');
 
           }
 
       }

 
       //if we have found no duplicates in the previous step
 
       if ($this->form_validation->run() == true && $data['error'] == '') {
 
           $repeat_ends $this->input->post('repeat_ends');
 
           $occurences $this->input->post('repeat_ends_after_occurences'TRUE);
 
           $repeats $this->input->post('repeats'TRUE);
 
           $repeats_every $this->input->post('repeats_every'TRUE);

 
           if($repeat_ends == 'after') {
 
               $repeat_end_date calculate_booking_end_after($unix_startdate$occurences$repeats$repeats_every);
 
               $insert['repeat_ends_time'] = $repeat_end_date;
 
           }
 
           elseif($repeat_ends == 'on') {
 
               $repeat_end_date calculate_booking_end_on($this->input->post('repeat_ends_on_date'));
 
               $insert['repeat_ends_time'] = $repeat_end_date;
 
           }

 
           switch($this->input->post('repeats')) {
 
               default:
 
               case '':
 
                   break;
 
               case 'yearly':
 
                   $insert['repeat_year'] = $this->input->post('repeat_ends') == 'never' '*' calculate_years_for_repeat(date('Y'$unix_startdate), $this->input->post('repeats_every'), date('Y'$repeat_end_date));
 
                   $insert['repeat_month'] = date('n'$unix_startdate);
 
                   $insert['repeat_week_im'] = week_of_month($insert['booking_date']);
 
                   $insert['repeat_day_im'] = date('j'$unix_startdate);
 
                   break;
 
               case 'monthly':
 
                   $insert['repeat_month_interval'] = $this->input->post('repeats_every'TRUE);

 
                   if($this->input->post('repeat_by') == 'week') {
 
                       $insert['repeat_week_im'] = week_of_month($insert['booking_date']);
 
                       $insert['repeat_weekday'] = date('N'$insert['booking_date']) . '|';
 
                   }
 
                   break;
 
               case 'weekly':
 
                   $insert['repeat_interval'] = 604800 * (int)$this->input->post('repeats_every'TRUE);
 
                   break;
 
               case 'daily':
 
                   $insert['repeat_interval'] = 86400 * (int)$this->input->post('repeats_every'TRUE);
 
                   break;
 
           }

 
           //if we are updating a pre-existing booking
 
           if($this->input->post('booking_id') != '') {
 
               $booking_id $this->input->post('booking_id');
 
               $message $this->bookings_model->edit($insert$booking_id);
 
           }
 
           else {
 
               $message $this->bookings_model->add($insert);

 
               if($message['type'] != 'error' && $insert['provisional'] == 1) {
 
                   $email_data = array(
 
                       'date' => $unix_startdate,
 
                       'start_time' => $insert['start_time'],
 
                       'end_time' => $insert['end_time'],
 
                       'user' => $this->ion_auth->user($insert['user_id'])->row()
 
                   );
 
                   $this->notify_admin($email_data);
 
               }
 
           }

 
           $uri 'Diary/index/' $data['year'] . '/' $data['month'] . '/' $data['day'];

 
           if($message['type'] == 'error') {
 
               $uri $this->uri->uri_string();
 
           }

 
           $this->session->set_flashdata($message['type'], $message['message']);
 
           redirect($uri'refresh');
 
       }
 
       else
        
{
 
           $start_date $this->form_validation->set_value('start_date'$data['date']);
 
           $session $this->form_validation->set_value('session_id'$data['session']);
 
           $sheet $this->form_validation->set_value('sheet'$data['sheet']);

 
           //the user is not logging in so display the login page
 
           //set the flash data error message if there is one
 
           $data['message'] .= $this->session->flashdata('message');
 
           $data['error'] .= validation_errors() . $this->session->flashdata('error');

 
           $data['title'] = array(
 
               'name' => 'title',
 
               'id' => 'title',
 
               'type' => 'text',
 
               'data-provide' => 'typeahead',
 
               'data-field' => 'title',
 
               'autocomplete' => 'off',
 
               'class' => 'typeahead',
 
               'value' => $this->form_validation->set_value('title'$booking->title)
 
           );
 
           $data['start_date'] = array(
 
               'name' => 'start_date',
 
               'id' => 'start_date',
 
               'type' => 'text',
 
               'value' => $start_date,
 
               'class' => 'datepicker'
 
           );
 
           $data['session'] = array(
 
               'name' => 'session_id[]',
 
               'attr' => 'id="session" size="6"',
 
               'options' => array(
 
                   '1' => '1',
 
                   '2' => '2',
 
                   '3' => '3',
 
                   '4' => '4',
 
                   '5' => '5',
 
                   '6' => '6'
 
               ),
 
               'value' => $session
            
);
 
           $data['sheet'] = array(
 
               'name' => 'sheet',
 
               'attr' => 'id="sheet"',
 
               'options' => array(
 
                   '' => 'Select a sheet',
 
                   'A' => 'A',
 
                   'B' => 'B',
 
                   'C' => 'C',
 
                   'D' => 'D',
 
                   'E' => 'E'
 
               ),
 
               'value' => $sheet
            
);

 
           $hours create_hour_array();
 
           $minutes create_minute_array();

 
           $data['start_time_hours'] = array(
 
               'name' => 'start_time_hours',
 
               'attr' => 'id="start_time_hours" class="span2"',
 
               'options' => $hours,
 
               'value' => $this->form_validation->set_value('start_time_hours'$data['start_time_hours'])
 
           );
 
           $data['start_time_mins'] = array(
 
               'name' => 'start_time_mins',
 
               'attr' => 'id="start_time_mins" class="span2"',
 
               'options' => $minutes,
 
               'value' => $this->form_validation->set_value('start_time_mins'$data['start_time_mins'])
 
           );

 
           $data['end_time_hours'] = array(
 
               'name' => 'end_time_hours',
 
               'attr' => 'id="end_time_hours" class="span2"',
 
               'options' => $hours,
 
               'value' => $this->form_validation->set_value('end_time_hours'$data['end_time_hours'])
 
           );
 
           $data['end_time_mins'] = array(
 
               'name' => 'end_time_mins',
 
               'attr' => 'id="end_time_mins" class="span2"',
 
               'options' => $minutes,
 
               'value' => $this->form_validation->set_value('end_time_mins'$data['end_time_mins'])
 
           );

 
           $data['team1'] = array(
 
               'name' => 'team1',
 
               'id' => 'team1',
 
               'type' => 'text',
 
               'data-provide' => 'typeahead',
 
               'data-field' => 'team_name',
 
               'autocomplete' => 'off',
 
               'class' => 'typeahead',
 
               'value' => $this->form_validation->set_value('team1'$booking->team_name_1)
 
           );
 
           $data['team2'] = array(
 
               'name' => 'team2',
 
               'id' => 'team2',
 
               'type' => 'text',
 
               'data-provide' => 'typeahead',
 
               'data-field' => 'team_name',
 
               'autocomplete' => 'off',
 
               'class' => 'typeahead',
 
               'value' => $this->form_validation->set_value('team2'$booking->team_name_2)
 
           );
 
           $data['score1'] = array(
 
               'name' => 'score1',
 
               'id' => 'score1',
 
               'type' => 'text',
 
               'value' => $this->form_validation->set_value('score1'$booking->score_1)
 
           );
 
           $data['score2'] = array(
 
               'name' => 'score2',
 
               'id' => 'score2',
 
               'type' => 'text',
 
               'value' => $this->form_validation->set_value('score2'$booking->score_2)
 
           );
 
           $provisional $this->form_validation->set_value('provisional'$booking->provisional);
 
           $data['provisional'] = array(
 
               'name' => 'provisional',
 
               'id' => 'provisional',
 
               'value' => '1',
 
               'checked' => !is_null($provisional) && $provisional != '' && $provisional == '1'
 
           );
 
           $paid $this->form_validation->set_value('paid'$booking->paid);
 
           $data['paid'] = array(
 
               'name' => 'paid',
 
               'id' => 'paid',
 
               'value' => '1',
 
               'checked' => !is_null($paid) && $paid != '' && $paid == '1'
 
           );
 
           $invoiced $this->form_validation->set_value('invoiced'$booking->invoiced);
 
           $data['invoiced'] = array(
 
               'name' => 'invoiced',
 
               'id' => 'invoiced',
 
               'value' => '1',
 
               'checked' => !is_null($invoiced) && $invoiced != '' && $invoiced == '1'
 
           );
 
           $data['repeats'] = array(
 
               'name' => 'repeats',
 
               'attr' => 'id="repeats"',
 
               'options' => array(
 
                   '' => 'Does not repeat',
 
                   'daily' => 'Daily',
 
                   'weekly' => 'Weekly',
 
                   'monthly' => 'Monthly',
 
                   'yearly' => 'Yearly',
 
               ),
 
               'value' => $this->form_validation->set_value('repeats'$booking->repeat)
 
           );
 
           $data['repeats_every'] = array(
 
               'name' => 'repeats_every',
 
               'attr' => 'id="repeats_every"',
 
               'options' => array(
 
                   '1' => '1',
 
                   '2' => '2',
 
                   '3' => '3',
 
                   '4' => '4',
 
                   '5' => '5',
 
                   '6' => '6',
 
                   '7' => '7',
 
                   '8' => '8',
 
                   '9' => '9',
 
                   '10' => '10',
 
                   '11' => '11',
 
                   '12' => '12'),
 
               'value' => $this->form_validation->set_value('repeats_every'explode('|'$booking->repeat_every))
 
           );
 
           $data['repeat_by_month'] = array(
 
               'name' => 'repeat_by',
 
               'id' => 'repeat_by_month',
 
               'value' => 'month',
 
               'checked' => $this->form_validation->set_value('repeat_by'$booking->repeat_by) == ''
 
                   || $this->form_validation->set_value('repeat_by'$booking->repeat_by) == 'month'
 
           );
 
           $data['repeat_by_week'] = array(
 
               'name' => 'repeat_by',
 
               'id' => 'repeat_by_week',
 
               'value' => 'week',
 
               'checked' => $this->form_validation->set_value('repeat_by'$booking->repeat_by) != ''
 
                   && $this->form_validation->set_value('repeat_by'$booking->repeat_by) == 'week'
 
           );

 
           $data['repeat_ends_never'] = array(
 
               'name' => 'repeat_ends',
 
               'id' => 'repeat_ends_never',
 
               'value' => 'never',
 
               'checked' => $this->form_validation->set_value('repeat_ends'$booking->repeat_ends) == ''
 
                   || $this->form_validation->set_value('repeat_ends'$booking->repeat_ends) == 'never'
 
           );
 
           $data['repeat_ends_on'] = array(
 
               'name' => 'repeat_ends',
 
               'id' => 'repeat_ends_on',
 
               'value' => 'on',
 
               'checked' => $this->form_validation->set_value('repeat_ends'$booking->repeat_ends) == 'on'
 
           );
 
           $repeat_ends_on_date $booking->repeat_ends_on != NULL date('d/m/Y'$booking->repeat_ends_on) : NULL;
 
           $data['repeat_ends_on_date'] = array(
 
               'name' => 'repeat_ends_on_date',
 
               'id' => 'repeat_ends_on_date',
 
               'type' => 'text',
 
               'value' => $this->form_validation->set_value('repeat_ends_on_date'$repeat_ends_on_date),
 
               'class' => 'datepicker input-small'
 
           );
 
           $data['repeat_ends_after'] = array(
 
               'name' => 'repeat_ends',
 
               'id' => 'repeat_ends_after',
 
               'value' => 'after',
 
               'checked' => $this->form_validation->set_value('repeat_ends'$booking->repeat_ends) == 'after'
 
           );
 
           $data['repeat_ends_after_occurences'] = array(
 
               'name' => 'repeat_ends_after_occurences',
 
               'id' => 'repeat_ends_after_occurences',
 
               'type' => 'text',
 
               'class' => 'input-small',
 
               'value' => $this->form_validation->set_value('repeat_ends_after_occurences'$booking->repeat_ends_after)
 
           );
 
           $data['booking_id'] = array(
 
               'booking_id' => $booking->id,
 
           );
 
           $data['save'] = array(
 
               'name' => 'save',
 
               'content' => lang('book_save_button'),
 
               'class' => 'btn btn-primary',
 
               'type' => 'submit'
 
           );
 
           $data['cancel'] = array(
 
               'name' => 'cancel',
 
               'content' => lang('book_cancel_button'),
 
               'class' => 'btn',
 
               'type' => 'submit'
 
           );
 
           $data['delete'] = array(
 
               'name' => 'delete',
 
               'content' => lang('book_delete_button'),
 
               'class' => 'btn btn-danger',
 
               'type' => 'submit'
 
           );

 
           $this->render_page('bookings/form'$data);
 
       }
 
   }

 
   public function approval()
 
   {
 
       if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin())
 
       {
 
           redirect('auth/login/' $this->uri->uri_string(), 'refresh');
 
       }

 
       if(isset($_POST['approve']) || isset($_POST['decline'])) {
 
           //if were posting back and cancel was clicked
 
           if(isset($_POST['approve'])) {
 
               $booking_id $this->input->post('approve'TRUE);
 
               $booking $this->bookings_model->get_booking($booking_id);

 
               $message $this->bookings_model->approve($booking_id);
 
               $method 'approve';
 
           }

 
           //if were posting back and cancel was clicked
 
           if(isset($_POST['decline'])) {
 
               $booking_id $this->input->post('decline'TRUE);
 
               $booking $this->bookings_model->get_booking($booking_id);
 
               $message $this->cancel($booking);
 
               $method 'decline';
 
           }

 
           if(is_null($booking_id) || $booking_id == '') {
 
               show_404();
 
           }

 
           if(!empty($booking)) {
 
               $this->load->library('Parser');
 
               $this->load->library('Email');

 
               $this->email->from(
 
                   $this->config->item('admin_email''ion_auth'),
 
                   $this->config->item('admin_name''ion_auth')
 
               );
 
               $this->email->to($booking->user->email);
 
               $this->email->subject(lang('booking_' $method '_email_subject'));

 
               $message $this->parser->parse_string(
 
                   lang('booking_' $method '_email_message'),
 
                   array(
 
                       'title' => $booking->title,
 
                       'date' => date('d/m/Y'$booking->start_date),
 
                       'time' => $booking->start_time
                    
),
 
                   TRUE
                
);

 
               $this->email->message($message);

 
               $this->email->send();
 
           }

 
           $this->session->set_flashdata($message['type'], $message['message']);

 
           redirect($this->uri->uri_string(), 'refresh');
 
       }

 
       //get unapproved bookings
 
       $data['bookings'] = $this->bookings_model->get_bookings_for_approval();
 
       $data['message'] = $this->session->flashdata('message');
 
       $data['error'] = $this->session->flashdata('error');

 
       $this->render_page('Bookings/approval'$data);
 
   }

 
   public function auto_complete()
 
   {
 
       $field $this->uri->segment(3true);
 
       $query $this->input->get('query');
 
       $available_fields = array('title''team_name');
 
       $double_fields = array('team_name');

 
       if($field == NULL || $field == '' || !in_array($field$available_fields)) {
 
           return array();
 
       }

 
       $data $this->bookings_model->get_auto_complete($field$queryin_array($field$double_fields));

 
       $this->output
            
->set_content_type('application/json')
 
           ->set_output(json_encode($data));
 
   }

 
   public function cancel($booking)
 
   {
 
       $message $this->bookings_model->delete($booking->id);

 
       if($message['type'] != 'error' && $booking->start_date time()) {
 
           $this->load->library('Parser');
 
           $this->load->library('Email');

 
           $users $this->ion_auth_model->get_mailing_list();

 
           foreach($users as $user) {
 
               $this->email->clear();
 
               $this->email->to($user->email);
 
               $this->email->from(
 
                   $this->config->item('admin_email''ion_auth'),
 
                   $this->config->item('admin_name''ion_auth')
 
               );
 
               $this->email->subject(lang('booking_cancellation_email_subject'));

 
               $email_message $this->parser->parse_string(
 
                   lang('booking_cancellation_email_message'),
 
                   array(
 
                       'first_name' => $user->first_name,
 
                       'date' => date('d/m/Y'$booking->start_date),
 
                       'start_time' => $booking->start_time,
 
                       'end_time' => $booking->end_time,
 
                       'unsubscribe' => site_url('auth/edit_user/' $user->id)
 
                   ),
 
                   TRUE
                
);

 
               $this->email->message($email_message);

 
               $this->email->send();
 
           }
 
       }

 
       return $message;
 
   }

 
   public function delete($booking_id)
 
   {
 
       if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin())
 
       {
 
           redirect('Auth/login/' $this->uri->uri_string(), 'refresh');
 
       }

 
       if(is_null($booking_id)) {
 
           show_404();
 
       }

 
       $booking $this->bookings_model->get_booking($booking_id);
 
       $message $this->cancel($booking);

 
       $this->session->set_flashdata($message['type'], $message['message']);

 
       redirect('/''refresh');
 
   }

 
   public function edit()
 
   {
 
       if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin())
 
       {
 
           redirect('auth/login/' $this->uri->uri_string(), 'refresh');
 
       }

 
       //send to booking function for shard code
 
       $this->add();
 
   }

 
   private  function notify_admin($booking)
 
   {
 
       if(!is_null($booking)) {
 
           $this->load->library('Parser');
 
           $this->load->library('Email');

 
           $admins $this->ion_auth_model->get_admin_users();

 
           $email_message $this->parser->parse_string(
 
               lang('booking_notify_admin_email_message'),
 
               array(
 
                   'user' => $booking['user']->first_name ' ' $booking['user']->last_name,
 
                   'date' => date('d/m/Y'$booking['date']),
 
                   'start_time' => $booking['start_time'],
 
                   'end_time' => $booking['end_time'],
 
                   'link' => site_url('bookings/approval')
 
               ),
 
               TRUE
            
);

 
           foreach($admins as $admin) {
 
               $this->email->clear();
 
               $this->email->to($admin->email);
 
               $this->email->from(
 
                   $this->config->item('admin_email''ion_auth'),
 
                   $this->config->item('admin_name''ion_auth')
 
               );
 
               $this->email->subject(lang('booking_notify_admin_email_subject'));
 
               $this->email->message($email_message);

 
               $this->email->send();
 
           }
 
       }

 
       return TRUE;
 
   }


Can someone tell me where i might be going wrong?
Many Thanks


  How to implement pagination on number and alphabet at the same time [CI3]
Posted by: pureexe - 08-08-2019, 04:55 AM - Forum: General Help - Replies (3)

Pagination on the number of pages but if i want to view data start with K, i click on 'K' and its jump to page 33 which is a page that starting with k letter. How to implement something like this? 

select all data to find the K starting point look waste of resource (because we need to find other 25 letter starting point too) any better way to implement this?

for example: *REDACTED*
[Image: jqTDttt.jpg]



  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.