Exemplo n.º 1
0
 protected function DoBeforeCreate()
 {
     $this->dataset = new TableDataset(
         new PgConnectionFactory(),
         GetConnectionOptions(),
         '"public"."sga_accion"');
     $field = new IntegerField('id_accion', null, null, true);
     $field->SetIsNotNull(true);
     $this->dataset->AddField($field, true);
     $field = new IntegerField('id_tipo_espacio');
     $this->dataset->AddField($field, false);
     $field = new IntegerField('id_tipo_bien');
     $this->dataset->AddField($field, false);
     $field = new IntegerField('id_origen');
     $this->dataset->AddField($field, false);
     $field = new IntegerField('id_metodologia');
     $this->dataset->AddField($field, false);
     $field = new IntegerField('id_periodicidad');
     $this->dataset->AddField($field, false);
     $field = new BooleanField('fl_a_demanda');
     $field->SetIsNotNull(true);
     $this->dataset->AddField($field, false);
     $field = new StringField('ds_referencia');
     $this->dataset->AddField($field, false);
     $field = new IntegerField('id_tipo_accion');
     $this->dataset->AddField($field, false);
     $this->dataset->AddLookupField('id_tipo_accion', 'public.sga_tipo_accion', new IntegerField('id_tipo_accion', null, null, true), new StringField('ds_referencia', 'id_tipo_accion_ds_referencia', 'id_tipo_accion_ds_referencia_public_sga_tipo_accion'), 'id_tipo_accion_ds_referencia_public_sga_tipo_accion');
     $this->dataset->AddLookupField('id_tipo_espacio', 'public.sga_tipo_espacio', new IntegerField('id_tipo_espacio', null, null, true), new StringField('ds_referencia', 'id_tipo_espacio_ds_referencia', 'id_tipo_espacio_ds_referencia_public_sga_tipo_espacio'), 'id_tipo_espacio_ds_referencia_public_sga_tipo_espacio');
     $this->dataset->AddLookupField('id_tipo_bien', 'public.sga_tipo_bien', new IntegerField('id_tipo_bien', null, null, true), new StringField('ds_referencia', 'id_tipo_bien_ds_referencia', 'id_tipo_bien_ds_referencia_public_sga_tipo_bien'), 'id_tipo_bien_ds_referencia_public_sga_tipo_bien');
     $this->dataset->AddLookupField('id_origen', 'public.sga_origen', new IntegerField('id_origen', null, null, true), new StringField('no_origen', 'id_origen_no_origen', 'id_origen_no_origen_public_sga_origen'), 'id_origen_no_origen_public_sga_origen');
     $this->dataset->AddLookupField('id_metodologia', 'public.sga_metodologia', new IntegerField('id_metodologia', null, null, true), new StringField('no_metodologia', 'id_metodologia_no_metodologia', 'id_metodologia_no_metodologia_public_sga_metodologia'), 'id_metodologia_no_metodologia_public_sga_metodologia');
     $this->dataset->AddLookupField('id_periodicidad', 'public.sga_periodicidad', new IntegerField('id_periodicidad', null, null, true), new StringField('no_periodicidad', 'id_periodicidad_no_periodicidad', 'id_periodicidad_no_periodicidad_public_sga_periodicidad'), 'id_periodicidad_no_periodicidad_public_sga_periodicidad');
 }
Exemplo n.º 2
0
 public function testCanSetData()
 {
     $b = new BooleanField();
     $b->setData(true);
     $this->assertTrue($b->getData());
     $b->setData(false);
     $this->assertFalse($b->getData());
 }
 protected function DoBeforeCreate()
 {
     $this->dataset = new TableDataset(new MsCOMConnectionFactory(), GetConnectionOptions(), '[dbo].[MachinesClientes]');
     $field = new IntegerField('ID', null, null, true);
     $field->SetIsNotNull(true);
     $this->dataset->AddField($field, true);
     $field = new StringField('IP');
     $field->SetIsNotNull(true);
     $this->dataset->AddField($field, false);
     $field = new StringField('NomMachine');
     $this->dataset->AddField($field, false);
     $field = new BooleanField('EtatMachine');
     $field->SetIsNotNull(true);
     $this->dataset->AddField($field, false);
     $field = new BooleanField('Service1');
     $field->SetIsNotNull(true);
     $this->dataset->AddField($field, false);
     $field = new BooleanField('Service2');
     $field->SetIsNotNull(true);
     $this->dataset->AddField($field, false);
     $field = new BooleanField('Service3');
     $field->SetIsNotNull(true);
     $this->dataset->AddField($field, false);
 }
Exemplo n.º 4
0
meta('translation-yes', 'Yes');
meta('translation-no', 'No');
meta('translation-field-empty', '[left blank]');
// Make an instance of a form
$form = new \Silverplate\Form();
// Then add some text fields to the form
$form->add('name', TextField::make('Full name', true));
$form->add('e-mail', TextField::make('E-mail address', true));
// The second parameter in Field constructor describes if a field is required
$form->add('phone', TextField::make('Your phone'));
// The third paramter in Field constructor specifies initial value for a field
$form->add('company', TextField::make('Company', false, 'n/a'));
// You can also add other types of fields
$form->add('message', TextareaField::make('Your message', true));
$form->add('topic', ChoiceField::make('Message topic', true)->choices(array('General inquiry', 'Job offer', 'I would love to speak to someone out there')));
$form->add('know-you', BooleanField::make('Do you know me?'));
// Or add a custom validator to a field
$form->add('question', TextField::make('2 + 2 =', true)->validate(function ($value) {
    if (trim($value) !== '4') {
        return 'This answer is not valid.';
    }
}));
// If form is valid, then we can send an e-mail
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $form->valid()) {
    // Set the file path to the mail template file
    Mailer::send_form($form, __DIR__ . '/mail-template.php');
    // Change this URL to match your domain
    throw new \Silverplate\Http302('http://mysite.com/thank-you');
}
/* 
 * Below is the code to display all form fields.
Exemplo n.º 5
0
 protected function AddInsertColumns(Grid $grid)
 {
     //
     // Edit column for id_accion field
     //
     $editor = new ComboBox('id_accion_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
     $lookupDataset = new TableDataset(
         new PgConnectionFactory(),
         GetConnectionOptions(),
         '"public"."sga_accion"');
     $field = new IntegerField('id_accion', null, null, true);
     $field->SetIsNotNull(true);
     $lookupDataset->AddField($field, true);
     $field = new IntegerField('id_tipo_espacio');
     $lookupDataset->AddField($field, false);
     $field = new IntegerField('id_tipo_bien');
     $lookupDataset->AddField($field, false);
     $field = new IntegerField('id_origen');
     $lookupDataset->AddField($field, false);
     $field = new IntegerField('id_metodologia');
     $lookupDataset->AddField($field, false);
     $field = new IntegerField('id_periodicidad');
     $lookupDataset->AddField($field, false);
     $field = new BooleanField('fl_a_demanda');
     $field->SetIsNotNull(true);
     $lookupDataset->AddField($field, false);
     $field = new StringField('ds_referencia');
     $lookupDataset->AddField($field, false);
     $field = new IntegerField('id_tipo_accion');
     $lookupDataset->AddField($field, false);
     $field = new IntegerField('id_sector');
     $lookupDataset->AddField($field, false);
     $lookupDataset->setOrderByField('ds_referencia', GetOrderTypeAsSQL(otAscending));
     $editColumn = new LookUpEditColumn(
         'Acción', 
         'id_accion', 
         $editor, 
         $this->dataset, 'id_accion', 'ds_referencia', $lookupDataset);
     $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption())));
     $editor->GetValidatorCollection()->AddValidator($validator);
     $this->ApplyCommonColumnEditProperties($editColumn);
     $grid->AddInsertColumn($editColumn);
     
     //
     // Edit column for id_espacio field
     //
     $editor = new ComboBox('id_espacio_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
     $lookupDataset = new TableDataset(
         new PgConnectionFactory(),
         GetConnectionOptions(),
         '"public"."sga_espacio"');
     $field = new IntegerField('id_espacio', null, null, true);
     $field->SetIsNotNull(true);
     $lookupDataset->AddField($field, true);
     $field = new IntegerField('id_tipo_espacio');
     $field->SetIsNotNull(true);
     $lookupDataset->AddField($field, false);
     $field = new IntegerField('id_espacio_contenedor');
     $lookupDataset->AddField($field, false);
     $field = new StringField('co_espacio');
     $field->SetIsNotNull(true);
     $lookupDataset->AddField($field, false);
     $field = new StringField('no_espacio');
     $field->SetIsNotNull(true);
     $lookupDataset->AddField($field, false);
     $field = new StringField('co_plano');
     $lookupDataset->AddField($field, false);
     $field = new IntegerField('id_planta');
     $lookupDataset->AddField($field, false);
     $field = new StringField('ds_referencia');
     $lookupDataset->AddField($field, false);
     $field = new IntegerField('id_sector');
     $lookupDataset->AddField($field, false);
     $lookupDataset->setOrderByField('ds_referencia', GetOrderTypeAsSQL(otAscending));
     $editColumn = new LookUpEditColumn(
         'Espacio', 
         'id_espacio', 
         $editor, 
         $this->dataset, 'id_espacio', 'ds_referencia', $lookupDataset);
     $editColumn->SetAllowSetToNull(true);
     $this->ApplyCommonColumnEditProperties($editColumn);
     $grid->AddInsertColumn($editColumn);
     
     //
     // Edit column for id_bien field
     //
     $editor = new ComboBox('id_bien_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
     $lookupDataset = new TableDataset(
         new PgConnectionFactory(),
         GetConnectionOptions(),
         '"public"."sga_bien"');
     $field = new IntegerField('id_bien', null, null, true);
     $field->SetIsNotNull(true);
     $lookupDataset->AddField($field, true);
     $field = new IntegerField('id_tipo_bien');
     $field->SetIsNotNull(true);
     $lookupDataset->AddField($field, false);
     $field = new IntegerField('id_espacio');
     $field->SetIsNotNull(true);
     $lookupDataset->AddField($field, false);
     $field = new StringField('ds_observacion');
     $lookupDataset->AddField($field, false);
     $field = new IntegerField('nu_cantidad');
     $lookupDataset->AddField($field, false);
     $lookupDataset->setOrderByField('ds_observacion', GetOrderTypeAsSQL(otAscending));
     $editColumn = new LookUpEditColumn(
         'Bien', 
         'id_bien', 
         $editor, 
         $this->dataset, 'id_bien', 'ds_observacion', $lookupDataset);
     $editColumn->SetAllowSetToNull(true);
     $this->ApplyCommonColumnEditProperties($editColumn);
     $grid->AddInsertColumn($editColumn);
     
     //
     // Edit column for id_periodicidad field
     //
     $editor = new ComboBox('id_periodicidad_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
     $lookupDataset = new TableDataset(
         new PgConnectionFactory(),
         GetConnectionOptions(),
         '"public"."sga_periodicidad"');
     $field = new IntegerField('id_periodicidad', null, null, true);
     $field->SetIsNotNull(true);
     $lookupDataset->AddField($field, true);
     $field = new StringField('no_periodicidad');
     $field->SetIsNotNull(true);
     $lookupDataset->AddField($field, false);
     $field = new IntegerField('va_frecuencia');
     $field->SetIsNotNull(true);
     $lookupDataset->AddField($field, false);
     $lookupDataset->setOrderByField('no_periodicidad', GetOrderTypeAsSQL(otAscending));
     $editColumn = new LookUpEditColumn(
         'Periodicidad', 
         'id_periodicidad', 
         $editor, 
         $this->dataset, 'id_periodicidad', 'no_periodicidad', $lookupDataset);
     $editColumn->SetAllowSetToNull(true);
     $this->ApplyCommonColumnEditProperties($editColumn);
     $grid->AddInsertColumn($editColumn);
     
     //
     // Edit column for ds_detalle field
     //
     $editor = new TextAreaEdit('ds_detalle_edit', 50, 8);
     $editColumn = new CustomEditColumn('Detalle', 'ds_detalle', $editor, $this->dataset);
     $editColumn->SetAllowSetToNull(true);
     $this->ApplyCommonColumnEditProperties($editColumn);
     $grid->AddInsertColumn($editColumn);
     
     //
     // Edit column for fe_inicio field
     //
     $editor = new DateTimeEdit('fe_inicio_edit', true, 'd/m/Y H:i:s', GetFirstDayOfWeek());
     $editColumn = new CustomEditColumn('Fecha Início', 'fe_inicio', $editor, $this->dataset);
     $editColumn->SetAllowSetToNull(true);
     $this->ApplyCommonColumnEditProperties($editColumn);
     $grid->AddInsertColumn($editColumn);
     if ($this->GetSecurityInfo()->HasAddGrant())
     {
         $grid->SetShowAddButton(true);
         $grid->SetShowInlineAddButton(false);
     }
     else
     {
         $grid->SetShowInlineAddButton(false);
         $grid->SetShowAddButton(false);
     }
 }
Exemplo n.º 6
0
 /**
  * @ignore
  *
  * @param array $opts
  *
  * @return BooleanField
  */
 public static function BooleanField($opts = [])
 {
     return BooleanField::createObject($opts);
 }
Exemplo n.º 7
0
 public function testBooleanFieldRenderChecked()
 {
     $f = new BooleanField();
     $this->assertEquals('<input type="hidden" name="foo" value="0" /><input type="checkbox" name="foo" checked="checked" value="1" />', $f->render('foo', true));
 }