Jump to content


mcl

Member Since 19 Sep 2013
Offline Last Active Private
-----

Topics I've Started

callback_after_update + condition + $post_array

30 September 2013 - 10:25 PM

Hello,

 

I have a problem evaluating a condition. I have if((empty($post_array['Date_Deb'])) && ($post_array['Etat'] == '3')) as condition and Date_Deb is being updated even if Date_Deb is NOT empty.

The second part of the condition is evaluated correctly. If Etat is not equal to 3, Date_Deb is not updated.

You can see my code below.

Note that Date_Deb is set as a read only field but removing that constraint don't change anything. It seems GC is seeing $post_array['Date_Deb'] on update even if it had been previously filled in using the function.

 

Can you tell me what is wrong please?

function st3() {
                  $crud = new grocery_CRUD();
            $crud->set_table('t3');
            $crud->columns('ID','Nom_agt','Date_Rem','Date_Deb', 'Etat');
            $crud->set_subject('T3');
            $crud->set_relation('Etat','etat_debriefe','etat');
            $crud->set_relation('Nom_agt','agents','agt');
            $crud->fields('Nom_agt','Date_Rem','Date_Deb', 'Etat');
            $crud->edit_fields('Nom_agt','Date_Deb', 'Etat');
           $crud->field_type('Date_Deb', 'readonly');
            $crud->callback_after_update(array($this, 'update_date_debriefe'));
            $output = $crud->render();
            $this->_example_output($output);
    }    
function update_date_debriefe($post_array,$primary_key)
{
if((empty($post_array['Date_Deb'])) && ($post_array['Etat'] == '3'))  {
    $date_debriefe = array("ID" => $primary_key,"Date_Deb" => date('2013-07-01'));
    $this->db->update('t3',$date_debriefe,array('ID' => $primary_key));
   return true;
   }
}

Change row color based on value

20 September 2013 - 11:47 PM

Hello all,

 

New to grocery CRUD and i wish to do some color rendering.

I have a column which contain a date and i need the text or background to be in red if 72 hours have passed. I have done some search on google and on this forum but haven't found anything clear enough for me to understand.

I think i may need to use callback but no clue how to change color with it.

Can someone explan it to me or give some hints?

 

Newbie programmer, bear with me please :)

Your help is greatly appreciated on this issue.