<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);





$link = mysqli_connect("mysql4ward.mysql.database.azure.com", "fourwardmysql@mysql4ward", "@kirede!18#@", "db_convicto");

/*
//Mostra tabelas
    $tableList = array();
  $res = mysqli_query($link,"SHOW TABLES");
  while($cRow = mysqli_fetch_array($res))
  {
    $tableList[] = $cRow[0];
  }
  var_dump($tableList);
  */

  /*
  //Criação de tabela
               $stmt = $link->prepare("CREATE TABLE lojista (id INT AUTO_INCREMENT PRIMARY KEY, lojista VARCHAR(250)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;");
               $stmt->execute();
*/


$tableList = array();
  $res = mysqli_query($link,"SHOW TABLES");
  while($cRow = mysqli_fetch_array($res))
  {
    $tableList[] = $cRow[0];
  }
  var_dump($tableList);

if (!$link) {
    echo "Error: Unable to connect to MySQL." . PHP_EOL;
    echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
    echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
    exit;
}

//echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL;
//echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;

//if ($result = $link->query("SELECT ean,nameProduct,dimazzo,sizeProduct FROM stock WHERE dimazzo != 0")) {
if ($result = $link->query("SELECT * FROM stock WHERE ean = 7909615318919")) {
    
    foreach ($result as $value) {
    	//printf($value["sizeProduct"]."<br>");
    	//printf($value["ean"]."  -  ".$value["nameProduct"]."  -  ".$value["dimazzo"]."  -  ".$value["forMen"]."<br>");
    	printf("Ean = ".$value["ean"]."<br><br>");
    	printf("Sku = ".$value["skuVtex"]."<br><br>");
    	printf("Name = ".$value["nameProduct"]."<br><br>");
    	printf("AcreSergio = ".$value["acreSergio"]."<br>");
    	printf("outletCvto = ".$value["outletCvto"]."<br>");
    	printf("ForMen = ".$value["forMen"]."<br>");
    	printf("Maiusculo = ".$value["maiusculo"]."<br>");
    	printf("Life = ".$value["life"]."<br>");
    	printf("Dimazzo = ".$value["dimazzo"]."<br>");
    	
    }

    
    $result->close();
}

if ($result = $link->query("SELECT * FROM stock WHERE ean = 7909615318919")) {
    foreach ($result as $value) {
    	//printf($value["sizeProduct"]."<br>");
    	//printf($value["ean"]."  -  ".$value["nameProduct"]."  -  ".$value["dimazzo"]."  -  ".$value["forMen"]."<br>");
    	printf("Ean = ".$value["ean"]."<br><br>");
    	printf("Sku = ".$value["skuVtex"]."<br><br>");
    	printf("Name = ".$value["nameProduct"]."<br><br>");
    	printf("AcreSergio = ".$value["acreSergio"]."<br>");
    	printf("outletCvto = ".$value["outletCvto"]."<br>");
    	printf("ForMen = ".$value["forMen"]."<br>");
    	printf("Maiusculo = ".$value["maiusculo"]."<br>");
    	printf("Life = ".$value["life"]."<br>");
    	printf("Dimazzo = ".$value["dimazzo"]."<br>");
    	printf("Gianotto Modas = ".$value["gianottoModas"]."<br>");
    	
    }
    
    echo "<br><br>==================================================<br><br>";
    if ($result = $link->query("SELECT * FROM stock WHERE ean = 7909615318919")) {
    foreach ($result as $value) {
    	//printf($value["sizeProduct"]."<br>");
    	//printf($value["ean"]."  -  ".$value["nameProduct"]."  -  ".$value["dimazzo"]."  -  ".$value["forMen"]."<br>");
    	printf("Ean = ".$value["ean"]." | ");
    	printf("Sku = ".$value["skuVtex"]." | ");
    	printf("Name = ".$value["nameProduct"]." | ");
    	printf("AcreSergio = ".$value["acreSergio"]." | ");
    	printf("outletCvto = ".$value["outletCvto"]." | ");
    	printf("ForMen = ".$value["forMen"]." | ");
    	printf("Maiusculo = ".$value["maiusculo"]." | ");
    	printf("Life = ".$value["life"]." | ");
    	printf("Vestylle = ".$value["vestylle"]." | ");
    	printf("Haut = ".$value["haut"]." | ");
    	printf("Dimazzo = ".$value["dimazzo"]." | ");
    	printf("BhPadilha = ".$value["bhPadilha"]." | ");
    	printf("Origem = ".$value["origem"]." | ");
    	printf("Emporio = ".$value["emporio"]." | ");
    	printf("Abusiva = ".$value["abusiva"]." | ");
    	printf("SignoriOtto = ".$value["signoriOtto"]." | ");
    	printf("Gianotto Modas = ".$value["gianottoModas"]." | ");
    	
    }
    }
    echo "<br><br>==================================================<br><br>";
    if ($result = $link->query("SELECT * FROM stock WHERE ean = 7909124221885")) {
    foreach ($result as $value) {
    	//printf($value["sizeProduct"]."<br>");
    	//printf($value["ean"]."  -  ".$value["nameProduct"]."  -  ".$value["dimazzo"]."  -  ".$value["forMen"]."<br>");
    	printf("Ean = ".$value["ean"]." | ");
    	printf("Sku = ".$value["skuVtex"]." | ");
    	printf("Name = ".$value["nameProduct"]." | ");
    	printf("AcreSergio = ".$value["acreSergio"]." | ");
    	printf("outletCvto = ".$value["outletCvto"]." | ");
    	printf("ForMen = ".$value["forMen"]." | ");
    	printf("Maiusculo = ".$value["maiusculo"]." | ");
    	printf("Life = ".$value["life"]." | ");
    	printf("Vestylle = ".$value["vestylle"]." | ");
    	printf("Haut = ".$value["haut"]." | ");
    	printf("Dimazzo = ".$value["dimazzo"]." | ");
    	printf("BhPadilha = ".$value["bhPadilha"]." | ");
    	printf("Origem = ".$value["origem"]." | ");
    	printf("Emporio = ".$value["emporio"]." | ");
    	printf("Abusiva = ".$value["abusiva"]." | ");
    	printf("SignoriOtto = ".$value["signoriOtto"]." | ");
    	printf("Gianotto Modas = ".$value["gianottoModas"]." | ");
    	
    }
    }
    echo "<br><br>==================================================<br><br>";
    if ($result = $link->query("SELECT * FROM stock WHERE ean = 7909615366392")) {
    foreach ($result as $value) {
    	//printf($value["sizeProduct"]."<br>");
    	//printf($value["ean"]."  -  ".$value["nameProduct"]."  -  ".$value["dimazzo"]."  -  ".$value["forMen"]."<br>");
    	printf("Ean = ".$value["ean"]." | ");
    	printf("Sku = ".$value["skuVtex"]." | ");
    	printf("Name = ".$value["nameProduct"]." | ");
    	printf("AcreSergio = ".$value["acreSergio"]." | ");
    	printf("outletCvto = ".$value["outletCvto"]." | ");
    	printf("ForMen = ".$value["forMen"]." | ");
    	printf("Maiusculo = ".$value["maiusculo"]." | ");
    	printf("Life = ".$value["life"]." | ");
    	printf("Vestylle = ".$value["vestylle"]." | ");
    	printf("Haut = ".$value["haut"]." | ");
    	printf("Dimazzo = ".$value["dimazzo"]." | ");
    	printf("BhPadilha = ".$value["bhPadilha"]." | ");
    	printf("Origem = ".$value["origem"]." | ");
    	printf("Emporio = ".$value["emporio"]." | ");
    	printf("Abusiva = ".$value["abusiva"]." | ");
    	printf("SignoriOtto = ".$value["signoriOtto"]." | ");
    	printf("Gianotto Modas = ".$value["gianottoModas"]." | ");
    	
    }
    }
    echo "<br><br>==================================================<br><br>";

    if ($result = $link->query("SELECT * FROM stock")) {
    foreach ($result as $value) {
        //printf($value["sizeProduct"]."<br>");
        //printf($value["ean"]."  -  ".$value["nameProduct"]."  -  ".$value["dimazzo"]."  -  ".$value["forMen"]."<br>");
        printf("Ean = ".$value["ean"]."<br>");
        
    }
    }
    echo "<br><br>==================================================<br><br>";
    
    echo "<br><br>==================================================<br><br>";

    if ($result = $link->query("SELECT * FROM userseller")) {
    foreach ($result as $value) {
        //printf($value["sizeProduct"]."<br>");
        //printf($value["ean"]."  -  ".$value["nameProduct"]."  -  ".$value["dimazzo"]."  -  ".$value["forMen"]."<br>");
        printf("nameUser = ".$value["nameUser"]."<br>");
printf("email = ".$value["email"]."<br>");
printf("password = ".$value["password"]."<br>");
printf("warehouseId = ".$value["warehouseId"]."<br>");
printf("razaoSocial = ".$value["razaoSocial"]."<br>");
printf("emailParaNfe = ".$value["emailParaNfe"]."<br>");
printf("bairro = ".$value["bairro"]."<br>");
printf("telefoneQuatro = ".$value["telefoneQuatro"]."<br>");
printf("telefoneTres = ".$value["telefoneTres"]."<br>");
printf("telefoneDois = ".$value["telefoneDois"]."<br>");
printf("cidade = ".$value["cidade"]."<br>");
printf("numero = ".$value["numero"]."<br>");
printf("endereco = ".$value["endereco"]."<br>");
printf("cep = ".$value["cep"]."<br>");
printf("uf = ".$value["uf"]."<br>");
printf("fornecedor = ".$value["fornecedor"]."<br>");
printf("clienteAtacado = ".$value["clienteAtacado"]."<br>");
printf("pessoaJuridica = ".$value["pessoaJuridica"]."<br>");

printf("cpfCnpj = ".$value["cpfCnpj"]."<br>");
printf("dataCadastro = ".$value["dataCadastro"]."<br>"."<br>"."<br>");
        
    }
    
    }
    echo "<br><br>==================================================<br><br>";

    echo "<br><br>==================================================<br><br>";

    if ($result = $link->query("SELECT * FROM lojista")) {
    foreach ($result as $value) {
        //printf($value["sizeProduct"]."<br>");
        //printf($value["ean"]."  -  ".$value["nameProduct"]."  -  ".$value["dimazzo"]."  -  ".$value["forMen"]."<br>");
        printf("Lojista = ".$value["lojista"]."<br>");

        
    }
    
    }
    echo "<br><br>==================================================<br><br>";

    echo "<br><br>==================================================<br><br>";

    if ($result = $link->query("SELECT * FROM stockhasuserseller where iduserseller = '59'")) {
    foreach ($result as $value) {
        //printf($value["sizeProduct"]."<br>");
        //printf($value["ean"]."  -  ".$value["nameProduct"]."  -  ".$value["dimazzo"]."  -  ".$value["forMen"]."<br>");
        printf("Lojista = ".$value["idstock"]."<br>");
        printf("Lojista = ".$value["iduserseller"]."<br>");

        
    }
    
    }
    echo "<br><br>==================================================<br><br>";
    
    //$result = $link->query("update stock set gianottoModas = 0 where gianottoModas is null");
    
    
    
    //$stmt = $link->prepare("update stock set gianottoModas =:GIANOTTOMODAS where gianottoModas is null");
    
    //$gianottoModas = '0';
    //$stmt->bindParam(":GIANOTTOMODAS",$gianottoModas);
    
    //$stmt->execute();

    /*$stmt = $link->prepare("INSERT INTO userseller (nameUser,email,password,warehouseId,razaoSocial,emailParaNfe,bairro,telefoneQuatro,telefoneTres,telefoneDois,cidade,numero,endereco,cep,uf,fornecedor,clienteAtacado,pessoaJuridica,cpfCnpj,dataCadastro) VALUES ('DimazzoArapongas','dimazzo@onda.com.br','$2y$10$7hkm3xhQz84tS3rQCuu4Me3Asih/Vj/aT5ESBF5KXUy//E3ravlrS','dimazzoArapongas','Di-Mazzo Artigos do vestuario ltda','financeiro.dimazzo@hotmail.com','Centro','(43) 32522670','(43) 30552602','(43) 32755529','Arapongas','568','Avenida Arapongas','4101507','PR','Sim','Sim','Sim','04.309.163/0001-01','18/07/2005')");

    $nameUser = "DimazzoArapongas";
$email = "dimazzo@onda.com.br";
$password = "$2y$10$7hkm3xhQz84tS3rQCuu4Me3Asih/Vj/aT5ESBF5KXUy//E3ravlrS";
$warehouseId = "dimazzoArapongas";
$razaoSocial = "Di-Mazzo Artigos do vestuario ltda";
$emailParaNfe = "financeiro.dimazzo@hotmail.com";
$bairro = "Centro";
$telefoneQuatro = "(43) 32522670";
$telefoneTres = "(43) 30552602";
$telefoneDois = "(43) 32755529";
$cidade = "Arapongas";
$numero = "568";
$endereco = "Avenida Arapongas";
$cep = "4101507";
$uf = "PR";
$fornecedor = "Sim";
$clienteAtacado = "Sim";
$pessoaJuridica = "Sim";

$cpfCnpj = "04.309.163/0001-01";
$dataCadastro = "18/07/2005";
    echo $link->error;die;
    
    $stmt->bindParam(":NAMEUSER",$nameUser);
$stmt->bindParam(":EMAIL",$email);
$stmt->bindParam(":PASSWORD",$password);
$stmt->bindParam(":WAREHOUSEID",$warehouseId);
$stmt->bindParam(":RAZAOSOCIAL",$razaoSocial);
$stmt->bindParam(":EMAILPARANFE",$emailParaNfe);
$stmt->bindParam(":BAIRRO",$bairro);
$stmt->bindParam(":TELEFONEQUATRO",$telefoneQuatro);
$stmt->bindParam(":TELEFONETRES",$telefoneTres);
$stmt->bindParam(":TELEFONEDOIS",$telefoneDois);
$stmt->bindParam(":CIDADE",$cidade);
$stmt->bindParam(":NUMERO",$numero);
$stmt->bindParam(":ENDERECO",$endereco);
$stmt->bindParam(":CEP",$cep);
$stmt->bindParam(":UF",$uf);
$stmt->bindParam(":FORNECEDOR",$fornecedor);
$stmt->bindParam(":CLIENTEATACADO",$clienteAtacado);
$stmt->bindParam(":PESSOAJURIDICA",$pessoaJuridica);

$stmt->bindParam(":CPFCNPJ",$cpfCnpj);
$stmt->bindParam(":DATACADASTRO",$dataCadastro);
    
    $stmt->execute();
    
    */
/*
           $stmt = $link->prepare("INSERT INTO lojista (lojista) values ('origem')");
               $stmt->execute();

               $stmt = $link->prepare("INSERT INTO lojista (lojista) values ('emporio')");
               $stmt->execute();

               $stmt = $link->prepare("INSERT INTO lojista (lojista) values ('abusiva')");
               $stmt->execute();

               $stmt = $link->prepare("INSERT INTO lojista (lojista) values ('signoriOtto')");
               $stmt->execute();

               $stmt = $link->prepare("INSERT INTO lojista (lojista) values ('gianottoModas')");
               $stmt->execute();
*/

    //$result->close();
}    

mysqli_close($link);

?>