Sunday, 25 June 2017

46.social engine edit and insert in 1 function

public function tipdurationAction()
    {
      $common_settings_table =  Engine_Api::_()->getDbtable('commonsettings', 'user');
 $common_settings = $common_settings_table->fetchRow($common_settings_table->select()->where('type =?', 'tip_duration'));
 

     $this->view->form = $form = new User_Form_Admin_Manage_Tipduration();
     $aData =  $this->_request->getPost();
 if(!empty($aData)){
   $tip_duration = $aData['value'];
   if(empty($common_settings)){


       if($tip_duration!='')
           {
            $tips_table_insert_id =  $common_settings_table->insert(array(
                    'type'   => 'tip_duration',                  
                    'value' => $tip_duration,
                    'created_at'=> date("Y-m-d"),
                    'updated_at'=> date("Y-m-d"),
                ));
             
}

}
else
{
   $common_settings->value=$tip_duration;
   $common_settings->save();
}
        return $this->_forward('success', 'utility', 'core', array(
      'smoothboxClose' => true,
      'parentRefresh' => true,
      'format'=> 'smoothbox',
      'messages' => array('Your changes have been saved.')
          ));
    }
    }

No comments:

Post a Comment