function substitadresse($texte)
{
    global $adresse;
    $tadresse = new Adresse();
    if ($tadresse->charger(intval($adresse))) {
        $raisondesc = new Raisondesc();
        $raisondesc->charger($tadresse->raison);
        $paysdesc = new Paysdesc();
        $paysdesc->charger($tadresse->pays);
        $texte = str_replace("#ADRESSE_RAISONID", $tadresse->raison, $texte);
        $texte = str_replace("#ADRESSE_IDPAYS", $tadresse->pays, $texte);
        $texte = str_replace("#ADRESSE_ID", $tadresse->id, $texte);
        $texte = str_replace("#ADRESSE_LIBELLE", $tadresse->libelle, $texte);
        $texte = str_replace("#ADRESSE_RAISON", $raisondesc->long, $texte);
        $texte = str_replace("#ADRESSE_ENTREPRISE", $tadresse->entreprise, $texte);
        $texte = str_replace("#ADRESSE_NOM", $tadresse->nom, $texte);
        $texte = str_replace("#ADRESSE_PRENOM", $tadresse->prenom, $texte);
        $texte = str_replace("#ADRESSE_ADRESSE1", $tadresse->adresse1, $texte);
        $texte = str_replace("#ADRESSE_ADRESSE2", $tadresse->adresse2, $texte);
        $texte = str_replace("#ADRESSE_ADRESSE3", $tadresse->adresse3, $texte);
        $texte = str_replace("#ADRESSE_CPOSTAL", $tadresse->cpostal, $texte);
        $texte = str_replace("#ADRESSE_VILLE", $tadresse->ville, $texte);
        $texte = str_replace("#ADRESSE_PAYS", $paysdesc->titre, $texte);
        $texte = str_replace("#ADRESSE_TEL", $tadresse->tel, $texte);
    }
    $texte = str_replace("#ADRESSE_ACTIVE", "" . $_SESSION['navig']->adresse . "", $texte);
    return $texte;
}
Beispiel #2
0
function boucleTransport($texte, $args)
{
    // récupération des arguments
    $id = lireTag($args, "id", "int_list");
    $nom = lireTag($args, "nom", "string");
    $exclusion = lireTag($args, "exclusion", "string_list");
    $idpays = intval(lireTag($args, "pays", "int"));
    $cpostal = intval(lireTag($args, "cpostal", "string"));
    $montantmini = intval(lireTag($args, "montantmini", "float"));
    $search = "";
    $res = "";
    if ($id != "") {
        $search .= "and id in ({$id})";
    }
    if ($nom != "") {
        $search .= "and nom=\"{$nom}\"";
    }
    if ($exclusion != "") {
        $liste = "";
        $tabexcl = explode(",", $exclusion);
        for ($i = 0; $i < count($tabexcl); $i++) {
            $liste .= "'" . $tabexcl[$i] . "'" . ",";
        }
        $liste = rtrim($liste, ",");
        $search .= " and nom not in ({$liste})";
    }
    $modules = new Modules();
    $query = "select * from {$modules->table} where type='2' and actif='1' {$search} order by classement";
    $resul = CacheBase::getCache()->query($query);
    if (empty($resul)) {
        return "";
    }
    $pays = new Pays();
    if ($idpays > 0) {
        $pays->charger($idpays);
    } else {
        if ($_SESSION['navig']->adresse != "" && $_SESSION['navig']->adresse != 0) {
            $adr = new Adresse();
            $adr->charger($_SESSION['navig']->adresse);
            $pays->charger($adr->pays);
        } else {
            $pays->charger($_SESSION['navig']->client->pays);
        }
    }
    $transzone = new Transzone();
    $compt = 0;
    foreach ($resul as $row) {
        if (!$transzone->charger($row->id, $pays->zone)) {
            continue;
        }
        $compt++;
        $modules = new Modules();
        $modules->charger_id($row->id);
        try {
            $instance = ActionsModules::instance()->instancier($modules->nom);
            $port = round(port($row->id, $pays->id, $cpostal), 2);
            $titre = $instance->getTitre();
            $chapo = $instance->getChapo();
            $description = $instance->getDescription();
        } catch (Exception $ex) {
            $titre = $chapo = $description = '';
        }
        if ($port < $montantmini) {
            continue;
        }
        // Chercher le logo
        $exts = array('png', 'gif', 'jpeg', 'jpg');
        $logo = false;
        foreach ($exts as $ext) {
            $tmp = ActionsModules::instance()->lire_chemin_base() . "/{$row->nom}/logo.{$ext}";
            if (file_exists($tmp)) {
                $logo = ActionsModules::instance()->lire_url_base() . "/{$row->nom}/logo.{$ext}";
                break;
            }
        }
        $temp = str_replace("#NOM", $row->nom, $texte);
        $temp = str_replace("#TITRE", "{$titre}", $temp);
        $temp = str_replace("#CHAPO", "{$chapo}", $temp);
        $temp = str_replace("#DESCRIPTION", "{$description}", $temp);
        $temp = str_replace("#URLCMD", urlfond("commande", "action=transport&amp;id=" . $row->id, true), $temp);
        $temp = str_replace("#ID", "{$row->id}", $temp);
        $temp = str_replace("#LOGO", $logo, $temp);
        $temp = str_replace("#PORT", formatter_somme($port), $temp);
        $temp = str_replace("#COMPT", "{$compt}", $temp);
        $res .= $temp;
    }
    return $res;
}
 public function editAddress($id, $libelle, $raison, $entreprise, $nom, $prenom, $adresse1, $adresse2, $adresse3, $cpostal, $ville, $tel, $pays)
 {
     $addressToEdit = new Adresse();
     if ($addressToEdit->charger($id)) {
         $addressToEdit->libelle = $libelle;
         $addressToEdit->raison = $raison;
         $addressToEdit->entreprise = $entreprise;
         $addressToEdit->prenom = $prenom;
         $addressToEdit->nom = $nom;
         $addressToEdit->adresse1 = $adresse1;
         $addressToEdit->adresse2 = $adresse2;
         $addressToEdit->adresse3 = $adresse3;
         $addressToEdit->cpostal = $cpostal;
         $addressToEdit->ville = $ville;
         $addressToEdit->tel = $tel;
         $addressToEdit->pays = $pays;
         if ($addressToEdit->libelle != "" && $addressToEdit->raison != "" && $addressToEdit->prenom != "" && $addressToEdit->nom != "" && $addressToEdit->adresse1 != "" && $addressToEdit->cpostal != "" && $addressToEdit->ville != "" && $addressToEdit->pays != "") {
             $addressToEdit->maj();
             ActionsModules::instance()->appel_module("apres_modifierlivraison", $addressToEdit);
         } else {
             throw new TheliaAdminException("impossible to edit adresse's client", TheliaAdminException::CLIENT_ADRESS_EDIT_ERROR);
         }
     }
     $this->redirect();
 }
Beispiel #4
0
function supprimerlivraison($id)
{
    $adresse = new Adresse();
    $adresse->charger($id);
    if ($adresse->client != $_SESSION['navig']->client->id) {
        return;
    }
    $adresse->delete();
    if ($_SESSION['navig']->adresse == $id) {
        $_SESSION['navig']->adresse = 0;
    }
}
function substitpanier($texte)
{
    $total = 0;
    $totalht = 0;
    $totaleco = 0;
    $totaltaxe = 0;
    $allItemCount = $nb_article = 0;
    if ($_SESSION['navig']->adresse) {
        $adr = new Adresse();
        $adr->charger($_SESSION['navig']->adresse);
        $idpays = $adr->pays;
    } else {
        $idpays = $_SESSION['navig']->client->pays;
    }
    $pays = new Pays();
    $pays->charger($idpays);
    $total = $_SESSION['navig']->panier->total();
    $totalht = $_SESSION['navig']->panier->total(0);
    $totaleco = $_SESSION['navig']->panier->totalecotaxe();
    $tva = $total - $totalht;
    $nb_article = $_SESSION['navig']->panier->nbart;
    foreach ($_SESSION['navig']->panier->tabarticle as $anItem) {
        $allItemCount += $anItem->quantite;
    }
    unset($anItem);
    $port = port();
    if ($port < 0) {
        $port = 0;
    }
    $totcmdport = $total + $port;
    $remise = $remise_client = $remise_promo = 0;
    if ($_SESSION['navig']->client->pourcentage > 0) {
        $remise_client = $total * $_SESSION['navig']->client->pourcentage / 100;
    }
    $remise_promo += calc_remise($total);
    $remise = $remise_promo + $remise_client;
    $totcmdport -= $remise;
    $totremise = $total - $remise;
    if ($totcmdport < $port) {
        $totcmdport = $port;
    }
    $totcmdportht = $totalht + $port;
    $totalht = formatter_somme($totalht);
    $total = formatter_somme($total);
    $totaleco = formatter_somme($totaleco);
    $totaltaxe = formatter_somme($totaltaxe);
    $port = formatter_somme($port);
    $totcmdport = formatter_somme($totcmdport);
    $remise = formatter_somme($remise);
    $totremise = formatter_somme($totremise);
    $totcmdportht = formatter_somme($totcmdportht);
    $tva = formatter_somme($tva, 2, ".", "");
    $remise_client = formatter_somme($remise_client);
    $remise_promo = formatter_somme($remise_promo);
    $totpoids = $_SESSION['navig']->panier->poids();
    $texte = str_replace("#PANIER_TOTALHT", "{$totalht}", $texte);
    $texte = str_replace("#PANIER_TOTALECO", "{$totaleco}", $texte);
    $texte = str_replace("#PANIER_TOTALTVA", "{$tva}", $texte);
    // total TVA du panier = #PANIER_TVA
    $texte = str_replace("#PANIER_TOTAL", "{$total}", $texte);
    $texte = str_replace("#PANIER_PORT", "{$port}", $texte);
    $texte = str_replace("#PANIER_TOTPORTHT", "{$totcmdportht}", $texte);
    $texte = str_replace("#PANIER_TOTPORT", "{$totcmdport}", $texte);
    $texte = str_replace("#PANIER_TOTREMISE", "{$totremise}", $texte);
    $texte = str_replace("#PANIER_REMISE_CLIENT", "{$remise_client}", $texte);
    $texte = str_replace("#PANIER_REMISE_PROMO", "{$remise_promo}", $texte);
    $texte = str_replace("#PANIER_REMISE", "{$remise}", $texte);
    $texte = str_replace("#PANIER_NBART_TOTAL", $allItemCount, $texte);
    $texte = str_replace("#PANIER_NBART", "" . $nb_article . "", $texte);
    $texte = str_replace("#PANIER_POIDS", "{$totpoids}", $texte);
    $texte = str_replace("#PANIER_TVA", "{$tva}", $texte);
    // total TVA du panier
    return $texte;
}
 function total($tva = 1, $remise = 0)
 {
     $total = 0;
     $taxe = 0;
     $pays = new Pays();
     if ($_SESSION['navig']->adresse != "" && $_SESSION['navig']->adresse != 0) {
         $adr = new Adresse();
         $adr->charger($_SESSION['navig']->adresse);
         $pays->charger($adr->pays);
     } else {
         $pays->charger($_SESSION['navig']->client->pays);
     }
     foreach ($this->tabarticle as $art) {
         $prix = $art->produit->promo ? $art->produit->prix2 : $art->produit->prix;
         $taxe += ($prix - $prix / (1 + $art->produit->tva / 100)) * $art->quantite;
         $total += $prix * $art->quantite;
     }
     if ($tva && $pays->tva != "" && !$pays->tva) {
         $total -= $taxe;
     } else {
         if ($tva == 0) {
             $total -= $taxe;
         }
     }
     $total -= $remise;
     ActionsModules::instance()->appel_module("totalPanier", $total);
     return round($total, 2);
 }