Initial commit

This commit is contained in:
2020-01-27 08:56:08 +01:00
commit b7525048d6
27129 changed files with 3409855 additions and 0 deletions

View File

@@ -0,0 +1,524 @@
<?php
// é
class Cadeau extends PluginsClassiques {
public $id;
public $image;
public $etat;
public $commande;
public $contenu = 29; // Les images devront obligatoirement être associées à ce contenu
public $montant = 129;
public $bddvars = array( "id", "image", "etat", "commande" );
public $table = "cadeau";
public function __construct() {
parent::__construct( "cadeau" );
}
public function charger( $id ) {
$sql = "
SELECT
*
FROM
`" . $this->table . "`
WHERE
id = " . intval( $id ) . "
";
return $this->getVars( $sql );
}
public function chargerAvecCommande( $idCommande ) {
$sql = "
SELECT
*
FROM
`" . $this->table . "`
WHERE
commande = " . intval( $idCommande ) . "
";
return $this->getVars( $sql );
}
public function chargerAvecRefCommande( $refCommande ) {
$commande = new Commande();
$sql = "
SELECT
cadeau.id as id,
cadeau.image as image,
cadeau.etat as etat,
cadeau.commande as commande
FROM
`" . $this->table . "` as cadeau
INNER JOIN
`" . $commande->table . "` as commande
ON
cadeau.commande = commande.id
WHERE
commande.ref = \"" . $refCommande . "\"
";
return $this->getVars( $sql );
}
public function init() {
$sql = "
CREATE TABLE IF NOT EXISTS `cadeau` (
`id` int(11) NOT NULL auto_increment,
`image` int(11) NOT NULL default '0',
`etat` int(11) NOT NULL default '0',
`commande` int(11) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
";
$this->query( $sql, true );
}
// Appelée lorsqu'une action est transmise (toujours donc)
public function action() {
$envAction = lireParam( 'action' , 'string' );
// Si l'action correspond au choix d'un cadeau, on enregistre le choix dans une session
if ( $envAction == 'choix_cadeau' ) {
$envCadeau = lireParam( 'cadeau' , 'int' );
$image = new Image( $envCadeau );
if ( $image->contenu == $this->contenu ) {
$_SESSION['thelia_choix_du_cadeau'] = intval( $envCadeau );
}
else {
if ( isset( $_SESSION['thelia_choix_du_cadeau'] ) ) {
unset( $_SESSION['thelia_choix_du_cadeau'] );
}
}
}
}
// Appelée lors de la création dune commande
public function aprescommande( $commande ) {
$total = $commande->total( false, true );
// Si le montant de la commande est suffisant ( total TTC, sans frais de port avec application remise)
if ( $total >= $this->montant ) {
$imageChoisie = 0;
if ( isset( $_SESSION['thelia_choix_du_cadeau'] ) ) {
$imageChoisie = intval( $_SESSION['thelia_choix_du_cadeau'] );
}
$cadeau = new Cadeau();
$cadeau->image = $imageChoisie;
$cadeau->etat = 0;
$cadeau->commande = $commande->id;
$cadeau->add();
}
}
// Appelée lors d'un changement de statut d'une commande
public function statut( $commande, $ancienStatut ) {
// On envoi un mail pour prise en compte cadeau si la commande est payée
if ( $commande->statut == 2 ) {
$cadeau = new Cadeau();
// Un cadeau doit être associé à la commande
if ( $cadeau->chargerAvecCommande( $commande->id ) ) {
if ( $cadeau->etat == 0 ) {
$sujet = "Un cadeau est associé à la commande";
$messagehtml = "<h3>Cadeau Offert</h3>
<p>
La commande " . $commande->ref . " nécessite l'envoi d'un cadeau.
</p>";
Mail::envoyer(
Variable::lire("nomsite"), Variable::lire("emailfrom"),
Variable::lire("nomsite"), Variable::lire("emailfrom"),
$sujet,
$messagehtml, "");
$cadeau->etat = 1;
$cadeau->maj();
}
}
}
elseif( $commande->statut == 5 ) {
$cadeau = new Cadeau();
// Un cadeau doit être associé à la commande
if ( $cadeau->chargerAvecCommande( $commande->id ) ) {
if ( $cadeau->etat <= 1 ) {
$cadeau->etat = 3;
$cadeau->maj();
}
}
}
}
public function boucle( $texte, $args ) {
$commande = lireTag( $args, "commande", "int" );
$etat = lireTag( $args, "etat", "int" );
$retourner = "";
$sqlIdCommande = "";
if ( !empty( $commande ) ) {
$sqlIdCommande = "
AND
commande = " . $commande . "
";
}
$sqlEtat = "";
if ( !empty( $etat ) ) {
$sqlIdCommande = "
AND
etat = " . $etat . "
";
}
$sql = "
SELECT
*
FROM
`" . $this->table . "`
WHERE
1
" . $sqlIdCommande . "
" . $sqlEtat . "
";
foreach ( $this->query_liste( $sql ) as $ligne ) {
$temp = str_replace( "#ID", $ligne->id, $texte );
$temp = str_replace( "#IMAGE", $ligne->image, $temp );
$temp = str_replace( "#ETAT", $ligne->etat, $temp );
$temp = str_replace( "#COMMANDE", $ligne->commande, $temp );
$retourner .= $temp;
}
return $retourner;
}
public function traduireEtat( $etat, $langue = 1 ) {
$etats = array(
'0' => '' ,
'1' => '' ,
'2' => '' ,
'3' => '' ,
);
if ( $langue == 1 ) {
$etats = array(
'0' => 'attente paiement commande' ,
'1' => 'attente envoi' ,
'2' => 'envoyé' ,
'3' => 'annulé' ,
);
}
$libelle = "";
if ( isset( $etats[$etat] ) ) {
$libelle = $etats[$etat];
}
return $libelle;
}
}

View File

@@ -0,0 +1,241 @@
<?php
// é
require_once( __DIR__ . '/../../../fonctions/authplugins.php' );
autorisation( "cadeau" );
$cadeauEstOffert = false;
$titreCadeau = "";
$imageCadeau =
$etatEnvoiCadeau = "";
$etats = array();
$cadeau = new Cadeau();
$refCommande = lireParam( 'ref', 'string' );
if ( $cadeau->chargerAvecRefCommande( $refCommande ) ) {
$image = new Image();
$imageDesc = new Imagedesc();
$cadeauEstOffert = true;
if ( $imageDesc->charger( $cadeau->image, 1 ) ) {
$titreCadeau = $imageDesc->titre;
if ( $image->charger( $cadeau->image ) ) {
$imageCadeau = "../fonctions/redimlive.php?type=contenu&nomorig=" . $image->fichier . "&width=80&height=80";
}
}
$etatEnvoiCadeau = $cadeau->etat;
$etats = array(
'0' => $cadeau->traduireEtat( 0 ) ,
'1' => $cadeau->traduireEtat( 1 ) ,
'2' => $cadeau->traduireEtat( 2 ) ,
'3' => $cadeau->traduireEtat( 3 ) ,
);
// Traitement aciton : changer_etat_livraison_cadeau
$action = lireParam( 'action', 'string' );
if ( $action == "changer_etat_livraison_cadeau" ) {
$etatEnvoiCadeau = lireParam( 'etat_envoi_cadeau', 'int' );
if ( !empty( $etatEnvoiCadeau ) && $etatEnvoiCadeau >= 0 && $etatEnvoiCadeau <= 3 ) {
$cadeau->etat = intval( $etatEnvoiCadeau );
$cadeau->maj();
}
}
$etatEnvoiCadeau = $cadeau->etat;
}
?>
<div class="bordure_bottom" style="margin:0 0 10px 0;">
<div class="entete_liste_client">
<div class="titre">CADEAU ASSOCIE A LA COMMANDE</div>
</div>
<?php
if ( $cadeauEstOffert ) {
?>
<ul class="ligne_claire_BlocDescription" style="background-image: url(gfx/degrade_ligne1.png); background-repeat: repeat-x;">
<li class="designation" style="width:290px; background-image: url(gfx/degrade_ligne1.png); background-repeat: repeat-x;">Cadeau</li>
<li><?php echo $titreCadeau; ?></li>
</ul>
<ul class="ligne_fonce_BlocDescription">
<li class="designation" style="width:290px; height: 84px;">Image</li>
<li>
<img src="<?php echo $imageCadeau; ?>" alt="" />
</li>
</ul>
<ul class="ligne_fonce_BlocDescription">
<li class="designation" style="width:290px; height: 46px;">Etat</li>
<li>
<form action="commande_details.php?ref=<?php echo $refCommande; ?>" method="post">
<input type="hidden" name="ref" value="<?php echo $refCommande; ?>" />
<input type="hidden" name="action" value="changer_etat_livraison_cadeau" />
<select name="etat_envoi_cadeau">
<?php
foreach ( $etats as $cle => $etat ) {
$selection = "";
if ( $cle == $etatEnvoiCadeau ) {
$selection = " selected='selected' ";
}
echo "
<option value='" . $cle . "' " . $selection . ">" . $etat . "</a>
";
}
?>
</select>
<br />
<input type="submit" value="Valider" />
</form>
</li>
</ul>
<?php
}
else {
?>
<ul class="ligne_fonce_BlocDescription">
<li class="designation" style="width:290px;">Pas de cadeau pour cette commande</li>
<li>&nbsp;</li>
</ul>
<?php
}
?>
</div>

View File

@@ -0,0 +1,18 @@
<?php
// é
// Les éléments suivants sont ajouter au fichier langue de votre template (fr)
$GLOBALS['dicotpl'] = array(
//commande_detail
'etat_envoi_cadeau_0' => 'Cadeau en attente du paiement de la commande',
'etat_envoi_cadeau_1' => 'Cadeau en attente d\'envoi',
'etat_envoi_cadeau_2' => 'Cadeau envoyé',
'etat_envoi_cadeau_3' => 'Cadeau annulé',
//moncompte
'cadeau' => 'Cadeau',
);

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<descriptif lang="fr">
<titre>Offir un cadeau</titre>
<chapo></chapo>
<description>
Permet d'associer un cadeau (image thelia) à une commande.
L'information est soumise par mail à l'administrateur et disponible dans l'administration ainsi que dans le compte client.
Le cadeau n'est pas un produit Thelia.
</description>
<postscriptum></postscriptum>
</descriptif>
<version>0.01</version>
<auteur>
<nom>Alexandre KELLER</nom>
<email>keller.alexandre0@gmail.com</email>
</auteur>
<type>classique</type>
<prerequis/>
<thelia>1.5</thelia>
<etat>production</etat>
<documentation>readme.txt</documentation>
<urlmiseajour></urlmiseajour>
</plugin>

View File

@@ -0,0 +1,322 @@
Offir un cadeau
Description
-----------
Permet d'associer un cadeau (image thelia) à une commande.
L'information est soumise par mail à l'administrateur et disponible dans l'administration ainsi que dans le compte client.
Le cadeau n'est pas un produit Thelia.
Installation
------------
Standard :
- upload de l'archive décompressée dans "client/plugins/".
- activation depuis l'administration Thelia.
Boucle cadeau
-------------
Description :
Cadeaux associés aux commandes.
Paramètre entrée :
commande : Identifiant (numérique) de la commande
etat : Etat (numerique) de soumission du cadeau
- 0 : Commande passée, attente paiement
- 1 : Commande payée, attente envoi
- 2 : Envoyé (manuellement)
- 3 : Annulé
Paramètre sortie :
id : Identifiant ligne base de donnée
image : Identifiant de l'image associée
etat : Etat d'envoi du cadeau
commande : Identifiant commande à laquelle est rataché le cadeau
Exemple :
<T_commandes_d_un_client>
<table id="table-panier">
<thead>
<tr>
<th>::numcommande:: </th>
<th>Date</th>
<th>::montant::</th>
<th>::statut::</th>
<th>::cadeau::</th>
<th>::voircommande::</th>
</tr>
</thead>
<tbody>
<THELIA_commandes_d_un_client type="COMMANDE" client="#CLIENT_ID">
<tr>
<td class="ligne">#REF</td>
<td class="ligne">#DATE</td>
<td class="ligne">#TOTCMDPORT €</td>
<td class="ligne">#STATUT</td>
<THELIA_cadeau_d_une_commande type="CADEAU" commande="#ID">
<THELIA_image_cadeau type="IMAGE" id="#IMAGE" largeur="50">
<td class="ligne">
<img src="#IMAGE" alt="#TITRE" title="#TITRE" />
</td>
</THELIA_image_cadeau>
</THELIA_cadeau_d_une_commande>
<td class="ligne"><a href="#URLFOND(commande_detail,commande=#REF)">::voircommande::</a></td>
</tr>
</THELIA_commandes_d_un_client>
</tbody>
</table>
</T_commandes_d_un_client>
<h4>::nocommande::</h4>
<//T_commandes_d_un_client>
Formulaire de sélection d'un cadeau
-----------------------------------
A insérer par défaut dans le template commande.html (mais rien ne l'oblige)
Nous listons toutes les images d'une page contenu (dans l'exemple c'est le contenu 10).
Le client doit sélectionner une image et valider.
<T_choix_cadeau>
<form method="post" action="#URLFOND(commande)">
<input type="hidden" name="action" value="choix_cadeau" />
<ul>
<THELIA_choix_cadeau type="IMAGE" contenu="1" largeur="180">
<li>
<h4>#TITRE</h4>
<img src="#IMAGE" alt="#TITRE"/>
<p>
<label>::choisir::</label>
<input type="radio" name="cadeau" value="#ID" />
</p>
</li>
</THELIA_choix_cadeau>
</ul>
<br />
<input type="submit" value="Envoyer" />
<br/>
</form>
</T_choix_cadeau>
<//T_choix_cadeau>
Pour conditionner l'affichage de ce formulaire selon le montant de la commande (99 €) :
<TEST_afficher_formulaire_cadeau variable="#PANIER_TOTREMISE" test="superieurouegal" valeur="99">
afficher le formulaire ici
</TEST_afficher_formulaire_cadeau>
ne rien mettre ici
<//TEST_afficher_formulaire_cadeau>
Commande détail
---------------
A placer dans la boucle commande du template commande_detail.html.
<THELIA_cadeau_d_une_commande type="CADEAU" commande="#ID">
<table>
<tbody>
<tr>
<td>
<THELIA_image_cadeau type="IMAGE" id="#IMAGE" largeur="120">
<img src="#IMAGE" alt="#TITRE" title="#TITRE" />
</THELIA_image_cadeau>
</td>
<td style="width: 30px;">
&nbsp;
</td>
<td>
<TEST_etat_0 variable="#ETAT" test="egal" valeur="0">
::etat_envoi_cadeau_0::
</TEST_etat_0>
<TEST_etat_1 variable="#ETAT" test="egal" valeur="1">
::etat_envoi_cadeau_1::
</TEST_etat_1>
<TEST_etat_2 variable="#ETAT" test="egal" valeur="2">
::etat_envoi_cadeau_2::
</TEST_etat_2>
<TEST_etat_3 variable="#ETAT" test="egal" valeur="3">
::etat_envoi_cadeau_3::
</TEST_etat_3>
<//TEST_etat_3>
<//TEST_etat_2>
<//TEST_etat_1>
<//TEST_etat_0>
</td>
</tr>
</tbody>
</table>
</THELIA_cadeau_d_une_commande>