/**
  * 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 PresupuestoImportacion the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = PresupuestoImportacion::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #2
0
		        <tr class="principaltr">
		            <th data-field="Producto">Producto Importado</th>
		            <th data-field="Divisa">Divisa</th>
		            <th data-field="tipoimportacion">Tipo Importación</th>
		            <th data-field="fechallegada">Fecha estimada de la importación</th>
		            <th data-field="unidad">Costo unitario en divisa </th>
		            <th data-field="cantidad">Cantidad</th>
		            <th data-field="descripcion">Descripción</th>
		            <th data-field="totalbs">Total Bs.</th>
		            <th data-field="accion">Accion</th>
		        </tr>
		    </thead>
		    <tbody>
		    <?php 

		    	foreach (PresupuestoImportacion::model()->findAllByAttributes(array('producto_id'=>$presuImp->producto_id,'presupuesto_partida_id'=>$presuImp->presupuesto_partida_id)) as $key => $presIm) {
		    		
		    ?>
		    	<tr class="principaltr">

		    		<td><?php echo $this->obtenerCodigoNcmNombre($presIm->codigosNcms);?></td>
		    		<td><?php echo $presIm->divisa->abreviatura; ?></td>
					<td><?php echo $presIm->tipo =='corpovex' ? 'Corpovex' : 'Licitacion Internacional'; ?></td>
					<td><?php echo $presIm->fecha_llegada; ?></td>
					<td><?php echo number_format($presIm->monto_presupuesto,2,',','.'); ?></td>
					<td><?php echo $presIm->cantidad; ?></td>
					<td><?php echo $presIm->descripcion; ?></td>
		    		<td><?php echo number_format($presIm->monto_presupuesto*$presIm->cantidad*$presIm->divisa->tasa->tasa,2,',','.');?></td>
		    		<td><?php echo CHtml::link('Eliminar',Yii::app()->createAbsoluteUrl('/planificacion/eliminarProductoImportado',
		    			array('ppid'=>$presIm->presupuesto_partida_id,'pid'=>$presIm->producto_id,'cn'=>$presIm->codigo_ncm_id)),
		    		array('onClick'=>"eliminar('".$this->obtenerCodigoNcmNombre($presIm->codigosNcms)."');"));?></td>
 public function actionEliminarProductoImportado()
 {
     //if (isset($_GET['ppid']) && isset($_GET['pid']) && isset($_GET['cn'])  ){
     $presuPartidaId = Yii::app()->getRequest()->getQuery('ppid');
     $productoId = Yii::app()->getRequest()->getQuery('pid');
     $codigoNcmId = Yii::app()->getRequest()->getQuery('cn');
     //}
     $presuImps = array();
     $producto = PresupuestoImportacion::model()->findByAttributes(array('presupuesto_partida_id' => $presuPartidaId, 'producto_id' => $productoId, 'codigo_ncm_id' => $codigoNcmId));
     if (!empty($producto)) {
         if ($producto->presupuestoPartida->ente_organo_id == $this->usuario()->ente_organo_id) {
             $transaction = $producto->dbConnection->beginTransaction();
             // Transaction begin //Yii::app()->db->beginTransaction
             try {
                 //$producto->scenario = 'eliminararancelario';
                 if ($producto->delete()) {
                     $transaction->commit();
                     // committing
                     //return true;
                 } else {
                     $transaction->rollBack();
                 }
             } catch (Exception $e) {
                 $transaction->rollBack();
                 //return false;
             }
             if (!empty($presuPartidaId)) {
                 $presuImps = PresupuestoImportacion::model()->findAllByAttributes(array('presupuesto_partida_id' => $presuPartidaId));
             }
         }
     }
     echo $this->renderPartial('_importado', array('presuImps' => $presuImps), false);
 }