Files
le-matelot/client/plugins/prodplusvus/Prodplusvus.class.php
2020-01-27 08:56:08 +01:00

133 lines
4.2 KiB
PHP

<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) Octolys Development */
/* email : thelia@octolys.fr */
/* web : http://www.octolys.fr */
/* */
/* 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 */
/* */
/*************************************************************************************/
?>
<?php
include_once(realpath(dirname(__FILE__)) . "/../../../classes/PluginsClassiques.class.php");
class Prodplusvus extends PluginsClassiques{
var $id;
var $vu;
var $ref;
var $table="prodplusvus";
var $bddvars = array("id", "vu", "ref");
function Prodplusvus(){
$this->PluginsClassiques();
}
function charger($id){
return $this->getVars("select * from $this->table where id=\"$id\"");
}
function init(){
$cnx = new Cnx();
$query_prodplusvus = "CREATE TABLE `prodplusvus` (
`id` int(11) NOT NULL auto_increment,
`vu` datetime NOT NULL,
`ref` text NOT NULL,
PRIMARY KEY (`id`)
) AUTO_INCREMENT=1 ;
";
$resul_prodplusvus = mysql_query($query_prodplusvus, $cnx->link);
}
function destroy(){
$cache = new Cache();
$cache->vider("PRODPLUSVUS", "%");
}
function boucle($texte, $args){
// récupération des arguments
$num = lireTag($args, "num");
$classement = lireTag($args, "classement");
$search ="";
$res="";
if($classement == "inverse")
$ordre = SORT_ASC;
else $ordre = SORT_DESC;
$prodplusvus = new Prodplusvus();
$query_prodplusvus = "select distinct(ref) from $prodplusvus->table where 1";
$resul_prodplusvus = mysql_query($query_prodplusvus, $prodplusvus->link);
$nbres = mysql_numrows($resul_prodplusvus);
if(!$nbres) return "";
$i=0;
while( $row = mysql_fetch_object($resul_prodplusvus)){
$query_prodplusvus2 = "select count(*) as nb from $prodplusvus->table where ref=\"" . $row->ref . "\"";
$resul_prodplusvus2 = mysql_query($query_prodplusvus2, $prodplusvus->link);
$nb = mysql_result($resul_prodplusvus2, 0, "nb");
$liste[$row->ref . " "]=$nb;
}
array_multisort($liste, $ordre);
foreach ($liste as $key=>$value) {
if($num != "" && $i>$num-1)
break;
$temp = str_replace("#REF", trim($key), $texte);
$temp = str_replace("#NB", $value, $temp);
$res .= $temp;
$i++;
}
return $res;
}
function action($res){
if($_GET['ref'] != ""){
$prodplusvus = new Prodplusvus();
$prodplusvus->ref = $_GET['ref'];
$prodplusvus->vu = date("Y-m-d H:i:s");
$prodplusvus->add();
}
}
}
?>