public function generadetalle() { $identidad = (int) MiFactoria::cleanInput($_GET['id']); if (is_null(Solcot::model()->findByPk($identidad))) { throw new CHttpException(500, 'NO existe ningun registor pàra este ID'); } foreach (yii::app()->maletin->getvalues(NOMBRECLASE_DESOLPE) as $fila) { $registro = new Desolcot(); $registro->setAttributes(array('hidsolcot' => $identidad, 'hiddesolpe' => $fila['idregistro'])); } }
<?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'detalle-grid', 'itemsCssClass' => 'table table-striped table-bordered table-hover', 'dataProvider' => Desolcot::model()->search_por_solcot($model->id), 'summaryText' => '->', 'columns' => array('desolpe.codart', 'cant', 'desolpe.maestro.maestro_ums.desum', 'desolpe.txtmaterial', array('htmlOptions' => array('width' => 400), 'class' => 'CButtonColumn', 'template' => '{delete}', 'buttons' => array('delete' => array('visible' => 'true', 'url' => '$this->grid->controller->createUrl("/solcot/ajaxborramaterial", array("id"=>$data->id))', 'options' => array('ajax' => array('type' => 'GET', 'success' => 'js:function() { $.fn.yiiGridView.update("detalle-grid");}', 'url' => 'js:$(this).attr("href")'), 'onClick' => 'Loading.show();Loading.hide(); '), 'imageUrl' => '' . Yii::app()->getTheme()->baseUrl . Yii::app()->params['rutatemaimagenes'] . 'borrador.png', 'label' => 'Borrar material')))))); ?>
public function actiongeneradetalle() { $identidad = (int) MiFactoria::cleanInput($_GET['id']); if (is_null(Solcot::model()->findByPk($identidad))) { throw new CHttpException(500, 'NO existe ningun registor pàra este ID'); } // var_dump(yii::app()->maletin->getvalues(NOMBRECLASE_DESOLPE));yii::app()->end(); foreach (yii::app()->maletin->getvalues(NOMBRECLASE_DESOLPE) as $fila) { if (is_null(Desolcot::model()->find("hidsolcot=" . $identidad . " and hiddesolpe=" . $fila['idregistro'] . ""))) { $registro = new Desolcot(); $registro->setAttributes(array('hidsolcot' => $identidad, 'hiddesolpe' => $fila['idregistro'], 'codispo' => ESTADO_CREADO, 'cant' => 1, 'preciounit' => 0)); if (!$registro->save()) { print_r($registro->geterrors()); } } else { echo "si existe"; } } }