Exemple #1
0
function changeRank($rs, $token)
{
    // globalize vars
    global $stored_rs, $stored_token, $group_id, $new_role_set_id, $target_user_id, $file_name_token;
    // set up promote_user request
    $promote_user = curl_init("http://www.roblox.com/groups/api/change-member-rank?groupId={$group_id}&newRoleSetId={$new_role_set_id}&targetUserId={$target_user_id}");
    curl_setopt_array($promote_user, array(CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_HEADER => true, CURLOPT_HTTPHEADER => array("Cookie: {$rs}", "X-CSRF-TOKEN: {$token}")));
    // get request's header & body
    $response = curl_exec($promote_user);
    $header_size = curl_getinfo($promote_user, CURLINFO_HEADER_SIZE);
    $header = substr($response, 0, $header_size);
    $body = substr($response, $header_size);
    // check if roblosecurity/token is valid
    if (!preg_match('/HTTP\\/1.1 200/', $header)) {
        if (preg_match('/HTTP\\/1.1 302/', $header) && $rs == $stored_rs) {
            // get updated roblosecurity
            $body = changeRank(getRS(), $token);
        } else {
            if (preg_match('/HTTP\\/1.1 403/', $header) && $token == $stored_token) {
                // get updated token
                $new_token = preg_match('/X-CSRF-TOKEN: (\\S+)/', $header, $matches) ? $matches[1] : '';
                file_put_contents($file_name_token, $new_token, true);
                $body = changeRank($rs, $new_token);
            } else {
                $body = "error: invalid input/forbidden attempt";
            }
        }
    }
    // close promote_user
    curl_close($promote_user);
    // return results
    return $body;
}
Exemple #2
0
function uploadAsset($rs)
{
    // globalize vars
    global $stored_rs, $asset_id, $asset_xml;
    // set up upload_xml request
    $upload_xml = curl_init("http://www.roblox.com/Data/Upload.ashx?assetid={$asset_id}");
    curl_setopt_array($upload_xml, array(CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_HEADER => true, CURLOPT_HTTPHEADER => array('User-Agent: Roblox/WinINet', "Cookie: {$rs}"), CURLOPT_POSTFIELDS => $asset_xml));
    // get header & body of request
    $response = curl_exec($upload_xml);
    $header_size = curl_getinfo($upload_xml, CURLINFO_HEADER_SIZE);
    $header = substr($response, 0, $header_size);
    $body = substr($response, $header_size);
    // check if roblosecurity is valid
    if (!preg_match('/HTTP\\/1.1 200/', $header)) {
        if (preg_match('/HTTP\\/1.1 302/', $header) && $rs == $stored_rs) {
            // get updated roblosecurity
            $body = uploadAsset(getRS());
        } else {
            // error
            $body = "error: invalid xml/invalid id";
        }
    }
    // close upload_xml
    curl_close($upload_xml);
    // return results
    return $body;
}
 function getCuentasEmailsTo()
 {
     $sql = "SELECT * FROM cuentas_emails_to";
     $resultSet = getRS($sql);
     $result = array();
     while ($row = getRow($resultSet)) {
         $result[$row["email"]] = $row["email"];
     }
     return $result;
 }
Exemple #4
0
 function valorizarPorCliente($year = null, $paraGraf = false)
 {
     $data = "";
     $sql = "SELECT *\n\t\t\t\tFROM\n\t\t\t\t(\n\t\t\t\t  SELECT t2.id_cliente, t2.razon_social_cliente, SUM(t1.total_venta) total_por_cliente\n\t\t\t\t  FROM ventas t1\n\t\t\t\t  INNER JOIN clientes t2 ON t2.id_cliente=t1.id_cliente\n\t\t\t\t  WHERE t1.id_registro_estado=1\n\t\t\t\t  AND EXTRACT(YEAR FROM t1.fecha_venta) = {$year}\n\t\t\t\t  GROUP BY t2.id_cliente\n\t\t\t\t) rs1\n\t\t\t\tORDER BY total_por_cliente DESC";
     $rs = getRS($sql);
     $sql = "SELECT SUM(t1.total_venta) total_por_anio\n\t\t\t\t  FROM ventas t1\n\t\t\t\t  WHERE t1.id_registro_estado=1\n\t\t\t\t  AND EXTRACT(YEAR FROM t1.fecha_venta) = {$year}";
     $rsTotalPorAnio = getRS($sql);
     $rowTotalPorAnio = getRow($rsTotalPorAnio);
     $totalPorAnio = $rowTotalPorAnio["total_por_anio"];
     $porc_cte = 0;
     $total_acum = 0;
     $porc_fact = 0;
     $porc_acum = 0;
     $nroDeClientes = getNrosRows($rs);
     if ($nroDeClientes) {
         $nro = 1;
         while ($row = getRow($rs)) {
             $porc_cte = round($nro * 100 / $nroDeClientes, 2);
             $porc_fact = round($row["total_por_cliente"] * 100 / $totalPorAnio, 4);
             $porc_acum += $row["total_por_cliente"] * 100 / $totalPorAnio;
             $total_acum += $row["total_por_cliente"];
             $porc_item = round($porc_acum, 4);
             if ($porc_item >= 0 && $porc_item <= 80) {
                 $clase = "A";
             } else {
                 if ($porc_item > 80 && $porc_item <= 90) {
                     $clase = "B";
                 } else {
                     $clase = "C";
                 }
             }
             if (!$paraGraf) {
                 $data .= "<row id='" . $row["id_cliente"] . "'>" . "<cell><![CDATA[" . $nro . "]]></cell>" . "<cell><![CDATA[" . $row["razon_social_cliente"] . "]]></cell>" . "<cell><![CDATA[" . $porc_cte . "]]></cell>" . "<cell><![CDATA[" . round($row["total_por_cliente"], 2) . "]]></cell>" . "<cell><![CDATA[" . $porc_fact . "]]></cell>" . "<cell><![CDATA[" . round($total_acum, 2) . "]]></cell>" . "<cell><![CDATA[" . $porc_item . "]]></cell>" . "<cell><![CDATA[" . $clase . "]]></cell></row>";
             } else {
                 if ($nro == 11) {
                     break;
                 }
                 $data .= "<item id='{$nro}'><cliente>" . $row["razon_social_cliente"] . "</cliente><monto>" . round($row["total_por_cliente"], 2) . "</monto></item>";
             }
             $nro++;
         }
     }
     if (!$paraGraf) {
         $fin = "</rows>";
         $cab = "<?xml version='1.0' encoding='iso-8859-1'?><rows>";
     } else {
         $fin = "</data>";
         $cab = "<data>";
     }
     return $cab . $data . $fin;
 }
 function getSinConfirmar()
 {
     $sql = "SELECT *\r\n\t\t\t\tFROM ordenes_compra oc\r\n\t\t\t\tWHERE oc.generada = 0";
     $rs = getRS($sql);
     if (!getNrosRows($rs)) {
         return false;
     } else {
         return true;
     }
 }
Exemple #6
0
    $rap = $item_data['AveragePrice'];
    // add up to total rap
    $total_rap += $rap;
    // return ordered data
    return array('Name' => $name, 'AssetId' => $id, 'Serial' => $is_ulimited ? $serial : 'NA', 'SerialTotal' => $is_ulimited ? $total_serial : "NA", 'RAP' => $rap);
}
// --------------------------------------------------------------------
// list vars
$requests_handler = curl_multi_init();
$requests = array();
// get hats data
$hats_data = curl_exec(getInvPage($stored_rs, 0, 1));
// check if robloxsecurity is valid
if ($hats_data == "") {
    // get updated roblosecurity
    $rs = getRS();
    $hats_data = curl_exec(getInvPage($rs, 0, 1));
} else {
    $rs = $stored_rs;
}
// get gears/faces data
$gears_data = curl_exec(getInvPage($rs, 1, 1));
$faces_data = curl_exec(getInvPage($rs, 2, 1));
// set up requests
foreach (array($hats_data, $gears_data, $faces_data) as $filter => $filter_data) {
    $filter_data = json_decode($filter_data, true);
    if ($filter_data['msg'] == 'Inventory retreived!') {
        $count = $filter_data['data']['totalNumber'];
        foreach ($filter_data['data']['InventoryItems'] as $index => $item_data) {
            array_push($inventory, organizeItem($item_data));
        }
 function graficarDemandaPronosticoError($oData)
 {
     $sql = "select\r\n\t\t\t\tdate_format(c1.fecha_fin, '%d/%m/%Y') fecha_fin, \r\n\t\t\t\tcantidad_demandada, \r\n\t\t\t\tprediccion, \r\n\t\t\t\terror,\r\n\t\t\t\tsenial \r\n\t\t\t\tfrom (\r\n\t\t\t\t\tselect\r\n\t\t\t\t\tfecha_fin, \r\n\t\t\t\t\tcantidad_demandada, \r\n\t\t\t\t\tprediccion, \r\n\t\t\t\t\terror, \r\n\t\t\t\t\tsenial \r\n\t\t\t\t\tfrom predicciones t1 \r\n\t\t\t\t\tinner join periodos t2 on t1.id_periodo = t2.id_periodo \r\n\t\t\t\t\twhere id_producto= " . $oData["id_producto"] . " \r\n\t\t\t\t\torder by fecha_fin asc) c1";
     $rs = getRS($sql);
     $data = array();
     $nro = getNrosRows($rs);
     $flag = 1;
     if ($nro) {
         while ($row = getRow($rs)) {
             if ($flag) {
                 $inicio = $row['fecha_fin'];
                 $flag = 0;
             }
             $nro--;
             if ($nro == 0) {
                 $fin = $row['fecha_fin'];
             }
             $data[] = array('', $row['cantidad_demandada'], $row['prediccion'], $row['error'], $row['senial']);
         }
     }
     $plot = new PHPlot(800, 465);
     //$plot->SetImageBorderType('plain');
     $plot->SetPlotType('lines');
     //tipo de gráfico
     $plot->SetDataType('text-data');
     $plot->SetDataValues($data);
     $plot->SetTitle('Demanda real, predicción, error y señal de rastreo. Periodo ' . $inicio . ' al ' . $fin);
     //Título
     $plot->SetLegend(array('Demanda real', 'Pronóstico', 'Error', 'Señal de rastreo'));
     //Referencia
     $plot->SetLineWidths(2);
     //ancho de la linea
     $plot->SetLineStyles("solid");
     //estilo de la linea
     $plot->SetDataColors(array('green', 'blue', 'red', 'purple'));
     $plot->SetXTickLabelPos('none');
     $plot->SetXTickPos('none');
     # Draw both grids:
     $plot->SetDrawXGrid(True);
     $plot->SetDrawYGrid(True);
     $plot->DrawGraph();
 }
 function getSubproducto($idProducto)
 {
     $sql = "SELECT * FROM productos WHERE id_subproducto=" . $idProducto;
     $resultSet = getRS($sql);
     $numsRows = getNrosRows($resultSet);
     if ($numsRows > 0) {
         return getRow($resultSet);
     } else {
         return false;
     }
 }
 function enviarVentas($data)
 {
     //excel
     //armar
     //guardar
     //mail
     //armar
     //adjuntar excel guardado
     //eliminar archivo guardado
     $elementos = explode(",", $data["tipo"]);
     $tipos = "";
     foreach ($elementos as $elemento) {
         $tipos .= "'{$elemento}',";
     }
     $tipos = substr($tipos, 0, -1);
     $sql = "SELECT * FROM (SELECT t1.fecha_venta,\r\n                                CASE WHEN t1.id_tipo_venta = 3 THEN 'P' ELSE t3.tipo_venta END tipo_venta,\r\n                                CASE\r\n                                    WHEN t1.numero_venta IS NULL THEN ''\r\n                                    ELSE t1.numero_venta\r\n                                END numero_venta,\r\n                                t1.total_venta,\r\n                                t1.neto_con_desc_venta,\r\n                                t1.iva_venta,\r\n                                t1.razon_social_cliente,\r\n                                CASE\r\n                                        WHEN t1.id_registro_estado = 4 THEN 'SI' ELSE 'NO'\r\n                                END anulada\r\n                                FROM ventas t1\r\n                                INNER JOIN tipo_venta t3 ON t3.id_tipo_venta=t1.id_tipo_venta\r\n\t\t\t\t\t\t\t\tWHERE 1=1\r\n                                AND MONTH(fecha_venta) = '" . $data["mes"] . "'\r\n\t\t\t\t\t\t\t\tAND YEAR(fecha_venta) = '" . $data["anio"] . "' \r\n\t\t\t\t\t\t\t\tAND t3.tipo_venta in ({$tipos})\r\n                                ) r0\r\n                                ORDER BY r0.fecha_venta DESC";
     $resultSet = getRS($sql);
     $params = array();
     $columnas = array();
     array_push($columnas, "Fecha");
     array_push($columnas, "Tipo venta");
     array_push($columnas, "Número");
     array_push($columnas, "Razón social");
     array_push($columnas, "Neto c/desc.");
     array_push($columnas, "Iva");
     array_push($columnas, "Total");
     array_push($columnas, "Anulada");
     $columnas_tabla = array();
     $columnas_tabla["fecha_venta"] = "String";
     $columnas_tabla["tipo_venta"] = "String";
     $columnas_tabla["numero_venta"] = "String";
     $columnas_tabla["razon_social_cliente"] = "String";
     $columnas_tabla["neto_con_desc_venta"] = "Number";
     $columnas_tabla["iva_venta"] = "Number";
     $columnas_tabla["total_venta"] = "Number";
     $columnas_tabla["anulada"] = "String";
     $params["TITULO"] = "Ventas " . $data["mes"] . "/" . $data["anio"];
     $params["NOMBRE_HOJA"] = "Ventas";
     $params["COLUMNAS"] = $columnas;
     $params["COLUMNAS_TABLA"] = $columnas_tabla;
     $params["NOMBRE_ARCHIVO"] = "Ventas " . $data["mes"] . "/" . $data["anio"];
     $xml = toExcel($params, $resultSet, true);
     $sfile = $data["asunto"] . ".xls";
     // Ruta del archivo a generar
     $fp = fopen($sfile, "w");
     fwrite($fp, $xml);
     fclose($fp);
     $expEmail = new ExpertoEmails();
     $rdo = $expEmail->mail_attachment($sfile, "", $data["email_to"], $data["email"], $data["nombre"], "", $data["asunto"], $data["mensaje"]);
     unlink($sfile);
     if ($rdo) {
         return true;
     } else {
         return false;
     }
 }
 function delete($id)
 {
     $sql = "SELECT id_reparto FROM ventas WHERE id_reparto={$id}\n                UNION ALL\n                SELECT id_reparto FROM cargas WHERE id_reparto={$id}";
     $rs = getRS($sql);
     $cantReg = getNrosRows($rs);
     if ($cantReg != 0) {
         return false;
     }
     $sql = "DELETE FROM repartos WHERE id_reparto={$id}";
     if (!mysql_query($sql)) {
         die('Error: ' . mysql_error() . $sql);
     } else {
         return true;
     }
 }
 function getMinTpoDeEntregaAndProv($oData)
 {
     $sql = "SELECT * FROM productos_proveedores WHERE id_producto = " . $oData["id_producto"] . " ORDER BY tpo_de_entrega ASC LIMIT 1";
     $rs = getRS($sql);
     $row = getRow($rs);
     $data = array();
     $data["tpo_de_entrega"] = $row["tpo_de_entrega"];
     $data["id_proveedor"] = $row["id_proveedor"];
     return $data;
 }