-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
114 lines (111 loc) · 4.01 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<body style="text-align:center">
<h2>Powerboutique API:</h2>
<h3>/gesco/autenthication/</h3>
<?php
session_start();
//URL de l'API Powerboutique (Maj 48)
$API ='https://back.ph1.powerboutique.net/maj_488/api/';
//Identifiants
$_GLOBALS['user'] = '';
$_GLOBALS['profil'] = '';
$_GLOBALS['pass'] = '';
// Paramètres de connexion
$params = http_build_query(array(
'username' => $_GLOBALS['user'],
'profil' => $_GLOBALS['profil'],
'password' => $_GLOBALS['pass']
));
// Header POST
$header = stream_context_create(array(
'http' => array(
'header' => "Content-Type: application/x-www-form-urlencoded\r\n" .
"Content-Length: " . strlen($params) . "\r\n" ,
'method' => 'POST',
'content' => $params
)
));
//API Gesco/Authentication
$connexion = get_headers($API.'authentication', 1, $header);
//Session stockage Authentication
$_SESSION['Authentication'] = $connexion['Authentication'];
//Affichage de la clé
echo '<br><b>' . $_SESSION['Authentication'] . '</b><br>';
//Définition 'Range' ou non
function context($range = null)
{
$Authentication = $_SESSION['Authentication'];
//Si 'Range' non défini
if (!$range) {
$header = array(
'http' => array(
'method' => "GET",
'header' => "Authentication: $Authentication \r\n"
)
);
}
//Si 'Range'
$header = array(
'http' => array(
'method' => "GET",
'header' => "Authentication:$Authentication \r\n" .
"Range: items=$range\r\n"
)
);
//Transforme en contexte pour envoyer en tant qu'Header
$header = stream_context_create($header);
return $header;
}
?>
<hr>
<h3>/gesco/client/</h3>
<?php
//API Gesco/client
$clients = file_get_contents($API.'gesco/client', false, context('0-4'));
$clients = new SimpleXMLElement($clients);
foreach ($clients->client as $client) {
echo '<div style="display:inline-block;margin:0 25px ;">';
echo '<p><b>Mail</b>:<br>' . $client->adresse->email . '<p>';
echo '<p><b>Nom:</b><br>' . $client->adresse->nom . '</p>';
echo '<p><b>Prénom:</b><br>' . $client->adresse->prenom . '</p>';
echo '</div>';
}
?>
<hr>
<h3>/gesco/commande/</h3>
<?php
//API Gesco/commande
$commandes = file_get_contents($API.'gesco/commande', false, context('0-0'));
$commandes = new SimpleXMLElement($commandes);
foreach ($commandes->commande as $commande) {
$id = $commande->attributes()->id;
$nom = $commande->client->adresse->nom;
$societe = $commande->client->adresse->societe;
if (strlen($societe) < 1) {
$societe = $nom;
}
$date = $commande->date;
$email = $commande->client->adresse->email;
$total = $commande->montants->montant[0];
$devise = $commande->montants->attributes()->devise;
//A SUPPRIMER -->
echo '<div style="display:inline-block;margin:0 25px;">';
echo '<p style="display:inline-block;"><b>NumCmd:</b><br>' . $id . '<br>';
echo '<b>Nom Facture:</b><br>' . $nom . '<br>';
echo '<b>Societe Facuration:</b><br>' . $societe . '<br>';
echo '<b>Date:</b><br>' . $date . '<br>';
echo '<b>Email Facuration:</b><br>' . $email . '<br>';
echo '<b>Total:</b><br>' . $total . ' ' . $devise . '</p>';
//FIN SUPPRESION <--
//API Gesco/commande/<ref>/produits
$produits = file_get_contents($API.'gesco/commande/' . $id . '/produits', false, context());
$produits = new SimpleXMLElement($produits);
$NbProduit = count($produits->commande->produits->produitCommande);
echo '<p><b>Nb Produit:</b><br>' . $NbProduit . '</p>';
//Ligne à ecrire (Format CSV)
echo '<p><b>' . $id . '</b> CSV String:</b><br>' . $id . ';' . $nom . ';' . $societe . ';' . $email . ';' . $total . ';' . $NbProduit . ';';
//Liste produits (Format CSV)
foreach ($produits->commande->produits->produitCommande as $produit) {
echo $produit->ref_produit . '|' . $produit->quantite . '|' . $produit->prixUnitaire . '|' . $produit->nom[0] . '$';
}
echo '</div><hr>';
}