Exemplo n.º 1
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aExpediente !== null) {
             if ($this->aExpediente->isModified() || $this->aExpediente->isNew()) {
                 $affectedRows += $this->aExpediente->save($con);
             }
             $this->setExpediente($this->aExpediente);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Exemplo n.º 2
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aExpediente !== null) {
             if ($this->aExpediente->isModified() || $this->aExpediente->isNew()) {
                 $affectedRows += $this->aExpediente->save($con);
             }
             $this->setExpediente($this->aExpediente);
         }
         if ($this->aServicio !== null) {
             if ($this->aServicio->isModified() || $this->aServicio->isNew()) {
                 $affectedRows += $this->aServicio->save($con);
             }
             $this->setServicio($this->aServicio);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->expedientehistorialsScheduledForDeletion !== null) {
             if (!$this->expedientehistorialsScheduledForDeletion->isEmpty()) {
                 ExpedientehistorialQuery::create()->filterByPrimaryKeys($this->expedientehistorialsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->expedientehistorialsScheduledForDeletion = null;
             }
         }
         if ($this->collExpedientehistorials !== null) {
             foreach ($this->collExpedientehistorials as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Exemplo n.º 3
0
 public function nuevoAction()
 {
     $request = $this->getRequest();
     $idcliente = $this->params()->fromRoute('id');
     $cliente = \ClienteQuery::create()->findPk($idcliente);
     if ($request->isPost()) {
         $post_data = $request->getPost();
         $entity = new \Expediente();
         foreach ($post_data as $key => $value) {
             if (\ExpedientePeer::getTableMap()->hasColumn($key) && !empty($value) && $key != 'cliente_cumpleanios') {
                 $entity->setByName($key, $value, \BasePeer::TYPE_FIELDNAME);
             }
         }
         //LA FECHA DE APERTURA
         $entity->setExpedienteFechainicio(new \DateTime());
         //EL ESTATUS
         $entity->setExpedienteEstatus('abierto');
         $date = new \DateTime();
         $entity->save();
         //CREAMOS EL FOLIO
         $folio = 'ITR' . $date->format('m') . $date->format('y');
         if ((int) $entity->getIdexpediente() < 10) {
             $folio .= '0';
         }
         $folio .= $entity->getIdexpediente();
         $entity->setExpedienteFolio($folio);
         $entity->save();
         $mailer = new \Shared\GeneralFunction\Itrademailer();
         if ($mailer->newExpedienteEmail($cliente, $folio)) {
             $this->flashMessenger()->addSuccessMessage('Correo electronico enviado exitosamente!');
         }
         $this->flashMessenger()->addSuccessMessage('Registro guardado exitosamente!');
         //REDIRECCIONAMOS A LA ENTIDAD QUE ACABAMOS DE CREAR
         return $this->redirect()->toUrl('/clientes/ver/' . $idcliente . '/expedientes/ver/' . $entity->getIdexpediente());
     }
     $form = new \Admin\Clientes\Form\ExpedienteForm($idcliente);
     $view_model = new ViewModel();
     $view_model->setTemplate('admin/clientes/expedientes/nuevo');
     $view_model->setVariable('form', $form);
     $view_model->setVariable('cliente', $cliente);
     return $view_model;
 }