phpScheduleIt
June 19, 2013, 03:19:59 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: phpScheduleIt 2.4.2 has been released!
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Add a field to DB and UI  (Read 337 times)
intelek
Newbie
*

Karma: 0
Posts: 18


« on: April 15, 2012, 12:49:34 PM »

Hello there

First of all, thanks for this brilliant piece of code.

I'm trying to add a new field to establish a cancel time by group of users. I took a look at http://php.brickhost.com/forums/index.php?topic=11112.0, but it is no the same problem.
I added the field to DB, and got it appearing in the admin page, but i cannot get the dialog form to change the value of the field. I tried copying the one named "renameDialog" in manage_groups.tpl, and adding proper code for Commands.php and DataConstant.php, but I'm loosing something, for sure.

manage_groups.tpl
Code:
<div id="cancelTimeDialog" class="dialog" style="display:none;" title="{translate key=CancelHours}">
<form id="cancelTimeForm" method="post">
<label>{translate key=Hours}<br/> <input type="text" class="textbox required" {formname key=CANCEL_TIME} /></label>
<button type="button" class="button save">{html_image src="disk-black.png"} {translate key=Change}</button>
<button type="button" class="button cancel">{html_image src="slash.png"} {translate key=Cancel}</button>
</form>
</div>

Commands.php
Code:
class UpdateCancelTime extends SqlCommand
{
        public function __construct($groupId, $cancelTime)
        {
                parent::__construct(Queries::UPDATE_CANCEL_TIME);
$this->AddParameter(new Parameter(ParameterNames::GROUP_ID, $groupId));
                $this->AddParameter(new Parameter(ParameterNames::CANCEL_TIME, $cancelTime));
        }
}

DataConstant.php
Code:
const UPDATE_CANCEL_TIME =
            'UPDATE groups
                SET autocancel_time = @canceltime
                WHERE group_id = @groupid';

Anyone can help, please?
Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5506


WWW
« Reply #1 on: April 16, 2012, 01:22:29 PM »

Right now this is a little more complicated than it should be.

If you want to use the fancy-dancy popup and asynchronous save, you'll need to do some additional mapping.

You'll need to add an action and method map to ManageGroupsPresenter.php. You'll also need to add this action to the javascript near the bottom of the manage_groups.tpl. Finally, you'll need to add a bit of javascript to wire up the dialog and form in Web/scripts/admin/groups.js

2.2 will bring the ability to add custom attributes to most tables, but this sounds pretty custom. I'll work on making this easier going forward.
Logged
intelek
Newbie
*

Karma: 0
Posts: 18


« Reply #2 on: April 18, 2012, 05:02:08 AM »

Thank you Nick, I'll work on it.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2006-2007, Simple Machines Valid XHTML 1.0! Valid CSS!