Example #1
0
 public function actionUserChange($akce = 0, $id = -1)
 {
     $this->access($id);
     //kvůli Nette - action je vyhrazeno
     $action = $akce;
     $this->verifyUser();
     $this->form = new AppForm($this, 'userChange');
     //TODO: Definovat zprávu
     //$this->form->addProtection($this->formProtectedMessage);
     $msg = 'Heslo musí obsahovat VELKÁ a malá písmena a číslice!';
     $this->form->addGroup('Přihlašovací informace');
     $this->form->addText('userName', 'Uživatelské jméno:')->addRule(Form::FILLED, 'Uživatelské jméno musí být vyplněno.')->addRule(Form::MIN_LENGTH, 'Uživatelské jméno musí mít alespoň %d znaky.', 4)->addRule(Form::MAX_LENGTH, 'Uživatelské jméno může mít nejvýše %d znaků.', 20);
     if ($action > 0) {
         $this->form['userName']->setDisabled(true);
     }
     if ($action != 1) {
         $this->form->addPassword('password1', 'Heslo:')->addRule(Form::FILLED, 'Heslo musí být vyplněno.')->addRule(Form::MIN_LENGTH, 'Heslo musí mít alespoň %d znaků.', 8)->addRule(Form::MAX_LENGTH, 'Heslo může mít nejvýše %d znaků', 50)->addRule(Form::REGEXP, $msg, '/[A-Z]+/')->addRule(Form::REGEXP, $msg, '/[a-z]+/')->addRule(Form::REGEXP, $msg, '/[0-9]+/');
         $this->form->addPassword('password2', 'Přístupové heslo (pro kontrolu):')->addRule(Form::EQUAL, 'Zadaná hesla se neshodují.', $this->form['password1']);
         $this->form->addText('navrhHesla', 'Navrhované heslo:');
     }
     if ($action < 2) {
         $this->form->addGroup('Osobní informace');
         $this->form->addText('firstName', 'Jméno:')->addRule(Form::FILLED, 'Jméno musí být vyplněno.');
         $this->form->addText('surname', 'Přijmení:')->addRule(Form::FILLED, 'Přijmení musí být vyplněno.');
         $this->form->addText('title', 'Titul:')->addRule(Form::MAX_LENGTH, 'Titul může mít nejvýše %d znaků.', 10);
         $this->form->addGroup('Kontaktní informace');
         $this->form->addText('email', 'E-mail:')->addRule(Form::FILLED, 'E-mail musí být vyplněn.')->addRule(Form::EMAIL, 'Zadaný e-mail není platný.');
         $this->form->addText('icq', 'ICQ:')->addCondition(Form::FILLED)->addRule(Form::NUMERIC, 'ICQ musí být číslo.')->addRule(Form::MAX_LENGTH, 'ICQ může mít nejvýše %d znaků.', 10);
         $this->form->addText('skype', 'Skype:')->addRule(Form::MAX_LENGTH, 'Skype může mát nejvýše %d znaků.', 50);
         $this->form->addText('mobile', 'Mobilní telefon:')->addCondition(Form::FILLED)->addRule(Form::NUMERIC, 'Mobilní telefon musí být číslo.')->addRule(Form::MAX_LENGTH, 'Mobilní telefon může mít nejvýše %d znaků.', 20);
         $roles = UsersModel::getRoles();
         // Zobrazujeme pouze tehdy je-li uživatel administrátor - aby si uživatel sám nemohl měnit skupinu
         if ($this->user->isInRole('Administrator')) {
             $this->form->addGroup('Přístupová práva (může být vybráno více skupin)');
             $this->form->addMultiSelect('prava', 'Přístupová práva:', $roles, 2);
         }
     }
     $this->form->onSubmit[] = array($this, 'UserFormSubmitted');
     $this->form->addHidden('action')->setValue($action);
     if ($action > 0) {
         $data = UsersModel::getUser($id);
         $data['navrhHesla'] = UsersModel::genPass();
         // Nastavíme výchozí hodnoty pro formulář
         $this->form->setDefaults($data);
         $this->form->addHidden('id')->setValue($id);
         $this->form->addSubmit('ok', 'Aktualizovat');
         //            ->onClick[] = array($this, 'OkClicked'); // nebo 'OkClickHandler'
     } else {
         $data['navrhHesla'] = UsersModel::genPass();
         // Nastavíme výchozí hodnoty pro formulář
         $this->form->setDefaults($data);
         $this->form->addSubmit('ok', 'Vytvořit');
         //            ->onClick[] = array($this, 'OkClicked'); // nebo 'OkClickHandler'
     }
     $this->template->form = $this->form;
 }
Example #2
0
 public function actionAddReply($id, $internal)
 {
     $this->form = new AppForm($this, 'sendReply');
     $this->form->addHidden('tiket', $id);
     $this->form->addHidden('internal', $internal);
     $this->form->addTextArea('message', 'Odpověď/komentář:', 10);
     $this->form->addSubmit('send', 'Odeslat');
     $this->form->onSubmit[] = array($this, 'ReplyFormProcess');
     $this->template->form = $this->form;
 }
Example #3
0
 private function exampleForm()
 {
     $countries = array('Select your country', 'Europe' => array('CZ' => 'Czech Republic', 'FR' => 'France', 'DE' => 'Germany', 'GR' => 'Greece', 'HU' => 'Hungary', 'IE' => 'Ireland', 'IT' => 'Italy', 'NL' => 'Netherlands', 'PL' => 'Poland', 'SK' => 'Slovakia', 'ES' => 'Spain', 'CH' => 'Switzerland', 'UA' => 'Ukraine', 'GB' => 'United Kingdom'), 'AU' => 'Australia', 'CA' => 'Canada', 'EG' => 'Egypt', 'JP' => 'Japan', 'US' => 'United States', '?' => 'other');
     $sex = array('m' => 'male', 'f' => 'female');
     // Step 1: Define form with validation rules
     $form = new Form();
     // group Personal data
     $form->addGroup('Personal data')->setOption('description', 'We value your privacy and we ensure that the information you give to us will not be shared to other entities.');
     $form->addText('name', 'Your name:', 35)->addRule(Form::FILLED, 'Enter your name');
     $form->addText('age', 'Your age:', 5)->addRule(Form::FILLED, 'Enter your age')->addRule(Form::INTEGER, 'Age must be numeric value')->addRule(Form::RANGE, 'Age must be in range from %.2f to %.2f', array(9.9, 100));
     $form->addRadioList('gender', 'Your gender:', $sex);
     $form->addText('email', 'E-mail:', 35)->setEmptyValue('@')->addCondition(Form::FILLED)->addRule(Form::EMAIL, 'Incorrect E-mail Address');
     // ... then check email
     // group Shipping address
     $form->addGroup('Shipping address')->setOption('embedNext', TRUE);
     $form->addCheckbox('send', 'Ship to address')->addCondition(Form::EQUAL, TRUE)->toggle('sendBox');
     // toggle div #sendBox
     // subgroup
     $form->addGroup()->setOption('container', Html::el('div')->id('sendBox'));
     $form->addText('street', 'Street:', 35);
     $form->addText('city', 'City:', 35)->addConditionOn($form['send'], Form::EQUAL, TRUE)->addRule(Form::FILLED, 'Enter your shipping address');
     $form->addSelect('country', 'Country:', $countries)->skipFirst()->addConditionOn($form['send'], Form::EQUAL, TRUE)->addRule(Form::FILLED, 'Select your country');
     // group Your account
     $form->addGroup('Your account');
     $form->addPassword('password', 'Choose password:'******'Choose your password')->addRule(Form::MIN_LENGTH, 'The password is too short: it must be at least %d characters', 3);
     $form->addPassword('password2', 'Reenter password:'******'password'], Form::VALID)->addRule(Form::FILLED, 'Reenter your password')->addRule(Form::EQUAL, 'Passwords do not match', $form['password']);
     $form->addFile('avatar', 'Picture:')->addCondition(Form::FILLED)->addRule(Form::MIME_TYPE, 'Uploaded file is not image', 'image/*');
     $form->addHidden('userid');
     $form->addTextArea('note', 'Comment:', 30, 5);
     // group for buttons
     $form->addGroup();
     $form->addSubmit('submit1', 'Send');
     // Step 2: Check if form was submitted?
     if ($form->isSubmitted()) {
         // Step 2c: Check if form is valid
         if ($form->isValid()) {
             echo '<h2>Form was submitted and successfully validated</h2>';
             $values = $form->getValues();
             Debug::dump($values);
             // this is the end, my friend :-)
             if (empty($disableExit)) {
                 exit;
             }
         }
     } else {
         // not submitted, define default values
         $defaults = array('name' => 'John Doe', 'userid' => 231, 'country' => 'CZ');
         $form->setDefaults($defaults);
     }
     return $form;
 }
Example #4
0
 public static function display()
 {
     if (!is_numeric($_GET['id'])) {
         cc_redirect(Admin::link('users'));
     }
     if ($_POST['cc_form'] == 'edit-group') {
         $id = $_GET['id'];
         $previous = (array) unserialize(urldecode($_POST['previous']));
         $group = $_POST['group'];
         $permissions = (array) $_POST['permissions'];
         $new = array_merge($previous, $permissions);
         foreach ($new as $k => $v) {
             if ($v == "1") {
                 $new[$k] = true;
             }
             if (!array_key_exists($k, $permissions)) {
                 $new[$k] = false;
             }
         }
         if (DB::update('users', array('name', 'data'), array($group, serialize(filter('admin_edit_group_data', array('permissions' => $new)))), array('users_id = ?', $id))) {
             $message = Message::success(__('admin', 'group-information-updated'));
         } else {
             $message = Message::error(__('admin', 'database-error'));
         }
     }
     $p = Permissions::getAll();
     $g = new Group((int) $_GET['id']);
     $p_form = new Form('');
     $p_form->setCC_Form('edit-group');
     $p_form->startFieldset(__('admin', 'group-information'));
     $p_form->addInput(__('admin', 'group-name'), 'text', 'group', $g->getName());
     $p_form->endFieldset();
     $p_form->addHTML(sprintf("<h3>%s</h3>", __('admin', 'permissions')));
     $p_table = new Table('permissions');
     $p_table->addHeader(array('Name', 'Allowed'));
     foreach ($p as $k => $v) {
         $previous[$v['name']] = $g->isAllowed($v['name']);
         $p_table->addRow(array(__('permissions', $v['name']), sprintf('<input type="checkbox" name="permissions[%s]"%svalue="1"/>', $v['name'], $g->isAllowed($v['name']) ? ' checked="checked"' : '')));
     }
     $p_form->addHidden('previous', urlencode(serialize($previous)));
     $p_form->addHTML($p_table->html());
     $p_form->addSubmit('', 'save-permissions', __('admin', 'save-changes'));
     return array(sprintf('%s: %s', __('admin', 'edit-group'), $g->getName()), $message . $p_form->html());
 }
Example #5
0
/*use Nette\Environment;*/
/*use Nette\Debug;*/
Debug::enable();
$countries = array('Select your country', 'Europe' => array(1 => 'Czech Republic', 2 => 'Slovakia'), 3 => 'USA', 4 => 'other');
$sex = array('m' => 'male', 'f' => 'female');
$form = new Form();
$form->addText('name', 'Your name:', 35);
// item name, label, size, maxlength
$form->addTextArea('note', 'Comment:', 30, 5);
$form->addRadioList('gender', 'Your gender:', $sex);
$form->addCheckbox('send', 'Ship to address');
$form->addSelect('country', 'Country:', $countries)->skipFirst();
$form->addMultiSelect('countrym', 'Country:', $countries);
$form->addPassword('password', 'Choose password:'******'avatar', 'Picture:');
$form->addHidden('userid');
$sub = $form->addContainer('firstperson');
$sub->addText('age', 'Your age:', 5);
$sub = $form->addContainer('secondperson');
$sub->addText('age', 'Your age:', 5);
$sub->addFile('avatar', 'Picture:');
$form->addSubmit('submit1', 'Send');
$_SERVER['REQUEST_METHOD'] = 'POST';
/* valid data
$_POST = array(
	'name' => 'string',
	'note' => 'textbox',
	'gender' => 'm',
	'send' => 'on',
	'country' => '1',
	'countrym' => array(
Example #6
0
 /**
  * Updates the form's hidden crop width and crop height fields.
  *
  * @param Form $form The form the crop module is inserted into.
  * @param int $width The width of the final cropped image.
  * @param int $height The height of the final cropped image.
  */
 private function updateHiddenSize($form, $width, $height)
 {
     $form->addHidden('CropSizeWidth', $width, true);
     $form->addHidden('CropSizeHeight', $height, true);
 }
Example #7
0
 public static function create_display()
 {
     i18n::set('admin');
     if ($_POST['cc_form'] == 'create_page') {
         plugin('admin_create_post_pre_proccessing');
         $id = $_GET['id'];
         $title = filter('admin_create_post_title', self::get('title'));
         $content = filter('admin_create_post_content', self::get('content_area'));
         $last_modified = filter('admin_create_post_last_modified', time());
         $settings = filter('admin_create_post_settings', self::get('settings'));
         $weight = filter('admin_create_post_weight', self::get('weight'));
         $menutitle = filter('admin_create_post_menutitle', self::get('menutitle'));
         $parent_id = filter('admin_create_post_parent_id', self::get('parent_id'));
         $slug = filter('admin_create_post_slug', self::get('slug'));
         if (empty($menutitle) || empty($slug)) {
             $message = Message::error(__('blank-error'));
             plugin('admin_create_post_blank_error');
         } else {
             plugin('admin_create_post_post_proccessing');
             $values = array('title' => $title, 'content' => $content, 'settings' => unserialize($settings), 'weight' => $weight, 'menutitle' => $menutitle, 'parent_id' => $parent_id, 'slug' => $slug);
             $values = filter('admin_create_post_posted_values', $values);
             $values['settings'] = serialize($values['settings']);
             $res = Content::createNode($_GET['type'], $values);
             if ($res) {
                 $message = Message::success(sprintf(__('page-creation-successful') . ' (<a href="%s">%s</a>)', Admin::link('content'), __('view-all-pages')));
             } else {
                 $message = Message::error(__('page-creation-failed'));
             }
         }
         //Hooks::bind('post_edit_page', 'EditPage::handlePost');
     }
     $r = $message;
     $themeList = array_subkeys(Themes::getThemeList(), 'name');
     $themeList['-1'] = 'Default Theme';
     ksort($themeList);
     $form = new Form('self', 'post', 'create_page');
     $form->addHidden('settings', 'a:0:{}');
     $form->startFieldset(__('page-info'), array('id' => 'page_info_f'));
     $form->addInput(__('page-title'), 'text', 'title', self::get('title'), array('class' => 'large'));
     $form->addHidden('content_type', self::get('type'));
     $form->addSelectList(__('theme-override'), 'theme', $themeList);
     $form->addSelectList(__('parent'), 'parent_id', self::buildParentOptions(), true, $_POST['parent_id'] ? $_POST['parent_id'] : '0');
     $form->endFieldset();
     plugin('admin_create_custom_fields', array(&$form));
     $form->startFieldset(__('menu-settings'), array('id' => 'menu_settings_f'));
     $form->addInput(__('menu-title'), 'text', 'menutitle', self::get('menutitle'));
     $form->addInput(__('slug'), 'text', 'slug', self::get('slug'));
     $form->addInput(__('weight'), 'text', 'weight', $_POST['weight'] ? $_POST['weight'] : '0');
     $form->endFieldset();
     plugin('admin_create_custom_fields2', array(&$form));
     $form->startFieldset(__('content'));
     $content = self::get('content_area');
     $form->addEditor('<p></p>', 'content_area', empty($content) ? "<p></p>" : $content);
     $form->endFieldset();
     plugin('admin_create_custom_fields3', array(&$form));
     $form->addSubmit('', 'save', __('save'));
     i18n::restore();
     return array(__('admin', 'add-page'), $r . $form->endAndGetHTML());
 }
Example #8
0
    public function getSearchBox()
    {
        static $id_count = 0;
        if ($id_count) {
            $id = 'search_list_' . $id_count;
        } else {
            $id = 'search_list';
            $id_count++;
        }
        $values = $this->getLinkValues();
        unset($values['pager_search']);
        unset($values['go']);
        $form = new \Form($id);
        $form->useGetMethod();
        $form->addClass('form-inline');
        $form->setAction('index.php');
        //$form->appendCSS('bootstrap');
        foreach ($values as $k => $v) {
            $form->addHidden($k, $v);
        }
        $input_array[] = '<div style="width: 300px">';
        $form->setOpen(false);
        $input_array[] = $form->printTag();
        $input_array[] = implode("\n", $form->getHiddens());
        $si = $form->addTextField('pager_c_search', $this->search);
        $si->addClass('pager_c_search');
        $si->addClass('form-control');
        $si->setPlaceholder(_('Search'));
        $input_array[] = '<div class="input-group">';
        $input_array[] = (string) $si;
        $input_array[] = '<span class="input-group-btn">';
        if ($this->search_button) {
            $sub = $form->addSubmit('submit', 'Go')->addClass('btn btn-success');
            $input_array[] = (string) $sub;
        }
        $input_array[] = <<<EOF
<input type="submit" onclick="\$(this).parents('form').find('input.pager_c_search').val('');" class="btn btn-info" value="Clear" />
EOF;
        $input_array[] = '</span>';
        $input_array[] = '</div>';
        $input_array[] = '</form></div>';
        return implode("\n", $input_array);
    }
Example #9
0
     echo "<tr>" . "<td colspan=\"2\">" . '<a class="modifiedLink" href="galleries.php?gid=' . $_GET["gid"] . '">' . $gallery->name . '</a>' . "</td>" . "</tr>";
     while ($a = $each[$i]) {
         if ($a->lastModified > $_SESSION["PrevVisit"]) {
             $classname = "modifiedLink";
         } else {
             $classname = "unmodifiedLink";
         }
         echo "<tr>" . "<td width=\"40\"></td>" . "<td width=\"660\">" . "<a class=\"" . $classname . "\" href=\"galleries.php?gid=" . $_GET["gid"] . "&aid=" . $a->id . "\">" . $a->name . "</a>" . "<br><span class=\"itemText\">" . $a->description . "</span>" . "</td>" . "</tr>";
         $i++;
     }
     echo '</table><br>';
     if ($gallery->isPublic || $gallery->creator == $_SESSION["UserID"]) {
         // form for creating an album
         writeSectionHeader("Create an Album");
         $frm = new Form("field", "createAlbum", "galleries.php?gid=" . $_GET["gid"], "addAlbum");
         $frm->addHidden("gid", $_GET["gid"]);
         $frm->addFormElement("album_name", "text", "Name", "", true);
         $frm->addFormElement("album_description", "textarea", "Description", "", true);
         $frm->addFormElement("album_files", "file", "Zip File", "", true);
         $frm->method = "post";
         $frm->draw();
     }
 } else {
     writeHeader(3, "Nerdery Pictures", "Picture Galleries");
     writeCP();
     $sh = new SectionHeader("Picture Galleries", true);
     $sh->start();
     $sh->end();
     echo '<table border="0" cellpadding="2" cellspacing="0" width="700">';
     $each = getGalleries();
     $i = 0;
Example #10
0
 public function echoFolderEdit()
 {
     $success = true;
     $name;
     $id;
     if ($this->page_type == 'edit') {
         $sth = $this->db->prepare("SELECT `name` " . 'FROM `folders` WHERE `id`=?');
         $sth->execute(array($this->id));
         if ($row = $sth->fetch()) {
             $id = $this->id;
             $name = $row['name'];
         } else {
             $success = false;
         }
     }
     if ($success) {
         $form = new Form('folder');
         $form->addText('Folder name:', 'name', true, $name);
         $form->addHidden('id', $id);
         $form->addHidden('folder_id', $this->parent_folder_id);
         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, $this->id);
             if (count($move_arr) > 1) {
                 //$form->addHeading('Move');
                 $form->addSelect('Move to:', 'move', $move_arr);
             }
             $form->addDelete();
         }
         $form->echoForm();
     }
 }
Example #11
0
 public static function display()
 {
     $r = "";
     if ($_POST['cc_form'] == 'settings') {
         $name_lookup = array();
         Database::beginTransaction();
         foreach ($_POST as $key => $value) {
             if ($key == 'cc_form') {
                 continue;
             }
             if (substr($key, 0, 12) == 'cc_settings_') {
                 $name_lookup[substr($key, 12)] = explode('|', $value);
                 continue;
             }
             $setting_name = $key;
             //var_dump(array_key_exists($key, $name_lookup),$name_lookup);
             if (!array_key_exists($setting_name, $name_lookup)) {
                 continue;
             }
             if ($key == 'clean-urls') {
                 $value = (bool) $value;
             }
             Database::update('settings', array('data'), array(serialize($value)), array('package = ? AND name = ?', $name_lookup[$setting_name][1], $name_lookup[$setting_name][0]));
         }
         $r .= Message::success(__('admin', 'settings-saved'));
         Database::endTransaction();
     }
     $settings = Database::select('settings', '*', array('package = ? OR package = ? OR package = ? OR package = ?', 'core', 'admin', 'site', 'gui'), array('package', 'ASC', 'name', 'ASC'));
     $settings = $settings->fetchAll(PDO::FETCH_ASSOC);
     $rows = array();
     foreach ($settings as $row) {
         if (!array_key_exists($row['package'], $rows)) {
             $rows[$row['package']] = array();
         }
         $rows[$row['package']][] = $row;
     }
     ksort($rows);
     $form = new Form('self', 'POST', 'settings');
     foreach ($rows as $cat => $catRows) {
         $form->startFieldset(__('settings', $cat));
         foreach ($catRows as $row) {
             $data = unserialize($row['data']);
             $form->addHidden('cc_settings_' . UTF8::slugify($row['name']), $row['name'] . '|' . $row['package']);
             if ($row['name'] == 'clean urls') {
                 $form->addSelectList(__('settings', $row['name']), UTF8::slugify($row['name']), array(1 => __('admin', 'yes'), 0 => __('admin', 'no')), true, $data);
             } else {
                 if ($row['name'] == 'theme') {
                     $themes = Themes::getThemeList();
                     $options = array();
                     foreach ($themes as $slug => $ini) {
                         $options[$slug] = $ini['name'];
                     }
                     $form->addSelectList(__('settings', $row['name']), UTF8::slugify($row['name']), $options, true, $data);
                 } else {
                     if ($row['name'] == 'locale') {
                         $locales = i18n::getLocales();
                         $form->addSelectList(__('settings', $row['name']), UTF8::slugify($row['name']), $locales, false, $data);
                     } else {
                         if ($row['name'] == 'homepage id') {
                             $form->addSelectList(__('settings', $row['name']), UTF8::slugify($row['name']), Content::optionListArrayFromArray(Content::parseNavigation()), true, $data);
                         } else {
                             if ($row['name'] == 'site name') {
                                 $form->addInput(__('settings', $row['name']), 'text', UTF8::slugify($row['name']), $data);
                             } else {
                                 if ($row['name'] == 'editor') {
                                     $editors = Editors::getNamesOfRegistered();
                                     $form->addSelectList(__('settings', $row['name']), UTF8::slugify($row['name']), $editors, false, $data);
                                 } else {
                                     if ($row['name'] == 'homepage') {
                                         $form->addSelectList(__('settings', $row['name']), UTF8::slugify($row['name']), Admin::getAdminPageOptions(), true, $data);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $form->endFieldset();
     }
     $form->startFieldset('');
     $form->addSubmit('', 'save-settings', __('admin', 'save'));
     $form->endFieldset();
     return array(__('admin', 'settings'), $r . $form->endAndGetHTML());
 }
Example #12
0
 public function echoEmail()
 {
     $email;
     $alert = 0;
     $primary = 0;
     $success = true;
     if ($this->contact_item_id) {
         $sth = $this->db->prepare("SELECT `primary`,`alert`,`email` " . 'FROM `con_emails` ' . 'WHERE `con_emails`.`id`=?');
         $sth->execute(array($this->contact_item_id));
         if ($row = $sth->fetch()) {
             $email = $row['email'];
             $alert = $row['alert'];
             $primary = $row['primary'];
         } else {
             $success = false;
         }
     }
     if ($success) {
         $form = new Form('email');
         $form->addText('Email:', 'email', true, $email, 'email="true"');
         $form->addSwitch('Primary:', 'primary', array('0' => 'No', '1' => 'Yes'), $primary);
         $form->addSwitch('Receive alerts:', 'alert', array('0' => 'No', '1' => 'Yes'), $alert);
         $form->addHidden('id', $this->contact_item_id);
         $form->addHidden('contact_id', $this->contact_id);
         //$form->addHidden('callback', $this->form_callback);
         if ($this->contact_item_id) {
             $form->addDelete();
         }
         $form->echoForm();
     }
 }
Example #13
0
 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();
     }
 }
Example #14
0
 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>';
     }
 }
Example #15
0
 public static function shortcut_menu()
 {
     PHPWS_Core::initModClass('access', 'Shortcut.php');
     $sch_id = filter_input(INPUT_GET, 'sch_id', FILTER_SANITIZE_NUMBER_INT);
     if ($sch_id === false) {
         $sch_id = 0;
     }
     if (!$sch_id) {
         @($key_id = $_REQUEST['key_id']);
         if (!$key_id) {
             javascript('close_window');
             return;
         } else {
             $shortcut = new Access_Shortcut();
             $key = new Key($key_id);
             if (!$key->id) {
                 javascript('close_window');
                 return;
             }
             $shortcut->keyword = trim(preg_replace('/[^\\w\\s\\-]/', '', $key->title));
         }
     } else {
         $shortcut = new Access_Shortcut($sch_id);
         if (!$shortcut->id) {
             return 'Error: shortcut not found';
         }
     }
     $form = new \Form();
     $form->setAction('index.php');
     $form->appendCSS('bootstrap');
     $form->setId('shortcut-menu');
     $form->addHidden('authkey', \Current_User::getAuthKey());
     $form->addHidden('module', 'access');
     $form->addHidden('command', 'post_shortcut');
     if (isset($key_id)) {
         $form->addHidden('key_id', $key_id);
     } else {
         $form->addHidden('sch_id', $shortcut->id);
     }
     $keyword = $form->addTextField('keyword', $shortcut->keyword)->setRequired();
     $keyword->setPlaceholder(dgettext('access', 'Type in a keyword'));
     $tpl = $form->getInputStringArray();
     $template = new \Template($tpl);
     $template->setModuleTemplate('access', 'shortcut_menu.tpl');
     $content = $template->render();
     return $content;
 }