Nouveaux fichiers

This commit is contained in:
Rodolphe Quiedeville 2003-11-03 08:40:18 +00:00
parent 69b842ea57
commit 9942b17e3a
6 changed files with 1435 additions and 115 deletions

View File

@ -1,6 +1,5 @@
<?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
@ -21,81 +20,134 @@
*
*/
class Commande {
class Commande
{
var $db ;
var $id ;
var $client_name ;
Function Commande($DB, $id=0) {
$this->db = $DB;
$this->id = $id ;
}
/*
*
*
*
*/
Function fetch ($id) {
$sql = "SELECT o.orders_id, o.customers_name, o.orders_status FROM ".DB_NAME_OSC.".orders as o";
$sql .= " WHERE o.orders_id = $id";
$result = $this->db->query($sql) ;
if ( $result ) {
$result = $this->db->fetch_array();
$this->id = $result["rowid"];
$this->client_name = $result["customers_name"];
$this->nom_url = '<a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$result["rowid"].'">'.$result["nom"].'</a>';
var $brouillon;
Function Commande($DB)
{
$this->db = $DB;
}
$this->db->free();
/**
* Créé la facture depuis une propale existante
*
*
*/
Function create_from_propale($user, $propale_id)
{
$this->propale_id = $propale_id;
return $this->create($user);
}
/**
* Créé la facture
*
*
*/
Function create($user)
{
/* On positionne en mode brouillon la facture */
$this->brouillon = 1;
return $result;
}
if (! $remise)
{
$remise = 0 ;
}
if (! $this->projetid)
{
$this->projetid = 0;
}
$sql = "INSERT INTO llx_commande (fk_soc, date_creation, fk_user_author,fk_projet) ";
$sql .= " VALUES ($socid, now(), $user->id, $this->projetid)";
if ( $this->db->query($sql) )
{
$this->id = $this->db->last_insert_id();
$sql = "UPDATE llx_commande SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id;
$this->db->query($sql);
if ($this->id && $this->propale_id)
{
$sql = "INSERT INTO llx_co_pr (fk_commande, fk_propale) VALUES (".$this->id.",".$this->propale_id.")";
$this->db->query($sql);
}
/*
* Produits
*
*/
for ($i = 0 ; $i < sizeof($this->products) ; $i++)
{
$prod = new Product($this->db, $this->products[$i]);
$prod->fetch($this->products[$i]);
$result_insert = $this->addline($this->id,
$prod->libelle,
$prod->price,
$this->products_qty[$i],
$prod->tva_tx,
$this->products[$i],
$this->products_remise_percent[$i]);
if ( $result_insert < 0)
{
print $sql . '<br>' . $this->db->error() .'<br>';
}
}
/*
*
*
*/
$this->updateprice($this->id);
return $this->id;
}
else
{
print $this->db->error() . '<b><br>'.$sql;
return 0;
}
}
/**
*
* Lit une commande
*
*/
Function fetch ($id)
{
$sql = "SELECT c.rowid, c.date, c.fk_user_author FROM commande as c";
$sql .= " WHERE c.rowid = $id";
$result = $this->db->query($sql) ;
if ( $result )
{
$result = $this->db->fetch_object();
$this->id = $obj->rowid;
$this->db->free();
return 1;
}
else
{
return -1;
}
}
/*
*
*
*/
Function liste_products ()
{
$ga = array();
$sql = "SELECT a.rowid, a.title FROM llx_album as a, llx_album_to_groupart as l";
$sql .= " WHERE a.rowid = l.fk_album AND l.fk_groupart = ".$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($i);
$ga[$obj->rowid] = $obj->title;
$i++;
}
}
return $ga;
}
else
{
print $this->db->error();
}
}
/*
*
*
*/
}
class CommandeLigne
{
var $pu;
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -24,20 +24,27 @@ require("./pre.inc.php");
llxHeader();
if ($sortfield == "") {
print '<table border="0" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td valign="top" width="30%">';
/*
*
*/
if ($sortfield == "")
{
$sortfield="o.orders_status ASC, o.date_purchased";
}
if ($sortorder == "") {
if ($sortorder == "")
{
$sortorder="DESC";
}
if ($page == -1) { $page = 0 ; }
$limit = $conf->liste_limit;
$offset = $limit * $page ;
$sql = "SELECT o.orders_id, o.customers_name, o.orders_status FROM ".DB_NAME_OSC.".orders as o";
$sql .= " ORDER BY $sortfield $sortorder ";
@ -50,27 +57,69 @@ if ( $db->query($sql) )
print_barre_liste("Liste des Commandes",$page,$PHP_SELF,"",$sortfield,$sortorder,'',$num);
$i = 0;
print "<p><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
print "<TR class=\"liste_titre\"><td>";
print '<p><table class="liste" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>';
print_liste_field_titre("Client",$PHP_SELF, "p.ref");
print "</td>";
print "<td></td>";
print "</TR>\n";
print "</tr>\n";
$var=True;
while ($i < min($num,$limit))
{
$objp = $db->fetch_object( $i);
$var=!$var;
print "<TR $bc[$var]>";
print "<TD><a href=\"fiche.php?id=$objp->orders_id\">$objp->customers_name</a></TD>\n";
print "<TD>$objp->orders_status</TD>\n";
print "</TR>\n";
$i++;
}
$var=!$var;
print "<tr $bc[$var]>";
print "<td><a href=\"fiche.php?id=$objp->orders_id\">$objp->customers_name</a></TD>\n";
print "<td>$objp->orders_status</TD>\n";
print "</tr>\n";
$i++;
}
print "</TABLE>";
$db->free();
}
/*
*
*/
print '</td><td valign="top" width="70%">';
/*
* Propales à facturer
*/
if ($user->comm > 0 && $conf->commercial )
{
$sql = "SELECT p.rowid, p.ref, s.nom, s.idp FROM llx_propal as p, llx_societe as s";
$sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut = 2";
if ($socidp)
{
$sql .= " AND p.fk_soc = $socidp";
}
if ( $db->query($sql) )
{
$num = $db->num_rows();
if ($num)
{
$i = 0;
print '<table border="0" cellspacing="0" cellpadding="3" width="100%">';
print "<tr class=\"liste_titre\">";
print '<td colspan="2">'.translate("Propositions commerciales signées").'</td></tr>';
while ($i < $num)
{
$var=!$var;
$obj = $db->fetch_object($i);
print "<tr $bc[$var]><td width=\"20%\"><a href=\"propal.php?propalid=$obj->rowid\">$obj->ref</a></td>";
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.$obj->nom.'</a></td></tr>';
$i++;
}
print "</table><br>";
}
}
}
print '</td></tr></table>';
$db->close();

View File

@ -0,0 +1,99 @@
<?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 OscCommande {
var $db ;
var $id ;
var $client_name ;
Function OscCommande($DB, $id=0) {
$this->db = $DB;
$this->id = $id ;
}
/*
*
*
*
*/
Function fetch ($id)
{
$sql = "SELECT o.orders_id, o.customers_name, o.orders_status FROM ".DB_NAME_OSC.".orders as o";
$sql .= " WHERE o.orders_id = $id";
$result = $this->db->query($sql) ;
if ( $result )
{
$result = $this->db->fetch_array();
$this->id = $result["rowid"];
$this->client_name = $result["customers_name"];
$this->nom_url = '<a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$result["rowid"].'">'.$result["nom"].'</a>';
}
$this->db->free();
return $result;
}
/*
*
*
*/
Function liste_products ()
{
$ga = array();
$sql = "SELECT a.rowid, a.title FROM llx_album as a, llx_album_to_groupart as l";
$sql .= " WHERE a.rowid = l.fk_album AND l.fk_groupart = ".$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($i);
$ga[$obj->rowid] = $obj->title;
$i++;
}
}
return $ga;
}
else
{
print $this->db->error();
}
}
/*
*
*
*/
}
?>

View File

@ -0,0 +1,27 @@
-- ===================================================================
-- 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$
-- ===================================================================
create table llx_co_pr
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_commande integer,
fk_propale integer
);

View File

@ -0,0 +1,49 @@
-- ===================================================================
-- 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$
--
-- ===================================================================
create table llx_commande
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
fk_soc integer,
fk_soc_contact integer,
fk_projet integer default 0, -- projet auquel est rattache la commande
ref varchar(30) NOT NULL, -- propal number
date_creation datetime, -- date de creation
date_valid datetime, -- date de validation
date_cloture datetime, -- date de cloture
date_commande date, -- date de la commande
fk_user_author integer, -- createur de la commande
fk_user_valid integer, -- valideur de la commande
fk_user_cloture integer, -- cloture de la propale signee ou non signee
source smallint NOT NULL,
fk_statut smallint default 0,
amount_ht real default 0,
remise_percent real default 0,
remise real default 0,
tva real default 0,
total_ht real default 0,
total_ttc real default 0,
note text,
model_pdf varchar(50),
UNIQUE INDEX (ref)
);