public function testSetValues() { $form = new Form(); $date = $form->addDate('date'); $date->setType($date::TIMESTAMP); $date->setValue(new \DateTime()); $this->assertSame(time(), $date->getValue()); $date->setValue(time()); $this->assertSame(time(), $date->getValue()); }
public function echoClientEdit() { $id; $contact_id; $sex = 'm'; $first_name; $middle_name; $last_name; $suffix; $ssn; $dob; $aka; $dba; $success = true; if ($this->page_type == 'edit') { $sth = $this->db->prepare("SELECT `contact_id`,`contacts`.`name` AS 'last_name'," . "`first_name`,`middle_name`,`suffix`,`sex`,`ssn`,`aka`,`dba`, " . "DATE_FORMAT(`dob`, '%c-%e-%Y') AS 'dob_format' " . 'FROM `clients` ' . 'JOIN `contacts` ON `clients`.`contact_id`=`contacts`.`id` ' . 'WHERE `clients`.`id`=?'); $sth->execute(array($this->id)); if ($row = $sth->fetch()) { $id = $this->id; $contact_id = $row['contact_id']; $first_name = $row['first_name']; $middle_name = $row['middle_name']; $last_name = $row['last_name']; $suffix = $row['suffix']; $sex = $row['sex'] ? $row['sex'] : 'none'; $ssn = $row['ssn']; $dob = $row['dob_format']; $aka = $row['aka']; $dba = $row['dba']; } else { $success = false; } } if ($success) { $form = new Form('client'); $form->addHeading('Name'); $form->addSelect('', 'sex', array('m' => 'Male', 'f' => 'Female', 'none' => 'None'), $sex); $form->addText('First name:', 'first_name', false, $first_name); $form->addText('Middle:', 'middle_name', false, $middle_name); $form->addText('Last (or biz name):', 'name', true, $last_name); $form->addText('Suffix (Jr/Sr/etc):', 'suffix', false, $suffix); $form->addHeading('Info'); $form->addDate('Date of birth:', 'dob', false, true, $dob); $form->addText('SSN (no dashes):', 'ssn', false, $ssn, 'minlength="9" maxlength="9" digits="true"'); $form->addText('AKA:', 'aka', false, $aka); $form->addText('DBA:', 'dba', false, $dba); $form->addHidden('id', $id); $form->addHidden('contact_id', $contact_id); if ($this->admin && $this->page_type == 'edit') { $form->addDelete(); } $form->echoForm(); } }
protected function createComponentForm() { $form = new \Form(); $form->addDate('date')->setType(Date::TIMESTAMP); return $form; }
public function echoNoteEdit() { $success = true; $today = new DateTime(); $date = $today->format('n-j-Y'); $body; if ($this->page_type != 'new') { $sth = $this->db->prepare("SELECT `body`, " . "DATE_FORMAT(`date`, '%c-%e-%Y') AS 'date_format' " . 'FROM `notes` WHERE `id`=?'); $sth->execute(array($this->id)); if ($row = $sth->fetch()) { $id = $this->id; $body = $row['body']; $date = $row['date_format']; } else { $success = false; } } if ($success) { $form = new Form('note'); // cant directly comment out below regex if (false) { if ($this->platform == 'and') { $nl = preg_replace('#<br\\s*/?>#i', "\r\n", $body); $form->addTextArea('', 'bodysource', true, $nl); } else { $form->addTextArea('', 'body', true, $body); } } // end comment out $form->addTextArea('', 'body', true, $body); $form->addDate('Date:', 'date', true, true, $date); if ($this->page_type == 'edit' && ($this->admin || $this->emp_id == $this->folder_emp_id || $this->office_admin && $this->folder_office_id == $this->office_id)) { $move_arr = $this->moveFolderArr($this->parent_folder_id); if (count($move_arr) > 1) { //$form->addHeading('Move'); $form->addSelect('Move to:', 'move', $move_arr); } $form->addDelete(); } $form->addHidden('id', $id); $form->addHidden('folder_id', $this->parent_folder_id); $form->echoForm(); // add link popup echo '<div data-role="popup" id="link-popup" class="ui-content">' . '<form>' . '<h4>Create link</h4>' . '<label for="link-url">URL</label>' . '<input name="link-url" id="link-url" type="text">' . '<button id="link-ok">OK</button>' . '</form>' . '</div>'; } }