コード例 #1
0
 public function IndexAction()
 {
     $almacenes = new Almacenes();
     $this->values['almacenes'] = $almacenes->fetchAll('', 'Nombre', false);
     unset($almacenes);
     return array('template' => $this->entity . '/index.html.twig', 'values' => $this->values);
 }
コード例 #2
0
 /**
  * Valida que la cantidad indicada esté disponible en
  * el almacén, ubicación y lote
  * 
  * @return boolean
  */
 public function validaLogico()
 {
     parent::validaLogico();
     $articulo = new Articulos($this->IDArticulo);
     $bloqueoStock = $articulo->getBloqueoStock()->getIDTIpo() == '1';
     if ($this->Unidades == 0) {
         $this->_errores[] = "Debe indicar una cantidad distinta a cero";
     }
     $almacen = new Almacenes($this->IDAlmacen);
     //print_r($this);
     if ($almacen->getControlUbicaciones()->getIDTipo() == '1' and $this->IDUbicacion == 0) {
         $this->_errores[] = "Debe indicar la ubicación";
     }
     unset($almacen);
     if ($bloqueoStock) {
         $udadMedidaVenta = $articulo->getUMV();
         $udadMedidaAlmacen = $articulo->getUMA();
         $stock = new Existencias();
         $existencias = $stock->getStock($this->IDArticulo, $this->IDAlmacen, $this->IDLote, $this->IDUbicacion);
         unset($stock);
         // Calcular las cantidades de ese articulo, almacen, lote y ubicación que estan
         // en lineas de expediciones sin estar expedidas aún. O sea lo que está en
         // proceso de expedición. No tengo en cuenta los valores de la BD de la línea actual
         // porque puede que hayan cambiado.
         $filtro = "IDLinea<>'{$this->IDLinea}' and Expedida='0' and IDAlmacen='{$this->IDAlmacen}' and IDLote='{$this->IDLote}' and IDUbicacion='{$this->IDUbicacion}'";
         $expedicion = new Expediciones();
         $rows = $expedicion->cargaCondicion("sum(Unidades) as Unidades,sum(Pales) as Pales,sum(Cajas) as Cajas", $filtro);
         $row = $rows[0];
         $row['Unidades'] += $this->Unidades;
         $row['Pales'] += $this->Pales;
         $row['Cajas'] += $this->Cajas;
         unset($expedicion);
         if ($existencias['DI'] < $articulo->convertUnit('UMV', 'UMA', $row['Unidades'])) {
             $this->_errores[] = "Hay " . round($articulo->convertUnit('UMA', 'UMV', $existencias['DI']), 2) . " {$udadMedidaVenta} (" . round($existencias['DI'], 2) . " {$udadMedidaAlmacen}) disponibles para ese lote y ubicación";
         }
         if ($existencias['CA'] < $row['Cajas']) {
             $this->_errores[] = "Hay {$existencias['CA']} cajas disponibles para ese lote y ubicacion";
         }
         if ($existencias['PT'] < $row['Pales']) {
             $this->_errores[] = "Hay {$existencias['PT']} pales disponibles para ese lote y ubicacion";
         }
     }
     unset($articulo);
     return count($this->_errores) == 0;
 }
コード例 #3
0
 /**
  * Calculo las unidades (kgrs) netas restando a las unidades brutas
  * Comprueba que se haya indicado el lote si procede(
  * Comprueba que se haya indicado la ubiación si procede
  *
  * @return boolean
  */
 public function validaLogico()
 {
     parent::validaLogico();
     $this->setUnidadesNetas($this->UnidadesBrutas - ($this->Pales * $this->DestarePale + $this->Cajas * $this->DestareCaja));
     if ($this->Unidades == 0 or $this->UnidadesNetas == 0) {
         $this->_errores[] = "Debe indicar la cantidad recibida y las unidades brutas";
     }
     $articulo = new Articulos($this->IDArticulo);
     if ($articulo->getTrazabilidad()->getIDTipo() and !$this->IDLote) {
         $this->_errores[] = "Debe indicar un lote";
     }
     unset($articulo);
     $almacen = new Almacenes($this->IDAlmacen);
     if ($almacen->getControlUbicaciones()->getIDTipo() and !$this->IDUbicacion) {
         $this->_errores[] = "Debe indicar una ubicación";
     }
     unset($almacen);
     return count($this->_errores) == 0;
 }
コード例 #4
0
ファイル: ParetoForm.php プロジェクト: hipogea/zega
 /**
  * Authenticates the password.
  * This is the 'authenticate' validator as declared in rules().
  */
 public function validarcentroalmacen($attribute, $params)
 {
     $centro = Centros::model()->findByPk($this->centro);
     $almacen = Almacenes::model()->findByPk($this->almacen);
     if (is_null($centro)) {
         $this->adderror('centro', 'El centro no existe');
     }
     if (is_null($almacen)) {
         $this->adderror('almacen', 'El almacen no existe');
     }
     if (!$almacen->codcen == $this->centro) {
         $this->adderror('almacen', 'Este almacen no correponde a este centro');
     }
 }
コード例 #5
0
ファイル: AlmacenesController.php プロジェクト: hipogea/zega
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Almacenes the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Almacenes::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
コード例 #6
0
ファイル: busqueda.php プロジェクト: hipogea/zega
		<?php 
echo $form->error($model, 'codcen');
?>
	</div>
	




	<div>	  
		
		<?php 
echo $form->labelEx($model, 'codalm');
?>
		<?php 
$datos = CHtml::listData(Almacenes::model()->findAll(array('order' => 'nomal')), 'codalm', 'nomal');
echo $form->DropDownList($model, 'codalm', $datos, array('empty' => '--Llene el centro--', 'disabled' => $model->isNewRecord ? '' : 'disabled'));
?>
		<?php 
echo $form->error($model, 'codalm');
?>
	</div>

	

	<div class="row">
		<?php 
echo $form->labelEx($model, 'periodocontable');
?>
		<?php 
echo $form->textField($model, 'periodocontable', array('size' => 4, 'maxlength' => 4));
コード例 #7
0
ファイル: MiFactoria.php プロジェクト: hipogea/zega
 public static function Validacentro($centro, $almacen)
 {
     $retorno = true;
     $almacenes = Almacenes::model()->findByPk($almacen);
     if (!is_null($almacenes)) {
         if (is_null($almacenes->centros)) {
             $retorno = false;
         } else {
             if ($almacenes->centros->codcen != trim($centro)) {
                 $retorno = false;
             }
         }
     } else {
         $retorno = false;
     }
     return $retorno;
 }
コード例 #8
0
ファイル: desplegableAjax.php プロジェクト: albatronic/hermes
/**
 * Construye un tag html <select> con todas las ubicaciones del almacen indicado en el parametro
 * @param string $filtro El id de almacen
 * @param string $nameSelect El Name del select
 * @param string $idSelect El Id del select
 * @return string Codigo html con el tag select
 */
function ubicacionesAlmacen($filtro, $nameSelect = '', $idSelect = '')
{
    if ($nameSelect == '') {
        $nameSelect = $_GET['nameselect'];
    }
    if ($idSelect == '') {
        $idSelect = $_GET['idselect'];
    }
    // En el filtro viene el id del almacen
    $idAlmacen = $filtro;
    $almacen = new Almacenes($idAlmacen);
    $rows = $almacen->getUbicaciones();
    unset($almacen);
    $ch = "";
    foreach ($rows as $row) {
        $ch .= "<option value='" . $row['Id'] . "'>" . $row['Value'] . "</option>";
    }
    return $ch;
}
コード例 #9
0
ファイル: Agentes.class.php プロジェクト: albatronic/hermes
 /**
  * Devuelve un array con todos los almacenes de la empresa a
  * los que tiene acceso el usuario.
  * Si no se indica empresa, se toma la actual: $_SESSION['emp']
  *
  * @param integer $idEmpresa EL id de Empresa
  * @return array
  */
 public function getAlmacenes($idEmpresa = '', $columna = 'Nombre', $defecto = true)
 {
     //if ($idEmpresa == '')
     //    $idEmpresa = $_SESSION['emp'];
     if ($columna == '') {
         $columna = "Nombre";
     }
     if ($this->IDAlmacen < 1) {
         //Puede acceder a todos
         $almacen = new Almacenes();
         $almacenes = $almacen->fetchAll($idEmpresa, $columna, $defecto);
     } else {
         //Puede acceder solo a una
         $almacen = new Almacenes($this->IDAlmacen);
         $almacenes[] = array('Id' => $almacen->getIDAlmacen(), 'Value' => $almacen->getNombre());
     }
     unset($almacen);
     return $almacenes;
 }
コード例 #10
0
 /**
  * Genera un listado en formato PDF en base a los parametros obtenidos
  * del fichero listados.yml de cada controlador y los datos filtrados
  * segun el request
  * @return array Template y valores
  */
 public function listadoAction($idAlmacen = '', $idDia = '', $idPeriodo = '', $idEstado = '', $idRuta = '')
 {
     if ($idAlmacen == '') {
         $idAlmacen = $this->request[2];
     }
     if ($idDia == '') {
         $idDia = $this->request[3];
     }
     if ($idPeriodo == '') {
         $idPeriodo = $this->request[4];
     }
     if ($idEstado == '') {
         $idEstado = $this->request[5];
     }
     if ($idRuta == '') {
         $idRuta = $this->request[6];
     }
     $fecha = new Fecha();
     $fechaDesde = $fecha->sumaDias(-1 * $idPeriodo);
     unset($fecha);
     $almacen = new Almacenes($idAlmacen);
     $dia = new DiasSemana($idDia);
     $ruta = new RutasReparto($idRuta);
     $opciones = array('almacen' => $almacen->getNombre(), 'dia' => $dia->getDescripcion(), 'ruta' => $ruta->getDescripcion());
     unset($almacen);
     unset($dia);
     unset($ruta);
     $albaran = new AlbaranesCab();
     $ruta = new RutasRepartoDetalle();
     $em = new EntityManager($albaran->getConectionName());
     if ($em->getDbLink()) {
         $query = "SELECT a.IDAlbaran\n                            FROM \n                                {$albaran->getDataBaseName()}.{$albaran->getTableName()} as a, \n                                {$ruta->getDataBaseName()}.{$ruta->getTableName()} as r\n                            WHERE a.Fecha>'{$fechaDesde}'\n                            AND a.IDEstado='{$idEstado}'\n                            AND a.IDAlmacen='{$idAlmacen}'\n                            AND a.IDSucursal='{$_SESSION['suc']}'\n                            AND a.DiaReparto='{$idDia}'\n                            AND a.IDDirec=r.IDDirec\n                            AND r.IDRuta = '{$idRuta}'\n                            ORDER BY r.OrdenDirec DESC;";
         $em->query($query);
         $rows = $em->fetchResult();
         $em->desConecta();
     }
     unset($albaran);
     unset($ruta);
     $pdf = new listadoOrdenRepartoPDF("L", 'mm', "A4", $opciones);
     $pdf->SetTopMargin(15);
     $pdf->SetLeftMargin(10);
     $pdf->AliasNbPages();
     $pdf->AddPage();
     $repartidor = "";
     foreach ($rows as $orden => $row) {
         $albaran = new AlbaranesCab($row['IDAlbaran']);
         $cliente = $albaran->getIDCliente();
         if ($repartidor != $albaran->getIDRepartidor()) {
             $repartidor = $albaran->getIDRepartidor();
             $pdf->SetFont('Arial', 'B', 10);
             $pdf->Cell(0, 4, $repartidor, 0, 1);
             $pdf->SetFont('Arial', '', 9);
         }
         $pdf->Cell(15, 4, "", 0, 0, "R");
         $pdf->Cell(15, 4, "", 0, 0, "C");
         $pdf->Cell(150, 4, $cliente->getNombreComercial() . " " . $cliente->getRazonSocial(), 0, 0, "L");
         $pdf->Cell(50, 4, $albaran->getIDComercial()->getNombre(), 0, 0, "L");
         $pdf->Ln();
         $pdf->Cell(30, 4, "", 0, 0, "C");
         $pdf->Cell(150, 4, $albaran->getIDDirec()->getDireccion() . " - " . $albaran->getIDDirec()->getIDPoblacion, 0, 0, "L");
         $pdf->Ln();
         $pdf->Ln();
         $pdf->Line($pdf->GetX(), $pdf->GetY(), 290, $pdf->GetY());
     }
     unset($cliente);
     unset($albaran);
     $archivo = Archivo::getTemporalFileName();
     $pdf->Output($archivo, 'F');
     unset($pdf);
     $this->values['archivo'] = $archivo;
     $template = '_global/listadoPdf.html.twig';
     return array('template' => $template, 'values' => $this->values);
 }
コード例 #11
0
ファイル: _search.php プロジェクト: hipogea/zega
				<div style="float: left; ">
			        <?php 
echo $form->labelEx($model, 'codentro');
?>
					<?php 
$datos = CHtml::listData(Centros::model()->findAll(array('order' => 'nomcen')), 'codcen', 'nomcen');
echo $form->DropDownList($model, 'codentro', $datos, array('empty' => '--Seleccione un centro --'));
?>
				</div>

		<div class="row">
			<?php 
echo $form->labelEx($model, 'codigoalma');
?>
			<?php 
$datos6 = CHtml::listData(Almacenes::model()->findAll(), 'codalm', 'nomal');
echo $form->DropDownList($model, 'codigoalma', $datos6, array('empty' => '--Seleccione un almacen --'));
?>
		</div>

				<div class="row">
					<?php 
echo $form->label($model, 'texto');
?>
					<?php 
echo $form->textField($model, 'texto', array('size' => 30, 'maxlength' => 30));
?>
				</div>

				<div class="row">
					<?php 
コード例 #12
0
 /**
  * Devuelve un array con todos los almacenes de la empresa a
  * los que tiene acceso el usuario.
  * Si no se indica empresa, se toma la actual: $_SESSION['emp']
  *
  * @param integer $idEmpresa EL id de Empresa
  * @return array
  */
 public function getAlmacenes($idEmpresa = '')
 {
     if ($idEmpresa == '') {
         $idEmpresa = $_SESSION['emp'];
     }
     if ($this->IDAlmacen < 1) {
         //Puede acceder a todos
         $almacen = new Almacenes();
         $almacenes = $almacen->fetchAll($idEmpresa, 'Nombre');
     } else {
         //Puede acceder solo a una
         $almacen = new Almacenes($this->IDAlmacen);
         $almacenes[] = array('Id' => $almacen->getIDAlmacen(), 'Value' => $almacen->getNombre());
     }
     unset($almacen);
     return $almacenes;
 }
コード例 #13
0
ファイル: Almacendocs.php プロジェクト: hipogea/experimento
 public function checkcentros($attribute, $params)
 {
     $modeloalmacenes = Almacenes::model()->findByPk($this->codalmacen);
     if (is_null($modeloalmacenes)) {
         $this->adderror('codalmacen', 'Este almacen no existe');
     } else {
         if (!$modeloalmacenes->codcen === $this->codcentro) {
             $this->adderror('codalmacen', 'Este almacen no existe en el centro seleccionado');
         }
     }
 }
コード例 #14
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Maestrocompo();
     $model->valorespordefecto();
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['Maestrocompo'])) {
         $model->attributes = $_POST['Maestrocompo'];
         $transaccion = $model->dbConnection->beginTransaction();
         if ($model->save()) {
             //actualizamos tambien las tablas inventario y maestrodetalle
             //inventario
             $centros = Centros::model()->findAll();
             foreach ($centros as $fila) {
                 $modeloporcentros = new Maestrodetallecentros();
                 $modeloporcentros->setAttributes(array('hcodart' => $model->codigo, 'codcen' => $fila->codcen, 'catvalor' => '', 'iqf' => '0'), true);
                 // var_dump($fila);
                 $modeloalmacenes = Almacenes::model()->findall("codcen=:vcdocen", array(":vcdocen" => $fila->codcen));
                 foreach ($modeloalmacenes as $filaalmacen) {
                     //$contact->setIsNewRecord(true);
                     $modeloinventario = new Alinventario();
                     $modelodetalle = new Maestrodetalle();
                     $modelodetalle->setAttributes(array('codart' => $model->codigo, 'codcentro' => $fila->codcen, 'codal' => $filaalmacen->codalm, 'codgrupoventas' => '001', 'canaldist' => '01', 'sujetolote' => '0', 'canteconomica' => 0, 'cantreposic' => 0, 'cantreorden' => 0, 'leadtime' => 0, 'controlprecio' => 'V'), true);
                     $modeloinventario->setAttributes(array('codart' => $model->codigo, 'codcen' => $fila->codcen, 'codalm' => $filaalmacen->codalm, 'cantlibre' => 0, 'canttran' => 0, 'cantres' => 0, 'ubicacion' => '', 'lote' => '', 'codmon' => Yii::app()->params['monedadef']), true);
                     //   var_dump($modeloinventario);
                     /*  echo "<br><br><br>";
                     		  var_dump($modelodetalle->attributes);
                     		  echo "<br><br><br>";*/
                     //  var_dump($modeloinventario->attributes);
                     if (!$modeloinventario->save() or !$modelodetalle->save()) {
                         $transaccion->rollback();
                         throw new CHttpException(404, 'No se pudieron grabar los datos detalles ');
                     } else {
                     }
                 }
                 //bucle de almacenes
                 if (!$modeloporcentros->save()) {
                     $transaccion->rollback();
                     throw new CHttpException(404, 'No se pudieron grabar los datos del modelo poR CENTROS ');
                 }
             }
             ///FIN DEL BUCLE CENTROS
             $transaccion->commit();
             Yii::app()->user->setFlash('success', "Se ha creado el material  " . $model->codigo);
         } else {
             /// SSI HUBO UN ERRRO AL GRANAR EL MATERIAL
             $transaccion->rollback();
             throw new CHttpException(404, 'No se pudieron grabar los datos del material ');
         }
         $this->redirect(array('update', 'id' => $model->codigo));
     }
     /// si no se puede grabar
     $this->render('create', array('model' => $model, 'habilitado' => ''));
 }
コード例 #15
0
ファイル: Maestrocompo.php プロジェクト: hipogea/zega
 public function checkalmacen($attribute, $params)
 {
     if (Almacenes::model()->find("codalm =:xcodalm and  codcen=:xcodcen", array(":xcodalm" => $this->alam, ":xcodcen" => $this->codcent)) == null) {
         $this->adderror('alam', 'Este almacen no corresponde a este centro');
     }
 }
コード例 #16
0
ファイル: Articulos.class.php プロジェクト: albatronic/hermes
 /**
  * Devuelve los mvtos de almacén del artículo en curso para
  * el almacen y el periodo de fechas indicado.
  * 
  * Los movimientos se ordenan por almacén y descendentemente por fecha y hora
  * 
  * @param integer $idAlmacen Por defecto todos los almacenes
  * @param date $desdeFecha Por defecto todas
  * @param date $hastaFecha Por defecto todas
  * @return array
  */
 public function getMvtosAlmacen($idAlmacen = 0, $desdeFecha = '', $hastaFecha = '')
 {
     $array = array();
     $filtro = "(mv.IDArticulo='{$this->IDArticulo}')";
     $filtro .= $idAlmacen <= 0 ? " and (1)" : " and (mv.IDAlmacen='{$idAlmacen}')";
     $filtro .= $desdeFecha == '' ? " and (1)" : " and (mv.Fecha>='{$desdeFecha}')";
     $filtro .= $hastaFecha == '' ? " and (1)" : " and (mv.Fecha<='{$hastaFecha}')";
     $mvtosAlmacen = new MvtosAlmacen();
     $tablaMvtos = $mvtosAlmacen->getDataBaseName() . "." . $mvtosAlmacen->getTableName();
     $almacenes = new Almacenes();
     $tablaAlmacenes = $almacenes->getDataBaseName() . "." . $almacenes->getTableName();
     $tipos = new TiposMvtosAlmacen();
     $tablaTipos = $tipos->getDataBaseName() . "." . $tipos->getTableName();
     $em = new EntityManager($this->getConectionName());
     if ($em->getDbLink()) {
         $query = "select\n                        al.Nombre as Almacen,\n                        ti.Descripcion,\n                        ti.Signo,\n                        ti.TipoDocumento,\n                        mv.Fecha,\n                        mv.Hora,\n                        mv.IDUbicacion,\n                        mv.IDLote,\n                        mv.IDDocumento,\n                        mv.UnidadesE,\n                        mv.UnidadesS\n                      from\n                        {$tablaMvtos} as mv\n                        left join {$tablaAlmacenes} as al on mv.IDAlmacen=al.IDAlmacen                        \n                        left join {$tablaTipos} as ti on mv.IDTipo=ti.Id                        \n                      where {$filtro}\n                      order by mv.IDAlmacen,mv.Fecha DESC,mv.Hora DESC";
         $em->query($query);
         $array = $em->fetchResult();
         $em->desConecta();
     }
     unset($em);
     return $array;
 }
コード例 #17
0
 public function actioncargaalmacenes1()
 {
     $criteria = new CDbCriteria();
     $criteria->addCondition("codcen=:proved");
     $valor = $_POST['cargainForm']['centro'];
     //echo "el valor es ..".$valor;
     //Yii::app()->end();
     $data = CHtml::listData(Almacenes::model()->findAll("codcen='" . $valor . "'"), "codalm", "nomal");
     echo CHtml::tag('option', array('value' => null), CHtml::encode('Escoja un almacen'), true);
     foreach ($data as $value => $name) {
         echo CHtml::tag('option', array('value' => $value), CHtml::encode($name), true);
     }
 }
コード例 #18
0
 /**
  * Valida la idoneidad del movimiento.
  *
  * Chequea si se aplica o no la trazabilidad, la ubicacion y el bloqueo de stock
  *
  * @param char $signo El signo del movimiento (E=Entrada, S=Salida)
  * @return boolean
  */
 private function validaMovimiento($signo)
 {
     $articulo = new Articulos($this->IDArticulo);
     $almacen = new Almacenes($this->IDAlmacen);
     $hayTrazabilidad = $articulo->getTrazabilidad()->getIDTipo();
     $hayBloqueoStock = $articulo->getBloqueoStock()->getIDTipo();
     $hayControlUbicaciones = $almacen->getControlUbicaciones()->getIDTipo();
     if ($hayBloqueoStock) {
         $exi = new Existencias();
         $stock = $exi->getStock($this->IDArticulo, $this->IDAlmacen, $this->IDLote, $this->IDUbicacion, '', 'UMA');
         unset($exi);
         switch ($signo) {
             case 'S':
                 $unidades = $this->UnidadesE + $this->UnidadesS;
                 if ($unidades < 0) {
                     $okBloqueoStock = true;
                 } else {
                     $okBloqueoStock = $stock['RE'] >= $unidades;
                 }
                 break;
             case 'E':
                 $unidades = $this->UnidadesE + $this->UnidadesS;
                 if ($unidades < 0) {
                     $okBloqueoStock = $unidades + $stock['RE'] >= 0;
                 } else {
                     $okBloqueoStock = true;
                 }
                 break;
         }
     } else {
         $okBloqueoStock = true;
     }
     $okTrazabilidad = (!$hayTrazabilidad or $this->IDLote != 0);
     $okUbicacion = (!$hayControlUbicaciones or $this->IDUbicacion != 0);
     if (!$okBloqueoStock) {
         $this->_errores[] = "No hay stock suficiente para " . $articulo->getDescripcion();
     }
     if (!$okTrazabilidad) {
         $this->_errores[] = "Debe indicar el lote para " . $articulo->getDescripcion();
     }
     if (!$okUbicacion) {
         $this->_errores[] = "Debe indicar la ubicación para " . $articulo->getDescripcion();
     }
     unset($articulo);
     unset($almacen);
     return count($this->_errores) == 0;
 }