This commit is contained in:
Laurent Destailleur
2011-09-20 22:45:39 +00:00
parent 1b3dcfa26d
commit d579c0f405
7 changed files with 578 additions and 91 deletions

View File

@@ -32,109 +32,102 @@ include_once(DOL_DOCUMENT_ROOT.'/boutique/commande/class/boutiquecommande.class.
*/
class BoutiqueCommande
{
var $db;
var $db ;
var $id;
var $nom;
var $id ;
var $nom;
function BoutiqueCommande($DB, $id=0)
{
$this->db = $DB;
$this->id = $id ;
/**
* Constructor
*
* @param DoliDB $DB Database handler
*/
function BoutiqueCommande($DB)
{
$this->db = $DB;
$this->id = $id;
$this->billing_adr = new Address();
$this->delivry_adr = new Address();
$this->billing_adr = new Address();
$this->delivry_adr = new Address();
$this->total_ot_subtotal = 0;
$this->total_ot_shipping = 0;
}
$this->total_ot_subtotal = 0;
$this->total_ot_shipping = 0;
}
/**
* \brief Get object and lines from database
* \param rowid id of object to load
* \param ref Ref of order
* \return int >0 si ok, <0 si ko
*/
function fetch ($id,$ref='')
{
global $conf;
/**
* Get object and lines from database
*
* @param int $id id of object to load
* @param string $ref Ref of order
* @return int >0 if OK, <0 if KO
*/
function fetch($id,$ref='')
{
global $conf;
$sql = "SELECT orders_id, customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, last_modified, date_purchased, orders_status, orders_date_finished, currency, currency_value";
$sql.= " FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."orders";
$sql.= " WHERE orders_id = ".$id;
$sql = "SELECT orders_id, customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, last_modified, date_purchased, orders_status, orders_date_finished, currency, currency_value";
$sql.= " FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."orders";
$sql.= " WHERE orders_id = ".$id;
$result = $this->db->query($sql);
if ( $result )
{
$array = $this->db->fetch_array($result);
$result = $this->db->query($sql);
if ( $result )
{
$array = $this->db->fetch_array($result);
$this->id = $array["orders_id"];
$this->client_id = stripslashes($array["customers_id"]);
$this->client_name = stripslashes($array["customers_name"]);
$this->id = $array["orders_id"];
$this->client_id = stripslashes($array["customers_id"]);
$this->client_name = stripslashes($array["customers_name"]);
$this->payment_method = stripslashes($array["payment_method"]);
$this->payment_method = stripslashes($array["payment_method"]);
$this->date = $this->db->jdate($array["date_purchased"]);
$this->date = $this->db->jdate($array["date_purchased"]);
$this->delivery_adr->name = stripslashes($array["delivery_name"]);
$this->delivery_adr->street = stripslashes($array["delivery_street_address"]);
$this->delivery_adr->cp = stripslashes($array["delivery_postcode"]);
$this->delivery_adr->city = stripslashes($array["delivery_city"]);
$this->delivery_adr->country = stripslashes($array["delivery_country"]);
$this->delivery_adr->name = stripslashes($array["delivery_name"]);
$this->delivery_adr->street = stripslashes($array["delivery_street_address"]);
$this->delivery_adr->cp = stripslashes($array["delivery_postcode"]);
$this->delivery_adr->city = stripslashes($array["delivery_city"]);
$this->delivery_adr->country = stripslashes($array["delivery_country"]);
$this->billing_adr->name = stripslashes($array["billing_name"]);
$this->billing_adr->street = stripslashes($array["billing_street_address"]);
$this->billing_adr->cp = stripslashes($array["billing_postcode"]);
$this->billing_adr->city = stripslashes($array["billing_city"]);
$this->billing_adr->country = stripslashes($array["billing_country"]);
$this->billing_adr->name = stripslashes($array["billing_name"]);
$this->billing_adr->street = stripslashes($array["billing_street_address"]);
$this->billing_adr->cp = stripslashes($array["billing_postcode"]);
$this->billing_adr->city = stripslashes($array["billing_city"]);
$this->billing_adr->country = stripslashes($array["billing_country"]);
$this->db->free();
$this->db->free();
/*
* Totaux
*/
$sql = "SELECT value, class ";
$sql .= " FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."orders_total WHERE orders_id = $id";
/*
* Totaux
*/
$sql = "SELECT value, class ";
$sql .= " FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."orders_total WHERE orders_id = $id";
$result = $this->db->query($sql);
if ( $result )
{
$num = $this->db->num_rows($result);
$result = $this->db->query($sql);
if ( $result )
{
$num = $this->db->num_rows($result);
while ($i < $num)
{
$array = $this->db->fetch_array($result);
if ($array["class"] == 'ot_total')
{
$this->total_ot_total = $array["value"];
}
if ($array["class"] == 'ot_shipping')
{
$this->total_ot_shipping = $array["value"];
}
$i++;
}
}
else
{
print $this->db->error();
}
while ($i < $num)
{
$array = $this->db->fetch_array($result);
if ($array["class"] == 'ot_total')
{
$this->total_ot_total = $array["value"];
}
if ($array["class"] == 'ot_shipping')
{
$this->total_ot_shipping = $array["value"];
}
$i++;
}
}
else
{
print $this->db->error();
}
}
else
{
print $this->db->error();
}
}
else
{
print $this->db->error();
}
return $result;
}
return $result;
}
}
?>

View File

@@ -0,0 +1,115 @@
<?php
/* Copyright (C) 2004-2005 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, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/class/comptacompte.class.php
* \ingroup compta
* \brief Fichier de la classe des comptes comptable
*/
/** \class ComptaCompte
* \brief Classe permettant la gestion des comptes generaux de compta
*/
class ComptaCompte
{
var $db ;
var $id ;
var $num;
var $intitule;
/**
* \brief Constructeur de la classe
* \param DB handler acces base de donnees
* \param id id compte (0 par defaut)
*/
function ComptaCompte($DB, $id=0)
{
$this->db = $DB;
$this->id = $id ;
}
/**
* \brief Insere le produit en base
* \param user utilisateur qui effectue l'insertion
*/
function create($user)
{
if (dol_strlen(trim($this->numero)) && dol_strlen(trim($this->intitule)))
{
$sql = "SELECT count(*)";
$sql .= " FROM ".MAIN_DB_PREFIX."compta_compte_generaux ";
$sql .= " WHERE numero = '" .trim($this->numero)."'";
$resql = $this->db->query($sql);
if ( $resql )
{
$row = $this->db->fetch_array($resql);
if ($row[0] == 0)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."compta_compte_generaux (date_creation, fk_user_author, numero,intitule)";
$sql .= " VALUES (".$this->db->idate(mktime()).",".$user->id.",'".$this->numero."','".$this->intitule."')";
$resql = $this->db->query($sql);
if ( $resql )
{
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."compta_compte_generaux");
if ($id > 0)
{
$this->id = $id;
$result = 0;
}
else
{
$result = -2;
dol_syslog("ComptaCompte::Create Erreur $result lecture ID");
}
}
else
{
$result = -1;
dol_syslog("ComptaCompte::Create Erreur $result INSERT Mysql");
}
}
else
{
$result = -3;
dol_syslog("ComptaCompte::Create Erreur $result SELECT Mysql");
}
}
else
{
$result = -5;
dol_syslog("ComptaCompte::Create Erreur $result SELECT Mysql");
}
}
else
{
$result = -4;
dol_syslog("ComptaCompte::Create Erreur $result Valeur Manquante");
}
return $result;
}
}
?>

View File

@@ -0,0 +1,103 @@
<?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 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, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file htdocs/compta/param/comptes/fiche.php
* \ingroup compta
* \brief Page de la fiche des comptes comptables
*/
require("../../../main.inc.php");
$mesg = '';
if ($_POST["action"] == 'add' && $user->rights->compta->ventilation->parametrer)
{
$compte = new ComptaCompte($db);
$compte->numero = $_POST["numero"];
$compte->intitule = $_POST["intitule"];
$e_compte = $compte;
$res = $compte->create($user);
if ($res == 0)
{
Header("Location: liste.php");
}
else
{
if ($res == -3)
{
$_error = 1;
$_GET["action"] = "create";
$_GET["type"] = $_POST["type"];
}
if ($res == -4)
{
$_error = 2;
$_GET["action"] = "create";
$_GET["type"] = $_POST["type"];
}
}
}
llxHeader("","Nouveau compte");
/*
* Creation d'un compte
*
*/
if ($_GET["action"] == 'create' && $user->rights->compta->ventilation->parametrer)
{
$html = new Form($db);
$nbligne=0;
print_fiche_titre($langs->trans("NewAccount"));
print '<form action="fiche.php" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="type" value="'.$_GET["type"].'">'."\n";
print '<table class="border" width="100%">';
print '<tr>';
print '<td>'.$langs->trans("AccountNumber").'</td><td><input name="numero" size="20" value="'.$compte->numero.'">';
if ($_error == 1)
{
print "Ce numéro de compte existe déjà";
}
if ($_error == 2)
{
print "Valeur(s) manquante(s)";
}
print '</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td><input name="intitule" size="40" value="'.$compte->intitule.'"></td></tr>';
print '<tr><td>&nbsp;</td><td><input type="submit" class="button" value="'.$langs->trans("Create").'"></td></tr>';
print '</table>';
print '</form>';
}
$db->close();
llxFooter();
?>

View File

@@ -0,0 +1,78 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 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, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file htdocs/compta/param/comptes/index.php
* \ingroup compta
* \brief Page acceuil zone parametrages
*/
require("../../../main.inc.php");
$langs->load("compta");
$langs->load("bills");
/*
* Securite acces client
*/
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
llxHeader("","Accueil Compta");
/*
* Affichage page
*
*/
print_fiche_titre($langs->trans("AccountancySetup"));
print '<table border="0" width="100%" class="notopnoleftnoright">';
print '<tr><td valign="top" width="30%" class="notopnoleft">';
/*
* Zone recherche facture
*/
print '<form method="post" action="facture.php">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">";
print '<td colspan="3">'.$langs->trans("SearchABill").'</td></tr>';
print "<tr $bc[0]>";
print '<td>'.$langs->trans("Ref").':</td><td><input type="text" class="flat" size="18" name="sf_ref"></td><td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
print "</table></form><br>";
print '</td><td valign="top" width="70%" class="notopnoleftnoright">';
print '</td></tr>';
print '</table>';
$db->close();
llxFooter();
?>

View File

@@ -0,0 +1,126 @@
<?PHP
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 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, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file htdocs/compta/param/comptes/liste.php
* \ingroup compta
* \brief Onglet de gestion de parametrages des ventilations
*/
require("../../../main.inc.php");
llxHeader('','Compta - Liste des comptes');
$page = $_GET["page"];
$sortorder = $_GET["sortorder"];
$sortfield = $_GET["sortfield"];
if ($sortorder == "") $sortorder="ASC";
if ($sortfield == "") $sortfield="cg.numero";
$offset = $conf->liste_limit * $page ;
/*
* Mode Liste
*
*
*
*/
$sql = "SELECT cg.rowid, cg.numero, cg.intitule, cg.date_creation as dc";
$sql .= " FROM ".MAIN_DB_PREFIX."compta_compte_generaux as cg";
if (dol_strlen(trim($_GET["search_numero"])) )
{
$sql .= " WHERE cg.numero LIKE '%".$_GET["search_numero"]."%'";
if ( dol_strlen(trim($_GET["search_intitule"])))
{
$sql .= " AND cg.intitule LIKE '%".$_GET["search_intitule"]."%'";
}
}
else
{
if ( dol_strlen(trim($_GET["search_intitule"])))
{
$sql .= " WHERE cg.intitule LIKE '%".$_GET["search_intitule"]."%'";
}
}
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
print_barre_liste("Comptes généraux", $page, "liste.php", "", $sortfield, $sortorder, '', $num);
print '<table class="liste">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("AccountNumberShort"),"liste.php","cg.numero");
print_liste_field_titre($langs->trans("Label"),"liste.php","cg.intitule");
print_liste_field_titre($langs->trans("DateCreation"),"liste.php","cg.date_creation");
print "</tr>\n";
print '<tr class="liste_titre">';
print '<form action="liste.php" method="GET">';
print '<td><input type="text" name="search_numero" value="'.$_GET["search_numero"].'"></td>';
print '<td><input type="text" name="search_intitule" value="'.$_GET["search_intitule"].'"></td>';
print '<td align="right">';
print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '</td>';
print '</form>';
print '</tr>';
$var=True;
while ($i < min($num,$conf->liste_limit))
{
$obj = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]>";
print '<td>'.$obj->numero.'</td>'."\n";
print '<td>'.$obj->intitule.'</td>';
print '<td align="right" width="100">';
print dol_print_date($db->jdate($obj->dc));
print '</td>';
print "</tr>\n";
$i++;
}
print "</table>";
$db->free($resql);
}
else
{
dol_print_error($db);
}
$db->close();
llxFooter();
?>

View File

@@ -0,0 +1,75 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 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, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/param/index.php
* \ingroup compta
* \brief Page acceuil zone parametrage comptabilite
*/
require("../../main.inc.php");
$langs->load("compta");
$langs->load("bills");
/*
* S<>curit<69> acc<63>s client
*/
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
llxHeader("",$langs->trans("AccountancySetup"));
/*
* Affichage page
*
*/
print_fiche_titre($langs->trans("AccountancySetup"));
print '<table border="0" width="100%" class="notopnoleftnoright">';
print '<tr><td valign="top" width="30%" class="notopnoleft">';
/*
* Zone recherche facture
*/
print '<form method="get" action="../facture.php">';
print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">";
print '<td colspan="3">'.$langs->trans("SearchABill").'</td></tr>';
print "<tr $bc[0]><td>";
print $langs->trans("Ref").':</td><td><input type="text" class="flat" name="search_ref"></td><td><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
print "</table></form><br>";
print '</td><td valign="top" width="70%" class="notopnoleftnoright">';
print '</td></tr>';
print '</table>';
$db->close();
llxFooter();
?>

View File

@@ -173,12 +173,9 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
/**
* Generate Header
*
* @param PDF &$pdf Pdf object
* @param int $page Current page number
* @param int $pages Total number of pages
* @param Translate $outputlangs Object language for output
* @return void
* @param pdf Pdf object
* @param page Current page number
* @param pages Total number of pages
*/
function Header(&$pdf, $page, $pages, $outputlangs)
{