Welcome Guest, Not a member yet? Register   Sign In
Problems with a model
#9

[eluser]Mat-Moo[/eluser]
Code:
function add($aid)
    //  special function to allow a non user to add a reminder to 4rd party based on request id
    {
        
        $this->load->model('reminders_model');

        $aidinfo=$this->reminders_model->get_date_request($aid);
        if ($aidinfo===FALSE) redirect ('');  // does not exist so go to front page
            
        $data["remindertype"]=$this->reminders_model->get_reminder_type($aidinfo->Type); // load the reminder type data

        $this->form_validation->set_rules('fmonth', 'Month', 'required');
        $this->form_validation->set_rules('fyear', 'Year', 'required');
        $this->form_validation->set_rules('fday', 'Day', 'required|callback_check_remind_date');

        $validated = $this->form_validation->run();
        
        if ($validated)
        {
            log_message('debug', '*** 3rd party! add_remindertype '.$aid.' which has been validated');

            $this->session->set_flashdata('user', $aidinfo->ForUserID);
            $this->load->model('groups_model');

            $event=array(
                'firsteventdate'=>set_value("fyear")."-".set_value("fmonth")."-".set_value("fday"),
                'groupid'=>'0'
            );
            $reminder=array(
                'days1'=>14,
                'days2'=>3,
                'name'=>$aidinfo->Name,
                'relationship'=>0,
                'notes'=>'TEST'
            );
            
            $this->reminders_model->add_reminder($data["remindertype"],$event,$reminder); // snd data to model for update
This is the routine I'm working on, and the groups_model (separate file to the reminders_model) is loaded only after the validation has taken place.

The add_reminder saves an event to the table, then an update is called to put correct reminder dates in, lastly reminds are created for everyone attached to that group of reminders. This all takes place in the reminders_model till :-
Code:
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    function add_reminders_for_event($eventid,$eventdate,$firstreminddays,$secondreminddays,$remindforname,$remindforrelid,$notes,$groupid)
    // doesn't matter if we are adding a new, or updating an old
    // rather than checking finding and updating reminders
    // simply delete any attached to this event, and add new ones
    // event date should be the next date for this event and should also be a class
    {
        log_message('debug', '*** add_reminders_for_event '.$eventid);
        
        // get users to create reminders for
        $users=$this->groups_model->get_group_users($groupid);

It dies there at getting data from the groups model.


Messages In This Thread
Problems with a model - by El Forum - 01-09-2009, 07:44 AM
Problems with a model - by El Forum - 01-09-2009, 08:21 AM
Problems with a model - by El Forum - 01-09-2009, 08:33 AM
Problems with a model - by El Forum - 01-09-2009, 01:03 PM
Problems with a model - by El Forum - 01-09-2009, 01:08 PM
Problems with a model - by El Forum - 01-09-2009, 01:44 PM
Problems with a model - by El Forum - 01-09-2009, 02:03 PM
Problems with a model - by El Forum - 01-09-2009, 02:08 PM
Problems with a model - by El Forum - 01-09-2009, 02:10 PM
Problems with a model - by El Forum - 01-09-2009, 02:22 PM
Problems with a model - by El Forum - 01-09-2009, 02:30 PM



Theme © iAndrew 2016 - Forum software by © MyBB