예제 #1
0
  public function executeIndex(sfWebRequest $request)
  {

  $this->form = new sfForm();
  $this->form->setWidgets(array(
    'input'    => new sfWidgetFormTextArea( array(), array( 
      'rows' => 10, 'class' => 'span9'
      )),
    'role'     => new sfWidgetFormChoice( array(
      'choices' => array( 'leader' => 'leader', 'follower' => 'follower')
    )),
    'type'     => new sfWidgetFormChoice( array(
      'choices' => Doctrine::getTable('dsClassStudent')->getTypes()
      )) 
  ));

  $this->form->setDefault('input', $this->getUser()->getAttribute('import_raw'));

  // Deal with the request
  if ($request->isMethod('post'))
  {
    // Handle the form submission
    $input = $request->getPostParameter('input');
    $role = $request->getPostParameter('role');
    $this->type = $request->getPostParameter('type');

    $this->getUser()->setAttribute('import_raw', $this->input);

    // Do stuff
    $array = Swingmachine::csvstring_to_array($input, "\t");

    // validate emails
    $this->array = array();
    foreach( $array as $row ):
      // $valid = 1;
      $newrow = array(
        'firstname' => array_key_exists(0, $row) ? $row[0] : null,
        'lastname' => array_key_exists(1, $row) ? $row[1] : null,
        'email' => array_key_exists(2, $row) ? $row[2] : null,
        'student' => array_key_exists(3, $row) ? $row[3] : null,
        'note' => array_key_exists(4, $row) ? $row[4] : null
      );
      $test = $newrow['email']."";
      $newrow['email-valid'] = Swingmachine::isValidEmail($test);
      array_push($this->array, $newrow);
    endforeach;

    $this->role = $role;
    $this->new = $this->array;

    $this->getUser()->setAttribute('import_data', $this->array);
    $this->getUser()->setAttribute('import_role', $this->role);
    $this->getUser()->setAttribute('import_type', $this->type);

    $this->redirect('import_preview');

    //$this->array = $new;
    //$this->redirect('ds_class_student_import_preview');
  }

  }
예제 #2
0
<table class="table table-condensed table-hover rowclick">
  <tbody>
<?php
      foreach ($enrolments as $i => $enrolment): 
        $class = Swingmachine::isValidEmail( $enrolment->getPerson()->getEmail() )  ? '' : ' error text-error';
?>
    <tr class="<?php echo $class ?>">
      <td>
        <?php echo $i+1 ?>
      </td>
      <td>
        <?php echo $enrolment->getPerson() ?>
      </td>
      <td>
        <?php echo $enrolment->getPerson()->getEmail() ?>
      </td>
      <td>
          <?php #echo $enrolment->getSentAt() ?>
      </td>
      <!--
      <td>
        <?php # if (!$enrolment->getSuccess() ) : ?>
        <a href="#<?php echo $enrolment->id ?>" data-toggle="modal" class="rowclick">Vorschau</a>
      <?php # endif; ?>
      </td>
    -->
    </tr>

<div id="<?php echo $enrolment->id ?>" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
예제 #3
0
  public function executeImport(sfWebRequest $request)
  {

  $this->form = new sfForm();
  $this->form->setWidgets(array(
    'input'    => new sfWidgetFormTextArea(),
    'role'     => new sfWidgetFormChoice( array('choices' => array( 'lead' => 'lead', 'follow' => 'follow'))) 
  ));

  $this->form->setDefault('input', $this->getUser()->getAttribute('import_raw'));

  // Deal with the request
  if ($request->isMethod('post'))
  {
    // Handle the form submission
    $input = $request->getPostParameter('input');
    $role = $request->getPostParameter('role');

    $this->getUser()->setAttribute('import_raw', $this->input);

    // Do stuff
    $array = Swingmachine::csvstring_to_array($input, "\t");

    // validate emails
    $this->array = array();
    foreach( $array as $row ):
      // $valid = 1;
      $test = $row[2]."";
      $valid = Swingmachine::isValidEmail($test);
      $row['email-valid'] = $valid;
      array_push($this->array, $row);
    endforeach;

    $this->role = $role;
    $this->new = $this->array;

    $this->getUser()->setAttribute('import_data', $this->array);
    $this->getUser()->setAttribute('import_role', $this->role);

    $this->redirect('@ds_class_students_importPreview?class_id='.$this->class->getId() );

    //$this->array = $new;
    //$this->redirect('ds_class_student_import_preview');
  }

  }