/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Solpe(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Solpe'])) { $model->attributes = $_POST['Solpe']; if ($model->save()) { $this->redirect(array('update', 'id' => $model->id)); $this->refresh(); } } $this->render('create', array('model' => $model)); }
public static function CreaSolpeAutomatica($codocu, $id) { $solpe = new Solpe(); $solpe->textocabecera = "Documento automático"; $solpe->hidref = $id; $solpe->codocuref = $codocu; $solpe->escompra = '0'; if (!$solpe->save()) { print_r($solpe->getErrors()); yii::app()->end(); } $solpe->refresh(); $identidad = $solpe->id; unset($solpe); $registrospeticiones = self::Devuelvepeticioneshijos($id); foreach ($registrospeticiones as $fila) { $registrodesolpe = new Desolpe(); $registrodesolpe->setScenario('insert'); $registrodesolpe->hidsolpe = $identidad; $registrodesolpe->cant = $fila->cant; $registrodesolpe->codart = $fila->codart; $registrodesolpe->um = $fila->um; $registrodesolpe->txtmaterial = $fila->descripcion; $registrodesolpe->imputacion = $fila->imputacion; $registrodesolpe->centro = $fila->codcen; $registrodesolpe->codal = $fila->codal; $registrodesolpe->item = $fila->item; $registrodesolpe->tipimputacion = 'V'; ////debe de implemntarse la progrtamacion del plan de ventas ///temporalmente quieda con programacion plana $registrodesolpe->fechaent = date("Y-m-d"); $registrodesolpe->tipsolpe = $fila->tipo; if (!$registrodesolpe->save()) { print_r($registrodesolpe->getErrors()); yii::app()->end(); } unset($registrodesolpe); } $nuevasolpe = Solpe::model()->findByPk($identidad); //$nuevasolpe->save(); if (!$nuevasolpe->save()) { print_r($nuevasolpe->getErrors()); yii::app()->end(); } }