public function actionValidarCupon() { if (Yii::app()->request->isAjaxRequest) { $texto = $_GET['texto']; $texto = str_replace(array("á", "à", "â", "ã", "ä", "é", "è", "ê", "ë", "í", "ì", "î", "ï", "ó", "ò", "ô", "õ", "ö", "ú", "ù", "û", "ü", "ç", "Á", "À", "Â", "Ã", "Ä", "É", "È", "Ê", "Ë", "Í", "Ì", "Î", "Ï", "Ó", "Ò", "Ô", "Õ", "Ö", "Ú", "Ù", "Û", "Ü", "Ç", "Ñ", "ñ", "\\", "¨", "º", "-", "~", "#", "@", "|", "!", "\"", "·", "\$", "%", "&", "/", "(", ")", "?", "'", "¡", "¿", "[", "^", "`", "]", "+", "}", "{", "¨", "´", ">", "<", ";", ",", ":", ".", "_", "=", "*", " "), array("a", "a", "a", "a", "a", "e", "e", "e", "e", "i", "i", "i", "i", "o", "o", "o", "o", "o", "u", "u", "u", "u", "c", "A", "A", "A", "A", "A", "E", "E", "E", "E", "I", "I", "I", "I", "O", "O", "O", "O", "O", "U", "U", "U", "U", "C", ""), utf8_decode($texto)); $model = Descuentos::model()->findAll("CuponesCod='{$texto}'", array('limit' => 1)); $validacion = "1"; if (!empty($model)) { $validacion = "0"; } $data = array('validacion' => $validacion, 'texto' => strtoupper($texto)); echo json_encode($data); } }
public static function validarDescuento($boleto) { /* *Esta funcion recibe un boleto listo para vender con numero de evento, funcion, zona, subzona, fila y lugar, ademas de la cantidad de boletos y y el precio *y devuelve a cambio el boleto con precio con descuento y si aplico descuento * boleto=[evento,funcion,zona, subzona, fila, asiento, precio ] */ if ($boleto) { $cupon = Descuentos::model()->findByPk(Yii::app()->session['descuento']['DescuentosId']); $restric = Yii::app()->session['level1']; if ($boleto['EventoId'] == $restric['EventoId']) { // Ha validado que el boleto sea del evento con descuento if ($restric['FuncionesId'] == $boleto['FuncionesId']) { if ($restric['ZonasId'] == $boleto['ZonasId']) { if ($restric['SubzonaId'] == $boleto['SubzonaId']) { if (in_array($boleto['FilasId'], array_keys($restric->arregloFilas))) { if (in_array($boleto['LugaresId'], array_keys($restric->arregloLugares))) { return $cupon['DescuentosExis'] == 0 or $cupon['DescuentosUso'] < $cupon['DescuentosExis']; } elseif ($restric['LugaresId'] > 0) { //return 1;//False; return false; } } elseif ($restric['FilasId'] > 0) { //return 2;//False; return false; } } elseif ($restric['SubzonaId'] > 0) { //return 3;//False; return false; } } elseif ($restric['ZonasId'] > 0) { //return 4;//False; return false; } } elseif ($restric['FuncionesId'] > 0) { //return 22; return False; } return $cupon['DescuentosExis'] == 0 or $cupon['DescuentosUso'] < $cupon['DescuentosExis']; } else { return False; //; } } }