Ejemplo n.º 1
0
 /**
  * Find object by primary key using raw SQL to go fast.
  * Bypass doSelect() and the object formatter by using generated code.
  *
  * @param     mixed $key Primary key to use for the query
  * @param     PropelPDO $con A connection object
  *
  * @return                 Expedientegasto A model object, or null if the key is not found
  * @throws PropelException
  */
 protected function findPkSimple($key, $con)
 {
     $sql = 'SELECT `idexpedientegasto`, `idexpediente`, `idgastofacturacion`, `idproveedoritrade`, `idempleado`, `expedientegasto_fecha`, `expedientegasto_monto`, `expedientegasto_tipo`, `expedientegasto_comprobante`, `expedientegasto_nota`, `expedientegasto_moneda` FROM `expedientegasto` WHERE `idexpedientegasto` = :p0';
     try {
         $stmt = $con->prepare($sql);
         $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
         $stmt->execute();
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
     }
     $obj = null;
     if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $obj = new Expedientegasto();
         $obj->hydrate($row);
         ExpedientegastoPeer::addInstanceToPool($obj, (string) $key);
     }
     $stmt->closeCursor();
     return $obj;
 }
Ejemplo n.º 2
0
 /**
  * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
  * feature (like MySQL or SQLite).
  *
  * This method is not very speedy because it must perform a query first to get
  * the implicated records and then perform the deletes by calling those Peer classes.
  *
  * This method should be used within a transaction if possible.
  *
  * @param      Criteria $criteria
  * @param      PropelPDO $con
  * @return int The number of affected rows (if supported by underlying database driver).
  */
 protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
 {
     // initialize var to track total num of affected rows
     $affectedRows = 0;
     // first find the objects that are implicated by the $criteria
     $objects = ProveedoritradePeer::doSelect($criteria, $con);
     foreach ($objects as $obj) {
         // delete related Expedientegasto objects
         $criteria = new Criteria(ExpedientegastoPeer::DATABASE_NAME);
         $criteria->add(ExpedientegastoPeer::IDPROVEEDORITRADE, $obj->getIdproveedoritrade());
         $affectedRows += ExpedientegastoPeer::doDelete($criteria, $con);
         // delete related Proveedoritradearchivo objects
         $criteria = new Criteria(ProveedoritradearchivoPeer::DATABASE_NAME);
         $criteria->add(ProveedoritradearchivoPeer::IDPROVEEDORITRADE, $obj->getIdproveedoritrade());
         $affectedRows += ProveedoritradearchivoPeer::doDelete($criteria, $con);
         // delete related Proveedoritradeservicio objects
         $criteria = new Criteria(ProveedoritradeservicioPeer::DATABASE_NAME);
         $criteria->add(ProveedoritradeservicioPeer::IDPROVEEDORITRADE, $obj->getIdproveedoritrade());
         $affectedRows += ProveedoritradeservicioPeer::doDelete($criteria, $con);
     }
     return $affectedRows;
 }
Ejemplo n.º 3
0
 /**
  * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
  * feature (like MySQL or SQLite).
  *
  * This method is not very speedy because it must perform a query first to get
  * the implicated records and then perform the deletes by calling those Peer classes.
  *
  * This method should be used within a transaction if possible.
  *
  * @param      Criteria $criteria
  * @param      PropelPDO $con
  * @return int The number of affected rows (if supported by underlying database driver).
  */
 protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
 {
     // initialize var to track total num of affected rows
     $affectedRows = 0;
     // first find the objects that are implicated by the $criteria
     $objects = GastofacturacionPeer::doSelect($criteria, $con);
     foreach ($objects as $obj) {
         // delete related Expedientegasto objects
         $criteria = new Criteria(ExpedientegastoPeer::DATABASE_NAME);
         $criteria->add(ExpedientegastoPeer::IDGASTOFACTURACION, $obj->getIdgastofacturacion());
         $affectedRows += ExpedientegastoPeer::doDelete($criteria, $con);
     }
     return $affectedRows;
 }
Ejemplo n.º 4
0
 /**
  * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
  * feature (like MySQL or SQLite).
  *
  * This method is not very speedy because it must perform a query first to get
  * the implicated records and then perform the deletes by calling those Peer classes.
  *
  * This method should be used within a transaction if possible.
  *
  * @param      Criteria $criteria
  * @param      PropelPDO $con
  * @return int The number of affected rows (if supported by underlying database driver).
  */
 protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
 {
     // initialize var to track total num of affected rows
     $affectedRows = 0;
     // first find the objects that are implicated by the $criteria
     $objects = EmpleadoPeer::doSelect($criteria, $con);
     foreach ($objects as $obj) {
         // delete related Cliente objects
         $criteria = new Criteria(ClientePeer::DATABASE_NAME);
         $criteria->add(ClientePeer::IDEMPLEADOCOMERCIAL, $obj->getIdempleado());
         $affectedRows += ClientePeer::doDelete($criteria, $con);
         // delete related Cliente objects
         $criteria = new Criteria(ClientePeer::DATABASE_NAME);
         $criteria->add(ClientePeer::IDEMPLEADOOPERACIONES, $obj->getIdempleado());
         $affectedRows += ClientePeer::doDelete($criteria, $con);
         // delete related Expedientearchivo objects
         $criteria = new Criteria(ExpedientearchivoPeer::DATABASE_NAME);
         $criteria->add(ExpedientearchivoPeer::IDEMPLEADO, $obj->getIdempleado());
         $affectedRows += ExpedientearchivoPeer::doDelete($criteria, $con);
         // delete related Expedientegasto objects
         $criteria = new Criteria(ExpedientegastoPeer::DATABASE_NAME);
         $criteria->add(ExpedientegastoPeer::IDEMPLEADO, $obj->getIdempleado());
         $affectedRows += ExpedientegastoPeer::doDelete($criteria, $con);
     }
     return $affectedRows;
 }
Ejemplo n.º 5
0
 public function editarcargoAction()
 {
     $request = $this->getRequest();
     $idgasto = $this->params()->fromQuery('id');
     $entity = \ExpedientegastoQuery::create()->findPk($idgasto);
     if ($request->isPost()) {
         $post_data = $request->getPost();
         $post_files = $request->getFiles();
         $auth = new \Shared\Session\AouthSession();
         $auth = $auth->getData();
         $entity = \ExpedientegastoQuery::create()->findPk($post_data['idexpedientegasto']);
         foreach ($post_data as $key => $value) {
             if (\ExpedientegastoPeer::getTableMap()->hasColumn($key) && !empty($value) && $key != 'expedientegasto_fecha') {
                 $entity->setByName($key, $value, \BasePeer::TYPE_FIELDNAME);
             }
         }
         //LA FECHA
         $expedientegasto_fecha = \DateTime::createFromFormat('d/m/Y', $post_data['expedientegasto_fecha']);
         $entity->setExpedientegastoFecha($expedientegasto_fecha);
         $entity->setIdempleado($auth['idempleado']);
         $entity->save();
         //El comprobante
         if (!empty($post_files['expedientegasto_comprobante']['name'])) {
             $target_path = "/files/expedientesgastos/";
             $target_path = $target_path . $entity->getIdexpedientegasto() . '_' . basename($post_files['expedientegasto_comprobante']['name']);
             if (move_uploaded_file($_FILES['expedientegasto_comprobante']['tmp_name'], $_SERVER['DOCUMENT_ROOT'] . $target_path)) {
                 $entity->setExpedientegastoComprobante($target_path);
                 $entity->save();
             }
         }
         $this->flashMessenger()->addSuccessMessage('Registro guardado exitosamente!');
         //REDIRECCIONAMOS A LA ENTIDAD QUE ACABAMOS DE CREAR
         return $this->redirect()->toUrl('/clientes/ver/' . $entity->getExpediente()->getIdcliente() . '/expedientes/ver/' . $entity->getIdexpediente());
     }
     //LAS CATEGORIAS DE NUESTROS GASTOS
     $categoriasgasto = \CategoriagastoQuery::create()->find();
     $categoriasgasto_array = array();
     foreach ($categoriasgasto as $categoriagastos) {
         $id = $categoriagastos->getIdcategoriagasto();
         $categoriasgasto_array[$id] = $categoriagastos->getCategoriagastoNombre();
     }
     //LOS PROVEEDORES
     $proveedores = \ProveedoritradeQuery::create()->filterByIdproveedoritrade(1, \Criteria::NOT_EQUAL)->find();
     $proveedores_array = array();
     foreach ($proveedores as $proveedor) {
         $id = $proveedor->getIdproveedoritrade();
         $proveedores_array[$id] = $proveedor->getProveedoritradeNombre();
     }
     //gastos de facturacion
     $gastos_facturacion = \GastofacturacionQuery::create()->filterByIdcategoriagasto($entity->getGastofacturacion()->getIdcategoriagasto())->find();
     $gastos_facturacion_array = array();
     foreach ($gastos_facturacion as $gasto_facturacion) {
         $id = $gasto_facturacion->getIdgastofacturacion();
         $gastos_facturacion_array[$id] = $gasto_facturacion->getGastofacturacionNombre();
     }
     //INSTANCIAMOS NUESTRO FORMULARIO
     $form = new \Admin\Clientes\Form\ExpedientegastoForm($entity->getIdexpediente(), $categoriasgasto_array, $proveedores_array, $entity->getExpedientegastoMoneda(), $gastos_facturacion_array);
     //Ponemos nuetros datos al formulario....
     $form->setData($entity->toArray(\BasePeer::TYPE_FIELDNAME));
     $form->get('expedientegasto_fecha')->setValue($entity->getExpedientegastoFecha('d/m/Y'));
     $form->get('idcategoriagasto')->setValue($entity->getGastofacturacion()->getIdcategoriagasto());
     $form->get('idgastofacturacion')->setValue($entity->getIdgastofacturacion());
     $form->get('idgastofacturacion')->setAttribute('disabled', false);
     //Enviamos a la vista
     $view_model = new ViewModel();
     $view_model->setTerminal(true)->setVariable('form', $form)->setVariable('entity', $entity)->setTemplate('/clientes/expedientes/modal/editarcargo');
     return $view_model;
 }
Ejemplo n.º 6
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @return Expedientegasto[]
  * @throws PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(ExpedientegastoPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(ExpedientegastoPeer::DATABASE_NAME);
         $criteria->add(ExpedientegastoPeer::IDEXPEDIENTEGASTO, $pks, Criteria::IN);
         $objs = ExpedientegastoPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Ejemplo n.º 7
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's BasePeer::TYPE_PHPNAME
  *
  * @param array  $arr     An array to populate the object from.
  * @param string $keyType The type of keys the array uses.
  * @return void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = ExpedientegastoPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setIdexpedientegasto($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setIdexpediente($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setIdgastofacturacion($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setIdproveedoritrade($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setIdempleado($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setExpedientegastoFecha($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setExpedientegastoMonto($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setExpedientegastoTipo($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setExpedientegastoComprobante($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setExpedientegastoNota($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setExpedientegastoMoneda($arr[$keys[10]]);
     }
 }