PHP code example of adesa / smartlabel-client

1. Go to this page and download the library: Download adesa/smartlabel-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

adesa / smartlabel-client example snippets


$config = \Adesa\SmartLabelClient\Config::fromIniFile(__DIR__ . "/../config/smartlabel.ini");

$config = \Adesa\SmartLabelClient\Config::fromArray([
    "locale" => "fr-FR",
    "localeBasPath" => "../locale",
    "identifiantRevendeur" => "{votre identifiant revendeur}",
    "ftp" => [
        "host" => "adesaweb.adesa.fr",
        "user" => "{votre identifiant revendeur}"
        "password" => "{votre mot de passe FTP}"
    ]
]);

$smartLabel = new \Adesa\SmartLabelClient($config);

$smartLabel->listeMandrins(); // retourne un tableau d'objet Mandrin

$matieres = $smartLabel->listeMatieres(); // tableau d'objet Matière

$select = "<select name=matieres>";
foreach($matieres as $matiere){
    $select.= '<option value="' . $matiere->numero . '">';
    $select.= $smartLabel->label($matiere);
    $select.= '</option>';
 }
$select.= "</select>";

$matiere = $smartLabel->trouverMatiere($_GET['numero_matiere']);
// Les finitions disponibles sont fonctions de la matière sélectionnée
$finitions = $smartLabel->listeFinitions($matiere);

$select = "<select name=finitions>";
foreach($finitions as $finition){
    $select.= '<option value="' . $finition->numero . '">';
    $select.= $smartLabel->label($finition);
    $select.= '</option>';
 }
$select.= "</select>";

$scenario = $smartLabel->trouverScenario($matiere, $finition);

$bonDeCommande = $smartLabel->commander($dossier, $myOrder->orderID);

foreach($myOrder->getAttachments() as $attachment){
    $bonDeCommande->ajouterModele($attachment['name'], $attachment['filename']);
}

$smartLabel->finaliserBonDeCommande($bonDeCommande);

// toutes vos commandes d'étiquettes smartlabel dans un tableau associatif
// avec pour clé le numéro de dossier
$orders = DB::fetchSmartLabelOrders();

$etats = $smartLabel->etatDossiers(array_keys($orders));

// Le tableau $etats est composé d'objets EtatDossier
foreach($etats as $numeroDossier => $etat) {
    $order = $orders[$numeroDossier];
    switch($etat->code){
        case EtatDossier::LIVRAISON:
            $order->setState("shipping");
            break;
        case EtatDossier::ERREUR_FICHIER:
            if(!$order->isInState("error")){
                $order->setState("error");
                $order->customer->sendErrorMail();
            }
            break;
    }
}

ini
# ./config/smartlabel.ini

locale = {fr|en|es|…}
localeBasePath = ../locale
identifiantRevendeur = {votre identifiant revendeur}

[FTP]
host = adesaweb.adesa.fr
user = {votre login FTP}
password = {votre mot de passe FTP}