Qual: Suppression fichiers obsoletes

This commit is contained in:
Laurent Destailleur 2006-09-03 13:03:21 +00:00
parent 7689f3c523
commit 02aff93fa7
25 changed files with 36 additions and 2970 deletions

View File

@ -1,219 +0,0 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* 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.
*
* $Id$
* $Source$
*
*/
/*! \file htdocs/boutique/auteur/auteur.class.php
\brief Classe permettant de gèrer des auteurs
\author Rodolphe Quideville
\version $Revision$
*/
/*! \class Auteur
\brief Classe permettant de gèrer des auteurs
*/
class Auteur {
var $db ;
var $id ;
var $nom;
function Auteur($DB, $id=0) {
$this->db = $DB;
$this->id = $id ;
}
/*
*
*
*
*/
function create($user) {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."auteur (fk_user_author) VALUES (".$user->id.")";
if ($this->db->query($sql) )
{
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."auteur");
if ( $this->update($id, $user) )
{
return $id;
}
}
}
/*
*
*
*/
function liste_array ()
{
$ga = array();
$sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."auteur ORDER BY nom";
if ($this->db->query($sql) )
{
$nump = $this->db->num_rows();
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$obj = $this->db->fetch_object();
$ga[$obj->rowid] = $obj->nom;
$i++;
}
}
return $ga;
}
else
{
print $this->db->error();
}
}
/*
*
*
*
*/
function update($id, $user)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."auteur ";
$sql .= " SET nom = '" . trim($this->nom) ."'";
$sql .= " WHERE rowid = " . $id;
if ( $this->db->query($sql) ) {
return 1;
} else {
print $this->db->error() . ' in ' . $sql;
}
}
/*
*
*
*
*/
function liste_livre($id_type='', $status=0)
{
$ga = array();
if ($id_type == 'oscid')
{
$sql = "SELECT a.oscid, ";
}
else
{
$sql = "SELECT a.rowid, ";
}
$sql .= " a.title FROM ".MAIN_DB_PREFIX."livre as a, ".MAIN_DB_PREFIX."livre_to_auteur as l";
$sql .= " WHERE a.rowid = l.fk_livre AND l.fk_auteur = ".$this->id;
if ($status)
{
$sql .= " AND a.status = 1";
}
$sql .= " ORDER BY a.title";
if ($this->db->query($sql) )
{
$nump = $this->db->num_rows();
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$row = $this->db->fetch_row($i);
$ga[$row[0]] = $row[1];
$i++;
}
}
return $ga;
}
else
{
print $this->db->error();
}
}
/*
*
*
*
*/
function fetch ($id) {
$sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."auteur WHERE rowid = $id";
$result = $this->db->query($sql) ;
if ( $result )
{
$result = $this->db->fetch_array();
$this->id = $result["rowid"];
$this->nom = stripslashes($result["nom"]);
$this->db->free();
}
else
{
print $this->db->error();
}
return $result;
}
/*
*
*
*/
function delete() {
$livres = $this->liste_livre();
if (sizeof($livres) == 0)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."auteur WHERE rowid = $this->id ";
$return = $this->db->query($sql) ;
}
}
}
?>

View File

@ -1,187 +0,0 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.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.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
if ($action == 'add') {
$auteur = new Auteur($db);
$auteur->nom = $nom;
$id = $auteur->create($user);
}
if ($action == 'addga') {
$auteur = new Auteur($db);
$auteur->linkga($id, $ga);
}
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == yes)
{
$auteur = new Auteur($db);
$result = $auteur->fetch($id);
$auteur->delete();
Header("Location: index.php");
}
if ($action == 'update' && !$cancel) {
$auteur = new Auteur($db);
$auteur->nom = $nom;
$auteur->update($id, $user);
}
llxHeader();
/*
*
*
*/
if ($action == 'create')
{
print "<form action=\"fiche.php?id=$id\" method=\"post\">\n";
print '<input type="hidden" name="action" value="add">';
print '<div class="titre">Nouvel Auteur</div><br>';
print '<table border="1" width="100%" cellspacing="0" cellpadding="4">';
print "<tr>";
print '<td>Nom</td><td><input name="nom" size="40" value=""></td></tr>';
print '<tr><td>&nbsp;</td><td><input type="submit" value="Créer"></td></tr>';
print '</table>';
print '</form>';
}
else
{
if ($id)
{
$auteur = new Auteur($db);
$result = $auteur->fetch($id);
if ( $result )
{
$livres = $auteur->liste_livre();
/*
* Confirmation de la suppression de l'auteur
*
*/
if ($action == 'delete')
{
$htmls = new Form($db);
$htmls->form_confirm("fiche.php?id=$id","Supprimer un auteur","Etes-vous sur de vouloir supprimer cet auteur ?","confirm_delete");
}
/*
* Edition
*
*/
if ($action == 'edit')
{
print '<div class="titre">Edition de la fiche Auteur : '.$auteur->nom.'</div><br>';
print "<form action=\"fiche.php?id=$id\" method=\"post\">\n";
print '<input type="hidden" name="action" value="update">';
print '<table class="border" width="100%">';
print "<tr>";
print '<td width="20%">Nom</td><td><input name="nom" size="40" value="'.$auteur->nom.'"></td>';
print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Save").'">&nbsp;<input type="submit" value="'.$langs->trans("Cancel").'" name="cancel"></td></tr>';
print '</form>';
print '</table><hr>';
}
print '<div class="titre">Fiche Auteur : '.$auteur->nom.'</div><br>';
print '<table class="border" width="100%">';
print "<tr>";
print '<td width="20%">Nom</td><td width="80%">'.$auteur->nom.'</td></tr>';
print '<tr><td>Livres</td><td>';
foreach ($livres as $key => $value)
{
print '<a href="../livre/fiche.php?id='.$key.'">'.$value."<br>\n";
}
print "</td></tr>";
print "</table>";
}
else
{
print "Fetch failed";
}
}
else
{
print "Error";
}
}
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
print '<div class="tabsAction">';
if ($action != 'create')
{
print '<a class="tabAction" href="fiche.php?action=edit&id='.$id.'">'.$langs->trans("Edit").'</a>';
}
if(sizeof($livres)==0 && $id)
{
print '<a class="tabAction" href="fiche.php?action=delete&id='.$id.'">'.$langs->trans("Delete").'</a>';
}
print '</div>';
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,74 +0,0 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.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.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
llxHeader();
if ($sortfield == "") {
$sortfield="lower(e.nom)";
}
if ($sortorder == "") {
$sortorder="ASC";
}
if ($page == -1) { $page = 0 ; }
$limit = $conf->liste_limit;
$offset = $limit * $page ;
print_barre_liste("Liste des Auteurs", $page, "index.php");
$sql = "SELECT e.rowid, e.nom FROM ".MAIN_DB_PREFIX."auteur as e";
$sql .= " ORDER BY $sortfield $sortorder ";
$sql .= $db->plimit( $limit ,$offset);
if ( $db->query($sql) ) {
$num = $db->num_rows();
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
print_liste_field_titre("Nom","index.php", "e.nom");
print "</tr>\n";
$var=True;
while ($i < $num) {
$objp = $db->fetch_object();
$var=!$var;
print "<tr $bc[$var]>";
print "<td width='70%'><a href=\"fiche.php?id=$objp->rowid\">$objp->nom</a></td>\n";
print "</tr>\n";
$i++;
}
print "</table>";
$db->free();
}
else
{
dolibarr_print_error($db);
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,58 +0,0 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* 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.
*
* $Id$
* $Source$
*
*/
require("../../main.inc.php");
require("../livre/livre.class.php");
require("./auteur.class.php");
function llxHeader($head = "", $urlp = "") {
global $user, $conf;
/*
*
*
*/
top_menu($head);
$menu = new Menu();
$menu->add(DOL_URL_ROOT."/boutique/livre/", "Livres");
$menu->add_submenu(DOL_URL_ROOT."/boutique/livre/fiche.php?&action=create","Nouvel ouvrage");
$menu->add(DOL_URL_ROOT."/boutique/auteur/", "Auteurs");
$menu->add_submenu(DOL_URL_ROOT."/boutique/auteur/fiche.php?&action=create","Nouvel auteur");
$menu->add(DOL_URL_ROOT."/boutique/editeur/", "Editeurs");
$menu->add_submenu(DOL_URL_ROOT."/boutique/editeur/fiche.php?&action=create","Nouvel éditeur");
$menu->add(DOL_URL_ROOT."/product/categorie/", "Catégories");
left_menu($menu->liste);
/*
*
*
*/
}
?>

View File

@ -42,6 +42,8 @@ function llxHeader($head = "", $urlp = "")
$menu->add(DOL_URL_ROOT."/boutique/index.php", $langs->trans("OSCommerceShop"));
$menu->add_submenu(DOL_URL_ROOT."/boutique/produits/osc-liste.php", $langs->trans("Products"));
$menu->add_submenu(DOL_URL_ROOT."/boutique/critiques/index.php", $langs->trans("Critiques"));
$menu->add_submenu(DOL_URL_ROOT."/boutique/critiques/bestproduct.php", "Meilleurs produits",2);
$menu->add_submenu(DOL_URL_ROOT."/boutique/promotion/index.php", $langs->trans("Promotion"));
$menu->add_submenu(DOL_URL_ROOT."/boutique/client/", $langs->trans("Customers"));
$menu->add_submenu(DOL_URL_ROOT."/boutique/commande/", $langs->trans("Orders"));

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.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
@ -21,6 +21,13 @@
*
*/
/**
\file htdocs/boutique/commande/index.php
\ingroup boutique
\brief Page gestion commandes OSCommerce
\version $Revision$
*/
require("./pre.inc.php");
llxHeader();

View File

@ -41,6 +41,8 @@ function llxHeader($head = "", $urlp = "")
$menu->add(DOL_URL_ROOT."/boutique/index.php", $langs->trans("OSCommerceShop"));
$menu->add_submenu(DOL_URL_ROOT."/boutique/produits/osc-liste.php", $langs->trans("Products"));
$menu->add_submenu(DOL_URL_ROOT."/boutique/critiques/index.php", $langs->trans("Critiques"));
$menu->add_submenu(DOL_URL_ROOT."/boutique/critiques/bestproduct.php", "Meilleurs produits",2);
$menu->add_submenu(DOL_URL_ROOT."/boutique/promotion/index.php", $langs->trans("Promotion"));
$menu->add_submenu(DOL_URL_ROOT."/boutique/client/", $langs->trans("Customers"));
$menu->add_submenu(DOL_URL_ROOT."/boutique/commande/", $langs->trans("Orders"));

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Éric Seigne <erics@rycks.com>
* Copyright (C) 2003 Éric Seigne <erics@rycks.com>
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.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
@ -82,6 +83,10 @@ if ($resql)
}
$db->free();
}
else
{
dolibarr_print_error($db);
}
print "</TABLE>";

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.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
@ -22,7 +23,7 @@
/**
\file htdocs/boutique/critiques/fiche.php
\ingroup boutique
\brief Page gestion critiques OS Commerce
\brief Page gestion critiques OSCommerce
\version $Revision$
*/

View File

@ -32,7 +32,8 @@ require_once(DOL_DOCUMENT_ROOT."/boutique/critiques/critique.class.php");
function llxHeader($head = "", $urlp = "")
{
global $user, $conf;
global $user,$conf, $langs;
$langs->load("shop");
top_menu($head);

View File

@ -1,185 +0,0 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* 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.
*
* $Id$
* $Source$
*
*/
class Editeur {
var $db ;
var $id ;
var $nom;
function Editeur($DB, $id=0) {
$this->db = $DB;
$this->id = $id ;
}
/*
*
*
*
*/
function create($user) {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."editeur (fk_user_author) VALUES (".$user->id.")";
if ($this->db->query($sql) )
{
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."editeur");
if ( $this->update($id, $user) )
{
return $id;
}
}
}
/*
*
*
*/
function liste_array ()
{
$ga = array();
$sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."editeur ORDER BY nom";
if ($this->db->query($sql) )
{
$nump = $this->db->num_rows();
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$obj = $this->db->fetch_object();
$ga[$obj->rowid] = $obj->nom;
$i++;
}
}
return $ga;
}
else
{
print $this->db->error();
}
}
/*
*
*
*
*/
function update($id, $user)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."editeur ";
$sql .= " SET nom = '" . trim($this->nom) ."'";
$sql .= " WHERE rowid = " . $id;
if ( $this->db->query($sql) ) {
return 1;
} else {
print $this->db->error() . ' in ' . $sql;
}
}
/*
*
*
*
*/
function fetch ($id) {
$sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."editeur WHERE rowid = $id";
$result = $this->db->query($sql) ;
if ( $result )
{
$result = $this->db->fetch_array();
$this->id = $result["rowid"];
$this->nom = stripslashes($result["nom"]);
$this->db->free();
}
else
{
print $this->db->error();
}
return $result;
}
/*
*
*
*
*/
function liste_livre()
{
$ga = array();
$sql = "SELECT a.rowid, a.title FROM ".MAIN_DB_PREFIX."livre as a";
$sql .= " WHERE a.fk_editeur = ".$this->id;
$sql .= " ORDER BY a.title";
if ($this->db->query($sql) )
{
$nump = $this->db->num_rows();
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$obj = $this->db->fetch_object();
$ga[$obj->rowid] = $obj->title;
$i++;
}
}
return $ga;
}
else
{
print $this->db->error();
}
}
/*
*
*
*/
function delete() {
$livres = $this->liste_livre();
if (sizeof($livres) == 0)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."editeur WHERE rowid = $this->id ";
$return = $this->db->query($sql) ;
}
}
}
?>

View File

@ -1,181 +0,0 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.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.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
if ($action == 'add') {
$editeur = new Editeur($db);
$editeur->nom = $nom;
$id = $editeur->create($user);
}
if ($action == 'addga') {
$editeur = new Editeur($db);
$editeur->linkga($id, $ga);
}
if ($action == 'update' && !$cancel)
{
$editeur = new Editeur($db);
$editeur->nom = $nom;
$editeur->update($id, $user);
}
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == yes)
{
$editeur = new Editeur($db);
$result = $editeur->fetch($id);
$editeur->delete();
Header("Location: index.php");
}
llxHeader();
/*
*
*
*/
if ($action == 'create')
{
print "<form action=\"fiche.php?id=$id\" method=\"post\">\n";
print '<input type="hidden" name="action" value="add">';
print '<div class="titre">Nouvel Editeur</div><br>';
print '<table border="1" width="100%" cellspacing="0" cellpadding="4">';
print "<tr>";
print '<td width="20%">Nom</td><td><input name="nom" size="40" value=""></td></tr>';
print '<tr><td>&nbsp;</td><td><input type="submit" value="Créer"></td></tr>';
print '</table>';
print '</form>';
}
else
{
if ($id)
{
$editeur = new Editeur($db);
$result = $editeur->fetch($id);
if ( $result )
{
$livres = $editeur->liste_livre();
/*
* Confirmation de la suppression de l'editeur
*
*/
if ($action == 'delete')
{
$htmls = new Form($db);
$htmls->form_confirm("fiche.php?id=$id","Supprimer un éditeur","Etes-vous sur de vouloir supprimer cet éditeur ?","confirm_delete");
}
/*
* Edition de la fiche
*
*/
if ($action == 'edit')
{
print '<div class="titre">Edition de la fiche Editeur : '.$editeur->titre.'</div><br>';
print "<form action=\"fiche.php?id=$id\" method=\"post\">\n";
print '<input type="hidden" name="action" value="update">';
print '<table class="border" width="100%">';
print "<tr>";
print '<td width="20%">Nom</td><td width="80%"><input name="nom" size="40" value="'.$editeur->nom.'"></td>';
print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Save").'">&nbsp;<input type="submit" value="'.$langs->trans("Cancel").'" name="cancel"></td></tr>';
print '</form>';
print '</table><hr>';
}
print '<div class="titre">Fiche Editeur : '.$editeur->titre.'</div><br>';
print '<table class="border" width="100%">';
print "<tr>";
print '<td width="20%">Nom</td><td width="80%">'.$editeur->nom.'</td></tr>';
print '<tr><td>Livres</td><td>';
foreach ($livres as $key => $value)
{
print '<a href="../livre/fiche.php?id='.$key.'">'.$value."<br>\n";
}
print "</td></tr>";
print "</table>";
}
else
{
print "Fetch failed";
}
}
else
{
print "Error";
}
}
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
print '<div class="tabsAction">';
if ($action != 'create')
{
print '<a class="tabAction" href="fiche.php?action=edit&id='.$id.'">'.$langs->trans("Edit").'</a>';
}
if(sizeof($livres)==0 && $id)
{
print '<a class="tabAction" href="fiche.php?action=delete&id='.$id.'">'.$langs->trans("Delete").'</a>';
}
print '</div>';
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,74 +0,0 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.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.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
llxHeader();
if ($sortfield == "") {
$sortfield="lower(e.nom)";
}
if ($sortorder == "") {
$sortorder="ASC";
}
if ($page == -1) { $page = 0 ; }
$limit = $conf->liste_limit;
$offset = $limit * $page ;
print_barre_liste("Liste des Editeurs", $page, "index.php");
$sql = "SELECT e.rowid, e.nom FROM ".MAIN_DB_PREFIX."editeur as e";
$sql .= " ORDER BY $sortfield $sortorder ";
$sql .= $db->plimit( $limit ,$offset);
if ( $db->query($sql) ) {
$num = $db->num_rows();
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
print_liste_field_titre($langs->trans("Name"),"index.php", "e.nom");
print "</tr>\n";
$var=True;
while ($i < $num) {
$objp = $db->fetch_object();
$var=!$var;
print "<tr $bc[$var]>";
print "<td width='70%'><a href=\"fiche.php?id=$objp->rowid\">$objp->nom</a></td>\n";
print "</tr>\n";
$i++;
}
print "</TABLE>";
$db->free();
}
else
{
print $db->error();
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,59 +0,0 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* 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.
*
* $Id$
* $Source$
*
*/
require("../../main.inc.php");
require("../livre/livre.class.php");
require("./editeur.class.php");
function llxHeader($head = "", $urlp = "") {
global $user, $conf;
/*
*
*
*/
top_menu($head);
$menu = new Menu();
$menu->add(DOL_URL_ROOT."/boutique/livre/", "Livres");
$menu->add_submenu(DOL_URL_ROOT."/boutique/livre/fiche.php?&action=create","Nouvel ouvrage");
$menu->add(DOL_URL_ROOT."/boutique/auteur/", "Auteurs");
$menu->add_submenu(DOL_URL_ROOT."/boutique/auteur/fiche.php?&action=create","Nouvel auteur");
$menu->add(DOL_URL_ROOT."/boutique/editeur/", "Editeurs");
$menu->add_submenu(DOL_URL_ROOT."/boutique/editeur/fiche.php?&action=create","Nouvel éditeur");
$menu->add(DOL_URL_ROOT."/product/categorie/", "Catégories");
left_menu($menu->liste);
/*
*
*
*/
}
?>

View File

@ -1,428 +0,0 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.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.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
if ( $_POST["sendit"] )
{
global $local_file, $error_msg;
$upload_dir = OSC_CATALOG_DIRECTORY."/images/";
if (! is_dir($upload_dir))
{
umask(0);
mkdir($upload_dir, 0755);
}
if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name']))
{
print "Le fichier est valide, et a &eacute;t&eacute; t&eacute;l&eacute;charg&eacute; avec succ&egrave;s.\n";
//print_r($_FILES);
}
else
{
echo "Le fichier n'a pas été téléchargé";
// print_r($_FILES);
}
if ($id or $oscid)
{
$livre = new Livre($db);
if ($id)
{
$result = $livre->fetch($id, 0);
$livre->update_image($_FILES['userfile']['name']);
$livre->updateosc($user);
}
}
}
if ($action == 'add')
{
$livre = new Livre($db);
$livre->titre = $titre;
$livre->ref = $ref;
$livre->price = $price;
$livre->annee = $annee;
$livre->editeurid = $editeurid;
$livre->description = $desc;
$livre->frais_de_port = $_POST["fdp"];
$id = $livre->create($user);
}
if ($action == 'addga')
{
$livre = new Livre($db);
$livre->linkga($id, $coauteurid);
}
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes")
{
$livre = new Livre($db);
$livre->fetch($id);
$livre->delete();
Header("Location: index.php");
}
if ($action == 'linkcat')
{
$livre = new Livre($db);
$livre->fetch($id);
$livre->linkcategorie( $catid);
}
if ($action == 'delcat')
{
$livre = new Livre($db);
$livre->fetch($id);
$livre->unlinkcategorie($catid);
}
if ($action == 'delauteur' && $auteurid)
{
$livre = new Livre($db);
$livre->fetch($id);
$livre->auteur_unlink($auteurid);
}
if ($action == "status")
{
$livre = new Livre($db);
$livre->fetch($id);
if ($livre->update_status($status))
{
}
}
if ($action == 'update' && !$cancel)
{
$livre = new Livre($db);
$livre->titre = $titre;
$livre->ref = $ref;
$livre->price = $price;
$livre->frais_de_port = $_POST["fdp"];
$livre->annee = $annee;
$livre->editeurid = $editeurid;
$livre->description = $desc;
if ($livre->update($id, $user))
{
$result = $livre->fetch($id);
$livre->updateosc($user);
}
else
{
$action = 'edit';
}
}
if ($action == 'updateosc')
{
$livre = new Livre($db);
$result = $livre->fetch($id);
$livre->updateosc($user);
}
/*
*
*
*/
llxHeader();
if ($action == 'create')
{
print "<form action=\"fiche.php?id=$id\" method=\"post\">\n";
print "<input type=\"hidden\" name=\"action\" value=\"add\">";
print '<div class="titre">Nouvel ouvrage</div><br>';
print '<table border="1" width="100%" cellspacing="0" cellpadding="4">';
print "<tr>";
print '<td>Référence</td><td><input name="ref" size="20" value=""></td></tr>';
print '<td>Titre</td><td><input name="titre" size="40" value=""></td></tr>';
print '<tr><td>'.$langs->trans("Price").'</td><TD><input name="price" size="10" value=""></td></tr>';
print '<tr><td>Frais de port</td><td><select name="fdp">';
print '<option value="1" selected="true">oui</option>';
print '<option value="0">non</option></td></tr>';
$htmls = new Form($db);
$edits = new Editeur($db);
print "<tr><td>Editeur</td><td>";
$htmls->select_array("editeurid", $edits->liste_array(), $livre->editeurid);
print "</td></tr>";
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
print '<textarea name="desc" rows="8" cols="50">';
print "</textarea></td></tr>";
print '<tr><td>&nbsp;</td><td><input type="submit" value="Créer"></td></tr>';
print '</table>';
print '</form>';
}
else
{
if ($id or $oscid)
{
$livre = new Livre($db);
if ($id)
{
$result = $livre->fetch($id, 0);
}
if ($oscid)
{
$result = $livre->fetch(0, $oscid);
$id = $livre->id;
}
if ( $result )
{
$htmls = new Form($db);
$auteurs = $livre->liste_auteur();
/*
* Confirmation de la suppression de l'adhérent
*
*/
if ($action == 'delete')
{
$htmls = new Form($db);
$htmls->form_confirm("fiche.php?id=$id","Supprimer un ouvrage","Etes-vous sur de vouloir supprimer cet ouvrage ?","confirm_delete");
}
if ($action == 'edit')
{
print '<div class="titre">Edition de la fiche Livre : '.$livre->titre.'</div><br>';
print "<form action=\"fiche.php?id=$id\" method=\"post\">\n";
print "<input type=\"hidden\" name=\"action\" value=\"update\">";
print '<table class="border" width="100%">';
print "<tr>";
print '<td width="20%">'.$langs->trans("Ref").'</td><td><input name="ref" size="20" value="'.$livre->ref.'"></td>';
print '<td valign="top">'.$langs->trans("Description").'</td></tr>';
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$livre->status_text;
if ($livre->status == 0)
{
print '<br><a href="fiche.php?id='.$id.'&status=1&action=status">Changer</a>';
}
else
{
print '<br><a href="fiche.php?id='.$id.'&status=0&action=status">Changer</a>';
}
print "</td>\n";
print '<td valign="top" width="50%" rowspan="7"><textarea name="desc" rows="14" cols="60">';
print $livre->description;
print "</textarea></td></tr>";
print '<tr><td>Titre</td><td><input name="titre" size="40" value="'.$livre->titre.'"></td></tr>';
print '<tr><td>Année</td><TD><input name="annee" size="6" maxlenght="4" value="'.$livre->annee.'"></td></tr>';
print '<tr><td>'.$langs->trans("Price").'</td><TD><input name="price" size="10" value="'.price($livre->price).'"></td></tr>';
print '<tr><td>Frais de port</td><td><select name="fdp">';
if ($livre->frais_de_port)
{
print '<option value="1" selected="true">oui</option>';
print '<option value="0">non</option>';
}
else
{
print '<option value="1">oui</option>';
print '<option value="0" selected="true">non</option>';
}
print '</select></td></tr>';
$htmls = new Form($db);
$edits = new Editeur($db);
print "<tr><td>Editeur</td><td>";
$htmls->select_array("editeurid", $edits->liste_array(), $livre->editeurid);
print "</td></tr>";
print '<tr><td>Auteur(s)</td><td>';
foreach ($auteurs as $key => $value)
{
print '<a href="fiche.php?id='.$id.'&action=delauteur&auteurid='.$key.'">';
print '<img src="/theme/'.$conf->theme.'/img/editdelete.png" height="16" width="16" alt="Supprimer" border="0"></a>&nbsp;';
print '<a href="../auteur/fiche.php?id='.$key.'">'.$value."<br>\n";
}
print "</td></tr>";
print '<tr><td align="center" colspan="3"><input type="submit" value="'.$langs->trans("Save").'">&nbsp;<input type="submit" value="'.$langs->trans("Cancel").'" name="cancel"></td></tr>';
print "</form>";
print '</form>';
$auteur = new Auteur($db);
print "<form action=\"fiche.php?id=$id\" method=\"post\">\n";
print "<input type=\"hidden\" name=\"action\" value=\"addga\">";
print '<tr><td>Auteur(s)</td><td colspan="2">';
$htmls->select_array("coauteurid", $auteur->liste_array());
print '&nbsp;<input type="submit" value="'.$langs->trans("Add").'"></td></tr>';
print "</form>";
print "<form action=\"fiche.php?id=$id\" method=\"post\">\n";
print '<input type="hidden" name="action" value="linkcat">';
$listecat = new Categorie($db);
print '<td valign="top">Catégories</td><td colspan="2">';
$htmls->select_array("catid", $listecat->liste_array());
print '&nbsp;<input type="submit" value="'.$langs->trans("Add").'"></td></tr>';
print "</form>";
print "</td></tr>\n";
print '<td valign="top">Vignette</td><td colspan="2">';
echo '<FORM NAME="userfile" ACTION="fiche.php?id='.$id.'" ENCTYPE="multipart/form-data" METHOD="POST">';
print '<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.'">';
print '<input type="file" name="userfile" size="80"><br>';
print '<input type="submit" value="Upload File!" name="sendit">';
print '<input type="submit" value="'.$langs->trans("Cancel").'" name="cancelit"><BR>';
print '</form>';
print "</td></tr>\n";
print '</table><hr>';
}
/*
* Affichage
*/
print '<div class="titre">Fiche Livre : '.$livre->titre.'</div><br>';
print '<table class="border" width="100%">';
print "<tr>";
print '<td width="15%">'.$langs->trans("Ref").'</td><td width="20%">'.$livre->ref.'</td>';
print '<td width="50%" valign="top">'.$langs->trans("Description").'</td>';
print '<td valign="top">Catégories</td></tr>';
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$livre->status_text;
if ($livre->status == 0)
{
print '<br><a href="fiche.php?id='.$id.'&status=1&action=status">Changer</a>';
}
else
{
print '<br><a href="fiche.php?id='.$id.'&status=0&action=status">Changer</a>';
}
print "</td>\n";
print '<td rowspan="7" valign="top">'.nl2br($livre->description);
$img = OSC_CATALOG_DIRECTORY."images/".$livre->image;
if(file_exists($img))
{
print '<p><img src="'.OSC_CATALOG_URL.'/images/'.$livre->image.'">';
}
print "</td>";
print '<td rowspan="7" valign="top">';
$livre->listcategorie();
print "</td></tr>";
print "<tr><td>Titre</td><td>$livre->titre</td></tr>\n";
print "<tr><td>Annee</td><td>$livre->annee</td></tr>\n";
print '<tr><td>Editeur</td><TD>';
if ($livre->editeurid)
{
$editeur = new Editeur($db);
$editeur->fetch($livre->editeurid);
print $editeur->nom;
}
print '</td></tr>';
print '<tr><td>Auteur(s)</td><td>';
foreach ($auteurs as $key => $value)
{
print '<a href="../auteur/fiche.php?id='.$key.'">';
print $value."</a><br>\n";
}
print "</td></tr>";
print '<tr><td>'.$langs->trans("Price").'</td><TD>'.price($livre->price).'</td></tr>';
print '<tr><td>Frais de port</td><td>';
if ($livre->frais_de_port)
{
print 'oui</td></tr>';
}
else
{
print 'non</td></tr>';
}
print "</table>";
}
else
{
print "Fetch failed";
}
}
else
{
print "Error";
}
}
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
print '<div class="tabsAction">';
if ($action != 'create')
{
print '<a class="tabAction" href="fiche.php?action=edit&id='.$id.'">'.$langs->trans("Edit").'</a>';
}
print '<a class="tabAction" href="fiche.php?action=delete&id='.$id.'">'.$langs->trans("Delete").'</a>';
print '</div>';
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,109 +0,0 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.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.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
llxHeader();
if ($sortfield == "")
{
$sortfield="lower(l.title)";
}
if ($sortorder == "")
{
$sortorder="ASC";
}
if ($page == -1) { $page = 0 ; }
$limit = $conf->liste_limit;
$offset = $limit * $page ;
$form = '<form action="index.php">'.
'<input type="hidden" name="mode" value="search">'.
'<input type="hidden" name="mode-search" value="soc">'.
'Titre : <input type="text" name="searchvalue" class="flat" size="15">&nbsp;'.
'<input type="submit" class="flat" value="go"></form>';
print_barre_liste("Liste des Livres", $page, "index.php", "", $sortfield, $sortorder, $form);
$sql = "SELECT l.rowid, l.title, l.oscid, l.ref, l.status FROM ".MAIN_DB_PREFIX."livre as l";
if ($searchvalue)
{
$sql .= " WHERE l.title like '%$searchvalue%'";
}
$sql .= " ORDER BY $sortfield $sortorder ";
$sql .= $db->plimit( $limit ,$offset);
if ( $db->query($sql) )
{
$num = $db->num_rows();
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
print_liste_field_titre($langs->trans("Ref"),"index.php", "l.ref");
print_liste_field_titre($langs->trans("Title"),"index.php", "l.title");
print '<td colspan="3">&nbsp;</td>';
print "</tr>\n";
$var=True;
while ($i < $num) {
$objp = $db->fetch_object();
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="fiche.php?id='.$objp->rowid.'"><img src="/theme/'.$conf->theme.'/img/filenew.png" border="0" alt="Fiche livre"></a>&nbsp;';
print "<a href=\"fiche.php?id=$objp->rowid\">$objp->ref</a></TD>\n";
print "<TD width='70%'><a href=\"fiche.php?id=$objp->rowid\">$objp->title</a></TD>\n";
if ($objp->status == 1)
{
print '<td align="center"><img src="/theme/'.$conf->theme.'/img/icon_status_green.png" border="0"></a></td>';
print '<td align="center"><img src="/theme/'.$conf->theme.'/img/icon_status_red_light.png" border="0"></a></td>';
print '<td align="right"><a href="'.OSC_CATALOG_URL.'product_info.php?products_id='.$objp->oscid.'">Fiche en ligne</a></TD>';
}
else
{
print '<td align="center"><img src="/theme/'.$conf->theme.'/img/icon_status_green_light.png" border="0"></a></td>';
print '<td align="center"><img src="/theme/'.$conf->theme.'/img/icon_status_red.png" border="0"></a></td>';
print '<td>&nbsp;</td>';
}
print "</tr>\n";
$i++;
}
print "</table>";
$db->free();
}
else
{
dolibarr_print_error($db);
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,570 +0,0 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Éric Seigne <erics@rycks.com>
*
* 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.
*
* $Id$
* $Source$
*
*/
class Livre {
var $db ;
var $id ;
var $oscid ;
var $ref;
var $price;
var $annee;
var $editeurid;
var $titre;
var $image;
var $description;
var $price ;
var $status ;
function Livre($DB, $id=0) {
$this->db = $DB;
$this->id = $id ;
}
/*
*
*
*
*/
function create($user) {
if (strlen($this->annee))
{
$this->annee = 0;
}
$sql = "INSERT INTO ".OSC_DB_NAME.".products (products_quantity, products_model, products_image, products_price, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id, products_date_added) ";
$sql .= "VALUES ('', '', 'Array', '', null, '', '0', '0', '8', now())";
if ($this->db->query($sql) )
{
$idosc = $this->db->last_insert_id(OSC_DB_NAME.".products");
$sql = "INSERT INTO ".OSC_DB_NAME.".products_to_categories (products_id, categories_id) VALUES ($idosc, 0)";
if ($this->db->query($sql) )
{
$sql = "INSERT INTO ".OSC_DB_NAME.".products_description (products_name, products_description, products_url, products_id, language_id) VALUES ('".trim($this->titre)."', '".trim($this->description)."', '', $idosc, '".OSC_LANGUAGE_ID."')";
if ($this->db->query($sql) )
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."livre (oscid, fk_user_author, date_ajout) VALUES ($idosc, ".$user->id.", now())";
if ($this->db->query($sql) )
{
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."livre");
if ( $this->update($id, $user) )
{
return $id;
}
}
else
{
print $this->db->error() . ' in ' . $sql;
}
}
else
{
print $this->db->error() . ' in ' . $sql;
}
}
else
{
print $this->db->error() . ' in ' . $sql;
}
}
else
{
print $this->db->error() . ' in ' . $sql;
}
}
/*
*
*
*
*/
function linkga($id, $gaid)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."livre_to_auteur (fk_livre, fk_auteur) VALUES ($id, $gaid)";
if ( $this->db->query($sql) )
{
return 1;
}
else
{
print $this->db->error() . ' in ' . $sql;
}
}
/*
*
*
*/
function liste_auteur()
{
$ga = array();
$sql = "SELECT a.rowid, a.nom FROM ".MAIN_DB_PREFIX."auteur as a, ".MAIN_DB_PREFIX."livre_to_auteur as l";
$sql .= " WHERE a.rowid = l.fk_auteur AND l.fk_livre = ".$this->id;
$sql .= " ORDER BY a.nom";
if ($this->db->query($sql) )
{
$nump = $this->db->num_rows();
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$obj = $this->db->fetch_object();
$ga[$obj->rowid] = $obj->nom;
$i++;
}
}
return $ga;
}
else
{
print $this->db->error();
}
}
/*
*
*
*/
function auteur_unlink($auteur_id)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."livre_to_auteur ";
$sql .= " WHERE fk_livre=".$this->id;
$sql .= " AND fk_auteur=".$auteur_id;
if ( $this->db->query($sql) )
{
return 1;
}
else
{
print $this->db->error() . ' in ' . $sql;
}
}
/*
*
*
*/
function unlinkcategorie($categories_id)
{
$sql = "DELETE FROM ".OSC_DB_NAME.".products_to_categories ";
$sql .= " WHERE products_id=".$this->oscid;
$sql .= " AND categories_id=".$categories_id;
if ( $this->db->query($sql) )
{
return 1;
}
else
{
print $this->db->error() . ' in ' . $sql;
}
}
/*
*
*
*/
function linkcategorie($categories_id)
{
$sql = "INSERT INTO ".OSC_DB_NAME.".products_to_categories ";
$sql .= " (products_id, categories_id)";
$sql .= " VALUES (".$this->oscid.",".$categories_id.")";
if ( $this->db->query($sql) )
{
return 1;
}
else
{
print $this->db->error() . ' in ' . $sql;
}
}
/*
*
*
*/
function listcategorie()
{
global $conf;
$listecat = new Categorie($this->db);
$cats = $listecat->liste_array();
$pcat = array();
$sql = "SELECT products_id, categories_id";
$sql .= " FROM ".OSC_DB_NAME.".products_to_categories ";
$sql .= " WHERE products_id = " . $this->oscid;
if ($this->db->query($sql) )
{
$nump = $this->db->num_rows();
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$obj = $this->db->fetch_object();
$pcat[$i] = $obj->categories_id;
$i++;
}
}
}
foreach ($cats as $key => $value)
{
$test = 0;
for ($i = 0 ; $i < $nump ; $i++)
{
if ($pcat[$i] == $key)
{
$test = 1;
}
}
if ($test)
{
print '<a href="'.DOL_URL_ROOT.'/boutique/livre/fiche.php?id='.$this->id.'&action=delcat&catid='.$key.'">';
print '<img src="/theme/'.$conf->theme.'/img/editdelete.png" height="16" width="16" alt="Supprimer" border="0">';
print "</a><b>$value</b><br>";
}
else
{
print '<img src="/theme/'.$conf->theme.'/img/transparent.png" height="16" width="16" alt="Supprimer" border="0">';
print "$value<br>";
}
}
}
/*
*
*
*/
function update_status($status)
{
$sql = "UPDATE ".OSC_DB_NAME.".products ";
$sql .= " SET products_status = ".$status;
$sql .= " WHERE products_id = " . $this->oscid;
if ( $this->db->query($sql) )
{
$sql = "UPDATE ".MAIN_DB_PREFIX."livre ";
$sql .= " SET status = ".$status;
$sql .= " WHERE rowid = " . $this->id;
if ( $this->db->query($sql) )
{
return 1;
}
}
else
{
print $this->db->error() . ' in ' . $sql;
}
}
/*
*
*
*
*/
function updateosc($noupdate_other=0)
{
$desc = trim(addslashes($this->description));
$desc .= "<p>";
$auteurs = array();
$auteurs = $this->liste_auteur();
if (sizeof($auteurs)>0)
{
$desc .= 'Auteur(s) : <ul>';
reset($auteurs);
foreach ($auteurs as $key => $value)
{
$auteursid = $key;
$auteur = new Auteur($this->db);
$result = $auteur->fetch($auteursid);
if ( $result )
{
$livraut = array();
$livraut = $auteur->liste_livre('oscid', 1);
$desc .= '<li>'.addslashes($auteur->nom);
if (sizeof($livraut) > 1)
{
$desc .= " : ";
foreach ($livraut as $lakey => $lavalue)
{
if ($lakey <> $this->oscid)
{
if (!$noupdate_other)
{
$lix = new Livre($this->db);
$lix->fetch(0, $lakey);
$lix->updateosc(1);
}
$desc .= '<a href="product_info.php?products_id='.$lakey.'">'.addslashes($lavalue) . "</a> ";
}
}
}
$desc .= "</li>";
}
}
$desc .= "</ul>";
}
else
{
}
$desc .= '<br>Année de parution : '.$this->annee;
$editeur = new Editeur($this->db);
$result = $editeur->fetch($this->editeurid);
if (result)
{
$desc .= '<br>Editeur : ' . addslashes($editeur->nom);
}
$sql = "UPDATE ".OSC_DB_NAME.".products_description ";
$sql .= " SET products_name = '".addslashes($this->titre)."'";
$sql .= ", products_description = '$desc'";
$sql .= " WHERE products_id = " . $this->oscid;
$this->image = $this->ref.".jpg";
if(! file_exists(OSC_CATALOG_DIRECTORY."images/".$this->ref.".jpg"))
{
$this->image = OSC_IMAGE_DEFAULT;
}
if ( $this->db->query($sql) )
{
$sql = "UPDATE ".OSC_DB_NAME.".products ";
$sql .= "SET products_model = '".$this->ref."'";
$sql .= ", products_image = '".$this->image."'";
$sql .= ", products_price = ".price2num($this->price)."";
if ($this->frais_de_port)
{
$sql .= ", products_weight = ".price2num($this->price)."";
}
else
{
$sql .= ", products_weight = -1";
}
$sql .= " WHERE products_id = " . $this->oscid;
if ( $this->db->query($sql) )
{
return 1;
}
else
{
print $this->db->error() . ' in <br />' . $sql;
}
}
else
{
print $this->db->error() . ' in ' . $sql;
}
}
/*
*
*
*/
/*
*
*
*/
function update($id, $user)
{
if (strlen($this->annee)==0)
{
$this->annee = 0;
}
$sql = "UPDATE ".MAIN_DB_PREFIX."livre ";
$sql .= " SET title = '" . trim($this->titre) ."'";
$sql .= ", ref = '" . trim($this->ref) ."'";
$sql .= ", prix = " . price2num($this->price)."";
$sql .= ", annee = " . $this->annee ;
$sql .= ", fk_editeur = " . $this->editeurid ;
$sql .= ", description = '" . trim($this->description) ."'";
$sql .= ", frais_de_port = " . $this->frais_de_port ."";
$sql .= " WHERE rowid = " . $id;
if ( $this->db->query($sql) )
{
return 1;
}
else
{
print $this->db->error() . ' in ' . $sql;
}
}
/*
*
*
*
*/
function fetch ($id, $oscid=0) {
$sql = "SELECT rowid, fk_editeur, ref, prix, annee, oscid, title, description, frais_de_port FROM ".MAIN_DB_PREFIX."livre";
if ($id)
{
$sql .= " WHERE rowid = $id";
}
if ($oscid)
{
$sql .= " WHERE oscid = $oscid";
}
$result = $this->db->query($sql) ;
if ( $result )
{
$result = $this->db->fetch_array();
$this->id = $result["rowid"];
$this->ref = $result["ref"];
$this->price = $result["prix"];
$this->frais_de_port = $result["frais_de_port"];
$this->annee = $result["annee"];
$this->editeurid = $result["fk_editeur"];
$this->titre = stripslashes($result["title"]);
$this->description = stripslashes($result["description"]);
$this->oscid = $result["oscid"];
$this->db->free();
$sql = "SELECT products_quantity, products_model, products_image, products_price, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id, products_date_added";
$sql .= " FROM ".OSC_DB_NAME.".products WHERE products_id = " . $this->oscid;
$result = $this->db->query($sql) ;
if ( $result )
{
$result = $this->db->fetch_array();
$this->status = $result["products_status"];
$this->image = $result["products_image"];
if ($this->status)
{
$this->status_text = "En vente";
}
else
{
$this->status_text = "Cet article n'est pas en vente";
}
$this->db->free();
}
else
{
print $this->db->error();
}
}
else
{
print $this->db->error();
}
return $result;
}
/*
*
*
*/
function update_image($file_name)
{
$sql = "UPDATE ".OSC_DB_NAME.".products SET products_image='".$file_name."'";
$sql .= " WHERE products_id = " . $this->oscid;
$result = $this->db->query($sql) ;
if ( $result )
{
}
}
/*
*
*
*/
function delete()
{
$sql = "DELETE FROM ".OSC_DB_NAME.".products WHERE products_id = ".$this->oscid;
$result = $this->db->query($sql) ;
$sql = "DELETE FROM ".OSC_DB_NAME.".products_to_categories WHERE products_id = ".$this->oscid;
$result = $this->db->query($sql) ;
$sql = "DELETE FROM ".OSC_DB_NAME.".products_description WHERE products_id = ".$this->oscid;
$result = $this->db->query($sql) ;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."livre WHERE rowid = ".$this->id;
$result = $this->db->query($sql) ;
}
}
?>

View File

@ -1,71 +0,0 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.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.
*
* $Id$
* $Source$
*/
/**
\file htdocs/boutique/livre/pre.inc.php
\brief Fichier gestionnaire du menu de gauche
\version $Revision$
*/
require("../../main.inc.php");
require("./livre.class.php");
require("../editeur/editeur.class.php");
require("../auteur/auteur.class.php");
function llxHeader($head = "", $urlp = "")
{
global $user, $conf;
/*
*
*
*/
top_menu($head);
$menu = new Menu();
$menu->add(DOL_URL_ROOT."/boutique/livre/", "Livres");
$menu->add_submenu(DOL_URL_ROOT."/boutique/livre/fiche.php?&action=create","Nouvel ouvrage");
$menu->add_submenu(DOL_URL_ROOT."/boutique/livre/vignettes.php","Vignettes manquantes");
$menu->add(DOL_URL_ROOT."/boutique/auteur/", "Auteurs");
$menu->add_submenu(DOL_URL_ROOT."/boutique/auteur/fiche.php?&action=create","Nouvel auteur");
$menu->add(DOL_URL_ROOT."/boutique/editeur/", "Editeurs");
$menu->add_submenu(DOL_URL_ROOT."/boutique/editeur/fiche.php?&action=create","Nouvel éditeur");
$menu->add(DOL_URL_ROOT."/product/categorie/", "Catégories");
$menu->add(DOL_URL_ROOT."/product/promotion/", "Promotions");
if (defined("MAIN_MODULE_POSTNUKE") && MAIN_MODULE_POSTNUKE)
{
$menu->add(DOL_URL_ROOT."/postnuke/articles/", "Editorial");
}
left_menu($menu->liste);
}
?>

View File

@ -1,114 +0,0 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.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.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
llxHeader();
if ($sortfield == "")
{
$sortfield="lower(l.ref)";
}
if ($sortorder == "")
{
$sortorder="ASC";
}
if ($page == -1) { $page = 0 ; }
$limit = $conf->liste_limit;
$offset = $limit * $page ;
$form = '<form action="index.php">'.
'<input type="hidden" name="mode" value="search">'.
'<input type="hidden" name="mode-search" value="soc">'.
'Titre : <input type="text" name="searchvalue" class="flat" size="15">&nbsp;'.
'<input type="submit" class="flat" value="go"></form>';
print_barre_liste("Liste des vignettes manquantes", $page, "vignettes.php", "", $sortfield, $sortorder, $form);
$sql = "SELECT l.rowid, l.title, l.oscid, l.ref, l.status FROM ".MAIN_DB_PREFIX."livre as l";
if ($searchvalue)
{
$sql .= " WHERE l.title like '%$searchvalue%'";
}
$sql .= " ORDER BY $sortfield $sortorder ";
//$sql .= $db->plimit( $limit ,$offset);
if ( $db->query($sql) )
{
$num = $db->num_rows();
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
print_liste_field_titre($langs->trans("Ref"),"vignettes.php", "l.ref");
print_liste_field_titre($langs->trans("Title"),"vignettes.php", "l.title");
print '<td colspan="3">&nbsp;</td>';
print "</tr>\n";
$var=True;
while ($i < $num) {
$objp = $db->fetch_object();
if(! file_exists(OSC_CATALOG_DIRECTORY."images/".$objp->ref.".jpg"))
{
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="fiche.php?id='.$objp->rowid.'"><img src="/theme/'.$conf->theme.'/img/filenew.png" border="0" alt="Fiche livre"></a>&nbsp;';
print "<a href=\"fiche.php?id=$objp->rowid\">$objp->ref</a></TD>\n";
print "<td width='70%'><a href=\"fiche.php?id=$objp->rowid\">$objp->title</a></TD>\n";
if ($objp->status == 1)
{
print '<td align="center"><img src="/theme/'.$conf->theme.'/img/icon_status_green.png" border="0"></a></td>';
print '<td align="center"><img src="/theme/'.$conf->theme.'/img/icon_status_red_light.png" border="0"></a></td>';
print '<td align="right"><a href="'.OSC_CATALOG_URL.'product_info.php?products_id='.$objp->oscid.'">Fiche en ligne</a></TD>';
}
else
{
print '<td align="center"><img src="/theme/'.$conf->theme.'/img/icon_status_green_light.png" border="0"></a></td>';
print '<td align="center"><img src="/theme/'.$conf->theme.'/img/icon_status_red.png" border="0"></a></td>';
print '<td>&nbsp;</td>';
}
print "</tr>\n";
}
$i++;
}
print "</table>";
$db->free();
}
else
{
dolibarr_print_error($db);
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,275 +0,0 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.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.
*
* $Id$
* $Source$
*
*/
/*! \file htdocs/boutique/newsletter/fiche.php
\ingroup boutique
\brief Fiche newsletter
\version $Revision$
*/
require("./pre.inc.php");
if ($_POST["action"] == 'add') {
$newsletter = new Newsletter($db);
$newsletter->email_subject = $_POST["email_subject"];
$newsletter->email_from_name = $_POST["email_from_name"];
$newsletter->email_from_email = $_POST["email_from_email"];
$newsletter->email_replyto = $_POST["email_replyto"];
$newsletter->email_body = $_POST["email_body"];
$id = $newsletter->create($user);
}
if ($_POST["action"] == 'addga') {
$newsletter = new Newsletter($db);
$newsletter->linkga($id, $ga);
}
if ($_POST["action"] == 'update' && !$cancel)
{
$newsletter = new Newsletter($db);
$newsletter->email_subject = $_POST["email_subject"];
$newsletter->email_from_name = $_POST["email_from_name"];
$newsletter->email_from_email = $_POST["email_from_email"];
$newsletter->email_replyto = $_POST["email_replyto"];
$newsletter->email_body = $_POST["email_body"];
$newsletter->update($id, $user);
}
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == yes)
{
$newsletter = new Newsletter($db);
$result = $newsletter->fetch($id);
$newsletter->delete();
Header("Location: index.php");
}
if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == yes)
{
$newsletter = new Newsletter($db);
$result = $newsletter->fetch($id);
$newsletter->validate($user);
}
if ($_POST["action"] == 'confirm_send' && $_POST["confirm"] == yes)
{
$newsletter = new Newsletter($db);
$result = $newsletter->fetch($id);
$newsletter->send($user);
}
llxHeader();
/*
*
*
*/
if ($action == 'create')
{
print "<form action=\"fiche.php?id=$id\" method=\"post\">\n";
print '<input type="hidden" name="action" value="add">';
print '<div class="titre">Nouvelle Newsletter</div><br>';
print '<table border="1" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="20%">Emetteur nom</td><td><input name="email_from_name" size="30" value=""></td></tr>';
print '<tr><td width="20%">Emetteur email</td><td><input name="email_from_email" size="40" value=""></td></tr>';
print '<tr><td width="20%">Email de réponse</td><td><input name="email_replyto" size="40" value=""> (facultatif)</td></tr>';
print '<tr><td width="20%">Sujet</td><td width="80%"><input name="email_subject" size="30" value=""></td></tr>';
print '<tr><td width="20%">Cible</td><td><input name="nom" size="40" value=""></td></tr>';
print '<tr><td width="20%" valign="top">Texte</td><td width="80%"><textarea name="email_body" rows="10" cols="60"></textarea></td></tr>';
print '<tr><td colspan="2" align="center"><input type="submit" value="Créer"></td></tr>';
print '</table>';
print '</form>';
}
else
{
if ($id)
{
$newsletter = new Newsletter($db);
$result = $newsletter->fetch($id);
if ( $result )
{
/*
* Confirmation de la suppression de la newsletter
*
*/
if ($action == 'delete')
{
$htmls = new Form($db);
$htmls->form_confirm("fiche.php?id=$id","Supprimer une newsletter","Etes-vous sur de vouloir supprimer cet newsletter ?","confirm_delete");
}
/*
* Confirmation de la validation
*
*/
if ($action == 'valid')
{
$htmls = new Form($db);
$htmls->form_confirm('fiche.php?id='.$id,"Valider une newsletter","Etes-vous sûr de vouloir valider cette newsletter ?");
}
/*
*
*
*/
if ($action == 'send')
{
print '<form method="post" action="fiche.php?id='.$id.'">';
print '<input type="hidden" name="action" value="confirm_send">';
print '<table class="border" width="100%">';
print '<tr><td colspan="3">Envoi de newsletter</td></tr>';
print '<tr><td class="delete">Etes-vous sur de vouloir envoyer cette newsletter ?</td><td class="delete">';
$htmls = new Form($db);
$htmls->selectyesno("confirm","no");
print "</td>\n";
print '<td class="delete" align="center"><input type="submit" value="Confirmer"</td></tr>';
print '</table>';
print "</form>\n";
}
/*
* Edition de la fiche
*
*/
if ($action == 'edit')
{
print '<div class="titre">Edition de la fiche Newsletter : '.$newsletter->titre.'</div><br>';
print "<form action=\"fiche.php?id=$id\" method=\"post\">\n";
print '<input type="hidden" name="action" value="update">';
print '<table class="border">';
print '<tr><td>Emetteur nom</td><td><input name="email_from_name" size="30" value="'.$newsletter->email_from_name.'"></td></tr>';
print '<tr><td>Emetteur email</td><td><input name="email_from_email" size="40" value="'.$newsletter->email_from_email.'"></td></tr>';
print '<tr><td>Email de réponse</td><td><input name="email_replyto" size="40" value="'.$newsletter->email_replyto.'"></td></tr>';
print "<tr>";
print '<td width="20%">Sujet</td>';
print '<td><input name="email_subject" size="40" value="'.$newsletter->email_subject.'"></td>';
print '<tr><td width="20%" valign="top">Texte</td><td width="80%"><textarea name="email_body" rows="10" cols="60">'.$newsletter->email_body.'</textarea></td></tr>';
print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Save").'">&nbsp;<input type="submit" value="'.$langs->trans("Cancel").'" name="cancel"></td></tr>';
print '</form>';
print '</table><hr>';
}
/*
* Affichage de la fiche
*
*/
print '<div class="titre">Fiche Newsletter : '.$newsletter->titre.'</div><br>';
print '<table class="border" width="100%">';
print '<tr><td width="20%">Emetteur nom</td><td>'.$newsletter->email_from_name.'</td></tr>';
print '<tr><td width="20%">Emetteur email</td><td>'.$newsletter->email_from_email.'</td></tr>';
print '<tr><td width="20%">Email de réponse</td><td>'.$newsletter->email_replyto.'</td></tr>';
print '<tr><td width="20%">Nom</td><td width="80%">'.$newsletter->email_subject.'</td></tr>';
print '<tr><td width="20%" valign="top">Texte</td><td width="80%">'.nl2br($newsletter->email_body).'</td></tr>';
print "</table>";
if ($newsletter->status == 3)
{
print "<br />";
print '<table class="border" width="100%">';
print '<tr><td width="20%">Début de l\'envoi</td><td width="30%">'.strftime("%d %B %Y %H:%M:%S",$newsletter->date_send_begin).'</td>';
print '<td width="20%">Nombre de mails envoyés</td><td width="30%">'.$newsletter->nbsent.'</td></tr>';
print '<tr><td width="20%">Fin de l\'envoi</td><td width="30%">'.strftime("%d %B %Y %H:%M:%S",$newsletter->date_send_end).'</td>';
print '<td width="20%">Nombre de mails en erreur</td><td width="30%">'.$newsletter->nberror.'</td></tr>';
print "</table>";
}
}
else
{
print "Fetch failed";
}
}
else
{
print "Error";
}
}
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
print '<div class="tabsAction">';
if ($newsletter->status == 0)
{
print '<a class="tabAction" href="fiche.php?action=edit&id='.$id.'">'.$langs->trans("Edit").'</a>';
}
if ($newsletter->status == 0 && $id)
{
print '<a class="tabAction" href="fiche.php?action=valid&id='.$id.'">'.$langs->trans("Valid").'</a>';
}
if ($newsletter->status == 1)
{
print '<a class="tabAction" href="fiche.php?action=send&id='.$id.'">'.$langs->trans("Send").'</a>';
}
if($id && $newsletter->status == 0)
{
print '<a class="tabAction" href="fiche.php?action=delete&id='.$id.'">'.$langs->trans("Delete").'</a>';
}
print '</div>';
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,83 +0,0 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.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.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
llxHeader();
if ($sortfield == "") {
$sortfield="datec";
}
if ($sortorder == "") {
$sortorder="DESC";
}
if ($page == -1) { $page = 0 ; }
$limit = $conf->liste_limit;
$offset = $limit * $page ;
print_barre_liste("Liste des Newsletter", $page, "index.php");
$sql = "SELECT rowid, email_subject, email_from_name, email_from_email, email_replyto, email_body, target, sql_target, status, date_send_request, date_send_begin, date_send_end, nbsent";
$sql .= " FROM ".MAIN_DB_PREFIX."newsletter";
$sql .= " ORDER BY $sortfield $sortorder ";
$sql .= $db->plimit( $limit ,$offset);
if ( $db->query($sql) )
{
$num = $db->num_rows();
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
print_liste_field_titre($langs->trans("Subject"),"index.php", "email_subject");
print '<td align="center">'.$langs->trans("Status").'</td>';
print '<td align="center">Nb envois</td>';
print "</tr>\n";
$var=True;
while ($i < $num)
{
$objp = $db->fetch_object();
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="fiche.php?id='.$objp->rowid.'"><img src="/theme/'.$conf->theme.'/img/filenew.png" border="0" alt="Fiche"></a>&nbsp;';
print "<a href=\"fiche.php?id=$objp->rowid\">$objp->email_subject</a></td>\n";
print '<td align="center">'.$objp->status.'</td>';
print '<td align="center">'.$objp->nbsent.'</td>';
print "</tr>\n";
$i++;
}
print "</table>";
$db->free();
}
else
{
dolibarr_print_error($db);
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,217 +0,0 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* 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.
*
* $Id$
* $Source$
*
*/
class Newsletter {
var $db ;
var $id ;
var $email_from_name;
var $email_from_email;
var $email_replyto;
var $email_body;
var $status;
function Newsletter($DB, $id=0) {
$this->db = $DB;
$this->id = $id ;
$statustext[0] = "Rédaction";
$statustext[1] = "Validé";
$statustext[2] = "Envoi en cours";
$statustext[3] = "Envoyé";
$statustext[4] = "Non envoyé (erreur)";
}
/*
*
*
*
*/
function create($user) {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."newsletter (fk_user_author, datec, nbsent) VALUES (".$user->id.",now(), 0)";
if ($this->db->query($sql) )
{
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."newsletter");
if ( $this->update($id, $user) )
{
return $id;
}
}
}
/*
*
*
*/
function update($id, $user)
{
if (strlen(trim($this->email_replyto))==0)
{
$this->email_replyto = $this->email_from_email;
}
$this->target = 1;
$this->target_sql = $this->build_sql($this->target);
$sql = "UPDATE ".MAIN_DB_PREFIX."newsletter ";
$sql .= " SET email_subject = '" . trim($this->email_subject) ."'";
$sql .= ", email_from_name = '" . trim($this->email_from_name) ."'";
$sql .= ", email_from_email = '" . trim($this->email_from_email) ."'";
$sql .= ", email_replyto = '" . trim($this->email_replyto) ."'";
$sql .= ", email_body= '" . trim($this->email_body) ."'";
$sql .= ", target = ".$this->target;
$sql .= ", sql_target = '".$this->target_sql."'";
$sql .= " WHERE rowid = " . $id;
if ( $this->db->query($sql) ) {
return 1;
} else {
print $this->db->error() . ' in ' . $sql;
}
}
/*
*
*
*
*/
function fetch ($id) {
$sql = "SELECT rowid, email_subject, email_from_name, email_from_email, email_replyto, email_body, target, sql_target, status, date_send_request,".$this->db->pdate("date_send_begin")." as date_send_begin,".$this->db->pdate("date_send_end")." as date_send_end, nbsent, nberror";
$sql .= " FROM ".MAIN_DB_PREFIX."newsletter WHERE rowid=$id";
$result = $this->db->query($sql) ;
if ( $result )
{
$result = $this->db->fetch_array();
$this->id = $result["rowid"];
$this->email_subject = stripslashes($result["email_subject"]);
$this->email_from_name = stripslashes($result["email_from_name"]);
$this->email_from_email = stripslashes($result["email_from_email"]);
$this->email_replyto = stripslashes($result["email_replyto"]);
$this->email_body = stripslashes($result["email_body"]);
$this->status = $result["status"];
$this->nbsent = $result["nbsent"];
$this->nberror = $result["nberror"];
$this->date_send_end = $result["date_send_end"];
$this->date_send_begin = $result["date_send_begin"];
$this->status_text = $statustext[$this->status];
$this->db->free();
}
else
{
print $this->db->error();
}
return $result;
}
/*
*
*
*
*/
function liste_array ()
{
$ga = array();
$sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."editeur ORDER BY nom";
if ($this->db->query($sql) )
{
$nump = $this->db->num_rows();
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$obj = $this->db->fetch_object();
$ga[$obj->rowid] = $obj->nom;
$i++;
}
}
return $ga;
}
else
{
print $this->db->error();
}
}
/*
*
*
*
*/
function validate($user) {
$sql = "UPDATE ".MAIN_DB_PREFIX."newsletter SET status=1, fk_user_valid = $user->id WHERE rowid = $this->id";
$return = $this->db->query($sql) ;
}
/*
*
*
*/
function send($user) {
$sql = "UPDATE ".MAIN_DB_PREFIX."newsletter SET status=2, date_send_request=now() WHERE rowid = $this->id";
$return = $this->db->query($sql) ;
}
/*
*
*
*/
function build_sql($target)
{
if ($target == 1)
{
$sql = "SELECT c.customers_lastname as name, c.customers_firstname as firstname, c.customers_email_address as email";
$sql .= " FROM ".OSC_DB_NAME.".customers as c";
$sql .= " WHERE c.customers_newsletter=1";
}
return $sql;
}
/*
*
*
*/
function delete() {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."newsletter WHERE rowid = $this->id ";
$return = $this->db->query($sql) ;
}
}
?>

View File

@ -1,55 +0,0 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* 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.
*
* $Id$
* $Source$
*
*/
require("../../main.inc.php");
require("./newsletter.class.php");
function llxHeader($head = "", $urlp = "") {
global $user, $conf;
/*
*
*
*/
top_menu($head);
$menu = new Menu();
$menu->add(DOL_URL_ROOT."/boutique/client/", "Clients");
$menu->add(DOL_URL_ROOT."/boutique/commande/", "Commandes");
$menu->add(DOL_URL_ROOT."/boutique/notification/", "Notifications");
$menu->add_submenu(DOL_URL_ROOT."/boutique/notification/produits.php", "Produits");
$menu->add(DOL_URL_ROOT."/boutique/newsletter/", "Newsletter");
$menu->add_submenu(DOL_URL_ROOT."/boutique/newsletter/fiche.php?action=create", "Nouvelle newsletter");
left_menu($menu->liste);
/*
*
*
*/
}
?>

View File

@ -18,9 +18,15 @@
*
* $Id$
* $Source$
*
*/
/**
\file htdocs/boutique/promotions/fiche.php
\ingroup boutique
\brief Page gestion promotions OSCommerce
\version $Revision$
*/
require("./pre.inc.php");
llxHeader();
@ -60,9 +66,10 @@ $sql .= " WHERE s.products_id = pd.products_id AND pd.products_id = p.products_i
$sql .= " ORDER BY $sortfield $sortorder ";
$sql .= $db->plimit( $limit ,$offset);
if ( $db->query($sql) )
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows();
$num = $db->num_rows($resql);
$i = 0;
print '<table class=\"noborder width="100%">';
print "<tr class=\"liste_titre\">";
@ -107,11 +114,10 @@ if ( $db->query($sql) )
}
else
{
print $db->error();
dolibarr_print_error($db);
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
llxFooter('$Date$ - $Revision$');
?>

View File

@ -32,7 +32,8 @@ require("./promotion.class.php");
function llxHeader($head = "", $urlp = "")
{
global $user, $conf;
global $user,$conf, $langs;
$langs->load("shop");
top_menu($head);