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,161 @@
<?php
/*************************************************************************************/
/* */
/* Plugin pour Thelia */
/* */
/* Alerte stock par produit */
/* Version 1.1 */
/* */
/* Copyright (c) Informatique Prog */
/* email : contact@informatiqueprog.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License, or */
/* (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program; if not, write to the Free Software */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* */
/*************************************************************************************/
include_once(realpath(dirname(__FILE__)) . "/../../../classes/PluginsClassiques.class.php");
include_once(realpath(dirname(__FILE__)) . "/../../../classes/Variable.class.php");
class Alertstockprod extends PluginsClassiques{
var $id;
var $mini;
var $table = 'alertstockprod';
var $bddvars = array('id', 'mini');
function Alertstockprod(){
$this->PluginsClassiques('alertstockprod');
}
function init(){
$cnx = new Cnx();
$query = "CREATE TABLE `$this->table` ("
. " `id` int(11) NOT NULL"
. ", `mini` float NOT NULL DEFAULT '0'"
. ", PRIMARY KEY (`id`)"
. ")";
$result = mysql_query($query, $cnx->link);
$variable = new Variable();
if(!$variable->charger('alertstock_defaut')){
$variable->nom = 'alertstock_defaut';
$variable->valeur = '0';
$variable->add();
}
if(!$variable->charger('alertstock_caracteristique')){
$variable->nom = 'alertstock_caracteristique';
$variable->valeur = '0';
$variable->add();
}
}
function destroy(){
}
function controleProduits($listeProduits){
/*
* INFORMATIONS GOLBALS
*/
$alertstock_defaut = new Variable();
$alertstock_defaut->charger('alertstock_defaut');
$mailMessage = '';
/*
* BOUCLE SUR LES PRODUITS
*/
foreach($listeProduits as $produit){
if(isset($produit['Alertstock']) && $produit['Alertstock'] != '')
$alertstockProduit = (int)$produit['Alertstock'];
else if(isset($produit['Alertstock2']) && $produit['Alertstock2'] != '')
$alertstockProduit = (int)$produit['Alertstock2'];
else
$alertstockProduit = (int)$alertstock_defaut->valeur;
if($produit['Stock'] <= $alertstockProduit)
$mailMessage .= 'Ref : ' . $produit['Ref'] . ' ( ' . $produit['Titre'] . ' ), Stock actuel => ' . $produit['Stock'] . ', Alerte stock =>' . $alertstockProduit . "\n";
}
/*
* MAIL
*/
if (!empty($mailMessage)){
$contact = new Variable();
$contact->charger('emailcontact');
$urlsite = new Variable();
$urlsite->charger('urlsite');
include_once(realpath(dirname(__FILE__)) . "/../../../classes/Mail.class.php");
$mail = new Mail();
$mail->IsMail();
$mail->From = $contact->valeur;
$mail->FromName = $urlsite->valeur;
$mail->Subject = 'Alerte stock pour le site : ' . $urlsite->valeur;
$mail->AltBody = $mailMessage;
$mail->MsgHTML(nl2br($mailMessage));
$mail->AddAddress($contact->valeur);
$mail->send();
return 'Email envoyé';
} else
return 'Aucune alerte stock';
}
function aprescommande($commande){
$caracteristique = new Variable();
$caracteristique->charger('alertstock_caracteristique');
$listeProduits = array();
/*
* PRODUITS DE LA COMMANDE
*/
include_once(realpath(dirname(__FILE__)) . "/../../../classes/Caracval.class.php");
$caracval = new Caracval();
include_once(realpath(dirname(__FILE__)) . "/../../../classes/Caracdispdesc.class.php");
$caracdispdesc = new Caracdispdesc();
include_once(realpath(dirname(__FILE__)) . "/../../../classes/Venteprod.class.php");
$venteprod = new Venteprod();
include_once(realpath(dirname(__FILE__)) . "/../../../classes/Produit.class.php");
$produit = new Produit();
$query = "SELECT tVentP.ref Ref, tVentP.titre Titre, tProd.stock Stock, tCaracDispDesc.titre Alertstock, tCaracVal.valeur Alertstock2 FROM $venteprod->table tVentP"
. " JOIN $produit->table tProd ON tVentP.ref=tProd.ref"
. " LEFT JOIN $caracval->table tCaracVal ON tProd.id=tCaracVal.produit AND tCaracVal.caracteristique=$caracteristique->valeur"
. " LEFT JOIN $caracdispdesc->table tCaracDispDesc ON tCaracVal.caracdisp=tCaracDispDesc.caracdisp"
. " WHERE commande=$commande->id";
$result = mysql_query($query, $venteprod->link);
while($row = mysql_fetch_assoc($result)){
$listeProduits[] = $row;
}
$this->controleProduits($listeProduits);
}
function chargerTousLesProduits(){
$caracteristique = new Variable();
$caracteristique->charger('alertstock_caracteristique');
$listeProduits = array();
/*
* TOUS LES PRODUITS
*/
include_once(realpath(dirname(__FILE__)) . "/../../../classes/Caracval.class.php");
$caracval = new Caracval();
include_once(realpath(dirname(__FILE__)) . "/../../../classes/Caracdispdesc.class.php");
$caracdispdesc = new Caracdispdesc();
include_once(realpath(dirname(__FILE__)) . "/../../../classes/Produit.class.php");
$produit = new Produit();
include_once(realpath(dirname(__FILE__)) . "/../../../classes/Produitdesc.class.php");
$produitdesc = new Produitdesc();
$query = "SELECT tProd.ref Ref, tProdDesc.titre Titre, tProd.stock Stock, tCaracDispDesc.titre Alertstock, tCaracVal.valeur Alertstock2 FROM $produit->table tProd"
. " JOIN $produitdesc->table tProdDesc ON tProd.id=tProdDesc.produit AND tProdDesc.lang=1"
. " LEFT JOIN $caracval->table tCaracVal ON tProd.id=tCaracVal.produit AND tCaracVal.caracteristique=$caracteristique->valeur"
. " LEFT JOIN $caracdispdesc->table tCaracDispDesc ON tCaracVal.caracdisp=tCaracDispDesc.caracdisp";
$result = mysql_query($query, $produit->link);
while($row = mysql_fetch_assoc($result)){
$listeProduits[] = $row;
}
return $this->controleProduits($listeProduits);
}
}
?>

View File

@@ -0,0 +1,33 @@
/************ INSTALLATION ************/
- Glisser le dossier dézippé dans "client/plugins" ou uploader le dossier zippé depuis l'interface d'administration.
- Activer le plugin depuis l'interface d'administration.
- Dans "Configuration", "Gestion des caractéristiques", Ajouter une caractéristique (que vous allez nommer "Alerte stock" par exemple)
- Noter l'ID de cette caractéristique (en dessous de "INFORMATION SUR LA CARACTERISTIQUE")
- Ajouter à cette caractéristique autant de valeurs que vous souhaitez (par exemple : 0, 1, 3 et 5)
- Dans "Configuration", "Gestion des variables", saisissez l'ID de la caractéristique pour la variable "alertstock_caracteristique"
/************ UTILISATION ************/
Ce plugin vous avertira par mail lorsque le stock d'un produit sera inférieur à sa quantité paramétrée si elle est renseignée ou la valeur "Alerte stock" par défaut pour le site.
Pour paramétrée la valeur "Alerte stock" par défaut pour le site :
- Dans "Configuration", "Gestion des variables", saisissez la valeur souhaitée pour la variable "alertstock_defaut"
Pour paramétrée la valeur par défaut pour chaque produit :
- Editez la fiche du produit, choisissez la valeur que vous souhaitez pour la caractéristique "Alerte stock"
Après chaque commande, le plugin contrôle les "alerte stock" des produits de la commande.
Dans "Modules", "Alerte stock par produit", vous pouvez demander au plugin de vous envoyer un mail avec toutes les "alerte stock".
Cet envoie peut être planifier, il faut configurer une tâche cron sur votre serveur (voir avec votre hébergeur) qui appele "/chemin/vers/client/plugins/alertstockprod/cron_alerte.php"
Merci à yoan pour son plugin "alertstock" qui m'a grandement inspiré.
/************** VERSION **************/
- Version 1.1 => Ajout de la possibilité de saisir la valeur de la caractéristique à la place d'une liste de caractéristiques
- Version 1.0 => Mise en production

View File

@@ -0,0 +1,64 @@
<?php
/*************************************************************************************/
/* */
/* Plugin pour Thelia */
/* */
/* Alerte stock par produit */
/* Version 1.1 */
/* */
/* Copyright (c) Informatique Prog */
/* email : contact@informatiqueprog.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License, or */
/* (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program; if not, write to the Free Software */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* */
/*************************************************************************************/
include_once(realpath(dirname(__FILE__)) . "/../../../fonctions/authplugins.php");
autorisation("alertstockprod");
include_once(realpath(dirname(__FILE__)) . "/Alertstockprod.class.php");
/*
* CONFIG
*/
$nomModule = "alertstockprod";
$urlPage = "module.php?nom=$nomModule";
?>
<script type="text/javascript" src="../lib/jquery/jquery.js"></script>
<script type="text/javascript">
//<![CDATA[
function sendMail(){
$('#resultAlerte').html('Traitement en cours...');
$('#resultAlerte').load('../client/plugins/alertstockprod/cron_alertstockprod.php', function() {
alert('terminé !');
});
}
//]]>
</script>
<div id="contenu_int">
<p align="left">
<a class="lien04" href="accueil.php">Accueil </a> <img src="gfx/suivant.gif" border="0" width="12" height="9">
<a href="module_liste.php" class="lien04" >Liste des modules</a> <img src="gfx/suivant.gif" border="0" width="12" height="9">
<a href="<?php echo $urlPage; ?>" class="lien04">Gestion des alertes stock par produit</a>
</p>
<div class="entete_liste_config" style="border-bottom: 1px solid #9DACB6;">
<div class="titre">Alertes stock par produit</div>
</div>
<p>&nbsp;</p>
<p align="center"><a href="#" id="alertstockprod" onclick="sendMail();">Envoyer le mail contenant les alertes stock</a></p>
<p>&nbsp;</p>
<p align="center" id="resultAlerte">&nbsp;</p>
<p>&nbsp;</p>
</div>

View File

@@ -0,0 +1,34 @@
<?php
/*************************************************************************************/
/* */
/* Plugin pour Thelia */
/* */
/* Alerte stock par produit */
/* Version 1.1 */
/* */
/* Copyright (c) Informatique Prog */
/* email : contact@informatiqueprog.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License, or */
/* (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program; if not, write to the Free Software */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* */
/*************************************************************************************/
include_once(realpath(dirname(__FILE__)) . "/Alertstockprod.class.php");
$Alertstockprod = new Alertstockprod();
$resultat = $Alertstockprod->chargerTousLesProduits();
echo utf8_encode($resultat);
?>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--Migration automatique depuis le fichier original, sauvegardé dans plugin.xml.save-->
<plugin>
<descriptif lang="fr">
<titre>Alerte stock par produit</titre>
<chapo></chapo>
<description>Ce plugin vous avertira par mail lorsque le stock d'un produit sera inférieur à sa quantité paramétrée si elle est renseignée ou la valeur "Alerte stock" par défaut pour le site.</description>
<postscriptum></postscriptum>
</descriptif>
<version>1.1</version>
<auteur>
<nom>Informatique Prog - contact@informatiqueprog.net</nom>
<societe></societe>
<email></email>
<web></web>
</auteur>
<type>classique</type>
<prerequis/>
<thelia>1.4.0</thelia>
<etat>production</etat>
<documentation>Readme.txt</documentation>
<urlmiseajour></urlmiseajour>
</plugin>