public static function getMaxId() { $row = Logreimp::model()->find(array('select' => 'MAX(LogReimpId) as maxId')); return $row['maxId']; }
public function reimprimeBoleto($codigo, $ventasId, $eventoId, $funcionesId, $zonasId, $subzonaId, $filasId, $lugaresId, $usuariosId, $ultimocodigo = "26", $tip = "NORMAL", $cosBol = 0) { $reimpresiones = Reimpresiones::model()->count(array('condition' => "EventoId={$eventoId} AND FuncionesId={$funcionesId} AND ZonasId={$zonasId} AND SubzonaId={$subzonaId} AND FilasId={$filasId} AND LugaresId={$lugaresId}")); $contra = $eventoId . "." . $funcionesId . "." . $zonasId . "." . $subzonaId; $contra .= "." . $filasId . "." . $lugaresId . "-" . date("m") . "." . date("d") . "-" . $usuariosId; $contra .= "PR{$reimpresiones}"; $ventaslevel1 = Ventaslevel1::model()->findByAttributes(array('VentasId' => $ventasId, 'EventoId' => $eventoId, 'FuncionesId' => $funcionesId, 'ZonasId' => $zonasId, 'SubzonaId' => $subzonaId, 'FilasId' => $filasId, 'LugaresId' => $lugaresId)); $ventaslevel1->LugaresNumBol = $codigo; $ventaslevel1->VentasCon = $contra; $ventaslevel1->update(); $ultimo = Reimpresiones::model()->findAll(array('limit' => 1, 'order' => 't.ReimpresionesId DESC')); $ultimo = $ultimo[0]->ReimpresionesId + 1; $hoy = date("Y-m-d G:i:s"); $user_id = Yii::app()->user->id; Yii::app()->db->createCommand("INSERT INTO reimpresiones VALUES({$ultimo},{$eventoId},{$funcionesId},{$zonasId},{$subzonaId},{$filasId},{$lugaresId},'PANEL ADMINISTRATIVO','',{$user_id},'{$hoy}','{$ultimocodigo}')")->execute(); $ultimologreimp = Logreimp::model()->findAll(array('limit' => 1, 'order' => 't.LogReimpId DESC')); $ultimologreimp = $ultimologreimp[0]->LogReimpId + 1; Yii::app()->db->createCommand("INSERT INTO logreimp VALUES({$ultimologreimp},'{$hoy}','{$tip}',{$cosBol},'{$tip}',{$user_id},0,{$eventoId},{$funcionesId},{$zonasId},{$subzonaId},{$filasId},{$lugaresId})")->execute(); }