import('form.FormElement');
class Checkbox extends FormElement {
- var $checked = false;
- var $mOptions = null;
function __construct($name) {
$this->class = 'Checkbox';
$this->name = $name;
}
- function setChecked($value) { $this->checked = $value; }
- function isChecked() { return $this->checked; }
-
- function setData($value) { $this->mOptions = $value; }
- function getData() { return $this->mOptions; }
-
function getHtml() {
if ($this->id == '') $this->id = $this->name;
$html = "\n\t<input type=\"checkbox\"";
$html.= " id=\"$this->id\" name=\"$this->name\"";
- if ($this->checked || (($this->value == $this->mOptions) && ($this->value != null)))
+ if ($this->value)
$html.= " checked=\"true\"";
if ($this->on_change!="")
if (!$this->isEnabled())
$html .= " disabled=\"disabled\"";
-
- $html .= " value=\"".htmlspecialchars($this->mOptions)."\"";
+
+ // Provide a value so that we pass "1" for set checkboxes on form submit.
+ // Otherwise the default is "on" string, which is not what we want.
+ $html .= " value=\"1\"";
$html .= "/>\n";
case 'checkbox':
import('form.Checkbox');
$el = new Checkbox($params['name']);
- if (isset($params['checked'])) $el->setChecked($params['checked']);
+ break;
// TODO: refactoring ongoing down from here.
- $el->setData(@$params["data"]);
- break;
-
case "checkboxgroup":
import('form.CheckboxGroup');
$el = new CheckboxGroup($params["name"]);
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.10.38.3620 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.10.38.3621 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
<a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
<a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
<a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
'data'=>array(CustomFields::TYPE_TEXT=>$i18n->getKey('label.type_text'),
CustomFields::TYPE_DROPDOWN=>$i18n->getKey('label.type_dropdown'))
));
-$form->addInput(array('type'=>'checkbox','name'=>'required','data'=>1,'value'=>'0'));
+$form->addInput(array('type'=>'checkbox','name'=>'required'));
$form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->getKey('button.add')));
if ($request->isPost()) {
if ($err->no()) {
$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'name','value'=>$field['label']));
$form->addInput(array('type'=>'hidden','name'=>'id','value'=>$cl_id));
- $form->addInput(array('type'=>'checkbox','name'=>'required','data'=>1,'value'=>$field['required']));
+ $form->addInput(array('type'=>'checkbox','name'=>'required','value'=>$field['required']));
$form->addInput(array('type'=>'combobox','name'=>'type','value'=>$field['type'],
'data'=>array(CustomFields::TYPE_TEXT=>$i18n->getKey('label.type_text'),
CustomFields::TYPE_DROPDOWN=>$i18n->getKey('label.type_dropdown'))));
$form->addInput(array('type'=>'text','name'=>'duration','value'=>$cl_duration,'onchange'=>"formDisable('duration');"));
$form->addInput(array('type'=>'textarea','name'=>'note','style'=>'width: 250px; height: 60px;','value'=>$cl_note));
if ($user->isPluginEnabled('iv'))
- $form->addInput(array('type'=>'checkbox','name'=>'billable','data'=>1,'value'=>$cl_billable));
+ $form->addInput(array('type'=>'checkbox','name'=>'billable','value'=>$cl_billable));
$form->addInput(array('type'=>'hidden','name'=>'browser_today','value'=>'')); // User current date, which gets filled in on btn_submit click.
$form->addInput(array('type'=>'submit','name'=>'btn_submit','onclick'=>'browser_today.value=get_date()','value'=>$i18n->getKey('button.submit')));
// Hidden control for record id.
$form->addInput(array('type'=>'hidden','name'=>'id','value'=>$cl_id));
if ($user->isPluginEnabled('iv'))
- $form->addInput(array('type'=>'checkbox','name'=>'billable','data'=>1,'value'=>$cl_billable));
+ $form->addInput(array('type'=>'checkbox','name'=>'billable','value'=>$cl_billable));
$form->addInput(array('type'=>'hidden','name'=>'browser_today','value'=>'')); // User current date, which gets filled in on btn_save click.
$form->addInput(array('type'=>'submit','name'=>'btn_save','onclick'=>'browser_today.value=get_date()','value'=>$i18n->getKey('button.save')));
$form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->getKey('label.delete')));
'empty'=>array(''=>$i18n->getKey('dropdown.select'))));
}
if ($user->isPluginEnabled('iv'))
- $form->addInput(array('type'=>'checkbox','name'=>'billable','data'=>1,'value'=>$cl_billable,'enable'=>$enable_controls));
+ $form->addInput(array('type'=>'checkbox','name'=>'billable','value'=>$cl_billable,'enable'=>$enable_controls));
$form->addInput(array('type'=>'hidden','name'=>'browser_today','value'=>'')); // User current date, which gets filled in on button click.
$form->addInput(array('type'=>'hidden','name'=>'browser_time','value'=>'')); // User current time, which gets filled in on button click.
$enable_start = $uncompleted ? false : true;
$uncompleted_indicators_options[UNCOMPLETED_INDICATORS] = $i18n->getKey('form.profile.uncompleted_indicators_show');
$form->addInput(array('type'=>'combobox','name'=>'uncompleted_indicators','style'=>'width: 150px;','data'=>$uncompleted_indicators_options,'value'=>$cl_uncompleted_indicators));
- $form->addInput(array('type'=>'checkbox','name'=>'charts','data'=>1,'value'=>$cl_charts));
- $form->addInput(array('type'=>'checkbox','name'=>'clients','data'=>1,'value'=>$cl_clients,'onchange'=>'handlePluginCheckboxes()'));
- $form->addInput(array('type'=>'checkbox','name'=>'client_required','data'=>1,'value'=>$cl_client_required));
+ $form->addInput(array('type'=>'checkbox','name'=>'charts','value'=>$cl_charts));
+ $form->addInput(array('type'=>'checkbox','name'=>'clients','value'=>$cl_clients,'onchange'=>'handlePluginCheckboxes()'));
+ $form->addInput(array('type'=>'checkbox','name'=>'client_required','value'=>$cl_client_required));
- $form->addInput(array('type'=>'checkbox','name'=>'invoices','data'=>1,'value'=>$cl_invoices));
- $form->addInput(array('type'=>'checkbox','name'=>'custom_fields','data'=>1,'value'=>$cl_custom_fields,'onchange'=>'handlePluginCheckboxes()'));
- $form->addInput(array('type'=>'checkbox','name'=>'expenses','data'=>1,'value'=>$cl_expenses,'onchange'=>'handlePluginCheckboxes()'));
- $form->addInput(array('type'=>'checkbox','name'=>'tax_expenses','data'=>1,'value'=>$cl_tax_expenses));
- $form->addInput(array('type'=>'checkbox','name'=>'notifications','data'=>1,'value'=>$cl_notifications,'onchange'=>'handlePluginCheckboxes()'));
- $form->addInput(array('type'=>'checkbox','name'=>'locking','data'=>1,'value'=>$cl_locking,'onchange'=>'handlePluginCheckboxes()'));
- $form->addInput(array('type'=>'checkbox','name'=>'quotas','data'=>1,'value'=>$cl_quotas,'onchange'=>'handlePluginCheckboxes()'));
+ $form->addInput(array('type'=>'checkbox','name'=>'invoices','value'=>$cl_invoices));
+ $form->addInput(array('type'=>'checkbox','name'=>'custom_fields','value'=>$cl_custom_fields,'onchange'=>'handlePluginCheckboxes()'));
+ $form->addInput(array('type'=>'checkbox','name'=>'expenses','value'=>$cl_expenses,'onchange'=>'handlePluginCheckboxes()'));
+ $form->addInput(array('type'=>'checkbox','name'=>'tax_expenses','value'=>$cl_tax_expenses));
+ $form->addInput(array('type'=>'checkbox','name'=>'notifications','value'=>$cl_notifications,'onchange'=>'handlePluginCheckboxes()'));
+ $form->addInput(array('type'=>'checkbox','name'=>'locking','value'=>$cl_locking,'onchange'=>'handlePluginCheckboxes()'));
+ $form->addInput(array('type'=>'checkbox','name'=>'quotas','value'=>$cl_quotas,'onchange'=>'handlePluginCheckboxes()'));
}
$form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->getKey('button.save')));
// Add checkboxes for fields.
if ($user->isPluginEnabled('cl'))
- $form->addInput(array('type'=>'checkbox','name'=>'chclient','data'=>1));
+ $form->addInput(array('type'=>'checkbox','name'=>'chclient'));
if (($user->canManageTeam() || $user->isClient()) && $user->isPluginEnabled('iv'))
- $form->addInput(array('type'=>'checkbox','name'=>'chinvoice','data'=>1));
+ $form->addInput(array('type'=>'checkbox','name'=>'chinvoice'));
if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode)
- $form->addInput(array('type'=>'checkbox','name'=>'chproject','data'=>1));
+ $form->addInput(array('type'=>'checkbox','name'=>'chproject'));
if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode)
- $form->addInput(array('type'=>'checkbox','name'=>'chtask','data'=>1));
+ $form->addInput(array('type'=>'checkbox','name'=>'chtask'));
if ((TYPE_START_FINISH == $user->record_type) || (TYPE_ALL == $user->record_type)) {
- $form->addInput(array('type'=>'checkbox','name'=>'chstart','data'=>1));
- $form->addInput(array('type'=>'checkbox','name'=>'chfinish','data'=>1));
+ $form->addInput(array('type'=>'checkbox','name'=>'chstart'));
+ $form->addInput(array('type'=>'checkbox','name'=>'chfinish'));
}
-$form->addInput(array('type'=>'checkbox','name'=>'chduration','data'=>1));
-$form->addInput(array('type'=>'checkbox','name'=>'chnote','checked'=>true, 'data'=>1));
+$form->addInput(array('type'=>'checkbox','name'=>'chduration'));
+$form->addInput(array('type'=>'checkbox','name'=>'chnote'));
if (defined('COST_ON_REPORTS') && isTrue(COST_ON_REPORTS))
- $form->addInput(array('type'=>'checkbox','name'=>'chcost','data'=>1));
+ $form->addInput(array('type'=>'checkbox','name'=>'chcost'));
// If we have a custom field - add a checkbox for it.
if ($custom_fields && $custom_fields->fields[0])
- $form->addInput(array('type'=>'checkbox','name'=>'chcf_1','data'=>1));
+ $form->addInput(array('type'=>'checkbox','name'=>'chcf_1'));
// Add group by control.
$group_by_options['no_grouping'] = $i18n->getKey('form.reports.group_by_no');
$group_by_options['cf_1'] = $custom_fields->fields[0]['label'];
}
$form->addInput(array('type'=>'combobox','onchange'=>'handleCheckboxes();','name'=>'group_by','data'=>$group_by_options));
-$form->addInput(array('type'=>'checkbox','name'=>'chtotalsonly','data'=>1));
+$form->addInput(array('type'=>'checkbox','name'=>'chtotalsonly'));
// Add text field for a new favorite report name.
$form->addInput(array('type'=>'text','name'=>'new_fav_report','maxlength'=>'30','style'=>'width: 250px;'));
$period = new Period(INTERVAL_THIS_MONTH, new DateAndTime($user->date_format));
$form->setValueByElement('start_date', $period->getBeginDate());
$form->setValueByElement('end_date', $period->getEndDate());
- $form->setValueByElement('chclient', 1);
- $form->setValueByElement('chinvoice', 0);
- $form->setValueByElement('chproject', 1);
- $form->setValueByElement('chstart', 1);
- $form->setValueByElement('chduration', 1);
- $form->setValueByElement('chcost', 0);
- $form->setValueByElement('chtask', 1);
- $form->setValueByElement('chfinish', 1);
- $form->setValueByElement('chnote', 1);
- $form->setValueByElement('chcf_1', 0);
- $form->setValueByElement('chtotalsonly', 0);
+ $form->setValueByElement('chclient', '1');
+ $form->setValueByElement('chinvoice', '0');
+ $form->setValueByElement('chproject', '1');
+ $form->setValueByElement('chstart', '1');
+ $form->setValueByElement('chduration', '1');
+ $form->setValueByElement('chcost', '0');
+ $form->setValueByElement('chtask', '1');
+ $form->setValueByElement('chfinish', '1');
+ $form->setValueByElement('chnote', '1');
+ $form->setValueByElement('chcf_1', '0');
+ $form->setValueByElement('chtotalsonly', '0');
}
$form->setValueByElement('fav_report_changed','');
$form->addInput(array('type'=>'textarea','name'=>'note','style'=>'width: 600px; height:'.NOTE_INPUT_HEIGHT.'px;','value'=>$cl_note));
$form->addInput(array('type'=>'calendar','name'=>'date','value'=>$cl_date)); // calendar
if ($user->isPluginEnabled('iv'))
- $form->addInput(array('type'=>'checkbox','name'=>'billable','data'=>1,'value'=>$cl_billable));
+ $form->addInput(array('type'=>'checkbox','name'=>'billable','value'=>$cl_billable));
$form->addInput(array('type'=>'hidden','name'=>'browser_today','value'=>'')); // User current date, which gets filled in on btn_submit click.
$form->addInput(array('type'=>'submit','name'=>'btn_submit','onclick'=>'browser_today.value=get_date()','value'=>$i18n->getKey('button.submit')));
// Hidden control for record id.
$form->addInput(array('type'=>'hidden','name'=>'id','value'=>$cl_id));
if ($user->isPluginEnabled('iv'))
- $form->addInput(array('type'=>'checkbox','name'=>'billable','data'=>1,'value'=>$cl_billable));
+ $form->addInput(array('type'=>'checkbox','name'=>'billable','value'=>$cl_billable));
$form->addInput(array('type'=>'hidden','name'=>'browser_today','value'=>'')); // User current date, which gets filled in on btn_save or btn_copy click.
$form->addInput(array('type'=>'submit','name'=>'btn_save','onclick'=>'browser_today.value=get_date()','value'=>$i18n->getKey('button.save')));
$form->addInput(array('type'=>'submit','name'=>'btn_copy','onclick'=>'browser_today.value=get_date()','value'=>$i18n->getKey('button.copy')));