/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Expedientearchivo $obj A Expedientearchivo object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool($obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getIdexpedientearchivo(); } // if key === null ExpedientearchivoPeer::$instances[$key] = $obj; } }
/** * Exclude object from result * * @param Expedientearchivo $expedientearchivo Object to remove from the list of results * * @return ExpedientearchivoQuery The current query, for fluid interface */ public function prune($expedientearchivo = null) { if ($expedientearchivo) { $this->addUsingAlias(ExpedientearchivoPeer::IDEXPEDIENTEARCHIVO, $expedientearchivo->getIdexpedientearchivo(), Criteria::NOT_EQUAL); } return $this; }
public function editarAction() { $request = $this->getRequest(); $idcliente = $this->params()->fromRoute('id'); $idexpediente = $this->params()->fromRoute('idexpediente'); if ($request->isPost()) { } $exist = \ExpedienteQuery::create()->filterByIdexpediente($idexpediente)->exists(); if ($exist) { $entity = \ExpedienteQuery::create()->findPk($idexpediente); $form = new \Admin\Clientes\Form\ExpedienteForm($idcliente); $form->setData($entity->toArray(\BasePeer::TYPE_FIELDNAME)); $form->get('expediente_fechainicio')->setValue($entity->getExpedienteFechainicio('d/m/Y')); $form->get('expediente_fechafin')->setValue($entity->getExpedienteFechafin('d/m/Y')); //ARCHIVOS $files = \ExpedientearchivoQuery::create()->filterByIdexpediente($entity->getIdexpediente())->find(); $files_array = array(); $file = new \Expedientearchivo(); foreach ($files as $file) { $file_path = $file->getExpedientearchivoArchivo(); $file_name = explode('files/expedientes/' . $entity->getIdexpediente() . '/', $file->getExpedientearchivoArchivo()); $tmp['id'] = $file->getIdexpedientearchivo(); $tmp['name'] = $file_name[1]; $tmp['size'] = $file->getExpedientearchivoSize(); $tmp['type'] = mime_content_type($_SERVER['DOCUMENT_ROOT'] . '/' . $file->getExpedientearchivoArchivo()); $files_array[] = $tmp; } //FACTURACION MXN //El esqueleto de nuestro arreglo $totales = array('subtotal' => 0, 'iva' => 0, 'total' => 0, 'utilidad' => 0, 'anticipo' => 0, 'saldo' => 0); //El esqueleto de nuestro arreglo $totales_usd = array('subtotal' => 0, 'iva' => 0, 'total' => 0, 'utilidad' => 0, 'anticipo' => 0, 'saldo' => 0); $expedientes_gastos = \ExpedientegastoQuery::create()->filterByExpedientegastoMoneda('mxn')->orderByExpedientegastoFecha(\Criteria::DESC)->filterByIdexpediente($entity->getIdexpediente())->groupByIdgastofacturacion()->find(); $expedientes_gastos_array = array(); foreach ($expedientes_gastos as $expediente_gasto) { $key = $expediente_gasto->getGastofacturacion()->getGastofacturacionNombre(); $expedientes_gastos_array[$key] = array('id' => $expediente_gasto->getIdgastofacturacion(), 'cargos_recibir' => '', 'cargos_conocidos' => '', 'sujetos_iva' => '', 'no_sujetos_iva' => ''); $expedientes_gastos_array[$key]['details'] = \ExpedientegastoQuery::create()->filterByExpedientegastoMoneda('mxn')->orderByIdexpedientegasto(\Criteria::DESC)->joinEmpleado()->withColumn('CONCAT(empleado_nombre,empleado_apellidopaterno,empleado_apallidomaterno)', 'empleado_nombre')->filterByIdexpediente($entity->getIdexpediente())->filterByIdgastofacturacion($expediente_gasto->getIdgastofacturacion())->find()->toArray(null, false, \BasePeer::TYPE_FIELDNAME); } //cargos conocidos $expedientes_gastos = \ExpedientegastoQuery::create()->filterByExpedientegastoMoneda('mxn')->filterByIdexpediente($entity->getIdexpediente())->filterByExpedientegastoTipo('gastorecibir')->withColumn('SUM(expedientegasto_monto)', 'gastorecibir_total')->groupByIdgastofacturacion()->find(); foreach ($expedientes_gastos as $expediente_gasto) { $key = $expediente_gasto->getGastofacturacion()->getGastofacturacionNombre(); $expedientes_gastos_array[$key]['cargos_recibir'] = $expediente_gasto->getVirtualColumn('gastorecibir_total'); } //cargos conocidos $expedientes_gastos = \ExpedientegastoQuery::create()->filterByExpedientegastoMoneda('mxn')->filterByIdexpediente($entity->getIdexpediente())->filterByExpedientegastoTipo('gastoconocido')->withColumn('SUM(expedientegasto_monto)', 'gastoconocido_total')->groupByIdgastofacturacion()->find(); $cargos_conocidos = 0.0; foreach ($expedientes_gastos as $expediente_gasto) { $cargos_conocidos += $expediente_gasto->getVirtualColumn('gastoconocido_total'); $key = $expediente_gasto->getGastofacturacion()->getGastofacturacionNombre(); $expedientes_gastos_array[$key]['cargos_conocidos'] = $expediente_gasto->getVirtualColumn('gastoconocido_total'); } //cobro $expedientes_gastos = \ExpedientegastoQuery::create()->filterByExpedientegastoMoneda('mxn')->filterByIdexpediente($entity->getIdexpediente())->filterByExpedientegastoTipo('cobro')->withColumn('SUM(expedientegasto_monto)', 'cobro_total')->groupByIdgastofacturacion()->find(); $cobros = 0.0; foreach ($expedientes_gastos as $expediente_gasto) { $cobros = +$expediente_gasto->getVirtualColumn('cobro_total'); $key = $expediente_gasto->getGastofacturacion()->getGastofacturacionNombre(); $iva = $expediente_gasto->getGastofacturacion()->getGastofacturacionIva(); if ($iva == 0) { $expedientes_gastos_array[$key]['no_sujetos_iva'] = $expediente_gasto->getVirtualColumn('cobro_total'); $calc_iva = $expediente_gasto->getVirtualColumn('cobro_total') * (double) ('0.' . $iva); $cal_sub = $expediente_gasto->getVirtualColumn('cobro_total') - $calc_iva; $totales['subtotal'] += $cal_sub; $totales['iva'] += $calc_iva; $totales['total'] += $expediente_gasto->getVirtualColumn('cobro_total') + $calc_iva; } else { $expedientes_gastos_array[$key]['sujetos_iva'] = $expediente_gasto->getVirtualColumn('cobro_total'); $calc_iva = $expediente_gasto->getVirtualColumn('cobro_total') * (double) ('0.' . $iva); $cal_sub = $expediente_gasto->getVirtualColumn('cobro_total'); $totales['subtotal'] += $cal_sub; $totales['iva'] += $calc_iva; $totales['total'] += $expediente_gasto->getVirtualColumn('cobro_total') + $calc_iva; } } //anticipo $expedientes_gastos = \ExpedienteanticipoQuery::create()->filterByIdexpediente($entity->getIdexpediente())->filterByExpedienteanticipoMoneda('mxn')->withColumn('SUM(expedienteanticipo_cantidad)', 'anticipo_total')->findOne(); if (!empty($expedientes_gastos)) { $totales['anticipo'] = $expedientes_gastos->getVirtualColumn('anticipo_total'); } $totales['saldo'] = $totales['total'] - $totales['anticipo']; $totales['utilidad'] = $cobros - $cargos_conocidos; //FACTURACION USD $expedientes_gastos = \ExpedientegastoQuery::create()->filterByExpedientegastoMoneda('usd')->filterByExpedientegastoMoneda('usd')->orderByExpedientegastoFecha(\Criteria::DESC)->filterByIdexpediente($entity->getIdexpediente())->groupByIdgastofacturacion()->find(); $expedientes_gastos_usd_array = array(); foreach ($expedientes_gastos as $expediente_gasto) { $key = $expediente_gasto->getGastofacturacion()->getGastofacturacionNombre(); $expedientes_gastos_usd_array[$key] = array('id' => $expediente_gasto->getIdgastofacturacion(), 'cargos_recibir' => '', 'cargos_conocidos' => '', 'sujetos_iva' => '', 'no_sujetos_iva' => ''); $expedientes_gastos_usd_array[$key]['details'] = \ExpedientegastoQuery::create()->filterByExpedientegastoMoneda('usd')->orderByIdexpedientegasto(\Criteria::DESC)->joinEmpleado()->withColumn('CONCAT(empleado_nombre,empleado_apellidopaterno,empleado_apallidomaterno)', 'empleado_nombre')->filterByIdexpediente($entity->getIdexpediente())->filterByIdgastofacturacion($expediente_gasto->getIdgastofacturacion())->find()->toArray(null, false, \BasePeer::TYPE_FIELDNAME); } //cargos conocidos $expedientes_gastos = \ExpedientegastoQuery::create()->filterByExpedientegastoMoneda('usd')->filterByIdexpediente($entity->getIdexpediente())->filterByExpedientegastoTipo('gastorecibir')->withColumn('SUM(expedientegasto_monto)', 'gastorecibir_total')->groupByIdgastofacturacion()->find(); foreach ($expedientes_gastos as $expediente_gasto) { $key = $expediente_gasto->getGastofacturacion()->getGastofacturacionNombre(); $expedientes_gastos_usd_array[$key]['cargos_recibir'] = $expediente_gasto->getVirtualColumn('gastorecibir_total'); } //cargos conocidos $expedientes_gastos = \ExpedientegastoQuery::create()->filterByExpedientegastoMoneda('usd')->filterByIdexpediente($entity->getIdexpediente())->filterByExpedientegastoTipo('gastoconocido')->withColumn('SUM(expedientegasto_monto)', 'gastoconocido_total')->groupByIdgastofacturacion()->find(); $cargos_conocidos = 0.0; foreach ($expedientes_gastos as $expediente_gasto) { $cargos_conocidos += $expediente_gasto->getVirtualColumn('gastoconocido_total'); $key = $expediente_gasto->getGastofacturacion()->getGastofacturacionNombre(); $expedientes_gastos_usd_array[$key]['cargos_conocidos'] = $expediente_gasto->getVirtualColumn('gastoconocido_total'); } //cargos conocidos $cobros = 0.0; $expedientes_gastos = \ExpedientegastoQuery::create()->filterByExpedientegastoMoneda('usd')->filterByIdexpediente($entity->getIdexpediente())->filterByExpedientegastoTipo('cobro')->withColumn('SUM(expedientegasto_monto)', 'cobro_total')->groupByIdgastofacturacion()->find(); foreach ($expedientes_gastos as $expediente_gasto) { $cobros += $expediente_gasto->getVirtualColumn('cobro_total'); $key = $expediente_gasto->getGastofacturacion()->getGastofacturacionNombre(); $iva = $expediente_gasto->getGastofacturacion()->getGastofacturacionIva(); if ($iva == 0) { $expedientes_gastos_usd_array[$key]['no_sujetos_iva'] = $expediente_gasto->getVirtualColumn('cobro_total'); $calc_iva = $expediente_gasto->getVirtualColumn('cobro_total') * (double) ('0.' . $iva); $cal_sub = $expediente_gasto->getVirtualColumn('cobro_total') - $calc_iva; $totales_usd['subtotal'] += $cal_sub; $totales_usd['iva'] += $calc_iva; $totales_usd['total'] += $expediente_gasto->getVirtualColumn('cobro_total') + $calc_iva; } else { $expedientes_gastos_usd_array[$key]['sujetos_iva'] = $expediente_gasto->getVirtualColumn('cobro_total'); $calc_iva = $expediente_gasto->getVirtualColumn('cobro_total') * (double) ('0.' . $iva); $cal_sub = $expediente_gasto->getVirtualColumn('cobro_total'); $totales_usd['subtotal'] += $cal_sub; $totales_usd['iva'] += $calc_iva; $totales_usd['total'] += $expediente_gasto->getVirtualColumn('cobro_total') + $calc_iva; } } //anticipo $expedientes_gastos = \ExpedienteanticipoQuery::create()->filterByIdexpediente($entity->getIdexpediente())->filterByExpedienteanticipoMoneda('usd')->withColumn('SUM(expedienteanticipo_cantidad)', 'anticipo_total')->findOne(); if (!empty($expedientes_gastos)) { $totales_usd['anticipo'] = $expedientes_gastos->getVirtualColumn('anticipo_total'); } $totales_usd['saldo'] = $totales_usd['total'] - $totales_usd['anticipo']; $totales_usd['utilidad'] = $cobros - $cargos_conocidos; //SERVICIOS $servicios = \ExpedienteservicioQuery::create()->filterByIdexpediente($entity->getIdexpediente())->find(); //LOS ANTICIPOS $anticipos = array(); $anticipos['mxn'] = \ExpedienteanticipoQuery::create()->filterByExpedienteanticipoMoneda('mxn')->filterByIdexpediente($entity->getIdexpediente())->find(); $anticipos['usd'] = \ExpedienteanticipoQuery::create()->filterByExpedienteanticipoMoneda('usd')->filterByIdexpediente($entity->getIdexpediente())->find(); //CONSIGNATARIO, EMBARCADOR if ($entity->getExpedienteTipo() == 'importacion') { $consignatario = $entity->getCliente()->getClienteRazonsocial(); $embarcador = $entity->getProveedorcliente()->getProveedorclienteNombre(); } else { $embarcador = $entity->getCliente()->getClienteRazonsocial(); $consignatario = $entity->getProveedorcliente()->getProveedorclienteNombre(); } $cliente = $entity->getCliente(); $view_model = new ViewModel(); $view_model->setTemplate('admin/clientes/expedientes/editar'); $view_model->setVariables(array('servicios' => $servicios, 'entity' => $entity, 'form' => $form, 'successMessages' => json_encode($this->flashMessenger()->getSuccessMessages()), 'cliente' => $cliente, 'facturacion' => $expedientes_gastos_array, 'totales' => $totales, 'facturacion_usd' => $expedientes_gastos_usd_array, 'totales_usd' => $totales_usd, 'files' => json_encode($files_array), 'consignatario' => $consignatario, 'embarcador' => $embarcador, 'anticipos' => $anticipos)); return $view_model; } else { return $this->redirect()->toUrl('/clientes/ver/' . $idcliente . '?active=expedientes'); } }