controllers/PagosController.php
/**
     * Creates a new Pagos model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
Creates a new Pagos model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed
Creates a new Pagos model . If creation is successful the browser will be redirected to the ' view ' page . @return mixed
public function actionCreate()
    {
        $model = new Pagos();
        $idFlete = 1;
        $modelFlete = Flete::findOne($idFlete);
        $modelConceptos = Conceptos::find()->joinWith('tarifas')->where(['tarifas.CENTRALES_ID' => $modelFlete->lISTA->dISTRIBUCION->cENTRALES->ID])->all();
	if ($model->load(Yii::$app->request->post()) && $modelFlete->load(Yii::$app->request->post())) {
	foreach($model->CONCEPTOS_ID as $pago){
        $monto = Tarifas::findOne(['CONCEPTOS_ID'=>$pago])->MONTO;
		$modelPago = new Pagos();
		$modelPago->CONCEPTOS_ID = $pago;
		$modelPago->MONTO = $monto;
        $modelPago->FLETE_ID = $modelFlete->ID;
        $modelPago->ESTATUS_PAGO = 1;
		$modelPago->FE_REGISTRO = new Expression('now()');
        $modelPago->save(false);
	}
            return $this->redirect(['view', 'id' => $modelPago->ID]);
        } else {
            return $this->render('create', [
                'model' => $model,
                'modelFlete' => $modelFlete,
                'modelConceptos' => $modelConceptos,
            ]);
        }
    }
public function actionCreate ( ) { $ model = new Pagos ( ) ; $ idFlete = 1 ; $ modelFlete = Flete :: findOne ( $ idFlete ) ; $ modelConceptos = Conceptos :: find ( ) -> joinWith ( 'tarifas' ) -> where ( [ 'tarifas.CENTRALES_ID' => $ modelFlete -> lISTA -> dISTRIBUCION -> cENTRALES -> ID ] ) -> all ( ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ modelFlete -> load ( Yii :: $ app -> request -> post ( ) ) ) { foreach ( $ model -> CONCEPTOS_ID as $ pago ) { $ monto = Tarifas :: findOne ( [ 'CONCEPTOS_ID' => $ pago ] ) -> MONTO ; $ modelPago = new Pagos ( ) ; $ modelPago -> CONCEPTOS_ID = $ pago ; $ modelPago -> MONTO = $ monto ; $ modelPago -> FLETE_ID = $ modelFlete -> ID ; $ modelPago -> ESTATUS_PAGO = 1 ; $ modelPago -> FE_REGISTRO = new Expression ( 'now()' ) ; $ modelPago -> save ( false ) ; } return $ this -> redirect ( [ 'view' , 'id' => $ modelPago -> ID ] ) ; } else { return $ this -> render ( 'create' , [ 'model' => $ model , 'modelFlete' => $ modelFlete , 'modelConceptos' => $ modelConceptos , ] ) ; } }
Creates a new Pagos model.
Creates a new Pagos model .
//$modelLista = ; //var_dump($modelFlete->eMPRESACHOFER->cHOFER->CEDULA);die; //var_dump($modelConceptos);die; //if ($model->load(Yii::$app->request->post()) && $model->save()) { //$formulario = Yii::$app->request->post(); //var_dump($formulario);die; //foreach($model as $mod){var_dump($mod);}die; /*if($model->save()){
			return $this->redirect(['view', 'id' => $model->ID]);
		}*/ //        var_dump($pago);die; //var_dump($pago)."<hr>"; //var_dump($modelPago); //echo "<hr>"; //die; //echo "<pre>";var_dump($model->CONCEPTOS_ID);die;