示例#1
0
    $i = 1;
    while ($row_planes = mysql_fetch_assoc($planes)) {
        createPlan($row_planes, $i, $dbConn);
        $i++;
        // Para obtener el plan sugerido para el plan actual.
        $query_planSugerido = sprintf("SELECT id_plan, nombre, (select nombre from empresas where empresas.id_empresa = planes.id_empresa) as empresa, (select codigo_color from empresas where empresas.id_empresa = planes.id_empresa) as empresa_color, precio, dato_principal_1, id_tipoDato_principal_1, dato_principal_2, id_tipoDato_principal_2, dato_principal_3, id_tipoDato_principal_3, dato_principal_4, id_tipoDato_principal_4, mas_datos FROM planes WHERE id_plan in(select id_plan from cobertura where id_estado = %s) AND id_plan in(SELECT id_plan FROM planes_tipoServicios WHERE id_plan IN (SELECT id_plan FROM planes_tipoServicios WHERE id_tipoServicio IN (%s)) GROUP BY id_plan HAVING count(*) > %s ) AND ((precio < %s AND precio >= %s-100) OR (precio > %s AND precio <= %s+100)) ORDER BY precio ASC LIMIT 1", GetSQLValueString($_POST['id_estado'], "int"), implode(", ", $_POST['servicios']), count($_POST['servicios']), $row_planes['precio'], $row_planes['precio'], $row_planes['precio'], $row_planes['precio']);
        $planSugerido = mysql_query($query_planSugerido, $dbConn) or die(mysql_error());
        $row_planSugerido = mysql_fetch_assoc($planSugerido);
        $totalRows_planSugerido = mysql_num_rows($planSugerido);
        //echo $query_planSugerido;
        //echo "<br>RESULT: " . $totalRows_planSugerido;
        if ($totalRows_planSugerido > 0) {
            // Si el plan sugerido para el plan actual ya fue incluido previamente, no lo incluye de nuevo.
            if (!in_array($row_planSugerido['id_plan'], $suggestedPlansIncluded)) {
                array_push($suggestedPlansIncluded, $row_planSugerido['id_plan']);
                createPlan($row_planSugerido, $i, $dbConn, "sugerido");
                $i++;
            }
        }
    }
    //while
} else {
    echo "<div id='no-results'>No hay resultados que mostrar para la combinaci&oacute;n de servicios seleccionada.</div>";
}
?>
       
       <div class="clearfix"></div>
           
    </div><!-- #results -->
    
		<?php 
function createSubscription($firstName, $lastName, $email)
{
    $plan = createPlan("Basic", "basic", 1000, 15);
    $createSubscriptionParam = array("plan_id" => $plan->id, "id" => $email, "customer[first_name]" => $firstName, "customer[last_name]" => $lastName, "customer[email]" => $email);
    try {
        $result = ChargeBee_Subscription::create($createSubscriptionParam);
        return $result;
    } catch (ChargeBee_InvalidRequestException $e) {
        if ($e->getApiErrorCode() == "duplicate_entry" && $e->getParam() != null && $e->getParam() == "id") {
            $result = ChargeBee_Subscription::retrieve($email);
            return $result;
        } else {
            throw $e;
        }
    }
}
示例#3
0
function processInsertPlanForm()
{
    $errorText = '';
    if (!check_csrf_token()) {
        biguglyerror("Mrš odavle");
        zamgerlog("1337 h4x0r detected", 3);
        zamgerlog2("csrf token ne odgovara");
        return "ERROR";
    }
    //get variables
    $godina_id = intval($_REQUEST['godina_vazenja']);
    $studij_id = intval($_REQUEST['studij']);
    $semestar = intval($_REQUEST['semestar']);
    //provjeri da je semestar cifra
    if (!is_int($semestar)) {
        $errorText = "Broj semestra nije validan!";
        return $errorText;
    }
    $predmet_id = intval($_REQUEST['predmet']);
    $obavezan = 0;
    if (isset($_REQUEST['obavezan'])) {
        $obavezan = 1;
    }
    $errorText = createPlan($godina_id, $studij_id, $semestar, $predmet_id, $obavezan);
    return $errorText;
}
示例#4
0
//$_POST['id_estado'] = 9; //Distrito Federal.
//$_POST['servicios'] = array(TEL_MOVIL);
$_SESSION['cantidadcargadas'] = (int) $_POST['cantidadcargadas'];
$_POST['id_estado'] = $_SESSION['id_estado'];
$_POST['servicios'] = $_SESSION['servicios'];
$query_planes = sprintf("SELECT id_plan, nombre, (select nombre from empresas where empresas.id_empresa = planes.id_empresa) as empresa, (select codigo_color from empresas where empresas.id_empresa = planes.id_empresa) as empresa_color, precio, dato_principal_1, id_tipoDato_principal_1, dato_principal_2, id_tipoDato_principal_2, dato_principal_3, id_tipoDato_principal_3, dato_principal_4, id_tipoDato_principal_4, mas_datos, visible FROM planes WHERE id_plan in(select id_plan from cobertura where id_estado = %s) AND id_plan in( SELECT id_plan FROM planes_tipoServicios WHERE id_tipoServicio IN (%s) AND id_plan NOT IN(SELECT id_plan FROM planes_tipoServicios WHERE id_tipoServicio NOT IN (%s)) AND visible=1 GROUP BY id_plan HAVING count(*) >= %s )  ORDER BY precio ASC limit " . $_SESSION['cantidadcargadas'] . ",10", GetSQLValueString($_POST['id_estado'], "int"), implode(", ", $_POST['servicios']), implode(", ", $_POST['servicios']), count($_POST['servicios']));
$planes = mysql_query($query_planes, $dbConn) or die(mysql_error());
$totalRows_planes = mysql_num_rows($planes);
$_SESSION['totalRows_planes'] = $totalRows_planes;
//$query_priceMax=sprintf("SELECT MAX(precio) FROM planes WHERE id_plan in(select id_plan from cobertura where id_estado = %s) AND id_plan in( SELECT id_plan FROM planes_tipoServicios WHERE id_tipoServicio IN (%s) AND id_plan NOT IN(SELECT id_plan FROM planes_tipoServicios WHERE id_tipoServicio NOT IN (%s)) AND visible=1 GROUP BY id_plan HAVING count(*) >= %s )  ORDER BY precio ASC limit ".$_SESSION['cantidadcargadas'].",10", GetSQLValueString($_POST['id_estado'], "int"), implode(", ", $_POST['servicios']), implode(", ", $_POST['servicios']), count($_POST['servicios']));
//$resultadoQueryPriceMax=mysql_query($query_priceMax, $dbConn) or die(mysql_error());
//$valor=mysql_fetch_object($resultadoQueryPriceMax);
//$_SESSION['priceMax']= mysql_fetch_assoc($resultadoQueryPriceMax);
$_SESSION['priceMax'] = 1999;
while ($row_planes = mysql_fetch_assoc($planes)) {
    createPlan($row_planes, $i, $dbConn);
    $i++;
}
//$_SESSION["cantidadcargadas"]+=10;
function createPlan($plan, $num, $dbConn, $sugerido)
{
    $query_redesSociales = sprintf("SELECT * FROM planes_redesSociales WHERE id_plan=%s", GetSQLValueString($plan['id_plan'], "int"));
    $redesSociales = mysql_query($query_redesSociales, $dbConn) or die(mysql_error());
    $totalRows_redesSociales = mysql_num_rows($redesSociales);
    $position = $num % 2 == 0 ? "right" : "";
    $planLink = "plan.php?id_plan=" . $plan['id_plan'];
    if ($sugerido) {
        $planLink .= "&sugerido=true";
    }
    echo "<div id='plan-" . $plan['id_plan'] . "' class='plan box {$sugerido} " . $position . "'>";
    echo "\t<div class='section-left'>";