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'])); } }
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"; } } }